From 3cf675883384991d0bec0bc9ecdfbcdd326e4677 Mon Sep 17 00:00:00 2001 From: parizval Date: Wed, 26 Nov 2025 21:52:52 +0530 Subject: [PATCH] feat: detect package manager and improve command line hint --- src/commands/version.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/commands/version.ts b/src/commands/version.ts index e14d02e1..b1defc95 100644 --- a/src/commands/version.ts +++ b/src/commands/version.ts @@ -4,7 +4,7 @@ import {clean} from 'semver'; import {version as cliCurrentVersion} from '../../package.json'; import {githubCliLastRelease} from '../rest/github.rest'; import {checkVersion} from '../services/version.services'; - +import {detectPackageManager} from '../utils/pm.utils'; export const version = async () => { await cliVersion(); }; @@ -26,10 +26,26 @@ const cliVersion = async () => { return; } + const commandLineHint = getCommandLineHint(); + checkVersion({ currentVersion: cliCurrentVersion, latestVersion, displayHint: 'CLI', - commandLineHint: `npm i -g @junobuild/cli` + commandLineHint }); }; + +const getCommandLineHint = () => { + const pm = detectPackageManager(); + + switch (pm) { + case 'yarn': + return 'yarn global add @junobuild/cli'; + case 'pnpm': + return 'pnpm add -g @junobuild/cli'; + case 'npm': + default: + return 'npm i -g @junobuild/cli'; + } +};