@shell-shock/core 0.8.13 → 0.9.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/api.cjs +34 -0
- package/dist/api.cjs.map +1 -1
- package/dist/api.mjs +34 -0
- package/dist/api.mjs.map +1 -1
- package/dist/components/docs.d.cts +5 -5
- package/dist/components/docs.d.cts.map +1 -1
- package/dist/components/docs.d.mts +5 -5
- package/dist/components/helpers.d.cts +6 -6
- package/dist/components/helpers.d.mts +6 -6
- package/dist/components/index.cjs +1 -0
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.mts +2 -2
- package/dist/components/index.mjs +2 -2
- package/dist/components/options-parser-logic.d.cts +9 -9
- package/dist/components/options-parser-logic.d.mts +9 -9
- package/dist/components/usage.d.cts +2 -2
- package/dist/components/usage.d.cts.map +1 -1
- package/dist/components/usage.d.mts +2 -2
- package/dist/components/utils-builtin.cjs +341 -0
- package/dist/components/utils-builtin.cjs.map +1 -1
- package/dist/components/utils-builtin.d.cts +12 -8
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts +12 -8
- package/dist/components/utils-builtin.d.mts.map +1 -1
- package/dist/components/utils-builtin.mjs +342 -2
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/config.cjs +12 -0
- package/dist/config.cjs.map +1 -1
- package/dist/config.mjs +12 -0
- package/dist/config.mjs.map +1 -1
- package/dist/contexts/command.cjs +3 -2
- package/dist/contexts/command.cjs.map +1 -1
- package/dist/contexts/command.mjs +3 -2
- package/dist/contexts/command.mjs.map +1 -1
- package/dist/contexts/options.cjs +20 -4
- package/dist/contexts/options.cjs.map +1 -1
- package/dist/contexts/options.mjs +20 -4
- package/dist/contexts/options.mjs.map +1 -1
- package/dist/helpers/docs-helpers.cjs +6 -0
- package/dist/helpers/docs-helpers.cjs.map +1 -1
- package/dist/helpers/docs-helpers.mjs +6 -0
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +92 -11
- package/dist/helpers/persistence.cjs.map +1 -1
- package/dist/helpers/persistence.mjs +92 -11
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/resolve-command.cjs +200 -18
- package/dist/helpers/resolve-command.cjs.map +1 -1
- package/dist/helpers/resolve-command.mjs +201 -19
- package/dist/helpers/resolve-command.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +27 -3
- package/dist/helpers/update-package-json.cjs.map +1 -1
- package/dist/helpers/update-package-json.mjs +27 -3
- package/dist/helpers/update-package-json.mjs.map +1 -1
- package/dist/helpers/utilities.cjs +58 -4
- package/dist/helpers/utilities.cjs.map +1 -1
- package/dist/helpers/utilities.mjs +58 -4
- package/dist/helpers/utilities.mjs.map +1 -1
- package/dist/helpers/validations.cjs +28 -1
- package/dist/helpers/validations.cjs.map +1 -1
- package/dist/helpers/validations.mjs +28 -1
- package/dist/helpers/validations.mjs.map +1 -1
- package/dist/index.cjs +33 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +6 -1
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-utils/context-helpers.cjs +78 -3
- package/dist/plugin-utils/context-helpers.cjs.map +1 -1
- package/dist/plugin-utils/context-helpers.mjs +78 -3
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/dist/plugin-utils/get-command-tree.cjs +17 -1
- package/dist/plugin-utils/get-command-tree.cjs.map +1 -1
- package/dist/plugin-utils/get-command-tree.mjs +17 -1
- package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/reflect.cjs +31 -3
- package/dist/plugin-utils/reflect.cjs.map +1 -1
- package/dist/plugin-utils/reflect.mjs +31 -3
- package/dist/plugin-utils/reflect.mjs.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.cjs +34 -4
- package/dist/plugin-utils/traverse-command-tree.cjs.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.mjs +34 -4
- package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
- package/dist/plugin.cjs +5 -1
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +5 -1
- package/dist/plugin.mjs.map +1 -1
- package/dist/types/command.cjs +241 -0
- package/dist/types/command.cjs.map +1 -0
- package/dist/types/command.mjs +221 -1
- package/dist/types/command.mjs.map +1 -0
- package/dist/types/config.cjs +114 -0
- package/dist/types/config.cjs.map +1 -0
- package/dist/types/config.d.cts +11 -10
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +11 -10
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +110 -1
- package/dist/types/config.mjs.map +1 -0
- package/dist/types/context.cjs +33 -0
- package/dist/types/context.cjs.map +1 -0
- package/dist/types/context.mjs +31 -1
- package/dist/types/context.mjs.map +1 -0
- package/dist/types/env.cjs +12 -0
- package/dist/types/env.cjs.map +1 -0
- package/dist/types/env.d.cts +17 -0
- package/dist/types/env.d.cts.map +1 -0
- package/dist/types/env.d.mts +17 -0
- package/dist/types/env.d.mts.map +1 -0
- package/dist/types/env.mjs +11 -0
- package/dist/types/env.mjs.map +1 -0
- package/dist/types/index.cjs +34 -0
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.mjs +7 -1
- package/dist/types/options.cjs +12 -0
- package/dist/types/options.cjs.map +1 -0
- package/dist/types/options.mjs +11 -1
- package/dist/types/options.mjs.map +1 -0
- package/dist/types/runtime.cjs +12 -0
- package/dist/types/runtime.cjs.map +1 -0
- package/dist/types/runtime.mjs +11 -1
- package/dist/types/runtime.mjs.map +1 -0
- package/package.json +25 -11
|
@@ -4,15 +4,16 @@ import { createNamedContext, useContext } from "@alloy-js/core";
|
|
|
4
4
|
/**
|
|
5
5
|
* The reflection parameter context used in template rendering.
|
|
6
6
|
*/
|
|
7
|
-
const CommandContext = createNamedContext("Command");
|
|
7
|
+
const CommandContext = (createNamedContext.Ω = [["CommandTree", "P\"w!-J"]], createNamedContext("Command"));
|
|
8
8
|
/**
|
|
9
9
|
* Hook to access the Command context.
|
|
10
10
|
*
|
|
11
11
|
* @returns A reactive version of the current reflection.
|
|
12
12
|
*/
|
|
13
13
|
function useCommand() {
|
|
14
|
-
return useContext(CommandContext);
|
|
14
|
+
return useContext.Ω = [["CommandTree", "P\"w!-J"]], useContext(CommandContext);
|
|
15
15
|
}
|
|
16
|
+
useCommand.__type = ["useCommand", "P\"/!"];
|
|
16
17
|
|
|
17
18
|
//#endregion
|
|
18
19
|
export { CommandContext, useCommand };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.mjs","names":[
|
|
1
|
+
{"version":3,"file":"command.mjs","names":[],"sources":["../../src/contexts/command.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ComponentContext } from \"@alloy-js/core\";\nimport { createNamedContext, useContext } from \"@alloy-js/core\";\nimport type { CommandTree } from \"../types/command\";\n\n/**\n * The reflection parameter context used in template rendering.\n */\nexport const CommandContext: ComponentContext<CommandTree | undefined> =\n createNamedContext<CommandTree | undefined>(\"Command\");\n\n/**\n * Hook to access the Command context.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useCommand() {\n return useContext<CommandTree | undefined>(CommandContext)!;\n}\n"],"mappings":";;;;;;;;;;;;;AA4BE,QAAA,WAAA,IAAA,CAAA,CAAA,eAAA,UAAA,CAAA,EAAA,WAAA,eAAA;;AAEF,WAAC,SAAA,CAAA,cAAA,QAAA"}
|
|
@@ -7,10 +7,14 @@ let __alloy_js_core = require("@alloy-js/core");
|
|
|
7
7
|
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
8
8
|
|
|
9
9
|
//#region src/contexts/options.ts
|
|
10
|
+
function __assignType(fn, args) {
|
|
11
|
+
fn.__type = args;
|
|
12
|
+
return fn;
|
|
13
|
+
}
|
|
10
14
|
/**
|
|
11
15
|
* The reflection parameter context used in template rendering.
|
|
12
16
|
*/
|
|
13
|
-
const ExistingOptionsContext = (0, __alloy_js_core.createNamedContext)("ExistingOptions", []);
|
|
17
|
+
const ExistingOptionsContext = (__alloy_js_core.createNamedContext.Ω = [["&F"]], (0, __alloy_js_core.createNamedContext)("ExistingOptions", []));
|
|
14
18
|
/**
|
|
15
19
|
* Hook to access the ExistingOptions context.
|
|
16
20
|
*
|
|
@@ -20,10 +24,11 @@ const ExistingOptionsContext = (0, __alloy_js_core.createNamedContext)("Existing
|
|
|
20
24
|
* @returns A reactive version of the current reflection.
|
|
21
25
|
*/
|
|
22
26
|
function useExistingOptions() {
|
|
23
|
-
return (0, __alloy_js_core.useContext)(ExistingOptionsContext);
|
|
27
|
+
return __alloy_js_core.useContext.Ω = [["&F"]], (0, __alloy_js_core.useContext)(ExistingOptionsContext);
|
|
24
28
|
}
|
|
29
|
+
useExistingOptions.__type = ["useExistingOptions", "P\"/!"];
|
|
25
30
|
function computedOptions(command) {
|
|
26
|
-
return Object.entries(command.options).reduce((ret, [name, option]) => {
|
|
31
|
+
return Object.entries(command.options).reduce(__assignType((ret, [name, option]) => {
|
|
27
32
|
ret[(0, __stryke_string_format_camel_case.camelCase)(name)] ??= (0, defu.default)({ name: (0, __stryke_string_format_camel_case.camelCase)(name) }, ret[name] ?? {}, option);
|
|
28
33
|
if (option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.boolean && option.isNegativeOf) ret[(0, __stryke_string_format_camel_case.camelCase)(option.isNegativeOf)] = (0, defu.default)({ name: (0, __stryke_string_format_camel_case.camelCase)(option.isNegativeOf) }, ret[option.isNegativeOf] ?? {}, {
|
|
29
34
|
...option,
|
|
@@ -33,8 +38,19 @@ function computedOptions(command) {
|
|
|
33
38
|
default: !option.default
|
|
34
39
|
});
|
|
35
40
|
return ret;
|
|
36
|
-
},
|
|
41
|
+
}, [
|
|
42
|
+
"ret",
|
|
43
|
+
"param1",
|
|
44
|
+
"",
|
|
45
|
+
"P\"2!\"2\"\"/#"
|
|
46
|
+
]), {});
|
|
37
47
|
}
|
|
48
|
+
computedOptions.__type = [
|
|
49
|
+
"CommandTree",
|
|
50
|
+
"command",
|
|
51
|
+
"computedOptions",
|
|
52
|
+
"P\"w!2\"\"/#"
|
|
53
|
+
];
|
|
38
54
|
|
|
39
55
|
//#endregion
|
|
40
56
|
exports.ExistingOptionsContext = ExistingOptionsContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.cjs","names":[
|
|
1
|
+
{"version":3,"file":"options.cjs","names":[],"sources":["../../src/contexts/options.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ComponentContext } from \"@alloy-js/core\";\nimport { createNamedContext, useContext } from \"@alloy-js/core\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport type {\n BooleanCommandOption,\n CommandOption,\n CommandTree\n} from \"../types\";\n\n/**\n * The reflection parameter context used in template rendering.\n */\nexport const ExistingOptionsContext: ComponentContext<string[]> =\n createNamedContext<string[]>(\"ExistingOptions\", []);\n\n/**\n * Hook to access the ExistingOptions context.\n *\n * @remarks\n * This context provides a list of option names that already exist on the interface definition.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useExistingOptions() {\n return useContext<string[]>(ExistingOptionsContext)!;\n}\n\nexport function computedOptions(command: CommandTree) {\n return Object.entries(command.options).reduce(\n (ret, [name, option]) => {\n ret[camelCase(name)] ??= defu(\n {\n name: camelCase(name)\n },\n ret[name] ?? {},\n option\n ) as CommandOption;\n\n if (option.kind === ReflectionKind.boolean && option.isNegativeOf) {\n ret[camelCase(option.isNegativeOf)] = defu(\n {\n name: camelCase(option.isNegativeOf)\n },\n ret[option.isNegativeOf] ?? {},\n {\n ...option,\n env: isSetString(option.env) ? `NO_${option.env}` : false,\n description: `${option.description.replace(\n /\\.+$/,\n \"\"\n )}. This property is the negative form of ${name}.`,\n isNegativeOf: camelCase(name),\n default: !option.default\n }\n ) as BooleanCommandOption;\n }\n\n return ret;\n },\n {} as Record<string, CommandOption>\n );\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;AAUX,MAAa,0BAA0B,mCAAmB,IAAC,CAAA,CAAA,KAAA,CAAA,0CAAA,mBAAA,EAAA,CAAA;;;;;;;;;AAS3D,SAAgB,qBAAqB;AACjC,QAAQ,2BAAW,IAAI,CAAC,CAAC,KAAK,CAAC,kCAAa,uBAAe;;AAE/D,mBAAY,SAAA,CAAA,sBAAA,QAAA;AACZ,SAAgB,gBAAM,SAAA;AAClB,QAAO,OAAI,QAAA,QAAA,QAAA,CAAA,OAAA,cAAA,KAAA,CAAA,MAAA,YAAA;AACP,uDAAI,KAAA,wBAAA,EACA,uDAAK,KAAA;AAEf,MAAA,OAAA,SAAA,gDAAA,WAAA,OAAA,aACU,sDAAc,OAAO,aAAa,sBAAS,EACrD,uDAAA,OAAA,aAAA,EACW,EAAE,IAAI,OAAO,iBAAiB,EAAE,EAAE;GAC/B,GAAG;;GAEjB,aAAA,GAAA,OAAA,YAAA,QAAA,QAAA,GAAA,CAAA,0CAAA,KAAA;GACc,+DAAwB,KAAK;GAC5C,SAAA,CAAA,OAAA;GACS,CAAA;AAET,SAAA;IACM;EAAC;EAAO;EAAU;EAAI;EAAa,CAAC,EAAE,EAAE,CAAC;;AAEhD,gBAAgB,SAAS;CAAC;CAAW;CAAA;CAAA;CAAA"}
|
|
@@ -5,10 +5,14 @@ import { createNamedContext, useContext } from "@alloy-js/core";
|
|
|
5
5
|
import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
|
|
6
6
|
|
|
7
7
|
//#region src/contexts/options.ts
|
|
8
|
+
function __assignType(fn, args) {
|
|
9
|
+
fn.__type = args;
|
|
10
|
+
return fn;
|
|
11
|
+
}
|
|
8
12
|
/**
|
|
9
13
|
* The reflection parameter context used in template rendering.
|
|
10
14
|
*/
|
|
11
|
-
const ExistingOptionsContext = createNamedContext("ExistingOptions", []);
|
|
15
|
+
const ExistingOptionsContext = (createNamedContext.Ω = [["&F"]], createNamedContext("ExistingOptions", []));
|
|
12
16
|
/**
|
|
13
17
|
* Hook to access the ExistingOptions context.
|
|
14
18
|
*
|
|
@@ -18,10 +22,11 @@ const ExistingOptionsContext = createNamedContext("ExistingOptions", []);
|
|
|
18
22
|
* @returns A reactive version of the current reflection.
|
|
19
23
|
*/
|
|
20
24
|
function useExistingOptions() {
|
|
21
|
-
return useContext(ExistingOptionsContext);
|
|
25
|
+
return useContext.Ω = [["&F"]], useContext(ExistingOptionsContext);
|
|
22
26
|
}
|
|
27
|
+
useExistingOptions.__type = ["useExistingOptions", "P\"/!"];
|
|
23
28
|
function computedOptions(command) {
|
|
24
|
-
return Object.entries(command.options).reduce((ret, [name, option]) => {
|
|
29
|
+
return Object.entries(command.options).reduce(__assignType((ret, [name, option]) => {
|
|
25
30
|
ret[camelCase(name)] ??= defu$1({ name: camelCase(name) }, ret[name] ?? {}, option);
|
|
26
31
|
if (option.kind === ReflectionKind.boolean && option.isNegativeOf) ret[camelCase(option.isNegativeOf)] = defu$1({ name: camelCase(option.isNegativeOf) }, ret[option.isNegativeOf] ?? {}, {
|
|
27
32
|
...option,
|
|
@@ -31,8 +36,19 @@ function computedOptions(command) {
|
|
|
31
36
|
default: !option.default
|
|
32
37
|
});
|
|
33
38
|
return ret;
|
|
34
|
-
},
|
|
39
|
+
}, [
|
|
40
|
+
"ret",
|
|
41
|
+
"param1",
|
|
42
|
+
"",
|
|
43
|
+
"P\"2!\"2\"\"/#"
|
|
44
|
+
]), {});
|
|
35
45
|
}
|
|
46
|
+
computedOptions.__type = [
|
|
47
|
+
"CommandTree",
|
|
48
|
+
"command",
|
|
49
|
+
"computedOptions",
|
|
50
|
+
"P\"w!2\"\"/#"
|
|
51
|
+
];
|
|
36
52
|
|
|
37
53
|
//#endregion
|
|
38
54
|
export { ExistingOptionsContext, computedOptions, useExistingOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.mjs","names":[
|
|
1
|
+
{"version":3,"file":"options.mjs","names":[],"sources":["../../src/contexts/options.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ComponentContext } from \"@alloy-js/core\";\nimport { createNamedContext, useContext } from \"@alloy-js/core\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport type {\n BooleanCommandOption,\n CommandOption,\n CommandTree\n} from \"../types\";\n\n/**\n * The reflection parameter context used in template rendering.\n */\nexport const ExistingOptionsContext: ComponentContext<string[]> =\n createNamedContext<string[]>(\"ExistingOptions\", []);\n\n/**\n * Hook to access the ExistingOptions context.\n *\n * @remarks\n * This context provides a list of option names that already exist on the interface definition.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useExistingOptions() {\n return useContext<string[]>(ExistingOptionsContext)!;\n}\n\nexport function computedOptions(command: CommandTree) {\n return Object.entries(command.options).reduce(\n (ret, [name, option]) => {\n ret[camelCase(name)] ??= defu(\n {\n name: camelCase(name)\n },\n ret[name] ?? {},\n option\n ) as CommandOption;\n\n if (option.kind === ReflectionKind.boolean && option.isNegativeOf) {\n ret[camelCase(option.isNegativeOf)] = defu(\n {\n name: camelCase(option.isNegativeOf)\n },\n ret[option.isNegativeOf] ?? {},\n {\n ...option,\n env: isSetString(option.env) ? `NO_${option.env}` : false,\n description: `${option.description.replace(\n /\\.+$/,\n \"\"\n )}. This property is the negative form of ${name}.`,\n isNegativeOf: camelCase(name),\n default: !option.default\n }\n ) as BooleanCommandOption;\n }\n\n return ret;\n },\n {} as Record<string, CommandOption>\n );\n}\n"],"mappings":";;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;AAUX,MAAa,0BAA0B,mBAAmB,IAAC,CAAA,CAAA,KAAA,CAAA,EAAA,mBAAA,mBAAA,EAAA,CAAA;;;;;;;;;AAS3D,SAAgB,qBAAqB;AACjC,QAAQ,WAAW,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,WAAW,uBAAe;;AAE/D,mBAAY,SAAA,CAAA,sBAAA,QAAA;AACZ,SAAgB,gBAAM,SAAA;AAClB,QAAO,OAAI,QAAA,QAAA,QAAA,CAAA,OAAA,cAAA,KAAA,CAAA,MAAA,YAAA;AACP,MAAI,UAAA,KAAA,MAAA,OAAA,EACA,MAAK,UAAA,KAAA;AAEf,MAAA,OAAA,SAAA,eAAA,WAAA,OAAA,aACU,KAAI,UAAU,OAAO,aAAa,IAAI,OAAK,EACrD,MAAA,UAAA,OAAA,aAAA,EACW,EAAE,IAAI,OAAO,iBAAiB,EAAE,EAAE;GAC/B,GAAG;;GAEjB,aAAA,GAAA,OAAA,YAAA,QAAA,QAAA,GAAA,CAAA,0CAAA,KAAA;GACc,cAAc,UAAU,KAAK;GAC5C,SAAA,CAAA,OAAA;GACS,CAAA;AAET,SAAA;IACM;EAAC;EAAO;EAAU;EAAI;EAAa,CAAC,EAAE,EAAE,CAAC;;AAEhD,gBAAgB,SAAS;CAAC;CAAW;CAAA;CAAA;CAAA"}
|
|
@@ -11,6 +11,12 @@ let __stryke_path_join = require("@stryke/path/join");
|
|
|
11
11
|
function getDocsOutputPath(context) {
|
|
12
12
|
return (0, __stryke_path_join.joinPaths)(context.config.projectRoot, "docs", "generated");
|
|
13
13
|
}
|
|
14
|
+
getDocsOutputPath.__type = [
|
|
15
|
+
"Context",
|
|
16
|
+
"context",
|
|
17
|
+
"getDocsOutputPath",
|
|
18
|
+
"P\"w!2\"&/#"
|
|
19
|
+
];
|
|
14
20
|
|
|
15
21
|
//#endregion
|
|
16
22
|
exports.getDocsOutputPath = getDocsOutputPath;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs-helpers.cjs","names":[
|
|
1
|
+
{"version":3,"file":"docs-helpers.cjs","names":[],"sources":["../../src/helpers/docs-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join\";\nimport type { Context } from \"../types/context\";\n\n/**\n * Gets the output path for the generated documentation.\n *\n * @param context - The Shell Shock context.\n * @returns The output path for the generated documentation.\n */\nexport function getDocsOutputPath(context: Context): string {\n return joinPaths(context.config.projectRoot, \"docs\", \"generated\");\n}\n"],"mappings":";;;;;;;;;;AAwBA,SAAgB,kBAAkB,SAAS;AACvC,0CAAiB,QAAQ,OAAO,aAAa,QAAQ,YAAE;;AAE3D,kBAAkB,SAAS;CAAC;CAAW;CAAW;CAAU;CAAA"}
|
|
@@ -10,6 +10,12 @@ import { joinPaths } from "@stryke/path/join";
|
|
|
10
10
|
function getDocsOutputPath(context) {
|
|
11
11
|
return joinPaths(context.config.projectRoot, "docs", "generated");
|
|
12
12
|
}
|
|
13
|
+
getDocsOutputPath.__type = [
|
|
14
|
+
"Context",
|
|
15
|
+
"context",
|
|
16
|
+
"getDocsOutputPath",
|
|
17
|
+
"P\"w!2\"&/#"
|
|
18
|
+
];
|
|
13
19
|
|
|
14
20
|
//#endregion
|
|
15
21
|
export { getDocsOutputPath };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs-helpers.mjs","names":[
|
|
1
|
+
{"version":3,"file":"docs-helpers.mjs","names":[],"sources":["../../src/helpers/docs-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"@stryke/path/join\";\nimport type { Context } from \"../types/context\";\n\n/**\n * Gets the output path for the generated documentation.\n *\n * @param context - The Shell Shock context.\n * @returns The output path for the generated documentation.\n */\nexport function getDocsOutputPath(context: Context): string {\n return joinPaths(context.config.projectRoot, \"docs\", \"generated\");\n}\n"],"mappings":";;;;;;;;;AAwBA,SAAgB,kBAAkB,SAAS;AACvC,QAAO,UAAU,QAAQ,OAAO,aAAa,QAAQ,YAAE;;AAE3D,kBAAkB,SAAS;CAAC;CAAW;CAAW;CAAU;CAAA"}
|
|
@@ -4,31 +4,73 @@ let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type"
|
|
|
4
4
|
let __stryke_helpers_omit = require("@stryke/helpers/omit");
|
|
5
5
|
|
|
6
6
|
//#region src/helpers/persistence.ts
|
|
7
|
+
const __ΩRecord = [
|
|
8
|
+
"K",
|
|
9
|
+
"T",
|
|
10
|
+
"Record",
|
|
11
|
+
"l'e#\"Rb!b\"Pde\"!N#!w#y"
|
|
12
|
+
];
|
|
13
|
+
function __assignType(fn, args) {
|
|
14
|
+
fn.__type = args;
|
|
15
|
+
return fn;
|
|
16
|
+
}
|
|
7
17
|
function getCommandsPersistencePath(context) {
|
|
8
18
|
return (0, __stryke_path_join_paths.joinPaths)(context.dataPath, "reflections", "commands.json");
|
|
9
19
|
}
|
|
20
|
+
getCommandsPersistencePath.__type = [
|
|
21
|
+
"Context",
|
|
22
|
+
"context",
|
|
23
|
+
"getCommandsPersistencePath",
|
|
24
|
+
"P\"w!2\"&/#"
|
|
25
|
+
];
|
|
10
26
|
function serializedCommandTree(commands) {
|
|
11
|
-
const serialize = (node, parent = null) => {
|
|
27
|
+
const serialize = __assignType((node, parent = null) => {
|
|
12
28
|
const serializedNode = {
|
|
13
29
|
...node,
|
|
14
|
-
options: Object.entries(node.options).reduce((ret, [key, option]) => {
|
|
30
|
+
options: Object.entries(node.options).reduce(__assignType((ret, [key, option]) => {
|
|
15
31
|
ret[key] = { ...(0, __stryke_helpers_omit.omit)(option, ["reflection"]) };
|
|
16
32
|
return ret;
|
|
17
|
-
},
|
|
18
|
-
|
|
33
|
+
}, [
|
|
34
|
+
"ret",
|
|
35
|
+
"param1",
|
|
36
|
+
"",
|
|
37
|
+
"P\"2!\"2\"\"/#"
|
|
38
|
+
]), {}),
|
|
39
|
+
arguments: node.arguments.map(__assignType((arg) => ({ ...(0, __stryke_helpers_omit.omit)(arg, ["reflection"]) }), [
|
|
40
|
+
"arg",
|
|
41
|
+
"",
|
|
42
|
+
"P\"2!\"/\""
|
|
43
|
+
])),
|
|
19
44
|
parent,
|
|
20
45
|
children: {},
|
|
21
46
|
reflection: node.reflection ? (0, __powerlines_deepkit_vendor_type.serializeType)(node.reflection.type) : void 0
|
|
22
47
|
};
|
|
23
48
|
for (const [key, child] of Object.entries(node.children || {})) serializedNode.children[key] = serialize(child, node.id);
|
|
24
49
|
return serializedNode;
|
|
25
|
-
}
|
|
50
|
+
}, [
|
|
51
|
+
"CommandTree",
|
|
52
|
+
"node",
|
|
53
|
+
"parent",
|
|
54
|
+
() => null,
|
|
55
|
+
"SerializedCommandTree",
|
|
56
|
+
"",
|
|
57
|
+
"P\"w!2\"P&,J2#>$\"w%/&"
|
|
58
|
+
]);
|
|
26
59
|
const result = {};
|
|
27
60
|
for (const [key, child] of Object.entries(commands)) result[key] = serialize(child, null);
|
|
28
61
|
return result;
|
|
29
62
|
}
|
|
63
|
+
serializedCommandTree.__type = [
|
|
64
|
+
() => __ΩRecord,
|
|
65
|
+
"CommandTree",
|
|
66
|
+
"commands",
|
|
67
|
+
() => __ΩRecord,
|
|
68
|
+
"SerializedCommandTree",
|
|
69
|
+
"serializedCommandTree",
|
|
70
|
+
"P&\"w\"o!#2#&\"w%o$#/&"
|
|
71
|
+
];
|
|
30
72
|
function deserializeCommandTree(serializedCommands) {
|
|
31
|
-
const deserialize = (node, parent = null) => {
|
|
73
|
+
const deserialize = __assignType((node, parent = null) => {
|
|
32
74
|
const type = (0, __powerlines_deepkit_vendor_type.deserializeType)(node.reflection);
|
|
33
75
|
if (type.kind !== __powerlines_deepkit_vendor_type.ReflectionKind.function) throw new Error(`Failed to deserialize persisted data - invalid command handler reflection type for command ${node.id}`);
|
|
34
76
|
const reflection = new __powerlines_deepkit_vendor_type.ReflectionFunction(type);
|
|
@@ -39,37 +81,76 @@ function deserializeCommandTree(serializedCommands) {
|
|
|
39
81
|
}
|
|
40
82
|
const deserializedNode = {
|
|
41
83
|
...node,
|
|
42
|
-
options: optionsReflection ? Object.entries(node.options).reduce((ret, [key, option]) => {
|
|
84
|
+
options: optionsReflection ? Object.entries(node.options).reduce(__assignType((ret, [key, option]) => {
|
|
43
85
|
ret[key] = {
|
|
44
86
|
...option,
|
|
45
87
|
reflection: optionsReflection.getProperty(option.name)
|
|
46
88
|
};
|
|
47
89
|
return ret;
|
|
48
|
-
},
|
|
49
|
-
|
|
90
|
+
}, [
|
|
91
|
+
"ret",
|
|
92
|
+
"param1",
|
|
93
|
+
"",
|
|
94
|
+
"P\"2!\"2\"\"/#"
|
|
95
|
+
]), {}) : {},
|
|
96
|
+
arguments: node.arguments.map(__assignType((arg, i) => ({
|
|
50
97
|
...arg,
|
|
51
98
|
reflection: reflection.getParameters().length > i + 1 ? reflection.getParameters()[i + 1] : reflection.getParameterOrUndefined(arg.name)
|
|
52
|
-
})
|
|
99
|
+
}), [
|
|
100
|
+
"arg",
|
|
101
|
+
"i",
|
|
102
|
+
"",
|
|
103
|
+
"P\"2!\"2\"\"/#"
|
|
104
|
+
])),
|
|
53
105
|
parent,
|
|
54
106
|
children: {},
|
|
55
107
|
reflection
|
|
56
108
|
};
|
|
57
109
|
for (const [key, child] of Object.entries(node.children || {})) deserializedNode.children[key] = deserialize(child, deserializedNode);
|
|
58
110
|
return deserializedNode;
|
|
59
|
-
}
|
|
111
|
+
}, [
|
|
112
|
+
"SerializedCommandTree",
|
|
113
|
+
"node",
|
|
114
|
+
"CommandTree",
|
|
115
|
+
"parent",
|
|
116
|
+
() => null,
|
|
117
|
+
"",
|
|
118
|
+
"P\"w!2\"P\"w#,J2$>%\"w#/&"
|
|
119
|
+
]);
|
|
60
120
|
const result = {};
|
|
61
121
|
for (const [key, child] of Object.entries(serializedCommands)) result[key] = deserialize(child, null);
|
|
62
122
|
return result;
|
|
63
123
|
}
|
|
124
|
+
deserializeCommandTree.__type = [
|
|
125
|
+
() => __ΩRecord,
|
|
126
|
+
"SerializedCommandTree",
|
|
127
|
+
"serializedCommands",
|
|
128
|
+
() => __ΩRecord,
|
|
129
|
+
"CommandTree",
|
|
130
|
+
"deserializeCommandTree",
|
|
131
|
+
"P&\"w\"o!#2#&\"w%o$#/&"
|
|
132
|
+
];
|
|
64
133
|
async function readCommandsPersistence(context) {
|
|
65
134
|
const reflections = await context.fs.read(getCommandsPersistencePath(context));
|
|
66
135
|
if (!reflections || !reflections.length) throw new Error(`CLI Command reflection file ${getCommandsPersistencePath(context)} is empty`);
|
|
67
136
|
context.commands = deserializeCommandTree(JSON.parse(reflections));
|
|
68
137
|
}
|
|
138
|
+
readCommandsPersistence.__type = [
|
|
139
|
+
"Context",
|
|
140
|
+
"context",
|
|
141
|
+
"readCommandsPersistence",
|
|
142
|
+
"P\"w!2\"\"/#"
|
|
143
|
+
];
|
|
69
144
|
async function writeCommandsPersistence(context) {
|
|
70
145
|
const filePath = getCommandsPersistencePath(context);
|
|
71
146
|
await context.fs.write(filePath, JSON.stringify(serializedCommandTree(context.commands), null, context.config.mode === "development" ? 2 : 0));
|
|
72
147
|
}
|
|
148
|
+
writeCommandsPersistence.__type = [
|
|
149
|
+
"Context",
|
|
150
|
+
"context",
|
|
151
|
+
"writeCommandsPersistence",
|
|
152
|
+
"P\"w!2\"\"/#"
|
|
153
|
+
];
|
|
73
154
|
|
|
74
155
|
//#endregion
|
|
75
156
|
exports.getCommandsPersistencePath = getCommandsPersistencePath;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.cjs","names":[
|
|
1
|
+
{"version":3,"file":"persistence.cjs","names":[],"sources":["../../src/helpers/persistence.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ReflectionClass } from \"@powerlines/deepkit/vendor/type\";\nimport {\n deserializeType,\n ReflectionFunction,\n ReflectionKind,\n resolveClassType,\n serializeType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandTree,\n SerializedCommandOption,\n SerializedCommandTree\n} from \"../types\";\nimport type { Context } from \"../types/context\";\n\nexport function getCommandsPersistencePath(context: Context): string {\n return joinPaths(context.dataPath, \"reflections\", \"commands.json\");\n}\n\nexport function serializedCommandTree(\n commands: Record<string, CommandTree>\n): Record<string, SerializedCommandTree> {\n const serialize = (\n node: CommandTree,\n parent: string | null = null\n ): SerializedCommandTree => {\n const serializedNode: SerializedCommandTree = {\n ...node,\n options: Object.entries(node.options).reduce(\n (ret, [key, option]) => {\n ret[key] = {\n ...omit(option, [\"reflection\"])\n };\n return ret;\n },\n {} as Record<string, SerializedCommandOption>\n ),\n arguments: node.arguments.map(arg => ({\n ...omit(arg, [\"reflection\"])\n })),\n parent,\n children: {},\n reflection: node.reflection\n ? serializeType(node.reflection.type)\n : undefined\n };\n\n for (const [key, child] of Object.entries(node.children || {})) {\n serializedNode.children[key] = serialize(child, node.id);\n }\n\n return serializedNode;\n };\n\n const result: Record<string, SerializedCommandTree> = {};\n for (const [key, child] of Object.entries(commands)) {\n result[key] = serialize(child, null);\n }\n\n return result;\n}\n\nexport function deserializeCommandTree(\n serializedCommands: Record<string, SerializedCommandTree>\n): Record<string, CommandTree> {\n const deserialize = (\n node: SerializedCommandTree,\n parent: CommandTree | null = null\n ): CommandTree => {\n const type = deserializeType(node.reflection);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `Failed to deserialize persisted data - invalid command handler reflection type for command ${node.id}`\n );\n }\n\n const reflection = new ReflectionFunction(type);\n\n let optionsReflection: ReflectionClass<any> | undefined;\n if (\n reflection.getParameters().length > 0 &&\n reflection.getParameters()[0]\n ) {\n const optionsType = reflection.getParameters()[0]!.type;\n if (optionsType.kind === ReflectionKind.objectLiteral) {\n optionsReflection = resolveClassType(optionsType);\n }\n }\n\n const deserializedNode: CommandTree = {\n ...node,\n options: optionsReflection\n ? Object.entries(node.options).reduce(\n (ret, [key, option]) => {\n ret[key] = {\n ...option,\n reflection: optionsReflection.getProperty(option.name)\n } as CommandOption;\n return ret;\n },\n {} as Record<string, CommandOption>\n )\n : {},\n arguments: node.arguments.map((arg, i) => ({\n ...arg,\n reflection:\n reflection.getParameters().length > i + 1\n ? reflection.getParameters()[i + 1]\n : reflection.getParameterOrUndefined(arg.name)\n })) as CommandArgument[],\n parent,\n children: {},\n reflection\n };\n\n for (const [key, child] of Object.entries(node.children || {})) {\n deserializedNode.children[key] = deserialize(child, deserializedNode);\n }\n\n return deserializedNode;\n };\n\n const result: Record<string, CommandTree> = {};\n for (const [key, child] of Object.entries(serializedCommands)) {\n result[key] = deserialize(child, null);\n }\n\n return result;\n}\n\nexport async function readCommandsPersistence(context: Context) {\n const reflections = await context.fs.read(\n getCommandsPersistencePath(context)\n );\n if (!reflections || !reflections.length) {\n throw new Error(\n `CLI Command reflection file ${getCommandsPersistencePath(context)} is empty`\n );\n }\n\n context.commands = deserializeCommandTree(JSON.parse(reflections));\n}\n\nexport async function writeCommandsPersistence(context: Context) {\n const filePath = getCommandsPersistencePath(context);\n\n await context.fs.write(\n filePath,\n JSON.stringify(\n serializedCommandTree(context.commands),\n null,\n context.config.mode === \"development\" ? 2 : 0\n )\n );\n}\n"],"mappings":"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"}
|
|
@@ -3,31 +3,73 @@ import { ReflectionFunction, ReflectionKind, deserializeType, resolveClassType,
|
|
|
3
3
|
import { omit } from "@stryke/helpers/omit";
|
|
4
4
|
|
|
5
5
|
//#region src/helpers/persistence.ts
|
|
6
|
+
const __ΩRecord = [
|
|
7
|
+
"K",
|
|
8
|
+
"T",
|
|
9
|
+
"Record",
|
|
10
|
+
"l'e#\"Rb!b\"Pde\"!N#!w#y"
|
|
11
|
+
];
|
|
12
|
+
function __assignType(fn, args) {
|
|
13
|
+
fn.__type = args;
|
|
14
|
+
return fn;
|
|
15
|
+
}
|
|
6
16
|
function getCommandsPersistencePath(context) {
|
|
7
17
|
return joinPaths(context.dataPath, "reflections", "commands.json");
|
|
8
18
|
}
|
|
19
|
+
getCommandsPersistencePath.__type = [
|
|
20
|
+
"Context",
|
|
21
|
+
"context",
|
|
22
|
+
"getCommandsPersistencePath",
|
|
23
|
+
"P\"w!2\"&/#"
|
|
24
|
+
];
|
|
9
25
|
function serializedCommandTree(commands) {
|
|
10
|
-
const serialize = (node, parent = null) => {
|
|
26
|
+
const serialize = __assignType((node, parent = null) => {
|
|
11
27
|
const serializedNode = {
|
|
12
28
|
...node,
|
|
13
|
-
options: Object.entries(node.options).reduce((ret, [key, option]) => {
|
|
29
|
+
options: Object.entries(node.options).reduce(__assignType((ret, [key, option]) => {
|
|
14
30
|
ret[key] = { ...omit(option, ["reflection"]) };
|
|
15
31
|
return ret;
|
|
16
|
-
},
|
|
17
|
-
|
|
32
|
+
}, [
|
|
33
|
+
"ret",
|
|
34
|
+
"param1",
|
|
35
|
+
"",
|
|
36
|
+
"P\"2!\"2\"\"/#"
|
|
37
|
+
]), {}),
|
|
38
|
+
arguments: node.arguments.map(__assignType((arg) => ({ ...omit(arg, ["reflection"]) }), [
|
|
39
|
+
"arg",
|
|
40
|
+
"",
|
|
41
|
+
"P\"2!\"/\""
|
|
42
|
+
])),
|
|
18
43
|
parent,
|
|
19
44
|
children: {},
|
|
20
45
|
reflection: node.reflection ? serializeType(node.reflection.type) : void 0
|
|
21
46
|
};
|
|
22
47
|
for (const [key, child] of Object.entries(node.children || {})) serializedNode.children[key] = serialize(child, node.id);
|
|
23
48
|
return serializedNode;
|
|
24
|
-
}
|
|
49
|
+
}, [
|
|
50
|
+
"CommandTree",
|
|
51
|
+
"node",
|
|
52
|
+
"parent",
|
|
53
|
+
() => null,
|
|
54
|
+
"SerializedCommandTree",
|
|
55
|
+
"",
|
|
56
|
+
"P\"w!2\"P&,J2#>$\"w%/&"
|
|
57
|
+
]);
|
|
25
58
|
const result = {};
|
|
26
59
|
for (const [key, child] of Object.entries(commands)) result[key] = serialize(child, null);
|
|
27
60
|
return result;
|
|
28
61
|
}
|
|
62
|
+
serializedCommandTree.__type = [
|
|
63
|
+
() => __ΩRecord,
|
|
64
|
+
"CommandTree",
|
|
65
|
+
"commands",
|
|
66
|
+
() => __ΩRecord,
|
|
67
|
+
"SerializedCommandTree",
|
|
68
|
+
"serializedCommandTree",
|
|
69
|
+
"P&\"w\"o!#2#&\"w%o$#/&"
|
|
70
|
+
];
|
|
29
71
|
function deserializeCommandTree(serializedCommands) {
|
|
30
|
-
const deserialize = (node, parent = null) => {
|
|
72
|
+
const deserialize = __assignType((node, parent = null) => {
|
|
31
73
|
const type = deserializeType(node.reflection);
|
|
32
74
|
if (type.kind !== ReflectionKind.function) throw new Error(`Failed to deserialize persisted data - invalid command handler reflection type for command ${node.id}`);
|
|
33
75
|
const reflection = new ReflectionFunction(type);
|
|
@@ -38,37 +80,76 @@ function deserializeCommandTree(serializedCommands) {
|
|
|
38
80
|
}
|
|
39
81
|
const deserializedNode = {
|
|
40
82
|
...node,
|
|
41
|
-
options: optionsReflection ? Object.entries(node.options).reduce((ret, [key, option]) => {
|
|
83
|
+
options: optionsReflection ? Object.entries(node.options).reduce(__assignType((ret, [key, option]) => {
|
|
42
84
|
ret[key] = {
|
|
43
85
|
...option,
|
|
44
86
|
reflection: optionsReflection.getProperty(option.name)
|
|
45
87
|
};
|
|
46
88
|
return ret;
|
|
47
|
-
},
|
|
48
|
-
|
|
89
|
+
}, [
|
|
90
|
+
"ret",
|
|
91
|
+
"param1",
|
|
92
|
+
"",
|
|
93
|
+
"P\"2!\"2\"\"/#"
|
|
94
|
+
]), {}) : {},
|
|
95
|
+
arguments: node.arguments.map(__assignType((arg, i) => ({
|
|
49
96
|
...arg,
|
|
50
97
|
reflection: reflection.getParameters().length > i + 1 ? reflection.getParameters()[i + 1] : reflection.getParameterOrUndefined(arg.name)
|
|
51
|
-
})
|
|
98
|
+
}), [
|
|
99
|
+
"arg",
|
|
100
|
+
"i",
|
|
101
|
+
"",
|
|
102
|
+
"P\"2!\"2\"\"/#"
|
|
103
|
+
])),
|
|
52
104
|
parent,
|
|
53
105
|
children: {},
|
|
54
106
|
reflection
|
|
55
107
|
};
|
|
56
108
|
for (const [key, child] of Object.entries(node.children || {})) deserializedNode.children[key] = deserialize(child, deserializedNode);
|
|
57
109
|
return deserializedNode;
|
|
58
|
-
}
|
|
110
|
+
}, [
|
|
111
|
+
"SerializedCommandTree",
|
|
112
|
+
"node",
|
|
113
|
+
"CommandTree",
|
|
114
|
+
"parent",
|
|
115
|
+
() => null,
|
|
116
|
+
"",
|
|
117
|
+
"P\"w!2\"P\"w#,J2$>%\"w#/&"
|
|
118
|
+
]);
|
|
59
119
|
const result = {};
|
|
60
120
|
for (const [key, child] of Object.entries(serializedCommands)) result[key] = deserialize(child, null);
|
|
61
121
|
return result;
|
|
62
122
|
}
|
|
123
|
+
deserializeCommandTree.__type = [
|
|
124
|
+
() => __ΩRecord,
|
|
125
|
+
"SerializedCommandTree",
|
|
126
|
+
"serializedCommands",
|
|
127
|
+
() => __ΩRecord,
|
|
128
|
+
"CommandTree",
|
|
129
|
+
"deserializeCommandTree",
|
|
130
|
+
"P&\"w\"o!#2#&\"w%o$#/&"
|
|
131
|
+
];
|
|
63
132
|
async function readCommandsPersistence(context) {
|
|
64
133
|
const reflections = await context.fs.read(getCommandsPersistencePath(context));
|
|
65
134
|
if (!reflections || !reflections.length) throw new Error(`CLI Command reflection file ${getCommandsPersistencePath(context)} is empty`);
|
|
66
135
|
context.commands = deserializeCommandTree(JSON.parse(reflections));
|
|
67
136
|
}
|
|
137
|
+
readCommandsPersistence.__type = [
|
|
138
|
+
"Context",
|
|
139
|
+
"context",
|
|
140
|
+
"readCommandsPersistence",
|
|
141
|
+
"P\"w!2\"\"/#"
|
|
142
|
+
];
|
|
68
143
|
async function writeCommandsPersistence(context) {
|
|
69
144
|
const filePath = getCommandsPersistencePath(context);
|
|
70
145
|
await context.fs.write(filePath, JSON.stringify(serializedCommandTree(context.commands), null, context.config.mode === "development" ? 2 : 0));
|
|
71
146
|
}
|
|
147
|
+
writeCommandsPersistence.__type = [
|
|
148
|
+
"Context",
|
|
149
|
+
"context",
|
|
150
|
+
"writeCommandsPersistence",
|
|
151
|
+
"P\"w!2\"\"/#"
|
|
152
|
+
];
|
|
72
153
|
|
|
73
154
|
//#endregion
|
|
74
155
|
export { getCommandsPersistencePath, readCommandsPersistence, writeCommandsPersistence };
|