Compare commits

..

3 Commits

Author SHA1 Message Date
Fabian Stamm
2ee628544e Add automatic version reading
All checks were successful
continuous-integration/drone/push Build is passing
2020-08-16 19:37:09 +02:00
Fabian Stamm
c78f6822e1 Add upgrade command 2020-08-16 19:28:27 +02:00
Fabian Stamm
438cee6bed Upgrading deps 2020-08-16 19:28:12 +02:00
8 changed files with 62 additions and 8 deletions

View File

@ -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 |

View File

@ -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) {

26
cli/commands/upgrade.ts Normal file
View File

@ -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!"));
}
}
}

View File

@ -6,6 +6,14 @@ 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";
let version = "unknown";
try {
const v = await import("./version.ts");
version = v.version;
} catch (err) {}
const HOME_FOLDER = Deno.env.get("HOME") || Deno.env.get("USERPROFILE") || "";
@ -25,7 +33,7 @@ const commandWrapper = (cmd: CommandHandler) => {
};
const flags = await new Cliffy.Command()
.name("denreg")
.version("1.1.9")
.version(version)
.description("CLI for the Open Source DenReg package registry")
.option("-i, --interactive [interactive:boolean]", "Interactive mode", {
default: true,
@ -74,6 +82,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);

View File

@ -1,7 +1,7 @@
export * as Compress from "https://deno.hibas123.de/raw/@denreg-tar/mod.ts";
export * as Ini from "https://deno.land/x/ini/mod.ts";
export * as Cliffy from "https://deno.land/x/cliffy/mod.ts";
export * as Base64 from "https://deno.land/std@0.63.0/encoding/base64.ts";
export * as FS from "https://deno.land/std@0.63.0/fs/mod.ts";
export * as Colors from "https://deno.land/std@0.63.0/fmt/colors.ts";
export * as Path from "https://deno.land/std@0.63.0/path/mod.ts";
export * as Base64 from "https://deno.land/std@0.65.0/encoding/base64.ts";
export * as FS from "https://deno.land/std@0.65.0/fs/mod.ts";
export * as Colors from "https://deno.land/std@0.65.0/fmt/colors.ts";
export * as Path from "https://deno.land/std@0.65.0/path/mod.ts";

View File

@ -1,8 +1,11 @@
{
"name": "@denreg-cli",
"version": "0.2.0",
"version": "0.2.3",
"description": "CLI for the DenReg package registry",
"author": "Fabian Stamm <dev@fabianstamm.de>",
"contributors": [],
"files": ["**/*.ts", "**/*.js", "README.md"]
"files": ["**/*.ts", "**/*.js", "README.md"],
"hooks": {
"prepublish": "pre.ts"
}
}

8
cli/pre.ts Normal file
View File

@ -0,0 +1,8 @@
import { FS } from "./deps.ts";
const meta = (await FS.readJson("./meta.json")) as any;
await Deno.writeTextFile(
"version.ts",
`export const version = "${meta.version}"`
);

1
cli/version.ts Normal file
View File

@ -0,0 +1 @@
export const version = "0.2.3"