1 | require('source-map-support').install()
|
2 | const path = require('path')
|
3 | const fse = require('fs-extra')
|
4 | import './error'
|
5 | import './framework/base'
|
6 |
|
7 |
|
8 |
|
9 | let package_json_file_path = path.join(__dirname, './package.json')
|
10 | let package_lock_json_file_path = path.join(__dirname, './package-lock.json')
|
11 |
|
12 |
|
13 | xassert(fse.existsSync(package_json_file_path))
|
14 | xassert(fse.existsSync(package_lock_json_file_path))
|
15 |
|
16 | function upgrade_patch_version(file_path: string): string {
|
17 | let cfg = fse.readJsonSync(file_path)
|
18 | xassert(cfg && cfg.version && /(\d+)\.(\d+)\.(\d+)/.test(cfg.version))
|
19 | let list: any = /(\d+)\.(\d+)\.(\d+)/.exec(cfg.version)
|
20 | cfg.version = `${list[1]}.${list[2]}.${parseInt(list[3]) + 1}`
|
21 | fse.writeJSONSync(file_path, cfg, {spaces: 2})
|
22 | return cfg.version
|
23 | }
|
24 |
|
25 |
|
26 | const v1 = upgrade_patch_version(package_json_file_path)
|
27 | const v2 = upgrade_patch_version(package_lock_json_file_path)
|
28 | xassert(v1 === v2)
|
29 |
|
30 | fse.writeFileSync(path.join(__dirname, './__version__'), v1 + '\r\n')
|