@shell-shock/core 0.9.7 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/api.cjs +1 -2
  2. package/dist/api.cjs.map +1 -1
  3. package/dist/api.d.cts +1 -1
  4. package/dist/api.d.mts +1 -1
  5. package/dist/api.mjs +1 -2
  6. package/dist/api.mjs.map +1 -1
  7. package/dist/components/docs.d.cts +5 -5
  8. package/dist/components/docs.d.cts.map +1 -1
  9. package/dist/components/docs.d.mts +5 -5
  10. package/dist/components/helpers.d.cts +6 -6
  11. package/dist/components/index.cjs +1 -0
  12. package/dist/components/index.d.cts +2 -2
  13. package/dist/components/index.d.mts +2 -2
  14. package/dist/components/index.mjs +2 -2
  15. package/dist/components/options-parser-logic.d.cts +9 -9
  16. package/dist/components/options-parser-logic.d.mts +9 -9
  17. package/dist/components/options-parser-logic.d.mts.map +1 -1
  18. package/dist/components/usage.d.cts +2 -2
  19. package/dist/components/usage.d.mts +2 -2
  20. package/dist/components/utils-builtin.cjs +204 -0
  21. package/dist/components/utils-builtin.cjs.map +1 -1
  22. package/dist/components/utils-builtin.d.cts +13 -9
  23. package/dist/components/utils-builtin.d.cts.map +1 -1
  24. package/dist/components/utils-builtin.d.mts +13 -9
  25. package/dist/components/utils-builtin.d.mts.map +1 -1
  26. package/dist/components/utils-builtin.mjs +205 -2
  27. package/dist/components/utils-builtin.mjs.map +1 -1
  28. package/dist/helpers/docs-helpers.cjs +1 -1
  29. package/dist/helpers/docs-helpers.cjs.map +1 -1
  30. package/dist/helpers/docs-helpers.mjs +1 -1
  31. package/dist/helpers/docs-helpers.mjs.map +1 -1
  32. package/dist/helpers/resolve-command.cjs +27 -7
  33. package/dist/helpers/resolve-command.cjs.map +1 -1
  34. package/dist/helpers/resolve-command.mjs +26 -6
  35. package/dist/helpers/resolve-command.mjs.map +1 -1
  36. package/dist/helpers/update-package-json.cjs +1 -1
  37. package/dist/helpers/update-package-json.cjs.map +1 -1
  38. package/dist/helpers/update-package-json.mjs +1 -1
  39. package/dist/helpers/update-package-json.mjs.map +1 -1
  40. package/dist/index.cjs +1 -5
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.cts +2 -4
  43. package/dist/index.d.mts +2 -4
  44. package/dist/index.mjs +2 -4
  45. package/dist/index.mjs.map +1 -1
  46. package/dist/plugin.cjs +20 -21
  47. package/dist/plugin.cjs.map +1 -1
  48. package/dist/plugin.d.cts.map +1 -1
  49. package/dist/plugin.d.mts.map +1 -1
  50. package/dist/plugin.mjs +19 -19
  51. package/dist/plugin.mjs.map +1 -1
  52. package/dist/types/command.cjs +12 -3
  53. package/dist/types/command.cjs.map +1 -1
  54. package/dist/types/command.d.cts +15 -2
  55. package/dist/types/command.d.cts.map +1 -1
  56. package/dist/types/command.d.mts +15 -2
  57. package/dist/types/command.d.mts.map +1 -1
  58. package/dist/types/command.mjs +12 -4
  59. package/dist/types/command.mjs.map +1 -1
  60. package/dist/types/config.cjs +1 -2
  61. package/dist/types/config.cjs.map +1 -1
  62. package/dist/types/config.d.cts +2 -2
  63. package/dist/types/config.d.cts.map +1 -1
  64. package/dist/types/config.d.mts +2 -2
  65. package/dist/types/config.d.mts.map +1 -1
  66. package/dist/types/config.mjs +1 -2
  67. package/dist/types/config.mjs.map +1 -1
  68. package/dist/types/context.cjs.map +1 -1
  69. package/dist/types/context.d.cts +1 -1
  70. package/dist/types/context.d.mts +1 -1
  71. package/dist/types/context.mjs.map +1 -1
  72. package/dist/types/index.cjs +1 -0
  73. package/dist/types/index.d.cts +2 -2
  74. package/dist/types/index.d.mts +2 -2
  75. package/dist/types/index.mjs +2 -2
  76. package/package.json +22 -16
package/dist/plugin.cjs CHANGED
@@ -20,8 +20,6 @@ let __powerlines_plugin_deepkit = require("@powerlines/plugin-deepkit");
20
20
  __powerlines_plugin_deepkit = require_rolldown_runtime.__toESM(__powerlines_plugin_deepkit);
21
21
  let __powerlines_plugin_nodejs = require("@powerlines/plugin-nodejs");
22
22
  __powerlines_plugin_nodejs = require_rolldown_runtime.__toESM(__powerlines_plugin_nodejs);
23
- let __powerlines_plugin_tsdown = require("@powerlines/plugin-tsdown");
24
- __powerlines_plugin_tsdown = require_rolldown_runtime.__toESM(__powerlines_plugin_tsdown);
25
23
  let __stryke_convert_to_array = require("@stryke/convert/to-array");
26
24
  let __stryke_fs_chmod_x = require("@stryke/fs/chmod-x");
27
25
  let __stryke_path_append = require("@stryke/path/append");
@@ -33,10 +31,12 @@ let __stryke_path_resolve_parent_path = require("@stryke/path/resolve-parent-pat
33
31
  let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
34
32
  let __stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
35
33
  let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
34
+ let __stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
36
35
  let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
37
36
  let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
38
37
  let defu = require("defu");
39
- let powerlines_lib_entry = require("powerlines/lib/entry");
38
+ let powerlines_tsdown = require("powerlines/tsdown");
39
+ let powerlines_utils = require("powerlines/utils");
40
40
 
41
41
  //#region src/plugin.tsx
42
42
  const MAX_DEPTH = 50;
@@ -45,7 +45,7 @@ const MAX_DEPTH = 50;
45
45
  */
46
46
  const plugin = (options = {}) => {
47
47
  return [
48
- (0, __powerlines_plugin_tsdown.default)(),
48
+ (0, powerlines_tsdown.tsdown)(),
49
49
  (0, __powerlines_plugin_deepkit.default)(),
50
50
  (0, __powerlines_plugin_automd.default)(),
51
51
  {
@@ -53,10 +53,12 @@ const plugin = (options = {}) => {
53
53
  async config() {
54
54
  this.debug("Resolving the Shell Shock configuration.");
55
55
  await require_update_package_json.updatePackageJsonBinary(this);
56
- const result = (0, defu.defu)({ output: { buildPath: (0, __stryke_path_join_paths.joinPaths)(this.config.projectRoot, "dist") } }, options, {
56
+ const result = (0, defu.defu)({ output: { buildPath: (0, __stryke_path_join_paths.joinPaths)(this.config.root, "dist") } }, options, {
57
57
  name: require_plugin_utils_context_helpers.getAppName(this),
58
58
  title: require_plugin_utils_context_helpers.getAppTitle(this),
59
59
  description: require_plugin_utils_context_helpers.getAppDescription(this),
60
+ platform: "node",
61
+ projectType: "application",
60
62
  envPrefix: (0, __stryke_string_format_constant_case.constantCase)(require_plugin_utils_context_helpers.getAppName(this)),
61
63
  env: { prefix: [] },
62
64
  isCaseSensitive: false,
@@ -64,16 +66,13 @@ const plugin = (options = {}) => {
64
66
  format: "esm",
65
67
  dts: true
66
68
  },
67
- entry: !this.config.entry || Array.isArray(this.config.entry) && this.config.entry.length === 0 ? [(0, __stryke_path_join_paths.joinPaths)(this.config.sourceRoot, "**/*.ts"), (0, __stryke_path_join_paths.joinPaths)(this.config.sourceRoot, "**/*.tsx")] : void 0,
68
- build: {
69
- dts: false,
70
- platform: "node",
69
+ input: !this.config.input || Array.isArray(this.config.input) && this.config.input.length === 0 || (0, __stryke_type_checks_is_object.isObject)(this.config.input) && Object.keys(this.config.input).length === 0 ? [(0, __stryke_path_join_paths.joinPaths)(this.config.root, "src/**/command.ts"), (0, __stryke_path_join_paths.joinPaths)(this.config.root, "src/**/command.tsx")] : void 0,
70
+ resolve: { external: ["@powerlines/deepkit"] },
71
+ tsdown: {
72
+ dts: true,
71
73
  nodeProtocol: true,
72
- unbundle: false,
73
- noExternal: ["@powerlines/deepkit"]
74
- },
75
- type: "application",
76
- framework: "shell-shock"
74
+ unbundle: false
75
+ }
77
76
  });
78
77
  if (!result.env.prefix || !Array.isArray(result.env.prefix)) result.env.prefix = (0, __stryke_convert_to_array.toArray)(result.env.prefix);
79
78
  if (!result.env.prefix.includes(result.envPrefix)) result.env.prefix.push(result.envPrefix);
@@ -107,10 +106,10 @@ const plugin = (options = {}) => {
107
106
  async configResolved() {
108
107
  this.debug("Finding command entry point files.");
109
108
  this.commandsPath = require_resolve_command.findCommandsRoot(this);
110
- const entries = await (0, powerlines_lib_entry.resolveEntries)(this, (0, __stryke_convert_to_array.toArray)(this.config.entry || []));
111
- this.debug(`Found ${entries.length} entry points specified in the configuration options.`);
112
- this.inputs = entries.reduce((ret, entry) => {
113
- if (!(0, __stryke_path_is_parent_path.isParentPath)(entry.file, this.commandsPath)) throw new Error(`Command entry point "${entry.file}" is not located within the commands root "${this.commandsPath}". Please ensure that all command entry points are located within the current project.`);
109
+ const inputs = await (0, powerlines_utils.resolveInputs)(this, this.config.input);
110
+ this.debug(`Found ${inputs.length} entry points specified in the configuration options.`);
111
+ this.inputs = inputs.reduce((ret, entry) => {
112
+ if (entry.file !== this.commandsPath && !(0, __stryke_path_is_parent_path.isParentPath)(entry.file, this.commandsPath)) throw new Error(`Command entry point "${entry.file}" is not located within the commands root "${this.commandsPath}". Please ensure that all command entry points are located within the current project.`);
114
113
  const id = require_resolve_command.resolveCommandId(this, entry.file);
115
114
  if (!ret.some((existing) => existing.id === id)) {
116
115
  const name = require_resolve_command.resolveCommandName(entry.file);
@@ -238,8 +237,8 @@ const plugin = (options = {}) => {
238
237
  {
239
238
  name: "shell-shock:chmod+x",
240
239
  configResolved() {
241
- this.config.build.outputOptions ??= {};
242
- this.config.build.outputOptions.banner = (chunk) => {
240
+ this.config.tsdown.outputOptions ??= {};
241
+ if ((0, __stryke_type_checks_is_object.isObject)(this.config.tsdown.outputOptions)) this.config.tsdown.outputOptions.banner = (chunk) => {
243
242
  if (chunk.isEntry && (0, __stryke_path_join_paths.joinPaths)(this.entryPath, "bin.ts") === chunk.facadeModuleId) {
244
243
  this.debug(`Adding hashbang to binary executable output file: ${chunk.fileName}`);
245
244
  return `#!/usr/bin/env ${this.config.mode === "development" ? "-S NODE_OPTIONS=--enable-source-maps" : ""} node\n`;
@@ -250,7 +249,7 @@ const plugin = (options = {}) => {
250
249
  async buildEnd() {
251
250
  if (!(0, __stryke_type_checks_is_set_object.isSetObject)(this.config.bin)) this.warn(`No binaries were found for the ${this.config.name} application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`);
252
251
  else await Promise.all(Object.values(this.config.bin).map(async (bin) => {
253
- const path = (0, __stryke_path_append.appendPath)(bin, (0, __stryke_path_join_paths.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.projectRoot));
252
+ const path = (0, __stryke_path_append.appendPath)(bin, (0, __stryke_path_join_paths.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.root));
254
253
  if (this.fs.existsSync(path)) {
255
254
  this.debug(`Adding executable permissions (chmod+x) to binary executable output file: ${path}`);
256
255
  await (0, __stryke_fs_chmod_x.chmodX)(path);
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs","names":["For","Show","render","automd","deepkit","nodejs","tsdown","toArray","chmodX","appendPath","findFilePath","relativePath","isParentPath","joinPaths","replacePath","resolveParentPath","camelCase","constantCase","kebabCase","isSetObject","isSetString","defu","resolveEntries","CommandDocsFile","UtilsBuiltin","commands","getCommandsPersistencePath","readCommandsPersistence","writeCommandsPersistence","findCommandsRoot","reflectCommandTree","resolveCommandId","resolveCommandName","resolveCommandPath","formatBinaryPath","updatePackageJsonBinary","formatCommandTree","getDefaultOptions","validateCommand","getAppDescription","getAppName","getAppTitle","getDynamicPathSegmentName","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","types","validate","commandsPath","entries","reduce","ret","file","Error","some","existing","split","filter","Boolean","map","segment","index","found","findIndex","replace","join","input","command","prepare","_$createComponent","warn","cmd","depth","parentPath","sort","a","b","skipCache","persistedMeta","checksum","meta","fs","existsSync","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","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, 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 { 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 { UtilsBuiltin } from \"./components/utils-builtin\";\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 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 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\n if (!result.env.prefix || !Array.isArray(result.env.prefix)) {\n result.env.prefix = toArray(result.env.prefix);\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 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.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 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 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 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 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: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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,MAAM+C,YAAY;;;;AAKlB,MAAaC,UACXC,UAAmB,EAAE,KAClB;AACH,QAAO;2CACG;4CACC;2CACD;EACR;GACEC,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MAAM,2CAA2C;AAEtD,UAAMjB,oDAAwB,KAAK;IAEnC,MAAMkB,wBACJ,EACEC,QAAQ,EACNC,mDAAqB,KAAKJ,OAAOK,aAAa,OAAM,EACtD,EACD,EACDP,SACA;KACEC,MAAMV,gDAAW,KAAK;KACtBiB,OAAOhB,iDAAY,KAAK;KACxBiB,aAAanB,uDAAkB,KAAK;KACpCoB,kEAAwBnB,gDAAW,KAAK,CAAC;KACzCoB,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,yCACY,KAAKjB,OA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C8J,OAAI;AAAA,cAAE,CAACD,MAAMlE;;MAAS,IAAAiE,WAAA;AAAA,+DACzBtI,yCAAe,EAAC2F,SAAS4C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAe9G"}
1
+ {"version":3,"file":"plugin.cjs","names":["For","Show","render","automd","deepkit","nodejs","toArray","chmodX","appendPath","findFilePath","relativePath","isParentPath","joinPaths","replacePath","resolveParentPath","camelCase","constantCase","kebabCase","isObject","isSetObject","isSetString","defu","tsdown","resolveInputs","CommandDocsFile","UtilsBuiltin","commands","getCommandsPersistencePath","readCommandsPersistence","writeCommandsPersistence","findCommandsRoot","reflectCommandTree","resolveCommandId","resolveCommandName","resolveCommandPath","formatBinaryPath","updatePackageJsonBinary","formatCommandTree","getDefaultOptions","validateCommand","getAppDescription","getAppName","getAppTitle","getDynamicPathSegmentName","isDynamicPathSegment","isPathSegmentGroup","getCommandTree","traverseCommands","MAX_DEPTH","plugin","options","name","config","debug","result","output","buildPath","root","title","description","platform","projectType","envPrefix","env","prefix","isCaseSensitive","format","dts","input","Array","isArray","length","Object","keys","undefined","resolve","external","nodeProtocol","unbundle","includes","push","configResolved","order","handler","bin","packageJson","inputs","values","id","path","segments","alias","isVirtual","types","validate","commandsPath","reduce","ret","entry","file","Error","some","existing","split","filter","Boolean","map","segment","index","found","findIndex","replace","join","command","prepare","_$createComponent","warn","cmd","depth","parentPath","sort","a","b","skipCache","persistedMeta","checksum","meta","fs","existsSync","option","optional","fromEntries","entries","isValid","failures","error","failure","code","details","info","outputOptions","banner","chunk","isEntry","entryPath","facadeModuleId","fileName","mode","buildEnd","Promise","all","workspaceConfig","workspaceRoot","generators","docs","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 { 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 { 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 { tsdown } from \"powerlines/tsdown\";\nimport { resolveInputs } from \"powerlines/utils\";\nimport type { OutputOptions, RenderedChunk } from \"rolldown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\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 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 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.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 envPrefix: constantCase(getAppName(this)),\n env: {\n prefix: [] as string[]\n },\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: true\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 },\n tsdown: {\n dts: true,\n nodeProtocol: true,\n unbundle: false\n }\n }\n );\n\n if (!result.env.prefix || !Array.isArray(result.env.prefix)) {\n result.env.prefix = toArray(result.env.prefix);\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 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.commandsPath = findCommandsRoot(this);\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 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 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 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: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.tsdown.outputOptions ??= {} as any;\n if (isObject(this.config.tsdown.outputOptions)) {\n (\n this.config.tsdown.outputOptions as NonNullable<OutputOptions>\n ).banner = (chunk: RenderedChunk) => {\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: ${\n chunk.fileName\n }`\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 },\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(this.workspaceConfig.workspaceRoot, this.config.root)\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EA,MAAMgD,YAAY;;;;AAKlB,MAAaC,UACXC,UAAmB,EAAE,KAClB;AACH,QAAO;iCACG;4CACC;2CACD;EACR;GACEC,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MAAM,2CAA2C;AAEtD,UAAMjB,oDAAwB,KAAK;IAEnC,MAAMkB,wBACJ,EACEC,QAAQ,EACNC,mDAAqB,KAAKJ,OAAOK,MAAM,OAAM,EAC/C,EACD,EACDP,SACA;KACEC,MAAMV,gDAAW,KAAK;KACtBiB,OAAOhB,iDAAY,KAAK;KACxBiB,aAAanB,uDAAkB,KAAK;KACpCoB,UAAU;KACVC,aAAa;KACbC,kEAAwBrB,gDAAW,KAAK,CAAC;KACzCsB,KAAK,EACHC,QAAQ,EAAA,EACT;KACDC,iBAAiB;KACjBV,QAAQ;MACNW,QAAQ;MACRC,KAAK;MACN;KACDC,OACE,CAAC,KAAKhB,OAAOgB,SACZC,MAAMC,QAAQ,KAAKlB,OAAOgB,MAAM,IAC/B,KAAKhB,OAAOgB,MAAMG,WAAW,kDACrB,KAAKnB,OAAOgB,MAAM,IAC1BI,OAAOC,KAAK,KAAKrB,OAAOgB,MAAM,CAACG,WAAW,IACxC,yCACY,KAAKnB,OAAOK,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CAAI;MAAA,IAAC8J,OAAI;AAAA,cAAE,CAACD,MAAMlE;;MAAS,IAAAiE,WAAA;AAAA,+DACzBrI,yCAAe,EAACyF,SAAS6C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAe7G"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAiFA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GAofjC,MApfiC,CAof1B,QApf0B,CAAA,EAAA"}
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAkFA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GAwfjC,MAxfiC,CAwf1B,QAxf0B,CAAA,EAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAiFA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GAofjC,MApfiC,CAof1B,QApf0B,CAAA,EAAA"}
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAkFA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GAwfjC,MAxfiC,CAwf1B,QAxf0B,CAAA,EAAA"}
package/dist/plugin.mjs CHANGED
@@ -15,7 +15,6 @@ import { render } from "@powerlines/plugin-alloy/render";
15
15
  import automd from "@powerlines/plugin-automd";
16
16
  import deepkit from "@powerlines/plugin-deepkit";
17
17
  import nodejs from "@powerlines/plugin-nodejs";
18
- import tsdown from "@powerlines/plugin-tsdown";
19
18
  import { toArray } from "@stryke/convert/to-array";
20
19
  import { chmodX } from "@stryke/fs/chmod-x";
21
20
  import { appendPath } from "@stryke/path/append";
@@ -27,10 +26,12 @@ import { resolveParentPath } from "@stryke/path/resolve-parent-path";
27
26
  import { camelCase } from "@stryke/string-format/camel-case";
28
27
  import { constantCase } from "@stryke/string-format/constant-case";
29
28
  import { kebabCase } from "@stryke/string-format/kebab-case";
29
+ import { isObject } from "@stryke/type-checks/is-object";
30
30
  import { isSetObject } from "@stryke/type-checks/is-set-object";
31
31
  import { isSetString } from "@stryke/type-checks/is-set-string";
32
32
  import { defu } from "defu";
33
- import { resolveEntries } from "powerlines/lib/entry";
33
+ import { tsdown } from "powerlines/tsdown";
34
+ import { resolveInputs } from "powerlines/utils";
34
35
 
35
36
  //#region src/plugin.tsx
36
37
  const MAX_DEPTH = 50;
@@ -47,10 +48,12 @@ const plugin = (options = {}) => {
47
48
  async config() {
48
49
  this.debug("Resolving the Shell Shock configuration.");
49
50
  await updatePackageJsonBinary(this);
50
- const result = defu({ output: { buildPath: joinPaths(this.config.projectRoot, "dist") } }, options, {
51
+ const result = defu({ output: { buildPath: joinPaths(this.config.root, "dist") } }, options, {
51
52
  name: getAppName(this),
52
53
  title: getAppTitle(this),
53
54
  description: getAppDescription(this),
55
+ platform: "node",
56
+ projectType: "application",
54
57
  envPrefix: constantCase(getAppName(this)),
55
58
  env: { prefix: [] },
56
59
  isCaseSensitive: false,
@@ -58,16 +61,13 @@ const plugin = (options = {}) => {
58
61
  format: "esm",
59
62
  dts: true
60
63
  },
61
- entry: !this.config.entry || Array.isArray(this.config.entry) && this.config.entry.length === 0 ? [joinPaths(this.config.sourceRoot, "**/*.ts"), joinPaths(this.config.sourceRoot, "**/*.tsx")] : void 0,
62
- build: {
63
- dts: false,
64
- platform: "node",
64
+ input: !this.config.input || Array.isArray(this.config.input) && this.config.input.length === 0 || isObject(this.config.input) && Object.keys(this.config.input).length === 0 ? [joinPaths(this.config.root, "src/**/command.ts"), joinPaths(this.config.root, "src/**/command.tsx")] : void 0,
65
+ resolve: { external: ["@powerlines/deepkit"] },
66
+ tsdown: {
67
+ dts: true,
65
68
  nodeProtocol: true,
66
- unbundle: false,
67
- noExternal: ["@powerlines/deepkit"]
68
- },
69
- type: "application",
70
- framework: "shell-shock"
69
+ unbundle: false
70
+ }
71
71
  });
72
72
  if (!result.env.prefix || !Array.isArray(result.env.prefix)) result.env.prefix = toArray(result.env.prefix);
73
73
  if (!result.env.prefix.includes(result.envPrefix)) result.env.prefix.push(result.envPrefix);
@@ -101,10 +101,10 @@ const plugin = (options = {}) => {
101
101
  async configResolved() {
102
102
  this.debug("Finding command entry point files.");
103
103
  this.commandsPath = findCommandsRoot(this);
104
- const entries = await resolveEntries(this, toArray(this.config.entry || []));
105
- this.debug(`Found ${entries.length} entry points specified in the configuration options.`);
106
- this.inputs = entries.reduce((ret, entry) => {
107
- if (!isParentPath(entry.file, this.commandsPath)) throw new Error(`Command entry point "${entry.file}" is not located within the commands root "${this.commandsPath}". Please ensure that all command entry points are located within the current project.`);
104
+ const inputs = await resolveInputs(this, this.config.input);
105
+ this.debug(`Found ${inputs.length} entry points specified in the configuration options.`);
106
+ this.inputs = inputs.reduce((ret, entry) => {
107
+ if (entry.file !== this.commandsPath && !isParentPath(entry.file, this.commandsPath)) throw new Error(`Command entry point "${entry.file}" is not located within the commands root "${this.commandsPath}". Please ensure that all command entry points are located within the current project.`);
108
108
  const id = resolveCommandId(this, entry.file);
109
109
  if (!ret.some((existing) => existing.id === id)) {
110
110
  const name = resolveCommandName(entry.file);
@@ -232,8 +232,8 @@ const plugin = (options = {}) => {
232
232
  {
233
233
  name: "shell-shock:chmod+x",
234
234
  configResolved() {
235
- this.config.build.outputOptions ??= {};
236
- this.config.build.outputOptions.banner = (chunk) => {
235
+ this.config.tsdown.outputOptions ??= {};
236
+ if (isObject(this.config.tsdown.outputOptions)) this.config.tsdown.outputOptions.banner = (chunk) => {
237
237
  if (chunk.isEntry && joinPaths(this.entryPath, "bin.ts") === chunk.facadeModuleId) {
238
238
  this.debug(`Adding hashbang to binary executable output file: ${chunk.fileName}`);
239
239
  return `#!/usr/bin/env ${this.config.mode === "development" ? "-S NODE_OPTIONS=--enable-source-maps" : ""} node\n`;
@@ -244,7 +244,7 @@ const plugin = (options = {}) => {
244
244
  async buildEnd() {
245
245
  if (!isSetObject(this.config.bin)) this.warn(`No binaries were found for the ${this.config.name} application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`);
246
246
  else await Promise.all(Object.values(this.config.bin).map(async (bin) => {
247
- const path = appendPath(bin, joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot));
247
+ const path = appendPath(bin, joinPaths(this.workspaceConfig.workspaceRoot, this.config.root));
248
248
  if (this.fs.existsSync(path)) {
249
249
  this.debug(`Adding executable permissions (chmod+x) to binary executable output file: ${path}`);
250
250
  await chmodX(path);
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.mjs","names":["For","Show","render","automd","deepkit","nodejs","tsdown","toArray","chmodX","appendPath","findFilePath","relativePath","isParentPath","joinPaths","replacePath","resolveParentPath","camelCase","constantCase","kebabCase","isSetObject","isSetString","defu","resolveEntries","CommandDocsFile","UtilsBuiltin","commands","getCommandsPersistencePath","readCommandsPersistence","writeCommandsPersistence","findCommandsRoot","reflectCommandTree","resolveCommandId","resolveCommandName","resolveCommandPath","formatBinaryPath","updatePackageJsonBinary","formatCommandTree","getDefaultOptions","validateCommand","getAppDescription","getAppName","getAppTitle","getDynamicPathSegmentName","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","types","validate","commandsPath","entries","reduce","ret","file","Error","some","existing","split","filter","Boolean","map","segment","index","found","findIndex","replace","join","input","command","prepare","_$createComponent","warn","cmd","depth","parentPath","sort","a","b","skipCache","persistedMeta","checksum","meta","fs","existsSync","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","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, 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 { 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 { UtilsBuiltin } from \"./components/utils-builtin\";\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 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 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\n if (!result.env.prefix || !Array.isArray(result.env.prefix)) {\n result.env.prefix = toArray(result.env.prefix);\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 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.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 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 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 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 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: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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,MAAM+C,YAAY;;;;AAKlB,MAAaC,UACXC,UAAmB,EAAE,KAClB;AACH,QAAO;EACL3C,QAAQ;EACRF,SAAS;EACTD,QAAQ;EACR;GACE+C,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MAAM,2CAA2C;AAEtD,UAAMjB,wBAAwB,KAAK;IAEnC,MAAMkB,SAAShC,KACb,EACEiC,QAAQ,EACNC,WAAW1C,UAAU,KAAKsC,OAAOK,aAAa,OAAM,EACtD,EACD,EACDP,SACA;KACEC,MAAMV,WAAW,K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jF,OAAOiF,KAAK;WAElB,MAAK4B,KACH,uDAAuD5B,KAAI,4GAC5D;MAGP,CAAC;;GAGN;EACD;GACEvC,MAAM;GACN8B,iBAAiB;AACf,SAAK7B,OAAOhD,WAAW,EAAE;AACzB,SAAKgD,OAAOhD,OAAOsJ,aAAa;KAC9B,GAAI,KAAKtG,OAAOhD,OAAOsJ,cAAc,EAAE;KACvChI,UAAUA,SAAS,KAAI;KACxB;;GAEH,MAAMiI,OAAO;AACX,SAAKtG,MACH,oEACD;IAED,MAAM3B,aAAW,KAAK4D,OACnBqB,KAAIO,UAASpE,eAAe,MAAMoE,MAAMvB,SAAS,CAAC,CAClDc,OAAOC,QAAyB;AAEnC,WAAOvG,OACL,MAAIkH,gBACHpH,KAAG;KAAA,IAAC2J,OAAI;AAAA,aAAErE,OAAOC,OAAO9D,WAAS;;KAAEmI,gBAAc;KAAAC,WAC/CC,UAAK1C,gBACHnH,MAAI;MAAA,IAAC8J,OAAI;AAAA,cAAE,CAACD,MAAMlE;;MAAS,IAAAiE,WAAA;AAAA,cAAAzC,gBACzB7F,iBAAe,EAAC2F,SAAS4C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAe9G"}
1
+ {"version":3,"file":"plugin.mjs","names":["For","Show","render","automd","deepkit","nodejs","toArray","chmodX","appendPath","findFilePath","relativePath","isParentPath","joinPaths","replacePath","resolveParentPath","camelCase","constantCase","kebabCase","isObject","isSetObject","isSetString","defu","tsdown","resolveInputs","CommandDocsFile","UtilsBuiltin","commands","getCommandsPersistencePath","readCommandsPersistence","writeCommandsPersistence","findCommandsRoot","reflectCommandTree","resolveCommandId","resolveCommandName","resolveCommandPath","formatBinaryPath","updatePackageJsonBinary","formatCommandTree","getDefaultOptions","validateCommand","getAppDescription","getAppName","getAppTitle","getDynamicPathSegmentName","isDynamicPathSegment","isPathSegmentGroup","getCommandTree","traverseCommands","MAX_DEPTH","plugin","options","name","config","debug","result","output","buildPath","root","title","description","platform","projectType","envPrefix","env","prefix","isCaseSensitive","format","dts","input","Array","isArray","length","Object","keys","undefined","resolve","external","nodeProtocol","unbundle","includes","push","configResolved","order","handler","bin","packageJson","inputs","values","id","path","segments","alias","isVirtual","types","validate","commandsPath","reduce","ret","entry","file","Error","some","existing","split","filter","Boolean","map","segment","index","found","findIndex","replace","join","command","prepare","_$createComponent","warn","cmd","depth","parentPath","sort","a","b","skipCache","persistedMeta","checksum","meta","fs","existsSync","option","optional","fromEntries","entries","isValid","failures","error","failure","code","details","info","outputOptions","banner","chunk","isEntry","entryPath","facadeModuleId","fileName","mode","buildEnd","Promise","all","workspaceConfig","workspaceRoot","generators","docs","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 { 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 { 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 { tsdown } from \"powerlines/tsdown\";\nimport { resolveInputs } from \"powerlines/utils\";\nimport type { OutputOptions, RenderedChunk } from \"rolldown\";\nimport { CommandDocsFile } from \"./components/docs\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\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 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 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.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 envPrefix: constantCase(getAppName(this)),\n env: {\n prefix: [] as string[]\n },\n isCaseSensitive: false,\n output: {\n format: \"esm\",\n dts: true\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 },\n tsdown: {\n dts: true,\n nodeProtocol: true,\n unbundle: false\n }\n }\n );\n\n if (!result.env.prefix || !Array.isArray(result.env.prefix)) {\n result.env.prefix = toArray(result.env.prefix);\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 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.commandsPath = findCommandsRoot(this);\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 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 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 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: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.tsdown.outputOptions ??= {} as any;\n if (isObject(this.config.tsdown.outputOptions)) {\n (\n this.config.tsdown.outputOptions as NonNullable<OutputOptions>\n ).banner = (chunk: RenderedChunk) => {\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: ${\n chunk.fileName\n }`\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 },\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(this.workspaceConfig.workspaceRoot, this.config.root)\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EA,MAAMgD,YAAY;;;;AAKlB,MAAaC,UACXC,UAAmB,EAAE,KAClB;AACH,QAAO;EACL5B,QAAQ;EACRlB,SAAS;EACTD,QAAQ;EACR;GACEgD,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MAAM,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n!a\"4#&4$8)4%&F4&8Mw'y"
50
51
  ];
51
52
  const __ΩNumberCommandParameter = [
52
53
  () => __ΩBaseCommandParameter,
@@ -54,8 +55,9 @@ const __ΩNumberCommandParameter = [
54
55
  "kind",
55
56
  "default",
56
57
  "variadic",
58
+ "choices",
57
59
  "NumberCommandParameter",
58
- "Pn!a\"4#'4$8)4%Mw&y"
60
+ "Pn!a\"4#'4$8)4%'F4&8Mw'y"
59
61
  ];
60
62
  const __ΩBooleanCommandParameter = [
61
63
  () => __ΩBaseCommandParameter,
@@ -209,12 +211,18 @@ const __ΩMetadata = [
209
211
  "Metadata",
210
212
  "P&4!8&4\"8P&&FJ4#8&4$8Mw%y"
211
213
  ];
214
+ const __ΩCommandParameterSchema = ["CommandParameterSchema", "P!!Jw!y"];
212
215
  const __ΩCommandModule = [
213
216
  () => __ΩMetadata,
214
217
  "metadata",
218
+ () => __ΩRecord,
219
+ () => __ΩCommandParameterSchema,
220
+ "options",
221
+ () => __ΩCommandParameterSchema,
222
+ "arguments",
215
223
  "default",
216
224
  "CommandModule",
217
- "Pn!4\"8!4#8Mw$y"
225
+ "Pn!4\"8&n$o##4%8n&F4'8!4(8Mw)y"
218
226
  ];
219
227
 
220
228
  //#endregion
@@ -227,6 +235,7 @@ exports.__ΩCommandBase = __ΩCommandBase;
227
235
  exports.__ΩCommandInput = __ΩCommandInput;
228
236
  exports.__ΩCommandModule = __ΩCommandModule;
229
237
  exports.__ΩCommandOption = __ΩCommandOption;
238
+ exports.__ΩCommandParameterSchema = __ΩCommandParameterSchema;
230
239
  exports.__ΩCommandTree = __ΩCommandTree;
231
240
  exports.__ΩMetadata = __ΩMetadata;
232
241
  exports.__ΩNumberCommandArgument = __ΩNumberCommandArgument;