-
Notifications
You must be signed in to change notification settings - Fork 0
/
vss.js
62 lines (46 loc) · 2.52 KB
/
vss.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
"use strict";
const fs = require ('fs')
const ccxt = require ('./ccxt')
const countries = require ('./countries')
const asTable = require ('as-table')
const util = require ('util')
const log = require ('ololog')
const ansi = require ('ansicolor').nice
//-----------------------------------------------------------------------------
let packageJSON = fs.readFileSync ('./package.json', 'utf8')
let config = JSON.parse (packageJSON);
let version = config.version
//-----------------------------------------------------------------------------
log.bright ('Old version: '.dim, version)
let [ major, minor, patch ] = version.split ('.')
// we don't increment it here anymore, because
// npm version patch will be explicitly called before
// patch = (parseInt (patch) + 1).toString ()
version = [ major, minor, patch ].join ('.')
log.bright ('New version: '.cyan, version)
//-----------------------------------------------------------------------------
log.bright.cyan ('Single-sourcing version', version, './package.json → ./ccxt.js'.yellow)
let ccxtjsFilename = './ccxt.js'
let ccxtjs = fs.readFileSync (ccxtjsFilename, 'utf8')
let ccxtjsParts = ccxtjs.split (/const version \= \'[^\']+\'/)
let ccxtjsNewContent = ccxtjsParts[0] + "const version = '" + version + "'" + ccxtjsParts[1]
fs.truncateSync (ccxtjsFilename)
fs.writeFileSync (ccxtjsFilename, ccxtjsNewContent)
//-----------------------------------------------------------------------------
log.bright.cyan ('Single-sourcing version', version, './package.json → ./ccxt/version.py'.yellow)
let ccxtpyFilename = './ccxt/version.py'
let ccxtpy = fs.readFileSync (ccxtpyFilename, 'utf8')
let ccxtpyParts = ccxtpy.split (/\_\_version\_\_ \= \'[^\']+\'/)
let ccxtpyNewContent = ccxtpyParts[0] + "__version__ = '" + version + "'" + ccxtpyParts[1]
fs.truncateSync (ccxtpyFilename)
fs.writeFileSync (ccxtpyFilename, ccxtpyNewContent)
//-----------------------------------------------------------------------------
log.bright.cyan ('Single-sourcing version', version, './package.json → ./ccxt.php'.yellow)
let ccxtphpFilename = './ccxt.php'
let ccxtphp = fs.readFileSync (ccxtphpFilename, 'utf8')
let ccxtphpParts = ccxtphp.split (/\$version \= \'[^\']+\'/)
let ccxtphpNewContent = ccxtphpParts[0] + '$version' + " = '" + version + "'" + ccxtphpParts[1]
fs.truncateSync (ccxtphpFilename)
fs.writeFileSync (ccxtphpFilename, ccxtphpNewContent)
//-----------------------------------------------------------------------------
log.bright.green ('Version single-sourced successfully.')