@shell-shock/core 0.7.0 → 0.8.1

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.
Files changed (76) hide show
  1. package/README.md +1 -1
  2. package/dist/components/docs.cjs +1 -1
  3. package/dist/components/docs.cjs.map +1 -1
  4. package/dist/components/docs.d.mts +5 -5
  5. package/dist/components/docs.mjs +1 -1
  6. package/dist/components/docs.mjs.map +1 -1
  7. package/dist/components/helpers.cjs +15 -0
  8. package/dist/components/helpers.cjs.map +1 -0
  9. package/dist/components/helpers.d.cts +13 -0
  10. package/dist/components/helpers.d.cts.map +1 -0
  11. package/dist/components/helpers.d.mts +13 -0
  12. package/dist/components/helpers.d.mts.map +1 -0
  13. package/dist/components/helpers.mjs +14 -0
  14. package/dist/components/helpers.mjs.map +1 -0
  15. package/dist/components/index.cjs +4 -2
  16. package/dist/components/index.d.cts +3 -2
  17. package/dist/components/index.d.mts +3 -2
  18. package/dist/components/index.mjs +3 -2
  19. package/dist/components/options-parser-logic.cjs +121 -97
  20. package/dist/components/options-parser-logic.cjs.map +1 -1
  21. package/dist/components/options-parser-logic.d.cts +25 -17
  22. package/dist/components/options-parser-logic.d.cts.map +1 -1
  23. package/dist/components/options-parser-logic.d.mts +18 -10
  24. package/dist/components/options-parser-logic.d.mts.map +1 -1
  25. package/dist/components/options-parser-logic.mjs +120 -96
  26. package/dist/components/options-parser-logic.mjs.map +1 -1
  27. package/dist/components/usage.cjs +33 -1
  28. package/dist/components/usage.cjs.map +1 -1
  29. package/dist/components/usage.d.cts +2 -2
  30. package/dist/components/usage.d.mts +2 -2
  31. package/dist/components/usage.d.mts.map +1 -1
  32. package/dist/components/usage.mjs +35 -3
  33. package/dist/components/usage.mjs.map +1 -1
  34. package/dist/helpers/persistence.cjs +4 -21
  35. package/dist/helpers/persistence.cjs.map +1 -1
  36. package/dist/helpers/persistence.mjs +4 -21
  37. package/dist/helpers/persistence.mjs.map +1 -1
  38. package/dist/helpers/resolve-command.cjs +15 -55
  39. package/dist/helpers/resolve-command.cjs.map +1 -1
  40. package/dist/helpers/resolve-command.mjs +16 -56
  41. package/dist/helpers/resolve-command.mjs.map +1 -1
  42. package/dist/helpers/validations.cjs +13 -36
  43. package/dist/helpers/validations.cjs.map +1 -1
  44. package/dist/helpers/validations.mjs +12 -36
  45. package/dist/helpers/validations.mjs.map +1 -1
  46. package/dist/index.d.cts +3 -2
  47. package/dist/index.d.mts +3 -2
  48. package/dist/plugin-utils/context-helpers.cjs +3 -45
  49. package/dist/plugin-utils/context-helpers.cjs.map +1 -1
  50. package/dist/plugin-utils/context-helpers.d.cts +1 -37
  51. package/dist/plugin-utils/context-helpers.d.cts.map +1 -1
  52. package/dist/plugin-utils/context-helpers.d.mts +1 -37
  53. package/dist/plugin-utils/context-helpers.d.mts.map +1 -1
  54. package/dist/plugin-utils/context-helpers.mjs +4 -44
  55. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  56. package/dist/plugin-utils/index.cjs +0 -2
  57. package/dist/plugin-utils/index.d.cts +2 -2
  58. package/dist/plugin-utils/index.d.mts +2 -2
  59. package/dist/plugin-utils/index.mjs +2 -2
  60. package/dist/plugin.cjs +9 -15
  61. package/dist/plugin.cjs.map +1 -1
  62. package/dist/plugin.d.cts.map +1 -1
  63. package/dist/plugin.d.mts.map +1 -1
  64. package/dist/plugin.mjs +9 -15
  65. package/dist/plugin.mjs.map +1 -1
  66. package/dist/types/command.d.cts +26 -118
  67. package/dist/types/command.d.cts.map +1 -1
  68. package/dist/types/command.d.mts +26 -118
  69. package/dist/types/command.d.mts.map +1 -1
  70. package/dist/types/index.d.cts +3 -2
  71. package/dist/types/index.d.mts +3 -2
  72. package/dist/types/runtime.d.cts +5 -15
  73. package/dist/types/runtime.d.cts.map +1 -1
  74. package/dist/types/runtime.d.mts +5 -15
  75. package/dist/types/runtime.d.mts.map +1 -1
  76. package/package.json +24 -10
package/dist/plugin.mjs CHANGED
@@ -80,13 +80,11 @@ const plugin = (options = {}) => {
80
80
  this.options = Object.values(getDefaultOptions(this, {
81
81
  id: null,
82
82
  name: this.config.name,
83
+ path: null,
84
+ segments: [],
83
85
  title: this.config.title,
84
86
  description: this.config.description,
85
87
  alias: [],
86
- path: {
87
- value: null,
88
- segments: []
89
- },
90
88
  isVirtual: false
91
89
  }));
92
90
  }
@@ -108,10 +106,8 @@ const plugin = (options = {}) => {
108
106
  const name = resolveCommandName(entry.file);
109
107
  ret.push({
110
108
  id,
111
- path: {
112
- value: path,
113
- segments: path.split("/").filter(Boolean)
114
- },
109
+ path,
110
+ segments: path.split("/").filter(Boolean),
115
111
  name,
116
112
  alias: [],
117
113
  isVirtual: false,
@@ -153,10 +149,8 @@ const plugin = (options = {}) => {
153
149
  const path = resolveCommandPath(this, file);
154
150
  ret.push({
155
151
  id,
156
- path: {
157
- value: path,
158
- segments: path.split("/").filter(Boolean)
159
- },
152
+ path,
153
+ segments: path.split("/").filter(Boolean),
160
154
  name,
161
155
  alias: [],
162
156
  isVirtual: true,
@@ -167,7 +161,7 @@ const plugin = (options = {}) => {
167
161
  parentPath = resolveParentPath(parentPath);
168
162
  }
169
163
  return ret;
170
- }, this.inputs).sort((a, b) => a.path.segments.length - b.path.segments.length);
164
+ }, this.inputs).sort((a, b) => a.segments.length - b.segments.length);
171
165
  this.debug(`Final command input list: \n${this.inputs.map((command) => ` - ${command.id}: ${replacePath(command.entry.file, this.commandsPath)}${command.isVirtual ? " (virtual)" : ""}`).join("\n")}`);
172
166
  }
173
167
  }
@@ -184,7 +178,7 @@ const plugin = (options = {}) => {
184
178
  this.debug(`Skipping reflection initialization as the meta checksum has not changed.`);
185
179
  await readCommandsPersistence(this);
186
180
  } else {
187
- for (const input of this.inputs.filter((input$1) => input$1.path.segments.filter((segment) => !isDynamicPathSegment(segment) && !isPathSegmentGroup(segment)).length === 1)) this.commands[input.name] = await reflectCommandTree(this, input);
181
+ for (const input of this.inputs.filter((input$1) => input$1.segments.filter((segment) => !isDynamicPathSegment(segment) && !isPathSegmentGroup(segment)).length === 1)) this.commands[input.name] = await reflectCommandTree(this, input);
188
182
  this.debug("Post-processing commands to ensure proper reflection.");
189
183
  this.options = this.options.map((option) => ({
190
184
  ...option,
@@ -250,7 +244,7 @@ const plugin = (options = {}) => {
250
244
  },
251
245
  async docs() {
252
246
  this.debug("Rendering entrypoint modules for the Shell Shock `script` preset.");
253
- const commands$1 = this.inputs.map((input) => getCommandTree(this, input.path.segments)).filter(Boolean);
247
+ const commands$1 = this.inputs.map((input) => getCommandTree(this, input.segments)).filter(Boolean);
254
248
  return render(this, createComponent(For, {
255
249
  get each() {
256
250
  return Object.values(commands$1);
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.mjs","names":["For","Show","render","automd","deepkit","nodejs","tsdown","toArray","chmodX","appendPath","findFilePath","isParentPath","joinPaths","replacePath","resolveParentPath","camelCase","constantCase","kebabCase","isSetObject","isSetString","defu","resolveEntries","CommandDocsFile","commands","getCommandsPersistencePath","readCommandsPersistence","writeCommandsPersistence","findCommandsRoot","reflectCommandTree","resolveCommandId","resolveCommandName","resolveCommandPath","formatBinaryPath","updatePackageJsonBinary","formatCommandTree","getDefaultOptions","validateCommand","getAppDescription","getAppName","getAppTitle","isDynamicPathSegment","isPathSegmentGroup","getCommandTree","traverseCommands","MAX_DEPTH","plugin","options","name","config","debug","result","output","buildPath","projectRoot","title","description","envPrefix","env","prefix","isCaseSensitive","format","dts","entry","Array","isArray","length","sourceRoot","undefined","build","platform","nodeProtocol","unbundle","noExternal","type","framework","includes","push","configResolved","order","handler","bin","packageJson","inputs","Object","values","id","alias","path","value","segments","isVirtual","commandsPath","entries","reduce","ret","file","Error","some","existing","split","filter","Boolean","input","map","command","join","warn","cmd","depth","parentPath","sort","a","b","prepare","skipCache","persistedMeta","checksum","meta","fs","existsSync","segment","option","optional","fromEntries","isValid","failures","error","failure","code","details","info","outputOptions","banner","chunk","isEntry","entryPath","facadeModuleId","fileName","mode","buildEnd","Promise","all","workspaceConfig","workspaceRoot","generators","docs","_$createComponent","each","doubleHardline","children","child","when","shellShock"],"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 tsdown from \"@powerlines/plugin-tsdown\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath } 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 { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { resolveEntries } from \"powerlines/lib/entry\";\nimport type { OutputOptions, RenderedChunk } from \"rolldown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { commands } from \"./helpers/automd\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n findCommandsRoot,\n reflectCommandTree,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/resolve-command\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getDefaultOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\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 type { CommandOption, CommandTree } 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 buildPath: joinPaths(this.config.projectRoot, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n envPrefix: constantCase(getAppName(this)),\n env: {\n prefix: [] as string[]\n },\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: true\n },\n entry:\n !this.config.entry ||\n (Array.isArray(this.config.entry) &&\n this.config.entry.length === 0)\n ? [\n joinPaths(this.config.sourceRoot, \"**/*.ts\"),\n joinPaths(this.config.sourceRoot, \"**/*.tsx\")\n ]\n : undefined,\n build: {\n dts: false,\n platform: \"node\",\n nodeProtocol: true,\n unbundle: false,\n noExternal: [\"@powerlines/deepkit\"]\n },\n type: \"application\",\n framework: \"shell-shock\"\n }\n );\n if (!result.env.prefix.includes(result.envPrefix)) {\n result.env.prefix.push(result.envPrefix);\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.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 this.inputs ??= [];\n this.options = Object.values(\n getDefaultOptions(this, {\n id: null,\n name: this.config.name,\n title: this.config.title,\n description: this.config.description,\n alias: [],\n path: {\n value: null,\n segments: []\n },\n isVirtual: false\n })\n );\n }\n }\n },\n ...nodejs<TContext>(),\n {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.commandsPath = findCommandsRoot(this);\n const entries = await resolveEntries(\n this,\n toArray(this.config.entry || [])\n );\n\n this.debug(\n `Found ${\n entries.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = entries.reduce((ret, entry) => {\n if (!isParentPath(entry.file, this.commandsPath)) {\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 path = resolveCommandPath(this, entry.file);\n const name = resolveCommandName(entry.file);\n\n ret.push({\n id,\n path: {\n value: path,\n segments: path.split(\"/\").filter(Boolean)\n },\n name,\n alias: [],\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 },\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}: ${replacePath(\n command.entry.file,\n 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 while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Maximum command virtual parent depth of ${\n MAX_DEPTH\n } exceeded while processing command: ${command.name}`\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 const path = resolveCommandPath(this, file);\n\n ret.push({\n id,\n path: {\n value: path,\n segments: path.split(\"/\").filter(Boolean)\n },\n name,\n alias: [],\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\n }\n\n return ret;\n }, this.inputs)\n .sort((a, b) => a.path.segments.length - b.path.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:reflect-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 reflection initialization 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.path.segments.filter(\n segment =>\n !isDynamicPathSegment(segment) &&\n !isPathSegmentGroup(segment)\n ).length === 1\n )) {\n this.commands[input.name] = await reflectCommandTree(this, input);\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.build.outputOptions ??= {} as OutputOptions;\n (this.config.build.outputOptions as OutputOptions).banner = (\n chunk: RenderedChunk\n ) => {\n if (\n chunk.isEntry &&\n joinPaths(this.entryPath, \"bin.ts\") === chunk.facadeModuleId\n ) {\n this.debug(\n `Adding hashbang to binary executable output file: ${chunk.fileName}`\n );\n\n return `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n`;\n }\n return \"\";\n };\n },\n async buildEnd() {\n if (!isSetObject(this.config.bin)) {\n this.warn(\n `No binaries were found for the ${\n this.config.name\n } application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`\n );\n } else {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(\n this.workspaceConfig.workspaceRoot,\n this.config.projectRoot\n )\n );\n\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${path}`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Unable to locate the binary executable output file: ${path}. This may indicate either a misconfiguration in the package.json file or an issue with the build process.`\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.path.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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,MAAM4C,YAAY;;;;AAKlB,MAAaC,UACXC,UAAmB,EAAE,KAClB;AACH,QAAO;EACLxC,QAAQ;EACRF,SAAS;EACTD,QAAQ;EACR;GACE4C,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MAAM,2CAA2C;AAEtD,UAAMhB,wBAAwB,KAAK;IAEnC,MAAMiB,SAAS9B,KACb,EACE+B,QAAQ,EACNC,WAAWxC,UAAU,KAAKoC,OAAOK,aAAa,OAAM,EACtD,EACD,EACDP,SACA;KAC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,QAAO;KAC9C,MAAMO,OAAO9E,WACXuE,KACApE,UACE,KAAKkI,gBAAgBC,eACrB,KAAK/F,OAAOK,YAEhB,CAAC;AAED,SAAI,KAAKiE,GAAGC,WAAWhC,KAAK,EAAE;AAC5B,WAAKtC,MACH,6EAA6EsC,OAC9E;AAED,YAAM/E,OAAO+E,KAAK;WAElB,MAAKmB,KACH,uDAAuDnB,KAAI,4GAC5D;MAGP,CAAC;;GAGN;EACD;GACExC,MAAM;GACN8B,iBAAiB;AACf,SAAK7B,OAAO7C,WAAW,EAAE;AACzB,SAAK6C,OAAO7C,OAAO6I,aAAa;KAC9B,GAAI,KAAKhG,OAAO7C,OAAO6I,cAAc,EAAE;KACvCzH,UAAUA,SAAS,KAAI;KACxB;;GAEH,MAAM0H,OAAO;AACX,SAAKhG,MACH,oEACD;IAED,MAAM1B,aAAW,KAAK2D,OACnBqB,KAAID,UAAS5D,eAAe,MAAM4D,MAAMf,KAAKE,SAAS,CAAC,CACvDW,OAAOC,QAAyB;AAEnC,WAAOnG,OACL,MAAIgJ,gBACHlJ,KAAG;KAAA,IAACmJ,OAAI;AAAA,aAAEhE,OAAOC,OAAO7D,WAAS;;KAAE6H,gBAAc;KAAAC,WAC/CC,UAAKJ,gBACHjJ,MAAI;MAAA,IAACsJ,OAAI;AAAA,cAAE,CAACD,MAAM5D;;MAAS,IAAA2D,WAAA;AAAA,cAAAH,gBACzB5H,iBAAe,EAACkF,SAAS8C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAezG"}
1
+ {"version":3,"file":"plugin.mjs","names":["For","Show","render","automd","deepkit","nodejs","tsdown","toArray","chmodX","appendPath","findFilePath","isParentPath","joinPaths","replacePath","resolveParentPath","camelCase","constantCase","kebabCase","isSetObject","isSetString","defu","resolveEntries","CommandDocsFile","commands","getCommandsPersistencePath","readCommandsPersistence","writeCommandsPersistence","findCommandsRoot","reflectCommandTree","resolveCommandId","resolveCommandName","resolveCommandPath","formatBinaryPath","updatePackageJsonBinary","formatCommandTree","getDefaultOptions","validateCommand","getAppDescription","getAppName","getAppTitle","isDynamicPathSegment","isPathSegmentGroup","getCommandTree","traverseCommands","MAX_DEPTH","plugin","options","name","config","debug","result","output","buildPath","projectRoot","title","description","envPrefix","env","prefix","isCaseSensitive","format","dts","entry","Array","isArray","length","sourceRoot","undefined","build","platform","nodeProtocol","unbundle","noExternal","type","framework","includes","push","configResolved","order","handler","bin","packageJson","inputs","Object","values","id","path","segments","alias","isVirtual","commandsPath","entries","reduce","ret","file","Error","some","existing","split","filter","Boolean","input","map","command","join","warn","cmd","depth","parentPath","sort","a","b","prepare","skipCache","persistedMeta","checksum","meta","fs","existsSync","segment","option","optional","fromEntries","isValid","failures","error","failure","code","details","info","outputOptions","banner","chunk","isEntry","entryPath","facadeModuleId","fileName","mode","buildEnd","Promise","all","workspaceConfig","workspaceRoot","generators","docs","_$createComponent","each","doubleHardline","children","child","when","shellShock"],"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 tsdown from \"@powerlines/plugin-tsdown\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { chmodX } from \"@stryke/fs/chmod-x\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { findFilePath } 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 { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { defu } from \"defu\";\nimport type { Plugin } from \"powerlines\";\nimport { resolveEntries } from \"powerlines/lib/entry\";\nimport type { OutputOptions, RenderedChunk } from \"rolldown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { commands } from \"./helpers/automd\";\nimport {\n getCommandsPersistencePath,\n readCommandsPersistence,\n writeCommandsPersistence\n} from \"./helpers/persistence\";\nimport {\n findCommandsRoot,\n reflectCommandTree,\n resolveCommandId,\n resolveCommandName,\n resolveCommandPath\n} from \"./helpers/resolve-command\";\nimport {\n formatBinaryPath,\n updatePackageJsonBinary\n} from \"./helpers/update-package-json\";\nimport { formatCommandTree, getDefaultOptions } from \"./helpers/utilities\";\nimport { validateCommand } from \"./helpers/validations\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\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 type { CommandOption, CommandTree } 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 buildPath: joinPaths(this.config.projectRoot, \"dist\")\n }\n },\n options,\n {\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n envPrefix: constantCase(getAppName(this)),\n env: {\n prefix: [] as string[]\n },\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: true\n },\n entry:\n !this.config.entry ||\n (Array.isArray(this.config.entry) &&\n this.config.entry.length === 0)\n ? [\n joinPaths(this.config.sourceRoot, \"**/*.ts\"),\n joinPaths(this.config.sourceRoot, \"**/*.tsx\")\n ]\n : undefined,\n build: {\n dts: false,\n platform: \"node\",\n nodeProtocol: true,\n unbundle: false,\n noExternal: [\"@powerlines/deepkit\"]\n },\n type: \"application\",\n framework: \"shell-shock\"\n }\n );\n if (!result.env.prefix.includes(result.envPrefix)) {\n result.env.prefix.push(result.envPrefix);\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.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 this.inputs ??= [];\n this.options = Object.values(\n getDefaultOptions(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 {\n name: \"shell-shock:inputs\",\n async configResolved() {\n this.debug(\"Finding command entry point files.\");\n\n this.commandsPath = findCommandsRoot(this);\n const entries = await resolveEntries(\n this,\n toArray(this.config.entry || [])\n );\n\n this.debug(\n `Found ${\n entries.length\n } entry points specified in the configuration options.`\n );\n\n this.inputs = entries.reduce((ret, entry) => {\n if (!isParentPath(entry.file, this.commandsPath)) {\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 path = resolveCommandPath(this, entry.file);\n const name = resolveCommandName(entry.file);\n\n ret.push({\n id,\n path,\n segments: path.split(\"/\").filter(Boolean),\n name,\n alias: [],\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 },\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}: ${replacePath(\n command.entry.file,\n 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 while (parentPath !== this.commandsPath) {\n if (depth++ > MAX_DEPTH) {\n throw new Error(\n `Maximum command virtual parent depth of ${\n MAX_DEPTH\n } exceeded while processing command: ${command.name}`\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 const path = resolveCommandPath(this, file);\n\n ret.push({\n id,\n path,\n segments: path.split(\"/\").filter(Boolean),\n name,\n alias: [],\n isVirtual: true,\n entry: {\n file\n }\n });\n }\n }\n\n parentPath = resolveParentPath(parentPath);\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:reflect-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 reflection initialization 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 reflectCommandTree(this, input);\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.build.outputOptions ??= {} as OutputOptions;\n (this.config.build.outputOptions as OutputOptions).banner = (\n chunk: RenderedChunk\n ) => {\n if (\n chunk.isEntry &&\n joinPaths(this.entryPath, \"bin.ts\") === chunk.facadeModuleId\n ) {\n this.debug(\n `Adding hashbang to binary executable output file: ${chunk.fileName}`\n );\n\n return `#!/usr/bin/env ${\n this.config.mode === \"development\"\n ? \"-S NODE_OPTIONS=--enable-source-maps\"\n : \"\"\n } node\\n`;\n }\n return \"\";\n };\n },\n async buildEnd() {\n if (!isSetObject(this.config.bin)) {\n this.warn(\n `No binaries were found for the ${\n this.config.name\n } application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`\n );\n } else {\n await Promise.all(\n Object.values(this.config.bin).map(async bin => {\n const path = appendPath(\n bin,\n joinPaths(\n this.workspaceConfig.workspaceRoot,\n this.config.projectRoot\n )\n );\n\n if (this.fs.existsSync(path)) {\n this.debug(\n `Adding executable permissions (chmod+x) to binary executable output file: ${path}`\n );\n\n await chmodX(path);\n } else {\n this.warn(\n `Unable to locate the binary executable output file: ${path}. This may indicate either a misconfiguration in the package.json file or an issue with the build process.`\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,MAAM4C,YAAY;;;;AAKlB,MAAaC,UACXC,UAAmB,EAAE,KAClB;AACH,QAAO;EACLxC,QAAQ;EACRF,SAAS;EACTD,QAAQ;EACR;GACE4C,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MAAM,2CAA2C;AAEtD,UAAMhB,wBAAwB,KAAK;IAEnC,MAAMiB,SAAS9B,KACb,EACE+B,QAAQ,EACNC,WAAWxC,UAAU,KAAKoC,OAAOK,aAAa,OAAM,EACtD,EACD,EACDP,SACA;KACEC,MAAMT,WAAW,KAAK;KACtBgB,OAAOf,YAAY,KAAK;KACxBgB,aAAalB,kBAAkB,KAAK;KACpCmB,WAAWxC,aAAasB,WAAW,KAAK,CAAC;KACzCmB,KAAK,EACHC,QAAQ,EAAA,EACT;KACDC,iBAAiB;KACjBR,QAAQ;MACNS,QAAQ;MACRC,KAAK;MACN;KACDC,OACE,CAAC,KAAKd,OAAOc,SACZC,MAAMC,QAAQ,KAAKhB,OAAOc,MAAM,IAC/B,KAAKd,OAAOc,MAAMG,WAAW,IAC3B,CACErD,UAAU,KAAKoC,OAAOkB,YAAY,UAAU,EAC5CtD,UAAU,KAAKoC,OAAOkB,YAAY,WAAW,CAC9C,GACDC;KACNC,OAAO;MACLP,KAAK;MACLQ,UAAU;MACVC,cAAc;MACdC,UAAU;MACVC,YAAY,CAAC,sBAAqB;MACnC;KACDC,MAAM;KACNC,WAAW;KAEf,CAAC;AACD,QAAI,CAACxB,OAAOO,IAAIC,OAAOiB,SAASzB,OAAOM,UAAU,CAC/CN,QAAOO,IAAIC,OAAOkB,KAAK1B,OAAOM,UAAU;AAG1C,WAAON;;GAET2B,gBAAgB;IAC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AA,cAAE,CAACD,MAAM5D;;MAAS,IAAA2D,WAAA;AAAA,cAAAH,gBACzB3H,iBAAe,EAACiF,SAAS8C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAexG"}
@@ -3,7 +3,7 @@ import { AnyFunction } from "@stryke/types/base";
3
3
  import { ResolvedEntryTypeDefinition } from "powerlines/types/resolved";
4
4
 
5
5
  //#region src/types/command.d.ts
6
- interface BaseCommandArgument {
6
+ interface BaseCommandParameter {
7
7
  /**
8
8
  * The option name.
9
9
  */
@@ -33,7 +33,7 @@ interface BaseCommandArgument {
33
33
  */
34
34
  optional: boolean;
35
35
  }
36
- interface StringCommandArgument extends BaseCommandArgument {
36
+ interface StringCommandParameter extends BaseCommandParameter {
37
37
  /**
38
38
  * The option kind.
39
39
  */
@@ -47,7 +47,7 @@ interface StringCommandArgument extends BaseCommandArgument {
47
47
  */
48
48
  variadic: boolean;
49
49
  }
50
- interface NumberCommandArgument extends BaseCommandArgument {
50
+ interface NumberCommandParameter extends BaseCommandParameter {
51
51
  /**
52
52
  * The option kind.
53
53
  */
@@ -61,7 +61,7 @@ interface NumberCommandArgument extends BaseCommandArgument {
61
61
  */
62
62
  variadic: boolean;
63
63
  }
64
- interface BooleanCommandArgument extends BaseCommandArgument {
64
+ interface BooleanCommandParameter extends BaseCommandParameter {
65
65
  /**
66
66
  * The option kind.
67
67
  */
@@ -79,19 +79,19 @@ interface BooleanCommandArgument extends BaseCommandArgument {
79
79
  */
80
80
  skipAddingNegative?: boolean;
81
81
  }
82
- interface StringCommandOption extends StringCommandArgument {
82
+ interface StringCommandOption extends StringCommandParameter {
83
83
  /**
84
84
  * The property reflection.
85
85
  */
86
86
  reflection?: ReflectionProperty;
87
87
  }
88
- interface NumberCommandOption extends NumberCommandArgument {
88
+ interface NumberCommandOption extends NumberCommandParameter {
89
89
  /**
90
90
  * The property reflection.
91
91
  */
92
92
  reflection?: ReflectionProperty;
93
93
  }
94
- interface BooleanCommandOption extends BooleanCommandArgument {
94
+ interface BooleanCommandOption extends BooleanCommandParameter {
95
95
  /**
96
96
  * The property reflection.
97
97
  */
@@ -106,35 +106,25 @@ interface BooleanCommandOption extends BooleanCommandArgument {
106
106
  skipAddingNegative?: boolean;
107
107
  }
108
108
  type CommandOption = StringCommandOption | NumberCommandOption | BooleanCommandOption;
109
- interface StringCommandParameter extends StringCommandArgument {
109
+ interface StringCommandArgument extends StringCommandParameter {
110
110
  /**
111
111
  * The parameter reflection.
112
112
  */
113
113
  reflection: ReflectionParameter;
114
114
  }
115
- interface NumberCommandParameter extends NumberCommandArgument {
115
+ interface NumberCommandArgument extends NumberCommandParameter {
116
116
  /**
117
117
  * The parameter reflection.
118
118
  */
119
119
  reflection: ReflectionParameter;
120
120
  }
121
- interface BooleanCommandParameter extends BooleanCommandArgument {
121
+ interface BooleanCommandArgument extends BooleanCommandParameter {
122
122
  /**
123
123
  * The parameter reflection.
124
124
  */
125
125
  reflection: ReflectionParameter;
126
126
  }
127
- type CommandParameter = StringCommandParameter | NumberCommandParameter | BooleanCommandParameter;
128
- interface CommandPath {
129
- /**
130
- * The full path value.
131
- */
132
- value: string | null;
133
- /**
134
- * The path segments.
135
- */
136
- segments: string[];
137
- }
127
+ type CommandArgument = StringCommandArgument | NumberCommandArgument | BooleanCommandArgument;
138
128
  interface CommandBase {
139
129
  /**
140
130
  * The command id.
@@ -144,6 +134,14 @@ interface CommandBase {
144
134
  * The command name.
145
135
  */
146
136
  name: string;
137
+ /**
138
+ * The full command path value.
139
+ */
140
+ path: string | null;
141
+ /**
142
+ * The path segments.
143
+ */
144
+ segments: string[];
147
145
  /**
148
146
  * The display title.
149
147
  */
@@ -160,10 +158,6 @@ interface CommandBase {
160
158
  * The command icon.
161
159
  */
162
160
  icon?: string;
163
- /**
164
- * The command path.
165
- */
166
- path: CommandPath;
167
161
  /**
168
162
  * Whether the command is virtual.
169
163
  */
@@ -179,80 +173,6 @@ interface CommandInput extends CommandBase {
179
173
  */
180
174
  entry: ResolvedEntryTypeDefinition;
181
175
  }
182
- /**
183
- * Represents a dynamic command segment with metadata and matching behavior.
184
- */
185
- type CommandDynamicSegment = {
186
- /**
187
- * The parameter reflection.
188
- */
189
- reflection?: ReflectionParameter;
190
- /**
191
- * The segment value.
192
- */
193
- segment: string;
194
- /**
195
- * The segment name.
196
- */
197
- name: string;
198
- /**
199
- * The segment title.
200
- */
201
- title: string;
202
- /**
203
- * The segment description.
204
- */
205
- description: string;
206
- /**
207
- * Whether the segment is optional.
208
- */
209
- optional: boolean;
210
- } & ({
211
- /**
212
- * The default value.
213
- */
214
- default?: string;
215
- /**
216
- * Whether the segment is a catch-all.
217
- */
218
- catchAll: false;
219
- /**
220
- * Whether the segment is variadic.
221
- */
222
- variadic: false;
223
- } | {
224
- /**
225
- * The default value.
226
- */
227
- default?: string;
228
- /**
229
- * Whether the segment is a catch-all.
230
- */
231
- catchAll: true;
232
- /**
233
- * Whether the segment is variadic.
234
- */
235
- variadic: false;
236
- } | {
237
- /**
238
- * The default values.
239
- */
240
- default?: string[];
241
- /**
242
- * Whether the segment is a catch-all.
243
- */
244
- catchAll: true;
245
- /**
246
- * Whether the segment is variadic.
247
- */
248
- variadic: true;
249
- });
250
- interface CommandTreePath extends CommandPath {
251
- /**
252
- * Dynamic segment definitions.
253
- */
254
- dynamics: Record<string, CommandDynamicSegment>;
255
- }
256
176
  type CommandTree = CommandInput & {
257
177
  /**
258
178
  * The display title.
@@ -266,18 +186,14 @@ type CommandTree = CommandInput & {
266
186
  * Alternative command names.
267
187
  */
268
188
  alias: string[];
269
- /**
270
- * The command path with dynamics.
271
- */
272
- path: CommandTreePath;
273
189
  /**
274
190
  * The command options.
275
191
  */
276
192
  options: Record<string, CommandOption>;
277
193
  /**
278
- * The positional parameter options provided to the command.
194
+ * The positional arguments provided to the command.
279
195
  */
280
- params: CommandParameter[];
196
+ arguments: CommandArgument[];
281
197
  /**
282
198
  * The parent command.
283
199
  */
@@ -292,24 +208,16 @@ type CommandTree = CommandInput & {
292
208
  reflection: ReflectionFunction | null;
293
209
  };
294
210
  type SerializedCommandOption = Omit<CommandOption, "reflection">;
295
- type SerializedCommandDynamicSegment = Omit<CommandDynamicSegment, "reflection">;
296
- type SerializedCommandTreePath = Omit<CommandTreePath, "dynamics"> & {
297
- dynamics: Record<string, SerializedCommandDynamicSegment>;
298
- };
299
- type SerializedCommandParameter = Omit<CommandParameter, "reflection">;
300
- type SerializedCommandTree = Omit<CommandTree, "options" | "path" | "params" | "parent" | "children" | "reflection"> & {
211
+ type SerializedCommandArgument = Omit<CommandArgument, "reflection">;
212
+ type SerializedCommandTree = Omit<CommandTree, "options" | "arguments" | "parent" | "children" | "reflection"> & {
301
213
  /**
302
214
  * The command options.
303
215
  */
304
216
  options: Record<string, SerializedCommandOption>;
305
217
  /**
306
- * The command path with dynamics.
307
- */
308
- path: SerializedCommandTreePath;
309
- /**
310
- * The positional parameter options provided to the command.
218
+ * The positional arguments provided to the command.
311
219
  */
312
- params: SerializedCommandParameter[];
220
+ arguments: SerializedCommandArgument[];
313
221
  /**
314
222
  * The parent command id.
315
223
  */
@@ -355,5 +263,5 @@ interface CommandModule {
355
263
  default?: AnyFunction;
356
264
  }
357
265
  //#endregion
358
- export { BaseCommandArgument, BooleanCommandArgument, BooleanCommandOption, BooleanCommandParameter, CommandBase, CommandDynamicSegment, CommandInput, CommandModule, CommandOption, CommandParameter, CommandPath, CommandTree, CommandTreePath, Metadata, NumberCommandArgument, NumberCommandOption, NumberCommandParameter, SerializedCommandDynamicSegment, SerializedCommandOption, SerializedCommandParameter, SerializedCommandTree, SerializedCommandTreePath, StringCommandArgument, StringCommandOption, StringCommandParameter };
266
+ export { BaseCommandParameter, BooleanCommandArgument, BooleanCommandOption, BooleanCommandParameter, CommandArgument, CommandBase, CommandInput, CommandModule, CommandOption, CommandTree, Metadata, NumberCommandArgument, NumberCommandOption, NumberCommandParameter, SerializedCommandArgument, SerializedCommandOption, SerializedCommandTree, StringCommandArgument, StringCommandOption, StringCommandParameter };
359
267
  //# sourceMappingURL=command.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"command.d.cts","names":[],"sources":["../../src/types/command.ts"],"sourcesContent":[],"mappings":";;;;;UA4BiB,mBAAA;;AAAjB;AA+BA;EAeiB,IAAA,EAAA,MAAA;EAeA;AAmBjB;AAOA;EAOiB,IAAA,EAtFT,cAsFS;EAeL;;;EAGR,KAAA,EAAA,MAAA;EAAoB;AAExB;AAOA;EAOiB,WAAA,EAAA,MAAA;EAOL;;;EAGR,KAAA,EAAA,MAAA,EAAA;EAAuB;AAE3B;AAWA;EAmCiB,GAAA,EAAA,MAAA,GAAA,KAAa;EAclB;AAsEZ;;EAIY,QAAA,EAAA,OAAA;;AAJwC,UA/OnC,qBAAA,SAA8B,mBA+OK,CAAA;EAOxC;;;EAoBc,IAAA,EAtQlB,cAAA,CAAe,MAsQG;EAAf;;;EAYgB,OAAA,CAAA,EAAA,MAAA;EAAf;;;EAOA,QAAA,EAAA,OAAA;AAEZ;AAKY,UArRK,qBAAA,SAA8B,mBAqRV,CAAA;EAAQ;;;EACjC,IAAA,EAlRJ,cAAA,CAAe,MAkRX;EAAM;AAGlB;AAEA;EACE,OAAA,CAAA,EAAA,MAAA;EADkC;;;EAW5B,QAAA,EAAA,OAAA;;AAYmB,UAnSV,sBAAA,SAA+B,mBAmSrB,CAAA;EAAf;;;EAOK,IAAA,EAtST,cAAA,CAAe,OAsSE;EA+BR;;;;;;;;;;;;;UAtTA,mBAAA,SAA4B;;;;eAI9B;;UAGE,mBAAA,SAA4B;;;;eAI9B;;UAGE,oBAAA,SAA6B;;;;eAI/B;;;;;;;;;;KAWH,aAAA,GACR,sBACA,sBACA;UAEa,sBAAA,SAA+B;;;;cAIlC;;UAGG,sBAAA,SAA+B;;;;cAIlC;;UAGG,uBAAA,SAAgC;;;;cAInC;;KAGF,gBAAA,GACR,yBACA,yBACA;UAEa,WAAA;;;;;;;;;;UAWA,WAAA;;;;;;;;;;;;;;;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