From c78f6822e1d5fee32ef06f7b0df11128699ae572 Mon Sep 17 00:00:00 2001 From: Fabian Stamm Date: Sun, 16 Aug 2020 19:28:27 +0200 Subject: [PATCH] Add upgrade command --- cli/README.md | 2 ++ cli/commands/deprecate.ts | 2 +- cli/commands/upgrade.ts | 26 ++++++++++++++++++++++++++ cli/denreg.ts | 7 +++++++ cli/meta.json | 2 +- 5 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 cli/commands/upgrade.ts diff --git a/cli/README.md b/cli/README.md index 7a0fea9..32cf730 100644 --- a/cli/README.md +++ b/cli/README.md @@ -9,6 +9,7 @@ Since the cli requires access to: - reading and writing files - access to environment variables - network access +- run programs The -A flag is the easiest way to install. You can however manually grant the required permissions. @@ -18,3 +19,4 @@ The -A flag is the easiest way to install. You can however manually grant the re | --allow-write | Write configuration file while using setup and init as well as during publish for temporary files | | --allow-net | Access to network for uploading to the registry (can be exclusive to the registry) | | --allow-env | Required to get config file path relative to user home directory | +| --allow-run | Required to run hook scripts | diff --git a/cli/commands/deprecate.ts b/cli/commands/deprecate.ts index 2e3be83..1fb2f00 100644 --- a/cli/commands/deprecate.ts +++ b/cli/commands/deprecate.ts @@ -6,7 +6,7 @@ export default async function deprecate(options: any) { const meta = await getMeta(); const res = await Cliffy.Confirm.prompt( - "Are you shure you want to deprecat this package?" + "Are you sure you want to deprecat this package?" ); if (res) { diff --git a/cli/commands/upgrade.ts b/cli/commands/upgrade.ts new file mode 100644 index 0000000..31cb5d8 --- /dev/null +++ b/cli/commands/upgrade.ts @@ -0,0 +1,26 @@ +import { Cliffy, Colors } from "../deps.ts"; + +export default async function upgrade() { + const res = await Cliffy.Confirm.prompt({ + message: "Are you sure you want to upgrade the denreg cli?", + default: true, + }); + + if (res) { + const process = Deno.run({ + cmd: [ + "deno", + "install", + "-A", + "--unstable", + "-f", + "https://deno.hibas123.de/raw/@denreg-cli/denreg.ts", + ], + }); + + const s = await process.status(); + if (!s) { + console.log(Colors.red("Upgrade failed!")); + } + } +} diff --git a/cli/denreg.ts b/cli/denreg.ts index c5f4b55..dc5d124 100644 --- a/cli/denreg.ts +++ b/cli/denreg.ts @@ -6,6 +6,7 @@ import initCMD from "./commands/init.ts"; import bumpCMD from "./commands/bump.ts"; import publishCMD from "./commands/publish.ts"; import deprecateCMD from "./commands/deprecate.ts"; +import upgradeCMD from "./commands/upgrade.ts"; const HOME_FOLDER = Deno.env.get("HOME") || Deno.env.get("USERPROFILE") || ""; @@ -74,6 +75,12 @@ const flags = await new Cliffy.Command() .description("Deprecate package") .action(commandWrapper(deprecateCMD)) ) + .command( + "upgrade", + new Cliffy.Command() + .description("Upgrade to latest version of denreg cli") + .action(commandWrapper(upgradeCMD)) + ) .command("completions", new Cliffy.CompletionsCommand()) .parse(Deno.args); diff --git a/cli/meta.json b/cli/meta.json index a84bb7a..59932ce 100644 --- a/cli/meta.json +++ b/cli/meta.json @@ -1,6 +1,6 @@ { "name": "@denreg-cli", - "version": "0.2.0", + "version": "0.2.1", "description": "CLI for the DenReg package registry", "author": "Fabian Stamm ", "contributors": [],