@shell-shock/plugin-banner 0.1.35 → 0.1.37
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 +29 -1
- package/dist/components/banner-builtin.cjs +70 -1
- package/dist/components/banner-builtin.mjs +67 -1
- package/dist/components/banner-builtin.mjs.map +1 -1
- package/dist/components/banner-function-declaration.cjs +163 -6
- package/dist/components/banner-function-declaration.mjs +159 -6
- package/dist/components/banner-function-declaration.mjs.map +1 -1
- package/dist/components/index.cjs +8 -1
- package/dist/components/index.mjs +4 -1
- package/dist/index.cjs +53 -1
- package/dist/index.mjs +48 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +12 -12
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -1 +1,70 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_components_banner_function_declaration = require('./banner-function-declaration.cjs');
|
|
4
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
5
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
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 _powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
|
|
9
|
+
let _stryke_path = require("@stryke/path");
|
|
10
|
+
let defu = require("defu");
|
|
11
|
+
defu = require_runtime.__toESM(defu);
|
|
12
|
+
|
|
13
|
+
//#region src/components/banner-builtin.tsx
|
|
14
|
+
/**
|
|
15
|
+
* A built-in banner module for Shell Shock.
|
|
16
|
+
*/
|
|
17
|
+
function BannerBuiltin(props) {
|
|
18
|
+
const [{ command, children }, rest] = (0, _alloy_js_core.splitProps)(props, ["command", "children"]);
|
|
19
|
+
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
20
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({
|
|
21
|
+
get id() {
|
|
22
|
+
return (0, _stryke_path.joinPaths)("banner", ...command.segments.filter((segment) => !(0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)));
|
|
23
|
+
},
|
|
24
|
+
get description() {
|
|
25
|
+
return (0, _alloy_js_core_jsx_runtime.memo)(() => !!command.path)() ? `A collection of utility functions that assist in displaying banner information for the ${command.title} command.` : `A collection of utility functions that assist in displaying banner information for the ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} command-line interface application.`;
|
|
26
|
+
}
|
|
27
|
+
}, rest, {
|
|
28
|
+
get builtinImports() {
|
|
29
|
+
return (0, defu.default)(rest.builtinImports ?? {}, {
|
|
30
|
+
utils: [
|
|
31
|
+
"isUnicodeSupported",
|
|
32
|
+
"isMinimal",
|
|
33
|
+
"sleep",
|
|
34
|
+
"isInteractive",
|
|
35
|
+
"getTerminalSize"
|
|
36
|
+
],
|
|
37
|
+
state: [
|
|
38
|
+
"useGlobal",
|
|
39
|
+
"hasFlag",
|
|
40
|
+
"isHelp",
|
|
41
|
+
"useMeta"
|
|
42
|
+
],
|
|
43
|
+
console: [
|
|
44
|
+
"splitText",
|
|
45
|
+
"writeLine",
|
|
46
|
+
"help",
|
|
47
|
+
"bold",
|
|
48
|
+
"table",
|
|
49
|
+
"stripAnsi",
|
|
50
|
+
"textColors",
|
|
51
|
+
"borderColors"
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
get children() {
|
|
56
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
57
|
+
get when() {
|
|
58
|
+
return Boolean(children);
|
|
59
|
+
},
|
|
60
|
+
get fallback() {
|
|
61
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_banner_function_declaration.BannerFunctionDeclaration, { command });
|
|
62
|
+
},
|
|
63
|
+
children
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
exports.BannerBuiltin = BannerBuiltin;
|
|
@@ -1,2 +1,68 @@
|
|
|
1
|
-
import{BannerFunctionDeclaration
|
|
1
|
+
import { BannerFunctionDeclaration } from "./banner-function-declaration.mjs";
|
|
2
|
+
import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import { Show, splitProps } from "@alloy-js/core";
|
|
4
|
+
import { getAppTitle, isDynamicPathSegment } from "@shell-shock/core/plugin-utils";
|
|
5
|
+
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
6
|
+
import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
7
|
+
import { joinPaths } from "@stryke/path";
|
|
8
|
+
import defu from "defu";
|
|
9
|
+
|
|
10
|
+
//#region src/components/banner-builtin.tsx
|
|
11
|
+
/**
|
|
12
|
+
* A built-in banner module for Shell Shock.
|
|
13
|
+
*/
|
|
14
|
+
function BannerBuiltin(props) {
|
|
15
|
+
const [{ command, children }, rest] = splitProps(props, ["command", "children"]);
|
|
16
|
+
const context = usePowerlines();
|
|
17
|
+
return createComponent(BuiltinFile, mergeProps({
|
|
18
|
+
get id() {
|
|
19
|
+
return joinPaths("banner", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)));
|
|
20
|
+
},
|
|
21
|
+
get description() {
|
|
22
|
+
return memo(() => !!command.path)() ? `A collection of utility functions that assist in displaying banner information for the ${command.title} command.` : `A collection of utility functions that assist in displaying banner information for the ${getAppTitle(context, true)} command-line interface application.`;
|
|
23
|
+
}
|
|
24
|
+
}, rest, {
|
|
25
|
+
get builtinImports() {
|
|
26
|
+
return defu(rest.builtinImports ?? {}, {
|
|
27
|
+
utils: [
|
|
28
|
+
"isUnicodeSupported",
|
|
29
|
+
"isMinimal",
|
|
30
|
+
"sleep",
|
|
31
|
+
"isInteractive",
|
|
32
|
+
"getTerminalSize"
|
|
33
|
+
],
|
|
34
|
+
state: [
|
|
35
|
+
"useGlobal",
|
|
36
|
+
"hasFlag",
|
|
37
|
+
"isHelp",
|
|
38
|
+
"useMeta"
|
|
39
|
+
],
|
|
40
|
+
console: [
|
|
41
|
+
"splitText",
|
|
42
|
+
"writeLine",
|
|
43
|
+
"help",
|
|
44
|
+
"bold",
|
|
45
|
+
"table",
|
|
46
|
+
"stripAnsi",
|
|
47
|
+
"textColors",
|
|
48
|
+
"borderColors"
|
|
49
|
+
]
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
get children() {
|
|
53
|
+
return createComponent(Show, {
|
|
54
|
+
get when() {
|
|
55
|
+
return Boolean(children);
|
|
56
|
+
},
|
|
57
|
+
get fallback() {
|
|
58
|
+
return createComponent(BannerFunctionDeclaration, { command });
|
|
59
|
+
},
|
|
60
|
+
children
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { BannerBuiltin };
|
|
2
68
|
//# sourceMappingURL=banner-builtin.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner-builtin.mjs","names":[],"sources":["../../src/components/banner-builtin.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 { Show, splitProps } from \"@alloy-js/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport { BuiltinFile } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport {\n getAppTitle,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport defu from \"defu\";\nimport type { BannerPluginContext } from \"../types\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\n\nexport type BannerBuiltinProps = Omit<\n BuiltinFileProps,\n \"id\" | \"description\"\n> & {\n /**\n * The command to generate the `banner` function declaration for.\n */\n command: CommandTree;\n};\n\n/**\n * A built-in banner module for Shell Shock.\n */\nexport function BannerBuiltin(props: BannerBuiltinProps) {\n const [{ command, children }, rest] = splitProps(props, [\n \"command\",\n \"children\"\n ]);\n const context = usePowerlines<BannerPluginContext>();\n\n return (\n <BuiltinFile\n id={joinPaths(\n \"banner\",\n ...command.segments.filter(segment => !isDynamicPathSegment(segment))\n )}\n description={\n command.path\n ? `A collection of utility functions that assist in displaying banner information for the ${command.title} command.`\n : `A collection of utility functions that assist in displaying banner information for the ${getAppTitle(\n context,\n true\n )} command-line interface application.`\n }\n {...rest}\n builtinImports={defu(rest.builtinImports ?? {}, {\n utils: [\n \"isUnicodeSupported\",\n \"isMinimal\",\n \"sleep\",\n \"isInteractive\",\n \"getTerminalSize\"\n ],\n state: [\"useGlobal\", \"hasFlag\", \"isHelp\", \"useMeta\"],\n console: [\n \"splitText\",\n \"writeLine\",\n \"help\",\n \"bold\",\n \"table\",\n \"stripAnsi\",\n \"textColors\",\n \"borderColors\"\n ]\n })}>\n <Show\n when={Boolean(children)}\n fallback={<BannerFunctionDeclaration command={command} />}>\n {children}\n </Show>\n </BuiltinFile>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"banner-builtin.mjs","names":[],"sources":["../../src/components/banner-builtin.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 { Show, splitProps } from \"@alloy-js/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport { BuiltinFile } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport {\n getAppTitle,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils\";\nimport { joinPaths } from \"@stryke/path\";\nimport defu from \"defu\";\nimport type { BannerPluginContext } from \"../types\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\n\nexport type BannerBuiltinProps = Omit<\n BuiltinFileProps,\n \"id\" | \"description\"\n> & {\n /**\n * The command to generate the `banner` function declaration for.\n */\n command: CommandTree;\n};\n\n/**\n * A built-in banner module for Shell Shock.\n */\nexport function BannerBuiltin(props: BannerBuiltinProps) {\n const [{ command, children }, rest] = splitProps(props, [\n \"command\",\n \"children\"\n ]);\n const context = usePowerlines<BannerPluginContext>();\n\n return (\n <BuiltinFile\n id={joinPaths(\n \"banner\",\n ...command.segments.filter(segment => !isDynamicPathSegment(segment))\n )}\n description={\n command.path\n ? `A collection of utility functions that assist in displaying banner information for the ${command.title} command.`\n : `A collection of utility functions that assist in displaying banner information for the ${getAppTitle(\n context,\n true\n )} command-line interface application.`\n }\n {...rest}\n builtinImports={defu(rest.builtinImports ?? {}, {\n utils: [\n \"isUnicodeSupported\",\n \"isMinimal\",\n \"sleep\",\n \"isInteractive\",\n \"getTerminalSize\"\n ],\n state: [\"useGlobal\", \"hasFlag\", \"isHelp\", \"useMeta\"],\n console: [\n \"splitText\",\n \"writeLine\",\n \"help\",\n \"bold\",\n \"table\",\n \"stripAnsi\",\n \"textColors\",\n \"borderColors\"\n ]\n })}>\n <Show\n when={Boolean(children)}\n fallback={<BannerFunctionDeclaration command={command} />}>\n {children}\n </Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA6BA,SAAc,cAAA,OAAsB;CACpC,MAAQ,CAAC,WAET,YACE,QAAA,WAAgB,OAAA,CAAA,WAAA,WAAA,CAAA;CAChB,MAAM,UAAE,eAAW;AACnB,QAAE,gBAAA,aAAA,WAAA;EACA,IAAA,KAAA;AACC,UAAI,UAAW,UAAa,GAAC,QAAQ,SAAS,QAAA,YAAe,CAAA,qBAAA,QAAA,CAAA,CAAA;;EAEhE,IAAA,cAAoB;AACrB,UAAA,WAAA,CAAA,CAAA,QAAA,KAAA,EAAA,GAAA,0FAAA,QAAA,MAAA,aAAA,0FAAA,YAAA,SAAA,KAAA,CAAA;;EAEC,EAAA,MAAA;EACE,IAAC,iBAAgB;AACnB,UAAA,KAAA,KAAA,kBAAA,EAAA,EAAA;IACK,OAAQ;KAAC;KAAqB;KAAA;KAAoB;KAAA;KAAA;IACjD,OAAG;KAAA;KAAkB;KAAW;KAAU;KAAQ;IACrD,SAAQ;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IACR,CAAA;;EAEH,IAAM,WAAU;;IAEV,IAAC,OAAA;AACJ,YAAA,QAAA,SAAA;;IAEG,IAAC,WAAO;AACN,YAAC,gBAAwB,2BAAY,EACxC,SACD,CAAA;;IAES;IACR,CAAC;;EAEL,CAAC,CAAC"}
|
|
@@ -1,10 +1,167 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
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 _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
6
|
+
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
7
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
8
|
+
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
9
|
+
let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
10
|
+
let _shell_shock_plugin_theme_contexts_theme = require("@shell-shock/plugin-theme/contexts/theme");
|
|
11
|
+
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
12
|
+
|
|
13
|
+
//#region src/components/banner-function-declaration.tsx
|
|
14
|
+
/**
|
|
15
|
+
* A component to generate the `banner` function for a specific command or application.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* This function will display a banner in the console with the application's name, version, and description. It can be customized with different variants for styling and supports conditional rendering based on flags or environment variables.
|
|
19
|
+
*/
|
|
20
|
+
function BannerFunctionDeclarationWrapper(props) {
|
|
21
|
+
const { command, children } = props;
|
|
22
|
+
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
23
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
24
|
+
get heading() {
|
|
25
|
+
return `Write the ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} command-line interface application banner ${command ? `for the ${command.title} command ` : ""}to the console.`;
|
|
26
|
+
},
|
|
27
|
+
get children() {
|
|
28
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
29
|
+
name: "sleepTimeoutMs",
|
|
30
|
+
children: `The amount of time in milliseconds to sleep before displaying the banner. This can be used to create a delay before the banner is shown, allowing for any necessary setup or initialization to occur first. The default value is 500 milliseconds.`
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
34
|
+
"export": true,
|
|
35
|
+
async: true,
|
|
36
|
+
name: "showBanner",
|
|
37
|
+
parameters: [{
|
|
38
|
+
name: "sleepTimeoutMs",
|
|
39
|
+
type: "number",
|
|
40
|
+
default: 500
|
|
41
|
+
}],
|
|
42
|
+
get children() {
|
|
43
|
+
return [children, (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
44
|
+
condition: _alloy_js_core.code`isInteractive && !isHelp()`,
|
|
45
|
+
children: _alloy_js_core.code`await sleep(sleepTimeoutMs);`
|
|
46
|
+
})];
|
|
47
|
+
}
|
|
48
|
+
})];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A component to generate the `banner` function's body for a specific command or application.
|
|
52
|
+
*
|
|
53
|
+
* @remarks
|
|
54
|
+
* This function will display a banner in the console with the application's name, version, and description. It can be customized with different variants for styling and supports conditional rendering based on flags or environment variables.
|
|
55
|
+
*/
|
|
56
|
+
function BannerFunctionBodyDeclaration(props) {
|
|
57
|
+
const { consoleFnName = "log", variant = "primary", title, header, footer, description, command, children, insertNewlineBeforeCommand = false, insertNewlineBeforeBanner = true, insertNewlineAfterDescription = false } = props;
|
|
58
|
+
const theme = (0, _shell_shock_plugin_theme_contexts_theme.useTheme)();
|
|
59
|
+
const borderStyle = theme.borderStyles.banner.outline[variant];
|
|
60
|
+
const icon = theme.icons.banner.header[variant];
|
|
61
|
+
const bannerPadding = (0, _alloy_js_core.computed)(() => Math.max(theme.padding.app, 0) * 2 + borderStyle.left.length + borderStyle.right.length);
|
|
62
|
+
const innerPadding = (0, _alloy_js_core.computed)(() => Math.max(theme.padding.banner, 2));
|
|
63
|
+
const totalPadding = (0, _alloy_js_core.computed)(() => Math.max(theme.padding.banner, 0) * 2 + bannerPadding.value);
|
|
64
|
+
const headerRepeat = (0, _alloy_js_core.computed)(() => Math.max(Math.floor(innerPadding.value / 2) - 1, 2));
|
|
65
|
+
const headerStaticWidth = (0, _alloy_js_core.computed)(() => borderStyle.topLeft.length + headerRepeat.value + (icon ? 1 + icon.length + 1 + borderStyle.top.length + 1 : 1) + (header ? header.length : 0) + 1 + borderStyle.topRight.length);
|
|
66
|
+
const footerStaticWidth = (0, _alloy_js_core.computed)(() => borderStyle.bottomLeft.length + 1 + (footer ? footer.length : 0) + 1 + headerRepeat.value + borderStyle.bottomRight.length);
|
|
67
|
+
return [
|
|
68
|
+
_alloy_js_core.code`
|
|
2
69
|
if (useMeta().get("banner") || hasFlag("no-banner") || hasFlag("hide-banner") || isMinimal) {
|
|
3
70
|
return;
|
|
4
71
|
}
|
|
5
72
|
|
|
6
|
-
useMeta().set("banner", true); `,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
73
|
+
useMeta().set("banner", true); `,
|
|
74
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
75
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
76
|
+
when: insertNewlineBeforeBanner,
|
|
77
|
+
children: _alloy_js_core.code`writeLine(""); `
|
|
78
|
+
}),
|
|
79
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
80
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`writeLine(borderColors.banner.outline.${variant}("${borderStyle.topLeft}") + borderColors.banner.outline.${variant}("${borderStyle.top}".repeat(${headerRepeat.value}))${icon ? ` + " " + textColors.banner.header.${variant}("${icon}") + " " + borderColors.banner.outline.${variant}("${borderStyle.top}")` : ""} + " " + bold(textColors.banner.header.${variant}("${(0, _shell_shock_core_plugin_utils.formatDescription)(header || "")}")) + " " + borderColors.banner.outline.${variant}("${borderStyle.top}".repeat(Math.max(getTerminalSize().columns - ${headerStaticWidth.value}, 0))) + borderColors.banner.outline.${variant}("${borderStyle.topRight}"), { consoleFn: console.${consoleFnName} }); `),
|
|
81
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
82
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
83
|
+
get when() {
|
|
84
|
+
return (0, _stryke_type_checks_is_set_string.isSetString)(title) && !children;
|
|
85
|
+
},
|
|
86
|
+
get children() {
|
|
87
|
+
return _alloy_js_core.code`splitText("${(0, _shell_shock_core_plugin_utils.formatDescription)(title || "")}", Math.max(getTerminalSize().columns - ${totalPadding.value}, 20)).forEach((line) => {
|
|
88
|
+
writeLine(borderColors.banner.outline.${variant}("${borderStyle.left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + bold(textColors.banner.title.${variant}(line)) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + borderColors.banner.outline.${variant}("${borderStyle.right}"), { consoleFn: console.${consoleFnName} });
|
|
89
|
+
}); `;
|
|
90
|
+
}
|
|
91
|
+
}),
|
|
92
|
+
children,
|
|
93
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
94
|
+
get when() {
|
|
95
|
+
return (0, _stryke_type_checks_is_set_string.isSetString)(command?.title);
|
|
96
|
+
},
|
|
97
|
+
get children() {
|
|
98
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
99
|
+
when: insertNewlineBeforeCommand,
|
|
100
|
+
get children() {
|
|
101
|
+
return _alloy_js_core.code`writeLine(borderColors.banner.outline.${variant}("${borderStyle.left}") + " ".repeat(Math.max(getTerminalSize().columns - ${bannerPadding.value}, 0)) + borderColors.banner.outline.${variant}("${borderStyle.right}"), { consoleFn: console.${consoleFnName} }); `;
|
|
102
|
+
}
|
|
103
|
+
}), (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`writeLine(borderColors.banner.outline.${variant}("${borderStyle.left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi("${(0, _shell_shock_core_plugin_utils.formatDescription)(command?.title || "")}").length + ${bannerPadding.value})) / 2), 0)) + bold(textColors.banner.command.${variant}("${(0, _shell_shock_core_plugin_utils.formatDescription)(command?.title || "")}")) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi("${(0, _shell_shock_core_plugin_utils.formatDescription)(command?.title || "")}").length + ${bannerPadding.value})) / 2), 0)) + borderColors.banner.outline.${variant}("${borderStyle.right}"), { consoleFn: console.${consoleFnName} }); `)];
|
|
104
|
+
}
|
|
105
|
+
}),
|
|
106
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
107
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`splitText(bold(textColors.banner.${command ? "description" : "command"}.${variant}(\`${(0, _shell_shock_core_plugin_utils.formatDescription)(description)}\`)), Math.max(${command ? `${totalPadding.value * 2} > getTerminalSize().columns / 2 ? getTerminalSize().columns - ${Math.max(bannerPadding.value + 4, 6)} : ` : ""}getTerminalSize().columns - ${totalPadding.value}, 20)).forEach((line) => {
|
|
108
|
+
writeLine(borderColors.banner.outline.${variant}("${borderStyle.left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + textColors.banner.description.${variant}(line) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + borderColors.banner.outline.${variant}("${borderStyle.right}"), { consoleFn: console.${consoleFnName} });
|
|
109
|
+
}); `),
|
|
110
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
111
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
112
|
+
when: insertNewlineAfterDescription,
|
|
113
|
+
get children() {
|
|
114
|
+
return _alloy_js_core.code`writeLine(borderColors.banner.outline.${variant}("${borderStyle.left}") + " ".repeat(Math.max(getTerminalSize().columns - ${bannerPadding.value}, 0)) + borderColors.banner.outline.${variant}("${borderStyle.right}"), { consoleFn: console.${consoleFnName} }); `;
|
|
115
|
+
}
|
|
116
|
+
}),
|
|
117
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
118
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`writeLine(borderColors.banner.outline.${variant}("${borderStyle.bottomLeft}") + ${footer ? `borderColors.banner.outline.${variant}("${borderStyle.bottom}".repeat(Math.max(getTerminalSize().columns - ${footerStaticWidth.value}, 0))) + " " + bold(textColors.banner.footer.${variant}("${(0, _shell_shock_core_plugin_utils.formatDescription)(footer)}")) + " " + borderColors.banner.outline.${variant}("${borderStyle.bottom}".repeat(${headerRepeat.value}))` : `borderColors.banner.outline.${variant}("${borderStyle.bottom}".repeat(Math.max(getTerminalSize().columns - ${borderStyle.bottomLeft.length + borderStyle.bottomRight.length}, 0)))`} + borderColors.banner.outline.${variant}("${borderStyle.bottomRight}"), { consoleFn: console.${consoleFnName} }); `),
|
|
119
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
120
|
+
_alloy_js_core.code`writeLine(""); `
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* A component to generate the `banner` function for a specific command or application.
|
|
125
|
+
*
|
|
126
|
+
* @remarks
|
|
127
|
+
* This function will display a banner in the console with the application's name, version, and description. It can be customized with different variants for styling and supports conditional rendering based on flags or environment variables.
|
|
128
|
+
*/
|
|
129
|
+
function BannerFunctionDeclaration(props) {
|
|
130
|
+
const { consoleFnName = "log", variant = "primary", command, children, insertNewlineBeforeBanner = true } = props;
|
|
131
|
+
const theme = (0, _shell_shock_plugin_theme_contexts_theme.useTheme)();
|
|
132
|
+
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
133
|
+
const header = (0, _alloy_js_core.computed)(() => `${theme.labels.banner.header[variant] || (0, _shell_shock_core_plugin_utils.getAppTitle)(context, false)} v${context.packageJson.version || "1.0.0"}`);
|
|
134
|
+
const footer = (0, _alloy_js_core.computed)(() => theme.labels.banner.footer[variant]);
|
|
135
|
+
const title = (0, _alloy_js_core.computed)(() => context.config.banner.title || (0, _shell_shock_core_plugin_utils.getAppTitle)(context, true).replace(`v${context.packageJson.version || "1.0.0"}`, ""));
|
|
136
|
+
const description = (0, _alloy_js_core.computed)(() => command?.description || (0, _shell_shock_core_plugin_utils.getAppDescription)(context));
|
|
137
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(BannerFunctionDeclarationWrapper, {
|
|
138
|
+
command,
|
|
139
|
+
get children() {
|
|
140
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(BannerFunctionBodyDeclaration, {
|
|
141
|
+
get title() {
|
|
142
|
+
return !children ? title.value : void 0;
|
|
143
|
+
},
|
|
144
|
+
get header() {
|
|
145
|
+
return header.value;
|
|
146
|
+
},
|
|
147
|
+
get description() {
|
|
148
|
+
return description.value;
|
|
149
|
+
},
|
|
150
|
+
get footer() {
|
|
151
|
+
return footer.value;
|
|
152
|
+
},
|
|
153
|
+
variant,
|
|
154
|
+
consoleFnName,
|
|
155
|
+
command,
|
|
156
|
+
insertNewlineBeforeCommand: true,
|
|
157
|
+
insertNewlineBeforeBanner,
|
|
158
|
+
children
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
//#endregion
|
|
165
|
+
exports.BannerFunctionBodyDeclaration = BannerFunctionBodyDeclaration;
|
|
166
|
+
exports.BannerFunctionDeclaration = BannerFunctionDeclaration;
|
|
167
|
+
exports.BannerFunctionDeclarationWrapper = BannerFunctionDeclarationWrapper;
|
|
@@ -1,11 +1,164 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Show, code, computed } from "@alloy-js/core";
|
|
3
|
+
import { formatDescription, getAppDescription, getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
4
|
+
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
5
|
+
import { FunctionDeclaration, IfStatement } from "@alloy-js/typescript";
|
|
6
|
+
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
7
|
+
import { TSDoc, TSDocParam } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
|
|
8
|
+
import { useTheme } from "@shell-shock/plugin-theme/contexts/theme";
|
|
9
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
10
|
+
|
|
11
|
+
//#region src/components/banner-function-declaration.tsx
|
|
12
|
+
/**
|
|
13
|
+
* A component to generate the `banner` function for a specific command or application.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* This function will display a banner in the console with the application's name, version, and description. It can be customized with different variants for styling and supports conditional rendering based on flags or environment variables.
|
|
17
|
+
*/
|
|
18
|
+
function BannerFunctionDeclarationWrapper(props) {
|
|
19
|
+
const { command, children } = props;
|
|
20
|
+
const context = usePowerlines();
|
|
21
|
+
return [createComponent(TSDoc, {
|
|
22
|
+
get heading() {
|
|
23
|
+
return `Write the ${getAppTitle(context, true)} command-line interface application banner ${command ? `for the ${command.title} command ` : ""}to the console.`;
|
|
24
|
+
},
|
|
25
|
+
get children() {
|
|
26
|
+
return createComponent(TSDocParam, {
|
|
27
|
+
name: "sleepTimeoutMs",
|
|
28
|
+
children: `The amount of time in milliseconds to sleep before displaying the banner. This can be used to create a delay before the banner is shown, allowing for any necessary setup or initialization to occur first. The default value is 500 milliseconds.`
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}), createComponent(FunctionDeclaration, {
|
|
32
|
+
"export": true,
|
|
33
|
+
async: true,
|
|
34
|
+
name: "showBanner",
|
|
35
|
+
parameters: [{
|
|
36
|
+
name: "sleepTimeoutMs",
|
|
37
|
+
type: "number",
|
|
38
|
+
default: 500
|
|
39
|
+
}],
|
|
40
|
+
get children() {
|
|
41
|
+
return [children, createComponent(IfStatement, {
|
|
42
|
+
condition: code`isInteractive && !isHelp()`,
|
|
43
|
+
children: code`await sleep(sleepTimeoutMs);`
|
|
44
|
+
})];
|
|
45
|
+
}
|
|
46
|
+
})];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A component to generate the `banner` function's body for a specific command or application.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* This function will display a banner in the console with the application's name, version, and description. It can be customized with different variants for styling and supports conditional rendering based on flags or environment variables.
|
|
53
|
+
*/
|
|
54
|
+
function BannerFunctionBodyDeclaration(props) {
|
|
55
|
+
const { consoleFnName = "log", variant = "primary", title, header, footer, description, command, children, insertNewlineBeforeCommand = false, insertNewlineBeforeBanner = true, insertNewlineAfterDescription = false } = props;
|
|
56
|
+
const theme = useTheme();
|
|
57
|
+
const borderStyle = theme.borderStyles.banner.outline[variant];
|
|
58
|
+
const icon = theme.icons.banner.header[variant];
|
|
59
|
+
const bannerPadding = computed(() => Math.max(theme.padding.app, 0) * 2 + borderStyle.left.length + borderStyle.right.length);
|
|
60
|
+
const innerPadding = computed(() => Math.max(theme.padding.banner, 2));
|
|
61
|
+
const totalPadding = computed(() => Math.max(theme.padding.banner, 0) * 2 + bannerPadding.value);
|
|
62
|
+
const headerRepeat = computed(() => Math.max(Math.floor(innerPadding.value / 2) - 1, 2));
|
|
63
|
+
const headerStaticWidth = computed(() => borderStyle.topLeft.length + headerRepeat.value + (icon ? 1 + icon.length + 1 + borderStyle.top.length + 1 : 1) + (header ? header.length : 0) + 1 + borderStyle.topRight.length);
|
|
64
|
+
const footerStaticWidth = computed(() => borderStyle.bottomLeft.length + 1 + (footer ? footer.length : 0) + 1 + headerRepeat.value + borderStyle.bottomRight.length);
|
|
65
|
+
return [
|
|
66
|
+
code`
|
|
2
67
|
if (useMeta().get("banner") || hasFlag("no-banner") || hasFlag("hide-banner") || isMinimal) {
|
|
3
68
|
return;
|
|
4
69
|
}
|
|
5
70
|
|
|
6
|
-
useMeta().set("banner", true); `,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
71
|
+
useMeta().set("banner", true); `,
|
|
72
|
+
createComponent(Spacing, {}),
|
|
73
|
+
createComponent(Show, {
|
|
74
|
+
when: insertNewlineBeforeBanner,
|
|
75
|
+
children: code`writeLine(""); `
|
|
76
|
+
}),
|
|
77
|
+
createComponent(Spacing, {}),
|
|
78
|
+
memo(() => code`writeLine(borderColors.banner.outline.${variant}("${borderStyle.topLeft}") + borderColors.banner.outline.${variant}("${borderStyle.top}".repeat(${headerRepeat.value}))${icon ? ` + " " + textColors.banner.header.${variant}("${icon}") + " " + borderColors.banner.outline.${variant}("${borderStyle.top}")` : ""} + " " + bold(textColors.banner.header.${variant}("${formatDescription(header || "")}")) + " " + borderColors.banner.outline.${variant}("${borderStyle.top}".repeat(Math.max(getTerminalSize().columns - ${headerStaticWidth.value}, 0))) + borderColors.banner.outline.${variant}("${borderStyle.topRight}"), { consoleFn: console.${consoleFnName} }); `),
|
|
79
|
+
createComponent(Spacing, {}),
|
|
80
|
+
createComponent(Show, {
|
|
81
|
+
get when() {
|
|
82
|
+
return isSetString(title) && !children;
|
|
83
|
+
},
|
|
84
|
+
get children() {
|
|
85
|
+
return code`splitText("${formatDescription(title || "")}", Math.max(getTerminalSize().columns - ${totalPadding.value}, 20)).forEach((line) => {
|
|
86
|
+
writeLine(borderColors.banner.outline.${variant}("${borderStyle.left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + bold(textColors.banner.title.${variant}(line)) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + borderColors.banner.outline.${variant}("${borderStyle.right}"), { consoleFn: console.${consoleFnName} });
|
|
87
|
+
}); `;
|
|
88
|
+
}
|
|
89
|
+
}),
|
|
90
|
+
children,
|
|
91
|
+
createComponent(Show, {
|
|
92
|
+
get when() {
|
|
93
|
+
return isSetString(command?.title);
|
|
94
|
+
},
|
|
95
|
+
get children() {
|
|
96
|
+
return [createComponent(Show, {
|
|
97
|
+
when: insertNewlineBeforeCommand,
|
|
98
|
+
get children() {
|
|
99
|
+
return code`writeLine(borderColors.banner.outline.${variant}("${borderStyle.left}") + " ".repeat(Math.max(getTerminalSize().columns - ${bannerPadding.value}, 0)) + borderColors.banner.outline.${variant}("${borderStyle.right}"), { consoleFn: console.${consoleFnName} }); `;
|
|
100
|
+
}
|
|
101
|
+
}), memo(() => code`writeLine(borderColors.banner.outline.${variant}("${borderStyle.left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi("${formatDescription(command?.title || "")}").length + ${bannerPadding.value})) / 2), 0)) + bold(textColors.banner.command.${variant}("${formatDescription(command?.title || "")}")) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi("${formatDescription(command?.title || "")}").length + ${bannerPadding.value})) / 2), 0)) + borderColors.banner.outline.${variant}("${borderStyle.right}"), { consoleFn: console.${consoleFnName} }); `)];
|
|
102
|
+
}
|
|
103
|
+
}),
|
|
104
|
+
createComponent(Spacing, {}),
|
|
105
|
+
memo(() => code`splitText(bold(textColors.banner.${command ? "description" : "command"}.${variant}(\`${formatDescription(description)}\`)), Math.max(${command ? `${totalPadding.value * 2} > getTerminalSize().columns / 2 ? getTerminalSize().columns - ${Math.max(bannerPadding.value + 4, 6)} : ` : ""}getTerminalSize().columns - ${totalPadding.value}, 20)).forEach((line) => {
|
|
106
|
+
writeLine(borderColors.banner.outline.${variant}("${borderStyle.left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + textColors.banner.description.${variant}(line) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + borderColors.banner.outline.${variant}("${borderStyle.right}"), { consoleFn: console.${consoleFnName} });
|
|
107
|
+
}); `),
|
|
108
|
+
createComponent(Spacing, {}),
|
|
109
|
+
createComponent(Show, {
|
|
110
|
+
when: insertNewlineAfterDescription,
|
|
111
|
+
get children() {
|
|
112
|
+
return code`writeLine(borderColors.banner.outline.${variant}("${borderStyle.left}") + " ".repeat(Math.max(getTerminalSize().columns - ${bannerPadding.value}, 0)) + borderColors.banner.outline.${variant}("${borderStyle.right}"), { consoleFn: console.${consoleFnName} }); `;
|
|
113
|
+
}
|
|
114
|
+
}),
|
|
115
|
+
createComponent(Spacing, {}),
|
|
116
|
+
memo(() => code`writeLine(borderColors.banner.outline.${variant}("${borderStyle.bottomLeft}") + ${footer ? `borderColors.banner.outline.${variant}("${borderStyle.bottom}".repeat(Math.max(getTerminalSize().columns - ${footerStaticWidth.value}, 0))) + " " + bold(textColors.banner.footer.${variant}("${formatDescription(footer)}")) + " " + borderColors.banner.outline.${variant}("${borderStyle.bottom}".repeat(${headerRepeat.value}))` : `borderColors.banner.outline.${variant}("${borderStyle.bottom}".repeat(Math.max(getTerminalSize().columns - ${borderStyle.bottomLeft.length + borderStyle.bottomRight.length}, 0)))`} + borderColors.banner.outline.${variant}("${borderStyle.bottomRight}"), { consoleFn: console.${consoleFnName} }); `),
|
|
117
|
+
createComponent(Spacing, {}),
|
|
118
|
+
code`writeLine(""); `
|
|
119
|
+
];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* A component to generate the `banner` function for a specific command or application.
|
|
123
|
+
*
|
|
124
|
+
* @remarks
|
|
125
|
+
* This function will display a banner in the console with the application's name, version, and description. It can be customized with different variants for styling and supports conditional rendering based on flags or environment variables.
|
|
126
|
+
*/
|
|
127
|
+
function BannerFunctionDeclaration(props) {
|
|
128
|
+
const { consoleFnName = "log", variant = "primary", command, children, insertNewlineBeforeBanner = true } = props;
|
|
129
|
+
const theme = useTheme();
|
|
130
|
+
const context = usePowerlines();
|
|
131
|
+
const header = computed(() => `${theme.labels.banner.header[variant] || getAppTitle(context, false)} v${context.packageJson.version || "1.0.0"}`);
|
|
132
|
+
const footer = computed(() => theme.labels.banner.footer[variant]);
|
|
133
|
+
const title = computed(() => context.config.banner.title || getAppTitle(context, true).replace(`v${context.packageJson.version || "1.0.0"}`, ""));
|
|
134
|
+
const description = computed(() => command?.description || getAppDescription(context));
|
|
135
|
+
return createComponent(BannerFunctionDeclarationWrapper, {
|
|
136
|
+
command,
|
|
137
|
+
get children() {
|
|
138
|
+
return createComponent(BannerFunctionBodyDeclaration, {
|
|
139
|
+
get title() {
|
|
140
|
+
return !children ? title.value : void 0;
|
|
141
|
+
},
|
|
142
|
+
get header() {
|
|
143
|
+
return header.value;
|
|
144
|
+
},
|
|
145
|
+
get description() {
|
|
146
|
+
return description.value;
|
|
147
|
+
},
|
|
148
|
+
get footer() {
|
|
149
|
+
return footer.value;
|
|
150
|
+
},
|
|
151
|
+
variant,
|
|
152
|
+
consoleFnName,
|
|
153
|
+
command,
|
|
154
|
+
insertNewlineBeforeCommand: true,
|
|
155
|
+
insertNewlineBeforeBanner,
|
|
156
|
+
children
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
//#endregion
|
|
163
|
+
export { BannerFunctionBodyDeclaration, BannerFunctionDeclaration, BannerFunctionDeclarationWrapper };
|
|
11
164
|
//# sourceMappingURL=banner-function-declaration.mjs.map
|
|
@@ -1 +1 @@
|
|
|
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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n TSDoc,\n TSDocParam\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport {\n formatDescription,\n getAppDescription,\n getAppTitle\n} from \"@shell-shock/core/plugin-utils\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport type { ThemeColorVariant } from \"@shell-shock/plugin-theme/types/theme\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { BannerPluginContext } from \"../types\";\n\nexport interface BannerFunctionDeclarationWrapperProps {\n command?: CommandTree;\n children?: Children;\n}\n\n/**\n * A component to generate the `banner` function for a specific command or application.\n *\n * @remarks\n * This function will display a banner in the console with the application's name, version, and description. It can be customized with different variants for styling and supports conditional rendering based on flags or environment variables.\n */\nexport function BannerFunctionDeclarationWrapper(\n props: BannerFunctionDeclarationWrapperProps\n) {\n const { command, children } = props;\n\n const context = usePowerlines<BannerPluginContext>();\n\n return (\n <>\n <TSDoc\n heading={`Write the ${getAppTitle(context, true)} command-line interface application banner ${\n command ? `for the ${command.title} command ` : \"\"\n }to the console.`}>\n <TSDocParam name=\"sleepTimeoutMs\">\n {`The amount of time in milliseconds to sleep before displaying the banner. This can be used to create a delay before the banner is shown, allowing for any necessary setup or initialization to occur first. The default value is 500 milliseconds.`}\n </TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"showBanner\"\n parameters={[{ name: \"sleepTimeoutMs\", type: \"number\", default: 500 }]}>\n {children}\n <IfStatement condition={code`isInteractive && !isHelp()`}>\n {code`await sleep(sleepTimeoutMs);`}\n </IfStatement>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface BannerFunctionBodyDeclarationProps extends BannerFunctionDeclarationProps {\n title?: string;\n header?: string;\n footer?: string;\n description: string;\n insertNewlineBeforeCommand?: boolean;\n insertNewlineBeforeBanner?: boolean;\n insertNewlineAfterDescription?: boolean;\n}\n\n/**\n * A component to generate the `banner` function's body for a specific command or application.\n *\n * @remarks\n * This function will display a banner in the console with the application's name, version, and description. It can be customized with different variants for styling and supports conditional rendering based on flags or environment variables.\n */\nexport function BannerFunctionBodyDeclaration(\n props: BannerFunctionBodyDeclarationProps\n) {\n const {\n consoleFnName = \"log\",\n variant = \"primary\",\n title,\n header,\n footer,\n description,\n command,\n children,\n insertNewlineBeforeCommand = false,\n insertNewlineBeforeBanner = true,\n insertNewlineAfterDescription = false\n } = props;\n\n const theme = useTheme();\n\n const borderStyle = theme.borderStyles.banner.outline[variant];\n const icon = theme.icons.banner.header[variant];\n\n const bannerPadding = computed(\n () =>\n Math.max(theme.padding.app, 0) * 2 +\n borderStyle.left.length +\n borderStyle.right.length\n );\n const innerPadding = computed(() => Math.max(theme.padding.banner, 2));\n const totalPadding = computed(\n () => Math.max(theme.padding.banner, 0) * 2 + bannerPadding.value\n );\n const headerRepeat = computed(() =>\n Math.max(Math.floor(innerPadding.value / 2) - 1, 2)\n );\n const headerStaticWidth = computed(\n () =>\n borderStyle.topLeft.length +\n headerRepeat.value +\n (icon ? 1 + icon.length + 1 + borderStyle.top.length + 1 : 1) +\n (header ? header.length : 0) +\n 1 +\n borderStyle.topRight.length\n );\n const footerStaticWidth = computed(\n () =>\n borderStyle.bottomLeft.length +\n 1 +\n (footer ? footer.length : 0) +\n 1 +\n headerRepeat.value +\n borderStyle.bottomRight.length\n );\n\n return (\n <>\n {code`\n if (useMeta().get(\"banner\") || hasFlag(\"no-banner\") || hasFlag(\"hide-banner\") || isMinimal) {\n return;\n }\n\n useMeta().set(\"banner\", true); `}\n <Spacing />\n <Show when={insertNewlineBeforeBanner}>{code`writeLine(\"\"); `}</Show>\n <Spacing />\n {code`writeLine(borderColors.banner.outline.${variant}(\"${\n borderStyle.topLeft\n }\") + borderColors.banner.outline.${\n variant\n }(\"${borderStyle.top}\".repeat(${headerRepeat.value}))${\n icon\n ? ` + \" \" + textColors.banner.header.${\n variant\n }(\"${icon}\") + \" \" + borderColors.banner.outline.${variant}(\"${\n borderStyle.top\n }\")`\n : \"\"\n } + \" \" + bold(textColors.banner.header.${variant}(\"${formatDescription(\n header || \"\"\n )}\")) + \" \" + borderColors.banner.outline.${\n variant\n }(\"${borderStyle.top}\".repeat(Math.max(getTerminalSize().columns - ${\n headerStaticWidth.value\n }, 0))) + borderColors.banner.outline.${\n variant\n }(\"${borderStyle.topRight}\"), { consoleFn: console.${consoleFnName} }); `}\n <Spacing />\n <Show when={isSetString(title) && !children}>\n {code`splitText(\"${formatDescription(\n title || \"\"\n )}\", Math.max(getTerminalSize().columns - ${\n totalPadding.value\n }, 20)).forEach((line) => {\n writeLine(borderColors.banner.outline.${variant}(\"${\n borderStyle.left\n }\") + \" \".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${\n bannerPadding.value\n })) / 2), 0)) + bold(textColors.banner.title.${\n variant\n }(line)) + \" \".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${\n bannerPadding.value\n })) / 2), 0)) + borderColors.banner.outline.${variant}(\"${\n borderStyle.right\n }\"), { consoleFn: console.${consoleFnName} });\n }); `}\n </Show>\n {children}\n <Show when={isSetString(command?.title)}>\n <Show when={insertNewlineBeforeCommand}>\n {code`writeLine(borderColors.banner.outline.${variant}(\"${\n borderStyle.left\n }\") + \" \".repeat(Math.max(getTerminalSize().columns - ${\n bannerPadding.value\n }, 0)) + borderColors.banner.outline.${variant}(\"${\n borderStyle.right\n }\"), { consoleFn: console.${consoleFnName} }); `}\n </Show>\n {code`writeLine(borderColors.banner.outline.${variant}(\"${\n borderStyle.left\n }\") + \" \".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(\"${formatDescription(\n command?.title || \"\"\n )}\").length + ${\n bannerPadding.value\n })) / 2), 0)) + bold(textColors.banner.command.${\n variant\n }(\"${formatDescription(\n command?.title || \"\"\n )}\")) + \" \".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(\"${formatDescription(\n command?.title || \"\"\n )}\").length + ${\n bannerPadding.value\n })) / 2), 0)) + borderColors.banner.outline.${variant}(\"${\n borderStyle.right\n }\"), { consoleFn: console.${consoleFnName} }); `}\n </Show>\n <Spacing />\n {code`splitText(bold(textColors.banner.${\n command ? \"description\" : \"command\"\n }.${variant}(\\`${formatDescription(description)}\\`)), Math.max(${\n command\n ? `${\n totalPadding.value * 2\n } > getTerminalSize().columns / 2 ? getTerminalSize().columns - ${Math.max(\n bannerPadding.value + 4,\n 6\n )} : `\n : \"\"\n }getTerminalSize().columns - ${\n totalPadding.value\n }, 20)).forEach((line) => {\n writeLine(borderColors.banner.outline.${\n variant\n }(\"${borderStyle.left}\") + \" \".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${\n bannerPadding.value\n })) / 2), 0)) + textColors.banner.description.${\n variant\n }(line) + \" \".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${\n bannerPadding.value\n })) / 2), 0)) + borderColors.banner.outline.${variant}(\"${\n borderStyle.right\n }\"), { consoleFn: console.${consoleFnName} });\n }); `}\n <Spacing />\n <Show when={insertNewlineAfterDescription}>\n {code`writeLine(borderColors.banner.outline.${variant}(\"${\n borderStyle.left\n }\") + \" \".repeat(Math.max(getTerminalSize().columns - ${\n bannerPadding.value\n }, 0)) + borderColors.banner.outline.${variant}(\"${\n borderStyle.right\n }\"), { consoleFn: console.${consoleFnName} }); `}\n </Show>\n <Spacing />\n {code`writeLine(borderColors.banner.outline.${variant}(\"${\n borderStyle.bottomLeft\n }\") + ${\n footer\n ? `borderColors.banner.outline.${variant}(\"${\n borderStyle.bottom\n }\".repeat(Math.max(getTerminalSize().columns - ${\n footerStaticWidth.value\n }, 0))) + \" \" + bold(textColors.banner.footer.${\n variant\n }(\"${formatDescription(\n footer\n )}\")) + \" \" + borderColors.banner.outline.${variant}(\"${\n borderStyle.bottom\n }\".repeat(${headerRepeat.value}))`\n : `borderColors.banner.outline.${variant}(\"${\n borderStyle.bottom\n }\".repeat(Math.max(getTerminalSize().columns - ${\n borderStyle.bottomLeft.length + borderStyle.bottomRight.length\n }, 0)))`\n } + borderColors.banner.outline.${variant}(\"${\n borderStyle.bottomRight\n }\"), { consoleFn: console.${consoleFnName} }); `}\n <Spacing />\n {code`writeLine(\"\"); `}\n </>\n );\n}\n\nexport interface BannerFunctionDeclarationProps extends BannerFunctionDeclarationWrapperProps {\n variant?: ThemeColorVariant;\n consoleFnName?: \"log\" | \"info\" | \"warn\" | \"error\" | \"debug\";\n insertNewlineBeforeBanner?: boolean;\n}\n\n/**\n * A component to generate the `banner` function for a specific command or application.\n *\n * @remarks\n * This function will display a banner in the console with the application's name, version, and description. It can be customized with different variants for styling and supports conditional rendering based on flags or environment variables.\n */\nexport function BannerFunctionDeclaration(\n props: BannerFunctionDeclarationProps\n) {\n const {\n consoleFnName = \"log\",\n variant = \"primary\",\n command,\n children,\n insertNewlineBeforeBanner = true\n } = props;\n\n const theme = useTheme();\n const context = usePowerlines<BannerPluginContext>();\n\n const header = computed(\n () =>\n `${theme.labels.banner.header[variant] || getAppTitle(context, false)} v${\n context.packageJson.version || \"1.0.0\"\n }`\n );\n const footer = computed(() => theme.labels.banner.footer[variant]);\n const title = computed(\n () =>\n context.config.banner.title ||\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 return (\n <BannerFunctionDeclarationWrapper command={command}>\n <BannerFunctionBodyDeclaration\n title={!children ? title.value : undefined}\n header={header.value}\n description={description.value}\n footer={footer.value}\n variant={variant}\n consoleFnName={consoleFnName}\n command={command}\n insertNewlineBeforeCommand\n insertNewlineBeforeBanner={insertNewlineBeforeBanner}>\n {children}\n </BannerFunctionBodyDeclaration>\n </BannerFunctionDeclarationWrapper>\n );\n}\n"],"mappings":"urBAiCA,SAAS,EAAqC,EAAM,CACpD,GAAO,CACP,UACA,YAAA,EAEO,EAAU,GAAA,CACf,MAAO,CAAC,EAAa,EAAA,CACrB,IAAA,SAAW,CACb,MAAA,aAAA,EAAA,EAAA,GAAA,CAAA,6CAAA,EAAA,WAAA,EAAA,MAAA,WAAA,GAAA,kBAEE,IAAA,UAAA,CACG,OAAA,EAA0B,EAAS,CACvC,KAAA,iBACG,SAAA,qPACG,CAAC,EAER,CAAA,CAAM,EAAU,EAAA,CACd,OAAO,GACP,MAAA,GACA,KAAQ,0BAER,KAAM,+BAEN,QAAO,IACJ,CAAA,CACD,IAAG,UAAA,CACD,MAAE,CAAA,EAAgB,EAAkB,EAAa,CAC/C,UAAW,CAAE,6BACb,SAAQ,CAAA,+BACT,CAAC,CAAC,EAEN,CAAC,CAAC,CAQL,SAAS,EAA4B,EAAgB,CACnD,GAAM,CACJ,gBAAM,MACN,UAAI,UACJ,QACD,SACH,SAAA,cAEA,UACE,WACA,6BAAe,GACf,4BAAe,GACf,gCAAmB,IACnB,EACA,EAAA,GAAA,CACA,EAAA,EAAA,aAAuC,OAAA,QAAA,GACzC,EAAA,EAAA,MAAA,OAAA,OAAA,qEAEE,EAAA,MAAA,KAAA,IAAA,EAAA,QAAA,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EAAA,IAAA,EAAA,OAAA,WAAA,EAAA,MAAA,IAAA,+BAAA,EAAA,IAAA,EAAA,OAAA,gDAAA,EAAA,WAAA,OAAA,EAAA,YAAA,OAAA,QAAA,iCAAA,EAAA,IAAA,EAAA,YAAA,2BAAA,EAAA,OAAA,CAAA,EAAA,EAAA,EAAA,CAAA,CAAA,CAAA,kBAAA,CAQpC,SAAG,EAAA,EAAA,CACD,GAAM,CACJ,gBAAI,MACJ,UAAE,UACF,UACA,WACA,4BAAI,IACF,EACA,EAAA,GAAY,CACf,EAAA,GAAA,qFAEK,EAAC,MAAA,EAAA,OAAA,OAAA,OAAA,GAAA,CACJ,EAAA,MAAA,EAAA,OAAA,OAAA,OAAA,EAAA,EAAA,GAAA,CAAA,QAAA,IAAA,EAAA,YAAA,SAAA,UAAA,GAAA,CAAA,CACE,EAAI,MAAA,GAAA,aAAA,EAAA,EAAA,CAAA,CACT,OAAM,EAAmB,EAAkC,CACnD,UACN,IAAI,UAAA,aAEA,IAAA,OAAU,CACX,OAAS,EAAA,IAAA,GAAA,EAAA,OAET,IAAA,QAAS,CACT,OAAK,EAAU,OAEd,IAAI,aAAa,CACjB,OAAA,EAAA,OAEA,IAAA,QAAA,CACE,OAAO,EAAK,OAEL,UACH,gBACC,UACP,2BAAK,GACmB,4BACd,WACX,CAAC,EAEL,CAAC"}
|
|
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 type { Children } from \"@alloy-js/core\";\nimport { code, computed, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration, IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n TSDoc,\n TSDocParam\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport {\n formatDescription,\n getAppDescription,\n getAppTitle\n} from \"@shell-shock/core/plugin-utils\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport type { ThemeColorVariant } from \"@shell-shock/plugin-theme/types/theme\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type { BannerPluginContext } from \"../types\";\n\nexport interface BannerFunctionDeclarationWrapperProps {\n command?: CommandTree;\n children?: Children;\n}\n\n/**\n * A component to generate the `banner` function for a specific command or application.\n *\n * @remarks\n * This function will display a banner in the console with the application's name, version, and description. It can be customized with different variants for styling and supports conditional rendering based on flags or environment variables.\n */\nexport function BannerFunctionDeclarationWrapper(\n props: BannerFunctionDeclarationWrapperProps\n) {\n const { command, children } = props;\n\n const context = usePowerlines<BannerPluginContext>();\n\n return (\n <>\n <TSDoc\n heading={`Write the ${getAppTitle(context, true)} command-line interface application banner ${\n command ? `for the ${command.title} command ` : \"\"\n }to the console.`}>\n <TSDocParam name=\"sleepTimeoutMs\">\n {`The amount of time in milliseconds to sleep before displaying the banner. This can be used to create a delay before the banner is shown, allowing for any necessary setup or initialization to occur first. The default value is 500 milliseconds.`}\n </TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"showBanner\"\n parameters={[{ name: \"sleepTimeoutMs\", type: \"number\", default: 500 }]}>\n {children}\n <IfStatement condition={code`isInteractive && !isHelp()`}>\n {code`await sleep(sleepTimeoutMs);`}\n </IfStatement>\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface BannerFunctionBodyDeclarationProps extends BannerFunctionDeclarationProps {\n title?: string;\n header?: string;\n footer?: string;\n description: string;\n insertNewlineBeforeCommand?: boolean;\n insertNewlineBeforeBanner?: boolean;\n insertNewlineAfterDescription?: boolean;\n}\n\n/**\n * A component to generate the `banner` function's body for a specific command or application.\n *\n * @remarks\n * This function will display a banner in the console with the application's name, version, and description. It can be customized with different variants for styling and supports conditional rendering based on flags or environment variables.\n */\nexport function BannerFunctionBodyDeclaration(\n props: BannerFunctionBodyDeclarationProps\n) {\n const {\n consoleFnName = \"log\",\n variant = \"primary\",\n title,\n header,\n footer,\n description,\n command,\n children,\n insertNewlineBeforeCommand = false,\n insertNewlineBeforeBanner = true,\n insertNewlineAfterDescription = false\n } = props;\n\n const theme = useTheme();\n\n const borderStyle = theme.borderStyles.banner.outline[variant];\n const icon = theme.icons.banner.header[variant];\n\n const bannerPadding = computed(\n () =>\n Math.max(theme.padding.app, 0) * 2 +\n borderStyle.left.length +\n borderStyle.right.length\n );\n const innerPadding = computed(() => Math.max(theme.padding.banner, 2));\n const totalPadding = computed(\n () => Math.max(theme.padding.banner, 0) * 2 + bannerPadding.value\n );\n const headerRepeat = computed(() =>\n Math.max(Math.floor(innerPadding.value / 2) - 1, 2)\n );\n const headerStaticWidth = computed(\n () =>\n borderStyle.topLeft.length +\n headerRepeat.value +\n (icon ? 1 + icon.length + 1 + borderStyle.top.length + 1 : 1) +\n (header ? header.length : 0) +\n 1 +\n borderStyle.topRight.length\n );\n const footerStaticWidth = computed(\n () =>\n borderStyle.bottomLeft.length +\n 1 +\n (footer ? footer.length : 0) +\n 1 +\n headerRepeat.value +\n borderStyle.bottomRight.length\n );\n\n return (\n <>\n {code`\n if (useMeta().get(\"banner\") || hasFlag(\"no-banner\") || hasFlag(\"hide-banner\") || isMinimal) {\n return;\n }\n\n useMeta().set(\"banner\", true); `}\n <Spacing />\n <Show when={insertNewlineBeforeBanner}>{code`writeLine(\"\"); `}</Show>\n <Spacing />\n {code`writeLine(borderColors.banner.outline.${variant}(\"${\n borderStyle.topLeft\n }\") + borderColors.banner.outline.${\n variant\n }(\"${borderStyle.top}\".repeat(${headerRepeat.value}))${\n icon\n ? ` + \" \" + textColors.banner.header.${\n variant\n }(\"${icon}\") + \" \" + borderColors.banner.outline.${variant}(\"${\n borderStyle.top\n }\")`\n : \"\"\n } + \" \" + bold(textColors.banner.header.${variant}(\"${formatDescription(\n header || \"\"\n )}\")) + \" \" + borderColors.banner.outline.${\n variant\n }(\"${borderStyle.top}\".repeat(Math.max(getTerminalSize().columns - ${\n headerStaticWidth.value\n }, 0))) + borderColors.banner.outline.${\n variant\n }(\"${borderStyle.topRight}\"), { consoleFn: console.${consoleFnName} }); `}\n <Spacing />\n <Show when={isSetString(title) && !children}>\n {code`splitText(\"${formatDescription(\n title || \"\"\n )}\", Math.max(getTerminalSize().columns - ${\n totalPadding.value\n }, 20)).forEach((line) => {\n writeLine(borderColors.banner.outline.${variant}(\"${\n borderStyle.left\n }\") + \" \".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${\n bannerPadding.value\n })) / 2), 0)) + bold(textColors.banner.title.${\n variant\n }(line)) + \" \".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${\n bannerPadding.value\n })) / 2), 0)) + borderColors.banner.outline.${variant}(\"${\n borderStyle.right\n }\"), { consoleFn: console.${consoleFnName} });\n }); `}\n </Show>\n {children}\n <Show when={isSetString(command?.title)}>\n <Show when={insertNewlineBeforeCommand}>\n {code`writeLine(borderColors.banner.outline.${variant}(\"${\n borderStyle.left\n }\") + \" \".repeat(Math.max(getTerminalSize().columns - ${\n bannerPadding.value\n }, 0)) + borderColors.banner.outline.${variant}(\"${\n borderStyle.right\n }\"), { consoleFn: console.${consoleFnName} }); `}\n </Show>\n {code`writeLine(borderColors.banner.outline.${variant}(\"${\n borderStyle.left\n }\") + \" \".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(\"${formatDescription(\n command?.title || \"\"\n )}\").length + ${\n bannerPadding.value\n })) / 2), 0)) + bold(textColors.banner.command.${\n variant\n }(\"${formatDescription(\n command?.title || \"\"\n )}\")) + \" \".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(\"${formatDescription(\n command?.title || \"\"\n )}\").length + ${\n bannerPadding.value\n })) / 2), 0)) + borderColors.banner.outline.${variant}(\"${\n borderStyle.right\n }\"), { consoleFn: console.${consoleFnName} }); `}\n </Show>\n <Spacing />\n {code`splitText(bold(textColors.banner.${\n command ? \"description\" : \"command\"\n }.${variant}(\\`${formatDescription(description)}\\`)), Math.max(${\n command\n ? `${\n totalPadding.value * 2\n } > getTerminalSize().columns / 2 ? getTerminalSize().columns - ${Math.max(\n bannerPadding.value + 4,\n 6\n )} : `\n : \"\"\n }getTerminalSize().columns - ${\n totalPadding.value\n }, 20)).forEach((line) => {\n writeLine(borderColors.banner.outline.${\n variant\n }(\"${borderStyle.left}\") + \" \".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${\n bannerPadding.value\n })) / 2), 0)) + textColors.banner.description.${\n variant\n }(line) + \" \".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${\n bannerPadding.value\n })) / 2), 0)) + borderColors.banner.outline.${variant}(\"${\n borderStyle.right\n }\"), { consoleFn: console.${consoleFnName} });\n }); `}\n <Spacing />\n <Show when={insertNewlineAfterDescription}>\n {code`writeLine(borderColors.banner.outline.${variant}(\"${\n borderStyle.left\n }\") + \" \".repeat(Math.max(getTerminalSize().columns - ${\n bannerPadding.value\n }, 0)) + borderColors.banner.outline.${variant}(\"${\n borderStyle.right\n }\"), { consoleFn: console.${consoleFnName} }); `}\n </Show>\n <Spacing />\n {code`writeLine(borderColors.banner.outline.${variant}(\"${\n borderStyle.bottomLeft\n }\") + ${\n footer\n ? `borderColors.banner.outline.${variant}(\"${\n borderStyle.bottom\n }\".repeat(Math.max(getTerminalSize().columns - ${\n footerStaticWidth.value\n }, 0))) + \" \" + bold(textColors.banner.footer.${\n variant\n }(\"${formatDescription(\n footer\n )}\")) + \" \" + borderColors.banner.outline.${variant}(\"${\n borderStyle.bottom\n }\".repeat(${headerRepeat.value}))`\n : `borderColors.banner.outline.${variant}(\"${\n borderStyle.bottom\n }\".repeat(Math.max(getTerminalSize().columns - ${\n borderStyle.bottomLeft.length + borderStyle.bottomRight.length\n }, 0)))`\n } + borderColors.banner.outline.${variant}(\"${\n borderStyle.bottomRight\n }\"), { consoleFn: console.${consoleFnName} }); `}\n <Spacing />\n {code`writeLine(\"\"); `}\n </>\n );\n}\n\nexport interface BannerFunctionDeclarationProps extends BannerFunctionDeclarationWrapperProps {\n variant?: ThemeColorVariant;\n consoleFnName?: \"log\" | \"info\" | \"warn\" | \"error\" | \"debug\";\n insertNewlineBeforeBanner?: boolean;\n}\n\n/**\n * A component to generate the `banner` function for a specific command or application.\n *\n * @remarks\n * This function will display a banner in the console with the application's name, version, and description. It can be customized with different variants for styling and supports conditional rendering based on flags or environment variables.\n */\nexport function BannerFunctionDeclaration(\n props: BannerFunctionDeclarationProps\n) {\n const {\n consoleFnName = \"log\",\n variant = \"primary\",\n command,\n children,\n insertNewlineBeforeBanner = true\n } = props;\n\n const theme = useTheme();\n const context = usePowerlines<BannerPluginContext>();\n\n const header = computed(\n () =>\n `${theme.labels.banner.header[variant] || getAppTitle(context, false)} v${\n context.packageJson.version || \"1.0.0\"\n }`\n );\n const footer = computed(() => theme.labels.banner.footer[variant]);\n const title = computed(\n () =>\n context.config.banner.title ||\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 return (\n <BannerFunctionDeclarationWrapper command={command}>\n <BannerFunctionBodyDeclaration\n title={!children ? title.value : undefined}\n header={header.value}\n description={description.value}\n footer={footer.value}\n variant={variant}\n consoleFnName={consoleFnName}\n command={command}\n insertNewlineBeforeCommand\n insertNewlineBeforeBanner={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AG,0BAAA,OAAA;CACD,MAAM,EACJ,gBAAI,OACJ,UAAE,WACF,SACA,UACA,4BAAI,SACF;CACJ,MAAI,QAAA,UAAY;CAChB,MAAC,UAAA,eAAA;;CAED,MAAM,SAAC,eAAA,MAAA,OAAA,OAAA,OAAA,SAAA;CACP,MAAG,QAAA,eAAA,QAAA,OAAA,OAAA,SAAA,YAAA,SAAA,KAAA,CAAA,QAAA,IAAA,QAAA,YAAA,WAAA,WAAA,GAAA,CAAA;CACH,MAAK,cAAI,eAAA,SAAA,eAAA,kBAAA,QAAA,CAAA;AACT,QAAM,gBAAmB,kCAAkC;EACnD;EACN,IAAI,WAAA;;IAEA,IAAA,QAAU;AACX,YAAS,CAAA,WAAA,MAAA,QAAA;;IAET,IAAA,SAAS;AACT,YAAK,OAAU;;IAEd,IAAI,cAAa;AACjB,YAAA,YAAA;;IAEA,IAAA,SAAA;AACE,YAAO,OAAK;;IAEL;IACH;IACC;IACP,4BAAK;IACmB;IACd;IACX,CAAC;;EAEL,CAAC"}
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_components_banner_function_declaration = require('./banner-function-declaration.cjs');
|
|
3
|
+
const require_components_banner_builtin = require('./banner-builtin.cjs');
|
|
4
|
+
|
|
5
|
+
exports.BannerBuiltin = require_components_banner_builtin.BannerBuiltin;
|
|
6
|
+
exports.BannerFunctionBodyDeclaration = require_components_banner_function_declaration.BannerFunctionBodyDeclaration;
|
|
7
|
+
exports.BannerFunctionDeclaration = require_components_banner_function_declaration.BannerFunctionDeclaration;
|
|
8
|
+
exports.BannerFunctionDeclarationWrapper = require_components_banner_function_declaration.BannerFunctionDeclarationWrapper;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
import{BannerFunctionBodyDeclaration
|
|
1
|
+
import { BannerFunctionBodyDeclaration, BannerFunctionDeclaration, BannerFunctionDeclarationWrapper } from "./banner-function-declaration.mjs";
|
|
2
|
+
import { BannerBuiltin } from "./banner-builtin.mjs";
|
|
3
|
+
|
|
4
|
+
export { BannerBuiltin, BannerFunctionBodyDeclaration, BannerFunctionDeclaration, BannerFunctionDeclarationWrapper };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,53 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_components_banner_builtin = require('./components/banner-builtin.cjs');
|
|
4
|
+
require('./components/index.cjs');
|
|
5
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
6
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
7
|
+
let _powerlines_plugin_alloy_core_components = require("@powerlines/plugin-alloy/core/components");
|
|
8
|
+
let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
9
|
+
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
10
|
+
let _shell_shock_plugin_console = require("@shell-shock/plugin-console");
|
|
11
|
+
_shell_shock_plugin_console = require_runtime.__toESM(_shell_shock_plugin_console);
|
|
12
|
+
let _shell_shock_plugin_theme = require("@shell-shock/plugin-theme");
|
|
13
|
+
_shell_shock_plugin_theme = require_runtime.__toESM(_shell_shock_plugin_theme);
|
|
14
|
+
|
|
15
|
+
//#region src/index.tsx
|
|
16
|
+
/**
|
|
17
|
+
* The Banner - Shell Shock plugin to add a banner command to the application.
|
|
18
|
+
*/
|
|
19
|
+
const plugin = (options = {}) => {
|
|
20
|
+
return [
|
|
21
|
+
...(0, _shell_shock_plugin_theme.default)(options.theme),
|
|
22
|
+
(0, _shell_shock_plugin_console.default)(options.console),
|
|
23
|
+
{
|
|
24
|
+
name: "shell-shock:banner",
|
|
25
|
+
enforce: "post",
|
|
26
|
+
config() {
|
|
27
|
+
return { banner: { title: options.title } };
|
|
28
|
+
},
|
|
29
|
+
prepare: { async handler() {
|
|
30
|
+
const _self$ = this;
|
|
31
|
+
const commands = await (0, _shell_shock_core_plugin_utils.getCommandList)(this);
|
|
32
|
+
this.debug(`Rendering \`banner\` built-ins for each of the ${commands.length} command modules.`);
|
|
33
|
+
return (0, _powerlines_plugin_alloy_render.render)(this, [
|
|
34
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(require_components_banner_builtin.BannerBuiltin, { get command() {
|
|
35
|
+
return (0, _shell_shock_core_plugin_utils.computeBin)(_self$);
|
|
36
|
+
} }),
|
|
37
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components.Spacing, {}),
|
|
38
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
39
|
+
get each() {
|
|
40
|
+
return commands.sort((a, b) => a.name.localeCompare(b.name));
|
|
41
|
+
},
|
|
42
|
+
doubleHardline: true,
|
|
43
|
+
children: (command) => (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_banner_builtin.BannerBuiltin, { command })
|
|
44
|
+
})
|
|
45
|
+
]);
|
|
46
|
+
} }
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
exports.default = plugin;
|
|
53
|
+
exports.plugin = plugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,49 @@
|
|
|
1
|
-
import{BannerBuiltin
|
|
1
|
+
import { BannerBuiltin } from "./components/banner-builtin.mjs";
|
|
2
|
+
import "./components/index.mjs";
|
|
3
|
+
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
4
|
+
import { For } from "@alloy-js/core";
|
|
5
|
+
import { Spacing } from "@powerlines/plugin-alloy/core/components";
|
|
6
|
+
import { render } from "@powerlines/plugin-alloy/render";
|
|
7
|
+
import { computeBin, getCommandList } from "@shell-shock/core/plugin-utils";
|
|
8
|
+
import console from "@shell-shock/plugin-console";
|
|
9
|
+
import theme from "@shell-shock/plugin-theme";
|
|
10
|
+
|
|
11
|
+
//#region src/index.tsx
|
|
12
|
+
/**
|
|
13
|
+
* The Banner - Shell Shock plugin to add a banner command to the application.
|
|
14
|
+
*/
|
|
15
|
+
const plugin = (options = {}) => {
|
|
16
|
+
return [
|
|
17
|
+
...theme(options.theme),
|
|
18
|
+
console(options.console),
|
|
19
|
+
{
|
|
20
|
+
name: "shell-shock:banner",
|
|
21
|
+
enforce: "post",
|
|
22
|
+
config() {
|
|
23
|
+
return { banner: { title: options.title } };
|
|
24
|
+
},
|
|
25
|
+
prepare: { async handler() {
|
|
26
|
+
const _self$ = this;
|
|
27
|
+
const commands = await getCommandList(this);
|
|
28
|
+
this.debug(`Rendering \`banner\` built-ins for each of the ${commands.length} command modules.`);
|
|
29
|
+
return render(this, [
|
|
30
|
+
createComponent(BannerBuiltin, { get command() {
|
|
31
|
+
return computeBin(_self$);
|
|
32
|
+
} }),
|
|
33
|
+
createComponent(Spacing, {}),
|
|
34
|
+
createComponent(For, {
|
|
35
|
+
get each() {
|
|
36
|
+
return commands.sort((a, b) => a.name.localeCompare(b.name));
|
|
37
|
+
},
|
|
38
|
+
doubleHardline: true,
|
|
39
|
+
children: (command) => createComponent(BannerBuiltin, { command })
|
|
40
|
+
})
|
|
41
|
+
]);
|
|
42
|
+
} }
|
|
43
|
+
}
|
|
44
|
+
];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { plugin as default, plugin };
|
|
2
49
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"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 { For } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { computeBin, getCommandList } from \"@shell-shock/core/plugin-utils\";\nimport console from \"@shell-shock/plugin-console\";\nimport theme from \"@shell-shock/plugin-theme\";\nimport type { Plugin } from \"powerlines\";\nimport { BannerBuiltin } from \"./components\";\nimport type { BannerPluginContext, BannerPluginOptions } from \"./types/plugin\";\n\nexport type * from \"./types\";\n\n/**\n * The Banner - Shell Shock plugin to add a banner command to the application.\n */\nexport const plugin = <\n TContext extends BannerPluginContext = BannerPluginContext\n>(\n options: BannerPluginOptions = {}\n) => {\n return [\n ...theme(options.theme),\n console(options.console),\n {\n name: \"shell-shock:banner\",\n enforce: \"post\",\n config() {\n return {\n banner: {\n title: options.title\n }\n };\n },\n prepare: {\n async handler() {\n const commands = await getCommandList(this);\n this.debug(\n `Rendering \\`banner\\` built-ins for each of the ${\n commands.length\n } command modules.`\n );\n\n return render(\n this,\n <>\n <BannerBuiltin command={computeBin(this)} />\n <Spacing />\n <For\n each={commands.sort((a, b) => a.name.localeCompare(b.name))}\n doubleHardline>\n {command => <BannerBuiltin command={command} />}\n </For>\n </>\n );\n }\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"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 { For } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { computeBin, getCommandList } from \"@shell-shock/core/plugin-utils\";\nimport console from \"@shell-shock/plugin-console\";\nimport theme from \"@shell-shock/plugin-theme\";\nimport type { Plugin } from \"powerlines\";\nimport { BannerBuiltin } from \"./components\";\nimport type { BannerPluginContext, BannerPluginOptions } from \"./types/plugin\";\n\nexport type * from \"./types\";\n\n/**\n * The Banner - Shell Shock plugin to add a banner command to the application.\n */\nexport const plugin = <\n TContext extends BannerPluginContext = BannerPluginContext\n>(\n options: BannerPluginOptions = {}\n) => {\n return [\n ...theme(options.theme),\n console(options.console),\n {\n name: \"shell-shock:banner\",\n enforce: \"post\",\n config() {\n return {\n banner: {\n title: options.title\n }\n };\n },\n prepare: {\n async handler() {\n const commands = await getCommandList(this);\n this.debug(\n `Rendering \\`banner\\` built-ins for each of the ${\n commands.length\n } command modules.`\n );\n\n return render(\n this,\n <>\n <BannerBuiltin command={computeBin(this)} />\n <Spacing />\n <For\n each={commands.sort((a, b) => a.name.localeCompare(b.name))}\n doubleHardline>\n {command => <BannerBuiltin command={command} />}\n </For>\n </>\n );\n }\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;AA8BE,QAAA;EAAA,GAAA,MAAA,QAAA,MAAA;EAAA,QAAA,QAAA,QAAA;EAAA;GACC,MAAI;GACL,SAAA;GACF,SAAa;AACX,WAAS,EACV,QAAA,EACS,OAAC,QAAA,OACN,EACH;;GAEE,SAAQ,EACR,MAAA,UAAA;IACE,MAAO,SAAM;IACb,MAAQ,WAAO,MAAA,eAAA,KAAA;AACf,SAAO,MAAE,kDAAA,SAAA,OAAA,mBAAA;AACP,WAAO,OAAA,MAAA;KAAA,gBAAA,eAAA,EACL,IAAA,UAAQ;AACN,aAAO,WAAQ,OAAA;QAElB,CAAA;KAAA,gBAAA,SAAA,EAAA,CAAA;KAAA,gBAAA,KAAA;MACF,IAAA,OAAA;AACD,cAAS,SAAA,MAAA,GAAA,MAAA,EAAA,KAAA,cAAA,EAAA,KAAA,CAAA;;MAEL,gBAAgB;MAChB,WAAU,YAAA,gBAAA,eAAA,EACP,SACF,CAAC;MACH,CAAC;KAAC,CAAC;;GAGT;EAAC"}
|
package/dist/types/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/dist/types/plugin.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shell-shock/plugin-banner",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A package containing a Shell Shock plugin to generate banner built-in modules that display information about the application.",
|
|
6
6
|
"keywords": [
|
|
@@ -52,19 +52,19 @@
|
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@alloy-js/core": "0.23.0-dev.8",
|
|
54
54
|
"@alloy-js/typescript": "0.23.0-dev.4",
|
|
55
|
-
"@powerlines/deepkit": "^0.8.
|
|
56
|
-
"@powerlines/plugin-alloy": "^0.26.
|
|
57
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
58
|
-
"@shell-shock/core": "^0.17.
|
|
59
|
-
"@shell-shock/plugin-theme": "^0.4.
|
|
60
|
-
"@shell-shock/plugin-console": "^0.2.
|
|
61
|
-
"@stryke/path": "^0.28.
|
|
62
|
-
"@stryke/type-checks": "^0.6.
|
|
55
|
+
"@powerlines/deepkit": "^0.8.64",
|
|
56
|
+
"@powerlines/plugin-alloy": "^0.26.84",
|
|
57
|
+
"@powerlines/plugin-plugin": "^0.12.416",
|
|
58
|
+
"@shell-shock/core": "^0.17.10",
|
|
59
|
+
"@shell-shock/plugin-theme": "^0.4.23",
|
|
60
|
+
"@shell-shock/plugin-console": "^0.2.14",
|
|
61
|
+
"@stryke/path": "^0.28.2",
|
|
62
|
+
"@stryke/type-checks": "^0.6.5",
|
|
63
63
|
"defu": "^6.1.7",
|
|
64
|
-
"powerlines": "^0.
|
|
64
|
+
"powerlines": "^0.47.4"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@powerlines/plugin-deepkit": "^0.11.
|
|
67
|
+
"@powerlines/plugin-deepkit": "^0.11.347",
|
|
68
68
|
"@types/node": "^25.6.0"
|
|
69
69
|
},
|
|
70
70
|
"publishConfig": { "access": "public" },
|
|
@@ -155,5 +155,5 @@
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
},
|
|
158
|
-
"gitHead": "
|
|
158
|
+
"gitHead": "7b4030fd6be000c960e8cc4c4f7b4db205054e69"
|
|
159
159
|
}
|