@shell-shock/core 0.17.2 → 0.17.3
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 +5 -4
- package/dist/api.mjs +4 -2
- package/dist/api.mjs.map +1 -1
- package/dist/components/command-validation-logic.cjs +44 -11
- package/dist/components/command-validation-logic.mjs +44 -10
- package/dist/components/command-validation-logic.mjs.map +1 -1
- package/dist/components/docs.cjs +1 -2
- package/dist/components/exec-builtin.cjs +1 -2
- package/dist/components/helpers.cjs +1 -2
- package/dist/components/options-parser-logic.cjs +1 -2
- package/dist/components/state-builtin.cjs +1 -2
- package/dist/components/state-builtin.mjs +1 -1
- package/dist/components/usage.cjs +1 -2
- package/dist/components/utils-builtin.cjs +1 -7
- package/dist/components/utils-builtin.mjs +0 -5
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/config.cjs +3 -3
- package/dist/config.mjs +2 -1
- package/dist/contexts/command.cjs +6 -3
- package/dist/contexts/command.mjs +5 -1
- package/dist/contexts/command.mjs.map +1 -1
- package/dist/contexts/options.cjs +6 -3
- package/dist/contexts/options.mjs +5 -1
- package/dist/contexts/options.mjs.map +1 -1
- package/dist/helpers/automd.cjs +1 -2
- package/dist/helpers/docs-helpers.cjs +3 -3
- package/dist/helpers/docs-helpers.mjs +2 -1
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/paths.cjs +3 -3
- package/dist/helpers/paths.mjs +2 -1
- package/dist/helpers/paths.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +7 -5
- package/dist/helpers/persistence.mjs +6 -3
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +1 -2
- package/dist/helpers/utilities.cjs +3 -3
- package/dist/helpers/utilities.mjs +2 -1
- package/dist/helpers/utilities.mjs.map +1 -1
- package/dist/helpers/validations.cjs +1 -2
- package/dist/plugin-utils/context-helpers.cjs +21 -12
- package/dist/plugin-utils/context-helpers.mjs +20 -10
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/dist/plugin-utils/deepkit.cjs +5 -6
- package/dist/plugin-utils/deepkit.mjs +5 -5
- package/dist/plugin-utils/deepkit.mjs.map +1 -1
- package/dist/plugin-utils/description-helpers.cjs +14 -8
- package/dist/plugin-utils/description-helpers.mjs +13 -6
- package/dist/plugin-utils/description-helpers.mjs.map +1 -1
- package/dist/plugin-utils/get-command-tree.cjs +5 -4
- package/dist/plugin-utils/get-command-tree.mjs +4 -2
- package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/reflect.cjs +3 -3
- package/dist/plugin-utils/reflect.mjs +2 -1
- package/dist/plugin-utils/traverse-command-tree.cjs +5 -4
- package/dist/plugin-utils/traverse-command-tree.mjs +4 -2
- package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/type-checks.cjs +11 -7
- package/dist/plugin-utils/type-checks.mjs +10 -5
- package/dist/plugin-utils/type-checks.mjs.map +1 -1
- package/dist/plugin.cjs +5 -5
- package/dist/plugin.mjs +5 -4
- package/dist/plugin.mjs.map +1 -1
- package/dist/resolver/deepkit.cjs +4 -9
- package/dist/resolver/deepkit.mjs +4 -8
- package/dist/resolver/deepkit.mjs.map +1 -1
- package/dist/resolver/helpers.cjs +5 -4
- package/dist/resolver/helpers.mjs +4 -2
- package/dist/resolver/helpers.mjs.map +1 -1
- package/dist/resolver/module.cjs +1 -2
- package/dist/resolver/resolve.cjs +8 -5
- package/dist/resolver/resolve.mjs +7 -3
- package/dist/resolver/resolve.mjs.map +1 -1
- package/dist/types/command.cjs +65 -12
- package/dist/types/command.d.cts +9 -1
- package/dist/types/command.d.cts.map +1 -1
- package/dist/types/command.d.mts +9 -1
- package/dist/types/command.d.mts.map +1 -1
- package/dist/types/command.mjs +64 -10
- package/dist/types/command.mjs.map +1 -1
- package/dist/types/config.cjs +19 -7
- package/dist/types/config.mjs +18 -5
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/context.cjs +6 -3
- package/dist/types/context.mjs +5 -1
- package/dist/types/env.cjs +8 -3
- package/dist/types/env.d.cts +3 -1
- package/dist/types/env.d.cts.map +1 -1
- package/dist/types/env.d.mts +3 -1
- package/dist/types/env.d.mts.map +1 -1
- package/dist/types/env.mjs +7 -1
- package/dist/types/env.mjs.map +1 -1
- package/dist/types/options.cjs +1 -2
- package/package.json +10 -10
- package/dist/api.cjs.map +0 -1
- package/dist/components/command-validation-logic.cjs.map +0 -1
- package/dist/components/docs.cjs.map +0 -1
- package/dist/components/exec-builtin.cjs.map +0 -1
- package/dist/components/helpers.cjs.map +0 -1
- package/dist/components/options-parser-logic.cjs.map +0 -1
- package/dist/components/state-builtin.cjs.map +0 -1
- package/dist/components/usage.cjs.map +0 -1
- package/dist/components/utils-builtin.cjs.map +0 -1
- package/dist/config.cjs.map +0 -1
- package/dist/contexts/command.cjs.map +0 -1
- package/dist/contexts/options.cjs.map +0 -1
- package/dist/helpers/automd.cjs.map +0 -1
- package/dist/helpers/docs-helpers.cjs.map +0 -1
- package/dist/helpers/paths.cjs.map +0 -1
- package/dist/helpers/persistence.cjs.map +0 -1
- package/dist/helpers/update-package-json.cjs.map +0 -1
- package/dist/helpers/utilities.cjs.map +0 -1
- package/dist/helpers/validations.cjs.map +0 -1
- package/dist/plugin-utils/context-helpers.cjs.map +0 -1
- package/dist/plugin-utils/deepkit.cjs.map +0 -1
- package/dist/plugin-utils/description-helpers.cjs.map +0 -1
- package/dist/plugin-utils/get-command-tree.cjs.map +0 -1
- package/dist/plugin-utils/reflect.cjs.map +0 -1
- package/dist/plugin-utils/traverse-command-tree.cjs.map +0 -1
- package/dist/plugin-utils/type-checks.cjs.map +0 -1
- package/dist/plugin.cjs.map +0 -1
- package/dist/resolver/deepkit.cjs.map +0 -1
- package/dist/resolver/helpers.cjs.map +0 -1
- package/dist/resolver/module.cjs.map +0 -1
- package/dist/resolver/resolve.cjs.map +0 -1
- package/dist/types/command.cjs.map +0 -1
- package/dist/types/config.cjs.map +0 -1
- package/dist/types/context.cjs.map +0 -1
- package/dist/types/env.cjs.map +0 -1
- package/dist/types/options.cjs.map +0 -1
|
@@ -21,12 +21,10 @@ function extractCommandParameterKind(type) {
|
|
|
21
21
|
else return require_types_command.CommandParameterKinds.string;
|
|
22
22
|
}
|
|
23
23
|
extractCommandParameterKind.__type = [
|
|
24
|
-
"Type",
|
|
25
|
-
() => _powerlines_deepkit_vendor_type.__ΩReflectionKind,
|
|
26
24
|
"type",
|
|
27
25
|
"CommandParameterKind",
|
|
28
26
|
"extractCommandParameterKind",
|
|
29
|
-
"PP
|
|
27
|
+
"PP!!J2!\"w\"/#"
|
|
30
28
|
];
|
|
31
29
|
function resolveCommandOption(ctx, reflection) {
|
|
32
30
|
const type = reflection.getType();
|
|
@@ -60,11 +58,10 @@ function resolveCommandOption(ctx, reflection) {
|
|
|
60
58
|
resolveCommandOption.__type = [
|
|
61
59
|
"ResolverContext",
|
|
62
60
|
"ctx",
|
|
63
|
-
"ReflectionProperty",
|
|
64
61
|
"reflection",
|
|
65
62
|
"CommandOption",
|
|
66
63
|
"resolveCommandOption",
|
|
67
|
-
"P\"w!2\"
|
|
64
|
+
"P\"w!2\"!2#\"w$/%"
|
|
68
65
|
];
|
|
69
66
|
function resolveCommandArgument(ctx, index, reflection) {
|
|
70
67
|
const type = reflection.getType();
|
|
@@ -101,11 +98,10 @@ resolveCommandArgument.__type = [
|
|
|
101
98
|
"ResolverContext",
|
|
102
99
|
"ctx",
|
|
103
100
|
"index",
|
|
104
|
-
"ReflectionParameter",
|
|
105
101
|
"reflection",
|
|
106
102
|
"CommandArgument",
|
|
107
103
|
"resolveCommandArgument",
|
|
108
|
-
"P\"w!2\"'2
|
|
104
|
+
"P\"w!2\"'2#!2$\"w%/&"
|
|
109
105
|
];
|
|
110
106
|
function resolveFromBytecode(ctx) {
|
|
111
107
|
const { input, module } = ctx;
|
|
@@ -136,5 +132,4 @@ resolveFromBytecode.__type = [
|
|
|
136
132
|
];
|
|
137
133
|
|
|
138
134
|
//#endregion
|
|
139
|
-
exports.resolveFromBytecode = resolveFromBytecode;
|
|
140
|
-
//# sourceMappingURL=deepkit.cjs.map
|
|
135
|
+
exports.resolveFromBytecode = resolveFromBytecode;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CommandParameterKinds } from "../types/command.mjs";
|
|
2
2
|
import { mergeCommandParameter } from "./helpers.mjs";
|
|
3
3
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
4
|
-
import { ReflectionClass, ReflectionFunction, ReflectionKind,
|
|
4
|
+
import { ReflectionClass, ReflectionFunction, ReflectionKind, reflect, stringifyType } from "@powerlines/deepkit/vendor/type";
|
|
5
5
|
import { isBigInt } from "@stryke/type-checks/is-bigint";
|
|
6
6
|
import { isNumber } from "@stryke/type-checks/is-number";
|
|
7
7
|
import { isRegExp } from "@stryke/type-checks/is-regexp";
|
|
@@ -20,12 +20,10 @@ function extractCommandParameterKind(type) {
|
|
|
20
20
|
else return CommandParameterKinds.string;
|
|
21
21
|
}
|
|
22
22
|
extractCommandParameterKind.__type = [
|
|
23
|
-
"Type",
|
|
24
|
-
() => __ΩReflectionKind,
|
|
25
23
|
"type",
|
|
26
24
|
"CommandParameterKind",
|
|
27
25
|
"extractCommandParameterKind",
|
|
28
|
-
"PP
|
|
26
|
+
"PP!!J2!\"w\"/#"
|
|
29
27
|
];
|
|
30
28
|
function resolveCommandOption(ctx, reflection) {
|
|
31
29
|
const type = reflection.getType();
|
|
@@ -59,11 +57,10 @@ function resolveCommandOption(ctx, reflection) {
|
|
|
59
57
|
resolveCommandOption.__type = [
|
|
60
58
|
"ResolverContext",
|
|
61
59
|
"ctx",
|
|
62
|
-
"ReflectionProperty",
|
|
63
60
|
"reflection",
|
|
64
61
|
"CommandOption",
|
|
65
62
|
"resolveCommandOption",
|
|
66
|
-
"P\"w!2\"
|
|
63
|
+
"P\"w!2\"!2#\"w$/%"
|
|
67
64
|
];
|
|
68
65
|
function resolveCommandArgument(ctx, index, reflection) {
|
|
69
66
|
const type = reflection.getType();
|
|
@@ -100,11 +97,10 @@ resolveCommandArgument.__type = [
|
|
|
100
97
|
"ResolverContext",
|
|
101
98
|
"ctx",
|
|
102
99
|
"index",
|
|
103
|
-
"ReflectionParameter",
|
|
104
100
|
"reflection",
|
|
105
101
|
"CommandArgument",
|
|
106
102
|
"resolveCommandArgument",
|
|
107
|
-
"P\"w!2\"'2
|
|
103
|
+
"P\"w!2\"'2#!2$\"w%/&"
|
|
108
104
|
];
|
|
109
105
|
function resolveFromBytecode(ctx) {
|
|
110
106
|
const { input, module } = ctx;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepkit.mjs","names":[],"sources":["../../src/resolver/deepkit.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 {\n ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterKind,\n Context,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\nimport { mergeCommandParameter } from \"./helpers\";\nimport type { ResolverContext } from \"./types\";\n\nfunction extractCommandParameterKind(\n type: Type | ReflectionKind\n): CommandParameterKind {\n const isKind = !(isSetObject(type) && \"kind\" in type);\n const kind = !isKind ? type.kind : type;\n if (kind === ReflectionKind.string) {\n return CommandParameterKinds.string;\n } else if (\n kind === ReflectionKind.number ||\n kind === ReflectionKind.bigint ||\n (!isKind &&\n type.kind === ReflectionKind.literal &&\n (isNumber(type.literal) || isBigInt(type.literal)))\n ) {\n return CommandParameterKinds.number;\n } else if (kind === ReflectionKind.boolean) {\n return CommandParameterKinds.boolean;\n } else {\n return CommandParameterKinds.string;\n }\n}\n\nfunction resolveCommandOption(\n ctx: ResolverContext,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n const existing = (ctx.output.options[reflection.getNameAsString()] ??\n {}) as Partial<CommandOption>;\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title: reflection.getTags().title?.trim(),\n description: reflection.getDescription(),\n kind: extractCommandParameterKind(type),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray()\n };\n\n if (option.variadic) {\n option.kind = extractCommandParameterKind((type as TypeArray).type.kind);\n } else if (type.kind === ReflectionKind.union) {\n option.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (option as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (option as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !existing.kind &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, option) as CommandOption;\n}\n\nfunction resolveCommandArgument(\n ctx: ResolverContext,\n index: number,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n const existing = (\n ctx.output.args.length > index ? ctx.output.args[index] : {}\n ) as Partial<CommandArgument>;\n\n const argument = {\n name: reflection.getName() || reflection.parameter.name,\n alias: reflection.getAlias(),\n kind: extractCommandParameterKind(type.kind),\n title: reflection.getTitle() || reflection.parameter.tags?.title,\n description: reflection.parameter.description,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue()\n };\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (argument as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind(type.type.kind) as \"string\" | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (type.kind === ReflectionKind.union) {\n argument.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (argument as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (argument as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !ctx.output.args?.length &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, argument, {\n name: `arg${index}`\n }) as CommandArgument;\n}\n\nexport function resolveFromBytecode<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n const { input, module } = ctx;\n\n const type = reflect(module);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${\n input.command.entry.input?.file || input.command.path\n }\" does not export a valid function.`\n );\n }\n\n const reflection = new ReflectionFunction(type);\n\n ctx.output.description ??= (ctx.input.command.description ||\n reflection.getDescription() ||\n type.description)!;\n\n const parameters = reflection.getParameters();\n if (parameters.length > 0) {\n const hasOptions =\n parameters[0] &&\n (parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class);\n if (hasOptions) {\n const optionsReflection = ReflectionClass.from(parameters[0]?.type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n }\n\n ctx.output.args = (hasOptions ? par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AAE,KAAK,SAAS,eAAe,SAC5B,OAAA,IAAA,MAAA,2BAAA,MAAA,QAAA,MAAA,OAAA,QAAA,MAAA,QAAA,KAAA,qCAAA;CAEH,MAAM,aAAa,IAAE,mBAAe,KAAA;AACpC,KAAE,OAAA,gBAAA,IAAA,MAAA,QAAA,eACC,WAAY,gBAAA,IACX,KAAI;CACR,MAAG,aAAY,WAAA,eAAyB;AACxC,KAAI,WAAA,SAAA,GAAA;EACF,MAAK,aAAA,WAAA,OACC,WAAS,GAAA,KAAA,SAAA,eAAA,iBACZ,WAAkB,GAAA,KAAQ,SAAC,eAAuB;AACnD,MAAE,YAAU;GACR,MAAK,oBAAoB,gBAAiB,KAAA,WAAW,IAAS,KAAE;AAClE,QAAA,MAAA,sBAAA,kBAAA,eAAA,CACF,KAAA,OAAA,QAAA,mBAAA,iBAAA,IACQ,qBAAA,KAAA,mBAAA;;AAGZ,MAAA,OAAA,QAAA,aAAA,WAAA,MAAA,EAAA,GAAA,YAAA,IAAA,cAAA,KAAA,UAAA,uBAAA,KAAA,OAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;;;AAGJ,oBAAS,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
|
|
1
|
+
{"version":3,"file":"deepkit.mjs","names":[],"sources":["../../src/resolver/deepkit.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 {\n ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterKind,\n Context,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\nimport { mergeCommandParameter } from \"./helpers\";\nimport type { ResolverContext } from \"./types\";\n\nfunction extractCommandParameterKind(\n type: Type | ReflectionKind\n): CommandParameterKind {\n const isKind = !(isSetObject(type) && \"kind\" in type);\n const kind = !isKind ? type.kind : type;\n if (kind === ReflectionKind.string) {\n return CommandParameterKinds.string;\n } else if (\n kind === ReflectionKind.number ||\n kind === ReflectionKind.bigint ||\n (!isKind &&\n type.kind === ReflectionKind.literal &&\n (isNumber(type.literal) || isBigInt(type.literal)))\n ) {\n return CommandParameterKinds.number;\n } else if (kind === ReflectionKind.boolean) {\n return CommandParameterKinds.boolean;\n } else {\n return CommandParameterKinds.string;\n }\n}\n\nfunction resolveCommandOption(\n ctx: ResolverContext,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n const existing = (ctx.output.options[reflection.getNameAsString()] ??\n {}) as Partial<CommandOption>;\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title: reflection.getTags().title?.trim(),\n description: reflection.getDescription(),\n kind: extractCommandParameterKind(type),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray()\n };\n\n if (option.variadic) {\n option.kind = extractCommandParameterKind((type as TypeArray).type.kind);\n } else if (type.kind === ReflectionKind.union) {\n option.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (option as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (option as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !existing.kind &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, option) as CommandOption;\n}\n\nfunction resolveCommandArgument(\n ctx: ResolverContext,\n index: number,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n const existing = (\n ctx.output.args.length > index ? ctx.output.args[index] : {}\n ) as Partial<CommandArgument>;\n\n const argument = {\n name: reflection.getName() || reflection.parameter.name,\n alias: reflection.getAlias(),\n kind: extractCommandParameterKind(type.kind),\n title: reflection.getTitle() || reflection.parameter.tags?.title,\n description: reflection.parameter.description,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue()\n };\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (argument as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind(type.type.kind) as \"string\" | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (type.kind === ReflectionKind.union) {\n argument.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (argument as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (argument as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !ctx.output.args?.length &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, argument, {\n name: `arg${index}`\n }) as CommandArgument;\n}\n\nexport function resolveFromBytecode<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n const { input, module } = ctx;\n\n const type = reflect(module);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${\n input.command.entry.input?.file || input.command.path\n }\" does not export a valid function.`\n );\n }\n\n const reflection = new ReflectionFunction(type);\n\n ctx.output.description ??= (ctx.input.command.description ||\n reflection.getDescription() ||\n type.description)!;\n\n const parameters = reflection.getParameters();\n if (parameters.length > 0) {\n const hasOptions =\n parameters[0] &&\n (parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class);\n if (hasOptions) {\n const optionsReflection = ReflectionClass.from(parameters[0]?.type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n }\n\n ctx.output.args = (hasOptions ? parameters.slice(1) : parameters).map(\n (arg, index) => resolveCommandArgument(ctx, index, arg)\n );\n }\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AASX,SAAC,4BAAkC,MAAK;CACvC,MAAS,SAAS,EAAE,YAAY,KAAE,IAAA,UAAiB;;AAEnD,KAAK,SAAQ,eAAa;4CAIpB,SAAK,eAAA,UACV,CAAA,UACA,KAAA,SAAkB,eAAA,YACd,SAAA,KAAA,QAAA,IAAA,SAAA,KAAA,QAAA,EACJ,QAAA,sBAAA;UAEK,SAAA,eAAA,QACL,QAAO,sBAAA;KAGP,QAAA,sBAAc;;AAGhB,4BAA2B,SAAO;CAAI;CAAQ;CAAU;CAAA;CAAA;AACxD,SAAS,qBAAkB,KAAO,YAAY;CAC9C,MAAS,OAAQ,WAAU,SAAO;CAClC,MAAS,WAAa,IAAC,OAAO,QAAW,WAAW,iBAAW,KACxD,EAAA;CACL,MAAA,SAAe;EACf,MAAA,WAAa,iBAAA;EACb,OAAA,WAAoB,SAAA,CAAA,SAAA,EAAA;EACpB,OAAO,WAAA,SAAA,CAAA,OAAA,MAAA;EACP,aAAA,WAAsB,gBAAA;EACtB,MAAA,4BAAA,KAAA;EACM,UAAS,WAAA,YAAA;EACT,SAAC,WAAA,iBAAiC;EAClC,UAAC,WAAA,SAA6B;EACtC;qBAEQ,QAAC,OAAA,4BAA2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Resolves the description for a command option based on its reflection.",
|
|
40
|
+
"P&2!\"w\"2#\"2$\"2%&2&8\"2'8&/(?)"
|
|
40
41
|
];
|
|
41
42
|
/**
|
|
42
43
|
* Resolves the description for a command argument based on its reflection.
|
|
@@ -61,7 +62,8 @@ resolveCommandArgumentDescription.__type = [
|
|
|
61
62
|
"title",
|
|
62
63
|
"defaultValue",
|
|
63
64
|
"resolveCommandArgumentDescription",
|
|
64
|
-
"
|
|
65
|
+
"Resolves the description for a command argument based on its reflection.",
|
|
66
|
+
"P&2!\"w\"2#\"2$\"2%&2&8\"2'8&/(?)"
|
|
65
67
|
];
|
|
66
68
|
function applyOptionsDefaults(ctx) {
|
|
67
69
|
return Object.fromEntries(Object.entries(ctx.output.options).map(__assignType(([key, option]) => {
|
|
@@ -168,5 +170,4 @@ exports.applyArgsDefaults = applyArgsDefaults;
|
|
|
168
170
|
exports.applyDefaults = applyDefaults;
|
|
169
171
|
exports.applyOptionsDefaults = applyOptionsDefaults;
|
|
170
172
|
exports.mergeCommandParameter = mergeCommandParameter;
|
|
171
|
-
exports.resolveVirtualCommand = resolveVirtualCommand;
|
|
172
|
-
//# sourceMappingURL=helpers.cjs.map
|
|
173
|
+
exports.resolveVirtualCommand = resolveVirtualCommand;
|
|
@@ -35,7 +35,8 @@ resolveCommandOptionDescription.__type = [
|
|
|
35
35
|
"title",
|
|
36
36
|
"defaultValue",
|
|
37
37
|
"resolveCommandOptionDescription",
|
|
38
|
-
"
|
|
38
|
+
"Resolves the description for a command option based on its reflection.",
|
|
39
|
+
"P&2!\"w\"2#\"2$\"2%&2&8\"2'8&/(?)"
|
|
39
40
|
];
|
|
40
41
|
/**
|
|
41
42
|
* Resolves the description for a command argument based on its reflection.
|
|
@@ -60,7 +61,8 @@ resolveCommandArgumentDescription.__type = [
|
|
|
60
61
|
"title",
|
|
61
62
|
"defaultValue",
|
|
62
63
|
"resolveCommandArgumentDescription",
|
|
63
|
-
"
|
|
64
|
+
"Resolves the description for a command argument based on its reflection.",
|
|
65
|
+
"P&2!\"w\"2#\"2$\"2%&2&8\"2'8&/(?)"
|
|
64
66
|
];
|
|
65
67
|
function applyOptionsDefaults(ctx) {
|
|
66
68
|
return Object.fromEntries(Object.entries(ctx.output.options).map(__assignType(([key, option]) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.mjs","names":[],"sources":["../../src/resolver/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 { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { createDefu } from \"defu\";\nimport {\n getAppTitle,\n isDynamicPathSegment\n} from \"../plugin-utils/context-helpers\";\nimport type { CommandArgument, CommandParameterKind } from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport type { ResolverContext } from \"./types\";\n\n/**\n * Resolves the description for a command option based on its reflection.\n *\n * @param name - The name of the command option.\n * @param kind - The reflection kind of the command option.\n * @param optional - Whether the command option is optional.\n * @param variadic - Whether the command option is variadic (i.e., an array).\n * @param title - The title of the command option, if any.\n * @param defaultValue - The default value of the command option, if any.\n * @returns The resolved description for the command option.\n */\nexport function resolveCommandOptionDescription(\n name: string,\n kind: CommandParameterKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `A${optional && !defaultValue ? \"n optional\" : \"\"} command-line ${\n kind === CommandParameterKinds.boolean ? \"flag\" : \"option\"\n } that allows the user to ${\n kind === CommandParameterKinds.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === CommandParameterKinds.boolean\n ? \"indicator\"\n : `${kind === CommandParameterKinds.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\n/**\n * Resolves the description for a command argument based on its reflection.\n *\n * @param name - The name of the command argument.\n * @param kind - The reflection kind of the command argument.\n * @param optional - Whether the command argument is optional.\n * @param variadic - Whether the command argument is variadic (i.e., an array).\n * @param title - The title of the command argument, if any.\n * @param defaultValue - The default value of the command argument, if any.\n * @returns The resolved description for the command argument.\n */\nexport function resolveCommandArgumentDescription(\n name: string,\n kind: CommandParameterKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `An${\n optional && !defaultValue ? \" optional\" : \"\"\n } argument that allows the user to ${\n kind === CommandParameterKinds.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === CommandParameterKinds.boolean\n ? \"indicator\"\n : `${kind === CommandParameterKinds.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\nexport function applyOptionsDefaults(ctx: ResolverContext) {\n return Object.fromEntries(\n Object.entries(ctx.output.options).map(([key, option]) => {\n const name = option.name || key;\n const title = option.title || titleCase(name);\n\n return [\n key,\n {\n ...option,\n name,\n title,\n description:\n option.description ||\n resolveCommandOptionDescription(\n name,\n option.kind,\n option.optional,\n option.kind !== CommandParameterKinds.boolean && option.variadic,\n title,\n option.default\n ),\n env:\n option.env || option.env === false\n ? option.env\n : ctx.input.context.config.autoAssignEnv\n ? constantCase(name)\n : false\n }\n ];\n })\n );\n}\n\nexport function applyArgsDefaults(ctx: ResolverContext): CommandArgument[] {\n return ctx.output.args.map((arg, i) => {\n const name = arg.name || `arg${i + 1}`;\n const title = arg.title || titleCase(name);\n\n return {\n ...arg,\n name,\n title,\n description:\n arg.description ||\n resolveCommandArgumentDescription(\n name,\n arg.kind,\n arg.optional,\n arg.kind !== CommandParameterKinds.boolean && arg.variadic,\n title,\n arg.default\n ),\n env: arg.name\n ? arg.env || arg.env === false\n ? arg.env\n : ctx.input.context.config.autoAssignEnv\n ? constantCase(name)\n : false\n : false\n };\n });\n}\n\nexport function applyDefaults(ctx: ResolverContext) {\n ctx.output.description ??= `The ${ctx.output.title.replace(/(?:c|C)ommands?$/, \"\").trim()} executable command-line interface.`;\n if (\n isSetString(ctx.input.context.config.reference?.commands) &&\n ctx.input.context.config.reference.commands.includes(\"{command}\")\n ) {\n ctx.output.reference ??= ctx.input.context.config.reference.commands\n ? ctx.input.context.config.reference.commands.replace(\n \"{command}\",\n ctx.input.command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\")\n )\n : undefined;\n }\n}\n\nexport function resolveVirtualCommand<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n ctx.output.title ??= titleCase(ctx.input.command.name);\n ctx.output.description ??= `A collection of available ${\n ctx.output.title.replace(/(?:c|C)ommands?$/, \"\").trim() ||\n titleCase(ctx.input.command.name)\n } commands that are included in the ${getAppTitle(\n ctx.input.context,\n true\n )} command-line application.`;\n}\n\n/**\n * Merges two command parameters, giving precedence to string values in the second configuration.\n *\n * @param objA - The first command parameter object.\n * @param objB - The second command parameter object.\n * @returns The merged command parameter object.\n */\nexport const mergeCommandParameter = createDefu((obj, key, value) => {\n if (isString(obj[key]) && isString(value)) {\n if (isSetString(value)) {\n obj[key] = value;\n }\n\n return true;\n } else if (Array.isArray(obj[key]) && Array.isArray(value)) {\n if (value.length > 0) {\n obj[key] = getUniqueBy((obj[key] as unknown[]).concat(value), item =>\n isString(item) ? item : JSON.stringify(item)\n ) as (typeof obj)[typeof key];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A;AACT,KAAI,OAAK,UAAA,UAAA,IAAA,MAAA,QAAA,KAAA;AACT,KAAI,OAAI,gBAAc,6BAAe,IAAA,OAAA,MAAA,QAAA,oBAAA,GAAA,CAAA,MAAA,IACjC,UAAQ,IAAM,MAAC,QAAA,KAAA,CAAA,qCAAA,YAAA,IAAA,MAAA,SAAA,KAAA,CAAA;;AAEvB,sBAAkB,SAAa;CAAA;CAAI;CAAA;CAAA;CAAA;;;;;;;;AAQnC,MAAO,wBAA8B,WAAE,cAAkB,KAAA,KAAe,UAAG;AACzE,KAAM,SAAK,IAAO,KAAK,IAAK,SAAS,MAAE,EAAA;AACrC,MAAM,YAAW,MAAS,CACpB,KAAM,OAAM;AAElB,SAAO;YAED,MAAA,QAAA,IAAA,KAAA,IAAA,MAAA,QAAA,MAAA,EAAA;AACJ,MAAK,MAAA,SAAA,EACL,KAAA,OAAW,YAAA,IAAA,KAAA,OAAA,MAAA,EAAA,cAAA,SAAA,SAAA,KAAA,GAAA,OAAA,KAAA,UAAA,KAAA,EAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;AAET,SAAA;;AAEJ,QAAM;GACP;CAAC;CAAM;CAAI;CAAQ;CAAA;CAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"helpers.mjs","names":[],"sources":["../../src/resolver/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 { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { createDefu } from \"defu\";\nimport {\n getAppTitle,\n isDynamicPathSegment\n} from \"../plugin-utils/context-helpers\";\nimport type { CommandArgument, CommandParameterKind } from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport type { ResolverContext } from \"./types\";\n\n/**\n * Resolves the description for a command option based on its reflection.\n *\n * @param name - The name of the command option.\n * @param kind - The reflection kind of the command option.\n * @param optional - Whether the command option is optional.\n * @param variadic - Whether the command option is variadic (i.e., an array).\n * @param title - The title of the command option, if any.\n * @param defaultValue - The default value of the command option, if any.\n * @returns The resolved description for the command option.\n */\nexport function resolveCommandOptionDescription(\n name: string,\n kind: CommandParameterKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `A${optional && !defaultValue ? \"n optional\" : \"\"} command-line ${\n kind === CommandParameterKinds.boolean ? \"flag\" : \"option\"\n } that allows the user to ${\n kind === CommandParameterKinds.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === CommandParameterKinds.boolean\n ? \"indicator\"\n : `${kind === CommandParameterKinds.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\n/**\n * Resolves the description for a command argument based on its reflection.\n *\n * @param name - The name of the command argument.\n * @param kind - The reflection kind of the command argument.\n * @param optional - Whether the command argument is optional.\n * @param variadic - Whether the command argument is variadic (i.e., an array).\n * @param title - The title of the command argument, if any.\n * @param defaultValue - The default value of the command argument, if any.\n * @returns The resolved description for the command argument.\n */\nexport function resolveCommandArgumentDescription(\n name: string,\n kind: CommandParameterKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `An${\n optional && !defaultValue ? \" optional\" : \"\"\n } argument that allows the user to ${\n kind === CommandParameterKinds.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === CommandParameterKinds.boolean\n ? \"indicator\"\n : `${kind === CommandParameterKinds.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\nexport function applyOptionsDefaults(ctx: ResolverContext) {\n return Object.fromEntries(\n Object.entries(ctx.output.options).map(([key, option]) => {\n const name = option.name || key;\n const title = option.title || titleCase(name);\n\n return [\n key,\n {\n ...option,\n name,\n title,\n description:\n option.description ||\n resolveCommandOptionDescription(\n name,\n option.kind,\n option.optional,\n option.kind !== CommandParameterKinds.boolean && option.variadic,\n title,\n option.default\n ),\n env:\n option.env || option.env === false\n ? option.env\n : ctx.input.context.config.autoAssignEnv\n ? constantCase(name)\n : false\n }\n ];\n })\n );\n}\n\nexport function applyArgsDefaults(ctx: ResolverContext): CommandArgument[] {\n return ctx.output.args.map((arg, i) => {\n const name = arg.name || `arg${i + 1}`;\n const title = arg.title || titleCase(name);\n\n return {\n ...arg,\n name,\n title,\n description:\n arg.description ||\n resolveCommandArgumentDescription(\n name,\n arg.kind,\n arg.optional,\n arg.kind !== CommandParameterKinds.boolean && arg.variadic,\n title,\n arg.default\n ),\n env: arg.name\n ? arg.env || arg.env === false\n ? arg.env\n : ctx.input.context.config.autoAssignEnv\n ? constantCase(name)\n : false\n : false\n };\n });\n}\n\nexport function applyDefaults(ctx: ResolverContext) {\n ctx.output.description ??= `The ${ctx.output.title.replace(/(?:c|C)ommands?$/, \"\").trim()} executable command-line interface.`;\n if (\n isSetString(ctx.input.context.config.reference?.commands) &&\n ctx.input.context.config.reference.commands.includes(\"{command}\")\n ) {\n ctx.output.reference ??= ctx.input.context.config.reference.commands\n ? ctx.input.context.config.reference.commands.replace(\n \"{command}\",\n ctx.input.command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\")\n )\n : undefined;\n }\n}\n\nexport function resolveVirtualCommand<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n ctx.output.title ??= titleCase(ctx.input.command.name);\n ctx.output.description ??= `A collection of available ${\n ctx.output.title.replace(/(?:c|C)ommands?$/, \"\").trim() ||\n titleCase(ctx.input.command.name)\n } commands that are included in the ${getAppTitle(\n ctx.input.context,\n true\n )} command-line application.`;\n}\n\n/**\n * Merges two command parameters, giving precedence to string values in the second configuration.\n *\n * @param objA - The first command parameter object.\n * @param objB - The second command parameter object.\n * @returns The merged command parameter object.\n */\nexport const mergeCommandParameter = createDefu((obj, key, value) => {\n if (isString(obj[key]) && isString(value)) {\n if (isSetString(value)) {\n obj[key] = value;\n }\n\n return true;\n } else if (Array.isArray(obj[key]) && Array.isArray(value)) {\n if (value.length > 0) {\n obj[key] = getUniqueBy((obj[key] as unknown[]).concat(value), item =>\n isString(item) ? item : JSON.stringify(item)\n ) as (typeof obj)[typeof key];\n }\n\n return true;\n }\n\n return false;\n});\n"],"mappings":";;;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;;;;;;AAsCX,SAAgB,gCAA2B,MAAW,MAAG,WAAA,OAAA,WAAA,OAAA,OAAA,cAAA;AACrD,QAAM,IAAA,YAAe,CAAG,eAAe,eAAe,GAAA,gBAAc,SAAA,sBAAA,UAAA,SAAA,SAAA,2BAAA,SAAA,sBAAA,UACpE,YACF,WACK,mBACO,mBAAA,GAAA,OAAA,MAAA,IAAA,UAAA,KAAA,CAAA,GAAA,SAAA,sBAAA,UACN,cACE,GAAG,SAAK,sBAAA,SAAA,YAAA,SAAA,QAAA,WAAA,MAAA,KAAA;;AAElB,gCAAgB,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;AAYhB,SAAa,kCAAsB,MAAA,MAAA,WAAA,OAAA,WAAA,OAAA,OAAA,cAAA;AAC/B,QAAK,KAAA,YAAS,CAAA,eAAA,cAAA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AA;GAAA;GAAA,CAAA,CAAA;AAET,SAAA;;AAEJ,QAAM;GACP;CAAC;CAAM;CAAI;CAAQ;CAAA;CAAA,CAAA,CAAA"}
|
package/dist/resolver/module.cjs
CHANGED
|
@@ -26,6 +26,7 @@ async function initialize(input) {
|
|
|
26
26
|
alias: [],
|
|
27
27
|
icon: parent?.icon,
|
|
28
28
|
tags: parent?.tags ?? [],
|
|
29
|
+
source: "file",
|
|
29
30
|
...command,
|
|
30
31
|
title,
|
|
31
32
|
options: parent === null ? require_utilities.getGlobalOptions(context, command) : {},
|
|
@@ -36,12 +37,14 @@ async function initialize(input) {
|
|
|
36
37
|
};
|
|
37
38
|
if (!command.isVirtual) {
|
|
38
39
|
if (!command.entry.input?.file || !context.fs.existsSync(command.entry.input.file)) throw new Error(`${!command.entry.input?.file ? "Missing" : "Non-existent"} command entry file for "${command.name}"`);
|
|
39
|
-
context.debug(`Adding reflection for
|
|
40
|
+
context.debug(`Adding reflection for CLI command: ${command.id} (file: ${command.entry.input.file})`);
|
|
40
41
|
result.module = await (_powerlines_plugin_esbuild_helpers_resolve.resolveModule.Ω = [["CommandModule", "\"w!"]], (0, _powerlines_plugin_esbuild_helpers_resolve.resolveModule)(context, command.entry.input, {
|
|
41
42
|
name: command.title || (0, _stryke_string_format_title_case.titleCase)(command.name),
|
|
43
|
+
treeShaking: true,
|
|
44
|
+
resolve: { skipNodeModulesBundle: true },
|
|
42
45
|
plugins: [(0, _powerlines_deepkit_esbuild_plugin.esbuildPlugin)(context, {
|
|
43
46
|
reflection: "default",
|
|
44
|
-
|
|
47
|
+
level: "all"
|
|
45
48
|
})]
|
|
46
49
|
}));
|
|
47
50
|
}
|
|
@@ -211,9 +214,9 @@ resolve.__type = [
|
|
|
211
214
|
"input",
|
|
212
215
|
"CommandTree",
|
|
213
216
|
"resolve",
|
|
214
|
-
"
|
|
217
|
+
"Resolves a command tree from the given resolver input.",
|
|
218
|
+
"P\"w!2\"\"w#`/$?%"
|
|
215
219
|
];
|
|
216
220
|
|
|
217
221
|
//#endregion
|
|
218
|
-
exports.resolve = resolve;
|
|
219
|
-
//# sourceMappingURL=resolve.cjs.map
|
|
222
|
+
exports.resolve = resolve;
|
|
@@ -25,6 +25,7 @@ async function initialize(input) {
|
|
|
25
25
|
alias: [],
|
|
26
26
|
icon: parent?.icon,
|
|
27
27
|
tags: parent?.tags ?? [],
|
|
28
|
+
source: "file",
|
|
28
29
|
...command,
|
|
29
30
|
title,
|
|
30
31
|
options: parent === null ? getGlobalOptions(context, command) : {},
|
|
@@ -35,12 +36,14 @@ async function initialize(input) {
|
|
|
35
36
|
};
|
|
36
37
|
if (!command.isVirtual) {
|
|
37
38
|
if (!command.entry.input?.file || !context.fs.existsSync(command.entry.input.file)) throw new Error(`${!command.entry.input?.file ? "Missing" : "Non-existent"} command entry file for "${command.name}"`);
|
|
38
|
-
context.debug(`Adding reflection for
|
|
39
|
+
context.debug(`Adding reflection for CLI command: ${command.id} (file: ${command.entry.input.file})`);
|
|
39
40
|
result.module = await (resolveModule.Ω = [["CommandModule", "\"w!"]], resolveModule(context, command.entry.input, {
|
|
40
41
|
name: command.title || titleCase(command.name),
|
|
42
|
+
treeShaking: true,
|
|
43
|
+
resolve: { skipNodeModulesBundle: true },
|
|
41
44
|
plugins: [esbuildPlugin(context, {
|
|
42
45
|
reflection: "default",
|
|
43
|
-
|
|
46
|
+
level: "all"
|
|
44
47
|
})]
|
|
45
48
|
}));
|
|
46
49
|
}
|
|
@@ -210,7 +213,8 @@ resolve.__type = [
|
|
|
210
213
|
"input",
|
|
211
214
|
"CommandTree",
|
|
212
215
|
"resolve",
|
|
213
|
-
"
|
|
216
|
+
"Resolves a command tree from the given resolver input.",
|
|
217
|
+
"P\"w!2\"\"w#`/$?%"
|
|
214
218
|
];
|
|
215
219
|
|
|
216
220
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.mjs","names":[],"sources":["../../src/resolver/resolve.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 { esbuildPlugin } from \"@powerlines/deepkit/esbuild-plugin\";\nimport { ReflectionVisibility } from \"@powerlines/deepkit/vendor/type\";\nimport { resolveModule } from \"@powerlines/plugin-esbuild/helpers/resolve\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { getGlobalOptions } from \"../helpers/utilities\";\nimport {\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"../plugin-utils/context-helpers\";\nimport { extractType } from \"../plugin-utils/deepkit\";\nimport type { CommandModule, CommandTree, Context } from \"../types\";\nimport { resolveFromBytecode } from \"./deepkit\";\nimport {\n applyArgsDefaults,\n applyDefaults,\n applyOptionsDefaults,\n resolveVirtualCommand\n} from \"./helpers\";\nimport { resolveFromExports } from \"./module\";\nimport type { ResolverContext, ResolverInput } from \"./types\";\n\nasync function initialize<TContext extends Context = Context>(\n input: ResolverInput<TContext>\n): Promise<ResolverContext> {\n const { context, command, parent } = input;\n\n const title =\n command.title ||\n `${\n parent?.title\n ? `${\n parent.isVirtual\n ? parent.title.replace(/(?:c|C)ommands?$/, \"\").trim()\n : parent.title\n } - `\n : \"\"\n }${titleCase(command.name)}${command.isVirtual ? \" Commands\" : \"\"}`;\n\n const output = {\n alias: [],\n icon: parent?.icon,\n tags: parent?.tags ?? [],\n ...command,\n title,\n options: parent === null ? getGlobalOptions(context, command) : {},\n args: [],\n parent: parent ?? null,\n children: {}\n } as CommandTree;\n\n const result: ResolverContext = {\n input,\n output\n };\n\n if (!command.isVirtual) {\n if (\n !command.entry.input?.file ||\n !context.fs.existsSync(command.entry.input.file)\n ) {\n throw new Error(\n `${\n !command.entry.input?.file ? \"Missing\" : \"Non-existent\"\n } command entry file for \"${command.name}\"`\n );\n }\n\n context.debug(\n `Adding reflection for application command: ${command.id} (file: ${\n command.entry.input.file\n })`\n );\n\n result.module = await resolveModule<CommandModule>(\n context,\n command.entry.input,\n {\n name: command.title || titleCase(command.name),\n plugins: [\n esbuildPlugin(context, {\n reflection: \"default\",\n reflectionLevel: \"verbose\"\n })\n ]\n }\n );\n }\n\n return result;\n}\n\nasync function postprocess<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n): Promise<CommandTree> {\n ctx.output.options = applyOptionsDefaults(ctx);\n ctx.output.args = applyArgsDefaults(ctx);\n\n // Ensure unique argument names by appending an index suffix to duplicates\n ctx.output.args.forEach((arg, index) => {\n const found = ctx.output.args.findIndex(a => a.name === arg.name);\n if (\n (found !== -1 && found !== index) ||\n ctx.output.segments.some(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment) === arg.name\n )\n ) {\n arg.name += `_${\n ctx.output.segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(/_\\d+$/, \"\") === arg.name\n ).length +\n ctx.output.args.filter(a => a.name.replace(/_\\d+$/, \"\") === arg.name)\n .length\n }`;\n arg.env = arg.name\n ? arg.env || arg.env === false\n ? arg.env\n : ctx.input.context.config.autoAssignEnv\n ? constantCase(arg.name)\n : false\n : false;\n }\n });\n\n applyDefaults(ctx);\n\n if (ctx.input.context.env) {\n if (isSetObject(ctx.output.options)) {\n Object.values(ctx.output.options)\n .filter(option => Boolean(option.env))\n .forEach(option => {\n ctx.input.context.env.types.env.addProperty({\n name: option.env as string,\n optional: option.optional ? true : undefined,\n description: option.description,\n visibility: ReflectionVisibility.public,\n type: extractType(option),\n default: option.default,\n tags: {\n title: option.title,\n alias: option.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n });\n });\n }\n\n ctx.output.args\n .filter(arg => Boolean(arg.env))\n .forEach(arg =>\n ctx.input.context.env.types.env.addProperty({\n name: arg.env as string,\n optional: arg.optional ? true : undefined,\n description: arg.description,\n visibility: ReflectionVisibility.public,\n type: extractType(arg),\n default: arg.default,\n tags: {\n alias: arg.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n })\n );\n }\n\n await Promise.all(\n ctx.input.context.inputs\n .filter(\n input =>\n input.segments.filter(segment => !isDynamicPathSegment(segment))\n .length ===\n ctx.input.command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n ).length +\n 1 &&\n input.segments\n .slice(0, ctx.input.command.segments.length)\n .every(\n (value, index) => value === ctx.input.command.segments[index]\n )\n )\n .map(async input => {\n ctx.output.children[input.name] = await resolve<TContext>({\n context: ctx.input.context,\n command: input,\n parent: ctx.output\n });\n })\n );\n\n return ctx.output;\n}\n\n/**\n * Resolves a command tree from the given resolver input.\n *\n * @param input - The resolver input containing the context, command, and optional parent command tree.\n * @returns A promise that resolves to the resolved command tree.\n */\nexport async function resolve<TContext extends Context = Context>(\n input: ResolverInput<TContext>\n): Promise<CommandTree> {\n const ctx = await initialize<TContext>(input);\n\n if (!ctx.output.isVirtual) {\n await resolveFromExports(ctx);\n resolveFromBytecode(ctx);\n } else {\n resolveVirtualCommand(ctx);\n }\n\n return postprocess(ctx);\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AA+BX,eAAE,WAAiB,OAAA;CACjB,MAAA,EAAA,SAAa,SAAA,WAAA;CACb,MAAA,QAAA,QAAoB,SACpB,GAAA,QAAA,QACQ,GAAO,OAAC,YACT,OAAA,MAAqB,QAAQ,oBAAO,GAAA,CAAA,MAAA,GAC/B,OAAA,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A;CAAA;CAAA;CAAA;CAAA"}
|
|
1
|
+
{"version":3,"file":"resolve.mjs","names":[],"sources":["../../src/resolver/resolve.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 { esbuildPlugin } from \"@powerlines/deepkit/esbuild-plugin\";\nimport { ReflectionVisibility } from \"@powerlines/deepkit/vendor/type\";\nimport { resolveModule } from \"@powerlines/plugin-esbuild/helpers/resolve\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { getGlobalOptions } from \"../helpers/utilities\";\nimport {\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"../plugin-utils/context-helpers\";\nimport { extractType } from \"../plugin-utils/deepkit\";\nimport type { CommandModule, CommandTree, Context } from \"../types\";\nimport { resolveFromBytecode } from \"./deepkit\";\nimport {\n applyArgsDefaults,\n applyDefaults,\n applyOptionsDefaults,\n resolveVirtualCommand\n} from \"./helpers\";\nimport { resolveFromExports } from \"./module\";\nimport type { ResolverContext, ResolverInput } from \"./types\";\n\nasync function initialize<TContext extends Context = Context>(\n input: ResolverInput<TContext>\n): Promise<ResolverContext> {\n const { context, command, parent } = input;\n\n const title =\n command.title ||\n `${\n parent?.title\n ? `${\n parent.isVirtual\n ? parent.title.replace(/(?:c|C)ommands?$/, \"\").trim()\n : parent.title\n } - `\n : \"\"\n }${titleCase(command.name)}${command.isVirtual ? \" Commands\" : \"\"}`;\n\n const output = {\n alias: [],\n icon: parent?.icon,\n tags: parent?.tags ?? [],\n source: \"file\",\n ...command,\n title,\n options: parent === null ? getGlobalOptions(context, command) : {},\n args: [],\n parent: parent ?? null,\n children: {}\n } as CommandTree;\n\n const result: ResolverContext = {\n input,\n output\n };\n\n if (!command.isVirtual) {\n if (\n !command.entry.input?.file ||\n !context.fs.existsSync(command.entry.input.file)\n ) {\n throw new Error(\n `${\n !command.entry.input?.file ? \"Missing\" : \"Non-existent\"\n } command entry file for \"${command.name}\"`\n );\n }\n\n context.debug(\n `Adding reflection for CLI command: ${command.id} (file: ${\n command.entry.input.file\n })`\n );\n\n result.module = await resolveModule<CommandModule>(\n context,\n command.entry.input,\n {\n name: command.title || titleCase(command.name),\n treeShaking: true,\n resolve: {\n skipNodeModulesBundle: true\n },\n plugins: [\n esbuildPlugin(context, {\n reflection: \"default\",\n level: \"all\"\n })\n ]\n }\n );\n }\n\n return result;\n}\n\nasync function postprocess<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n): Promise<CommandTree> {\n ctx.output.options = applyOptionsDefaults(ctx);\n ctx.output.args = applyArgsDefaults(ctx);\n\n // Ensure unique argument names by appending an index suffix to duplicates\n ctx.output.args.forEach((arg, index) => {\n const found = ctx.output.args.findIndex(a => a.name === arg.name);\n if (\n (found !== -1 && found !== index) ||\n ctx.output.segments.some(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment) === arg.name\n )\n ) {\n arg.name += `_${\n ctx.output.segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(/_\\d+$/, \"\") === arg.name\n ).length +\n ctx.output.args.filter(a => a.name.replace(/_\\d+$/, \"\") === arg.name)\n .length\n }`;\n arg.env = arg.name\n ? arg.env || arg.env === false\n ? arg.env\n : ctx.input.context.config.autoAssignEnv\n ? constantCase(arg.name)\n : false\n : false;\n }\n });\n\n applyDefaults(ctx);\n\n if (ctx.input.context.env) {\n if (isSetObject(ctx.output.options)) {\n Object.values(ctx.output.options)\n .filter(option => Boolean(option.env))\n .forEach(option => {\n ctx.input.context.env.types.env.addProperty({\n name: option.env as string,\n optional: option.optional ? true : undefined,\n description: option.description,\n visibility: ReflectionVisibility.public,\n type: extractType(option),\n default: option.default,\n tags: {\n title: option.title,\n alias: option.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n });\n });\n }\n\n ctx.output.args\n .filter(arg => Boolean(arg.env))\n .forEach(arg =>\n ctx.input.context.env.types.env.addProperty({\n name: arg.env as string,\n optional: arg.optional ? true : undefined,\n description: arg.description,\n visibility: ReflectionVisibility.public,\n type: extractType(arg),\n default: arg.default,\n tags: {\n alias: arg.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n })\n );\n }\n\n await Promise.all(\n ctx.input.context.inputs\n .filter(\n input =>\n input.segments.filter(segment => !isDynamicPathSegment(segment))\n .length ===\n ctx.input.command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n ).length +\n 1 &&\n input.segments\n .slice(0, ctx.input.command.segments.length)\n .every(\n (value, index) => value === ctx.input.command.segments[index]\n )\n )\n .map(async input => {\n ctx.output.children[input.name] = await resolve<TContext>({\n context: ctx.input.context,\n command: input,\n parent: ctx.output\n });\n })\n );\n\n return ctx.output;\n}\n\n/**\n * Resolves a command tree from the given resolver input.\n *\n * @param input - The resolver input containing the context, command, and optional parent command tree.\n * @returns A promise that resolves to the resolved command tree.\n */\nexport async function resolve<TContext extends Context = Context>(\n input: ResolverInput<TContext>\n): Promise<CommandTree> {\n const ctx = await initialize<TContext>(input);\n\n if (!ctx.output.isVirtual) {\n await resolveFromExports(ctx);\n resolveFromBytecode(ctx);\n } else {\n resolveVirtualCommand(ctx);\n }\n\n return postprocess(ctx);\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AA+BX,eAAE,WAAiB,OAAA;CACj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C;CAAY;CAAA;CAAA;;;;;;;AAOtD,eAAkB,QAAA,OAAA;CACd,MAAM,MAAI,OAAO,WAAY,IAAA,CAAA;QAAA;EAAA;EAAA;EAAA,CAAA,EAAA,WAAA,MAAA;AAC7B,KAAI,CAAC,IAAI,OAAO,WAAQ;AACpB,QAAM,mBAAmB,IAAA;AACzB,sBAAoB,IAAE;OAGtB,uBAAI,IAAA;AAER,QAAA,YAAA,IAAA;;AAEJ,QAAQ,SAAO;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
|
package/dist/types/command.cjs
CHANGED
|
@@ -46,23 +46,33 @@ const __ΩCommandParameterKind = [
|
|
|
46
46
|
];
|
|
47
47
|
const __ΩBaseCommandParameter = [
|
|
48
48
|
"name",
|
|
49
|
+
"The option name.",
|
|
49
50
|
() => __ΩCommandParameterKind,
|
|
50
51
|
"kind",
|
|
52
|
+
"The option kind.",
|
|
51
53
|
"title",
|
|
54
|
+
"The display title.",
|
|
52
55
|
"description",
|
|
56
|
+
"The option description.",
|
|
53
57
|
"alias",
|
|
58
|
+
"Alternative option names.",
|
|
54
59
|
false,
|
|
55
60
|
"env",
|
|
61
|
+
"The environment variable name or false to disable.",
|
|
56
62
|
"optional",
|
|
63
|
+
"Whether the option is optional.",
|
|
57
64
|
"variadic",
|
|
65
|
+
"Whether the option accepts multiple values.",
|
|
58
66
|
"BaseCommandParameter",
|
|
59
|
-
"P&4
|
|
67
|
+
"P&4!?\"n#4$?%&4&?'&4(?)&F4*?+P&.,J4-?.)4/?0)41?2Mw3y"
|
|
60
68
|
];
|
|
61
69
|
const __ΩStringCommandParameter = [
|
|
62
70
|
() => __ΩBaseCommandParameter,
|
|
63
71
|
"string",
|
|
64
72
|
"kind",
|
|
73
|
+
"The option kind.",
|
|
65
74
|
"default",
|
|
75
|
+
"The default value.",
|
|
66
76
|
"email",
|
|
67
77
|
"uri",
|
|
68
78
|
"uuid",
|
|
@@ -73,26 +83,33 @@ const __ΩStringCommandParameter = [
|
|
|
73
83
|
"date-time",
|
|
74
84
|
"duration",
|
|
75
85
|
"format",
|
|
86
|
+
"A standard string format to validate the option value against.",
|
|
76
87
|
"choices",
|
|
88
|
+
"The allowed choices for the option value.",
|
|
77
89
|
"StringCommandParameter",
|
|
78
|
-
"Pn!.\"4
|
|
90
|
+
"Pn!.\"4#?$&4%8?&P.'.(.).*.+.,.-.../J408?1&F428?3Mw4y"
|
|
79
91
|
];
|
|
80
92
|
const __ΩNumberCommandParameter = [
|
|
81
93
|
() => __ΩBaseCommandParameter,
|
|
82
94
|
"number",
|
|
83
95
|
"kind",
|
|
96
|
+
"The option kind.",
|
|
84
97
|
"default",
|
|
98
|
+
"The default value.",
|
|
85
99
|
"choices",
|
|
100
|
+
"The allowed choices for the option value.",
|
|
86
101
|
"NumberCommandParameter",
|
|
87
|
-
"Pn!.\"4
|
|
102
|
+
"Pn!.\"4#?$'4%8?&'F4'8?(Mw)y"
|
|
88
103
|
];
|
|
89
104
|
const __ΩBooleanCommandParameter = [
|
|
90
105
|
() => __ΩBaseCommandParameter,
|
|
91
106
|
"boolean",
|
|
92
107
|
"kind",
|
|
108
|
+
"The option kind.",
|
|
93
109
|
"default",
|
|
110
|
+
"The default value.",
|
|
94
111
|
"BooleanCommandParameter",
|
|
95
|
-
"Pn!.\"4
|
|
112
|
+
"Pn!.\"4#?$)4%8?&Mw'y"
|
|
96
113
|
];
|
|
97
114
|
const __ΩCommandParameter = [
|
|
98
115
|
() => __ΩStringCommandParameter,
|
|
@@ -142,9 +159,11 @@ const __ΩCommandParameterConfig = [
|
|
|
142
159
|
const __ΩBooleanCommandOption = [
|
|
143
160
|
() => __ΩBooleanCommandParameter,
|
|
144
161
|
"isNegativeOf",
|
|
162
|
+
"The option this negates.",
|
|
145
163
|
"skipAddingNegative",
|
|
164
|
+
"Whether to skip adding a negative option.",
|
|
146
165
|
"BooleanCommandOption",
|
|
147
|
-
"Pn!&4\"8)4
|
|
166
|
+
"Pn!&4\"8?#)4$8?%Mw&y"
|
|
148
167
|
];
|
|
149
168
|
const __ΩCommandOption = [
|
|
150
169
|
() => __ΩStringCommandParameter,
|
|
@@ -174,44 +193,71 @@ const __ΩCommandArgumentConfig = [
|
|
|
174
193
|
];
|
|
175
194
|
const __ΩCommandBase = [
|
|
176
195
|
"id",
|
|
196
|
+
"The command id.",
|
|
177
197
|
"name",
|
|
198
|
+
"The command name.",
|
|
178
199
|
"path",
|
|
200
|
+
"The full command path value.",
|
|
179
201
|
"segments",
|
|
202
|
+
"The path segments.",
|
|
180
203
|
"title",
|
|
204
|
+
"The display title.",
|
|
181
205
|
"description",
|
|
206
|
+
"The command description.",
|
|
182
207
|
"alias",
|
|
208
|
+
"Alternative command names.",
|
|
183
209
|
"icon",
|
|
210
|
+
"The command icon.",
|
|
184
211
|
"reference",
|
|
212
|
+
"A URL to the command documentation or reference.",
|
|
185
213
|
"isVirtual",
|
|
214
|
+
"Whether the command is virtual.",
|
|
186
215
|
"CommandBase",
|
|
187
|
-
"PP&,J4
|
|
216
|
+
"PP&,J4!?\"&4#?$P&,J4%?&&F4'?(&4)8?*&4+8?,&F4-8?.&4/8?0&418?2)43?4Mw5y"
|
|
188
217
|
];
|
|
189
218
|
const __ΩCommandConfig = [
|
|
190
219
|
() => __ΩCommandBase,
|
|
191
220
|
"id",
|
|
221
|
+
"The command id.",
|
|
192
222
|
"entry",
|
|
223
|
+
"The resolved entry definition.",
|
|
193
224
|
"tags",
|
|
225
|
+
"Optional tags for the command.",
|
|
226
|
+
"file",
|
|
227
|
+
"source",
|
|
228
|
+
"A string representing the source of the command, which can be \"file\", a specific plugin name, or any other string value that describes the source that added the command.",
|
|
194
229
|
"CommandConfig",
|
|
195
|
-
"Pn!&4\"
|
|
230
|
+
"Pn!&4\"?#!4$?%&F4&8?'P.(&J4)8?*Mw+y"
|
|
196
231
|
];
|
|
197
232
|
const __ΩCommandTree = [
|
|
198
233
|
() => __ΩCommandConfig,
|
|
199
234
|
"title",
|
|
235
|
+
"The display title.",
|
|
200
236
|
"description",
|
|
237
|
+
"The command description.",
|
|
201
238
|
"alias",
|
|
239
|
+
"Alternative command names.",
|
|
202
240
|
"tags",
|
|
241
|
+
"A set of tags for the command.",
|
|
242
|
+
"file",
|
|
243
|
+
"source",
|
|
244
|
+
"A string representing the source of the command, which can be \"file\", a specific plugin name, or any other string value that describes the source that added the command.",
|
|
203
245
|
() => __ΩRecord,
|
|
204
246
|
() => __ΩCommandOption,
|
|
205
247
|
"options",
|
|
248
|
+
"The command options.",
|
|
206
249
|
() => __ΩCommandArgument,
|
|
207
250
|
"args",
|
|
251
|
+
"The positional arguments provided to the command.",
|
|
208
252
|
0,
|
|
209
253
|
"parent",
|
|
254
|
+
"The parent command.",
|
|
210
255
|
() => __ΩRecord,
|
|
211
256
|
0,
|
|
212
257
|
"children",
|
|
258
|
+
"Child commands.",
|
|
213
259
|
"CommandTree",
|
|
214
|
-
"Pn!P&4\"
|
|
260
|
+
"Pn!P&4\"?#&4$?%&F4&?'&F4(?)P.*&J4+?,&n.o-#4/?0n1F42?3P,n4J45?6&n8o7#49?:MKw;y"
|
|
215
261
|
];
|
|
216
262
|
const __ΩSerializedCommandTree = [
|
|
217
263
|
() => __ΩOmit,
|
|
@@ -219,21 +265,29 @@ const __ΩSerializedCommandTree = [
|
|
|
219
265
|
"parent",
|
|
220
266
|
"children",
|
|
221
267
|
"parent",
|
|
268
|
+
"The parent command id.",
|
|
222
269
|
() => __ΩRecord,
|
|
223
270
|
0,
|
|
224
271
|
"children",
|
|
272
|
+
"Serialized child commands.",
|
|
225
273
|
"SerializedCommandTree",
|
|
226
|
-
"Pn\"P.#.$Jo!#PP,&J4
|
|
274
|
+
"Pn\"P.#.$Jo!#PP,&J4%?&&n(o'#4)?*MKw+y"
|
|
227
275
|
];
|
|
228
276
|
const __ΩCommandMetadata = [
|
|
229
277
|
"title",
|
|
278
|
+
"The display name of the command.",
|
|
230
279
|
"description",
|
|
280
|
+
"A brief description of what the command does.",
|
|
231
281
|
"alias",
|
|
282
|
+
"One or more alternative names for the command.",
|
|
232
283
|
"tags",
|
|
284
|
+
"Optional tags for the command.",
|
|
233
285
|
"icon",
|
|
286
|
+
"An optional icon to visually represent the command in user interfaces.",
|
|
234
287
|
"reference",
|
|
288
|
+
"A URL to the command documentation or reference.",
|
|
235
289
|
"CommandMetadata",
|
|
236
|
-
"P&4!8&4
|
|
290
|
+
"P&4!8?\"&4#8?$P&&FJ4%8?&&F4'8?(&4)8?*&4+8?,Mw-y"
|
|
237
291
|
];
|
|
238
292
|
const __ΩCommandModule = [
|
|
239
293
|
() => __ΩCommandMetadata,
|
|
@@ -274,5 +328,4 @@ exports.__ΩNumberCommandParameter = __ΩNumberCommandParameter;
|
|
|
274
328
|
exports.__ΩNumberCommandParameterConfig = __ΩNumberCommandParameterConfig;
|
|
275
329
|
exports.__ΩSerializedCommandTree = __ΩSerializedCommandTree;
|
|
276
330
|
exports.__ΩStringCommandParameter = __ΩStringCommandParameter;
|
|
277
|
-
exports.__ΩStringCommandParameterConfig = __ΩStringCommandParameterConfig;
|
|
278
|
-
//# sourceMappingURL=command.cjs.map
|
|
331
|
+
exports.__ΩStringCommandParameterConfig = __ΩStringCommandParameterConfig;
|
package/dist/types/command.d.cts
CHANGED
|
@@ -172,6 +172,10 @@ interface CommandConfig extends CommandBase {
|
|
|
172
172
|
* Tags can be used to categorize and organize commands, and can also be utilized by plugins to provide additional functionality or filtering based on tags.
|
|
173
173
|
*/
|
|
174
174
|
tags?: string[];
|
|
175
|
+
/**
|
|
176
|
+
* A string representing the source of the command, which can be "file", a specific plugin name, or any other string value that describes the source that added the command.
|
|
177
|
+
*/
|
|
178
|
+
source?: "file" | string;
|
|
175
179
|
}
|
|
176
180
|
type CommandTree = CommandConfig & {
|
|
177
181
|
/**
|
|
@@ -187,12 +191,16 @@ type CommandTree = CommandConfig & {
|
|
|
187
191
|
*/
|
|
188
192
|
alias: string[];
|
|
189
193
|
/**
|
|
190
|
-
*
|
|
194
|
+
* A set of tags for the command.
|
|
191
195
|
*
|
|
192
196
|
* @remarks
|
|
193
197
|
* Tags can be used to categorize and organize commands, and can also be utilized by plugins to provide additional functionality or filtering based on tags.
|
|
194
198
|
*/
|
|
195
199
|
tags: string[];
|
|
200
|
+
/**
|
|
201
|
+
* A string representing the source of the command, which can be "file", a specific plugin name, or any other string value that describes the source that added the command.
|
|
202
|
+
*/
|
|
203
|
+
source: "file" | string;
|
|
196
204
|
/**
|
|
197
205
|
* The command options.
|
|
198
206
|
*/
|