@flowscripter/dynamic-cli-framework 7.1.2 → 8.0.0
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/prettyPrinter/DefaultPrettyPrinterService.d.ts +4 -2
- package/dist/src/service/prettyPrinter/DefaultPrettyPrinterService.d.ts.map +1 -1
- package/dist/src/service/prettyPrinter/DefaultPrettyPrinterService.js +16 -28
- package/dist/src/service/prompter/prompt/promptOpenUrl.d.ts.map +1 -1
- package/dist/src/service/prompter/prompt/promptOpenUrl.js +2 -3
- package/dist/src/service/upgrade/DefaultUpgradeService.d.ts.map +1 -1
- package/dist/src/service/upgrade/DefaultUpgradeService.js +29 -20
- package/package.json +2 -1
- package/src/service/prettyPrinter/DefaultPrettyPrinterService.ts +17 -34
- package/src/service/prompter/prompt/promptOpenUrl.ts +2 -3
- package/src/service/upgrade/DefaultUpgradeService.ts +31 -18
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { PrettyPrinterService } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
2
|
import type { Plugin } from "prettier";
|
|
3
3
|
/**
|
|
4
|
-
* Default implementation of {@link PrettyPrinterService} which provides by default
|
|
5
|
-
*
|
|
4
|
+
* Default implementation of {@link PrettyPrinterService} which provides JSON by default.
|
|
5
|
+
*
|
|
6
|
+
* Only prettier's babel and estree plugins are bundled, which provide the JSON parser and printer.
|
|
7
|
+
* Other syntaxes are added with {@link registerSyntax}.
|
|
6
8
|
*/
|
|
7
9
|
export default class DefaultPrettyPrinterService implements PrettyPrinterService {
|
|
8
10
|
#private;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultPrettyPrinterService.d.ts","sourceRoot":"","sources":["../../../../src/service/prettyPrinter/DefaultPrettyPrinterService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAEpF,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"DefaultPrettyPrinterService.d.ts","sourceRoot":"","sources":["../../../../src/service/prettyPrinter/DefaultPrettyPrinterService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAEpF,OAAO,KAAK,EAAW,MAAM,EAAE,MAAM,UAAU,CAAC;AAIhD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,2BAA4B,YAAW,oBAAoB;;IAI9E,qBAAqB,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAEtD;IAEK,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAShE;IAED,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAS/E;CACF"}
|
|
@@ -1,45 +1,33 @@
|
|
|
1
|
-
import * as prettier from "prettier";
|
|
1
|
+
import * as prettier from "prettier/standalone";
|
|
2
|
+
import * as babel from "prettier/plugins/babel";
|
|
3
|
+
import * as estree from "prettier/plugins/estree";
|
|
2
4
|
/**
|
|
3
|
-
* Default implementation of {@link PrettyPrinterService} which provides by default
|
|
4
|
-
*
|
|
5
|
+
* Default implementation of {@link PrettyPrinterService} which provides JSON by default.
|
|
6
|
+
*
|
|
7
|
+
* Only prettier's babel and estree plugins are bundled, which provide the JSON parser and printer.
|
|
8
|
+
* Other syntaxes are added with {@link registerSyntax}.
|
|
5
9
|
*/
|
|
6
10
|
export default class DefaultPrettyPrinterService {
|
|
7
|
-
#registeredSyntaxes =
|
|
8
|
-
#
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.#registeredSyntaxes = languages.map((language) => language.name.toLowerCase());
|
|
12
|
-
}
|
|
13
|
-
async getRegisteredSyntaxes() {
|
|
14
|
-
if (this.#registeredSyntaxes.length === 0) {
|
|
15
|
-
await this.#populateBuiltInSyntaxes();
|
|
16
|
-
}
|
|
17
|
-
return this.#registeredSyntaxes;
|
|
11
|
+
#registeredSyntaxes = ["json"];
|
|
12
|
+
#plugins = [babel, estree];
|
|
13
|
+
getRegisteredSyntaxes() {
|
|
14
|
+
return Promise.resolve(this.#registeredSyntaxes);
|
|
18
15
|
}
|
|
19
16
|
async prettify(text, syntaxName) {
|
|
20
|
-
if (this.#registeredSyntaxes.length === 0) {
|
|
21
|
-
await this.#populateBuiltInSyntaxes();
|
|
22
|
-
}
|
|
23
17
|
const name = syntaxName.toLowerCase();
|
|
24
18
|
if (!this.#registeredSyntaxes.includes(name)) {
|
|
25
19
|
throw new Error(`Syntax name is not registered: ${name}`);
|
|
26
20
|
}
|
|
27
|
-
const options = { parser: syntaxName };
|
|
28
|
-
const syntaxPlugin = this.#syntaxNameToPluginnMap.get(name);
|
|
29
|
-
if (syntaxPlugin) {
|
|
30
|
-
options.plugins = [syntaxPlugin];
|
|
31
|
-
}
|
|
21
|
+
const options = { parser: syntaxName, plugins: this.#plugins };
|
|
32
22
|
return prettier.format(text, options);
|
|
33
23
|
}
|
|
34
|
-
|
|
35
|
-
if (this.#registeredSyntaxes.length === 0) {
|
|
36
|
-
await this.#populateBuiltInSyntaxes();
|
|
37
|
-
}
|
|
24
|
+
registerSyntax(syntaxName, syntaxPlugin) {
|
|
38
25
|
const name = syntaxName.toLowerCase();
|
|
39
26
|
if (this.#registeredSyntaxes.includes(name)) {
|
|
40
|
-
|
|
27
|
+
return Promise.reject(new Error(`Syntax name already registered: ${name}`));
|
|
41
28
|
}
|
|
42
29
|
this.#registeredSyntaxes.push(name);
|
|
43
|
-
this.#
|
|
30
|
+
this.#plugins.push(syntaxPlugin);
|
|
31
|
+
return Promise.resolve();
|
|
44
32
|
}
|
|
45
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promptOpenUrl.d.ts","sourceRoot":"","sources":["../../../../../src/service/prompter/prompt/promptOpenUrl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAGlG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMxD,wBAAsB,cAAc,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"promptOpenUrl.d.ts","sourceRoot":"","sources":["../../../../../src/service/prompter/prompt/promptOpenUrl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yCAAyC,CAAC;AAGlG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMxD,wBAAsB,cAAc,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB3F;AAED,wBAA8B,aAAa,CACzC,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,YAAY,CAAC,CAkDvB"}
|
|
@@ -8,12 +8,11 @@ export async function defaultOpenUrl(spawnService, url) {
|
|
|
8
8
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
9
9
|
throw new Error(`Unsupported URL protocol: ${parsed.protocol}`);
|
|
10
10
|
}
|
|
11
|
-
const platform = process.platform;
|
|
12
11
|
let cmd;
|
|
13
|
-
if (platform === "darwin") {
|
|
12
|
+
if (process.platform === "darwin") {
|
|
14
13
|
cmd = ["open", url];
|
|
15
14
|
}
|
|
16
|
-
else if (platform === "win32") {
|
|
15
|
+
else if (process.platform === "win32") {
|
|
17
16
|
cmd = ["cmd", "/c", "start", "", url];
|
|
18
17
|
}
|
|
19
18
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultUpgradeService.d.ts","sourceRoot":"","sources":["../../../../src/service/upgrade/D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AG,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,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;CA2TF"}
|
|
@@ -242,36 +242,41 @@ export default class DefaultUpgradeService {
|
|
|
242
242
|
return toRunState(result);
|
|
243
243
|
}
|
|
244
244
|
detectOs() {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
case "win32":
|
|
251
|
-
return SupportedOs.WINDOWS;
|
|
252
|
-
default:
|
|
253
|
-
return undefined;
|
|
245
|
+
if (process.platform === "linux") {
|
|
246
|
+
return SupportedOs.LINUX;
|
|
247
|
+
}
|
|
248
|
+
if (process.platform === "darwin") {
|
|
249
|
+
return SupportedOs.MACOS;
|
|
254
250
|
}
|
|
251
|
+
if (process.platform === "win32") {
|
|
252
|
+
return SupportedOs.WINDOWS;
|
|
253
|
+
}
|
|
254
|
+
return undefined;
|
|
255
255
|
}
|
|
256
256
|
detectArch() {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
default:
|
|
263
|
-
return undefined;
|
|
257
|
+
if (process.arch === "x64") {
|
|
258
|
+
return SupportedArch.X64;
|
|
259
|
+
}
|
|
260
|
+
if (process.arch === "arm64") {
|
|
261
|
+
return SupportedArch.ARM64;
|
|
264
262
|
}
|
|
263
|
+
return undefined;
|
|
265
264
|
}
|
|
266
265
|
async detectInstallMethod(os) {
|
|
267
266
|
// Cheap, no-spawn signals are checked first and always win over the cache below, so a fresh
|
|
268
267
|
// install is picked up immediately rather than waiting on a stale cached method.
|
|
269
|
-
|
|
268
|
+
// Each platform-specific branch also compares process.platform directly, so a compiled
|
|
269
|
+
// executable keeps only the branches for its own platform.
|
|
270
|
+
if (process.platform === "darwin" &&
|
|
271
|
+
os === SupportedOs.MACOS &&
|
|
270
272
|
this.#config.homebrew &&
|
|
271
273
|
this.#isRunningFromHomebrewCellar(this.#config.homebrew.formula)) {
|
|
272
274
|
return InstallMethod.HOMEBREW;
|
|
273
275
|
}
|
|
274
|
-
if (
|
|
276
|
+
if (process.platform === "linux" &&
|
|
277
|
+
os === SupportedOs.LINUX &&
|
|
278
|
+
this.#config.linuxScript &&
|
|
279
|
+
this.#isLinuxScriptInstall()) {
|
|
275
280
|
return InstallMethod.LINUX_SCRIPT;
|
|
276
281
|
}
|
|
277
282
|
// Everything else needs an external process spawn (`brew list`, `winget list`) to confirm -
|
|
@@ -281,10 +286,14 @@ export default class DefaultUpgradeService {
|
|
|
281
286
|
return cached;
|
|
282
287
|
}
|
|
283
288
|
let detected;
|
|
284
|
-
if (
|
|
289
|
+
if (process.platform === "darwin" &&
|
|
290
|
+
os === SupportedOs.MACOS &&
|
|
291
|
+
this.#config.homebrew &&
|
|
292
|
+
(await this.#isHomebrewInstalled())) {
|
|
285
293
|
detected = InstallMethod.HOMEBREW;
|
|
286
294
|
}
|
|
287
|
-
else if (
|
|
295
|
+
else if (process.platform === "win32" &&
|
|
296
|
+
os === SupportedOs.WINDOWS &&
|
|
288
297
|
this.#config.winget &&
|
|
289
298
|
(await this.#isWingetInstalled())) {
|
|
290
299
|
detected = InstallMethod.WINGET;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowscripter/dynamic-cli-framework",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "A framework for developing CLI applications which supports dynamic discovery and installation of new commands",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"LICENSE"
|
|
27
27
|
],
|
|
28
28
|
"type": "module",
|
|
29
|
+
"sideEffects": false,
|
|
29
30
|
"main": "dist/index.js",
|
|
30
31
|
"module": "dist/index.js",
|
|
31
32
|
"types": "dist/index.d.ts",
|
|
@@ -1,59 +1,42 @@
|
|
|
1
1
|
import type { PrettyPrinterService } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
|
-
import * as prettier from "prettier";
|
|
3
|
-
import type { Plugin } from "prettier";
|
|
2
|
+
import * as prettier from "prettier/standalone";
|
|
3
|
+
import type { Options, Plugin } from "prettier";
|
|
4
|
+
import * as babel from "prettier/plugins/babel";
|
|
5
|
+
import * as estree from "prettier/plugins/estree";
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
|
-
* Default implementation of {@link PrettyPrinterService} which provides by default
|
|
7
|
-
*
|
|
8
|
+
* Default implementation of {@link PrettyPrinterService} which provides JSON by default.
|
|
9
|
+
*
|
|
10
|
+
* Only prettier's babel and estree plugins are bundled, which provide the JSON parser and printer.
|
|
11
|
+
* Other syntaxes are added with {@link registerSyntax}.
|
|
8
12
|
*/
|
|
9
13
|
export default class DefaultPrettyPrinterService implements PrettyPrinterService {
|
|
10
|
-
#registeredSyntaxes =
|
|
11
|
-
#
|
|
14
|
+
readonly #registeredSyntaxes = ["json"];
|
|
15
|
+
readonly #plugins: Array<Plugin<unknown>> = [babel, estree as Plugin<unknown>];
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
this.#registeredSyntaxes = languages.map((language) => language.name.toLowerCase());
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async getRegisteredSyntaxes(): Promise<ReadonlyArray<string>> {
|
|
19
|
-
if (this.#registeredSyntaxes.length === 0) {
|
|
20
|
-
await this.#populateBuiltInSyntaxes();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return this.#registeredSyntaxes;
|
|
17
|
+
getRegisteredSyntaxes(): Promise<ReadonlyArray<string>> {
|
|
18
|
+
return Promise.resolve(this.#registeredSyntaxes);
|
|
24
19
|
}
|
|
25
20
|
|
|
26
21
|
async prettify(text: string, syntaxName: string): Promise<string> {
|
|
27
|
-
if (this.#registeredSyntaxes.length === 0) {
|
|
28
|
-
await this.#populateBuiltInSyntaxes();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
22
|
const name = syntaxName.toLowerCase();
|
|
32
23
|
if (!this.#registeredSyntaxes.includes(name)) {
|
|
33
24
|
throw new Error(`Syntax name is not registered: ${name}`);
|
|
34
25
|
}
|
|
35
26
|
|
|
36
|
-
const options:
|
|
37
|
-
|
|
38
|
-
const syntaxPlugin = this.#syntaxNameToPluginnMap.get(name);
|
|
39
|
-
if (syntaxPlugin) {
|
|
40
|
-
options.plugins = [syntaxPlugin];
|
|
41
|
-
}
|
|
27
|
+
const options: Options = { parser: syntaxName, plugins: this.#plugins };
|
|
42
28
|
|
|
43
29
|
return prettier.format(text, options);
|
|
44
30
|
}
|
|
45
31
|
|
|
46
|
-
|
|
47
|
-
if (this.#registeredSyntaxes.length === 0) {
|
|
48
|
-
await this.#populateBuiltInSyntaxes();
|
|
49
|
-
}
|
|
50
|
-
|
|
32
|
+
registerSyntax(syntaxName: string, syntaxPlugin: Plugin<unknown>): Promise<void> {
|
|
51
33
|
const name = syntaxName.toLowerCase();
|
|
52
34
|
if (this.#registeredSyntaxes.includes(name)) {
|
|
53
|
-
|
|
35
|
+
return Promise.reject(new Error(`Syntax name already registered: ${name}`));
|
|
54
36
|
}
|
|
55
37
|
|
|
56
38
|
this.#registeredSyntaxes.push(name);
|
|
57
|
-
this.#
|
|
39
|
+
this.#plugins.push(syntaxPlugin);
|
|
40
|
+
return Promise.resolve();
|
|
58
41
|
}
|
|
59
42
|
}
|
|
@@ -12,11 +12,10 @@ export async function defaultOpenUrl(spawnService: SpawnService, url: string): P
|
|
|
12
12
|
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
13
13
|
throw new Error(`Unsupported URL protocol: ${parsed.protocol}`);
|
|
14
14
|
}
|
|
15
|
-
const platform = process.platform;
|
|
16
15
|
let cmd: string[];
|
|
17
|
-
if (platform === "darwin") {
|
|
16
|
+
if (process.platform === "darwin") {
|
|
18
17
|
cmd = ["open", url];
|
|
19
|
-
} else if (platform === "win32") {
|
|
18
|
+
} else if (process.platform === "win32") {
|
|
20
19
|
cmd = ["cmd", "/c", "start", "", url];
|
|
21
20
|
} else {
|
|
22
21
|
cmd = ["xdg-open", url];
|
|
@@ -319,40 +319,47 @@ export default class DefaultUpgradeService implements UpgradeService {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
public detectOs(): SupportedOs | undefined {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
case "win32":
|
|
328
|
-
return SupportedOs.WINDOWS;
|
|
329
|
-
default:
|
|
330
|
-
return undefined;
|
|
322
|
+
if (process.platform === "linux") {
|
|
323
|
+
return SupportedOs.LINUX;
|
|
324
|
+
}
|
|
325
|
+
if (process.platform === "darwin") {
|
|
326
|
+
return SupportedOs.MACOS;
|
|
331
327
|
}
|
|
328
|
+
if (process.platform === "win32") {
|
|
329
|
+
return SupportedOs.WINDOWS;
|
|
330
|
+
}
|
|
331
|
+
return undefined;
|
|
332
332
|
}
|
|
333
333
|
|
|
334
334
|
public detectArch(): SupportedArch | undefined {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
default:
|
|
341
|
-
return undefined;
|
|
335
|
+
if (process.arch === "x64") {
|
|
336
|
+
return SupportedArch.X64;
|
|
337
|
+
}
|
|
338
|
+
if (process.arch === "arm64") {
|
|
339
|
+
return SupportedArch.ARM64;
|
|
342
340
|
}
|
|
341
|
+
return undefined;
|
|
343
342
|
}
|
|
344
343
|
|
|
345
344
|
public async detectInstallMethod(os: SupportedOs): Promise<InstallMethod | undefined> {
|
|
346
345
|
// Cheap, no-spawn signals are checked first and always win over the cache below, so a fresh
|
|
347
346
|
// install is picked up immediately rather than waiting on a stale cached method.
|
|
347
|
+
// Each platform-specific branch also compares process.platform directly, so a compiled
|
|
348
|
+
// executable keeps only the branches for its own platform.
|
|
348
349
|
if (
|
|
350
|
+
process.platform === "darwin" &&
|
|
349
351
|
os === SupportedOs.MACOS &&
|
|
350
352
|
this.#config.homebrew &&
|
|
351
353
|
this.#isRunningFromHomebrewCellar(this.#config.homebrew.formula)
|
|
352
354
|
) {
|
|
353
355
|
return InstallMethod.HOMEBREW;
|
|
354
356
|
}
|
|
355
|
-
if (
|
|
357
|
+
if (
|
|
358
|
+
process.platform === "linux" &&
|
|
359
|
+
os === SupportedOs.LINUX &&
|
|
360
|
+
this.#config.linuxScript &&
|
|
361
|
+
this.#isLinuxScriptInstall()
|
|
362
|
+
) {
|
|
356
363
|
return InstallMethod.LINUX_SCRIPT;
|
|
357
364
|
}
|
|
358
365
|
|
|
@@ -364,9 +371,15 @@ export default class DefaultUpgradeService implements UpgradeService {
|
|
|
364
371
|
}
|
|
365
372
|
|
|
366
373
|
let detected: InstallMethod | undefined;
|
|
367
|
-
if (
|
|
374
|
+
if (
|
|
375
|
+
process.platform === "darwin" &&
|
|
376
|
+
os === SupportedOs.MACOS &&
|
|
377
|
+
this.#config.homebrew &&
|
|
378
|
+
(await this.#isHomebrewInstalled())
|
|
379
|
+
) {
|
|
368
380
|
detected = InstallMethod.HOMEBREW;
|
|
369
381
|
} else if (
|
|
382
|
+
process.platform === "win32" &&
|
|
370
383
|
os === SupportedOs.WINDOWS &&
|
|
371
384
|
this.#config.winget &&
|
|
372
385
|
(await this.#isWingetInstalled())
|