Skip to content

Commit f75392c

Browse files
committed
Add version bump script and npm command
- add similar bump script to browser, but it should bump in manifest └── apps ├── browser │ ├── package.json │ ├── scripts │ │ └── bump.js │ └── src │ └── manifest.json └── editor ├── package.json └── scripts └── bump.js
1 parent 3f42147 commit f75392c

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎apps/browser/package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"scripts": {
44
"build": "webpack --mode production && ts-node create-firefox-build.ts && ts-node create-zip-archives.ts",
55
"lint": "eslint src --ext ts,tsx",
6-
"lint:fix": "eslint src --ext ts,tsx --fix"
6+
"lint:fix": "eslint src --ext ts,tsx --fix",
7+
"bump": "node scripts/bump.js"
78
},
89
"devDependencies": {
910
"@pmmmwh/react-refresh-webpack-plugin": "0.6.1",

‎apps/browser/scripts/bump.js‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
const { execSync } = require('child_process')
4+
5+
const manifest_path = path.resolve(__dirname, '../src/manifest.json')
6+
const manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8'))
7+
8+
const date = new Date()
9+
const year = date.getFullYear()
10+
const month = String(date.getMonth() + 1).padStart(2, '0')
11+
const day = String(date.getDate()).padStart(2, '0')
12+
const date_prefix = `${year}.${month}${day}`
13+
14+
const version_parts = manifest.version.split('.')
15+
const last_segment = parseInt(version_parts.pop(), 10) || 0
16+
17+
const next_segment = last_segment + 1
18+
manifest.version = `${date_prefix}.${next_segment}`
19+
20+
fs.writeFileSync(manifest_path, JSON.stringify(manifest, null, 2) + '\n')
21+
console.log(`Bumped version to ${manifest.version}`)
22+
23+
try {
24+
execSync(`git add "${manifest_path}"`, { stdio: 'ignore' })
25+
execSync(`git commit --no-verify -m "Bump version to ${manifest.version}"`, { stdio: 'ignore' })
26+
console.log('Successfully committed the version bump.')
27+
} catch (error) {
28+
console.error('Failed to commit version bump:', error.message)
29+
}

0 commit comments

Comments
 (0)