-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathversion-bump.mjs
More file actions
39 lines (34 loc) · 1.36 KB
/
Copy pathversion-bump.mjs
File metadata and controls
39 lines (34 loc) · 1.36 KB
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
import { readFileSync, writeFileSync } from 'fs';
const targetVersion = process.env.npm_package_version;
// read minAppVersion from manifest.json and bump version to target version
let manifest = JSON.parse(readFileSync('manifest.json', 'utf8'));
const { minAppVersion } = manifest;
manifest.version = targetVersion;
writeFileSync('manifest.json', JSON.stringify(manifest, null, '\t'));
// update versions.json with target version and minAppVersion from manifest.json
let versions = JSON.parse(readFileSync('versions.json', 'utf8'));
versions[targetVersion] = minAppVersion;
writeFileSync('versions.json', JSON.stringify(versions, null, '\t'));
// update package.json with target version
let packageJson = JSON.parse(readFileSync('package.json', 'utf8'));
packageJson.version = targetVersion;
writeFileSync('package.json', JSON.stringify(packageJson, null, '\t'));
// update CHANGELOG.md with header for target version
// turns:
//
// ## [Unreleased]
//
// Into:
//
// ## [Unreleased]
//
// ## [targetVersion] - YYYY-MM-DD
let changelog = readFileSync('CHANGELOG.md', 'utf8');
const today = new Date().toISOString().split('T')[0];
const unreleasedHeader = '## [Unreleased]';
const newVersionHeader = `## [${targetVersion}] - ${today}`;
changelog = changelog.replace(
unreleasedHeader,
`${unreleasedHeader}\n\n${newVersionHeader}`,
);
writeFileSync('CHANGELOG.md', changelog);