Skip to content

Commit 6280128

Browse files
committed
Add confirmation prompt to browser and editor bump scripts before applying and committing version changes
- before bumping, ask for confirmation
1 parent f4a6326 commit 6280128

2 files changed

Lines changed: 52 additions & 24 deletions

File tree

‎apps/browser/scripts/bump.js‎

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fs = require('fs')
22
const path = require('path')
33
const { execSync } = require('child_process')
4+
const readline = require('readline')
45

56
const manifest_path = path.resolve(__dirname, '../src/manifest.json')
67
const manifest = JSON.parse(fs.readFileSync(manifest_path, 'utf-8'))
@@ -15,17 +16,30 @@ const version_parts = manifest.version.split('.')
1516
const last_segment = parseInt(version_parts.pop(), 10) || 0
1617

1718
const next_segment = last_segment + 1
18-
manifest.version = `${date_prefix}.${next_segment}`
19+
const next_version = `${date_prefix}.${next_segment}`
1920

20-
fs.writeFileSync(manifest_path, JSON.stringify(manifest, null, 2) + '\n')
21-
console.log(`Bump version of the browser extension to ${manifest.version}`)
21+
const rl = readline.createInterface({
22+
input: process.stdin,
23+
output: process.stdout
24+
})
2225

23-
try {
24-
execSync(`git add "${manifest_path}"`, { stdio: 'ignore' })
25-
execSync(`git commit --no-verify -m "Bump version to ${manifest.version}"`, {
26-
stdio: 'ignore'
27-
})
28-
console.log('Successfully committed the version bump.')
29-
} catch (error) {
30-
console.error('Failed to commit version bump:', error.message)
31-
}
26+
rl.question(`Bump version of the browser extension to ${next_version}? (y/N) `, (answer) => {
27+
if (answer.toLowerCase() === 'y') {
28+
manifest.version = next_version
29+
fs.writeFileSync(manifest_path, JSON.stringify(manifest, null, 2) + '\n')
30+
console.log(`Bumped version of the browser extension to ${manifest.version}`)
31+
32+
try {
33+
execSync(`git add "${manifest_path}"`, { stdio: 'ignore' })
34+
execSync(`git commit --no-verify -m "Bump version to ${manifest.version}"`, {
35+
stdio: 'ignore'
36+
})
37+
console.log('Successfully committed the version bump.')
38+
} catch (error) {
39+
console.error('Failed to commit version bump:', error.message)
40+
}
41+
} else {
42+
console.log('Version bump aborted.')
43+
}
44+
rl.close()
45+
})

‎apps/editor/scripts/bump.js‎

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const fs = require('fs')
22
const path = require('path')
33
const { execSync } = require('child_process')
4+
const readline = require('readline')
45

56
const pkg_path = path.resolve(__dirname, '../package.json')
67
const pkg = JSON.parse(fs.readFileSync(pkg_path, 'utf-8'))
@@ -15,17 +16,30 @@ const version_parts = pkg.version.split('.')
1516
const last_segment = parseInt(version_parts.pop(), 10) || 0
1617

1718
const next_segment = last_segment + 1
18-
pkg.version = `${date_prefix}.${next_segment}`
19+
const next_version = `${date_prefix}.${next_segment}`
1920

20-
fs.writeFileSync(pkg_path, JSON.stringify(pkg, null, 2) + '\n')
21-
console.log(`Bump version of the VS Code extension to ${pkg.version}`)
21+
const rl = readline.createInterface({
22+
input: process.stdin,
23+
output: process.stdout
24+
})
2225

23-
try {
24-
execSync(`git add "${pkg_path}"`, { stdio: 'ignore' })
25-
execSync(`git commit --no-verify -m "Bump version to ${pkg.version}"`, {
26-
stdio: 'ignore'
27-
})
28-
console.log('Successfully committed the version bump.')
29-
} catch (error) {
30-
console.error('Failed to commit version bump:', error.message)
31-
}
26+
rl.question(`Bump version of the VS Code extension to ${next_version}? (y/N) `, (answer) => {
27+
if (answer.toLowerCase() === 'y') {
28+
pkg.version = next_version
29+
fs.writeFileSync(pkg_path, JSON.stringify(pkg, null, 2) + '\n')
30+
console.log(`Bumped version of the VS Code extension to ${pkg.version}`)
31+
32+
try {
33+
execSync(`git add "${pkg_path}"`, { stdio: 'ignore' })
34+
execSync(`git commit --no-verify -m "Bump version to ${pkg.version}"`, {
35+
stdio: 'ignore'
36+
})
37+
console.log('Successfully committed the version bump.')
38+
} catch (error) {
39+
console.error('Failed to commit version bump:', error.message)
40+
}
41+
} else {
42+
console.log('Version bump aborted.')
43+
}
44+
rl.close()
45+
})

0 commit comments

Comments
 (0)