forked from ccxt/ccxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
postinstall.js
86 lines (72 loc) · 3.31 KB
/
postinstall.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const fetch = require ('./js/static_dependencies/fetch-ponyfill/fetch-node') ().fetch
function style(s, style) {
return style + s + '\033[0m'
}
const colors = {
black: 30,
red: 31,
green: 32,
yellow: 33,
blue: 34,
white: 37,
gray: 90,
}
let colorFunctions = {}
for (let color of Object.keys (colors)) {
colorFunctions[color] = (s) => console.log (style (s, '\033[' + colors[color].toString () + 'm'))
}
let ascii = [
' ',
' :Siiiiiiiiiiir rSiiiiiiiiiiS:',
' r&9hh&&&&&&&A5 SG99h&&&&&&GHr',
' ;hX32;::::::;, i9X9S:;:::::;,',
' ;hX9S ihXhr ',
' ;hX32::::::,:, i9X9i::::::,:.',
' rG999GGGGGGGAS iG99hGGGGGGGAr',
' ;2S55SSSSSSS2r r2555SSSSSSS2;',
' ',
' ',
' ;2S5s ;2S2r r2SS555555SS2;',
' rAh&2 sAhAS SAGGh9999GGGAr',
' .:,::rrrs::::, ,:,,;9X3X:,,:.',
' &A&H, ,hX33 ',
' ,;:;;;;;r;;:;, ,hX3X. ',
' rHGAX sAGA5 :&9h9. ',
' :Ssir ;isir ,Siii ',
' ',
]
async function getData () {
const [collectiveData_result, githubData_result] = await Promise.all ([fetch ('https://opencollective.com/ccxt.json'), fetch ('https://api.github.com/repos/ccxt/ccxt')])
const collectiveData = await collectiveData_result.json()
const githubData = await githubData_result.json()
return {
contributors: collectiveData['contributorsCount'].toLocaleString (),
backers: collectiveData['backersCount'].toLocaleString (),
balance: Math.floor (collectiveData['balance'] / 100).toLocaleString (),
budget: Math.floor (collectiveData['yearlyIncome'] / 100).toLocaleString (),
stars: githubData['stargazers_count'].toLocaleString (),
forks: githubData['forks_count'].toLocaleString (),
size: (githubData['size'] / 1000000).toFixed (2)
}
}
function pad (string) {
const padding = 80 - string.length
const half = Math.floor (padding / 2)
return ' '.repeat (half + (padding % 2)) + string + ' '.repeat (half)
}
async function main () {
try {
const data = await getData()
colorFunctions['blue'] (ascii.join ('\n'))
colorFunctions['red'] (pad (`Stars: ${data.stars}`))
colorFunctions['red'] (pad (`Forks: ${data.forks}`))
colorFunctions['red'] (pad (`Size: ${data.size}MB`))
colorFunctions['yellow'] ('\n' + pad ('Thanks for installing ccxt 🙏'))
colorFunctions['gray'] (pad ('Please consider donating to our open collective'))
colorFunctions['gray'] (pad ('to help us maintain this package.'))
colorFunctions['yellow'] (pad ('👉 Donate: https://opencollective.com/ccxt/donate 🎉'))
} catch (e) {
// console.log (e.constructor.name, e.message)
}
}
main()