@shell-shock/preset-cli 0.7.5 → 0.7.7

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.
@@ -2,6 +2,7 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
3
3
  let __alloy_js_core = require("@alloy-js/core");
4
4
  let __alloy_js_typescript = require("@alloy-js/typescript");
5
+ let __powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
5
6
  let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
6
7
  let __shell_shock_core_plugin_utils_context_helpers = require("@shell-shock/core/plugin-utils/context-helpers");
7
8
  let __shell_shock_plugin_theme_contexts_theme = require("@shell-shock/plugin-theme/contexts/theme");
@@ -49,7 +50,7 @@ function BannerFunctionDeclaration(props) {
49
50
  default: 500
50
51
  }, {
51
52
  name: "upgradeCheck",
52
- default: context.config.upgrade?.type === "auto" || context.config.upgrade?.type === "confirm" ? "true" : "false"
53
+ default: context.config.upgrade !== false ? "true" : "false"
53
54
  }];
54
55
  },
55
56
  get children() {
@@ -67,6 +68,7 @@ function BannerFunctionDeclaration(props) {
67
68
  variant,
68
69
  consoleFnName,
69
70
  command,
71
+ insertNewlineAfterDescription: true,
70
72
  get children() {
71
73
  return __alloy_js_core.code`const titleLines = [${titleLines.value.map((line) => JSON.stringify(line.trim())).join(", ")}];
72
74
  const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(process.stdout.columns - ${totalPadding.value}, 0) ? "${title.value}" : \`\\n\${titleLines.join("\\n")}\\n\`; `;
@@ -76,17 +78,112 @@ function BannerFunctionDeclaration(props) {
76
78
  condition: __alloy_js_core.code`isInteractive && !isHelp`,
77
79
  children: __alloy_js_core.code`await sleep(pause);`
78
80
  }),
79
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
80
- condition: __alloy_js_core.code`upgradeCheck`,
81
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
82
+ get when() {
83
+ return context.config.upgrade !== false;
84
+ },
81
85
  get children() {
82
- return [__alloy_js_core.code`const result = await checkForUpdates();`, (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
83
- condition: __alloy_js_core.code`result?.updateAvailable`,
86
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
87
+ condition: __alloy_js_core.code`upgradeCheck && (await isCheckForUpdatesRequired())`,
84
88
  get children() {
85
- return __alloy_js_core.code`
86
- info(\`A new version of ${(0, __shell_shock_core_plugin_utils_context_helpers.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})\`) : ""}\`);
89
+ return [
90
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
91
+ "const": true,
92
+ name: "spinner",
93
+ initializer: __alloy_js_core.code`createSpinner({
94
+ message: "Checking for updates..."
95
+ }).start(); `
96
+ }),
97
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
98
+ "const": true,
99
+ name: "result",
100
+ initializer: __alloy_js_core.code`await checkForUpdates({ force: true }); `
101
+ }),
102
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
103
+ condition: __alloy_js_core.code`!result.isUpToDate`,
104
+ get children() {
105
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
106
+ get when() {
107
+ return context.config.upgrade !== false && (context.config.upgrade.type === "confirm" || context.config.upgrade.type === "manual");
108
+ },
109
+ get fallback() {
110
+ return [(0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`spinner.stop();
111
+ info(\`A new version of ${(0, __shell_shock_core_plugin_utils_context_helpers.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
+
113
+ try {
114
+ await upgrade();
115
+ spinner.success("Update successful! Please restart the application to apply the update.");
116
+
117
+ writeLine("");
118
+ writeLine("Press any key to exit application...");
119
+
120
+ await waitForKeyPress();
121
+ return;
122
+ } catch (err) {
123
+ spinner.error(\`An error occurred while updating ${(0, __shell_shock_core_plugin_utils_context_helpers.getAppTitle)(context, true)} to v\${result.latestVersion}. Please try again later - if the problem persists, please contact support.\`);
124
+ debug(err);
125
+ } `), (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {})];
126
+ },
127
+ get children() {
128
+ return [
129
+ (0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`spinner.stop();
130
+ warn(\`A new version of ${(0, __shell_shock_core_plugin_utils_context_helpers.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_context_helpers.getAppBin)(context)} update\` to upgrade to the latest version.` : ""}\`); `),
131
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
132
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
133
+ get when() {
134
+ return context.config.upgrade !== false && context.config.upgrade.type === "confirm";
135
+ },
136
+ get children() {
137
+ return __alloy_js_core.code`const willUpgradeNow = await confirm({
138
+ message: \`Would you like to update to v\${result.latestVersion} now?\`,
139
+ initialValue: true
140
+ });
141
+ if (isCancel(willUpgradeNow)) {
142
+ return;
143
+ }
144
+
145
+ if (willUpgradeNow) {
146
+ spinner.text = \`Updating ${(0, __shell_shock_core_plugin_utils_context_helpers.getAppTitle)(context, true)} to v\${result.latestVersion}...\`;
147
+ spinner.start();
148
+
149
+ try {
150
+ await upgrade();
151
+ spinner.success("Update successful! Please restart the application to apply the update.");
152
+
153
+ writeLine("");
154
+ writeLine("Press any key to exit application...");
155
+
156
+ await waitForKeyPress();
157
+ return;
158
+ } catch (err) {
159
+ spinner.error(\`An error occurred while updating ${(0, __shell_shock_core_plugin_utils_context_helpers.getAppTitle)(context, true)} to v\${result.latestVersion}. Please try again later - if the problem persists, please contact support.\`);
160
+ return { error: err };
161
+ }
162
+ } else {
163
+ help("Updates can be performed at any time by running the \`${(0, __shell_shock_core_plugin_utils_context_helpers.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
+ } `;
165
+ }
166
+ })
167
+ ];
168
+ }
169
+ });
170
+ }
171
+ }),
172
+ (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
173
+ condition: __alloy_js_core.code`result.isError`,
174
+ get children() {
175
+ return __alloy_js_core.code`spinner.error(\`An error occurred while checking for ${(0, __shell_shock_core_plugin_utils_context_helpers.getAppTitle)(context, true)} application updates. Please try again later - if the problem persists, please contact support.\`);
176
+ debug(result.error); `;
177
+ }
178
+ }),
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, __shell_shock_core_plugin_utils_context_helpers.getAppTitle)(context, true)}.");
181
+ writeLine("");
87
182
  `;
183
+ } })
184
+ ];
88
185
  }
89
- })];
186
+ });
90
187
  }
91
188
  })
92
189
  ];
@@ -1,11 +1,11 @@
1
- import * as _alloy_js_core3 from "@alloy-js/core";
1
+ import * as _alloy_js_core1 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): _alloy_js_core3.Children;
8
+ declare function BannerFunctionDeclaration(props: BannerFunctionDeclarationProps): _alloy_js_core1.Children;
9
9
  //#endregion
10
10
  export { BannerFunctionDeclaration };
11
11
  //# sourceMappingURL=banner-function-declaration.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"banner-function-declaration.d.cts","names":[],"sources":["../../src/components/banner-function-declaration.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAkCgB,iBAAA,yBAAA,CACP,KAAA,EAAA,8BAA8B,CAAA,EAAA,eAAA,CAAA,QAAA"}
1
+ {"version":3,"file":"banner-function-declaration.d.cts","names":[],"sources":["../../src/components/banner-function-declaration.tsx"],"sourcesContent":[],"mappings":";;;;;;;AA0CgB,iBAAA,yBAAA,CACP,KAAA,EAAA,8BAA8B,CAAA,EAAA,eAAA,CAAA,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"banner-function-declaration.d.mts","names":[],"sources":["../../src/components/banner-function-declaration.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAkCgB,iBAAA,yBAAA,CACP,KAAA,EAAA,8BAA8B,CAAA,EAAA,eAAA,CAAA,QAAA"}
1
+ {"version":3,"file":"banner-function-declaration.d.mts","names":[],"sources":["../../src/components/banner-function-declaration.tsx"],"sourcesContent":[],"mappings":";;;;;;;AA0CgB,iBAAA,yBAAA,CACP,KAAA,EAAA,8BAA8B,CAAA,EAAA,eAAA,CAAA,QAAA"}
@@ -1,8 +1,9 @@
1
1
  import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
2
- import { code, computed } from "@alloy-js/core";
3
- import { FunctionDeclaration, IfStatement } from "@alloy-js/typescript";
2
+ import { Show, code, computed } from "@alloy-js/core";
3
+ import { ElseClause, ElseIfClause, FunctionDeclaration, IfStatement, VarDeclaration } from "@alloy-js/typescript";
4
+ import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
4
5
  import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
5
- import { getAppDescription, getAppTitle } from "@shell-shock/core/plugin-utils/context-helpers";
6
+ import { getAppBin, getAppDescription, getAppTitle } from "@shell-shock/core/plugin-utils/context-helpers";
6
7
  import { useTheme } from "@shell-shock/plugin-theme/contexts/theme";
7
8
  import { BannerFunctionBodyDeclaration } from "@shell-shock/preset-script/components/banner-function-declaration";
8
9
  import { render } from "cfonts";
@@ -48,7 +49,7 @@ function BannerFunctionDeclaration(props) {
48
49
  default: 500
49
50
  }, {
50
51
  name: "upgradeCheck",
51
- default: context.config.upgrade?.type === "auto" || context.config.upgrade?.type === "confirm" ? "true" : "false"
52
+ default: context.config.upgrade !== false ? "true" : "false"
52
53
  }];
53
54
  },
54
55
  get children() {
@@ -66,6 +67,7 @@ function BannerFunctionDeclaration(props) {
66
67
  variant,
67
68
  consoleFnName,
68
69
  command,
70
+ insertNewlineAfterDescription: true,
69
71
  get children() {
70
72
  return code`const titleLines = [${titleLines.value.map((line) => JSON.stringify(line.trim())).join(", ")}];
71
73
  const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(process.stdout.columns - ${totalPadding.value}, 0) ? "${title.value}" : \`\\n\${titleLines.join("\\n")}\\n\`; `;
@@ -75,17 +77,112 @@ function BannerFunctionDeclaration(props) {
75
77
  condition: code`isInteractive && !isHelp`,
76
78
  children: code`await sleep(pause);`
77
79
  }),
78
- createComponent(IfStatement, {
79
- condition: code`upgradeCheck`,
80
+ createComponent(Show, {
81
+ get when() {
82
+ return context.config.upgrade !== false;
83
+ },
80
84
  get children() {
81
- return [code`const result = await checkForUpdates();`, createComponent(IfStatement, {
82
- condition: code`result?.updateAvailable`,
85
+ return createComponent(IfStatement, {
86
+ condition: code`upgradeCheck && (await isCheckForUpdatesRequired())`,
83
87
  get children() {
84
- return code`
85
- info(\`A new version of ${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})\`) : ""}\`);
88
+ return [
89
+ createComponent(VarDeclaration, {
90
+ "const": true,
91
+ name: "spinner",
92
+ initializer: code`createSpinner({
93
+ message: "Checking for updates..."
94
+ }).start(); `
95
+ }),
96
+ createComponent(VarDeclaration, {
97
+ "const": true,
98
+ name: "result",
99
+ initializer: code`await checkForUpdates({ force: true }); `
100
+ }),
101
+ createComponent(IfStatement, {
102
+ condition: code`!result.isUpToDate`,
103
+ get children() {
104
+ return createComponent(Show, {
105
+ get when() {
106
+ return context.config.upgrade !== false && (context.config.upgrade.type === "confirm" || context.config.upgrade.type === "manual");
107
+ },
108
+ get fallback() {
109
+ return [memo(() => code`spinner.stop();
110
+ info(\`A new version of ${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})\`) : ""}\`);
111
+
112
+ try {
113
+ await upgrade();
114
+ spinner.success("Update successful! Please restart the application to apply the update.");
115
+
116
+ writeLine("");
117
+ writeLine("Press any key to exit application...");
118
+
119
+ await waitForKeyPress();
120
+ return;
121
+ } catch (err) {
122
+ spinner.error(\`An error occurred while updating ${getAppTitle(context, true)} to v\${result.latestVersion}. Please try again later - if the problem persists, please contact support.\`);
123
+ debug(err);
124
+ } `), createComponent(Spacing, {})];
125
+ },
126
+ get children() {
127
+ return [
128
+ memo(() => code`spinner.stop();
129
+ warn(\`A new version of ${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 \`${getAppBin(context)} update\` to upgrade to the latest version.` : ""}\`); `),
130
+ createComponent(Spacing, {}),
131
+ createComponent(Show, {
132
+ get when() {
133
+ return context.config.upgrade !== false && context.config.upgrade.type === "confirm";
134
+ },
135
+ get children() {
136
+ return code`const willUpgradeNow = await confirm({
137
+ message: \`Would you like to update to v\${result.latestVersion} now?\`,
138
+ initialValue: true
139
+ });
140
+ if (isCancel(willUpgradeNow)) {
141
+ return;
142
+ }
143
+
144
+ if (willUpgradeNow) {
145
+ spinner.text = \`Updating ${getAppTitle(context, true)} to v\${result.latestVersion}...\`;
146
+ spinner.start();
147
+
148
+ try {
149
+ await upgrade();
150
+ spinner.success("Update successful! Please restart the application to apply the update.");
151
+
152
+ writeLine("");
153
+ writeLine("Press any key to exit application...");
154
+
155
+ await waitForKeyPress();
156
+ return;
157
+ } catch (err) {
158
+ spinner.error(\`An error occurred while updating ${getAppTitle(context, true)} to v\${result.latestVersion}. Please try again later - if the problem persists, please contact support.\`);
159
+ return { error: err };
160
+ }
161
+ } else {
162
+ help("Updates can be performed at any time by running the \`${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.");
163
+ } `;
164
+ }
165
+ })
166
+ ];
167
+ }
168
+ });
169
+ }
170
+ }),
171
+ createComponent(ElseIfClause, {
172
+ condition: code`result.isError`,
173
+ get children() {
174
+ return code`spinner.error(\`An error occurred while checking for ${getAppTitle(context, true)} application updates. Please try again later - if the problem persists, please contact support.\`);
175
+ debug(result.error); `;
176
+ }
177
+ }),
178
+ createComponent(ElseClause, { get children() {
179
+ return code`spinner.success("Currently running the latest version of ${getAppTitle(context, true)}.");
180
+ writeLine("");
86
181
  `;
182
+ } })
183
+ ];
87
184
  }
88
- })];
185
+ });
89
186
  }
90
187
  })
91
188
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"banner-function-declaration.mjs","names":["code","computed","FunctionDeclaration","IfStatement","usePowerlines","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","map","line","JSON","stringify","trim","join","condition"],"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 } from \"@alloy-js/core\";\nimport { FunctionDeclaration, IfStatement } from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\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:\n context.config.upgrade?.type === \"auto\" ||\n context.config.upgrade?.type === \"confirm\"\n ? \"true\"\n : \"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 {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 <IfStatement condition={code`upgradeCheck`}>\n {code`const result = await checkForUpdates();`}\n <IfStatement condition={code`result?.updateAvailable`}>\n {code`\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 </IfStatement>\n </IfStatement>\n </FunctionDeclaration>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAkCA,SAAgBU,0BACdC,OACA;CACA,MAAM,EAAEC,gBAAgB,OAAOC,UAAU,WAAWC,YAAYH;CAEhE,MAAMI,QAAQR,UAAU;CAExB,MAAMS,UAAUZ,eAAiC;CAEjD,MAAMa,SAAShB,eAEX,GAAGc,MAAMG,OAAOC,OAAOF,OAAOJ,YAAYP,YAAYU,QAAQ,CAAA,IAC5DA,QAAQI,YAAYC,WAAW,UAEpC;CACD,MAAMC,SAASrB,eAAec,MAAMG,OAAOC,OAAOG,OAAOT,SAAS;CAClE,MAAMU,QAAQtB,eACZK,YAAYU,SAAS,KAAK,CAACQ,QACzB,IAAIR,QAAQI,YAAYC,WAAW,WACnC,GAEJ,CAAC;CACD,MAAMI,cAAcxB,eACZa,SAASW,eAAepB,kBAAkBW,QAClD,CAAC;CAED,MAAMU,aAAazB,eAAe;EAChC,MAAM0B,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,gBAAgBpC,eAElB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1D,IAAI,2CAAyCiD,gBAC7C9C,aAAW;OAAC8D,WAAWjE,IAAI;OAAyB,IAAA0D,WAAA;AAAA,eAClD1D,IAAI;sCACqBM,YACxBU,SACA,KACD,CAAA;;;OACA,CAAA,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/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,0BAC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OC,QAAQH,SAAS,aAC/BtC,QAAQwC,OAAOC,QAAQH,SAAS;;YAAS,IAE7Ce,WAAQ;AAAA,oBAAA,CAAAC,WAEH5E,IAAI;8CACqBY,YACxBU,SACA,KACD,CAAA;;;;;;;;;;;;yEAYoDV,YACjDU,SACA,KACD,CAAA;;wBAEA,EAAAiC,gBACF/C,SAAO,EAAA,CAAA,CAAA;;YAAA,IAAAwD,WAAA;AAAA,oBAAA;cAAAY,WAGX5E,IAAI;0CACqBY,YACxBU,SACA,KACD,CAAA,qPACCA,QAAQwC,OAAOC,YAAY,SAC3BzC,QAAQwC,OAAOC,QAAQH,SAAS,WAC5B,oBAAoBlD,UAClBY,QACD,CAAA,+CACD,GAAE,OACD;cAAAiC,gBACN/C,SAAO,EAAA,CAAA;cAAA+C,gBACPrD,MAAI;eAAA,IACHuE,OAAI;AAAA,uBACFnD,QAAQwC,OAAOC,YAAY,SAC3BzC,QAAQwC,OAAOC,QAAQH,SAAS;;eAAS,IAAAI,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"}
@@ -4,10 +4,10 @@ const require_components_virtual_command_entry = require('./virtual-command-entr
4
4
  let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
5
5
  let __alloy_js_core = require("@alloy-js/core");
6
6
  let __alloy_js_typescript = require("@alloy-js/typescript");
7
+ let __powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
7
8
  let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
8
9
  let __shell_shock_core_plugin_utils_context_helpers = require("@shell-shock/core/plugin-utils/context-helpers");
9
10
  let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
10
- let __powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
11
11
  let __powerlines_plugin_alloy_typescript_components_entry_file = require("@powerlines/plugin-alloy/typescript/components/entry-file");
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");
@@ -49,18 +49,21 @@ function CommandEntry(props) {
49
49
  env: [
50
50
  "env",
51
51
  "isDevelopment",
52
- "isDebug"
52
+ "isDebug",
53
+ "paths"
53
54
  ],
54
55
  console: [
55
56
  "debug",
56
57
  "info",
58
+ "help",
57
59
  "warn",
58
60
  "error",
59
61
  "table",
60
62
  "colors",
61
63
  "stripAnsi",
62
64
  "writeLine",
63
- "splitText"
65
+ "splitText",
66
+ "createSpinner"
64
67
  ],
65
68
  utils: [
66
69
  "useApp",
@@ -77,10 +80,16 @@ function CommandEntry(props) {
77
80
  "numeric",
78
81
  "toggle",
79
82
  "select",
83
+ "confirm",
84
+ "waitForKeyPress",
80
85
  "isCancel",
81
86
  "sleep"
82
87
  ],
83
- upgrade: ["checkForUpdates"]
88
+ upgrade: [
89
+ "checkForUpdates",
90
+ "isCheckForUpdatesRequired",
91
+ "upgrade"
92
+ ]
84
93
  });
85
94
  },
86
95
  get children() {
@@ -1,4 +1,4 @@
1
- import * as _alloy_js_core0 from "@alloy-js/core";
1
+ import * as _alloy_js_core3 from "@alloy-js/core";
2
2
  import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
3
3
  import { CommandTree } from "@shell-shock/core/types/command";
4
4
 
@@ -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): _alloy_js_core0.Children;
12
+ declare function CommandEntry(props: CommandEntryProps): _alloy_js_core3.Children;
13
13
  //#endregion
14
14
  export { CommandEntry, CommandEntryProps };
15
15
  //# sourceMappingURL=command-entry.d.cts.map
@@ -3,10 +3,10 @@ import { VirtualCommandEntry } from "./virtual-command-entry.mjs";
3
3
  import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
4
4
  import { For, Match, Show, Switch, code, computed } from "@alloy-js/core";
5
5
  import { ElseIfClause, IfStatement } from "@alloy-js/typescript";
6
+ import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
6
7
  import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
7
8
  import { isDynamicPathSegment } from "@shell-shock/core/plugin-utils/context-helpers";
8
9
  import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
9
- import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
10
10
  import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
11
11
  import { CommandHandlerDeclaration, CommandValidationLogic } from "@shell-shock/preset-script/components/command-entry";
12
12
  import { findFilePath, relativePath } from "@stryke/path/find";
@@ -47,18 +47,21 @@ function CommandEntry(props) {
47
47
  env: [
48
48
  "env",
49
49
  "isDevelopment",
50
- "isDebug"
50
+ "isDebug",
51
+ "paths"
51
52
  ],
52
53
  console: [
53
54
  "debug",
54
55
  "info",
56
+ "help",
55
57
  "warn",
56
58
  "error",
57
59
  "table",
58
60
  "colors",
59
61
  "stripAnsi",
60
62
  "writeLine",
61
- "splitText"
63
+ "splitText",
64
+ "createSpinner"
62
65
  ],
63
66
  utils: [
64
67
  "useApp",
@@ -75,10 +78,16 @@ function CommandEntry(props) {
75
78
  "numeric",
76
79
  "toggle",
77
80
  "select",
81
+ "confirm",
82
+ "waitForKeyPress",
78
83
  "isCancel",
79
84
  "sleep"
80
85
  ],
81
- upgrade: ["checkForUpdates"]
86
+ upgrade: [
87
+ "checkForUpdates",
88
+ "isCheckForUpdatesRequired",
89
+ "upgrade"
90
+ ]
82
91
  });
83
92
  },
84
93
  get children() {
@@ -1 +1 @@
1
- {"version":3,"file":"command-entry.mjs","names":["code","computed","For","Match","Show","Switch","ElseIfClause","IfStatement","ReflectionKind","Spacing","usePowerlines","EntryFile","isDynamicPathSegment","CommandHandlerDeclaration","CommandValidationLogic","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","pascalCase","defu","BannerFunctionDeclaration","VirtualCommandEntry","CommandEntry","props","command","imports","builtinImports","rest","context","filePath","segments","filter","segment","join","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$createComponent","_$mergeProps","path","name","prompts","env","console","utils","upgrade","children","_$createIntrinsic","banner","condition","when","Object","values","options","option","optional","length","arguments","argument","map","kind","string","number","variadic","includes","each","doubleHardline","description","boolean","child","isVirtual","fallback"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Match, Show, Switch } from \"@alloy-js/core\";\nimport { ElseIfClause, IfStatement } from \"@alloy-js/typescript\";\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 type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport {\n CommandHandlerDeclaration,\n CommandValidationLogic\n} from \"@shell-shock/preset-script/components/command-entry\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`,\n prompts: \"prompts\"\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\"],\n console: [\n \"debug\",\n \"info\",\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\"\n ],\n utils: [\n \"useApp\",\n \"useArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isInteractive\",\n \"isHelp\",\n \"isUnicodeSupported\",\n \"internal_commandContext\"\n ],\n prompts: [\"text\", \"numeric\", \"toggle\", \"select\", \"isCancel\", \"sleep\"],\n upgrade: [\"checkForUpdates\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await banner(); `}>\n <IfStatement condition={code`!isInteractive`}>\n <CommandValidationLogic command={command} />\n </IfStatement>\n <Show\n when={\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 ||\n Object.values(command.arguments ?? {}).filter(\n argument => !argument.optional\n ).length > 0\n }>\n <ElseIfClause\n condition={code`!isHelp && (${Object.values(command.options ?? {})\n .filter(option => !option.optional)\n .map(option =>\n (option.kind === ReflectionKind.string ||\n option.kind === ReflectionKind.number) &&\n option.variadic\n ? `(!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } || options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0)`\n : `options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } === undefined`\n )\n .join(\" || \")}${\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 &&\n Object.values(command.arguments ?? {}).filter(\n argument => !argument.optional\n ).length > 0\n ? \" || \"\n : \"\"\n }${Object.values(command.arguments ?? {})\n .filter(argument => !argument.optional)\n .map(argument =>\n (argument.kind === ReflectionKind.string ||\n argument.kind === ReflectionKind.number) &&\n argument.variadic\n ? `(!${camelCase(\n argument.name\n )} || ${camelCase(argument.name)}.length === 0)`\n : `${camelCase(argument.name)} === undefined`\n )\n .join(\" || \")}) `}>\n {code`writeLine(\"\"); `}\n <Spacing />\n <For each={Object.values(command.options ?? {})} doubleHardline>\n {option => (\n <>\n <Show when={!option.optional}>\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }`}>\n <Switch>\n <Match\n when={option.kind === ReflectionKind.string}>{code`\n const value = await text({\n message: \"Please provide a value for the \\\\\"${option.name}\\\\\" option\",\n ${\n option.description\n ? `description: \"${option.description}\",\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={option.kind === ReflectionKind.number}>{code`\n const value = await numeric({\n message: \"Please provide a numeric value for the \\\\\"${option.name}\\\\\" option\",\n ${\n option.description\n ? `description: \"${option.description}\",\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={option.kind === ReflectionKind.boolean}>{code`\n const value = await toggle({\n message: \"Please select a value for the \\\\\"${\n option.name\n }\\\\\" option\",\n ${\n option.description\n ? `description: \"${option.description}\",\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n </Switch>\n </IfStatement>\n <Show\n when={\n (option.kind === ReflectionKind.string ||\n option.kind === ReflectionKind.number) &&\n option.variadic\n }>\n <ElseIfClause\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0`}>\n {code`\n const value = await text({\n message: \"Please provide one or more${\n option.kind === ReflectionKind.number\n ? \" numeric\"\n : \"\"\n } values for the \\\\\"${option.name}\\\\\" option (values are separated by a \\\\\",\\\\\" character)\",\n ${\n option.description\n ? `description: \"${option.description}\",\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this option\";\n }\n ${\n option.kind === ReflectionKind.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n option.kind === ReflectionKind.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.arguments} doubleHardline>\n {argument => (\n <>\n <Show when={!argument.optional}>\n <IfStatement\n condition={code`!${camelCase(argument.name)}`}>\n <Switch>\n <Match\n when={\n argument.kind === ReflectionKind.string\n }>{code`\n const value = await text({\n message: \"Please provide a value for the \\\\\"${argument.name}\\\\\" argument\",\n ${\n argument.description\n ? `description: \"${argument.description}\",\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(argument.name)} = value;\n `}</Match>\n <Match\n when={\n argument.kind === ReflectionKind.number\n }>{code`\n const value = await numeric({\n message: \"Please provide a numeric value for the \\\\\"${argument.name}\\\\\" argument\",\n ${\n argument.description\n ? `description: \"${argument.description}\",\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(argument.name)} = value;\n `}</Match>\n <Match\n when={\n argument.kind === ReflectionKind.boolean\n }>{code`\n const value = await toggle({\n message: \"Please select a value for the \\\\\"${argument.name}\\\\\" argument\",\n ${\n argument.description\n ? `description: \"${argument.description}\",\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(argument.name)} = value;\n `}</Match>\n </Switch>\n </IfStatement>\n <Show\n when={\n (argument.kind === ReflectionKind.string ||\n argument.kind === ReflectionKind.number) &&\n argument.variadic\n }>\n <ElseIfClause\n condition={code`${camelCase(argument.name)}.length === 0`}>\n {code`\n const value = await text({\n message: \"Please provide one or more${\n argument.kind === ReflectionKind.number\n ? \" numeric\"\n : \"\"\n } (values are separated by a \\\\\",\\\\\" character)\",\n ${\n argument.description\n ? `description: \"${argument.description}\",\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this argument\";\n }\n ${\n argument.kind === ReflectionKind.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(argument.name)} = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n argument.kind === ReflectionKind.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n {code`writeLine(\"\"); `}\n <Spacing />\n </ElseIfClause>\n </Show>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </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AAEd,OAAOC,OAAOlC,QAAQ4B,SAAS;;EAAAA,WACvCuB,UAAKhC,gBACHzC,MAAI;GAAA,IACHsD,OAAI;AAAA,WAAEmB,MAAMC;;GAAS,IACrBC,WAAQ;AAAA,WAAAlC,gBAAGrB,cAAY,EAACE,SAASmD,OAAK,CAAA;;GAAA,IAAAvB,WAAA;AAAA,WAAAT,gBACrCtB,qBAAmB,EAACG,SAASmD,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
1
+ {"version":3,"file":"command-entry.mjs","names":["code","computed","For","Match","Show","Switch","ElseIfClause","IfStatement","ReflectionKind","Spacing","usePowerlines","EntryFile","isDynamicPathSegment","CommandHandlerDeclaration","CommandValidationLogic","findFilePath","relativePath","joinPaths","replaceExtension","camelCase","pascalCase","defu","BannerFunctionDeclaration","VirtualCommandEntry","CommandEntry","props","command","imports","builtinImports","rest","context","filePath","segments","filter","segment","join","commandSourcePath","entryPath","value","entry","input","file","typeDefinition","output","id","_$createComponent","_$mergeProps","path","name","prompts","env","console","utils","upgrade","children","_$createIntrinsic","banner","condition","when","Object","values","options","option","optional","length","arguments","argument","map","kind","string","number","variadic","includes","each","doubleHardline","description","boolean","child","isVirtual","fallback"],"sources":["../../src/components/command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, For, Match, Show, Switch } from \"@alloy-js/core\";\nimport { ElseIfClause, IfStatement } from \"@alloy-js/typescript\";\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 type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { EntryFile } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport { isDynamicPathSegment } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport {\n CommandHandlerDeclaration,\n CommandValidationLogic\n} from \"@shell-shock/preset-script/components/command-entry\";\nimport { findFilePath, relativePath } from \"@stryke/path/find\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { replaceExtension } from \"@stryke/path/replace\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { CLIPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { VirtualCommandEntry } from \"./virtual-command-entry\";\n\nexport interface CommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The command entry point for the Shell Shock project.\n */\nexport function CommandEntry(props: CommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n const commandSourcePath = computed(() =>\n replaceExtension(\n relativePath(\n joinPaths(context.entryPath, findFilePath(filePath.value)),\n command.entry.input?.file || command.entry.file\n )\n )\n );\n const typeDefinition = computed(() => ({\n ...command.entry,\n output: command.id\n }));\n\n return (\n <>\n <EntryFile\n {...rest}\n path={filePath.value}\n typeDefinition={typeDefinition.value}\n imports={defu(imports ?? {}, {\n [commandSourcePath.value]: `handle${pascalCase(command.name)}`,\n prompts: \"prompts\"\n })}\n builtinImports={defu(builtinImports ?? {}, {\n env: [\"env\", \"isDevelopment\", \"isDebug\", \"paths\"],\n console: [\n \"debug\",\n \"info\",\n \"help\",\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"createSpinner\"\n ],\n utils: [\n \"useApp\",\n \"useArgs\",\n \"hasFlag\",\n \"isMinimal\",\n \"isInteractive\",\n \"isHelp\",\n \"isUnicodeSupported\",\n \"internal_commandContext\"\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"waitForKeyPress\",\n \"isCancel\",\n \"sleep\"\n ],\n upgrade: [\"checkForUpdates\", \"isCheckForUpdatesRequired\", \"upgrade\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <CommandHandlerDeclaration\n command={command}\n banner={code`await banner(); `}>\n <IfStatement condition={code`!isInteractive`}>\n <CommandValidationLogic command={command} />\n </IfStatement>\n <Show\n when={\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 ||\n Object.values(command.arguments ?? {}).filter(\n argument => !argument.optional\n ).length > 0\n }>\n <ElseIfClause\n condition={code`!isHelp && (${Object.values(command.options ?? {})\n .filter(option => !option.optional)\n .map(option =>\n (option.kind === ReflectionKind.string ||\n option.kind === ReflectionKind.number) &&\n option.variadic\n ? `(!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } || options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0)`\n : `options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } === undefined`\n )\n .join(\" || \")}${\n Object.values(command.options ?? {}).filter(\n option => !option.optional\n ).length > 0 &&\n Object.values(command.arguments ?? {}).filter(\n argument => !argument.optional\n ).length > 0\n ? \" || \"\n : \"\"\n }${Object.values(command.arguments ?? {})\n .filter(argument => !argument.optional)\n .map(argument =>\n (argument.kind === ReflectionKind.string ||\n argument.kind === ReflectionKind.number) &&\n argument.variadic\n ? `(!${camelCase(\n argument.name\n )} || ${camelCase(argument.name)}.length === 0)`\n : `${camelCase(argument.name)} === undefined`\n )\n .join(\" || \")}) `}>\n {code`writeLine(\"\"); `}\n <Spacing />\n <For each={Object.values(command.options ?? {})} doubleHardline>\n {option => (\n <>\n <Show when={!option.optional}>\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }`}>\n <Switch>\n <Match\n when={option.kind === ReflectionKind.string}>{code`\n const value = await text({\n message: \"Please provide a value for the \\\\\"${option.name}\\\\\" option\",\n ${\n option.description\n ? `description: \"${option.description}\",\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={option.kind === ReflectionKind.number}>{code`\n const value = await numeric({\n message: \"Please provide a numeric value for the \\\\\"${option.name}\\\\\" option\",\n ${\n option.description\n ? `description: \"${option.description}\",\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n <Match\n when={option.kind === ReflectionKind.boolean}>{code`\n const value = await toggle({\n message: \"Please select a value for the \\\\\"${\n option.name\n }\\\\\" option\",\n ${\n option.description\n ? `description: \"${option.description}\",\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value;\n `}</Match>\n </Switch>\n </IfStatement>\n <Show\n when={\n (option.kind === ReflectionKind.string ||\n option.kind === ReflectionKind.number) &&\n option.variadic\n }>\n <ElseIfClause\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0`}>\n {code`\n const value = await text({\n message: \"Please provide one or more${\n option.kind === ReflectionKind.number\n ? \" numeric\"\n : \"\"\n } values for the \\\\\"${option.name}\\\\\" option (values are separated by a \\\\\",\\\\\" character)\",\n ${\n option.description\n ? `description: \"${option.description}\",\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this option\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this option\";\n }\n ${\n option.kind === ReflectionKind.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n option.kind === ReflectionKind.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.arguments} doubleHardline>\n {argument => (\n <>\n <Show when={!argument.optional}>\n <IfStatement\n condition={code`!${camelCase(argument.name)}`}>\n <Switch>\n <Match\n when={\n argument.kind === ReflectionKind.string\n }>{code`\n const value = await text({\n message: \"Please provide a value for the \\\\\"${argument.name}\\\\\" argument\",\n ${\n argument.description\n ? `description: \"${argument.description}\",\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n\n return null;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(argument.name)} = value;\n `}</Match>\n <Match\n when={\n argument.kind === ReflectionKind.number\n }>{code`\n const value = await numeric({\n message: \"Please provide a numeric value for the \\\\\"${argument.name}\\\\\" argument\",\n ${\n argument.description\n ? `description: \"${argument.description}\",\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(argument.name)} = value;\n `}</Match>\n <Match\n when={\n argument.kind === ReflectionKind.boolean\n }>{code`\n const value = await toggle({\n message: \"Please select a value for the \\\\\"${argument.name}\\\\\" argument\",\n ${\n argument.description\n ? `description: \"${argument.description}\",\n `\n : \"\"\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(argument.name)} = value;\n `}</Match>\n </Switch>\n </IfStatement>\n <Show\n when={\n (argument.kind === ReflectionKind.string ||\n argument.kind === ReflectionKind.number) &&\n argument.variadic\n }>\n <ElseIfClause\n condition={code`${camelCase(argument.name)}.length === 0`}>\n {code`\n const value = await text({\n message: \"Please provide one or more${\n argument.kind === ReflectionKind.number\n ? \" numeric\"\n : \"\"\n } (values are separated by a \\\\\",\\\\\" character)\",\n ${\n argument.description\n ? `description: \"${argument.description}\",\n `\n : \"\"\n }validate(val) {\n if (!val || val.trim() === \"\") {\n return \"A value must be provided for this argument\";\n }\n if (val.split(\",\").map(v => v.trim()).filter(Boolean).length === 0) {\n return \"At least one value must be provided for this argument\";\n }\n ${\n argument.kind === ReflectionKind.number\n ? `const invalidIndex = val.split(\",\").map(v => v.trim()).filter(Boolean).findIndex(v => Number.isNaN(Number(v));\n if (invalidIndex !== -1) {\n return \\`Invalid numeric value provided for item #\\${invalidIndex + 1} - all provided items must be a valid number\\`;\n } `\n : \"\"\n }\n\n return undefined;\n }\n });\n if (isCancel(value)) {\n return;\n }\n\n ${camelCase(argument.name)} = value.split(\",\").map(value => value.trim()).filter(Boolean)${\n argument.kind === ReflectionKind.number\n ? `.map(Number)`\n : \"\"\n } ;\n `}\n </ElseIfClause>\n </Show>\n </Show>\n </>\n )}\n </For>\n {code`writeLine(\"\"); `}\n <Spacing />\n </ElseIfClause>\n </Show>\n </CommandHandlerDeclaration>\n </EntryFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmDA,SAAgBwB,aAAaC,OAA0B;CACrD,MAAM,EAAEC,SAASC,SAASC,gBAAgB,GAAGC,SAASJ;CAEtD,MAAMK,UAAUpB,eAAiC;CACjD,MAAMqB,WAAW9B,eACfgB,UACES,QAAQM,SACLC,QAAOC,YAAW,CAACtB,qBAAqBsB,QAAQ,CAAC,CACjDC,KAAK,IAAI,EACZ,WAEJ,CAAC;CACD,MAAMC,oBAAoBnC,eACxBiB,iBACEF,aACEC,UAAUa,QAAQO,WAAWtB,aAAagB,SAASO,MAAM,CAAC,EAC1DZ,QAAQa,MAAMC,OAAOC,QAAQf,QAAQa,MAAME,KAE/C,CACF,CAAC;CACD,MAAMC,iBAAiBzC,gBAAgB;EACrC,GAAGyB,QAAQa;EACXI,QAAQjB,QAAQkB;EACjB,EAAE;AAEH,QAAA,CAAAC,gBAEKlC,WAASmC,WACJjB,MAAI;EAAA,IACRkB,OAAI;AAAA,UAAEhB,SAASO;;EAAK,IACpBI,iBAAc;AAAA,UAAEA,eAAeJ;;EAAK,IACpCX,UAAO;AAAA,UAAEN,KAAKM,WAAW,EAAE,EAAE;KAC1BS,kBAAkBE,QAAQ,SAASlB,WAAWM,QAAQsB,KAAK;IAC5DC,SAAS;IACV,CAAC;;EAAA,IACFrB,iBAAc;AAAA,UAAEP,KAAKO,kBAAkB,EAAE,EAAE;IACzCsB,KAAK;KAAC;KAAO;KAAiB;KAAW;KAAQ;IACjDC,SAAS;KACP;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACD;IACDC,OAAO;KACL;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACD;IACDH,SAAS;KACP;KACA;KACA;KACA;KACA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E,IAAI;WAAiB6C,gBACrBpC,SAAO,EAAA,CAAA;WAAA;;SAAA,CAAA;;OAAA,CAAA,CAAA;;KAAA,CAAA;IAAA;;EAAA,CAAA,CAAA,EAAAoC,gBAKf3C,KAAG;EAAA,IAACuE,OAAI;AAAA,UAAEd,OAAOC,OAAOlC,QAAQ4B,SAAS;;EAAAA,WACvCuB,UAAKhC,gBACHzC,MAAI;GAAA,IACHsD,OAAI;AAAA,WAAEmB,MAAMC;;GAAS,IACrBC,WAAQ;AAAA,WAAAlC,gBAAGrB,cAAY,EAACE,SAASmD,OAAK,CAAA;;GAAA,IAAAvB,WAAA;AAAA,WAAAT,gBACrCtB,qBAAmB,EAACG,SAASmD,OAAK,CAAA;;GAAA,CAAA;EAEtC,CAAA,CAAA"}
@@ -1,4 +1,4 @@
1
- import * as _alloy_js_core1 from "@alloy-js/core";
1
+ import * as _alloy_js_core0 from "@alloy-js/core";
2
2
  import { CommandTree } from "@shell-shock/core/types/command";
3
3
  import { CommandRouterProps } from "@shell-shock/preset-script/components/command-router";
4
4
 
@@ -6,11 +6,11 @@ import { CommandRouterProps } from "@shell-shock/preset-script/components/comman
6
6
  interface CommandRouterSelectOptionsProps {
7
7
  commands?: Record<string, CommandTree>;
8
8
  }
9
- declare function CommandRouterSelectOptions(props: CommandRouterSelectOptionsProps): _alloy_js_core1.Children;
9
+ declare function CommandRouterSelectOptions(props: CommandRouterSelectOptionsProps): _alloy_js_core0.Children;
10
10
  /**
11
11
  * A component that renders a command router interface, allowing users to select and execute commands from a provided list of commands and segments. This component serves as a wrapper around the base CommandRouter, adding additional UI elements and logic for command selection.
12
12
  */
13
- declare function CommandRouter(props: CommandRouterProps): _alloy_js_core1.Children;
13
+ declare function CommandRouter(props: CommandRouterProps): _alloy_js_core0.Children;
14
14
  //#endregion
15
15
  export { CommandRouter, CommandRouterSelectOptions, CommandRouterSelectOptionsProps };
16
16
  //# sourceMappingURL=command-router.d.cts.map
@@ -1,4 +1,4 @@
1
- import * as _alloy_js_core0 from "@alloy-js/core";
1
+ import * as _alloy_js_core2 from "@alloy-js/core";
2
2
  import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
3
3
  import { CommandTree } from "@shell-shock/core/types/command";
4
4
 
@@ -9,7 +9,7 @@ interface VirtualCommandEntryProps extends Omit<EntryFileProps, "path" | "typeDe
9
9
  /**
10
10
  * The virtual command entry point for the Shell Shock project.
11
11
  */
12
- declare function VirtualCommandEntry(props: VirtualCommandEntryProps): _alloy_js_core0.Children;
12
+ declare function VirtualCommandEntry(props: VirtualCommandEntryProps): _alloy_js_core2.Children;
13
13
  //#endregion
14
14
  export { VirtualCommandEntry, VirtualCommandEntryProps };
15
15
  //# sourceMappingURL=virtual-command-entry.d.cts.map
package/dist/index.cjs CHANGED
@@ -55,15 +55,19 @@ const plugin = (options = {}) => {
55
55
  builtinImports: {
56
56
  console: [
57
57
  "info",
58
+ "debug",
59
+ "warn",
60
+ "help",
61
+ "error",
58
62
  "divider",
59
63
  "stripAnsi",
60
64
  "writeLine",
61
65
  "splitText",
62
66
  "colors",
63
- "help",
64
67
  "writeLine",
65
68
  "splitText",
66
- "stripAnsi"
69
+ "stripAnsi",
70
+ "createSpinner"
67
71
  ],
68
72
  utils: [
69
73
  "useApp",
@@ -77,10 +81,17 @@ const plugin = (options = {}) => {
77
81
  "numeric",
78
82
  "toggle",
79
83
  "select",
84
+ "confirm",
85
+ "waitForKeyPress",
80
86
  "isCancel",
81
87
  "sleep"
82
88
  ],
83
- upgrade: ["checkForUpdates"]
89
+ upgrade: [
90
+ "checkForUpdates",
91
+ "isCheckForUpdatesRequired",
92
+ "upgrade"
93
+ ],
94
+ env: ["env", "paths"]
84
95
  },
85
96
  get prefix() {
86
97
  return [
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAwCA;;;;AA8Gc,cA9GD,MA8GC,EAAA,CAAA,iBA9G0B,gBA8G1B,GA9G6C,gBA8G7C,CAAA,CAAA,OAAA,CAAA,EA7GH,gBA6GG,EAAA,GAAP,MAAO,CAAA,QAAA,CAAA,EAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAwCA;;;;AAyHc,cAzHD,MAyHC,EAAA,CAAA,iBAzH0B,gBAyH1B,GAzH6C,gBAyH7C,CAAA,CAAA,OAAA,CAAA,EAxHH,gBAwHG,EAAA,GAAP,MAAO,CAAA,QAAA,CAAA,EAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAwCA;;;;AA8Gc,cA9GD,MA8GC,EAAA,CAAA,iBA9G0B,gBA8G1B,GA9G6C,gBA8G7C,CAAA,CAAA,OAAA,CAAA,EA7GH,gBA6GG,EAAA,GAAP,MAAO,CAAA,QAAA,CAAA,EAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAwCA;;;;AAyHc,cAzHD,MAyHC,EAAA,CAAA,iBAzH0B,gBAyH1B,GAzH6C,gBAyH7C,CAAA,CAAA,OAAA,CAAA,EAxHH,gBAwHG,EAAA,GAAP,MAAO,CAAA,QAAA,CAAA,EAAA"}
package/dist/index.mjs CHANGED
@@ -50,15 +50,19 @@ const plugin = (options = {}) => {
50
50
  builtinImports: {
51
51
  console: [
52
52
  "info",
53
+ "debug",
54
+ "warn",
55
+ "help",
56
+ "error",
53
57
  "divider",
54
58
  "stripAnsi",
55
59
  "writeLine",
56
60
  "splitText",
57
61
  "colors",
58
- "help",
59
62
  "writeLine",
60
63
  "splitText",
61
- "stripAnsi"
64
+ "stripAnsi",
65
+ "createSpinner"
62
66
  ],
63
67
  utils: [
64
68
  "useApp",
@@ -72,10 +76,17 @@ const plugin = (options = {}) => {
72
76
  "numeric",
73
77
  "toggle",
74
78
  "select",
79
+ "confirm",
80
+ "waitForKeyPress",
75
81
  "isCancel",
76
82
  "sleep"
77
83
  ],
78
- upgrade: ["checkForUpdates"]
84
+ upgrade: [
85
+ "checkForUpdates",
86
+ "isCheckForUpdatesRequired",
87
+ "upgrade"
88
+ ],
89
+ env: ["env", "paths"]
79
90
  },
80
91
  get prefix() {
81
92
  return [
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["code","For","Show","VarDeclaration","render","console","prompts","upgrade","BinEntry","VirtualHelp","BannerFunctionDeclaration","CommandEntry","CommandRouter","VirtualCommandEntry","getDefaultOptions","plugin","options","name","config","debug","defaultOptions","isCaseSensitive","configResolved","dependencies","didyoumean2","prepare","order","handler","_self$","_$createComponent","builtinImports","utils","prefix","_$createIntrinsic","children","when","Object","keys","commands","length","type","initializer","segments","values","each","doubleHardline","child","isVirtual","fallback","command"],"sources":["../src/index.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, For, Show } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport console from \"@shell-shock/plugin-console\";\nimport prompts from \"@shell-shock/plugin-prompts\";\nimport upgrade from \"@shell-shock/plugin-upgrade\";\nimport { BinEntry } from \"@shell-shock/preset-script/components/bin-entry\";\nimport { VirtualHelp } from \"@shell-shock/preset-script/components/help\";\nimport type { Plugin } from \"powerlines/types/plugin\";\nimport { BannerFunctionDeclaration } from \"./components/banner-function-declaration\";\nimport { CommandEntry } from \"./components/command-entry\";\nimport { CommandRouter } from \"./components/command-router\";\nimport { VirtualCommandEntry } from \"./components/virtual-command-entry\";\nimport { getDefaultOptions } from \"./helpers/get-default-options\";\nimport type { CLIPresetContext, CLIPresetOptions } from \"./types/plugin\";\n\n/**\n * The Shell Shock CLI Preset plugin.\n *\n * @remarks\n * This preset includes a set of built-in modules and commands to create a CLI application, as well as configuration options to customize the generated code. It also includes the `prompts` plugin to provide interactive prompts in the CLI application, and the `upgrade` plugin to manage upgrading the local application's version.\n */\nexport const plugin = <TContext extends CLIPresetContext = CLIPresetContext>(\n options: CLIPresetOptions = {}\n) => {\n return [\n console(options),\n prompts(options),\n options.upgrade !== false && upgrade(options.upgrade),\n {\n name: \"shell-shock:cli-preset\",\n config() {\n this.debug(\n \"Providing default configuration for the Shell Shock `cli` preset.\"\n );\n\n return {\n defaultOptions: getDefaultOptions,\n isCaseSensitive: false,\n ...options\n };\n },\n configResolved() {\n this.dependencies.didyoumean2 = \"^7.0.4\";\n }\n },\n {\n name: \"shell-shock:cli-preset:generate-entrypoint\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `cli` preset.\"\n );\n\n return render(\n this,\n <>\n <BinEntry\n builtinImports={{\n console: [\n \"info\",\n \"divider\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"colors\",\n \"help\",\n \"writeLine\",\n \"splitText\",\n \"stripAnsi\"\n ],\n utils: [\n \"useApp\",\n \"useArgs\",\n \"isMinimal\",\n \"isInteractive\",\n \"isHelp\"\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"isCancel\",\n \"sleep\"\n ],\n upgrade: [\"checkForUpdates\"]\n }}\n prefix={\n <>\n <BannerFunctionDeclaration />\n <hbr />\n <hbr />\n </>\n }>\n <Show when={Object.keys(this.commands).length > 0}>\n <VarDeclaration\n let\n name=\"args\"\n type=\"string[]\"\n initializer={code`useArgs();`}\n />\n <hbr />\n <CommandRouter segments={[]} commands={this.commands ?? {}} />\n <hbr />\n </Show>\n <hbr />\n {code`await banner(0, false);`}\n <hbr />\n <hbr />\n <VirtualHelp\n options={this.options}\n commands={this.commands ?? {}}\n />\n </BinEntry>\n <Show when={Object.values(this.commands).length > 0}>\n <For each={Object.values(this.commands)} doubleHardline>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </Show>\n </>\n );\n }\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAae,UACXC,UAA4B,EAAE,KAC3B;AACH,QAAO;EACLX,QAAQW,QAAQ;EAChBV,QAAQU,QAAQ;EAChBA,QAAQT,YAAY,SAASA,QAAQS,QAAQT,QAAQ;EACrD;GACEU,MAAM;GACNC,SAAS;AACP,SAAKC,MACH,oEACD;AAED,WAAO;KACLC,gBAAgBN;KAChBO,iBAAiB;KACjB,GAAGL;KACJ;;GAEHM,iBAAiB;AACf,SAAKC,aAAaC,cAAc;;GAEnC;EACD;GACEP,MAAM;GACNQ,SAAS;IACPC,OAAO;IACP,MAAMC,UAAU;KAAA,MAAAC,SAAA;AACd,UAAKT,MACH,iEACD;AAED,YAAOf,OACL,MAAI,CAAAyB,gBAEDrB,UAAQ;MACPsB,gBAAgB;OACdzB,SAAS;QACP;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACD;OACD0B,OAAO;QACL;QACA;QACA;QACA;QACA;QACD;OACDzB,SAAS;QACP;QACA;QACA;QACA;QACA;QACA;QACD;OACDC,SAAS,CAAC,kBAAiB;OAC5B;MAAA,IACDyB,SAAM;AAAA,cAAA;QAAAH,gBAEDnB,2BAAyB,EAAA,CAAA;QAAAuB,gBAAA,OAAA,EAAA,CAAA;QAAAA,gBAAA,OAAA,EAAA,CAAA;QAAA;;MAAA,IAAAC,WAAA;AAAA,cAAA;Q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Ae/B"}
1
+ {"version":3,"file":"index.mjs","names":["code","For","Show","VarDeclaration","render","console","prompts","upgrade","BinEntry","VirtualHelp","BannerFunctionDeclaration","CommandEntry","CommandRouter","VirtualCommandEntry","getDefaultOptions","plugin","options","name","config","debug","defaultOptions","isCaseSensitive","configResolved","dependencies","didyoumean2","prepare","order","handler","_self$","_$createComponent","builtinImports","utils","env","prefix","_$createIntrinsic","children","when","Object","keys","commands","length","type","initializer","segments","values","each","doubleHardline","child","isVirtual","fallback","command"],"sources":["../src/index.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, For, Show } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport console from \"@shell-shock/plugin-console\";\nimport prompts from \"@shell-shock/plugin-prompts\";\nimport upgrade from \"@shell-shock/plugin-upgrade\";\nimport { BinEntry } from \"@shell-shock/preset-script/components/bin-entry\";\nimport { VirtualHelp } from \"@shell-shock/preset-script/components/help\";\nimport type { Plugin } from \"powerlines/types/plugin\";\nimport { BannerFunctionDeclaration } from \"./components/banner-function-declaration\";\nimport { CommandEntry } from \"./components/command-entry\";\nimport { CommandRouter } from \"./components/command-router\";\nimport { VirtualCommandEntry } from \"./components/virtual-command-entry\";\nimport { getDefaultOptions } from \"./helpers/get-default-options\";\nimport type { CLIPresetContext, CLIPresetOptions } from \"./types/plugin\";\n\n/**\n * The Shell Shock CLI Preset plugin.\n *\n * @remarks\n * This preset includes a set of built-in modules and commands to create a CLI application, as well as configuration options to customize the generated code. It also includes the `prompts` plugin to provide interactive prompts in the CLI application, and the `upgrade` plugin to manage upgrading the local application's version.\n */\nexport const plugin = <TContext extends CLIPresetContext = CLIPresetContext>(\n options: CLIPresetOptions = {}\n) => {\n return [\n console(options),\n prompts(options),\n options.upgrade !== false && upgrade(options.upgrade),\n {\n name: \"shell-shock:cli-preset\",\n config() {\n this.debug(\n \"Providing default configuration for the Shell Shock `cli` preset.\"\n );\n\n return {\n defaultOptions: getDefaultOptions,\n isCaseSensitive: false,\n ...options\n };\n },\n configResolved() {\n this.dependencies.didyoumean2 = \"^7.0.4\";\n }\n },\n {\n name: \"shell-shock:cli-preset:generate-entrypoint\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `cli` preset.\"\n );\n\n return render(\n this,\n <>\n <BinEntry\n builtinImports={{\n console: [\n \"info\",\n \"debug\",\n \"warn\",\n \"help\",\n \"error\",\n \"divider\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"colors\",\n \"writeLine\",\n \"splitText\",\n \"stripAnsi\",\n \"createSpinner\"\n ],\n utils: [\n \"useApp\",\n \"useArgs\",\n \"isMinimal\",\n \"isInteractive\",\n \"isHelp\"\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"waitForKeyPress\",\n \"isCancel\",\n \"sleep\"\n ],\n upgrade: [\n \"checkForUpdates\",\n \"isCheckForUpdatesRequired\",\n \"upgrade\"\n ],\n env: [\"env\", \"paths\"]\n }}\n prefix={\n <>\n <BannerFunctionDeclaration />\n <hbr />\n <hbr />\n </>\n }>\n <Show when={Object.keys(this.commands).length > 0}>\n <VarDeclaration\n let\n name=\"args\"\n type=\"string[]\"\n initializer={code`useArgs();`}\n />\n <hbr />\n <CommandRouter segments={[]} commands={this.commands ?? {}} />\n <hbr />\n </Show>\n <hbr />\n {code`await banner(0, false);`}\n <hbr />\n <hbr />\n <VirtualHelp\n options={this.options}\n commands={this.commands ?? {}}\n />\n </BinEntry>\n <Show when={Object.values(this.commands).length > 0}>\n <For each={Object.values(this.commands)} doubleHardline>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </Show>\n </>\n );\n }\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAae,UACXC,UAA4B,EAAE,KAC3B;AACH,QAAO;EACLX,QAAQW,QAAQ;EAChBV,QAAQU,QAAQ;EAChBA,QAAQT,YAAY,SAASA,QAAQS,QAAQT,QAAQ;EACrD;GACEU,MAAM;GACNC,SAAS;AACP,SAAKC,MACH,oEACD;AAED,WAAO;KACLC,gBAAgBN;KAChBO,iBAAiB;KACjB,GAAGL;KACJ;;GAEHM,iBAAiB;AACf,SAAKC,aAAaC,cAAc;;GAEnC;EACD;GACEP,MAAM;GACNQ,SAAS;IACPC,OAAO;IACP,MAAMC,UAAU;KAAA,MAAAC,SAAA;AACd,UAAKT,MACH,iEACD;AAED,YAAOf,OACL,MAAI,CAAAyB,gBAEDrB,UAAQ;MACPsB,gBAAgB;OACdzB,SAAS;QACP;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACD;OACD0B,OAAO;QACL;QACA;QACA;QACA;QACA;QACD;OACDzB,SAAS;QACP;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACD;OACDC,SAAS;QACP;QACA;QACA;QACD;OACDyB,KAAK,CAAC,OAAO,QAAO;OACrB;MAAA,IACDC,SAAM;AAAA,cAAA;QAAAJ,gBAEDnB,2BAAyB,EAAA,CAAA;QAAAwB,gBAAA,OAAA,EAAA,CAAA;QAAAA,gBAAA,OAAA,EAAA,CAAA;QAAA;;MAAA,IAAAC,WAAA;AAAA,cAAA;QAAAN,gBAK7B3B,MAAI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 @@
1
- import { CLIPresetContext, CLIPresetOptions, CLIPresetResolvedConfig, CLIPresetUserConfig } from "./plugin.cjs";
2
- export { CLIPresetContext, CLIPresetOptions, CLIPresetResolvedConfig, CLIPresetUserConfig };
1
+ import { CLIPresetContext, CLIPresetOptions, CLIPresetResolvedConfig, CLIPresetUpgradeOptions, CLIPresetUserConfig, UpgradeType } from "./plugin.cjs";
2
+ export { CLIPresetContext, CLIPresetOptions, CLIPresetResolvedConfig, CLIPresetUpgradeOptions, CLIPresetUserConfig, UpgradeType };
@@ -1,2 +1,2 @@
1
- import { CLIPresetContext, CLIPresetOptions, CLIPresetResolvedConfig, CLIPresetUserConfig } from "./plugin.mjs";
2
- export { CLIPresetContext, CLIPresetOptions, CLIPresetResolvedConfig, CLIPresetUserConfig };
1
+ import { CLIPresetContext, CLIPresetOptions, CLIPresetResolvedConfig, CLIPresetUpgradeOptions, CLIPresetUserConfig, UpgradeType } from "./plugin.mjs";
2
+ export { CLIPresetContext, CLIPresetOptions, CLIPresetResolvedConfig, CLIPresetUpgradeOptions, CLIPresetUserConfig, UpgradeType };
@@ -1,10 +1,26 @@
1
1
  import { CommandBase, CommandOption } from "@shell-shock/core/types/command";
2
2
  import { Context } from "@shell-shock/core/types/context";
3
+ import { PromptsPluginContext } from "@shell-shock/plugin-prompts/types/plugin";
3
4
  import { ThemePluginResolvedConfig, ThemePluginUserConfig } from "@shell-shock/plugin-theme/types/plugin";
4
- import { UpgradePluginContext, UpgradePluginOptions, UpgradePluginResolvedConfig, UpgradePluginUserConfig } from "@shell-shock/plugin-upgrade/types/plugin";
5
+ import { UpgradePluginOptions } from "@shell-shock/plugin-upgrade/types/plugin";
5
6
  import { ScriptPresetContext, ScriptPresetOptions, ScriptPresetResolvedConfig, ScriptPresetUserConfig } from "@shell-shock/preset-script/types/plugin";
6
7
 
7
8
  //#region src/types/plugin.d.ts
9
+ type UpgradeType = "confirm" | "auto" | "manual";
10
+ interface CLIPresetUpgradeOptions extends UpgradePluginOptions {
11
+ /**
12
+ * The type of upgrade to perform. This option determines how the upgrade process will be handled.
13
+ *
14
+ * @remarks
15
+ * The upgrade logic will behave differently based on the value of this field:
16
+ * - `"confirm"` - the user will be prompted to confirm the upgrade before it is performed. This is the default behavior and is recommended for most users, as it provides an extra layer of safety against unintended upgrades.
17
+ * - `"auto"` - the upgrade will be performed automatically without any user confirmation. This option is suitable for advanced users who want a seamless upgrade experience and are confident in the stability of new versions.
18
+ * - `"manual"` - the command will only display the latest available version without performing any upgrade. This option is useful for users who want to check for updates without making any changes to their system.
19
+ *
20
+ * @defaultValue "confirm"
21
+ */
22
+ type?: UpgradeType;
23
+ }
8
24
  type CLIPresetOptions = Omit<ScriptPresetOptions, "defaultOptions"> & {
9
25
  /**
10
26
  * The default interactive mode to apply to commands.
@@ -39,11 +55,19 @@ type CLIPresetOptions = Omit<ScriptPresetOptions, "defaultOptions"> & {
39
55
  * @remarks
40
56
  * The upgrade command allows users to check for and perform upgrades to the latest version of the application. If you would like to include the upgrade command in your CLI application, but manage its configuration separately, you can set this field to `true` and configure the upgrade plugin directly in your application's configuration.
41
57
  */
42
- upgrade?: UpgradePluginOptions | false;
58
+ upgrade?: CLIPresetUpgradeOptions | false;
59
+ };
60
+ type CLIPresetUserConfig = ScriptPresetUserConfig & ThemePluginUserConfig & CLIPresetOptions;
61
+ type CLIPresetResolvedConfig = ScriptPresetResolvedConfig & ThemePluginResolvedConfig & Required<Pick<CLIPresetOptions, "interactive" | "defaultOptions">> & {
62
+ /**
63
+ * Whether to include the upgrade process provided by the `@shell-shock/plugin-upgrade` package. If not set to `false`, the upgrade command will be included with default options. If set to an object, the provided options will be used to configure the upgrade command. If set to `false`, the upgrade command will not be included.
64
+ *
65
+ * @remarks
66
+ * The upgrade command allows users to check for and perform upgrades to the latest version of the application. If you would like to include the upgrade command in your CLI application, but manage its configuration separately, you can set this field to `true` and configure the upgrade plugin directly in your application's configuration.
67
+ */
68
+ upgrade: Required<CLIPresetUpgradeOptions> | false;
43
69
  };
44
- type CLIPresetUserConfig = ScriptPresetUserConfig & ThemePluginUserConfig & UpgradePluginUserConfig & Omit<CLIPresetOptions, "upgrade">;
45
- type CLIPresetResolvedConfig = ScriptPresetResolvedConfig & UpgradePluginResolvedConfig & ThemePluginResolvedConfig & Required<Pick<CLIPresetOptions, "interactive" | "defaultOptions">>;
46
- type CLIPresetContext<TResolvedConfig extends CLIPresetResolvedConfig = CLIPresetResolvedConfig> = ScriptPresetContext<TResolvedConfig> & UpgradePluginContext<TResolvedConfig>;
70
+ type CLIPresetContext<TResolvedConfig extends CLIPresetResolvedConfig = CLIPresetResolvedConfig> = PromptsPluginContext & ScriptPresetContext<TResolvedConfig>;
47
71
  //#endregion
48
- export { CLIPresetContext, CLIPresetOptions, CLIPresetResolvedConfig, CLIPresetUserConfig };
72
+ export { CLIPresetContext, CLIPresetOptions, CLIPresetResolvedConfig, CLIPresetUpgradeOptions, CLIPresetUserConfig, UpgradeType };
49
73
  //# sourceMappingURL=plugin.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;KAwCY,gBAAA,GAAmB,KAAK;;AAApC;;;;;;;;;AA0CA;EAAkC,WAAA,CAAA,EAAA,OAAA,GAAA,OAAA;EAChC;;;;;AAIF;;;;;;;;AAKA;EAC0B,cAAA,CAAA,EAxBpB,aAwBoB,EAAA,GAAA,CAAA,CAAA,OAAA,EAvBT,OAuBS,EAAA,KAAA,EAvBO,WAuBP,EAAA,GAvBuB,aAuBvB,EAAA,CAAA,GAAA,KAAA;EAA0B;;;;;;YAdxC;;KAGA,mBAAA,GAAsB,yBAChC,wBACA,0BACA,KAAK;KAEK,uBAAA,GAA0B,6BACpC,8BACA,4BACA,SAAS,KAAK;KAEJ,yCACc,0BAA0B,2BAChD,oBAAoB,mBACtB,qBAAqB"}
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;;KAoCY,WAAA;UAEK,uBAAA,SAAgC;EAFrC;AAEZ;AAeA;;;;;;;;;EA0CY,IAAA,CAAA,EA7CH,WA6CG;;AACV,KA3CU,gBAAA,GAAmB,IA2C7B,CA3CkC,mBA2ClC,EAAA,gBAAA,CAAA,GAAA;EACA;;AAEF;;;;;;;;;EAYY,WAAA,CAAA,EAAA,OAAgB,GAAA,OAAA;EACF;;;;;;;;;;;;;;mBA9BpB,6BACW,gBAAgB,gBAAgB;;;;;;;YASrC;;KAGA,mBAAA,GAAsB,yBAChC,wBACA;KAEU,uBAAA,GAA0B,6BACpC,4BACA,SAAS,KAAK;;;;;;;WAOH,SAAS;;KAGV,yCACc,0BAA0B,2BAChD,uBAAuB,oBAAoB"}
@@ -1,10 +1,26 @@
1
1
  import { CommandBase, CommandOption } from "@shell-shock/core/types/command";
2
2
  import { Context } from "@shell-shock/core/types/context";
3
+ import { PromptsPluginContext } from "@shell-shock/plugin-prompts/types/plugin";
3
4
  import { ThemePluginResolvedConfig, ThemePluginUserConfig } from "@shell-shock/plugin-theme/types/plugin";
4
- import { UpgradePluginContext, UpgradePluginOptions, UpgradePluginResolvedConfig, UpgradePluginUserConfig } from "@shell-shock/plugin-upgrade/types/plugin";
5
+ import { UpgradePluginOptions } from "@shell-shock/plugin-upgrade/types/plugin";
5
6
  import { ScriptPresetContext, ScriptPresetOptions, ScriptPresetResolvedConfig, ScriptPresetUserConfig } from "@shell-shock/preset-script/types/plugin";
6
7
 
7
8
  //#region src/types/plugin.d.ts
9
+ type UpgradeType = "confirm" | "auto" | "manual";
10
+ interface CLIPresetUpgradeOptions extends UpgradePluginOptions {
11
+ /**
12
+ * The type of upgrade to perform. This option determines how the upgrade process will be handled.
13
+ *
14
+ * @remarks
15
+ * The upgrade logic will behave differently based on the value of this field:
16
+ * - `"confirm"` - the user will be prompted to confirm the upgrade before it is performed. This is the default behavior and is recommended for most users, as it provides an extra layer of safety against unintended upgrades.
17
+ * - `"auto"` - the upgrade will be performed automatically without any user confirmation. This option is suitable for advanced users who want a seamless upgrade experience and are confident in the stability of new versions.
18
+ * - `"manual"` - the command will only display the latest available version without performing any upgrade. This option is useful for users who want to check for updates without making any changes to their system.
19
+ *
20
+ * @defaultValue "confirm"
21
+ */
22
+ type?: UpgradeType;
23
+ }
8
24
  type CLIPresetOptions = Omit<ScriptPresetOptions, "defaultOptions"> & {
9
25
  /**
10
26
  * The default interactive mode to apply to commands.
@@ -39,11 +55,19 @@ type CLIPresetOptions = Omit<ScriptPresetOptions, "defaultOptions"> & {
39
55
  * @remarks
40
56
  * The upgrade command allows users to check for and perform upgrades to the latest version of the application. If you would like to include the upgrade command in your CLI application, but manage its configuration separately, you can set this field to `true` and configure the upgrade plugin directly in your application's configuration.
41
57
  */
42
- upgrade?: UpgradePluginOptions | false;
58
+ upgrade?: CLIPresetUpgradeOptions | false;
59
+ };
60
+ type CLIPresetUserConfig = ScriptPresetUserConfig & ThemePluginUserConfig & CLIPresetOptions;
61
+ type CLIPresetResolvedConfig = ScriptPresetResolvedConfig & ThemePluginResolvedConfig & Required<Pick<CLIPresetOptions, "interactive" | "defaultOptions">> & {
62
+ /**
63
+ * Whether to include the upgrade process provided by the `@shell-shock/plugin-upgrade` package. If not set to `false`, the upgrade command will be included with default options. If set to an object, the provided options will be used to configure the upgrade command. If set to `false`, the upgrade command will not be included.
64
+ *
65
+ * @remarks
66
+ * The upgrade command allows users to check for and perform upgrades to the latest version of the application. If you would like to include the upgrade command in your CLI application, but manage its configuration separately, you can set this field to `true` and configure the upgrade plugin directly in your application's configuration.
67
+ */
68
+ upgrade: Required<CLIPresetUpgradeOptions> | false;
43
69
  };
44
- type CLIPresetUserConfig = ScriptPresetUserConfig & ThemePluginUserConfig & UpgradePluginUserConfig & Omit<CLIPresetOptions, "upgrade">;
45
- type CLIPresetResolvedConfig = ScriptPresetResolvedConfig & UpgradePluginResolvedConfig & ThemePluginResolvedConfig & Required<Pick<CLIPresetOptions, "interactive" | "defaultOptions">>;
46
- type CLIPresetContext<TResolvedConfig extends CLIPresetResolvedConfig = CLIPresetResolvedConfig> = ScriptPresetContext<TResolvedConfig> & UpgradePluginContext<TResolvedConfig>;
70
+ type CLIPresetContext<TResolvedConfig extends CLIPresetResolvedConfig = CLIPresetResolvedConfig> = PromptsPluginContext & ScriptPresetContext<TResolvedConfig>;
47
71
  //#endregion
48
- export { CLIPresetContext, CLIPresetOptions, CLIPresetResolvedConfig, CLIPresetUserConfig };
72
+ export { CLIPresetContext, CLIPresetOptions, CLIPresetResolvedConfig, CLIPresetUpgradeOptions, CLIPresetUserConfig, UpgradeType };
49
73
  //# sourceMappingURL=plugin.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;KAwCY,gBAAA,GAAmB,KAAK;;AAApC;;;;;;;;;AA0CA;EAAkC,WAAA,CAAA,EAAA,OAAA,GAAA,OAAA;EAChC;;;;;AAIF;;;;;;;;AAKA;EAC0B,cAAA,CAAA,EAxBpB,aAwBoB,EAAA,GAAA,CAAA,CAAA,OAAA,EAvBT,OAuBS,EAAA,KAAA,EAvBO,WAuBP,EAAA,GAvBuB,aAuBvB,EAAA,CAAA,GAAA,KAAA;EAA0B;;;;;;YAdxC;;KAGA,mBAAA,GAAsB,yBAChC,wBACA,0BACA,KAAK;KAEK,uBAAA,GAA0B,6BACpC,8BACA,4BACA,SAAS,KAAK;KAEJ,yCACc,0BAA0B,2BAChD,oBAAoB,mBACtB,qBAAqB"}
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;;KAoCY,WAAA;UAEK,uBAAA,SAAgC;EAFrC;AAEZ;AAeA;;;;;;;;;EA0CY,IAAA,CAAA,EA7CH,WA6CG;;AACV,KA3CU,gBAAA,GAAmB,IA2C7B,CA3CkC,mBA2ClC,EAAA,gBAAA,CAAA,GAAA;EACA;;AAEF;;;;;;;;;EAYY,WAAA,CAAA,EAAA,OAAgB,GAAA,OAAA;EACF;;;;;;;;;;;;;;mBA9BpB,6BACW,gBAAgB,gBAAgB;;;;;;;YASrC;;KAGA,mBAAA,GAAsB,yBAChC,wBACA;KAEU,uBAAA,GAA0B,6BACpC,4BACA,SAAS,KAAK;;;;;;;WAOH,SAAS;;KAGV,yCACc,0BAA0B,2BAChD,uBAAuB,oBAAoB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shell-shock/preset-cli",
3
- "version": "0.7.5",
3
+ "version": "0.7.7",
4
4
  "type": "module",
5
5
  "description": "A package containing a Shell Shock plugin to generate source code given a list design tokens.",
6
6
  "repository": {
@@ -167,20 +167,20 @@
167
167
  "dependencies": {
168
168
  "@alloy-js/core": "0.23.0-dev.8",
169
169
  "@alloy-js/typescript": "0.23.0-dev.4",
170
- "@powerlines/deepkit": "^0.6.67",
171
- "@powerlines/plugin-alloy": "^0.23.17",
172
- "@powerlines/plugin-plugin": "^0.12.238",
173
- "@shell-shock/core": "^0.9.1",
174
- "@shell-shock/plugin-console": "^0.0.5",
175
- "@shell-shock/plugin-prompts": "^0.3.0",
176
- "@shell-shock/plugin-theme": "^0.3.3",
177
- "@shell-shock/plugin-upgrade": "^0.1.5",
178
- "@shell-shock/preset-script": "^0.6.14",
170
+ "@powerlines/deepkit": "^0.6.69",
171
+ "@powerlines/plugin-alloy": "^0.23.19",
172
+ "@powerlines/plugin-plugin": "^0.12.240",
173
+ "@shell-shock/core": "^0.9.3",
174
+ "@shell-shock/plugin-console": "^0.1.1",
175
+ "@shell-shock/plugin-prompts": "^0.3.2",
176
+ "@shell-shock/plugin-theme": "^0.3.5",
177
+ "@shell-shock/plugin-upgrade": "^0.1.7",
178
+ "@shell-shock/preset-script": "^0.6.16",
179
179
  "@stryke/path": "0.26.6",
180
180
  "@stryke/string-format": "0.14.2",
181
181
  "cfonts": "^3.3.1",
182
182
  "defu": "6.1.4",
183
- "powerlines": "^0.38.54"
183
+ "powerlines": "^0.38.56"
184
184
  },
185
185
  "devDependencies": {
186
186
  "@babel/core": "^7.29.0",
@@ -210,5 +210,5 @@
210
210
  "./package.json": "./package.json"
211
211
  }
212
212
  },
213
- "gitHead": "b94dfbfbfd27471351cac0596afe1f550d8dca57"
213
+ "gitHead": "4cf65f37aca1c43ffac57a86bf21e184134437f1"
214
214
  }