From f8f201564f7a323eb96f6dc684a525a0784d41f2 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Thu, 15 May 2025 19:49:16 +0200 Subject: [PATCH] fix(cli): --version improvement --- cli/main.ts | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/cli/main.ts b/cli/main.ts index 100fc521bc..f63ab769d3 100644 --- a/cli/main.ts +++ b/cli/main.ts @@ -94,6 +94,7 @@ const command = new Command() "Specify headers to use for all requests. e.g: \"HEADERS='h1: v1, h2: v2'\"" ) .version(VERSION) + .versionOption(false) .command("init", "Bootstrap a windmill project with a wmill.yaml file") .action(async () => { if (await Deno.stat("wmill.yaml").catch(() => null)) { @@ -134,15 +135,34 @@ const command = new Command() .command("worker-groups", workerGroups) .command("workers", workers) .command("queues", queues) - .command("version", "Show version information") + .command("version --version", "Show version information") .action(async (opts) => { - console.log("CLI build against " + VERSION); + console.log("CLI version: " + VERSION); + try { + const provider = new NpmProvider({ package: "windmill-cli" }); + const versions = await provider.getVersions("windmill-cli"); + if (versions.latest !== VERSION) { + console.log( + `CLI is outdated. Latest version ${versions.latest} is available. Run \`wmill upgrade\` to update.` + ); + } else { + console.log("CLI is up to date"); + } + } catch (e) { + console.warn( + `Cannot fetch latest CLI version on npmjs to check if up-to-date: ${e}` + ); + } const workspace = await getActiveWorkspace(opts as GlobalOptions); if (workspace) { - const backendVersion = await fetchVersion(workspace.remote); - console.log("Backend Version: " + backendVersion); + try { + const backendVersion = await fetchVersion(workspace.remote); + console.log("Backend Version: " + backendVersion); + } catch (e) { + console.warn("Cannot fetch backend version: " + e); + } } else { - console.log( + console.warn( "Cannot fetch backend version: no active workspace selected, choose one to pick a remote to fetch version of" ); }