Skip to content

Commit ecf71da

Browse files
committed
feat(version): Add version script.
1 parent 52fa30a commit ecf71da

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

bump.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { readFileSync, writeFileSync } from 'fs'
2+
3+
const targetVersion = process.env.npm_package_version
4+
if (!targetVersion) process.exit(1);
5+
console.log(`Bumping version to ${targetVersion}`)
6+
7+
// read minAppVersion from manifest.json and bump version to target version
8+
const manifest = JSON.parse(readFileSync('manifest.json', 'utf8'))
9+
const { minAppVersion } = manifest
10+
manifest.version = targetVersion
11+
writeFileSync('manifest.json', JSON.stringify(manifest, null, '\t'))
12+
13+
// update versions.json with target version and minAppVersion from manifest.json
14+
const versions = JSON.parse(readFileSync('versions.json', 'utf8'))
15+
versions[targetVersion] = minAppVersion
16+
writeFileSync('versions.json', JSON.stringify(versions, null, '\t'))

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"dev": "node esbuild.config.mjs",
77
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
88
"format": "npx prettier --write .",
9+
"version": "node bump.mjs",
910
"clean": "npx rimraf main.js",
1011
"test": "cross-env TS_NODE_COMPILER_OPTIONS={\\\"module\\\":\\\"commonjs\\\"} mocha -r ts-node/register 'tests/**/*.ts'"
1112
},

0 commit comments

Comments
 (0)