1 | "use strict"; |
||
2 | |||
3 | const fs = require ('fs') |
||
4 | const ccxt = require ('./ccxt') |
||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
5 | const countries = require ('./countries') |
||
0 ignored issues
–
show
|
|||
6 | const asTable = require ('as-table') |
||
0 ignored issues
–
show
|
|||
7 | const util = require ('util') |
||
0 ignored issues
–
show
|
|||
8 | const log = require ('ololog') |
||
9 | const ansi = require ('ansicolor').nice |
||
0 ignored issues
–
show
|
|||
10 | |||
11 | //----------------------------------------------------------------------------- |
||
12 | |||
13 | let packageJSON = fs.readFileSync ('./package.json', 'utf8') |
||
14 | let config = JSON.parse (packageJSON); |
||
15 | let version = config.version |
||
16 | |||
17 | //----------------------------------------------------------------------------- |
||
18 | |||
19 | log.bright ('Old version: '.dim, version) |
||
20 | let [ major, minor, patch ] = version.split ('.') |
||
21 | |||
22 | // we don't increment it here anymore, because |
||
23 | // npm version patch will be explicitly called before |
||
24 | |||
25 | // patch = (parseInt (patch) + 1).toString () |
||
26 | |||
27 | version = [ major, minor, patch ].join ('.') |
||
28 | log.bright ('New version: '.cyan, version) |
||
29 | |||
30 | //----------------------------------------------------------------------------- |
||
31 | |||
32 | log.bright.cyan ('Single-sourcing version', version, './package.json → ./ccxt.js'.yellow) |
||
33 | let ccxtjsFilename = './ccxt.js' |
||
34 | let ccxtjs = fs.readFileSync (ccxtjsFilename, 'utf8') |
||
35 | let ccxtjsParts = ccxtjs.split (/const version \= \'[^\']+\'/) |
||
36 | let ccxtjsNewContent = ccxtjsParts[0] + "const version = '" + version + "'" + ccxtjsParts[1] |
||
37 | fs.truncateSync (ccxtjsFilename) |
||
38 | fs.writeFileSync (ccxtjsFilename, ccxtjsNewContent) |
||
39 | |||
40 | //----------------------------------------------------------------------------- |
||
41 | |||
42 | log.bright.cyan ('Single-sourcing version', version, './package.json → ./ccxt/version.py'.yellow) |
||
43 | let ccxtpyFilename = './ccxt/version.py' |
||
44 | let ccxtpy = fs.readFileSync (ccxtpyFilename, 'utf8') |
||
45 | let ccxtpyParts = ccxtpy.split (/\_\_version\_\_ \= \'[^\']+\'/) |
||
46 | let ccxtpyNewContent = ccxtpyParts[0] + "__version__ = '" + version + "'" + ccxtpyParts[1] |
||
47 | fs.truncateSync (ccxtpyFilename) |
||
48 | fs.writeFileSync (ccxtpyFilename, ccxtpyNewContent) |
||
49 | |||
50 | //----------------------------------------------------------------------------- |
||
51 | |||
52 | log.bright.cyan ('Single-sourcing version', version, './package.json → ./ccxt.php'.yellow) |
||
53 | let ccxtphpFilename = './ccxt.php' |
||
54 | let ccxtphp = fs.readFileSync (ccxtphpFilename, 'utf8') |
||
55 | let ccxtphpParts = ccxtphp.split (/\$version \= \'[^\']+\'/) |
||
56 | let ccxtphpNewContent = ccxtphpParts[0] + '$version' + " = '" + version + "'" + ccxtphpParts[1] |
||
57 | fs.truncateSync (ccxtphpFilename) |
||
58 | fs.writeFileSync (ccxtphpFilename, ccxtphpNewContent) |
||
59 | |||
60 | //----------------------------------------------------------------------------- |
||
61 | |||
62 | log.bright.green ('Version single-sourced successfully.') |