@flowscripter/dynamic-cli-framework 8.0.1 → 9.0.1
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.
- package/dist/src/service/upgrade/DefaultUpgradeService.d.ts +2 -2
- package/dist/src/service/upgrade/DefaultUpgradeService.d.ts.map +1 -1
- package/dist/src/service/upgrade/DefaultUpgradeService.js +27 -10
- package/dist/src/service/upgrade/command/UpgradeSubCommand.d.ts.map +1 -1
- package/dist/src/service/upgrade/command/UpgradeSubCommand.js +5 -14
- package/package.json +2 -2
- package/src/service/upgrade/DefaultUpgradeService.ts +32 -20
- package/src/service/upgrade/command/UpgradeSubCommand.ts +4 -15
|
@@ -50,7 +50,7 @@ export default class DefaultUpgradeService implements UpgradeService {
|
|
|
50
50
|
detectOs(): SupportedOs | undefined;
|
|
51
51
|
detectArch(): SupportedArch | undefined;
|
|
52
52
|
detectInstallMethod(os: SupportedOs): Promise<InstallMethod | undefined>;
|
|
53
|
-
checkForUpgrade(
|
|
54
|
-
upgrade(
|
|
53
|
+
checkForUpgrade(installMethodOverride?: InstallMethod): Promise<UpgradeCheckResult>;
|
|
54
|
+
upgrade(installMethodOverride?: InstallMethod): Promise<UpgradeResult>;
|
|
55
55
|
}
|
|
56
56
|
//# sourceMappingURL=DefaultUpgradeService.d.ts.map
|
|
@@ -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,eA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pF;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"}
|
|
@@ -341,9 +341,9 @@ export default class DefaultUpgradeService {
|
|
|
341
341
|
await this.#safeKeyValueCall(() => keyValueService.set(INSTALL_METHOD_CACHE_KEY, { method, checkedAt: Date.now() }));
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
|
-
async checkForUpgrade(
|
|
345
|
-
const os =
|
|
346
|
-
const arch =
|
|
344
|
+
async checkForUpgrade(installMethodOverride) {
|
|
345
|
+
const os = this.detectOs();
|
|
346
|
+
const arch = this.detectArch();
|
|
347
347
|
if (!os || !arch || !this.#isPlatformSupported(os, arch)) {
|
|
348
348
|
return { status: "unsupported" };
|
|
349
349
|
}
|
|
@@ -374,17 +374,16 @@ export default class DefaultUpgradeService {
|
|
|
374
374
|
installMethod,
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
|
-
async upgrade(
|
|
377
|
+
async upgrade(installMethodOverride) {
|
|
378
378
|
const oldVersion = this.#cliConfig.version;
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
? await this.checkForUpgrade(osOverride, archOverride, installMethodOverride)
|
|
379
|
+
const checkResult = installMethodOverride !== undefined
|
|
380
|
+
? await this.checkForUpgrade(installMethodOverride)
|
|
382
381
|
: await this.getUpgradeCheckResult();
|
|
383
382
|
if (checkResult.status === "unsupported") {
|
|
384
383
|
return {
|
|
385
384
|
ok: false,
|
|
386
385
|
oldVersion,
|
|
387
|
-
error: new Error("No upgrade location configured for the detected
|
|
386
|
+
error: new Error("No upgrade location configured for the detected platform"),
|
|
388
387
|
};
|
|
389
388
|
}
|
|
390
389
|
if (checkResult.status === "failed") {
|
|
@@ -408,7 +407,7 @@ export default class DefaultUpgradeService {
|
|
|
408
407
|
await this.#upgradeViaLinuxScript();
|
|
409
408
|
break;
|
|
410
409
|
case InstallMethod.HOMEBREW:
|
|
411
|
-
await this.#upgradeViaHomebrew();
|
|
410
|
+
await this.#upgradeViaHomebrew(checkResult.latestVersion);
|
|
412
411
|
break;
|
|
413
412
|
case InstallMethod.WINGET:
|
|
414
413
|
await this.#upgradeViaWinget();
|
|
@@ -587,12 +586,30 @@ export default class DefaultUpgradeService {
|
|
|
587
586
|
throw new Error(`Install script failed: ${describeSpawnFailure(result)}`);
|
|
588
587
|
}
|
|
589
588
|
}
|
|
590
|
-
|
|
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) {
|
|
591
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
|
+
}
|
|
592
598
|
const result = await this.#spawnQuoted(["brew", "upgrade", `${tap}/${formula}`]);
|
|
593
599
|
if (!result.ok) {
|
|
594
600
|
throw new Error(`brew upgrade failed: ${describeSpawnFailure(result)}`);
|
|
595
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
|
+
}
|
|
596
613
|
}
|
|
597
614
|
async #upgradeViaWinget() {
|
|
598
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;
|
|
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,18 +1,11 @@
|
|
|
1
1
|
import { ValueTypeName } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
|
-
import { Icon, InstallMethod, PRINTER_SERVICE_ID,
|
|
2
|
+
import { Icon, InstallMethod, PRINTER_SERVICE_ID, UPGRADE_SERVICE_ID, } from "@flowscripter/dynamic-cli-framework-api";
|
|
3
3
|
export class UpgradeSubCommand {
|
|
4
4
|
name = "upgrade";
|
|
5
5
|
description = "Upgrade to the latest available version";
|
|
6
6
|
enableConfiguration = false;
|
|
7
7
|
positionals = [];
|
|
8
8
|
options = [
|
|
9
|
-
{
|
|
10
|
-
name: "os",
|
|
11
|
-
type: ValueTypeName.STRING,
|
|
12
|
-
isOptional: true,
|
|
13
|
-
allowableValues: Object.values(SupportedOs),
|
|
14
|
-
description: "Override the detected operating system",
|
|
15
|
-
},
|
|
16
9
|
{
|
|
17
10
|
name: "install-method",
|
|
18
11
|
type: ValueTypeName.STRING,
|
|
@@ -26,16 +19,14 @@ export class UpgradeSubCommand {
|
|
|
26
19
|
const upgradeService = context.getServiceById(UPGRADE_SERVICE_ID);
|
|
27
20
|
const cliName = context.cliConfig.name;
|
|
28
21
|
const currentVersion = context.cliConfig.version;
|
|
29
|
-
const os = argumentValues.os;
|
|
30
|
-
const arch = undefined;
|
|
31
22
|
const installMethod = argumentValues["install-method"];
|
|
32
23
|
await printerService.showSpinner(`Looking for version newer than ${currentVersion}`);
|
|
33
|
-
const checkResult =
|
|
24
|
+
const checkResult = installMethod === undefined
|
|
34
25
|
? await upgradeService.refreshUpgradeCheckCache()
|
|
35
|
-
: await upgradeService.checkForUpgrade(
|
|
26
|
+
: await upgradeService.checkForUpgrade(installMethod);
|
|
36
27
|
await printerService.hideSpinner();
|
|
37
28
|
if (checkResult.status === "unsupported") {
|
|
38
|
-
await printerService.error(`No upgrade location is configured for the detected
|
|
29
|
+
await printerService.error(`No upgrade location is configured for the detected platform.\n`, Icon.FAILURE);
|
|
39
30
|
return;
|
|
40
31
|
}
|
|
41
32
|
if (checkResult.status === "failed") {
|
|
@@ -46,7 +37,7 @@ export class UpgradeSubCommand {
|
|
|
46
37
|
await printerService.print(`${cliName} is already up to date: ${checkResult.currentVersion}\n`, Icon.INFORMATION);
|
|
47
38
|
return;
|
|
48
39
|
}
|
|
49
|
-
const upgradeResult = await upgradeService.upgrade(
|
|
40
|
+
const upgradeResult = await upgradeService.upgrade(installMethod);
|
|
50
41
|
if (!upgradeResult.ok) {
|
|
51
42
|
await printerService.error(`Failed to upgrade ${cliName}: ${upgradeResult.error?.message ?? "unknown error"}\n`, Icon.FAILURE);
|
|
52
43
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowscripter/dynamic-cli-framework",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.1",
|
|
4
4
|
"description": "A framework for developing CLI applications which supports dynamic discovery and installation of new commands",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"build": "tsc -p tsconfig.build.json"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@flowscripter/dynamic-cli-framework-api": "^
|
|
52
|
+
"@flowscripter/dynamic-cli-framework-api": "^5.0.0",
|
|
53
53
|
"@flowscripter/dynamic-plugin-framework": "^2.2.16",
|
|
54
54
|
"emphasize": "^7.0.0",
|
|
55
55
|
"fastest-levenshtein": "^1.0.16",
|
|
@@ -436,13 +436,9 @@ export default class DefaultUpgradeService implements UpgradeService {
|
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
-
public async checkForUpgrade(
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
installMethodOverride?: InstallMethod,
|
|
443
|
-
): Promise<UpgradeCheckResult> {
|
|
444
|
-
const os = osOverride ?? this.detectOs();
|
|
445
|
-
const arch = archOverride ?? this.detectArch();
|
|
439
|
+
public async checkForUpgrade(installMethodOverride?: InstallMethod): Promise<UpgradeCheckResult> {
|
|
440
|
+
const os = this.detectOs();
|
|
441
|
+
const arch = this.detectArch();
|
|
446
442
|
if (!os || !arch || !this.#isPlatformSupported(os, arch)) {
|
|
447
443
|
return { status: "unsupported" };
|
|
448
444
|
}
|
|
@@ -480,22 +476,17 @@ export default class DefaultUpgradeService implements UpgradeService {
|
|
|
480
476
|
};
|
|
481
477
|
}
|
|
482
478
|
|
|
483
|
-
public async upgrade(
|
|
484
|
-
osOverride?: SupportedOs,
|
|
485
|
-
archOverride?: SupportedArch,
|
|
486
|
-
installMethodOverride?: InstallMethod,
|
|
487
|
-
): Promise<UpgradeResult> {
|
|
479
|
+
public async upgrade(installMethodOverride?: InstallMethod): Promise<UpgradeResult> {
|
|
488
480
|
const oldVersion = this.#cliConfig.version;
|
|
489
|
-
const
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
: await this.getUpgradeCheckResult();
|
|
481
|
+
const checkResult =
|
|
482
|
+
installMethodOverride !== undefined
|
|
483
|
+
? await this.checkForUpgrade(installMethodOverride)
|
|
484
|
+
: await this.getUpgradeCheckResult();
|
|
494
485
|
if (checkResult.status === "unsupported") {
|
|
495
486
|
return {
|
|
496
487
|
ok: false,
|
|
497
488
|
oldVersion,
|
|
498
|
-
error: new Error("No upgrade location configured for the detected
|
|
489
|
+
error: new Error("No upgrade location configured for the detected platform"),
|
|
499
490
|
};
|
|
500
491
|
}
|
|
501
492
|
if (checkResult.status === "failed") {
|
|
@@ -521,7 +512,7 @@ export default class DefaultUpgradeService implements UpgradeService {
|
|
|
521
512
|
await this.#upgradeViaLinuxScript();
|
|
522
513
|
break;
|
|
523
514
|
case InstallMethod.HOMEBREW:
|
|
524
|
-
await this.#upgradeViaHomebrew();
|
|
515
|
+
await this.#upgradeViaHomebrew(checkResult.latestVersion);
|
|
525
516
|
break;
|
|
526
517
|
case InstallMethod.WINGET:
|
|
527
518
|
await this.#upgradeViaWinget();
|
|
@@ -734,12 +725,33 @@ export default class DefaultUpgradeService implements UpgradeService {
|
|
|
734
725
|
}
|
|
735
726
|
}
|
|
736
727
|
|
|
737
|
-
|
|
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> {
|
|
738
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
|
+
}
|
|
739
737
|
const result = await this.#spawnQuoted(["brew", "upgrade", `${tap}/${formula}`]);
|
|
740
738
|
if (!result.ok) {
|
|
741
739
|
throw new Error(`brew upgrade failed: ${describeSpawnFailure(result)}`);
|
|
742
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
|
+
}
|
|
743
755
|
}
|
|
744
756
|
|
|
745
757
|
async #upgradeViaWinget(): Promise<void> {
|
|
@@ -6,8 +6,6 @@ import {
|
|
|
6
6
|
Icon,
|
|
7
7
|
InstallMethod,
|
|
8
8
|
PRINTER_SERVICE_ID,
|
|
9
|
-
SupportedArch,
|
|
10
|
-
SupportedOs,
|
|
11
9
|
UPGRADE_SERVICE_ID,
|
|
12
10
|
} from "@flowscripter/dynamic-cli-framework-api";
|
|
13
11
|
import type { PrinterService } from "@flowscripter/dynamic-cli-framework-api";
|
|
@@ -20,13 +18,6 @@ export class UpgradeSubCommand implements SubCommand {
|
|
|
20
18
|
readonly positionals = [];
|
|
21
19
|
|
|
22
20
|
readonly options: ReadonlyArray<Option> = [
|
|
23
|
-
{
|
|
24
|
-
name: "os",
|
|
25
|
-
type: ValueTypeName.STRING,
|
|
26
|
-
isOptional: true,
|
|
27
|
-
allowableValues: Object.values(SupportedOs),
|
|
28
|
-
description: "Override the detected operating system",
|
|
29
|
-
},
|
|
30
21
|
{
|
|
31
22
|
name: "install-method",
|
|
32
23
|
type: ValueTypeName.STRING,
|
|
@@ -42,21 +33,19 @@ export class UpgradeSubCommand implements SubCommand {
|
|
|
42
33
|
const cliName = context.cliConfig.name;
|
|
43
34
|
const currentVersion = context.cliConfig.version;
|
|
44
35
|
|
|
45
|
-
const os = argumentValues.os as SupportedOs | undefined;
|
|
46
|
-
const arch = undefined as SupportedArch | undefined;
|
|
47
36
|
const installMethod = argumentValues["install-method"] as InstallMethod | undefined;
|
|
48
37
|
|
|
49
38
|
await printerService.showSpinner(`Looking for version newer than ${currentVersion}`);
|
|
50
39
|
|
|
51
40
|
const checkResult =
|
|
52
|
-
|
|
41
|
+
installMethod === undefined
|
|
53
42
|
? await upgradeService.refreshUpgradeCheckCache()
|
|
54
|
-
: await upgradeService.checkForUpgrade(
|
|
43
|
+
: await upgradeService.checkForUpgrade(installMethod);
|
|
55
44
|
|
|
56
45
|
await printerService.hideSpinner();
|
|
57
46
|
if (checkResult.status === "unsupported") {
|
|
58
47
|
await printerService.error(
|
|
59
|
-
`No upgrade location is configured for the detected
|
|
48
|
+
`No upgrade location is configured for the detected platform.\n`,
|
|
60
49
|
Icon.FAILURE,
|
|
61
50
|
);
|
|
62
51
|
return;
|
|
@@ -78,7 +67,7 @@ export class UpgradeSubCommand implements SubCommand {
|
|
|
78
67
|
return;
|
|
79
68
|
}
|
|
80
69
|
|
|
81
|
-
const upgradeResult = await upgradeService.upgrade(
|
|
70
|
+
const upgradeResult = await upgradeService.upgrade(installMethod);
|
|
82
71
|
if (!upgradeResult.ok) {
|
|
83
72
|
await printerService.error(
|
|
84
73
|
`Failed to upgrade ${cliName}: ${upgradeResult.error?.message ?? "unknown error"}\n`,
|