Skip to content

Commit 3f42147

Browse files
committed
Add version bump script for editor app
- rename bump version to bump - remove all this [logging]... [Image]
1 parent 21f5b68 commit 3f42147

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

‎apps/editor/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 pkg_path = path.resolve(__dirname, '../package.json')
6+
const pkg = JSON.parse(fs.readFileSync(pkg_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 = pkg.version.split('.')
15+
const last_segment = parseInt(version_parts.pop(), 10) || 0
16+
17+
const next_segment = last_segment + 1
18+
pkg.version = `${date_prefix}.${next_segment}`
19+
20+
fs.writeFileSync(pkg_path, JSON.stringify(pkg, null, 2) + '\n')
21+
console.log(`Bumped version to ${pkg.version}`)
22+
23+
try {
24+
execSync(`git add "${pkg_path}"`, { stdio: 'ignore' })
25+
execSync(`git commit --no-verify -m "Bump version to ${pkg.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)