-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Je
committed
Oct 14, 2020
1 parent
db301ee
commit 6069b8b
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { version } from './version.ts'; | ||
|
||
const p = version.split('.').map(s => parseInt(s)) | ||
const versions = [ | ||
`${p[0]}.${p[1]}.${p[2] + 1}`, | ||
`${p[0]}.${p[1] + 1}.0`, | ||
`${p[0] + 1}.0.0`, | ||
] | ||
|
||
async function ask(question: string = '', stdin = Deno.stdin, stdout = Deno.stdout) { | ||
const buf = new Uint8Array(1024) | ||
await stdout.write(new TextEncoder().encode(question)) | ||
const n = <number>await stdin.read(buf) | ||
const answer = new TextDecoder().decode(buf.subarray(0, n)) | ||
return answer.trim() | ||
} | ||
|
||
async function run(...cmd: string[]) { | ||
const p = Deno.run({ | ||
cmd, | ||
stdout: 'piped', | ||
stderr: 'piped' | ||
}) | ||
Deno.stdout.write(await p.output()) | ||
Deno.stderr.write(await p.stderrOutput()) | ||
p.close() | ||
} | ||
|
||
async function main() { | ||
const answer = await ask([...versions.map((v, i) => `${i + 1}. v${v}`), 'upgrade to: '].join('\n')) | ||
const v = parseInt(answer) | ||
if (!isNaN(v) && v > 0 && v <= 3) { | ||
const up = versions[v - 1] | ||
if (await ask('are you sure? (y/n) ') === 'y') { | ||
await Deno.writeTextFile('./version.ts', `export const version = '${up}'\n`) | ||
await run('git', 'add', '.', '--all') | ||
await run('git', 'commit', '-m', `v${up}`) | ||
await run('git', 'tag', `v${up}`) | ||
} | ||
} | ||
} | ||
|
||
if (import.meta.main) { | ||
main() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const version = '0.1.9' | ||
export const version = '0.2.0' |