diff --git a/cli/denreg.ts b/cli/denreg.ts index dc5d124..d1653b6 100644 --- a/cli/denreg.ts +++ b/cli/denreg.ts @@ -8,6 +8,13 @@ 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") || ""; type CommandHandler = (...opts: any[]) => void | Promise; @@ -26,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, diff --git a/cli/meta.json b/cli/meta.json index 59932ce..85eb2a7 100644 --- a/cli/meta.json +++ b/cli/meta.json @@ -1,8 +1,11 @@ { "name": "@denreg-cli", - "version": "0.2.1", + "version": "0.2.3", "description": "CLI for the DenReg package registry", "author": "Fabian Stamm ", "contributors": [], - "files": ["**/*.ts", "**/*.js", "README.md"] + "files": ["**/*.ts", "**/*.js", "README.md"], + "hooks": { + "prepublish": "pre.ts" + } } diff --git a/cli/pre.ts b/cli/pre.ts new file mode 100644 index 0000000..a872ab7 --- /dev/null +++ b/cli/pre.ts @@ -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}"` +); diff --git a/cli/version.ts b/cli/version.ts new file mode 100644 index 0000000..2f1d92a --- /dev/null +++ b/cli/version.ts @@ -0,0 +1 @@ +export const version = "0.2.3" \ No newline at end of file