Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 6069b8b

Browse files
author
Je
committed
v0.2.0
1 parent db301ee commit 6069b8b

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

bump.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { version } from './version.ts';
2+
3+
const p = version.split('.').map(s => parseInt(s))
4+
const versions = [
5+
`${p[0]}.${p[1]}.${p[2] + 1}`,
6+
`${p[0]}.${p[1] + 1}.0`,
7+
`${p[0] + 1}.0.0`,
8+
]
9+
10+
async function ask(question: string = '', stdin = Deno.stdin, stdout = Deno.stdout) {
11+
const buf = new Uint8Array(1024)
12+
await stdout.write(new TextEncoder().encode(question))
13+
const n = <number>await stdin.read(buf)
14+
const answer = new TextDecoder().decode(buf.subarray(0, n))
15+
return answer.trim()
16+
}
17+
18+
async function run(...cmd: string[]) {
19+
const p = Deno.run({
20+
cmd,
21+
stdout: 'piped',
22+
stderr: 'piped'
23+
})
24+
Deno.stdout.write(await p.output())
25+
Deno.stderr.write(await p.stderrOutput())
26+
p.close()
27+
}
28+
29+
async function main() {
30+
const answer = await ask([...versions.map((v, i) => `${i + 1}. v${v}`), 'upgrade to: '].join('\n'))
31+
const v = parseInt(answer)
32+
if (!isNaN(v) && v > 0 && v <= 3) {
33+
const up = versions[v - 1]
34+
if (await ask('are you sure? (y/n) ') === 'y') {
35+
await Deno.writeTextFile('./version.ts', `export const version = '${up}'\n`)
36+
await run('git', 'add', '.', '--all')
37+
await run('git', 'commit', '-m', `v${up}`)
38+
await run('git', 'tag', `v${up}`)
39+
}
40+
}
41+
}
42+
43+
if (import.meta.main) {
44+
main()
45+
}

version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const version = '0.1.9'
1+
export const version = '0.2.0'

0 commit comments

Comments
 (0)