@shell-shock/preset-cli 0.7.11 → 0.7.13
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/banner-function-declaration.cjs +15 -15
- package/dist/components/banner-function-declaration.d.cts +2 -2
- package/dist/components/banner-function-declaration.mjs +1 -1
- package/dist/components/banner-function-declaration.mjs.map +1 -1
- package/dist/components/command-entry.cjs +35 -35
- package/dist/components/command-entry.d.cts +3 -3
- package/dist/components/command-entry.d.mts +1 -1
- package/dist/components/command-entry.mjs +34 -34
- package/dist/components/command-entry.mjs.map +1 -1
- package/dist/components/command-router.cjs +3 -3
- package/dist/components/command-router.d.cts +2 -2
- package/dist/components/command-router.d.mts +2 -2
- package/dist/components/command-router.mjs +1 -1
- package/dist/components/command-router.mjs.map +1 -1
- package/dist/components/virtual-command-entry.cjs +5 -11
- package/dist/components/virtual-command-entry.d.cts +3 -3
- package/dist/components/virtual-command-entry.d.mts +1 -1
- package/dist/components/virtual-command-entry.mjs +4 -10
- package/dist/components/virtual-command-entry.mjs.map +1 -1
- package/dist/helpers/get-default-options.cjs +3 -3
- package/dist/helpers/get-default-options.mjs +3 -3
- package/dist/helpers/get-default-options.mjs.map +1 -1
- package/dist/index.cjs +0 -3
- 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.cts +1 -2
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +1 -2
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +36 -36
|
@@ -4,7 +4,7 @@ let __alloy_js_core = require("@alloy-js/core");
|
|
|
4
4
|
let __alloy_js_typescript = require("@alloy-js/typescript");
|
|
5
5
|
let __powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
6
6
|
let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
7
|
-
let
|
|
7
|
+
let __shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
8
8
|
let __shell_shock_plugin_theme_contexts_theme = require("@shell-shock/plugin-theme/contexts/theme");
|
|
9
9
|
let __shell_shock_preset_script_components_banner_function_declaration = require("@shell-shock/preset-script/components/banner-function-declaration");
|
|
10
10
|
let cfonts = require("cfonts");
|
|
@@ -17,12 +17,12 @@ function BannerFunctionDeclaration(props) {
|
|
|
17
17
|
const { consoleFnName = "log", variant = "primary", command } = props;
|
|
18
18
|
const theme = (0, __shell_shock_plugin_theme_contexts_theme.useTheme)();
|
|
19
19
|
const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
20
|
-
const header = (0, __alloy_js_core.computed)(() => `${theme.labels.banner.header[variant] || (0,
|
|
20
|
+
const header = (0, __alloy_js_core.computed)(() => `${theme.labels.banner.header[variant] || (0, __shell_shock_core_plugin_utils.getAppTitle)(context)} v${context.packageJson.version || "1.0.0"}`);
|
|
21
21
|
const footer = (0, __alloy_js_core.computed)(() => theme.labels.banner.footer[variant]);
|
|
22
|
-
const title = (0, __alloy_js_core.computed)(() => (0,
|
|
23
|
-
const description = (0, __alloy_js_core.computed)(() => command?.description || (0,
|
|
22
|
+
const title = (0, __alloy_js_core.computed)(() => (0, __shell_shock_core_plugin_utils.getAppTitle)(context, true).replace(`v${context.packageJson.version || "1.0.0"}`, ""));
|
|
23
|
+
const description = (0, __alloy_js_core.computed)(() => command?.description || (0, __shell_shock_core_plugin_utils.getAppDescription)(context));
|
|
24
24
|
const titleLines = (0, __alloy_js_core.computed)(() => {
|
|
25
|
-
const result = (0, cfonts.render)((0,
|
|
25
|
+
const result = (0, cfonts.render)((0, __shell_shock_core_plugin_utils.getAppTitle)(context, true), {
|
|
26
26
|
font: "tiny",
|
|
27
27
|
align: "left",
|
|
28
28
|
background: "transparent",
|
|
@@ -32,7 +32,7 @@ function BannerFunctionDeclaration(props) {
|
|
|
32
32
|
transitionGradient: false,
|
|
33
33
|
env: "node"
|
|
34
34
|
});
|
|
35
|
-
if (!result) return [`${(0,
|
|
35
|
+
if (!result) return [`${(0, __shell_shock_core_plugin_utils.getAppTitle)(context, true)} Command-Line Interface`];
|
|
36
36
|
return result.array;
|
|
37
37
|
});
|
|
38
38
|
const bannerPadding = (0, __alloy_js_core.computed)(() => Math.max(theme.padding.app, 0) * 2 + theme.borderStyles.banner.outline[variant].left.length + theme.borderStyles.banner.outline[variant].right.length);
|
|
@@ -41,7 +41,7 @@ function BannerFunctionDeclaration(props) {
|
|
|
41
41
|
async: true,
|
|
42
42
|
name: "banner",
|
|
43
43
|
get doc() {
|
|
44
|
-
return `Write the ${(0,
|
|
44
|
+
return `Write the ${(0, __shell_shock_core_plugin_utils.getAppTitle)(context, true)} application banner ${command ? `for the ${command.title} command ` : ""}to the console.`;
|
|
45
45
|
},
|
|
46
46
|
get parameters() {
|
|
47
47
|
return [{
|
|
@@ -108,7 +108,7 @@ function BannerFunctionDeclaration(props) {
|
|
|
108
108
|
},
|
|
109
109
|
get fallback() {
|
|
110
110
|
return [(0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`spinner.stop();
|
|
111
|
-
info(\`A new version of ${(0,
|
|
111
|
+
info(\`A new version of ${(0, __shell_shock_core_plugin_utils.getAppTitle)(context, true)} is available: \${colors.red(\`v\${result.currentVersion}\`)} \${colors.text.body.tertiary("➜")} \${colors.green(\`v\${result.latestVersion}\`)}\${result.package.date ? colors.text.body.tertiary(\` (updated on \${result.package.date})\`) : ""}\`);
|
|
112
112
|
|
|
113
113
|
try {
|
|
114
114
|
await upgrade();
|
|
@@ -120,14 +120,14 @@ function BannerFunctionDeclaration(props) {
|
|
|
120
120
|
await waitForKeyPress();
|
|
121
121
|
return;
|
|
122
122
|
} catch (err) {
|
|
123
|
-
spinner.error(\`An error occurred while updating ${(0,
|
|
123
|
+
spinner.error(\`An error occurred while updating ${(0, __shell_shock_core_plugin_utils.getAppTitle)(context, true)} to v\${result.latestVersion}. Please try again later - if the problem persists, please contact support.\`);
|
|
124
124
|
debug(err);
|
|
125
125
|
} `), (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {})];
|
|
126
126
|
},
|
|
127
127
|
get children() {
|
|
128
128
|
return [
|
|
129
129
|
(0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`spinner.stop();
|
|
130
|
-
warn(\`A new version of ${(0,
|
|
130
|
+
warn(\`A new version of ${(0, __shell_shock_core_plugin_utils.getAppTitle)(context, true)} is available: \${colors.red(\`v\${result.currentVersion}\`)} \${colors.text.body.tertiary("➜")} \${colors.green(\`v\${result.latestVersion}\`)}\${result.package.date ? colors.text.body.tertiary(\` (updated on \${result.package.date})\`) : ""}${context.config.upgrade !== false && context.config.upgrade.type === "manual" ? ` \\nPlease run \`${(0, __shell_shock_core_plugin_utils.getAppBin)(context)} update\` to upgrade to the latest version.` : ""}\`); `),
|
|
131
131
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
132
132
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
133
133
|
get when() {
|
|
@@ -143,7 +143,7 @@ function BannerFunctionDeclaration(props) {
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
if (willUpgradeNow) {
|
|
146
|
-
spinner.text = \`Updating ${(0,
|
|
146
|
+
spinner.text = \`Updating ${(0, __shell_shock_core_plugin_utils.getAppTitle)(context, true)} to v\${result.latestVersion}...\`;
|
|
147
147
|
spinner.start();
|
|
148
148
|
|
|
149
149
|
try {
|
|
@@ -156,11 +156,11 @@ function BannerFunctionDeclaration(props) {
|
|
|
156
156
|
await waitForKeyPress();
|
|
157
157
|
return;
|
|
158
158
|
} catch (err) {
|
|
159
|
-
spinner.error(\`An error occurred while updating ${(0,
|
|
159
|
+
spinner.error(\`An error occurred while updating ${(0, __shell_shock_core_plugin_utils.getAppTitle)(context, true)} to v\${result.latestVersion}. Please try again later - if the problem persists, please contact support.\`);
|
|
160
160
|
return { error: err };
|
|
161
161
|
}
|
|
162
162
|
} else {
|
|
163
|
-
help("Updates can be performed at any time by running the \`${(0,
|
|
163
|
+
help("Updates can be performed at any time by running the \`${(0, __shell_shock_core_plugin_utils.getAppBin)(context)} update\` command. Please remember that keeping your application up to date is important for ensuring you have the latest features, performance improvements, and security patches.");
|
|
164
164
|
} `;
|
|
165
165
|
}
|
|
166
166
|
})
|
|
@@ -172,12 +172,12 @@ function BannerFunctionDeclaration(props) {
|
|
|
172
172
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
|
|
173
173
|
condition: __alloy_js_core.code`result.isError`,
|
|
174
174
|
get children() {
|
|
175
|
-
return __alloy_js_core.code`spinner.error(\`An error occurred while checking for ${(0,
|
|
175
|
+
return __alloy_js_core.code`spinner.error(\`An error occurred while checking for ${(0, __shell_shock_core_plugin_utils.getAppTitle)(context, true)} application updates. Please try again later - if the problem persists, please contact support.\`);
|
|
176
176
|
debug(result.error); `;
|
|
177
177
|
}
|
|
178
178
|
}),
|
|
179
179
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseClause, { get children() {
|
|
180
|
-
return __alloy_js_core.code`spinner.success("Currently running the latest version of ${(0,
|
|
180
|
+
return __alloy_js_core.code`spinner.success("Currently running the latest version of ${(0, __shell_shock_core_plugin_utils.getAppTitle)(context, true)}.");
|
|
181
181
|
writeLine("");
|
|
182
182
|
`;
|
|
183
183
|
} })
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core3 from "@alloy-js/core";
|
|
2
2
|
import { BannerFunctionDeclarationProps } from "@shell-shock/preset-script/components/banner-function-declaration";
|
|
3
3
|
|
|
4
4
|
//#region src/components/banner-function-declaration.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* A component to generate the `banner` function in the `shell-shock:console` builtin module.
|
|
7
7
|
*/
|
|
8
|
-
declare function BannerFunctionDeclaration(props: BannerFunctionDeclarationProps):
|
|
8
|
+
declare function BannerFunctionDeclaration(props: BannerFunctionDeclarationProps): _alloy_js_core3.Children;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { BannerFunctionDeclaration };
|
|
11
11
|
//# sourceMappingURL=banner-function-declaration.d.cts.map
|
|
@@ -3,7 +3,7 @@ import { Show, code, computed } from "@alloy-js/core";
|
|
|
3
3
|
import { ElseClause, ElseIfClause, FunctionDeclaration, IfStatement, VarDeclaration } from "@alloy-js/typescript";
|
|
4
4
|
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
5
5
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
6
|
-
import { getAppBin, getAppDescription, getAppTitle } from "@shell-shock/core/plugin-utils
|
|
6
|
+
import { getAppBin, getAppDescription, getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
7
7
|
import { useTheme } from "@shell-shock/plugin-theme/contexts/theme";
|
|
8
8
|
import { BannerFunctionBodyDeclaration } from "@shell-shock/preset-script/components/banner-function-declaration";
|
|
9
9
|
import { render } from "cfonts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner-function-declaration.mjs","names":["code","computed","Show","ElseClause","ElseIfClause","FunctionDeclaration","IfStatement","VarDeclaration","Spacing","usePowerlines","getAppBin","getAppDescription","getAppTitle","useTheme","BannerFunctionBodyDeclaration","render","BannerFunctionDeclaration","props","consoleFnName","variant","command","theme","context","header","labels","banner","packageJson","version","footer","title","replace","description","titleLines","result","font","align","background","letterSpacing","lineHeight","gradient","transitionGradient","env","array","bannerPadding","Math","max","padding","app","borderStyles","outline","left","length","right","totalPadding","value","_$createComponent","async","name","doc","parameters","type","default","config","upgrade","children","insertNewlineAfterDescription","map","line","JSON","stringify","trim","join","condition","when","initializer","fallback","_$memo"],"sources":["../../src/components/banner-function-declaration.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, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n ElseIfClause,\n FunctionDeclaration,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n getAppBin,\n getAppDescription,\n getAppTitle\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport type { BannerFunctionDeclarationProps } from \"@shell-shock/preset-script/components/banner-function-declaration\";\nimport { BannerFunctionBodyDeclaration } from \"@shell-shock/preset-script/components/banner-function-declaration\";\nimport { render } from \"cfonts\";\nimport type { CLIPresetContext } from \"../types/plugin\";\n\n/**\n * A component to generate the `banner` function in the `shell-shock:console` builtin module.\n */\nexport function BannerFunctionDeclaration(\n props: BannerFunctionDeclarationProps\n) {\n const { consoleFnName = \"log\", variant = \"primary\", command } = props;\n\n const theme = useTheme();\n\n const context = usePowerlines<CLIPresetContext>();\n\n const header = computed(\n () =>\n `${theme.labels.banner.header[variant] || getAppTitle(context)} v${\n context.packageJson.version || \"1.0.0\"\n }`\n );\n const footer = computed(() => theme.labels.banner.footer[variant]);\n const title = computed(() =>\n getAppTitle(context, true).replace(\n `v${context.packageJson.version || \"1.0.0\"}`,\n \"\"\n )\n );\n const description = computed(\n () => command?.description || getAppDescription(context)\n );\n\n const titleLines = computed(() => {\n const result = render(getAppTitle(context, true), {\n font: \"tiny\",\n align: \"left\",\n background: \"transparent\",\n letterSpacing: 1,\n lineHeight: 1,\n gradient: false,\n transitionGradient: false,\n env: \"node\"\n });\n if (!result) {\n return [`${getAppTitle(context, true)} Command-Line Interface`];\n }\n\n return result.array;\n });\n\n const bannerPadding = computed(\n () =>\n Math.max(theme.padding.app, 0) * 2 +\n theme.borderStyles.banner.outline[variant].left.length +\n theme.borderStyles.banner.outline[variant].right.length\n );\n const totalPadding = computed(\n () => Math.max(theme.padding.banner, 0) * 2 + bannerPadding.value\n );\n\n return (\n <>\n <FunctionDeclaration\n async\n name=\"banner\"\n doc={`Write the ${getAppTitle(context, true)} application banner ${\n command ? `for the ${command.title} command ` : \"\"\n }to the console.`}\n parameters={[\n { name: \"pause\", type: \"number\", default: 500 },\n {\n name: \"upgradeCheck\",\n default: context.config.upgrade !== false ? \"true\" : \"false\"\n }\n ]}>\n <BannerFunctionBodyDeclaration\n header={header.value}\n description={description.value}\n footer={footer.value}\n variant={variant}\n consoleFnName={consoleFnName}\n command={command}\n insertNewlineAfterDescription>\n {code`const titleLines = [${titleLines.value\n .map(line => JSON.stringify(line.trim()))\n .join(\", \")}];\n const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(process.stdout.columns - ${\n totalPadding.value\n }, 0) ? \"${title.value}\" : \\`\\\\n\\${titleLines.join(\"\\\\n\")}\\\\n\\`; `}\n </BannerFunctionBodyDeclaration>\n <IfStatement condition={code`isInteractive && !isHelp`}>\n {code`await sleep(pause);`}\n </IfStatement>\n <Show when={context.config.upgrade !== false}>\n <IfStatement\n condition={code`upgradeCheck && (await isCheckForUpdatesRequired())`}>\n <VarDeclaration\n const\n name=\"spinner\"\n initializer={code`createSpinner({\n message: \"Checking for updates...\"\n }).start(); `}\n />\n <VarDeclaration\n const\n name=\"result\"\n initializer={code`await checkForUpdates({ force: true }); `}\n />\n <IfStatement condition={code`!result.isUpToDate`}>\n <Show\n when={\n context.config.upgrade !== false &&\n (context.config.upgrade.type === \"confirm\" ||\n context.config.upgrade.type === \"manual\")\n }\n fallback={\n <>\n {code`spinner.stop();\n info(\\`A new version of ${getAppTitle(\n context,\n true\n )} is available: \\${colors.red(\\`v\\${result.currentVersion}\\`)} \\${colors.text.body.tertiary(\"➜\")} \\${colors.green(\\`v\\${result.latestVersion}\\`)}\\${result.package.date ? colors.text.body.tertiary(\\` (updated on \\${result.package.date})\\`) : \"\"}\\`);\n\n try {\n await upgrade();\n spinner.success(\"Update successful! Please restart the application to apply the update.\");\n\n writeLine(\"\");\n writeLine(\"Press any key to exit application...\");\n\n await waitForKeyPress();\n return;\n } catch (err) {\n spinner.error(\\`An error occurred while updating ${getAppTitle(\n context,\n true\n )} to v\\${result.latestVersion}. Please try again later - if the problem persists, please contact support.\\`);\n debug(err);\n } `}\n <Spacing />\n </>\n }>\n {code`spinner.stop();\n warn(\\`A new version of ${getAppTitle(\n context,\n true\n )} is available: \\${colors.red(\\`v\\${result.currentVersion}\\`)} \\${colors.text.body.tertiary(\"➜\")} \\${colors.green(\\`v\\${result.latestVersion}\\`)}\\${result.package.date ? colors.text.body.tertiary(\\` (updated on \\${result.package.date})\\`) : \"\"}${\n context.config.upgrade !== false &&\n context.config.upgrade.type === \"manual\"\n ? ` \\\\nPlease run \\`${getAppBin(\n context\n )} update\\` to upgrade to the latest version.`\n : \"\"\n }\\`); `}\n <Spacing />\n <Show\n when={\n context.config.upgrade !== false &&\n context.config.upgrade.type === \"confirm\"\n }>\n {code`const willUpgradeNow = await confirm({\n message: \\`Would you like to update to v\\${result.latestVersion} now?\\`,\n initialValue: true\n });\n if (isCancel(willUpgradeNow)) {\n return;\n }\n\n if (willUpgradeNow) {\n spinner.text = \\`Updating ${getAppTitle(\n context,\n true\n )} to v\\${result.latestVersion}...\\`;\n spinner.start();\n\n try {\n await upgrade();\n spinner.success(\"Update successful! Please restart the application to apply the update.\");\n\n writeLine(\"\");\n writeLine(\"Press any key to exit application...\");\n\n await waitForKeyPress();\n return;\n } catch (err) {\n spinner.error(\\`An error occurred while updating ${getAppTitle(\n context,\n true\n )} to v\\${result.latestVersion}. Please try again later - if the problem persists, please contact support.\\`);\n return { error: err };\n }\n } else {\n help(\"Updates can be performed at any time by running the \\`${getAppBin(\n context\n )} update\\` command. Please remember that keeping your application up to date is important for ensuring you have the latest features, performance improvements, and security patches.\");\n } `}\n </Show>\n </Show>\n </IfStatement>\n <ElseIfClause condition={code`result.isError`}>\n {code`spinner.error(\\`An error occurred while checking for ${getAppTitle(\n context,\n true\n )} application updates. Please try again later - if the problem persists, please contact support.\\`);\n debug(result.error); `}\n </ElseIfClause>\n <ElseClause>{code`spinner.success(\"Currently running the latest version of ${getAppTitle(\n context,\n true\n )}.\");\n writeLine(\"\");\n `}</ElseClause>\n </IfStatement>\n </Show>\n </FunctionDeclaration>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA0CA,SAAgBgB,0BACdC,OACA;CACA,MAAM,EAAEC,gBAAgB,OAAOC,UAAU,WAAWC,YAAYH;CAEhE,MAAMI,QAAQR,UAAU;CAExB,MAAMS,UAAUb,eAAiC;CAEjD,MAAMc,SAAStB,eAEX,GAAGoB,MAAMG,OAAOC,OAAOF,OAAOJ,YAAYP,YAAYU,QAAQ,CAAA,IAC5DA,QAAQI,YAAYC,WAAW,UAEpC;CACD,MAAMC,SAAS3B,eAAeoB,MAAMG,OAAOC,OAAOG,OAAOT,SAAS;CAClE,MAAMU,QAAQ5B,eACZW,YAAYU,SAAS,KAAK,CAACQ,QACzB,IAAIR,QAAQI,YAAYC,WAAW,WACnC,GAEJ,CAAC;CACD,MAAMI,cAAc9B,eACZmB,SAASW,eAAepB,kBAAkBW,QAClD,CAAC;CAED,MAAMU,aAAa/B,eAAe;EAChC,MAAMgC,SAASlB,OAAOH,YAAYU,SAAS,KAAK,EAAE;GAChDY,MAAM;GACNC,OAAO;GACPC,YAAY;GACZC,eAAe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AI,WAAA;AAAA,uBAE1ChE,IAAI;;;;;;;;;8CASuBY,YAC1BU,SACA,KACD,CAAA;;;;;;;;;;;;;uEAaoDV,YACjDU,SACA,KACD,CAAA;;;;gFAI2DZ,UAC5DY,QACD,CAAA;;;eACA,CAAA;cAAA;;YAAA,CAAA;;UAAA,CAAA;SAAAiC,gBAINnD,cAAY;UAACoE,WAAWxE,IAAI;UAAgB,IAAAgE,WAAA;AAAA,kBAC1ChE,IAAI,wDAAwDY,YAC3DU,SACA,KACD,CAAA;;;UACqB,CAAA;SAAAiC,gBAEvBpD,YAAU,EAAA,IAAA6D,WAAA;AAAA,iBAAEhE,IAAI,4DAA4DY,YAC3EU,SACA,KACD,CAAA;;;YAEA,CAAA;SAAA;;OAAA,CAAA;;KAAA,CAAA;IAAA;;EAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"banner-function-declaration.mjs","names":["code","computed","Show","ElseClause","ElseIfClause","FunctionDeclaration","IfStatement","VarDeclaration","Spacing","usePowerlines","getAppBin","getAppDescription","getAppTitle","useTheme","BannerFunctionBodyDeclaration","render","BannerFunctionDeclaration","props","consoleFnName","variant","command","theme","context","header","labels","banner","packageJson","version","footer","title","replace","description","titleLines","result","font","align","background","letterSpacing","lineHeight","gradient","transitionGradient","env","array","bannerPadding","Math","max","padding","app","borderStyles","outline","left","length","right","totalPadding","value","_$createComponent","async","name","doc","parameters","type","default","config","upgrade","children","insertNewlineAfterDescription","map","line","JSON","stringify","trim","join","condition","when","initializer","fallback","_$memo"],"sources":["../../src/components/banner-function-declaration.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, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n ElseIfClause,\n FunctionDeclaration,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n getAppBin,\n getAppDescription,\n getAppTitle\n} from \"@shell-shock/core/plugin-utils\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport type { BannerFunctionDeclarationProps } from \"@shell-shock/preset-script/components/banner-function-declaration\";\nimport { BannerFunctionBodyDeclaration } from \"@shell-shock/preset-script/components/banner-function-declaration\";\nimport { render } from \"cfonts\";\nimport type { CLIPresetContext } from \"../types/plugin\";\n\n/**\n * A component to generate the `banner` function in the `shell-shock:console` builtin module.\n */\nexport function BannerFunctionDeclaration(\n props: BannerFunctionDeclarationProps\n) {\n const { consoleFnName = \"log\", variant = \"primary\", command } = props;\n\n const theme = useTheme();\n\n const context = usePowerlines<CLIPresetContext>();\n\n const header = computed(\n () =>\n `${theme.labels.banner.header[variant] || getAppTitle(context)} v${\n context.packageJson.version || \"1.0.0\"\n }`\n );\n const footer = computed(() => theme.labels.banner.footer[variant]);\n const title = computed(() =>\n getAppTitle(context, true).replace(\n `v${context.packageJson.version || \"1.0.0\"}`,\n \"\"\n )\n );\n const description = computed(\n () => command?.description || getAppDescription(context)\n );\n\n const titleLines = computed(() => {\n const result = render(getAppTitle(context, true), {\n font: \"tiny\",\n align: \"left\",\n background: \"transparent\",\n letterSpacing: 1,\n lineHeight: 1,\n gradient: false,\n transitionGradient: false,\n env: \"node\"\n });\n if (!result) {\n return [`${getAppTitle(context, true)} Command-Line Interface`];\n }\n\n return result.array;\n });\n\n const bannerPadding = computed(\n () =>\n Math.max(theme.padding.app, 0) * 2 +\n theme.borderStyles.banner.outline[variant].left.length +\n theme.borderStyles.banner.outline[variant].right.length\n );\n const totalPadding = computed(\n () => Math.max(theme.padding.banner, 0) * 2 + bannerPadding.value\n );\n\n return (\n <>\n <FunctionDeclaration\n async\n name=\"banner\"\n doc={`Write the ${getAppTitle(context, true)} application banner ${\n command ? `for the ${command.title} command ` : \"\"\n }to the console.`}\n parameters={[\n { name: \"pause\", type: \"number\", default: 500 },\n {\n name: \"upgradeCheck\",\n default: context.config.upgrade !== false ? \"true\" : \"false\"\n }\n ]}>\n <BannerFunctionBodyDeclaration\n header={header.value}\n description={description.value}\n footer={footer.value}\n variant={variant}\n consoleFnName={consoleFnName}\n command={command}\n insertNewlineAfterDescription>\n {code`const titleLines = [${titleLines.value\n .map(line => JSON.stringify(line.trim()))\n .join(\", \")}];\n const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(process.stdout.columns - ${\n totalPadding.value\n }, 0) ? \"${title.value}\" : \\`\\\\n\\${titleLines.join(\"\\\\n\")}\\\\n\\`; `}\n </BannerFunctionBodyDeclaration>\n <IfStatement condition={code`isInteractive && !isHelp`}>\n {code`await sleep(pause);`}\n </IfStatement>\n <Show when={context.config.upgrade !== false}>\n <IfStatement\n condition={code`upgradeCheck && (await isCheckForUpdatesRequired())`}>\n <VarDeclaration\n const\n name=\"spinner\"\n initializer={code`createSpinner({\n message: \"Checking for updates...\"\n }).start(); `}\n />\n <VarDeclaration\n const\n name=\"result\"\n initializer={code`await checkForUpdates({ force: true }); `}\n />\n <IfStatement condition={code`!result.isUpToDate`}>\n <Show\n when={\n context.config.upgrade !== false &&\n (context.config.upgrade.type === \"confirm\" ||\n context.config.upgrade.type === \"manual\")\n }\n fallback={\n <>\n {code`spinner.stop();\n info(\\`A new version of ${getAppTitle(\n context,\n true\n )} is available: \\${colors.red(\\`v\\${result.currentVersion}\\`)} \\${colors.text.body.tertiary(\"➜\")} \\${colors.green(\\`v\\${result.latestVersion}\\`)}\\${result.package.date ? colors.text.body.tertiary(\\` (updated on \\${result.package.date})\\`) : \"\"}\\`);\n\n try {\n await upgrade();\n spinner.success(\"Update successful! Please restart the application to apply the update.\");\n\n writeLine(\"\");\n writeLine(\"Press any key to exit application...\");\n\n await waitForKeyPress();\n return;\n } catch (err) {\n spinner.error(\\`An error occurred while updating ${getAppTitle(\n context,\n true\n )} to v\\${result.latestVersion}. Please try again later - if the problem persists, please contact support.\\`);\n debug(err);\n } `}\n <Spacing />\n </>\n }>\n {code`spinner.stop();\n warn(\\`A new version of ${getAppTitle(\n context,\n true\n )} is available: \\${colors.red(\\`v\\${result.currentVersion}\\`)} \\${colors.text.body.tertiary(\"➜\")} \\${colors.green(\\`v\\${result.latestVersion}\\`)}\\${result.package.date ? colors.text.body.tertiary(\\` (updated on \\${result.package.date})\\`) : \"\"}${\n context.config.upgrade !== false &&\n context.config.upgrade.type === \"manual\"\n ? ` \\\\nPlease run \\`${getAppBin(\n context\n )} update\\` to upgrade to the latest version.`\n : \"\"\n }\\`); `}\n <Spacing />\n <Show\n when={\n context.config.upgrade !== false &&\n context.config.upgrade.type === \"confirm\"\n }>\n {code`const willUpgradeNow = await confirm({\n message: \\`Would you like to update to v\\${result.latestVersion} now?\\`,\n initialValue: true\n });\n if (isCancel(willUpgradeNow)) {\n return;\n }\n\n if (willUpgradeNow) {\n spinner.text = \\`Updating ${getAppTitle(\n context,\n true\n )} to v\\${result.latestVersion}...\\`;\n spinner.start();\n\n try {\n await upgrade();\n spinner.success(\"Update successful! Please restart the application to apply the update.\");\n\n writeLine(\"\");\n writeLine(\"Press any key to exit application...\");\n\n await waitForKeyPress();\n return;\n } catch (err) {\n spinner.error(\\`An error occurred while updating ${getAppTitle(\n context,\n true\n )} to v\\${result.latestVersion}. Please try again later - if the problem persists, please contact support.\\`);\n return { error: err };\n }\n } else {\n help(\"Updates can be performed at any time by running the \\`${getAppBin(\n context\n )} update\\` command. Please remember that keeping your application up to date is important for ensuring you have the latest features, performance improvements, and security patches.\");\n } `}\n </Show>\n </Show>\n </IfStatement>\n <ElseIfClause condition={code`result.isError`}>\n {code`spinner.error(\\`An error occurred while checking for ${getAppTitle(\n context,\n true\n )} application updates. Please try again later - if the problem persists, please contact support.\\`);\n debug(result.error); `}\n </ElseIfClause>\n <ElseClause>{code`spinner.success(\"Currently running the latest version of ${getAppTitle(\n context,\n true\n )}.\");\n writeLine(\"\");\n `}</ElseClause>\n </IfStatement>\n </Show>\n </FunctionDeclaration>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA0CA,SAAgBgB,0BACdC,OACA;CACA,MAAM,EAAEC,gBAAgB,OAAOC,UAAU,WAAWC,YAAYH;CAEhE,MAAMI,QAAQR,UAAU;CAExB,MAAMS,UAAUb,eAAiC;CAEjD,MAAMc,SAAStB,eAEX,GAAGoB,MAAMG,OAAOC,OAAOF,OAAOJ,YAAYP,YAAYU,QAAQ,CAAA,IAC5DA,QAAQI,YAAYC,WAAW,UAEpC;CACD,MAAMC,SAAS3B,eAAeoB,MAAMG,OAAOC,OAAOG,OAAOT,SAAS;CAClE,MAAMU,QAAQ5B,eACZW,YAAYU,SAAS,KAAK,CAACQ,QACzB,IAAIR,QAAQI,YAAYC,WAAW,WACnC,GAEJ,CAAC;CACD,MAAMI,cAAc9B,eACZmB,SAASW,eAAepB,kBAAkBW,QAClD,CAAC;CAED,MAAMU,aAAa/B,eAAe;EAChC,MAAMgC,SAASlB,OAAOH,YAAYU,SAAS,KAAK,EAAE;GAChDY,MAAM;GACNC,OAAO;GACPC,YAAY;GACZC,eAAe;GACfC,YAAY;GACZC,UAAU;GACVC,oBAAoB;GACpBC,KAAK;GACN,CAAC;AACF,MAAI,CAACR,OACH,QAAO,CAAC,GAAGrB,YAAYU,SAAS,KAAK,CAAA,yBAA0B;AAGjE,SAAOW,OAAOS;GACd;CAEF,MAAMC,gBAAgB1C,eAElB2C,KAAKC,IAAIxB,MAAMyB,QAAQC,KAAK,EAAE,GAAG,IACjC1B,MAAM2B,aAAavB,OAAOwB,QAAQ9B,SAAS+B,KA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AC3DU,SACA,KACD,CAAA;;;UACqB,CAAA;SAAAiC,gBAEvBpD,YAAU,EAAA,IAAA6D,WAAA;AAAA,iBAAEhE,IAAI,4DAA4DY,YAC3EU,SACA,KACD,CAAA;;;YAEA,CAAA;SAAA;;OAAA,CAAA;;KAAA,CAAA;IAAA;;EAAA,CAAA,CAAA"}
|
|
@@ -6,9 +6,9 @@ let __alloy_js_core = require("@alloy-js/core");
|
|
|
6
6
|
let __alloy_js_typescript = require("@alloy-js/typescript");
|
|
7
7
|
let __powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
8
8
|
let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
9
|
-
let
|
|
10
|
-
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
9
|
+
let __shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
11
10
|
let __powerlines_plugin_alloy_typescript_components_entry_file = require("@powerlines/plugin-alloy/typescript/components/entry-file");
|
|
11
|
+
let __shell_shock_core = require("@shell-shock/core");
|
|
12
12
|
let __shell_shock_preset_script_components_command_entry = require("@shell-shock/preset-script/components/command-entry");
|
|
13
13
|
let __stryke_path_find = require("@stryke/path/find");
|
|
14
14
|
let __stryke_path_join = require("@stryke/path/join");
|
|
@@ -25,8 +25,8 @@ defu = require_rolldown_runtime.__toESM(defu);
|
|
|
25
25
|
function CommandEntry(props) {
|
|
26
26
|
const { command, imports, builtinImports, ...rest } = props;
|
|
27
27
|
const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
28
|
-
const filePath = (0, __alloy_js_core.computed)(() => (0, __stryke_path_join.joinPaths)(command.segments.filter((segment) => !(0,
|
|
29
|
-
const commandSourcePath = (0, __alloy_js_core.computed)(() => (0, __stryke_path_replace.replaceExtension)((0, __stryke_path_find.relativePath)((0, __stryke_path_join.joinPaths)(context.entryPath, (0, __stryke_path_find.findFilePath)(filePath.value)), command.entry.input?.file || command.entry.file)));
|
|
28
|
+
const filePath = (0, __alloy_js_core.computed)(() => (0, __stryke_path_join.joinPaths)(command.segments.filter((segment) => !(0, __shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)).join("/"), "index.ts"));
|
|
29
|
+
const commandSourcePath = (0, __alloy_js_core.computed)(() => `./${(0, __stryke_path_replace.replaceExtension)((0, __stryke_path_find.relativePath)((0, __stryke_path_join.joinPaths)(context.entryPath, (0, __stryke_path_find.findFilePath)(filePath.value)), command.entry.input?.file || command.entry.file))}`);
|
|
30
30
|
const typeDefinition = (0, __alloy_js_core.computed)(() => ({
|
|
31
31
|
...command.entry,
|
|
32
32
|
output: command.id
|
|
@@ -109,12 +109,12 @@ function CommandEntry(props) {
|
|
|
109
109
|
}
|
|
110
110
|
}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
111
111
|
get when() {
|
|
112
|
-
return Object.values(command.options ?? {}).filter((option) => !option.optional).length > 0 || Object.values(command.
|
|
112
|
+
return Object.values(command.options ?? {}).filter((option) => !option.optional).length > 0 || Object.values(command.args ?? {}).filter((arg) => !arg.optional).length > 0;
|
|
113
113
|
},
|
|
114
114
|
get children() {
|
|
115
115
|
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
|
|
116
116
|
get condition() {
|
|
117
|
-
return __alloy_js_core.code`!isHelp && (${Object.values(command.options ?? {}).filter((option) => !option.optional).map((option) => (option.kind ===
|
|
117
|
+
return __alloy_js_core.code`!isHelp && (${Object.values(command.options ?? {}).filter((option) => !option.optional).map((option) => (option.kind === __shell_shock_core.CommandParameterKinds.string || option.kind === __shell_shock_core.CommandParameterKinds.number) && option.variadic ? `(!options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`} || options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`}.length === 0)` : `options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`} === undefined`).join(" || ")}${Object.values(command.options ?? {}).filter((option) => !option.optional).length > 0 && Object.values(command.args ?? {}).filter((arg) => !arg.optional).length > 0 ? " || " : ""}${Object.values(command.args ?? {}).filter((arg) => !arg.optional).map((arg) => (arg.kind === __shell_shock_core.CommandParameterKinds.string || arg.kind === __shell_shock_core.CommandParameterKinds.number) && arg.variadic ? `(!${(0, __stryke_string_format_camel_case.camelCase)(arg.name)} || ${(0, __stryke_string_format_camel_case.camelCase)(arg.name)}.length === 0)` : `${(0, __stryke_string_format_camel_case.camelCase)(arg.name)} === undefined`).join(" || ")}) `;
|
|
118
118
|
},
|
|
119
119
|
get children() {
|
|
120
120
|
return [
|
|
@@ -139,7 +139,7 @@ function CommandEntry(props) {
|
|
|
139
139
|
return [
|
|
140
140
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Match, {
|
|
141
141
|
get when() {
|
|
142
|
-
return option.kind ===
|
|
142
|
+
return option.kind === __shell_shock_core.CommandParameterKinds.string;
|
|
143
143
|
},
|
|
144
144
|
get children() {
|
|
145
145
|
return __alloy_js_core.code`
|
|
@@ -164,7 +164,7 @@ function CommandEntry(props) {
|
|
|
164
164
|
}),
|
|
165
165
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Match, {
|
|
166
166
|
get when() {
|
|
167
|
-
return option.kind ===
|
|
167
|
+
return option.kind === __shell_shock_core.CommandParameterKinds.number;
|
|
168
168
|
},
|
|
169
169
|
get children() {
|
|
170
170
|
return __alloy_js_core.code`
|
|
@@ -183,7 +183,7 @@ function CommandEntry(props) {
|
|
|
183
183
|
}),
|
|
184
184
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Match, {
|
|
185
185
|
get when() {
|
|
186
|
-
return option.kind ===
|
|
186
|
+
return option.kind === __shell_shock_core.CommandParameterKinds.boolean;
|
|
187
187
|
},
|
|
188
188
|
get children() {
|
|
189
189
|
return __alloy_js_core.code`
|
|
@@ -205,7 +205,7 @@ function CommandEntry(props) {
|
|
|
205
205
|
}
|
|
206
206
|
}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
207
207
|
get when() {
|
|
208
|
-
return (option.kind ===
|
|
208
|
+
return (option.kind === __shell_shock_core.CommandParameterKinds.string || option.kind === __shell_shock_core.CommandParameterKinds.number) && option.variadic;
|
|
209
209
|
},
|
|
210
210
|
get children() {
|
|
211
211
|
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
|
|
@@ -215,7 +215,7 @@ function CommandEntry(props) {
|
|
|
215
215
|
get children() {
|
|
216
216
|
return __alloy_js_core.code`
|
|
217
217
|
const value = await text({
|
|
218
|
-
message: \`Please provide one or more${option.kind ===
|
|
218
|
+
message: \`Please provide one or more${option.kind === __shell_shock_core.CommandParameterKinds.number ? " numeric" : ""} values for the \${colors.italic("${option.name}")} option (values are separated by a \\",\\" character)\`,
|
|
219
219
|
${option.description ? `description: "${option.description}",
|
|
220
220
|
` : ""}validate(val) {
|
|
221
221
|
if (!val || val.trim() === "") {
|
|
@@ -224,7 +224,7 @@ function CommandEntry(props) {
|
|
|
224
224
|
if (val.split(",").map(v => v.trim()).filter(Boolean).length === 0) {
|
|
225
225
|
return "At least one value must be provided for this option";
|
|
226
226
|
}
|
|
227
|
-
${option.kind ===
|
|
227
|
+
${option.kind === __shell_shock_core.CommandParameterKinds.number ? `const invalidIndex = val.split(",").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));
|
|
228
228
|
if (invalidIndex !== -1) {
|
|
229
229
|
return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
|
|
230
230
|
} ` : ""}
|
|
@@ -235,7 +235,7 @@ function CommandEntry(props) {
|
|
|
235
235
|
return;
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`} = value.split(",").map(value => value.trim()).filter(Boolean)${option.kind ===
|
|
238
|
+
options${option.name.includes("?") ? `["${option.name}"]` : `.${(0, __stryke_string_format_camel_case.camelCase)(option.name)}`} = value.split(",").map(value => value.trim()).filter(Boolean)${option.kind === __shell_shock_core.CommandParameterKinds.number ? `.map(Number)` : ""} ;
|
|
239
239
|
`;
|
|
240
240
|
}
|
|
241
241
|
});
|
|
@@ -247,30 +247,30 @@ function CommandEntry(props) {
|
|
|
247
247
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
248
248
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
|
|
249
249
|
get each() {
|
|
250
|
-
return command.
|
|
250
|
+
return command.args;
|
|
251
251
|
},
|
|
252
252
|
doubleHardline: true,
|
|
253
|
-
children: (
|
|
253
|
+
children: (arg) => [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
254
254
|
get when() {
|
|
255
|
-
return !
|
|
255
|
+
return !arg.optional;
|
|
256
256
|
},
|
|
257
257
|
get children() {
|
|
258
258
|
return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
|
|
259
259
|
get condition() {
|
|
260
|
-
return __alloy_js_core.code`!${(0, __stryke_string_format_camel_case.camelCase)(
|
|
260
|
+
return __alloy_js_core.code`!${(0, __stryke_string_format_camel_case.camelCase)(arg.name)}`;
|
|
261
261
|
},
|
|
262
262
|
get children() {
|
|
263
263
|
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Switch, { get children() {
|
|
264
264
|
return [
|
|
265
265
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Match, {
|
|
266
266
|
get when() {
|
|
267
|
-
return
|
|
267
|
+
return arg.kind === __shell_shock_core.CommandParameterKinds.string;
|
|
268
268
|
},
|
|
269
269
|
get children() {
|
|
270
270
|
return __alloy_js_core.code`
|
|
271
271
|
const value = await text({
|
|
272
|
-
message: \`Please provide a value for the \${colors.italic("${
|
|
273
|
-
${
|
|
272
|
+
message: \`Please provide a value for the \${colors.italic("${arg.name}")} argument\`,
|
|
273
|
+
${arg.description ? `description: "${arg.description}",
|
|
274
274
|
` : ""}validate(val) {
|
|
275
275
|
if (!val || val.trim() === "") {
|
|
276
276
|
return "A value must be provided for this argument";
|
|
@@ -283,45 +283,45 @@ function CommandEntry(props) {
|
|
|
283
283
|
return;
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
${(0, __stryke_string_format_camel_case.camelCase)(
|
|
286
|
+
${(0, __stryke_string_format_camel_case.camelCase)(arg.name)} = value;
|
|
287
287
|
`;
|
|
288
288
|
}
|
|
289
289
|
}),
|
|
290
290
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Match, {
|
|
291
291
|
get when() {
|
|
292
|
-
return
|
|
292
|
+
return arg.kind === __shell_shock_core.CommandParameterKinds.number;
|
|
293
293
|
},
|
|
294
294
|
get children() {
|
|
295
295
|
return __alloy_js_core.code`
|
|
296
296
|
const value = await numeric({
|
|
297
|
-
message: \`Please provide a numeric value for the \${colors.italic("${
|
|
298
|
-
${
|
|
297
|
+
message: \`Please provide a numeric value for the \${colors.italic("${arg.name}")} argument\`,
|
|
298
|
+
${arg.description ? `description: "${arg.description}",
|
|
299
299
|
` : ""}
|
|
300
300
|
});
|
|
301
301
|
if (isCancel(value)) {
|
|
302
302
|
return;
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
${(0, __stryke_string_format_camel_case.camelCase)(
|
|
305
|
+
${(0, __stryke_string_format_camel_case.camelCase)(arg.name)} = value;
|
|
306
306
|
`;
|
|
307
307
|
}
|
|
308
308
|
}),
|
|
309
309
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Match, {
|
|
310
310
|
get when() {
|
|
311
|
-
return
|
|
311
|
+
return arg.kind === __shell_shock_core.CommandParameterKinds.boolean;
|
|
312
312
|
},
|
|
313
313
|
get children() {
|
|
314
314
|
return __alloy_js_core.code`
|
|
315
315
|
const value = await toggle({
|
|
316
|
-
message: \`Please select a value for the \${colors.italic("${
|
|
317
|
-
${
|
|
316
|
+
message: \`Please select a value for the \${colors.italic("${arg.name}")} argument\`,
|
|
317
|
+
${arg.description ? `description: "${arg.description}",
|
|
318
318
|
` : ""}
|
|
319
319
|
});
|
|
320
320
|
if (isCancel(value)) {
|
|
321
321
|
return;
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
${(0, __stryke_string_format_camel_case.camelCase)(
|
|
324
|
+
${(0, __stryke_string_format_camel_case.camelCase)(arg.name)} = value;
|
|
325
325
|
`;
|
|
326
326
|
}
|
|
327
327
|
})
|
|
@@ -330,18 +330,18 @@ function CommandEntry(props) {
|
|
|
330
330
|
}
|
|
331
331
|
}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
332
332
|
get when() {
|
|
333
|
-
return (
|
|
333
|
+
return (arg.kind === __shell_shock_core.CommandParameterKinds.string || arg.kind === __shell_shock_core.CommandParameterKinds.number) && arg.variadic;
|
|
334
334
|
},
|
|
335
335
|
get children() {
|
|
336
336
|
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
|
|
337
337
|
get condition() {
|
|
338
|
-
return __alloy_js_core.code`${(0, __stryke_string_format_camel_case.camelCase)(
|
|
338
|
+
return __alloy_js_core.code`${(0, __stryke_string_format_camel_case.camelCase)(arg.name)}.length === 0`;
|
|
339
339
|
},
|
|
340
340
|
get children() {
|
|
341
341
|
return __alloy_js_core.code`
|
|
342
342
|
const value = await text({
|
|
343
|
-
message: \`Please provide one or more${
|
|
344
|
-
${
|
|
343
|
+
message: \`Please provide one or more${arg.kind === __shell_shock_core.CommandParameterKinds.number ? " numeric" : ""} values for the \${colors.italic("${arg.name}")} argument (values are separated by a \\",\\" character)\`,
|
|
344
|
+
${arg.description ? `description: "${arg.description}",
|
|
345
345
|
` : ""}validate(val) {
|
|
346
346
|
if (!val || val.trim() === "") {
|
|
347
347
|
return "A value must be provided for this argument";
|
|
@@ -349,7 +349,7 @@ function CommandEntry(props) {
|
|
|
349
349
|
if (val.split(",").map(v => v.trim()).filter(Boolean).length === 0) {
|
|
350
350
|
return "At least one value must be provided for this argument";
|
|
351
351
|
}
|
|
352
|
-
${
|
|
352
|
+
${arg.kind === __shell_shock_core.CommandParameterKinds.number ? `const invalidIndex = val.split(",").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));
|
|
353
353
|
if (invalidIndex !== -1) {
|
|
354
354
|
return \`Invalid numeric value provided for item #\${invalidIndex + 1} - all provided items must be a valid number\`;
|
|
355
355
|
} ` : ""}
|
|
@@ -361,7 +361,7 @@ function CommandEntry(props) {
|
|
|
361
361
|
return;
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
-
${(0, __stryke_string_format_camel_case.camelCase)(
|
|
364
|
+
${(0, __stryke_string_format_camel_case.camelCase)(arg.name)} = value.split(",").map(value => value.trim()).filter(Boolean)${arg.kind === __shell_shock_core.CommandParameterKinds.number ? `.map(Number)` : ""} ;
|
|
365
365
|
`;
|
|
366
366
|
}
|
|
367
367
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core2 from "@alloy-js/core";
|
|
2
2
|
import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
3
|
-
import { CommandTree } from "@shell-shock/core
|
|
3
|
+
import { CommandTree } from "@shell-shock/core";
|
|
4
4
|
|
|
5
5
|
//#region src/components/command-entry.d.ts
|
|
6
6
|
interface CommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinition"> {
|
|
@@ -9,7 +9,7 @@ interface CommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinitio
|
|
|
9
9
|
/**
|
|
10
10
|
* The command entry point for the Shell Shock project.
|
|
11
11
|
*/
|
|
12
|
-
declare function CommandEntry(props: CommandEntryProps):
|
|
12
|
+
declare function CommandEntry(props: CommandEntryProps): _alloy_js_core2.Children;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { CommandEntry, CommandEntryProps };
|
|
15
15
|
//# sourceMappingURL=command-entry.d.cts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _alloy_js_core2 from "@alloy-js/core";
|
|
2
2
|
import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
3
|
-
import { CommandTree } from "@shell-shock/core
|
|
3
|
+
import { CommandTree } from "@shell-shock/core";
|
|
4
4
|
|
|
5
5
|
//#region src/components/command-entry.d.ts
|
|
6
6
|
interface CommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinition"> {
|