@shell-shock/preset-cli 0.7.13 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
- package/dist/_virtual/_rolldown/runtime.mjs +3 -0
- package/dist/components/banner-function-declaration.cjs +48 -164
- package/dist/components/banner-function-declaration.d.cts +2 -2
- package/dist/components/banner-function-declaration.d.cts.map +1 -1
- package/dist/components/banner-function-declaration.d.mts +2 -2
- package/dist/components/banner-function-declaration.d.mts.map +1 -1
- package/dist/components/banner-function-declaration.mjs +29 -146
- package/dist/components/banner-function-declaration.mjs.map +1 -1
- package/dist/components/command-entry.cjs +185 -144
- package/dist/components/command-entry.d.cts +2 -2
- package/dist/components/command-entry.d.cts.map +1 -1
- package/dist/components/command-entry.d.mts +3 -3
- package/dist/components/command-entry.d.mts.map +1 -1
- package/dist/components/command-entry.mjs +124 -84
- package/dist/components/command-entry.mjs.map +1 -1
- package/dist/components/command-router.cjs +20 -18
- package/dist/components/command-router.d.cts.map +1 -1
- package/dist/components/command-router.d.mts.map +1 -1
- package/dist/components/command-router.mjs +2 -1
- package/dist/components/command-router.mjs.map +1 -1
- package/dist/components/index.cjs +4 -0
- package/dist/components/index.d.cts +2 -1
- package/dist/components/index.d.mts +2 -1
- package/dist/components/index.mjs +2 -1
- package/dist/components/upgrade-builtin.cjs +171 -0
- package/dist/components/upgrade-builtin.d.cts +15 -0
- package/dist/components/upgrade-builtin.d.cts.map +1 -0
- package/dist/components/upgrade-builtin.d.mts +15 -0
- package/dist/components/upgrade-builtin.d.mts.map +1 -0
- package/dist/components/upgrade-builtin.mjs +169 -0
- package/dist/components/upgrade-builtin.mjs.map +1 -0
- package/dist/components/virtual-command-entry.cjs +26 -24
- package/dist/components/virtual-command-entry.d.cts.map +1 -1
- package/dist/components/virtual-command-entry.d.mts +1 -1
- package/dist/components/virtual-command-entry.d.mts.map +1 -1
- package/dist/components/virtual-command-entry.mjs +7 -6
- package/dist/components/virtual-command-entry.mjs.map +1 -1
- package/dist/helpers/get-default-options.cjs +6 -6
- package/dist/helpers/get-default-options.mjs.map +1 -1
- package/dist/index.cjs +49 -62
- package/dist/index.d.cts +0 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +23 -36
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-help/dist/components/display.cjs +259 -0
- package/dist/plugin-help/dist/components/display.mjs +254 -0
- package/dist/plugin-help/dist/components/display.mjs.map +1 -0
- package/dist/plugin-help/dist/components/help-builtin.cjs +85 -0
- package/dist/plugin-help/dist/components/help-builtin.mjs +84 -0
- package/dist/plugin-help/dist/components/help-builtin.mjs.map +1 -0
- package/dist/plugin-help/dist/components/help-command.cjs +96 -0
- package/dist/plugin-help/dist/components/help-command.mjs +96 -0
- package/dist/plugin-help/dist/components/help-command.mjs.map +1 -0
- package/dist/plugin-help/dist/components/index.cjs +3 -0
- package/dist/plugin-help/dist/components/index.mjs +5 -0
- package/dist/plugin-help/dist/index.cjs +103 -0
- package/dist/plugin-help/dist/index.d.cts +2 -0
- package/dist/plugin-help/dist/index.d.mts +2 -0
- package/dist/plugin-help/dist/index.mjs +100 -0
- package/dist/plugin-help/dist/index.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/constant-case.cjs +17 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/constant-case.mjs +17 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/constant-case.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/get-words.cjs +38 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/get-words.mjs +38 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/get-words.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/kebab-case.cjs +33 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/kebab-case.mjs +34 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/kebab-case.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/snake-case.cjs +40 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/snake-case.mjs +41 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/snake-case.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/upper-case-first.cjs +17 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/upper-case-first.mjs +17 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/upper-case-first.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-empty.cjs +20 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-empty.mjs +21 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-empty.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-null.cjs +12 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-null.mjs +12 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-null.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set-string.cjs +20 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set-string.mjs +21 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set-string.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set.cjs +19 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set.mjs +20 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-string.cjs +12 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-string.mjs +12 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-string.mjs.map +1 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-undefined.cjs +8 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-undefined.mjs +8 -0
- package/dist/plugin-help/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-undefined.mjs.map +1 -0
- package/dist/plugin-help/dist/types/plugin.d.cts +62 -0
- package/dist/plugin-help/dist/types/plugin.d.cts.map +1 -0
- package/dist/plugin-help/dist/types/plugin.d.mts +62 -0
- package/dist/plugin-help/dist/types/plugin.d.mts.map +1 -0
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/plugin.d.cts +20 -34
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +20 -34
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +30 -16
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
let
|
|
4
|
-
let
|
|
5
|
-
let
|
|
6
|
-
let
|
|
7
|
-
let
|
|
8
|
-
let
|
|
9
|
-
let
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
5
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
6
|
+
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
7
|
+
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
8
|
+
let _shell_shock_plugin_theme_contexts_theme = require("@shell-shock/plugin-theme/contexts/theme");
|
|
9
|
+
let _shell_shock_preset_script_components_banner_function_declaration = require("@shell-shock/preset-script/components/banner-function-declaration");
|
|
10
10
|
let cfonts = require("cfonts");
|
|
11
11
|
|
|
12
12
|
//#region src/components/banner-function-declaration.tsx
|
|
@@ -15,14 +15,14 @@ let cfonts = require("cfonts");
|
|
|
15
15
|
*/
|
|
16
16
|
function BannerFunctionDeclaration(props) {
|
|
17
17
|
const { consoleFnName = "log", variant = "primary", command } = props;
|
|
18
|
-
const theme = (0,
|
|
19
|
-
const context = (0,
|
|
20
|
-
const header = (0,
|
|
21
|
-
const footer = (0,
|
|
22
|
-
const title = (0,
|
|
23
|
-
const description = (0,
|
|
24
|
-
const titleLines = (0,
|
|
25
|
-
const result = (0, cfonts.render)((0,
|
|
18
|
+
const theme = (0, _shell_shock_plugin_theme_contexts_theme.useTheme)();
|
|
19
|
+
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
20
|
+
const header = (0, _alloy_js_core.computed)(() => `${theme.labels.banner.header[variant] || (0, _shell_shock_core_plugin_utils.getAppTitle)(context)} v${context.packageJson.version || "1.0.0"}`);
|
|
21
|
+
const footer = (0, _alloy_js_core.computed)(() => theme.labels.banner.footer[variant]);
|
|
22
|
+
const title = (0, _alloy_js_core.computed)(() => (0, _shell_shock_core_plugin_utils.getAppTitle)(context, true).replace(`v${context.packageJson.version || "1.0.0"}`, ""));
|
|
23
|
+
const description = (0, _alloy_js_core.computed)(() => command?.description || (0, _shell_shock_core_plugin_utils.getAppDescription)(context));
|
|
24
|
+
const titleLines = (0, _alloy_js_core.computed)(() => {
|
|
25
|
+
const result = (0, cfonts.render)((0, _shell_shock_core_plugin_utils.getAppTitle)(context, true), {
|
|
26
26
|
font: "tiny",
|
|
27
27
|
align: "left",
|
|
28
28
|
background: "transparent",
|
|
@@ -32,161 +32,45 @@ function BannerFunctionDeclaration(props) {
|
|
|
32
32
|
transitionGradient: false,
|
|
33
33
|
env: "node"
|
|
34
34
|
});
|
|
35
|
-
if (!result) return [`${(0,
|
|
35
|
+
if (!result) return [`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} Command-Line Interface`];
|
|
36
36
|
return result.array;
|
|
37
37
|
});
|
|
38
|
-
const bannerPadding = (0,
|
|
39
|
-
const totalPadding = (0,
|
|
40
|
-
return [(0,
|
|
38
|
+
const bannerPadding = (0, _alloy_js_core.computed)(() => Math.max(theme.padding.app, 0) * 2 + theme.borderStyles.banner.outline[variant].left.length + theme.borderStyles.banner.outline[variant].right.length);
|
|
39
|
+
const totalPadding = (0, _alloy_js_core.computed)(() => Math.max(theme.padding.banner, 0) * 2 + bannerPadding.value);
|
|
40
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
41
41
|
async: true,
|
|
42
42
|
name: "banner",
|
|
43
43
|
get doc() {
|
|
44
|
-
return `Write the ${(0,
|
|
45
|
-
},
|
|
46
|
-
get parameters() {
|
|
47
|
-
return [{
|
|
48
|
-
name: "pause",
|
|
49
|
-
type: "number",
|
|
50
|
-
default: 500
|
|
51
|
-
}, {
|
|
52
|
-
name: "upgradeCheck",
|
|
53
|
-
default: context.config.upgrade !== false ? "true" : "false"
|
|
54
|
-
}];
|
|
44
|
+
return `Write the ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} application banner ${command ? `for the ${command.title} command ` : ""}to the console.`;
|
|
55
45
|
},
|
|
46
|
+
parameters: [{
|
|
47
|
+
name: "pause",
|
|
48
|
+
type: "number",
|
|
49
|
+
default: 500
|
|
50
|
+
}],
|
|
56
51
|
get children() {
|
|
57
|
-
return [
|
|
58
|
-
(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return __alloy_js_core.code`const titleLines = [${titleLines.value.map((line) => JSON.stringify(line.trim())).join(", ")}];
|
|
52
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_preset_script_components_banner_function_declaration.BannerFunctionBodyDeclaration, {
|
|
53
|
+
get header() {
|
|
54
|
+
return header.value;
|
|
55
|
+
},
|
|
56
|
+
get description() {
|
|
57
|
+
return description.value;
|
|
58
|
+
},
|
|
59
|
+
get footer() {
|
|
60
|
+
return footer.value;
|
|
61
|
+
},
|
|
62
|
+
variant,
|
|
63
|
+
consoleFnName,
|
|
64
|
+
command,
|
|
65
|
+
insertNewlineAfterDescription: true,
|
|
66
|
+
get children() {
|
|
67
|
+
return _alloy_js_core.code`const titleLines = [${titleLines.value.map((line) => JSON.stringify(line.trim())).join(", ")}];
|
|
74
68
|
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
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}),
|
|
81
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
|
|
82
|
-
get when() {
|
|
83
|
-
return context.config.upgrade !== false;
|
|
84
|
-
},
|
|
85
|
-
get children() {
|
|
86
|
-
return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
|
|
87
|
-
condition: __alloy_js_core.code`upgradeCheck && (await isCheckForUpdatesRequired())`,
|
|
88
|
-
get children() {
|
|
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.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.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.getAppTitle)(context, true)} is available: \${colors.red(\`v\${result.currentVersion}\`)} \${colors.text.body.tertiary("➜")} \${colors.green(\`v\${result.latestVersion}\`)}\${result.package.date ? colors.text.body.tertiary(\` (updated on \${result.package.date})\`) : ""}${context.config.upgrade !== false && context.config.upgrade.type === "manual" ? ` \\nPlease run \`${(0, __shell_shock_core_plugin_utils.getAppBin)(context)} update\` to upgrade to the latest version.` : ""}\`); `),
|
|
131
|
-
(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.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.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.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.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.getAppTitle)(context, true)}.");
|
|
181
|
-
writeLine("");
|
|
182
|
-
`;
|
|
183
|
-
} })
|
|
184
|
-
];
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
})
|
|
189
|
-
];
|
|
69
|
+
}
|
|
70
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
71
|
+
condition: _alloy_js_core.code`isInteractive && !isHelp`,
|
|
72
|
+
children: _alloy_js_core.code`await sleep(pause);`
|
|
73
|
+
})];
|
|
190
74
|
}
|
|
191
75
|
})];
|
|
192
76
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
2
2
|
import { BannerFunctionDeclarationProps } from "@shell-shock/preset-script/components/banner-function-declaration";
|
|
3
3
|
|
|
4
4
|
//#region src/components/banner-function-declaration.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* A component to generate the `banner` function in the `shell-shock:console` builtin module.
|
|
7
7
|
*/
|
|
8
|
-
declare function BannerFunctionDeclaration(props: BannerFunctionDeclarationProps):
|
|
8
|
+
declare function BannerFunctionDeclaration(props: BannerFunctionDeclarationProps): _alloy_js_core0.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"],"
|
|
1
|
+
{"version":3,"file":"banner-function-declaration.d.cts","names":[],"sources":["../../src/components/banner-function-declaration.tsx"],"mappings":";;;;;;;iBA+BgB,yBAAA,CACd,KAAA,EAAO,8BAAA,GAA8B,eAAA,CAAA,QAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
2
2
|
import { BannerFunctionDeclarationProps } from "@shell-shock/preset-script/components/banner-function-declaration";
|
|
3
3
|
|
|
4
4
|
//#region src/components/banner-function-declaration.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* A component to generate the `banner` function in the `shell-shock:console` builtin module.
|
|
7
7
|
*/
|
|
8
|
-
declare function BannerFunctionDeclaration(props: BannerFunctionDeclarationProps):
|
|
8
|
+
declare function BannerFunctionDeclaration(props: BannerFunctionDeclarationProps): _alloy_js_core0.Children;
|
|
9
9
|
//#endregion
|
|
10
10
|
export { BannerFunctionDeclaration };
|
|
11
11
|
//# sourceMappingURL=banner-function-declaration.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner-function-declaration.d.mts","names":[],"sources":["../../src/components/banner-function-declaration.tsx"],"
|
|
1
|
+
{"version":3,"file":"banner-function-declaration.d.mts","names":[],"sources":["../../src/components/banner-function-declaration.tsx"],"mappings":";;;;;;;iBA+BgB,yBAAA,CACd,KAAA,EAAO,8BAAA,GAA8B,eAAA,CAAA,QAAA"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { code, computed } from "@alloy-js/core";
|
|
3
|
+
import { FunctionDeclaration, IfStatement } from "@alloy-js/typescript";
|
|
4
|
+
import { getAppDescription, getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
5
5
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
6
|
-
import { getAppBin, getAppDescription, getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
7
6
|
import { useTheme } from "@shell-shock/plugin-theme/contexts/theme";
|
|
8
7
|
import { BannerFunctionBodyDeclaration } from "@shell-shock/preset-script/components/banner-function-declaration";
|
|
9
8
|
import { render } from "cfonts";
|
|
@@ -42,150 +41,34 @@ function BannerFunctionDeclaration(props) {
|
|
|
42
41
|
get doc() {
|
|
43
42
|
return `Write the ${getAppTitle(context, true)} application banner ${command ? `for the ${command.title} command ` : ""}to the console.`;
|
|
44
43
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}, {
|
|
51
|
-
name: "upgradeCheck",
|
|
52
|
-
default: context.config.upgrade !== false ? "true" : "false"
|
|
53
|
-
}];
|
|
54
|
-
},
|
|
44
|
+
parameters: [{
|
|
45
|
+
name: "pause",
|
|
46
|
+
type: "number",
|
|
47
|
+
default: 500
|
|
48
|
+
}],
|
|
55
49
|
get children() {
|
|
56
|
-
return [
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return code`const titleLines = [${titleLines.value.map((line) => JSON.stringify(line.trim())).join(", ")}];
|
|
50
|
+
return [createComponent(BannerFunctionBodyDeclaration, {
|
|
51
|
+
get header() {
|
|
52
|
+
return header.value;
|
|
53
|
+
},
|
|
54
|
+
get description() {
|
|
55
|
+
return description.value;
|
|
56
|
+
},
|
|
57
|
+
get footer() {
|
|
58
|
+
return footer.value;
|
|
59
|
+
},
|
|
60
|
+
variant,
|
|
61
|
+
consoleFnName,
|
|
62
|
+
command,
|
|
63
|
+
insertNewlineAfterDescription: true,
|
|
64
|
+
get children() {
|
|
65
|
+
return code`const titleLines = [${titleLines.value.map((line) => JSON.stringify(line.trim())).join(", ")}];
|
|
73
66
|
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\`; `;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}),
|
|
80
|
-
createComponent(Show, {
|
|
81
|
-
get when() {
|
|
82
|
-
return context.config.upgrade !== false;
|
|
83
|
-
},
|
|
84
|
-
get children() {
|
|
85
|
-
return createComponent(IfStatement, {
|
|
86
|
-
condition: code`upgradeCheck && (await isCheckForUpdatesRequired())`,
|
|
87
|
-
get children() {
|
|
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("");
|
|
181
|
-
`;
|
|
182
|
-
} })
|
|
183
|
-
];
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
})
|
|
188
|
-
];
|
|
67
|
+
}
|
|
68
|
+
}), createComponent(IfStatement, {
|
|
69
|
+
condition: code`isInteractive && !isHelp`,
|
|
70
|
+
children: code`await sleep(pause);`
|
|
71
|
+
})];
|
|
189
72
|
}
|
|
190
73
|
})];
|
|
191
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner-function-declaration.mjs","names":["code","computed","Show","ElseClause","ElseIfClause","FunctionDeclaration","IfStatement","VarDeclaration","Spacing","usePowerlines","getAppBin","getAppDescription","getAppTitle","useTheme","BannerFunctionBodyDeclaration","render","BannerFunctionDeclaration","props","consoleFnName","variant","command","theme","context","header","labels","banner","packageJson","version","footer","title","replace","description","titleLines","result","font","align","background","letterSpacing","lineHeight","gradient","transitionGradient","env","array","bannerPadding","Math","max","padding","app","borderStyles","outline","left","length","right","totalPadding","value","_$createComponent","async","name","doc","parameters","type","default","config","upgrade","children","insertNewlineAfterDescription","map","line","JSON","stringify","trim","join","condition","when","initializer","fallback","_$memo"],"sources":["../../src/components/banner-function-declaration.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, computed, Show } from \"@alloy-js/core\";\nimport {\n ElseClause,\n ElseIfClause,\n FunctionDeclaration,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n getAppBin,\n getAppDescription,\n getAppTitle\n} from \"@shell-shock/core/plugin-utils\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport type { BannerFunctionDeclarationProps } from \"@shell-shock/preset-script/components/banner-function-declaration\";\nimport { BannerFunctionBodyDeclaration } from \"@shell-shock/preset-script/components/banner-function-declaration\";\nimport { render } from \"cfonts\";\nimport type { CLIPresetContext } from \"../types/plugin\";\n\n/**\n * A component to generate the `banner` function in the `shell-shock:console` builtin module.\n */\nexport function BannerFunctionDeclaration(\n props: BannerFunctionDeclarationProps\n) {\n const { consoleFnName = \"log\", variant = \"primary\", command } = props;\n\n const theme = useTheme();\n\n const context = usePowerlines<CLIPresetContext>();\n\n const header = computed(\n () =>\n `${theme.labels.banner.header[variant] || getAppTitle(context)} v${\n context.packageJson.version || \"1.0.0\"\n }`\n );\n const footer = computed(() => theme.labels.banner.footer[variant]);\n const title = computed(() =>\n getAppTitle(context, true).replace(\n `v${context.packageJson.version || \"1.0.0\"}`,\n \"\"\n )\n );\n const description = computed(\n () => command?.description || getAppDescription(context)\n );\n\n const titleLines = computed(() => {\n const result = render(getAppTitle(context, true), {\n font: \"tiny\",\n align: \"left\",\n background: \"transparent\",\n letterSpacing: 1,\n lineHeight: 1,\n gradient: false,\n transitionGradient: false,\n env: \"node\"\n });\n if (!result) {\n return [`${getAppTitle(context, true)} Command-Line Interface`];\n }\n\n return result.array;\n });\n\n const bannerPadding = computed(\n () =>\n Math.max(theme.padding.app, 0) * 2 +\n theme.borderStyles.banner.outline[variant].left.length +\n theme.borderStyles.banner.outline[variant].right.length\n );\n const totalPadding = computed(\n () => Math.max(theme.padding.banner, 0) * 2 + bannerPadding.value\n );\n\n return (\n <>\n <FunctionDeclaration\n async\n name=\"banner\"\n doc={`Write the ${getAppTitle(context, true)} application banner ${\n command ? `for the ${command.title} command ` : \"\"\n }to the console.`}\n parameters={[\n { name: \"pause\", type: \"number\", default: 500 },\n {\n name: \"upgradeCheck\",\n default: context.config.upgrade !== false ? \"true\" : \"false\"\n }\n ]}>\n <BannerFunctionBodyDeclaration\n header={header.value}\n description={description.value}\n footer={footer.value}\n variant={variant}\n consoleFnName={consoleFnName}\n command={command}\n insertNewlineAfterDescription>\n {code`const titleLines = [${titleLines.value\n .map(line => JSON.stringify(line.trim()))\n .join(\", \")}];\n const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(process.stdout.columns - ${\n totalPadding.value\n }, 0) ? \"${title.value}\" : \\`\\\\n\\${titleLines.join(\"\\\\n\")}\\\\n\\`; `}\n </BannerFunctionBodyDeclaration>\n <IfStatement condition={code`isInteractive && !isHelp`}>\n {code`await sleep(pause);`}\n </IfStatement>\n <Show when={context.config.upgrade !== false}>\n <IfStatement\n condition={code`upgradeCheck && (await isCheckForUpdatesRequired())`}>\n <VarDeclaration\n const\n name=\"spinner\"\n initializer={code`createSpinner({\n message: \"Checking for updates...\"\n }).start(); `}\n />\n <VarDeclaration\n const\n name=\"result\"\n initializer={code`await checkForUpdates({ force: true }); `}\n />\n <IfStatement condition={code`!result.isUpToDate`}>\n <Show\n when={\n context.config.upgrade !== false &&\n (context.config.upgrade.type === \"confirm\" ||\n context.config.upgrade.type === \"manual\")\n }\n fallback={\n <>\n {code`spinner.stop();\n info(\\`A new version of ${getAppTitle(\n context,\n true\n )} is available: \\${colors.red(\\`v\\${result.currentVersion}\\`)} \\${colors.text.body.tertiary(\"➜\")} \\${colors.green(\\`v\\${result.latestVersion}\\`)}\\${result.package.date ? colors.text.body.tertiary(\\` (updated on \\${result.package.date})\\`) : \"\"}\\`);\n\n try {\n await upgrade();\n spinner.success(\"Update successful! Please restart the application to apply the update.\");\n\n writeLine(\"\");\n writeLine(\"Press any key to exit application...\");\n\n await waitForKeyPress();\n return;\n } catch (err) {\n spinner.error(\\`An error occurred while updating ${getAppTitle(\n context,\n true\n )} to v\\${result.latestVersion}. Please try again later - if the problem persists, please contact support.\\`);\n debug(err);\n } `}\n <Spacing />\n </>\n }>\n {code`spinner.stop();\n warn(\\`A new version of ${getAppTitle(\n context,\n true\n )} is available: \\${colors.red(\\`v\\${result.currentVersion}\\`)} \\${colors.text.body.tertiary(\"➜\")} \\${colors.green(\\`v\\${result.latestVersion}\\`)}\\${result.package.date ? colors.text.body.tertiary(\\` (updated on \\${result.package.date})\\`) : \"\"}${\n context.config.upgrade !== false &&\n context.config.upgrade.type === \"manual\"\n ? ` \\\\nPlease run \\`${getAppBin(\n context\n )} update\\` to upgrade to the latest version.`\n : \"\"\n }\\`); `}\n <Spacing />\n <Show\n when={\n context.config.upgrade !== false &&\n context.config.upgrade.type === \"confirm\"\n }>\n {code`const willUpgradeNow = await confirm({\n message: \\`Would you like to update to v\\${result.latestVersion} now?\\`,\n initialValue: true\n });\n if (isCancel(willUpgradeNow)) {\n return;\n }\n\n if (willUpgradeNow) {\n spinner.text = \\`Updating ${getAppTitle(\n context,\n true\n )} to v\\${result.latestVersion}...\\`;\n spinner.start();\n\n try {\n await upgrade();\n spinner.success(\"Update successful! Please restart the application to apply the update.\");\n\n writeLine(\"\");\n writeLine(\"Press any key to exit application...\");\n\n await waitForKeyPress();\n return;\n } catch (err) {\n spinner.error(\\`An error occurred while updating ${getAppTitle(\n context,\n true\n )} to v\\${result.latestVersion}. Please try again later - if the problem persists, please contact support.\\`);\n return { error: err };\n }\n } else {\n help(\"Updates can be performed at any time by running the \\`${getAppBin(\n context\n )} update\\` command. Please remember that keeping your application up to date is important for ensuring you have the latest features, performance improvements, and security patches.\");\n } `}\n </Show>\n </Show>\n </IfStatement>\n <ElseIfClause condition={code`result.isError`}>\n {code`spinner.error(\\`An error occurred while checking for ${getAppTitle(\n context,\n true\n )} application updates. Please try again later - if the problem persists, please contact support.\\`);\n debug(result.error); `}\n </ElseIfClause>\n <ElseClause>{code`spinner.success(\"Currently running the latest version of ${getAppTitle(\n context,\n true\n )}.\");\n writeLine(\"\");\n `}</ElseClause>\n </IfStatement>\n </Show>\n </FunctionDeclaration>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA0CA,SAAgBgB,0BACdC,OACA;CACA,MAAM,EAAEC,gBAAgB,OAAOC,UAAU,WAAWC,YAAYH;CAE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7Ce,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"}
|
|
1
|
+
{"version":3,"file":"banner-function-declaration.mjs","names":[],"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 { getAppDescription, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport type { BannerFunctionDeclarationProps } from \"@shell-shock/preset-script/components/banner-function-declaration\";\nimport { BannerFunctionBodyDeclaration } from \"@shell-shock/preset-script/components/banner-function-declaration\";\nimport { render } from \"cfonts\";\nimport type { CLIPresetContext } from \"../types/plugin\";\n\n/**\n * A component to generate the `banner` function in the `shell-shock:console` builtin module.\n */\nexport function BannerFunctionDeclaration(\n props: BannerFunctionDeclarationProps\n) {\n const { consoleFnName = \"log\", variant = \"primary\", command } = props;\n\n const theme = useTheme();\n 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={[{ name: \"pause\", type: \"number\", default: 500 }]}>\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 </FunctionDeclaration>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAgCA,SAAS,0BAAA,OAAA;CACP,MAAA,EACA,gBAAQ,4BAER,YACA;;CAEA,MAAM,UAAS,eAAQ;CACvB,MAAM,SAAA,eAAA,GAAA,MAAA,OAAA,OAAA,OAAA,YAAA,YAAA,QAAA,CAAA,IAAA,QAAA,YAAA,WAAA,UAAA;CACN,MAAM,SAAO,eAAc,MAAO,OAAS,OAAG,OAAW,SAAS;CAClE,MAAM,QAAQ,eAAY,YAAe,SAAE,KAAA,CAAA,QAAA,IAAA,QAAA,YAAA,WAAA,WAAA,GAAA,CAAA;CAC3C,MAAK,cAAA,eAAA,SAAA,eAAA,kBAAA,QAAA,CAAA;CACL,MAAC,aAAA,eAAA;EACD,MAAM,SAAS,OAAS,YAAY,SAAO,KAAO,EAAA;GACl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