@shell-shock/preset-script 0.6.26 → 0.6.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/components/bin-entry.cjs +2 -1
- package/dist/components/bin-entry.cjs.map +1 -1
- package/dist/components/bin-entry.mjs +2 -1
- package/dist/components/bin-entry.mjs.map +1 -1
- package/dist/components/command-entry.cjs +4 -4
- package/dist/components/command-entry.cjs.map +1 -1
- package/dist/components/command-entry.d.cts.map +1 -1
- package/dist/components/command-entry.d.mts.map +1 -1
- package/dist/components/command-entry.mjs +4 -4
- package/dist/components/command-entry.mjs.map +1 -1
- package/dist/components/index.cjs +0 -3
- package/dist/components/index.d.cts +1 -2
- package/dist/components/index.d.mts +1 -2
- package/dist/components/index.mjs +1 -2
- package/dist/components/virtual-command-entry.cjs +16 -20
- package/dist/components/virtual-command-entry.cjs.map +1 -1
- package/dist/components/virtual-command-entry.d.cts +1 -1
- package/dist/components/virtual-command-entry.d.cts.map +1 -1
- package/dist/components/virtual-command-entry.d.mts.map +1 -1
- package/dist/components/virtual-command-entry.mjs +16 -20
- package/dist/components/virtual-command-entry.mjs.map +1 -1
- package/dist/index.cjs +1 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -6
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-help/dist/components/display.cjs +16 -2
- package/dist/plugin-help/dist/components/display.cjs.map +1 -1
- package/dist/plugin-help/dist/components/display.mjs +16 -2
- package/dist/plugin-help/dist/components/display.mjs.map +1 -1
- package/dist/plugin-help/dist/index.cjs +1 -1
- package/dist/plugin-help/dist/index.cjs.map +1 -1
- package/dist/plugin-help/dist/index.mjs +1 -1
- package/dist/plugin-help/dist/index.mjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/constant-case.cjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/constant-case.cjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/constant-case.mjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/constant-case.mjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/get-words.cjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/get-words.cjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/get-words.mjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/get-words.mjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/kebab-case.cjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/kebab-case.cjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/kebab-case.mjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/kebab-case.mjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/snake-case.cjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/snake-case.cjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/snake-case.mjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/snake-case.mjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/upper-case-first.cjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/upper-case-first.cjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/upper-case-first.mjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_string-format@0.17.4 → @stryke_string-format@0.17.6}/node_modules/@stryke/string-format/dist/upper-case-first.mjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-empty.cjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-empty.cjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-empty.mjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-empty.mjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-null.cjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-null.cjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-null.mjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-null.mjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-set-string.cjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-set-string.cjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-set-string.mjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-set-string.mjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-set.cjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-set.cjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-set.mjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-set.mjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-string.cjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-string.cjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-string.mjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-string.mjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-undefined.cjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-undefined.cjs.map +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-undefined.mjs +1 -1
- package/dist/plugin-help/dist/node_modules/.pnpm/{@stryke_type-checks@0.5.39 → @stryke_type-checks@0.5.41}/node_modules/@stryke/type-checks/dist/is-undefined.mjs.map +1 -1
- package/package.json +13 -27
- package/dist/components/banner-function-declaration.cjs +0 -110
- package/dist/components/banner-function-declaration.cjs.map +0 -1
- package/dist/components/banner-function-declaration.d.cts +0 -38
- package/dist/components/banner-function-declaration.d.cts.map +0 -1
- package/dist/components/banner-function-declaration.d.mts +0 -38
- package/dist/components/banner-function-declaration.d.mts.map +0 -1
- package/dist/components/banner-function-declaration.mjs +0 -107
- package/dist/components/banner-function-declaration.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ This package is part of the ⚡<b>Shell Shock</b> monorepo. The Shell Shock pack
|
|
|
27
27
|
|
|
28
28
|
<h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
|
|
29
29
|
|
|
30
|
-
[](https://stormsoftware.com/projects/shell-shock/) [](http://commitizen.github.io/cz-cli/)  
|
|
31
31
|
|
|
32
32
|
<!-- prettier-ignore-start -->
|
|
33
33
|
<!-- markdownlint-disable -->
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin-entry.cjs","names":[],"sources":["../../src/components/bin-entry.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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { TypescriptFileImports } from \"@powerlines/plugin-alloy/types/components\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocRemarks,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { ExitFunctionDeclaration } from \"./exit-function-declaration\";\n\n/**\n * Runs the application main logic with proper exit handling.\n */\nexport function RunApplication() {\n return (\n <>\n <Spacing />\n {code`// Run the application main logic inside an asynchronous IIFE\n (async () => {\n const startDate = new Date();\n try {\n process.on(\"exit\", () => exit({\n startDate,\n skipProcessExit: true,\n isSynchronous: true,\n signal: 0\n }));\n process.on(\"beforeExit\", () => exit({\n startDate,\n signal: 0\n }));\n process.on(\"message\", message => {\n if (message === 'shutdown') {\n exit({\n startDate,\n isSynchronous: true,\n signal: -128\n });\n }\n });\n\n process.once(\"SIGTERM\", () => exit({\n startDate,\n signal: 15\n }));\n process.once(\"SIGINT\", () => exit({\n startDate,\n signal: 2\n }));\n process.once(\"SIGUSR2\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n startDate,\n signal: 12\n });\n });\n process.once(\"SIGQUIT\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n startDate,\n signal: 12\n });\n });\n\n for (const type of [\"unhandledRejection\", \"uncaughtException\"]) {\n process.on(type, err => exit({\n startDate,\n exception: err || new Error(\\`An \\${type === \"unhandledRejection\" ? \"unhandled promise rejection\" : \"uncaught exception\"} occurred during processing - the application is shutting down.\\`)\n }));\n }\n\n await internal_appContext.run(new Map([[\"args\", getArgs()]]), async () => {\n const result = await main();\n if (result?.error) {\n error(result.error);\n }\n });\n\n exit({ startDate });\n } catch (err) {\n exit({ startDate, exception: err as Error });\n }\n })();\n `}\n <hbr />\n </>\n );\n}\n\nexport interface BinEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"hashbang\"\n> {\n prefix?: Children;\n postfix?: Children;\n children: Children;\n}\n\n/**\n * The binary entry point for the Shell Shock project.\n */\nexport function BinEntry(props: BinEntryProps) {\n const { prefix, postfix, builtinImports, imports, children, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const bins = computed(() => getUnique(Object.values(context.config.bin)));\n\n return (\n <For each={bins.value}>\n {bin => (\n <EntryFile\n {...rest}\n path={findFileName(replaceExtension(bin))}\n typeDefinition={{\n file: bin,\n output: \"bin\"\n }}\n imports={defu(\n imports ?? {},\n Object.entries(context.commands)\n .filter(([, command]) => command.isVirtual)\n .reduce((ret, [name, command]) => {\n ret[`./${command.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\"],\n console: [\"error\", \"verbose\", \"table\", \"writeLine\"],\n utils: [\n \"useApp\",\n \"hasFlag\",\n \"isUnicodeSupported\",\n \"internal_appContext\",\n \"getArgs\",\n \"findSuggestions\"\n ],\n help: [\"showHelp\"]\n })}>\n <ExitFunctionDeclaration />\n <Spacing />\n <Show when={Boolean(prefix)}>\n {prefix}\n <Spacing />\n </Show>\n <TSDoc\n heading={`Binary entry point for the ${getAppTitle(\n context,\n true\n )} command-line interface application.`}>\n <TSDocRemarks>\n {`This file serves as the main entry point for the binary executable of the ${getAppTitle(\n context,\n true\n )} command-line interface application. It sets up the necessary environment and runs the application logic with proper exit handling. The main function is defined within this file, and the application is executed inside an asynchronous IIFE to allow for the use of async/await syntax. The file also includes signal handling for graceful shutdowns and error handling for uncaught exceptions and unhandled promise rejections.`}\n </TSDocRemarks>\n <TSDocReturns>\n {`Returns a promise that resolves to either a successful result or an error object.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n async\n returnType=\"any | { error: string | Error }\"\n name=\"main\">\n <IfStatement condition={code`hasFlag([\"version\", \"v\"])`}>\n {code`console.log(${\n context?.packageJson.version\n ? `\"${context?.packageJson.version}\"`\n : \"0.0.1\"\n });\n return; `}\n </IfStatement>\n <Spacing />\n {children}\n <hbr />\n </FunctionDeclaration>\n <hbr />\n <hbr />\n <hbr />\n <Show when={Boolean(postfix)} fallback={<RunApplication />}>\n {postfix}\n </Show>\n <hbr />\n </EntryFile>\n )}\n </For>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAE,iBAAA;AACA,QAAM;kDAAoB,0DAAO,EAAI,CAAC;EAAA,mBAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8E9C,MAAO,EACL,QACC,SACD,gBACA,SACA,UACA,GAAA,SACF;;CAEE,MAAA,oFAAA,OAAA,OAAA,QAAA,OAAA,IAAA,CAAA,CAAA;AACA,wDAAwB,oBAAI;EAC5B,IAAA,OAAA;AACI,UAAC,KAAS;;;GAGd,IAAM,OAAS;AACT,mGAAgC,IAAO,CAAA;;GAE7C,gBAAO;IACD,MAAM;IACP,QAAO;IACP;GACD,IAAI,UAAQ;AACV,6BAAQ,WAAa,EAAA,EAAA,OAAA,QAAqB,QAAC,SAAA,CAAA,QAAA,GAAA,aAAA,QAAA,UAAA,CAAA,QAAA,KAAA,CAAA,MAAA,aAAA;AACzC,SAAA,KAAA,QAAgB,UAAA,CAAA;MACd,MAAM;MACN,OAAO,2DAAK,KAAA;MACb,CAAA;AACD,YAAO;OACN,EAAC,CAAa,CAAA;;GAEnB,IAAI,iBAAgB;AAClB,6BAAO,kBAAoB,EAAA,EAAO;KAChC,KAAK;MAAC;MAAO;MAAiB;MAAG;KACjC,SAAS;MAAC;MAAO;MAAU;MAAQ;MAAQ;KAC3C,OAAO;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;MAAA;;
|
|
1
|
+
{"version":3,"file":"bin-entry.cjs","names":[],"sources":["../../src/components/bin-entry.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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { TypescriptFileImports } from \"@powerlines/plugin-alloy/types/components\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocRemarks,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { ExitFunctionDeclaration } from \"./exit-function-declaration\";\n\n/**\n * Runs the application main logic with proper exit handling.\n */\nexport function RunApplication() {\n return (\n <>\n <Spacing />\n {code`// Run the application main logic inside an asynchronous IIFE\n (async () => {\n const startDate = new Date();\n try {\n process.on(\"exit\", () => exit({\n startDate,\n skipProcessExit: true,\n isSynchronous: true,\n signal: 0\n }));\n process.on(\"beforeExit\", () => exit({\n startDate,\n signal: 0\n }));\n process.on(\"message\", message => {\n if (message === 'shutdown') {\n exit({\n startDate,\n isSynchronous: true,\n signal: -128\n });\n }\n });\n\n process.once(\"SIGTERM\", () => exit({\n startDate,\n signal: 15\n }));\n process.once(\"SIGINT\", () => exit({\n startDate,\n signal: 2\n }));\n process.once(\"SIGUSR2\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n startDate,\n signal: 12\n });\n });\n process.once(\"SIGQUIT\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n startDate,\n signal: 12\n });\n });\n\n for (const type of [\"unhandledRejection\", \"uncaughtException\"]) {\n process.on(type, err => exit({\n startDate,\n exception: err || new Error(\\`An \\${type === \"unhandledRejection\" ? \"unhandled promise rejection\" : \"uncaught exception\"} occurred during processing - the application is shutting down.\\`)\n }));\n }\n\n await internal_appContext.run(new Map([[\"args\", getArgs()]]), async () => {\n const result = await main();\n if (result?.error) {\n error(result.error);\n }\n });\n\n exit({ startDate });\n } catch (err) {\n exit({ startDate, exception: err as Error });\n }\n })();\n `}\n <hbr />\n </>\n );\n}\n\nexport interface BinEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"hashbang\"\n> {\n prefix?: Children;\n postfix?: Children;\n children: Children;\n}\n\n/**\n * The binary entry point for the Shell Shock project.\n */\nexport function BinEntry(props: BinEntryProps) {\n const { prefix, postfix, builtinImports, imports, children, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const bins = computed(() => getUnique(Object.values(context.config.bin)));\n\n return (\n <For each={bins.value}>\n {bin => (\n <EntryFile\n {...rest}\n path={findFileName(replaceExtension(bin))}\n typeDefinition={{\n file: bin,\n output: \"bin\"\n }}\n imports={defu(\n imports ?? {},\n Object.entries(context.commands)\n .filter(([, command]) => command.isVirtual)\n .reduce((ret, [name, command]) => {\n ret[`./${command.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\"],\n console: [\"error\", \"verbose\", \"table\", \"writeLine\"],\n utils: [\n \"useApp\",\n \"hasFlag\",\n \"isUnicodeSupported\",\n \"internal_appContext\",\n \"getArgs\",\n \"findSuggestions\"\n ],\n help: [\"showHelp\"],\n banner: [\"showBanner\"]\n })}>\n <ExitFunctionDeclaration />\n <Spacing />\n <Show when={Boolean(prefix)}>\n {prefix}\n <Spacing />\n </Show>\n <TSDoc\n heading={`Binary entry point for the ${getAppTitle(\n context,\n true\n )} command-line interface application.`}>\n <TSDocRemarks>\n {`This file serves as the main entry point for the binary executable of the ${getAppTitle(\n context,\n true\n )} command-line interface application. It sets up the necessary environment and runs the application logic with proper exit handling. The main function is defined within this file, and the application is executed inside an asynchronous IIFE to allow for the use of async/await syntax. The file also includes signal handling for graceful shutdowns and error handling for uncaught exceptions and unhandled promise rejections.`}\n </TSDocRemarks>\n <TSDocReturns>\n {`Returns a promise that resolves to either a successful result or an error object.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n async\n returnType=\"any | { error: string | Error }\"\n name=\"main\">\n <IfStatement condition={code`hasFlag([\"version\", \"v\"])`}>\n {code`console.log(${\n context?.packageJson.version\n ? `\"${context?.packageJson.version}\"`\n : \"0.0.1\"\n });\n return; `}\n </IfStatement>\n <Spacing />\n {children}\n <hbr />\n </FunctionDeclaration>\n <hbr />\n <hbr />\n <hbr />\n <Show when={Boolean(postfix)} fallback={<RunApplication />}>\n {postfix}\n </Show>\n <hbr />\n </EntryFile>\n )}\n </For>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAE,iBAAA;AACA,QAAM;kDAAoB,0DAAO,EAAI,CAAC;EAAA,mBAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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H,CAAC;qDAAmB,0CAAsB;MACzC,OAAI;MACJ,YAAI;MACJ,MAAK;MACL,IAAG,WAAY;AACb,cAAI;wDAAoB,kCAAe;SACrC,WAAS,mBAAA;SACT,IAAE,WAAA;AACA,iBAAC,mBAAQ,eAAe,SAAW,YAAY,UAAK,IAAS,SAAC,YAAoB,QAAK,KAAA,QAAY;;;SAGtG,CAAC;wDAAoB,0DAAK,EAAA,CAAA;QAAS;wDAAuB,OAAY,EAAC,CAAA;QAAA;;MAE3E,CAAC;qDAAO,OAAA,EAAA,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAAA,OAAA,EAAA,CAAA;qDAAA,qBAAA;MACP,IAAC,OAAA;AACC,cAAA,QAAA,QAAA;;MAEF,IAAE,WAAW;AACX,8DAAwB,gBAAe,EAAA,CAAA;;MAEzC,UAAM;MACP,CAAC;qDAAc,OAAS,EAAA,CAAA;KAAA;;GAE5B,CAAC,CAAC;EACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin-entry.mjs","names":[],"sources":["../../src/components/bin-entry.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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { TypescriptFileImports } from \"@powerlines/plugin-alloy/types/components\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocRemarks,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { ExitFunctionDeclaration } from \"./exit-function-declaration\";\n\n/**\n * Runs the application main logic with proper exit handling.\n */\nexport function RunApplication() {\n return (\n <>\n <Spacing />\n {code`// Run the application main logic inside an asynchronous IIFE\n (async () => {\n const startDate = new Date();\n try {\n process.on(\"exit\", () => exit({\n startDate,\n skipProcessExit: true,\n isSynchronous: true,\n signal: 0\n }));\n process.on(\"beforeExit\", () => exit({\n startDate,\n signal: 0\n }));\n process.on(\"message\", message => {\n if (message === 'shutdown') {\n exit({\n startDate,\n isSynchronous: true,\n signal: -128\n });\n }\n });\n\n process.once(\"SIGTERM\", () => exit({\n startDate,\n signal: 15\n }));\n process.once(\"SIGINT\", () => exit({\n startDate,\n signal: 2\n }));\n process.once(\"SIGUSR2\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n startDate,\n signal: 12\n });\n });\n process.once(\"SIGQUIT\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n startDate,\n signal: 12\n });\n });\n\n for (const type of [\"unhandledRejection\", \"uncaughtException\"]) {\n process.on(type, err => exit({\n startDate,\n exception: err || new Error(\\`An \\${type === \"unhandledRejection\" ? \"unhandled promise rejection\" : \"uncaught exception\"} occurred during processing - the application is shutting down.\\`)\n }));\n }\n\n await internal_appContext.run(new Map([[\"args\", getArgs()]]), async () => {\n const result = await main();\n if (result?.error) {\n error(result.error);\n }\n });\n\n exit({ startDate });\n } catch (err) {\n exit({ startDate, exception: err as Error });\n }\n })();\n `}\n <hbr />\n </>\n );\n}\n\nexport interface BinEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"hashbang\"\n> {\n prefix?: Children;\n postfix?: Children;\n children: Children;\n}\n\n/**\n * The binary entry point for the Shell Shock project.\n */\nexport function BinEntry(props: BinEntryProps) {\n const { prefix, postfix, builtinImports, imports, children, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const bins = computed(() => getUnique(Object.values(context.config.bin)));\n\n return (\n <For each={bins.value}>\n {bin => (\n <EntryFile\n {...rest}\n path={findFileName(replaceExtension(bin))}\n typeDefinition={{\n file: bin,\n output: \"bin\"\n }}\n imports={defu(\n imports ?? {},\n Object.entries(context.commands)\n .filter(([, command]) => command.isVirtual)\n .reduce((ret, [name, command]) => {\n ret[`./${command.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\"],\n console: [\"error\", \"verbose\", \"table\", \"writeLine\"],\n utils: [\n \"useApp\",\n \"hasFlag\",\n \"isUnicodeSupported\",\n \"internal_appContext\",\n \"getArgs\",\n \"findSuggestions\"\n ],\n help: [\"showHelp\"]\n })}>\n <ExitFunctionDeclaration />\n <Spacing />\n <Show when={Boolean(prefix)}>\n {prefix}\n <Spacing />\n </Show>\n <TSDoc\n heading={`Binary entry point for the ${getAppTitle(\n context,\n true\n )} command-line interface application.`}>\n <TSDocRemarks>\n {`This file serves as the main entry point for the binary executable of the ${getAppTitle(\n context,\n true\n )} command-line interface application. It sets up the necessary environment and runs the application logic with proper exit handling. The main function is defined within this file, and the application is executed inside an asynchronous IIFE to allow for the use of async/await syntax. The file also includes signal handling for graceful shutdowns and error handling for uncaught exceptions and unhandled promise rejections.`}\n </TSDocRemarks>\n <TSDocReturns>\n {`Returns a promise that resolves to either a successful result or an error object.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n async\n returnType=\"any | { error: string | Error }\"\n name=\"main\">\n <IfStatement condition={code`hasFlag([\"version\", \"v\"])`}>\n {code`console.log(${\n context?.packageJson.version\n ? `\"${context?.packageJson.version}\"`\n : \"0.0.1\"\n });\n return; `}\n </IfStatement>\n <Spacing />\n {children}\n <hbr />\n </FunctionDeclaration>\n <hbr />\n <hbr />\n <hbr />\n <Show when={Boolean(postfix)} fallback={<RunApplication />}>\n {postfix}\n </Show>\n <hbr />\n </EntryFile>\n )}\n </For>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,SAAE,iBAAA;AACA,QAAM;EAAA,gBAAoB,SAAO,EAAI,CAAC;EAAA,IAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8E9C,MAAO,EACL,QACC,SACD,gBACA,SACA,UACA,GAAA,SACF;;CAEE,MAAA,OAAA,eAAA,UAAA,OAAA,OAAA,QAAA,OAAA,IAAA,CAAA,CAAA;AACA,QAAK,gBAAmB,KAAI;EAC5B,IAAA,OAAA;AACI,UAAC,KAAS;;;GAGd,IAAM,OAAS;AACT,WAAO,aAAa,iBAAY,IAAO,CAAA;;GAE7C,gBAAO;IACD,MAAM;IACP,QAAO;IACP;GACD,IAAI,UAAQ;AACV,WAAO,KAAC,WAAa,EAAA,EAAA,OAAA,QAAqB,QAAC,SAAA,CAAA,QAAA,GAAA,aAAA,QAAA,UAAA,CAAA,QAAA,KAAA,CAAA,MAAA,aAAA;AACzC,SAAA,KAAA,QAAgB,UAAA,CAAA;MACd,MAAM;MACN,OAAO,SAAK,WAAA,KAAA;MACb,CAAA;AACD,YAAO;OACN,EAAC,CAAa,CAAA;;GAEnB,IAAI,iBAAgB;AAClB,WAAO,KAAA,kBAAoB,EAAA,EAAO;KA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BAAY,OAAS,EAAA,CAAA;KAAA;;GAE5B,CAAC,CAAC;EACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"bin-entry.mjs","names":[],"sources":["../../src/components/bin-entry.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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { TypescriptFileImports } from \"@powerlines/plugin-alloy/types/components\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocRemarks,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { getUnique } from \"@stryke/helpers/get-unique\";\nimport { findFileName } from \"@stryke/path/file-path-fns\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { ExitFunctionDeclaration } from \"./exit-function-declaration\";\n\n/**\n * Runs the application main logic with proper exit handling.\n */\nexport function RunApplication() {\n return (\n <>\n <Spacing />\n {code`// Run the application main logic inside an asynchronous IIFE\n (async () => {\n const startDate = new Date();\n try {\n process.on(\"exit\", () => exit({\n startDate,\n skipProcessExit: true,\n isSynchronous: true,\n signal: 0\n }));\n process.on(\"beforeExit\", () => exit({\n startDate,\n signal: 0\n }));\n process.on(\"message\", message => {\n if (message === 'shutdown') {\n exit({\n startDate,\n isSynchronous: true,\n signal: -128\n });\n }\n });\n\n process.once(\"SIGTERM\", () => exit({\n startDate,\n signal: 15\n }));\n process.once(\"SIGINT\", () => exit({\n startDate,\n signal: 2\n }));\n process.once(\"SIGUSR2\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n startDate,\n signal: 12\n });\n });\n process.once(\"SIGQUIT\", () => {\n verbose(\"The application was terminated by the user\");\n return exit({\n startDate,\n signal: 12\n });\n });\n\n for (const type of [\"unhandledRejection\", \"uncaughtException\"]) {\n process.on(type, err => exit({\n startDate,\n exception: err || new Error(\\`An \\${type === \"unhandledRejection\" ? \"unhandled promise rejection\" : \"uncaught exception\"} occurred during processing - the application is shutting down.\\`)\n }));\n }\n\n await internal_appContext.run(new Map([[\"args\", getArgs()]]), async () => {\n const result = await main();\n if (result?.error) {\n error(result.error);\n }\n });\n\n exit({ startDate });\n } catch (err) {\n exit({ startDate, exception: err as Error });\n }\n })();\n `}\n <hbr />\n </>\n );\n}\n\nexport interface BinEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"hashbang\"\n> {\n prefix?: Children;\n postfix?: Children;\n children: Children;\n}\n\n/**\n * The binary entry point for the Shell Shock project.\n */\nexport function BinEntry(props: BinEntryProps) {\n const { prefix, postfix, builtinImports, imports, children, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const bins = computed(() => getUnique(Object.values(context.config.bin)));\n\n return (\n <For each={bins.value}>\n {bin => (\n <EntryFile\n {...rest}\n path={findFileName(replaceExtension(bin))}\n typeDefinition={{\n file: bin,\n output: \"bin\"\n }}\n imports={defu(\n imports ?? {},\n Object.entries(context.commands)\n .filter(([, command]) => command.isVirtual)\n .reduce((ret, [name, command]) => {\n ret[`./${command.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\"],\n console: [\"error\", \"verbose\", \"table\", \"writeLine\"],\n utils: [\n \"useApp\",\n \"hasFlag\",\n \"isUnicodeSupported\",\n \"internal_appContext\",\n \"getArgs\",\n \"findSuggestions\"\n ],\n help: [\"showHelp\"],\n banner: [\"showBanner\"]\n })}>\n <ExitFunctionDeclaration />\n <Spacing />\n <Show when={Boolean(prefix)}>\n {prefix}\n <Spacing />\n </Show>\n <TSDoc\n heading={`Binary entry point for the ${getAppTitle(\n context,\n true\n )} command-line interface application.`}>\n <TSDocRemarks>\n {`This file serves as the main entry point for the binary executable of the ${getAppTitle(\n context,\n true\n )} command-line interface application. It sets up the necessary environment and runs the application logic with proper exit handling. The main function is defined within this file, and the application is executed inside an asynchronous IIFE to allow for the use of async/await syntax. The file also includes signal handling for graceful shutdowns and error handling for uncaught exceptions and unhandled promise rejections.`}\n </TSDocRemarks>\n <TSDocReturns>\n {`Returns a promise that resolves to either a successful result or an error object.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n async\n returnType=\"any | { error: string | Error }\"\n name=\"main\">\n <IfStatement condition={code`hasFlag([\"version\", \"v\"])`}>\n {code`console.log(${\n context?.packageJson.version\n ? `\"${context?.packageJson.version}\"`\n : \"0.0.1\"\n });\n return; `}\n </IfStatement>\n <Spacing />\n {children}\n <hbr />\n </FunctionDeclaration>\n <hbr />\n <hbr />\n <hbr />\n <Show when={Boolean(postfix)} fallback={<RunApplication />}>\n {postfix}\n </Show>\n <hbr />\n </EntryFile>\n )}\n </For>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,SAAE,iBAAA;AACA,QAAM;EAAA,gBAAoB,SAAO,EAAI,CAAC;EAAA,IAAM;;;;;;;;;;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,gBAAA,cAAA,EACF,IAAA,WAAA;AACA,eAAS,6EAAA,YAAA,SAAA,KAAA,CAAA;UAEP,CAAA,EAAA,gBAAM,cAAA,EACN,UAAS,qFACV,CAAA,CAAA;;MAEH,CAAC;KAAE,gBAAiB,qBAAsB;MACzC,OAAI;MACJ,YAAI;MACJ,MAAK;MACL,IAAG,WAAY;AACb,cAAI;QAAI,gBAAgB,aAAe;SACrC,WAAS,IAAA;SACT,IAAE,WAAA;AACA,iBAAC,IAAQ,eAAe,SAAW,YAAY,UAAK,IAAS,SAAC,YAAoB,QAAK,KAAA,QAAY;;;SAGtG,CAAC;QAAE,gBAAkB,SAAK,EAAA,CAAA;QAAS;QAAU,gBAAa,OAAY,EAAC,CAAA;QAAA;;MAE3E,CAAC;KAAE,gBAAK,OAAA,EAAA,CAAA;KAAA,gBAAA,OAAA,EAAA,CAAA;KAAA,gBAAA,OAAA,EAAA,CAAA;KAAA,gBAAA,MAAA;MACP,IAAC,OAAA;AACC,cAAA,QAAA,QAAA;;MAEF,IAAE,WAAW;AACX,cAAC,gBAAuB,gBAAe,EAAA,CAAA;;MAEzC,UAAM;MACP,CAAC;KAAE,gBAAY,OAAS,EAAA,CAAA;KAAA;;GAE5B,CAAC,CAAC;EACJ,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_components_banner_function_declaration = require('./banner-function-declaration.cjs');
|
|
4
3
|
const require_components_virtual_command_entry = require('./virtual-command-entry.cjs');
|
|
5
4
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
6
5
|
let _alloy_js_core = require("@alloy-js/core");
|
|
@@ -108,6 +107,7 @@ function CommandHandlerDeclaration(props) {
|
|
|
108
107
|
get children() {
|
|
109
108
|
return _alloy_js_core.code`writeLine("");
|
|
110
109
|
writeLine(colors.text.body.tertiary("Debug mode is enabled. Additional debug information may be logged to the console."));
|
|
110
|
+
writeLine("");
|
|
111
111
|
debug(\`Command path: ${command.segments.map((segment) => (0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment) ? `\${${(0, _stryke_string_format_camel_case.camelCase)((0, _shell_shock_core_plugin_utils.getDynamicPathSegmentName)(segment))}}` : segment).join(" / ")} \\n\\nOptions: \\n${Object.values(command.options).map((option) => ` - ${(0, _stryke_string_format_kebab_case.kebabCase)(option.name)}: \${options.${(0, _stryke_string_format_camel_case.camelCase)(option.name)} === undefined ? "" : JSON.stringify(options.${(0, _stryke_string_format_camel_case.camelCase)(option.name)})}`).join("\\n")}${command.args.length > 0 ? ` \\n\\nArguments: \\n${command.args.map((arg) => ` - ${(0, _stryke_string_format_kebab_case.kebabCase)(arg.name)}: \${${(0, _stryke_string_format_camel_case.camelCase)(arg.name)} === undefined ? "" : JSON.stringify(${(0, _stryke_string_format_camel_case.camelCase)(arg.name)})}`).join("\\n")}` : ""}\`);
|
|
112
112
|
writeLine(""); `;
|
|
113
113
|
}
|
|
@@ -170,18 +170,18 @@ function CommandEntry(props) {
|
|
|
170
170
|
"isUnicodeSupported",
|
|
171
171
|
"internal_commandContext"
|
|
172
172
|
],
|
|
173
|
-
[(0, _stryke_path_join.joinPaths)("help", ...command.segments.filter((segment) => !(0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)))]: ["showHelp"]
|
|
173
|
+
[(0, _stryke_path_join.joinPaths)("help", ...command.segments.filter((segment) => !(0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)))]: ["showHelp"],
|
|
174
|
+
[(0, _stryke_path_join.joinPaths)("banner", ...command.segments.filter((segment) => !(0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)))]: ["showBanner"]
|
|
174
175
|
});
|
|
175
176
|
},
|
|
176
177
|
get children() {
|
|
177
178
|
return [
|
|
178
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(require_components_banner_function_declaration.BannerFunctionDeclaration, { command }),
|
|
179
179
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
180
180
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_core_components_options_parser_logic.OptionsInterfaceDeclaration, { command }),
|
|
181
181
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
182
182
|
(0, _alloy_js_core_jsx_runtime.createComponent)(CommandHandlerDeclaration, {
|
|
183
183
|
command,
|
|
184
|
-
banner: _alloy_js_core.code`
|
|
184
|
+
banner: _alloy_js_core.code`await showBanner(); `,
|
|
185
185
|
get children() {
|
|
186
186
|
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_core_components_command_validation_logic.CommandValidationLogic, { command }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
187
187
|
condition: _alloy_js_core.code`failures.length > 0`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-entry.cjs","names":[],"sources":["../../src/components/command-entry.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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { CommandValidationLogic } from \"@shell-shock/core/components/command-validation-logic\";\nimport { IsDebug } from \"@shell-shock/core/components/helpers\";\nimport {\n CommandParserLogic,\n OptionsInterfaceDeclaration\n} from \"@shell-shock/core/components/options-parser-logic\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\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 { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n <VarDeclaration\n name=\"__context\"\n initializer={code`{ path: \\`${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `\\${${camelCase(getDynamicPathSegmentName(segment))}}`\n : segment\n )\n .join(\"/\")}\\`, segments: [${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? camelCase(getDynamicPathSegmentName(segment))\n : `\"${segment}\"`\n )\n .join(\", \")}] }`}\n />\n <Spacing />\n {code`\n\n return internal_commandContext.run(__context, () => {\n return Promise.resolve(Reflect.apply(handle${pascalCase(\n command.name\n )}, __context, [options${\n command.args.length > 0\n ? `, ${command.args.map(arg => camelCase(arg.name)).join(\", \")}`\n : \"\"\n }]));\n });\n\n `}\n <hbr />\n </>\n );\n}\n\nexport interface CommandHandlerDeclarationProps {\n command: CommandTree;\n banner?: Children;\n children?: Children;\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(\n props: CommandHandlerDeclarationProps\n) {\n const { command, banner, children } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <OptionsInterfaceDeclaration command={command} />\n <Spacing />\n <TSDoc\n heading={`The ${command.title} (${getAppBin(context)} ${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `[${constantCase(getDynamicPathSegmentName(segment))}]`\n : segment\n )\n .join(\" \")}) command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"useArgs()\" }]}>\n <CommandParserLogic\n command={command}\n appSpecificEnvPrefix={context.config.appSpecificEnvPrefix}\n isCaseSensitive={context.config.isCaseSensitive}\n />\n <Spacing />\n <Show when={Boolean(banner)}>{banner}</Show>\n <Spacing />\n <IfStatement condition={<IsDebug />}>\n {code`writeLine(\"\");\n writeLine(colors.text.body.tertiary(\"Debug mode is enabled. Additional debug information may be logged to the console.\"));\n debug(\\`Command path: ${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `\\${${camelCase(getDynamicPathSegmentName(segment))}}`\n : segment\n )\n .join(\" / \")} \\\\n\\\\nOptions: \\\\n${Object.values(command.options)\n .map(\n option =>\n ` - ${kebabCase(option.name)}: \\${options.${camelCase(\n option.name\n )} === undefined ? \"\" : JSON.stringify(options.${camelCase(\n option.name\n )})}`\n )\n .join(\"\\\\n\")}${\n command.args.length > 0\n ? ` \\\\n\\\\nArguments: \\\\n${command.args\n .map(\n arg =>\n ` - ${kebabCase(arg.name)}: \\${${camelCase(\n arg.name\n )} === undefined ? \"\" : JSON.stringify(${camelCase(\n arg.name\n )})}`\n )\n .join(\"\\\\n\")}`\n : \"\"\n }\\`);\n writeLine(\"\"); `}\n </IfStatement>\n <Spacing />\n {children}\n <Spacing />\n <IfStatement condition={code`options.help`}>\n {code`return showHelp(); `}\n </IfStatement>\n <ElseClause>\n <hbr />\n <CommandInvocation command={command} />\n </ElseClause>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value.startsWith(\".\")\n ? commandSourcePath.value\n : `./${commandSourcePath.value}`]:\n `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\"],\n console: [\"debug\", \"warn\", \"error\", \"colors\", \"writeLine\"],\n utils: [\n \"useArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isUnicodeSupported\",\n \"internal_commandContext\"\n ],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <Spacing />\n <OptionsInterfaceDeclaration command={command} />\n <Spacing />\n <CommandHandlerDeclaration command={command} banner={code`banner(); `}>\n <CommandValidationLogic command={command} />\n <IfStatement condition={code`failures.length > 0`}>\n {code`error(\"The following validation failures were found while processing the user provided input, and must be corrected before the command-line process can be executed: \\\\n\\\\n\" + failures.map(failure => \" - \" + failure).join(\"\\\\n\"));\n options.help = true; `}\n </IfStatement>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAO,kBAAA,OAEL;CACA,MAAA,EACA,YACI;AACN,QAAS;kDAAmB,qCAAgB;GAC5C,MAAS;GACT,IAAQ,cAAa;AACf,WAAG,mBAAA,aAAqB,QAAQ,SAAO,KAAM,qEAAe,QAAA,GAAA,oHAAA,QAAA,CAAA,CAAA,KAAA,QAAA,CAAA,KAAA,IAAA,CAAA,iBAAA,QAAA,SAAA,KAAA,qEAAA,QAAA,iHAAA,QAAA,CAAA,GAAA,IAAA,QAAA,GAAA,CAAA,KAAA,KAAA,CAAA;;GAElE,CAAA;kDAAsB,0DAAO,EAAM,CAAC;6CAAc,mBAAA;;;uGAGW,QAAW,KAAC,CAAA,uBAAA,QAAA,KAAA,SAAA,IAAA,KAAA,QAAA,KAAA,KAAA,wDAAA,IAAA,KAAA,CAAA,CAAA,KAAA,KAAA,KAAA,GAAA;;;QAGlE;kDAAS,OAAkB,EAAA,CAAA;EAAK;;;;;AAWvC,SAAgB,0BAAA,OAAA;CACd,MAAM,EACJ,SACA,QACA,aACE;CACJ,MAAM,6EAAqB;AAC3B,QAAO;kDAAC,+EAAA,EACC,SACR,CAAC;kDAAG,0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CACC,QAAA,GAAA,QAAA,SAAA,QAAA,YAAA,0DAAA,QAAA,CAAA,CAAA,GAAA,CAAA,WAAA;IACX,CAAC;;EAEJ,IAAI,WAAE;AACJ,UAAG;oDAAU,0EAAA,EACH,SACT,CAAC;oDAAoB,0DAAS,EAAC,CAAA;oDAAU,+EAAA,EACtC,SACH,CAAC;oDAAmB,0DAAA,EAAA,CAAA;oDAAA,2BAAA;KACrB;KACH,QAAA,mBAAA;KACH,IAAA,WAAA;8IAEiB,SACf,CAAA,kDAAc,kCAAA;OACJ,WAAA,mBAAc;OACxB,UAAA,mBAAA;;OAEF,CAAA,CAAA;;KAEE,CAAA;IAAA;;EAEA,CAAA,CAAA,kDAAA,oBAAA;EACF,IAAO,OAAQ;AACb,UAAQ,OAAS,OAAQ,QAAC,SAAgB;;EAE1C,WAAM,0DAAwB,qBAAA;GAC9B,IAAM,OAAS;AACb,WAAS,MAAA;;GAEP,IAAG,WAAO;AACR,2DAAU,cAAA,EACX,SAAQ,OACX,CAAA;;GAEF,IAAM,WAAA;AACJ,2DAAgB,8DAAA,EACd,SAAY,OACV,CAAA;;GAEH,CAAC;EACH,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"command-entry.cjs","names":[],"sources":["../../src/components/command-entry.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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { CommandValidationLogic } from \"@shell-shock/core/components/command-validation-logic\";\nimport { IsDebug } from \"@shell-shock/core/components/helpers\";\nimport {\n CommandParserLogic,\n OptionsInterfaceDeclaration\n} from \"@shell-shock/core/components/options-parser-logic\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\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 { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n <VarDeclaration\n name=\"__context\"\n initializer={code`{ path: \\`${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `\\${${camelCase(getDynamicPathSegmentName(segment))}}`\n : segment\n )\n .join(\"/\")}\\`, segments: [${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? camelCase(getDynamicPathSegmentName(segment))\n : `\"${segment}\"`\n )\n .join(\", \")}] }`}\n />\n <Spacing />\n {code`\n\n return internal_commandContext.run(__context, () => {\n return Promise.resolve(Reflect.apply(handle${pascalCase(\n command.name\n )}, __context, [options${\n command.args.length > 0\n ? `, ${command.args.map(arg => camelCase(arg.name)).join(\", \")}`\n : \"\"\n }]));\n });\n\n `}\n <hbr />\n </>\n );\n}\n\nexport interface CommandHandlerDeclarationProps {\n command: CommandTree;\n banner?: Children;\n children?: Children;\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(\n props: CommandHandlerDeclarationProps\n) {\n const { command, banner, children } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <OptionsInterfaceDeclaration command={command} />\n <Spacing />\n <TSDoc\n heading={`The ${command.title} (${getAppBin(context)} ${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `[${constantCase(getDynamicPathSegmentName(segment))}]`\n : segment\n )\n .join(\" \")}) command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"useArgs()\" }]}>\n <CommandParserLogic\n command={command}\n appSpecificEnvPrefix={context.config.appSpecificEnvPrefix}\n isCaseSensitive={context.config.isCaseSensitive}\n />\n <Spacing />\n <Show when={Boolean(banner)}>{banner}</Show>\n <Spacing />\n <IfStatement condition={<IsDebug />}>\n {code`writeLine(\"\");\n writeLine(colors.text.body.tertiary(\"Debug mode is enabled. Additional debug information may be logged to the console.\"));\n writeLine(\"\");\n debug(\\`Command path: ${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `\\${${camelCase(getDynamicPathSegmentName(segment))}}`\n : segment\n )\n .join(\" / \")} \\\\n\\\\nOptions: \\\\n${Object.values(command.options)\n .map(\n option =>\n ` - ${kebabCase(option.name)}: \\${options.${camelCase(\n option.name\n )} === undefined ? \"\" : JSON.stringify(options.${camelCase(\n option.name\n )})}`\n )\n .join(\"\\\\n\")}${\n command.args.length > 0\n ? ` \\\\n\\\\nArguments: \\\\n${command.args\n .map(\n arg =>\n ` - ${kebabCase(arg.name)}: \\${${camelCase(\n arg.name\n )} === undefined ? \"\" : JSON.stringify(${camelCase(\n arg.name\n )})}`\n )\n .join(\"\\\\n\")}`\n : \"\"\n }\\`);\n writeLine(\"\"); `}\n </IfStatement>\n <Spacing />\n {children}\n <Spacing />\n <IfStatement condition={code`options.help`}>\n {code`return showHelp(); `}\n </IfStatement>\n <ElseClause>\n <hbr />\n <CommandInvocation command={command} />\n </ElseClause>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value.startsWith(\".\")\n ? commandSourcePath.value\n : `./${commandSourcePath.value}`]:\n `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\"],\n console: [\"debug\", \"warn\", \"error\", \"colors\", \"writeLine\"],\n utils: [\n \"useArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isUnicodeSupported\",\n \"internal_commandContext\"\n ],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"],\n [joinPaths(\n \"banner\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showBanner\"]\n })}>\n <Spacing />\n <OptionsInterfaceDeclaration command={command} />\n <Spacing />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await showBanner(); `}>\n <CommandValidationLogic command={command} />\n <IfStatement condition={code`failures.length > 0`}>\n {code`error(\"The following validation failures were found while processing the user provided input, and must be corrected before the command-line process can be executed: \\\\n\\\\n\" + failures.map(failure => \" - \" + failure).join(\"\\\\n\"));\n options.help = true; `}\n </IfStatement>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAe,kBAAW,OAExB;CACA,MAAA,EACA,YACI;AACN,QAAS;kDAAc,qCAAqB;GAC5C,MAAS;GACT,IAAQ,cAAC;AACH,WAAG,mBAAA,aAAmB,QAAO,SAAO,KAAO,qEAAW,QAAA,GAAA,oHAAA,QAAA,CAAA,CAAA,KAAA,QAAA,CAAA,KAAA,IAAA,CAAA,iBAAA,QAAA,SAAA,KAAA,qEAAA,QAAA,iHAAA,QAAA,CAAA,GAAA,IAAA,QAAA,GAAA,CAAA,KAAA,KAAA,CAAA;;GAE5D,CAAA;kDAAqB,0DAAO,EAAO,CAAA;6CAAc,mBAAM;;;uGAGG,QAAA,KAAA,CAAA,uBAAA,QAAA,KAAA,SAAA,IAAA,KAAA,QAAA,KAAA,KAAA,wDAAA,IAAA,KAAA,CAAA,CAAA,KAAA,KAAA,KAAA,GAAA;;;QAGnD;kDAAS,OAAkB,EAAA,CAAA;EAAK;;;;;AAWvC,SA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AA;KAAW;KAAA;KAAA;IACb,SAAS;KAAC;KAAA;KAAA;KAAA;KAAA;KAAA;IACV,OAAC;KAAA;KAAQ;KAAA;KAAA;KAAA;KAAA;sCACC,QAAA,GAAA,QAAA,SAAA,QAAA,YAAA,0DAAA,QAAA,CAAA,CAAA,GAAA,CAAA,WAAA;sCACT,UAAY,GAAW,QAAK,SAAY,QAAE,YAAA,0DAAA,QAAA,CAAA,CAAA,GAAA,CAAA,aAAA;IAC5C,CAAC;;EAEJ,IAAI,WAAW;AACb,UAAK;oDAAK,0DAAA,EAAA,CAAA;oDAAA,+EAAA,EACL,SACJ,CAAC;oDAAY,0DAAA,EAAA,CAAA;oDAAA,2BAAA;KACZ;KACF,QAAA,mBAAA;KACH,IAAA,WAAA;AACH,aAAA,iDAAA,8EAAA,WAEO,CAAA,kDAAU,kCAA0B;OACzC,WAAc,mBAAA;OACJ,UAAA,mBAAc;;OAEf,CAAA,CAAA;;;;;EAIR,CAAA,CAAA,kDAAkB,oBAAS;EAC5B,IAAA,OAAA;AACI,UAAC,OAAS,OAAA,QAAmB,SAAC;;;GAGlC,IAAM,OAAS;AACT,WAAA,MAAW;;GAEb,IAAA,WAAQ;AACN,2DAAoB,cAAA,EACnB,SAAS,OACX,CAAA;;GAEJ,IAAA,WAAA;AACK,2DAAoB,8DAAa,EACrC,SAAA,OACE,CAAA;;GAED,CAAC;EACH,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-entry.d.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"command-entry.d.cts","names":[],"sources":["../../src/components/command-entry.tsx"],"mappings":";;;;;iBA2DgB,iBAAA,CAAkB,KAAA;EAAS,OAAA,EAAS,WAAA;AAAA,IAAa,QAAA;AAAA,UAwChD,8BAAA;EACf,OAAA,EAAS,WAAA;EACT,MAAA,GAAS,QAAA;EACT,QAAA,GAAW,QAAA;AAAA;;;;iBAMG,yBAAA,CACd,KAAA,EAAO,8BAAA,GAA8B,QAAA;AAAA,UAsFtB,iBAAA,SAA0B,IAAA,CACzC,cAAA;EAGA,OAAA,EAAS,WAAA;AAAA;;;;iBAMK,YAAA,CAAa,KAAA,EAAO,iBAAA,GAAiB,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"command-entry.d.mts","names":[],"sources":["../../src/components/command-entry.tsx"],"mappings":";;;;;iBA2DgB,iBAAA,CAAkB,KAAA;EAAS,OAAA,EAAS,WAAA;AAAA,IAAa,QAAA;AAAA,UAwChD,8BAAA;EACf,OAAA,EAAS,WAAA;EACT,MAAA,GAAS,QAAA;EACT,QAAA,GAAW,QAAA;AAAA;;;;iBAMG,yBAAA,CACd,KAAA,EAAO,8BAAA,GAA8B,QAAA;AAAA,UAsFtB,iBAAA,SAA0B,IAAA,CACzC,cAAA;EAGA,OAAA,EAAS,WAAA;AAAA;;;;iBAMK,YAAA,CAAa,KAAA,EAAO,iBAAA,GAAiB,QAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BannerFunctionDeclaration } from "./banner-function-declaration.mjs";
|
|
2
1
|
import { VirtualCommandEntry } from "./virtual-command-entry.mjs";
|
|
3
2
|
import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
4
3
|
import { For, Show, code, computed } from "@alloy-js/core";
|
|
@@ -105,6 +104,7 @@ function CommandHandlerDeclaration(props) {
|
|
|
105
104
|
get children() {
|
|
106
105
|
return code`writeLine("");
|
|
107
106
|
writeLine(colors.text.body.tertiary("Debug mode is enabled. Additional debug information may be logged to the console."));
|
|
107
|
+
writeLine("");
|
|
108
108
|
debug(\`Command path: ${command.segments.map((segment) => isDynamicPathSegment(segment) ? `\${${camelCase(getDynamicPathSegmentName(segment))}}` : segment).join(" / ")} \\n\\nOptions: \\n${Object.values(command.options).map((option) => ` - ${kebabCase(option.name)}: \${options.${camelCase(option.name)} === undefined ? "" : JSON.stringify(options.${camelCase(option.name)})}`).join("\\n")}${command.args.length > 0 ? ` \\n\\nArguments: \\n${command.args.map((arg) => ` - ${kebabCase(arg.name)}: \${${camelCase(arg.name)} === undefined ? "" : JSON.stringify(${camelCase(arg.name)})}`).join("\\n")}` : ""}\`);
|
|
109
109
|
writeLine(""); `;
|
|
110
110
|
}
|
|
@@ -167,18 +167,18 @@ function CommandEntry(props) {
|
|
|
167
167
|
"isUnicodeSupported",
|
|
168
168
|
"internal_commandContext"
|
|
169
169
|
],
|
|
170
|
-
[joinPaths("help", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showHelp"]
|
|
170
|
+
[joinPaths("help", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showHelp"],
|
|
171
|
+
[joinPaths("banner", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)))]: ["showBanner"]
|
|
171
172
|
});
|
|
172
173
|
},
|
|
173
174
|
get children() {
|
|
174
175
|
return [
|
|
175
|
-
createComponent(BannerFunctionDeclaration, { command }),
|
|
176
176
|
createComponent(Spacing, {}),
|
|
177
177
|
createComponent(OptionsInterfaceDeclaration, { command }),
|
|
178
178
|
createComponent(Spacing, {}),
|
|
179
179
|
createComponent(CommandHandlerDeclaration, {
|
|
180
180
|
command,
|
|
181
|
-
banner: code`
|
|
181
|
+
banner: code`await showBanner(); `,
|
|
182
182
|
get children() {
|
|
183
183
|
return [createComponent(CommandValidationLogic, { command }), createComponent(IfStatement, {
|
|
184
184
|
condition: code`failures.length > 0`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-entry.mjs","names":[],"sources":["../../src/components/command-entry.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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { CommandValidationLogic } from \"@shell-shock/core/components/command-validation-logic\";\nimport { IsDebug } from \"@shell-shock/core/components/helpers\";\nimport {\n CommandParserLogic,\n OptionsInterfaceDeclaration\n} from \"@shell-shock/core/components/options-parser-logic\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\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 { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n <VarDeclaration\n name=\"__context\"\n initializer={code`{ path: \\`${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `\\${${camelCase(getDynamicPathSegmentName(segment))}}`\n : segment\n )\n .join(\"/\")}\\`, segments: [${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? camelCase(getDynamicPathSegmentName(segment))\n : `\"${segment}\"`\n )\n .join(\", \")}] }`}\n />\n <Spacing />\n {code`\n\n return internal_commandContext.run(__context, () => {\n return Promise.resolve(Reflect.apply(handle${pascalCase(\n command.name\n )}, __context, [options${\n command.args.length > 0\n ? `, ${command.args.map(arg => camelCase(arg.name)).join(\", \")}`\n : \"\"\n }]));\n });\n\n `}\n <hbr />\n </>\n );\n}\n\nexport interface CommandHandlerDeclarationProps {\n command: CommandTree;\n banner?: Children;\n children?: Children;\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(\n props: CommandHandlerDeclarationProps\n) {\n const { command, banner, children } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <OptionsInterfaceDeclaration command={command} />\n <Spacing />\n <TSDoc\n heading={`The ${command.title} (${getAppBin(context)} ${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `[${constantCase(getDynamicPathSegmentName(segment))}]`\n : segment\n )\n .join(\" \")}) command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"useArgs()\" }]}>\n <CommandParserLogic\n command={command}\n appSpecificEnvPrefix={context.config.appSpecificEnvPrefix}\n isCaseSensitive={context.config.isCaseSensitive}\n />\n <Spacing />\n <Show when={Boolean(banner)}>{banner}</Show>\n <Spacing />\n <IfStatement condition={<IsDebug />}>\n {code`writeLine(\"\");\n writeLine(colors.text.body.tertiary(\"Debug mode is enabled. Additional debug information may be logged to the console.\"));\n debug(\\`Command path: ${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `\\${${camelCase(getDynamicPathSegmentName(segment))}}`\n : segment\n )\n .join(\" / \")} \\\\n\\\\nOptions: \\\\n${Object.values(command.options)\n .map(\n option =>\n ` - ${kebabCase(option.name)}: \\${options.${camelCase(\n option.name\n )} === undefined ? \"\" : JSON.stringify(options.${camelCase(\n option.name\n )})}`\n )\n .join(\"\\\\n\")}${\n command.args.length > 0\n ? ` \\\\n\\\\nArguments: \\\\n${command.args\n .map(\n arg =>\n ` - ${kebabCase(arg.name)}: \\${${camelCase(\n arg.name\n )} === undefined ? \"\" : JSON.stringify(${camelCase(\n arg.name\n )})}`\n )\n .join(\"\\\\n\")}`\n : \"\"\n }\\`);\n writeLine(\"\"); `}\n </IfStatement>\n <Spacing />\n {children}\n <Spacing />\n <IfStatement condition={code`options.help`}>\n {code`return showHelp(); `}\n </IfStatement>\n <ElseClause>\n <hbr />\n <CommandInvocation command={command} />\n </ElseClause>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value.startsWith(\".\")\n ? commandSourcePath.value\n : `./${commandSourcePath.value}`]:\n `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\"],\n console: [\"debug\", \"warn\", \"error\", \"colors\", \"writeLine\"],\n utils: [\n \"useArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isUnicodeSupported\",\n \"internal_commandContext\"\n ],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <Spacing />\n <OptionsInterfaceDeclaration command={command} />\n <Spacing />\n <CommandHandlerDeclaration command={command} banner={code`banner(); `}>\n <CommandValidationLogic command={command} />\n <IfStatement condition={code`failures.length > 0`}>\n {code`error(\"The following validation failures were found while processing the user provided input, and must be corrected before the command-line process can be executed: \\\\n\\\\n\" + failures.map(failure => \" - \" + failure).join(\"\\\\n\"));\n options.help = true; `}\n </IfStatement>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAO,kBAAA,OAEL;CACA,MAAA,EACA,YACI;AACN,QAAS;EAAA,gBAAmB,gBAAgB;GAC5C,MAAS;GACT,IAAQ,cAAa;AACf,WAAG,IAAA,aAAqB,QAAQ,SAAO,KAAM,YAAU,qBAAK,QAAA,GAAA,MAAA,UAAA,0BAAA,QAAA,CAAA,CAAA,KAAA,QAAA,CAAA,KAAA,IAAA,CAAA,iBAAA,QAAA,SAAA,KAAA,YAAA,qBAAA,QAAA,GAAA,UAA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AAQ,OAAS,OAAQ,QAAC,SAAgB;;EAE1C,WAAM,UAAU,gBAAc,MAAA;GAC9B,IAAM,OAAS;AACb,WAAS,MAAA;;GAEP,IAAG,WAAO;AACR,WAAO,gBAAG,cAAA,EACX,SAAQ,OACX,CAAA;;GAEF,IAAM,WAAA;AACJ,WAAA,gBAAgB,qBAAA,EACd,SAAY,OACV,CAAA;;GAEH,CAAC;EACH,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"command-entry.mjs","names":[],"sources":["../../src/components/command-entry.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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n FunctionDeclaration,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { CommandValidationLogic } from \"@shell-shock/core/components/command-validation-logic\";\nimport { IsDebug } from \"@shell-shock/core/components/helpers\";\nimport {\n CommandParserLogic,\n OptionsInterfaceDeclaration\n} from \"@shell-shock/core/components/options-parser-logic\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\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 { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport function CommandInvocation(props: { command: CommandTree }) {\n const { command } = props;\n\n return (\n <>\n <VarDeclaration\n name=\"__context\"\n initializer={code`{ path: \\`${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `\\${${camelCase(getDynamicPathSegmentName(segment))}}`\n : segment\n )\n .join(\"/\")}\\`, segments: [${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? camelCase(getDynamicPathSegmentName(segment))\n : `\"${segment}\"`\n )\n .join(\", \")}] }`}\n />\n <Spacing />\n {code`\n\n return internal_commandContext.run(__context, () => {\n return Promise.resolve(Reflect.apply(handle${pascalCase(\n command.name\n )}, __context, [options${\n command.args.length > 0\n ? `, ${command.args.map(arg => camelCase(arg.name)).join(\", \")}`\n : \"\"\n }]));\n });\n\n `}\n <hbr />\n </>\n );\n}\n\nexport interface CommandHandlerDeclarationProps {\n command: CommandTree;\n banner?: Children;\n children?: Children;\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function CommandHandlerDeclaration(\n props: CommandHandlerDeclarationProps\n) {\n const { command, banner, children } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <OptionsInterfaceDeclaration command={command} />\n <Spacing />\n <TSDoc\n heading={`The ${command.title} (${getAppBin(context)} ${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `[${constantCase(getDynamicPathSegmentName(segment))}]`\n : segment\n )\n .join(\" \")}) command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"useArgs()\" }]}>\n <CommandParserLogic\n command={command}\n appSpecificEnvPrefix={context.config.appSpecificEnvPrefix}\n isCaseSensitive={context.config.isCaseSensitive}\n />\n <Spacing />\n <Show when={Boolean(banner)}>{banner}</Show>\n <Spacing />\n <IfStatement condition={<IsDebug />}>\n {code`writeLine(\"\");\n writeLine(colors.text.body.tertiary(\"Debug mode is enabled. Additional debug information may be logged to the console.\"));\n writeLine(\"\");\n debug(\\`Command path: ${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `\\${${camelCase(getDynamicPathSegmentName(segment))}}`\n : segment\n )\n .join(\" / \")} \\\\n\\\\nOptions: \\\\n${Object.values(command.options)\n .map(\n option =>\n ` - ${kebabCase(option.name)}: \\${options.${camelCase(\n option.name\n )} === undefined ? \"\" : JSON.stringify(options.${camelCase(\n option.name\n )})}`\n )\n .join(\"\\\\n\")}${\n command.args.length > 0\n ? ` \\\\n\\\\nArguments: \\\\n${command.args\n .map(\n arg =>\n ` - ${kebabCase(arg.name)}: \\${${camelCase(\n arg.name\n )} === undefined ? \"\" : JSON.stringify(${camelCase(\n arg.name\n )})}`\n )\n .join(\"\\\\n\")}`\n : \"\"\n }\\`);\n writeLine(\"\"); `}\n </IfStatement>\n <Spacing />\n {children}\n <Spacing />\n <IfStatement condition={code`options.help`}>\n {code`return showHelp(); `}\n </IfStatement>\n <ElseClause>\n <hbr />\n <CommandInvocation command={command} />\n </ElseClause>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value.startsWith(\".\")\n ? commandSourcePath.value\n : `./${commandSourcePath.value}`]:\n `handle${pascalCase(command.name)}`\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\"],\n console: [\"debug\", \"warn\", \"error\", \"colors\", \"writeLine\"],\n utils: [\n \"useArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isUnicodeSupported\",\n \"internal_commandContext\"\n ],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"],\n [joinPaths(\n \"banner\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showBanner\"]\n })}>\n <Spacing />\n <OptionsInterfaceDeclaration command={command} />\n <Spacing />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await showBanner(); `}>\n <CommandValidationLogic command={command} />\n <IfStatement condition={code`failures.length > 0`}>\n {code`error(\"The following validation failures were found while processing the user provided input, and must be corrected before the command-line process can be executed: \\\\n\\\\n\" + failures.map(failure => \" - \" + failure).join(\"\\\\n\"));\n options.help = true; `}\n </IfStatement>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0CA,SAAe,kBAAW,OAExB;CACA,MAAA,EACA,YACI;AACN,QAAS;EAAA,gBAAc,gBAAqB;GAC5C,MAAS;GACT,IAAQ,cAAC;AACH,WAAG,IAAA,aAAmB,QAAO,SAAO,KAAO,YAAW,qBAAA,QAAA,GAAA,MAAA,UAAA,0BAAA,QAAA,CAAA,CAAA,KAAA,QAAA,CAAA,KAAA,IAAA,CAAA,iBAAA,QAAA,SAAA,KAAA,YAAA,qBAAA,QAAA,GAAA,UAAA,0BAAA,QAAA,CAAA,GAAA,IAAA,QAAA,GAAA,CAAA,KAAA,KAAA,CAAA;;GAE5D,CAAA;EAAM,gBAAe,SAAO,EAAO,CAAA;EAAA,WAAc,IAAM;;;qDAGJ,WAAO,QAAA,KAAA,CAAA,uBAAA,QAAA,KAAA,SAAA,IAAA,KAAA,QAAA,KAAA,KAAA,QAAA,UAAA,IAAA,KAAA,CAAA,CAAA,KAAA,KAAA,KAAA,GAAA;;;QAGnD;EAAA,gBAAS,OAAkB,EAAA,CAAA;EAAK;;;;;AAWvC,SAAgB,0BAAA,OAAA;CACd,MAAM,EACJ,SACA,QACA,aACE;CACJ,MAAM,UAAU,eAAW;AAC3B,QAAO;EAAC,gBAAA,6BAAA,EACC,SACR,CAAC;EAAE,gBAAC,SAAA,EAAA,CAAA;EAAA,gBAAA,OAAA;GACH,IAAG,UAAS;AACV,WAAK,OAAA,QAAA,MAAA,IAAA,UAAA,QAAA,CAAA,GAAA,QAAA,SAAA,KAAA,YAAA,qBAAA,QAAA,GAAA,IAAA,aAAA,0BAAA,QAAA,CAAA,CAAA,KAAA,QAAA,CAAA,KAAA,IAAA,CAAA;;GAEP,IAAE,WAAO;AACP,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A,QAAA,SAAA,QAAA,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,GAAA,CAAA,WAAA;KACT,UAAA,UAAY,GAAW,QAAK,SAAY,QAAE,YAAA,CAAA,qBAAA,QAAA,CAAA,CAAA,GAAA,CAAA,aAAA;IAC5C,CAAC;;EAEJ,IAAI,WAAW;AACb,UAAK;IAAG,gBAAE,SAAA,EAAA,CAAA;IAAA,gBAAA,6BAAA,EACL,SACJ,CAAC;IAAE,gBAAU,SAAA,EAAA,CAAA;IAAA,gBAAA,2BAAA;KACZ;KACF,QAAA,IAAA;KACH,IAAA,WAAA;AACH,aAAA,CAAA,gBAAA,wBAAA,WAEO,CAAA,EAAA,gBAAU,aAA0B;OACzC,WAAc,IAAA;OACJ,UAAA,IAAc;;OAEf,CAAA,CAAA;;;;;EAIR,CAAA,CAAA,EAAI,gBAAc,KAAS;EAC5B,IAAA,OAAA;AACI,UAAC,OAAS,OAAA,QAAmB,SAAC;;;GAGlC,IAAM,OAAS;AACT,WAAA,MAAW;;GAEb,IAAA,WAAQ;AACN,WAAO,gBAAa,cAAA,EACnB,SAAS,OACX,CAAA;;GAEJ,IAAA,WAAA;AACK,WAAA,gBAAoB,qBAAa,EACrC,SAAA,OACE,CAAA;;GAED,CAAC;EACH,CAAC,CAAC"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_components_banner_function_declaration = require('./banner-function-declaration.cjs');
|
|
3
2
|
const require_components_exit_function_declaration = require('./exit-function-declaration.cjs');
|
|
4
3
|
const require_components_bin_entry = require('./bin-entry.cjs');
|
|
5
4
|
const require_components_command_router = require('./command-router.cjs');
|
|
6
5
|
const require_components_virtual_command_entry = require('./virtual-command-entry.cjs');
|
|
7
6
|
const require_components_command_entry = require('./command-entry.cjs');
|
|
8
7
|
|
|
9
|
-
exports.BannerFunctionBodyDeclaration = require_components_banner_function_declaration.BannerFunctionBodyDeclaration;
|
|
10
|
-
exports.BannerFunctionDeclaration = require_components_banner_function_declaration.BannerFunctionDeclaration;
|
|
11
8
|
exports.BinEntry = require_components_bin_entry.BinEntry;
|
|
12
9
|
exports.CommandEntry = require_components_command_entry.CommandEntry;
|
|
13
10
|
exports.CommandHandlerDeclaration = require_components_command_entry.CommandHandlerDeclaration;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { BannerFunctionBodyDeclaration, BannerFunctionBodyDeclarationProps, BannerFunctionDeclaration, BannerFunctionDeclarationProps } from "./banner-function-declaration.cjs";
|
|
2
1
|
import { BinEntry, BinEntryProps, RunApplication } from "./bin-entry.cjs";
|
|
3
2
|
import { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandHandlerDeclarationProps, CommandInvocation } from "./command-entry.cjs";
|
|
4
3
|
import { CommandRouter, CommandRouterBody, CommandRouterProps, CommandRouterRoute } from "./command-router.cjs";
|
|
5
4
|
import { ExitFunctionDeclaration } from "./exit-function-declaration.cjs";
|
|
6
5
|
import { VirtualCommandEntry, VirtualCommandEntryProps, VirtualCommandHandlerDeclaration, VirtualCommandHandlerDeclarationProps } from "./virtual-command-entry.cjs";
|
|
7
|
-
export {
|
|
6
|
+
export { BinEntry, BinEntryProps, CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandHandlerDeclarationProps, CommandInvocation, CommandRouter, CommandRouterBody, CommandRouterProps, CommandRouterRoute, ExitFunctionDeclaration, RunApplication, VirtualCommandEntry, VirtualCommandEntryProps, VirtualCommandHandlerDeclaration, VirtualCommandHandlerDeclarationProps };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { BannerFunctionBodyDeclaration, BannerFunctionBodyDeclarationProps, BannerFunctionDeclaration, BannerFunctionDeclarationProps } from "./banner-function-declaration.mjs";
|
|
2
1
|
import { BinEntry, BinEntryProps, RunApplication } from "./bin-entry.mjs";
|
|
3
2
|
import { CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandHandlerDeclarationProps, CommandInvocation } from "./command-entry.mjs";
|
|
4
3
|
import { CommandRouter, CommandRouterBody, CommandRouterProps, CommandRouterRoute } from "./command-router.mjs";
|
|
5
4
|
import { ExitFunctionDeclaration } from "./exit-function-declaration.mjs";
|
|
6
5
|
import { VirtualCommandEntry, VirtualCommandEntryProps, VirtualCommandHandlerDeclaration, VirtualCommandHandlerDeclarationProps } from "./virtual-command-entry.mjs";
|
|
7
|
-
export {
|
|
6
|
+
export { BinEntry, BinEntryProps, CommandEntry, CommandEntryProps, CommandHandlerDeclaration, CommandHandlerDeclarationProps, CommandInvocation, CommandRouter, CommandRouterBody, CommandRouterProps, CommandRouterRoute, ExitFunctionDeclaration, RunApplication, VirtualCommandEntry, VirtualCommandEntryProps, VirtualCommandHandlerDeclaration, VirtualCommandHandlerDeclarationProps };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { BannerFunctionBodyDeclaration, BannerFunctionDeclaration } from "./banner-function-declaration.mjs";
|
|
2
1
|
import { ExitFunctionDeclaration } from "./exit-function-declaration.mjs";
|
|
3
2
|
import { BinEntry, RunApplication } from "./bin-entry.mjs";
|
|
4
3
|
import { CommandRouter, CommandRouterBody, CommandRouterRoute } from "./command-router.mjs";
|
|
5
4
|
import { VirtualCommandEntry, VirtualCommandHandlerDeclaration } from "./virtual-command-entry.mjs";
|
|
6
5
|
import { CommandEntry, CommandHandlerDeclaration, CommandInvocation } from "./command-entry.mjs";
|
|
7
6
|
|
|
8
|
-
export {
|
|
7
|
+
export { BinEntry, CommandEntry, CommandHandlerDeclaration, CommandInvocation, CommandRouter, CommandRouterBody, CommandRouterRoute, ExitFunctionDeclaration, RunApplication, VirtualCommandEntry, VirtualCommandHandlerDeclaration };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_components_banner_function_declaration = require('./banner-function-declaration.cjs');
|
|
4
3
|
const require_components_command_router = require('./command-router.cjs');
|
|
5
4
|
const require_components_command_entry = require('./command-entry.cjs');
|
|
6
5
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
@@ -106,28 +105,25 @@ function VirtualCommandEntry(props) {
|
|
|
106
105
|
"isUnicodeSupported",
|
|
107
106
|
"findSuggestions"
|
|
108
107
|
],
|
|
109
|
-
[(0, _stryke_path_join.joinPaths)("help", ...command.segments.filter((segment) => !(0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)))]: ["showHelp"]
|
|
108
|
+
[(0, _stryke_path_join.joinPaths)("help", ...command.segments.filter((segment) => !(0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)))]: ["showHelp"],
|
|
109
|
+
[(0, _stryke_path_join.joinPaths)("banner", ...command.segments.filter((segment) => !(0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)))]: ["showBanner"]
|
|
110
110
|
});
|
|
111
111
|
},
|
|
112
112
|
get children() {
|
|
113
|
-
return [
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
];
|
|
113
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}), (0, _alloy_js_core_jsx_runtime.createComponent)(VirtualCommandHandlerDeclaration, {
|
|
114
|
+
command,
|
|
115
|
+
banner: _alloy_js_core.code`await showBanner(); `,
|
|
116
|
+
get children() {
|
|
117
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_command_router.CommandRouter, {
|
|
118
|
+
get segments() {
|
|
119
|
+
return command.segments;
|
|
120
|
+
},
|
|
121
|
+
get commands() {
|
|
122
|
+
return command.children;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
})];
|
|
131
127
|
}
|
|
132
128
|
})), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
133
129
|
get each() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-command-entry.cjs","names":[],"sources":["../../src/components/virtual-command-entry.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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { TypescriptFileImports } from \"@powerlines/plugin-alloy/types/components\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport {
|
|
1
|
+
{"version":3,"file":"virtual-command-entry.cjs","names":[],"sources":["../../src/components/virtual-command-entry.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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { TypescriptFileImports } from \"@powerlines/plugin-alloy/types/components\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { CommandEntry } from \"./command-entry\";\nimport { CommandRouter } from \"./command-router\";\n\nexport interface VirtualCommandHandlerDeclarationProps {\n command: CommandTree;\n banner?: Children;\n children?: Children;\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function VirtualCommandHandlerDeclaration(\n props: VirtualCommandHandlerDeclarationProps\n) {\n const { command, children, banner } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(context)} ${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `[${constantCase(getDynamicPathSegmentName(segment))}]`\n : segment\n )\n .join(\" \")}) virtual command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"useArgs()\" }]}>\n <Spacing />\n {children}\n <Spacing />\n <Show when={Boolean(banner)}>{banner}</Show>\n <Spacing />\n {code`return showHelp(); `}\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface VirtualCommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The virtual command entry point for the Shell Shock project.\n */\nexport function VirtualCommandEntry(props: VirtualCommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n context.entryPath,\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n\n return (\n <>\n <TypescriptFile\n {...rest}\n path={filePath.value}\n imports={defu(\n imports ?? {},\n Object.entries(command.children)\n .filter(([, child]) => child.isVirtual)\n .reduce((ret, [name, child]) => {\n ret[`./${child.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"isDevelopment\", \"isDebug\"],\n console: [\"warn\", \"error\", \"colors\", \"writeLine\"],\n utils: [\n \"useApp\",\n \"useArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isUnicodeSupported\",\n \"findSuggestions\"\n ],\n [joinPaths(\n \"help\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showHelp\"],\n [joinPaths(\n \"banner\",\n ...command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n )\n )]: [\"showBanner\"]\n })}>\n <Spacing />\n <VirtualCommandHandlerDeclaration\n command={command}\n banner={code`await showBanner(); `}>\n <CommandRouter\n segments={command.segments}\n commands={command.children}\n />\n </VirtualCommandHandlerDeclaration>\n </TypescriptFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,iCAAC,OAAsC;CACrD,MAAA,EACA,SACA,UACF;CAEE,MAAA,6EAAA;AACA,QAAG,iDAAe,4DAAe;EACjC,IAAA,UAAA;AACI,UAAC,OAAS,QAAA,MAAA,kDAAgC,QAAA,CAAA,GAAA,QAAA,SAAA,KAAA,qEAAA,QAAA,GAAA,wHAAA,QAAA,CAAA,CAAA,KAAA,QAAA,CAAA,KAAA,IAAA,CAAA;;EAE9C,IAAA,WAAA;AACA,UAAQ;oDAAmB,mEAAgB;AAErC,YAAS,GAAC,QAAA,YAAc,QAAA,QAAsB,GAAA,CAAA;OAEpD,CAAM;oDAAC,OAAA,EAAA,CAAA;oDAAA,iEAAA,EACJ,IAAA,WAAA;AACE,YAAA,QAAA;OAEA,CAAC;oDAAgB,iEAAA;KAChB,MAAI;KACJ,UAAU;KACX,CAAC;IAAC;;EAEN,CAAC,kDAAmB,0CAAkB;EACrC,UAAK;EACL,OAAK;EACL,MAAK;EACL,YAAK,CAAA;GACH,MAAE;GACF,MAA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J,cAAO,QAAA;;MAET,CAAC;;IAEL,CAAC,CAAC;;EAEN,CAAC,CAAC,kDAAM,oBAAA;EACP,IAAI,OAAG;AACL,UAAO,OAAK,OAAA,QAAA,SAAA;;EAEd,WAAU,0DAAY,qBAAqB;GACzC,IAAI,OAAE;AACJ,WAAO,MAAC;;GAEV,IAAI,WAAU;AACZ,2DAAwB,+CAAM,EAC5B,SAAI,OACL,CAAC;;GAEJ,IAAI,WAAC;AACH,2DAAU,qBAAA,EACT,SAAA,OACA,CAAC;;GAEL,CAAC;EACH,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Children } from "@alloy-js/core";
|
|
2
|
-
import { CommandTree } from "@shell-shock/core/types/command";
|
|
3
2
|
import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
3
|
+
import { CommandTree } from "@shell-shock/core/types/command";
|
|
4
4
|
|
|
5
5
|
//#region src/components/virtual-command-entry.d.ts
|
|
6
6
|
interface VirtualCommandHandlerDeclarationProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-command-entry.d.cts","names":[],"sources":["../../src/components/virtual-command-entry.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"virtual-command-entry.d.cts","names":[],"sources":["../../src/components/virtual-command-entry.tsx"],"mappings":";;;;;UA8CiB,qCAAA;EACf,OAAA,EAAS,WAAA;EACT,MAAA,GAAS,QAAA;EACT,QAAA,GAAW,QAAA;AAAA;;;;iBAMG,gCAAA,CACd,KAAA,EAAO,qCAAA,GAAqC,QAAA;AAAA,UAqC7B,wBAAA,SAAiC,IAAA,CAChD,cAAA;EAGA,OAAA,EAAS,WAAA;AAAA;;;;iBAMK,mBAAA,CAAoB,KAAA,EAAO,wBAAA,GAAwB,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-command-entry.d.mts","names":[],"sources":["../../src/components/virtual-command-entry.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"virtual-command-entry.d.mts","names":[],"sources":["../../src/components/virtual-command-entry.tsx"],"mappings":";;;;;UA8CiB,qCAAA;EACf,OAAA,EAAS,WAAA;EACT,MAAA,GAAS,QAAA;EACT,QAAA,GAAW,QAAA;AAAA;;;;iBAMG,gCAAA,CACd,KAAA,EAAO,qCAAA,GAAqC,QAAA;AAAA,UAqC7B,wBAAA,SAAiC,IAAA,CAChD,cAAA;EAGA,OAAA,EAAS,WAAA;AAAA;;;;iBAMK,mBAAA,CAAoB,KAAA,EAAO,wBAAA,GAAwB,QAAA"}
|