@flowscripter/dynamic-cli-framework 7.0.7 → 7.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,11 @@ export default class DefaultUpgradeService implements UpgradeService {
14
14
  * pick it up on a later invocation.
15
15
  */
16
16
  refreshUpgradeCheckCache(): Promise<UpgradeCheckResult>;
17
+ /**
18
+ * Return the result last persisted by {@link refreshUpgradeCheckCache}, without running a check.
19
+ * Returns `undefined` if nothing has been persisted yet or no KeyValueService is available.
20
+ */
21
+ getCachedUpgradeCheckResult(): Promise<UpgradeCheckResult | undefined>;
17
22
  detectOs(): SupportedOs | undefined;
18
23
  detectArch(): SupportedArch | undefined;
19
24
  detectInstallMethod(os: SupportedOs): Promise<InstallMethod | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"DefaultUpgradeService.d.ts","sourceRoot":"","sources":["../../../../src/service/upgrade/DefaultUpgradeService.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EAOP,kBAAkB,EAClB,aAAa,EAEd,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAEL,aAAa,EAIb,aAAa,EACb,WAAW,EACX,KAAK,cAAc,EACpB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAuC1E,eAAO,MAAM,uBAAuB,yBAAyB,CAAC;AAY9D,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAI7E;AAQD,MAAM,CAAC,OAAO,OAAO,qBAAsB,YAAW,cAAc;;IAMlE,YAAmB,MAAM,EAAE,sBAAsB,EAAE,SAAS,EAAE,SAAS,EAGtE;IAEM,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAExC;IA4DM,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAe1D;IAED;;;;OAIG;IACU,wBAAwB,IAAI,OA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CAAC,kBAAkB,CAAC,CASnE;IAED;;;OAGG;IACU,2BAA2B,IAAI,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAWlF;IAEM,QAAQ,IAAI,WAAW,GAAG,SAAS,CAWzC;IAEM,UAAU,IAAI,aAAa,GAAG,SAAS,CAS7C;IAEY,mBAAmB,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAsCpF;IA2CY,eAAe,CAC1B,UAAU,CAAC,EAAE,WAAW,EACxB,YAAY,CAAC,EAAE,aAAa,EAC5B,qBAAqB,CAAC,EAAE,aAAa,GACpC,OAAO,CAAC,kBAAkB,CAAC,CAsC7B;IAEY,OAAO,CAClB,UAAU,CAAC,EAAE,WAAW,EACxB,YAAY,CAAC,EAAE,aAAa,EAC5B,qBAAqB,CAAC,EAAE,aAAa,GACpC,OAAO,CAAC,aAAa,CAAC,CAkDxB;CAwTF"}
@@ -23,9 +23,10 @@ const LATEST_VERSION_CACHE_KEY_PREFIX = "latest-version:";
23
23
  const CACHE_TTL_MILLIS = 24 * 60 * 60 * 1000;
24
24
  // KeyValueService key holding the last checkForUpgrade() result, refreshed opportunistically by
25
25
  // UpgradeServiceProvider's background StartupTask and by the `upgrade` command - shared by both so
26
- // there's one cache, not two. The banner task only ever reads this key (kv.has()/kv.get()) - it
27
- // never calls checkForUpgrade()/getUpgradeCheckResult() live, since checking live would stall
28
- // startup on the network/spawn calls checkForUpgrade() makes.
26
+ // there's one cache, not two. The key lives in this service's own KeyValueService scope, so other
27
+ // consumers (e.g. the banner task) read it via getCachedUpgradeCheckResult() rather than their own
28
+ // scoped KeyValueService. The banner never calls checkForUpgrade()/getUpgradeCheckResult() live,
29
+ // since checking live would stall startup on the network/spawn calls checkForUpgrade() makes.
29
30
  export const UPGRADE_CHECK_CACHE_KEY = "upgrade-check-result";
30
31
  function describeSpawnFailure(result) {
31
32
  return "timedOut" in result
@@ -133,6 +134,22 @@ export default class DefaultUpgradeService {
133
134
  }
134
135
  return result;
135
136
  }
137
+ /**
138
+ * Return the result last persisted by {@link refreshUpgradeCheckCache}, without running a check.
139
+ * Returns `undefined` if nothing has been persisted yet or no KeyValueService is available.
140
+ */
141
+ async getCachedUpgradeCheckResult() {
142
+ const keyValueService = this.#keyValueService;
143
+ if (!keyValueService) {
144
+ return undefined;
145
+ }
146
+ const has = await this.#safeKeyValueCall(() => keyValueService.has(UPGRADE_CHECK_CACHE_KEY));
147
+ if (!has) {
148
+ return undefined;
149
+ }
150
+ const cached = await this.#safeKeyValueCall(() => keyValueService.get(UPGRADE_CHECK_CACHE_KEY));
151
+ return cached;
152
+ }
136
153
  detectOs() {
137
154
  switch (process.platform) {
138
155
  case "linux":
@@ -1 +1 @@
1
- {"version":3,"file":"bannerStartupTask.d.ts","sourceRoot":"","sources":["../../../../src/startup/banner/bannerStartupTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,WAAW,EAEZ,MAAM,yCAAyC,CAAC;AAYjD,eAAO,MAAM,sBAAsB,4DAA4D,CAAC;AAEhG;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,QAAQ,EAAE,MAAM,EAChB,QAAQ,SAAa,GACpB,WAAW,CA2Db"}
1
+ {"version":3,"file":"bannerStartupTask.d.ts","sourceRoot":"","sources":["../../../../src/startup/banner/bannerStartupTask.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA2B,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAYpG,eAAO,MAAM,sBAAsB,4DAA4D,CAAC;AAEhG;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,QAAQ,EAAE,MAAM,EAChB,QAAQ,SAAa,GACpB,WAAW,CA+Db"}
@@ -1,5 +1,5 @@
1
- import { ASCII_BANNER_GENERATOR_SERVICE_ID, CONFIGURATION_SERVICE_ID, KEY_VALUE_SERVICE_ID, PRINTER_SERVICE_ID, } from "@flowscripter/dynamic-cli-framework-api";
2
- import { UPGRADE_CHECK_CACHE_KEY } from "../../service/upgrade/DefaultUpgradeService.js";
1
+ import { ASCII_BANNER_GENERATOR_SERVICE_ID, CONFIGURATION_SERVICE_ID, PRINTER_SERVICE_ID, UPGRADE_SERVICE_ID, } from "@flowscripter/dynamic-cli-framework-api";
2
+ import DefaultUpgradeService from "../../service/upgrade/DefaultUpgradeService.js";
3
3
  import NoBannerCommand, {} from "./command/NoBannerCommand.js";
4
4
  export const BANNER_STARTUP_TASK_ID = "@flowscripter/dynamic-cli-framework/banner-startup-task";
5
5
  /**
@@ -41,14 +41,18 @@ export default function createBannerStartupTask(priority, fontName = "standard")
41
41
  let versionLine = "version: " + cliConfig.version;
42
42
  // Cheap cache read only - never calls checkForUpgrade()/getUpgradeCheckResult() live,
43
43
  // since that could stall startup on a network/spawn call. A first-ever run (no cached
44
- // key yet) simply shows no upgrade-available suffix - that's expected, not a bug.
45
- if (context.doesServiceExist(KEY_VALUE_SERVICE_ID)) {
46
- const keyValueService = context.getServiceById(KEY_VALUE_SERVICE_ID);
47
- if (await keyValueService.has(UPGRADE_CHECK_CACHE_KEY)) {
48
- const result = (await keyValueService.get(UPGRADE_CHECK_CACHE_KEY));
49
- if (result.status === "checked" && result.updateAvailable) {
50
- versionLine += ` (${result.latestVersion} available, run '${cliConfig.name} upgrade')`;
51
- }
44
+ // result yet) shows no upgrade-available suffix. The cached result is read through the
45
+ // upgrade service because it is stored in that service's own KeyValueService scope, and
46
+ // it is ignored if it was recorded by a different version (e.g. before an upgrade).
47
+ const upgradeService = context.doesServiceExist(UPGRADE_SERVICE_ID)
48
+ ? context.getServiceById(UPGRADE_SERVICE_ID)
49
+ : undefined;
50
+ if (upgradeService instanceof DefaultUpgradeService) {
51
+ const result = await upgradeService.getCachedUpgradeCheckResult();
52
+ if (result?.status === "checked" &&
53
+ result.updateAvailable &&
54
+ result.currentVersion === cliConfig.version) {
55
+ versionLine += ` (${result.latestVersion} available, run '${cliConfig.name} upgrade')`;
52
56
  }
53
57
  }
54
58
  await printerService.info(` ${printerService.secondary(versionLine)}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowscripter/dynamic-cli-framework",
3
- "version": "7.0.7",
3
+ "version": "7.0.9",
4
4
  "description": "A framework for developing CLI applications which supports dynamic discovery and installation of new commands",
5
5
  "keywords": [
6
6
  "bun",
@@ -48,7 +48,7 @@
48
48
  "build": "tsc -p tsconfig.build.json"
49
49
  },
50
50
  "dependencies": {
51
- "@flowscripter/dynamic-cli-framework-api": "^4.0.4",
51
+ "@flowscripter/dynamic-cli-framework-api": "^4.0.6",
52
52
  "@flowscripter/dynamic-plugin-framework": "^2.2.14",
53
53
  "emphasize": "^7.0.0",
54
54
  "fastest-levenshtein": "^1.0.16",
@@ -63,8 +63,8 @@
63
63
  "@types/bun": "^1.4.2",
64
64
  "@types/node": "^26.6.3",
65
65
  "@types/semver": "^7.8.0",
66
- "oxfmt": "0.70.0",
67
- "oxlint": "1.85.0"
66
+ "oxfmt": "0.71.0",
67
+ "oxlint": "1.86.0"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "typescript": "^7.0.2"
@@ -63,9 +63,10 @@ interface CachedLatestVersion {
63
63
 
64
64
  // KeyValueService key holding the last checkForUpgrade() result, refreshed opportunistically by
65
65
  // UpgradeServiceProvider's background StartupTask and by the `upgrade` command - shared by both so
66
- // there's one cache, not two. The banner task only ever reads this key (kv.has()/kv.get()) - it
67
- // never calls checkForUpgrade()/getUpgradeCheckResult() live, since checking live would stall
68
- // startup on the network/spawn calls checkForUpgrade() makes.
66
+ // there's one cache, not two. The key lives in this service's own KeyValueService scope, so other
67
+ // consumers (e.g. the banner task) read it via getCachedUpgradeCheckResult() rather than their own
68
+ // scoped KeyValueService. The banner never calls checkForUpgrade()/getUpgradeCheckResult() live,
69
+ // since checking live would stall startup on the network/spawn calls checkForUpgrade() makes.
69
70
  export const UPGRADE_CHECK_CACHE_KEY = "upgrade-check-result";
70
71
 
71
72
  type VersionLookupResult =
@@ -196,6 +197,23 @@ export default class DefaultUpgradeService implements UpgradeService {
196
197
  return result;
197
198
  }
198
199
 
200
+ /**
201
+ * Return the result last persisted by {@link refreshUpgradeCheckCache}, without running a check.
202
+ * Returns `undefined` if nothing has been persisted yet or no KeyValueService is available.
203
+ */
204
+ public async getCachedUpgradeCheckResult(): Promise<UpgradeCheckResult | undefined> {
205
+ const keyValueService = this.#keyValueService;
206
+ if (!keyValueService) {
207
+ return undefined;
208
+ }
209
+ const has = await this.#safeKeyValueCall(() => keyValueService.has(UPGRADE_CHECK_CACHE_KEY));
210
+ if (!has) {
211
+ return undefined;
212
+ }
213
+ const cached = await this.#safeKeyValueCall(() => keyValueService.get(UPGRADE_CHECK_CACHE_KEY));
214
+ return cached as unknown as UpgradeCheckResult | undefined;
215
+ }
216
+
199
217
  public detectOs(): SupportedOs | undefined {
200
218
  switch (process.platform) {
201
219
  case "linux":
@@ -1,19 +1,13 @@
1
- import type {
2
- Context,
3
- KeyValueService,
4
- PrinterService,
5
- StartupTask,
6
- UpgradeCheckResult,
7
- } from "@flowscripter/dynamic-cli-framework-api";
1
+ import type { Context, PrinterService, StartupTask } from "@flowscripter/dynamic-cli-framework-api";
8
2
  import {
9
3
  ASCII_BANNER_GENERATOR_SERVICE_ID,
10
4
  CONFIGURATION_SERVICE_ID,
11
- KEY_VALUE_SERVICE_ID,
12
5
  PRINTER_SERVICE_ID,
6
+ UPGRADE_SERVICE_ID,
13
7
  } from "@flowscripter/dynamic-cli-framework-api";
14
8
  import type { AsciiBannerGeneratorService } from "@flowscripter/dynamic-cli-framework-api";
15
9
  import type { ConfigurationService } from "@flowscripter/dynamic-cli-framework-api";
16
- import { UPGRADE_CHECK_CACHE_KEY } from "../../service/upgrade/DefaultUpgradeService.ts";
10
+ import DefaultUpgradeService from "../../service/upgrade/DefaultUpgradeService.ts";
17
11
  import NoBannerCommand, { type BannerState } from "./command/NoBannerCommand.ts";
18
12
 
19
13
  export const BANNER_STARTUP_TASK_ID = "@flowscripter/dynamic-cli-framework/banner-startup-task";
@@ -67,16 +61,20 @@ export default function createBannerStartupTask(
67
61
  let versionLine = "version: " + cliConfig.version;
68
62
  // Cheap cache read only - never calls checkForUpgrade()/getUpgradeCheckResult() live,
69
63
  // since that could stall startup on a network/spawn call. A first-ever run (no cached
70
- // key yet) simply shows no upgrade-available suffix - that's expected, not a bug.
71
- if (context.doesServiceExist(KEY_VALUE_SERVICE_ID)) {
72
- const keyValueService = context.getServiceById(KEY_VALUE_SERVICE_ID) as KeyValueService;
73
- if (await keyValueService.has(UPGRADE_CHECK_CACHE_KEY)) {
74
- const result = (await keyValueService.get(
75
- UPGRADE_CHECK_CACHE_KEY,
76
- )) as unknown as UpgradeCheckResult;
77
- if (result.status === "checked" && result.updateAvailable) {
78
- versionLine += ` (${result.latestVersion} available, run '${cliConfig.name} upgrade')`;
79
- }
64
+ // result yet) shows no upgrade-available suffix. The cached result is read through the
65
+ // upgrade service because it is stored in that service's own KeyValueService scope, and
66
+ // it is ignored if it was recorded by a different version (e.g. before an upgrade).
67
+ const upgradeService = context.doesServiceExist(UPGRADE_SERVICE_ID)
68
+ ? context.getServiceById(UPGRADE_SERVICE_ID)
69
+ : undefined;
70
+ if (upgradeService instanceof DefaultUpgradeService) {
71
+ const result = await upgradeService.getCachedUpgradeCheckResult();
72
+ if (
73
+ result?.status === "checked" &&
74
+ result.updateAvailable &&
75
+ result.currentVersion === cliConfig.version
76
+ ) {
77
+ versionLine += ` (${result.latestVersion} available, run '${cliConfig.name} upgrade')`;
80
78
  }
81
79
  }
82
80
  await printerService.info(` ${printerService.secondary(versionLine)}\n`);