-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-version.mjs
executable file
·36 lines (30 loc) · 1.31 KB
/
update-version.mjs
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
#!/usr/bin/env node
import { readFileSync, writeFileSync } from 'fs';
import process from 'process';
const replaceInTextFile = (filename, textPresent, newText) => {
const contents = readFileSync(filename, 'utf-8');
const replaced = contents.replace(textPresent, newText);
writeFileSync(filename, replaced);
};
const replaceVersionInPackageJson = (newVersion) => {
replaceInTextFile('./package.json', /"version": ".*"/g, `"version": "${newVersion}"`);
};
const replaceVersionInConfig = (newVersion) => {
replaceInTextFile('./src/config/about.ts', /const version = '.*'/g, `const version = '${newVersion}'`);
};
const replaceVersionInProjectPackageJson = (projectName, newVersion) => {
replaceInTextFile(
`./project-types/${projectName}/package-definition.json`,
/"@gobstones\/gobstones-scripts": ".*"/g,
`"@gobstones/gobstones-scripts": "^${newVersion}"`
);
};
const updateToVersion = (newVersion) => {
replaceVersionInPackageJson(newVersion);
replaceVersionInConfig(newVersion);
replaceVersionInProjectPackageJson('Library', newVersion);
replaceVersionInProjectPackageJson('CLILibrary', newVersion);
replaceVersionInProjectPackageJson('ReactLibrary', newVersion);
replaceVersionInProjectPackageJson('NonCode', newVersion);
};
updateToVersion(process.argv[2]);