@shell-shock/plugin-help 0.1.2
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/LICENSE +201 -0
- package/README.md +264 -0
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/_virtual/_rolldown/runtime.mjs +3 -0
- package/dist/components/display.cjs +260 -0
- package/dist/components/display.d.cts +105 -0
- package/dist/components/display.d.cts.map +1 -0
- package/dist/components/display.d.mts +105 -0
- package/dist/components/display.d.mts.map +1 -0
- package/dist/components/display.mjs +254 -0
- package/dist/components/display.mjs.map +1 -0
- package/dist/components/help-builtin.cjs +113 -0
- package/dist/components/help-builtin.d.cts +22 -0
- package/dist/components/help-builtin.d.cts.map +1 -0
- package/dist/components/help-builtin.d.mts +22 -0
- package/dist/components/help-builtin.d.mts.map +1 -0
- package/dist/components/help-builtin.mjs +110 -0
- package/dist/components/help-builtin.mjs.map +1 -0
- package/dist/components/help-command.cjs +97 -0
- package/dist/components/help-command.d.cts +10 -0
- package/dist/components/help-command.d.cts.map +1 -0
- package/dist/components/help-command.d.mts +10 -0
- package/dist/components/help-command.d.mts.map +1 -0
- package/dist/components/help-command.mjs +96 -0
- package/dist/components/help-command.mjs.map +1 -0
- package/dist/components/index.cjs +14 -0
- package/dist/components/index.d.cts +4 -0
- package/dist/components/index.d.mts +4 -0
- package/dist/components/index.mjs +5 -0
- package/dist/index.cjs +105 -0
- package/dist/index.d.cts +11 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +11 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +100 -0
- package/dist/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/constant-case.cjs +17 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/constant-case.mjs +17 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/constant-case.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/get-words.cjs +38 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/get-words.mjs +38 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/get-words.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/kebab-case.cjs +33 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/kebab-case.mjs +34 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/kebab-case.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/snake-case.cjs +40 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/snake-case.mjs +41 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/snake-case.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/upper-case-first.cjs +17 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/upper-case-first.mjs +17 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/upper-case-first.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-empty.cjs +20 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-empty.mjs +21 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-empty.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-null.cjs +12 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-null.mjs +12 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-null.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set-string.cjs +20 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set-string.mjs +21 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set-string.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set.cjs +19 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set.mjs +20 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-set.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-string.cjs +12 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-string.mjs +12 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-string.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-undefined.cjs +8 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-undefined.mjs +8 -0
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.39/node_modules/@stryke/type-checks/dist/is-undefined.mjs.map +1 -0
- package/dist/types/index.cjs +0 -0
- package/dist/types/index.d.cts +2 -0
- package/dist/types/index.d.mts +2 -0
- package/dist/types/index.mjs +1 -0
- package/dist/types/plugin.cjs +0 -0
- package/dist/types/plugin.d.cts +61 -0
- package/dist/types/plugin.d.cts.map +1 -0
- package/dist/types/plugin.d.mts +61 -0
- package/dist/types/plugin.d.mts.map +1 -0
- package/dist/types/plugin.mjs +1 -0
- package/package.json +177 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { kebabCase } from "../node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/kebab-case.mjs";
|
|
2
|
+
import { snakeCase } from "../node_modules/.pnpm/@stryke_string-format@0.17.4/node_modules/@stryke/string-format/dist/snake-case.mjs";
|
|
3
|
+
import { createComponent, createIntrinsic, memo } from "@alloy-js/core/jsx-runtime";
|
|
4
|
+
import { For, Show, code, computed } from "@alloy-js/core";
|
|
5
|
+
import { formatDescription, formatShortDescription, getAppBin, getAppTitle, getDynamicPathSegmentName, isDynamicPathSegment, sortOptions } from "@shell-shock/core/plugin-utils";
|
|
6
|
+
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
7
|
+
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
8
|
+
import { CommandParameterKinds } from "@shell-shock/core";
|
|
9
|
+
import { useTheme } from "@shell-shock/plugin-theme/contexts/theme";
|
|
10
|
+
|
|
11
|
+
//#region src/components/display.tsx
|
|
12
|
+
/**
|
|
13
|
+
* A component that generates the usage display for a command.
|
|
14
|
+
*/
|
|
15
|
+
function HelpUsageDisplay(props) {
|
|
16
|
+
const { command, indent = 2 } = props;
|
|
17
|
+
const context = usePowerlines();
|
|
18
|
+
const theme = useTheme();
|
|
19
|
+
return [createComponent(For, {
|
|
20
|
+
get each() {
|
|
21
|
+
return Object.keys(context.config.bin);
|
|
22
|
+
},
|
|
23
|
+
hardline: true,
|
|
24
|
+
children: (bin) => [memo(() => code`
|
|
25
|
+
writeLine(
|
|
26
|
+
colors.text.body.secondary(\`\$ \${colors.text.usage.bin("${bin}")}${command.segments.length > 0 ? ` ${command.segments.map((segment) => `\${colors.text.usage.${isDynamicPathSegment(segment) ? "dynamic" : "command"}("${isDynamicPathSegment(segment) ? `[${snakeCase(getDynamicPathSegmentName(segment))}]` : segment}")}`).join(" ")}` : ""}${Object.values(command.children).length > 0 ? ` \${colors.text.usage.dynamic("[command]")}` : ""}${command.args.length > 0 ? ` ${command.args.map((arg) => `\${colors.text.usage.args("<${snakeCase((arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.choices && arg.choices.length > 0 ? arg.choices.join("|") : arg.kind === CommandParameterKinds.string && arg.format ? arg.format : arg.name)}${(arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.variadic ? "..." : ""}>")}`).join(" ")}` : ""} \${colors.text.usage.options("[options]")}\`), { padding: ${theme.padding.app * indent} }
|
|
27
|
+
);`), createIntrinsic("hbr", {})]
|
|
28
|
+
}), createComponent(Show, {
|
|
29
|
+
get when() {
|
|
30
|
+
return command.args.length > 0;
|
|
31
|
+
},
|
|
32
|
+
get children() {
|
|
33
|
+
return [createIntrinsic("hbr", {}), createComponent(For, {
|
|
34
|
+
get each() {
|
|
35
|
+
return Object.keys(context.config.bin);
|
|
36
|
+
},
|
|
37
|
+
hardline: true,
|
|
38
|
+
children: (bin) => [memo(() => code`
|
|
39
|
+
writeLine(
|
|
40
|
+
colors.text.body.secondary(\`\$ \${colors.text.usage.bin("${bin}")}${command.segments.length > 0 ? ` ${command.segments.map((segment) => `\${colors.text.usage.${isDynamicPathSegment(segment) ? "dynamic" : "command"}("${isDynamicPathSegment(segment) ? `[${snakeCase(getDynamicPathSegmentName(segment))}]` : segment}")}`).join(" ")}` : ""}${Object.values(command.children).length > 0 ? ` \${colors.text.usage.dynamic("[command]")}` : ""} \${colors.text.usage.options("[options]")}${command.args.length > 0 ? ` ${command.args.map((arg) => `\${colors.text.usage.args("<${snakeCase((arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.choices && arg.choices.length > 0 ? arg.choices.join("|") : arg.kind === CommandParameterKinds.string && arg.format ? arg.format : arg.name)}${(arg.kind === CommandParameterKinds.string || arg.kind === CommandParameterKinds.number) && arg.variadic ? "..." : ""}>")}`).join(" ")}` : ""}\`), { padding: ${theme.padding.app * indent} }
|
|
41
|
+
);`), createIntrinsic("hbr", {})]
|
|
42
|
+
})];
|
|
43
|
+
}
|
|
44
|
+
})];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A component that generates the options table display for a command.
|
|
48
|
+
*/
|
|
49
|
+
function HelpOptionsDisplay(props) {
|
|
50
|
+
const { options } = props;
|
|
51
|
+
const context = usePowerlines();
|
|
52
|
+
return [
|
|
53
|
+
code`table([ `,
|
|
54
|
+
createIntrinsic("hbr", {}),
|
|
55
|
+
createComponent(For, {
|
|
56
|
+
get each() {
|
|
57
|
+
return sortOptions(options);
|
|
58
|
+
},
|
|
59
|
+
hardline: true,
|
|
60
|
+
children: (option) => {
|
|
61
|
+
const flags = [];
|
|
62
|
+
const names = [];
|
|
63
|
+
if (option.name.length === 1) flags.push(`-${option.name}`);
|
|
64
|
+
else names.push(`--${kebabCase(option.name)}`);
|
|
65
|
+
option.alias.forEach((alias) => {
|
|
66
|
+
if (alias.length === 1) flags.push(`-${alias}`);
|
|
67
|
+
else names.push(`--${kebabCase(alias)}`);
|
|
68
|
+
});
|
|
69
|
+
return code`[{ value: colors.text.body.primary("${flags.length > 0 ? `${flags.sort().join(", ")}${names.length > 0 ? ", " : ""}` : ""}${names.length > 0 ? names.sort().join(", ") : ""}${option.kind === CommandParameterKinds.string ? ` <${snakeCase(option.choices && option.choices.length > 0 ? option.choices.join("|") : option.format ? option.format : option.name)}${option.variadic ? "..." : ""}>` : option.kind === CommandParameterKinds.number ? ` <${snakeCase(option.choices && option.choices.length > 0 ? option.choices.join("|") : option.name)}${option.variadic ? "..." : ""}>` : ""}"), align: "right", border: "none", maxWidth: "1/3" }, { value: colors.text.body.tertiary(\`${formatShortDescription(option.description).replace(/\.+$/, "").trim()}${option.env || option.default !== void 0 ? ` (${option.env ? `env: ${context.config.appSpecificEnvPrefix}_${option.env}${option.default !== void 0 ? ", " : ""}` : ""}${option.default !== void 0 ? `default: ${JSON.stringify(option.default).replace(/"/g, "\\\"")}` : ""})` : ""}.\`), align: "left", border: "none" }], `;
|
|
70
|
+
}
|
|
71
|
+
}),
|
|
72
|
+
createIntrinsic("hbr", {}),
|
|
73
|
+
code` ]); `
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A component that generates the commands table display for a command.
|
|
78
|
+
*/
|
|
79
|
+
function HelpCommandsDisplay(props) {
|
|
80
|
+
const { commands } = props;
|
|
81
|
+
return [
|
|
82
|
+
code`table([ `,
|
|
83
|
+
createIntrinsic("hbr", {}),
|
|
84
|
+
createComponent(For, {
|
|
85
|
+
get each() {
|
|
86
|
+
return Object.values(commands);
|
|
87
|
+
},
|
|
88
|
+
hardline: true,
|
|
89
|
+
children: (child) => code`[{ value: colors.text.body.primary("${child.name}"), align: "right", border: "none" }, { value: colors.text.body.tertiary(\`${formatShortDescription(child.description).replace(/\.+$/, "").trim()}.\`), align: "left", border: "none" }], `
|
|
90
|
+
}),
|
|
91
|
+
createIntrinsic("hbr", {}),
|
|
92
|
+
code` ]); `
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A component that generates the `help` function declaration for a command.
|
|
97
|
+
*/
|
|
98
|
+
function BaseHelpDisplay(props) {
|
|
99
|
+
const { command, indent = 1, filterGlobalOptions = false } = props;
|
|
100
|
+
const theme = useTheme();
|
|
101
|
+
const context = usePowerlines();
|
|
102
|
+
const options = computed(() => filterGlobalOptions ? Object.values(command.options).filter((option) => !context.options.some((globalOption) => globalOption.name === option.name || option.alias.includes(globalOption.name) || globalOption.alias?.includes(option.name) || globalOption.alias?.some((alias) => option.alias.includes(alias)))) : Object.values(command.options));
|
|
103
|
+
return [
|
|
104
|
+
memo(() => code`writeLine(colors.bold(colors.text.heading.secondary("Usage:"))${indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : ""});`),
|
|
105
|
+
createIntrinsic("hbr", {}),
|
|
106
|
+
createComponent(HelpUsageDisplay, {
|
|
107
|
+
command,
|
|
108
|
+
indent
|
|
109
|
+
}),
|
|
110
|
+
createComponent(Spacing, {}),
|
|
111
|
+
createComponent(Show, {
|
|
112
|
+
get when() {
|
|
113
|
+
return options.value.length > 0;
|
|
114
|
+
},
|
|
115
|
+
get children() {
|
|
116
|
+
return [
|
|
117
|
+
memo(() => code`writeLine("");
|
|
118
|
+
writeLine(colors.bold(colors.text.heading.secondary("Options:"))${indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : ""});`),
|
|
119
|
+
createIntrinsic("hbr", {}),
|
|
120
|
+
createComponent(HelpOptionsDisplay, { get options() {
|
|
121
|
+
return options.value;
|
|
122
|
+
} }),
|
|
123
|
+
createComponent(Spacing, {})
|
|
124
|
+
];
|
|
125
|
+
}
|
|
126
|
+
}),
|
|
127
|
+
createComponent(Show, {
|
|
128
|
+
get when() {
|
|
129
|
+
return Object.keys(command.children).length > 0;
|
|
130
|
+
},
|
|
131
|
+
get children() {
|
|
132
|
+
return [
|
|
133
|
+
memo(() => code`writeLine("");
|
|
134
|
+
writeLine(colors.bold(colors.text.heading.secondary("Commands:"))${indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : ""});`),
|
|
135
|
+
createIntrinsic("hbr", {}),
|
|
136
|
+
createComponent(HelpCommandsDisplay, { get commands() {
|
|
137
|
+
return command.children;
|
|
138
|
+
} }),
|
|
139
|
+
createComponent(Spacing, {})
|
|
140
|
+
];
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
];
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* A component that generates the invocation of the `help` function for a command.
|
|
147
|
+
*/
|
|
148
|
+
function VirtualCommandHelpDisplay(props) {
|
|
149
|
+
const { options, segments, commands } = props;
|
|
150
|
+
const context = usePowerlines();
|
|
151
|
+
return [
|
|
152
|
+
createIntrinsic("hbr", {}),
|
|
153
|
+
code`writeLine(colors.bold(colors.text.heading.secondary("Global Options:")));`,
|
|
154
|
+
createIntrinsic("hbr", {}),
|
|
155
|
+
createComponent(HelpOptionsDisplay, { options }),
|
|
156
|
+
code`writeLine(""); `,
|
|
157
|
+
createComponent(Spacing, {}),
|
|
158
|
+
createComponent(Show, {
|
|
159
|
+
get when() {
|
|
160
|
+
return Object.keys(commands).length > 0;
|
|
161
|
+
},
|
|
162
|
+
get children() {
|
|
163
|
+
return [
|
|
164
|
+
memo(() => code`writeLine(colors.text.body.secondary("The following commands are available through the ${getAppTitle(context, true)} command-line interface:"));
|
|
165
|
+
writeLine(""); `),
|
|
166
|
+
createComponent(Spacing, {}),
|
|
167
|
+
createComponent(For, {
|
|
168
|
+
get each() {
|
|
169
|
+
return Object.values(commands);
|
|
170
|
+
},
|
|
171
|
+
doubleHardline: true,
|
|
172
|
+
joiner: code`writeLine(""); `,
|
|
173
|
+
ender: code`writeLine(""); `,
|
|
174
|
+
children: (child) => [
|
|
175
|
+
memo(() => code`
|
|
176
|
+
writeLine(colors.text.heading.primary(${child.icon ? `(isUnicodeSupported ? " ${child.icon} " : "") + ` : ""}"${child.title} ${child.isVirtual ? "" : "Command"}"));
|
|
177
|
+
writeLine("");
|
|
178
|
+
writeLine(colors.text.body.secondary(splitText(\`${formatDescription(child.description).replace(/\.+$/, "").trim()}.\`)));
|
|
179
|
+
writeLine("");
|
|
180
|
+
`),
|
|
181
|
+
createIntrinsic("hbr", {}),
|
|
182
|
+
createComponent(BaseHelpDisplay, {
|
|
183
|
+
command: child,
|
|
184
|
+
indent: 2,
|
|
185
|
+
filterGlobalOptions: true
|
|
186
|
+
}),
|
|
187
|
+
createIntrinsic("hbr", {})
|
|
188
|
+
]
|
|
189
|
+
}),
|
|
190
|
+
memo(() => code`help("Running a specific command with the help flag (via: '${getAppBin(context)}${segments && segments.length > 0 ? ` ${segments.join(" ")}` : ""} <specific command> --help') will provide additional information that is specific to that command.");
|
|
191
|
+
writeLine("");`)
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
];
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* A component that generates the invocation of the `help` function for a command.
|
|
199
|
+
*/
|
|
200
|
+
function CommandHelpDisplay(props) {
|
|
201
|
+
const { command } = props;
|
|
202
|
+
const context = usePowerlines();
|
|
203
|
+
return [
|
|
204
|
+
code`writeLine(""); `,
|
|
205
|
+
createComponent(Spacing, {}),
|
|
206
|
+
createComponent(BaseHelpDisplay, {
|
|
207
|
+
command,
|
|
208
|
+
filterGlobalOptions: false
|
|
209
|
+
}),
|
|
210
|
+
code`writeLine(""); `,
|
|
211
|
+
createComponent(Spacing, {}),
|
|
212
|
+
createComponent(Show, {
|
|
213
|
+
get when() {
|
|
214
|
+
return Object.keys(command.children).length > 0;
|
|
215
|
+
},
|
|
216
|
+
get children() {
|
|
217
|
+
return [
|
|
218
|
+
code`writeLine(colors.text.body.secondary("The following sub-commands are available:"));
|
|
219
|
+
writeLine(""); `,
|
|
220
|
+
createComponent(Spacing, {}),
|
|
221
|
+
createComponent(For, {
|
|
222
|
+
get each() {
|
|
223
|
+
return Object.values(command.children);
|
|
224
|
+
},
|
|
225
|
+
doubleHardline: true,
|
|
226
|
+
joiner: code`writeLine(""); `,
|
|
227
|
+
ender: code`writeLine(""); `,
|
|
228
|
+
children: (child) => [
|
|
229
|
+
memo(() => code`
|
|
230
|
+
writeLine(colors.text.heading.primary(${child.icon ? `(isUnicodeSupported ? " ${child.icon} " : "") + ` : ""}"${child.title} ${child.isVirtual ? "" : "Command"}"));
|
|
231
|
+
writeLine("");
|
|
232
|
+
writeLine(colors.text.body.secondary(splitText(\`${formatDescription(child.description).replace(/\.+$/, "").trim()}.\`)));
|
|
233
|
+
writeLine("");
|
|
234
|
+
`),
|
|
235
|
+
createIntrinsic("hbr", {}),
|
|
236
|
+
createComponent(BaseHelpDisplay, {
|
|
237
|
+
command: child,
|
|
238
|
+
indent: 2,
|
|
239
|
+
filterGlobalOptions: true
|
|
240
|
+
}),
|
|
241
|
+
createIntrinsic("hbr", {})
|
|
242
|
+
]
|
|
243
|
+
}),
|
|
244
|
+
memo(() => code`help("Running a specific command with the help flag (via: '${getAppBin(context)} ${command.segments.join(" ")} <specific command> --help') will provide additional information that is specific to that command.");
|
|
245
|
+
writeLine("");`)
|
|
246
|
+
];
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
];
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
//#endregion
|
|
253
|
+
export { BaseHelpDisplay, CommandHelpDisplay, HelpCommandsDisplay, HelpOptionsDisplay, HelpUsageDisplay, VirtualCommandHelpDisplay };
|
|
254
|
+
//# sourceMappingURL=display.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.mjs","names":[],"sources":["../../src/components/display.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 { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { CommandOption, CommandTree } from \"@shell-shock/core\";\nimport { CommandParameterKinds } from \"@shell-shock/core\";\nimport {\n formatDescription,\n formatShortDescription,\n getAppBin,\n getAppTitle,\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n sortOptions\n} from \"@shell-shock/core/plugin-utils\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { snakeCase } from \"@stryke/string-format/snake-case\";\nimport type { HelpPluginContext } from \"../types/plugin\";\n\nexport interface HelpUsageDisplayProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * The padding scale to apply to the help display headings.\n *\n * @remarks\n * This value is multiplied by the theme's app padding to determine the final padding.\n *\n * @defaultValue 2\n */\n indent?: number;\n}\n\n/**\n * A component that generates the usage display for a command.\n */\nexport function HelpUsageDisplay(props: HelpUsageDisplayProps) {\n const { command, indent = 2 } = props;\n\n const context = usePowerlines<HelpPluginContext>();\n const theme = useTheme();\n\n return (\n <>\n <For each={Object.keys(context.config.bin)} hardline>\n {bin => (\n <>\n {code`\n writeLine(\n colors.text.body.secondary(\\`\\$ \\${colors.text.usage.bin(\"${bin}\")}${\n command.segments.length > 0\n ? ` ${command.segments\n .map(\n segment =>\n `\\${colors.text.usage.${isDynamicPathSegment(segment) ? \"dynamic\" : \"command\"}(\"${\n isDynamicPathSegment(segment)\n ? `[${snakeCase(getDynamicPathSegmentName(segment))}]`\n : segment\n }\")}`\n )\n .join(\" \")}`\n : \"\"\n }${Object.values(command.children).length > 0 ? ` \\${colors.text.usage.dynamic(\"[command]\")}` : \"\"}${\n command.args.length > 0\n ? ` ${command.args\n .map(\n arg =>\n `\\${colors.text.usage.args(\"<${snakeCase(\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.choices &&\n arg.choices.length > 0\n ? arg.choices.join(\"|\")\n : arg.kind === CommandParameterKinds.string &&\n arg.format\n ? arg.format\n : arg.name\n )}${\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? \"...\"\n : \"\"\n }>\")}`\n )\n .join(\" \")}`\n : \"\"\n } \\${colors.text.usage.options(\"[options]\")}\\`), { padding: ${theme.padding.app * indent} }\n );`}\n <hbr />\n </>\n )}\n </For>\n <Show when={command.args.length > 0}>\n <hbr />\n <For each={Object.keys(context.config.bin)} hardline>\n {bin => (\n <>\n {code`\n writeLine(\n colors.text.body.secondary(\\`\\$ \\${colors.text.usage.bin(\"${bin}\")}${\n command.segments.length > 0\n ? ` ${command.segments\n .map(\n segment =>\n `\\${colors.text.usage.${isDynamicPathSegment(segment) ? \"dynamic\" : \"command\"}(\"${\n isDynamicPathSegment(segment)\n ? `[${snakeCase(getDynamicPathSegmentName(segment))}]`\n : segment\n }\")}`\n )\n .join(\" \")}`\n : \"\"\n }${Object.values(command.children).length > 0 ? ` \\${colors.text.usage.dynamic(\"[command]\")}` : \"\"} \\${colors.text.usage.options(\"[options]\")}${\n command.args.length > 0\n ? ` ${command.args\n .map(\n arg =>\n `\\${colors.text.usage.args(\"<${snakeCase(\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.choices &&\n arg.choices.length > 0\n ? arg.choices.join(\"|\")\n : arg.kind === CommandParameterKinds.string &&\n arg.format\n ? arg.format\n : arg.name\n )}${\n (arg.kind === CommandParameterKinds.string ||\n arg.kind === CommandParameterKinds.number) &&\n arg.variadic\n ? \"...\"\n : \"\"\n }>\")}`\n )\n .join(\" \")}`\n : \"\"\n }\\`), { padding: ${theme.padding.app * indent} }\n );`}\n <hbr />\n </>\n )}\n </For>\n </Show>\n </>\n );\n}\n\nexport interface HelpOptionsDisplayProps {\n /**\n * The options to display help for.\n */\n options: CommandOption[];\n}\n\n/**\n * A component that generates the options table display for a command.\n */\nexport function HelpOptionsDisplay(props: HelpOptionsDisplayProps) {\n const { options } = props;\n\n const context = usePowerlines<HelpPluginContext>();\n\n return (\n <>\n {code`table([ `}\n <hbr />\n <For each={sortOptions(options)} hardline>\n {option => {\n const flags = [] as string[];\n const names = [] as string[];\n if (option.name.length === 1) {\n flags.push(`-${option.name}`);\n } else {\n names.push(`--${kebabCase(option.name)}`);\n }\n\n option.alias.forEach((alias: string) => {\n if (alias.length === 1) {\n flags.push(`-${alias}`);\n } else {\n names.push(`--${kebabCase(alias)}`);\n }\n });\n\n return code`[{ value: colors.text.body.primary(\"${\n flags.length > 0\n ? `${flags.sort().join(\", \")}${names.length > 0 ? \", \" : \"\"}`\n : \"\"\n }${names.length > 0 ? names.sort().join(\", \") : \"\"}${\n option.kind === CommandParameterKinds.string\n ? ` <${snakeCase(\n option.choices && option.choices.length > 0\n ? option.choices.join(\"|\")\n : option.format\n ? option.format\n : option.name\n )}${option.variadic ? \"...\" : \"\"}>`\n : option.kind === CommandParameterKinds.number\n ? ` <${snakeCase(\n option.choices && option.choices.length > 0\n ? option.choices.join(\"|\")\n : option.name\n )}${option.variadic ? \"...\" : \"\"}>`\n : \"\"\n }\"), align: \"right\", border: \"none\", maxWidth: \"1/3\" }, { value: colors.text.body.tertiary(\\`${formatShortDescription(\n option.description\n )\n .replace(/\\.+$/, \"\")\n .trim()}${\n option.env || option.default !== undefined\n ? ` (${\n option.env\n ? `env: ${context.config.appSpecificEnvPrefix}_${option.env}${\n option.default !== undefined ? \", \" : \"\"\n }`\n : \"\"\n }${\n option.default !== undefined\n ? `default: ${JSON.stringify(option.default).replace(/\"/g, '\\\\\"')}`\n : \"\"\n })`\n : \"\"\n }.\\`), align: \"left\", border: \"none\" }], `;\n }}\n </For>\n <hbr />\n {code` ]); `}\n </>\n );\n}\n\nexport interface HelpCommandsDisplayProps {\n /**\n * A mapping of command names to their command definitions.\n */\n commands: Record<string, CommandTree>;\n}\n\n/**\n * A component that generates the commands table display for a command.\n */\nexport function HelpCommandsDisplay(props: HelpCommandsDisplayProps) {\n const { commands } = props;\n\n return (\n <>\n {code`table([ `}\n <hbr />\n <For each={Object.values(commands)} hardline>\n {child =>\n code`[{ value: colors.text.body.primary(\"${\n child.name\n }\"), align: \"right\", border: \"none\" }, { value: colors.text.body.tertiary(\\`${formatShortDescription(\n child.description\n )\n .replace(/\\.+$/, \"\")\n .trim()}.\\`), align: \"left\", border: \"none\" }], `\n }\n </For>\n <hbr />\n {code` ]); `}\n </>\n );\n}\n\nexport interface BaseHelpDisplayProps {\n /**\n * The command to generate help for.\n */\n command: CommandTree;\n\n /**\n * Whether to filter out global options from the help display.\n *\n * @remarks\n * When enabled, any options that are present in the global options context will be filtered out from the help display. This is useful for sub-commands to avoid displaying global options that are not relevant to the specific command.\n *\n * @defaultValue false\n */\n filterGlobalOptions?: boolean;\n\n /**\n * The padding scale to apply to the help display headings.\n *\n * @remarks\n * This value is multiplied by the theme's app padding to determine the final padding.\n *\n * @defaultValue 1\n */\n indent?: number;\n}\n\n/**\n * A component that generates the `help` function declaration for a command.\n */\nexport function BaseHelpDisplay(props: BaseHelpDisplayProps) {\n const { command, indent = 1, filterGlobalOptions = false } = props;\n\n const theme = useTheme();\n const context = usePowerlines<HelpPluginContext>();\n\n const options = computed(() =>\n filterGlobalOptions\n ? Object.values(command.options).filter(\n option =>\n !context.options.some(\n globalOption =>\n globalOption.name === option.name ||\n option.alias.includes(globalOption.name) ||\n globalOption.alias?.includes(option.name) ||\n globalOption.alias?.some(alias => option.alias.includes(alias))\n )\n )\n : Object.values(command.options)\n );\n\n return (\n <>\n {code`writeLine(colors.bold(colors.text.heading.secondary(\"Usage:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpUsageDisplay command={command} indent={indent} />\n <Spacing />\n <Show when={options.value.length > 0}>\n {code`writeLine(\"\");\n writeLine(colors.bold(colors.text.heading.secondary(\"Options:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpOptionsDisplay options={options.value} />\n <Spacing />\n </Show>\n <Show when={Object.keys(command.children).length > 0}>\n {code`writeLine(\"\");\n writeLine(colors.bold(colors.text.heading.secondary(\"Commands:\"))${\n indent > 1 ? `, { padding: ${theme.padding.app * indent} }` : \"\"\n });`}\n <hbr />\n <HelpCommandsDisplay commands={command.children} />\n <Spacing />\n </Show>\n </>\n );\n}\n\nexport interface VirtualCommandHelpDisplayProps {\n /**\n * The options to display help for.\n */\n options: CommandOption[];\n\n /**\n * A mapping of command names to their command definitions.\n */\n commands: Record<string, CommandTree>;\n\n /**\n * The command path to generate help for, used for generating the help invocation instructions.\n *\n * @remarks\n * This is optional since the virtual command entry component can be used for both the global binary executable and virtual commands (there will be no command definition for the binary executable).\n */\n segments?: string[];\n}\n\n/**\n * A component that generates the invocation of the `help` function for a command.\n */\nexport function VirtualCommandHelpDisplay(\n props: VirtualCommandHelpDisplayProps\n) {\n const { options, segments, commands } = props;\n\n const context = usePowerlines<HelpPluginContext>();\n\n return (\n <>\n <hbr />\n {code`writeLine(colors.bold(colors.text.heading.secondary(\"Global Options:\")));`}\n <hbr />\n <HelpOptionsDisplay options={options} />\n {code`writeLine(\"\"); `}\n <Spacing />\n <Show when={Object.keys(commands).length > 0}>\n {code`writeLine(colors.text.body.secondary(\"The following commands are available through the ${getAppTitle(\n context,\n true\n )} command-line interface:\"));\n writeLine(\"\"); `}\n <Spacing />\n <For\n each={Object.values(commands)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n {code`\n writeLine(colors.text.heading.primary(${\n child.icon\n ? `(isUnicodeSupported ? \" ${child.icon} \" : \"\") + `\n : \"\"\n }\"${child.title} ${child.isVirtual ? \"\" : \"Command\"}\"));\n writeLine(\"\");\n writeLine(colors.text.body.secondary(splitText(\\`${formatDescription(\n child.description\n )\n .replace(/\\.+$/, \"\")\n .trim()}.\\`)));\n writeLine(\"\");\n `}\n <hbr />\n <BaseHelpDisplay command={child} indent={2} filterGlobalOptions />\n <hbr />\n </>\n )}\n </For>\n {code`help(\"Running a specific command with the help flag (via: '${getAppBin(\n context\n )}${\n segments && segments.length > 0 ? ` ${segments.join(\" \")}` : \"\"\n } <specific command> --help') will provide additional information that is specific to that command.\");\n writeLine(\"\");`}\n </Show>\n </>\n );\n}\n\nexport interface CommandHelpDisplayProps {\n /**\n * A mapping of command names to their command definitions.\n */\n command: CommandTree;\n}\n\n/**\n * A component that generates the invocation of the `help` function for a command.\n */\nexport function CommandHelpDisplay(props: CommandHelpDisplayProps) {\n const { command } = props;\n\n const context = usePowerlines<HelpPluginContext>();\n\n return (\n <>\n {code`writeLine(\"\"); `}\n <Spacing />\n <BaseHelpDisplay command={command} filterGlobalOptions={false} />\n {code`writeLine(\"\"); `}\n <Spacing />\n <Show when={Object.keys(command.children).length > 0}>\n {code`writeLine(colors.text.body.secondary(\"The following sub-commands are available:\"));\n writeLine(\"\"); `}\n <Spacing />\n <For\n each={Object.values(command.children)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n {code`\n writeLine(colors.text.heading.primary(${\n child.icon\n ? `(isUnicodeSupported ? \" ${child.icon} \" : \"\") + `\n : \"\"\n }\"${child.title} ${child.isVirtual ? \"\" : \"Command\"}\"));\n writeLine(\"\");\n writeLine(colors.text.body.secondary(splitText(\\`${formatDescription(\n child.description\n )\n .replace(/\\.+$/, \"\")\n .trim()}.\\`)));\n writeLine(\"\");\n `}\n <hbr />\n <BaseHelpDisplay command={child} indent={2} filterGlobalOptions />\n <hbr />\n </>\n )}\n </For>\n {code`help(\"Running a specific command with the help flag (via: '${getAppBin(\n context\n )} ${command.segments.join(\n \" \"\n )} <specific command> --help') will provide additional information that is specific to that command.\");\n writeLine(\"\");`}\n </Show>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAiDA,SAAM,iBAAa,OAAA;CACjB,MAAE,EACF,SACF,SAAA;CAEE,MAAA,UAAA,eAAA;CACA,MAAG,QAAU,UAAK;AAClB,QAAA,CAAA,gBAAA,KAAA;EACF,IAAO,OAAQ;AACb,UAAQ,OAAS,KAAM,QAAQ,OAAM,IAAA;;EAErC,UAAM;EACN,WAAY,QAAE,CAAA,WAAU,IAAA;;oEAEjB,IAAA,KAAA,QAAA,SAAA,SAAA,IAAA,IAAA,QAAA,SAAA,KAAA,YAAA,wBAAA,qBA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AA,GAAA,QAAA,SAAA,KAAA,IAAA,CAAA;;;;GAGG,CAAC;EAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_components_display = require('./display.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 defu = require("defu");
|
|
8
|
+
defu = require_runtime.__toESM(defu);
|
|
9
|
+
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
10
|
+
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
11
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
12
|
+
let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
|
|
13
|
+
let _powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
|
|
14
|
+
let _stryke_path = require("@stryke/path");
|
|
15
|
+
|
|
16
|
+
//#region src/components/help-builtin.tsx
|
|
17
|
+
/**
|
|
18
|
+
* The `updateVersionCheckFile` handler function declaration code for the Shell Shock project.
|
|
19
|
+
*/
|
|
20
|
+
function HelpFunctionDeclaration() {
|
|
21
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDoc, {
|
|
22
|
+
heading: "A helper function that updates the version check file.",
|
|
23
|
+
get children() {
|
|
24
|
+
return [
|
|
25
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDocRemarks, { children: `This function is used to update the version check file with the current timestamp. It can be used in the CLI upgrade command to record the last time a check for updates was performed. The function writes a "version-check.json" file in the data directory, which contains a timestamp of the last check for updates.` }),
|
|
26
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
27
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TSDocReturns, { children: `A promise that resolves to a boolean indicating whether a check for updates is required.` })
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
31
|
+
"export": true,
|
|
32
|
+
async: true,
|
|
33
|
+
name: "updateVersionCheckFile",
|
|
34
|
+
returnType: "void",
|
|
35
|
+
get children() {
|
|
36
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
37
|
+
condition: _alloy_js_core.code`!existsSync(paths.data)`,
|
|
38
|
+
children: _alloy_js_core.code`await mkdir(paths.data, { recursive: true }); `
|
|
39
|
+
}), _alloy_js_core.code`await writeFile(join(paths.data, "version-check.json"), JSON.stringify({ timestamp: new Date().getTime() }), "utf8"); `];
|
|
40
|
+
}
|
|
41
|
+
})];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A built-in help module for Shell Shock.
|
|
45
|
+
*/
|
|
46
|
+
function HelpBuiltin(props) {
|
|
47
|
+
const [{ command, children }, rest] = (0, _alloy_js_core.splitProps)(props, ["command", "children"]);
|
|
48
|
+
const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
|
|
49
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({
|
|
50
|
+
get id() {
|
|
51
|
+
return (0, _stryke_path.joinPaths)("help", ...command.segments.filter((segment) => !(0, _shell_shock_core_plugin_utils.isDynamicPathSegment)(segment)));
|
|
52
|
+
},
|
|
53
|
+
get description() {
|
|
54
|
+
return (0, _alloy_js_core_jsx_runtime.memo)(() => !!command.path)() ? `A collection of utility functions that assist in displaying help information for the ${command.title} command.` : `A collection of utility functions that assist in displaying help information for the ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} command-line interface application.`;
|
|
55
|
+
}
|
|
56
|
+
}, rest, {
|
|
57
|
+
get builtinImports() {
|
|
58
|
+
return (0, defu.default)(rest.builtinImports ?? {}, {
|
|
59
|
+
utils: ["isUnicodeSupported"],
|
|
60
|
+
console: [
|
|
61
|
+
"splitText",
|
|
62
|
+
"writeLine",
|
|
63
|
+
"colors",
|
|
64
|
+
"help",
|
|
65
|
+
"table"
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
get children() {
|
|
70
|
+
return [
|
|
71
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
72
|
+
"export": true,
|
|
73
|
+
name: "showHelp",
|
|
74
|
+
get doc() {
|
|
75
|
+
return `Display help information for the ${command.path ? `${command.title} command` : `${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} application`}.`;
|
|
76
|
+
},
|
|
77
|
+
parameters: [],
|
|
78
|
+
get children() {
|
|
79
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
80
|
+
get when() {
|
|
81
|
+
return !command.isVirtual;
|
|
82
|
+
},
|
|
83
|
+
get fallback() {
|
|
84
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_display.VirtualCommandHelpDisplay, {
|
|
85
|
+
get options() {
|
|
86
|
+
return Object.values(command.options);
|
|
87
|
+
},
|
|
88
|
+
get commands() {
|
|
89
|
+
return command.children ?? {};
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
get children() {
|
|
94
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_display.CommandHelpDisplay, { command });
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}),
|
|
99
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
100
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
101
|
+
get when() {
|
|
102
|
+
return Boolean(children);
|
|
103
|
+
},
|
|
104
|
+
children
|
|
105
|
+
})
|
|
106
|
+
];
|
|
107
|
+
}
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
//#endregion
|
|
112
|
+
exports.HelpBuiltin = HelpBuiltin;
|
|
113
|
+
exports.HelpFunctionDeclaration = HelpFunctionDeclaration;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
2
|
+
import { CommandTree } from "@shell-shock/core";
|
|
3
|
+
import { BuiltinFileProps } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
4
|
+
|
|
5
|
+
//#region src/components/help-builtin.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* The `updateVersionCheckFile` handler function declaration code for the Shell Shock project.
|
|
8
|
+
*/
|
|
9
|
+
declare function HelpFunctionDeclaration(): _alloy_js_core0.Children;
|
|
10
|
+
interface HelpBuiltinProps extends Omit<BuiltinFileProps, "id" | "description"> {
|
|
11
|
+
/**
|
|
12
|
+
* The command to generate the `help` function declaration for.
|
|
13
|
+
*/
|
|
14
|
+
command: CommandTree;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A built-in help module for Shell Shock.
|
|
18
|
+
*/
|
|
19
|
+
declare function HelpBuiltin(props: HelpBuiltinProps): _alloy_js_core0.Children;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { HelpBuiltin, HelpBuiltinProps, HelpFunctionDeclaration };
|
|
22
|
+
//# sourceMappingURL=help-builtin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help-builtin.d.cts","names":[],"sources":["../../src/components/help-builtin.tsx"],"mappings":";;;;;;;;iBA0CgB,uBAAA,CAAA,GAAuB,eAAA,CAAA,QAAA;AAAA,UA0BtB,gBAAA,SAAyB,IAAA,CACxC,gBAAA;;;;EAMA,OAAA,EAAS,WAAA;AAAA;;;;iBAMK,WAAA,CAAY,KAAA,EAAO,gBAAA,GAAgB,eAAA,CAAA,QAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as _alloy_js_core0 from "@alloy-js/core";
|
|
2
|
+
import { CommandTree } from "@shell-shock/core";
|
|
3
|
+
import { BuiltinFileProps } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
4
|
+
|
|
5
|
+
//#region src/components/help-builtin.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* The `updateVersionCheckFile` handler function declaration code for the Shell Shock project.
|
|
8
|
+
*/
|
|
9
|
+
declare function HelpFunctionDeclaration(): _alloy_js_core0.Children;
|
|
10
|
+
interface HelpBuiltinProps extends Omit<BuiltinFileProps, "id" | "description"> {
|
|
11
|
+
/**
|
|
12
|
+
* The command to generate the `help` function declaration for.
|
|
13
|
+
*/
|
|
14
|
+
command: CommandTree;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A built-in help module for Shell Shock.
|
|
18
|
+
*/
|
|
19
|
+
declare function HelpBuiltin(props: HelpBuiltinProps): _alloy_js_core0.Children;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { HelpBuiltin, HelpBuiltinProps, HelpFunctionDeclaration };
|
|
22
|
+
//# sourceMappingURL=help-builtin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help-builtin.d.mts","names":[],"sources":["../../src/components/help-builtin.tsx"],"mappings":";;;;;;;;iBA0CgB,uBAAA,CAAA,GAAuB,eAAA,CAAA,QAAA;AAAA,UA0BtB,gBAAA,SAAyB,IAAA,CACxC,gBAAA;;;;EAMA,OAAA,EAAS,WAAA;AAAA;;;;iBAMK,WAAA,CAAY,KAAA,EAAO,gBAAA,GAAgB,eAAA,CAAA,QAAA"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { CommandHelpDisplay, VirtualCommandHelpDisplay } from "./display.mjs";
|
|
2
|
+
import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import { Show, code, splitProps } from "@alloy-js/core";
|
|
4
|
+
import { getAppTitle, isDynamicPathSegment } from "@shell-shock/core/plugin-utils";
|
|
5
|
+
import defu from "defu";
|
|
6
|
+
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
7
|
+
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
8
|
+
import { FunctionDeclaration, IfStatement } from "@alloy-js/typescript";
|
|
9
|
+
import { TSDoc, TSDocRemarks, TSDocReturns } from "@powerlines/plugin-alloy/typescript";
|
|
10
|
+
import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
11
|
+
import { joinPaths } from "@stryke/path";
|
|
12
|
+
|
|
13
|
+
//#region src/components/help-builtin.tsx
|
|
14
|
+
/**
|
|
15
|
+
* The `updateVersionCheckFile` handler function declaration code for the Shell Shock project.
|
|
16
|
+
*/
|
|
17
|
+
function HelpFunctionDeclaration() {
|
|
18
|
+
return [createComponent(TSDoc, {
|
|
19
|
+
heading: "A helper function that updates the version check file.",
|
|
20
|
+
get children() {
|
|
21
|
+
return [
|
|
22
|
+
createComponent(TSDocRemarks, { children: `This function is used to update the version check file with the current timestamp. It can be used in the CLI upgrade command to record the last time a check for updates was performed. The function writes a "version-check.json" file in the data directory, which contains a timestamp of the last check for updates.` }),
|
|
23
|
+
createComponent(Spacing, {}),
|
|
24
|
+
createComponent(TSDocReturns, { children: `A promise that resolves to a boolean indicating whether a check for updates is required.` })
|
|
25
|
+
];
|
|
26
|
+
}
|
|
27
|
+
}), createComponent(FunctionDeclaration, {
|
|
28
|
+
"export": true,
|
|
29
|
+
async: true,
|
|
30
|
+
name: "updateVersionCheckFile",
|
|
31
|
+
returnType: "void",
|
|
32
|
+
get children() {
|
|
33
|
+
return [createComponent(IfStatement, {
|
|
34
|
+
condition: code`!existsSync(paths.data)`,
|
|
35
|
+
children: code`await mkdir(paths.data, { recursive: true }); `
|
|
36
|
+
}), code`await writeFile(join(paths.data, "version-check.json"), JSON.stringify({ timestamp: new Date().getTime() }), "utf8"); `];
|
|
37
|
+
}
|
|
38
|
+
})];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A built-in help module for Shell Shock.
|
|
42
|
+
*/
|
|
43
|
+
function HelpBuiltin(props) {
|
|
44
|
+
const [{ command, children }, rest] = splitProps(props, ["command", "children"]);
|
|
45
|
+
const context = usePowerlines();
|
|
46
|
+
return createComponent(BuiltinFile, mergeProps({
|
|
47
|
+
get id() {
|
|
48
|
+
return joinPaths("help", ...command.segments.filter((segment) => !isDynamicPathSegment(segment)));
|
|
49
|
+
},
|
|
50
|
+
get description() {
|
|
51
|
+
return memo(() => !!command.path)() ? `A collection of utility functions that assist in displaying help information for the ${command.title} command.` : `A collection of utility functions that assist in displaying help information for the ${getAppTitle(context, true)} command-line interface application.`;
|
|
52
|
+
}
|
|
53
|
+
}, rest, {
|
|
54
|
+
get builtinImports() {
|
|
55
|
+
return defu(rest.builtinImports ?? {}, {
|
|
56
|
+
utils: ["isUnicodeSupported"],
|
|
57
|
+
console: [
|
|
58
|
+
"splitText",
|
|
59
|
+
"writeLine",
|
|
60
|
+
"colors",
|
|
61
|
+
"help",
|
|
62
|
+
"table"
|
|
63
|
+
]
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
get children() {
|
|
67
|
+
return [
|
|
68
|
+
createComponent(FunctionDeclaration, {
|
|
69
|
+
"export": true,
|
|
70
|
+
name: "showHelp",
|
|
71
|
+
get doc() {
|
|
72
|
+
return `Display help information for the ${command.path ? `${command.title} command` : `${getAppTitle(context, true)} application`}.`;
|
|
73
|
+
},
|
|
74
|
+
parameters: [],
|
|
75
|
+
get children() {
|
|
76
|
+
return createComponent(Show, {
|
|
77
|
+
get when() {
|
|
78
|
+
return !command.isVirtual;
|
|
79
|
+
},
|
|
80
|
+
get fallback() {
|
|
81
|
+
return createComponent(VirtualCommandHelpDisplay, {
|
|
82
|
+
get options() {
|
|
83
|
+
return Object.values(command.options);
|
|
84
|
+
},
|
|
85
|
+
get commands() {
|
|
86
|
+
return command.children ?? {};
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
get children() {
|
|
91
|
+
return createComponent(CommandHelpDisplay, { command });
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}),
|
|
96
|
+
createComponent(Spacing, {}),
|
|
97
|
+
createComponent(Show, {
|
|
98
|
+
get when() {
|
|
99
|
+
return Boolean(children);
|
|
100
|
+
},
|
|
101
|
+
children
|
|
102
|
+
})
|
|
103
|
+
];
|
|
104
|
+
}
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//#endregion
|
|
109
|
+
export { HelpBuiltin, HelpFunctionDeclaration };
|
|
110
|
+
//# sourceMappingURL=help-builtin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help-builtin.mjs","names":[],"sources":["../../src/components/help-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, Show, splitProps } 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 TSDocRemarks,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript\";\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 { HelpPluginContext } from \"../types\";\nimport { CommandHelpDisplay, VirtualCommandHelpDisplay } from \"./display\";\n\n/**\n * The `updateVersionCheckFile` handler function declaration code for the Shell Shock project.\n */\nexport function HelpFunctionDeclaration() {\n return (\n <>\n <TSDoc heading=\"A helper function that updates the version check file.\">\n <TSDocRemarks>\n {`This function is used to update the version check file with the current timestamp. It can be used in the CLI upgrade command to record the last time a check for updates was performed. The function writes a \"version-check.json\" file in the data directory, which contains a timestamp of the last check for updates.`}\n </TSDocRemarks>\n <Spacing />\n <TSDocReturns>\n {`A promise that resolves to a boolean indicating whether a check for updates is required.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"updateVersionCheckFile\"\n returnType=\"void\">\n <IfStatement condition={code`!existsSync(paths.data)`}>\n {code`await mkdir(paths.data, { recursive: true }); `}\n </IfStatement>\n {code`await writeFile(join(paths.data, \"version-check.json\"), JSON.stringify({ timestamp: new Date().getTime() }), \"utf8\"); `}\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface HelpBuiltinProps extends Omit<\n BuiltinFileProps,\n \"id\" | \"description\"\n> {\n /**\n * The command to generate the `help` function declaration for.\n */\n command: CommandTree;\n}\n\n/**\n * A built-in help module for Shell Shock.\n */\nexport function HelpBuiltin(props: HelpBuiltinProps) {\n const [{ command, children }, rest] = splitProps(props, [\n \"command\",\n \"children\"\n ]);\n const context = usePowerlines<HelpPluginContext>();\n\n return (\n <BuiltinFile\n id={joinPaths(\n \"help\",\n ...command.segments.filter(segment => !isDynamicPathSegment(segment))\n )}\n description={\n command.path\n ? `A collection of utility functions that assist in displaying help information for the ${\n command.title\n } command.`\n : `A collection of utility functions that assist in displaying help information for the ${getAppTitle(\n context,\n true\n )} command-line interface application.`\n }\n {...rest}\n builtinImports={defu(rest.builtinImports ?? {}, {\n utils: [\"isUnicodeSupported\"],\n console: [\"splitText\", \"writeLine\", \"colors\", \"help\", \"table\"]\n })}>\n <FunctionDeclaration\n export\n name=\"showHelp\"\n doc={`Display help information for the ${\n command.path\n ? `${command.title} command`\n : `${getAppTitle(context, true)} application`\n }.`}\n parameters={[]}>\n <Show\n when={!command.isVirtual}\n fallback={\n <VirtualCommandHelpDisplay\n options={Object.values(command.options)}\n commands={command.children ?? {}}\n />\n }>\n <CommandHelpDisplay command={command} />\n </Show>\n </FunctionDeclaration>\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAoCA,SAAc,0BAA4B;AAC1C,QAAS,CAAA,gBAAmB,OAAC;;EAE3B,IAAA,WAAA;AACI,UAAE;IAAA,gBAAwB,cAAQ,EACtC,UAAA,4TACK,CAAA;IAAA,gBAAS,SAAA,EAAuB,CAAC;IAAE,gBAAA,cAAA,EAClC,UAAC,4FACJ,CAAA;IAAA;;EAEF,CAAC,EAAE,gBAAe,qBAAA;EACjB,UAAQ;EACR,OAAM;EACN,MAAK;EACL,YAAK;EACL,IAAI,WAAM;AACR,UAAI,CAAA,gBAAY,aAAA;IACd,WAAK,IAAA;IACN,UAAA,IAAA;IACA,CAAC,EAAA,IAAA,yHAAA;;EAEL,CAAC,CAAC;;;;;AAYL,SAAE,YAAgB,OAAA;CAChB,MAAM,CAAC,EACP,SACE,YACC,QAAI,WAAW,OAAS,CAAG,WAAQ,WAAS,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