Add automatic version reading
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Fabian Stamm 2020-08-16 19:37:09 +02:00
parent c78f6822e1
commit 2ee628544e
4 changed files with 22 additions and 3 deletions

View File

@ -8,6 +8,13 @@ import publishCMD from "./commands/publish.ts";
import deprecateCMD from "./commands/deprecate.ts"; import deprecateCMD from "./commands/deprecate.ts";
import upgradeCMD from "./commands/upgrade.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") || ""; const HOME_FOLDER = Deno.env.get("HOME") || Deno.env.get("USERPROFILE") || "";
type CommandHandler = (...opts: any[]) => void | Promise<void>; type CommandHandler = (...opts: any[]) => void | Promise<void>;
@ -26,7 +33,7 @@ const commandWrapper = (cmd: CommandHandler) => {
}; };
const flags = await new Cliffy.Command() const flags = await new Cliffy.Command()
.name("denreg") .name("denreg")
.version("1.1.9") .version(version)
.description("CLI for the Open Source DenReg package registry") .description("CLI for the Open Source DenReg package registry")
.option("-i, --interactive [interactive:boolean]", "Interactive mode", { .option("-i, --interactive [interactive:boolean]", "Interactive mode", {
default: true, default: true,

View File

@ -1,8 +1,11 @@
{ {
"name": "@denreg-cli", "name": "@denreg-cli",
"version": "0.2.1", "version": "0.2.3",
"description": "CLI for the DenReg package registry", "description": "CLI for the DenReg package registry",
"author": "Fabian Stamm <dev@fabianstamm.de>", "author": "Fabian Stamm <dev@fabianstamm.de>",
"contributors": [], "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"