@shell-shock/core 0.8.10 → 0.8.12

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 (43) hide show
  1. package/dist/components/docs.d.cts +5 -5
  2. package/dist/components/docs.d.mts +5 -5
  3. package/dist/components/docs.d.mts.map +1 -1
  4. package/dist/components/helpers.cjs +47 -0
  5. package/dist/components/helpers.cjs.map +1 -1
  6. package/dist/components/helpers.d.cts +25 -3
  7. package/dist/components/helpers.d.cts.map +1 -1
  8. package/dist/components/helpers.d.mts +25 -3
  9. package/dist/components/helpers.d.mts.map +1 -1
  10. package/dist/components/helpers.mjs +44 -1
  11. package/dist/components/helpers.mjs.map +1 -1
  12. package/dist/components/index.cjs +12 -1
  13. package/dist/components/index.d.cts +3 -2
  14. package/dist/components/index.d.mts +3 -2
  15. package/dist/components/index.mjs +3 -2
  16. package/dist/components/options-parser-logic.d.cts +9 -9
  17. package/dist/components/options-parser-logic.d.cts.map +1 -1
  18. package/dist/components/options-parser-logic.d.mts +9 -9
  19. package/dist/components/usage.d.cts +2 -2
  20. package/dist/components/usage.d.cts.map +1 -1
  21. package/dist/components/usage.d.mts +2 -2
  22. package/dist/components/usage.d.mts.map +1 -1
  23. package/dist/components/utils-builtin.cjs +572 -0
  24. package/dist/components/utils-builtin.cjs.map +1 -0
  25. package/dist/components/utils-builtin.d.cts +29 -0
  26. package/dist/components/utils-builtin.d.cts.map +1 -0
  27. package/dist/components/utils-builtin.d.mts +29 -0
  28. package/dist/components/utils-builtin.d.mts.map +1 -0
  29. package/dist/components/utils-builtin.mjs +565 -0
  30. package/dist/components/utils-builtin.mjs.map +1 -0
  31. package/dist/plugin-utils/context-helpers.cjs +1 -1
  32. package/dist/plugin-utils/context-helpers.cjs.map +1 -1
  33. package/dist/plugin-utils/context-helpers.d.cts.map +1 -1
  34. package/dist/plugin-utils/context-helpers.d.mts.map +1 -1
  35. package/dist/plugin-utils/context-helpers.mjs +1 -1
  36. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  37. package/dist/plugin.cjs +5 -0
  38. package/dist/plugin.cjs.map +1 -1
  39. package/dist/plugin.d.cts.map +1 -1
  40. package/dist/plugin.d.mts.map +1 -1
  41. package/dist/plugin.mjs +5 -0
  42. package/dist/plugin.mjs.map +1 -1
  43. package/package.json +25 -11
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.cjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","replaceCLI","title","replace","getAppDescription","description","getAppBin","Object","keys","isDynamicPathSegment","path","startsWith","endsWith","getDynamicPathSegmentName","replaceAll","isPathSegmentGroup","getPathSegmentGroupName","getPathSegmentName"],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @param replaceCLI - Whether to replace CLI-related terms in the title with the application name.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(\n context: UnresolvedContext | Context,\n replaceCLI = false\n): string {\n const title =\n context.config.title ||\n titleCase(context.config.name || getAppName(context));\n\n return replaceCLI\n ? title.replace(\n /(?:cli|command-line|command line)\\s*(?:interface\\s*)?(?:application|app)?$/gi,\n \"\"\n )\n : title;\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context, true)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @example\n * ```typescript\n * isDynamicPathSegment(\"[user]\"); // true\n * isDynamicPathSegment(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isDynamicPathSegment(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getDynamicPathSegmentName(path: string): string {\n return path.replaceAll(/^\\[+/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n\n/**\n * Determines if a given command path segment is a path segment group (enclosed in parentheses).\n *\n * @example\n * ```typescript\n * isPathSegmentGroup(\"(user)\"); // true\n * isPathSegmentGroup(\"[user]\"); // false\n * isPathSegmentGroup(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a path segment group, false otherwise.\n */\nexport function isPathSegmentGroup(path: string): boolean {\n return (path.startsWith(\"(\") && path.endsWith(\")\")) || path.startsWith(\"_\");\n}\n\n/**\n * Extracts the group name from a command path segment by removing enclosing parentheses.\n *\n * @example\n * ```typescript\n * getPathSegmentGroupName(\"(admin)\"); // \"admin\"\n * getPathSegmentGroupName(\"((group))\"); // \"group\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The group name without parentheses.\n */\nexport function getPathSegmentGroupName(path: string): string {\n return path\n .replaceAll(/^\\(+/g, \"\")\n .replaceAll(/\\)+$/g, \"\")\n .replaceAll(/^_+/g, \"\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPathSegmentName(path: string): string {\n return getPathSegmentGroupName(getDynamicPathSegmentName(path));\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAA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AC9D,QAAOA,KAAKI,WAAW,SAAS,GAAG,CAACA,WAAW,SAAS,GAAG;;;;;;;;;;;;;;;AAgB7D,SAAgBC,mBAAmBL,MAAuB;AACxD,QAAQA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI,IAAKF,KAAKC,WAAW,IAAI;;;;;;;;;;;;;;AAe7E,SAAgBK,wBAAwBN,MAAsB;AAC5D,QAAOA,KACJI,WAAW,SAAS,GAAG,CACvBA,WAAW,SAAS,GAAG,CACvBA,WAAW,QAAQ,GAAG;;;;;;;;;;;;;AAc3B,SAAgBG,mBAAmBP,MAAsB;AACvD,QAAOM,wBAAwBH,0BAA0BH,KAAK,CAAC"}
1
+ {"version":3,"file":"context-helpers.cjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","replaceCLI","title","replace","trim","getAppDescription","description","getAppBin","Object","keys","isDynamicPathSegment","path","startsWith","endsWith","getDynamicPathSegmentName","replaceAll","isPathSegmentGroup","getPathSegmentGroupName","getPathSegmentName"],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @param replaceCLI - Whether to replace CLI-related terms in the title with the application name.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(\n context: UnresolvedContext | Context,\n replaceCLI = false\n): string {\n const title =\n context.config.title ||\n titleCase(context.config.name || getAppName(context));\n\n return (\n replaceCLI\n ? title.replace(\n /(?:cli|command-line|command line)\\s*(?:interface\\s*)?(?:application|app)?$/gi,\n \"\"\n )\n : title\n ).trim();\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context, true)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @example\n * ```typescript\n * isDynamicPathSegment(\"[user]\"); // true\n * isDynamicPathSegment(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isDynamicPathSegment(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getDynamicPathSegmentName(path: string): string {\n return path.replaceAll(/^\\[+/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n\n/**\n * Determines if a given command path segment is a path segment group (enclosed in parentheses).\n *\n * @example\n * ```typescript\n * isPathSegmentGroup(\"(user)\"); // true\n * isPathSegmentGroup(\"[user]\"); // false\n * isPathSegmentGroup(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a path segment group, false otherwise.\n */\nexport function isPathSegmentGroup(path: string): boolean {\n return (path.startsWith(\"(\") && path.endsWith(\")\")) || path.startsWith(\"_\");\n}\n\n/**\n * Extracts the group name from a command path segment by removing enclosing parentheses.\n *\n * @example\n * ```typescript\n * getPathSegmentGroupName(\"(admin)\"); // \"admin\"\n * getPathSegmentGroupName(\"((group))\"); // \"group\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The group name without parentheses.\n */\nexport function getPathSegmentGroupName(path: string): string {\n return path\n .replaceAll(/^\\(+/g, \"\")\n .replaceAll(/\\)+$/g, \"\")\n .replaceAll(/^_+/g, \"\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPathSegmentName(path: string): string {\n return getPathSegmentGroupName(getDynamicPathSegmentName(path));\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE,MAAMT,SACJS,QAAQC,OAAOC,6DACFF,QAAQC,OAAOE,IAAI,IAC/BC,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,yDAChBU,QAAQC,OAAOE,IAAI,GAAI,uDACrBH,QAAQC,OAAOE,IAAI,GAC7BH,QAAQC,OAAOE,MACfH,QAAQC,OAAOE,IAAI,KACrBH,QAAQM,aAAaJ;AAC3B,KAAI,qDAAaX,OAAO,CACtB,OAAM,IAAIgB,MACR,qIACD;AAGH,yDAAiBhB,OAAO;;;;;;;;;AAU1B,SAAgBiB,YACdR,SACAS,aAAa,OACL;CACR,MAAMC,QACJV,QAAQC,OAAOS,0DACLV,QAAQC,OAAOC,QAAQH,WAAWC,QAAQ,CAAC;AAEvD,SACES,aACIC,MAAMC,QACJ,gFACA,GACD,GACDD,OACJE,MAAM;;;;;;;;AASV,SAAgBC,kBACdb,SACQ;AACR,QACEA,QAAQC,OAAOa,eACfd,QAAQM,aAAaQ,eACrB,OAAON,YAAYR,SAAS,KAAK,CAAA;;;;;;;;AAUrC,SAAgBe,UAAUf,SAA0B;AAClD,4DAAmBA,QAAQC,OAAOE,IAAI,GAClCa,OAAOC,KAAKjB,QAAQC,OAAOE,IAAI,CAAC,sDACtBJ,WAAWC,QAAQ,CAAC;;;;;;;;;;;;;;AAepC,SAAgBkB,qBAAqBC,MAAuB;AAC1D,QAAOA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI;;;;;;;;;;;;;AAcnD,SAAgBC,0BAA0BH,MAAsB;AAC9D,QAAOA,KAAKI,WAAW,SAAS,GAAG,CAACA,WAAW,SAAS,GAAG;;;;;;;;;;;;;;;AAgB7D,SAAgBC,mBAAmBL,MAAuB;AACxD,QAAQA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI,IAAKF,KAAKC,WAAW,IAAI;;;;;;;;;;;;;;AAe7E,SAAgBK,wBAAwBN,MAAsB;AAC5D,QAAOA,KACJI,WAAW,SAAS,GAAG,CACvBA,WAAW,SAAS,GAAG,CACvBA,WAAW,QAAQ,GAAG;;;;;;;;;;;;;AAc3B,SAAgBG,mBAAmBP,MAAsB;AACvD,QAAOM,wBAAwBH,0BAA0BH,KAAK,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.d.cts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA2BA;AAsBgB,iBAnEA,cAAA,CAoEL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAkBA;AAeA;AAiBA;AAgBA;AAkBA;;iBArJgB,UAAA,UAAoB,oBAAoB;;;;;;;;iBA2BxC,WAAA,UACL,oBAAoB;;;;;;;iBAqBf,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;;;;;;;iBAkBnB,oBAAA;;;;;;;;;;;;iBAeA,yBAAA;;;;;;;;;;;;;;iBAiBA,kBAAA;;;;;;;;;;;;;iBAgBA,uBAAA;;;;;;;;;;;;iBAkBA,kBAAA"}
1
+ {"version":3,"file":"context-helpers.d.cts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA2BA;AAwBgB,iBArEA,cAAA,CAsEL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAkBA;AAeA;AAiBA;AAgBA;AAkBA;;iBAvJgB,UAAA,UAAoB,oBAAoB;;;;;;;;iBA2BxC,WAAA,UACL,oBAAoB;;;;;;;iBAuBf,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;;;;;;;iBAkBnB,oBAAA;;;;;;;;;;;;iBAeA,yBAAA;;;;;;;;;;;;;;iBAiBA,kBAAA;;;;;;;;;;;;;iBAgBA,uBAAA;;;;;;;;;;;;iBAkBA,kBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.d.mts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA2BA;AAsBgB,iBAnEA,cAAA,CAoEL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAkBA;AAeA;AAiBA;AAgBA;AAkBA;;iBArJgB,UAAA,UAAoB,oBAAoB;;;;;;;;iBA2BxC,WAAA,UACL,oBAAoB;;;;;;;iBAqBf,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;;;;;;;iBAkBnB,oBAAA;;;;;;;;;;;;iBAeA,yBAAA;;;;;;;;;;;;;;iBAiBA,kBAAA;;;;;;;;;;;;;iBAgBA,uBAAA;;;;;;;;;;;;iBAkBA,kBAAA"}
1
+ {"version":3,"file":"context-helpers.d.mts","names":[],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAkBA;AA2BA;AAwBgB,iBArEA,cAAA,CAsEL,OAAA,EAAA,MAAA,EAAoB,CAAA,EAAA,MAAO,EAAA;AAetC;AAkBA;AAeA;AAiBA;AAgBA;AAkBA;;iBAvJgB,UAAA,UAAoB,oBAAoB;;;;;;;;iBA2BxC,WAAA,UACL,oBAAoB;;;;;;;iBAuBf,iBAAA,UACL,oBAAoB;;;;;;;iBAef,SAAA,UAAmB;;;;;;;;;;;;;iBAkBnB,oBAAA;;;;;;;;;;;;iBAeA,yBAAA;;;;;;;;;;;;;;iBAiBA,kBAAA;;;;;;;;;;;;;iBAgBA,uBAAA;;;;;;;;;;;;iBAkBA,kBAAA"}
@@ -37,7 +37,7 @@ function getAppName(context) {
37
37
  */
38
38
  function getAppTitle(context, replaceCLI = false) {
39
39
  const title = context.config.title || titleCase(context.config.name || getAppName(context));
40
- return replaceCLI ? title.replace(/(?:cli|command-line|command line)\s*(?:interface\s*)?(?:application|app)?$/gi, "") : title;
40
+ return (replaceCLI ? title.replace(/(?:cli|command-line|command line)\s*(?:interface\s*)?(?:application|app)?$/gi, "") : title).trim();
41
41
  }
42
42
  /**
43
43
  * Retrieves the application description from the context and configuration.
@@ -1 +1 @@
1
- {"version":3,"file":"context-helpers.mjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","replaceCLI","title","replace","getAppDescription","description","getAppBin","Object","keys","isDynamicPathSegment","path","startsWith","endsWith","getDynamicPathSegmentName","replaceAll","isPathSegmentGroup","getPathSegmentGroupName","getPathSegmentName"],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @param replaceCLI - Whether to replace CLI-related terms in the title with the application name.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(\n context: UnresolvedContext | Context,\n replaceCLI = false\n): string {\n const title =\n context.config.title ||\n titleCase(context.config.name || getAppName(context));\n\n return replaceCLI\n ? title.replace(\n /(?:cli|command-line|command line)\\s*(?:interface\\s*)?(?:application|app)?$/gi,\n \"\"\n )\n : title;\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context, true)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @example\n * ```typescript\n * isDynamicPathSegment(\"[user]\"); // true\n * isDynamicPathSegment(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isDynamicPathSegment(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getDynamicPathSegmentName(path: string): string {\n return path.replaceAll(/^\\[+/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n\n/**\n * Determines if a given command path segment is a path segment group (enclosed in parentheses).\n *\n * @example\n * ```typescript\n * isPathSegmentGroup(\"(user)\"); // true\n * isPathSegmentGroup(\"[user]\"); // false\n * isPathSegmentGroup(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a path segment group, false otherwise.\n */\nexport function isPathSegmentGroup(path: string): boolean {\n return (path.startsWith(\"(\") && path.endsWith(\")\")) || path.startsWith(\"_\");\n}\n\n/**\n * Extracts the group name from a command path segment by removing enclosing parentheses.\n *\n * @example\n * ```typescript\n * getPathSegmentGroupName(\"(admin)\"); // \"admin\"\n * getPathSegmentGroupName(\"((group))\"); // \"group\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The group name without parentheses.\n */\nexport function getPathSegmentGroupName(path: string): string {\n return path\n .replaceAll(/^\\(+/g, \"\")\n .replaceAll(/\\)+$/g, \"\")\n .replaceAll(/^_+/g, \"\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPathSegmentName(path: string): string {\n return getPathSegmentGroupName(getDynamicPathSegmentName(path));\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE,MAAMT,SACJS,QAAQC,OAAOC,SACdf,YAAYa,QAAQC,OAAOE,IAAI,IAC/BC,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,KAC5BH,YAAYa,QAAQC,OAAOE,IAAI,GAAI,GACjChB,YAAYa,QAAQC,OAAOE,IAAI,GAC7BH,QAAQC,OAAOE,MACfH,QAAQC,OAAOE,IAAI,KACrBH,QAAQM,aAAaJ;AAC3B,KAAI,CAACf,YAAYI,OAAO,CACtB,OAAM,IAAIgB,MACR,qIACD;AAGH,QAAOvB,UAAUO,OAAO;;;;;;;;;AAU1B,SAAgBiB,YACdR,SACAS,aAAa,OACL;CACR,MAAMC,QACJV,QAAQC,OAAOS,SACfzB,UAAUe,QAAQC,OAAOC,QAAQH,WAAWC,QAAQ,CAAC;AAEvD,QAAOS,aACHC,MAAMC,QACJ,gFACA,GACD,GACDD;;;;;;;;AASN,SAAgBE,kBACdZ,SACQ;AACR,QACEA,QAAQC,OAAOY,eACfb,QAAQM,aAAaO,eACrB,OAAOL,YAAYR,SAAS,KAAK,CAAA;;;;;;;;AAUrC,SAAgBc,UAAUd,SAA0B;AAClD,QAAOd,YAAYc,QAAQC,OAAOE,IAAI,GAClCY,OAAOC,KAAKhB,QAAQC,OAAOE,IAAI,CAAC,KAChCnB,UAAUe,WAAWC,QAAQ,CAAC;;;;;;;;;;;;;;AAepC,SAAgBiB,qBAAqBC,MAAuB;AAC1D,QAAOA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI;;;;;;;;;;;;;AAcnD,SAAgBC,0BAA0BH,MAAsB;AAC9D,QAAOA,KAAKI,WAAW,SAAS,GAAG,CAACA,WAAW,SAAS,GAAG;;;;;;;;;;;;;;;AAgB7D,SAAgBC,mBAAmBL,MAAuB;AACxD,QAAQA,KAAKC,WAAW,IAAI,IAAID,KAAKE,SAAS,IAAI,IAAKF,KAAKC,WAAW,IAAI;;;;;;;;;;;;;;AAe7E,SAAgBK,wBAAwBN,MAAsB;AAC5D,QAAOA,KACJI,WAAW,SAAS,GAAG,CACvBA,WAAW,SAAS,GAAG,CACvBA,WAAW,QAAQ,GAAG;;;;;;;;;;;;;AAc3B,SAAgBG,mBAAmBP,MAAsB;AACvD,QAAOM,wBAAwBH,0BAA0BH,KAAK,CAAC"}
1
+ {"version":3,"file":"context-helpers.mjs","names":["kebabCase","titleCase","isSetObject","isSetString","sortArgAliases","aliases","length","result","filter","alias","push","sort","a","b","localeCompare","getAppName","context","config","name","bin","Array","isArray","packageJson","Error","getAppTitle","replaceCLI","title","replace","trim","getAppDescription","description","getAppBin","Object","keys","isDynamicPathSegment","path","startsWith","endsWith","getDynamicPathSegmentName","replaceAll","isPathSegmentGroup","getPathSegmentGroupName","getPathSegmentName"],"sources":["../../src/plugin-utils/context-helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { Context, UnresolvedContext } from \"../types\";\n\n/**\n * Sorts command argument aliases, placing single-character aliases first, followed by multi-character aliases, and then sorting them alphabetically.\n *\n * @param aliases - An array of argument aliases to sort.\n * @returns A new array of sorted aliases.\n */\nexport function sortArgAliases(aliases: string[]): string[] {\n if (aliases.length === 0) {\n return [];\n }\n\n const result = aliases.filter(alias => alias.length === 1);\n result.push(...aliases.filter(alias => alias.length > 1));\n\n return result.sort((a, b) => a.localeCompare(b));\n}\n\n/**\n * Retrieves the application name from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application name in kebab-case format.\n * @throws An error if no valid application name is found.\n */\nexport function getAppName(context: UnresolvedContext | Context): string {\n const result =\n context.config.name ||\n (isSetString(context.config.bin) ||\n (Array.isArray(context.config.bin) &&\n context.config.bin.length > 0 &&\n isSetString(context.config.bin[0]))\n ? isSetString(context.config.bin)\n ? context.config.bin\n : context.config.bin[0]\n : context.packageJson?.name);\n if (!isSetString(result)) {\n throw new Error(\n \"No application name found. Please provide a 'bin' option in the configuration or ensure the package.json has a valid 'name' field.\"\n );\n }\n\n return kebabCase(result);\n}\n\n/**\n * Retrieves the application title from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @param replaceCLI - Whether to replace CLI-related terms in the title with the application name.\n * @returns The application title in title-case format.\n */\nexport function getAppTitle(\n context: UnresolvedContext | Context,\n replaceCLI = false\n): string {\n const title =\n context.config.title ||\n titleCase(context.config.name || getAppName(context));\n\n return (\n replaceCLI\n ? title.replace(\n /(?:cli|command-line|command line)\\s*(?:interface\\s*)?(?:application|app)?$/gi,\n \"\"\n )\n : title\n ).trim();\n}\n\n/**\n * Retrieves the application description from the context and configuration.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The application description.\n */\nexport function getAppDescription(\n context: UnresolvedContext | Context\n): string {\n return (\n context.config.description ||\n context.packageJson?.description ||\n `The ${getAppTitle(context, true)} command-line interface application.`\n );\n}\n\n/**\n * Retrieves the primary binary name for the application.\n *\n * @param context - The build context containing workspace and package information.\n * @returns The primary binary name as a string.\n */\nexport function getAppBin(context: Context): string {\n return isSetObject(context.config.bin)\n ? Object.keys(context.config.bin)[0]!\n : kebabCase(getAppName(context));\n}\n\n/**\n * Determines if a given command path segment is variable (enclosed in square brackets).\n *\n * @example\n * ```typescript\n * isDynamicPathSegment(\"[user]\"); // true\n * isDynamicPathSegment(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is variable, false otherwise.\n */\nexport function isDynamicPathSegment(path: string): boolean {\n return path.startsWith(\"[\") && path.endsWith(\"]\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getDynamicPathSegmentName(path: string): string {\n return path.replaceAll(/^\\[+/g, \"\").replaceAll(/\\]+$/g, \"\");\n}\n\n/**\n * Determines if a given command path segment is a path segment group (enclosed in parentheses).\n *\n * @example\n * ```typescript\n * isPathSegmentGroup(\"(user)\"); // true\n * isPathSegmentGroup(\"[user]\"); // false\n * isPathSegmentGroup(\"user\"); // false\n * ```\n *\n * @param path - The command path segment to check.\n * @returns True if the path is a path segment group, false otherwise.\n */\nexport function isPathSegmentGroup(path: string): boolean {\n return (path.startsWith(\"(\") && path.endsWith(\")\")) || path.startsWith(\"_\");\n}\n\n/**\n * Extracts the group name from a command path segment by removing enclosing parentheses.\n *\n * @example\n * ```typescript\n * getPathSegmentGroupName(\"(admin)\"); // \"admin\"\n * getPathSegmentGroupName(\"((group))\"); // \"group\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The group name without parentheses.\n */\nexport function getPathSegmentGroupName(path: string): string {\n return path\n .replaceAll(/^\\(+/g, \"\")\n .replaceAll(/\\)+$/g, \"\")\n .replaceAll(/^_+/g, \"\");\n}\n\n/**\n * Extracts the variable name from a command path segment by removing enclosing square brackets.\n *\n * @example\n * ```typescript\n * getDynamicPathSegmentName(\"[user]\"); // \"user\"\n * ```\n *\n * @param path - The command path segment.\n * @returns The variable name without square brackets.\n */\nexport function getPathSegmentName(path: string): string {\n return getPathSegmentGroupName(getDynamicPathSegmentName(path));\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAgBI,eAAeC,SAA6B;AAC1D,KAAIA,QAAQC,WAAW,EACrB,QAAO,EAAE;CAGX,MAAMC,SAASF,QAAQG,QAAOC,UAASA,MAAMH,WAAW,EAAE;AAC1DC,QAAOG,KAAK,GAAGL,QAAQG,QAAOC,UAASA,MAAMH,SAAS,EAAE,CAAC;AAEzD,QAAOC,OAAOI,MAAMC,GAAGC,MAAMD,EAAEE,cAAcD,EAAE,CAAC;;;;;;;;;AAUlD,SAAgBE,WAAWC,SAA8C;CACvE,MAAMT,SACJS,QAAQC,OAAOC,SACdf,YAAYa,QAAQC,OAAOE,IAAI,IAC/BC,MAAMC,QAAQL,QAAQC,OAAOE,IAAI,IAChCH,QAAQC,OAAOE,IAAIb,SAAS,KAC5BH,YAAYa,QAAQC,OAAOE,IAAI,GAAI,GACjChB,YAAYa,QAAQC,OAAOE,IAAI,GAC7BH,QAAQC,OAAOE,MACfH,QAAQC,OAAOE,IAAI,KACrBH,QAAQM,aAAaJ;AAC3B,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olldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
3
  const require_plugin_utils_context_helpers = require('./plugin-utils/context-helpers.cjs');
4
4
  const require_components_docs = require('./components/docs.cjs');
5
+ const require_components_utils_builtin = require('./components/utils-builtin.cjs');
5
6
  const require_plugin_utils_get_command_tree = require('./plugin-utils/get-command-tree.cjs');
6
7
  const require_plugin_utils_traverse_command_tree = require('./plugin-utils/traverse-command-tree.cjs');
7
8
  const require_automd = require('./helpers/automd.cjs');
@@ -136,6 +137,10 @@ const plugin = (options = {}) => {
136
137
  return ret;
137
138
  }, this.inputs);
138
139
  this.debug(`Shell Shock will process ${this.inputs.length} command entry files: \n${this.inputs.map((command) => ` - ${command.id}: ${(0, __stryke_path_replace.replacePath)(command.entry.file, this.commandsPath)}`).join("\n")}`);
140
+ },
141
+ async prepare() {
142
+ this.debug("Rendering base built-in modules for the Shell Shock application.");
143
+ return (0, __powerlines_plugin_alloy_render.render)(this, [(0, __alloy_js_core_jsx_runtime.createComponent)(require_components_utils_builtin.UtilsBuiltin, {})]);
139
144
  }
140
145
  },
141
146
  {
@@ -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","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","commandsPath","entries","reduce","ret","file","Error","some","existing","split","filter","Boolean","map","segment","index","found","findIndex","replace","join","input","command","warn","cmd","depth","parentPath","sort","a","b","prepare","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","_$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, 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 { 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 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 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 },\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAM8C,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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MC,WAAW;AACf,QAAI,qDAAa,KAAK9F,OAAOgC,IAAI,CAC/B,MAAK8B,KACH,kCACE,KAAK9D,OAAOD,KAAI,sHAEnB;QAED,OAAMgG,QAAQC,IACZ7D,OAAOC,OAAO,KAAKpC,OAAOgC,IAAI,CAACqB,IAAI,OAAMrB,QAAO;KAC9C,MAAMM,4CACJN,6CAEE,KAAKiE,gBAAgBC,eACrB,KAAKlG,OAAOK,YAEhB,CAAC;AAED,SAAI,KAAKqE,GAAGC,WAAWrC,KAAK,EAAE;AAC5B,WAAKrC,MACH,6EAA6EqC,OAC9E;AAED,4CAAaA,KAAK;WAElB,MAAKwB,KACH,uDAAuDxB,KAAI,4GAC5D;MAGP,CAAC;;GAGN;EACD;GACEvC,MAAM;GACN8B,iBAAiB;AACf,SAAK7B,OAAO/C,WAAW,EAAE;AACzB,SAAK+C,OAAO/C,OAAOkJ,aAAa;KAC9B,GAAI,KAAKnG,OAAO/C,OAAOkJ,cAAc,EAAE;KACvC7H,UAAUA,wBAAS,KAAI;KACxB;;GAEH,MAAM8H,OAAO;AACX,SAAKnG,MACH,oEACD;IAED,MAAM3B,aAAW,KAAK4D,OACnBmB,KAAIO,UAASlE,qDAAe,MAAMkE,MAAMrB,SAAS,CAAC,CAClDY,OAAOC,QAAyB;AAEnC,wDACE,uDACCtG,gCAAG;KAAA,IAACwJ,OAAI;AAAA,aAAEnE,OAAOC,OAAO9D,WAAS;;KAAEiI,gBAAc;KAAAC,WAC/CC,2DACE1J,iCAAI;MAAA,IAAC2J,OAAI;AAAA,cAAE,CAACD,MAAMhE;;MAAS,IAAA+D,WAAA;AAAA,+DACzBnI,yCAAe,EAACwF,SAAS4C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAe5G"}
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","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 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 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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,GAAI,KAAKpG,OAAOhD,OAAOoJ,cAAc,EAAE;KACvC9H,UAAUA,wBAAS,KAAI;KACxB;;GAEH,MAAM+H,OAAO;AACX,SAAKpG,MACH,oEACD;IAED,MAAM3B,aAAW,KAAK4D,OACnBmB,KAAIO,UAASlE,qDAAe,MAAMkE,MAAMrB,SAAS,CAAC,CAClDY,OAAOC,QAAyB;AAEnC,wDACE,uDACCvG,gCAAG;KAAA,IAACyJ,OAAI;AAAA,aAAEnE,OAAOC,OAAO9D,WAAS;;KAAEiI,gBAAc;KAAAC,WAC/CC,2DACE3J,iCAAI;MAAA,IAAC4J,OAAI;AAAA,cAAE,CAACD,MAAMhE;;MAAS,IAAA+D,WAAA;AAAA,+DACzBpI,yCAAe,EAACyF,SAAS4C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAe5G"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAgFA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GA6djC,MA7diC,CA6d1B,QA7d0B,CAAA,EAAA"}
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,GAyejC,MAzeiC,CAye1B,QAze0B,CAAA,EAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AAgFA;AAAwC,cAA3B,MAA2B,EAAA,CAAA,iBAAA,OAAA,GAAU,OAAV,CAAA,CAAA,OAAA,CAAA,EAC7B,OAD6B,EAAA,GA6djC,MA7diC,CA6d1B,QA7d0B,CAAA,EAAA"}
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,GAyejC,MAzeiC,CAye1B,QAze0B,CAAA,EAAA"}
package/dist/plugin.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { getAppDescription, getAppName, getAppTitle, getDynamicPathSegmentName, isDynamicPathSegment, isPathSegmentGroup } from "./plugin-utils/context-helpers.mjs";
2
2
  import { CommandDocsFile } from "./components/docs.mjs";
3
+ import { UtilsBuiltin } from "./components/utils-builtin.mjs";
3
4
  import { getCommandTree } from "./plugin-utils/get-command-tree.mjs";
4
5
  import { traverseCommands } from "./plugin-utils/traverse-command-tree.mjs";
5
6
  import { commands } from "./helpers/automd.mjs";
@@ -130,6 +131,10 @@ const plugin = (options = {}) => {
130
131
  return ret;
131
132
  }, this.inputs);
132
133
  this.debug(`Shell Shock will process ${this.inputs.length} command entry files: \n${this.inputs.map((command) => ` - ${command.id}: ${replacePath(command.entry.file, this.commandsPath)}`).join("\n")}`);
134
+ },
135
+ async prepare() {
136
+ this.debug("Rendering base built-in modules for the Shell Shock application.");
137
+ return render(this, [createComponent(UtilsBuiltin, {})]);
133
138
  }
134
139
  },
135
140
  {
@@ -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","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","commandsPath","entries","reduce","ret","file","Error","some","existing","split","filter","Boolean","map","segment","index","found","findIndex","replace","join","input","command","warn","cmd","depth","parentPath","sort","a","b","prepare","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","_$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, 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 { 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 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 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 },\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,MAAM8C,YAAY;;;;AAKlB,MAAaC,UACXC,UAAmB,EAAE,KAClB;AACH,QAAO;EACL1C,QAAQ;EACRF,SAAS;EACTD,QAAQ;EACR;GACE8C,MAAM;GACN,MAAMC,SAAS;AACb,SAAKC,MAAM,2CAA2C;AAEtD,UAAMjB,wBAAwB,KAAK;IAEnC,MAAMkB,SAAS/B,KACb,EACEgC,QAAQ,EACNC,WAAWzC,UAAU,KAAKqC,OAAOK,aAAa,OAAM,EACtD,EACD,EACDP,SACA;KACEC,MAAMV,WAAW,KAAK;KACtBiB,OAAOhB,YAAY,KAAK;KACxBiB,aAAanB,kBAAkB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AAMrB,SAAS,CAAC,CAClDY,OAAOC,QAAyB;AAEnC,WAAOpG,OACL,MAAIqJ,gBACHvJ,KAAG;KAAA,IAACwJ,OAAI;AAAA,aAAEnE,OAAOC,OAAO9D,WAAS;;KAAEiI,gBAAc;KAAAC,WAC/CC,UAAKJ,gBACHtJ,MAAI;MAAA,IAAC2J,OAAI;AAAA,cAAE,CAACD,MAAMhE;;MAAS,IAAA+D,WAAA;AAAA,cAAAH,gBACzBhI,iBAAe,EAACwF,SAAS4C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAe5G"}
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","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 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 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,KAAK;KACtBiB,OAAOhB,YAAY,KAAK;KACxBiB,aAAanB,kBAAkB,KAAK;KACpCoB,WAAW1C,aAAauB,WAAW,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,CACEvD,UAAU,KAAKsC,OAAOkB,YAAY,UAAU,EAC5CxD,UAAU,KAAKsC,OAAOkB,YAAY,WAAW,CAC9C,GACDC;KACNC,OAAO;MACLP,KAAK;MACLQ,UAA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BACzB3F,iBAAe,EAACyF,SAAS4C,OAAK,CAAA;;MAAA,CAAA;KAElC,CAEL,CAAC;;GAEJ;EACF;;AAIH,qBAAe5G"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shell-shock/core",
3
- "version": "0.8.10",
3
+ "version": "0.8.12",
4
4
  "type": "module",
5
5
  "description": "A package containing the core Shell Shock functionality used to build and manage a command-line application.",
6
6
  "repository": {
@@ -130,6 +130,20 @@
130
130
  "default": "./dist/components/usage.mjs"
131
131
  }
132
132
  },
133
+ "./components/utils-builtin": {
134
+ "require": {
135
+ "types": "./dist/components/utils-builtin.d.cts",
136
+ "default": "./dist/components/utils-builtin.cjs"
137
+ },
138
+ "import": {
139
+ "types": "./dist/components/utils-builtin.d.mts",
140
+ "default": "./dist/components/utils-builtin.mjs"
141
+ },
142
+ "default": {
143
+ "types": "./dist/components/utils-builtin.d.mts",
144
+ "default": "./dist/components/utils-builtin.mjs"
145
+ }
146
+ },
133
147
  "./config": {
134
148
  "require": {
135
149
  "types": "./dist/config.d.cts",
@@ -364,28 +378,28 @@
364
378
  "@alloy-js/core": "0.23.0-dev.8",
365
379
  "@alloy-js/markdown": "0.23.0-dev.1",
366
380
  "@alloy-js/typescript": "0.23.0-dev.4",
367
- "@powerlines/deepkit": "^0.6.65",
368
- "@powerlines/plugin-alloy": "^0.23.15",
369
- "@powerlines/plugin-automd": "^0.1.285",
370
- "@powerlines/plugin-deepkit": "^0.11.164",
371
- "@powerlines/plugin-nodejs": "^0.1.199",
372
- "@powerlines/plugin-plugin": "^0.12.236",
373
- "@powerlines/plugin-tsdown": "^0.1.238",
381
+ "@powerlines/deepkit": "^0.6.66",
382
+ "@powerlines/plugin-alloy": "0.23.16",
383
+ "@powerlines/plugin-automd": "^0.1.286",
384
+ "@powerlines/plugin-deepkit": "^0.11.165",
385
+ "@powerlines/plugin-nodejs": "^0.1.200",
386
+ "@powerlines/plugin-plugin": "^0.12.237",
387
+ "@powerlines/plugin-tsdown": "^0.1.239",
374
388
  "@stryke/cli": "^0.13.15",
375
389
  "@stryke/convert": "^0.6.40",
376
390
  "@stryke/fs": "^0.33.43",
377
391
  "@stryke/helpers": "^0.9.42",
378
392
  "@stryke/json": "^0.9.43",
379
393
  "@stryke/path": "0.26.6",
380
- "@stryke/string-format": "^0.14.2",
394
+ "@stryke/string-format": "0.14.2",
381
395
  "@stryke/type-checks": "^0.5.25",
382
396
  "@stryke/types": "^0.10.39",
383
397
  "automd": "^0.4.3",
384
398
  "defu": "6.1.4",
385
- "powerlines": "^0.38.52",
399
+ "powerlines": "^0.38.53",
386
400
  "rolldown": "1.0.0-beta.52"
387
401
  },
388
402
  "devDependencies": { "@types/node": "^22.19.11", "typescript": "^5.9.3" },
389
403
  "publishConfig": { "access": "public" },
390
- "gitHead": "ba4e6ba921fb77de5be8950f02ea798752b61450"
404
+ "gitHead": "a802bf947afd12ce5c0f29aae1d4039c9e4f40f7"
391
405
  }