-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetver.js
44 lines (37 loc) · 1.8 KB
/
setver.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
import fs from 'fs'
import { logStep, logDone } from './common.js'
const ver = process.argv[2]
if (!ver) {
logDone(`No version provided, exit.`)
}
logStep('Setting version to ' + ver)
// update version in package.json
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'))
packageJson.version = ver
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 4))
logDone('Updated package.json')
// update version in src/config.h
let configContent = fs.readFileSync('src/config.h', 'utf8')
configContent = configContent.replace(/#define VERSION ".*"/, `#define VERSION "${ver}"`)
fs.writeFileSync('src/config.h', configContent)
logDone('Updated src/config.h')
// update version in pypi/camel-lang/pyproject.toml
let pyprojectContent = fs.readFileSync('pypi/camel-lang/pyproject.toml', 'utf8')
pyprojectContent = pyprojectContent.replace(/version = ".*"/, `version = "${ver}"`)
fs.writeFileSync('pypi/camel-lang/pyproject.toml', pyprojectContent)
logDone('Updated pypi/camel-lang/pyproject.toml')
// update version in pypi/camel-lang/src/camel/__init__.py
let initContent = fs.readFileSync('pypi/camel-lang/src/camel/__init__.py', 'utf8')
initContent = initContent.replace(/__version__ = '.*'/, `__version__ = '${ver}'`)
fs.writeFileSync('pypi/camel-lang/src/camel/__init__.py', initContent)
logDone('Updated pypi/camel-lang/src/camel/__init__.py')
// check if changes.log exists and starts with the version like "[ver]"
const changesLog = fs.readFileSync('changes.log', 'utf8')
const changesLogLines = changesLog.split('\n')
const firstLine = changesLogLines[0]
if (!firstLine.startsWith(`[${ver}]`)) {
logStep('changes.log does not start with the version, adding it')
fs.writeFileSync('changes.log', `[${ver}]\n\n${changesLog}`)
}
logDone('Updated changes.log')
logDone('All processes completed.')