@shell-shock/core 0.17.8 → 0.17.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.cjs +29 -1
- package/dist/api.cjs +36 -1
- package/dist/api.cjs.map +1 -0
- package/dist/api.d.cts +2 -77
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts +2 -76
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +35 -1
- package/dist/api.mjs.map +1 -1
- package/dist/components/command-validation-logic.cjs +291 -1
- package/dist/components/command-validation-logic.cjs.map +1 -0
- package/dist/components/command-validation-logic.d.cts +1 -3
- package/dist/components/command-validation-logic.d.cts.map +1 -1
- package/dist/components/command-validation-logic.d.mts +1 -3
- package/dist/components/command-validation-logic.d.mts.map +1 -1
- package/dist/components/command-validation-logic.mjs +288 -1
- package/dist/components/command-validation-logic.mjs.map +1 -1
- package/dist/components/docs.cjs +265 -1
- package/dist/components/docs.cjs.map +1 -0
- package/dist/components/docs.d.cts +4 -5
- package/dist/components/docs.d.cts.map +1 -1
- package/dist/components/docs.d.mts +4 -5
- package/dist/components/docs.d.mts.map +1 -1
- package/dist/components/docs.mjs +256 -1
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/exec-builtin.cjs +429 -15
- package/dist/components/exec-builtin.cjs.map +1 -0
- package/dist/components/exec-builtin.d.cts +1 -2
- package/dist/components/exec-builtin.d.cts.map +1 -1
- package/dist/components/exec-builtin.d.mts +1 -2
- package/dist/components/exec-builtin.d.mts.map +1 -1
- package/dist/components/exec-builtin.mjs +424 -15
- package/dist/components/exec-builtin.mjs.map +1 -1
- package/dist/components/helpers.cjs +119 -1
- package/dist/components/helpers.cjs.map +1 -0
- package/dist/components/helpers.d.cts +6 -8
- package/dist/components/helpers.d.cts.map +1 -1
- package/dist/components/helpers.d.mts +6 -8
- package/dist/components/helpers.d.mts.map +1 -1
- package/dist/components/helpers.mjs +111 -1
- package/dist/components/helpers.mjs.map +1 -1
- package/dist/components/index.cjs +58 -1
- package/dist/components/index.mjs +10 -1
- package/dist/components/options-parser-logic.cjs +959 -5
- package/dist/components/options-parser-logic.cjs.map +1 -0
- package/dist/components/options-parser-logic.d.cts +8 -9
- package/dist/components/options-parser-logic.d.cts.map +1 -1
- package/dist/components/options-parser-logic.d.mts +8 -9
- package/dist/components/options-parser-logic.d.mts.map +1 -1
- package/dist/components/options-parser-logic.mjs +944 -5
- package/dist/components/options-parser-logic.mjs.map +1 -1
- package/dist/components/state-builtin.cjs +630 -8
- package/dist/components/state-builtin.cjs.map +1 -0
- package/dist/components/state-builtin.d.cts +4 -5
- package/dist/components/state-builtin.d.cts.map +1 -1
- package/dist/components/state-builtin.d.mts +4 -5
- package/dist/components/state-builtin.d.mts.map +1 -1
- package/dist/components/state-builtin.mjs +622 -8
- package/dist/components/state-builtin.mjs.map +1 -1
- package/dist/components/usage.cjs +116 -1
- package/dist/components/usage.cjs.map +1 -0
- package/dist/components/usage.d.cts +1 -2
- package/dist/components/usage.d.cts.map +1 -1
- package/dist/components/usage.d.mts +1 -2
- package/dist/components/usage.d.mts.map +1 -1
- package/dist/components/usage.mjs +113 -1
- package/dist/components/usage.mjs.map +1 -1
- package/dist/components/utils-builtin.cjs +839 -33
- package/dist/components/utils-builtin.cjs.map +1 -0
- package/dist/components/utils-builtin.d.cts +7 -8
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts +7 -8
- package/dist/components/utils-builtin.d.mts.map +1 -1
- package/dist/components/utils-builtin.mjs +828 -33
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/config.cjs +65 -1
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +29 -8
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +29 -8
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +62 -1
- package/dist/config.mjs.map +1 -1
- package/dist/contexts/command.cjs +26 -1
- package/dist/contexts/command.cjs.map +1 -0
- package/dist/contexts/command.d.cts.map +1 -1
- package/dist/contexts/command.d.mts.map +1 -1
- package/dist/contexts/command.mjs +23 -1
- package/dist/contexts/command.mjs.map +1 -1
- package/dist/contexts/index.cjs +9 -1
- package/dist/contexts/index.mjs +4 -1
- package/dist/contexts/options.cjs +63 -1
- package/dist/contexts/options.cjs.map +1 -0
- package/dist/contexts/options.d.cts.map +1 -1
- package/dist/contexts/options.d.mts.map +1 -1
- package/dist/contexts/options.mjs +57 -1
- package/dist/contexts/options.mjs.map +1 -1
- package/dist/engine.cjs +138 -0
- package/dist/engine.cjs.map +1 -0
- package/dist/engine.d.cts +79 -0
- package/dist/engine.d.cts.map +1 -0
- package/dist/engine.d.mts +79 -0
- package/dist/engine.d.mts.map +1 -0
- package/dist/engine.mjs +136 -0
- package/dist/engine.mjs.map +1 -0
- package/dist/helpers/automd.cjs +70 -1
- package/dist/helpers/automd.cjs.map +1 -0
- package/dist/helpers/automd.mjs +69 -1
- package/dist/helpers/automd.mjs.map +1 -1
- package/dist/helpers/docs-helpers.cjs +23 -1
- package/dist/helpers/docs-helpers.cjs.map +1 -0
- package/dist/helpers/docs-helpers.mjs +22 -1
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/get-framework.cjs +24 -0
- package/dist/helpers/get-framework.cjs.map +1 -0
- package/dist/helpers/get-framework.mjs +24 -0
- package/dist/helpers/get-framework.mjs.map +1 -0
- package/dist/helpers/paths.cjs +137 -1
- package/dist/helpers/paths.cjs.map +1 -0
- package/dist/helpers/paths.mjs +133 -1
- package/dist/helpers/paths.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +113 -1
- package/dist/helpers/persistence.cjs.map +1 -0
- package/dist/helpers/persistence.mjs +112 -1
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +65 -1
- package/dist/helpers/update-package-json.cjs.map +1 -0
- package/dist/helpers/update-package-json.mjs +63 -1
- package/dist/helpers/update-package-json.mjs.map +1 -1
- package/dist/helpers/utilities.cjs +95 -1
- package/dist/helpers/utilities.cjs.map +1 -0
- package/dist/helpers/utilities.mjs +93 -1
- package/dist/helpers/utilities.mjs.map +1 -1
- package/dist/helpers/validations.cjs +71 -1
- package/dist/helpers/validations.cjs.map +1 -0
- package/dist/helpers/validations.mjs +69 -1
- package/dist/helpers/validations.mjs.map +1 -1
- package/dist/index.cjs +123 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +80 -5
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +80 -5
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +119 -1
- package/dist/index.mjs.map +1 -0
- package/dist/package.cjs +12 -0
- package/dist/package.cjs.map +1 -0
- package/dist/package.mjs +6 -0
- package/dist/package.mjs.map +1 -0
- package/dist/plugin-utils/compute-bin.cjs +48 -1
- package/dist/plugin-utils/compute-bin.cjs.map +1 -0
- package/dist/plugin-utils/compute-bin.d.cts +2 -2
- package/dist/plugin-utils/compute-bin.d.cts.map +1 -1
- package/dist/plugin-utils/compute-bin.d.mts +2 -2
- package/dist/plugin-utils/compute-bin.d.mts.map +1 -1
- package/dist/plugin-utils/compute-bin.mjs +47 -1
- package/dist/plugin-utils/compute-bin.mjs.map +1 -1
- package/dist/plugin-utils/context-helpers.cjs +224 -1
- package/dist/plugin-utils/context-helpers.cjs.map +1 -0
- package/dist/plugin-utils/context-helpers.d.cts +4 -4
- package/dist/plugin-utils/context-helpers.d.cts.map +1 -1
- package/dist/plugin-utils/context-helpers.d.mts +4 -4
- package/dist/plugin-utils/context-helpers.d.mts.map +1 -1
- package/dist/plugin-utils/context-helpers.mjs +214 -1
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/dist/plugin-utils/deepkit.cjs +70 -1
- package/dist/plugin-utils/deepkit.cjs.map +1 -0
- package/dist/plugin-utils/deepkit.d.cts +5 -5
- package/dist/plugin-utils/deepkit.d.cts.map +1 -1
- package/dist/plugin-utils/deepkit.d.mts +5 -5
- package/dist/plugin-utils/deepkit.d.mts.map +1 -1
- package/dist/plugin-utils/deepkit.mjs +68 -1
- package/dist/plugin-utils/deepkit.mjs.map +1 -1
- package/dist/plugin-utils/description-helpers.cjs +112 -2
- package/dist/plugin-utils/description-helpers.cjs.map +1 -0
- package/dist/plugin-utils/description-helpers.d.cts.map +1 -1
- package/dist/plugin-utils/description-helpers.d.mts.map +1 -1
- package/dist/plugin-utils/description-helpers.mjs +107 -2
- package/dist/plugin-utils/description-helpers.mjs.map +1 -1
- package/dist/plugin-utils/get-command-tree.cjs +118 -1
- package/dist/plugin-utils/get-command-tree.cjs.map +1 -0
- package/dist/plugin-utils/get-command-tree.d.cts.map +1 -1
- package/dist/plugin-utils/get-command-tree.d.mts.map +1 -1
- package/dist/plugin-utils/get-command-tree.mjs +114 -1
- package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/index.cjs +39 -1
- package/dist/plugin-utils/index.d.cts +2 -2
- package/dist/plugin-utils/index.d.mts +2 -2
- package/dist/plugin-utils/index.mjs +10 -1
- package/dist/plugin-utils/reflect.cjs +52 -1
- package/dist/plugin-utils/reflect.cjs.map +1 -0
- package/dist/plugin-utils/reflect.d.cts.map +1 -1
- package/dist/plugin-utils/reflect.d.mts.map +1 -1
- package/dist/plugin-utils/reflect.mjs +50 -1
- package/dist/plugin-utils/reflect.mjs.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.cjs +65 -1
- package/dist/plugin-utils/traverse-command-tree.cjs.map +1 -0
- package/dist/plugin-utils/traverse-command-tree.d.cts.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.d.mts.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.mjs +62 -1
- package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/type-checks.cjs +222 -1
- package/dist/plugin-utils/type-checks.cjs.map +1 -0
- package/dist/plugin-utils/type-checks.d.cts +5 -5
- package/dist/plugin-utils/type-checks.d.cts.map +1 -1
- package/dist/plugin-utils/type-checks.d.mts +5 -5
- package/dist/plugin-utils/type-checks.d.mts.map +1 -1
- package/dist/plugin-utils/type-checks.mjs +217 -1
- package/dist/plugin-utils/type-checks.mjs.map +1 -1
- package/dist/plugin.cjs +495 -4
- package/dist/plugin.cjs.map +1 -0
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +488 -4
- package/dist/plugin.mjs.map +1 -1
- package/dist/resolver/helpers.cjs +182 -1
- package/dist/resolver/helpers.cjs.map +1 -0
- package/dist/resolver/helpers.mjs +178 -1
- package/dist/resolver/helpers.mjs.map +1 -1
- package/dist/resolver/resolve.cjs +479 -1
- package/dist/resolver/resolve.cjs.map +1 -0
- package/dist/resolver/resolve.mjs +478 -1
- package/dist/resolver/resolve.mjs.map +1 -1
- package/dist/types/command.cjs +402 -1
- package/dist/types/command.cjs.map +1 -0
- package/dist/types/command.d.cts +61 -119
- package/dist/types/command.d.cts.map +1 -1
- package/dist/types/command.d.mts +61 -119
- package/dist/types/command.d.mts.map +1 -1
- package/dist/types/command.mjs +367 -1
- package/dist/types/command.mjs.map +1 -1
- package/dist/types/config.cjs +175 -1
- package/dist/types/config.cjs.map +1 -0
- package/dist/types/config.d.cts +19 -12
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +19 -12
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +163 -1
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/context.cjs +45 -1
- package/dist/types/context.cjs.map +1 -0
- package/dist/types/context.d.cts +3 -2
- package/dist/types/context.d.cts.map +1 -1
- package/dist/types/context.d.mts +3 -2
- package/dist/types/context.d.mts.map +1 -1
- package/dist/types/context.mjs +40 -1
- package/dist/types/context.mjs.map +1 -1
- package/dist/types/env.cjs +53 -1
- package/dist/types/env.cjs.map +1 -0
- package/dist/types/env.d.cts +1 -1
- package/dist/types/env.d.cts.map +1 -1
- package/dist/types/env.d.mts +1 -1
- package/dist/types/env.d.mts.map +1 -1
- package/dist/types/env.mjs +50 -1
- package/dist/types/env.mjs.map +1 -1
- package/dist/types/index.cjs +53 -1
- package/dist/types/index.d.cts +4 -4
- package/dist/types/index.d.mts +4 -4
- package/dist/types/index.mjs +6 -1
- package/dist/types/options.cjs +13 -1
- package/dist/types/options.cjs.map +1 -0
- package/dist/types/options.d.cts.map +1 -1
- package/dist/types/options.d.mts.map +1 -1
- package/dist/types/options.mjs +10 -1
- package/dist/types/options.mjs.map +1 -1
- package/package.json +43 -34
- package/dist/resolver/deepkit.cjs +0 -1
- package/dist/resolver/deepkit.mjs +0 -2
- package/dist/resolver/deepkit.mjs.map +0 -1
- package/dist/resolver/module.cjs +0 -1
- package/dist/resolver/module.mjs +0 -2
- package/dist/resolver/module.mjs.map +0 -1
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { CommandTree } from "../types/command.mjs";
|
|
2
|
-
import * as _$_alloy_js_core0 from "@alloy-js/core";
|
|
3
|
-
|
|
4
2
|
//#region src/components/command-validation-logic.d.ts
|
|
5
3
|
interface CommandValidationLogicProps {
|
|
6
4
|
command: CommandTree;
|
|
@@ -8,7 +6,7 @@ interface CommandValidationLogicProps {
|
|
|
8
6
|
/**
|
|
9
7
|
* A component that generates command validation logic for required options and arguments.
|
|
10
8
|
*/
|
|
11
|
-
declare function CommandValidationLogic(props: CommandValidationLogicProps):
|
|
9
|
+
declare function CommandValidationLogic(props: CommandValidationLogicProps): import("@alloy-js/core").Children;
|
|
12
10
|
//#endregion
|
|
13
11
|
export { CommandValidationLogic, CommandValidationLogicProps };
|
|
14
12
|
//# sourceMappingURL=command-validation-logic.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-validation-logic.d.mts","names":[],"sources":["../../src/components/command-validation-logic.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"command-validation-logic.d.mts","names":[],"sources":["../../src/components/command-validation-logic.tsx"],"mappings":""}
|
|
@@ -1,2 +1,289 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { createComponent, createIntrinsic } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { For, Show, code } from "@alloy-js/core";
|
|
3
|
+
import { camelCase } from "@stryke/string-format/camel-case";
|
|
4
|
+
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
5
|
+
import { ElseIfClause, IfStatement, VarDeclaration } from "@alloy-js/typescript";
|
|
6
|
+
import { list } from "@stryke/string-format/list";
|
|
7
|
+
|
|
8
|
+
//#region src/components/command-validation-logic.tsx
|
|
9
|
+
function __assignType(fn, args) {
|
|
10
|
+
fn.__type = args;
|
|
11
|
+
return fn;
|
|
12
|
+
}
|
|
13
|
+
const __ΩCommandValidationLogicProps = [
|
|
14
|
+
"CommandTree",
|
|
15
|
+
"command",
|
|
16
|
+
"CommandValidationLogicProps",
|
|
17
|
+
"P\"w!4\"Mw#y"
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* A component that generates command validation logic for required options and arguments.
|
|
21
|
+
*/
|
|
22
|
+
function CommandValidationLogic(props) {
|
|
23
|
+
const { command } = props;
|
|
24
|
+
return [
|
|
25
|
+
createComponent(VarDeclaration, {
|
|
26
|
+
name: "failures",
|
|
27
|
+
type: "string[]",
|
|
28
|
+
initializer: code`[];`
|
|
29
|
+
}),
|
|
30
|
+
createIntrinsic("hbr", {}),
|
|
31
|
+
createComponent(For, {
|
|
32
|
+
get each() {
|
|
33
|
+
return Object.values(command.options ?? {});
|
|
34
|
+
},
|
|
35
|
+
doubleHardline: true,
|
|
36
|
+
get children() {
|
|
37
|
+
return __assignType((option) => [
|
|
38
|
+
createComponent(Show, {
|
|
39
|
+
get when() {
|
|
40
|
+
return option.required;
|
|
41
|
+
},
|
|
42
|
+
get children() {
|
|
43
|
+
return [createComponent(IfStatement, {
|
|
44
|
+
get condition() {
|
|
45
|
+
return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}`;
|
|
46
|
+
},
|
|
47
|
+
get children() {
|
|
48
|
+
return code`failures.push("Missing required \\"${option.name}\\" option");`;
|
|
49
|
+
}
|
|
50
|
+
}), createComponent(Show, {
|
|
51
|
+
get when() {
|
|
52
|
+
return option.variadic;
|
|
53
|
+
},
|
|
54
|
+
get children() {
|
|
55
|
+
return createComponent(ElseIfClause, {
|
|
56
|
+
get condition() {
|
|
57
|
+
return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.length === 0`;
|
|
58
|
+
},
|
|
59
|
+
get children() {
|
|
60
|
+
return code`failures.push("No values were provided to the required \\"${option.name}\\" array option");`;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
})];
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
createComponent(Show, {
|
|
68
|
+
get when() {
|
|
69
|
+
return option.type === "number";
|
|
70
|
+
},
|
|
71
|
+
get children() {
|
|
72
|
+
return createComponent(Show, {
|
|
73
|
+
get when() {
|
|
74
|
+
return option.variadic;
|
|
75
|
+
},
|
|
76
|
+
get fallback() {
|
|
77
|
+
return createComponent(IfStatement, {
|
|
78
|
+
get condition() {
|
|
79
|
+
return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`} && Number.isNaN(options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`})`;
|
|
80
|
+
},
|
|
81
|
+
get children() {
|
|
82
|
+
return code`failures.push("Invalid numeric value provided for the \\"${option.name}\\" option");`;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
get children() {
|
|
87
|
+
return createComponent(IfStatement, {
|
|
88
|
+
get condition() {
|
|
89
|
+
return code`options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.some(value => Number.isNaN(value))`;
|
|
90
|
+
},
|
|
91
|
+
get children() {
|
|
92
|
+
return code`failures.push("Invalid numeric value provided in the \\"${option.name}\\" array option");`;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}),
|
|
99
|
+
createComponent(Show, {
|
|
100
|
+
get when() {
|
|
101
|
+
return (option.type === "string" || option.type === "number") && option.choices && option.choices.length > 0;
|
|
102
|
+
},
|
|
103
|
+
get children() {
|
|
104
|
+
return createComponent(Show, {
|
|
105
|
+
get when() {
|
|
106
|
+
return !option.variadic;
|
|
107
|
+
},
|
|
108
|
+
get fallback() {
|
|
109
|
+
return createComponent(Show, {
|
|
110
|
+
get when() {
|
|
111
|
+
return option.required;
|
|
112
|
+
},
|
|
113
|
+
get fallback() {
|
|
114
|
+
return createComponent(IfStatement, {
|
|
115
|
+
get condition() {
|
|
116
|
+
return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.every(value => [${option.choices?.map(__assignType((choice) => option.type === "string" ? `"${choice}"` : choice, [
|
|
117
|
+
"choice",
|
|
118
|
+
"",
|
|
119
|
+
"P\"2!\"/\""
|
|
120
|
+
])).join(", ")}].includes(value))`;
|
|
121
|
+
},
|
|
122
|
+
get children() {
|
|
123
|
+
return code`failures.push(\`Invalid value provided for the \\"${option.name}\\" option - valid values include: ${list(option?.choices?.map(__assignType((choice) => String(choice), [
|
|
124
|
+
"choice",
|
|
125
|
+
"",
|
|
126
|
+
"P\"2!\"/\""
|
|
127
|
+
])) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}}\`);`;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
get children() {
|
|
132
|
+
return createComponent(ElseIfClause, {
|
|
133
|
+
get condition() {
|
|
134
|
+
return code`!options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}.every(value => [${option.choices?.map(__assignType((choice) => option.type === "string" ? `"${choice}"` : choice, [
|
|
135
|
+
"choice",
|
|
136
|
+
"",
|
|
137
|
+
"P\"2!\"/\""
|
|
138
|
+
])).join(", ")}].includes(value))`;
|
|
139
|
+
},
|
|
140
|
+
get children() {
|
|
141
|
+
return code`failures.push(\`Invalid value provided for the \\"${option.name}\\" option - valid values include: ${list(option?.choices?.map(__assignType((choice) => String(choice), [
|
|
142
|
+
"choice",
|
|
143
|
+
"",
|
|
144
|
+
"P\"2!\"/\""
|
|
145
|
+
])) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}}\`);`;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
},
|
|
151
|
+
get children() {
|
|
152
|
+
return createComponent(Show, {
|
|
153
|
+
get when() {
|
|
154
|
+
return option.required;
|
|
155
|
+
},
|
|
156
|
+
get fallback() {
|
|
157
|
+
return createComponent(IfStatement, {
|
|
158
|
+
get condition() {
|
|
159
|
+
return code`![${option.choices?.map(__assignType((choice) => option.type === "string" ? `"${choice}"` : choice, [
|
|
160
|
+
"choice",
|
|
161
|
+
"",
|
|
162
|
+
"P\"2!\"/\""
|
|
163
|
+
])).join(", ")}].includes(options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`})`;
|
|
164
|
+
},
|
|
165
|
+
get children() {
|
|
166
|
+
return code`failures.push(\`Invalid value provided for the \\"${option.name}\\" option - valid values include: ${list(option?.choices?.map(__assignType((choice) => String(choice), [
|
|
167
|
+
"choice",
|
|
168
|
+
"",
|
|
169
|
+
"P\"2!\"/\""
|
|
170
|
+
])) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}}\`);`;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
},
|
|
174
|
+
get children() {
|
|
175
|
+
return createComponent(ElseIfClause, {
|
|
176
|
+
get condition() {
|
|
177
|
+
return code`![${option.choices?.map(__assignType((choice) => option.type === "string" ? `"${choice}"` : choice, [
|
|
178
|
+
"choice",
|
|
179
|
+
"",
|
|
180
|
+
"P\"2!\"/\""
|
|
181
|
+
])).join(", ")}].includes(options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`})`;
|
|
182
|
+
},
|
|
183
|
+
get children() {
|
|
184
|
+
return code`failures.push(\`Invalid value provided for the \\"${option.name}\\" option - valid values include: ${list(option?.choices?.map(__assignType((choice) => String(choice), [
|
|
185
|
+
"choice",
|
|
186
|
+
"",
|
|
187
|
+
"P\"2!\"/\""
|
|
188
|
+
])) ?? [])}; provided: \${options${option.name.includes("?") ? `["${option.name}"]` : `.${camelCase(option.name)}`}}\`);`;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
], [
|
|
198
|
+
"option",
|
|
199
|
+
"",
|
|
200
|
+
"P\"2!\"/\""
|
|
201
|
+
]);
|
|
202
|
+
}
|
|
203
|
+
}),
|
|
204
|
+
createComponent(Spacing, {}),
|
|
205
|
+
createComponent(For, {
|
|
206
|
+
get each() {
|
|
207
|
+
return command.args;
|
|
208
|
+
},
|
|
209
|
+
doubleHardline: true,
|
|
210
|
+
get children() {
|
|
211
|
+
return __assignType((argument) => [createComponent(Show, {
|
|
212
|
+
get when() {
|
|
213
|
+
return argument.required;
|
|
214
|
+
},
|
|
215
|
+
get children() {
|
|
216
|
+
return [createComponent(IfStatement, {
|
|
217
|
+
get condition() {
|
|
218
|
+
return code`!${camelCase(argument.name)}`;
|
|
219
|
+
},
|
|
220
|
+
get children() {
|
|
221
|
+
return code`failures.push("Missing required \\"${argument.name}\\" positional argument");`;
|
|
222
|
+
}
|
|
223
|
+
}), createComponent(Show, {
|
|
224
|
+
get when() {
|
|
225
|
+
return argument.variadic;
|
|
226
|
+
},
|
|
227
|
+
get children() {
|
|
228
|
+
return createComponent(ElseIfClause, {
|
|
229
|
+
get condition() {
|
|
230
|
+
return code`${camelCase(argument.name)}.length === 0`;
|
|
231
|
+
},
|
|
232
|
+
get children() {
|
|
233
|
+
return code`failures.push("No values were provided to the required \\"${argument.name}\\" array positional argument");`;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
})];
|
|
238
|
+
}
|
|
239
|
+
}), createComponent(Show, {
|
|
240
|
+
get when() {
|
|
241
|
+
return argument.type === "number";
|
|
242
|
+
},
|
|
243
|
+
get children() {
|
|
244
|
+
return createComponent(Show, {
|
|
245
|
+
get when() {
|
|
246
|
+
return argument.variadic;
|
|
247
|
+
},
|
|
248
|
+
get fallback() {
|
|
249
|
+
return createComponent(IfStatement, {
|
|
250
|
+
get condition() {
|
|
251
|
+
return code`${camelCase(argument.name)} && Number.isNaN(${camelCase(argument.name)})`;
|
|
252
|
+
},
|
|
253
|
+
get children() {
|
|
254
|
+
return code`failures.push("Invalid numeric value provided for the \\"${argument.name}\\" positional argument");`;
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
},
|
|
258
|
+
get children() {
|
|
259
|
+
return createComponent(IfStatement, {
|
|
260
|
+
get condition() {
|
|
261
|
+
return code`${camelCase(argument.name)}.some(value => Number.isNaN(value))`;
|
|
262
|
+
},
|
|
263
|
+
get children() {
|
|
264
|
+
return code`failures.push("Invalid numeric value provided in the \\"${argument.name}\\" array positional argument");`;
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
})], [
|
|
271
|
+
"argument",
|
|
272
|
+
"",
|
|
273
|
+
"P\"2!\"/\""
|
|
274
|
+
]);
|
|
275
|
+
}
|
|
276
|
+
})
|
|
277
|
+
];
|
|
278
|
+
}
|
|
279
|
+
CommandValidationLogic.__type = [
|
|
280
|
+
() => __ΩCommandValidationLogicProps,
|
|
281
|
+
"props",
|
|
282
|
+
"CommandValidationLogic",
|
|
283
|
+
"A component that generates command validation logic for required options and arguments.",
|
|
284
|
+
"Pn!2\"\"/#?$"
|
|
285
|
+
];
|
|
286
|
+
|
|
287
|
+
//#endregion
|
|
288
|
+
export { CommandValidationLogic, __ΩCommandValidationLogicProps };
|
|
2
289
|
//# sourceMappingURL=command-validation-logic.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-validation-logic.mjs","names":[],"sources":["../../src/components/command-validation-logic.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, Show } from \"@alloy-js/core\";\nimport {\n ElseIfClause,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { list } from \"@stryke/string-format/list\";\nimport type {\n CommandTree,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\n\nexport interface CommandValidationLogicProps {\n command: CommandTree;\n}\n\n/**\n * A component that generates command validation logic for required options and arguments.\n */\nexport function CommandValidationLogic(props: CommandValidationLogicProps) {\n const { command } = props;\n\n return (\n <>\n <VarDeclaration name=\"failures\" type=\"string[]\" initializer={code`[];`} />\n <hbr />\n <For each={Object.values(command.options ?? {})} doubleHardline>\n {option => (\n <>\n <Show when={!option.optional}>\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }`}>\n {code`failures.push(\"Missing required \\\\\"${option.name}\\\\\" option\");`}\n </IfStatement>\n <Show when={option.variadic}>\n <ElseIfClause\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.length === 0`}>\n {code`failures.push(\"No values were provided to the required \\\\\"${\n option.name\n }\\\\\" array option\");`}\n </ElseIfClause>\n </Show>\n </Show>\n <Show when={option.kind === CommandParameterKinds.number}>\n <Show\n when={option.variadic}\n fallback={\n <IfStatement\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n } && Number.isNaN(options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n })`}>\n {code`failures.push(\"Invalid numeric value provided for the \\\\\"${\n option.name\n }\\\\\" option\");`}\n </IfStatement>\n }>\n <IfStatement\n condition={code`options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.some(value => Number.isNaN(value))`}>\n {code`failures.push(\"Invalid numeric value provided in the \\\\\"${\n option.name\n }\\\\\" array option\");`}\n </IfStatement>\n </Show>\n </Show>\n <Show\n when={\n (option.kind === CommandParameterKinds.string ||\n option.kind === CommandParameterKinds.number) &&\n option.choices &&\n option.choices.length > 0\n }>\n <Show\n when={!option.variadic}\n fallback={\n <Show\n when={!option.optional}\n fallback={\n <IfStatement\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.every(value => [${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(value))`}>\n {code`failures.push(\\`Invalid value provided for the \\\\\"${\n option.name\n }\\\\\" option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`!options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }.every(value => [${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(value))`}>\n {code`failures.push(\\`Invalid value provided for the \\\\\"${\n option.name\n }\\\\\" option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </ElseIfClause>\n </Show>\n }>\n <Show\n when={!option.optional}\n fallback={\n <IfStatement\n condition={code`![${(\n option as\n | StringCommandParameter\n | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n })`}>\n {code`failures.push(\\`Invalid value provided for the \\\\\"${\n option.name\n }\\\\\" option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`![${(\n option as StringCommandParameter | NumberCommandParameter\n ).choices\n ?.map(choice =>\n option.kind === CommandParameterKinds.string\n ? `\"${choice}\"`\n : choice\n )\n .join(\", \")}].includes(options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n })`}>\n {code`failures.push(\\`Invalid value provided for the \\\\\"${\n option.name\n }\\\\\" option - valid values include: ${list(\n (\n option as\n | StringCommandParameter\n | NumberCommandParameter\n )?.choices?.map(choice => String(choice)) ?? []\n )}; provided: \\${options${\n option.name.includes(\"?\")\n ? `[\"${option.name}\"]`\n : `.${camelCase(option.name)}`\n }}\\`);`}\n </ElseIfClause>\n </Show>\n </Show>\n </Show>\n </>\n )}\n </For>\n <Spacing />\n <For each={command.args} doubleHardline>\n {argument => (\n <>\n <Show when={!argument.optional}>\n <IfStatement condition={code`!${camelCase(argument.name)}`}>\n {code`failures.push(\"Missing required \\\\\"${\n argument.name\n }\\\\\" positional argument\");`}\n </IfStatement>\n <Show when={argument.variadic}>\n <ElseIfClause\n condition={code`${camelCase(argument.name)}.length === 0`}>\n {code`failures.push(\"No values were provided to the required \\\\\"${\n argument.name\n }\\\\\" array positional argument\");`}\n </ElseIfClause>\n </Show>\n </Show>\n <Show when={argument.kind === CommandParameterKinds.number}>\n <Show\n when={(argument as NumberCommandParameter).variadic}\n fallback={\n <IfStatement\n condition={code`${camelCase(\n argument.name\n )} && Number.isNaN(${camelCase(argument.name)})`}>\n {code`failures.push(\"Invalid numeric value provided for the \\\\\"${\n argument.name\n }\\\\\" positional argument\");`}\n </IfStatement>\n }>\n <IfStatement\n condition={code`${camelCase(argument.name)}.some(value => Number.isNaN(value))`}>\n {code`failures.push(\"Invalid numeric value provided in the \\\\\"${\n argument.name\n }\\\\\" array positional argument\");`}\n </IfStatement>\n </Show>\n </Show>\n </>\n )}\n </For>\n </>\n );\n}\n"],"mappings":"ifAEE,GAAG,OAAS,IA0Bd,MAAE,EAAW,CAAA,cAAA,UAAA,8BAAA,aAAA,eAMb,GAAO,CACL,WACF,cAEE,KAAA,WACE,KAAC,WACH,YAAA,CAAA,MACF,CAAA,CAAM,EAAU,MAAA,EAAA,CAAA,CAAA,EAA8B,EAAA,CAC5C,IAAM,MAAE,sCAGN,eAAC,GACD,IAAG,UAAA,CACD,OAAM,EAAA,GAAA,CAAA,EAAA,EAAA,CACL,IAAI,MAAM,CACR,MAAQ,CAAC,EAAC,UAEX,IAAI,UAAW,CACb,MAAK,CAAA,EAAA,EAAA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EAAA,CACN,IAAI,WAAQ,CACV,MAAM,EAAA,GAAO,EAAS,EAAA,KAAA,CAAA,mBAAsB,EAAA,EAAA,KAAA,CAAA,IAE9C,IAAI,UAAQ,CACV,MAAI,EAAA,4DAAA,EAAA,KAAA,6BAEP,CAAC,EAEJ,IAAI,UAAW,CACb,OAAO,EAAG,EAAA,CACR,IAAI,WAAM,CACR,MAAI,EAAO,GAAA,EAAA,EAAA,KAAA,CAAA,sCAEb,IAAI,UAAE,CACJ,MAAM,EAAA,2DAAO,EAAA,KAAA,mCAEhB,CAAC,EAEL,CAAC,EAEL,CAAC,CAAC,CAAE,CAAC,WAAY,GAAI,UAAU,CAAA,EAEnC,CAAC,CAAC,CAEL,EAAsB,OAAA,KAAA,EAAA,QAAA,yBAAA,0FAAA,aAAA"}
|
|
1
|
+
{"version":3,"file":"command-validation-logic.mjs","names":[],"sources":[],"mappings":""}
|
package/dist/components/docs.cjs
CHANGED
|
@@ -1 +1,265 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_contexts_command = require('../contexts/command.cjs');
|
|
3
|
+
const require_docs_helpers = require('../helpers/docs-helpers.cjs');
|
|
4
|
+
const require_context_helpers = require('../plugin-utils/context-helpers.cjs');
|
|
5
|
+
const require_reflect = require('../plugin-utils/reflect.cjs');
|
|
6
|
+
const require_components_usage = require('./usage.cjs');
|
|
7
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
8
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
9
|
+
let defu = require("defu");
|
|
10
|
+
let _alloy_js_markdown = require("@alloy-js/markdown");
|
|
11
|
+
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
12
|
+
let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
13
|
+
let _powerlines_plugin_alloy_markdown_components_markdown_file = require("@powerlines/plugin-alloy/markdown/components/markdown-file");
|
|
14
|
+
let _powerlines_plugin_alloy_markdown_components_markdown_table = require("@powerlines/plugin-alloy/markdown/components/markdown-table");
|
|
15
|
+
let _stryke_path_join = require("@stryke/path/join");
|
|
16
|
+
|
|
17
|
+
//#region src/components/docs.tsx
|
|
18
|
+
const __ΩRequired = [
|
|
19
|
+
"T",
|
|
20
|
+
"Required",
|
|
21
|
+
"l+e#!e\"!fRb!Pde\"!gN##w\"y"
|
|
22
|
+
];
|
|
23
|
+
const __ΩPartial = [
|
|
24
|
+
"T",
|
|
25
|
+
"Partial",
|
|
26
|
+
"l+e#!e\"!fRb!Pde\"!gN#\"w\"y"
|
|
27
|
+
];
|
|
28
|
+
function __assignType(fn, args) {
|
|
29
|
+
fn.__type = args;
|
|
30
|
+
return fn;
|
|
31
|
+
}
|
|
32
|
+
const __ΩCommandOptionsDocsProps = [
|
|
33
|
+
"CommandTree",
|
|
34
|
+
"command",
|
|
35
|
+
"The command to generate options documentation for.",
|
|
36
|
+
"CommandOptionsDocsProps",
|
|
37
|
+
"P\"w!4\"?#Mw$y"
|
|
38
|
+
];
|
|
39
|
+
/**
|
|
40
|
+
* Generates the options markdown documentation for a command.
|
|
41
|
+
*/
|
|
42
|
+
function CommandOptionsDocs(props) {
|
|
43
|
+
const { command } = props;
|
|
44
|
+
if (Object.keys(command.options).length === 0) return _alloy_js_core.code`This command does not have any options.`;
|
|
45
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_markdown_components_markdown_table.MarkdownTable, { get data() {
|
|
46
|
+
return require_reflect.sortOptions(Object.values(command.options)).map(__assignType((option) => {
|
|
47
|
+
return {
|
|
48
|
+
name: option.name.trim(),
|
|
49
|
+
description: option.description.trim(),
|
|
50
|
+
defaultValue: option.default ? String(option.default)?.includes("\"") ? option.default : `\`${Array.isArray(option.default) ? option.default.join(", ") : option.default}\`` : "",
|
|
51
|
+
required: !option.required || option.default ? "" : "✔"
|
|
52
|
+
};
|
|
53
|
+
}, [
|
|
54
|
+
"option",
|
|
55
|
+
"",
|
|
56
|
+
"P\"2!\"/\""
|
|
57
|
+
]));
|
|
58
|
+
} });
|
|
59
|
+
}
|
|
60
|
+
CommandOptionsDocs.__type = [
|
|
61
|
+
() => __ΩCommandOptionsDocsProps,
|
|
62
|
+
"props",
|
|
63
|
+
"CommandOptionsDocs",
|
|
64
|
+
"Generates the options markdown documentation for a command.",
|
|
65
|
+
"Pn!2\"\"/#?$"
|
|
66
|
+
];
|
|
67
|
+
const __ΩCommandDocsUsageExampleProps = [
|
|
68
|
+
"npm",
|
|
69
|
+
"yarn",
|
|
70
|
+
"pnpm",
|
|
71
|
+
"bun",
|
|
72
|
+
"packageManager",
|
|
73
|
+
"npm",
|
|
74
|
+
"The package manager to generate the usage example for.",
|
|
75
|
+
"CommandTree",
|
|
76
|
+
"command",
|
|
77
|
+
"The command to generate the usage example for.",
|
|
78
|
+
"CommandDocsUsageExampleProps",
|
|
79
|
+
"PP.!.\".#.$J4%8>&?'\"w(4)?*Mw+y"
|
|
80
|
+
];
|
|
81
|
+
/**
|
|
82
|
+
* Generates the markdown documentation for a command.
|
|
83
|
+
*/
|
|
84
|
+
function CommandDocsUsageExample(props) {
|
|
85
|
+
const { packageManager = "npm", command } = props;
|
|
86
|
+
const context = (_powerlines_plugin_alloy_core_contexts_context.usePowerlines.Ω = [["Context", "\"w!"]], (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)());
|
|
87
|
+
return [
|
|
88
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
89
|
+
_alloy_js_core.code`\`\`\`bash `,
|
|
90
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
91
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(require_components_usage.Usage, {
|
|
92
|
+
command,
|
|
93
|
+
get bin() {
|
|
94
|
+
return require_context_helpers.getAppBin(context);
|
|
95
|
+
},
|
|
96
|
+
packageManager
|
|
97
|
+
}),
|
|
98
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
99
|
+
_alloy_js_core.code`\`\`\``,
|
|
100
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
CommandDocsUsageExample.__type = [
|
|
104
|
+
() => __ΩCommandDocsUsageExampleProps,
|
|
105
|
+
"props",
|
|
106
|
+
"CommandDocsUsageExample",
|
|
107
|
+
"Generates the markdown documentation for a command.",
|
|
108
|
+
"Pn!2\"\"/#?$"
|
|
109
|
+
];
|
|
110
|
+
const __ΩCommandDocsProps = [
|
|
111
|
+
"levelOffset",
|
|
112
|
+
0,
|
|
113
|
+
"The heading level offset to apply to the generated documentation.",
|
|
114
|
+
"CommandTree",
|
|
115
|
+
"command",
|
|
116
|
+
"The command to generate options documentation for.",
|
|
117
|
+
() => __ΩRequired,
|
|
118
|
+
() => __ΩCommandDocsUsageExampleProps,
|
|
119
|
+
"packageManager",
|
|
120
|
+
"usageExamples",
|
|
121
|
+
"`[\"npm\"]`",
|
|
122
|
+
"Optional usage examples to include in the documentation.",
|
|
123
|
+
"CommandDocsProps",
|
|
124
|
+
"P'4!8>\"?#\"w$4%?&n(o'\".)fF4*8>+?,Mw-y"
|
|
125
|
+
];
|
|
126
|
+
/**
|
|
127
|
+
* Generates the markdown documentation for a command.
|
|
128
|
+
*/
|
|
129
|
+
function CommandDocs(props) {
|
|
130
|
+
const { levelOffset = 0, command, usageExamples } = props;
|
|
131
|
+
return [
|
|
132
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_markdown.Heading, {
|
|
133
|
+
level: 1 + levelOffset,
|
|
134
|
+
get children() {
|
|
135
|
+
return command.title;
|
|
136
|
+
}
|
|
137
|
+
}),
|
|
138
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
139
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`${command.description}`),
|
|
140
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
141
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_markdown.Heading, {
|
|
142
|
+
level: 2 + levelOffset,
|
|
143
|
+
children: "Usage"
|
|
144
|
+
}),
|
|
145
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
146
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`The ${command.name} command can be executed using the following syntax: `),
|
|
147
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
148
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
149
|
+
get when() {
|
|
150
|
+
return usageExamples && usageExamples.length > 0;
|
|
151
|
+
},
|
|
152
|
+
get fallback() {
|
|
153
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(CommandDocsUsageExample, {
|
|
154
|
+
packageManager: "npm",
|
|
155
|
+
command
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
get children() {
|
|
159
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
160
|
+
each: usageExamples,
|
|
161
|
+
hardline: true,
|
|
162
|
+
get children() {
|
|
163
|
+
return __assignType((packageManager) => (0, _alloy_js_core_jsx_runtime.createComponent)(CommandDocsUsageExample, {
|
|
164
|
+
packageManager,
|
|
165
|
+
command
|
|
166
|
+
}), [
|
|
167
|
+
"packageManager",
|
|
168
|
+
"",
|
|
169
|
+
"P\"2!\"/\""
|
|
170
|
+
]);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}),
|
|
175
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
176
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_markdown.Heading, {
|
|
177
|
+
level: 2 + levelOffset,
|
|
178
|
+
children: "Options"
|
|
179
|
+
}),
|
|
180
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
181
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`The following options are available for the ${command.name} command:`),
|
|
182
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
183
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(CommandOptionsDocs, { command }),
|
|
184
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
|
|
185
|
+
];
|
|
186
|
+
}
|
|
187
|
+
CommandDocs.__type = [
|
|
188
|
+
() => __ΩCommandDocsProps,
|
|
189
|
+
"props",
|
|
190
|
+
"CommandDocs",
|
|
191
|
+
"Generates the markdown documentation for a command.",
|
|
192
|
+
"Pn!2\"\"/#?$"
|
|
193
|
+
];
|
|
194
|
+
const __ΩCommandDocsFileProps = [
|
|
195
|
+
() => __ΩPartial,
|
|
196
|
+
"levelOffset",
|
|
197
|
+
0,
|
|
198
|
+
"The heading level offset to apply to the generated documentation.",
|
|
199
|
+
"CommandTree",
|
|
200
|
+
"command",
|
|
201
|
+
"The command to generate documentation for.",
|
|
202
|
+
"CommandDocsFileProps",
|
|
203
|
+
"P!o!\"'4\"8>#?$\"w%4&?'Mw(y"
|
|
204
|
+
];
|
|
205
|
+
/**
|
|
206
|
+
* Generates the markdown documentation file for a command.
|
|
207
|
+
*/
|
|
208
|
+
function CommandDocsFile(props) {
|
|
209
|
+
const { levelOffset = 0, command, frontMatter, ...rest } = props;
|
|
210
|
+
const context = (_powerlines_plugin_alloy_core_contexts_context.usePowerlines.Ω = [["Context", "\"w!"]], (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)());
|
|
211
|
+
const usageExamples = (0, _alloy_js_core.memo)(() => [
|
|
212
|
+
"npm",
|
|
213
|
+
"yarn",
|
|
214
|
+
"pnpm",
|
|
215
|
+
"bun"
|
|
216
|
+
]);
|
|
217
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(require_contexts_command.CommandContext.Provider, {
|
|
218
|
+
value: command,
|
|
219
|
+
get children() {
|
|
220
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_markdown_components_markdown_file.MarkdownFile, (0, _alloy_js_core_jsx_runtime.mergeProps)({ get path() {
|
|
221
|
+
return (0, _stryke_path_join.joinPaths)(require_docs_helpers.getDocsOutputPath(context), `${command.path}.md`);
|
|
222
|
+
} }, rest, {
|
|
223
|
+
get frontMatter() {
|
|
224
|
+
return (0, defu.defu)(frontMatter ?? {}, {
|
|
225
|
+
id: command.id,
|
|
226
|
+
name: command.name,
|
|
227
|
+
path: command.path,
|
|
228
|
+
reference: command.docs,
|
|
229
|
+
virtual: command.virtual,
|
|
230
|
+
title: command.title,
|
|
231
|
+
description: command.description,
|
|
232
|
+
tags: command.tags
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
get children() {
|
|
236
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(CommandDocs, {
|
|
237
|
+
levelOffset,
|
|
238
|
+
command,
|
|
239
|
+
get usageExamples() {
|
|
240
|
+
return usageExamples();
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}));
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
CommandDocsFile.__type = [
|
|
249
|
+
() => __ΩCommandDocsFileProps,
|
|
250
|
+
"props",
|
|
251
|
+
"CommandDocsFile",
|
|
252
|
+
"Generates the markdown documentation file for a command.",
|
|
253
|
+
"Pn!2\"\"/#?$"
|
|
254
|
+
];
|
|
255
|
+
|
|
256
|
+
//#endregion
|
|
257
|
+
exports.CommandDocs = CommandDocs;
|
|
258
|
+
exports.CommandDocsFile = CommandDocsFile;
|
|
259
|
+
exports.CommandDocsUsageExample = CommandDocsUsageExample;
|
|
260
|
+
exports.CommandOptionsDocs = CommandOptionsDocs;
|
|
261
|
+
exports.__ΩCommandDocsFileProps = __ΩCommandDocsFileProps;
|
|
262
|
+
exports.__ΩCommandDocsProps = __ΩCommandDocsProps;
|
|
263
|
+
exports.__ΩCommandDocsUsageExampleProps = __ΩCommandDocsUsageExampleProps;
|
|
264
|
+
exports.__ΩCommandOptionsDocsProps = __ΩCommandOptionsDocsProps;
|
|
265
|
+
//# sourceMappingURL=docs.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.cjs","names":[],"sources":[],"mappings":""}
|