@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 +1,479 @@
|
|
|
1
|
-
|
|
1
|
+
const require_context_helpers = require('../plugin-utils/context-helpers.cjs');
|
|
2
|
+
const require_utilities = require('../helpers/utilities.cjs');
|
|
3
|
+
const require_helpers = require('./helpers.cjs');
|
|
4
|
+
let _powerlines_schema = require("@powerlines/schema");
|
|
5
|
+
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
6
|
+
let _stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
|
|
7
|
+
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
8
|
+
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
9
|
+
let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
10
|
+
let _stryke_type_checks_is_boolean = require("@stryke/type-checks/is-boolean");
|
|
11
|
+
let _stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
12
|
+
let _powerlines_deepkit_esbuild_plugin = require("@powerlines/deepkit/esbuild-plugin");
|
|
13
|
+
let _stryke_json = require("@stryke/json");
|
|
14
|
+
|
|
15
|
+
//#region src/resolver/resolve.ts
|
|
16
|
+
const __ΩRecord = [
|
|
17
|
+
"K",
|
|
18
|
+
"T",
|
|
19
|
+
"Record",
|
|
20
|
+
"l'e#\"Rb!b\"Pde\"!N#!w#y"
|
|
21
|
+
];
|
|
22
|
+
function __assignType(fn, args) {
|
|
23
|
+
fn.__type = args;
|
|
24
|
+
return fn;
|
|
25
|
+
}
|
|
26
|
+
function isFiniteNumber(value) {
|
|
27
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
28
|
+
}
|
|
29
|
+
isFiniteNumber.__type = [
|
|
30
|
+
"value",
|
|
31
|
+
"isFiniteNumber",
|
|
32
|
+
"P#2!!/\""
|
|
33
|
+
];
|
|
34
|
+
function asRecord(value) {
|
|
35
|
+
return (0, _stryke_type_checks_is_set_object.isSetObject)(value) ? value : {};
|
|
36
|
+
}
|
|
37
|
+
asRecord.__type = [
|
|
38
|
+
"value",
|
|
39
|
+
() => __ΩRecord,
|
|
40
|
+
"asRecord",
|
|
41
|
+
"P#2!&#o\"#/#"
|
|
42
|
+
];
|
|
43
|
+
function toAliasList(value) {
|
|
44
|
+
if (Array.isArray(value)) return (0, _stryke_helpers_get_unique.getUnique)(value.filter(_stryke_type_checks_is_set_string.isSetString));
|
|
45
|
+
return (0, _stryke_type_checks_is_set_string.isSetString)(value) ? [value] : [];
|
|
46
|
+
}
|
|
47
|
+
toAliasList.__type = [
|
|
48
|
+
"value",
|
|
49
|
+
"toAliasList",
|
|
50
|
+
"P#2!&F/\""
|
|
51
|
+
];
|
|
52
|
+
function inferParameterType(input) {
|
|
53
|
+
const schemaType = input.type;
|
|
54
|
+
if (Array.isArray(schemaType)) {
|
|
55
|
+
const first = schemaType.find(__assignType((type) => type !== "null", [
|
|
56
|
+
"type",
|
|
57
|
+
"",
|
|
58
|
+
"P\"2!\"/\""
|
|
59
|
+
]));
|
|
60
|
+
if (first === "integer" || first === "number") return "number";
|
|
61
|
+
if (first === "boolean") return "boolean";
|
|
62
|
+
if (first === "array") {
|
|
63
|
+
const nestedType = asRecord(input.items).type;
|
|
64
|
+
if (nestedType === "integer" || nestedType === "number") return "number";
|
|
65
|
+
if (nestedType === "boolean") return "boolean";
|
|
66
|
+
return "string";
|
|
67
|
+
}
|
|
68
|
+
return "string";
|
|
69
|
+
}
|
|
70
|
+
if (schemaType === "integer" || schemaType === "number") return "number";
|
|
71
|
+
if (schemaType === "boolean") return "boolean";
|
|
72
|
+
if (schemaType === "array") {
|
|
73
|
+
const nestedType = asRecord(input.items).type;
|
|
74
|
+
if (nestedType === "integer" || nestedType === "number") return "number";
|
|
75
|
+
if (nestedType === "boolean") return "boolean";
|
|
76
|
+
return "string";
|
|
77
|
+
}
|
|
78
|
+
if (Array.isArray(input.enum) && input.enum.length > 0) {
|
|
79
|
+
const first = input.enum.find(__assignType((value) => value !== null, [
|
|
80
|
+
"value",
|
|
81
|
+
"",
|
|
82
|
+
"P\"2!\"/\""
|
|
83
|
+
]));
|
|
84
|
+
if (isFiniteNumber(first)) return "number";
|
|
85
|
+
if ((0, _stryke_type_checks_is_boolean.isBoolean)(first)) return "boolean";
|
|
86
|
+
}
|
|
87
|
+
if (isFiniteNumber(input.default)) return "number";
|
|
88
|
+
if ((0, _stryke_type_checks_is_boolean.isBoolean)(input.default)) return "boolean";
|
|
89
|
+
return "string";
|
|
90
|
+
}
|
|
91
|
+
inferParameterType.__type = [
|
|
92
|
+
() => __ΩRecord,
|
|
93
|
+
"input",
|
|
94
|
+
"CommandOption",
|
|
95
|
+
"type",
|
|
96
|
+
"inferParameterType",
|
|
97
|
+
"P&#o!#2\"\"w#.$f/%"
|
|
98
|
+
];
|
|
99
|
+
function inferVariadic(input) {
|
|
100
|
+
if ((0, _stryke_type_checks_is_boolean.isBoolean)(input.variadic)) return input.variadic;
|
|
101
|
+
return input.type === "array";
|
|
102
|
+
}
|
|
103
|
+
inferVariadic.__type = [
|
|
104
|
+
() => __ΩRecord,
|
|
105
|
+
"input",
|
|
106
|
+
"inferVariadic",
|
|
107
|
+
"P&#o!#2\")/#"
|
|
108
|
+
];
|
|
109
|
+
function normalizeDefault(input, type, variadic) {
|
|
110
|
+
const defaultValue = input.default;
|
|
111
|
+
if (defaultValue === void 0) return;
|
|
112
|
+
if (type === "boolean") {
|
|
113
|
+
if (variadic) {
|
|
114
|
+
if (Array.isArray(defaultValue)) return defaultValue.filter(_stryke_type_checks_is_boolean.isBoolean);
|
|
115
|
+
return (0, _stryke_type_checks_is_boolean.isBoolean)(defaultValue) ? [defaultValue] : void 0;
|
|
116
|
+
}
|
|
117
|
+
if (Array.isArray(defaultValue)) return defaultValue.find(_stryke_type_checks_is_boolean.isBoolean);
|
|
118
|
+
return (0, _stryke_type_checks_is_boolean.isBoolean)(defaultValue) ? defaultValue : void 0;
|
|
119
|
+
}
|
|
120
|
+
if (type === "number") {
|
|
121
|
+
if (variadic) {
|
|
122
|
+
if (Array.isArray(defaultValue)) return defaultValue.map(__assignType((item) => typeof item === "bigint" ? Number(item) : item, [
|
|
123
|
+
"item",
|
|
124
|
+
"",
|
|
125
|
+
"P\"2!\"/\""
|
|
126
|
+
])).filter(isFiniteNumber);
|
|
127
|
+
const normalized = typeof defaultValue === "bigint" ? Number(defaultValue) : defaultValue;
|
|
128
|
+
return isFiniteNumber(normalized) ? [normalized] : void 0;
|
|
129
|
+
}
|
|
130
|
+
if (Array.isArray(defaultValue)) return defaultValue.map(__assignType((item) => typeof item === "bigint" ? Number(item) : item, [
|
|
131
|
+
"item",
|
|
132
|
+
"",
|
|
133
|
+
"P\"2!\"/\""
|
|
134
|
+
])).find(isFiniteNumber);
|
|
135
|
+
const normalized = typeof defaultValue === "bigint" ? Number(defaultValue) : defaultValue;
|
|
136
|
+
return isFiniteNumber(normalized) ? normalized : void 0;
|
|
137
|
+
}
|
|
138
|
+
if (variadic) {
|
|
139
|
+
if (Array.isArray(defaultValue)) return defaultValue.filter(_stryke_type_checks_is_set_string.isSetString);
|
|
140
|
+
return (0, _stryke_type_checks_is_set_string.isSetString)(defaultValue) ? [defaultValue] : void 0;
|
|
141
|
+
}
|
|
142
|
+
if (Array.isArray(defaultValue)) return defaultValue.find(_stryke_type_checks_is_set_string.isSetString);
|
|
143
|
+
return (0, _stryke_type_checks_is_set_string.isSetString)(defaultValue) ? defaultValue : void 0;
|
|
144
|
+
}
|
|
145
|
+
normalizeDefault.__type = [
|
|
146
|
+
() => __ΩRecord,
|
|
147
|
+
"input",
|
|
148
|
+
"CommandOption",
|
|
149
|
+
"type",
|
|
150
|
+
"type",
|
|
151
|
+
"variadic",
|
|
152
|
+
"normalizeDefault",
|
|
153
|
+
"P&#o!#2\"\"w#.$f2%)2&\"/'"
|
|
154
|
+
];
|
|
155
|
+
function normalizeStringChoices(input) {
|
|
156
|
+
const source = Array.isArray(input.choices) ? input.choices : input.enum;
|
|
157
|
+
if (!Array.isArray(source)) return;
|
|
158
|
+
return source.filter(_stryke_type_checks_is_set_string.isSetString);
|
|
159
|
+
}
|
|
160
|
+
normalizeStringChoices.__type = [
|
|
161
|
+
() => __ΩRecord,
|
|
162
|
+
"input",
|
|
163
|
+
"normalizeStringChoices",
|
|
164
|
+
"P&#o!#2\"\"/#"
|
|
165
|
+
];
|
|
166
|
+
function normalizeNumberChoices(input) {
|
|
167
|
+
const source = Array.isArray(input.choices) ? input.choices : input.enum;
|
|
168
|
+
if (!Array.isArray(source)) return;
|
|
169
|
+
return source.map(__assignType((item) => typeof item === "bigint" ? Number(item) : item, [
|
|
170
|
+
"item",
|
|
171
|
+
"",
|
|
172
|
+
"P\"2!\"/\""
|
|
173
|
+
])).filter(isFiniteNumber);
|
|
174
|
+
}
|
|
175
|
+
normalizeNumberChoices.__type = [
|
|
176
|
+
() => __ΩRecord,
|
|
177
|
+
"input",
|
|
178
|
+
"normalizeNumberChoices",
|
|
179
|
+
"P&#o!#2\"\"/#"
|
|
180
|
+
];
|
|
181
|
+
function resolveCommandParameter(schema, defaults) {
|
|
182
|
+
const input = asRecord(schema);
|
|
183
|
+
const type = inferParameterType(input);
|
|
184
|
+
const variadic = inferVariadic(input);
|
|
185
|
+
const defaultValue = normalizeDefault(input, type, variadic);
|
|
186
|
+
const required = (0, _stryke_type_checks_is_boolean.isBoolean)(input.required) ? input.required : defaultValue === void 0 ? defaults.fallbackRequired : false;
|
|
187
|
+
const env = (0, _stryke_type_checks_is_set_string.isSetString)(input.env) ? input.env : false;
|
|
188
|
+
const result = {
|
|
189
|
+
name: (0, _stryke_type_checks_is_set_string.isSetString)(input.name) ? input.name : "",
|
|
190
|
+
type,
|
|
191
|
+
title: (0, _stryke_type_checks_is_set_string.isSetString)(input.title) ? input.title : "",
|
|
192
|
+
description: (0, _stryke_type_checks_is_set_string.isSetString)(input.description) ? input.description : "",
|
|
193
|
+
alias: toAliasList(input.alias),
|
|
194
|
+
default: defaultValue,
|
|
195
|
+
env,
|
|
196
|
+
required,
|
|
197
|
+
variadic
|
|
198
|
+
};
|
|
199
|
+
if (type === "string") {
|
|
200
|
+
const stringChoices = normalizeStringChoices(input);
|
|
201
|
+
if (Array.isArray(stringChoices)) result.choices = stringChoices;
|
|
202
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(input.format)) result.format = input.format;
|
|
203
|
+
}
|
|
204
|
+
if (type === "number") {
|
|
205
|
+
const numberChoices = normalizeNumberChoices(input);
|
|
206
|
+
if (Array.isArray(numberChoices)) result.choices = numberChoices;
|
|
207
|
+
}
|
|
208
|
+
if (defaults.includeBooleanOptionFields && type === "boolean" && !variadic) {
|
|
209
|
+
const optionResult = result;
|
|
210
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(input.isNegativeOf)) optionResult.isNegativeOf = input.isNegativeOf;
|
|
211
|
+
if ((0, _stryke_type_checks_is_boolean.isBoolean)(input.skipAddingNegative)) optionResult.skipAddingNegative = input.skipAddingNegative;
|
|
212
|
+
}
|
|
213
|
+
return result;
|
|
214
|
+
}
|
|
215
|
+
resolveCommandParameter.__type = [
|
|
216
|
+
"schema",
|
|
217
|
+
"fallbackRequired",
|
|
218
|
+
"includeBooleanOptionFields",
|
|
219
|
+
"defaults",
|
|
220
|
+
"CommandOption",
|
|
221
|
+
"CommandArgument",
|
|
222
|
+
"resolveCommandParameter",
|
|
223
|
+
"P#2!P)4\")4#M2$P\"w%\"w&J/'"
|
|
224
|
+
];
|
|
225
|
+
/**
|
|
226
|
+
* Resolves a command option from the given schema.
|
|
227
|
+
*
|
|
228
|
+
* @param schema - The command option schema, which can be a command option configuration or a JSON schema input.
|
|
229
|
+
* @returns The resolved command option definition.
|
|
230
|
+
*/
|
|
231
|
+
function resolveCommandOption(schema) {
|
|
232
|
+
return resolveCommandParameter(schema, {
|
|
233
|
+
fallbackRequired: false,
|
|
234
|
+
includeBooleanOptionFields: true
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
resolveCommandOption.__type = [
|
|
238
|
+
"schema",
|
|
239
|
+
"CommandOption",
|
|
240
|
+
"resolveCommandOption",
|
|
241
|
+
"Resolves a command option from the given schema.",
|
|
242
|
+
"P#2!\"w\"/#?$"
|
|
243
|
+
];
|
|
244
|
+
/**
|
|
245
|
+
* Resolves a command argument from the given schema.
|
|
246
|
+
*
|
|
247
|
+
* @param schema - The command argument schema, which can be a command argument configuration or a JSON schema input.
|
|
248
|
+
* @returns The resolved command argument definition.
|
|
249
|
+
*/
|
|
250
|
+
function resolveCommandArgument(schema) {
|
|
251
|
+
return resolveCommandParameter(schema, {
|
|
252
|
+
fallbackRequired: true,
|
|
253
|
+
includeBooleanOptionFields: false
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
resolveCommandArgument.__type = [
|
|
257
|
+
"schema",
|
|
258
|
+
"CommandArgument",
|
|
259
|
+
"resolveCommandArgument",
|
|
260
|
+
"Resolves a command argument from the given schema.",
|
|
261
|
+
"P#2!\"w\"/#?$"
|
|
262
|
+
];
|
|
263
|
+
async function preprocess(input) {
|
|
264
|
+
const { context, command, parent } = input;
|
|
265
|
+
const title = command.title || `${parent?.title ? `${parent.virtual ? parent.title.replace(/(?:c|C)ommands?$/, "").trim() : parent.title} - ` : ""}${(0, _stryke_string_format_title_case.titleCase)(command.name)}${command.virtual ? " Commands" : ""}`;
|
|
266
|
+
const result = {
|
|
267
|
+
input,
|
|
268
|
+
output: {
|
|
269
|
+
alias: [],
|
|
270
|
+
icon: parent?.icon,
|
|
271
|
+
tags: parent?.tags ?? [],
|
|
272
|
+
source: "file",
|
|
273
|
+
...command,
|
|
274
|
+
title,
|
|
275
|
+
options: parent === null ? require_utilities.getGlobalOptions(context, command) : {},
|
|
276
|
+
args: [],
|
|
277
|
+
parent: parent ?? null,
|
|
278
|
+
children: {}
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
if (!command.virtual) {
|
|
282
|
+
if (!command.entry.input?.file || !context.fs.existsSync(command.entry.input.file)) throw new Error(`${!command.entry.input?.file ? "Missing" : "Non-existent"} command entry file for "${command.name}"`);
|
|
283
|
+
context.debug(`Adding reflection for CLI command: ${command.id} (file: ${command.entry.input.file})`);
|
|
284
|
+
result.module = await (_powerlines_schema.resolveModule.Ω = [["CommandModule", "\"w!"]], (0, _powerlines_schema.resolveModule)(context, command.entry.input, {
|
|
285
|
+
name: command.title || (0, _stryke_string_format_title_case.titleCase)(command.name),
|
|
286
|
+
plugins: [(0, _powerlines_deepkit_esbuild_plugin.esbuildPlugin)(context, {
|
|
287
|
+
reflection: "default",
|
|
288
|
+
level: "all"
|
|
289
|
+
})],
|
|
290
|
+
resolve: { skipNodeModulesBundle: true }
|
|
291
|
+
}));
|
|
292
|
+
}
|
|
293
|
+
return result;
|
|
294
|
+
}
|
|
295
|
+
preprocess.__type = [
|
|
296
|
+
"ResolverInput",
|
|
297
|
+
"input",
|
|
298
|
+
"ResolverContext",
|
|
299
|
+
"preprocess",
|
|
300
|
+
"P\"w!2\"\"w#`/$"
|
|
301
|
+
];
|
|
302
|
+
async function postprocess(ctx) {
|
|
303
|
+
ctx.output.options = require_helpers.applyOptionsDefaults(ctx);
|
|
304
|
+
ctx.output.args = require_helpers.applyArgsDefaults(ctx);
|
|
305
|
+
ctx.output.args.forEach(__assignType((arg, index) => {
|
|
306
|
+
const found = ctx.output.args.findIndex(__assignType((a) => a.name === arg.name, [
|
|
307
|
+
"a",
|
|
308
|
+
"",
|
|
309
|
+
"P\"2!\"/\""
|
|
310
|
+
]));
|
|
311
|
+
if (found !== -1 && found !== index || ctx.output.segments.some(__assignType((segment) => require_context_helpers.isDynamicPathSegment(segment) && require_context_helpers.getDynamicPathSegmentName(segment) === arg.name, [
|
|
312
|
+
"segment",
|
|
313
|
+
"",
|
|
314
|
+
"P\"2!\"/\""
|
|
315
|
+
]))) {
|
|
316
|
+
arg.name += `_${ctx.output.segments.filter(__assignType((segment) => require_context_helpers.isDynamicPathSegment(segment) && require_context_helpers.getDynamicPathSegmentName(segment).replace(/_\d+$/, "") === arg.name, [
|
|
317
|
+
"segment",
|
|
318
|
+
"",
|
|
319
|
+
"P\"2!\"/\""
|
|
320
|
+
])).length + ctx.output.args.filter(__assignType((a) => a.name.replace(/_\d+$/, "") === arg.name, [
|
|
321
|
+
"a",
|
|
322
|
+
"",
|
|
323
|
+
"P\"2!\"/\""
|
|
324
|
+
])).length}`;
|
|
325
|
+
arg.env = arg.name ? arg.env || arg.env === false ? arg.env : ctx.input.context.config.autoAssignEnv ? (0, _stryke_string_format_constant_case.constantCase)(arg.name) : false : false;
|
|
326
|
+
}
|
|
327
|
+
}, [
|
|
328
|
+
"arg",
|
|
329
|
+
"index",
|
|
330
|
+
"",
|
|
331
|
+
"P\"2!\"2\"\"/#"
|
|
332
|
+
]));
|
|
333
|
+
require_helpers.applyDefaults(ctx);
|
|
334
|
+
if (ctx.input.context.env) {
|
|
335
|
+
if ((0, _stryke_type_checks_is_set_object.isSetObject)(ctx.output.options)) Object.values(ctx.output.options).filter(__assignType((option) => Boolean(option.env), [
|
|
336
|
+
"option",
|
|
337
|
+
"",
|
|
338
|
+
"P\"2!\"/\""
|
|
339
|
+
])).forEach(__assignType((option) => {
|
|
340
|
+
(0, _powerlines_schema.addProperty)(ctx.input.context.env.config.schema, option.env, {
|
|
341
|
+
...option,
|
|
342
|
+
name: option.env,
|
|
343
|
+
alias: option.alias.filter(__assignType((alias) => alias.length > 1, [
|
|
344
|
+
"alias",
|
|
345
|
+
"",
|
|
346
|
+
"P\"2!\"/\""
|
|
347
|
+
])).map(__assignType((alias) => (0, _stryke_string_format_constant_case.constantCase)(alias), [
|
|
348
|
+
"alias",
|
|
349
|
+
"",
|
|
350
|
+
"P\"2!\"/\""
|
|
351
|
+
]))
|
|
352
|
+
});
|
|
353
|
+
}, [
|
|
354
|
+
"option",
|
|
355
|
+
"",
|
|
356
|
+
"P\"2!\"/\""
|
|
357
|
+
]));
|
|
358
|
+
ctx.output.args.filter(__assignType((arg) => Boolean(arg.env), [
|
|
359
|
+
"arg",
|
|
360
|
+
"",
|
|
361
|
+
"P\"2!\"/\""
|
|
362
|
+
])).forEach(__assignType((arg) => (0, _powerlines_schema.addProperty)(ctx.input.context.env.config.schema, arg.env, {
|
|
363
|
+
...arg,
|
|
364
|
+
name: arg.env,
|
|
365
|
+
alias: arg.alias.filter(__assignType((alias) => alias.length > 1, [
|
|
366
|
+
"alias",
|
|
367
|
+
"",
|
|
368
|
+
"P\"2!\"/\""
|
|
369
|
+
])).map(__assignType((alias) => (0, _stryke_string_format_constant_case.constantCase)(alias), [
|
|
370
|
+
"alias",
|
|
371
|
+
"",
|
|
372
|
+
"P\"2!\"/\""
|
|
373
|
+
]))
|
|
374
|
+
}), [
|
|
375
|
+
"arg",
|
|
376
|
+
"",
|
|
377
|
+
"P\"2!\"/\""
|
|
378
|
+
]));
|
|
379
|
+
}
|
|
380
|
+
await Promise.all(ctx.input.context.inputs.filter(__assignType((input) => input.segments.filter(__assignType((segment) => !require_context_helpers.isDynamicPathSegment(segment), [
|
|
381
|
+
"segment",
|
|
382
|
+
"",
|
|
383
|
+
"P\"2!\"/\""
|
|
384
|
+
])).length === ctx.input.command.segments.filter(__assignType((segment) => !require_context_helpers.isDynamicPathSegment(segment), [
|
|
385
|
+
"segment",
|
|
386
|
+
"",
|
|
387
|
+
"P\"2!\"/\""
|
|
388
|
+
])).length + 1 && input.segments.slice(0, ctx.input.command.segments.length).every(__assignType((value, index) => value === ctx.input.command.segments[index], [
|
|
389
|
+
"value",
|
|
390
|
+
"index",
|
|
391
|
+
"",
|
|
392
|
+
"P\"2!\"2\"\"/#"
|
|
393
|
+
])), [
|
|
394
|
+
"input",
|
|
395
|
+
"",
|
|
396
|
+
"P\"2!\"/\""
|
|
397
|
+
])).map(__assignType(async (input) => {
|
|
398
|
+
ctx.output.children[input.name] = await (resolve.Ω = [[
|
|
399
|
+
() => ctx,
|
|
400
|
+
"ResolverContext",
|
|
401
|
+
"Pi!\"w\"q\"!j"
|
|
402
|
+
]], resolve({
|
|
403
|
+
context: ctx.input.context,
|
|
404
|
+
command: input,
|
|
405
|
+
parent: ctx.output
|
|
406
|
+
}));
|
|
407
|
+
}, [
|
|
408
|
+
"input",
|
|
409
|
+
"",
|
|
410
|
+
"P\"2!\"/\""
|
|
411
|
+
])));
|
|
412
|
+
return ctx.output;
|
|
413
|
+
}
|
|
414
|
+
postprocess.__type = [
|
|
415
|
+
"ResolverContext",
|
|
416
|
+
"ctx",
|
|
417
|
+
"CommandTree",
|
|
418
|
+
"postprocess",
|
|
419
|
+
"P\"w!2\"\"w#`/$"
|
|
420
|
+
];
|
|
421
|
+
/**
|
|
422
|
+
* Resolves a command tree from the given resolver input.
|
|
423
|
+
*
|
|
424
|
+
* @param input - The resolver input containing the context, command, and optional parent command tree.
|
|
425
|
+
* @returns A promise that resolves to the resolved command tree.
|
|
426
|
+
*/
|
|
427
|
+
async function resolve(input) {
|
|
428
|
+
const ctx = await (preprocess.Ω = [[
|
|
429
|
+
() => input,
|
|
430
|
+
"ResolverInput",
|
|
431
|
+
"Pi!\"w\"q\"!j"
|
|
432
|
+
]], preprocess(input));
|
|
433
|
+
if (!ctx.output.virtual) {
|
|
434
|
+
if (!ctx.module) throw new Error(`Command module at path "${ctx.input.command.path}" is undefined or null. Please ensure the module exports a valid command.`);
|
|
435
|
+
else if (!(0, _stryke_type_checks_is_set_object.isSetObject)(ctx.module)) throw new TypeError(`Command module at path "${ctx.input.command.path}" is not an object. Please ensure the module exports a valid command.`);
|
|
436
|
+
else if (!("default" in ctx.module)) throw new Error(`Command module at path "${ctx.input.command.path}" does not appear to be valid. Please ensure the module's default export is a valid command handler function.`);
|
|
437
|
+
const metadata = ctx.module.metadata ?? {};
|
|
438
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(metadata.title)) ctx.output.title = metadata.title;
|
|
439
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(metadata.description)) ctx.output.description = metadata.description;
|
|
440
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(metadata.alias) || Array.isArray(metadata.alias) && metadata.alias.length > 0) ctx.output.alias = (0, _stryke_convert_to_array.toArray)(metadata.alias);
|
|
441
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(metadata.icon)) ctx.output.icon = metadata.icon;
|
|
442
|
+
if ((0, _stryke_type_checks_is_set_string.isSetString)(metadata.tags)) ctx.output.tags = (0, _stryke_helpers_get_unique.getUnique)(ctx.output.tags.concat((0, _stryke_convert_to_array.toArray)(metadata.tags)));
|
|
443
|
+
if ((0, _stryke_type_checks_is_set_object.isSetObject)(ctx.module.options)) {
|
|
444
|
+
const options = await (0, _powerlines_schema.extract)(ctx.input.context, ctx.module.options);
|
|
445
|
+
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(options) || !(0, _stryke_json.isJsonSchemaObjectType)(options.schema)) throw new TypeError(`Command options for command at path "${ctx.input.command.path}" must resolve to an object.`);
|
|
446
|
+
ctx.output.options = (0, _powerlines_schema.getPropertiesList)(options).reduce(__assignType((ret, property) => {
|
|
447
|
+
ret[property.name] = resolveCommandOption(property);
|
|
448
|
+
return ret;
|
|
449
|
+
}, [
|
|
450
|
+
"ret",
|
|
451
|
+
"property",
|
|
452
|
+
"",
|
|
453
|
+
"P\"2!\"2\"\"/#"
|
|
454
|
+
]), {});
|
|
455
|
+
}
|
|
456
|
+
if (ctx.module.args && Array.isArray(ctx.module.args)) {
|
|
457
|
+
const args = await (0, _powerlines_schema.extract)(ctx.input.context, ctx.module.args);
|
|
458
|
+
if (!(0, _stryke_type_checks_is_set_object.isSetObject)(args) || !(0, _stryke_json.isJsonSchemaTupleType)(args.schema)) throw new TypeError(`Command arguments for command at path "${ctx.input.command.path}" must resolve to a tuple.`);
|
|
459
|
+
ctx.output.args = args.schema.items.map(__assignType((item) => resolveCommandArgument(item), [
|
|
460
|
+
"item",
|
|
461
|
+
"",
|
|
462
|
+
"P\"2!\"/\""
|
|
463
|
+
]));
|
|
464
|
+
}
|
|
465
|
+
} else require_helpers.resolveVirtualCommand(ctx);
|
|
466
|
+
return postprocess(ctx);
|
|
467
|
+
}
|
|
468
|
+
resolve.__type = [
|
|
469
|
+
"ResolverInput",
|
|
470
|
+
"input",
|
|
471
|
+
"CommandTree",
|
|
472
|
+
"resolve",
|
|
473
|
+
"Resolves a command tree from the given resolver input.",
|
|
474
|
+
"P\"w!2\"\"w#`/$?%"
|
|
475
|
+
];
|
|
476
|
+
|
|
477
|
+
//#endregion
|
|
478
|
+
exports.resolve = resolve;
|
|
479
|
+
//# sourceMappingURL=resolve.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.cjs","names":[],"sources":[],"mappings":""}
|