@shell-shock/preset-cli 0.8.16 → 0.8.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/banner-builtin.cjs +2 -2
- package/dist/components/banner-builtin.d.cts.map +1 -1
- package/dist/components/banner-builtin.d.mts +1 -1
- package/dist/components/banner-builtin.d.mts.map +1 -1
- package/dist/components/banner-builtin.mjs +2 -2
- package/dist/components/banner-builtin.mjs.map +1 -1
- package/dist/components/command-entry.cjs +2 -2
- package/dist/components/command-entry.mjs +2 -2
- package/dist/components/command-router.cjs +3 -1
- package/dist/components/command-router.d.cts.map +1 -1
- package/dist/components/command-router.d.mts.map +1 -1
- package/dist/components/command-router.mjs +4 -2
- package/dist/components/command-router.mjs.map +1 -1
- package/dist/components/upgrade-builtin.cjs +1 -1
- package/dist/components/upgrade-builtin.mjs +1 -1
- package/dist/index.cjs +5 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +5 -2
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-banner/dist/components/banner-builtin.cjs +2 -2
- package/dist/plugin-banner/dist/components/banner-builtin.mjs +1 -1
- package/dist/plugin-banner/dist/components/banner-function-declaration.cjs +9 -6
- package/dist/plugin-banner/dist/components/banner-function-declaration.mjs +9 -6
- package/dist/plugin-banner/dist/components/banner-function-declaration.mjs.map +1 -1
- package/dist/plugin-banner/dist/components/index.cjs +2 -0
- package/dist/plugin-banner/dist/components/index.mjs +4 -0
- package/dist/plugin-banner/dist/index.cjs +70 -0
- package/dist/plugin-banner/dist/index.d.cts +2 -0
- package/dist/plugin-banner/dist/index.d.mts +2 -0
- package/dist/plugin-banner/dist/index.mjs +68 -0
- package/dist/plugin-banner/dist/index.mjs.map +1 -0
- package/dist/plugin-banner/dist/types/plugin.d.cts +31 -0
- package/dist/plugin-banner/dist/types/plugin.d.cts.map +1 -0
- package/dist/plugin-banner/dist/types/plugin.d.mts +31 -0
- package/dist/plugin-banner/dist/types/plugin.d.mts.map +1 -0
- package/dist/plugin-help/dist/components/display.cjs +19 -8
- package/dist/plugin-help/dist/components/display.mjs +19 -8
- package/dist/plugin-help/dist/components/display.mjs.map +1 -1
- package/dist/plugin-help/dist/components/help-builtin.cjs +3 -3
- package/dist/plugin-help/dist/components/help-builtin.mjs +3 -3
- package/dist/plugin-help/dist/components/help-command.cjs +1 -1
- package/dist/plugin-help/dist/components/help-command.mjs +1 -1
- package/dist/plugin-help/dist/index.cjs +6 -4
- package/dist/plugin-help/dist/index.mjs +5 -3
- package/dist/plugin-help/dist/index.mjs.map +1 -1
- package/dist/plugin-help/dist/types/plugin.d.cts +1 -1
- package/dist/plugin-help/dist/types/plugin.d.mts +1 -1
- package/dist/types/plugin.d.cts +5 -4
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +5 -4
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +8 -8
|
@@ -5,8 +5,8 @@ const require_banner_builtin = require('../plugin-banner/dist/components/banner-
|
|
|
5
5
|
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
6
6
|
let _alloy_js_core = require("@alloy-js/core");
|
|
7
7
|
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
8
|
-
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
9
8
|
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
9
|
+
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
10
10
|
let _shell_shock_plugin_theme_contexts_theme = require("@shell-shock/plugin-theme/contexts/theme");
|
|
11
11
|
let cfonts = require("cfonts");
|
|
12
12
|
|
|
@@ -23,7 +23,7 @@ function BannerFunctionBodyDeclaration(props) {
|
|
|
23
23
|
const title = (0, _alloy_js_core.computed)(() => (0, _shell_shock_core_plugin_utils.getAppTitle)(context, true).replace(`v${context.packageJson.version || "1.0.0"}`, ""));
|
|
24
24
|
const description = (0, _alloy_js_core.computed)(() => command?.description || (0, _shell_shock_core_plugin_utils.getAppDescription)(context));
|
|
25
25
|
const titleLines = (0, _alloy_js_core.computed)(() => {
|
|
26
|
-
const result = (0, cfonts.render)((0, _shell_shock_core_plugin_utils.getAppTitle)(context, true), {
|
|
26
|
+
const result = context.config.banner.title ? { array: context.config.banner.title.split("\n") } : (0, cfonts.render)((0, _shell_shock_core_plugin_utils.getAppTitle)(context, true), {
|
|
27
27
|
font: "tiny",
|
|
28
28
|
align: "left",
|
|
29
29
|
background: "transparent",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner-builtin.d.cts","names":[],"sources":["../../src/components/banner-builtin.tsx"],"mappings":";;;;;;;;;iBAqCgB,6BAAA,CACd,KAAA,EAAO,IAAA,CACL,kCAAA,yCADS,iBAAA,CAGV,QAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"banner-builtin.d.cts","names":[],"sources":["../../src/components/banner-builtin.tsx"],"mappings":";;;;;;;;;iBAqCgB,6BAAA,CACd,KAAA,EAAO,IAAA,CACL,kCAAA,yCADS,iBAAA,CAGV,QAAA;AAAA,KAyES,kBAAA,GAAqB,IAAA,CAC/B,gBAAA;;;;EAMA,OAAA,EAAS,WAAA;AAAA;;;;iBAMK,aAAA,CAAc,KAAA,EAAO,kBAAA,GAAkB,iBAAA,CAAA,QAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BannerFunctionBodyDeclarationProps } from "../plugin-banner/dist/components/banner-function-declaration.mjs";
|
|
2
2
|
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
3
|
-
import { CommandTree } from "@shell-shock/core";
|
|
4
3
|
import { BuiltinFileProps } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
4
|
+
import { CommandTree } from "@shell-shock/core";
|
|
5
5
|
|
|
6
6
|
//#region src/components/banner-builtin.d.ts
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"banner-builtin.d.mts","names":[],"sources":["../../src/components/banner-builtin.tsx"],"mappings":";;;;;;;;;iBAqCgB,6BAAA,CACd,KAAA,EAAO,IAAA,CACL,kCAAA,yCADS,iBAAA,CAGV,QAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"banner-builtin.d.mts","names":[],"sources":["../../src/components/banner-builtin.tsx"],"mappings":";;;;;;;;;iBAqCgB,6BAAA,CACd,KAAA,EAAO,IAAA,CACL,kCAAA,yCADS,iBAAA,CAGV,QAAA;AAAA,KAyES,kBAAA,GAAqB,IAAA,CAC/B,gBAAA;;;;EAMA,OAAA,EAAS,WAAA;AAAA;;;;iBAMK,aAAA,CAAc,KAAA,EAAO,kBAAA,GAAkB,iBAAA,CAAA,QAAA"}
|
|
@@ -3,8 +3,8 @@ import { BannerBuiltin as BannerBuiltin$1 } from "../plugin-banner/dist/componen
|
|
|
3
3
|
import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
4
4
|
import { Show, code, computed, splitProps } from "@alloy-js/core";
|
|
5
5
|
import { getAppDescription, getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
6
|
-
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
7
6
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
7
|
+
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
8
8
|
import { useTheme } from "@shell-shock/plugin-theme/contexts/theme";
|
|
9
9
|
import { render } from "cfonts";
|
|
10
10
|
|
|
@@ -21,7 +21,7 @@ function BannerFunctionBodyDeclaration(props) {
|
|
|
21
21
|
const title = computed(() => getAppTitle(context, true).replace(`v${context.packageJson.version || "1.0.0"}`, ""));
|
|
22
22
|
const description = computed(() => command?.description || getAppDescription(context));
|
|
23
23
|
const titleLines = computed(() => {
|
|
24
|
-
const result = render(getAppTitle(context, true), {
|
|
24
|
+
const result = context.config.banner.title ? { array: context.config.banner.title.split("\n") } : render(getAppTitle(context, true), {
|
|
25
25
|
font: "tiny",
|
|
26
26
|
align: "left",
|
|
27
27
|
background: "transparent",
|
|
@@ -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 { code, computed, Show, splitProps } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { getAppDescription, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { BannerBuiltin as BaseBannerBuiltin } from \"@shell-shock/plugin-banner/components/banner-builtin\";\nimport type { BannerFunctionBodyDeclarationProps } from \"@shell-shock/plugin-banner/components/banner-function-declaration\";\nimport {\n BannerFunctionDeclarationWrapper,\n BannerFunctionBodyDeclaration as BaseBannerFunctionBodyDeclaration\n} from \"@shell-shock/plugin-banner/components/banner-function-declaration\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport { render } from \"cfonts\";\nimport type { CLIPresetContext } from \"../types/plugin\";\n\n/**\n * A component to generate the `banner` function in the `shell-shock:console` builtin module.\n */\nexport function BannerFunctionBodyDeclaration(\n props: Omit<\n BannerFunctionBodyDeclarationProps,\n \"header\" | \"description\" | \"footer\"\n >\n) {\n const { consoleFnName = \"log\", variant = \"primary\", command } = props;\n\n const theme = useTheme();\n const context = usePowerlines<CLIPresetContext>();\n\n const header = computed(\n () =>\n `${theme.labels.banner.header[variant] || getAppTitle(context)} v${\n context.packageJson.version || \"1.0.0\"\n }`\n );\n const footer = computed(() => theme.labels.banner.footer[variant]);\n const title = computed(() =>\n getAppTitle(context, true).replace(\n `v${context.packageJson.version || \"1.0.0\"}`,\n \"\"\n )\n );\n const description = computed(\n () => command?.description || getAppDescription(context)\n );\n\n const titleLines = computed(() => {\n const result = render(getAppTitle(context, true), {\n
|
|
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 { code, computed, Show, splitProps } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { getAppDescription, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { BannerBuiltin as BaseBannerBuiltin } from \"@shell-shock/plugin-banner/components/banner-builtin\";\nimport type { BannerFunctionBodyDeclarationProps } from \"@shell-shock/plugin-banner/components/banner-function-declaration\";\nimport {\n BannerFunctionDeclarationWrapper,\n BannerFunctionBodyDeclaration as BaseBannerFunctionBodyDeclaration\n} from \"@shell-shock/plugin-banner/components/banner-function-declaration\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport { render } from \"cfonts\";\nimport type { CLIPresetContext } from \"../types/plugin\";\n\n/**\n * A component to generate the `banner` function in the `shell-shock:console` builtin module.\n */\nexport function BannerFunctionBodyDeclaration(\n props: Omit<\n BannerFunctionBodyDeclarationProps,\n \"header\" | \"description\" | \"footer\"\n >\n) {\n const { consoleFnName = \"log\", variant = \"primary\", command } = props;\n\n const theme = useTheme();\n const context = usePowerlines<CLIPresetContext>();\n\n const header = computed(\n () =>\n `${theme.labels.banner.header[variant] || getAppTitle(context)} v${\n context.packageJson.version || \"1.0.0\"\n }`\n );\n const footer = computed(() => theme.labels.banner.footer[variant]);\n const title = computed(() =>\n getAppTitle(context, true).replace(\n `v${context.packageJson.version || \"1.0.0\"}`,\n \"\"\n )\n );\n const description = computed(\n () => command?.description || getAppDescription(context)\n );\n\n const titleLines = computed(() => {\n const result = context.config.banner.title\n ? { array: context.config.banner.title.split(\"\\n\") }\n : render(getAppTitle(context, true), {\n font: \"tiny\",\n align: \"left\",\n background: \"transparent\",\n letterSpacing: 1,\n lineHeight: 1,\n gradient: false,\n transitionGradient: false,\n env: \"node\"\n });\n if (!result) {\n return [`${getAppTitle(context, true)} Command-Line Interface`];\n }\n\n return result.array;\n });\n\n const bannerPadding = computed(\n () =>\n Math.max(theme.padding.app, 0) * 2 +\n (theme.borderStyles.banner.outline[variant]?.left.length ?? 0) +\n (theme.borderStyles.banner.outline[variant]?.right.length ?? 0)\n );\n const totalPadding = computed(\n () => Math.max(theme.padding.banner, 0) * 2 + bannerPadding.value\n );\n\n return (\n <BaseBannerFunctionBodyDeclaration\n header={header.value}\n description={description.value}\n footer={footer.value}\n variant={variant}\n consoleFnName={consoleFnName}\n command={command}\n insertNewlineAfterDescription>\n {code`const titleLines = [${titleLines.value\n .map(line => JSON.stringify(line.trim()))\n .join(\", \")}];\n const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(process.stdout.columns - ${\n totalPadding.value\n }, 0) ? \"${title.value}\" : \\`\\\\n\\${titleLines.join(\"\\\\n\")}\\\\n\\`; `}\n </BaseBannerFunctionBodyDeclaration>\n );\n}\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\n return (\n <BaseBannerBuiltin {...rest} command={command}>\n <BannerFunctionDeclarationWrapper command={command}>\n <BannerFunctionBodyDeclaration command={command} />\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BannerFunctionDeclarationWrapper>\n </BaseBannerBuiltin>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAmCA,SAAe,8BAAyB,OAAoD;CAC1F,MAAA,EACF,gBAAgB,OACd,UAAW,WACT,YACC;CACH,MAAA,QAAA,UAAA;CACA,MAAA,UAAA,eAAA;CACA,MAAM,SAAE,eAAsB,GAAC,MAAQ,OAAG,OAAU,OAAQ,YAAS,YAAA,QAAA,CAAA,IAAA,QAAA,YAAA,WAAA,UAAA;;CAErE,MAAM,QAAQ,eAAU,YAAA,SAAA,KAAA,CAAA,QAAA,IAAA,QAAA,YAAA,WAAA,WAAA,GAAA,CAAA;CACxB,MAAM,cAAU,eAAc,SAAA,eAAmB,kBAAA,QAAA,CAAA;;EAEjD,MAAM,SAAS,QAAQ,OAAA,OAAA,QAAA,EACnB,OAAE,QAAA,OAAA,OAAA,MAAA,MAAA,KAAA,EACH,GAAG,OAAO,YAAO,SAAc,KAAA,EAAO;GACrC,MAAE;GACF,OAAC;GACJ,YAAA;GACD,eAAe;GACf,YAAc;GACZ,UAAY;GACV,oBAAY;GACZ,KAAC;GACH,CAAA;AACD,MAAA,CAAA,OACD,QAAM,CAAA,GAAA,YAAc,SAAQ,KAAA,CAAA,yBAAA;AAE3B,SAAA,OAAA;;CAED,MAAM,gBAAa,eAAe,KAAA,IAAA,MAAA,QAAA,KAAA,EAAA,GAAA,KAAA,MAAA,aAAA,OAAA,QAAA,UAAA,KAAA,UAAA,MAAA,MAAA,aAAA,OAAA,QAAA,UAAA,MAAA,UAAA,GAAA;CAClC,MAAE,eAAe,eAAe,KAAO,IAAA,MAAA,QAAA,QAAA,EAAA,GAAA,IAAA,cAAA,MAAA;AACvC,QAAO,gBAAgB,iCAAgC;EACrD,IAAI,SAAO;AACT,UAAI,OAAO;;EAEb,IAAI,cAAc;AAChB,UAAI,YAAe;;EAErB,IAAI,SAAE;AACJ,UAAI,OAAA;;EAEA;EACO;EACJ;EACT,+BAAA;;AAEA,UAAO,IAAM,uBAAM,WAAA,MAAA,KAAA,SAAA,KAAA,UAAA,KAAA,MAAA,CAAA,CAAA,CAAA,KAAA,KAAA,CAAA;wHACnB,aAAA,MAAA,UAAA,MAAA,MAAA;;EAEF,CAAA;;;;;AAYF,SAAc,cAAY,OAAA;CACxB,MAAI,CAAA,EACF,SACA,YACC,QAAC,WAAe,OAAA,CAAA,WAAa,WAAA,CAAA;AAChC,QAAI,gBAAgB,iBAAA,WAAA,MAAA;EAChB;EACF,IAAG,WAAW;AACZ,UAAO,gBAAa,kCAAsB;IAC/B;IACT,IAAA,WAAc;AACZ,YAAA;MAAA,gBAAa,+BAAA,EACJ,SACb,CAAA;MAAA,gBAAA,SAAiC,EAAA,CAAA;MAAA,gBAAA,MAAA;OACpC,IAAA,OAAA;AACH,eAAA,QAAA,SAAA;;OAEY;OACV,CAAA;MAAA;;IAEE,CAAA;;EAED,CAAC,CAAC"}
|
|
@@ -5,12 +5,12 @@ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
|
5
5
|
let _alloy_js_core = require("@alloy-js/core");
|
|
6
6
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
7
7
|
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
8
|
-
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
9
8
|
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
10
|
-
let
|
|
9
|
+
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
11
10
|
let defu = require("defu");
|
|
12
11
|
defu = require_runtime.__toESM(defu);
|
|
13
12
|
let _stryke_path_join = require("@stryke/path/join");
|
|
13
|
+
let _shell_shock_core = require("@shell-shock/core");
|
|
14
14
|
let _powerlines_plugin_alloy_typescript_components_entry_file = require("@powerlines/plugin-alloy/typescript/components/entry-file");
|
|
15
15
|
let _shell_shock_core_components_command_validation_logic = require("@shell-shock/core/components/command-validation-logic");
|
|
16
16
|
let _shell_shock_preset_script_components_command_entry = require("@shell-shock/preset-script/components/command-entry");
|
|
@@ -3,11 +3,11 @@ import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
|
3
3
|
import { For, Match, Show, Switch, code, computed } from "@alloy-js/core";
|
|
4
4
|
import { ElseIfClause, IfStatement } from "@alloy-js/typescript";
|
|
5
5
|
import { formatDescription, formatShortDescription, isDynamicPathSegment } from "@shell-shock/core/plugin-utils";
|
|
6
|
-
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
7
6
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
8
|
-
import {
|
|
7
|
+
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
9
8
|
import defu from "defu";
|
|
10
9
|
import { joinPaths } from "@stryke/path/join";
|
|
10
|
+
import { CommandParameterKinds } from "@shell-shock/core";
|
|
11
11
|
import { EntryFile } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
12
12
|
import { CommandValidationLogic } from "@shell-shock/core/components/command-validation-logic";
|
|
13
13
|
import { CommandHandlerDeclaration } from "@shell-shock/preset-script/components/command-entry";
|
|
@@ -4,12 +4,14 @@ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
|
4
4
|
let _alloy_js_core = require("@alloy-js/core");
|
|
5
5
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
6
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");
|
|
7
8
|
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
8
9
|
let _shell_shock_preset_script_components = require("@shell-shock/preset-script/components");
|
|
9
10
|
|
|
10
11
|
//#region src/components/command-router.tsx
|
|
11
12
|
function CommandRouterSelectOptions(props) {
|
|
12
13
|
const { commands } = props;
|
|
14
|
+
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
13
15
|
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
14
16
|
get each() {
|
|
15
17
|
return Object.values(commands ?? {});
|
|
@@ -18,7 +20,7 @@ function CommandRouterSelectOptions(props) {
|
|
|
18
20
|
hardline: true,
|
|
19
21
|
children: (command) => command.isVirtual ? (0, _alloy_js_core_jsx_runtime.createComponent)(CommandRouterSelectOptions, { get commands() {
|
|
20
22
|
return command.children ?? {};
|
|
21
|
-
} }) : _alloy_js_core.code`{ value: [${command.segments.map((segment) => `"${segment}"`).join(", ")}], label: "${command.title}", description:
|
|
23
|
+
} }) : _alloy_js_core.code`{ value: [${command.segments.map((segment) => `"${segment}"`).join(", ")}], label: "${command.title}", description: \`(${(0, _shell_shock_core_plugin_utils.getAppBin)(context)} ${command.segments.join(" ")})\`${command.icon ? `, icon: "${command.icon.trim()}"` : ""} }`
|
|
22
24
|
});
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-router.d.cts","names":[],"sources":["../../src/components/command-router.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"command-router.d.cts","names":[],"sources":["../../src/components/command-router.tsx"],"mappings":";;;;;UA+BiB,+BAAA;EACf,QAAA,GAAW,MAAA,SAAe,WAAA;AAAA;AAAA,iBAGZ,0BAAA,CACd,KAAA,EAAO,+BAAA,GAA+B,iBAAA,CAAA,QAAA;;;;iBA8BxB,aAAA,CAAc,KAAA,EAAO,kBAAA,GAAkB,iBAAA,CAAA,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-router.d.mts","names":[],"sources":["../../src/components/command-router.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"command-router.d.mts","names":[],"sources":["../../src/components/command-router.tsx"],"mappings":";;;;;UA+BiB,+BAAA;EACf,QAAA,GAAW,MAAA,SAAe,WAAA;AAAA;AAAA,iBAGZ,0BAAA,CACd,KAAA,EAAO,+BAAA,GAA+B,iBAAA,CAAA,QAAA;;;;iBA8BxB,aAAA,CAAc,KAAA,EAAO,kBAAA,GAAkB,iBAAA,CAAA,QAAA"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { For, code } from "@alloy-js/core";
|
|
3
3
|
import { IfStatement } from "@alloy-js/typescript";
|
|
4
|
-
import {
|
|
4
|
+
import { getAppBin } from "@shell-shock/core/plugin-utils";
|
|
5
|
+
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
5
6
|
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
6
7
|
import { CommandRouter as CommandRouter$1, CommandRouterBody } from "@shell-shock/preset-script/components";
|
|
7
8
|
|
|
8
9
|
//#region src/components/command-router.tsx
|
|
9
10
|
function CommandRouterSelectOptions(props) {
|
|
10
11
|
const { commands } = props;
|
|
12
|
+
const context = usePowerlines();
|
|
11
13
|
return createComponent(For, {
|
|
12
14
|
get each() {
|
|
13
15
|
return Object.values(commands ?? {});
|
|
@@ -16,7 +18,7 @@ function CommandRouterSelectOptions(props) {
|
|
|
16
18
|
hardline: true,
|
|
17
19
|
children: (command) => command.isVirtual ? createComponent(CommandRouterSelectOptions, { get commands() {
|
|
18
20
|
return command.children ?? {};
|
|
19
|
-
} }) : code`{ value: [${command.segments.map((segment) => `"${segment}"`).join(", ")}], label: "${command.title}", description:
|
|
21
|
+
} }) : code`{ value: [${command.segments.map((segment) => `"${segment}"`).join(", ")}], label: "${command.title}", description: \`(${getAppBin(context)} ${command.segments.join(" ")})\`${command.icon ? `, icon: "${command.icon.trim()}"` : ""} }`
|
|
20
22
|
});
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-router.mjs","names":[],"sources":["../../src/components/command-router.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, For } from \"@alloy-js/core\";\nimport { IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport {
|
|
1
|
+
{"version":3,"file":"command-router.mjs","names":[],"sources":["../../src/components/command-router.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, For } from \"@alloy-js/core\";\nimport { IfStatement } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { getAppBin } from \"@shell-shock/core/plugin-utils\";\nimport type { CommandRouterProps } from \"@shell-shock/preset-script/components\";\nimport {\n CommandRouter as BaseCommandRouter,\n CommandRouterBody\n} from \"@shell-shock/preset-script/components\";\nimport type { CLIPresetContext } from \"../types\";\n\nexport interface CommandRouterSelectOptionsProps {\n commands?: Record<string, CommandTree>;\n}\n\nexport function CommandRouterSelectOptions(\n props: CommandRouterSelectOptionsProps\n) {\n const { commands } = props;\n\n const context = usePowerlines<CLIPresetContext>();\n\n return (\n <For each={Object.values(commands ?? {})} joiner=\",\" hardline>\n {command =>\n command.isVirtual ? (\n <CommandRouterSelectOptions commands={command.children ?? {}} />\n ) : (\n code`{ value: [${command.segments\n .map(segment => `\"${segment}\"`)\n .join(\n \", \"\n )}], label: \"${command.title}\", description: \\`(${getAppBin(\n context\n )} ${command.segments.join(\" \")})\\`${\n command.icon ? `, icon: \"${command.icon.trim()}\"` : \"\"\n } }`\n )\n }\n </For>\n );\n}\n\n/**\n * A component that renders a command router interface, allowing users to select and execute commands from a provided list of commands and segments. This component serves as a wrapper around the base CommandRouter, adding additional UI elements and logic for command selection.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { segments, commands } = props;\n\n return (\n <>\n <BaseCommandRouter {...props} segments={segments} commands={commands} />\n <Spacing />\n <IfStatement condition={code`isInteractive && !isHelp`}>\n {code`await showBanner();\n\n let segments = await select({\n message: \"Which command would you like to execute?\",\n options: [ `}\n <CommandRouterSelectOptions commands={commands} />\n {` ],\n });\n if (isCancel(segments)) {\n return;\n }\n\n let dynamics = {} as Record<string, string>;\n for (const dynamic of segments.filter(segment => segment.startsWith(\"[\") && segment.endsWith(\"]\"))) {\n const value = await text({\n message: \\`Please provide a value for \\${dynamic.replace(/^\\[+/, \"\").replace(/\\]+$/, \"\")}:\\`,\n });\n if (isCancel(value)) {\n return;\n }\n dynamics[dynamic] = value;\n }\n\n segments = segments.map(segment => dynamics[segment] || segment);\n const context = useApp();\n context.set(\"args\", [args.length > 0 ? args[0] : undefined, args.length > 1 ? args[1] : undefined, ...segments, ...args.slice(${\n segments.length + 2\n })].filter(Boolean) as string[]);\n\n command = segments[0];\n args = context.get(\"args\"); `}\n <CommandRouterBody {...props} segments={segments} commands={commands} />\n </IfStatement>\n <Spacing />\n </>\n );\n}\n"],"mappings":";;;;;;;;;AA+BA,SAAgB,2BAAC,OAAgC;CAC/C,MAAA,EACF;CAEA,MAAO,UAAS,eAA0B;AACxC,QAAO,gBAAA,KAAA;EACP,IAAA,OAAA;AACA,UAAQ,OAAU,OAAG,YAAK,EAAA,CAAA;;EAE1B,QAAM;;EAEN,WAAO,YAAA,QAAA,YAAA,gBAAA,4BAAA,EACJ,IAAI,WAAY;AACd,UAAQ,QAAC,YAAA,EAAA;KAEX,CAAC,GAAG,IAAE,aAAA,QAAA,SAA2B,KAAS,YAAS,IAAA,QAAc,GAAG,CAAA,KAAA,KAAA,CAAA,aAAA,QAAA,MAAA,qBAAA,UAAA,QAAA,CAAA,GAAA,QAAA,SAAA,KAAA,IAAA,CAAA,KAAA,QAAA,OAAA,YAAA,QAAA,KAAA,MAAA,CAAA,KAAA,GAAA;EACtE,CAAC;;;;;AAMJ,SAAY,cAAA,OAAA;CACV,MAAM,EACJ,UACA,aACE;AACJ,QAAI;EAAA,gBAAA,iBAAA,WAAA,OAAA;GACG;GACN;GACH,CAAA,CAAA;EAAA,gBAAA,SAAA,EAAA,CAAA;EAAA,gBAAA,aAAA;;GAEE,IAAA,WAAA;AACG,WAAA;KAAS,IAAC;;;;;mDAKN,UACJ,CAAA;KAAA,WAAA;;;;;;;;;;;;;;;;;;;wIAmBmG,SAAA,SAAA,EAAA;;;sCAGtF;KAAA,gBAAA,mBAAA,WAAA,OAAA;MACR;MACQ;MACX,CAAC,CAAA;KAAA;;GAEL,CAAC;EAAE,gBAAa,SAAa,EAAA,CAAA;EAAA"}
|
|
@@ -4,8 +4,8 @@ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
|
4
4
|
let _alloy_js_core = require("@alloy-js/core");
|
|
5
5
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
6
6
|
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
7
|
-
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
8
7
|
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
8
|
+
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
9
9
|
let defu = require("defu");
|
|
10
10
|
let _shell_shock_plugin_upgrade_components_upgrade_builtin = require("@shell-shock/plugin-upgrade/components/upgrade-builtin");
|
|
11
11
|
|
|
@@ -2,8 +2,8 @@ import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
|
2
2
|
import { Show, code, splitProps } from "@alloy-js/core";
|
|
3
3
|
import { ElseClause, ElseIfClause, FunctionDeclaration, IfStatement, VarDeclaration } from "@alloy-js/typescript";
|
|
4
4
|
import { getAppBin, getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
5
|
-
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
6
5
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
6
|
+
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
7
7
|
import { defu as defu$1 } from "defu";
|
|
8
8
|
import { UpgradeBuiltin as UpgradeBuiltin$1 } from "@shell-shock/plugin-upgrade/components/upgrade-builtin";
|
|
9
9
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
2
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const require_index = require('./plugin-
|
|
3
|
+
const require_index = require('./plugin-banner/dist/index.cjs');
|
|
4
|
+
const require_index$1 = require('./plugin-help/dist/index.cjs');
|
|
4
5
|
const require_components_banner_builtin = require('./components/banner-builtin.cjs');
|
|
5
6
|
const require_components_command_router = require('./components/command-router.cjs');
|
|
6
7
|
const require_components_virtual_command_entry = require('./components/virtual-command-entry.cjs');
|
|
@@ -14,9 +15,9 @@ let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
|
14
15
|
let _powerlines_plugin_alloy_core_components = require("@powerlines/plugin-alloy/core/components");
|
|
15
16
|
let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
16
17
|
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
18
|
+
let _stryke_path = require("@stryke/path");
|
|
17
19
|
let _shell_shock_plugin_console = require("@shell-shock/plugin-console");
|
|
18
20
|
_shell_shock_plugin_console = require_runtime.__toESM(_shell_shock_plugin_console);
|
|
19
|
-
let _stryke_path = require("@stryke/path");
|
|
20
21
|
let _shell_shock_plugin_prompts = require("@shell-shock/plugin-prompts");
|
|
21
22
|
_shell_shock_plugin_prompts = require_runtime.__toESM(_shell_shock_plugin_prompts);
|
|
22
23
|
let _shell_shock_plugin_upgrade = require("@shell-shock/plugin-upgrade");
|
|
@@ -33,6 +34,7 @@ let _shell_shock_preset_script_components_bin_entry = require("@shell-shock/pres
|
|
|
33
34
|
const plugin = (options = {}) => {
|
|
34
35
|
return [
|
|
35
36
|
...(0, _shell_shock_plugin_console.default)(options),
|
|
37
|
+
...require_index$1.plugin(options),
|
|
36
38
|
...require_index.plugin(options),
|
|
37
39
|
...(0, _shell_shock_plugin_prompts.default)(options),
|
|
38
40
|
(0, _shell_shock_plugin_upgrade.default)(options),
|
|
@@ -61,6 +63,7 @@ const plugin = (options = {}) => {
|
|
|
61
63
|
path: null,
|
|
62
64
|
segments: [],
|
|
63
65
|
alias: [],
|
|
66
|
+
tags: [],
|
|
64
67
|
options: Object.fromEntries(this.options.map((option) => [option.name, option])),
|
|
65
68
|
entry: { file: (0, _stryke_path.joinPaths)(this.entryPath, "bin.ts") },
|
|
66
69
|
args: [],
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;AAkDA;;;;cAAa,MAAA,oBAA2B,gBAAA,GAAmB,gBAAA,EACzD,OAAA,GAAS,gBAAA,KACR,MAAA,CAAO,QAAA"}
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;AAkDA;;;;cAAa,MAAA,oBAA2B,gBAAA,GAAmB,gBAAA,EACzD,OAAA,GAAS,gBAAA,KACR,MAAA,CAAO,QAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { plugin as plugin$1 } from "./plugin-
|
|
1
|
+
import { plugin as plugin$1 } from "./plugin-banner/dist/index.mjs";
|
|
2
|
+
import { plugin as plugin$2 } from "./plugin-help/dist/index.mjs";
|
|
2
3
|
import { BannerBuiltin } from "./components/banner-builtin.mjs";
|
|
3
4
|
import { CommandRouter } from "./components/command-router.mjs";
|
|
4
5
|
import { VirtualCommandEntry } from "./components/virtual-command-entry.mjs";
|
|
@@ -12,8 +13,8 @@ import { VarDeclaration } from "@alloy-js/typescript";
|
|
|
12
13
|
import { Spacing } from "@powerlines/plugin-alloy/core/components";
|
|
13
14
|
import { render } from "@powerlines/plugin-alloy/render";
|
|
14
15
|
import { getAppDescription, getAppName, getAppTitle, getCommandList } from "@shell-shock/core/plugin-utils";
|
|
15
|
-
import console from "@shell-shock/plugin-console";
|
|
16
16
|
import { joinPaths } from "@stryke/path";
|
|
17
|
+
import console from "@shell-shock/plugin-console";
|
|
17
18
|
import prompts from "@shell-shock/plugin-prompts";
|
|
18
19
|
import upgrade from "@shell-shock/plugin-upgrade";
|
|
19
20
|
import { BinEntry } from "@shell-shock/preset-script/components/bin-entry";
|
|
@@ -28,6 +29,7 @@ import { BinEntry } from "@shell-shock/preset-script/components/bin-entry";
|
|
|
28
29
|
const plugin = (options = {}) => {
|
|
29
30
|
return [
|
|
30
31
|
...console(options),
|
|
32
|
+
...plugin$2(options),
|
|
31
33
|
...plugin$1(options),
|
|
32
34
|
...prompts(options),
|
|
33
35
|
upgrade(options),
|
|
@@ -56,6 +58,7 @@ const plugin = (options = {}) => {
|
|
|
56
58
|
path: null,
|
|
57
59
|
segments: [],
|
|
58
60
|
alias: [],
|
|
61
|
+
tags: [],
|
|
59
62
|
options: Object.fromEntries(this.options.map((option) => [option.name, option])),
|
|
60
63
|
entry: { file: joinPaths(this.entryPath, "bin.ts") },
|
|
61
64
|
args: [],
|
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 { code, computed, For, Show } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n getCommandList\n} from \"@shell-shock/core/plugin-utils\";\nimport console from \"@shell-shock/plugin-console\";\nimport help from \"@shell-shock/plugin-help\";\nimport prompts from \"@shell-shock/plugin-prompts\";\nimport upgrade from \"@shell-shock/plugin-upgrade\";\nimport { BinEntry } from \"@shell-shock/preset-script/components/bin-entry\";\nimport { joinPaths } from \"@stryke/path\";\nimport type { Plugin } from \"powerlines\";\nimport { BannerBuiltin } from \"./components\";\nimport { CommandEntry } from \"./components/command-entry\";\nimport { CommandRouter } from \"./components/command-router\";\nimport { UpgradeBuiltin } from \"./components/upgrade-builtin\";\nimport { VirtualCommandEntry } from \"./components/virtual-command-entry\";\nimport { getDefaultOptions } from \"./helpers/get-default-options\";\nimport type { CLIPresetContext, CLIPresetOptions } from \"./types/plugin\";\n\n/**\n * The Shell Shock CLI Preset plugin.\n *\n * @remarks\n * This preset includes a set of built-in modules and commands to create a CLI application, as well as configuration options to customize the generated code. It also includes the `prompts` plugin to provide interactive prompts in the CLI application, and the `upgrade` plugin to manage upgrading the local application's version.\n */\nexport const plugin = <TContext extends CLIPresetContext = CLIPresetContext>(\n options: CLIPresetOptions = {}\n): Plugin<TContext>[] => {\n return [\n ...console<TContext>(options),\n ...help<TContext>(options),\n ...prompts<TContext>(options),\n upgrade<TContext>(options),\n {\n name: \"shell-shock:cli-preset\",\n config() {\n this.debug(\n \"Providing default configuration for the Shell Shock `cli` preset.\"\n );\n\n return {\n defaultOptions: getDefaultOptions,\n isCaseSensitive: false,\n ...options\n };\n },\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Rendering built-in modules.\");\n\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 const bin = computed(() => ({\n id: \"\",\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n isVirtual: true,\n path: null,\n segments: [],\n alias: [],\n options: Object.fromEntries(\n this.options.map(option => [option.name, option])\n ),\n entry: {\n file: joinPaths(this.entryPath, \"bin.ts\")\n },\n args: [],\n parent: null,\n children: this.commands\n }));\n\n return render(\n this,\n <>\n <UpgradeBuiltin />\n <BannerBuiltin command={bin.value} />\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 {\n name: \"shell-shock:cli-preset:generate-entrypoint\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `cli` preset.\"\n );\n\n return render(\n this,\n <>\n <BinEntry\n builtinImports={{\n console: [\n \"info\",\n \"debug\",\n \"warn\",\n \"help\",\n \"error\",\n \"cursor\",\n \"divider\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"colors\"\n ],\n utils: [\n \"useApp\",\n \"useArgs\",\n \"isMinimal\",\n \"isInteractive\",\n \"isHelp\"\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"isCancel\"\n ],\n env: [\"env\", \"paths\"],\n upgrade: [\"executeUpgrade\"]\n }}>\n <Show when={Object.keys(this.commands).length > 0}>\n <VarDeclaration\n let\n name=\"args\"\n type=\"string[]\"\n initializer={code`useArgs();`}\n />\n <hbr />\n <CommandRouter segments={[]} commands={this.commands ?? {}} />\n <hbr />\n </Show>\n <hbr />\n {code`await showBanner(0);`}\n <Spacing />\n {code`return showHelp(); `}\n </BinEntry>\n <Show when={Object.values(this.commands).length > 0}>\n <For each={Object.values(this.commands)} doubleHardline>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </Show>\n </>\n );\n }\n }\n }\n ];\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 { code, computed, For, Show } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport {\n getAppDescription,\n getAppName,\n getAppTitle,\n getCommandList\n} from \"@shell-shock/core/plugin-utils\";\nimport banner from \"@shell-shock/plugin-banner\";\nimport console from \"@shell-shock/plugin-console\";\nimport help from \"@shell-shock/plugin-help\";\nimport prompts from \"@shell-shock/plugin-prompts\";\nimport upgrade from \"@shell-shock/plugin-upgrade\";\nimport { BinEntry } from \"@shell-shock/preset-script/components/bin-entry\";\nimport { joinPaths } from \"@stryke/path\";\nimport type { Plugin } from \"powerlines\";\nimport { BannerBuiltin } from \"./components\";\nimport { CommandEntry } from \"./components/command-entry\";\nimport { CommandRouter } from \"./components/command-router\";\nimport { UpgradeBuiltin } from \"./components/upgrade-builtin\";\nimport { VirtualCommandEntry } from \"./components/virtual-command-entry\";\nimport { getDefaultOptions } from \"./helpers/get-default-options\";\nimport type { CLIPresetContext, CLIPresetOptions } from \"./types/plugin\";\n\n/**\n * The Shell Shock CLI Preset plugin.\n *\n * @remarks\n * This preset includes a set of built-in modules and commands to create a CLI application, as well as configuration options to customize the generated code. It also includes the `prompts` plugin to provide interactive prompts in the CLI application, and the `upgrade` plugin to manage upgrading the local application's version.\n */\nexport const plugin = <TContext extends CLIPresetContext = CLIPresetContext>(\n options: CLIPresetOptions = {}\n): Plugin<TContext>[] => {\n return [\n ...console<TContext>(options),\n ...help<TContext>(options),\n ...banner<TContext>(options),\n ...prompts<TContext>(options),\n upgrade<TContext>(options),\n {\n name: \"shell-shock:cli-preset\",\n config() {\n this.debug(\n \"Providing default configuration for the Shell Shock `cli` preset.\"\n );\n\n return {\n defaultOptions: getDefaultOptions,\n isCaseSensitive: false,\n ...options\n };\n },\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\"Rendering built-in modules.\");\n\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 const bin = computed(() => ({\n id: \"\",\n name: getAppName(this),\n title: getAppTitle(this),\n description: getAppDescription(this),\n isVirtual: true,\n path: null,\n segments: [],\n alias: [],\n tags: [],\n options: Object.fromEntries(\n this.options.map(option => [option.name, option])\n ),\n entry: {\n file: joinPaths(this.entryPath, \"bin.ts\")\n },\n args: [],\n parent: null,\n children: this.commands\n }));\n\n return render(\n this,\n <>\n <UpgradeBuiltin />\n <BannerBuiltin command={bin.value} />\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 {\n name: \"shell-shock:cli-preset:generate-entrypoint\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `cli` preset.\"\n );\n\n return render(\n this,\n <>\n <BinEntry\n builtinImports={{\n console: [\n \"info\",\n \"debug\",\n \"warn\",\n \"help\",\n \"error\",\n \"cursor\",\n \"divider\",\n \"stripAnsi\",\n \"writeLine\",\n \"splitText\",\n \"colors\"\n ],\n utils: [\n \"useApp\",\n \"useArgs\",\n \"isMinimal\",\n \"isInteractive\",\n \"isHelp\"\n ],\n prompts: [\n \"text\",\n \"numeric\",\n \"toggle\",\n \"select\",\n \"confirm\",\n \"isCancel\"\n ],\n env: [\"env\", \"paths\"],\n upgrade: [\"executeUpgrade\"]\n }}>\n <Show when={Object.keys(this.commands).length > 0}>\n <VarDeclaration\n let\n name=\"args\"\n type=\"string[]\"\n initializer={code`useArgs();`}\n />\n <hbr />\n <CommandRouter segments={[]} commands={this.commands ?? {}} />\n <hbr />\n </Show>\n <hbr />\n {code`await showBanner(0);`}\n <Spacing />\n {code`return showHelp(); `}\n </BinEntry>\n <Show when={Object.values(this.commands).length > 0}>\n <For each={Object.values(this.commands)} doubleHardline>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </Show>\n </>\n );\n }\n }\n }\n ];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,MAAC,UAAA,UAAA,EAAA,KAAA;AACC,QAAE;EAAA,GAAA,QAAA,QAAA;EAAA,GAAA,SAAA,QAAA;EAAA,GAAA,SAAA,QAAA;EAAA,GAAA,QAAA,QAAA;EAAA,QAAA,QAAA;EAAA;GACD,MAAK;GACN,SAAA;AACI,SAAC,MAAM,oEAA+D;AAC1E,WAAS;KACR,gBAAqB;KAChB,iBAAC;KACF,GAAA;KACA;;GAEH,SAAG;IACH,OAAQ;IACR,MAAA,UAAA;AACE,UAAO,MAAM,8BAAiB;KAC9B,MAAQ,WAAC,MAAA,eAAA,KAAA;AACP,UAAK,MAAK,kDAAA,SAAA,OAAA,mBAAA;KACV,MAAG,MAAS,gBAAS;MACpB,IAAA;;MAED,OAAO,YAAA,KAAA;MACL,aAAA,kBAAgB,KAAiB;MACjC,WAAA;MACA,MAAG;MACJ,UAAA,EAAA;MACF,OAAA,EAAA;MACD,MAAS,EAAA;MACP,SAAQ,OAAK,YAAA,KAAA,QAAA,KAAA,WAAA,CAAA,OAAA,MAAA,OAAA,CAAA,CAAA;MACb,OAAM,EACJ,MAAK,UAAO,KAAU,WAAS,SAAU;MAEzC,MAAM,EAAA;MACN,QAAK;MACL,UAAG,KAAY;MAChB,EAAE;AACH,YAAM,OAAQ,MAAA;MAAO,gBAAC,gBAAA,EAAA,CAAA;MAAA,gBAAA,eAAA,EACpB,IAAC,UAAA;;SAGF,CAAC;MAAE,gBAAM,SAAA,EAAA,CAAA;MAAA,gBAAA,KAAA;OACR,IAAE,OAAM;AACN,eAAO,SAAA,MAAY,GAAK,MAAA,EAAA,KAAA,cAAA,EAAA,KAAA,CAAA;;OAE1B,gBAAa;OACb,WAAQ,YAAI,gBAAA,eAAA,EACD,SACV,CAAC;OACH,CAAC;MAAC,CAAC;;IAEP;GACF;EAAE;GACD,MAAM;GACN,SAAS;IACP,OAAO;IACP,MAAM,UAAQ;KACZ,MAAI,SAAQ;AACZ,UAAI,MAAA,iEAAe;AACnB,YAAK,OAAA,MAAA,CAAA,gBAAA,UAAA;;OAEH,SAAO;QAAA;QAAM;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;OACX,OAAI;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;OACJ,SAAC;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;QAAA;OACD,KAAG,CAAA,OAAA,QAAgB;OACnB,SAAG,CAAA,iBAAuB;OAC3B;MACD,IAAI,WAAC;AACH,cAAI;QAAI,gBAAkB,MAAM;SAC9B,IAAE,OAAA;AACA,iBAAC,OAAY,KAAA,OAAa,SAAS,CAAC,SAAS;;SAE/C,IAAA,WAAA;AACH,iBAAA;WAAA,gBAAA,gBAAA;YACH,OAAA;YACF,MAAA;YACD,MAAA;YACD,aAAA,IAAA;YACS,CAAK;WAAC,gBAAiB,OAAS,EAAA,CAAA;WAAA,gBAAW,eAAA;YACzC,UAAA,EAAA;YACC,IAAK,WAAA;AACP,oBAAU,OAAA,YAAA,EAAA;;YAEX,CAAA;WAAA,gBAAqB,OAAW,EAAC,CAAA;WAAG;;;;;;;;;MAIxC,CAAC,EAAE,gBAAI,MAAA;MACN,IAAG,OAAA;AACD,cAAG,OAAA,OAAA,OAAA,SAAA,CAAA,SAAA;;MAEL,IAAI,WAAW;AACb,cAAO,gBAAO,KAAA;QACZ,IAAI,OAAG;AACL,gBAAK,OAAK,OAAA,OAAA,SAAA;;QAEZ,gBAAa;QACb,WAAO,UAAO,gBAAA,MAAA;SACZ,IAAI,OAAC;AACH,iBAAG,MAAU;;SAEf,IAAI,WAAW;AACb,iBAAG,gBAAM,cAAA,EACR,SAAA,OACD,CAAA;;SAEF,IAAI,WAAS;AACX,iBAAG,gBAAU,qBAAA,EACX,SAAC,OACF,CAAC;;SAEL,CAAC;QACH,CAAC;;MAEL,CAAC,CAAC,CAAC;;IAEP;GACF;EAAC"}
|
|
@@ -4,10 +4,10 @@ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
|
4
4
|
let _alloy_js_core = require("@alloy-js/core");
|
|
5
5
|
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
6
6
|
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
7
|
-
let defu = require("defu");
|
|
8
|
-
defu = require_runtime.__toESM(defu);
|
|
9
7
|
let _powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
|
|
10
8
|
let _stryke_path = require("@stryke/path");
|
|
9
|
+
let defu = require("defu");
|
|
10
|
+
defu = require_runtime.__toESM(defu);
|
|
11
11
|
|
|
12
12
|
//#region ../plugin-banner/dist/components/banner-builtin.mjs
|
|
13
13
|
/**
|
|
@@ -3,9 +3,9 @@ import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
|
3
3
|
import { Show, splitProps } from "@alloy-js/core";
|
|
4
4
|
import { getAppTitle, isDynamicPathSegment } from "@shell-shock/core/plugin-utils";
|
|
5
5
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
6
|
-
import defu from "defu";
|
|
7
6
|
import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
8
7
|
import { joinPaths } from "@stryke/path";
|
|
8
|
+
import defu from "defu";
|
|
9
9
|
|
|
10
10
|
//#region ../plugin-banner/dist/components/banner-builtin.mjs
|
|
11
11
|
/**
|
|
@@ -3,8 +3,8 @@ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
|
3
3
|
let _alloy_js_core = require("@alloy-js/core");
|
|
4
4
|
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
5
5
|
let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
|
|
6
|
-
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
7
6
|
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
7
|
+
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
8
8
|
let _shell_shock_plugin_theme_contexts_theme = require("@shell-shock/plugin-theme/contexts/theme");
|
|
9
9
|
|
|
10
10
|
//#region ../plugin-banner/dist/components/banner-function-declaration.mjs
|
|
@@ -66,19 +66,22 @@ function BannerFunctionBodyDeclaration(props) {
|
|
|
66
66
|
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`
|
|
67
67
|
writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].topLeft}") + ${theme.icons.banner.header[variant] ? `colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].top}".repeat(6)) + " " + ${theme.icons.banner.header[variant] ? `colors.text.banner.header.${variant}("${theme.icons.banner.header[variant]}") + " " + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].top}") + " " +` : ""} colors.bold(colors.text.banner.header.${variant}("${header}")) + " " + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].top}".repeat(Math.max(process.stdout.columns - ${6 + (theme.icons.banner.header[variant] ? theme.icons.banner.header[variant].length + 3 : 0) + (header ? header.length + 2 : 0) + bannerPadding.value}, 0)))` : `colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].top}".repeat(Math.max(process.stdout.columns - ${bannerPadding.value}, 0)))`} + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].topRight}"), { consoleFn: console.${consoleFnName} });
|
|
68
68
|
|
|
69
|
-
splitText(
|
|
70
|
-
${title ? `"${title}"` : "title"},
|
|
69
|
+
${title ? title.split("\n").map((line) => `splitText("${line}",
|
|
71
70
|
Math.max(process.stdout.columns - ${totalPadding.value}, 0)
|
|
72
71
|
).forEach((line) => {
|
|
73
72
|
writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.bold(colors.text.banner.title.${variant}(line)) + " ".repeat(Math.max(Math.ceil((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} });
|
|
74
|
-
});
|
|
73
|
+
}); `) : `splitText(title,
|
|
74
|
+
Math.max(process.stdout.columns - ${totalPadding.value}, 0)
|
|
75
|
+
).forEach((line) => {
|
|
76
|
+
writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.bold(colors.text.banner.title.${variant}(line)) + " ".repeat(Math.max(Math.ceil((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} });
|
|
77
|
+
});`}
|
|
75
78
|
|
|
76
79
|
${command?.title ? `${insertNewlineBeforeCommand ? `writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(process.stdout.columns - ${bannerPadding.value})) + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} }); ` : ""}
|
|
77
80
|
${`writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((process.stdout.columns - (stripAnsi("${command.title}").length ${command.icon ? " + 3" : ""} + ${bannerPadding.value})) / 2), 0)) + colors.bold(colors.text.banner.command.${variant}("${command.icon ? `${command.icon} ` : ""}${command.title}")) + " ".repeat(Math.max(Math.ceil((process.stdout.columns - (stripAnsi("${command.title}").length ${command.icon ? " + 3" : ""} + ${bannerPadding.value})) / 2), 0)) + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} }); `} ` : ""}
|
|
78
81
|
|
|
79
82
|
splitText(
|
|
80
83
|
colors.bold(${command?.title ? "colors.text.banner.description" : "colors.text.banner.command"}.${variant}(\`${(0, _shell_shock_core_plugin_utils.formatDescription)(description)}\`)),
|
|
81
|
-
Math.max(process.stdout.columns - ${totalPadding.value}, 0)
|
|
84
|
+
Math.max(${command?.title ? `${totalPadding.value} * 2 > process.stdout.columns / 2 ? process.stdout.columns - 6 : process.stdout.columns - ${totalPadding.value}` : `process.stdout.columns - ${totalPadding.value}`} , 0)
|
|
82
85
|
).forEach((line) => {
|
|
83
86
|
writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.text.banner.description.${variant}(line) + " ".repeat(Math.max(Math.ceil((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} });
|
|
84
87
|
});
|
|
@@ -100,7 +103,7 @@ function BannerFunctionDeclaration(props) {
|
|
|
100
103
|
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
101
104
|
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"}`);
|
|
102
105
|
const footer = (0, _alloy_js_core.computed)(() => theme.labels.banner.footer[variant]);
|
|
103
|
-
const title = (0, _alloy_js_core.computed)(() => (0, _shell_shock_core_plugin_utils.getAppTitle)(context, true).replace(`v${context.packageJson.version || "1.0.0"}`, ""));
|
|
106
|
+
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"}`, ""));
|
|
104
107
|
const description = (0, _alloy_js_core.computed)(() => command?.description || (0, _shell_shock_core_plugin_utils.getAppDescription)(context));
|
|
105
108
|
return (0, _alloy_js_core_jsx_runtime.createComponent)(BannerFunctionDeclarationWrapper, {
|
|
106
109
|
command,
|
|
@@ -2,8 +2,8 @@ import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
|
|
|
2
2
|
import { Show, code, computed } from "@alloy-js/core";
|
|
3
3
|
import { FunctionDeclaration, IfStatement } from "@alloy-js/typescript";
|
|
4
4
|
import { formatDescription, getAppDescription, getAppTitle } from "@shell-shock/core/plugin-utils";
|
|
5
|
-
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
6
5
|
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
6
|
+
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
7
7
|
import { useTheme } from "@shell-shock/plugin-theme/contexts/theme";
|
|
8
8
|
|
|
9
9
|
//#region ../plugin-banner/dist/components/banner-function-declaration.mjs
|
|
@@ -65,19 +65,22 @@ function BannerFunctionBodyDeclaration(props) {
|
|
|
65
65
|
memo(() => code`
|
|
66
66
|
writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].topLeft}") + ${theme.icons.banner.header[variant] ? `colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].top}".repeat(6)) + " " + ${theme.icons.banner.header[variant] ? `colors.text.banner.header.${variant}("${theme.icons.banner.header[variant]}") + " " + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].top}") + " " +` : ""} colors.bold(colors.text.banner.header.${variant}("${header}")) + " " + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].top}".repeat(Math.max(process.stdout.columns - ${6 + (theme.icons.banner.header[variant] ? theme.icons.banner.header[variant].length + 3 : 0) + (header ? header.length + 2 : 0) + bannerPadding.value}, 0)))` : `colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].top}".repeat(Math.max(process.stdout.columns - ${bannerPadding.value}, 0)))`} + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].topRight}"), { consoleFn: console.${consoleFnName} });
|
|
67
67
|
|
|
68
|
-
splitText(
|
|
69
|
-
${title ? `"${title}"` : "title"},
|
|
68
|
+
${title ? title.split("\n").map((line) => `splitText("${line}",
|
|
70
69
|
Math.max(process.stdout.columns - ${totalPadding.value}, 0)
|
|
71
70
|
).forEach((line) => {
|
|
72
71
|
writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.bold(colors.text.banner.title.${variant}(line)) + " ".repeat(Math.max(Math.ceil((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} });
|
|
73
|
-
});
|
|
72
|
+
}); `) : `splitText(title,
|
|
73
|
+
Math.max(process.stdout.columns - ${totalPadding.value}, 0)
|
|
74
|
+
).forEach((line) => {
|
|
75
|
+
writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.bold(colors.text.banner.title.${variant}(line)) + " ".repeat(Math.max(Math.ceil((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} });
|
|
76
|
+
});`}
|
|
74
77
|
|
|
75
78
|
${command?.title ? `${insertNewlineBeforeCommand ? `writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(process.stdout.columns - ${bannerPadding.value})) + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} }); ` : ""}
|
|
76
79
|
${`writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((process.stdout.columns - (stripAnsi("${command.title}").length ${command.icon ? " + 3" : ""} + ${bannerPadding.value})) / 2), 0)) + colors.bold(colors.text.banner.command.${variant}("${command.icon ? `${command.icon} ` : ""}${command.title}")) + " ".repeat(Math.max(Math.ceil((process.stdout.columns - (stripAnsi("${command.title}").length ${command.icon ? " + 3" : ""} + ${bannerPadding.value})) / 2), 0)) + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} }); `} ` : ""}
|
|
77
80
|
|
|
78
81
|
splitText(
|
|
79
82
|
colors.bold(${command?.title ? "colors.text.banner.description" : "colors.text.banner.command"}.${variant}(\`${formatDescription(description)}\`)),
|
|
80
|
-
Math.max(process.stdout.columns - ${totalPadding.value}, 0)
|
|
83
|
+
Math.max(${command?.title ? `${totalPadding.value} * 2 > process.stdout.columns / 2 ? process.stdout.columns - 6 : process.stdout.columns - ${totalPadding.value}` : `process.stdout.columns - ${totalPadding.value}`} , 0)
|
|
81
84
|
).forEach((line) => {
|
|
82
85
|
writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.text.banner.description.${variant}(line) + " ".repeat(Math.max(Math.ceil((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} });
|
|
83
86
|
});
|
|
@@ -99,7 +102,7 @@ function BannerFunctionDeclaration(props) {
|
|
|
99
102
|
const context = usePowerlines();
|
|
100
103
|
const header = computed(() => `${theme.labels.banner.header[variant] || getAppTitle(context, false)} v${context.packageJson.version || "1.0.0"}`);
|
|
101
104
|
const footer = computed(() => theme.labels.banner.footer[variant]);
|
|
102
|
-
const title = computed(() => getAppTitle(context, true).replace(`v${context.packageJson.version || "1.0.0"}`, ""));
|
|
105
|
+
const title = computed(() => context.config.banner.title || getAppTitle(context, true).replace(`v${context.packageJson.version || "1.0.0"}`, ""));
|
|
103
106
|
const description = computed(() => command?.description || getAppDescription(context));
|
|
104
107
|
return createComponent(BannerFunctionDeclarationWrapper, {
|
|
105
108
|
command,
|