From ab9c6570b144f3bb1db1ce0d7f997290537e4a4b Mon Sep 17 00:00:00 2001 From: hasundue Date: Mon, 23 Oct 2023 17:32:21 +0900 Subject: [PATCH] chore(cli): resolve version dynamically --- cli.ts | 8 +++++++- lib/dependency.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cli.ts b/cli.ts index 7ee51280..fe3c2d52 100644 --- a/cli.ts +++ b/cli.ts @@ -8,6 +8,12 @@ import { URI } from "./lib/uri.ts"; import { DependencyUpdate } from "./lib/update.ts"; import { FileUpdate } from "./lib/file.ts"; import { GitCommitSequence } from "./lib/git.ts"; +import { parseSemVer } from "./lib/semver.ts"; +import { resolveLatestSemVer } from "./lib/dependency.ts"; + +const VERSION = parseSemVer(import.meta.url) ?? + await resolveLatestSemVer(new URL("https://deno.land/x/molt@0.0.0/cli.ts")) ?? + "undefined"; const { gray, yellow, bold, cyan } = colors; @@ -330,7 +336,7 @@ const main = new Command() .action(function () { this.showHelp(); }) - .version("0.7.4") + .version(VERSION) .command("check", checkCommand) .command("update", updateCommand); diff --git a/lib/dependency.ts b/lib/dependency.ts index 98a0dcaa..fa88354b 100644 --- a/lib/dependency.ts +++ b/lib/dependency.ts @@ -29,7 +29,7 @@ function parseProps( return { name, version: semver, path: path as Path }; } -async function resolveLatestSemVer( +export async function resolveLatestSemVer( url: URL, ): Promise> { const props = parseProps(url);