@shell-shock/core 0.14.3 → 0.14.4

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/README.md CHANGED
@@ -27,7 +27,7 @@ This package is part of the ⚡<b>Shell Shock</b> monorepo. The Shell Shock pack
27
27
 
28
28
  <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
29
29
 
30
- [![Version](https://img.shields.io/badge/version-0.14.1-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://stormsoftware.com/projects/shell-shock/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/shell-shock/release.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
30
+ [![Version](https://img.shields.io/badge/version-0.14.2-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://stormsoftware.com/projects/shell-shock/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/shell-shock/release.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
31
31
 
32
32
  <!-- prettier-ignore-start -->
33
33
  <!-- markdownlint-disable -->
package/dist/plugin.cjs CHANGED
@@ -156,10 +156,9 @@ const plugin = (options = {}) => {
156
156
  }, this.inputs);
157
157
  this.debug(`Shell Shock will process ${this.inputs.length} command entry files: \n${this.inputs.map((command) => ` - ${command.id}: ${(0, _stryke_path_replace.replacePath)(command.entry.file, this.commandsPath)}`).join("\n")}`);
158
158
  },
159
- types(code) {
159
+ types() {
160
160
  this.debug("Generating type definitions for the Shell Shock application.");
161
- return `${code}
162
-
161
+ return `
163
162
  /**
164
163
  * The global options available for every command in the ${require_context_helpers.getAppTitle(this, true)} command-line application.
165
164
  */
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs","names":[],"sources":["../src/plugin.tsx"],"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 { For, Show } from \"@alloy-js/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport deepkit from \"@powerlines/plugin-deepkit\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath, relativePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { tsdown } from \"powerlines/tsdown\";\nimport { resolveInputs } from \"powerlines/utils\";\nimport type { BuildContext, RolldownChunk, TsdownHooks } from \"tsdown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\nimport { commands } from \"./helpers/automd\";\nimport {\n findCommandsRoot,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/paths\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getGlobalOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport { resolve } from \"./resolver/resolve\";\nimport type { CommandOption, CommandTree } from \"./types/command\";\nimport { CommandParameterKinds } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n) => {\n return [\n tsdown(),\n deepkit(),\n automd(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n await updatePackageJsonBinary(this);\n\n const result = defu(\n {\n output: {\n path: joinPaths(this.config.root, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n platform: \"node\",\n projectType: \"application\",\n framework: \"shell-shock\",\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: false\n },\n input:\n !this.config.input ||\n (Array.isArray(this.config.input) &&\n this.config.input.length === 0) ||\n (isObject(this.config.input) &&\n Object.keys(this.config.input).length === 0)\n ? [\n joinPaths(this.config.root, \"src/**/command.ts\"),\n joinPaths(this.config.root, \"src/**/command.tsx\")\n ]\n : undefined,\n resolve: {\n external: [\"@powerlines/deepkit\"],\n skipNodeModulesBundle: true\n },\n tsdown: {\n dts: false,\n nodeProtocol: true,\n unbundle: false\n }\n }\n );\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n this.config.appSpecificEnvPrefix = isSetString(\n this.config.autoAssignEnv\n )\n ? this.config.autoAssignEnv\n : constantCase(getAppName(this));\n if (\n !this.config.env.prefix ||\n !Array.isArray(this.config.env.prefix)\n ) {\n this.config.env.prefix = toArray(this.config.env.prefix);\n }\n\n if (\n !this.config.env.prefix.includes(this.config.appSpecificEnvPrefix)\n ) {\n this.config.env.prefix.push(this.config.appSpecificEnvPrefix);\n }\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n if (isSetString(this.config.reference)) {\n if (this.config.reference.includes(\"{command}\")) {\n this.config.reference = {\n app: this.config.reference\n .substring(0, this.config.reference.indexOf(\"{command}\"))\n .replace(/\\/?$/, \"/\"),\n commands: this.config.reference\n };\n } else if (this.config.reference.includes(\"{commands}\")) {\n this.config.reference = {\n app: this.config.reference\n .substring(0, this.config.reference.indexOf(\"{commands}\"))\n .replace(/\\/?$/, \"/\"),\n commands: this.config.reference\n };\n } else {\n this.config.reference = {\n app: this.config.reference\n };\n }\n }\n\n this.inputs ??= [];\n this.options = Object.values(\n getGlobalOptions(this, {\n id: null,\n name: this.config.name,\n path: null,\n segments: [],\n title: this.config.title,\n description: this.config.description,\n alias: [],\n isVirtual: false\n })\n );\n }\n }\n },\n ...nodejs<TContext>(\n defu(options ?? {}, {\n env: {\n types: \"@shell-shock/core/types/env#ShellShockEnv\",\n validate: false\n }\n })\n ),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.debug(\n `Checking for commands using input: ${JSON.stringify(this.config.input)}`\n );\n\n this.commandsPath = await findCommandsRoot(this);\n this.debug(`Resolved commands root path: ${this.commandsPath}`);\n\n const inputs = await resolveInputs(this, this.config.input);\n\n this.debug(\n `Found ${\n inputs.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = inputs.reduce((ret, entry) => {\n if (\n entry.file !== this.commandsPath &&\n !isParentPath(entry.file, this.commandsPath)\n ) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(entry.file);\n let segments = resolveCommandPath(this, entry.file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n tags: [],\n isVirtual: false,\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n },\n types(code: string) {\n this.debug(\n \"Generating type definitions for the Shell Shock application.\"\n );\n\n return `${code}\n\n/**\n * The global options available for every command in the ${getAppTitle(\n this,\n true\n )} command-line application.\n */\nexport interface GlobalOptions {\n ${this.options\n .map(\n option =>\n `${\n option.description\n ? `\n/**\n * ${option.description}${\n option.default\n ? `\n *\n * @defaultValue ${\n option.kind === CommandParameterKinds.string\n ? `\"${option.default}\"`\n : option.default\n }`\n : \"\"\n }\n */\n`\n : \"\"\n }${option.name}${option.optional ? \"?\" : \"\"}: ${\n option.kind === CommandParameterKinds.boolean\n ? \"boolean\"\n : `${option.variadic ? \"(\" : \"\"}${\n option.choices\n ? option.choices\n .map(choice =>\n option.kind === CommandParameterKinds.number\n ? `${choice}`\n : `\"${choice}\"`\n )\n .join(\" | \")\n : option.kind === CommandParameterKinds.number\n ? \"number\"\n : \"string\"\n }${option.variadic ? \")[]\" : \"\"}`\n };${\n option.alias && option.alias.length > 0\n ? option.alias\n .map(\n alias =>\n `${alias}${option.optional ? \"?\" : \"\"}: ${\n option.kind === CommandParameterKinds.boolean\n ? \"boolean\"\n : `${option.variadic ? \"(\" : \"\"}${\n option.choices\n ? option.choices\n .map(choice =>\n option.kind === CommandParameterKinds.number\n ? `${choice}`\n : `\"${choice}\"`\n )\n .join(\" | \")\n : option.kind === CommandParameterKinds.number\n ? \"number\"\n : \"string\"\n }${option.variadic ? \")[]\" : \"\"}`\n };`\n )\n .join(\"\\n\\n\")\n : \"\"\n }`\n )\n .join(\"\\n\\n\")}\n}\n`;\n },\n async prepare() {\n this.debug(\n \"Rendering base built-in modules for the Shell Shock application.\"\n );\n\n return render(\n this,\n <>\n <UtilsBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${\n isParentPath(command.entry.file, this.commandsPath)\n ? replacePath(command.entry.file, this.commandsPath)\n : relativePath(command.entry.file, this.commandsPath)\n }${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n if (isParentPath(parentPath, this.commandsPath)) {\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Unable to process virtual commands for ${command.name} \\n\\nPlease ensure ${command.entry.file} is a valid command entry file and does not have an invalid path.`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n\n let segments = resolveCommandPath(this, file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n tags: [],\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.segments.length - b.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:resolve-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n\n this.commands = {};\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping command resolution as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await resolve({\n context: this,\n command: input\n });\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n this.options = this.options.map(\n option =>\n ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }) as CommandOption\n );\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n } as CommandOption\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.tsdown.hooks ??= {} as TsdownHooks;\n (this.config.tsdown.hooks as TsdownHooks)[\"build:done\"] = async (\n _: BuildContext & {\n chunks: RolldownChunk[];\n }\n ) => {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(this.workspaceConfig.workspaceRoot, this.config.root)\n );\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding hashbang to binary executable output file: ${path}`\n );\n\n const content = await this.fs.read(path);\n if (content && !content.startsWith(\"#!\")) {\n await this.fs.write(\n path,\n `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n\\n${content}`\n );\n }\n\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${\n path\n }`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Expected binary output file not found at path: ${\n path\n }. Skipping adding hashbang and executable permissions (chmod+x).`\n );\n }\n })\n );\n };\n }\n },\n {\n name: \"shell-shock:docs\",\n configResolved() {\n this.config.automd ??= {};\n this.config.automd.generators = {\n ...(this.config.automd.generators ?? {}),\n commands: commands(this)\n };\n },\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAM,YAAY;;;;AAKlB,MAAY,UAAA,UAAA,EAAA,KAAA;AACV,QAAA;iCAAW;2CAAA;0CAAA;EAAA;GACX,MAAA;GACA,MAAA,SAAA;AACA,SAAA,MAAA,2CAAA;AACI,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G,OAAO,OAAA,cAAA,EAAA;KACd,UAAS,wBAAO,KAAQ;KACzB;;GAEH,MAAM,OAAO;AACX,SAAK,MAAM,oEAA6C;IACxD,MAAM,WAAW,KAAK,OAAG,KAAO,UAAA,wCAAA,MAAA,MAAA,SAAA,CAAA,CAAA,OAAA,QAAA;AAChC,uDAAc,sDAAoB,+BAAA;KAChC,IAAI,OAAO;AACT,aAAO,OAAM,OAAQ,SAAE;;KAEzB,gBAAe;KACf,WAAU,0DAAW,gCAAA;MACnB,IAAI,OAAG;AACN,cAAA,CAAA,MAAA;;MAED,IAAI,WAAO;AACT,8DAAQ,yCAAA,EACN,SAAS,OACV,CAAC;;MAEL,CAAC;KACH,CAAC,CAAC;;GAEN;EAAC"}
1
+ {"version":3,"file":"plugin.cjs","names":[],"sources":["../src/plugin.tsx"],"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 { For, Show } from \"@alloy-js/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport deepkit from \"@powerlines/plugin-deepkit\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath, relativePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { tsdown } from \"powerlines/tsdown\";\nimport { resolveInputs } from \"powerlines/utils\";\nimport type { BuildContext, RolldownChunk, TsdownHooks } from \"tsdown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\nimport { commands } from \"./helpers/automd\";\nimport {\n findCommandsRoot,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/paths\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getGlobalOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport { resolve } from \"./resolver/resolve\";\nimport type { CommandOption, CommandTree } from \"./types/command\";\nimport { CommandParameterKinds } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n) => {\n return [\n tsdown(),\n deepkit(),\n automd(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n await updatePackageJsonBinary(this);\n\n const result = defu(\n {\n output: {\n path: joinPaths(this.config.root, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n platform: \"node\",\n projectType: \"application\",\n framework: \"shell-shock\",\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: false\n },\n input:\n !this.config.input ||\n (Array.isArray(this.config.input) &&\n this.config.input.length === 0) ||\n (isObject(this.config.input) &&\n Object.keys(this.config.input).length === 0)\n ? [\n joinPaths(this.config.root, \"src/**/command.ts\"),\n joinPaths(this.config.root, \"src/**/command.tsx\")\n ]\n : undefined,\n resolve: {\n external: [\"@powerlines/deepkit\"],\n skipNodeModulesBundle: true\n },\n tsdown: {\n dts: false,\n nodeProtocol: true,\n unbundle: false\n }\n }\n );\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n this.config.appSpecificEnvPrefix = isSetString(\n this.config.autoAssignEnv\n )\n ? this.config.autoAssignEnv\n : constantCase(getAppName(this));\n if (\n !this.config.env.prefix ||\n !Array.isArray(this.config.env.prefix)\n ) {\n this.config.env.prefix = toArray(this.config.env.prefix);\n }\n\n if (\n !this.config.env.prefix.includes(this.config.appSpecificEnvPrefix)\n ) {\n this.config.env.prefix.push(this.config.appSpecificEnvPrefix);\n }\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n if (isSetString(this.config.reference)) {\n if (this.config.reference.includes(\"{command}\")) {\n this.config.reference = {\n app: this.config.reference\n .substring(0, this.config.reference.indexOf(\"{command}\"))\n .replace(/\\/?$/, \"/\"),\n commands: this.config.reference\n };\n } else if (this.config.reference.includes(\"{commands}\")) {\n this.config.reference = {\n app: this.config.reference\n .substring(0, this.config.reference.indexOf(\"{commands}\"))\n .replace(/\\/?$/, \"/\"),\n commands: this.config.reference\n };\n } else {\n this.config.reference = {\n app: this.config.reference\n };\n }\n }\n\n this.inputs ??= [];\n this.options = Object.values(\n getGlobalOptions(this, {\n id: null,\n name: this.config.name,\n path: null,\n segments: [],\n title: this.config.title,\n description: this.config.description,\n alias: [],\n isVirtual: false\n })\n );\n }\n }\n },\n ...nodejs<TContext>(\n defu(options ?? {}, {\n env: {\n types: \"@shell-shock/core/types/env#ShellShockEnv\",\n validate: false\n }\n })\n ),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.debug(\n `Checking for commands using input: ${JSON.stringify(this.config.input)}`\n );\n\n this.commandsPath = await findCommandsRoot(this);\n this.debug(`Resolved commands root path: ${this.commandsPath}`);\n\n const inputs = await resolveInputs(this, this.config.input);\n\n this.debug(\n `Found ${\n inputs.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = inputs.reduce((ret, entry) => {\n if (\n entry.file !== this.commandsPath &&\n !isParentPath(entry.file, this.commandsPath)\n ) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(entry.file);\n let segments = resolveCommandPath(this, entry.file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n tags: [],\n isVirtual: false,\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n },\n types() {\n this.debug(\n \"Generating type definitions for the Shell Shock application.\"\n );\n\n return `\n/**\n * The global options available for every command in the ${getAppTitle(\n this,\n true\n )} command-line application.\n */\nexport interface GlobalOptions {\n ${this.options\n .map(\n option =>\n `${\n option.description\n ? `\n/**\n * ${option.description}${\n option.default\n ? `\n *\n * @defaultValue ${\n option.kind === CommandParameterKinds.string\n ? `\"${option.default}\"`\n : option.default\n }`\n : \"\"\n }\n */\n`\n : \"\"\n }${option.name}${option.optional ? \"?\" : \"\"}: ${\n option.kind === CommandParameterKinds.boolean\n ? \"boolean\"\n : `${option.variadic ? \"(\" : \"\"}${\n option.choices\n ? option.choices\n .map(choice =>\n option.kind === CommandParameterKinds.number\n ? `${choice}`\n : `\"${choice}\"`\n )\n .join(\" | \")\n : option.kind === CommandParameterKinds.number\n ? \"number\"\n : \"string\"\n }${option.variadic ? \")[]\" : \"\"}`\n };${\n option.alias && option.alias.length > 0\n ? option.alias\n .map(\n alias =>\n `${alias}${option.optional ? \"?\" : \"\"}: ${\n option.kind === CommandParameterKinds.boolean\n ? \"boolean\"\n : `${option.variadic ? \"(\" : \"\"}${\n option.choices\n ? option.choices\n .map(choice =>\n option.kind === CommandParameterKinds.number\n ? `${choice}`\n : `\"${choice}\"`\n )\n .join(\" | \")\n : option.kind === CommandParameterKinds.number\n ? \"number\"\n : \"string\"\n }${option.variadic ? \")[]\" : \"\"}`\n };`\n )\n .join(\"\\n\\n\")\n : \"\"\n }`\n )\n .join(\"\\n\\n\")}\n}\n`;\n },\n async prepare() {\n this.debug(\n \"Rendering base built-in modules for the Shell Shock application.\"\n );\n\n return render(\n this,\n <>\n <UtilsBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${\n isParentPath(command.entry.file, this.commandsPath)\n ? replacePath(command.entry.file, this.commandsPath)\n : relativePath(command.entry.file, this.commandsPath)\n }${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n if (isParentPath(parentPath, this.commandsPath)) {\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Unable to process virtual commands for ${command.name} \\n\\nPlease ensure ${command.entry.file} is a valid command entry file and does not have an invalid path.`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n\n let segments = resolveCommandPath(this, file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n tags: [],\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.segments.length - b.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:resolve-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n\n this.commands = {};\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping command resolution as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await resolve({\n context: this,\n command: input\n });\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n this.options = this.options.map(\n option =>\n ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }) as CommandOption\n );\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n } as CommandOption\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.tsdown.hooks ??= {} as TsdownHooks;\n (this.config.tsdown.hooks as TsdownHooks)[\"build:done\"] = async (\n _: BuildContext & {\n chunks: RolldownChunk[];\n }\n ) => {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(this.workspaceConfig.workspaceRoot, this.config.root)\n );\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding hashbang to binary executable output file: ${path}`\n );\n\n const content = await this.fs.read(path);\n if (content && !content.startsWith(\"#!\")) {\n await this.fs.write(\n path,\n `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n\\n${content}`\n );\n }\n\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${\n path\n }`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Expected binary output file not found at path: ${\n path\n }. Skipping adding hashbang and executable permissions (chmod+x).`\n );\n }\n })\n );\n };\n }\n },\n {\n name: \"shell-shock:docs\",\n configResolved() {\n this.config.automd ??= {};\n this.config.automd.generators = {\n ...(this.config.automd.generators ?? {}),\n commands: commands(this)\n };\n },\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,M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,OAAA,KA2mBJ,MAAA,CAAO,QAAA"}
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.tsx"],"mappings":";;;;;;;AAkFA;cAAa,MAAA,oBAA2B,OAAA,GAAU,OAAA,EAChD,OAAA,GAAS,OAAA,KA0mBJ,MAAA,CAAO,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.tsx"],"mappings":";;;;;;;AAkFA;cAAa,MAAA,oBAA2B,OAAA,GAAU,OAAA,EAChD,OAAA,GAAS,OAAA,KA2mBJ,MAAA,CAAO,QAAA"}
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.tsx"],"mappings":";;;;;;;AAkFA;cAAa,MAAA,oBAA2B,OAAA,GAAU,OAAA,EAChD,OAAA,GAAS,OAAA,KA0mBJ,MAAA,CAAO,QAAA"}
package/dist/plugin.mjs CHANGED
@@ -151,10 +151,9 @@ const plugin = (options = {}) => {
151
151
  }, this.inputs);
152
152
  this.debug(`Shell Shock will process ${this.inputs.length} command entry files: \n${this.inputs.map((command) => ` - ${command.id}: ${replacePath(command.entry.file, this.commandsPath)}`).join("\n")}`);
153
153
  },
154
- types(code) {
154
+ types() {
155
155
  this.debug("Generating type definitions for the Shell Shock application.");
156
- return `${code}
157
-
156
+ return `
158
157
  /**
159
158
  * The global options available for every command in the ${getAppTitle(this, true)} command-line application.
160
159
  */
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.tsx"],"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 { For, Show } from \"@alloy-js/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport deepkit from \"@powerlines/plugin-deepkit\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath, relativePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { tsdown } from \"powerlines/tsdown\";\nimport { resolveInputs } from \"powerlines/utils\";\nimport type { BuildContext, RolldownChunk, TsdownHooks } from \"tsdown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\nimport { commands } from \"./helpers/automd\";\nimport {\n findCommandsRoot,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/paths\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getGlobalOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport { resolve } from \"./resolver/resolve\";\nimport type { CommandOption, CommandTree } from \"./types/command\";\nimport { CommandParameterKinds } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n) => {\n return [\n tsdown(),\n deepkit(),\n automd(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n await updatePackageJsonBinary(this);\n\n const result = defu(\n {\n output: {\n path: joinPaths(this.config.root, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n platform: \"node\",\n projectType: \"application\",\n framework: \"shell-shock\",\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: false\n },\n input:\n !this.config.input ||\n (Array.isArray(this.config.input) &&\n this.config.input.length === 0) ||\n (isObject(this.config.input) &&\n Object.keys(this.config.input).length === 0)\n ? [\n joinPaths(this.config.root, \"src/**/command.ts\"),\n joinPaths(this.config.root, \"src/**/command.tsx\")\n ]\n : undefined,\n resolve: {\n external: [\"@powerlines/deepkit\"],\n skipNodeModulesBundle: true\n },\n tsdown: {\n dts: false,\n nodeProtocol: true,\n unbundle: false\n }\n }\n );\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n this.config.appSpecificEnvPrefix = isSetString(\n this.config.autoAssignEnv\n )\n ? this.config.autoAssignEnv\n : constantCase(getAppName(this));\n if (\n !this.config.env.prefix ||\n !Array.isArray(this.config.env.prefix)\n ) {\n this.config.env.prefix = toArray(this.config.env.prefix);\n }\n\n if (\n !this.config.env.prefix.includes(this.config.appSpecificEnvPrefix)\n ) {\n this.config.env.prefix.push(this.config.appSpecificEnvPrefix);\n }\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n if (isSetString(this.config.reference)) {\n if (this.config.reference.includes(\"{command}\")) {\n this.config.reference = {\n app: this.config.reference\n .substring(0, this.config.reference.indexOf(\"{command}\"))\n .replace(/\\/?$/, \"/\"),\n commands: this.config.reference\n };\n } else if (this.config.reference.includes(\"{commands}\")) {\n this.config.reference = {\n app: this.config.reference\n .substring(0, this.config.reference.indexOf(\"{commands}\"))\n .replace(/\\/?$/, \"/\"),\n commands: this.config.reference\n };\n } else {\n this.config.reference = {\n app: this.config.reference\n };\n }\n }\n\n this.inputs ??= [];\n this.options = Object.values(\n getGlobalOptions(this, {\n id: null,\n name: this.config.name,\n path: null,\n segments: [],\n title: this.config.title,\n description: this.config.description,\n alias: [],\n isVirtual: false\n })\n );\n }\n }\n },\n ...nodejs<TContext>(\n defu(options ?? {}, {\n env: {\n types: \"@shell-shock/core/types/env#ShellShockEnv\",\n validate: false\n }\n })\n ),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.debug(\n `Checking for commands using input: ${JSON.stringify(this.config.input)}`\n );\n\n this.commandsPath = await findCommandsRoot(this);\n this.debug(`Resolved commands root path: ${this.commandsPath}`);\n\n const inputs = await resolveInputs(this, this.config.input);\n\n this.debug(\n `Found ${\n inputs.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = inputs.reduce((ret, entry) => {\n if (\n entry.file !== this.commandsPath &&\n !isParentPath(entry.file, this.commandsPath)\n ) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(entry.file);\n let segments = resolveCommandPath(this, entry.file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n tags: [],\n isVirtual: false,\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n },\n types(code: string) {\n this.debug(\n \"Generating type definitions for the Shell Shock application.\"\n );\n\n return `${code}\n\n/**\n * The global options available for every command in the ${getAppTitle(\n this,\n true\n )} command-line application.\n */\nexport interface GlobalOptions {\n ${this.options\n .map(\n option =>\n `${\n option.description\n ? `\n/**\n * ${option.description}${\n option.default\n ? `\n *\n * @defaultValue ${\n option.kind === CommandParameterKinds.string\n ? `\"${option.default}\"`\n : option.default\n }`\n : \"\"\n }\n */\n`\n : \"\"\n }${option.name}${option.optional ? \"?\" : \"\"}: ${\n option.kind === CommandParameterKinds.boolean\n ? \"boolean\"\n : `${option.variadic ? \"(\" : \"\"}${\n option.choices\n ? option.choices\n .map(choice =>\n option.kind === CommandParameterKinds.number\n ? `${choice}`\n : `\"${choice}\"`\n )\n .join(\" | \")\n : option.kind === CommandParameterKinds.number\n ? \"number\"\n : \"string\"\n }${option.variadic ? \")[]\" : \"\"}`\n };${\n option.alias && option.alias.length > 0\n ? option.alias\n .map(\n alias =>\n `${alias}${option.optional ? \"?\" : \"\"}: ${\n option.kind === CommandParameterKinds.boolean\n ? \"boolean\"\n : `${option.variadic ? \"(\" : \"\"}${\n option.choices\n ? option.choices\n .map(choice =>\n option.kind === CommandParameterKinds.number\n ? `${choice}`\n : `\"${choice}\"`\n )\n .join(\" | \")\n : option.kind === CommandParameterKinds.number\n ? \"number\"\n : \"string\"\n }${option.variadic ? \")[]\" : \"\"}`\n };`\n )\n .join(\"\\n\\n\")\n : \"\"\n }`\n )\n .join(\"\\n\\n\")}\n}\n`;\n },\n async prepare() {\n this.debug(\n \"Rendering base built-in modules for the Shell Shock application.\"\n );\n\n return render(\n this,\n <>\n <UtilsBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${\n isParentPath(command.entry.file, this.commandsPath)\n ? replacePath(command.entry.file, this.commandsPath)\n : relativePath(command.entry.file, this.commandsPath)\n }${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n if (isParentPath(parentPath, this.commandsPath)) {\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Unable to process virtual commands for ${command.name} \\n\\nPlease ensure ${command.entry.file} is a valid command entry file and does not have an invalid path.`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n\n let segments = resolveCommandPath(this, file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n tags: [],\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.segments.length - b.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:resolve-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n\n this.commands = {};\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping command resolution as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await resolve({\n context: this,\n command: input\n });\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n this.options = this.options.map(\n option =>\n ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }) as CommandOption\n );\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n } as CommandOption\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.tsdown.hooks ??= {} as TsdownHooks;\n (this.config.tsdown.hooks as TsdownHooks)[\"build:done\"] = async (\n _: BuildContext & {\n chunks: RolldownChunk[];\n }\n ) => {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(this.workspaceConfig.workspaceRoot, this.config.root)\n );\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding hashbang to binary executable output file: ${path}`\n );\n\n const content = await this.fs.read(path);\n if (content && !content.startsWith(\"#!\")) {\n await this.fs.write(\n path,\n `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n\\n${content}`\n );\n }\n\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${\n path\n }`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Expected binary output file not found at path: ${\n path\n }. Skipping adding hashbang and executable permissions (chmod+x).`\n );\n }\n })\n );\n };\n }\n },\n {\n name: \"shell-shock:docs\",\n configResolved() {\n this.config.automd ??= {};\n this.config.automd.generators = {\n ...(this.config.automd.generators ?? {}),\n commands: commands(this)\n };\n },\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAM,YAAY;;;;AAKlB,MAAY,UAAA,UAAA,EAAA,KAAA;AACV,QAAA;EAAA,QAAW;EAAA,SAAA;EAAA,QAAA;EAAA;GACX,MAAA;GACA,MAAA,SAAA;AACA,SAAA,MAAA,2CAAA;AACI,UAAI,wBAAqB,KAAQ;AA4BjC,WA3BG,KAAiB,EAClB,QAAC,EACA,MAAO,UAAU,KAAC,OAAS,MAAQ,OAAA,EACrC,EACA,EAAE,SAAA;KACF,MAAO,WAAU,KAAM;KACvB,OAAO,YAAU,KAAQ;;KAE1B,UAAY;;KAEhB,WAAA;KACK,iBAAgB;KACrB,QAAA;MACK,QAAM;MACH,KAAC;MACN;KACG,OAAC,CAAA,KAAA,OAAA,SAAA,MAAA,QAAA,KAAA,OAAA,MAAA,IAAA,KAAA,OAAA,MAAA,WAAA,KAAA,SAAA,KAAA,OAAA,MAAA,IAAA,OAAA,KAAA,KAAA,OAAA,MAAA,CAAA,WAAA,IAAA,CAAA,UAAA,KAAA,OAAA,MAAA,oBAAA,EAAA,UAAA,KAAA,OAAA,MAAA,qBAAA,CAAA,GAAA;KACL,SAAQ;MACR,UAAS,CAAA,sBAAA;MACH,uBAAE;MACR;KACE,QAAO;MACP,KAAM;MACJ,cAAY;;MAEZ;;;GAIJ,gBAA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.mjs","names":[],"sources":["../src/plugin.tsx"],"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 { For, Show } from \"@alloy-js/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport automd from \"@powerlines/plugin-automd\";\nimport deepkit from \"@powerlines/plugin-deepkit\";\nimport nodejs from \"@powerlines/plugin-nodejs\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath, relativePath } from \"@stryke/path/file-path-fns\";\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { tsdown } from \"powerlines/tsdown\";\nimport { resolveInputs } from \"powerlines/utils\";\nimport type { BuildContext, RolldownChunk, TsdownHooks } from \"tsdown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\nimport { commands } from \"./helpers/automd\";\nimport {\n findCommandsRoot,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/paths\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getGlobalOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"./plugin-utils/context-helpers\";\nimport { getCommandTree } from \"./plugin-utils/get-command-tree\";\nimport { traverseCommands } from \"./plugin-utils/traverse-command-tree\";\nimport { resolve } from \"./resolver/resolve\";\nimport type { CommandOption, CommandTree } from \"./types/command\";\nimport { CommandParameterKinds } from \"./types/command\";\nimport type { Options } from \"./types/config\";\nimport type { Context } from \"./types/context\";\n\nconst MAX_DEPTH = 50;\n\n/**\n * The core Powerlines plugin to build Shell Shock projects.\n */\nexport const plugin = <TContext extends Context = Context>(\n options: Options = {}\n) => {\n return [\n tsdown(),\n deepkit(),\n automd(),\n {\n name: \"shell-shock:config\",\n async config() {\n this.debug(\"Resolving the Shell Shock configuration.\");\n\n await updatePackageJsonBinary(this);\n\n const result = defu(\n {\n output: {\n path: joinPaths(this.config.root, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n platform: \"node\",\n projectType: \"application\",\n framework: \"shell-shock\",\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: false\n },\n input:\n !this.config.input ||\n (Array.isArray(this.config.input) &&\n this.config.input.length === 0) ||\n (isObject(this.config.input) &&\n Object.keys(this.config.input).length === 0)\n ? [\n joinPaths(this.config.root, \"src/**/command.ts\"),\n joinPaths(this.config.root, \"src/**/command.tsx\")\n ]\n : undefined,\n resolve: {\n external: [\"@powerlines/deepkit\"],\n skipNodeModulesBundle: true\n },\n tsdown: {\n dts: false,\n nodeProtocol: true,\n unbundle: false\n }\n }\n );\n\n return result;\n },\n configResolved: {\n order: \"pre\",\n async handler() {\n this.debug(\"Shell Shock configuration has been resolved.\");\n\n this.config.appSpecificEnvPrefix = isSetString(\n this.config.autoAssignEnv\n )\n ? this.config.autoAssignEnv\n : constantCase(getAppName(this));\n if (\n !this.config.env.prefix ||\n !Array.isArray(this.config.env.prefix)\n ) {\n this.config.env.prefix = toArray(this.config.env.prefix);\n }\n\n if (\n !this.config.env.prefix.includes(this.config.appSpecificEnvPrefix)\n ) {\n this.config.env.prefix.push(this.config.appSpecificEnvPrefix);\n }\n\n this.config.bin = (isSetString(this.packageJson.bin)\n ? { [kebabCase(this.config.name)]: this.packageJson.bin }\n : this.packageJson.bin) ?? {\n [kebabCase(this.config.name)]: formatBinaryPath(\n this.config.output.format\n )\n };\n\n if (isSetString(this.config.reference)) {\n if (this.config.reference.includes(\"{command}\")) {\n this.config.reference = {\n app: this.config.reference\n .substring(0, this.config.reference.indexOf(\"{command}\"))\n .replace(/\\/?$/, \"/\"),\n commands: this.config.reference\n };\n } else if (this.config.reference.includes(\"{commands}\")) {\n this.config.reference = {\n app: this.config.reference\n .substring(0, this.config.reference.indexOf(\"{commands}\"))\n .replace(/\\/?$/, \"/\"),\n commands: this.config.reference\n };\n } else {\n this.config.reference = {\n app: this.config.reference\n };\n }\n }\n\n this.inputs ??= [];\n this.options = Object.values(\n getGlobalOptions(this, {\n id: null,\n name: this.config.name,\n path: null,\n segments: [],\n title: this.config.title,\n description: this.config.description,\n alias: [],\n isVirtual: false\n })\n );\n }\n }\n },\n ...nodejs<TContext>(\n defu(options ?? {}, {\n env: {\n types: \"@shell-shock/core/types/env#ShellShockEnv\",\n validate: false\n }\n })\n ),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.debug(\n `Checking for commands using input: ${JSON.stringify(this.config.input)}`\n );\n\n this.commandsPath = await findCommandsRoot(this);\n this.debug(`Resolved commands root path: ${this.commandsPath}`);\n\n const inputs = await resolveInputs(this, this.config.input);\n\n this.debug(\n `Found ${\n inputs.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = inputs.reduce((ret, entry) => {\n if (\n entry.file !== this.commandsPath &&\n !isParentPath(entry.file, this.commandsPath)\n ) {\n throw new Error(\n `Command entry point \"${\n entry.file\n }\" is not located within the commands root \"${\n this.commandsPath\n }\". Please ensure that all command entry points are located within the current project.`\n );\n }\n\n const id = resolveCommandId(this, entry.file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(entry.file);\n let segments = resolveCommandPath(this, entry.file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n tags: [],\n isVirtual: false,\n entry: {\n ...entry,\n file: entry.file,\n input: {\n file: entry.file,\n name: entry.name\n },\n output: name\n }\n });\n }\n\n return ret;\n }, this.inputs);\n\n this.debug(\n `Shell Shock will process ${\n this.inputs.length\n } command entry files: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}`\n )\n .join(\"\\n\")}`\n );\n },\n types() {\n this.debug(\n \"Generating type definitions for the Shell Shock application.\"\n );\n\n return `\n/**\n * The global options available for every command in the ${getAppTitle(\n this,\n true\n )} command-line application.\n */\nexport interface GlobalOptions {\n ${this.options\n .map(\n option =>\n `${\n option.description\n ? `\n/**\n * ${option.description}${\n option.default\n ? `\n *\n * @defaultValue ${\n option.kind === CommandParameterKinds.string\n ? `\"${option.default}\"`\n : option.default\n }`\n : \"\"\n }\n */\n`\n : \"\"\n }${option.name}${option.optional ? \"?\" : \"\"}: ${\n option.kind === CommandParameterKinds.boolean\n ? \"boolean\"\n : `${option.variadic ? \"(\" : \"\"}${\n option.choices\n ? option.choices\n .map(choice =>\n option.kind === CommandParameterKinds.number\n ? `${choice}`\n : `\"${choice}\"`\n )\n .join(\" | \")\n : option.kind === CommandParameterKinds.number\n ? \"number\"\n : \"string\"\n }${option.variadic ? \")[]\" : \"\"}`\n };${\n option.alias && option.alias.length > 0\n ? option.alias\n .map(\n alias =>\n `${alias}${option.optional ? \"?\" : \"\"}: ${\n option.kind === CommandParameterKinds.boolean\n ? \"boolean\"\n : `${option.variadic ? \"(\" : \"\"}${\n option.choices\n ? option.choices\n .map(choice =>\n option.kind === CommandParameterKinds.number\n ? `${choice}`\n : `\"${choice}\"`\n )\n .join(\" | \")\n : option.kind === CommandParameterKinds.number\n ? \"number\"\n : \"string\"\n }${option.variadic ? \")[]\" : \"\"}`\n };`\n )\n .join(\"\\n\\n\")\n : \"\"\n }`\n )\n .join(\"\\n\\n\")}\n}\n`;\n },\n async prepare() {\n this.debug(\n \"Rendering base built-in modules for the Shell Shock application.\"\n );\n\n return render(\n this,\n <>\n <UtilsBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:virtual-inputs\",\n configResolved: {\n order: \"post\",\n async handler() {\n if (this.inputs.length === 0) {\n this.warn(\n \"No commands were found in the project. Please ensure at least one command exists.\"\n );\n } else {\n this.debug(\n `Shell Shock will create an application with the following commands: \\n${this.inputs\n .filter(cmd => !cmd.isVirtual)\n .map(\n command =>\n ` - ${command.id}: ${\n isParentPath(command.entry.file, this.commandsPath)\n ? replacePath(command.entry.file, this.commandsPath)\n : relativePath(command.entry.file, this.commandsPath)\n }${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n\n this.debug(\n \"Finding and adding virtual command inputs for each command previously found.\"\n );\n\n this.inputs = this.inputs\n .reduce((ret, command) => {\n let depth = 0;\n\n let parentPath = resolveParentPath(\n findFilePath(command.entry.file)\n );\n if (isParentPath(parentPath, this.commandsPath)) {\n while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Unable to process virtual commands for ${command.name} \\n\\nPlease ensure ${command.entry.file} is a valid command entry file and does not have an invalid path.`\n );\n }\n\n if (\n !ret.some(\n existing =>\n findFilePath(existing.entry.file) === parentPath\n )\n ) {\n const file = joinPaths(parentPath, \"command.ts\");\n const id = resolveCommandId(this, file);\n if (!ret.some(existing => existing.id === id)) {\n const name = resolveCommandName(file);\n\n let segments = resolveCommandPath(this, file)\n .split(\"/\")\n .filter(Boolean);\n\n // Ensure unique segment names by appending an index suffix to duplicates\n segments = segments.map((segment, index) => {\n const found = segments.findIndex(\n existing => existing === segment\n );\n if (found !== -1 && found !== index) {\n segment += `_${\n segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(\n /_\\d+$/,\n \"\"\n ) === segment\n ).length\n }`;\n }\n\n return segment;\n });\n\n ret.push({\n id,\n path: segments.join(\"/\"),\n segments,\n name,\n alias: [],\n tags: [],\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.segments.length - b.segments.length);\n\n this.debug(\n `Final command input list: \\n${this.inputs\n .map(\n command =>\n ` - ${command.id}: ${replacePath(\n command.entry.file,\n this.commandsPath\n )}${command.isVirtual ? \" (virtual)\" : \"\"}`\n )\n .join(\"\\n\")}`\n );\n }\n }\n }\n },\n {\n name: \"shell-shock:resolve-commands\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Initializing the CLI application's command tree.\");\n\n this.commands = {};\n if (\n this.config.command !== \"prepare\" &&\n this.config.skipCache !== true &&\n this.persistedMeta?.checksum === this.meta.checksum &&\n this.fs.existsSync(getCommandsPersistencePath(this))\n ) {\n this.debug(\n `Skipping command resolution as the meta checksum has not changed.`\n );\n\n await readCommandsPersistence(this);\n } else {\n for (const input of this.inputs.filter(\n input =>\n input.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await resolve({\n context: this,\n command: input\n });\n }\n\n this.debug(\"Post-processing commands to ensure proper reflection.\");\n\n this.options = this.options.map(\n option =>\n ({\n ...option,\n name: camelCase(option.name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n }) as CommandOption\n );\n\n await traverseCommands(this, command => {\n command.options = Object.fromEntries(\n Object.entries(command.options).map(([name, option]) => [\n camelCase(name),\n {\n ...option,\n name: camelCase(name),\n alias: option.alias ?? [],\n optional: option.optional ?? false\n } as CommandOption\n ])\n );\n });\n\n await writeCommandsPersistence(this);\n }\n\n this.debug(\"Validating the CLI applications command tree.\");\n\n let isValid = true;\n await traverseCommands(this, command => {\n const failures = validateCommand(command);\n if (failures.length > 0) {\n this.error(\n `Found ${failures.length} issue${failures.length > 1 ? \"s\" : \"\"} with the ${\n command.title\n } command: \\n${failures\n .map(failure => ` - ${failure.code}: ${failure.details}`)\n .join(\"\\n\")}\\n`\n );\n isValid = false;\n }\n });\n if (!isValid) {\n throw new Error(\n `One or more commands in the command tree are invalid. Please review the errors above and correct them before proceeding.`\n );\n }\n\n this.info(\n `\\nCreating an application with the following command tree: \\n${formatCommandTree(\n this\n )}\\n`\n );\n }\n }\n },\n {\n name: \"shell-shock:chmod+x\",\n configResolved() {\n this.config.tsdown.hooks ??= {} as TsdownHooks;\n (this.config.tsdown.hooks as TsdownHooks)[\"build:done\"] = async (\n _: BuildContext & {\n chunks: RolldownChunk[];\n }\n ) => {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(this.workspaceConfig.workspaceRoot, this.config.root)\n );\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding hashbang to binary executable output file: ${path}`\n );\n\n const content = await this.fs.read(path);\n if (content && !content.startsWith(\"#!\")) {\n await this.fs.write(\n path,\n `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n\\n${content}`\n );\n }\n\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${\n path\n }`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Expected binary output file not found at path: ${\n path\n }. Skipping adding hashbang and executable permissions (chmod+x).`\n );\n }\n })\n );\n };\n }\n },\n {\n name: \"shell-shock:docs\",\n configResolved() {\n this.config.automd ??= {};\n this.config.automd.generators = {\n ...(this.config.automd.generators ?? {}),\n commands: commands(this)\n };\n },\n async docs() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n const commands = this.inputs\n .map(input => getCommandTree(this, input.segments))\n .filter(Boolean) as CommandTree[];\n\n return render(\n this,\n <For each={Object.values(commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocsFile command={child} />\n </Show>\n )}\n </For>\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport { plugin as shellShock };\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,MAAM,YAAY;;;;AAKlB,MAAY,UAAA,UAAA,EAAA,KAAA;AACV,QAAA;EAAA,QAAW;EAAA,SAAA;EAAA,QAAA;EAAA;GACX,MAAA;GACA,MAAA,SAAA;AACA,SAAA,MAAA,2CAAA;AACI,UAAI,wBAAqB,KAAQ;AA4BjC,WA3BG,KAAiB,EAClB,QAAC,EACA,MAAO,UAAU,KAAC,OAAS,MAAQ,OAAA,EACrC,EACA,EAAE,SAAA;KACF,MAAO,WAAU,KAAM;KACvB,OAAO,YAAU,KAAQ;;KAE1B,UAAY;;KAEhB,WAAA;KACK,iBAAgB;KACrB,QAAA;MACK,QAAM;MACH,KAAC;MACN;KACG,OAAC,CAAA,KAAA,OAAA,SAAA,MAAA,QAAA,KAAA,OAAA,MAAA,IAAA,KA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,CACf,OAAA,KAAA,GAAA,MAAA,MAAA,kBAAA,KAAA,OAAA,SAAA,gBAAA,yCAAA,GAAA,WAAA,UAAA;AAET,YAAA,MAAA,6EAAA,OAAA;AACG,aAAc,OAAA,KAAA;YAEP,MAAM,KAAC,kDAAS,KAAA,kEAAA;OAEzB,CAAA;;;GAGA;EAAA;GACF,MAAA;GACI,iBAAW;AACT,SAAK,OAAO,WAAO,EAAM;AACzB,SAAI,OAAO,OAAQ,aAAC;KAClB,GAAI,KAAG,OAAO,OAAA,cAAA,EAAA;KACd,UAAS,SAAO,KAAQ;KACzB;;GAEH,MAAM,OAAO;AACX,SAAK,MAAM,oEAA6C;IACxD,MAAM,WAAW,KAAK,OAAG,KAAO,UAAA,eAAA,MAAA,MAAA,SAAA,CAAA,CAAA,OAAA,QAAA;AAChC,WAAO,OAAO,MAAM,gBAAc,KAAA;KAChC,IAAI,OAAO;AACT,aAAO,OAAM,OAAQ,SAAE;;KAEzB,gBAAe;KACf,WAAU,UAAK,gBAAM,MAAA;MACnB,IAAI,OAAG;AACN,cAAA,CAAA,MAAA;;MAED,IAAI,WAAO;AACT,cAAK,gBAAG,iBAAA,EACN,SAAS,OACV,CAAC;;MAEL,CAAC;KACH,CAAC,CAAC;;GAEN;EAAC"}
@@ -41,10 +41,7 @@ function resolveCommandOption(ctx, reflection) {
41
41
  default: reflection.getDefaultValue(),
42
42
  variadic: reflection.isArray()
43
43
  };
44
- if (reflection.isArray()) if (type.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.string || type.type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.number) {
45
- option.variadic = true;
46
- option.kind = extractCommandParameterKind(type.type.kind);
47
- } else throw new Error(`Unsupported array type for option "${reflection.getNameAsString()}" in command "${ctx.input.command.name}". Only string[], number[], or literal[] are supported, received ${(0, _powerlines_deepkit_vendor_type.stringifyType)(type).trim().replaceAll(" | ", ", or ")}.`);
44
+ if (option.variadic) option.kind = extractCommandParameterKind(type.type.kind);
48
45
  else if (type.kind === _powerlines_deepkit_vendor_type.ReflectionKind.union) {
49
46
  option.kind = type.types.every(__assignType((t) => t.kind === _powerlines_deepkit_vendor_type.ReflectionKind.number || t.kind === _powerlines_deepkit_vendor_type.ReflectionKind.literal && ((0, _stryke_type_checks_is_number.isNumber)(t.literal) || (0, _stryke_type_checks_is_bigint.isBigInt)(t.literal)), [
50
47
  "t",
@@ -1 +1 @@
1
- {"version":3,"file":"deepkit.cjs","names":[],"sources":["../../src/resolver/deepkit.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterKind,\n Context,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\nimport { mergeCommandParameter } from \"./helpers\";\nimport type { ResolverContext } from \"./types\";\n\nfunction extractCommandParameterKind(\n type: Type | ReflectionKind\n): CommandParameterKind {\n const isKind = !(isSetObject(type) && \"kind\" in type);\n const kind = !isKind ? type.kind : type;\n if (kind === ReflectionKind.string) {\n return CommandParameterKinds.string;\n } else if (\n kind === ReflectionKind.number ||\n kind === ReflectionKind.bigint ||\n (!isKind &&\n type.kind === ReflectionKind.literal &&\n (isNumber(type.literal) || isBigInt(type.literal)))\n ) {\n return CommandParameterKinds.number;\n } else if (kind === ReflectionKind.boolean) {\n return CommandParameterKinds.boolean;\n } else {\n return CommandParameterKinds.string;\n }\n}\n\nfunction resolveCommandOption(\n ctx: ResolverContext,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n const existing = (ctx.output.options[reflection.getNameAsString()] ??\n {}) as Partial<CommandOption>;\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title: reflection.getTags().title?.trim(),\n description: reflection.getDescription(),\n kind: extractCommandParameterKind(type),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray()\n };\n\n if (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (option as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind((type as TypeArray).type.kind) as\n | \"string\"\n | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (type.kind === ReflectionKind.union) {\n option.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (option as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (option as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !existing.kind &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, option) as CommandOption;\n}\n\nfunction resolveCommandArgument(\n ctx: ResolverContext,\n index: number,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n const existing = (\n ctx.output.args.length > index ? ctx.output.args[index] : {}\n ) as Partial<CommandArgument>;\n\n const argument = {\n name: reflection.getName() || reflection.parameter.name,\n alias: reflection.getAlias(),\n kind: extractCommandParameterKind(type.kind),\n title: reflection.getTitle() || reflection.parameter.tags?.title,\n description: reflection.parameter.description,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue()\n };\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (argument as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind(type.type.kind) as \"string\" | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (type.kind === ReflectionKind.union) {\n argument.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (argument as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (argument as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !ctx.output.args?.length &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, argument, {\n name: `arg${index}`\n }) as CommandArgument;\n}\n\nexport function resolveFromBytecode<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n const { input, module } = ctx;\n\n const type = reflect(module);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${\n input.command.entry.input?.file || input.command.path\n }\" does not export a valid function.`\n );\n }\n\n const reflection = new ReflectionFunction(type);\n\n ctx.output.description ??= (ctx.input.command.description ||\n reflection.getDescription() ||\n type.description)!;\n\n const parameters = reflection.getParameters();\n if (parameters.length > 0) {\n const hasOptions =\n parameters[0] &&\n (parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class);\n if (hasOptions) {\n const optionsReflection = ReflectionClass.from(parameters[0]?.type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n }\n\n ctx.output.args = (hasOptions ? parameters.slice(1) : parameters).map(\n (arg, index) => resolveCommandArgument(ctx, index, arg)\n );\n }\n}\n"],"mappings":";;;;;;;;;;AAEA,SAAS,aAAW,IAAM,MAAA;;AAEzB,QAAU;;;CAUV,MAAK,SAAQ,qDAAmB,KAAG,IAAA,UAAA;;AAEhC,KAAI,SAAS,+CAAe;UAG9B,SAAmB,+CAAA,UACnB,SAAA,+CAAkB,UACd,CAAA,UACJ,KAAA,SAAA,+CAAA,wDACkB,KAAO,QAAQ,gDAAK,KAAA,QAAA,EACjC,QAAA,4CAAA;UAEL,SAAe,+CAAA,QACf,QAAA,4CAAkB;KAGZ,QAAC,4CAA0B;;AAGnC,4BAA2B,SAAO;CAAI;OAAW;CAAO;CAAA;CAAA;CAAA;CAAA;AACxD,SAAS,qBAAqB,KAAA,YAAY;CAC1C,MAAO,OAAK,WAAA,SAAA;CACV,MAAA,WAAe,IAAA,OAAA,QAAA,WAAA,iBAAA,KACf,EAAA;CACA,MAAA,SAAA;EACA,MAAO,WAAA,iBAAA;EACP,OAAA,WAAsB,SAAA,CAAA,SAAA,EAAA;EACtB,OAAA,WAAA,SAAA,CAAA,OAAA,MAAA;EACM,aAAS,WAAA,gBAAA;EACT,MAAC,4BAAiC,KAAK;EACvC,UAAC,WAAA,YAAgC;EAClC,SAAO,WAAA,iBAA+B;;EAE7C;AACE,KAAM,WAAO,SAAA,CACZ,KAAA,KAAA,KAAA,SAAqB,+CAAA,UAChB,KAAS,KAAE,SAAY,+CAAe,QAAQ;AAC1C,SAAI,WACD;AACJ,SAAA,OACC,4BAAA,KAAA,KAAA,KAAA;OAGA,OAAE,IAAA,MAAA,sCAAA,WAAA,iBAAA,CAAA,gBAAA,IAAA,MAAA,QAAA,KAAA,sHAAA,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KAAC,SAAA,+CAAsB,UAC/B,KAAA,SAAA,+CAAA,+QAES,MAAA,CACF,WAAe,OAAA,QAAA,CAAA,GAAA;AAEpB,QAAA,sCAAY,UAAA,UAAA,EACX,MAAA,MAAgB,SACjB,CAAA;;AAEF,uBAAoB,SAAS;CAAA;CAAuB;CAAO;CAAI;CAAA;CAAA;CAAA;CAAA;CAAA;AAC/D,SAAe,oBAAgB,KAAA;;CAE7B,MAAM,oDAAW,OAAA;AACf,KAAI,KAAE,SAAW,+CAAa,SAC9B,OAAO,IAAA,MAAW,2BAAU,MAAA,QAAA,MAAA,OAAA,QAAA,MAAA,QAAA,KAAA,qCAAA;CAE5B,MAAM,aAAY,IAAA,mDAAwB,KAAC;AAC3C,KAAA,OAAW,gBAAa,IAAA,MAAU,QAAW,eAC7C,WAAU,gBAAqB,IAC/B,KAAS;CACV,MAAA,aAAA,WAAA,eAAA;;EAEG,MAAK,aAAS,WAAe,OAC5B,WAAA,GAAA,KAAA,SAAA,+CAAA,iBACS,WAAS,GAAA,KAAA,SAAe,+CAAQ;AAC1C,MAAK,YAAa;GAClB,MAAA,oBAAA,gDAAA,KAAA,WAAA,IAAA,KAAA;AACC,QAAS,MAAG,sBAAyB,kBAAA,eAAiC,CACjE,KAAA,OAAA,QAAA,mBAAA,iBAAA,IACO,qBAAsB,KAAG,mBAAA;;AAGtC,MAAM,OAAI,QAAK,aAAA,WAAA,MAAA,EAAA,GAAA,YAAA,IAAA,cAAA,KAAA,UAAA,uBAAA,KAAA,OAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;;;AAGrB,oBAAiB,SAAU;CAAA;CAAsB;CAAK;CAAsB;CAAa"}
1
+ {"version":3,"file":"deepkit.cjs","names":[],"sources":["../../src/resolver/deepkit.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterKind,\n Context,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\nimport { mergeCommandParameter } from \"./helpers\";\nimport type { ResolverContext } from \"./types\";\n\nfunction extractCommandParameterKind(\n type: Type | ReflectionKind\n): CommandParameterKind {\n const isKind = !(isSetObject(type) && \"kind\" in type);\n const kind = !isKind ? type.kind : type;\n if (kind === ReflectionKind.string) {\n return CommandParameterKinds.string;\n } else if (\n kind === ReflectionKind.number ||\n kind === ReflectionKind.bigint ||\n (!isKind &&\n type.kind === ReflectionKind.literal &&\n (isNumber(type.literal) || isBigInt(type.literal)))\n ) {\n return CommandParameterKinds.number;\n } else if (kind === ReflectionKind.boolean) {\n return CommandParameterKinds.boolean;\n } else {\n return CommandParameterKinds.string;\n }\n}\n\nfunction resolveCommandOption(\n ctx: ResolverContext,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n const existing = (ctx.output.options[reflection.getNameAsString()] ??\n {}) as Partial<CommandOption>;\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title: reflection.getTags().title?.trim(),\n description: reflection.getDescription(),\n kind: extractCommandParameterKind(type),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray()\n };\n\n if (option.variadic) {\n option.kind = extractCommandParameterKind((type as TypeArray).type.kind);\n } else if (type.kind === ReflectionKind.union) {\n option.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (option as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (option as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !existing.kind &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, option) as CommandOption;\n}\n\nfunction resolveCommandArgument(\n ctx: ResolverContext,\n index: number,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n const existing = (\n ctx.output.args.length > index ? ctx.output.args[index] : {}\n ) as Partial<CommandArgument>;\n\n const argument = {\n name: reflection.getName() || reflection.parameter.name,\n alias: reflection.getAlias(),\n kind: extractCommandParameterKind(type.kind),\n title: reflection.getTitle() || reflection.parameter.tags?.title,\n description: reflection.parameter.description,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue()\n };\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (argument as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind(type.type.kind) as \"string\" | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (type.kind === ReflectionKind.union) {\n argument.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (argument as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (argument as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !ctx.output.args?.length &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, argument, {\n name: `arg${index}`\n }) as CommandArgument;\n}\n\nexport function resolveFromBytecode<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n const { input, module } = ctx;\n\n const type = reflect(module);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${\n input.command.entry.input?.file || input.command.path\n }\" does not export a valid function.`\n );\n }\n\n const reflection = new ReflectionFunction(type);\n\n ctx.output.description ??= (ctx.input.command.description ||\n reflection.getDescription() ||\n type.description)!;\n\n const parameters = reflection.getParameters();\n if (parameters.length > 0) {\n const hasOptions =\n parameters[0] &&\n (parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class);\n if (hasOptions) {\n const optionsReflection = ReflectionClass.from(parameters[0]?.type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n }\n\n ctx.output.args = (hasOptions ? parameters.slice(1) : parameters).map(\n (arg, index) => resolveCommandArgument(ctx, index, arg)\n );\n }\n}\n"],"mappings":";;;;;;;;;;AAEA,SAAS,aAAW,IAAM,MAAA;;AAEzB,QAAU;;;CAUV,MAAK,SAAQ,qDAAmB,KAAG,IAAA,UAAA;;AAEhC,KAAI,SAAS,+CAAe;UAG9B,SAAmB,+CAAA,UACnB,SAAA,+CAAkB,UACd,CAAA,UACJ,KAAA,SAAA,+CAAA,wDACkB,KAAO,QAAQ,gDAAK,KAAA,QAAA,EACjC,QAAA,4CAAA;UAEL,SAAe,+CAAA,QACf,QAAA,4CAAkB;KAGZ,QAAC,4CAA0B;;AAGnC,4BAA2B,SAAO;CAAI;OAAW;CAAO;CAAA;CAAA;CAAA;CAAA;AACxD,SAAS,qBAAqB,KAAA,YAAY;CAC1C,MAAO,OAAK,WAAA,SAAA;CACV,MAAA,WAAe,IAAA,OAAA,QAAA,WAAA,iBAAA,KACf,EAAA;CACA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A,EAAA;GAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;;;AAGJ,oBAAS,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -40,10 +40,7 @@ function resolveCommandOption(ctx, reflection) {
40
40
  default: reflection.getDefaultValue(),
41
41
  variadic: reflection.isArray()
42
42
  };
43
- if (reflection.isArray()) if (type.type.kind === ReflectionKind.string || type.type.kind === ReflectionKind.number) {
44
- option.variadic = true;
45
- option.kind = extractCommandParameterKind(type.type.kind);
46
- } else throw new Error(`Unsupported array type for option "${reflection.getNameAsString()}" in command "${ctx.input.command.name}". Only string[], number[], or literal[] are supported, received ${stringifyType(type).trim().replaceAll(" | ", ", or ")}.`);
43
+ if (option.variadic) option.kind = extractCommandParameterKind(type.type.kind);
47
44
  else if (type.kind === ReflectionKind.union) {
48
45
  option.kind = type.types.every(__assignType((t) => t.kind === ReflectionKind.number || t.kind === ReflectionKind.literal && (isNumber(t.literal) || isBigInt(t.literal)), [
49
46
  "t",
@@ -1 +1 @@
1
- {"version":3,"file":"deepkit.mjs","names":[],"sources":["../../src/resolver/deepkit.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterKind,\n Context,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\nimport { mergeCommandParameter } from \"./helpers\";\nimport type { ResolverContext } from \"./types\";\n\nfunction extractCommandParameterKind(\n type: Type | ReflectionKind\n): CommandParameterKind {\n const isKind = !(isSetObject(type) && \"kind\" in type);\n const kind = !isKind ? type.kind : type;\n if (kind === ReflectionKind.string) {\n return CommandParameterKinds.string;\n } else if (\n kind === ReflectionKind.number ||\n kind === ReflectionKind.bigint ||\n (!isKind &&\n type.kind === ReflectionKind.literal &&\n (isNumber(type.literal) || isBigInt(type.literal)))\n ) {\n return CommandParameterKinds.number;\n } else if (kind === ReflectionKind.boolean) {\n return CommandParameterKinds.boolean;\n } else {\n return CommandParameterKinds.string;\n }\n}\n\nfunction resolveCommandOption(\n ctx: ResolverContext,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n const existing = (ctx.output.options[reflection.getNameAsString()] ??\n {}) as Partial<CommandOption>;\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title: reflection.getTags().title?.trim(),\n description: reflection.getDescription(),\n kind: extractCommandParameterKind(type),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray()\n };\n\n if (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (option as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind((type as TypeArray).type.kind) as\n | \"string\"\n | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (type.kind === ReflectionKind.union) {\n option.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (option as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (option as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !existing.kind &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, option) as CommandOption;\n}\n\nfunction resolveCommandArgument(\n ctx: ResolverContext,\n index: number,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n const existing = (\n ctx.output.args.length > index ? ctx.output.args[index] : {}\n ) as Partial<CommandArgument>;\n\n const argument = {\n name: reflection.getName() || reflection.parameter.name,\n alias: reflection.getAlias(),\n kind: extractCommandParameterKind(type.kind),\n title: reflection.getTitle() || reflection.parameter.tags?.title,\n description: reflection.parameter.description,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue()\n };\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (argument as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind(type.type.kind) as \"string\" | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (type.kind === ReflectionKind.union) {\n argument.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (argument as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (argument as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !ctx.output.args?.length &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, argument, {\n name: `arg${index}`\n }) as CommandArgument;\n}\n\nexport function resolveFromBytecode<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n const { input, module } = ctx;\n\n const type = reflect(module);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${\n input.command.entry.input?.file || input.command.path\n }\" does not export a valid function.`\n );\n }\n\n const reflection = new ReflectionFunction(type);\n\n ctx.output.description ??= (ctx.input.command.description ||\n reflection.getDescription() ||\n type.description)!;\n\n const parameters = reflection.getParameters();\n if (parameters.length > 0) {\n const hasOptions =\n parameters[0] &&\n (parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class);\n if (hasOptions) {\n const optionsReflection = ReflectionClass.from(parameters[0]?.type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n }\n\n ctx.output.args = (hasOptions ? parameters.slice(1) : parameters).map(\n (arg, index) => resolveCommandArgument(ctx, index, arg)\n );\n }\n}\n"],"mappings":";;;;;;;;;AAEA,SAAS,aAAW,IAAM,MAAA;;AAEzB,QAAU;;;CAUV,MAAK,SAAQ,EAAA,YAAmB,KAAG,IAAA,UAAA;;AAEhC,KAAI,SAAS,eAAe;UAG9B,SAAmB,eAAA,UACnB,SAAA,eAAkB,UACd,CAAA,UACJ,KAAA,SAAA,eAAA,YACO,SAAW,KAAO,QAAQ,IAAI,SAAC,KAAA,QAAA,EACjC,QAAA,sBAAA;UAEL,SAAe,eAAA,QACf,QAAA,sBAAkB;KAGZ,QAAC,sBAA0B;;AAGnC,4BAA2B,SAAO;CAAI;OAAW;CAAO;CAAA;CAAA;CAAA;CAAA;AACxD,SAAS,qBAAqB,KAAA,YAAY;CAC1C,MAAO,OAAK,WAAA,SAAA;CACV,MAAA,WAAe,IAAA,OAAA,QAAA,WAAA,iBAAA,KACf,EAAA;CACA,MAAA,SAAA;EACA,MAAO,WAAA,iBAAA;EACP,OAAA,WAAsB,SAAA,CAAA,SAAA,EAAA;EACtB,OAAA,WAA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,OAAA,QAAA,mBAAA,iBAAA,IACO,qBAAsB,KAAG,mBAAA;;AAGtC,MAAM,OAAI,QAAK,aAAA,WAAA,MAAA,EAAA,GAAA,YAAA,IAAA,cAAA,KAAA,UAAA,uBAAA,KAAA,OAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;;;AAGrB,oBAAiB,SAAU;CAAA;CAAsB;CAAK;CAAsB;CAAa"}
1
+ {"version":3,"file":"deepkit.mjs","names":[],"sources":["../../src/resolver/deepkit.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterKind,\n Context,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\nimport { mergeCommandParameter } from \"./helpers\";\nimport type { ResolverContext } from \"./types\";\n\nfunction extractCommandParameterKind(\n type: Type | ReflectionKind\n): CommandParameterKind {\n const isKind = !(isSetObject(type) && \"kind\" in type);\n const kind = !isKind ? type.kind : type;\n if (kind === ReflectionKind.string) {\n return CommandParameterKinds.string;\n } else if (\n kind === ReflectionKind.number ||\n kind === ReflectionKind.bigint ||\n (!isKind &&\n type.kind === ReflectionKind.literal &&\n (isNumber(type.literal) || isBigInt(type.literal)))\n ) {\n return CommandParameterKinds.number;\n } else if (kind === ReflectionKind.boolean) {\n return CommandParameterKinds.boolean;\n } else {\n return CommandParameterKinds.string;\n }\n}\n\nfunction resolveCommandOption(\n ctx: ResolverContext,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n const existing = (ctx.output.options[reflection.getNameAsString()] ??\n {}) as Partial<CommandOption>;\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title: reflection.getTags().title?.trim(),\n description: reflection.getDescription(),\n kind: extractCommandParameterKind(type),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray()\n };\n\n if (option.variadic) {\n option.kind = extractCommandParameterKind((type as TypeArray).type.kind);\n } else if (type.kind === ReflectionKind.union) {\n option.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (option as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (option as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !existing.kind &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, option) as CommandOption;\n}\n\nfunction resolveCommandArgument(\n ctx: ResolverContext,\n index: number,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n const existing = (\n ctx.output.args.length > index ? ctx.output.args[index] : {}\n ) as Partial<CommandArgument>;\n\n const argument = {\n name: reflection.getName() || reflection.parameter.name,\n alias: reflection.getAlias(),\n kind: extractCommandParameterKind(type.kind),\n title: reflection.getTitle() || reflection.parameter.tags?.title,\n description: reflection.parameter.description,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue()\n };\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (argument as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind(type.type.kind) as \"string\" | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (type.kind === ReflectionKind.union) {\n argument.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (argument as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (argument as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !ctx.output.args?.length &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for positional argument \"${argument.name}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[], number[], or literal[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, argument, {\n name: `arg${index}`\n }) as CommandArgument;\n}\n\nexport function resolveFromBytecode<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n const { input, module } = ctx;\n\n const type = reflect(module);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${\n input.command.entry.input?.file || input.command.path\n }\" does not export a valid function.`\n );\n }\n\n const reflection = new ReflectionFunction(type);\n\n ctx.output.description ??= (ctx.input.command.description ||\n reflection.getDescription() ||\n type.description)!;\n\n const parameters = reflection.getParameters();\n if (parameters.length > 0) {\n const hasOptions =\n parameters[0] &&\n (parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class);\n if (hasOptions) {\n const optionsReflection = ReflectionClass.from(parameters[0]?.type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n }\n\n ctx.output.args = (hasOptions ? parameters.slice(1) : parameters).map(\n (arg, index) => resolveCommandArgument(ctx, index, arg)\n );\n }\n}\n"],"mappings":";;;;;;;;;AAEA,SAAS,aAAW,IAAM,MAAA;;AAEzB,QAAU;;;CAUV,MA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e,KAAA;AACpC,KAAE,OAAA,gBAAA,IAAA,MAAA,QAAA,eACC,WAAY,gBAAA,IACX,KAAI;CACR,MAAG,aAAY,WAAA,eAAyB;AACxC,KAAI,WAAA,SAAA,GAAA;EACF,MAAK,aAAA,WAAA,OACC,WAAS,GAAA,KAAA,SAAA,eAAA,iBACZ,WAAkB,GAAA,KAAQ,SAAC,eAAuB;AACnD,MAAE,YAAU;GACR,MAAK,oBAAoB,gBAAiB,KAAA,WAAW,IAAS,KAAE;AAClE,QAAA,MAAA,sBAAA,kBAAA,eAAA,CACF,KAAA,OAAA,QAAA,mBAAA,iBAAA,IACQ,qBAAA,KAAA,mBAAA;;AAGZ,MAAA,OAAA,QAAA,aAAA,WAAA,MAAA,EAAA,GAAA,YAAA,IAAA,cAAA,KAAA,UAAA,uBAAA,KAAA,OAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;;;AAGJ,oBAAS,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -54,8 +54,9 @@ const __ΩBaseCommandParameter = [
54
54
  false,
55
55
  "env",
56
56
  "optional",
57
+ "variadic",
57
58
  "BaseCommandParameter",
58
- "P&4!n\"4#&4$&4%&F4&P&.'J4()4)Mw*y"
59
+ "P&4!n\"4#&4$&4%&F4&P&.'J4()4))4*Mw+y"
59
60
  ];
60
61
  const __ΩStringCommandParameter = [
61
62
  () => __ΩBaseCommandParameter,
@@ -72,20 +73,18 @@ const __ΩStringCommandParameter = [
72
73
  "date-time",
73
74
  "duration",
74
75
  "format",
75
- "variadic",
76
76
  "choices",
77
77
  "StringCommandParameter",
78
- "Pn!.\"4#&4$8P.%.&.'.(.).*.+.,.-J4.8)4/&F408Mw1y"
78
+ "Pn!.\"4#&4$8P.%.&.'.(.).*.+.,.-J4.8&F4/8Mw0y"
79
79
  ];
80
80
  const __ΩNumberCommandParameter = [
81
81
  () => __ΩBaseCommandParameter,
82
82
  "number",
83
83
  "kind",
84
84
  "default",
85
- "variadic",
86
85
  "choices",
87
86
  "NumberCommandParameter",
88
- "Pn!.\"4#'4$8)4%'F4&8Mw'y"
87
+ "Pn!.\"4#'4$8'F4%8Mw&y"
89
88
  ];
90
89
  const __ΩBooleanCommandParameter = [
91
90
  () => __ΩBaseCommandParameter,
@@ -1 +1 @@
1
- {"version":3,"file":"command.cjs","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 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\nexport interface StringCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"string\";\n\n /**\n * The default value.\n */\n default?: 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 * Whether the option accepts multiple values.\n */\n variadic: boolean;\n\n /**\n * The allowed choices for the option value.\n */\n choices?: string[];\n}\n\nexport interface NumberCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"number\";\n\n /**\n * The default value.\n */\n default?: number;\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: boolean;\n\n /**\n * The allowed choices for the option value.\n */\n choices?: number[];\n}\n\nexport interface BooleanCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"boolean\";\n\n /**\n * The default value.\n */\n default?: boolean;\n}\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 BooleanCommandParameter {\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;\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\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 * 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 * 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;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;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
1
+ {"version":3,"file":"command.cjs","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 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 StringCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"string\";\n\n /**\n * The default value.\n */\n default?: 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 NumberCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"number\";\n\n /**\n * The default value.\n */\n default?: number;\n\n /**\n * The allowed choices for the option value.\n */\n choices?: number[];\n}\n\nexport interface BooleanCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"boolean\";\n\n /**\n * The default value.\n */\n default?: boolean;\n}\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 BooleanCommandParameter {\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;\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\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 * 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 * 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;OAAG;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEpC,MAAM,4BAA4B;OAAO;CAAyB;CAAI;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEtE,MAAM,4BAA4B;OAAO;CAAwB;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEjE,MAAM,6BAA6B;OAAO;CAAW;CAAA;CAAA;CAAA;CAAA;CAAA;AAErD,MAAM,sBAAQ;OAAA;OAA+C;OAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;;;AAI7D,MAAI,kCAAA;OAAA;OAAA;CAAA;CAAA;CAAA;AAEJ,MAAI,kCAAA;OAAA;OAAA;CAAA;CAAA;CAAA;;;;;;;AAIJ,MAAE,4BAAgB;OAAA;OAAA;OAAA;CAAA;CAAA;CAAA;AAElB,MAAE,0BAAiB;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAInB,MAAG,yBAA4B;OAAO;OAA8B;CAAA;CAAA;CAAA;AAEpE,MAAM,qBAAW;OAAA;OAAqB;OAAA;CAAA;CAAA;CAAA;AAEtC,MAAK,2BAAe;OAAA;OAAA;CAAA;CAAA;CAAA;AAEpB,MAAM,iBAAQ;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEd,MAAI,mBAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEJ,MAAI,iBAAA;OAAA;CAAA;CAAA;CAAA;CAAA;OAAA;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;;AAIJ,MAAK,qBAAiB;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEtB,MAAE,mBAAa;OAAA;CAAA;OAAA;OAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
@@ -42,6 +42,10 @@ interface BaseCommandParameter {
42
42
  * Whether the option is optional.
43
43
  */
44
44
  optional: boolean;
45
+ /**
46
+ * Whether the option accepts multiple values.
47
+ */
48
+ variadic: boolean;
45
49
  }
46
50
  interface StringCommandParameter extends BaseCommandParameter {
47
51
  /**
@@ -56,10 +60,6 @@ interface StringCommandParameter extends BaseCommandParameter {
56
60
  * A standard string format to validate the option value against.
57
61
  */
58
62
  format?: "email" | "uri" | "uuid" | "ipv4" | "ipv6" | "date" | "time" | "date-time" | "duration";
59
- /**
60
- * Whether the option accepts multiple values.
61
- */
62
- variadic: boolean;
63
63
  /**
64
64
  * The allowed choices for the option value.
65
65
  */
@@ -74,10 +74,6 @@ interface NumberCommandParameter extends BaseCommandParameter {
74
74
  * The default value.
75
75
  */
76
76
  default?: number;
77
- /**
78
- * Whether the option accepts multiple values.
79
- */
80
- variadic: boolean;
81
77
  /**
82
78
  * The allowed choices for the option value.
83
79
  */
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.cts","names":[],"sources":["../../src/types/command.ts"],"mappings":";;;;;;;;KAyBY,oBAAA;AAAA,cAMC,qBAAA;EAAA;;;;KAMD,oBAAA,WACF,qBAAA,eAAoC,qBAAA;AAAA,UAE7B,oBAAA;EALP;;;EASR,IAAA;;;;EAKA,IAAA,EAAM,oBAAA;EAZI;;;EAiBV,KAAA;EAhBiE;AAEnE;;EAmBE,WAAA;EAV0B;;;EAe1B,KAAA;EAVA;;;EAeA,GAAA;EAKA;;;EAAA,QAAA;AAAA;AAAA,UAGe,sBAAA,SAA+B,oBAAA;EAAoB;;;EAIlE,IAAA;EAUA;;;EALA,OAAA;EAwBO;AAGT;;EAtBE,MAAA;EAsBkE;;;EARlE,QAAA;EAsBA;;;EAjBA,OAAA;AAAA;AAAA,UAGe,sBAAA,SAA+B,oBAAA;;;;EAI9C,IAAA;EA2BA;;;EAtBA,OAAA;EAyB0B;;;EApB1B,QAAA;EAuBE;;;EAlBF,OAAA;AAAA;AAAA,UAGe,uBAAA,SAAgC,oBAAA;EAetB;;AAE3B;EAbE,IAAA;EAakC;;;EARlC,OAAA;AAAA;AAAA,KAGU,gBAAA,GACR,sBAAA,GACA,sBAAA,G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;EAoFE,WAAA;EApF0B;;;EAyF1B,KAAA;EAtEA;;;;;;EA8EA,IAAA;EA7CS;;AAGX;EA+CE,OAAA,EAAS,MAAA,SAAe,aAAA;;;;EAKxB,IAAA,EAAM,eAAA;EA3CN;;;EAgDA,MAAA,SAAe,WAAA;EAxCX;AAGN;;EA0CE,QAAA,EAAU,MAAA,SAAe,WAAA;AAAA;AAAA,KAGf,qBAAA,GAAwB,IAAA,CAAK,WAAA;EAlB9B;;;EAsBT,MAAA;EAPU;;;EAWV,QAAA,EAAU,MAAA,SAAe,qBAAA;AAAA;AAAA,UAGV,eAAA;EA1Cf;;;;;;EAiDA,KAAA;EA1BA;;;;;;EAkCA,WAAA;EA1BU;;;EA+BV,KAAA;EA/BkC;;;;;;EAuClC,IAAA;EAnCA;;;;;;EA2CA,IAAA;EApC8B;;;;;;EA4C9B,SAAA;AAAA;AAAA,UAGe,aAAA;EACf,QAAA,GAAW,eAAA;EACX,OAAA,GACI,MAAA,SAAe,mBAAA,IACf,iBAAA,GACA,oBAAA,CAAqB,MAAA,SAAe,oBAAA,KACpC,EAAA,CAAG,YAAA;EACP,IAAA,GACI,qBAAA,KACA,oBAAA,GACA,oBAAA,CAAqB,oBAAA,MACrB,EAAA,CAAG,WAAA;EACP,OAAA,GAAU,WAAA;AAAA"}
@@ -42,6 +42,10 @@ interface BaseCommandParameter {
42
42
  * Whether the option is optional.
43
43
  */
44
44
  optional: boolean;
45
+ /**
46
+ * Whether the option accepts multiple values.
47
+ */
48
+ variadic: boolean;
45
49
  }
46
50
  interface StringCommandParameter extends BaseCommandParameter {
47
51
  /**
@@ -56,10 +60,6 @@ interface StringCommandParameter extends BaseCommandParameter {
56
60
  * A standard string format to validate the option value against.
57
61
  */
58
62
  format?: "email" | "uri" | "uuid" | "ipv4" | "ipv6" | "date" | "time" | "date-time" | "duration";
59
- /**
60
- * Whether the option accepts multiple values.
61
- */
62
- variadic: boolean;
63
63
  /**
64
64
  * The allowed choices for the option value.
65
65
  */
@@ -74,10 +74,6 @@ interface NumberCommandParameter extends BaseCommandParameter {
74
74
  * The default value.
75
75
  */
76
76
  default?: number;
77
- /**
78
- * Whether the option accepts multiple values.
79
- */
80
- variadic: boolean;
81
77
  /**
82
78
  * The allowed choices for the option value.
83
79
  */
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.mts","names":[],"sources":["../../src/types/command.ts"],"mappings":";;;;;;;;KAyBY,oBAAA;AAAA,cAMC,qBAAA;EAAA;;;;KAMD,oBAAA,WACF,qBAAA,eAAoC,qBAAA;AAAA,UAE7B,oBAAA;EALP;;;EASR,IAAA;;;;EAKA,IAAA,EAAM,oBAAA;EAZI;;;EAiBV,KAAA;EAhBiE;AAEnE;;EAmBE,WAAA;EAV0B;;;EAe1B,KAAA;EAVA;;;EAeA,GAAA;EAKA;;;EAAA,QAAA;AAAA;AAAA,UAGe,sBAAA,SAA+B,oBAAA;EAAoB;;;EAIlE,IAAA;EAUA;;;EALA,OAAA;EAwBO;AAGT;;EAtBE,MAAA;EAsBkE;;;EARlE,QAAA;EAsBA;;;EAjBA,OAAA;AAAA;AAAA,UAGe,sBAAA,SAA+B,oBAAA;;;;EAI9C,IAAA;EA2BA;;;EAtBA,OAAA;EAyB0B;;;EApB1B,QAAA;EAuBE;;;EAlBF,OAAA;AAAA;AAAA,UAGe,uBAAA,SAAgC,oBAAA;EAetB;;AAE3B;EAbE,IAAA;EAakC;;;EARlC,OAAA;AAAA;AAAA,KAGU,gBAAA,GACR,sBAAA,GACA,sBAAA,GACA,uBAAA;AAAA,KAEQ,wBAAA,WAAmC,oBAAA,IAAwB,IAAA,CACrE,CAAA,sBAGA,OAAA,CAAQ,IAAA,CAAK,CAAA;EACX,KAAA;AAAA;AAAA,KAGQ,4BAAA,GACV,wBAAA,CAAyB,sBAAA;AAAA,KACf,4BAAA,GACV,wBAAA,CAAyB,sBAAA;AAAA,KACf,6BAAA,GACV,wBAAA,CAAyB,uBAAA;AAAA,KAEf,sBAAA,GACR,4BAAA,GACA,4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,MAAA;EAPU;;;EAWV,QAAA,EAAU,MAAA,SAAe,qBAAA;AAAA;AAAA,UAGV,eAAA;EA1Cf;;;;;;EAiDA,KAAA;EA1BA;;;;;;EAkCA,WAAA;EA1BU;;;EA+BV,KAAA;EA/BkC;;;;;;EAuClC,IAAA;EAnCA;;;;;;EA2CA,IAAA;EApC8B;;;;;;EA4C9B,SAAA;AAAA;AAAA,UAGe,aAAA;EACf,QAAA,GAAW,eAAA;EACX,OAAA,GACI,MAAA,SAAe,mBAAA,IACf,iBAAA,GACA,oBAAA,CAAqB,MAAA,SAAe,oBAAA,KACpC,EAAA,CAAG,YAAA;EACP,IAAA,GACI,qBAAA,KACA,oBAAA,GACA,oBAAA,CAAqB,oBAAA,MACrB,EAAA,CAAG,WAAA;EACP,OAAA,GAAU,WAAA;AAAA"}
@@ -52,8 +52,9 @@ const __ΩBaseCommandParameter = [
52
52
  false,
53
53
  "env",
54
54
  "optional",
55
+ "variadic",
55
56
  "BaseCommandParameter",
56
- "P&4!n\"4#&4$&4%&F4&P&.'J4()4)Mw*y"
57
+ "P&4!n\"4#&4$&4%&F4&P&.'J4()4))4*Mw+y"
57
58
  ];
58
59
  const __ΩStringCommandParameter = [
59
60
  () => __ΩBaseCommandParameter,
@@ -70,20 +71,18 @@ const __ΩStringCommandParameter = [
70
71
  "date-time",
71
72
  "duration",
72
73
  "format",
73
- "variadic",
74
74
  "choices",
75
75
  "StringCommandParameter",
76
- "Pn!.\"4#&4$8P.%.&.'.(.).*.+.,.-J4.8)4/&F408Mw1y"
76
+ "Pn!.\"4#&4$8P.%.&.'.(.).*.+.,.-J4.8&F4/8Mw0y"
77
77
  ];
78
78
  const __ΩNumberCommandParameter = [
79
79
  () => __ΩBaseCommandParameter,
80
80
  "number",
81
81
  "kind",
82
82
  "default",
83
- "variadic",
84
83
  "choices",
85
84
  "NumberCommandParameter",
86
- "Pn!.\"4#'4$8)4%'F4&8Mw'y"
85
+ "Pn!.\"4#'4$8'F4%8Mw&y"
87
86
  ];
88
87
  const __ΩBooleanCommandParameter = [
89
88
  () => __ΩBaseCommandParameter,
@@ -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 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\nexport interface StringCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"string\";\n\n /**\n * The default value.\n */\n default?: 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 * Whether the option accepts multiple values.\n */\n variadic: boolean;\n\n /**\n * The allowed choices for the option value.\n */\n choices?: string[];\n}\n\nexport interface NumberCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"number\";\n\n /**\n * The default value.\n */\n default?: number;\n\n /**\n * Whether the option accepts multiple values.\n */\n variadic: boolean;\n\n /**\n * The allowed choices for the option value.\n */\n choices?: number[];\n}\n\nexport interface BooleanCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"boolean\";\n\n /**\n * The default value.\n */\n default?: boolean;\n}\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 BooleanCommandParameter {\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;\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\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 * 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 * 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;OAAG;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEpC,MAAM,4BAA4B;OAAO;CAAyB;CAAI;CAAA;CAAA;C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-------------------------------------------------------------------\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 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 StringCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"string\";\n\n /**\n * The default value.\n */\n default?: 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 NumberCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"number\";\n\n /**\n * The default value.\n */\n default?: number;\n\n /**\n * The allowed choices for the option value.\n */\n choices?: number[];\n}\n\nexport interface BooleanCommandParameter extends BaseCommandParameter {\n /**\n * The option kind.\n */\n kind: \"boolean\";\n\n /**\n * The default value.\n */\n default?: boolean;\n}\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 BooleanCommandParameter {\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;\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\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 * 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 * 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;OAAG;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEpC,MAAM,4BAA4B;OAAO;CAAyB;CAAI;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEtE,MAAM,4BAA4B;OAAO;CAAwB;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEjE,MAAM,6BAA6B;OAAO;CAAW;CAAA;CAAA;CAAA;CAAA;CAAA;AAErD,MAAM,sBAAQ;OAAA;OAA+C;OAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;;;AAI7D,MAAI,kCAAA;OAAA;OAAA;CAAA;CAAA;CAAA;AAEJ,MAAI,kCAAA;OAAA;OAAA;CAAA;CAAA;CAAA;;;;;;;AAIJ,MAAE,4BAAgB;OAAA;OAAA;OAAA;CAAA;CAAA;CAAA;AAElB,MAAE,0BAAiB;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAInB,MAAG,yBAA4B;OAAO;OAA8B;CAAA;CAAA;CAAA;AAEpE,MAAM,qBAAW;OAAA;OAAqB;OAAA;CAAA;CAAA;CAAA;AAEtC,MAAK,2BAAe;OAAA;OAAA;CAAA;CAAA;CAAA;AAEpB,MAAM,iBAAQ;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEd,MAAI,mBAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEJ,MAAI,iBAAA;OAAA;CAAA;CAAA;CAAA;CAAA;OAAA;OAAA;CAAA;OAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;;AAIJ,MAAK,qBAAiB;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAEtB,MAAE,mBAAa;OAAA;CAAA;OAAA;OAAA;CAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shell-shock/core",
3
- "version": "0.14.3",
3
+ "version": "0.14.4",
4
4
  "private": false,
5
5
  "description": "A package containing the core Shell Shock functionality used to build and manage a command-line application.",
6
6
  "keywords": ["shell-shock", "powerlines", "storm-software"],
@@ -350,12 +350,12 @@
350
350
  "@alloy-js/core": "0.23.0-dev.8",
351
351
  "@alloy-js/markdown": "0.23.0-dev.1",
352
352
  "@alloy-js/typescript": "0.23.0-dev.4",
353
- "@powerlines/deepkit": "^0.6.162",
354
- "@powerlines/plugin-alloy": "^0.25.70",
355
- "@powerlines/plugin-automd": "^0.1.383",
356
- "@powerlines/plugin-deepkit": "^0.11.262",
357
- "@powerlines/plugin-nodejs": "^0.1.306",
358
- "@powerlines/plugin-tsdown": "^0.1.325",
353
+ "@powerlines/deepkit": "^0.6.163",
354
+ "@powerlines/plugin-alloy": "^0.26.0",
355
+ "@powerlines/plugin-automd": "^0.1.384",
356
+ "@powerlines/plugin-deepkit": "^0.11.263",
357
+ "@powerlines/plugin-nodejs": "^0.1.307",
358
+ "@powerlines/plugin-tsdown": "^0.1.326",
359
359
  "@standard-schema/spec": "^1.1.0",
360
360
  "@standard-schema/utils": "^0.3.0",
361
361
  "@stryke/cli": "^0.13.36",
@@ -371,18 +371,18 @@
371
371
  "automd": "^0.4.3",
372
372
  "defu": "^6.1.4",
373
373
  "json-schema": "^0.4.0",
374
- "tsdown": "^0.21.6"
374
+ "tsdown": "^0.21.7"
375
375
  },
376
376
  "devDependencies": {
377
- "@powerlines/plugin-plugin": "^0.12.334",
377
+ "@powerlines/plugin-plugin": "^0.12.335",
378
378
  "@types/json-schema": "^7.0.15",
379
379
  "@types/node": "^25.5.0",
380
- "powerlines": "^0.42.24",
380
+ "powerlines": "^0.42.25",
381
381
  "typescript": "^5.9.3",
382
382
  "zod": "^4.3.6"
383
383
  },
384
384
  "peerDependencies": { "powerlines": ">=0.42.10", "zod": "^3.25.0 || ^4.0.0" },
385
385
  "peerDependenciesMeta": { "zod": { "optional": true } },
386
386
  "publishConfig": { "access": "public" },
387
- "gitHead": "27a9e457bd50dd3576a1edf1882f43d82a402743"
387
+ "gitHead": "d123fb843b98e07d65b61f69f3f6a74b68ddc3b0"
388
388
  }