-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathbump-version.ts
More file actions
28 lines (21 loc) · 1019 Bytes
/
Copy pathbump-version.ts
File metadata and controls
28 lines (21 loc) · 1019 Bytes
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
import { execSync } from 'child_process';
import * as path from 'path';
const cliArgs = process.argv;
if (cliArgs.length < 4) {
console.log('Usage: npm run bump:<lua-types|panorama-types> <major|minor|patch>');
process.exit(1);
}
const packageDirectory = cliArgs[2];
const packageName = path.basename(packageDirectory);
const bumpType = cliArgs[3];
if (bumpType !== 'major' && bumpType !== 'minor' && bumpType !== 'patch') {
console.log(`'${bumpType}' should be one of: major, minor or patch`);
process.exit(1);
}
execSync(`npm version ${bumpType} --git-tag-version false`, { cwd: packageDirectory });
const packageVersion = require(path.resolve(path.join(packageDirectory, 'package.json'))).version;
execSync(`git add ${path.join(packageDirectory, 'package.json')}`);
execSync(`git add package-lock.json`);
execSync(`git commit -m "${packageName} ${packageVersion}"`);
execSync(`git tag ${packageName}@${packageVersion}`);
console.log(`Successfully bumped ${packageName} to version ${packageVersion}`);