@shell-shock/core 0.17.21 → 0.17.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -7
- package/dist/api.cjs +4 -5
- package/dist/api.d.cts +1 -1
- package/dist/api.d.mts +1 -1
- package/dist/api.mjs +2 -2
- package/dist/command-B6KYexlV.d.mts +308 -0
- package/dist/command-B6KYexlV.d.mts.map +1 -0
- package/dist/command-CtfR7hKM.d.cts +308 -0
- package/dist/command-CtfR7hKM.d.cts.map +1 -0
- package/dist/components/command-validation-logic.cjs +153 -216
- package/dist/components/command-validation-logic.d.cts +2 -1
- package/dist/components/command-validation-logic.d.cts.map +1 -1
- package/dist/components/command-validation-logic.d.mts +2 -1
- package/dist/components/command-validation-logic.mjs +153 -214
- package/dist/components/docs.cjs +6 -364
- package/dist/components/docs.d.cts +2 -3
- package/dist/components/docs.d.cts.map +1 -1
- package/dist/components/docs.d.mts +2 -3
- package/dist/components/docs.mjs +2 -356
- package/dist/components/exec-builtin.cjs +63 -100
- 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.mjs +7 -41
- package/dist/components/helpers.cjs +2 -52
- package/dist/components/helpers.d.cts +2 -1
- package/dist/components/helpers.d.cts.map +1 -1
- package/dist/components/helpers.d.mts +2 -1
- package/dist/components/helpers.mjs +2 -50
- package/dist/components/index.cjs +7 -23
- package/dist/components/index.mjs +9 -9
- package/dist/components/options-parser-logic.cjs +198 -420
- package/dist/components/options-parser-logic.d.cts +2 -5
- package/dist/components/options-parser-logic.d.cts.map +1 -1
- package/dist/components/options-parser-logic.d.mts +2 -5
- package/dist/components/options-parser-logic.mjs +192 -407
- package/dist/components/state-builtin.cjs +106 -164
- package/dist/components/state-builtin.d.cts +1 -2
- package/dist/components/state-builtin.d.cts.map +1 -1
- package/dist/components/state-builtin.d.mts +1 -2
- package/dist/components/state-builtin.mjs +12 -68
- package/dist/components/usage.cjs +4 -48
- 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.mjs +4 -46
- package/dist/components/utils-builtin.cjs +77 -144
- package/dist/components/utils-builtin.d.cts +1 -2
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts +1 -2
- package/dist/components/utils-builtin.mjs +9 -74
- package/dist/config-BIF9mEz0.d.cts +157 -0
- package/dist/config-BIF9mEz0.d.cts.map +1 -0
- package/dist/config-CnNYdfsL.d.mts +157 -0
- package/dist/config-CnNYdfsL.d.mts.map +1 -0
- package/dist/config.cjs +24 -58
- package/dist/config.d.cts +1 -2
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +1 -2
- package/dist/config.mjs +23 -55
- package/dist/{plugin-utils/context-helpers.mjs → context-helpers-D3EJxwbq.mjs} +5 -83
- package/dist/context-helpers-D3EJxwbq.mjs.map +1 -0
- package/dist/{plugin-utils/context-helpers.cjs → context-helpers-_wUuFRB8.cjs} +63 -92
- package/dist/contexts/command.cjs +3 -9
- package/dist/contexts/command.d.cts +1 -2
- package/dist/contexts/command.d.cts.map +1 -1
- package/dist/contexts/command.d.mts +1 -2
- package/dist/contexts/command.mjs +2 -7
- package/dist/contexts/index.cjs +19 -1
- package/dist/contexts/index.d.cts +2 -1
- package/dist/contexts/index.d.mts +2 -1
- package/dist/contexts/index.mjs +2 -1
- package/dist/contexts/options.cjs +7 -30
- package/dist/contexts/options.d.cts +1 -2
- package/dist/contexts/options.d.cts.map +1 -1
- package/dist/contexts/options.d.mts +1 -2
- package/dist/contexts/options.mjs +7 -27
- package/dist/contexts/power-plant.cjs +19 -0
- package/dist/contexts/power-plant.d.cts +2 -0
- package/dist/contexts/power-plant.d.mts +2 -0
- package/dist/contexts/power-plant.mjs +5 -0
- package/dist/docs-C6ZvsVMu.cjs +278 -0
- package/dist/docs-CGQ2HtEY.mjs +249 -0
- package/dist/docs-CGQ2HtEY.mjs.map +1 -0
- package/dist/engine.cjs +5 -39
- package/dist/engine.d.cts +1 -2
- package/dist/engine.d.cts.map +1 -1
- package/dist/engine.d.mts +1 -2
- package/dist/engine.mjs +4 -37
- package/dist/generator.cjs +68 -0
- package/dist/generator.d.cts +15 -0
- package/dist/generator.d.cts.map +1 -0
- package/dist/generator.d.mts +15 -0
- package/dist/generator.d.mts.map +1 -0
- package/dist/generator.mjs +66 -0
- package/dist/generator.mjs.map +1 -0
- package/dist/{helpers/get-framework.cjs → get-framework-CxZc2krd.cjs} +7 -8
- package/dist/{helpers/get-framework.mjs → get-framework-Dlqz2hVZ.mjs} +3 -8
- package/dist/get-framework-Dlqz2hVZ.mjs.map +1 -0
- package/dist/helpers/power-plant.cjs +102 -0
- package/dist/helpers/power-plant.d.cts +61 -0
- package/dist/helpers/power-plant.d.cts.map +1 -0
- package/dist/helpers/power-plant.d.mts +61 -0
- package/dist/helpers/power-plant.d.mts.map +1 -0
- package/dist/helpers/power-plant.mjs +99 -0
- package/dist/helpers/power-plant.mjs.map +1 -0
- package/dist/index-D4klH_pj.d.mts +2 -0
- package/dist/index-DYOBadKY.d.cts +2 -0
- package/dist/index.cjs +1 -37
- package/dist/index.d.cts +4 -6
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +4 -6
- package/dist/index.mjs +0 -35
- package/dist/package-B7Vu265G.mjs +6 -0
- package/dist/package-B7Vu265G.mjs.map +1 -0
- package/dist/{package.cjs → package-BLC4qc8t.cjs} +2 -4
- package/dist/plugin-B-hM2twc.mjs +1458 -0
- package/dist/plugin-B-hM2twc.mjs.map +1 -0
- package/dist/plugin-Bhfq0DMC.cjs +1490 -0
- package/dist/plugin-utils/index.cjs +359 -26
- package/dist/plugin-utils/index.d.cts +273 -9
- package/dist/plugin-utils/index.d.cts.map +1 -0
- package/dist/plugin-utils/index.d.mts +273 -9
- package/dist/plugin-utils/index.d.mts.map +1 -0
- package/dist/plugin-utils/index.mjs +346 -10
- package/dist/plugin-utils/index.mjs.map +1 -0
- package/dist/plugin.cjs +3 -496
- package/dist/plugin.d.cts +1 -3
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +1 -3
- package/dist/plugin.mjs +2 -491
- package/dist/power-plant-LgxcvlMN.d.cts +4 -0
- package/dist/power-plant-LgxcvlMN.d.mts +4 -0
- package/dist/reflect-CSiffeL9.cjs +27 -0
- package/dist/reflect-DXKSFgvS.mjs +23 -0
- package/dist/reflect-DXKSFgvS.mjs.map +1 -0
- package/dist/schemas/env.cjs +91 -0
- package/dist/schemas/env.d.cts +145 -0
- package/dist/schemas/env.d.cts.map +1 -0
- package/dist/schemas/env.d.mts +145 -0
- package/dist/{types → schemas}/env.d.mts.map +1 -1
- package/dist/schemas/env.mjs +91 -0
- package/dist/schemas/index.cjs +4 -0
- package/dist/schemas/index.d.cts +2 -0
- package/dist/schemas/index.d.mts +2 -0
- package/dist/schemas/index.mjs +3 -0
- package/dist/types/command.cjs +0 -402
- package/dist/types/command.d.cts +2 -309
- package/dist/types/command.d.mts +2 -309
- package/dist/types/command.mjs +1 -368
- package/dist/types/config.cjs +0 -175
- package/dist/types/config.d.cts +2 -126
- package/dist/types/config.d.mts +2 -126
- package/dist/types/config.mjs +1 -164
- package/dist/types/context.cjs +0 -45
- package/dist/types/context.d.cts +2 -31
- package/dist/types/context.d.mts +2 -31
- package/dist/types/context.mjs +1 -41
- package/dist/types/index.cjs +3 -53
- package/dist/types/index.d.cts +4 -5
- package/dist/types/index.d.mts +4 -5
- package/dist/types/index.mjs +4 -5
- package/package.json +106 -42
- package/dist/_virtual/_rolldown/runtime.cjs +0 -29
- package/dist/api.cjs.map +0 -1
- package/dist/components/command-validation-logic.cjs.map +0 -1
- package/dist/components/docs.cjs.map +0 -1
- package/dist/components/docs.mjs.map +0 -1
- package/dist/components/exec-builtin.cjs.map +0 -1
- package/dist/components/helpers.cjs.map +0 -1
- package/dist/components/options-parser-logic.cjs.map +0 -1
- package/dist/components/state-builtin.cjs.map +0 -1
- package/dist/components/usage.cjs.map +0 -1
- package/dist/components/utils-builtin.cjs.map +0 -1
- package/dist/config.cjs.map +0 -1
- package/dist/contexts/command.cjs.map +0 -1
- package/dist/contexts/options.cjs.map +0 -1
- package/dist/engine.cjs.map +0 -1
- package/dist/helpers/automd.cjs +0 -193
- package/dist/helpers/automd.cjs.map +0 -1
- package/dist/helpers/automd.mjs +0 -190
- package/dist/helpers/automd.mjs.map +0 -1
- package/dist/helpers/docs-helpers.cjs +0 -24
- package/dist/helpers/docs-helpers.cjs.map +0 -1
- package/dist/helpers/docs-helpers.mjs +0 -24
- package/dist/helpers/docs-helpers.mjs.map +0 -1
- package/dist/helpers/get-framework.cjs.map +0 -1
- package/dist/helpers/get-framework.mjs.map +0 -1
- package/dist/helpers/paths.cjs +0 -137
- package/dist/helpers/paths.cjs.map +0 -1
- package/dist/helpers/paths.mjs +0 -134
- package/dist/helpers/paths.mjs.map +0 -1
- package/dist/helpers/persistence.cjs +0 -114
- package/dist/helpers/persistence.cjs.map +0 -1
- package/dist/helpers/persistence.mjs +0 -113
- package/dist/helpers/persistence.mjs.map +0 -1
- package/dist/helpers/update-package-json.cjs +0 -65
- package/dist/helpers/update-package-json.cjs.map +0 -1
- package/dist/helpers/update-package-json.mjs +0 -64
- package/dist/helpers/update-package-json.mjs.map +0 -1
- package/dist/helpers/utilities.cjs +0 -95
- package/dist/helpers/utilities.cjs.map +0 -1
- package/dist/helpers/utilities.mjs +0 -94
- package/dist/helpers/utilities.mjs.map +0 -1
- package/dist/helpers/validations.cjs +0 -71
- package/dist/helpers/validations.cjs.map +0 -1
- package/dist/helpers/validations.mjs +0 -70
- package/dist/helpers/validations.mjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/package.cjs.map +0 -1
- package/dist/package.mjs +0 -6
- package/dist/package.mjs.map +0 -1
- package/dist/plugin-utils/compute-bin.cjs +0 -49
- package/dist/plugin-utils/compute-bin.cjs.map +0 -1
- package/dist/plugin-utils/compute-bin.d.cts +0 -13
- package/dist/plugin-utils/compute-bin.d.cts.map +0 -1
- package/dist/plugin-utils/compute-bin.d.mts +0 -13
- package/dist/plugin-utils/compute-bin.d.mts.map +0 -1
- package/dist/plugin-utils/compute-bin.mjs +0 -49
- package/dist/plugin-utils/compute-bin.mjs.map +0 -1
- package/dist/plugin-utils/context-helpers.cjs.map +0 -1
- package/dist/plugin-utils/context-helpers.d.cts +0 -106
- package/dist/plugin-utils/context-helpers.d.cts.map +0 -1
- package/dist/plugin-utils/context-helpers.d.mts +0 -106
- package/dist/plugin-utils/context-helpers.d.mts.map +0 -1
- package/dist/plugin-utils/context-helpers.mjs.map +0 -1
- package/dist/plugin-utils/deepkit.cjs +0 -70
- package/dist/plugin-utils/deepkit.cjs.map +0 -1
- package/dist/plugin-utils/deepkit.d.cts +0 -23
- package/dist/plugin-utils/deepkit.d.cts.map +0 -1
- package/dist/plugin-utils/deepkit.d.mts +0 -23
- package/dist/plugin-utils/deepkit.d.mts.map +0 -1
- package/dist/plugin-utils/deepkit.mjs +0 -69
- package/dist/plugin-utils/deepkit.mjs.map +0 -1
- package/dist/plugin-utils/description-helpers.cjs +0 -112
- package/dist/plugin-utils/description-helpers.cjs.map +0 -1
- package/dist/plugin-utils/description-helpers.d.cts +0 -44
- package/dist/plugin-utils/description-helpers.d.cts.map +0 -1
- package/dist/plugin-utils/description-helpers.d.mts +0 -44
- package/dist/plugin-utils/description-helpers.d.mts.map +0 -1
- package/dist/plugin-utils/description-helpers.mjs +0 -108
- package/dist/plugin-utils/description-helpers.mjs.map +0 -1
- package/dist/plugin-utils/get-command-tree.cjs +0 -118
- package/dist/plugin-utils/get-command-tree.cjs.map +0 -1
- package/dist/plugin-utils/get-command-tree.d.cts +0 -36
- package/dist/plugin-utils/get-command-tree.d.cts.map +0 -1
- package/dist/plugin-utils/get-command-tree.d.mts +0 -36
- package/dist/plugin-utils/get-command-tree.d.mts.map +0 -1
- package/dist/plugin-utils/get-command-tree.mjs +0 -115
- package/dist/plugin-utils/get-command-tree.mjs.map +0 -1
- package/dist/plugin-utils/reflect.cjs +0 -54
- package/dist/plugin-utils/reflect.cjs.map +0 -1
- package/dist/plugin-utils/reflect.d.cts +0 -14
- package/dist/plugin-utils/reflect.d.cts.map +0 -1
- package/dist/plugin-utils/reflect.d.mts +0 -14
- package/dist/plugin-utils/reflect.d.mts.map +0 -1
- package/dist/plugin-utils/reflect.mjs +0 -53
- package/dist/plugin-utils/reflect.mjs.map +0 -1
- package/dist/plugin-utils/traverse-command-tree.cjs +0 -65
- package/dist/plugin-utils/traverse-command-tree.cjs.map +0 -1
- package/dist/plugin-utils/traverse-command-tree.d.cts +0 -22
- package/dist/plugin-utils/traverse-command-tree.d.cts.map +0 -1
- package/dist/plugin-utils/traverse-command-tree.d.mts +0 -22
- package/dist/plugin-utils/traverse-command-tree.d.mts.map +0 -1
- package/dist/plugin-utils/traverse-command-tree.mjs +0 -63
- package/dist/plugin-utils/traverse-command-tree.mjs.map +0 -1
- package/dist/plugin-utils/type-checks.cjs +0 -222
- package/dist/plugin-utils/type-checks.cjs.map +0 -1
- package/dist/plugin-utils/type-checks.d.cts +0 -41
- package/dist/plugin-utils/type-checks.d.cts.map +0 -1
- package/dist/plugin-utils/type-checks.d.mts +0 -41
- package/dist/plugin-utils/type-checks.d.mts.map +0 -1
- package/dist/plugin-utils/type-checks.mjs +0 -218
- package/dist/plugin-utils/type-checks.mjs.map +0 -1
- package/dist/plugin.cjs.map +0 -1
- package/dist/plugin.mjs.map +0 -1
- package/dist/resolver/deepkit.cjs +0 -110
- package/dist/resolver/deepkit.cjs.map +0 -1
- package/dist/resolver/deepkit.mjs +0 -109
- package/dist/resolver/deepkit.mjs.map +0 -1
- package/dist/resolver/helpers.cjs +0 -184
- package/dist/resolver/helpers.cjs.map +0 -1
- package/dist/resolver/helpers.mjs +0 -180
- package/dist/resolver/helpers.mjs.map +0 -1
- package/dist/resolver/resolve.cjs +0 -473
- package/dist/resolver/resolve.cjs.map +0 -1
- package/dist/resolver/resolve.mjs +0 -473
- package/dist/resolver/resolve.mjs.map +0 -1
- package/dist/types/command.cjs.map +0 -1
- package/dist/types/command.d.cts.map +0 -1
- package/dist/types/command.d.mts.map +0 -1
- package/dist/types/command.mjs.map +0 -1
- package/dist/types/config.cjs.map +0 -1
- package/dist/types/config.d.cts.map +0 -1
- package/dist/types/config.d.mts.map +0 -1
- package/dist/types/config.mjs.map +0 -1
- package/dist/types/context.cjs.map +0 -1
- package/dist/types/context.d.cts.map +0 -1
- package/dist/types/context.d.mts.map +0 -1
- package/dist/types/context.mjs.map +0 -1
- package/dist/types/env.cjs +0 -53
- package/dist/types/env.cjs.map +0 -1
- package/dist/types/env.d.cts +0 -71
- package/dist/types/env.d.cts.map +0 -1
- package/dist/types/env.d.mts +0 -71
- package/dist/types/env.mjs +0 -51
- /package/dist/{types → schemas}/env.mjs.map +0 -0
|
@@ -1,10 +1,346 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { sortOptions } from "
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { a as getDynamicPathSegmentName, c as isDynamicPathSegment, i as getAppTitle, l as isPathSegmentGroup, n as getAppDescription, o as getPathSegmentGroupName, r as getAppName, s as getPathSegmentName, t as getAppBin, u as sortArgAliases } from "../context-helpers-D3EJxwbq.mjs";
|
|
2
|
+
import { t as sortOptions } from "../reflect-DXKSFgvS.mjs";
|
|
3
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
4
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
5
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
6
|
+
import { ReflectionKind } from "@deepkit/type";
|
|
7
|
+
import { isBoolean } from "@stryke/type-checks/is-boolean";
|
|
8
|
+
|
|
9
|
+
//#region src/plugin-utils/compute-bin.ts
|
|
10
|
+
/**
|
|
11
|
+
* Computes the command tree for the root binary command based on the provided context.
|
|
12
|
+
*
|
|
13
|
+
* @param context - The plugin context containing the necessary information to compute the command tree.
|
|
14
|
+
* @returns The computed command tree for the root binary command.
|
|
15
|
+
*/
|
|
16
|
+
function computeBin(context) {
|
|
17
|
+
return {
|
|
18
|
+
id: "",
|
|
19
|
+
name: getAppName(context),
|
|
20
|
+
title: getAppTitle(context),
|
|
21
|
+
description: getAppDescription(context),
|
|
22
|
+
virtual: true,
|
|
23
|
+
path: null,
|
|
24
|
+
segments: [],
|
|
25
|
+
alias: [],
|
|
26
|
+
tags: [],
|
|
27
|
+
options: Object.fromEntries(context.globalOptions.map((option) => [option.name, option])),
|
|
28
|
+
args: [],
|
|
29
|
+
entry: { file: joinPaths(context.entryPath, "bin.ts") },
|
|
30
|
+
parent: null,
|
|
31
|
+
children: context.commands,
|
|
32
|
+
docs: context.config.docs?.app
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/plugin-utils/type-checks.ts
|
|
38
|
+
function isStringArray(value) {
|
|
39
|
+
return Array.isArray(value) && value.every((item) => isSetString(item));
|
|
40
|
+
}
|
|
41
|
+
function isNumberArray(value) {
|
|
42
|
+
return Array.isArray(value) && value.every((item) => typeof item === "number" && Number.isFinite(item));
|
|
43
|
+
}
|
|
44
|
+
function isBooleanArray(value) {
|
|
45
|
+
return Array.isArray(value) && value.every((item) => isBoolean(item));
|
|
46
|
+
}
|
|
47
|
+
function isAliasConfig(value) {
|
|
48
|
+
return isSetString(value) || isStringArray(value);
|
|
49
|
+
}
|
|
50
|
+
function isTypedDefaultValue(type, value, variadic) {
|
|
51
|
+
if (type === "string") {
|
|
52
|
+
if (variadic === true) return isStringArray(value);
|
|
53
|
+
if (variadic === false) return isSetString(value);
|
|
54
|
+
return isSetString(value) || isStringArray(value);
|
|
55
|
+
}
|
|
56
|
+
if (type === "number") {
|
|
57
|
+
if (variadic === true) return isNumberArray(value);
|
|
58
|
+
if (variadic === false) return typeof value === "number" && Number.isFinite(value);
|
|
59
|
+
return typeof value === "number" && Number.isFinite(value) || isNumberArray(value);
|
|
60
|
+
}
|
|
61
|
+
if (variadic === true) return isBooleanArray(value);
|
|
62
|
+
if (variadic === false) return isBoolean(value);
|
|
63
|
+
return isBoolean(value) || isBooleanArray(value);
|
|
64
|
+
}
|
|
65
|
+
function hasValidOptionalCommonFields(obj) {
|
|
66
|
+
if ("alias" in obj && obj.alias !== void 0 && !isAliasConfig(obj.alias)) return false;
|
|
67
|
+
if ("name" in obj && obj.name !== void 0 && !isSetString(obj.name)) return false;
|
|
68
|
+
if ("title" in obj && obj.title !== void 0 && !isSetString(obj.title)) return false;
|
|
69
|
+
if ("description" in obj && obj.description !== void 0 && !isSetString(obj.description)) return false;
|
|
70
|
+
if ("env" in obj && obj.env !== void 0 && !(isSetString(obj.env) || obj.env === false)) return false;
|
|
71
|
+
if ("required" in obj && obj.required !== void 0 && !isBoolean(obj.required)) return false;
|
|
72
|
+
if ("variadic" in obj && obj.variadic !== void 0 && !isBoolean(obj.variadic)) return false;
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
function hasValidTypeSpecificFields(obj, type) {
|
|
76
|
+
const variadic = isBoolean(obj.variadic) ? obj.variadic : void 0;
|
|
77
|
+
if ("default" in obj && obj.default !== void 0 && !isTypedDefaultValue(type, obj.default, variadic)) return false;
|
|
78
|
+
if (type === "string") {
|
|
79
|
+
if ("format" in obj && obj.format !== void 0 && !isSetString(obj.format)) return false;
|
|
80
|
+
if ("choices" in obj && obj.choices !== void 0 && !isStringArray(obj.choices)) return false;
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
if (type === "number") {
|
|
84
|
+
if ("choices" in obj && obj.choices !== void 0 && !isNumberArray(obj.choices)) return false;
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
if ("choices" in obj && obj.choices !== void 0) return false;
|
|
88
|
+
if ("format" in obj && obj.format !== void 0) return false;
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Type guard to check if a value is a valid {@link CommandParameterType} type.
|
|
93
|
+
*
|
|
94
|
+
* @param obj - The value to check.
|
|
95
|
+
* @returns True if the value is a valid {@link CommandParameterType} type, false otherwise.
|
|
96
|
+
*/
|
|
97
|
+
function isCommandParameterType(obj) {
|
|
98
|
+
return isSetString(obj) && [
|
|
99
|
+
"string",
|
|
100
|
+
"number",
|
|
101
|
+
"boolean"
|
|
102
|
+
].includes(obj);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Type guard to check if a value is a valid {@link CommandParameterConfig} type.
|
|
106
|
+
*
|
|
107
|
+
* @param obj - The value to check.
|
|
108
|
+
* @returns True if the value is a valid {@link CommandParameterConfig} type, false otherwise.
|
|
109
|
+
*/
|
|
110
|
+
function isCommandParameterConfig(obj) {
|
|
111
|
+
if (!isSetObject(obj) || !("type" in obj) || !isCommandParameterType(obj.type)) return false;
|
|
112
|
+
return hasValidOptionalCommonFields(obj) && hasValidTypeSpecificFields(obj, obj.type);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Type guard to check if a value is a valid {@link CommandParameter} type.
|
|
116
|
+
*
|
|
117
|
+
* @param obj - The value to check.
|
|
118
|
+
* @returns True if the value is a valid {@link CommandParameter} type, false otherwise.
|
|
119
|
+
*/
|
|
120
|
+
function isCommandParameter(obj) {
|
|
121
|
+
if (!isCommandParameterConfig(obj)) return false;
|
|
122
|
+
if (!("name" in obj) || !isSetString(obj.name)) return false;
|
|
123
|
+
if (!("title" in obj) || !isSetString(obj.title)) return false;
|
|
124
|
+
if (!("description" in obj) || !isSetString(obj.description)) return false;
|
|
125
|
+
if (!("alias" in obj) || !isStringArray(obj.alias)) return false;
|
|
126
|
+
if (!("env" in obj) || !(isSetString(obj.env) || obj.env === false)) return false;
|
|
127
|
+
if (!("required" in obj) || !isBoolean(obj.required)) return false;
|
|
128
|
+
if (!("variadic" in obj) || !isBoolean(obj.variadic)) return false;
|
|
129
|
+
return hasValidTypeSpecificFields(obj, obj.type);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Type guard to check if a value is a valid {@link CommandOption} type.
|
|
133
|
+
*
|
|
134
|
+
* @param obj - The value to check.
|
|
135
|
+
* @returns True if the value is a valid {@link CommandOption} type, false otherwise.
|
|
136
|
+
*/
|
|
137
|
+
function isCommandOption(obj) {
|
|
138
|
+
if (!isCommandParameter(obj)) return false;
|
|
139
|
+
if (obj.type !== "boolean") return true;
|
|
140
|
+
if ("isNegativeOf" in obj && obj.isNegativeOf !== void 0 && !isSetString(obj.isNegativeOf)) return false;
|
|
141
|
+
if ("skipAddingNegative" in obj && obj.skipAddingNegative !== void 0 && !isBoolean(obj.skipAddingNegative)) return false;
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Type guard to check if a value is a valid {@link CommandArgument} type.
|
|
146
|
+
*
|
|
147
|
+
* @param obj - The value to check.
|
|
148
|
+
* @returns True if the value is a valid {@link CommandArgument} type, false otherwise.
|
|
149
|
+
*/
|
|
150
|
+
function isCommandArgument(obj) {
|
|
151
|
+
return isCommandParameter(obj);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
//#endregion
|
|
155
|
+
//#region src/plugin-utils/deepkit.ts
|
|
156
|
+
/**
|
|
157
|
+
* Extracts a {@link ReflectionKind} from a {@link BaseCommandParameter} or {@link CommandParameterType}.
|
|
158
|
+
*
|
|
159
|
+
* @param command - The command parameter or kind to extract the reflection kind from.
|
|
160
|
+
* @param checkVariadic - Whether to check for variadic parameters (arrays).
|
|
161
|
+
* @returns The extracted {@link ReflectionKind}.
|
|
162
|
+
*/
|
|
163
|
+
function extractReflectionKind(command, checkVariadic = true) {
|
|
164
|
+
if (isCommandParameterType(command) && command === "string" || isSetObject(command) && command.type === "string") return checkVariadic && command.variadic ? ReflectionKind.array : ReflectionKind.string;
|
|
165
|
+
else if (isCommandParameterType(command) && command === "number" || isSetObject(command) && command.type === "number") return checkVariadic && command.variadic ? ReflectionKind.array : ReflectionKind.number;
|
|
166
|
+
else if (isCommandParameterType(command) && command === "boolean" || isSetObject(command) && command.type === "boolean") return ReflectionKind.boolean;
|
|
167
|
+
else return ReflectionKind.string;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Extracts a {@link Type} from a {@link BaseCommandParameter} or {@link CommandParameterType}.
|
|
171
|
+
*
|
|
172
|
+
* @param command - The command parameter or kind to extract the type from.
|
|
173
|
+
* @param checkVariadic - Whether to check for variadic parameters (arrays).
|
|
174
|
+
* @returns The extracted {@link Type}.
|
|
175
|
+
*/
|
|
176
|
+
function extractType(command, checkVariadic = true) {
|
|
177
|
+
const reflectionKind = extractReflectionKind(command, checkVariadic);
|
|
178
|
+
if (reflectionKind === ReflectionKind.string) return { kind: ReflectionKind.string };
|
|
179
|
+
else if (reflectionKind === ReflectionKind.number) return { kind: ReflectionKind.number };
|
|
180
|
+
else if (reflectionKind === ReflectionKind.boolean) return { kind: ReflectionKind.boolean };
|
|
181
|
+
else if (reflectionKind === ReflectionKind.array) {
|
|
182
|
+
if (isCommandParameterType(command)) return {
|
|
183
|
+
kind: ReflectionKind.array,
|
|
184
|
+
type: extractType({ type: command }, false)
|
|
185
|
+
};
|
|
186
|
+
else if (isSetObject(command)) return {
|
|
187
|
+
kind: ReflectionKind.array,
|
|
188
|
+
type: extractType({
|
|
189
|
+
...command,
|
|
190
|
+
type: command.type
|
|
191
|
+
}, false)
|
|
192
|
+
};
|
|
193
|
+
else return {
|
|
194
|
+
kind: ReflectionKind.array,
|
|
195
|
+
type: { kind: ReflectionKind.string }
|
|
196
|
+
};
|
|
197
|
+
} else return { kind: ReflectionKind.string };
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/plugin-utils/description-helpers.ts
|
|
202
|
+
/**
|
|
203
|
+
* Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.
|
|
204
|
+
*
|
|
205
|
+
* @remarks
|
|
206
|
+
* This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.
|
|
207
|
+
*
|
|
208
|
+
* @param description - The full description string.
|
|
209
|
+
* @returns The formatted description string.
|
|
210
|
+
*/
|
|
211
|
+
function formatDescriptionWhitespace(description, options = {}) {
|
|
212
|
+
let formattedDescription = description.trim();
|
|
213
|
+
if (options.replaceNewlines) formattedDescription = formattedDescription.replace(/\s*\n\s*/g, " ");
|
|
214
|
+
if (options.collapseWhitespace) formattedDescription = formattedDescription.replace(/\s{2,}/g, " ");
|
|
215
|
+
return formattedDescription.trim();
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.
|
|
219
|
+
*
|
|
220
|
+
* @remarks
|
|
221
|
+
* This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.
|
|
222
|
+
*
|
|
223
|
+
* @param description - The full description string.
|
|
224
|
+
* @returns The formatted description string.
|
|
225
|
+
*/
|
|
226
|
+
function formatDescriptionEscapes(description) {
|
|
227
|
+
return description.replaceAll("'", "\\'").replaceAll("\"", "\\\"").replaceAll("`", "\\`").replace(/\$\{/g, "\\${");
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Formats a description string by trimming whitespace, replacing newlines with spaces (optionally), collapsing multiple spaces into a single space (optionally), and escaping special characters.
|
|
231
|
+
*
|
|
232
|
+
* @remarks
|
|
233
|
+
* This is useful for ensuring that descriptions are concise and well-formatted when displayed in the CLI or documentation.
|
|
234
|
+
*
|
|
235
|
+
* @param description - The full description string.
|
|
236
|
+
* @returns The formatted description string.
|
|
237
|
+
*/
|
|
238
|
+
function formatDescription(description, options = {}) {
|
|
239
|
+
return formatDescriptionEscapes(formatDescriptionWhitespace(description, options));
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Extracts the short description from a longer description string. The short description is typically the first sentence or the first line of the description.
|
|
243
|
+
*
|
|
244
|
+
* @param description - The full description string.
|
|
245
|
+
* @param options - Options for formatting the short description, including the maximum length.
|
|
246
|
+
* @returns The extracted short description.
|
|
247
|
+
*/
|
|
248
|
+
function formatShortDescription(description, options = {}) {
|
|
249
|
+
const length = options.length ?? 62;
|
|
250
|
+
const formattedDescription = formatDescriptionWhitespace(description, options);
|
|
251
|
+
let result = ((formattedDescription.indexOf("\n") < length - 3 || formattedDescription.search(/[.!?\n]\s*\S/) > length - 3 ? formattedDescription.match(/^.*[.!?\n]\s?\S/)?.[0]?.trim()?.slice(0, -1)?.trim() : void 0) || formattedDescription).trim();
|
|
252
|
+
if (result.trim().length > length) result = `${result.substring(0, Math.max(0, length - 3)).trim()}...`;
|
|
253
|
+
return formatDescriptionEscapes(result);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/plugin-utils/traverse-command-tree.ts
|
|
258
|
+
/**
|
|
259
|
+
* Traverses a command tree and applies a visitor function to each node.
|
|
260
|
+
*
|
|
261
|
+
* @param commandTree - The command tree to traverse.
|
|
262
|
+
* @param visitor - The visitor function to apply to each node.
|
|
263
|
+
*/
|
|
264
|
+
async function traverseCommandTree(commandTree, visitor) {
|
|
265
|
+
if (!commandTree.children) return;
|
|
266
|
+
await Promise.all(Object.values(commandTree.children).map(async (childTree) => {
|
|
267
|
+
await Promise.resolve(visitor(childTree));
|
|
268
|
+
await traverseCommandTree(childTree, visitor);
|
|
269
|
+
}));
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Traverses all commands in the context and applies a visitor function to each command tree.
|
|
273
|
+
*
|
|
274
|
+
* @param context - The build context containing the command definitions.
|
|
275
|
+
* @param visitor - The visitor function to apply to each command tree.
|
|
276
|
+
*/
|
|
277
|
+
async function traverseCommands(context, visitor) {
|
|
278
|
+
if (!context.commands) return;
|
|
279
|
+
await Promise.all(Object.values(context.commands).map(async (childTree) => {
|
|
280
|
+
await Promise.resolve(visitor(childTree));
|
|
281
|
+
await traverseCommandTree(childTree, visitor);
|
|
282
|
+
}));
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region src/plugin-utils/get-command-tree.ts
|
|
287
|
+
/**
|
|
288
|
+
* Retrieves a specific command tree based on the provided path.
|
|
289
|
+
*
|
|
290
|
+
* @param context - The build context containing the command definitions.
|
|
291
|
+
* @param path - An array of strings representing the command path.
|
|
292
|
+
* @returns The command tree at the specified path, or null if not found.
|
|
293
|
+
*/
|
|
294
|
+
function getCommandTree(context, path = []) {
|
|
295
|
+
if (path.length === 0) return null;
|
|
296
|
+
let currentTree = context.commands[path[0]] ?? null;
|
|
297
|
+
if (path.length > 1) {
|
|
298
|
+
const segments = path.slice(1).filter((segment) => !isDynamicPathSegment(segment));
|
|
299
|
+
for (const segment of segments) if (currentTree?.children && Object.prototype.hasOwnProperty.call(currentTree.children, segment)) currentTree = currentTree.children[segment] ?? null;
|
|
300
|
+
else return null;
|
|
301
|
+
}
|
|
302
|
+
return currentTree;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Retrieves a list of all command trees defined in the context.
|
|
306
|
+
*
|
|
307
|
+
* @param context - The build context containing the command definitions.
|
|
308
|
+
* @returns A promise that resolves to an array of all command trees in the context.
|
|
309
|
+
*/
|
|
310
|
+
async function getCommandList(context) {
|
|
311
|
+
const commandList = [];
|
|
312
|
+
await traverseCommands(context, (commandTree) => {
|
|
313
|
+
commandList.push(commandTree);
|
|
314
|
+
});
|
|
315
|
+
return commandList;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Retrieves a list of all command paths defined in the context.
|
|
319
|
+
*
|
|
320
|
+
* @param context - The build context containing the command definitions.
|
|
321
|
+
* @returns A promise that resolves to an array of all command paths in the context.
|
|
322
|
+
*/
|
|
323
|
+
async function getCommandPaths(context) {
|
|
324
|
+
const commandPaths = [];
|
|
325
|
+
await traverseCommands(context, (commandTree) => {
|
|
326
|
+
if (commandTree.path) commandPaths.push(commandTree.path);
|
|
327
|
+
});
|
|
328
|
+
return commandPaths;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Retrieves a list of all command segments defined in the context.
|
|
332
|
+
*
|
|
333
|
+
* @param context - The build context containing the command definitions.
|
|
334
|
+
* @returns A promise that resolves to an array of all command segments in the context.
|
|
335
|
+
*/
|
|
336
|
+
async function getCommandSegments(context) {
|
|
337
|
+
const commandSegments = [];
|
|
338
|
+
await traverseCommands(context, (commandTree) => {
|
|
339
|
+
if (commandTree.path) commandSegments.push(commandTree.segments);
|
|
340
|
+
});
|
|
341
|
+
return commandSegments;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
//#endregion
|
|
345
|
+
export { computeBin, extractReflectionKind, extractType, formatDescription, formatShortDescription, getAppBin, getAppDescription, getAppName, getAppTitle, getCommandList, getCommandPaths, getCommandSegments, getCommandTree, getDynamicPathSegmentName, getPathSegmentGroupName, getPathSegmentName, isCommandArgument, isCommandOption, isCommandParameter, isCommandParameterConfig, isCommandParameterType, isDynamicPathSegment, isPathSegmentGroup, sortArgAliases, sortOptions, traverseCommandTree, traverseCommands };
|
|
346
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":[],"mappings":""}
|