@shell-shock/core 0.9.7 → 0.11.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 +1 -2
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.cts +1 -1
- package/dist/api.d.mts +1 -1
- package/dist/api.mjs +1 -2
- package/dist/api.mjs.map +1 -1
- package/dist/components/docs.cjs +4 -4
- package/dist/components/docs.cjs.map +1 -1
- package/dist/components/docs.d.cts +5 -5
- 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/helpers.d.mts.map +1 -1
- 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.cjs +31 -31
- package/dist/components/options-parser-logic.cjs.map +1 -1
- package/dist/components/options-parser-logic.d.cts +9 -9
- package/dist/components/options-parser-logic.d.cts.map +1 -1
- package/dist/components/options-parser-logic.d.mts +9 -9
- package/dist/components/options-parser-logic.d.mts.map +1 -1
- package/dist/components/options-parser-logic.mjs +26 -26
- package/dist/components/options-parser-logic.mjs.map +1 -1
- package/dist/components/usage.cjs +5 -5
- package/dist/components/usage.cjs.map +1 -1
- package/dist/components/usage.d.cts +2 -2
- package/dist/components/usage.d.cts.map +1 -1
- package/dist/components/usage.mjs +4 -4
- package/dist/components/usage.mjs.map +1 -1
- package/dist/components/utils-builtin.cjs +204 -0
- package/dist/components/utils-builtin.cjs.map +1 -1
- package/dist/components/utils-builtin.d.cts +13 -9
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts +13 -9
- package/dist/components/utils-builtin.d.mts.map +1 -1
- package/dist/components/utils-builtin.mjs +208 -5
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/contexts/options.cjs +2 -2
- package/dist/contexts/options.cjs.map +1 -1
- package/dist/contexts/options.d.cts +1 -1
- package/dist/contexts/options.d.cts.map +1 -1
- package/dist/contexts/options.d.mts +1 -1
- package/dist/contexts/options.d.mts.map +1 -1
- package/dist/contexts/options.mjs +4 -4
- package/dist/contexts/options.mjs.map +1 -1
- package/dist/helpers/automd.cjs +2 -2
- package/dist/helpers/automd.cjs.map +1 -1
- package/dist/helpers/automd.mjs.map +1 -1
- package/dist/helpers/docs-helpers.cjs +1 -1
- package/dist/helpers/docs-helpers.cjs.map +1 -1
- package/dist/helpers/docs-helpers.mjs +1 -1
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/paths.cjs +125 -0
- package/dist/helpers/paths.cjs.map +1 -0
- package/dist/helpers/paths.mjs +121 -0
- package/dist/helpers/paths.mjs.map +1 -0
- package/dist/helpers/persistence.cjs +68 -116
- package/dist/helpers/persistence.cjs.map +1 -1
- package/dist/helpers/persistence.mjs +68 -116
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +5 -5
- package/dist/helpers/update-package-json.cjs.map +1 -1
- package/dist/helpers/update-package-json.mjs +1 -1
- package/dist/helpers/update-package-json.mjs.map +1 -1
- package/dist/helpers/utilities.cjs +1 -1
- package/dist/helpers/utilities.mjs +1 -1
- package/dist/helpers/validations.cjs +2 -3
- package/dist/helpers/validations.cjs.map +1 -1
- package/dist/helpers/validations.mjs +2 -2
- package/dist/helpers/validations.mjs.map +1 -1
- package/dist/index.cjs +14 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -4
- package/dist/index.d.mts +2 -4
- package/dist/index.mjs +3 -5
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-utils/deepkit.cjs +72 -0
- package/dist/plugin-utils/deepkit.cjs.map +1 -0
- package/dist/plugin-utils/deepkit.d.cts +24 -0
- package/dist/plugin-utils/deepkit.d.cts.map +1 -0
- package/dist/plugin-utils/deepkit.d.mts +24 -0
- package/dist/plugin-utils/deepkit.d.mts.map +1 -0
- package/dist/plugin-utils/deepkit.mjs +70 -0
- package/dist/plugin-utils/deepkit.mjs.map +1 -0
- package/dist/plugin-utils/get-command-tree.cjs +2 -2
- package/dist/plugin-utils/get-command-tree.cjs.map +1 -1
- package/dist/plugin-utils/index.cjs +27 -18
- package/dist/plugin-utils/index.d.cts +3 -1
- package/dist/plugin-utils/index.d.mts +3 -1
- package/dist/plugin-utils/index.mjs +3 -1
- package/dist/plugin-utils/reflect.cjs +4 -5
- package/dist/plugin-utils/reflect.cjs.map +1 -1
- package/dist/plugin-utils/reflect.mjs +4 -4
- package/dist/plugin-utils/reflect.mjs.map +1 -1
- package/dist/plugin-utils/type-checks.cjs +89 -0
- package/dist/plugin-utils/type-checks.cjs.map +1 -0
- package/dist/plugin-utils/type-checks.d.cts +42 -0
- package/dist/plugin-utils/type-checks.d.cts.map +1 -0
- package/dist/plugin-utils/type-checks.d.mts +42 -0
- package/dist/plugin-utils/type-checks.d.mts.map +1 -0
- package/dist/plugin-utils/type-checks.mjs +84 -0
- package/dist/plugin-utils/type-checks.mjs.map +1 -0
- package/dist/plugin.cjs +48 -45
- 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 +30 -26
- package/dist/plugin.mjs.map +1 -1
- package/dist/resolver/deepkit.cjs +129 -0
- package/dist/resolver/deepkit.cjs.map +1 -0
- package/dist/resolver/deepkit.mjs +128 -0
- package/dist/resolver/deepkit.mjs.map +1 -0
- package/dist/resolver/helpers.cjs +173 -0
- package/dist/resolver/helpers.cjs.map +1 -0
- package/dist/resolver/helpers.mjs +168 -0
- package/dist/resolver/helpers.mjs.map +1 -0
- package/dist/resolver/module.cjs +144 -0
- package/dist/resolver/module.cjs.map +1 -0
- package/dist/resolver/module.mjs +143 -0
- package/dist/resolver/module.mjs.map +1 -0
- package/dist/resolver/resolve.cjs +209 -0
- package/dist/resolver/resolve.cjs.map +1 -0
- package/dist/resolver/resolve.mjs +208 -0
- package/dist/resolver/resolve.mjs.map +1 -0
- package/dist/types/command.cjs +131 -99
- package/dist/types/command.cjs.map +1 -1
- package/dist/types/command.d.cts +49 -75
- package/dist/types/command.d.cts.map +1 -1
- package/dist/types/command.d.mts +49 -75
- package/dist/types/command.d.mts.map +1 -1
- package/dist/types/command.mjs +119 -91
- package/dist/types/command.mjs.map +1 -1
- package/dist/types/config.cjs +1 -2
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.cts +2 -2
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +2 -2
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +1 -2
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/context.cjs +1 -1
- package/dist/types/context.cjs.map +1 -1
- package/dist/types/context.d.cts +3 -3
- package/dist/types/context.d.cts.map +1 -1
- package/dist/types/context.d.mts +3 -3
- package/dist/types/context.d.mts.map +1 -1
- package/dist/types/context.mjs +1 -1
- package/dist/types/context.mjs.map +1 -1
- package/dist/types/index.cjs +13 -9
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.mjs +2 -2
- package/package.json +34 -79
- package/dist/helpers/resolve-command.cjs +0 -410
- package/dist/helpers/resolve-command.cjs.map +0 -1
- package/dist/helpers/resolve-command.mjs +0 -405
- package/dist/helpers/resolve-command.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deepkit.cjs","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 TypeLiteral\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 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 if (type === ReflectionKind.string) {\n return CommandParameterKinds.string;\n } else if (\n type === ReflectionKind.number ||\n type === ReflectionKind.bigint ||\n ((type as Type).kind === ReflectionKind.literal &&\n (isNumber((type as TypeLiteral).literal) ||\n isBigInt((type as TypeLiteral).literal)))\n ) {\n return CommandParameterKinds.number;\n } else if (type === 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 (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (option as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind((type as TypeArray).type.kind) as\n | \"string\"\n | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\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[] and number[] 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 if (\n !existing.kind &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number &&\n type.kind !== ReflectionKind.boolean &&\n !(\n type.kind === ReflectionKind.array &&\n (type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\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 if (!existing.kind) {\n throw new Error(\n `Unsupported array type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\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 argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[] and number[] 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 && parameters[0]) {\n if (\n parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class\n ) {\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 } else if (!ctx.module?.options) {\n throw new Error(\n `The first parameter of the command handler function in \"${\n ctx.input.command.entry.input?.file || ctx.input.command.path\n }\" must be an object literal or class type representing the command options.`\n );\n }\n\n ctx.output.args = parameters\n .slice(1)\n .map((arg, index) => resolveCommandArgument(ctx, index, arg));\n }\n}\n"],"mappings":";;;;;;;;;AAEA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AAQX,SAAS,4BAA4B,MAAM;qEAEnC,QAAO,4CAAqB;UAEvB,SAAS,gDAAe,6EAE5B,KAAG,SAAA,gDAAA,yDACS,KAAA,QAAA,iDACD,KAAA,QAAA,EACd,QAAA,4CAAA;UAEM,SAAA,gDAAA,QACJ,QAAO,4CAAsB;KAG7B,QAAO,4CAAE;;AAGjB,4BAAc,SAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AACd,SAAS,qBAAqB,KAAK,YAAK;CACpC,MAAM,OAAO,WAAW,SAAS;CACjC,MAAM,WAAY,IAAI,OAAO,QAAQ,WAAW,iBAAI,KAChD,EAAG;CACP,MAAM,SAAE;EACJ,MAAM,WAAG,iBAAA;EACT,OAAO,WAAA,SAAA,CAAA,SAAA,EAAA;EACP,OAAO,WAAO,SAAA,CAAA,OAAA,MAAA;EACd,aAAC,WAAA,gBAAA;EACD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K,SAAS,gDAAW,OACzB,OAAM,IAAI,MAAM,kCAAoB,WAAA,SAAA,CAAA,gBAAA,IAAA,MAAA,QAAA,KAAA,qIAAA,KAAA,CAChC,MAAA,CACC,WAAO,OAAA,QAAA,CAAA,GAAA;AAEhB,QAAO,sCAAsB,UAAQ,UAAA,EACjC,MAAM,MAAM,SAChB,CAAA;;AAEJ,uBAAuB,SAAS;CAAC;CAAmB;CAAO;CAAS;CAAc;CAAA;CAAA;CAAA;CAAA;AAClF,SAAgB,oBAAa,KAAA;CACzB,MAAM,EAAE,OAAO,qBAAW;CAC1B,MAAM,qDAAC,SAAA;AACP,KAAE,KAAA,SAAA,gDAAA,SACE,OAAM,IAAA,MAAA,2BAAA,MAAA,QAAA,MAAA,OAAA,QAAA,MAAA,QAAA,KAAA,qCAAA;CAEV,MAAC,aAAA,IAAA,oDAAA,KAAA;AACH,KAAA,OAAA,gBAAA,IAAA,MAAA,QAAA,8CAEM,KAAK;CACb,MAAA,aAAA,WAAA,eAAA;;AAEQ,MAAI,WAAW,GAAG,KAAK,SAAA,gDAAA,iBACnB,WAAU,GAAA,KAAA,SAAA,gDAAA,OAAA;GACV,MAAG,oBAAA,iDAAA,KAAA,WAAA,GAAA,KAAA;AACH,QAAK,MAAM,sBAAS,kBAAA,eAAA,CAChB,KAAG,OAAA,QAAA,mBAAA,iBAAA,IACC,qBAAe,KAAA,mBAAA;aAGlB,CAAC,IAAI,QAAQ;AAGtB,MAAI,OAAO,OAAC,WACP,MAAM,EAAE,CACR,IAAI,cAAc,KAAK,UAAK,uBAAA,KAAA,OAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;;;AAGzC,oBAAoB,SAAS;CAAC;CAAY;CAAA;CAAA;CAAA"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { CommandParameterKinds } from "../types/command.mjs";
|
|
2
|
+
import { mergeCommandParameter } from "./helpers.mjs";
|
|
3
|
+
import { ReflectionClass, ReflectionFunction, ReflectionKind, __ΩReflectionKind, reflect, stringifyType } from "@powerlines/deepkit/vendor/type";
|
|
4
|
+
import { isBigInt } from "@stryke/type-checks/is-bigint";
|
|
5
|
+
import { isNumber } from "@stryke/type-checks/is-number";
|
|
6
|
+
import { isRegExp } from "@stryke/type-checks/is-regexp";
|
|
7
|
+
|
|
8
|
+
//#region src/resolver/deepkit.ts
|
|
9
|
+
function __assignType(fn, args) {
|
|
10
|
+
fn.__type = args;
|
|
11
|
+
return fn;
|
|
12
|
+
}
|
|
13
|
+
function extractCommandParameterKind(type) {
|
|
14
|
+
if (type === ReflectionKind.string) return CommandParameterKinds.string;
|
|
15
|
+
else if (type === ReflectionKind.number || type === ReflectionKind.bigint || type.kind === ReflectionKind.literal && (isNumber(type.literal) || isBigInt(type.literal))) return CommandParameterKinds.number;
|
|
16
|
+
else if (type === ReflectionKind.boolean) return CommandParameterKinds.boolean;
|
|
17
|
+
else return CommandParameterKinds.string;
|
|
18
|
+
}
|
|
19
|
+
extractCommandParameterKind.__type = [
|
|
20
|
+
"Type",
|
|
21
|
+
() => __ΩReflectionKind,
|
|
22
|
+
"type",
|
|
23
|
+
"CommandParameterKind",
|
|
24
|
+
"extractCommandParameterKind",
|
|
25
|
+
"PP\"w!n\"J2#\"w$/%"
|
|
26
|
+
];
|
|
27
|
+
function resolveCommandOption(ctx, reflection) {
|
|
28
|
+
const type = reflection.getType();
|
|
29
|
+
const existing = ctx.output.options[reflection.getNameAsString()] ?? {};
|
|
30
|
+
const option = {
|
|
31
|
+
name: reflection.getNameAsString(),
|
|
32
|
+
alias: reflection.getTags().alias ?? [],
|
|
33
|
+
title: reflection.getTags().title?.trim(),
|
|
34
|
+
description: reflection.getDescription(),
|
|
35
|
+
kind: extractCommandParameterKind(type),
|
|
36
|
+
optional: reflection.isOptional(),
|
|
37
|
+
default: reflection.getDefaultValue(),
|
|
38
|
+
variadic: reflection.isArray()
|
|
39
|
+
};
|
|
40
|
+
if (reflection.isArray()) if (type.type.kind === ReflectionKind.string || type.type.kind === ReflectionKind.number) {
|
|
41
|
+
option.variadic = true;
|
|
42
|
+
option.kind = extractCommandParameterKind(type.type.kind);
|
|
43
|
+
} else throw new Error(`Unsupported array type for option "${reflection.getNameAsString()}" in command "${ctx.input.command.name}". Only string[] and number[] are supported, received ${stringifyType(type).trim().replaceAll(" | ", ", or ")}.`);
|
|
44
|
+
else if (type.kind === ReflectionKind.union) {
|
|
45
|
+
option.kind = type.types.every(__assignType((t) => t.kind === ReflectionKind.number || t.kind === ReflectionKind.literal && (isNumber(t.literal) || isBigInt(t.literal)), [
|
|
46
|
+
"t",
|
|
47
|
+
"",
|
|
48
|
+
"P\"2!\"/\""
|
|
49
|
+
])) ? CommandParameterKinds.number : CommandParameterKinds.string;
|
|
50
|
+
option.choices = type.types.map(__assignType((t) => t.kind === ReflectionKind.literal ? isNumber(t.literal) ? t.literal : isBigInt(t.literal) ? Number(t.literal) : isRegExp(t.literal) ? t.literal.source : String(t.literal) : null, [
|
|
51
|
+
"t",
|
|
52
|
+
"",
|
|
53
|
+
"P\"2!\"/\""
|
|
54
|
+
])).filter(Boolean);
|
|
55
|
+
} else if (type.kind === ReflectionKind.literal) option.choices = [isNumber(type.literal) ? type.literal : isBigInt(type.literal) ? Number(type.literal) : isRegExp(type.literal) ? type.literal.source : String(type.literal)].filter(Boolean);
|
|
56
|
+
else if (!existing.kind && type.kind !== ReflectionKind.boolean && type.kind !== ReflectionKind.string && type.kind !== ReflectionKind.number) throw new Error(`Unsupported type for option "${reflection.getNameAsString()}" in command "${ctx.input.command.name}". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(type).trim().replaceAll(" | ", ", or ")}.`);
|
|
57
|
+
return mergeCommandParameter(existing, option);
|
|
58
|
+
}
|
|
59
|
+
resolveCommandOption.__type = [
|
|
60
|
+
"ResolverContext",
|
|
61
|
+
"ctx",
|
|
62
|
+
"ReflectionProperty",
|
|
63
|
+
"reflection",
|
|
64
|
+
"CommandOption",
|
|
65
|
+
"resolveCommandOption",
|
|
66
|
+
"P\"w!2\"\"w#2$\"w%/&"
|
|
67
|
+
];
|
|
68
|
+
function resolveCommandArgument(ctx, index, reflection) {
|
|
69
|
+
const type = reflection.getType();
|
|
70
|
+
const existing = ctx.output.args.length > index ? ctx.output.args[index] : {};
|
|
71
|
+
if (!existing.kind && type.kind !== ReflectionKind.string && type.kind !== ReflectionKind.number && type.kind !== ReflectionKind.boolean && !(type.kind === ReflectionKind.array && (type.type.kind === ReflectionKind.string || type.type.kind === ReflectionKind.number))) throw new Error(`Unsupported type for argument "${reflection.getName()}" in command "${ctx.input.command.name}". Only string types (or an array of strings) are supported, received ${stringifyType(type).trim().replaceAll(" | ", ", or ")}.`);
|
|
72
|
+
const argument = {
|
|
73
|
+
name: reflection.getName() || reflection.parameter.name,
|
|
74
|
+
alias: reflection.getAlias(),
|
|
75
|
+
kind: extractCommandParameterKind(type.kind),
|
|
76
|
+
title: reflection.getTitle() || reflection.parameter.tags?.title,
|
|
77
|
+
description: reflection.parameter.description,
|
|
78
|
+
optional: reflection.isOptional(),
|
|
79
|
+
default: reflection.getDefaultValue()
|
|
80
|
+
};
|
|
81
|
+
if (type.kind === ReflectionKind.array) {
|
|
82
|
+
if (type.type.kind === ReflectionKind.string || type.type.kind === ReflectionKind.number) {
|
|
83
|
+
argument.variadic = true;
|
|
84
|
+
argument.kind = extractCommandParameterKind(type.type.kind);
|
|
85
|
+
} else if (!existing.kind) throw new Error(`Unsupported array type for argument "${reflection.getName()}" in command "${ctx.input.command.name}". Only string[] and number[] are supported, received ${stringifyType(type).trim().replaceAll(" | ", ", or ")}.`);
|
|
86
|
+
} else if (!existing.kind && type.kind !== ReflectionKind.boolean && type.kind !== ReflectionKind.string && type.kind !== ReflectionKind.number) throw new Error(`Unsupported type for argument "${reflection.getName()}" in command "${ctx.input.command.name}". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(type).trim().replaceAll(" | ", ", or ")}.`);
|
|
87
|
+
return mergeCommandParameter(existing, argument, { name: `arg${index}` });
|
|
88
|
+
}
|
|
89
|
+
resolveCommandArgument.__type = [
|
|
90
|
+
"ResolverContext",
|
|
91
|
+
"ctx",
|
|
92
|
+
"index",
|
|
93
|
+
"ReflectionParameter",
|
|
94
|
+
"reflection",
|
|
95
|
+
"CommandArgument",
|
|
96
|
+
"resolveCommandArgument",
|
|
97
|
+
"P\"w!2\"'2#\"w$2%\"w&/'"
|
|
98
|
+
];
|
|
99
|
+
function resolveFromBytecode(ctx) {
|
|
100
|
+
const { input, module } = ctx;
|
|
101
|
+
const type = reflect(module);
|
|
102
|
+
if (type.kind !== ReflectionKind.function) throw new Error(`The command entry file "${input.command.entry.input?.file || input.command.path}" does not export a valid function.`);
|
|
103
|
+
const reflection = new ReflectionFunction(type);
|
|
104
|
+
ctx.output.description ??= ctx.input.command.description || reflection.getDescription() || type.description;
|
|
105
|
+
const parameters = reflection.getParameters();
|
|
106
|
+
if (parameters.length > 0 && parameters[0]) {
|
|
107
|
+
if (parameters[0].type.kind === ReflectionKind.objectLiteral || parameters[0].type.kind === ReflectionKind.class) {
|
|
108
|
+
const optionsReflection = ReflectionClass.from(parameters[0].type);
|
|
109
|
+
for (const propertyReflection of optionsReflection.getProperties()) ctx.output.options[propertyReflection.getNameAsString()] = resolveCommandOption(ctx, propertyReflection);
|
|
110
|
+
} else if (!ctx.module?.options) throw new Error(`The first parameter of the command handler function in "${ctx.input.command.entry.input?.file || ctx.input.command.path}" must be an object literal or class type representing the command options.`);
|
|
111
|
+
ctx.output.args = parameters.slice(1).map(__assignType((arg, index) => resolveCommandArgument(ctx, index, arg), [
|
|
112
|
+
"arg",
|
|
113
|
+
"index",
|
|
114
|
+
"",
|
|
115
|
+
"P\"2!\"2\"\"/#"
|
|
116
|
+
]));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
resolveFromBytecode.__type = [
|
|
120
|
+
"ResolverContext",
|
|
121
|
+
"ctx",
|
|
122
|
+
"resolveFromBytecode",
|
|
123
|
+
"P\"w!2\"\"/#"
|
|
124
|
+
];
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
export { resolveFromBytecode };
|
|
128
|
+
//# sourceMappingURL=deepkit.mjs.map
|
|
@@ -0,0 +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 TypeLiteral\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 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 if (type === ReflectionKind.string) {\n return CommandParameterKinds.string;\n } else if (\n type === ReflectionKind.number ||\n type === ReflectionKind.bigint ||\n ((type as Type).kind === ReflectionKind.literal &&\n (isNumber((type as TypeLiteral).literal) ||\n isBigInt((type as TypeLiteral).literal)))\n ) {\n return CommandParameterKinds.number;\n } else if (type === 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 (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (option as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind((type as TypeArray).type.kind) as\n | \"string\"\n | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\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[] and number[] 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 if (\n !existing.kind &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number &&\n type.kind !== ReflectionKind.boolean &&\n !(\n type.kind === ReflectionKind.array &&\n (type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\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 if (!existing.kind) {\n throw new Error(\n `Unsupported array type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\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 argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[] and number[] 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 && parameters[0]) {\n if (\n parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class\n ) {\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 } else if (!ctx.module?.options) {\n throw new Error(\n `The first parameter of the command handler function in \"${\n ctx.input.command.entry.input?.file || ctx.input.command.path\n }\" must be an object literal or class type representing the command options.`\n );\n }\n\n ctx.output.args = parameters\n .slice(1)\n .map((arg, index) => resolveCommandArgument(ctx, index, arg));\n }\n}\n"],"mappings":";;;;;;;;AAEA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AAQX,SAAS,4BAA4B,MAAM;oCAEnC,QAAO,sBAAqB;UAE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AA,KAAA,SAAA,eAAA,OAAA;GACV,MAAG,oBAAA,gBAAA,KAAA,WAAA,GAAA,KAAA;AACH,QAAK,MAAM,sBAAS,kBAAA,eAAA,CAChB,KAAG,OAAA,QAAA,mBAAA,iBAAA,IACC,qBAAe,KAAA,mBAAA;aAGlB,CAAC,IAAI,QAAQ;AAGtB,MAAI,OAAO,OAAC,WACP,MAAM,EAAE,CACR,IAAI,cAAc,KAAK,UAAK,uBAAA,KAAA,OAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;;;AAGzC,oBAAoB,SAAS;CAAC;CAAY;CAAA;CAAA;CAAA"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_context_helpers = require('../plugin-utils/context-helpers.cjs');
|
|
3
|
+
const require_types_command = require('../types/command.cjs');
|
|
4
|
+
let __stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
|
|
5
|
+
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
6
|
+
let defu = require("defu");
|
|
7
|
+
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
8
|
+
let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
9
|
+
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
10
|
+
|
|
11
|
+
//#region src/resolver/helpers.ts
|
|
12
|
+
const __ΩRecord = [
|
|
13
|
+
"K",
|
|
14
|
+
"T",
|
|
15
|
+
"Record",
|
|
16
|
+
"l'e#\"Rb!b\"Pde\"!N#!w#y"
|
|
17
|
+
];
|
|
18
|
+
function __assignType(fn, args) {
|
|
19
|
+
fn.__type = args;
|
|
20
|
+
return fn;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Resolves the description for a command option based on its reflection.
|
|
24
|
+
*
|
|
25
|
+
* @param name - The name of the command option.
|
|
26
|
+
* @param kind - The reflection kind of the command option.
|
|
27
|
+
* @param optional - Whether the command option is optional.
|
|
28
|
+
* @param variadic - Whether the command option is variadic (i.e., an array).
|
|
29
|
+
* @param title - The title of the command option, if any.
|
|
30
|
+
* @param defaultValue - The default value of the command option, if any.
|
|
31
|
+
* @returns The resolved description for the command option.
|
|
32
|
+
*/
|
|
33
|
+
function resolveCommandOptionDescription(name, kind, optional = false, variadic = false, title, defaultValue) {
|
|
34
|
+
return `A${optional && !defaultValue ? "n optional" : ""} command-line ${kind === require_types_command.CommandParameterKinds.boolean ? "flag" : "option"} that allows the user to ${kind === require_types_command.CommandParameterKinds.boolean ? "set the" : variadic ? "specify custom" : "specify a custom"} ${title?.trim() || (0, __stryke_string_format_title_case.titleCase)(name)} ${kind === require_types_command.CommandParameterKinds.boolean ? "indicator" : `${kind === require_types_command.CommandParameterKinds.number ? "numeric" : "string"} value${variadic ? "s" : ""}`}.`;
|
|
35
|
+
}
|
|
36
|
+
resolveCommandOptionDescription.__type = [
|
|
37
|
+
"name",
|
|
38
|
+
"CommandParameterKind",
|
|
39
|
+
"kind",
|
|
40
|
+
"optional",
|
|
41
|
+
"variadic",
|
|
42
|
+
"title",
|
|
43
|
+
"defaultValue",
|
|
44
|
+
"resolveCommandOptionDescription",
|
|
45
|
+
"P&2!\"w\"2#\"2$\"2%&2&8\"2'8&/("
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* Resolves the description for a command argument based on its reflection.
|
|
49
|
+
*
|
|
50
|
+
* @param name - The name of the command argument.
|
|
51
|
+
* @param kind - The reflection kind of the command argument.
|
|
52
|
+
* @param optional - Whether the command argument is optional.
|
|
53
|
+
* @param variadic - Whether the command argument is variadic (i.e., an array).
|
|
54
|
+
* @param title - The title of the command argument, if any.
|
|
55
|
+
* @param defaultValue - The default value of the command argument, if any.
|
|
56
|
+
* @returns The resolved description for the command argument.
|
|
57
|
+
*/
|
|
58
|
+
function resolveCommandArgumentDescription(name, kind, optional = false, variadic = false, title, defaultValue) {
|
|
59
|
+
return `An${optional && !defaultValue ? " optional" : ""} argument that allows the user to ${kind === require_types_command.CommandParameterKinds.boolean ? "set the" : variadic ? "specify custom" : "specify a custom"} ${title?.trim() || (0, __stryke_string_format_title_case.titleCase)(name)} ${kind === require_types_command.CommandParameterKinds.boolean ? "indicator" : `${kind === require_types_command.CommandParameterKinds.number ? "numeric" : "string"} value${variadic ? "s" : ""}`}.`;
|
|
60
|
+
}
|
|
61
|
+
resolveCommandArgumentDescription.__type = [
|
|
62
|
+
"name",
|
|
63
|
+
"CommandParameterKind",
|
|
64
|
+
"kind",
|
|
65
|
+
"optional",
|
|
66
|
+
"variadic",
|
|
67
|
+
"title",
|
|
68
|
+
"defaultValue",
|
|
69
|
+
"resolveCommandArgumentDescription",
|
|
70
|
+
"P&2!\"w\"2#\"2$\"2%&2&8\"2'8&/("
|
|
71
|
+
];
|
|
72
|
+
function applyOptionsDefaults(options) {
|
|
73
|
+
return Object.fromEntries(Object.entries(options).map(__assignType(([key, option]) => {
|
|
74
|
+
const name = option.name || key;
|
|
75
|
+
const title = option.title || (0, __stryke_string_format_title_case.titleCase)(name);
|
|
76
|
+
return [key, {
|
|
77
|
+
...option,
|
|
78
|
+
name,
|
|
79
|
+
title,
|
|
80
|
+
description: option.description || resolveCommandOptionDescription(name, option.kind, option.optional, option.kind !== require_types_command.CommandParameterKinds.boolean && option.variadic, title, option.default),
|
|
81
|
+
env: option.env || (0, __stryke_string_format_constant_case.constantCase)(key)
|
|
82
|
+
}];
|
|
83
|
+
}, [
|
|
84
|
+
"param0",
|
|
85
|
+
"",
|
|
86
|
+
"P\"2!\"/\""
|
|
87
|
+
])));
|
|
88
|
+
}
|
|
89
|
+
applyOptionsDefaults.__type = [
|
|
90
|
+
() => __ΩRecord,
|
|
91
|
+
"CommandOption",
|
|
92
|
+
"options",
|
|
93
|
+
"applyOptionsDefaults",
|
|
94
|
+
"P&\"w\"o!#2#\"/$"
|
|
95
|
+
];
|
|
96
|
+
function applyArgsDefaults(args) {
|
|
97
|
+
return args.map(__assignType((arg, i) => {
|
|
98
|
+
const name = arg.name || `arg${i + 1}`;
|
|
99
|
+
const title = arg.title || (0, __stryke_string_format_title_case.titleCase)(name);
|
|
100
|
+
return {
|
|
101
|
+
...arg,
|
|
102
|
+
name,
|
|
103
|
+
title,
|
|
104
|
+
description: arg.description || resolveCommandArgumentDescription(name, arg.kind, arg.optional, arg.kind !== require_types_command.CommandParameterKinds.boolean && arg.variadic, title, arg.default),
|
|
105
|
+
env: arg.name ? arg.env || arg.env === false ? arg.env : (0, __stryke_string_format_constant_case.constantCase)(name) : false
|
|
106
|
+
};
|
|
107
|
+
}, [
|
|
108
|
+
"arg",
|
|
109
|
+
"i",
|
|
110
|
+
"",
|
|
111
|
+
"P\"2!\"2\"\"/#"
|
|
112
|
+
]));
|
|
113
|
+
}
|
|
114
|
+
applyArgsDefaults.__type = [
|
|
115
|
+
"CommandArgument",
|
|
116
|
+
"args",
|
|
117
|
+
"applyArgsDefaults",
|
|
118
|
+
"P\"w!F2\"\"w!F/#"
|
|
119
|
+
];
|
|
120
|
+
function applyDefaults(context) {
|
|
121
|
+
context.output.description ??= `The ${context.output.title.replace(/(?:c|C)ommands?$/, "").trim()} executable command-line interface.`;
|
|
122
|
+
}
|
|
123
|
+
applyDefaults.__type = [
|
|
124
|
+
"ResolverContext",
|
|
125
|
+
"context",
|
|
126
|
+
"applyDefaults",
|
|
127
|
+
"P\"w!2\"\"/#"
|
|
128
|
+
];
|
|
129
|
+
function resolveVirtualCommand(ctx) {
|
|
130
|
+
ctx.output.title ??= (0, __stryke_string_format_title_case.titleCase)(ctx.input.command.name);
|
|
131
|
+
ctx.output.description ??= `A collection of available ${ctx.output.title.replace(/(?:c|C)ommands?$/, "").trim() || (0, __stryke_string_format_title_case.titleCase)(ctx.input.command.name)} commands that are included in the ${require_context_helpers.getAppTitle(ctx.input.context)} command-line application.`;
|
|
132
|
+
}
|
|
133
|
+
resolveVirtualCommand.__type = [
|
|
134
|
+
"ResolverContext",
|
|
135
|
+
"ctx",
|
|
136
|
+
"resolveVirtualCommand",
|
|
137
|
+
"P\"w!2\"\"/#"
|
|
138
|
+
];
|
|
139
|
+
/**
|
|
140
|
+
* Merges two command parameters, giving precedence to string values in the second configuration.
|
|
141
|
+
*
|
|
142
|
+
* @param objA - The first command parameter object.
|
|
143
|
+
* @param objB - The second command parameter object.
|
|
144
|
+
* @returns The merged command parameter object.
|
|
145
|
+
*/
|
|
146
|
+
const mergeCommandParameter = (0, defu.createDefu)(__assignType((obj, key, value) => {
|
|
147
|
+
if ((0, __stryke_type_checks_is_string.isString)(obj[key]) && (0, __stryke_type_checks_is_string.isString)(value)) {
|
|
148
|
+
if ((0, __stryke_type_checks_is_set_string.isSetString)(value)) obj[key] = value;
|
|
149
|
+
return true;
|
|
150
|
+
} else if (Array.isArray(obj[key]) && Array.isArray(value)) {
|
|
151
|
+
if (value.length > 0) obj[key] = (0, __stryke_helpers_get_unique.getUniqueBy)(obj[key].concat(value), __assignType((item) => (0, __stryke_type_checks_is_string.isString)(item) ? item : JSON.stringify(item), [
|
|
152
|
+
"item",
|
|
153
|
+
"",
|
|
154
|
+
"P\"2!\"/\""
|
|
155
|
+
]));
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
return false;
|
|
159
|
+
}, [
|
|
160
|
+
"obj",
|
|
161
|
+
"key",
|
|
162
|
+
"value",
|
|
163
|
+
"",
|
|
164
|
+
"P\"2!\"2\"\"2#\"/$"
|
|
165
|
+
]));
|
|
166
|
+
|
|
167
|
+
//#endregion
|
|
168
|
+
exports.applyArgsDefaults = applyArgsDefaults;
|
|
169
|
+
exports.applyDefaults = applyDefaults;
|
|
170
|
+
exports.applyOptionsDefaults = applyOptionsDefaults;
|
|
171
|
+
exports.mergeCommandParameter = mergeCommandParameter;
|
|
172
|
+
exports.resolveVirtualCommand = resolveVirtualCommand;
|
|
173
|
+
//# sourceMappingURL=helpers.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.cjs","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 { getAppTitle } from \"../plugin-utils/context-helpers\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterKind\n} 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(options: Record<string, CommandOption>) {\n return Object.fromEntries(\n Object.entries(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: option.env || constantCase(key)\n }\n ];\n })\n );\n}\n\nexport function applyArgsDefaults(args: CommandArgument[]): CommandArgument[] {\n return 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 : constantCase(name)\n : false\n };\n });\n}\n\nexport function applyDefaults(context: ResolverContext) {\n context.output.description ??= `The ${context.output.title.replace(/(?:c|C)ommands?$/, \"\").trim()} executable command-line interface.`;\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 )} 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,MAAM,YAAY;CAAC;CAAK;CAAK;CAAU;CAAyB;;AAE5D,IAAG,SAAS;;;;;;;;;;;;;;AAuChB,SAAgB,gCAAgC,MAAM,MAAG,WAAA,OAAA,WAAA,OAAA,OAAA,cAAA;AACrD,QAAO,IAAI,YAAY,CAAC,eAAe,eAAe,GAAE,gBAAY,SAAA,4CAAA,UAAA,SAAA,SAAA,2BAAA,SAAA,4CAAA,UAC9D,YACR,WACY,mBACA,mBAAA,GAAA,OAAA,MAAA,qDAAA,KAAA,CAAA,GAAA,SAAA,4CAAA,UACJ,cACA,GAAG,SAAK,4CAAA,SAAA,YAAA,SAAA,QAAA,WAAA,MAAA,KAAA;;AAElB,gCAAgB,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA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;EAAa,CAAC,CAAC;;AAEvC,kBAAkB,SAAS;CAAC;CAAmB;CAAI;CAAA;CAAA;AACnD,SAAgB,cAAc,SAAO;AACjC,SAAQ,OAAO,gBAAgB,OAAO,QAAQ,OAAC,MAAA,QAAA,oBAAA,GAAA,CAAA,MAAA,CAAA;;AAEnD,cAAa,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AACb,SAAW,sBAAA,KAAA;AACP,KAAI,OAAA,2DAAA,IAAA,MAAA,QAAA,KAAA;AACJ,KAAI,OAAO,gBAAI,6BAAA,IAAA,OAAA,MAAA,QAAA,oBAAA,GAAA,CAAA,MAAA,qDACL,IAAA,MAAA,QAAA,KAAA,CAAA,qCAAA,oCAAA,IAAA,MAAA,QAAA,CAAA;;AAEd,sBAAqB,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQrB,MAAa,6CAAc,cAAA,KAAA,KAAA,UAAA;AACvB,kDAAS,IAAA,KAAA,iDAAA,MAAA,EAAA;AACL,0DAAgB,MAAM,CACtB,KAAA,OAAA;AAEH,SAAA;YAEL,MAAA,QAAA,IAAA,KAAA,IAAA,MAAA,QAAA,MAAA,EAAA;uBAEY,KAAI,oDAAmB,IAAI,KAAK,OAAO,MAAM,EAAE,cAAa,sDAAM,KAAA,GAAA,OAAA,KAAA,UAAA,KAAA,EAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;AAEtE,SAAO;;;GAGZ;CAAC;CAAO;CAAA;CAAA;CAAA;CAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { getAppTitle } from "../plugin-utils/context-helpers.mjs";
|
|
2
|
+
import { CommandParameterKinds } from "../types/command.mjs";
|
|
3
|
+
import { constantCase } from "@stryke/string-format/constant-case";
|
|
4
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
5
|
+
import { createDefu } from "defu";
|
|
6
|
+
import { titleCase } from "@stryke/string-format/title-case";
|
|
7
|
+
import { getUniqueBy } from "@stryke/helpers/get-unique";
|
|
8
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
9
|
+
|
|
10
|
+
//#region src/resolver/helpers.ts
|
|
11
|
+
const __ΩRecord = [
|
|
12
|
+
"K",
|
|
13
|
+
"T",
|
|
14
|
+
"Record",
|
|
15
|
+
"l'e#\"Rb!b\"Pde\"!N#!w#y"
|
|
16
|
+
];
|
|
17
|
+
function __assignType(fn, args) {
|
|
18
|
+
fn.__type = args;
|
|
19
|
+
return fn;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resolves the description for a command option based on its reflection.
|
|
23
|
+
*
|
|
24
|
+
* @param name - The name of the command option.
|
|
25
|
+
* @param kind - The reflection kind of the command option.
|
|
26
|
+
* @param optional - Whether the command option is optional.
|
|
27
|
+
* @param variadic - Whether the command option is variadic (i.e., an array).
|
|
28
|
+
* @param title - The title of the command option, if any.
|
|
29
|
+
* @param defaultValue - The default value of the command option, if any.
|
|
30
|
+
* @returns The resolved description for the command option.
|
|
31
|
+
*/
|
|
32
|
+
function resolveCommandOptionDescription(name, kind, optional = false, variadic = false, title, defaultValue) {
|
|
33
|
+
return `A${optional && !defaultValue ? "n optional" : ""} command-line ${kind === CommandParameterKinds.boolean ? "flag" : "option"} that allows the user to ${kind === CommandParameterKinds.boolean ? "set the" : variadic ? "specify custom" : "specify a custom"} ${title?.trim() || titleCase(name)} ${kind === CommandParameterKinds.boolean ? "indicator" : `${kind === CommandParameterKinds.number ? "numeric" : "string"} value${variadic ? "s" : ""}`}.`;
|
|
34
|
+
}
|
|
35
|
+
resolveCommandOptionDescription.__type = [
|
|
36
|
+
"name",
|
|
37
|
+
"CommandParameterKind",
|
|
38
|
+
"kind",
|
|
39
|
+
"optional",
|
|
40
|
+
"variadic",
|
|
41
|
+
"title",
|
|
42
|
+
"defaultValue",
|
|
43
|
+
"resolveCommandOptionDescription",
|
|
44
|
+
"P&2!\"w\"2#\"2$\"2%&2&8\"2'8&/("
|
|
45
|
+
];
|
|
46
|
+
/**
|
|
47
|
+
* Resolves the description for a command argument based on its reflection.
|
|
48
|
+
*
|
|
49
|
+
* @param name - The name of the command argument.
|
|
50
|
+
* @param kind - The reflection kind of the command argument.
|
|
51
|
+
* @param optional - Whether the command argument is optional.
|
|
52
|
+
* @param variadic - Whether the command argument is variadic (i.e., an array).
|
|
53
|
+
* @param title - The title of the command argument, if any.
|
|
54
|
+
* @param defaultValue - The default value of the command argument, if any.
|
|
55
|
+
* @returns The resolved description for the command argument.
|
|
56
|
+
*/
|
|
57
|
+
function resolveCommandArgumentDescription(name, kind, optional = false, variadic = false, title, defaultValue) {
|
|
58
|
+
return `An${optional && !defaultValue ? " optional" : ""} argument that allows the user to ${kind === CommandParameterKinds.boolean ? "set the" : variadic ? "specify custom" : "specify a custom"} ${title?.trim() || titleCase(name)} ${kind === CommandParameterKinds.boolean ? "indicator" : `${kind === CommandParameterKinds.number ? "numeric" : "string"} value${variadic ? "s" : ""}`}.`;
|
|
59
|
+
}
|
|
60
|
+
resolveCommandArgumentDescription.__type = [
|
|
61
|
+
"name",
|
|
62
|
+
"CommandParameterKind",
|
|
63
|
+
"kind",
|
|
64
|
+
"optional",
|
|
65
|
+
"variadic",
|
|
66
|
+
"title",
|
|
67
|
+
"defaultValue",
|
|
68
|
+
"resolveCommandArgumentDescription",
|
|
69
|
+
"P&2!\"w\"2#\"2$\"2%&2&8\"2'8&/("
|
|
70
|
+
];
|
|
71
|
+
function applyOptionsDefaults(options) {
|
|
72
|
+
return Object.fromEntries(Object.entries(options).map(__assignType(([key, option]) => {
|
|
73
|
+
const name = option.name || key;
|
|
74
|
+
const title = option.title || titleCase(name);
|
|
75
|
+
return [key, {
|
|
76
|
+
...option,
|
|
77
|
+
name,
|
|
78
|
+
title,
|
|
79
|
+
description: option.description || resolveCommandOptionDescription(name, option.kind, option.optional, option.kind !== CommandParameterKinds.boolean && option.variadic, title, option.default),
|
|
80
|
+
env: option.env || constantCase(key)
|
|
81
|
+
}];
|
|
82
|
+
}, [
|
|
83
|
+
"param0",
|
|
84
|
+
"",
|
|
85
|
+
"P\"2!\"/\""
|
|
86
|
+
])));
|
|
87
|
+
}
|
|
88
|
+
applyOptionsDefaults.__type = [
|
|
89
|
+
() => __ΩRecord,
|
|
90
|
+
"CommandOption",
|
|
91
|
+
"options",
|
|
92
|
+
"applyOptionsDefaults",
|
|
93
|
+
"P&\"w\"o!#2#\"/$"
|
|
94
|
+
];
|
|
95
|
+
function applyArgsDefaults(args) {
|
|
96
|
+
return args.map(__assignType((arg, i) => {
|
|
97
|
+
const name = arg.name || `arg${i + 1}`;
|
|
98
|
+
const title = arg.title || titleCase(name);
|
|
99
|
+
return {
|
|
100
|
+
...arg,
|
|
101
|
+
name,
|
|
102
|
+
title,
|
|
103
|
+
description: arg.description || resolveCommandArgumentDescription(name, arg.kind, arg.optional, arg.kind !== CommandParameterKinds.boolean && arg.variadic, title, arg.default),
|
|
104
|
+
env: arg.name ? arg.env || arg.env === false ? arg.env : constantCase(name) : false
|
|
105
|
+
};
|
|
106
|
+
}, [
|
|
107
|
+
"arg",
|
|
108
|
+
"i",
|
|
109
|
+
"",
|
|
110
|
+
"P\"2!\"2\"\"/#"
|
|
111
|
+
]));
|
|
112
|
+
}
|
|
113
|
+
applyArgsDefaults.__type = [
|
|
114
|
+
"CommandArgument",
|
|
115
|
+
"args",
|
|
116
|
+
"applyArgsDefaults",
|
|
117
|
+
"P\"w!F2\"\"w!F/#"
|
|
118
|
+
];
|
|
119
|
+
function applyDefaults(context) {
|
|
120
|
+
context.output.description ??= `The ${context.output.title.replace(/(?:c|C)ommands?$/, "").trim()} executable command-line interface.`;
|
|
121
|
+
}
|
|
122
|
+
applyDefaults.__type = [
|
|
123
|
+
"ResolverContext",
|
|
124
|
+
"context",
|
|
125
|
+
"applyDefaults",
|
|
126
|
+
"P\"w!2\"\"/#"
|
|
127
|
+
];
|
|
128
|
+
function resolveVirtualCommand(ctx) {
|
|
129
|
+
ctx.output.title ??= titleCase(ctx.input.command.name);
|
|
130
|
+
ctx.output.description ??= `A collection of available ${ctx.output.title.replace(/(?:c|C)ommands?$/, "").trim() || titleCase(ctx.input.command.name)} commands that are included in the ${getAppTitle(ctx.input.context)} command-line application.`;
|
|
131
|
+
}
|
|
132
|
+
resolveVirtualCommand.__type = [
|
|
133
|
+
"ResolverContext",
|
|
134
|
+
"ctx",
|
|
135
|
+
"resolveVirtualCommand",
|
|
136
|
+
"P\"w!2\"\"/#"
|
|
137
|
+
];
|
|
138
|
+
/**
|
|
139
|
+
* Merges two command parameters, giving precedence to string values in the second configuration.
|
|
140
|
+
*
|
|
141
|
+
* @param objA - The first command parameter object.
|
|
142
|
+
* @param objB - The second command parameter object.
|
|
143
|
+
* @returns The merged command parameter object.
|
|
144
|
+
*/
|
|
145
|
+
const mergeCommandParameter = createDefu(__assignType((obj, key, value) => {
|
|
146
|
+
if (isString(obj[key]) && isString(value)) {
|
|
147
|
+
if (isSetString(value)) obj[key] = value;
|
|
148
|
+
return true;
|
|
149
|
+
} else if (Array.isArray(obj[key]) && Array.isArray(value)) {
|
|
150
|
+
if (value.length > 0) obj[key] = getUniqueBy(obj[key].concat(value), __assignType((item) => isString(item) ? item : JSON.stringify(item), [
|
|
151
|
+
"item",
|
|
152
|
+
"",
|
|
153
|
+
"P\"2!\"/\""
|
|
154
|
+
]));
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
}, [
|
|
159
|
+
"obj",
|
|
160
|
+
"key",
|
|
161
|
+
"value",
|
|
162
|
+
"",
|
|
163
|
+
"P\"2!\"2\"\"2#\"/$"
|
|
164
|
+
]));
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
export { applyArgsDefaults, applyDefaults, applyOptionsDefaults, mergeCommandParameter, resolveVirtualCommand };
|
|
168
|
+
//# sourceMappingURL=helpers.mjs.map
|
|
@@ -0,0 +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 { getAppTitle } from \"../plugin-utils/context-helpers\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterKind\n} 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(options: Record<string, CommandOption>) {\n return Object.fromEntries(\n Object.entries(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: option.env || constantCase(key)\n }\n ];\n })\n );\n}\n\nexport function applyArgsDefaults(args: CommandArgument[]): CommandArgument[] {\n return 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 : constantCase(name)\n : false\n };\n });\n}\n\nexport function applyDefaults(context: ResolverContext) {\n context.output.description ??= `The ${context.output.title.replace(/(?:c|C)ommands?$/, \"\").trim()} executable command-line interface.`;\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 )} 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,MAAM,YAAY;CAAC;CAAK;CAAK;CAAU;CAAyB;;AAE5D,IAAG,SAAS;;;;;;;;;;;;;;AAuChB,SAAgB,gCAAgC,MAAM,MAAG,WAAA,OAAA,WAAA,OAAA,OAAA,cAAA;AACrD,QAAO,IAAI,YAAY,CAAC,eAAe,eAAe,GAAE,gBAAY,SAAA,sBAAA,UAAA,SAAA,SAAA,2BAAA,SAAA,sBAAA,UAC9D,YACR,WACY,mBACA,mBAAA,GAAA,OAAA,MAAA,IAAA,UAAA,KAAA,CAAA,GAAA,SAAA,sBAAA,UACJ,cACA,GAAG,SAAK,sBAAA,SAAA,YAAA,SAAA,QAAA,WAAA,MAAA,KAAA;;AAElB,gCAAgB,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;AAYh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