@flowscripter/dynamic-cli-framework 9.0.0 → 9.0.2

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.
@@ -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,EAKP,WAAW,EAEX,kBAAkB,EAClB,aAAa,EAEd,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAEL,aAAa,EAGb,QAAQ,EAER,aAAa,EACb,WAAW,EACX,KAAK,cAAc,EACpB,MAAM,yCAAyC,CAAC;AAEjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAwC1E,eAAO,MAAM,uBAAuB,yBAAyB,CAAC;AAY9D,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAI7E;AAaD;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,SAAS,CAiBpE;AAQD,MAAM,CAAC,OAAO,OAAO,qBAAsB,YAAW,cAAc;;IAKlE,SAAgB,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IAEzD,YAAmB,MAAM,EAAE,sBAAsB,EAAE,SAAS,EAAE,SAAS,EAItE;IAEM,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAExC;IA4DM,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAe1D;IAED;;;;OAIG;IACU,wBAAwB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CASnE;IAED;;;OAGG;IACU,2BAA2B,IAAI,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAWlF;IAED;;;;;OAKG;IACI,yBAAyB,CAAC,aAAa,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAUjF;IAoBD;;;;;;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,EAItE;IAEM,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAExC;IA4DM,qBAAqB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAe1D;IAED;;;;OAIG;IACU,wBAAwB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CASnE;IAED;;;OAGG;IACU,2BAA2B,IAAI,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAWlF;IAED;;;;;OAKG;IACI,yBAAyB,CAAC,aAAa,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAUjF;IAoBD;;;;;;;OAOG;IACU,OAAO,CAClB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,GAC1B,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAY/B;IAEM,QAAQ,IAAI,WAAW,GAAG,SAAS,CAWzC;IAEM,UAAU,IAAI,aAAa,GAAG,SAAS,CAQ7C;IAEY,mBAAmB,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAoDpF;IA2CY,eAAe,CAAC,qBAAqB,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAsC/F;IAEY,OAAO,CAAC,qBAAqB,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAiDlF;CAgVF"}
@@ -407,7 +407,7 @@ export default class DefaultUpgradeService {
407
407
  await this.#upgradeViaLinuxScript();
408
408
  break;
409
409
  case InstallMethod.HOMEBREW:
410
- await this.#upgradeViaHomebrew();
410
+ await this.#upgradeViaHomebrew(checkResult.latestVersion);
411
411
  break;
412
412
  case InstallMethod.WINGET:
413
413
  await this.#upgradeViaWinget();
@@ -586,12 +586,30 @@ export default class DefaultUpgradeService {
586
586
  throw new Error(`Install script failed: ${describeSpawnFailure(result)}`);
587
587
  }
588
588
  }
589
- async #upgradeViaHomebrew() {
589
+ // The latest version is read from the tap's formula on GitHub, but `brew upgrade` only sees the
590
+ // local tap clone, which is stale until `brew update` runs. A stale tap makes `brew upgrade`
591
+ // exit 0 with "already installed", so update first and then confirm the installed version.
592
+ async #upgradeViaHomebrew(expectedVersion) {
590
593
  const { tap, formula } = this.#config.homebrew;
594
+ const updateResult = await this.#spawnQuoted(["brew", "update"]);
595
+ if (!updateResult.ok) {
596
+ throw new Error(`brew update failed: ${describeSpawnFailure(updateResult)}`);
597
+ }
591
598
  const result = await this.#spawnQuoted(["brew", "upgrade", `${tap}/${formula}`]);
592
599
  if (!result.ok) {
593
600
  throw new Error(`brew upgrade failed: ${describeSpawnFailure(result)}`);
594
601
  }
602
+ const lines = [];
603
+ const listResult = await this.#spawnService.spawn(["brew", "list", "--versions", formula], {
604
+ mode: "wrapped",
605
+ longRunning: false,
606
+ onOutput: (line) => lines.push(line),
607
+ });
608
+ const installed = lines.join(" ").trim();
609
+ const installedVersions = installed.split(/\s+/).slice(1);
610
+ if (!listResult.ok || !installedVersions.includes(expectedVersion)) {
611
+ throw new Error(`brew upgrade completed but version ${expectedVersion} is not installed (installed: ${installed || "unknown"})`);
612
+ }
595
613
  }
596
614
  async #upgradeViaWinget() {
597
615
  const { packageId } = this.#config.winget;
@@ -1 +1 @@
1
- {"version":3,"file":"UpgradeSubCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/upgrade/command/UpgradeSubCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,KAAK,MAAM,EAAiB,MAAM,yCAAyC,CAAC;AAUrF,qBAAa,iBAAkB,YAAW,UAAU;IAClD,QAAQ,CAAC,IAAI,aAAa;IAC1B,QAAQ,CAAC,WAAW,6CAA6C;IACjE,QAAQ,CAAC,mBAAmB,SAAS;IACrC,QAAQ,CAAC,WAAW,UAAM;IAE1B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAQrC;IAEW,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqD5E;CACF"}
1
+ {"version":3,"file":"UpgradeSubCommand.d.ts","sourceRoot":"","sources":["../../../../../src/service/upgrade/command/UpgradeSubCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yCAAyC,CAAC;AACtE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AACvE,OAAO,EAAE,KAAK,MAAM,EAAiB,MAAM,yCAAyC,CAAC;AAuBrF,qBAAa,iBAAkB,YAAW,UAAU;IAClD,QAAQ,CAAC,IAAI,aAAa;IAC1B,QAAQ,CAAC,WAAW,6CAA6C;IACjE,QAAQ,CAAC,mBAAmB,SAAS;IACrC,QAAQ,CAAC,WAAW,UAAM;IAE1B,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,CAQrC;IAEW,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqD5E;CACF"}
@@ -1,5 +1,17 @@
1
1
  import { ValueTypeName } from "@flowscripter/dynamic-cli-framework-api";
2
2
  import { Icon, InstallMethod, PRINTER_SERVICE_ID, UPGRADE_SERVICE_ID, } from "@flowscripter/dynamic-cli-framework-api";
3
+ function installMethodsForPlatform() {
4
+ if (process.platform === "darwin") {
5
+ return [InstallMethod.HOMEBREW, InstallMethod.GITHUB_RELEASE];
6
+ }
7
+ if (process.platform === "linux") {
8
+ return [InstallMethod.LINUX_SCRIPT, InstallMethod.GITHUB_RELEASE];
9
+ }
10
+ if (process.platform === "win32") {
11
+ return [InstallMethod.WINGET, InstallMethod.GITHUB_RELEASE];
12
+ }
13
+ return [InstallMethod.GITHUB_RELEASE];
14
+ }
3
15
  export class UpgradeSubCommand {
4
16
  name = "upgrade";
5
17
  description = "Upgrade to the latest available version";
@@ -10,7 +22,7 @@ export class UpgradeSubCommand {
10
22
  name: "install-method",
11
23
  type: ValueTypeName.STRING,
12
24
  isOptional: true,
13
- allowableValues: Object.values(InstallMethod),
25
+ allowableValues: installMethodsForPlatform(),
14
26
  description: "Override the detected install method",
15
27
  },
16
28
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowscripter/dynamic-cli-framework",
3
- "version": "9.0.0",
3
+ "version": "9.0.2",
4
4
  "description": "A framework for developing CLI applications which supports dynamic discovery and installation of new commands",
5
5
  "keywords": [
6
6
  "bun",
@@ -512,7 +512,7 @@ export default class DefaultUpgradeService implements UpgradeService {
512
512
  await this.#upgradeViaLinuxScript();
513
513
  break;
514
514
  case InstallMethod.HOMEBREW:
515
- await this.#upgradeViaHomebrew();
515
+ await this.#upgradeViaHomebrew(checkResult.latestVersion);
516
516
  break;
517
517
  case InstallMethod.WINGET:
518
518
  await this.#upgradeViaWinget();
@@ -725,12 +725,33 @@ export default class DefaultUpgradeService implements UpgradeService {
725
725
  }
726
726
  }
727
727
 
728
- async #upgradeViaHomebrew(): Promise<void> {
728
+ // The latest version is read from the tap's formula on GitHub, but `brew upgrade` only sees the
729
+ // local tap clone, which is stale until `brew update` runs. A stale tap makes `brew upgrade`
730
+ // exit 0 with "already installed", so update first and then confirm the installed version.
731
+ async #upgradeViaHomebrew(expectedVersion: string): Promise<void> {
729
732
  const { tap, formula } = this.#config.homebrew!;
733
+ const updateResult = await this.#spawnQuoted(["brew", "update"]);
734
+ if (!updateResult.ok) {
735
+ throw new Error(`brew update failed: ${describeSpawnFailure(updateResult)}`);
736
+ }
730
737
  const result = await this.#spawnQuoted(["brew", "upgrade", `${tap}/${formula}`]);
731
738
  if (!result.ok) {
732
739
  throw new Error(`brew upgrade failed: ${describeSpawnFailure(result)}`);
733
740
  }
741
+
742
+ const lines: string[] = [];
743
+ const listResult = await this.#spawnService!.spawn(["brew", "list", "--versions", formula], {
744
+ mode: "wrapped",
745
+ longRunning: false,
746
+ onOutput: (line) => lines.push(line),
747
+ });
748
+ const installed = lines.join(" ").trim();
749
+ const installedVersions = installed.split(/\s+/).slice(1);
750
+ if (!listResult.ok || !installedVersions.includes(expectedVersion)) {
751
+ throw new Error(
752
+ `brew upgrade completed but version ${expectedVersion} is not installed (installed: ${installed || "unknown"})`,
753
+ );
754
+ }
734
755
  }
735
756
 
736
757
  async #upgradeViaWinget(): Promise<void> {
@@ -11,6 +11,19 @@ import {
11
11
  import type { PrinterService } from "@flowscripter/dynamic-cli-framework-api";
12
12
  import type { UpgradeService } from "@flowscripter/dynamic-cli-framework-api";
13
13
 
14
+ function installMethodsForPlatform(): InstallMethod[] {
15
+ if (process.platform === "darwin") {
16
+ return [InstallMethod.HOMEBREW, InstallMethod.GITHUB_RELEASE];
17
+ }
18
+ if (process.platform === "linux") {
19
+ return [InstallMethod.LINUX_SCRIPT, InstallMethod.GITHUB_RELEASE];
20
+ }
21
+ if (process.platform === "win32") {
22
+ return [InstallMethod.WINGET, InstallMethod.GITHUB_RELEASE];
23
+ }
24
+ return [InstallMethod.GITHUB_RELEASE];
25
+ }
26
+
14
27
  export class UpgradeSubCommand implements SubCommand {
15
28
  readonly name = "upgrade";
16
29
  readonly description = "Upgrade to the latest available version";
@@ -22,7 +35,7 @@ export class UpgradeSubCommand implements SubCommand {
22
35
  name: "install-method",
23
36
  type: ValueTypeName.STRING,
24
37
  isOptional: true,
25
- allowableValues: Object.values(InstallMethod),
38
+ allowableValues: installMethodsForPlatform(),
26
39
  description: "Override the detected install method",
27
40
  },
28
41
  ];