@shell-shock/core 0.17.7 → 0.17.10
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 +81 -28
- package/dist/api.d.cts +51 -3
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts +51 -3
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +79 -26
- package/dist/api.mjs.map +1 -1
- package/dist/components/docs.cjs +1 -1
- package/dist/components/docs.d.cts.map +1 -1
- package/dist/components/docs.d.mts.map +1 -1
- package/dist/components/docs.mjs +1 -1
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/exec-builtin.cjs +1 -1
- package/dist/components/exec-builtin.mjs +1 -1
- package/dist/components/state-builtin.cjs +2 -2
- package/dist/components/state-builtin.d.cts.map +1 -1
- package/dist/components/state-builtin.d.mts.map +1 -1
- package/dist/components/state-builtin.mjs +2 -2
- package/dist/components/state-builtin.mjs.map +1 -1
- package/dist/components/utils-builtin.cjs +1 -1
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts.map +1 -1
- package/dist/components/utils-builtin.mjs +1 -1
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/contexts/options.cjs +1 -1
- package/dist/contexts/options.mjs +1 -1
- package/dist/contexts/options.mjs.map +1 -1
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/paths.cjs +7 -7
- package/dist/helpers/paths.mjs +7 -7
- package/dist/helpers/paths.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +2 -0
- package/dist/helpers/persistence.mjs +2 -0
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +30 -24
- package/dist/helpers/update-package-json.mjs +30 -24
- package/dist/helpers/update-package-json.mjs.map +1 -1
- package/dist/helpers/utilities.mjs.map +1 -1
- package/dist/helpers/validations.mjs.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/plugin-utils/compute-bin.cjs +1 -1
- package/dist/plugin-utils/compute-bin.mjs +1 -1
- package/dist/plugin-utils/compute-bin.mjs.map +1 -1
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/dist/plugin-utils/deepkit.cjs +1 -1
- package/dist/plugin-utils/deepkit.mjs +1 -1
- package/dist/plugin-utils/deepkit.mjs.map +1 -1
- package/dist/plugin-utils/description-helpers.mjs.map +1 -1
- package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/reflect.cjs +2 -2
- package/dist/plugin-utils/reflect.mjs +2 -2
- package/dist/plugin-utils/reflect.mjs.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/type-checks.mjs.map +1 -1
- package/dist/plugin.cjs +49 -7
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +49 -7
- package/dist/plugin.mjs.map +1 -1
- package/dist/resolver/deepkit.cjs +1 -1
- package/dist/resolver/deepkit.mjs +1 -1
- package/dist/resolver/deepkit.mjs.map +1 -1
- package/dist/resolver/helpers.mjs.map +1 -1
- package/dist/resolver/module.cjs +1 -1
- package/dist/resolver/module.mjs +1 -1
- package/dist/resolver/module.mjs.map +1 -1
- package/dist/resolver/resolve.cjs +1 -1
- package/dist/resolver/resolve.mjs +1 -1
- package/dist/resolver/resolve.mjs.map +1 -1
- package/dist/types/command.d.cts +1 -1
- package/dist/types/command.d.mts +2 -2
- package/dist/types/command.mjs.map +1 -1
- package/dist/types/config.cjs +20 -30
- package/dist/types/config.d.cts +13 -10
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +13 -10
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +20 -31
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/context.cjs +2 -2
- package/dist/types/context.d.cts +3 -2
- package/dist/types/context.d.cts.map +1 -1
- package/dist/types/context.d.mts +3 -2
- package/dist/types/context.d.mts.map +1 -1
- package/dist/types/context.mjs +2 -2
- package/dist/types/context.mjs.map +1 -1
- package/dist/types/env.d.cts +1 -1
- package/dist/types/env.d.mts +1 -1
- package/dist/types/env.mjs.map +1 -1
- package/dist/types/index.cjs +1 -0
- 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 +25 -24
|
@@ -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];\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,GAAA,oCAAA,SAAA,sBAAA,UACR,YACA,WACD,mBACJ,mBAAA,GAAA,OAAA,MAAA,IAAA,UAAA,KAAA,CAAA,GAAA,SAAA,sBAAA,UACL;;AAGA,kCAAkC,SAAQ;CAAA;CAAS;CAAuB;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAC1E,SAAC,qBAAA,KAAA;AACG,QAAM,OAAO,YAAY,OAAI,QAAQ,IAAQ,OAAA,QAAA,CAAA,IAAA,cAAA,CAAA,KAAA,YAAA;EAC7C,MAAU,OAAO,OAAA,QAAe;EAChC,MAAM,QAAW,OAAQ,SAAI,UAAQ,KAAY;AACjD,SAAM,CACA,KACA;GACM,GAAA;GACd;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;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CACJ,KAAO,IAAI,CAAA,GACX;;AAGd,cAAc,SAAO;CAAA;CAAA;CAAA;CAAA;CAAA;AACrB,SAAa,sBAAA,KAAA;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;;AAE9B,QAAO;;;;;;;;;;;;;AAsCT,SAAgB,gCAA2B,MAAW,MAAG,WAAA,OAAA,WAAA,OAAA,OAAA,cAAA;AACvD,QAAO,IAAC,YAAe,CAAA,eAAY,eAAa,GAAQ,gBAAc,SAAA,sBAAA,UAAA,SAAA,SAAA,2BAAA,SAAA,sBAAA,UAAA,YAAA,WAAA,mBAAA,mBAAA,GAAA,OAAA,MAAA,IAAA,UAAA,KAAA,CAAA,GAAA,SAAA,sBAAA,UAAA,cAAA,GAAA,SAAA,sBAAA,SAAA,YAAA,SAAA,QAAA,WAAA,MAAA,KAAA;;AAExE,gCAAE,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA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AA,QAAA,MAAA,EAAA;AACP,MAAI,MAAA,SAAA,EACF,KAAI,OAAG,YAAM,IAAA,KAAA,OAAA,MAAA,EAAA,cAAA,SAAA,SAAA,KAAA,GAAA,OAAA,KAAA,UAAA,KAAA,EAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;AAEf,SAAM;;AAER,QAAO;GACN;CAAC;CAAO;CAAC;CAAA;CAAA;CAA+B,CAAA,CAAA"}
|
package/dist/resolver/module.cjs
CHANGED
|
@@ -34,7 +34,7 @@ function resolveCommandOption(name, parent, schema) {
|
|
|
34
34
|
result.variadic = (0, _stryke_json.isJsonSchema7ArrayType)(schema);
|
|
35
35
|
if (result.kind === require_types_command.CommandParameterKinds.string) result.format = schema.format;
|
|
36
36
|
if (((0, _stryke_json.isJsonSchema7StringType)(schema) || (0, _stryke_json.isJsonSchema7NumberType)(schema)) && schema.enum) result.choices = schema.enum;
|
|
37
|
-
} else if (result.kind === require_types_command.CommandParameterKinds.boolean) {
|
|
37
|
+
} else if (result.kind === require_types_command.CommandParameterKinds.boolean && !result.variadic) {
|
|
38
38
|
result.skipAddingNegative = schema.skipAddingNegative;
|
|
39
39
|
result.isNegativeOf = schema.isNegativeOf;
|
|
40
40
|
}
|
package/dist/resolver/module.mjs
CHANGED
|
@@ -33,7 +33,7 @@ function resolveCommandOption(name, parent, schema) {
|
|
|
33
33
|
result.variadic = isJsonSchema7ArrayType(schema);
|
|
34
34
|
if (result.kind === CommandParameterKinds.string) result.format = schema.format;
|
|
35
35
|
if ((isJsonSchema7StringType(schema) || isJsonSchema7NumberType(schema)) && schema.enum) result.choices = schema.enum;
|
|
36
|
-
} else if (result.kind === CommandParameterKinds.boolean) {
|
|
36
|
+
} else if (result.kind === CommandParameterKinds.boolean && !result.variadic) {
|
|
37
37
|
result.skipAddingNegative = schema.skipAddingNegative;
|
|
38
38
|
result.isNegativeOf = schema.isNegativeOf;
|
|
39
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.mjs","names":[],"sources":["../../src/resolver/module.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 { toArray } from \"@stryke/convert/to-array\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport type {\n JsonSchema7EnumType,\n JsonSchema7ObjectType,\n JsonSchema7Type\n} from \"@stryke/json\";\nimport {\n isJsonSchema7ArrayType,\n isJsonSchema7BooleanType,\n isJsonSchema7NumberType,\n isJsonSchema7ObjectType,\n isJsonSchema7StringType,\n isJsonSchema7TupleType,\n isStandardJsonSchema\n} from \"@stryke/json\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { extractJsonSchema7, isZod3Type } from \"@stryke/zod\";\nimport { isCommandParameterConfig } from \"../plugin-utils\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterConfig,\n Context,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\nimport type { ResolverContext } from \"./types\";\n\nfunction resolveCommandOption(\n name: string,\n parent: JsonSchema7ObjectType,\n schema: JsonSchema7Type\n): Partial<CommandOption> {\n const result = {\n name,\n kind:\n isJsonSchema7ArrayType(schema) && schema.items\n ? isJsonSchema7NumberType(schema.items)\n ? CommandParameterKinds.number\n : CommandParameterKinds.string\n : isJsonSchema7BooleanType(schema)\n ? CommandParameterKinds.boolean\n : isJsonSchema7NumberType(schema)\n ? CommandParameterKinds.number\n : CommandParameterKinds.string,\n title: schema.title,\n description: schema.description,\n alias: toArray((schema as { alias?: string | string[] }).alias || []),\n env: (schema as { env?: string }).env,\n optional: !parent.required?.includes(name),\n default: schema.default\n } as Partial<CommandOption>;\n if (\n result.kind === CommandParameterKinds.string ||\n result.kind === CommandParameterKinds.number\n ) {\n result.variadic = isJsonSchema7ArrayType(schema);\n if (result.kind === CommandParameterKinds.string) {\n result.format = (\n schema as { format?: StringCommandParameter[\"format\"] }\n ).format;\n }\n\n if (\n (isJsonSchema7StringType(schema) || isJsonSchema7NumberType(schema)) &&\n (schema as JsonSchema7EnumType).enum\n ) {\n result.choices = (schema as JsonSchema7EnumType).enum;\n }\n } else if (result.kind === CommandParameterKinds.boolean) {\n result.skipAddingNegative = (\n schema as { skipAddingNegative?: boolean }\n ).skipAddingNegative;\n result.isNegativeOf = (schema as { isNegativeOf?: string }).isNegativeOf;\n }\n\n return result;\n}\n\nfunction resolveCommandArgument(\n schema: JsonSchema7Type\n): Partial<CommandArgument> {\n const result = {\n name: (schema as { name?: string }).name,\n kind:\n isJsonSchema7ArrayType(schema) && schema.items\n ? isJsonSchema7NumberType(schema.items)\n ? CommandParameterKinds.number\n : CommandParameterKinds.string\n : isJsonSchema7BooleanType(schema)\n ? CommandParameterKinds.boolean\n : isJsonSchema7NumberType(schema)\n ? CommandParameterKinds.number\n : CommandParameterKinds.string,\n title: schema.title,\n description: schema.description,\n alias: toArray((schema as { alias?: string | string[] }).alias || []),\n env: (schema as { env?: string }).env,\n default: schema.default\n } as Partial<CommandArgument>;\n if (\n result.kind === CommandParameterKinds.string ||\n result.kind === CommandParameterKinds.number\n ) {\n result.variadic = isJsonSchema7ArrayType(schema);\n if (result.kind === CommandParameterKinds.string) {\n result.format = (\n schema as { format?: StringCommandParameter[\"format\"] }\n ).format;\n }\n\n if (\n (isJsonSchema7StringType(schema) || isJsonSchema7NumberType(schema)) &&\n (schema as JsonSchema7EnumType).enum\n ) {\n result.choices = (schema as JsonSchema7EnumType).enum;\n }\n }\n\n return result;\n}\n\nexport async function resolveFromExports<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n validateExports(ctx);\n\n const metadata = ctx.module?.metadata ?? {};\n if (isSetString(metadata.title)) {\n ctx.output.title = metadata.title;\n }\n if (isSetString(metadata.description)) {\n ctx.output.description = metadata.description;\n }\n if (\n isSetString(metadata.alias) ||\n (Array.isArray(metadata.alias) && metadata.alias.length > 0)\n ) {\n ctx.output.alias = toArray(metadata.alias);\n }\n if (isSetString(metadata.icon)) {\n ctx.output.icon = metadata.icon;\n }\n if (isSetString(metadata.tags)) {\n ctx.output.tags = getUnique(ctx.output.tags.concat(toArray(metadata.tags)));\n }\n\n if (isSetObject(ctx.module?.options)) {\n if (\n isZod3Type(ctx.module.options) ||\n isStandardJsonSchema(ctx.module.options) ||\n isJsonSchema7ObjectType(ctx.module.options)\n ) {\n let jsonSchema: JsonSchema7Type;\n if (isZod3Type(ctx.module.options)) {\n jsonSchema = extractJsonSchema7(ctx.module.options);\n } else if (isStandardJsonSchema(ctx.module.options)) {\n jsonSchema = ctx.module.options[\"~standard\"].jsonSchema.input({\n target: \"draft-07\"\n });\n } else {\n jsonSchema = ctx.module.options as JsonSchema7ObjectType;\n }\n\n if (!isJsonSchema7ObjectType(jsonSchema)) {\n throw new TypeError(\n `Command options for command at path \"${\n ctx.input.command.path\n }\" must be defined as a Zod object schema, a standard JSON Schema object, or a JSON Schema object.`\n );\n }\n\n ctx.output.options = Object.fromEntries(\n Object.entries((jsonSchema as JsonSchema7ObjectType).properties)\n .map(([name, property]) => [\n name,\n resolveCommandOption(name, jsonSchema, property)\n ])\n .concat(Object.entries(ctx.output.options))\n ) as Record<string, CommandOption>;\n } else if (\n Object.values(ctx.module.options).every(isCommandParameterConfig)\n ) {\n ctx.output.options = Object.fromEntries(\n Object.entries(\n ctx.module.options as Record<string, CommandParameterConfig>\n )\n .map(([name, option]) => [\n name,\n { name, ...option, alias: toArray(option.alias) }\n ])\n .concat(Object.entries(ctx.output.options))\n ) as Record<string, CommandOption>;\n } else {\n throw new TypeError(\n `Command options for command at path \"${\n ctx.input.command.path\n }\" must be defined as a record of valid CommandOption objects, a Zod object schema, or a standard JSON Schema object.`\n );\n }\n }\n\n if (isSetObject(ctx.module?.args)) {\n if (\n isZod3Type(ctx.module.args) ||\n isStandardJsonSchema(ctx.module.args) ||\n isJsonSchema7TupleType(ctx.module.args)\n ) {\n let jsonSchema: JsonSchema7Type;\n if (isZod3Type(ctx.module.args)) {\n jsonSchema = extractJsonSchema7(ctx.module.args);\n } else if (isStandardJsonSchema(ctx.module.args)) {\n jsonSchema = ctx.module.args[\"~standard\"].jsonSchema.input({\n target: \"draft-07\"\n });\n } else {\n jsonSchema = ctx.module.args;\n }\n\n if (!isJsonSchema7TupleType(jsonSchema)) {\n throw new TypeError(\n `Command arguments for command at path \"${\n ctx.input.command.path\n }\" must be defined as a Zod tuple schema, a standard JSON Schema tuple object, or a JSON Schema tuple object.`\n );\n }\n\n ctx.output.args = jsonSchema.items.map(item =>\n resolveCommandArgument(item)\n ) as CommandArgument[];\n } else if (Object.values(ctx.module.args).every(isCommandParameterConfig)) {\n ctx.output.args = ctx.module.args.map(arg => ({\n ...arg,\n alias: toArray(arg.alias)\n })) as CommandArgument[];\n } else {\n throw new TypeError(\n `Command arguments for command at path \"${\n ctx.input.command.path\n }\" must be defined as a record of valid CommandArgument objects, a Zod tuple schema, or a standard JSON Schema tuple object.`\n );\n }\n }\n}\n\nfunction validateExports<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n if (!ctx.module) {\n throw new Error(\n `Command module at path \"${\n ctx.input.command.path\n }\" is undefined or null. Please ensure the module exports a valid command.`\n );\n } else if (!isSetObject(ctx.module)) {\n throw new TypeError(\n `Command module at path \"${\n ctx.input.command.path\n }\" is not an object. Please ensure the module exports a valid command.`\n );\n } else if (!(\"default\" in ctx.module)) {\n throw new Error(\n `Command module at path \"${\n ctx.input.command.path\n }\" does not appear to be valid. Please ensure the module's default export is a valid command handler function.`\n );\n }\n}\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AAO,CAAC;KAG7B,OAAA,IAAA,UAAA,0CAAqC,IAAA,MAAA,QAAA,KAAA,6HAAA;;AAIhD,mBAAkB,SAAU;CAAC;CAAgB;CAAU;CAAqB;CAAa;AACzF,SAAS,gBAAA,KAAA;AACL,KAAE,CAAA,IAAA;UAGE,CAAM,YAAU,IAAA,OAAa,CAC7B,OAAM,IAAG,UAAM,2BAAc,IAAA,MAAA,QAAA,KAAA,uEAAA;UAEzB,EAAA,aAAA,IAAoB,QACxB,OAAG,IAAA,MAAA,2BAAA,IAAA,MAAA,QAAA,KAAA,+GAAA;;AAGX,gBAAc,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
|
|
1
|
+
{"version":3,"file":"module.mjs","names":[],"sources":["../../src/resolver/module.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 { toArray } from \"@stryke/convert/to-array\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport type {\n JsonSchema7EnumType,\n JsonSchema7ObjectType,\n JsonSchema7Type\n} from \"@stryke/json\";\nimport {\n isJsonSchema7ArrayType,\n isJsonSchema7BooleanType,\n isJsonSchema7NumberType,\n isJsonSchema7ObjectType,\n isJsonSchema7StringType,\n isJsonSchema7TupleType,\n isStandardJsonSchema\n} from \"@stryke/json\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { extractJsonSchema7, isZod3Type } from \"@stryke/zod\";\nimport { isCommandParameterConfig } from \"../plugin-utils\";\nimport type {\n BooleanCommandOption,\n CommandArgument,\n CommandOption,\n CommandParameterConfig,\n Context,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\nimport type { ResolverContext } from \"./types\";\n\nfunction resolveCommandOption(\n name: string,\n parent: JsonSchema7ObjectType,\n schema: JsonSchema7Type\n): Partial<CommandOption> {\n const result = {\n name,\n kind:\n isJsonSchema7ArrayType(schema) && schema.items\n ? isJsonSchema7NumberType(schema.items)\n ? CommandParameterKinds.number\n : CommandParameterKinds.string\n : isJsonSchema7BooleanType(schema)\n ? CommandParameterKinds.boolean\n : isJsonSchema7NumberType(schema)\n ? CommandParameterKinds.number\n : CommandParameterKinds.string,\n title: schema.title,\n description: schema.description,\n alias: toArray((schema as { alias?: string | string[] }).alias || []),\n env: (schema as { env?: string }).env,\n optional: !parent.required?.includes(name),\n default: schema.default\n } as Partial<CommandOption>;\n if (\n result.kind === CommandParameterKinds.string ||\n result.kind === CommandParameterKinds.number\n ) {\n result.variadic = isJsonSchema7ArrayType(schema);\n if (result.kind === CommandParameterKinds.string) {\n result.format = (\n schema as { format?: StringCommandParameter[\"format\"] }\n ).format;\n }\n\n if (\n (isJsonSchema7StringType(schema) || isJsonSchema7NumberType(schema)) &&\n (schema as JsonSchema7EnumType).enum\n ) {\n result.choices = (schema as JsonSchema7EnumType).enum;\n }\n } else if (\n result.kind === CommandParameterKinds.boolean &&\n !result.variadic\n ) {\n (result as BooleanCommandOption).skipAddingNegative = (\n schema as { skipAddingNegative?: boolean }\n ).skipAddingNegative;\n (result as BooleanCommandOption).isNegativeOf = (\n schema as { isNegativeOf?: string }\n ).isNegativeOf;\n }\n\n return result;\n}\n\nfunction resolveCommandArgument(\n schema: JsonSchema7Type\n): Partial<CommandArgument> {\n const result = {\n name: (schema as { name?: string }).name,\n kind:\n isJsonSchema7ArrayType(schema) && schema.items\n ? isJsonSchema7NumberType(schema.items)\n ? CommandParameterKinds.number\n : CommandParameterKinds.string\n : isJsonSchema7BooleanType(schema)\n ? CommandParameterKinds.boolean\n : isJsonSchema7NumberType(schema)\n ? CommandParameterKinds.number\n : CommandParameterKinds.string,\n title: schema.title,\n description: schema.description,\n alias: toArray((schema as { alias?: string | string[] }).alias || []),\n env: (schema as { env?: string }).env,\n default: schema.default\n } as Partial<CommandArgument>;\n if (\n result.kind === CommandParameterKinds.string ||\n result.kind === CommandParameterKinds.number\n ) {\n result.variadic = isJsonSchema7ArrayType(schema);\n if (result.kind === CommandParameterKinds.string) {\n result.format = (\n schema as { format?: StringCommandParameter[\"format\"] }\n ).format;\n }\n\n if (\n (isJsonSchema7StringType(schema) || isJsonSchema7NumberType(schema)) &&\n (schema as JsonSchema7EnumType).enum\n ) {\n result.choices = (schema as JsonSchema7EnumType).enum;\n }\n }\n\n return result;\n}\n\nexport async function resolveFromExports<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n validateExports(ctx);\n\n const metadata = ctx.module?.metadata ?? {};\n if (isSetString(metadata.title)) {\n ctx.output.title = metadata.title;\n }\n if (isSetString(metadata.description)) {\n ctx.output.description = metadata.description;\n }\n if (\n isSetString(metadata.alias) ||\n (Array.isArray(metadata.alias) && metadata.alias.length > 0)\n ) {\n ctx.output.alias = toArray(metadata.alias);\n }\n if (isSetString(metadata.icon)) {\n ctx.output.icon = metadata.icon;\n }\n if (isSetString(metadata.tags)) {\n ctx.output.tags = getUnique(ctx.output.tags.concat(toArray(metadata.tags)));\n }\n\n if (isSetObject(ctx.module?.options)) {\n if (\n isZod3Type(ctx.module.options) ||\n isStandardJsonSchema(ctx.module.options) ||\n isJsonSchema7ObjectType(ctx.module.options)\n ) {\n let jsonSchema: JsonSchema7Type;\n if (isZod3Type(ctx.module.options)) {\n jsonSchema = extractJsonSchema7(ctx.module.options);\n } else if (isStandardJsonSchema(ctx.module.options)) {\n jsonSchema = ctx.module.options[\"~standard\"].jsonSchema.input({\n target: \"draft-07\"\n });\n } else {\n jsonSchema = ctx.module.options;\n }\n\n if (!isJsonSchema7ObjectType(jsonSchema)) {\n throw new TypeError(\n `Command options for command at path \"${\n ctx.input.command.path\n }\" must be defined as a Zod object schema, a standard JSON Schema object, or a JSON Schema object.`\n );\n }\n\n ctx.output.options = Object.fromEntries(\n Object.entries(jsonSchema.properties)\n .map(([name, property]) => [\n name,\n resolveCommandOption(name, jsonSchema, property)\n ])\n .concat(Object.entries(ctx.output.options))\n ) as Record<string, CommandOption>;\n } else if (\n Object.values(ctx.module.options).every(isCommandParameterConfig)\n ) {\n ctx.output.options = Object.fromEntries(\n Object.entries(\n ctx.module.options as Record<string, CommandParameterConfig>\n )\n .map(([name, option]) => [\n name,\n { name, ...option, alias: toArray(option.alias) }\n ])\n .concat(Object.entries(ctx.output.options))\n ) as Record<string, CommandOption>;\n } else {\n throw new TypeError(\n `Command options for command at path \"${\n ctx.input.command.path\n }\" must be defined as a record of valid CommandOption objects, a Zod object schema, or a standard JSON Schema object.`\n );\n }\n }\n\n if (isSetObject(ctx.module?.args)) {\n if (\n isZod3Type(ctx.module.args) ||\n isStandardJsonSchema(ctx.module.args) ||\n isJsonSchema7TupleType(ctx.module.args)\n ) {\n let jsonSchema: JsonSchema7Type;\n if (isZod3Type(ctx.module.args)) {\n jsonSchema = extractJsonSchema7(ctx.module.args);\n } else if (isStandardJsonSchema(ctx.module.args)) {\n jsonSchema = ctx.module.args[\"~standard\"].jsonSchema.input({\n target: \"draft-07\"\n });\n } else {\n jsonSchema = ctx.module.args;\n }\n\n if (!isJsonSchema7TupleType(jsonSchema)) {\n throw new TypeError(\n `Command arguments for command at path \"${\n ctx.input.command.path\n }\" must be defined as a Zod tuple schema, a standard JSON Schema tuple object, or a JSON Schema tuple object.`\n );\n }\n\n ctx.output.args = jsonSchema.items.map(item =>\n resolveCommandArgument(item)\n ) as CommandArgument[];\n } else if (Object.values(ctx.module.args).every(isCommandParameterConfig)) {\n ctx.output.args = ctx.module.args.map(arg => ({\n ...arg,\n alias: toArray(arg.alias)\n })) as CommandArgument[];\n } else {\n throw new TypeError(\n `Command arguments for command at path \"${\n ctx.input.command.path\n }\" must be defined as a record of valid CommandArgument objects, a Zod tuple schema, or a standard JSON Schema tuple object.`\n );\n }\n }\n}\n\nfunction validateExports<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n if (!ctx.module) {\n throw new Error(\n `Command module at path \"${\n ctx.input.command.path\n }\" is undefined or null. Please ensure the module exports a valid command.`\n );\n } else if (!isSetObject(ctx.module)) {\n throw new TypeError(\n `Command module at path \"${\n ctx.input.command.path\n }\" is not an object. Please ensure the module exports a valid command.`\n );\n } else if (!(\"default\" in ctx.module)) {\n throw new Error(\n `Command module at path \"${\n ctx.input.command.path\n }\" does not appear to be valid. Please ensure the module's default export is a valid command handler function.`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA,MAAM,aAAa;CAAC;CAAK;CAAW;CAA2B;;AAE7D,IAAG,SAAS;;;AA4Bd,SAAE,qBAAuB,MAAA,QAAA,QAAA;CACvB,MAAA,SAAA;EACA;EACA,MAAO,uBAAY,OAAA,IAAA,OAAA,QAAA,wBAAA,OAAA,MAAA,GAAA,sBAAA,SAAA,sBAAA,SAAA,yBAAA,OAAA,GAAA,sBAAA,UAAA,wBAAA,OAAA,GAAA,sBAAA,SAAA,sBAAA;EACrB,OAAS,OAAA;EACT,aAAS,OAAc;EACvB,OAAS,QAAA,OAAA,SAAoB,EAAA,CAAA;EAC7B,KAAS,OAAA;EACT,UAAY,CAAA,OAAA,UAAA,SAAA,KAAA;EACV,SAAA,OAAA;EACA;AACA,KAAA,OAAA,SAAa,sBAAA,UAAA,OAAA,SAAA,sBAAA,QAAA;AACb,SAAA,WAAA,uBAAsB,OAAA;AACtB,MAAA,OAAO,SAAA,sBAAA,OACP,QAAA,SAAA,OAAA;AAEF,OAAS,wBAAwB,OAAO,IAAE,wBAAM,OAAA,KAAA,OAAA,KAC1C,QAAO,UAAC,OAAgB;YAErB,OAAA,SAAoB,sBAAA,WAAA,CAAA,OAAA,UAAA;AAC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,IAAA,OAAA,KAAA,EAAA;EACrC,IAAA;AACE,MAAC,WAAQ,IAAA,OAAgB,KAAA,CAC1B,cAAA,mBAAA,IAAA,OAAA,KAAA;WACY,qBAAG,IAAsB,OAAO,KAAC,CAC9C,cAAgB,IAAA,OAAA,KAAA,aAAsB,WAAA,MAAA,EACtC,QAAA,YACA,CAAM;MAEJ,cAAe,IAAC,OAAA;AAEhB,MAAE,CAAA,uBAAM,WAAA,CACV,OAAA,IAAA,UAAA,0CAAA,IAAA,MAAA,QAAA,KAAA,8GAAA;AAEE,MAAC,OAAA,OAAA,WAAA,MAAA,IAAA,cAAA,SAAA,uBAAA,KAAA,EAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;YACA,OAAA,OAAA,IAAwB,OAAS,KAAE,CAAA,MAAA,yBAAkC,CACtE,KAAC,OAAU,OAAA,IAAA,OAAA,KAAqB,IAAA,cAAA,SAAA;EAChC,GAAA;EACA,OAAO,QAAU,IAAC,MAAS;EAC7B,GAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA;;;AAMJ,mBAAa,SAAS;CAAA;CAAmB;CAAS;CAA0B;CAAA;AAC5E,SAAO,gBAAgB,KAAA;AACrB,KAAA,CAAA,IAAA,OACA,OAAA,IAAA,MAAgB,2BAAI,IAAA,MAAA,QAAA,KAAA,2EAAA;mCAEpB,OAAM,IAAA,UAAe,2BAAsB,IAAA,MAAA,QAAA,KAAA,uEAAA;UACvC,EAAA,aAAqB,IAAK,QAC5B,OAAI,IAAM,MAAM,2BAAiB,IAAA,MAAA,QAAA,KAAA,+GAAA;;AAGrC,gBAAe,SAAA;CAAW;CAAY;CAAW;CAAA;CAAA"}
|
|
@@ -5,10 +5,10 @@ const require_utilities = require('../helpers/utilities.cjs');
|
|
|
5
5
|
const require_helpers = require('./helpers.cjs');
|
|
6
6
|
const require_deepkit$1 = require('./deepkit.cjs');
|
|
7
7
|
const require_module = require('./module.cjs');
|
|
8
|
+
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
8
9
|
let _stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
|
|
9
10
|
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
10
11
|
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
11
|
-
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
12
12
|
let _powerlines_deepkit_esbuild_plugin = require("@powerlines/deepkit/esbuild-plugin");
|
|
13
13
|
let _powerlines_plugin_esbuild_helpers_resolve = require("@powerlines/plugin-esbuild/helpers/resolve");
|
|
14
14
|
|
|
@@ -4,10 +4,10 @@ import { getGlobalOptions } from "../helpers/utilities.mjs";
|
|
|
4
4
|
import { applyArgsDefaults, applyDefaults, applyOptionsDefaults, resolveVirtualCommand } from "./helpers.mjs";
|
|
5
5
|
import { resolveFromBytecode } from "./deepkit.mjs";
|
|
6
6
|
import { resolveFromExports } from "./module.mjs";
|
|
7
|
+
import { ReflectionVisibility } from "@powerlines/deepkit/vendor/type";
|
|
7
8
|
import { constantCase } from "@stryke/string-format/constant-case";
|
|
8
9
|
import { titleCase } from "@stryke/string-format/title-case";
|
|
9
10
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
10
|
-
import { ReflectionVisibility } from "@powerlines/deepkit/vendor/type";
|
|
11
11
|
import { esbuildPlugin } from "@powerlines/deepkit/esbuild-plugin";
|
|
12
12
|
import { resolveModule } from "@powerlines/plugin-esbuild/helpers/resolve";
|
|
13
13
|
|
|
@@ -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 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;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,MAAiB;CAc3B,MAAM,SAAM;EACR;EACA,QAdO;GACP,OAAC,EAAA;GACN,MAAQ,QAAA;GACH,MAAE,QAAS,QAAS,EAAA;;GAEpB,GAAA;GACJ;GACE,SAAA,WAAA,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CAAA;CAAA;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;;AAE9B,QAAO;;AA+BT,eAAE,WAAiB,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d,CAAA;IACA;EAAE;EAAC;EAAA;EAAA,CAAA,CAAA,CAAA;AACL,QAAK,IAAM;;AAEb,YAAQ,SAAS;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOjB,eAAmB,QAAA,OAAA;CACjB,MAAM,MAAI,OAAA,WAAoB,IAAC,CAAA;QAAU;EAAA;EAAA;EAAA,CAAA,EAAA,WAAA,MAAA;AACzC,KAAI,CAAC,IAAI,OAAC,WAAA;AACR,QAAM,mBAAO,IAAA;AACb,sBAAoB,IAAA;OAEpB,uBAAI,IAAA;AAEN,QAAO,YAAY,IAAI;;AAEzB,QAAQ,SAAQ;CAAA;CAAc;CAAO;CAAA;CAAA;CAAA;CAAA"}
|
package/dist/types/command.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ResolvedEntryTypeDefinition } from "powerlines";
|
|
2
|
+
import { AnyFunction } from "@stryke/types/base";
|
|
2
3
|
import { StandardJSONSchemaV1 } from "@standard-schema/spec";
|
|
3
4
|
import { JsonSchema7TupleType } from "@stryke/json";
|
|
4
|
-
import { AnyFunction } from "@stryke/types/base";
|
|
5
5
|
import { JSONSchema7Object } from "json-schema";
|
|
6
6
|
import * as z3 from "zod/v3";
|
|
7
7
|
|
package/dist/types/command.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ResolvedEntryTypeDefinition } from "powerlines";
|
|
2
1
|
import { JsonSchema7TupleType } from "@stryke/json";
|
|
3
|
-
import {
|
|
2
|
+
import { ResolvedEntryTypeDefinition } from "powerlines";
|
|
4
3
|
import { AnyFunction } from "@stryke/types/base";
|
|
4
|
+
import { StandardJSONSchemaV1 } from "@standard-schema/spec";
|
|
5
5
|
import { JSONSchema7Object } from "json-schema";
|
|
6
6
|
import * as z3 from "zod/v3";
|
|
7
7
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.mjs","names":[],"sources":["../../src/types/command.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { StandardJSONSchemaV1 } from \"@standard-schema/spec\";\nimport type { JsonSchema7TupleType } from \"@stryke/json\";\nimport type { AnyFunction } from \"@stryke/types/base\";\nimport type { JSONSchema7Object } from \"json-schema\";\nimport type { ResolvedEntryTypeDefinition } from \"powerlines\";\nimport type * as z3 from \"zod/v3\";\n\nexport type CommandParameterType =\n | string\n | number\n | boolean\n | (string | number)[];\n\nexport const CommandParameterKinds = {\n string: \"string\",\n number: \"number\",\n boolean: \"boolean\"\n} as const;\n\nexport type CommandParameterKind =\n (typeof CommandParameterKinds)[keyof typeof CommandParameterKinds];\n\nexport interface BaseCommandParameter {\n /**\n * The option name.\n */\n name: string;\n\n /**\n * The option kind.\n */\n kind: CommandParameterKind;\n\n /**\n * The display title.\n */\n title: string;\n\n /**\n * The option description.\n */\n description: string;\n\n /**\n * Alternative option names.\n */\n alias: string[];\n\n /**\n * The default value.\n */\n default?: string | number | boolean | string[] | number[] | boolean[];\n\n /**\n * The environment variable name or false to disable.\n */\n env: string | false;\n\n /**\n * Whether the option is optional.\n */\n optional: boolean;\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: boolean;\n}\n\nexport interface BaseSingleCommandParameter {\n /**\n * The default value.\n */\n default?: string | number | boolean;\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: false;\n}\n\nexport interface BaseVariadicCommandParameter {\n /**\n * The default value.\n */\n default?: string[] | number[] | boolean[];\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: true;\n}\n\nexport interface BaseStringCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"string\";\n\n /**\n * The default value.\n */\n default?: string | string[];\n\n /**\n * A standard string format to validate the option value against.\n */\n format?:\n | \"email\"\n | \"uri\"\n | \"uuid\"\n | \"ipv4\"\n | \"ipv6\"\n | \"date\"\n | \"time\"\n | \"date-time\"\n | \"duration\";\n\n /**\n * The allowed choices for the option value.\n */\n choices?: string[];\n}\n\nexport interface SingleStringCommandParameter extends BaseStringCommandParameter {\n /**\n * The default value.\n */\n default?: string;\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: false;\n}\n\nexport interface VariadicStringCommandParameter extends BaseStringCommandParameter {\n /**\n * The default value.\n */\n default?: string[];\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: true;\n}\n\nexport type StringCommandParameter =\n | SingleStringCommandParameter\n | VariadicStringCommandParameter;\n\nexport interface BaseNumberCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"number\";\n\n /**\n * The default value.\n */\n default?: number | number[];\n\n /**\n * The allowed choices for the option value.\n */\n choices?: number[];\n}\n\nexport interface SingleNumberCommandParameter extends BaseNumberCommandParameter {\n /**\n * The default value.\n */\n default?: number;\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: false;\n}\n\nexport interface VariadicNumberCommandParameter extends BaseNumberCommandParameter {\n /**\n * The default value.\n */\n default?: number[];\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: true;\n}\n\nexport type NumberCommandParameter =\n | SingleNumberCommandParameter\n | VariadicNumberCommandParameter;\n\nexport interface BaseBooleanCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"boolean\";\n\n /**\n * The default value.\n */\n default?: boolean | boolean[];\n}\n\nexport interface SingleBooleanCommandParameter extends BaseBooleanCommandParameter {\n /**\n * The default value.\n */\n default?: boolean;\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: false;\n}\n\nexport interface VariadicBooleanCommandParameter extends BaseBooleanCommandParameter {\n /**\n * The default value.\n */\n default?: boolean[];\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: true;\n}\n\nexport type BooleanCommandParameter =\n | SingleBooleanCommandParameter\n | VariadicBooleanCommandParameter;\n\nexport type CommandParameter =\n | StringCommandParameter\n | NumberCommandParameter\n | BooleanCommandParameter;\n\nexport type AsCommandParameterConfig<T extends BaseCommandParameter> = Pick<\n T,\n \"kind\" | \"alias\"\n> &\n Partial<Omit<T, \"kind\" | \"alias\">> & {\n alias?: string | string[];\n };\n\nexport type StringCommandParameterConfig =\n AsCommandParameterConfig<StringCommandParameter>;\nexport type NumberCommandParameterConfig =\n AsCommandParameterConfig<NumberCommandParameter>;\nexport type BooleanCommandParameterConfig =\n AsCommandParameterConfig<BooleanCommandParameter>;\n\nexport type CommandParameterConfig =\n | StringCommandParameterConfig\n | NumberCommandParameterConfig\n | BooleanCommandParameterConfig;\n\nexport interface BooleanCommandOption extends SingleBooleanCommandParameter {\n /**\n * The option this negates.\n */\n isNegativeOf?: string;\n\n /**\n * Whether to skip adding a negative option.\n */\n skipAddingNegative?: boolean;\n}\n\nexport type CommandOption =\n | StringCommandParameter\n | NumberCommandParameter\n | BooleanCommandOption\n | VariadicBooleanCommandParameter;\nexport type CommandOptionConfig = AsCommandParameterConfig<CommandOption>;\n\nexport type CommandArgument =\n | StringCommandParameter\n | NumberCommandParameter\n | BooleanCommandParameter;\nexport type CommandArgumentConfig = AsCommandParameterConfig<CommandArgument>;\n\nexport interface CommandBase {\n /**\n * The command id.\n */\n id: string | null;\n\n /**\n * The command name.\n */\n name: string;\n\n /**\n * The full command path value.\n */\n path: string | null;\n\n /**\n * The path segments.\n */\n segments: string[];\n\n /**\n * The display title.\n */\n title?: string;\n\n /**\n * The command description.\n */\n description?: string;\n\n /**\n * Alternative command names.\n */\n alias?: string[];\n\n /**\n * The command icon.\n */\n icon?: string;\n\n /**\n * A URL to the command documentation or reference.\n */\n reference?: string;\n\n /**\n * Whether the command is virtual.\n *\n * @remarks\n * Virtual commands are considered forks in the command tree and are not directly executable. They are used to group related subcommands together without having an actual command handler or entry point.\n */\n isVirtual: boolean;\n}\n\nexport interface CommandConfig extends CommandBase {\n /**\n * The command id.\n */\n id: string;\n\n /**\n * The resolved entry definition.\n */\n entry: ResolvedEntryTypeDefinition;\n\n /**\n * Optional tags for the command.\n *\n * @remarks\n * 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.\n */\n tags?: string[];\n\n /**\n * 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.\n */\n source?: \"file\" | string;\n}\n\nexport type CommandTree = CommandConfig & {\n /**\n * The display title.\n */\n title: string;\n\n /**\n * The command description.\n */\n description: string;\n\n /**\n * Alternative command names.\n */\n alias: string[];\n\n /**\n * A set of tags for the command.\n *\n * @remarks\n * 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.\n */\n tags: string[];\n\n /**\n * 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.\n */\n source: \"file\" | string;\n\n /**\n * The command options.\n */\n options: Record<string, CommandOption>;\n\n /**\n * The positional arguments provided to the command.\n */\n args: CommandArgument[];\n\n /**\n * The parent command.\n */\n parent: null | CommandTree;\n\n /**\n * Child commands.\n */\n children: Record<string, CommandTree>;\n};\n\nexport type SerializedCommandTree = Omit<CommandTree, \"parent\" | \"children\"> & {\n /**\n * The parent command id.\n */\n parent: null | string;\n /**\n * Serialized child commands.\n */\n children: Record<string, SerializedCommandTree>;\n};\n\nexport interface CommandMetadata {\n /**\n * The display name of the command.\n *\n * @remarks\n * This value will be used in various displays of the user interface and documentation. If not provided, a formatted value of the command name will be used.\n */\n title?: string;\n\n /**\n * A brief description of what the command does.\n *\n * @remarks\n * This value will be used in various displays of the user interface and documentation. If not provided, a default message may be shown.\n */\n description?: string;\n\n /**\n * One or more alternative names for the command.\n */\n alias?: string | string[];\n\n /**\n * Optional tags for the command.\n *\n * @remarks\n * 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.\n */\n tags?: string[];\n\n /**\n * An optional icon to visually represent the command in user interfaces.\n *\n * @remarks\n * This can be a string containing an emoji, a Unicode character, or any other symbol that helps to visually identify the command. If not provided, no icon will be displayed.\n */\n icon?: string;\n\n /**\n * A URL to the command documentation or reference.\n *\n * @remarks\n * This URL can be used in various displays of the user interface and documentation to provide users with a reference for the command. It can also be used by plugins to link to the documentation in relevant contexts. If the token `{command}` is included in the URL, it will be replaced with the full command path to provide links to command specific documentation. For example, `myapp command subcommand` will be translated to `{referenceLink}/command/subcommand`.\n */\n reference?: string;\n}\n\nexport interface CommandModule {\n metadata?: CommandMetadata;\n options?:\n | Record<string, CommandOptionConfig>\n | JSONSchema7Object\n | StandardJSONSchemaV1<Record<string, CommandParameterType>>\n | z3.AnyZodObject;\n args?:\n | CommandArgumentConfig[]\n | JsonSchema7TupleType\n | StandardJSONSchemaV1<CommandParameterType[]>\n | z3.AnyZodTuple;\n default?: AnyFunction;\n}\n"],"mappings":";AAAA,MAAM,UAAU;CAAC;CAAK;CAAK;CAAQ;CAA4B;;;;;;AAE/D,MAAM,UAAU;CAAC;CAAG;OAAM;OAAiB;CAAA;CAAA;CAAA;;;;;;;AAE3C,MAAM,aAAS;CAAA;CAAS;CAAG;CAAY;CAA2B;AAClE,MAAI,0BAA4B,CAAC,wBAAqB,gBAAa;AAEnE,MAAK,wBAA0B;;CAE9B,QAAW;CACX,SAAY;CACZ;AACD,MAAC,0BAA+B;OAAG;OAAkB;CAAA;CAAA;CAAA;AAErD,MAAM,0BAAqB;CAAM;CAAG;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEpC,MAAM,gCAAgC;CAAC;CAAW;CAAoB;CAAA;CAAA;CAAA;CAAA;CAAA;AAEtE,MAAM,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A;;;;;;;AAIJ,MAAK,qBAAmB;OAAK;OAAA;OAAA;CAAA;CAAA;CAAA;AAE7B,MAAE,2BAAe;OAAA;OAAA;CAAA;CAAA;CAAA;AAEjB,MAAI,iBAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEJ,MAAI,mBAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIJ,MAAK,2BAAyB;OAAQ;OAAgB;CAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEtD,MAAM,qBAAe;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAErB,MAAI,mBAAA;OAAA;CAAA;OAAA;OAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
|
|
1
|
+
{"version":3,"file":"command.mjs","names":[],"sources":["../../src/types/command.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { StandardJSONSchemaV1 } from \"@standard-schema/spec\";\nimport type { JsonSchema7TupleType } from \"@stryke/json\";\nimport type { AnyFunction } from \"@stryke/types/base\";\nimport type { JSONSchema7Object } from \"json-schema\";\nimport type { ResolvedEntryTypeDefinition } from \"powerlines\";\nimport type * as z3 from \"zod/v3\";\n\nexport type CommandParameterType =\n | string\n | number\n | boolean\n | (string | number)[];\n\nexport const CommandParameterKinds = {\n string: \"string\",\n number: \"number\",\n boolean: \"boolean\"\n} as const;\n\nexport type CommandParameterKind =\n (typeof CommandParameterKinds)[keyof typeof CommandParameterKinds];\n\nexport interface BaseCommandParameter {\n /**\n * The option name.\n */\n name: string;\n\n /**\n * The option kind.\n */\n kind: CommandParameterKind;\n\n /**\n * The display title.\n */\n title: string;\n\n /**\n * The option description.\n */\n description: string;\n\n /**\n * Alternative option names.\n */\n alias: string[];\n\n /**\n * The default value.\n */\n default?: string | number | boolean | string[] | number[] | boolean[];\n\n /**\n * The environment variable name or false to disable.\n */\n env: string | false;\n\n /**\n * Whether the option is optional.\n */\n optional: boolean;\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: boolean;\n}\n\nexport interface BaseSingleCommandParameter {\n /**\n * The default value.\n */\n default?: string | number | boolean;\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: false;\n}\n\nexport interface BaseVariadicCommandParameter {\n /**\n * The default value.\n */\n default?: string[] | number[] | boolean[];\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: true;\n}\n\nexport interface BaseStringCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"string\";\n\n /**\n * The default value.\n */\n default?: string | string[];\n\n /**\n * A standard string format to validate the option value against.\n */\n format?:\n | \"email\"\n | \"uri\"\n | \"uuid\"\n | \"ipv4\"\n | \"ipv6\"\n | \"date\"\n | \"time\"\n | \"date-time\"\n | \"duration\";\n\n /**\n * The allowed choices for the option value.\n */\n choices?: string[];\n}\n\nexport interface SingleStringCommandParameter extends BaseStringCommandParameter {\n /**\n * The default value.\n */\n default?: string;\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: false;\n}\n\nexport interface VariadicStringCommandParameter extends BaseStringCommandParameter {\n /**\n * The default value.\n */\n default?: string[];\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: true;\n}\n\nexport type StringCommandParameter =\n | SingleStringCommandParameter\n | VariadicStringCommandParameter;\n\nexport interface BaseNumberCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"number\";\n\n /**\n * The default value.\n */\n default?: number | number[];\n\n /**\n * The allowed choices for the option value.\n */\n choices?: number[];\n}\n\nexport interface SingleNumberCommandParameter extends BaseNumberCommandParameter {\n /**\n * The default value.\n */\n default?: number;\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: false;\n}\n\nexport interface VariadicNumberCommandParameter extends BaseNumberCommandParameter {\n /**\n * The default value.\n */\n default?: number[];\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: true;\n}\n\nexport type NumberCommandParameter =\n | SingleNumberCommandParameter\n | VariadicNumberCommandParameter;\n\nexport interface BaseBooleanCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"boolean\";\n\n /**\n * The default value.\n */\n default?: boolean | boolean[];\n}\n\nexport interface SingleBooleanCommandParameter extends BaseBooleanCommandParameter {\n /**\n * The default value.\n */\n default?: boolean;\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: false;\n}\n\nexport interface VariadicBooleanCommandParameter extends BaseBooleanCommandParameter {\n /**\n * The default value.\n */\n default?: boolean[];\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: true;\n}\n\nexport type BooleanCommandParameter =\n | SingleBooleanCommandParameter\n | VariadicBooleanCommandParameter;\n\nexport type CommandParameter =\n | StringCommandParameter\n | NumberCommandParameter\n | BooleanCommandParameter;\n\nexport type AsCommandParameterConfig<T extends BaseCommandParameter> = Pick<\n T,\n \"kind\" | \"alias\"\n> &\n Partial<Omit<T, \"kind\" | \"alias\">> & {\n alias?: string | string[];\n };\n\nexport type StringCommandParameterConfig =\n AsCommandParameterConfig<StringCommandParameter>;\nexport type NumberCommandParameterConfig =\n AsCommandParameterConfig<NumberCommandParameter>;\nexport type BooleanCommandParameterConfig =\n AsCommandParameterConfig<BooleanCommandParameter>;\n\nexport type CommandParameterConfig =\n | StringCommandParameterConfig\n | NumberCommandParameterConfig\n | BooleanCommandParameterConfig;\n\nexport interface BooleanCommandOption extends SingleBooleanCommandParameter {\n /**\n * The option this negates.\n */\n isNegativeOf?: string;\n\n /**\n * Whether to skip adding a negative option.\n */\n skipAddingNegative?: boolean;\n}\n\nexport type CommandOption =\n | StringCommandParameter\n | NumberCommandParameter\n | BooleanCommandOption\n | VariadicBooleanCommandParameter;\nexport type CommandOptionConfig = AsCommandParameterConfig<CommandOption>;\n\nexport type CommandArgument =\n | StringCommandParameter\n | NumberCommandParameter\n | BooleanCommandParameter;\nexport type CommandArgumentConfig = AsCommandParameterConfig<CommandArgument>;\n\nexport interface CommandBase {\n /**\n * The command id.\n */\n id: string | null;\n\n /**\n * The command name.\n */\n name: string;\n\n /**\n * The full command path value.\n */\n path: string | null;\n\n /**\n * The path segments.\n */\n segments: string[];\n\n /**\n * The display title.\n */\n title?: string;\n\n /**\n * The command description.\n */\n description?: string;\n\n /**\n * Alternative command names.\n */\n alias?: string[];\n\n /**\n * The command icon.\n */\n icon?: string;\n\n /**\n * A URL to the command documentation or reference.\n */\n reference?: string;\n\n /**\n * Whether the command is virtual.\n *\n * @remarks\n * Virtual commands are considered forks in the command tree and are not directly executable. They are used to group related subcommands together without having an actual command handler or entry point.\n */\n isVirtual: boolean;\n}\n\nexport interface CommandConfig extends CommandBase {\n /**\n * The command id.\n */\n id: string;\n\n /**\n * The resolved entry definition.\n */\n entry: ResolvedEntryTypeDefinition;\n\n /**\n * Optional tags for the command.\n *\n * @remarks\n * 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.\n */\n tags?: string[];\n\n /**\n * 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.\n */\n source?: \"file\" | string;\n}\n\nexport type CommandTree = CommandConfig & {\n /**\n * The display title.\n */\n title: string;\n\n /**\n * The command description.\n */\n description: string;\n\n /**\n * Alternative command names.\n */\n alias: string[];\n\n /**\n * A set of tags for the command.\n *\n * @remarks\n * 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.\n */\n tags: string[];\n\n /**\n * 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.\n */\n source: \"file\" | string;\n\n /**\n * The command options.\n */\n options: Record<string, CommandOption>;\n\n /**\n * The positional arguments provided to the command.\n */\n args: CommandArgument[];\n\n /**\n * The parent command.\n */\n parent: null | CommandTree;\n\n /**\n * Child commands.\n */\n children: Record<string, CommandTree>;\n};\n\nexport type SerializedCommandTree = Omit<CommandTree, \"parent\" | \"children\"> & {\n /**\n * The parent command id.\n */\n parent: null | string;\n /**\n * Serialized child commands.\n */\n children: Record<string, SerializedCommandTree>;\n};\n\nexport interface CommandMetadata {\n /**\n * The display name of the command.\n *\n * @remarks\n * This value will be used in various displays of the user interface and documentation. If not provided, a formatted value of the command name will be used.\n */\n title?: string;\n\n /**\n * A brief description of what the command does.\n *\n * @remarks\n * This value will be used in various displays of the user interface and documentation. If not provided, a default message may be shown.\n */\n description?: string;\n\n /**\n * One or more alternative names for the command.\n */\n alias?: string | string[];\n\n /**\n * Optional tags for the command.\n *\n * @remarks\n * 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.\n */\n tags?: string[];\n\n /**\n * An optional icon to visually represent the command in user interfaces.\n *\n * @remarks\n * This can be a string containing an emoji, a Unicode character, or any other symbol that helps to visually identify the command. If not provided, no icon will be displayed.\n */\n icon?: string;\n\n /**\n * A URL to the command documentation or reference.\n *\n * @remarks\n * This URL can be used in various displays of the user interface and documentation to provide users with a reference for the command. It can also be used by plugins to link to the documentation in relevant contexts. If the token `{command}` is included in the URL, it will be replaced with the full command path to provide links to command specific documentation. For example, `myapp command subcommand` will be translated to `{referenceLink}/command/subcommand`.\n */\n reference?: string;\n}\n\nexport interface CommandModule {\n metadata?: CommandMetadata;\n options?:\n | Record<string, CommandOptionConfig>\n | JSONSchema7Object\n | StandardJSONSchemaV1<Record<string, CommandParameterType>>\n | z3.AnyZodObject;\n args?:\n | CommandArgumentConfig[]\n | JsonSchema7TupleType\n | StandardJSONSchemaV1<CommandParameterType[]>\n | z3.AnyZodTuple;\n default?: AnyFunction;\n}\n"],"mappings":";AAAA,MAAM,UAAU;CAAC;CAAK;CAAK;CAAQ;CAA4B;;;;;;AAE/D,MAAM,UAAU;CAAC;CAAG;OAAM;OAAiB;CAAA;CAAA;CAAA;;;;;;;AAE3C,MAAM,aAAS;CAAA;CAAS;CAAG;CAAY;CAA2B;AAClE,MAAI,0BAA4B,CAAC,wBAAqB,gBAAa;AAEnE,MAAK,wBAA0B;;CAE9B,QAAS;CACT,SAAU;CACV;AACD,MAAC,0BAA+B;OAAG;OAAkB;CAAA;CAAA;CAAA;AAErD,MAAM,0BAAqB;CAAM;CAAG;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEpC,MAAM,gCAAgC;CAAC;CAAW;CAAoB;CAAA;CAAA;CAAA;CAAA;CAAA;AAEtE,MAAM,kCAA+B;CAAI;CAAW;CAAa;CAAA;CAAA;CAAA;CAAA;CAAA;AAEjE,MAAM,gCAA6B;OAAO;CAAW;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAErD,MAAM,kCAAQ;OAA8B;CAAiB;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;AAI7D,MAAI,4BAAA;OAAA;OAAA;CAAA;CAAA;CAAA;AAEJ,MAAI,gCAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAA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AAQ;OAAgB;CAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEtD,MAAM,qBAAe;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAErB,MAAI,mBAAA;OAAA;CAAA;OAAA;OAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
|
package/dist/types/config.cjs
CHANGED
|
@@ -12,11 +12,6 @@ const __ΩPartial = [
|
|
|
12
12
|
"Partial",
|
|
13
13
|
"l+e#!e\"!fRb!Pde\"!gN#\"w\"y"
|
|
14
14
|
];
|
|
15
|
-
const __ΩRequired = [
|
|
16
|
-
"T",
|
|
17
|
-
"Required",
|
|
18
|
-
"l+e#!e\"!fRb!Pde\"!gN##w\"y"
|
|
19
|
-
];
|
|
20
15
|
const __ΩOmit = [
|
|
21
16
|
"T",
|
|
22
17
|
"K",
|
|
@@ -25,6 +20,11 @@ const __ΩOmit = [
|
|
|
25
20
|
"Omit",
|
|
26
21
|
"b!b\"e!!e!!ge!\"o$#o##w%y"
|
|
27
22
|
];
|
|
23
|
+
const __ΩRequired = [
|
|
24
|
+
"T",
|
|
25
|
+
"Required",
|
|
26
|
+
"l+e#!e\"!fRb!Pde\"!gN##w\"y"
|
|
27
|
+
];
|
|
28
28
|
const __ΩRecord = [
|
|
29
29
|
"K",
|
|
30
30
|
"T",
|
|
@@ -37,22 +37,6 @@ const __ΩExclude = [
|
|
|
37
37
|
"Exclude",
|
|
38
38
|
"l6!Re$!RPe#!e$\"qk#%QRb!b\"Pde\"!p)w#y"
|
|
39
39
|
];
|
|
40
|
-
const __ΩBuildOptions = [
|
|
41
|
-
() => __ΩPick,
|
|
42
|
-
"root",
|
|
43
|
-
"name",
|
|
44
|
-
"title",
|
|
45
|
-
"description",
|
|
46
|
-
"logLevel",
|
|
47
|
-
"mode",
|
|
48
|
-
"skipCache",
|
|
49
|
-
"autoInstall",
|
|
50
|
-
"plugins",
|
|
51
|
-
"tsconfig",
|
|
52
|
-
"tsconfigRaw",
|
|
53
|
-
"BuildOptions",
|
|
54
|
-
"!P.\".#.$.%.&.'.(.).*.+.,Jo!#w-y"
|
|
55
|
-
];
|
|
56
40
|
const __ΩReferenceOptions = [
|
|
57
41
|
"app",
|
|
58
42
|
"A URL to the application documentation or reference.",
|
|
@@ -62,8 +46,6 @@ const __ΩReferenceOptions = [
|
|
|
62
46
|
"P&4!?\"&4#8?$Mw%y"
|
|
63
47
|
];
|
|
64
48
|
const __ΩBaseOptions = [
|
|
65
|
-
() => __ΩPartial,
|
|
66
|
-
() => __ΩBuildOptions,
|
|
67
49
|
"CommandOption",
|
|
68
50
|
"Context",
|
|
69
51
|
"context",
|
|
@@ -85,7 +67,7 @@ const __ΩBaseOptions = [
|
|
|
85
67
|
"reference",
|
|
86
68
|
"A URL to the application documentation or reference.",
|
|
87
69
|
"BaseOptions",
|
|
88
|
-
"
|
|
70
|
+
"PP\"w!FP\"w\"2#\"w$2%\"w!F/&.'J4(8?))4*8>+?,P&&FJ4-8?.P./&J408?1Pn2&J438?4Mw5y"
|
|
89
71
|
];
|
|
90
72
|
const __ΩOptions = [
|
|
91
73
|
() => __ΩBaseOptions,
|
|
@@ -98,22 +80,29 @@ const __ΩOutputConfig = [
|
|
|
98
80
|
"path",
|
|
99
81
|
"copy",
|
|
100
82
|
"storage",
|
|
83
|
+
"sourceMap",
|
|
101
84
|
false,
|
|
102
85
|
"dts",
|
|
103
86
|
"An indicator specifying whether to generate TypeScript declaration files (.d.ts) during the build process.",
|
|
104
87
|
"OutputConfig",
|
|
105
|
-
"P!P.\"
|
|
88
|
+
"P!P.\".#.$.%Jo!#P.&4'8?(MKw)y"
|
|
106
89
|
];
|
|
107
90
|
const __ΩUserConfig = [
|
|
108
91
|
() => __ΩBaseOptions,
|
|
109
|
-
() => __ΩPartial,
|
|
110
|
-
() => __ΩPick,
|
|
111
|
-
"root",
|
|
112
92
|
() => __ΩOutputConfig,
|
|
113
93
|
"output",
|
|
114
94
|
"Configuration for the output of the build process",
|
|
115
95
|
"UserConfig",
|
|
116
|
-
"Pn!!
|
|
96
|
+
"Pn!!Pn\"4#8?$MKw%y"
|
|
97
|
+
];
|
|
98
|
+
const __ΩEngineOptions = [
|
|
99
|
+
() => __ΩOmit,
|
|
100
|
+
"root",
|
|
101
|
+
"name",
|
|
102
|
+
"framework",
|
|
103
|
+
() => __ΩUserConfig,
|
|
104
|
+
"EngineOptions",
|
|
105
|
+
"P!P.\".#.$Jo!#n%Kw&y"
|
|
117
106
|
];
|
|
118
107
|
const __ΩResolvedConfig = [
|
|
119
108
|
() => __ΩRequired,
|
|
@@ -133,10 +122,11 @@ const __ΩResolvedConfig = [
|
|
|
133
122
|
"userConfig",
|
|
134
123
|
"The user configuration for the Shell Shock process.",
|
|
135
124
|
"ResolvedConfig",
|
|
136
|
-
"P
|
|
125
|
+
"P!!!!n#P.$.%Jo\"#o!\"P&&o'?(n)4*?+&4,?-n.4/?0MKw1y"
|
|
137
126
|
];
|
|
138
127
|
|
|
139
128
|
//#endregion
|
|
129
|
+
exports.__ΩEngineOptions = __ΩEngineOptions;
|
|
140
130
|
exports.__ΩOptions = __ΩOptions;
|
|
141
131
|
exports.__ΩOutputConfig = __ΩOutputConfig;
|
|
142
132
|
exports.__ΩReferenceOptions = __ΩReferenceOptions;
|
package/dist/types/config.d.cts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { CommandBase, CommandOption } from "./command.cjs";
|
|
2
2
|
import { Context } from "./context.cjs";
|
|
3
|
-
import { OutputConfig as OutputConfig$1 } from "powerlines";
|
|
3
|
+
import { EngineOptions as EngineOptions$1, OutputConfig as OutputConfig$1, UserConfig as UserConfig$1 } from "powerlines";
|
|
4
|
+
import { AlloyPluginResolvedConfig } from "@powerlines/plugin-alloy/types/plugin";
|
|
4
5
|
import { AutoMDPluginResolvedConfig } from "@powerlines/plugin-automd";
|
|
5
|
-
import { NodeJsPluginOptions, NodeJsPluginResolvedConfig
|
|
6
|
-
import { TsdownPluginResolvedConfig
|
|
6
|
+
import { NodeJsPluginOptions, NodeJsPluginResolvedConfig } from "@powerlines/plugin-nodejs/types/plugin";
|
|
7
|
+
import { TsdownPluginResolvedConfig } from "@powerlines/plugin-tsdown/types/plugin";
|
|
8
|
+
import { RequiredKeys } from "@stryke/types/base";
|
|
7
9
|
|
|
8
10
|
//#region src/types/config.d.ts
|
|
9
|
-
type BuildOptions = Pick<
|
|
11
|
+
type BuildOptions = Pick<UserConfig$1, "root" | "name" | "title" | "description" | "logLevel" | "mode" | "skipCache" | "autoInstall" | "plugins" | "tsconfig" | "tsconfigRaw">;
|
|
10
12
|
interface ReferenceOptions {
|
|
11
13
|
/**
|
|
12
14
|
* A URL to the application documentation or reference.
|
|
@@ -20,7 +22,7 @@ interface ReferenceOptions {
|
|
|
20
22
|
*/
|
|
21
23
|
commands?: string;
|
|
22
24
|
}
|
|
23
|
-
|
|
25
|
+
interface BaseOptions {
|
|
24
26
|
/**
|
|
25
27
|
* A set of global command options to apply to each command.
|
|
26
28
|
*
|
|
@@ -62,7 +64,7 @@ type BaseOptions = Partial<BuildOptions> & {
|
|
|
62
64
|
* This URL can be used in various displays of the user interface and documentation to provide users with a reference for the application. It can also be used by plugins to link to the documentation in relevant contexts. If the token `{command}` is included in the URL, it will be replaced with the full command path to provide links to command specific documentation. For example, `myapp command subcommand` will be translated to `{reference}/command/subcommand`.
|
|
63
65
|
*/
|
|
64
66
|
reference?: ReferenceOptions | string;
|
|
65
|
-
}
|
|
67
|
+
}
|
|
66
68
|
/**
|
|
67
69
|
* The plugin options for Shell Shock.
|
|
68
70
|
*/
|
|
@@ -70,7 +72,7 @@ type Options = BaseOptions & Partial<NodeJsPluginOptions>;
|
|
|
70
72
|
/**
|
|
71
73
|
* The output configuration options for Shell Shock.
|
|
72
74
|
*/
|
|
73
|
-
type OutputConfig = Pick<OutputConfig$1, "path" | "copy" | "storage"> & {
|
|
75
|
+
type OutputConfig = Pick<OutputConfig$1, "path" | "copy" | "storage" | "sourceMap"> & {
|
|
74
76
|
/**
|
|
75
77
|
* An indicator specifying whether to generate TypeScript declaration files (.d.ts) during the build process.
|
|
76
78
|
*/
|
|
@@ -79,16 +81,17 @@ type OutputConfig = Pick<OutputConfig$1, "path" | "copy" | "storage"> & {
|
|
|
79
81
|
/**
|
|
80
82
|
* The user configuration options for Shell Shock.
|
|
81
83
|
*/
|
|
82
|
-
type UserConfig = BaseOptions &
|
|
84
|
+
type UserConfig = BaseOptions & RequiredKeys<BuildOptions, "root" | "name"> & {
|
|
83
85
|
/**
|
|
84
86
|
* Configuration for the output of the build process
|
|
85
87
|
*/
|
|
86
88
|
output?: OutputConfig;
|
|
87
89
|
};
|
|
90
|
+
type EngineOptions = Omit<EngineOptions$1, "root" | "name" | "framework"> & UserConfig;
|
|
88
91
|
/**
|
|
89
92
|
* The resolved configuration options for Shell Shock.
|
|
90
93
|
*/
|
|
91
|
-
type ResolvedConfig = TsdownPluginResolvedConfig & AutoMDPluginResolvedConfig & NodeJsPluginResolvedConfig & Required<Omit<Options, "bin" | "reference">> & {
|
|
94
|
+
type ResolvedConfig = TsdownPluginResolvedConfig & AlloyPluginResolvedConfig & AutoMDPluginResolvedConfig & NodeJsPluginResolvedConfig & Required<Omit<Options, "bin" | "reference">> & {
|
|
92
95
|
/**
|
|
93
96
|
* The name of the binary (the {@link https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bin | "bin" field} in package.json) that will be used to run the application through NodeJs package managers (e.g., npm, yarn, pnpm).
|
|
94
97
|
*
|
|
@@ -114,5 +117,5 @@ type ResolvedConfig = TsdownPluginResolvedConfig & AutoMDPluginResolvedConfig &
|
|
|
114
117
|
userConfig: UserConfig;
|
|
115
118
|
};
|
|
116
119
|
//#endregion
|
|
117
|
-
export { Options, OutputConfig, ReferenceOptions, ResolvedConfig, UserConfig };
|
|
120
|
+
export { EngineOptions, Options, OutputConfig, ReferenceOptions, ResolvedConfig, UserConfig };
|
|
118
121
|
//# sourceMappingURL=config.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.cts","names":[],"sources":["../../src/types/config.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../../src/types/config.ts"],"mappings":";;;;;;;;;;KAkCK,YAAA,GAAe,IAAA,CAClB,YAAA;AAAA,UAce,gBAAA;EAfZ;;;EAmBH,GAAA;EAlBoB;AActB;;;;;EAYE,QAAA;AAAA;AAAA,UAGQ,WAAA;EAQJ;;;;;;EADJ,aAAA,GACI,aAAA,OACE,OAAA,EAAS,OAAA,EAAS,KAAA,EAAO,WAAA,KAAgB,aAAA;EAF/C;;;;;EAUA,eAAA;EAR+C;;;;;;;;AA6CjD;;EAzBE,GAAA;EAyBoB;;;;;;;;;EAdpB,aAAA;EAmBU;;;;;;EAXV,SAAA,GAAY,gBAAA;AAAA;;AAwBd;;KAlBY,OAAA,GAAU,WAAA,GAAc,OAAA,CAAQ,mBAAA;;;;KAKhC,YAAA,GAAe,IAAA,CACzB,cAAA;EAiBuB;;;EAXvB,GAAA;AAAA;;;;KAMU,UAAA,GAAa,WAAA,GACvB,YAAA,CAAa,YAAA;EAOH;;;EAHR,MAAA,GAAS,YAAA;AAAA;AAAA,KAGD,aAAA,GAAgB,IAAA,CAC1B,eAAA,mCAGA,UAAA;;;;KAKU,cAAA,GAAiB,0BAAA,GAC3B,yBAAA,GACA,0BAAA,GACA,0BAAA,GACA,QAAA,CAAS,IAAA,CAAK,OAAA;EATd;;;AAKF;;;;;;;EAeI,GAAA,EAAK,MAAA;EAXE;;;EAgBP,SAAA,EAAW,gBAAA;EAUC;;;EALZ,oBAAA;EAxBF;;;EA6BE,UAAA,EAAY,UAAA;AAAA"}
|
package/dist/types/config.d.mts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { CommandBase, CommandOption } from "./command.mjs";
|
|
2
2
|
import { Context } from "./context.mjs";
|
|
3
|
-
import { OutputConfig as OutputConfig$1 } from "powerlines";
|
|
4
3
|
import { AutoMDPluginResolvedConfig } from "@powerlines/plugin-automd";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { EngineOptions as EngineOptions$1, OutputConfig as OutputConfig$1, UserConfig as UserConfig$1 } from "powerlines";
|
|
5
|
+
import { AlloyPluginResolvedConfig } from "@powerlines/plugin-alloy/types/plugin";
|
|
6
|
+
import { NodeJsPluginOptions, NodeJsPluginResolvedConfig } from "@powerlines/plugin-nodejs/types/plugin";
|
|
7
|
+
import { TsdownPluginResolvedConfig } from "@powerlines/plugin-tsdown/types/plugin";
|
|
8
|
+
import { RequiredKeys } from "@stryke/types/base";
|
|
7
9
|
|
|
8
10
|
//#region src/types/config.d.ts
|
|
9
|
-
type BuildOptions = Pick<
|
|
11
|
+
type BuildOptions = Pick<UserConfig$1, "root" | "name" | "title" | "description" | "logLevel" | "mode" | "skipCache" | "autoInstall" | "plugins" | "tsconfig" | "tsconfigRaw">;
|
|
10
12
|
interface ReferenceOptions {
|
|
11
13
|
/**
|
|
12
14
|
* A URL to the application documentation or reference.
|
|
@@ -20,7 +22,7 @@ interface ReferenceOptions {
|
|
|
20
22
|
*/
|
|
21
23
|
commands?: string;
|
|
22
24
|
}
|
|
23
|
-
|
|
25
|
+
interface BaseOptions {
|
|
24
26
|
/**
|
|
25
27
|
* A set of global command options to apply to each command.
|
|
26
28
|
*
|
|
@@ -62,7 +64,7 @@ type BaseOptions = Partial<BuildOptions> & {
|
|
|
62
64
|
* This URL can be used in various displays of the user interface and documentation to provide users with a reference for the application. It can also be used by plugins to link to the documentation in relevant contexts. If the token `{command}` is included in the URL, it will be replaced with the full command path to provide links to command specific documentation. For example, `myapp command subcommand` will be translated to `{reference}/command/subcommand`.
|
|
63
65
|
*/
|
|
64
66
|
reference?: ReferenceOptions | string;
|
|
65
|
-
}
|
|
67
|
+
}
|
|
66
68
|
/**
|
|
67
69
|
* The plugin options for Shell Shock.
|
|
68
70
|
*/
|
|
@@ -70,7 +72,7 @@ type Options = BaseOptions & Partial<NodeJsPluginOptions>;
|
|
|
70
72
|
/**
|
|
71
73
|
* The output configuration options for Shell Shock.
|
|
72
74
|
*/
|
|
73
|
-
type OutputConfig = Pick<OutputConfig$1, "path" | "copy" | "storage"> & {
|
|
75
|
+
type OutputConfig = Pick<OutputConfig$1, "path" | "copy" | "storage" | "sourceMap"> & {
|
|
74
76
|
/**
|
|
75
77
|
* An indicator specifying whether to generate TypeScript declaration files (.d.ts) during the build process.
|
|
76
78
|
*/
|
|
@@ -79,16 +81,17 @@ type OutputConfig = Pick<OutputConfig$1, "path" | "copy" | "storage"> & {
|
|
|
79
81
|
/**
|
|
80
82
|
* The user configuration options for Shell Shock.
|
|
81
83
|
*/
|
|
82
|
-
type UserConfig = BaseOptions &
|
|
84
|
+
type UserConfig = BaseOptions & RequiredKeys<BuildOptions, "root" | "name"> & {
|
|
83
85
|
/**
|
|
84
86
|
* Configuration for the output of the build process
|
|
85
87
|
*/
|
|
86
88
|
output?: OutputConfig;
|
|
87
89
|
};
|
|
90
|
+
type EngineOptions = Omit<EngineOptions$1, "root" | "name" | "framework"> & UserConfig;
|
|
88
91
|
/**
|
|
89
92
|
* The resolved configuration options for Shell Shock.
|
|
90
93
|
*/
|
|
91
|
-
type ResolvedConfig = TsdownPluginResolvedConfig & AutoMDPluginResolvedConfig & NodeJsPluginResolvedConfig & Required<Omit<Options, "bin" | "reference">> & {
|
|
94
|
+
type ResolvedConfig = TsdownPluginResolvedConfig & AlloyPluginResolvedConfig & AutoMDPluginResolvedConfig & NodeJsPluginResolvedConfig & Required<Omit<Options, "bin" | "reference">> & {
|
|
92
95
|
/**
|
|
93
96
|
* The name of the binary (the {@link https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bin | "bin" field} in package.json) that will be used to run the application through NodeJs package managers (e.g., npm, yarn, pnpm).
|
|
94
97
|
*
|
|
@@ -114,5 +117,5 @@ type ResolvedConfig = TsdownPluginResolvedConfig & AutoMDPluginResolvedConfig &
|
|
|
114
117
|
userConfig: UserConfig;
|
|
115
118
|
};
|
|
116
119
|
//#endregion
|
|
117
|
-
export { Options, OutputConfig, ReferenceOptions, ResolvedConfig, UserConfig };
|
|
120
|
+
export { EngineOptions, Options, OutputConfig, ReferenceOptions, ResolvedConfig, UserConfig };
|
|
118
121
|
//# sourceMappingURL=config.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.mts","names":[],"sources":["../../src/types/config.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../../src/types/config.ts"],"mappings":";;;;;;;;;;KAkCK,YAAA,GAAe,IAAA,CAClB,YAAA;AAAA,UAce,gBAAA;EAfZ;;;EAmBH,GAAA;EAlBoB;AActB;;;;;EAYE,QAAA;AAAA;AAAA,UAGQ,WAAA;EAQJ;;;;;;EADJ,aAAA,GACI,aAAA,OACE,OAAA,EAAS,OAAA,EAAS,KAAA,EAAO,WAAA,KAAgB,aAAA;EAF/C;;;;;EAUA,eAAA;EAR+C;;;;;;;;AA6CjD;;EAzBE,GAAA;EAyBoB;;;;;;;;;EAdpB,aAAA;EAmBU;;;;;;EAXV,SAAA,GAAY,gBAAA;AAAA;;AAwBd;;KAlBY,OAAA,GAAU,WAAA,GAAc,OAAA,CAAQ,mBAAA;;;;KAKhC,YAAA,GAAe,IAAA,CACzB,cAAA;EAiBuB;;;EAXvB,GAAA;AAAA;;;;KAMU,UAAA,GAAa,WAAA,GACvB,YAAA,CAAa,YAAA;EAOH;;;EAHR,MAAA,GAAS,YAAA;AAAA;AAAA,KAGD,aAAA,GAAgB,IAAA,CAC1B,eAAA,mCAGA,UAAA;;;;KAKU,cAAA,GAAiB,0BAAA,GAC3B,yBAAA,GACA,0BAAA,GACA,0BAAA,GACA,QAAA,CAAS,IAAA,CAAK,OAAA;EATd;;;AAKF;;;;;;;EAeI,GAAA,EAAK,MAAA;EAXE;;;EAgBP,SAAA,EAAW,gBAAA;EAUC;;;EALZ,oBAAA;EAxBF;;;EA6BE,UAAA,EAAY,UAAA;AAAA"}
|