This repository was archived by the owner on Sep 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed
Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 22
33# Change Log
44
5+ ## 2025-04-08 - CLI 0.17.3
6+
7+ - feat: Add update prompt on CLI usage [ #811 ] ( https://github.com/hypermodeinc/modus/pull/811 )
8+
59## 2025-04-01 - Runtime 0.17.8
610
711- fix: Update Hypermode api key reading for modus local dev [ #805 ] ( https://github.com/hypermodeinc/modus/pull/805 )
Original file line number Diff line number Diff line change 11import { Command , Flags } from "@oclif/core" ;
2+ import { checkForUpdates } from "./util/updateNotifier.js" ;
23
34export abstract class BaseCommand extends Command {
45 static baseFlags = {
@@ -13,4 +14,13 @@ export abstract class BaseCommand extends Command {
1314 hidden : true ,
1415 } ) ,
1516 } ;
17+
18+ async init ( ) : Promise < void > {
19+ await super . init ( ) ;
20+
21+ const cmd = this . id ?. split ( " " ) [ 0 ] ;
22+ if ( cmd !== "version" && ! this . argv . includes ( "--version" ) && ! this . argv . includes ( "-v" ) ) {
23+ await checkForUpdates ( this . config . version ) ;
24+ }
25+ }
1626}
Original file line number Diff line number Diff line change 1+ import chalk from "chalk" ;
2+ import semver from "semver" ;
3+ import * as vi from "./versioninfo.js" ;
4+ import { isOnline } from "./index.js" ;
5+
6+ /**
7+ * Checks if there's a newer version of the CLI available and prints an update message if needed.
8+ * @param currentVersion Current CLI version
9+ */
10+ export async function checkForUpdates ( currentVersion : string ) : Promise < void > {
11+ if ( ! ( await isOnline ( ) ) ) {
12+ return ;
13+ }
14+
15+ if ( currentVersion . startsWith ( "v" ) ) {
16+ currentVersion = currentVersion . slice ( 1 ) ;
17+ }
18+
19+ const latestVersion = await vi . getLatestCliVersion ( false ) ;
20+ if ( ! latestVersion ) return ;
21+
22+ const latestVersionNumber = latestVersion . startsWith ( "v" ) ? latestVersion . slice ( 1 ) : latestVersion ;
23+
24+ if ( semver . gt ( latestVersionNumber , currentVersion ) ) {
25+ console . log ( ) ;
26+ console . log ( chalk . yellow ( "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" ) ) ;
27+ console . log ( chalk . yellow ( `Update available! ${ chalk . dim ( currentVersion ) } → ${ chalk . greenBright ( latestVersionNumber ) } ` ) ) ;
28+ console . log ( chalk . yellow ( "Run " ) + chalk . cyanBright ( "npm update -g @hypermode/modus-cli" ) + chalk . yellow ( " to update." ) ) ;
29+ console . log ( chalk . yellow ( "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" ) ) ;
30+ console . log ( ) ;
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments