@shell-shock/preset-script 0.6.19 → 0.6.21
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/dist/components/bin-entry.cjs +3 -9
- package/dist/components/bin-entry.cjs.map +1 -1
- package/dist/components/bin-entry.mjs +3 -9
- package/dist/components/bin-entry.mjs.map +1 -1
- package/dist/components/command-router.cjs +1 -6
- package/dist/components/command-router.cjs.map +1 -1
- package/dist/components/command-router.mjs +1 -6
- package/dist/components/command-router.mjs.map +1 -1
- package/dist/components/exit-function-declaration.d.cts +2 -2
- package/dist/components/exit-function-declaration.d.mts +2 -2
- package/dist/components/help.cjs +1 -1
- package/dist/components/help.cjs.map +1 -1
- package/dist/components/help.d.cts +7 -7
- package/dist/components/help.d.mts +7 -7
- package/dist/components/help.mjs +1 -1
- package/dist/components/help.mjs.map +1 -1
- package/dist/components/helpers.d.cts +5 -5
- package/dist/components/helpers.d.mts +5 -5
- package/dist/components/virtual-command-entry.cjs +3 -9
- package/dist/components/virtual-command-entry.cjs.map +1 -1
- package/dist/components/virtual-command-entry.mjs +3 -9
- package/dist/components/virtual-command-entry.mjs.map +1 -1
- package/dist/index.cjs +0 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +0 -3
- package/dist/index.mjs.map +1 -1
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +34 -34
|
@@ -112,14 +112,7 @@ function BinEntry(props) {
|
|
|
112
112
|
output: "bin"
|
|
113
113
|
},
|
|
114
114
|
get imports() {
|
|
115
|
-
return (0, defu.default)({
|
|
116
|
-
{
|
|
117
|
-
name: "didYouMean",
|
|
118
|
-
default: true
|
|
119
|
-
},
|
|
120
|
-
{ name: "ReturnTypeEnums" },
|
|
121
|
-
{ name: "ThresholdTypeEnums" }
|
|
122
|
-
] }, imports ?? {}, Object.entries(context.commands).filter(([, command]) => command.isVirtual).reduce((ret, [name, command]) => {
|
|
115
|
+
return (0, defu.default)(imports ?? {}, Object.entries(context.commands).filter(([, command]) => command.isVirtual).reduce((ret, [name, command]) => {
|
|
123
116
|
ret[`./${command.name}`] = [{
|
|
124
117
|
name: "handler",
|
|
125
118
|
alias: `handle${(0, __stryke_string_format_pascal_case.pascalCase)(name)}`
|
|
@@ -144,7 +137,8 @@ function BinEntry(props) {
|
|
|
144
137
|
"hasFlag",
|
|
145
138
|
"isUnicodeSupported",
|
|
146
139
|
"internal_appContext",
|
|
147
|
-
"getArgs"
|
|
140
|
+
"getArgs",
|
|
141
|
+
"findSuggestions"
|
|
148
142
|
]
|
|
149
143
|
});
|
|
150
144
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin-entry.cjs","names":["code","computed","For","Show","FunctionDeclaration","IfStatement","Spacing","usePowerlines","EntryFile","TSDoc","getAppTitle","getUnique","findFileName","replaceExtension","pascalCase","defu","ExitFunctionDeclaration","RunApplication","_$createComponent","_$createIntrinsic","BinEntry","props","prefix","postfix","builtinImports","imports","children","rest","context","bins","Object","values","config","bin","each","value","_$mergeProps","path","typeDefinition","file","output","
|
|
1
|
+
{"version":3,"file":"bin-entry.cjs","names":["code","computed","For","Show","FunctionDeclaration","IfStatement","Spacing","usePowerlines","EntryFile","TSDoc","getAppTitle","getUnique","findFileName","replaceExtension","pascalCase","defu","ExitFunctionDeclaration","RunApplication","_$createComponent","_$createIntrinsic","BinEntry","props","prefix","postfix","builtinImports","imports","children","rest","context","bins","Object","values","config","bin","each","value","_$mergeProps","path","typeDefinition","file","output","entries","commands","filter","command","isVirtual","reduce","ret","name","alias","env","console","utils","when","Boolean","heading","async","returnType","condition","packageJson","version","fallback"],"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 { TSDoc } from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils/context-helpers\";\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 \"hasFlag\",\n \"isUnicodeSupported\",\n \"internal_appContext\",\n \"getArgs\",\n \"findSuggestions\"\n ]\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 )} CLI application.`}></TSDoc>\n <FunctionDeclaration async returnType=\"any\" 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":";;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgBiB,iBAAiB;AAC/B,QAAA;mDAEKX,2DAAO,EAAA,CAAA;EACPN,oBAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mDAkEJ,OAAA,EAAA,CAAA;EAAA;;;;;AAkBP,SAAgBoB,SAASC,OAAsB;CAC7C,MAAM,EAAEC,QAAQC,SAASC,gBAAgBC,SAASC,UAAU,GAAGC,SAASN;CAExE,MAAMO,8EAA8C;CACpD,MAAMC,sFAAgCC,OAAOC,OAAOH,QAAQI,OAAOC,IAAI,CAAC,CAAC;AAEzE,yDACG/B,qBAAG;EAAA,IAACgC,OAAI;AAAA,UAAEL,KAAKM;;EAAKT,WAClBO,yDACEzB,kHACKmB,MAAI;GAAA,IACRU,OAAI;AAAA,qGAAgCJ,IAAI,CAAC;;GACzCK,gBAAgB;IACdC,MAAMN;IACNO,QAAQ;IACT;GAAA,IACDf,UAAO;AAAA,6BACLA,WAAW,EAAE,EACbK,OAAOW,QAAQb,QAAQc,SAAS,CAC7BC,QAAQ,GAAGC,aAAaA,QAAQC,U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MAAAS,UACpDH;MAAO,CAAA;sDAAA,OAAA,EAAA,CAAA;KAAA;;GAAA,CAAA,CAAA;EAIb,CAAA"}
|
|
@@ -110,14 +110,7 @@ function BinEntry(props) {
|
|
|
110
110
|
output: "bin"
|
|
111
111
|
},
|
|
112
112
|
get imports() {
|
|
113
|
-
return defu({
|
|
114
|
-
{
|
|
115
|
-
name: "didYouMean",
|
|
116
|
-
default: true
|
|
117
|
-
},
|
|
118
|
-
{ name: "ReturnTypeEnums" },
|
|
119
|
-
{ name: "ThresholdTypeEnums" }
|
|
120
|
-
] }, imports ?? {}, Object.entries(context.commands).filter(([, command]) => command.isVirtual).reduce((ret, [name, command]) => {
|
|
113
|
+
return defu(imports ?? {}, Object.entries(context.commands).filter(([, command]) => command.isVirtual).reduce((ret, [name, command]) => {
|
|
121
114
|
ret[`./${command.name}`] = [{
|
|
122
115
|
name: "handler",
|
|
123
116
|
alias: `handle${pascalCase(name)}`
|
|
@@ -142,7 +135,8 @@ function BinEntry(props) {
|
|
|
142
135
|
"hasFlag",
|
|
143
136
|
"isUnicodeSupported",
|
|
144
137
|
"internal_appContext",
|
|
145
|
-
"getArgs"
|
|
138
|
+
"getArgs",
|
|
139
|
+
"findSuggestions"
|
|
146
140
|
]
|
|
147
141
|
});
|
|
148
142
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin-entry.mjs","names":["code","computed","For","Show","FunctionDeclaration","IfStatement","Spacing","usePowerlines","EntryFile","TSDoc","getAppTitle","getUnique","findFileName","replaceExtension","pascalCase","defu","ExitFunctionDeclaration","RunApplication","_$createComponent","_$createIntrinsic","BinEntry","props","prefix","postfix","builtinImports","imports","children","rest","context","bins","Object","values","config","bin","each","value","_$mergeProps","path","typeDefinition","file","output","didyoumean2","name","default","entries","commands","filter","command","isVirtual","reduce","ret","alias","env","console","utils","when","Boolean","heading","async","returnType","condition","packageJson","version","fallback"],"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 { TSDoc } from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils/context-helpers\";\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 {\n didyoumean2: [\n { name: \"didYouMean\", default: true },\n { name: \"ReturnTypeEnums\" },\n { name: \"ThresholdTypeEnums\" }\n ]\n },\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 \"hasFlag\",\n \"isUnicodeSupported\",\n \"internal_appContext\",\n \"getArgs\"\n ]\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 )} CLI application.`}></TSDoc>\n <FunctionDeclaration async returnType=\"any\" 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":";;;;;;;;;;;;;;;;;;;AAuCA,SAAgBiB,iBAAiB;AAC/B,QAAA;EAAAC,gBAEKZ,SAAO,EAAA,CAAA;EACPN,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkEJmB,gBAAA,OAAA,EAAA,CAAA;EAAA;;;;;AAkBP,SAAgBC,SAASC,OAAsB;CAC7C,MAAM,EAAEC,QAAQC,SAASC,gBAAgBC,SAASC,UAAU,GAAGC,SAASN;CAExE,MAAMO,UAAUrB,eAAoC;CACpD,MAAMsB,OAAO5B,eAAeU,UAAUmB,OAAOC,OAAOH,QAAQI,OAAOC,IAAI,CAAC,CAAC;AAEzE,QAAAf,gBACGhB,KAAG;EAAA,IAACgC,OAAI;AAAA,UAAEL,KAAKM;;EAAKT,WAClBO,QAAGf,gBACDV,WAAS4B,WACJT,MAA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AW5D,IAAI;SAA2B,IAAA0B,WAAA;AAAA,iBACpD1B,IAAI,eACH4B,SAASiC,YAAYC,UACjB,IAAIlC,SAASiC,YAAYC,QAAO,KAChC,QAAO;;;SAET,CAAA;QAAA5C,gBAELZ,SAAO,EAAA,CAAA;QACPoB;QAAQP,gBAAA,OAAA,EAAA,CAAA;QAAA;;MAAA,CAAA;KAAAA,gBAAA,OAAA,EAAA,CAAA;KAAAA,gBAAA,OAAA,EAAA,CAAA;KAAAA,gBAAA,OAAA,EAAA,CAAA;KAAAD,gBAMVf,MAAI;MAAA,IAACoD,OAAI;AAAA,cAAEC,QAAQjC,QAAQ;;MAAA,IAAEwC,WAAQ;AAAA,cAAA7C,gBAAGD,gBAAc,EAAA,CAAA;;MAAAS,UACpDH;MAAO,CAAA;KAAAJ,gBAAA,OAAA,EAAA,CAAA;KAAA;;GAAA,CAAA,CAAA;EAIb,CAAA"}
|
|
1
|
+
{"version":3,"file":"bin-entry.mjs","names":["code","computed","For","Show","FunctionDeclaration","IfStatement","Spacing","usePowerlines","EntryFile","TSDoc","getAppTitle","getUnique","findFileName","replaceExtension","pascalCase","defu","ExitFunctionDeclaration","RunApplication","_$createComponent","_$createIntrinsic","BinEntry","props","prefix","postfix","builtinImports","imports","children","rest","context","bins","Object","values","config","bin","each","value","_$mergeProps","path","typeDefinition","file","output","entries","commands","filter","command","isVirtual","reduce","ret","name","alias","env","console","utils","when","Boolean","heading","async","returnType","condition","packageJson","version","fallback"],"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 { TSDoc } from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils/context-helpers\";\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 \"hasFlag\",\n \"isUnicodeSupported\",\n \"internal_appContext\",\n \"getArgs\",\n \"findSuggestions\"\n ]\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 )} CLI application.`}></TSDoc>\n <FunctionDeclaration async returnType=\"any\" 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":";;;;;;;;;;;;;;;;;;;AAuCA,SAAgBiB,iBAAiB;AAC/B,QAAA;EAAAC,gBAEKZ,SAAO,EAAA,CAAA;EACPN,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkEJmB,gBAAA,OAAA,EAAA,CAAA;EAAA;;;;;AAkBP,SAAgBC,SAASC,OAAsB;CAC7C,MAAM,EAAEC,QAAQC,SAASC,gBAAgBC,SAASC,UAAU,GAAGC,SAASN;CAExE,MAAMO,UAAUrB,eAAoC;CACpD,MAAMsB,OAAO5B,eAAeU,UAAUmB,OAAOC,OAAOH,QAAQI,OAAOC,IAAI,CAAC,CAAC;AAEzE,QAAAf,gBACGhB,KAAG;EAAA,IAACgC,OAAI;AAAA,UAAEL,KAAKM;;EAAKT,WAClBO,QAAGf,gBACDV,WAAS4B,WACJT,MAAI;GAAA,IACRU,OAAI;AAAA,WAAEzB,aAAaC,iBAAiBoB,IAAI,CAAC;;GACzCK,gBAAgB;IACdC,MAAMN;IACNO,QAAQ;IACT;GAAA,IACDf,UAAO;AAAA,WAAEV,KACPU,WAAW,EAAE,EACbK,OAAOW,QAAQb,QAAQc,SAAS,CAC7BC,QAAQ,GAAGC,aAAaA,QAAQC,UAAU,CAC1CC,QAAQC,KAAK,CAACC,MAAMJ,aAAa;AAChCG,SAAI,KAAKH,QAAQI,UAAU,CACzB;MAAEA,MAAM;MAAWC,OAAO,SAAS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S,UACpDH;MAAO,CAAA;KAAAJ,gBAAA,OAAA,EAAA,CAAA;KAAA;;GAAA,CAAA,CAAA;EAIb,CAAA"}
|
|
@@ -144,12 +144,7 @@ function CommandRouterBody(props) {
|
|
|
144
144
|
}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
|
|
145
145
|
condition: __alloy_js_core.code`Boolean(command) && !command.startsWith("-")`,
|
|
146
146
|
get children() {
|
|
147
|
-
return __alloy_js_core.code`const suggestions =
|
|
148
|
-
caseSensitive: ${JSON.stringify(context.config.isCaseSensitive)},
|
|
149
|
-
returnType: ReturnTypeEnums.ALL_CLOSEST_MATCHES,
|
|
150
|
-
thresholdType: ThresholdTypeEnums.SIMILARITY,
|
|
151
|
-
threshold: 0.25
|
|
152
|
-
});
|
|
147
|
+
return __alloy_js_core.code`const suggestions = findSuggestions(command, [${Object.values(commands ?? {}).map((cmd) => `"${cmd.name}"${(cmd.alias ?? []).map((alias) => `, "${alias}"`).join("")}`).join(", ")}]).slice(0, 3);
|
|
153
148
|
error(\`Unknown command: "\${command}"\${suggestions && suggestions.length > 0 ? \`, did you mean: \${suggestions.length === 1 ? \`"\${suggestions[0]}"\` : suggestions.map((suggestion, i) => i < suggestions.length - 1 ? \`"\${suggestion}", \` : \`or "\${suggestion}"\`)}?\` : ""} \`);`;
|
|
154
149
|
}
|
|
155
150
|
})];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-router.cjs","names":["code","computed","For","Show","ElseIfClause","IfStatement","VarDeclaration","Spacing","usePowerlines","DynamicImportStatement","CommandContext","useCommand","isDynamicPathSegment","pascalCase","CommandRouterRoute","command","_$createComponent","when","isVirtual","children","name","importPath","segments","filter","segment","length","exportName","_$createIntrinsic","_$memo","CommandRouter","props","commands","route","index","Object","keys","type","initializer","condition","value","CommandRouterBody","context","each","values","subcommand","idx","Provider","Boolean","fallback","config","isCaseSensitive","toLowerCase","replaceAll","alias","map","join","cmd","JSON","stringify"],"sources":["../../src/components/command-router.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 ElseIfClause,\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 { DynamicImportStatement } from \"@powerlines/plugin-alloy/typescript/components/dynamic-import-statement\";\nimport { CommandContext, useCommand } from \"@shell-shock/core/contexts/command\";\nimport { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport function CommandRouterRoute() {\n const command = useCommand();\n\n return (\n <>\n <Show when={!command.isVirtual}>\n <DynamicImportStatement\n name={`handle${pascalCase(command.name)}`}\n importPath={`./${\n command.segments.filter(segment => !isDynamicPathSegment(segment))[\n command.segments.filter(segment => !isDynamicPathSegment(segment))\n .length - 1\n ]\n }`}\n exportName=\"handler\"\n />\n </Show>\n <hbr />\n {code`return handle${pascalCase(command.name)}(args);`}\n </>\n );\n}\n\nexport interface CommandRouterProps {\n segments: string[];\n commands?: Record<string, CommandTree>;\n route?: Children;\n}\n\n/**\n * The command router component.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { segments, commands, route } = props;\n\n const index = computed(() => 2 + (segments.length ?? 0));\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <VarDeclaration\n let\n name=\"command\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n <Show when={commands && Object.keys(commands).length > 0}>\n <IfStatement\n condition={code`args.length > ${\n index.value\n } && args[${index.value}]`}>{code`command = args[${\n index.value\n }];`}</IfStatement>\n <hbr />\n <hbr />\n </Show>\n <CommandRouterBody\n segments={segments}\n commands={commands}\n route={route}\n />\n </Show>\n );\n}\n\n/**\n * The internal command router body logic component.\n */\nexport function CommandRouterBody(props: CommandRouterProps) {\n const { commands, route } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <For each={Object.values(commands ?? {})}>\n {(subcommand, idx) => (\n <CommandContext.Provider value={subcommand}>\n <Show\n when={Boolean(idx)}\n fallback={\n <IfStatement\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"${\n subcommand.alias && subcommand.alias.length > 0\n ? ` || ${subcommand.alias\n .map(\n alias =>\n `${context.config.isCaseSensitive ? \"command\" : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'} === \"${\n context.config.isCaseSensitive\n ? alias\n : alias\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"`\n )\n .join(\" || \")}`\n : \"\"\n }`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"${\n subcommand.alias && subcommand.alias.length > 0\n ? ` || ${subcommand.alias\n .map(\n alias =>\n `${context.config.isCaseSensitive ? \"command\" : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'} === \"${\n context.config.isCaseSensitive\n ? alias\n : alias\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"`\n )\n .join(\" || \")}`\n : \"\"\n }`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n </Show>\n </CommandContext.Provider>\n )}\n </For>\n <ElseIfClause\n condition={code`Boolean(command) && !command.startsWith(\"-\")`}>{code`const suggestions = didYouMean(command, [${Object.values(\n commands ?? {}\n )\n .map(\n cmd =>\n `\"${cmd.name}\"${(cmd.alias ?? []).map(alias => `, \"${alias}\"`).join(\"\")}`\n )\n .join(\", \")}], {\n caseSensitive: ${JSON.stringify(context.config.isCaseSensitive)},\n returnType: ReturnTypeEnums.ALL_CLOSEST_MATCHES,\n thresholdType: ThresholdTypeEnums.SIMILARITY,\n threshold: 0.25\n });\n error(\\`Unknown command: \"\\${command}\"\\${suggestions && suggestions.length > 0 ? \\`, did you mean: \\${suggestions.length === 1 ? \\`\"\\${suggestions[0]}\"\\` : suggestions.map((suggestion, i) => i < suggestions.length - 1 ? \\`\"\\${suggestion}\", \\` : \\`or \"\\${suggestion}\"\\`)}?\\` : \"\"} \\`);`}</ElseIfClause>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,SAAgBc,qBAAqB;CACnC,MAAMC,+DAAsB;AAE5B,QAAA;mDAEKZ,sBAAI;GAAA,IAACc,OAAI;AAAA,WAAE,CAACF,QAAQG;;GAAS,IAAAC,WAAA;AAAA,4DAC3BV,iGAAsB;KAAA,IACrBW,OAAI;AAA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bC,WAAW,KAAK,GAAG,CACnBA,WAAW,KAAK,GAAG,CAAA,GAE1BR,WAAWS,SAAST,WAAWS,MAAM5B,SAAS,IAC1C,OAAOmB,WAAWS,MACfC,KACCD,UACE,GAAGZ,QAAQQ,OAAOC,kBAAkB,YAAY,wEAA+D,QAC7GT,QAAQQ,OAAOC,kBACXG,QACAA,MACGF,aAAa,CACbC,WAAW,KAAK,GAAG,CACnBA,WAAW,KAAK,GAAG,CAAA,GAE/B,CACAG,KAAK,OAAO,KACf;;SACJ,IAAApC,WAAA;AAAA,kEACDhB,sBAAI;WAAA,IAACc,OAAI;AAAA,mBAAE8B,QAAQf,MAAM;;WAAA,IAAEgB,WAAQ;AAAA,oEAAGlC,oBAAkB,EAAA,CAAA;;WAAAK,UACtDa;WAAK,CAAA;;SAAA,CAAA;;OAAA,CAAA;;KAAA,CAAA;IAKf,CAAA,mDAEF5B,oCAAY;IACXkC,WAAWtC,oBAAI;IAA8C,IAAAmB,WAAA;AAAA,YAAGnB,oBAAI,4CAA4CkC,OAAOS,OACvHZ,YAAY,EACd,CAAC,CACEuB,KACCE,QACE,IAAIA,IAAIpC,KAAI,IAAKoC,IAAIH,SAAS,EAAE,EAAEC,KAAID,UAAS,MAAMA,MAAK,GAAI,CAACE,KAAK,GAAG,GAC1E,CACAA,KAAK,KAAK,CAAA;2BACQE,KAAKC,UAAUjB,QAAQQ,OAAOC,gBAAgB,CAAA;;;;;;;IAK4N,CAAA,CAAA;;EAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"command-router.cjs","names":["code","computed","For","Show","ElseIfClause","IfStatement","VarDeclaration","Spacing","usePowerlines","DynamicImportStatement","CommandContext","useCommand","isDynamicPathSegment","pascalCase","CommandRouterRoute","command","_$createComponent","when","isVirtual","children","name","importPath","segments","filter","segment","length","exportName","_$createIntrinsic","_$memo","CommandRouter","props","commands","route","index","Object","keys","type","initializer","condition","value","CommandRouterBody","context","each","values","subcommand","idx","Provider","Boolean","fallback","config","isCaseSensitive","toLowerCase","replaceAll","alias","map","join","cmd"],"sources":["../../src/components/command-router.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 ElseIfClause,\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 { DynamicImportStatement } from \"@powerlines/plugin-alloy/typescript/components/dynamic-import-statement\";\nimport { CommandContext, useCommand } from \"@shell-shock/core/contexts/command\";\nimport { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport function CommandRouterRoute() {\n const command = useCommand();\n\n return (\n <>\n <Show when={!command.isVirtual}>\n <DynamicImportStatement\n name={`handle${pascalCase(command.name)}`}\n importPath={`./${\n command.segments.filter(segment => !isDynamicPathSegment(segment))[\n command.segments.filter(segment => !isDynamicPathSegment(segment))\n .length - 1\n ]\n }`}\n exportName=\"handler\"\n />\n </Show>\n <hbr />\n {code`return handle${pascalCase(command.name)}(args);`}\n </>\n );\n}\n\nexport interface CommandRouterProps {\n segments: string[];\n commands?: Record<string, CommandTree>;\n route?: Children;\n}\n\n/**\n * The command router component.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { segments, commands, route } = props;\n\n const index = computed(() => 2 + (segments.length ?? 0));\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <VarDeclaration\n let\n name=\"command\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n <Show when={commands && Object.keys(commands).length > 0}>\n <IfStatement\n condition={code`args.length > ${\n index.value\n } && args[${index.value}]`}>{code`command = args[${\n index.value\n }];`}</IfStatement>\n <hbr />\n <hbr />\n </Show>\n <CommandRouterBody\n segments={segments}\n commands={commands}\n route={route}\n />\n </Show>\n );\n}\n\n/**\n * The internal command router body logic component.\n */\nexport function CommandRouterBody(props: CommandRouterProps) {\n const { commands, route } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <For each={Object.values(commands ?? {})}>\n {(subcommand, idx) => (\n <CommandContext.Provider value={subcommand}>\n <Show\n when={Boolean(idx)}\n fallback={\n <IfStatement\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"${\n subcommand.alias && subcommand.alias.length > 0\n ? ` || ${subcommand.alias\n .map(\n alias =>\n `${context.config.isCaseSensitive ? \"command\" : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'} === \"${\n context.config.isCaseSensitive\n ? alias\n : alias\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"`\n )\n .join(\" || \")}`\n : \"\"\n }`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"${\n subcommand.alias && subcommand.alias.length > 0\n ? ` || ${subcommand.alias\n .map(\n alias =>\n `${context.config.isCaseSensitive ? \"command\" : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'} === \"${\n context.config.isCaseSensitive\n ? alias\n : alias\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"`\n )\n .join(\" || \")}`\n : \"\"\n }`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n </Show>\n </CommandContext.Provider>\n )}\n </For>\n <ElseIfClause\n condition={code`Boolean(command) && !command.startsWith(\"-\")`}>{code`const suggestions = findSuggestions(command, [${Object.values(\n commands ?? {}\n )\n .map(\n cmd =>\n `\"${cmd.name}\"${(cmd.alias ?? []).map(alias => `, \"${alias}\"`).join(\"\")}`\n )\n .join(\", \")}]).slice(0, 3);\n error(\\`Unknown command: \"\\${command}\"\\${suggestions && suggestions.length > 0 ? \\`, did you mean: \\${suggestions.length === 1 ? \\`\"\\${suggestions[0]}\"\\` : suggestions.map((suggestion, i) => i < suggestions.length - 1 ? \\`\"\\${suggestion}\", \\` : \\`or \"\\${suggestion}\"\\`)}?\\` : \"\"} \\`);`}</ElseIfClause>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,SAAgBc,qBAAqB;CACnC,MAAMC,+DAAsB;AAE5B,QAAA;mDAEKZ,sBAAI;GAAA,IAACc,OAAI;AAAA,WAAE,CAACF,QAAQG;;GAAS,IAAAC,WAAA;AAAA,4DAC3BV,iGAAsB;KAAA,IACrBW,OAAI;AAAA,aAAE,4DAAoBL,QAAQK,KAAK;;KAAE,IACzCC,aAAU;AAAA,aAAE,KACVN,QAAQO,SAASC,QAAOC,YA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AS,IAC1C,OAAOmB,WAAWS,MACfC,KACCD,UACE,GAAGZ,QAAQQ,OAAOC,kBAAkB,YAAY,wEAA+D,QAC7GT,QAAQQ,OAAOC,kBACXG,QACAA,MACGF,aAAa,CACbC,WAAW,KAAK,GAAG,CACnBA,WAAW,KAAK,GAAG,CAAA,GAE/B,CACAG,KAAK,OAAO,KACf;;SACJ,IAAApC,WAAA;AAAA,kEACDhB,sBAAI;WAAA,IAACc,OAAI;AAAA,mBAAE8B,QAAQf,MAAM;;WAAA,IAAEgB,WAAQ;AAAA,oEAAGlC,oBAAkB,EAAA,CAAA;;WAAAK,UACtDa;WAAK,CAAA;;SAAA,CAAA;;OAAA,CAAA;;KAAA,CAAA;IAKf,CAAA,mDAEF5B,oCAAY;IACXkC,WAAWtC,oBAAI;IAA8C,IAAAmB,WAAA;AAAA,YAAGnB,oBAAI,iDAAiDkC,OAAOS,OAC5HZ,YAAY,EACd,CAAC,CACEuB,KACCE,QACE,IAAIA,IAAIpC,KAAI,IAAKoC,IAAIH,SAAS,EAAE,EAAEC,KAAID,UAAS,MAAMA,MAAK,GAAI,CAACE,KAAK,GAAG,GAC1E,CACAA,KAAK,KAAK,CAAA;;;IACkR,CAAA,CAAA;;EAAA,CAAA"}
|
|
@@ -143,12 +143,7 @@ function CommandRouterBody(props) {
|
|
|
143
143
|
}), createComponent(ElseIfClause, {
|
|
144
144
|
condition: code`Boolean(command) && !command.startsWith("-")`,
|
|
145
145
|
get children() {
|
|
146
|
-
return code`const suggestions =
|
|
147
|
-
caseSensitive: ${JSON.stringify(context.config.isCaseSensitive)},
|
|
148
|
-
returnType: ReturnTypeEnums.ALL_CLOSEST_MATCHES,
|
|
149
|
-
thresholdType: ThresholdTypeEnums.SIMILARITY,
|
|
150
|
-
threshold: 0.25
|
|
151
|
-
});
|
|
146
|
+
return code`const suggestions = findSuggestions(command, [${Object.values(commands ?? {}).map((cmd) => `"${cmd.name}"${(cmd.alias ?? []).map((alias) => `, "${alias}"`).join("")}`).join(", ")}]).slice(0, 3);
|
|
152
147
|
error(\`Unknown command: "\${command}"\${suggestions && suggestions.length > 0 ? \`, did you mean: \${suggestions.length === 1 ? \`"\${suggestions[0]}"\` : suggestions.map((suggestion, i) => i < suggestions.length - 1 ? \`"\${suggestion}", \` : \`or "\${suggestion}"\`)}?\` : ""} \`);`;
|
|
153
148
|
}
|
|
154
149
|
})];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-router.mjs","names":["code","computed","For","Show","ElseIfClause","IfStatement","VarDeclaration","Spacing","usePowerlines","DynamicImportStatement","CommandContext","useCommand","isDynamicPathSegment","pascalCase","CommandRouterRoute","command","_$createComponent","when","isVirtual","children","name","importPath","segments","filter","segment","length","exportName","_$createIntrinsic","_$memo","CommandRouter","props","commands","route","index","Object","keys","type","initializer","condition","value","CommandRouterBody","context","each","values","subcommand","idx","Provider","Boolean","fallback","config","isCaseSensitive","toLowerCase","replaceAll","alias","map","join","cmd","JSON","stringify"],"sources":["../../src/components/command-router.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 ElseIfClause,\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 { DynamicImportStatement } from \"@powerlines/plugin-alloy/typescript/components/dynamic-import-statement\";\nimport { CommandContext, useCommand } from \"@shell-shock/core/contexts/command\";\nimport { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport function CommandRouterRoute() {\n const command = useCommand();\n\n return (\n <>\n <Show when={!command.isVirtual}>\n <DynamicImportStatement\n name={`handle${pascalCase(command.name)}`}\n importPath={`./${\n command.segments.filter(segment => !isDynamicPathSegment(segment))[\n command.segments.filter(segment => !isDynamicPathSegment(segment))\n .length - 1\n ]\n }`}\n exportName=\"handler\"\n />\n </Show>\n <hbr />\n {code`return handle${pascalCase(command.name)}(args);`}\n </>\n );\n}\n\nexport interface CommandRouterProps {\n segments: string[];\n commands?: Record<string, CommandTree>;\n route?: Children;\n}\n\n/**\n * The command router component.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { segments, commands, route } = props;\n\n const index = computed(() => 2 + (segments.length ?? 0));\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <VarDeclaration\n let\n name=\"command\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n <Show when={commands && Object.keys(commands).length > 0}>\n <IfStatement\n condition={code`args.length > ${\n index.value\n } && args[${index.value}]`}>{code`command = args[${\n index.value\n }];`}</IfStatement>\n <hbr />\n <hbr />\n </Show>\n <CommandRouterBody\n segments={segments}\n commands={commands}\n route={route}\n />\n </Show>\n );\n}\n\n/**\n * The internal command router body logic component.\n */\nexport function CommandRouterBody(props: CommandRouterProps) {\n const { commands, route } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <For each={Object.values(commands ?? {})}>\n {(subcommand, idx) => (\n <CommandContext.Provider value={subcommand}>\n <Show\n when={Boolean(idx)}\n fallback={\n <IfStatement\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"${\n subcommand.alias && subcommand.alias.length > 0\n ? ` || ${subcommand.alias\n .map(\n alias =>\n `${context.config.isCaseSensitive ? \"command\" : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'} === \"${\n context.config.isCaseSensitive\n ? alias\n : alias\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"`\n )\n .join(\" || \")}`\n : \"\"\n }`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"${\n subcommand.alias && subcommand.alias.length > 0\n ? ` || ${subcommand.alias\n .map(\n alias =>\n `${context.config.isCaseSensitive ? \"command\" : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'} === \"${\n context.config.isCaseSensitive\n ? alias\n : alias\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"`\n )\n .join(\" || \")}`\n : \"\"\n }`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n </Show>\n </CommandContext.Provider>\n )}\n </For>\n <ElseIfClause\n condition={code`Boolean(command) && !command.startsWith(\"-\")`}>{code`const suggestions = didYouMean(command, [${Object.values(\n commands ?? {}\n )\n .map(\n cmd =>\n `\"${cmd.name}\"${(cmd.alias ?? []).map(alias => `, \"${alias}\"`).join(\"\")}`\n )\n .join(\", \")}], {\n caseSensitive: ${JSON.stringify(context.config.isCaseSensitive)},\n returnType: ReturnTypeEnums.ALL_CLOSEST_MATCHES,\n thresholdType: ThresholdTypeEnums.SIMILARITY,\n threshold: 0.25\n });\n error(\\`Unknown command: \"\\${command}\"\\${suggestions && suggestions.length > 0 ? \\`, did you mean: \\${suggestions.length === 1 ? \\`\"\\${suggestions[0]}\"\\` : suggestions.map((suggestion, i) => i < suggestions.length - 1 ? \\`\"\\${suggestion}\", \\` : \\`or \"\\${suggestion}\"\\`)}?\\` : \"\"} \\`);`}</ElseIfClause>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;AAkCA,SAAgBc,qBAAqB;CACnC,MAAMC,UAAUJ,YAAY;AAE5B,QAAA;EAAAK,gBAEKb,MAAI;GAAA,IAACc,OAAI;AAAA,WAAE,CAACF,QAAQG;;GAAS,IAAAC,WAAA;AAAA,WAAAH,gBAC3BP,wBAAsB;KAAA,IACrBW,OAAI;AAAA,aAAE,SAASP,WAAWE,QAAQK,KAAK;;KAAE,IACzCC,aAAU;AAAA,aAAE,KACVN,QAAQO,SAASC,QAAOC,YAAW,CAACZ,qBAAqBY,QAAQ,CAAC,CAChET,QAAQO,SAASC,QAAOC,YAAW,CAACZ,qBAAqBY,QAAQ,CAAC,CAC/DC,SAAS;;KAGhBC,YAAU;KAAA,CAAA;;GAAA,CAAA;EAAAC,gBAAA,OAAA,EAAA,CAAA;EAAAC,WAIb5B,IAAI,gBAAgBa,WAAWE,QAAQK,KAAK,CAAA,SAAS;EAAA;;;;;AAc5D,SAAgBS,cAAcC,OAA2B;CACvD,MAAM,EAAER,UAAUS,UAAUC,UAAUF;CAEtC,MAAMG,QAAQhC,eAAe,KAAKqB,SAASG,UAAU,GAAG;AAExD,QAAAT,gBACGb,MAAI;EAAA,IAACc,OAAI;AAAA,UAAEc,YAAYG,OAAOC,KAAKJ,SAAS,CAACN,SAAS;;EAAC,IAAAN,WAAA;AAAA,UAAA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oBAAkB,EAAA,CAAA;;WAAAK,UACtDa;WAAK,CAAA;;SAAA,CAAA;;OAAA,CAAA;;KAAA,CAAA;IAKf,CAAA,EAAAhB,gBAEFZ,cAAY;IACXkC,WAAWtC,IAAI;IAA8C,IAAAmB,WAAA;AAAA,YAAGnB,IAAI,4CAA4CkC,OAAOS,OACvHZ,YAAY,EACd,CAAC,CACEuB,KACCE,QACE,IAAIA,IAAIpC,KAAI,IAAKoC,IAAIH,SAAS,EAAE,EAAEC,KAAID,UAAS,MAAMA,MAAK,GAAI,CAACE,KAAK,GAAG,GAC1E,CACAA,KAAK,KAAK,CAAA;2BACQE,KAAKC,UAAUjB,QAAQQ,OAAOC,gBAAgB,CAAA;;;;;;;IAK4N,CAAA,CAAA;;EAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"command-router.mjs","names":["code","computed","For","Show","ElseIfClause","IfStatement","VarDeclaration","Spacing","usePowerlines","DynamicImportStatement","CommandContext","useCommand","isDynamicPathSegment","pascalCase","CommandRouterRoute","command","_$createComponent","when","isVirtual","children","name","importPath","segments","filter","segment","length","exportName","_$createIntrinsic","_$memo","CommandRouter","props","commands","route","index","Object","keys","type","initializer","condition","value","CommandRouterBody","context","each","values","subcommand","idx","Provider","Boolean","fallback","config","isCaseSensitive","toLowerCase","replaceAll","alias","map","join","cmd"],"sources":["../../src/components/command-router.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 ElseIfClause,\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 { DynamicImportStatement } from \"@powerlines/plugin-alloy/typescript/components/dynamic-import-statement\";\nimport { CommandContext, useCommand } from \"@shell-shock/core/contexts/command\";\nimport { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport function CommandRouterRoute() {\n const command = useCommand();\n\n return (\n <>\n <Show when={!command.isVirtual}>\n <DynamicImportStatement\n name={`handle${pascalCase(command.name)}`}\n importPath={`./${\n command.segments.filter(segment => !isDynamicPathSegment(segment))[\n command.segments.filter(segment => !isDynamicPathSegment(segment))\n .length - 1\n ]\n }`}\n exportName=\"handler\"\n />\n </Show>\n <hbr />\n {code`return handle${pascalCase(command.name)}(args);`}\n </>\n );\n}\n\nexport interface CommandRouterProps {\n segments: string[];\n commands?: Record<string, CommandTree>;\n route?: Children;\n}\n\n/**\n * The command router component.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { segments, commands, route } = props;\n\n const index = computed(() => 2 + (segments.length ?? 0));\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <VarDeclaration\n let\n name=\"command\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <Spacing />\n <Show when={commands && Object.keys(commands).length > 0}>\n <IfStatement\n condition={code`args.length > ${\n index.value\n } && args[${index.value}]`}>{code`command = args[${\n index.value\n }];`}</IfStatement>\n <hbr />\n <hbr />\n </Show>\n <CommandRouterBody\n segments={segments}\n commands={commands}\n route={route}\n />\n </Show>\n );\n}\n\n/**\n * The internal command router body logic component.\n */\nexport function CommandRouterBody(props: CommandRouterProps) {\n const { commands, route } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <For each={Object.values(commands ?? {})}>\n {(subcommand, idx) => (\n <CommandContext.Provider value={subcommand}>\n <Show\n when={Boolean(idx)}\n fallback={\n <IfStatement\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"${\n subcommand.alias && subcommand.alias.length > 0\n ? ` || ${subcommand.alias\n .map(\n alias =>\n `${context.config.isCaseSensitive ? \"command\" : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'} === \"${\n context.config.isCaseSensitive\n ? alias\n : alias\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"`\n )\n .join(\" || \")}`\n : \"\"\n }`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"${\n subcommand.alias && subcommand.alias.length > 0\n ? ` || ${subcommand.alias\n .map(\n alias =>\n `${context.config.isCaseSensitive ? \"command\" : 'command.toLowerCase().replaceAll(\"-\", \"\").replaceAll(\"_\", \"\")'} === \"${\n context.config.isCaseSensitive\n ? alias\n : alias\n .toLowerCase()\n .replaceAll(\"-\", \"\")\n .replaceAll(\"_\", \"\")\n }\"`\n )\n .join(\" || \")}`\n : \"\"\n }`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n </Show>\n </CommandContext.Provider>\n )}\n </For>\n <ElseIfClause\n condition={code`Boolean(command) && !command.startsWith(\"-\")`}>{code`const suggestions = findSuggestions(command, [${Object.values(\n commands ?? {}\n )\n .map(\n cmd =>\n `\"${cmd.name}\"${(cmd.alias ?? []).map(alias => `, \"${alias}\"`).join(\"\")}`\n )\n .join(\", \")}]).slice(0, 3);\n error(\\`Unknown command: \"\\${command}\"\\${suggestions && suggestions.length > 0 ? \\`, did you mean: \\${suggestions.length === 1 ? \\`\"\\${suggestions[0]}\"\\` : suggestions.map((suggestion, i) => i < suggestions.length - 1 ? \\`\"\\${suggestion}\", \\` : \\`or \"\\${suggestion}\"\\`)}?\\` : \"\"} \\`);`}</ElseIfClause>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;;AAkCA,SAAgBc,qBAAqB;CACnC,MAAMC,UAAUJ,YAAY;AAE5B,QAAA;EAAAK,gBAEKb,MAAI;GAAA,IAACc,OAAI;AAAA,WAAE,CAACF,QAAQG;;GAAS,IAAAC,WAAA;AAAA,WAAAH,gBAC3BP,wBAAsB;KAAA,IACrBW,OAAI;AAAA,aAAE,SAASP,WAAWE,QAAQK,KAAK;;KAAE,IACzCC,aAAU;AAAA,aAAE,KACVN,QAAQO,SAASC,QAAOC,YAAW,CAACZ,qBAAqBY,QAAQ,CAAC,CAChET,QAAQO,SAASC,QAAOC,YAAW,CAACZ,qBAAqBY,QAAQ,CAAC,CAC/DC,SAAS;;KAGhBC,YAAU;KAAA,CAAA;;GAAA,CAAA;EAAAC,gBAAA,OAAA,EAAA,CAAA;EAAAC,WAIb5B,IAAI,gBAAgBa,WAAWE,QAAQK,KAAK,CAAA,SAAS;EAAA;;;;;AAc5D,SAAgBS,cAAcC,OAA2B;CACvD,MAAM,EAAER,UAAUS,UAAUC,UAAUF;CAEtC,MAAMG,QAAQhC,eAAe,KAAKqB,SAASG,UAAU,GAAG;AAExD,QAAAT,gBACGb,MAAI;EAAA,IAAC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WAAA,IAACc,OAAI;AAAA,mBAAE8B,QAAQf,MAAM;;WAAA,IAAEgB,WAAQ;AAAA,mBAAAhC,gBAAGF,oBAAkB,EAAA,CAAA;;WAAAK,UACtDa;WAAK,CAAA;;SAAA,CAAA;;OAAA,CAAA;;KAAA,CAAA;IAKf,CAAA,EAAAhB,gBAEFZ,cAAY;IACXkC,WAAWtC,IAAI;IAA8C,IAAAmB,WAAA;AAAA,YAAGnB,IAAI,iDAAiDkC,OAAOS,OAC5HZ,YAAY,EACd,CAAC,CACEuB,KACCE,QACE,IAAIA,IAAIpC,KAAI,IAAKoC,IAAIH,SAAS,EAAE,EAAEC,KAAID,UAAS,MAAMA,MAAK,GAAI,CAACE,KAAK,GAAG,GAC1E,CACAA,KAAK,KAAK,CAAA;;;IACkR,CAAA,CAAA;;EAAA,CAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
2
2
|
|
|
3
3
|
//#region src/components/exit-function-declaration.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* The `exit` handler function declaration code for the Shell Shock project.
|
|
6
6
|
*/
|
|
7
|
-
declare function ExitFunctionDeclaration():
|
|
7
|
+
declare function ExitFunctionDeclaration(): _alloy_js_core0.Children;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { ExitFunctionDeclaration };
|
|
10
10
|
//# sourceMappingURL=exit-function-declaration.d.cts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
2
2
|
|
|
3
3
|
//#region src/components/exit-function-declaration.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* The `exit` handler function declaration code for the Shell Shock project.
|
|
6
6
|
*/
|
|
7
|
-
declare function ExitFunctionDeclaration():
|
|
7
|
+
declare function ExitFunctionDeclaration(): _alloy_js_core0.Children;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { ExitFunctionDeclaration };
|
|
10
10
|
//# sourceMappingURL=exit-function-declaration.d.mts.map
|
package/dist/components/help.cjs
CHANGED
|
@@ -68,7 +68,7 @@ function HelpOptions(props) {
|
|
|
68
68
|
if (alias.length === 1) flags.push(`-${alias}`);
|
|
69
69
|
else names.push(`--${(0, __stryke_string_format_kebab_case.kebabCase)(alias)}`);
|
|
70
70
|
});
|
|
71
|
-
return __alloy_js_core.code`[{ value: colors.text.body.primary("${flags.length > 0 ? `${flags.sort().join(", ")}${names.length > 0 ? ", " : ""}` : ""}${names.length > 0 ? names.sort().join(", ") : ""}${option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string ? ` <${(0, __stryke_string_format_snake_case.snakeCase)(option.name)}${option.variadic ? "..." : ""}>` : option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? ` <${(0, __stryke_string_format_snake_case.snakeCase)(option.name)}${option.variadic ? "..." : ""}>` : ""}"), align: "right", border: "none", maxWidth: "1/3" }, { value: colors.text.body.tertiary("${option.description.replace(/\.+$/, "")} ${option.env || option.default !== void 0 ? `(${option.env ? `env: ${context.config.envPrefix}_${option.env}${option.default !== void 0 ? ", " : ""}` : ""}${option.default !== void 0 ? `default: ${JSON.stringify(option.default)}` : ""})` : ""}."), align: "left", border: "none" }], `;
|
|
71
|
+
return __alloy_js_core.code`[{ value: colors.text.body.primary("${flags.length > 0 ? `${flags.sort().join(", ")}${names.length > 0 ? ", " : ""}` : ""}${names.length > 0 ? names.sort().join(", ") : ""}${option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.string ? ` <${(0, __stryke_string_format_snake_case.snakeCase)(option.name)}${option.variadic ? "..." : ""}>` : option.kind === __powerlines_deepkit_vendor_type.ReflectionKind.number ? ` <${(0, __stryke_string_format_snake_case.snakeCase)(option.name)}${option.variadic ? "..." : ""}>` : ""}"), align: "right", border: "none", maxWidth: "1/3" }, { value: colors.text.body.tertiary("${option.description.replace(/\.+$/, "")} ${option.env || option.default !== void 0 ? `(${option.env ? `env: ${context.config.envPrefix}_${option.env}${option.default !== void 0 ? ", " : ""}` : ""}${option.default !== void 0 ? `default: ${JSON.stringify(option.default).replace(/"/g, "\\\"")}` : ""})` : ""}."), align: "left", border: "none" }], `;
|
|
72
72
|
}
|
|
73
73
|
}),
|
|
74
74
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.cjs","names":["code","computed","For","Show","ReflectionKind","Spacing","usePowerlines","getAppBin","getDynamicPathSegmentName","isDynamicPathSegment","sortOptions","useTheme","kebabCase","snakeCase","HelpUsage","props","command","indent","context","theme","_$createComponent","each","Object","keys","config","bin","hardline","children","_$memo","segments","length","map","segment","join","values","arguments","argument","name","kind","string","number","variadic","padding","app","_$createIntrinsic","when","HelpOptions","options","option","flags","names","push","alias","forEach","sort","description","replace","env","default","undefined","envPrefix","JSON","stringify","HelpCommands","commands","child","BaseHelp","filterGlobalOptions","filter","some","globalOption","includes","value","VirtualHelp","doubleHardline","joiner","ender","icon","title","isVirtual","CommandHelp"],"sources":["../../src/components/help.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 { code, computed, For, Show } from \"@alloy-js/core\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport { sortOptions } from \"@shell-shock/core/plugin-utils/reflect\";\nimport type {\n CommandOption,\n CommandTree\n} from \"@shell-shock/core/types/command\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport interface HelpUsageProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * The padding scale to apply to the help display headings.\n *\n * @remarks\n * This value is multiplied by the theme's app padding to determine the final padding.\n *\n * @defaultValue 2\n */\n indent?: number;\n}\n\n/**\n * A component that generates the usage display for a command.\n */\nexport function HelpUsage(props: HelpUsageProps) {\n const { command, indent = 2 } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const theme = useTheme();\n\n return (\n <>\n <For each={Object.keys(context.config.bin)} hardline>\n {bin => (\n <>\n {code`\n writeLine(\n colors.text.body.secondary(\\`\\$ \\${colors.text.usage.bin(\"${bin}\")}${\n command.segments.length > 0\n ? ` ${command.segments\n .map(\n segment =>\n `\\${colors.text.usage.${isDynamicPathSegment(segment) ? \"dynamic\" : \"command\"}(\"${\n isDynamicPathSegment(segment)\n ? `[${snakeCase(getDynamicPathSegmentName(segment))}]`\n : segment\n }\")}`\n )\n .join(\" \")}`\n : \"\"\n }${Object.values(command.children).length > 0 ? ` \\${colors.text.usage.dynamic(\"[command]\")}` : \"\"}${\n command.arguments.length > 0\n ? ` ${command.arguments\n .map(\n argument =>\n `\\${colors.text.usage.arguments(\"<${snakeCase(argument.name)}${\n (argument.kind === ReflectionKind.string ||\n argument.kind === ReflectionKind.number) &&\n argument.variadic\n ? \"...\"\n : \"\"\n }>\")}`\n )\n .join(\" \")}`\n : \"\"\n } \\${colors.text.usage.options(\"[options]\")}\\`), { padding: ${theme.padding.app * indent} }\n );`}\n <hbr />\n </>\n )}\n </For>\n <Show when={command.arguments.length > 0}>\n <hbr />\n <For each={Object.keys(context.config.bin)} hardline>\n {bin => (\n <>\n {code`\n writeLine(\n colors.text.body.secondary(\\`\\$ \\${colors.text.usage.bin(\"${bin}\")}${\n command.segments.length > 0\n ? ` ${command.segments\n .map(\n segment =>\n `\\${colors.text.usage.${isDynamicPathSegment(segment) ? \"dynamic\" : \"command\"}(\"${\n isDynamicPathSegment(segment)\n ? `[${snakeCase(getDynamicPathSegmentName(segment))}]`\n : segment\n }\")}`\n )\n .join(\" \")}`\n : \"\"\n }${Object.values(command.children).length > 0 ? ` \\${colors.text.usage.dynamic(\"[command]\")}` : \"\"} \\${colors.text.usage.options(\"[options]\")}${\n command.arguments.length > 0\n ? ` ${command.arguments\n .map(\n argument =>\n `\\${colors.text.usage.arguments(\"<${snakeCase(argument.name)}${\n (argument.kind === ReflectionKind.string ||\n argument.kind === ReflectionKind.number) &&\n argument.variadic\n ? \"...\"\n : \"\"\n }>\")}`\n )\n .join(\" \")}`\n : \"\"\n }\\`), { padding: ${theme.padding.app * indent} }\n );`}\n <hbr />\n </>\n )}\n </For>\n </Show>\n </>\n );\n}\n\nexport interface HelpOptionsProps {\n /**\n * The options to display help for.\n */\n options: CommandOption[];\n}\n\n/**\n * A component that generates the options table display for a command.\n */\nexport function HelpOptions(props: HelpOptionsProps) {\n const { options } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n {code`table([ `}\n <hbr />\n <For each={sortOptions(options)} hardline>\n {option => {\n const flags = [] as string[];\n const names = [] as string[];\n if (option.name.length === 1) {\n flags.push(`-${option.name}`);\n } else {\n names.push(`--${kebabCase(option.name)}`);\n }\n\n option.alias.forEach((alias: string) => {\n if (alias.length === 1) {\n flags.push(`-${alias}`);\n } else {\n names.push(`--${kebabCase(alias)}`);\n }\n });\n\n return code`[{ value: colors.text.body.primary(\"${\n flags.length > 0\n ? `${flags.sort().join(\", \")}${names.length > 0 ? \", \" : \"\"}`\n : \"\"\n }${names.length > 0 ? names.sort().join(\", \") : \"\"}${\n option.kind === ReflectionKind.string\n ? ` <${snakeCase(option.name)}${option.variadic ? \"...\" : \"\"}>`\n : option.kind === ReflectionKind.number\n ? ` <${snakeCase(option.name)}${option.variadic ? \"...\" : \"\"}>`\n : \"\"\n }\"), align: \"right\", border: \"none\", maxWidth: \"1/3\" }, { value: colors.text.body.tertiary(\"${option.description.replace(\n /\\.+$/,\n \"\"\n )} ${\n option.env || option.default !== undefined\n ? `(${\n option.env\n ? `env: ${context.config.envPrefix}_${option.env}${\n option.default !== undefined ? \", \" : \"\"\n }`\n : \"\"\n }${\n option.default !== undefined\n ? `default: ${JSON.stringify(option.default)}`\n : \"\"\n })`\n : \"\"\n }.\"), align: \"left\", border: \"none\" }], `;\n }}\n </For>\n <hbr />\n {code` ]); `}\n </>\n );\n}\n\nexport interface HelpCommandsProps {\n /**\n * A mapping of command names to their command definitions.\n */\n commands: Record<string, CommandTree>;\n}\n\n/**\n * A component that generates the commands table display for a command.\n */\nexport function HelpCommands(props: HelpCommandsProps) {\n const { commands } = props;\n\n return (\n <>\n {code`table([ `}\n <hbr />\n <For each={Object.values(commands)} hardline>\n {child =>\n code`[{ value: colors.text.body.primary(\"${\n child.name\n }\"), align: \"right\", border: \"none\" }, { value: colors.text.body.tertiary(\"${child.description.replace(\n /\\.+$/,\n \"\"\n )}\"), align: \"left\", border: \"none\" }], `\n }\n </For>\n <hbr />\n {code` ]); `}\n </>\n );\n}\n\nexport interface BaseHelpProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * Whether to filter out global options from the help display.\n *\n * @remarks\n * When enabled, any options that are present in the global options context will be filtered out from the help display. This is useful for sub-commands to avoid displaying global options that are not relevant to the specific command.\n *\n * @defaultValue false\n */\n filterGlobalOptions?: boolean;\n\n /**\n * The padding scale to apply to the help display headings.\n *\n * @remarks\n * This value is multiplied by the theme's app padding to determine the final padding.\n *\n * @defaultValue 1\n */\n indent?: number;\n}\n\n/**\n * A component that generates the `help` function declaration for a command.\n */\nexport function BaseHelp(props: BaseHelpProps) {\n const { command, indent = 1, filterGlobalOptions = false } = props;\n\n const theme = useTheme();\n const context = usePowerlines<ScriptPresetContext>();\n\n const options = computed(() =>\n filterGlobalOptions\n ? Object.values(command.options).filter(\n option =>\n !context.options.some(\n globalOption =>\n globalOption.name === option.name ||\n option.alias.includes(globalOption.name) ||\n globalOption.alias?.includes(option.name) ||\n globalOption.alias?.some(alias => option.alias.includes(alias))\n )\n )\n : Object.values(command.options)\n );\n\n return (\n <>\n {code`writeLine(colors.bold(colors.text.heading.secondary(\"Usage:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpUsage command={command} indent={indent} />\n <Spacing />\n <Show when={options.value.length > 0}>\n {code`writeLine(\"\");\n writeLine(colors.bold(colors.text.heading.secondary(\"Options:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpOptions options={options.value} />\n <hbr />\n <hbr />\n </Show>\n <Show when={Object.keys(command.children).length > 0}>\n {code`writeLine(\"\");\n writeLine(colors.bold(colors.text.heading.secondary(\"Commands:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpCommands commands={command.children} />\n <hbr />\n <hbr />\n </Show>\n </>\n );\n}\n\nexport interface VirtualHelpProps {\n /**\n * The options to display help for.\n */\n options: CommandOption[];\n\n /**\n * A mapping of command names to their command definitions.\n */\n commands: Record<string, CommandTree>;\n\n /**\n * The command path to generate help for, used for generating the help invocation instructions.\n *\n * @remarks\n * This is optional since the virtual command entry component can be used for both the global binary executable and virtual commands (there will be no command definition for the binary executable).\n */\n segments?: string[];\n}\n\n/**\n * A component that generates the invocation of the `help` function for a command.\n */\nexport function VirtualHelp(props: VirtualHelpProps) {\n const { options, segments, commands } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <hbr />\n {code`writeLine(colors.bold(colors.text.heading.secondary(\"Global Options:\")));`}\n <hbr />\n <HelpOptions options={options} />\n {code`writeLine(\"\"); `}\n <Spacing />\n <Show when={Object.keys(commands).length > 0}>\n {code`writeLine(colors.text.body.secondary(\"The following commands are available:\"));\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n <For\n each={Object.values(commands)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n {code`\n writeLine(colors.text.heading.primary(${\n child.icon\n ? `(isUnicodeSupported ? \" ${child.icon} \" : \"\") + `\n : \"\"\n }\"${child.title} ${child.isVirtual ? \"\" : \"Command\"}\"));\n writeLine(\"\");\n writeLine(colors.text.body.secondary(\"${child.description}\"));\n writeLine(\"\");\n `}\n <hbr />\n <BaseHelp command={child} indent={2} filterGlobalOptions />\n <hbr />\n </>\n )}\n </For>\n {code`help(\"Running a specific command with the help flag (via: '${getAppBin(\n context\n )}${\n segments && segments.length > 0 ? ` ${segments.join(\" \")}` : \"\"\n } <specific command> --help') will provide additional information that is specific to that command.\");\n writeLine(\"\");`}\n </Show>\n </>\n );\n}\n\nexport interface CommandHelpProps {\n /**\n * A mapping of command names to their command definitions.\n */\n command: CommandTree;\n}\n\n/**\n * A component that generates the invocation of the `help` function for a command.\n */\nexport function CommandHelp(props: CommandHelpProps) {\n const { command } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n {code`writeLine(\"\"); `}\n <Spacing />\n <BaseHelp command={command} filterGlobalOptions={false} />\n {code`writeLine(\"\"); `}\n <Spacing />\n <Show when={Object.keys(command.children).length > 0}>\n {code`writeLine(colors.text.body.secondary(\"The following sub-commands are available:\"));\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n <For\n each={Object.values(command.children)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n {code`\n writeLine(colors.text.heading.primary(${\n child.icon\n ? `(isUnicodeSupported ? \" ${child.icon} \" : \"\") + `\n : \"\"\n }\"${child.title} ${child.isVirtual ? \"\" : \"Command\"}\"));\n writeLine(\"\");\n writeLine(colors.text.body.secondary(\"${child.description}\"));\n writeLine(\"\");\n `}\n <hbr />\n <BaseHelp command={child} indent={2} filterGlobalOptions />\n <hbr />\n </>\n )}\n </For>\n {code`help(\"Running a specific command with the help flag (via: '${getAppBin(\n context\n )} ${command.segments.join(\n \" \"\n )} <specific command> --help') will provide additional information that is specific to that command.\");\n writeLine(\"\");`}\n </Show>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyDA,SAAgBc,UAAUC,OAAuB;CAC/C,MAAM,EAAEC,SAASC,SAAS,MAAMF;CAEhC,MAAMG,8EAA8C;CACpD,MAAMC,iEAAkB;AAExB,QAAA,kDAEKjB,qBAAG;EAAA,IAACmB,OAAI;AAAA,UAAEC,OAAOC,KAAKL,QAAQM,OAAOC,IAAI;;EAAEC,UAAQ;EAAAC,WACjDF,QAAG,6CAECzB,oBAAI;;oEAEmDyB,IAAG,KAC7DT,QAAQa,SAASC,SAAS,IACtB,IAAId,QAAQa,SACTE,KACCC,YACE,kGAA6CA,QAAQ,GAAG,YAAY,UAAS,8EACtDA,QAAQ,GACzB,oIAAwCA,QAAQ,CAAC,CAAA,KACjDA,QAAO,KAEhB,CACAC,KAAK,IAAI,KACZ,KACHX,OAAOY,OAAOlB,QAAQW,SAAS,CAACG,SAAS,IAAI,gDAAgD,KAC9Fd,QAAQmB,UAAUL,SAAS,IACvB,IAAId,QAAQmB,UACTJ,KACCK,aACE,qFAA8CA,SAASC,KAAK,IACzDD,SAASE,SAASlC,gDAAemC,UAChCH,SAASE,SAASlC,gDAAeoC,WACnCJ,SAASK,WACL,QACA,GAAE,MAEX,CACAR,KAAK,IAAI,KACZ,GAAE,6DACsDd,MAAMuB,QAAQC,MAAM1B,OAAM;UACvF,mDAAA,OAAA,EAAA,CAAA,CAAA;EAGA,CAAA,mDAEFd,sBAAI;EAAA,IAAC0C,OAAI;AAAA,U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I,IAAID,SAASI,KAAK,IAAI,KAAK,GAAE;wBAElD;KAAA;;GAAA,CAAA;EAAA;;;;;AAgBvB,SAAgB+C,YAAYjE,OAAyB;CACnD,MAAM,EAAEC,YAAYD;CAEpB,MAAMG,8EAA8C;AAEpD,QAAA;EAEKlB,oBAAI;mDACJK,2DAAO,EAAA,CAAA;mDACP6D,UAAQ;GAAUlD;GAASmD,qBAAqB;GAAK,CAAA;EACrDnE,oBAAI;mDACJK,2DAAO,EAAA,CAAA;mDACPF,sBAAI;GAAA,IAAC0C,OAAI;AAAA,WAAEvB,OAAOC,KAAKP,QAAQW,SAAS,CAACG,SAAS;;GAAC,IAAAH,WAAA;AAAA,WAAA;KACjD3B,oBAAI;;sDACW,OAAA,EAAA,CAAA;sDAAA,OAAA,EAAA,CAAA;sDAGfE,qBAAG;MAAA,IACFmB,OAAI;AAAA,cAAEC,OAAOY,OAAOlB,QAAQW,SAAS;;MACrC+C,gBAAc;MACdC,QAAQ3E,oBAAI;MACZ4E,OAAO5E,oBAAI;MAAiB2B,WAC3BsC,UAAK;mDAEDjE,oBAAI;wDAEDiE,MAAMY,OACF,2BAA2BZ,MAAMY,KAAI,gBACrC,GAAE,GACJZ,MAAMa,MAAK,GAAIb,MAAMc,YAAY,KAAK,UAAS;;wDAEXd,MAAMV,YAAW;;kBAExD;wDAAA,OAAA,EAAA,CAAA;wDAEFW,UAAQ;QAAClD,SAASiD;QAAOhD,QAAQ;QAAGkD,qBAAmB;QAAA,CAAA;wDAAA,OAAA,EAAA,CAAA;OAAA;MAG3D,CAAA;iDAEFnE,oBAAI,6HACHkB,QACD,CAAA,GAAIF,QAAQa,SAASI,KACpB,IACD,CAAA;wBACc;KAAA;;GAAA,CAAA;EAAA"}
|
|
1
|
+
{"version":3,"file":"help.cjs","names":["code","computed","For","Show","ReflectionKind","Spacing","usePowerlines","getAppBin","getDynamicPathSegmentName","isDynamicPathSegment","sortOptions","useTheme","kebabCase","snakeCase","HelpUsage","props","command","indent","context","theme","_$createComponent","each","Object","keys","config","bin","hardline","children","_$memo","segments","length","map","segment","join","values","arguments","argument","name","kind","string","number","variadic","padding","app","_$createIntrinsic","when","HelpOptions","options","option","flags","names","push","alias","forEach","sort","description","replace","env","default","undefined","envPrefix","JSON","stringify","HelpCommands","commands","child","BaseHelp","filterGlobalOptions","filter","some","globalOption","includes","value","VirtualHelp","doubleHardline","joiner","ender","icon","title","isVirtual","CommandHelp"],"sources":["../../src/components/help.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 { code, computed, For, Show } from \"@alloy-js/core\";\nimport { ReflectionKind } from \"@powerlines/deepkit/vendor/type\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport { sortOptions } from \"@shell-shock/core/plugin-utils/reflect\";\nimport type {\n CommandOption,\n CommandTree\n} from \"@shell-shock/core/types/command\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport interface HelpUsageProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * The padding scale to apply to the help display headings.\n *\n * @remarks\n * This value is multiplied by the theme's app padding to determine the final padding.\n *\n * @defaultValue 2\n */\n indent?: number;\n}\n\n/**\n * A component that generates the usage display for a command.\n */\nexport function HelpUsage(props: HelpUsageProps) {\n const { command, indent = 2 } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const theme = useTheme();\n\n return (\n <>\n <For each={Object.keys(context.config.bin)} hardline>\n {bin => (\n <>\n {code`\n writeLine(\n colors.text.body.secondary(\\`\\$ \\${colors.text.usage.bin(\"${bin}\")}${\n command.segments.length > 0\n ? ` ${command.segments\n .map(\n segment =>\n `\\${colors.text.usage.${isDynamicPathSegment(segment) ? \"dynamic\" : \"command\"}(\"${\n isDynamicPathSegment(segment)\n ? `[${snakeCase(getDynamicPathSegmentName(segment))}]`\n : segment\n }\")}`\n )\n .join(\" \")}`\n : \"\"\n }${Object.values(command.children).length > 0 ? ` \\${colors.text.usage.dynamic(\"[command]\")}` : \"\"}${\n command.arguments.length > 0\n ? ` ${command.arguments\n .map(\n argument =>\n `\\${colors.text.usage.arguments(\"<${snakeCase(argument.name)}${\n (argument.kind === ReflectionKind.string ||\n argument.kind === ReflectionKind.number) &&\n argument.variadic\n ? \"...\"\n : \"\"\n }>\")}`\n )\n .join(\" \")}`\n : \"\"\n } \\${colors.text.usage.options(\"[options]\")}\\`), { padding: ${theme.padding.app * indent} }\n );`}\n <hbr />\n </>\n )}\n </For>\n <Show when={command.arguments.length > 0}>\n <hbr />\n <For each={Object.keys(context.config.bin)} hardline>\n {bin => (\n <>\n {code`\n writeLine(\n colors.text.body.secondary(\\`\\$ \\${colors.text.usage.bin(\"${bin}\")}${\n command.segments.length > 0\n ? ` ${command.segments\n .map(\n segment =>\n `\\${colors.text.usage.${isDynamicPathSegment(segment) ? \"dynamic\" : \"command\"}(\"${\n isDynamicPathSegment(segment)\n ? `[${snakeCase(getDynamicPathSegmentName(segment))}]`\n : segment\n }\")}`\n )\n .join(\" \")}`\n : \"\"\n }${Object.values(command.children).length > 0 ? ` \\${colors.text.usage.dynamic(\"[command]\")}` : \"\"} \\${colors.text.usage.options(\"[options]\")}${\n command.arguments.length > 0\n ? ` ${command.arguments\n .map(\n argument =>\n `\\${colors.text.usage.arguments(\"<${snakeCase(argument.name)}${\n (argument.kind === ReflectionKind.string ||\n argument.kind === ReflectionKind.number) &&\n argument.variadic\n ? \"...\"\n : \"\"\n }>\")}`\n )\n .join(\" \")}`\n : \"\"\n }\\`), { padding: ${theme.padding.app * indent} }\n );`}\n <hbr />\n </>\n )}\n </For>\n </Show>\n </>\n );\n}\n\nexport interface HelpOptionsProps {\n /**\n * The options to display help for.\n */\n options: CommandOption[];\n}\n\n/**\n * A component that generates the options table display for a command.\n */\nexport function HelpOptions(props: HelpOptionsProps) {\n const { options } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n {code`table([ `}\n <hbr />\n <For each={sortOptions(options)} hardline>\n {option => {\n const flags = [] as string[];\n const names = [] as string[];\n if (option.name.length === 1) {\n flags.push(`-${option.name}`);\n } else {\n names.push(`--${kebabCase(option.name)}`);\n }\n\n option.alias.forEach((alias: string) => {\n if (alias.length === 1) {\n flags.push(`-${alias}`);\n } else {\n names.push(`--${kebabCase(alias)}`);\n }\n });\n\n return code`[{ value: colors.text.body.primary(\"${\n flags.length > 0\n ? `${flags.sort().join(\", \")}${names.length > 0 ? \", \" : \"\"}`\n : \"\"\n }${names.length > 0 ? names.sort().join(\", \") : \"\"}${\n option.kind === ReflectionKind.string\n ? ` <${snakeCase(option.name)}${option.variadic ? \"...\" : \"\"}>`\n : option.kind === ReflectionKind.number\n ? ` <${snakeCase(option.name)}${option.variadic ? \"...\" : \"\"}>`\n : \"\"\n }\"), align: \"right\", border: \"none\", maxWidth: \"1/3\" }, { value: colors.text.body.tertiary(\"${option.description.replace(\n /\\.+$/,\n \"\"\n )} ${\n option.env || option.default !== undefined\n ? `(${\n option.env\n ? `env: ${context.config.envPrefix}_${option.env}${\n option.default !== undefined ? \", \" : \"\"\n }`\n : \"\"\n }${\n option.default !== undefined\n ? `default: ${JSON.stringify(option.default).replace(/\"/g, '\\\\\"')}`\n : \"\"\n })`\n : \"\"\n }.\"), align: \"left\", border: \"none\" }], `;\n }}\n </For>\n <hbr />\n {code` ]); `}\n </>\n );\n}\n\nexport interface HelpCommandsProps {\n /**\n * A mapping of command names to their command definitions.\n */\n commands: Record<string, CommandTree>;\n}\n\n/**\n * A component that generates the commands table display for a command.\n */\nexport function HelpCommands(props: HelpCommandsProps) {\n const { commands } = props;\n\n return (\n <>\n {code`table([ `}\n <hbr />\n <For each={Object.values(commands)} hardline>\n {child =>\n code`[{ value: colors.text.body.primary(\"${\n child.name\n }\"), align: \"right\", border: \"none\" }, { value: colors.text.body.tertiary(\"${child.description.replace(\n /\\.+$/,\n \"\"\n )}\"), align: \"left\", border: \"none\" }], `\n }\n </For>\n <hbr />\n {code` ]); `}\n </>\n );\n}\n\nexport interface BaseHelpProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * Whether to filter out global options from the help display.\n *\n * @remarks\n * When enabled, any options that are present in the global options context will be filtered out from the help display. This is useful for sub-commands to avoid displaying global options that are not relevant to the specific command.\n *\n * @defaultValue false\n */\n filterGlobalOptions?: boolean;\n\n /**\n * The padding scale to apply to the help display headings.\n *\n * @remarks\n * This value is multiplied by the theme's app padding to determine the final padding.\n *\n * @defaultValue 1\n */\n indent?: number;\n}\n\n/**\n * A component that generates the `help` function declaration for a command.\n */\nexport function BaseHelp(props: BaseHelpProps) {\n const { command, indent = 1, filterGlobalOptions = false } = props;\n\n const theme = useTheme();\n const context = usePowerlines<ScriptPresetContext>();\n\n const options = computed(() =>\n filterGlobalOptions\n ? Object.values(command.options).filter(\n option =>\n !context.options.some(\n globalOption =>\n globalOption.name === option.name ||\n option.alias.includes(globalOption.name) ||\n globalOption.alias?.includes(option.name) ||\n globalOption.alias?.some(alias => option.alias.includes(alias))\n )\n )\n : Object.values(command.options)\n );\n\n return (\n <>\n {code`writeLine(colors.bold(colors.text.heading.secondary(\"Usage:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpUsage command={command} indent={indent} />\n <Spacing />\n <Show when={options.value.length > 0}>\n {code`writeLine(\"\");\n writeLine(colors.bold(colors.text.heading.secondary(\"Options:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpOptions options={options.value} />\n <hbr />\n <hbr />\n </Show>\n <Show when={Object.keys(command.children).length > 0}>\n {code`writeLine(\"\");\n writeLine(colors.bold(colors.text.heading.secondary(\"Commands:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpCommands commands={command.children} />\n <hbr />\n <hbr />\n </Show>\n </>\n );\n}\n\nexport interface VirtualHelpProps {\n /**\n * The options to display help for.\n */\n options: CommandOption[];\n\n /**\n * A mapping of command names to their command definitions.\n */\n commands: Record<string, CommandTree>;\n\n /**\n * The command path to generate help for, used for generating the help invocation instructions.\n *\n * @remarks\n * This is optional since the virtual command entry component can be used for both the global binary executable and virtual commands (there will be no command definition for the binary executable).\n */\n segments?: string[];\n}\n\n/**\n * A component that generates the invocation of the `help` function for a command.\n */\nexport function VirtualHelp(props: VirtualHelpProps) {\n const { options, segments, commands } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <hbr />\n {code`writeLine(colors.bold(colors.text.heading.secondary(\"Global Options:\")));`}\n <hbr />\n <HelpOptions options={options} />\n {code`writeLine(\"\"); `}\n <Spacing />\n <Show when={Object.keys(commands).length > 0}>\n {code`writeLine(colors.text.body.secondary(\"The following commands are available:\"));\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n <For\n each={Object.values(commands)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n {code`\n writeLine(colors.text.heading.primary(${\n child.icon\n ? `(isUnicodeSupported ? \" ${child.icon} \" : \"\") + `\n : \"\"\n }\"${child.title} ${child.isVirtual ? \"\" : \"Command\"}\"));\n writeLine(\"\");\n writeLine(colors.text.body.secondary(\"${child.description}\"));\n writeLine(\"\");\n `}\n <hbr />\n <BaseHelp command={child} indent={2} filterGlobalOptions />\n <hbr />\n </>\n )}\n </For>\n {code`help(\"Running a specific command with the help flag (via: '${getAppBin(\n context\n )}${\n segments && segments.length > 0 ? ` ${segments.join(\" \")}` : \"\"\n } <specific command> --help') will provide additional information that is specific to that command.\");\n writeLine(\"\");`}\n </Show>\n </>\n );\n}\n\nexport interface CommandHelpProps {\n /**\n * A mapping of command names to their command definitions.\n */\n command: CommandTree;\n}\n\n/**\n * A component that generates the invocation of the `help` function for a command.\n */\nexport function CommandHelp(props: CommandHelpProps) {\n const { command } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n {code`writeLine(\"\"); `}\n <Spacing />\n <BaseHelp command={command} filterGlobalOptions={false} />\n {code`writeLine(\"\"); `}\n <Spacing />\n <Show when={Object.keys(command.children).length > 0}>\n {code`writeLine(colors.text.body.secondary(\"The following sub-commands are available:\"));\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n <For\n each={Object.values(command.children)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n {code`\n writeLine(colors.text.heading.primary(${\n child.icon\n ? `(isUnicodeSupported ? \" ${child.icon} \" : \"\") + `\n : \"\"\n }\"${child.title} ${child.isVirtual ? \"\" : \"Command\"}\"));\n writeLine(\"\");\n writeLine(colors.text.body.secondary(\"${child.description}\"));\n writeLine(\"\");\n `}\n <hbr />\n <BaseHelp command={child} indent={2} filterGlobalOptions />\n <hbr />\n </>\n )}\n </For>\n {code`help(\"Running a specific command with the help flag (via: '${getAppBin(\n context\n )} ${command.segments.join(\n \" \"\n )} <specific command> --help') will provide additional information that is specific to that command.\");\n writeLine(\"\");`}\n </Show>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyDA,SAAgBc,UAAUC,OAAuB;CAC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OAAOC,KAAKP,QAAQW,SAAS,CAACG,SAAS;;GAAC,IAAAH,WAAA;AAAA,WAAA;KACjD3B,oBAAI;;sDACW,OAAA,EAAA,CAAA;sDAAA,OAAA,EAAA,CAAA;sDAGfE,qBAAG;MAAA,IACFmB,OAAI;AAAA,cAAEC,OAAOY,OAAOlB,QAAQW,SAAS;;MACrC+C,gBAAc;MACdC,QAAQ3E,oBAAI;MACZ4E,OAAO5E,oBAAI;MAAiB2B,WAC3BsC,UAAK;mDAEDjE,oBAAI;wDAEDiE,MAAMY,OACF,2BAA2BZ,MAAMY,KAAI,gBACrC,GAAE,GACJZ,MAAMa,MAAK,GAAIb,MAAMc,YAAY,KAAK,UAAS;;wDAEXd,MAAMV,YAAW;;kBAExD;wDAAA,OAAA,EAAA,CAAA;wDAEFW,UAAQ;QAAClD,SAASiD;QAAOhD,QAAQ;QAAGkD,qBAAmB;QAAA,CAAA;wDAAA,OAAA,EAAA,CAAA;OAAA;MAG3D,CAAA;iDAEFnE,oBAAI,6HACHkB,QACD,CAAA,GAAIF,QAAQa,SAASI,KACpB,IACD,CAAA;wBACc;KAAA;;GAAA,CAAA;EAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core4 from "@alloy-js/core";
|
|
2
2
|
import { CommandOption, CommandTree } from "@shell-shock/core/types/command";
|
|
3
3
|
|
|
4
4
|
//#region src/components/help.d.ts
|
|
@@ -20,7 +20,7 @@ interface HelpUsageProps {
|
|
|
20
20
|
/**
|
|
21
21
|
* A component that generates the usage display for a command.
|
|
22
22
|
*/
|
|
23
|
-
declare function HelpUsage(props: HelpUsageProps):
|
|
23
|
+
declare function HelpUsage(props: HelpUsageProps): _alloy_js_core4.Children;
|
|
24
24
|
interface HelpOptionsProps {
|
|
25
25
|
/**
|
|
26
26
|
* The options to display help for.
|
|
@@ -30,7 +30,7 @@ interface HelpOptionsProps {
|
|
|
30
30
|
/**
|
|
31
31
|
* A component that generates the options table display for a command.
|
|
32
32
|
*/
|
|
33
|
-
declare function HelpOptions(props: HelpOptionsProps):
|
|
33
|
+
declare function HelpOptions(props: HelpOptionsProps): _alloy_js_core4.Children;
|
|
34
34
|
interface HelpCommandsProps {
|
|
35
35
|
/**
|
|
36
36
|
* A mapping of command names to their command definitions.
|
|
@@ -40,7 +40,7 @@ interface HelpCommandsProps {
|
|
|
40
40
|
/**
|
|
41
41
|
* A component that generates the commands table display for a command.
|
|
42
42
|
*/
|
|
43
|
-
declare function HelpCommands(props: HelpCommandsProps):
|
|
43
|
+
declare function HelpCommands(props: HelpCommandsProps): _alloy_js_core4.Children;
|
|
44
44
|
interface BaseHelpProps {
|
|
45
45
|
/**
|
|
46
46
|
* The command to generate help for.
|
|
@@ -68,7 +68,7 @@ interface BaseHelpProps {
|
|
|
68
68
|
/**
|
|
69
69
|
* A component that generates the `help` function declaration for a command.
|
|
70
70
|
*/
|
|
71
|
-
declare function BaseHelp(props: BaseHelpProps):
|
|
71
|
+
declare function BaseHelp(props: BaseHelpProps): _alloy_js_core4.Children;
|
|
72
72
|
interface VirtualHelpProps {
|
|
73
73
|
/**
|
|
74
74
|
* The options to display help for.
|
|
@@ -89,7 +89,7 @@ interface VirtualHelpProps {
|
|
|
89
89
|
/**
|
|
90
90
|
* A component that generates the invocation of the `help` function for a command.
|
|
91
91
|
*/
|
|
92
|
-
declare function VirtualHelp(props: VirtualHelpProps):
|
|
92
|
+
declare function VirtualHelp(props: VirtualHelpProps): _alloy_js_core4.Children;
|
|
93
93
|
interface CommandHelpProps {
|
|
94
94
|
/**
|
|
95
95
|
* A mapping of command names to their command definitions.
|
|
@@ -99,7 +99,7 @@ interface CommandHelpProps {
|
|
|
99
99
|
/**
|
|
100
100
|
* A component that generates the invocation of the `help` function for a command.
|
|
101
101
|
*/
|
|
102
|
-
declare function CommandHelp(props: CommandHelpProps):
|
|
102
|
+
declare function CommandHelp(props: CommandHelpProps): _alloy_js_core4.Children;
|
|
103
103
|
//#endregion
|
|
104
104
|
export { BaseHelp, BaseHelpProps, CommandHelp, CommandHelpProps, HelpCommands, HelpCommandsProps, HelpOptions, HelpOptionsProps, HelpUsage, HelpUsageProps, VirtualHelp, VirtualHelpProps };
|
|
105
105
|
//# sourceMappingURL=help.d.cts.map
|