2023-11-28 15:10:33 +00:00
|
|
|
import { CliffyPrompt, Colors } from "../deps.ts";
|
2020-10-14 20:04:18 +00:00
|
|
|
import { version } from "../version.ts";
|
2020-08-16 17:28:27 +00:00
|
|
|
|
|
|
|
export default async function upgrade() {
|
2020-10-14 20:04:18 +00:00
|
|
|
const meta = await fetch(
|
|
|
|
"https://deno.hibas123.de/raw/@denreg-cli/meta.json"
|
|
|
|
).then((e) => e.json());
|
|
|
|
|
|
|
|
if (meta.version === version) {
|
2023-11-28 15:10:33 +00:00
|
|
|
const res = await CliffyPrompt.Confirm.prompt({
|
2020-10-14 20:04:18 +00:00
|
|
|
message: Colors.yellow("No update available!") + " Continue?",
|
|
|
|
default: false,
|
|
|
|
});
|
|
|
|
if (!res) return;
|
|
|
|
}
|
|
|
|
|
2023-11-28 15:10:33 +00:00
|
|
|
const res = await CliffyPrompt.Confirm.prompt({
|
2020-10-14 20:04:18 +00:00
|
|
|
message: "Are you sure you want to upgrade?",
|
2020-08-16 17:28:27 +00:00
|
|
|
default: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (res) {
|
|
|
|
const process = Deno.run({
|
|
|
|
cmd: [
|
|
|
|
"deno",
|
|
|
|
"install",
|
|
|
|
"-A",
|
|
|
|
"--unstable",
|
|
|
|
"-f",
|
2020-10-14 20:04:18 +00:00
|
|
|
`https://deno.hibas123.de/raw/@denreg-cli@${meta.version}/denreg.ts`,
|
2020-08-16 17:28:27 +00:00
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
const s = await process.status();
|
|
|
|
if (!s) {
|
|
|
|
console.log(Colors.red("Upgrade failed!"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|