@flowscripter/dynamic-cli-framework 7.1.3 → 8.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/runtime/values/subCommandValuePopulation.d.ts.map +1 -1
- package/dist/src/runtime/values/subCommandValuePopulation.js +2 -2
- 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/package.json +2 -1
- package/src/runtime/values/subCommandValuePopulation.ts +2 -3
- package/src/service/prettyPrinter/DefaultPrettyPrinterService.ts +17 -34
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subCommandValuePopulation.d.ts","sourceRoot":"","sources":["../../../../src/runtime/values/subCommandValuePopulation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"subCommandValuePopulation.d.ts","sourceRoot":"","sources":["../../../../src/runtime/values/subCommandValuePopulation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAsjBlF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAC9C,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,CAAC,MAAM,CAAC,EACpC,aAAa,EAAE,eAAe,GAAG,SAAS,GACzC,+BAA+B,CAkEjC"}
|
|
@@ -131,6 +131,7 @@ class ParseContext {
|
|
|
131
131
|
const complexAndArrayPathElements = [];
|
|
132
132
|
let option = undefined;
|
|
133
133
|
let currentValue = this.populatedArgumentValues;
|
|
134
|
+
let lookupPath = this.subCommand.name;
|
|
134
135
|
for (let i = 0; i < complexPathElements.length; i++) {
|
|
135
136
|
let arrayIndexString;
|
|
136
137
|
let complexPathElement = complexPathElements[i];
|
|
@@ -140,7 +141,6 @@ class ParseContext {
|
|
|
140
141
|
.slice(0, complexPathElement.length - 1)
|
|
141
142
|
.split("[");
|
|
142
143
|
}
|
|
143
|
-
let lookupPath = this.subCommand.name;
|
|
144
144
|
// root option navigation
|
|
145
145
|
if (i === 0) {
|
|
146
146
|
if (complexPathElement.startsWith("--")) {
|
|
@@ -164,7 +164,7 @@ class ParseContext {
|
|
|
164
164
|
complexPathElement = option.name;
|
|
165
165
|
} // complex option property navigation
|
|
166
166
|
else {
|
|
167
|
-
lookupPath = `${lookupPath}
|
|
167
|
+
lookupPath = `${lookupPath}.${option.name}`;
|
|
168
168
|
// lazy creation of nested option paths to options
|
|
169
169
|
if (!this.optionLookupMapsByPath.has(lookupPath)) {
|
|
170
170
|
const properties = option.properties;
|
|
@@ -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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowscripter/dynamic-cli-framework",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.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",
|
|
@@ -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",
|
|
@@ -168,6 +168,7 @@ class ParseContext {
|
|
|
168
168
|
| PopulatedValueType
|
|
169
169
|
| undefined = this.populatedArgumentValues;
|
|
170
170
|
|
|
171
|
+
let lookupPath = this.subCommand.name;
|
|
171
172
|
for (let i = 0; i < complexPathElements.length; i++) {
|
|
172
173
|
let arrayIndexString: string | undefined;
|
|
173
174
|
let complexPathElement = complexPathElements[i]!;
|
|
@@ -179,8 +180,6 @@ class ParseContext {
|
|
|
179
180
|
.split("[") as [string, string | undefined];
|
|
180
181
|
}
|
|
181
182
|
|
|
182
|
-
let lookupPath = this.subCommand.name;
|
|
183
|
-
|
|
184
183
|
// root option navigation
|
|
185
184
|
if (i === 0) {
|
|
186
185
|
if (complexPathElement.startsWith("--")) {
|
|
@@ -205,7 +204,7 @@ class ParseContext {
|
|
|
205
204
|
complexPathElement = option.name;
|
|
206
205
|
} // complex option property navigation
|
|
207
206
|
else {
|
|
208
|
-
lookupPath = `${lookupPath}
|
|
207
|
+
lookupPath = `${lookupPath}.${option!.name}`;
|
|
209
208
|
|
|
210
209
|
// lazy creation of nested option paths to options
|
|
211
210
|
if (!this.optionLookupMapsByPath.has(lookupPath)) {
|
|
@@ -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
|
}
|