@shell-shock/plugin-banner 0.1.33 → 0.1.35
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/README.md +1 -1
- package/dist/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/components/banner-builtin.cjs +1 -70
- package/dist/components/banner-builtin.mjs +1 -67
- package/dist/components/banner-builtin.mjs.map +1 -1
- package/dist/components/banner-function-declaration.cjs +6 -163
- package/dist/components/banner-function-declaration.mjs +6 -159
- package/dist/components/banner-function-declaration.mjs.map +1 -1
- package/dist/components/index.cjs +1 -8
- package/dist/components/index.mjs +1 -4
- package/dist/index.cjs +1 -53
- package/dist/index.mjs +1 -48
- 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
package/README.md
CHANGED
|
@@ -249,7 +249,7 @@ generation of development tools, please reach out on our
|
|
|
249
249
|
|
|
250
250
|
<div align="center"><a href="https://stormsoftware.com" target="_blank"><img src="https://public.storm-cdn.com/storm-software/icon-circle-fill-dark.png" alt="Storm Software" width="200px"/></a></div>
|
|
251
251
|
<br />
|
|
252
|
-
<div align="center"><a href="https://stormsoftware.com" target="_blank"><img src="https://public.storm-cdn.com/visit-us-
|
|
252
|
+
<div align="center"><a href="https://stormsoftware.com" target="_blank"><picture><source media="(prefers-color-scheme: dark)" srcset="https://public.storm-cdn.com/misc/text/visit-us-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://public.storm-cdn.com/misc/text/visit-us-light.png"><img src="https://public.storm-cdn.com/misc/text/visit-us-dark.png" height="90px" alt="Visit us at stormsoftware.com" /></picture></a></div>
|
|
253
253
|
|
|
254
254
|
<br />
|
|
255
255
|
|
|
@@ -1,29 +1 @@
|
|
|
1
|
-
|
|
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
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
|
|
@@ -1,70 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
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
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./banner-function-declaration.cjs`);let n=require(`@alloy-js/core/jsx-runtime`),r=require(`@alloy-js/core`),i=require(`@shell-shock/core/plugin-utils`),a=require(`@powerlines/plugin-alloy/core/contexts/context`),o=require(`@powerlines/plugin-alloy/typescript/components/builtin-file`),s=require(`@stryke/path`),c=require(`defu`);c=e.__toESM(c);function l(e){let[{command:l,children:u},d]=(0,r.splitProps)(e,[`command`,`children`]),f=(0,a.usePowerlines)();return(0,n.createComponent)(o.BuiltinFile,(0,n.mergeProps)({get id(){return(0,s.joinPaths)(`banner`,...l.segments.filter(e=>!(0,i.isDynamicPathSegment)(e)))},get description(){return(0,n.memo)(()=>!!l.path)()?`A collection of utility functions that assist in displaying banner information for the ${l.title} command.`:`A collection of utility functions that assist in displaying banner information for the ${(0,i.getAppTitle)(f,!0)} command-line interface application.`}},d,{get builtinImports(){return(0,c.default)(d.builtinImports??{},{utils:[`isUnicodeSupported`,`isMinimal`,`sleep`,`isInteractive`,`getTerminalSize`],state:[`useGlobal`,`hasFlag`,`isHelp`,`useMeta`],console:[`splitText`,`writeLine`,`help`,`bold`,`table`,`stripAnsi`,`textColors`,`borderColors`]})},get children(){return(0,n.createComponent)(r.Show,{get when(){return!!u},get fallback(){return(0,n.createComponent)(t.BannerFunctionDeclaration,{command:l})},children:u})}}))}exports.BannerBuiltin=l;
|
|
@@ -1,68 +1,2 @@
|
|
|
1
|
-
import
|
|
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 };
|
|
1
|
+
import{BannerFunctionDeclaration as e}from"./banner-function-declaration.mjs";import{createComponent as t,memo as n,mergeProps as r}from"@alloy-js/core/jsx-runtime";import{Show as i,splitProps as a}from"@alloy-js/core";import{getAppTitle as o,isDynamicPathSegment as s}from"@shell-shock/core/plugin-utils";import{usePowerlines as c}from"@powerlines/plugin-alloy/core/contexts/context";import{BuiltinFile as l}from"@powerlines/plugin-alloy/typescript/components/builtin-file";import{joinPaths as u}from"@stryke/path";import d from"defu";function f(f){let[{command:p,children:m},h]=a(f,[`command`,`children`]),g=c();return t(l,r({get id(){return u(`banner`,...p.segments.filter(e=>!s(e)))},get description(){return n(()=>!!p.path)()?`A collection of utility functions that assist in displaying banner information for the ${p.title} command.`:`A collection of utility functions that assist in displaying banner information for the ${o(g,!0)} command-line interface application.`}},h,{get builtinImports(){return d(h.builtinImports??{},{utils:[`isUnicodeSupported`,`isMinimal`,`sleep`,`isInteractive`,`getTerminalSize`],state:[`useGlobal`,`hasFlag`,`isHelp`,`useMeta`],console:[`splitText`,`writeLine`,`help`,`bold`,`table`,`stripAnsi`,`textColors`,`borderColors`]})},get children(){return t(i,{get when(){return!!m},get fallback(){return t(e,{command:p})},children:m})}}))}export{f as BannerBuiltin};
|
|
68
2
|
//# 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":"whBA6BA,SAAc,EAAA,EAAsB,CACpC,GAAQ,CAAC,CAAA,UAET,YACE,GAAA,EAAgB,EAAA,CAAA,UAAA,WAAA,CAAA,CACV,EAAE,GAAW,CACnB,OAAE,EAAA,EAAA,EAAA,CACA,IAAA,IAAA,CACC,OAAI,EAAW,SAAa,GAAC,EAAQ,SAAS,OAAA,GAAe,CAAA,EAAA,EAAA,CAAA,CAAA,EAEhE,IAAA,aAAoB,CACrB,OAAA,MAAA,CAAA,CAAA,EAAA,KAAA,EAAA,CAAA,0FAAA,EAAA,MAAA,WAAA,0FAAA,EAAA,EAAA,GAAA,CAAA,uCAEC,CAAA,EAAA,CACE,IAAC,gBAAgB,CACnB,OAAA,EAAA,EAAA,gBAAA,EAAA,CAAA,CACK,MAAQ,CAAC,qBAAqB,YAAA,QAAoB,gBAAA,kBAAA,CACjD,MAAG,CAAA,YAAkB,UAAW,SAAU,UAAQ,CACrD,QAAQ,CAAA,YAAA,YAAA,OAAA,OAAA,QAAA,YAAA,aAAA,eAAA,CACR,CAAA,EAEH,IAAM,UAAU,aAEV,IAAC,MAAA,CACJ,MAAA,EAAA,GAEG,IAAC,UAAO,CACN,OAAC,EAAwB,EAAY,CACxC,UACD,CAAA,EAES,WACR,CAAC,EAEL,CAAC,CAAC"}
|
|
@@ -1,167 +1,10 @@
|
|
|
1
|
-
Object.defineProperty(exports,
|
|
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`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@alloy-js/core/jsx-runtime`),t=require(`@alloy-js/core`),n=require(`@shell-shock/core/plugin-utils`),r=require(`@powerlines/plugin-alloy/core/contexts/context`),i=require(`@alloy-js/typescript`),a=require(`@powerlines/plugin-alloy/core/components/spacing`),o=require(`@powerlines/plugin-alloy/typescript/components/tsdoc`),s=require(`@shell-shock/plugin-theme/contexts/theme`),c=require(`@stryke/type-checks/is-set-string`);function l(a){let{command:s,children:c}=a,l=(0,r.usePowerlines)();return[(0,e.createComponent)(o.TSDoc,{get heading(){return`Write the ${(0,n.getAppTitle)(l,!0)} command-line interface application banner ${s?`for the ${s.title} command `:``}to the console.`},get children(){return(0,e.createComponent)(o.TSDocParam,{name:`sleepTimeoutMs`,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.`})}}),(0,e.createComponent)(i.FunctionDeclaration,{export:!0,async:!0,name:`showBanner`,parameters:[{name:`sleepTimeoutMs`,type:`number`,default:500}],get children(){return[c,(0,e.createComponent)(i.IfStatement,{condition:t.code`isInteractive && !isHelp()`,children:t.code`await sleep(sleepTimeoutMs);`})]}})]}function u(r){let{consoleFnName:i=`log`,variant:o=`primary`,title:l,header:u,footer:d,description:f,command:p,children:m,insertNewlineBeforeCommand:h=!1,insertNewlineBeforeBanner:g=!0,insertNewlineAfterDescription:_=!1}=r,v=(0,s.useTheme)(),y=v.borderStyles.banner.outline[o],b=v.icons.banner.header[o],x=(0,t.computed)(()=>Math.max(v.padding.app,0)*2+y.left.length+y.right.length),S=(0,t.computed)(()=>Math.max(v.padding.banner,2)),C=(0,t.computed)(()=>Math.max(v.padding.banner,0)*2+x.value),w=(0,t.computed)(()=>Math.max(Math.floor(S.value/2)-1,2)),T=(0,t.computed)(()=>y.topLeft.length+w.value+(b?1+b.length+1+y.top.length+1:1)+(u?u.length:0)+1+y.topRight.length),E=(0,t.computed)(()=>y.bottomLeft.length+1+(d?d.length:0)+1+w.value+y.bottomRight.length);return[t.code`
|
|
69
2
|
if (useMeta().get("banner") || hasFlag("no-banner") || hasFlag("hide-banner") || isMinimal) {
|
|
70
3
|
return;
|
|
71
4
|
}
|
|
72
5
|
|
|
73
|
-
useMeta().set("banner", true); `,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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;
|
|
6
|
+
useMeta().set("banner", true); `,(0,e.createComponent)(a.Spacing,{}),(0,e.createComponent)(t.Show,{when:g,children:t.code`writeLine(""); `}),(0,e.createComponent)(a.Spacing,{}),(0,e.memo)(()=>t.code`writeLine(borderColors.banner.outline.${o}("${y.topLeft}") + borderColors.banner.outline.${o}("${y.top}".repeat(${w.value}))${b?` + " " + textColors.banner.header.${o}("${b}") + " " + borderColors.banner.outline.${o}("${y.top}")`:``} + " " + bold(textColors.banner.header.${o}("${(0,n.formatDescription)(u||``)}")) + " " + borderColors.banner.outline.${o}("${y.top}".repeat(Math.max(getTerminalSize().columns - ${T.value}, 0))) + borderColors.banner.outline.${o}("${y.topRight}"), { consoleFn: console.${i} }); `),(0,e.createComponent)(a.Spacing,{}),(0,e.createComponent)(t.Show,{get when(){return(0,c.isSetString)(l)&&!m},get children(){return t.code`splitText("${(0,n.formatDescription)(l||``)}", Math.max(getTerminalSize().columns - ${C.value}, 20)).forEach((line) => {
|
|
7
|
+
writeLine(borderColors.banner.outline.${o}("${y.left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${x.value})) / 2), 0)) + bold(textColors.banner.title.${o}(line)) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${x.value})) / 2), 0)) + borderColors.banner.outline.${o}("${y.right}"), { consoleFn: console.${i} });
|
|
8
|
+
}); `}}),m,(0,e.createComponent)(t.Show,{get when(){return(0,c.isSetString)(p?.title)},get children(){return[(0,e.createComponent)(t.Show,{when:h,get children(){return t.code`writeLine(borderColors.banner.outline.${o}("${y.left}") + " ".repeat(Math.max(getTerminalSize().columns - ${x.value}, 0)) + borderColors.banner.outline.${o}("${y.right}"), { consoleFn: console.${i} }); `}}),(0,e.memo)(()=>t.code`writeLine(borderColors.banner.outline.${o}("${y.left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi("${(0,n.formatDescription)(p?.title||``)}").length + ${x.value})) / 2), 0)) + bold(textColors.banner.command.${o}("${(0,n.formatDescription)(p?.title||``)}")) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi("${(0,n.formatDescription)(p?.title||``)}").length + ${x.value})) / 2), 0)) + borderColors.banner.outline.${o}("${y.right}"), { consoleFn: console.${i} }); `)]}}),(0,e.createComponent)(a.Spacing,{}),(0,e.memo)(()=>t.code`splitText(bold(textColors.banner.${p?`description`:`command`}.${o}(\`${(0,n.formatDescription)(f)}\`)), Math.max(${p?`${C.value*2} > getTerminalSize().columns / 2 ? getTerminalSize().columns - ${Math.max(x.value+4,6)} : `:``}getTerminalSize().columns - ${C.value}, 20)).forEach((line) => {
|
|
9
|
+
writeLine(borderColors.banner.outline.${o}("${y.left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${x.value})) / 2), 0)) + textColors.banner.description.${o}(line) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${x.value})) / 2), 0)) + borderColors.banner.outline.${o}("${y.right}"), { consoleFn: console.${i} });
|
|
10
|
+
}); `),(0,e.createComponent)(a.Spacing,{}),(0,e.createComponent)(t.Show,{when:_,get children(){return t.code`writeLine(borderColors.banner.outline.${o}("${y.left}") + " ".repeat(Math.max(getTerminalSize().columns - ${x.value}, 0)) + borderColors.banner.outline.${o}("${y.right}"), { consoleFn: console.${i} }); `}}),(0,e.createComponent)(a.Spacing,{}),(0,e.memo)(()=>t.code`writeLine(borderColors.banner.outline.${o}("${y.bottomLeft}") + ${d?`borderColors.banner.outline.${o}("${y.bottom}".repeat(Math.max(getTerminalSize().columns - ${E.value}, 0))) + " " + bold(textColors.banner.footer.${o}("${(0,n.formatDescription)(d)}")) + " " + borderColors.banner.outline.${o}("${y.bottom}".repeat(${w.value}))`:`borderColors.banner.outline.${o}("${y.bottom}".repeat(Math.max(getTerminalSize().columns - ${y.bottomLeft.length+y.bottomRight.length}, 0)))`} + borderColors.banner.outline.${o}("${y.bottomRight}"), { consoleFn: console.${i} }); `),(0,e.createComponent)(a.Spacing,{}),t.code`writeLine(""); `]}function d(i){let{consoleFnName:a=`log`,variant:o=`primary`,command:c,children:d,insertNewlineBeforeBanner:f=!0}=i,p=(0,s.useTheme)(),m=(0,r.usePowerlines)(),h=(0,t.computed)(()=>`${p.labels.banner.header[o]||(0,n.getAppTitle)(m,!1)} v${m.packageJson.version||`1.0.0`}`),g=(0,t.computed)(()=>p.labels.banner.footer[o]),_=(0,t.computed)(()=>m.config.banner.title||(0,n.getAppTitle)(m,!0).replace(`v${m.packageJson.version||`1.0.0`}`,``)),v=(0,t.computed)(()=>c?.description||(0,n.getAppDescription)(m));return(0,e.createComponent)(l,{command:c,get children(){return(0,e.createComponent)(u,{get title(){return d?void 0:_.value},get header(){return h.value},get description(){return v.value},get footer(){return g.value},variant:o,consoleFnName:a,command:c,insertNewlineBeforeCommand:!0,insertNewlineBeforeBanner:f,children:d})}})}exports.BannerFunctionBodyDeclaration=u,exports.BannerFunctionDeclaration=d,exports.BannerFunctionDeclarationWrapper=l;
|
|
@@ -1,164 +1,11 @@
|
|
|
1
|
-
import {
|
|
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`
|
|
1
|
+
import{createComponent as e,memo as t}from"@alloy-js/core/jsx-runtime";import{Show as n,code as r,computed as i}from"@alloy-js/core";import{formatDescription as a,getAppDescription as o,getAppTitle as s}from"@shell-shock/core/plugin-utils";import{usePowerlines as c}from"@powerlines/plugin-alloy/core/contexts/context";import{FunctionDeclaration as l,IfStatement as u}from"@alloy-js/typescript";import{Spacing as d}from"@powerlines/plugin-alloy/core/components/spacing";import{TSDoc as f,TSDocParam as p}from"@powerlines/plugin-alloy/typescript/components/tsdoc";import{useTheme as m}from"@shell-shock/plugin-theme/contexts/theme";import{isSetString as h}from"@stryke/type-checks/is-set-string";function g(t){let{command:n,children:i}=t,a=c();return[e(f,{get heading(){return`Write the ${s(a,!0)} command-line interface application banner ${n?`for the ${n.title} command `:``}to the console.`},get children(){return e(p,{name:`sleepTimeoutMs`,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.`})}}),e(l,{export:!0,async:!0,name:`showBanner`,parameters:[{name:`sleepTimeoutMs`,type:`number`,default:500}],get children(){return[i,e(u,{condition:r`isInteractive && !isHelp()`,children:r`await sleep(sleepTimeoutMs);`})]}})]}function _(o){let{consoleFnName:s=`log`,variant:c=`primary`,title:l,header:u,footer:f,description:p,command:g,children:_,insertNewlineBeforeCommand:v=!1,insertNewlineBeforeBanner:y=!0,insertNewlineAfterDescription:b=!1}=o,x=m(),S=x.borderStyles.banner.outline[c],C=x.icons.banner.header[c],w=i(()=>Math.max(x.padding.app,0)*2+S.left.length+S.right.length),T=i(()=>Math.max(x.padding.banner,2)),E=i(()=>Math.max(x.padding.banner,0)*2+w.value),D=i(()=>Math.max(Math.floor(T.value/2)-1,2)),O=i(()=>S.topLeft.length+D.value+(C?1+C.length+1+S.top.length+1:1)+(u?u.length:0)+1+S.topRight.length),k=i(()=>S.bottomLeft.length+1+(f?f.length:0)+1+D.value+S.bottomRight.length);return[r`
|
|
67
2
|
if (useMeta().get("banner") || hasFlag("no-banner") || hasFlag("hide-banner") || isMinimal) {
|
|
68
3
|
return;
|
|
69
4
|
}
|
|
70
5
|
|
|
71
|
-
useMeta().set("banner", true); `,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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 };
|
|
6
|
+
useMeta().set("banner", true); `,e(d,{}),e(n,{when:y,children:r`writeLine(""); `}),e(d,{}),t(()=>r`writeLine(borderColors.banner.outline.${c}("${S.topLeft}") + borderColors.banner.outline.${c}("${S.top}".repeat(${D.value}))${C?` + " " + textColors.banner.header.${c}("${C}") + " " + borderColors.banner.outline.${c}("${S.top}")`:``} + " " + bold(textColors.banner.header.${c}("${a(u||``)}")) + " " + borderColors.banner.outline.${c}("${S.top}".repeat(Math.max(getTerminalSize().columns - ${O.value}, 0))) + borderColors.banner.outline.${c}("${S.topRight}"), { consoleFn: console.${s} }); `),e(d,{}),e(n,{get when(){return h(l)&&!_},get children(){return r`splitText("${a(l||``)}", Math.max(getTerminalSize().columns - ${E.value}, 20)).forEach((line) => {
|
|
7
|
+
writeLine(borderColors.banner.outline.${c}("${S.left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${w.value})) / 2), 0)) + bold(textColors.banner.title.${c}(line)) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${w.value})) / 2), 0)) + borderColors.banner.outline.${c}("${S.right}"), { consoleFn: console.${s} });
|
|
8
|
+
}); `}}),_,e(n,{get when(){return h(g?.title)},get children(){return[e(n,{when:v,get children(){return r`writeLine(borderColors.banner.outline.${c}("${S.left}") + " ".repeat(Math.max(getTerminalSize().columns - ${w.value}, 0)) + borderColors.banner.outline.${c}("${S.right}"), { consoleFn: console.${s} }); `}}),t(()=>r`writeLine(borderColors.banner.outline.${c}("${S.left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi("${a(g?.title||``)}").length + ${w.value})) / 2), 0)) + bold(textColors.banner.command.${c}("${a(g?.title||``)}")) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi("${a(g?.title||``)}").length + ${w.value})) / 2), 0)) + borderColors.banner.outline.${c}("${S.right}"), { consoleFn: console.${s} }); `)]}}),e(d,{}),t(()=>r`splitText(bold(textColors.banner.${g?`description`:`command`}.${c}(\`${a(p)}\`)), Math.max(${g?`${E.value*2} > getTerminalSize().columns / 2 ? getTerminalSize().columns - ${Math.max(w.value+4,6)} : `:``}getTerminalSize().columns - ${E.value}, 20)).forEach((line) => {
|
|
9
|
+
writeLine(borderColors.banner.outline.${c}("${S.left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${w.value})) / 2), 0)) + textColors.banner.description.${c}(line) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${w.value})) / 2), 0)) + borderColors.banner.outline.${c}("${S.right}"), { consoleFn: console.${s} });
|
|
10
|
+
}); `),e(d,{}),e(n,{when:b,get children(){return r`writeLine(borderColors.banner.outline.${c}("${S.left}") + " ".repeat(Math.max(getTerminalSize().columns - ${w.value}, 0)) + borderColors.banner.outline.${c}("${S.right}"), { consoleFn: console.${s} }); `}}),e(d,{}),t(()=>r`writeLine(borderColors.banner.outline.${c}("${S.bottomLeft}") + ${f?`borderColors.banner.outline.${c}("${S.bottom}".repeat(Math.max(getTerminalSize().columns - ${k.value}, 0))) + " " + bold(textColors.banner.footer.${c}("${a(f)}")) + " " + borderColors.banner.outline.${c}("${S.bottom}".repeat(${D.value}))`:`borderColors.banner.outline.${c}("${S.bottom}".repeat(Math.max(getTerminalSize().columns - ${S.bottomLeft.length+S.bottomRight.length}, 0)))`} + borderColors.banner.outline.${c}("${S.bottomRight}"), { consoleFn: console.${s} }); `),e(d,{}),r`writeLine(""); `]}function v(t){let{consoleFnName:n=`log`,variant:r=`primary`,command:a,children:l,insertNewlineBeforeBanner:u=!0}=t,d=m(),f=c(),p=i(()=>`${d.labels.banner.header[r]||s(f,!1)} v${f.packageJson.version||`1.0.0`}`),h=i(()=>d.labels.banner.footer[r]),v=i(()=>f.config.banner.title||s(f,!0).replace(`v${f.packageJson.version||`1.0.0`}`,``)),y=i(()=>a?.description||o(f));return e(g,{command:a,get children(){return e(_,{get title(){return l?void 0:v.value},get header(){return p.value},get description(){return y.value},get footer(){return h.value},variant:r,consoleFnName:n,command:a,insertNewlineBeforeCommand:!0,insertNewlineBeforeBanner:u,children:l})}})}export{_ as BannerFunctionBodyDeclaration,v as BannerFunctionDeclaration,g as BannerFunctionDeclarationWrapper};
|
|
164
11
|
//# 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":";;;;;;;;;;;;;;;;;;CA2CE,MAAA,EACE,SACH,aACG;CACF,MAAM,UAAS,eAAqC;AACpD,QAAA,CAAA,gBAAA,OAAA;EACF,IAAO,UAAS;AACd,UAAO,aAAA,YAAA,SAAA,KAAA,CAAA,6CAAA,UAAA,WAAA,QAAA,MAAA,aAAA,GAAA;;EAEP,IAAM,WAAW;;IAEX,MAAA;;IAEN,CAAM;;EAEL,CAAC,EAAE,gBAAC,qBAAA;EACH,UAAI;EACJ,OAAM;EACN,MAAK;EACL,YAAK,CAAA;GACH,MAAM;GACN,MAAI;GACJ,SAAO;GACR,CAAC;EACF,IAAI,WAAA;AACF,UAAE,CA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,WAAA;AACF,UAAK,gBAAoB,+BAA4B;IACpD,IAAA,QAAS;AACT,YAAU,CAAC,WAAW,MAAM,QAAM;;IAEjC,IAAE,SAAU;AACV,YAAO,OAAK;;IAEd,IAAG,cAAc;AACrB,YAAU,YAAa;;IAEnB,IAAI,SAAS;AACf,YAAA,OAAc;;IAEd;IACa;IACb;IACE,4BAAyB;IACf;IACP;IACJ,CAAA;;EAEJ,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={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,CAA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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
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./banner-function-declaration.cjs`),t=require(`./banner-builtin.cjs`);exports.BannerBuiltin=t.BannerBuiltin,exports.BannerFunctionBodyDeclaration=e.BannerFunctionBodyDeclaration,exports.BannerFunctionDeclaration=e.BannerFunctionDeclaration,exports.BannerFunctionDeclarationWrapper=e.BannerFunctionDeclarationWrapper;
|
|
@@ -1,4 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { BannerBuiltin } from "./banner-builtin.mjs";
|
|
3
|
-
|
|
4
|
-
export { BannerBuiltin, BannerFunctionBodyDeclaration, BannerFunctionDeclaration, BannerFunctionDeclarationWrapper };
|
|
1
|
+
import{BannerFunctionBodyDeclaration as e,BannerFunctionDeclaration as t,BannerFunctionDeclarationWrapper as n}from"./banner-function-declaration.mjs";import{BannerBuiltin as r}from"./banner-builtin.mjs";export{r as BannerBuiltin,e as BannerFunctionBodyDeclaration,t as BannerFunctionDeclaration,n as BannerFunctionDeclarationWrapper};
|
package/dist/index.cjs
CHANGED
|
@@ -1,53 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,
|
|
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;
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./_virtual/_rolldown/runtime.cjs`),t=require(`./components/banner-builtin.cjs`);require(`./components/index.cjs`);let n=require(`@alloy-js/core/jsx-runtime`),r=require(`@alloy-js/core`),i=require(`@powerlines/plugin-alloy/core/components`),a=require(`@powerlines/plugin-alloy/render`),o=require(`@shell-shock/core/plugin-utils`),s=require(`@shell-shock/plugin-console`);s=e.__toESM(s);let c=require(`@shell-shock/plugin-theme`);c=e.__toESM(c);const l=(e={})=>[...(0,c.default)(e.theme),(0,s.default)(e.console),{name:`shell-shock:banner`,enforce:`post`,config(){return{banner:{title:e.title}}},prepare:{async handler(){let e=this,s=await(0,o.getCommandList)(this);return this.debug(`Rendering \`banner\` built-ins for each of the ${s.length} command modules.`),(0,a.render)(this,[(0,n.createComponent)(t.BannerBuiltin,{get command(){return(0,o.computeBin)(e)}}),(0,n.createComponent)(i.Spacing,{}),(0,n.createComponent)(r.For,{get each(){return s.sort((e,t)=>e.name.localeCompare(t.name))},doubleHardline:!0,children:e=>(0,n.createComponent)(t.BannerBuiltin,{command:e})})])}}}];exports.default=l,exports.plugin=l;
|
package/dist/index.mjs
CHANGED
|
@@ -1,49 +1,2 @@
|
|
|
1
|
-
import
|
|
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 };
|
|
1
|
+
import{BannerBuiltin as e}from"./components/banner-builtin.mjs";import"./components/index.mjs";import{createComponent as t}from"@alloy-js/core/jsx-runtime";import{For as n}from"@alloy-js/core";import{Spacing as r}from"@powerlines/plugin-alloy/core/components";import{render as i}from"@powerlines/plugin-alloy/render";import{computeBin as a,getCommandList as o}from"@shell-shock/core/plugin-utils";import s from"@shell-shock/plugin-console";import c from"@shell-shock/plugin-theme";const l=(l={})=>[...c(l.theme),s(l.console),{name:`shell-shock:banner`,enforce:`post`,config(){return{banner:{title:l.title}}},prepare:{async handler(){let s=this,c=await o(this);return this.debug(`Rendering \`banner\` built-ins for each of the ${c.length} command modules.`),i(this,[t(e,{get command(){return a(s)}}),t(r,{}),t(n,{get each(){return c.sort((e,t)=>e.name.localeCompare(t.name))},doubleHardline:!0,children:n=>t(e,{command:n})})])}}}];export{l as default,l as plugin};
|
|
49
2
|
//# 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":"ifA8BE,CAAA,GAAA,EAAA,EAAA,MAAA,CAAA,EAAA,EAAA,QAAA,CAAA,CACC,KAAI,qBACL,QAAA,OACF,QAAa,CACX,MAAS,CACV,OAAA,CACS,MAAC,EAAA,MACN,CACH,EAEE,QAAQ,CACR,MAAA,SAAA,CACE,IAAO,EAAM,KACL,EAAO,MAAA,EAAA,KAAA,CAEb,OADF,KAAO,MAAE,kDAAA,EAAA,OAAA,mBAAA,CACA,EAAA,KAAA,CAAA,EAAA,EAAA,CACL,IAAA,SAAQ,CACN,OAAO,EAAQ,EAAA,EAElB,CAAA,CAAA,EAAA,EAAA,EAAA,CAAA,CAAA,EAAA,EAAA,CACF,IAAA,MAAA,CACD,OAAS,EAAA,MAAA,EAAA,IAAA,EAAA,KAAA,cAAA,EAAA,KAAA,CAAA,EAEL,eAAgB,GAChB,SAAU,GAAA,EAAA,EAAA,CACP,UACF,CAAC,CACH,CAAC,CAAC,CAAC,GAGT,CAAC"}
|
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.35",
|
|
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.
|
|
62
|
-
"@stryke/type-checks": "^0.6.
|
|
55
|
+
"@powerlines/deepkit": "^0.8.49",
|
|
56
|
+
"@powerlines/plugin-alloy": "^0.26.67",
|
|
57
|
+
"@powerlines/plugin-plugin": "^0.12.399",
|
|
58
|
+
"@shell-shock/core": "^0.17.8",
|
|
59
|
+
"@shell-shock/plugin-theme": "^0.4.21",
|
|
60
|
+
"@shell-shock/plugin-console": "^0.2.12",
|
|
61
|
+
"@stryke/path": "^0.28.1",
|
|
62
|
+
"@stryke/type-checks": "^0.6.4",
|
|
63
63
|
"defu": "^6.1.7",
|
|
64
|
-
"powerlines": "^0.
|
|
64
|
+
"powerlines": "^0.44.12"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@powerlines/plugin-deepkit": "^0.11.
|
|
67
|
+
"@powerlines/plugin-deepkit": "^0.11.330",
|
|
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": "832c19e668deb4d29b5e0219a7708d111790f607"
|
|
159
159
|
}
|