@shell-shock/core 0.9.7 → 0.11.0
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/api.cjs +1 -2
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.cts +1 -1
- package/dist/api.d.mts +1 -1
- package/dist/api.mjs +1 -2
- package/dist/api.mjs.map +1 -1
- package/dist/components/docs.cjs +4 -4
- package/dist/components/docs.cjs.map +1 -1
- package/dist/components/docs.d.cts +5 -5
- package/dist/components/docs.d.mts +5 -5
- package/dist/components/helpers.d.cts +6 -6
- package/dist/components/helpers.d.mts +6 -6
- package/dist/components/helpers.d.mts.map +1 -1
- package/dist/components/index.cjs +1 -0
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.mts +2 -2
- package/dist/components/index.mjs +2 -2
- package/dist/components/options-parser-logic.cjs +31 -31
- package/dist/components/options-parser-logic.cjs.map +1 -1
- package/dist/components/options-parser-logic.d.cts +9 -9
- package/dist/components/options-parser-logic.d.cts.map +1 -1
- package/dist/components/options-parser-logic.d.mts +9 -9
- package/dist/components/options-parser-logic.d.mts.map +1 -1
- package/dist/components/options-parser-logic.mjs +26 -26
- package/dist/components/options-parser-logic.mjs.map +1 -1
- package/dist/components/usage.cjs +5 -5
- package/dist/components/usage.cjs.map +1 -1
- package/dist/components/usage.d.cts +2 -2
- package/dist/components/usage.d.cts.map +1 -1
- package/dist/components/usage.mjs +4 -4
- package/dist/components/usage.mjs.map +1 -1
- package/dist/components/utils-builtin.cjs +204 -0
- package/dist/components/utils-builtin.cjs.map +1 -1
- package/dist/components/utils-builtin.d.cts +13 -9
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts +13 -9
- package/dist/components/utils-builtin.d.mts.map +1 -1
- package/dist/components/utils-builtin.mjs +208 -5
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/contexts/options.cjs +2 -2
- package/dist/contexts/options.cjs.map +1 -1
- package/dist/contexts/options.d.cts +1 -1
- package/dist/contexts/options.d.cts.map +1 -1
- package/dist/contexts/options.d.mts +1 -1
- package/dist/contexts/options.d.mts.map +1 -1
- package/dist/contexts/options.mjs +4 -4
- package/dist/contexts/options.mjs.map +1 -1
- package/dist/helpers/automd.cjs +2 -2
- package/dist/helpers/automd.cjs.map +1 -1
- package/dist/helpers/automd.mjs.map +1 -1
- package/dist/helpers/docs-helpers.cjs +1 -1
- package/dist/helpers/docs-helpers.cjs.map +1 -1
- package/dist/helpers/docs-helpers.mjs +1 -1
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/paths.cjs +125 -0
- package/dist/helpers/paths.cjs.map +1 -0
- package/dist/helpers/paths.mjs +121 -0
- package/dist/helpers/paths.mjs.map +1 -0
- package/dist/helpers/persistence.cjs +68 -116
- package/dist/helpers/persistence.cjs.map +1 -1
- package/dist/helpers/persistence.mjs +68 -116
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +5 -5
- package/dist/helpers/update-package-json.cjs.map +1 -1
- package/dist/helpers/update-package-json.mjs +1 -1
- package/dist/helpers/update-package-json.mjs.map +1 -1
- package/dist/helpers/utilities.cjs +1 -1
- package/dist/helpers/utilities.mjs +1 -1
- package/dist/helpers/validations.cjs +2 -3
- package/dist/helpers/validations.cjs.map +1 -1
- package/dist/helpers/validations.mjs +2 -2
- package/dist/helpers/validations.mjs.map +1 -1
- package/dist/index.cjs +14 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -4
- package/dist/index.d.mts +2 -4
- package/dist/index.mjs +3 -5
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-utils/deepkit.cjs +72 -0
- package/dist/plugin-utils/deepkit.cjs.map +1 -0
- package/dist/plugin-utils/deepkit.d.cts +24 -0
- package/dist/plugin-utils/deepkit.d.cts.map +1 -0
- package/dist/plugin-utils/deepkit.d.mts +24 -0
- package/dist/plugin-utils/deepkit.d.mts.map +1 -0
- package/dist/plugin-utils/deepkit.mjs +70 -0
- package/dist/plugin-utils/deepkit.mjs.map +1 -0
- package/dist/plugin-utils/get-command-tree.cjs +2 -2
- package/dist/plugin-utils/get-command-tree.cjs.map +1 -1
- package/dist/plugin-utils/index.cjs +27 -18
- package/dist/plugin-utils/index.d.cts +3 -1
- package/dist/plugin-utils/index.d.mts +3 -1
- package/dist/plugin-utils/index.mjs +3 -1
- package/dist/plugin-utils/reflect.cjs +4 -5
- package/dist/plugin-utils/reflect.cjs.map +1 -1
- package/dist/plugin-utils/reflect.mjs +4 -4
- package/dist/plugin-utils/reflect.mjs.map +1 -1
- package/dist/plugin-utils/type-checks.cjs +89 -0
- package/dist/plugin-utils/type-checks.cjs.map +1 -0
- package/dist/plugin-utils/type-checks.d.cts +42 -0
- package/dist/plugin-utils/type-checks.d.cts.map +1 -0
- package/dist/plugin-utils/type-checks.d.mts +42 -0
- package/dist/plugin-utils/type-checks.d.mts.map +1 -0
- package/dist/plugin-utils/type-checks.mjs +84 -0
- package/dist/plugin-utils/type-checks.mjs.map +1 -0
- package/dist/plugin.cjs +48 -45
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +30 -26
- package/dist/plugin.mjs.map +1 -1
- package/dist/resolver/deepkit.cjs +129 -0
- package/dist/resolver/deepkit.cjs.map +1 -0
- package/dist/resolver/deepkit.mjs +128 -0
- package/dist/resolver/deepkit.mjs.map +1 -0
- package/dist/resolver/helpers.cjs +173 -0
- package/dist/resolver/helpers.cjs.map +1 -0
- package/dist/resolver/helpers.mjs +168 -0
- package/dist/resolver/helpers.mjs.map +1 -0
- package/dist/resolver/module.cjs +144 -0
- package/dist/resolver/module.cjs.map +1 -0
- package/dist/resolver/module.mjs +143 -0
- package/dist/resolver/module.mjs.map +1 -0
- package/dist/resolver/resolve.cjs +209 -0
- package/dist/resolver/resolve.cjs.map +1 -0
- package/dist/resolver/resolve.mjs +208 -0
- package/dist/resolver/resolve.mjs.map +1 -0
- package/dist/types/command.cjs +131 -99
- package/dist/types/command.cjs.map +1 -1
- package/dist/types/command.d.cts +49 -75
- package/dist/types/command.d.cts.map +1 -1
- package/dist/types/command.d.mts +49 -75
- package/dist/types/command.d.mts.map +1 -1
- package/dist/types/command.mjs +119 -91
- package/dist/types/command.mjs.map +1 -1
- package/dist/types/config.cjs +1 -2
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.cts +2 -2
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +2 -2
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +1 -2
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/context.cjs +1 -1
- package/dist/types/context.cjs.map +1 -1
- package/dist/types/context.d.cts +3 -3
- package/dist/types/context.d.cts.map +1 -1
- package/dist/types/context.d.mts +3 -3
- package/dist/types/context.d.mts.map +1 -1
- package/dist/types/context.mjs +1 -1
- package/dist/types/context.mjs.map +1 -1
- package/dist/types/index.cjs +13 -9
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.mjs +2 -2
- package/package.json +34 -79
- package/dist/helpers/resolve-command.cjs +0 -410
- package/dist/helpers/resolve-command.cjs.map +0 -1
- package/dist/helpers/resolve-command.mjs +0 -405
- package/dist/helpers/resolve-command.mjs.map +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
1
|
+
const require_types_command = require('../types/command.cjs');
|
|
3
2
|
|
|
4
3
|
//#region src/plugin-utils/reflect.ts
|
|
5
4
|
function __assignType(fn, args) {
|
|
@@ -14,7 +13,7 @@ function __assignType(fn, args) {
|
|
|
14
13
|
*/
|
|
15
14
|
function sortOptions(options) {
|
|
16
15
|
if (!options || options.length === 0) return [];
|
|
17
|
-
return options.filter(__assignType((arg) => arg.kind !==
|
|
16
|
+
return options.filter(__assignType((arg) => arg.kind !== require_types_command.CommandParameterKinds.boolean || !arg.isNegativeOf, [
|
|
18
17
|
"arg",
|
|
19
18
|
"",
|
|
20
19
|
"P\"2!\"/\""
|
|
@@ -25,8 +24,8 @@ function sortOptions(options) {
|
|
|
25
24
|
"P\"2!\"2\"\"/#"
|
|
26
25
|
])).reduce(__assignType((ret, arg) => {
|
|
27
26
|
ret.push(arg);
|
|
28
|
-
if (arg.kind ===
|
|
29
|
-
const negativeArg = options.find(__assignType((a) => a.kind ===
|
|
27
|
+
if (arg.kind === require_types_command.CommandParameterKinds.boolean) {
|
|
28
|
+
const negativeArg = options.find(__assignType((a) => a.kind === require_types_command.CommandParameterKinds.boolean && a.isNegativeOf === arg.name, [
|
|
30
29
|
"a",
|
|
31
30
|
"",
|
|
32
31
|
"P\"2!\"/\""
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reflect.cjs","names":[],"sources":["../../src/plugin-utils/reflect.ts"],"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 {
|
|
1
|
+
{"version":3,"file":"reflect.cjs","names":[],"sources":["../../src/plugin-utils/reflect.ts"],"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 type { CommandOption } from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\n\n/**\n * Sort command options alphabetically by name, placing boolean options with negatives appropriately.\n *\n * @param options - The array of command options to sort.\n * @returns A new array of sorted command options.\n */\nexport function sortOptions(options: CommandOption[]): CommandOption[] {\n if (!options || options.length === 0) {\n return [];\n }\n\n return options\n .filter(\n arg => arg.kind !== CommandParameterKinds.boolean || !arg.isNegativeOf\n )\n .sort((a, b) => a.name.localeCompare(b.name))\n .reduce((ret, arg) => {\n ret.push(arg);\n\n if (arg.kind === CommandParameterKinds.boolean) {\n // Add the negative argument if it exists\n const negativeArg = options.find(\n a =>\n a.kind === CommandParameterKinds.boolean &&\n a.isNegativeOf === arg.name\n );\n if (negativeArg) {\n ret.push(negativeArg);\n }\n }\n\n return ret;\n }, [] as CommandOption[]);\n}\n"],"mappings":";;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;AASX,SAAgB,YAAY,SAAS;AACjC,KAAI,CAAC,WAAW,QAAQ,WAAW;gBAI9B,OAAO,cAAa,QAAO,IAAI,SAAS,4CAAqB,WAAA,CAAA,IAAA,cAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA;;;;;KAE7D,OAAO,cAAc,KAAK,QAAQ;AACnC,MAAI,KAAK,IAAI;;GAGT,MAAM,cAAc,QAAQ,KAAK,cAAa,MAAK,EAAE,SAAS,4CAAsB,WAC/F,EAAA,iBAAA,IAAA,MAAA;IAAA;IAAA;IAAA;IAAA,CAAA,CAAA;AACW,OAAI,YACA,KAAI,KAAK,YAAY;;AAG7B,SAAO;IACR;EAAC;EAAK;EAAA;EAAA;EAAA,CAAA,EAAA,EAAA,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CommandParameterKinds } from "../types/command.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin-utils/reflect.ts
|
|
4
4
|
function __assignType(fn, args) {
|
|
@@ -13,7 +13,7 @@ function __assignType(fn, args) {
|
|
|
13
13
|
*/
|
|
14
14
|
function sortOptions(options) {
|
|
15
15
|
if (!options || options.length === 0) return [];
|
|
16
|
-
return options.filter(__assignType((arg) => arg.kind !==
|
|
16
|
+
return options.filter(__assignType((arg) => arg.kind !== CommandParameterKinds.boolean || !arg.isNegativeOf, [
|
|
17
17
|
"arg",
|
|
18
18
|
"",
|
|
19
19
|
"P\"2!\"/\""
|
|
@@ -24,8 +24,8 @@ function sortOptions(options) {
|
|
|
24
24
|
"P\"2!\"2\"\"/#"
|
|
25
25
|
])).reduce(__assignType((ret, arg) => {
|
|
26
26
|
ret.push(arg);
|
|
27
|
-
if (arg.kind ===
|
|
28
|
-
const negativeArg = options.find(__assignType((a) => a.kind ===
|
|
27
|
+
if (arg.kind === CommandParameterKinds.boolean) {
|
|
28
|
+
const negativeArg = options.find(__assignType((a) => a.kind === CommandParameterKinds.boolean && a.isNegativeOf === arg.name, [
|
|
29
29
|
"a",
|
|
30
30
|
"",
|
|
31
31
|
"P\"2!\"/\""
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reflect.mjs","names":[],"sources":["../../src/plugin-utils/reflect.ts"],"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 {
|
|
1
|
+
{"version":3,"file":"reflect.mjs","names":[],"sources":["../../src/plugin-utils/reflect.ts"],"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 type { CommandOption } from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\n\n/**\n * Sort command options alphabetically by name, placing boolean options with negatives appropriately.\n *\n * @param options - The array of command options to sort.\n * @returns A new array of sorted command options.\n */\nexport function sortOptions(options: CommandOption[]): CommandOption[] {\n if (!options || options.length === 0) {\n return [];\n }\n\n return options\n .filter(\n arg => arg.kind !== CommandParameterKinds.boolean || !arg.isNegativeOf\n )\n .sort((a, b) => a.name.localeCompare(b.name))\n .reduce((ret, arg) => {\n ret.push(arg);\n\n if (arg.kind === CommandParameterKinds.boolean) {\n // Add the negative argument if it exists\n const negativeArg = options.find(\n a =>\n a.kind === CommandParameterKinds.boolean &&\n a.isNegativeOf === arg.name\n );\n if (negativeArg) {\n ret.push(negativeArg);\n }\n }\n\n return ret;\n }, [] as CommandOption[]);\n}\n"],"mappings":";;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;AASX,SAAgB,YAAY,SAAS;AACjC,KAAI,CAAC,WAAW,QAAQ,WAAW;gBAI9B,OAAO,cAAa,QAAO,IAAI,SAAS,sBAAqB,WAAA,CAAA,IAAA,cAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA;;;;;KAE7D,OAAO,cAAc,KAAK,QAAQ;AACnC,MAAI,KAAK,IAAI;;GAGT,MAAM,cAAc,QAAQ,KAAK,cAAa,MAAK,EAAE,SAAS,sBAAsB,WAC/F,EAAA,iBAAA,IAAA,MAAA;IAAA;IAAA;IAAA;IAAA,CAAA,CAAA;AACW,OAAI,YACA,KAAI,KAAK,YAAY;;AAG7B,SAAO;IACR;EAAC;EAAK;EAAA;EAAA;EAAA,CAAA,EAAA,EAAA,CAAA"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_types_command = require('../types/command.cjs');
|
|
3
|
+
let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
4
|
+
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
5
|
+
let __stryke_type_checks_is_boolean = require("@stryke/type-checks/is-boolean");
|
|
6
|
+
|
|
7
|
+
//#region src/plugin-utils/type-checks.ts
|
|
8
|
+
/**
|
|
9
|
+
* Type guard to check if a value is a valid {@link CommandParameterKind} type.
|
|
10
|
+
*
|
|
11
|
+
* @param obj - The value to check.
|
|
12
|
+
* @returns True if the value is a valid {@link CommandParameterKind} type, false otherwise.
|
|
13
|
+
*/
|
|
14
|
+
function isCommandParameterKind(obj) {
|
|
15
|
+
return (0, __stryke_type_checks_is_set_string.isSetString)(obj) && [
|
|
16
|
+
require_types_command.CommandParameterKinds.string,
|
|
17
|
+
require_types_command.CommandParameterKinds.number,
|
|
18
|
+
require_types_command.CommandParameterKinds.boolean
|
|
19
|
+
].includes(obj);
|
|
20
|
+
}
|
|
21
|
+
isCommandParameterKind.__type = [
|
|
22
|
+
"obj",
|
|
23
|
+
"isCommandParameterKind",
|
|
24
|
+
"P\"2!!/\""
|
|
25
|
+
];
|
|
26
|
+
/**
|
|
27
|
+
* Type guard to check if a value is a valid {@link CommandParameterConfig} type.
|
|
28
|
+
*
|
|
29
|
+
* @param obj - The value to check.
|
|
30
|
+
* @returns True if the value is a valid {@link CommandParameterConfig} type, false otherwise.
|
|
31
|
+
*/
|
|
32
|
+
function isCommandParameterConfig(obj) {
|
|
33
|
+
return (0, __stryke_type_checks_is_set_object.isSetObject)(obj) && "kind" in obj && isCommandParameterKind(obj.kind);
|
|
34
|
+
}
|
|
35
|
+
isCommandParameterConfig.__type = [
|
|
36
|
+
"obj",
|
|
37
|
+
"isCommandParameterConfig",
|
|
38
|
+
"P\"2!!/\""
|
|
39
|
+
];
|
|
40
|
+
/**
|
|
41
|
+
* Type guard to check if a value is a valid {@link CommandParameter} type.
|
|
42
|
+
*
|
|
43
|
+
* @param obj - The value to check.
|
|
44
|
+
* @returns True if the value is a valid {@link CommandParameter} type, false otherwise.
|
|
45
|
+
*/
|
|
46
|
+
function isCommandParameter(obj) {
|
|
47
|
+
return isCommandParameterConfig(obj) && "name" in obj && (0, __stryke_type_checks_is_set_string.isSetString)(obj.name) && "title" in obj && (0, __stryke_type_checks_is_set_string.isSetString)(obj.title) && "description" in obj && (0, __stryke_type_checks_is_set_string.isSetString)(obj.description) && "alias" in obj && Array.isArray(obj.alias) && "env" in obj && ((0, __stryke_type_checks_is_set_string.isSetString)(obj.env) || obj.env === false) && "optional" in obj && (0, __stryke_type_checks_is_boolean.isBoolean)(obj.optional) && "variadic" in obj && (0, __stryke_type_checks_is_boolean.isBoolean)(obj.variadic);
|
|
48
|
+
}
|
|
49
|
+
isCommandParameter.__type = [
|
|
50
|
+
"obj",
|
|
51
|
+
"isCommandParameter",
|
|
52
|
+
"P\"2!!/\""
|
|
53
|
+
];
|
|
54
|
+
/**
|
|
55
|
+
* Type guard to check if a value is a valid {@link CommandOption} type.
|
|
56
|
+
*
|
|
57
|
+
* @param obj - The value to check.
|
|
58
|
+
* @returns True if the value is a valid {@link CommandOption} type, false otherwise.
|
|
59
|
+
*/
|
|
60
|
+
function isCommandOption(obj) {
|
|
61
|
+
return isCommandParameterConfig(obj) && isCommandParameter(obj) && "default" in obj;
|
|
62
|
+
}
|
|
63
|
+
isCommandOption.__type = [
|
|
64
|
+
"obj",
|
|
65
|
+
"isCommandOption",
|
|
66
|
+
"P\"2!!/\""
|
|
67
|
+
];
|
|
68
|
+
/**
|
|
69
|
+
* Type guard to check if a value is a valid {@link CommandArgument} type.
|
|
70
|
+
*
|
|
71
|
+
* @param obj - The value to check.
|
|
72
|
+
* @returns True if the value is a valid {@link CommandArgument} type, false otherwise.
|
|
73
|
+
*/
|
|
74
|
+
function isCommandArgument(obj) {
|
|
75
|
+
return isCommandParameterConfig(obj) && isCommandParameter(obj);
|
|
76
|
+
}
|
|
77
|
+
isCommandArgument.__type = [
|
|
78
|
+
"obj",
|
|
79
|
+
"isCommandArgument",
|
|
80
|
+
"P\"2!!/\""
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
84
|
+
exports.isCommandArgument = isCommandArgument;
|
|
85
|
+
exports.isCommandOption = isCommandOption;
|
|
86
|
+
exports.isCommandParameter = isCommandParameter;
|
|
87
|
+
exports.isCommandParameterConfig = isCommandParameterConfig;
|
|
88
|
+
exports.isCommandParameterKind = isCommandParameterKind;
|
|
89
|
+
//# sourceMappingURL=type-checks.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-checks.cjs","names":[],"sources":["../../src/plugin-utils/type-checks.ts"],"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 { isBoolean } from \"@stryke/type-checks/is-boolean\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameter,\n CommandParameterConfig,\n CommandParameterKind\n} from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameterKind} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameterKind} type, false otherwise.\n */\nexport function isCommandParameterKind(obj: any): obj is CommandParameterKind {\n return (\n isSetString(obj) &&\n [\n CommandParameterKinds.string,\n CommandParameterKinds.number,\n CommandParameterKinds.boolean\n ].includes(obj as CommandParameterKind)\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameterConfig} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameterConfig} type, false otherwise.\n */\nexport function isCommandParameterConfig(\n obj: any\n): obj is CommandParameterConfig {\n return isSetObject(obj) && \"kind\" in obj && isCommandParameterKind(obj.kind);\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameter} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameter} type, false otherwise.\n */\nexport function isCommandParameter(obj: any): obj is CommandParameter {\n return (\n isCommandParameterConfig(obj) &&\n \"name\" in obj &&\n isSetString(obj.name) &&\n \"title\" in obj &&\n isSetString(obj.title) &&\n \"description\" in obj &&\n isSetString(obj.description) &&\n \"alias\" in obj &&\n Array.isArray(obj.alias) &&\n \"env\" in obj &&\n (isSetString(obj.env) || obj.env === false) &&\n \"optional\" in obj &&\n isBoolean(obj.optional) &&\n \"variadic\" in obj &&\n isBoolean(obj.variadic)\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandOption} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandOption} type, false otherwise.\n */\nexport function isCommandOption(obj: any): obj is CommandOption {\n return (\n isCommandParameterConfig(obj) && isCommandParameter(obj) && \"default\" in obj\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandArgument} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandArgument} type, false otherwise.\n */\nexport function isCommandArgument(obj: any): obj is CommandArgument {\n return isCommandParameterConfig(obj) && isCommandParameter(obj);\n}\n"],"mappings":";;;;;;;;;;;;;AA2BA,SAAgB,uBAAS,KAAA;AACrB,4DAAoB,IAAI;EAE1B,4CAAA;EACU,4CAAsB;EACjC,4CAAA;EACQ,CAAC,SAAS,IAAI;;AAEvB,uBAAE,SAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOF,SAAgB,yBAAkB,KAAA;AAC9B,4DAAmB,IAAI,IAAI,UAAU,OAAC,uBAAA,IAAA,KAAA;;AAE1C,yBAAA,SAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOA,SAAE,mBAAA,KAAA;AACE,QAAQ,yBAAyB,IAAG,IAChC,UAAC,2DACW,IAAI,KAAK,IACrB,WAAW,2DACnB,IAAA,MAAA,gFAEE,IAAA,YAAA,IACM,WAAW,OAClB,MAAA,QAAA,IAAA,MAAA,IACO,SAAS,4DACI,IAAI,IAAI,IAAI,IAAI,QAAQ,UAC3C,cAAA,sDACgB,IAAI,SAAS,IACvB,cAAC,sDACS,IAAI,SAAS;;AAE/B,mBAAmB,SAAQ;CAAA;CAAA;CAAA;CAAA;;;;;;;AAO3B,SAAgB,gBAAE,KAAA;AACd,QAAQ,yBAAyB,IAAI,IAAI,mBAAI,IAAA,IAAA,aAAA;;AAEjD,gBAAgB,SAAS;CAAC;CAAG;CAAA;CAAA;;;;;;;AAO7B,SAAgB,kBAAkB,KAAK;AACtC,QAAA,yBAAA,IAAA,IAAA,mBAAA,IAAA;;AAED,kBAAkB,SAAS;CAAC;CAAO;CAAqB;CAAU"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CommandArgument, CommandOption, CommandParameter, CommandParameterConfig, CommandParameterKind } from "../types/command.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugin-utils/type-checks.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Type guard to check if a value is a valid {@link CommandParameterKind} type.
|
|
7
|
+
*
|
|
8
|
+
* @param obj - The value to check.
|
|
9
|
+
* @returns True if the value is a valid {@link CommandParameterKind} type, false otherwise.
|
|
10
|
+
*/
|
|
11
|
+
declare function isCommandParameterKind(obj: any): obj is CommandParameterKind;
|
|
12
|
+
/**
|
|
13
|
+
* Type guard to check if a value is a valid {@link CommandParameterConfig} type.
|
|
14
|
+
*
|
|
15
|
+
* @param obj - The value to check.
|
|
16
|
+
* @returns True if the value is a valid {@link CommandParameterConfig} type, false otherwise.
|
|
17
|
+
*/
|
|
18
|
+
declare function isCommandParameterConfig(obj: any): obj is CommandParameterConfig;
|
|
19
|
+
/**
|
|
20
|
+
* Type guard to check if a value is a valid {@link CommandParameter} type.
|
|
21
|
+
*
|
|
22
|
+
* @param obj - The value to check.
|
|
23
|
+
* @returns True if the value is a valid {@link CommandParameter} type, false otherwise.
|
|
24
|
+
*/
|
|
25
|
+
declare function isCommandParameter(obj: any): obj is CommandParameter;
|
|
26
|
+
/**
|
|
27
|
+
* Type guard to check if a value is a valid {@link CommandOption} type.
|
|
28
|
+
*
|
|
29
|
+
* @param obj - The value to check.
|
|
30
|
+
* @returns True if the value is a valid {@link CommandOption} type, false otherwise.
|
|
31
|
+
*/
|
|
32
|
+
declare function isCommandOption(obj: any): obj is CommandOption;
|
|
33
|
+
/**
|
|
34
|
+
* Type guard to check if a value is a valid {@link CommandArgument} type.
|
|
35
|
+
*
|
|
36
|
+
* @param obj - The value to check.
|
|
37
|
+
* @returns True if the value is a valid {@link CommandArgument} type, false otherwise.
|
|
38
|
+
*/
|
|
39
|
+
declare function isCommandArgument(obj: any): obj is CommandArgument;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { isCommandArgument, isCommandOption, isCommandParameter, isCommandParameterConfig, isCommandParameterKind };
|
|
42
|
+
//# sourceMappingURL=type-checks.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-checks.d.cts","names":[],"sources":["../../src/plugin-utils/type-checks.ts"],"sourcesContent":[],"mappings":";;;;;;AAoCA;AAiBA;AAYA;AA0BA;AAYgB,iBAnEA,sBAAA,CAmEoC,GAAA,EAAe,GAAA,CAAA,EAAA,GAAA,IAnEV,oBAmEU;;;;;;;iBAlDnD,wBAAA,mBAEN;;;;;;;iBAUM,kBAAA,mBAAqC;;;;;;;iBA0BrC,eAAA,mBAAkC;;;;;;;iBAYlC,iBAAA,mBAAoC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CommandArgument, CommandOption, CommandParameter, CommandParameterConfig, CommandParameterKind } from "../types/command.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/plugin-utils/type-checks.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Type guard to check if a value is a valid {@link CommandParameterKind} type.
|
|
7
|
+
*
|
|
8
|
+
* @param obj - The value to check.
|
|
9
|
+
* @returns True if the value is a valid {@link CommandParameterKind} type, false otherwise.
|
|
10
|
+
*/
|
|
11
|
+
declare function isCommandParameterKind(obj: any): obj is CommandParameterKind;
|
|
12
|
+
/**
|
|
13
|
+
* Type guard to check if a value is a valid {@link CommandParameterConfig} type.
|
|
14
|
+
*
|
|
15
|
+
* @param obj - The value to check.
|
|
16
|
+
* @returns True if the value is a valid {@link CommandParameterConfig} type, false otherwise.
|
|
17
|
+
*/
|
|
18
|
+
declare function isCommandParameterConfig(obj: any): obj is CommandParameterConfig;
|
|
19
|
+
/**
|
|
20
|
+
* Type guard to check if a value is a valid {@link CommandParameter} type.
|
|
21
|
+
*
|
|
22
|
+
* @param obj - The value to check.
|
|
23
|
+
* @returns True if the value is a valid {@link CommandParameter} type, false otherwise.
|
|
24
|
+
*/
|
|
25
|
+
declare function isCommandParameter(obj: any): obj is CommandParameter;
|
|
26
|
+
/**
|
|
27
|
+
* Type guard to check if a value is a valid {@link CommandOption} type.
|
|
28
|
+
*
|
|
29
|
+
* @param obj - The value to check.
|
|
30
|
+
* @returns True if the value is a valid {@link CommandOption} type, false otherwise.
|
|
31
|
+
*/
|
|
32
|
+
declare function isCommandOption(obj: any): obj is CommandOption;
|
|
33
|
+
/**
|
|
34
|
+
* Type guard to check if a value is a valid {@link CommandArgument} type.
|
|
35
|
+
*
|
|
36
|
+
* @param obj - The value to check.
|
|
37
|
+
* @returns True if the value is a valid {@link CommandArgument} type, false otherwise.
|
|
38
|
+
*/
|
|
39
|
+
declare function isCommandArgument(obj: any): obj is CommandArgument;
|
|
40
|
+
//#endregion
|
|
41
|
+
export { isCommandArgument, isCommandOption, isCommandParameter, isCommandParameterConfig, isCommandParameterKind };
|
|
42
|
+
//# sourceMappingURL=type-checks.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-checks.d.mts","names":[],"sources":["../../src/plugin-utils/type-checks.ts"],"sourcesContent":[],"mappings":";;;;;;AAoCA;AAiBA;AAYA;AA0BA;AAYgB,iBAnEA,sBAAA,CAmEoC,GAAA,EAAe,GAAA,CAAA,EAAA,GAAA,IAnEV,oBAmEU;;;;;;;iBAlDnD,wBAAA,mBAEN;;;;;;;iBAUM,kBAAA,mBAAqC;;;;;;;iBA0BrC,eAAA,mBAAkC;;;;;;;iBAYlC,iBAAA,mBAAoC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { CommandParameterKinds } from "../types/command.mjs";
|
|
2
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
3
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
4
|
+
import { isBoolean } from "@stryke/type-checks/is-boolean";
|
|
5
|
+
|
|
6
|
+
//#region src/plugin-utils/type-checks.ts
|
|
7
|
+
/**
|
|
8
|
+
* Type guard to check if a value is a valid {@link CommandParameterKind} type.
|
|
9
|
+
*
|
|
10
|
+
* @param obj - The value to check.
|
|
11
|
+
* @returns True if the value is a valid {@link CommandParameterKind} type, false otherwise.
|
|
12
|
+
*/
|
|
13
|
+
function isCommandParameterKind(obj) {
|
|
14
|
+
return isSetString(obj) && [
|
|
15
|
+
CommandParameterKinds.string,
|
|
16
|
+
CommandParameterKinds.number,
|
|
17
|
+
CommandParameterKinds.boolean
|
|
18
|
+
].includes(obj);
|
|
19
|
+
}
|
|
20
|
+
isCommandParameterKind.__type = [
|
|
21
|
+
"obj",
|
|
22
|
+
"isCommandParameterKind",
|
|
23
|
+
"P\"2!!/\""
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* Type guard to check if a value is a valid {@link CommandParameterConfig} type.
|
|
27
|
+
*
|
|
28
|
+
* @param obj - The value to check.
|
|
29
|
+
* @returns True if the value is a valid {@link CommandParameterConfig} type, false otherwise.
|
|
30
|
+
*/
|
|
31
|
+
function isCommandParameterConfig(obj) {
|
|
32
|
+
return isSetObject(obj) && "kind" in obj && isCommandParameterKind(obj.kind);
|
|
33
|
+
}
|
|
34
|
+
isCommandParameterConfig.__type = [
|
|
35
|
+
"obj",
|
|
36
|
+
"isCommandParameterConfig",
|
|
37
|
+
"P\"2!!/\""
|
|
38
|
+
];
|
|
39
|
+
/**
|
|
40
|
+
* Type guard to check if a value is a valid {@link CommandParameter} type.
|
|
41
|
+
*
|
|
42
|
+
* @param obj - The value to check.
|
|
43
|
+
* @returns True if the value is a valid {@link CommandParameter} type, false otherwise.
|
|
44
|
+
*/
|
|
45
|
+
function isCommandParameter(obj) {
|
|
46
|
+
return isCommandParameterConfig(obj) && "name" in obj && isSetString(obj.name) && "title" in obj && isSetString(obj.title) && "description" in obj && isSetString(obj.description) && "alias" in obj && Array.isArray(obj.alias) && "env" in obj && (isSetString(obj.env) || obj.env === false) && "optional" in obj && isBoolean(obj.optional) && "variadic" in obj && isBoolean(obj.variadic);
|
|
47
|
+
}
|
|
48
|
+
isCommandParameter.__type = [
|
|
49
|
+
"obj",
|
|
50
|
+
"isCommandParameter",
|
|
51
|
+
"P\"2!!/\""
|
|
52
|
+
];
|
|
53
|
+
/**
|
|
54
|
+
* Type guard to check if a value is a valid {@link CommandOption} type.
|
|
55
|
+
*
|
|
56
|
+
* @param obj - The value to check.
|
|
57
|
+
* @returns True if the value is a valid {@link CommandOption} type, false otherwise.
|
|
58
|
+
*/
|
|
59
|
+
function isCommandOption(obj) {
|
|
60
|
+
return isCommandParameterConfig(obj) && isCommandParameter(obj) && "default" in obj;
|
|
61
|
+
}
|
|
62
|
+
isCommandOption.__type = [
|
|
63
|
+
"obj",
|
|
64
|
+
"isCommandOption",
|
|
65
|
+
"P\"2!!/\""
|
|
66
|
+
];
|
|
67
|
+
/**
|
|
68
|
+
* Type guard to check if a value is a valid {@link CommandArgument} type.
|
|
69
|
+
*
|
|
70
|
+
* @param obj - The value to check.
|
|
71
|
+
* @returns True if the value is a valid {@link CommandArgument} type, false otherwise.
|
|
72
|
+
*/
|
|
73
|
+
function isCommandArgument(obj) {
|
|
74
|
+
return isCommandParameterConfig(obj) && isCommandParameter(obj);
|
|
75
|
+
}
|
|
76
|
+
isCommandArgument.__type = [
|
|
77
|
+
"obj",
|
|
78
|
+
"isCommandArgument",
|
|
79
|
+
"P\"2!!/\""
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
export { isCommandArgument, isCommandOption, isCommandParameter, isCommandParameterConfig, isCommandParameterKind };
|
|
84
|
+
//# sourceMappingURL=type-checks.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-checks.mjs","names":[],"sources":["../../src/plugin-utils/type-checks.ts"],"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 { isBoolean } from \"@stryke/type-checks/is-boolean\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameter,\n CommandParameterConfig,\n CommandParameterKind\n} from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameterKind} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameterKind} type, false otherwise.\n */\nexport function isCommandParameterKind(obj: any): obj is CommandParameterKind {\n return (\n isSetString(obj) &&\n [\n CommandParameterKinds.string,\n CommandParameterKinds.number,\n CommandParameterKinds.boolean\n ].includes(obj as CommandParameterKind)\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameterConfig} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameterConfig} type, false otherwise.\n */\nexport function isCommandParameterConfig(\n obj: any\n): obj is CommandParameterConfig {\n return isSetObject(obj) && \"kind\" in obj && isCommandParameterKind(obj.kind);\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandParameter} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandParameter} type, false otherwise.\n */\nexport function isCommandParameter(obj: any): obj is CommandParameter {\n return (\n isCommandParameterConfig(obj) &&\n \"name\" in obj &&\n isSetString(obj.name) &&\n \"title\" in obj &&\n isSetString(obj.title) &&\n \"description\" in obj &&\n isSetString(obj.description) &&\n \"alias\" in obj &&\n Array.isArray(obj.alias) &&\n \"env\" in obj &&\n (isSetString(obj.env) || obj.env === false) &&\n \"optional\" in obj &&\n isBoolean(obj.optional) &&\n \"variadic\" in obj &&\n isBoolean(obj.variadic)\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandOption} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandOption} type, false otherwise.\n */\nexport function isCommandOption(obj: any): obj is CommandOption {\n return (\n isCommandParameterConfig(obj) && isCommandParameter(obj) && \"default\" in obj\n );\n}\n\n/**\n * Type guard to check if a value is a valid {@link CommandArgument} type.\n *\n * @param obj - The value to check.\n * @returns True if the value is a valid {@link CommandArgument} type, false otherwise.\n */\nexport function isCommandArgument(obj: any): obj is CommandArgument {\n return isCommandParameterConfig(obj) && isCommandParameter(obj);\n}\n"],"mappings":";;;;;;;;;;;;AA2BA,SAAgB,uBAAS,KAAA;AACrB,QAAQ,YAAY,IAAI;EAE1B,sBAAA;EACU,sBAAsB;EACjC,sBAAA;EACQ,CAAC,SAAS,IAAI;;AAEvB,uBAAE,SAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOF,SAAgB,yBAAkB,KAAA;AAC9B,QAAO,YAAY,IAAI,IAAI,UAAU,OAAC,uBAAA,IAAA,KAAA;;AAE1C,yBAAA,SAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAOA,SAAE,mBAAA,KAAA;AACE,QAAQ,yBAAyB,IAAG,IAChC,UAAC,OACD,YAAY,IAAI,KAAK,IACrB,WAAW,OACnB,YAAA,IAAA,MAAA,4BAEE,YAAA,IAAA,YAAA,IACM,WAAW,OAClB,MAAA,QAAA,IAAA,MAAA,IACO,SAAS,QACR,YAAY,IAAI,IAAI,IAAI,IAAI,QAAQ,UAC3C,cAAA,OACM,UAAU,IAAI,SAAS,IACvB,cAAC,OACD,UAAU,IAAI,SAAS;;AAE/B,mBAAmB,SAAQ;CAAA;CAAA;CAAA;CAAA;;;;;;;AAO3B,SAAgB,gBAAE,KAAA;AACd,QAAQ,yBAAyB,IAAI,IAAI,mBAAI,IAAA,IAAA,aAAA;;AAEjD,gBAAgB,SAAS;CAAC;CAAG;CAAA;CAAA;;;;;;;AAO7B,SAAgB,kBAAkB,KAAK;AACtC,QAAA,yBAAA,IAAA,IAAA,mBAAA,IAAA;;AAED,kBAAkB,SAAS;CAAC;CAAO;CAAqB;CAAU"}
|
package/dist/plugin.cjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
|
-
const
|
|
3
|
+
const require_context_helpers = require('./plugin-utils/context-helpers.cjs');
|
|
4
4
|
const require_components_docs = require('./components/docs.cjs');
|
|
5
5
|
const require_components_utils_builtin = require('./components/utils-builtin.cjs');
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const require_get_command_tree = require('./plugin-utils/get-command-tree.cjs');
|
|
7
|
+
const require_traverse_command_tree = require('./plugin-utils/traverse-command-tree.cjs');
|
|
8
8
|
const require_automd = require('./helpers/automd.cjs');
|
|
9
|
+
const require_paths = require('./helpers/paths.cjs');
|
|
9
10
|
const require_persistence = require('./helpers/persistence.cjs');
|
|
10
|
-
const require_utilities = require('./helpers/utilities.cjs');
|
|
11
|
-
const require_resolve_command = require('./helpers/resolve-command.cjs');
|
|
12
11
|
const require_update_package_json = require('./helpers/update-package-json.cjs');
|
|
12
|
+
const require_utilities = require('./helpers/utilities.cjs');
|
|
13
13
|
const require_validations = require('./helpers/validations.cjs');
|
|
14
|
+
const require_resolve = require('./resolver/resolve.cjs');
|
|
14
15
|
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
15
16
|
let __alloy_js_core_components = require("@alloy-js/core/components");
|
|
16
17
|
let __powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
@@ -20,8 +21,6 @@ let __powerlines_plugin_deepkit = require("@powerlines/plugin-deepkit");
|
|
|
20
21
|
__powerlines_plugin_deepkit = require_rolldown_runtime.__toESM(__powerlines_plugin_deepkit);
|
|
21
22
|
let __powerlines_plugin_nodejs = require("@powerlines/plugin-nodejs");
|
|
22
23
|
__powerlines_plugin_nodejs = require_rolldown_runtime.__toESM(__powerlines_plugin_nodejs);
|
|
23
|
-
let __powerlines_plugin_tsdown = require("@powerlines/plugin-tsdown");
|
|
24
|
-
__powerlines_plugin_tsdown = require_rolldown_runtime.__toESM(__powerlines_plugin_tsdown);
|
|
25
24
|
let __stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
26
25
|
let __stryke_fs_chmod_x = require("@stryke/fs/chmod-x");
|
|
27
26
|
let __stryke_path_append = require("@stryke/path/append");
|
|
@@ -33,10 +32,12 @@ let __stryke_path_resolve_parent_path = require("@stryke/path/resolve-parent-pat
|
|
|
33
32
|
let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
34
33
|
let __stryke_string_format_constant_case = require("@stryke/string-format/constant-case");
|
|
35
34
|
let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
|
|
35
|
+
let __stryke_type_checks_is_object = require("@stryke/type-checks/is-object");
|
|
36
36
|
let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
37
37
|
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
38
38
|
let defu = require("defu");
|
|
39
|
-
let
|
|
39
|
+
let powerlines_tsdown = require("powerlines/tsdown");
|
|
40
|
+
let powerlines_utils = require("powerlines/utils");
|
|
40
41
|
|
|
41
42
|
//#region src/plugin.tsx
|
|
42
43
|
const MAX_DEPTH = 50;
|
|
@@ -45,7 +46,7 @@ const MAX_DEPTH = 50;
|
|
|
45
46
|
*/
|
|
46
47
|
const plugin = (options = {}) => {
|
|
47
48
|
return [
|
|
48
|
-
(0,
|
|
49
|
+
(0, powerlines_tsdown.tsdown)(),
|
|
49
50
|
(0, __powerlines_plugin_deepkit.default)(),
|
|
50
51
|
(0, __powerlines_plugin_automd.default)(),
|
|
51
52
|
{
|
|
@@ -53,27 +54,26 @@ const plugin = (options = {}) => {
|
|
|
53
54
|
async config() {
|
|
54
55
|
this.debug("Resolving the Shell Shock configuration.");
|
|
55
56
|
await require_update_package_json.updatePackageJsonBinary(this);
|
|
56
|
-
const result = (0, defu.defu)({ output: { buildPath: (0, __stryke_path_join_paths.joinPaths)(this.config.
|
|
57
|
-
name:
|
|
58
|
-
title:
|
|
59
|
-
description:
|
|
60
|
-
|
|
57
|
+
const result = (0, defu.defu)({ output: { buildPath: (0, __stryke_path_join_paths.joinPaths)(this.config.root, "dist") } }, options, {
|
|
58
|
+
name: require_context_helpers.getAppName(this),
|
|
59
|
+
title: require_context_helpers.getAppTitle(this),
|
|
60
|
+
description: require_context_helpers.getAppDescription(this),
|
|
61
|
+
platform: "node",
|
|
62
|
+
projectType: "application",
|
|
63
|
+
envPrefix: (0, __stryke_string_format_constant_case.constantCase)(require_context_helpers.getAppName(this)),
|
|
61
64
|
env: { prefix: [] },
|
|
62
65
|
isCaseSensitive: false,
|
|
63
66
|
output: {
|
|
64
67
|
format: "esm",
|
|
65
68
|
dts: true
|
|
66
69
|
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
input: !this.config.input || Array.isArray(this.config.input) && this.config.input.length === 0 || (0, __stryke_type_checks_is_object.isObject)(this.config.input) && Object.keys(this.config.input).length === 0 ? [(0, __stryke_path_join_paths.joinPaths)(this.config.root, "src/**/command.ts"), (0, __stryke_path_join_paths.joinPaths)(this.config.root, "src/**/command.tsx")] : void 0,
|
|
71
|
+
resolve: { external: ["@powerlines/deepkit"] },
|
|
72
|
+
tsdown: {
|
|
73
|
+
dts: true,
|
|
71
74
|
nodeProtocol: true,
|
|
72
|
-
unbundle: false
|
|
73
|
-
|
|
74
|
-
},
|
|
75
|
-
type: "application",
|
|
76
|
-
framework: "shell-shock"
|
|
75
|
+
unbundle: false
|
|
76
|
+
}
|
|
77
77
|
});
|
|
78
78
|
if (!result.env.prefix || !Array.isArray(result.env.prefix)) result.env.prefix = (0, __stryke_convert_to_array.toArray)(result.env.prefix);
|
|
79
79
|
if (!result.env.prefix.includes(result.envPrefix)) result.env.prefix.push(result.envPrefix);
|
|
@@ -106,18 +106,18 @@ const plugin = (options = {}) => {
|
|
|
106
106
|
name: "shell-shock:inputs",
|
|
107
107
|
async configResolved() {
|
|
108
108
|
this.debug("Finding command entry point files.");
|
|
109
|
-
this.commandsPath =
|
|
110
|
-
const
|
|
111
|
-
this.debug(`Found ${
|
|
112
|
-
this.inputs =
|
|
113
|
-
if (!(0, __stryke_path_is_parent_path.isParentPath)(entry.file, this.commandsPath)) throw new Error(`Command entry point "${entry.file}" is not located within the commands root "${this.commandsPath}". Please ensure that all command entry points are located within the current project.`);
|
|
114
|
-
const id =
|
|
109
|
+
this.commandsPath = require_paths.findCommandsRoot(this);
|
|
110
|
+
const inputs = await (0, powerlines_utils.resolveInputs)(this, this.config.input);
|
|
111
|
+
this.debug(`Found ${inputs.length} entry points specified in the configuration options.`);
|
|
112
|
+
this.inputs = inputs.reduce((ret, entry) => {
|
|
113
|
+
if (entry.file !== this.commandsPath && !(0, __stryke_path_is_parent_path.isParentPath)(entry.file, this.commandsPath)) throw new Error(`Command entry point "${entry.file}" is not located within the commands root "${this.commandsPath}". Please ensure that all command entry points are located within the current project.`);
|
|
114
|
+
const id = require_paths.resolveCommandId(this, entry.file);
|
|
115
115
|
if (!ret.some((existing) => existing.id === id)) {
|
|
116
|
-
const name =
|
|
117
|
-
let segments =
|
|
116
|
+
const name = require_paths.resolveCommandName(entry.file);
|
|
117
|
+
let segments = require_paths.resolveCommandPath(this, entry.file).split("/").filter(Boolean);
|
|
118
118
|
segments = segments.map((segment, index) => {
|
|
119
119
|
const found = segments.findIndex((existing) => existing === segment);
|
|
120
|
-
if (found !== -1 && found !== index) segment += `_${segments.filter((segment$1) =>
|
|
120
|
+
if (found !== -1 && found !== index) segment += `_${segments.filter((segment$1) => require_context_helpers.isDynamicPathSegment(segment$1) && require_context_helpers.getDynamicPathSegmentName(segment$1).replace(/_\d+$/, "") === segment$1).length}`;
|
|
121
121
|
return segment;
|
|
122
122
|
});
|
|
123
123
|
ret.push({
|
|
@@ -163,13 +163,13 @@ const plugin = (options = {}) => {
|
|
|
163
163
|
if (depth++ > MAX_DEPTH) throw new Error(`Unable to process virtual commands for ${command.name} \n\nPlease ensure ${command.entry.file} is a valid command entry file and does not have an invalid path.`);
|
|
164
164
|
if (!ret.some((existing) => (0, __stryke_path_file_path_fns.findFilePath)(existing.entry.file) === parentPath)) {
|
|
165
165
|
const file = (0, __stryke_path_join_paths.joinPaths)(parentPath, "command.ts");
|
|
166
|
-
const id =
|
|
166
|
+
const id = require_paths.resolveCommandId(this, file);
|
|
167
167
|
if (!ret.some((existing) => existing.id === id)) {
|
|
168
|
-
const name =
|
|
169
|
-
let segments =
|
|
168
|
+
const name = require_paths.resolveCommandName(file);
|
|
169
|
+
let segments = require_paths.resolveCommandPath(this, file).split("/").filter(Boolean);
|
|
170
170
|
segments = segments.map((segment, index) => {
|
|
171
171
|
const found = segments.findIndex((existing) => existing === segment);
|
|
172
|
-
if (found !== -1 && found !== index) segment += `_${segments.filter((segment$1) =>
|
|
172
|
+
if (found !== -1 && found !== index) segment += `_${segments.filter((segment$1) => require_context_helpers.isDynamicPathSegment(segment$1) && require_context_helpers.getDynamicPathSegmentName(segment$1).replace(/_\d+$/, "") === segment$1).length}`;
|
|
173
173
|
return segment;
|
|
174
174
|
});
|
|
175
175
|
ret.push({
|
|
@@ -193,17 +193,20 @@ const plugin = (options = {}) => {
|
|
|
193
193
|
}
|
|
194
194
|
},
|
|
195
195
|
{
|
|
196
|
-
name: "shell-shock:
|
|
196
|
+
name: "shell-shock:resolve-commands",
|
|
197
197
|
prepare: {
|
|
198
198
|
order: "post",
|
|
199
199
|
async handler() {
|
|
200
200
|
this.debug("Initializing the CLI application's command tree.");
|
|
201
201
|
this.commands = {};
|
|
202
202
|
if (this.config.command !== "prepare" && this.config.skipCache !== true && this.persistedMeta?.checksum === this.meta.checksum && this.fs.existsSync(require_persistence.getCommandsPersistencePath(this))) {
|
|
203
|
-
this.debug(`Skipping
|
|
203
|
+
this.debug(`Skipping command resolution as the meta checksum has not changed.`);
|
|
204
204
|
await require_persistence.readCommandsPersistence(this);
|
|
205
205
|
} else {
|
|
206
|
-
for (const input of this.inputs.filter((input$1) => input$1.segments.filter((segment) => !
|
|
206
|
+
for (const input of this.inputs.filter((input$1) => input$1.segments.filter((segment) => !require_context_helpers.isDynamicPathSegment(segment) && !require_context_helpers.isPathSegmentGroup(segment)).length === 1)) this.commands[input.name] = await require_resolve.resolve({
|
|
207
|
+
context: this,
|
|
208
|
+
command: input
|
|
209
|
+
});
|
|
207
210
|
this.debug("Post-processing commands to ensure proper reflection.");
|
|
208
211
|
this.options = this.options.map((option) => ({
|
|
209
212
|
...option,
|
|
@@ -211,7 +214,7 @@ const plugin = (options = {}) => {
|
|
|
211
214
|
alias: option.alias ?? [],
|
|
212
215
|
optional: option.optional ?? false
|
|
213
216
|
}));
|
|
214
|
-
await
|
|
217
|
+
await require_traverse_command_tree.traverseCommands(this, (command) => {
|
|
215
218
|
command.options = Object.fromEntries(Object.entries(command.options).map(([name, option]) => [(0, __stryke_string_format_camel_case.camelCase)(name), {
|
|
216
219
|
...option,
|
|
217
220
|
name: (0, __stryke_string_format_camel_case.camelCase)(name),
|
|
@@ -223,7 +226,7 @@ const plugin = (options = {}) => {
|
|
|
223
226
|
}
|
|
224
227
|
this.debug("Validating the CLI applications command tree.");
|
|
225
228
|
let isValid = true;
|
|
226
|
-
await
|
|
229
|
+
await require_traverse_command_tree.traverseCommands(this, (command) => {
|
|
227
230
|
const failures = require_validations.validateCommand(command);
|
|
228
231
|
if (failures.length > 0) {
|
|
229
232
|
this.error(`Found ${failures.length} issue${failures.length > 1 ? "s" : ""} with the ${command.title} command: \n${failures.map((failure) => ` - ${failure.code}: ${failure.details}`).join("\n")}\n`);
|
|
@@ -238,8 +241,8 @@ const plugin = (options = {}) => {
|
|
|
238
241
|
{
|
|
239
242
|
name: "shell-shock:chmod+x",
|
|
240
243
|
configResolved() {
|
|
241
|
-
this.config.
|
|
242
|
-
this.config.
|
|
244
|
+
this.config.tsdown.outputOptions ??= {};
|
|
245
|
+
if ((0, __stryke_type_checks_is_object.isObject)(this.config.tsdown.outputOptions)) this.config.tsdown.outputOptions.banner = (chunk) => {
|
|
243
246
|
if (chunk.isEntry && (0, __stryke_path_join_paths.joinPaths)(this.entryPath, "bin.ts") === chunk.facadeModuleId) {
|
|
244
247
|
this.debug(`Adding hashbang to binary executable output file: ${chunk.fileName}`);
|
|
245
248
|
return `#!/usr/bin/env ${this.config.mode === "development" ? "-S NODE_OPTIONS=--enable-source-maps" : ""} node\n`;
|
|
@@ -250,7 +253,7 @@ const plugin = (options = {}) => {
|
|
|
250
253
|
async buildEnd() {
|
|
251
254
|
if (!(0, __stryke_type_checks_is_set_object.isSetObject)(this.config.bin)) this.warn(`No binaries were found for the ${this.config.name} application. Please ensure the binaries are correctly configured in your Shell Shock configuration or package.json.`);
|
|
252
255
|
else await Promise.all(Object.values(this.config.bin).map(async (bin) => {
|
|
253
|
-
const path = (0, __stryke_path_append.appendPath)(bin, (0, __stryke_path_join_paths.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.
|
|
256
|
+
const path = (0, __stryke_path_append.appendPath)(bin, (0, __stryke_path_join_paths.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.root));
|
|
254
257
|
if (this.fs.existsSync(path)) {
|
|
255
258
|
this.debug(`Adding executable permissions (chmod+x) to binary executable output file: ${path}`);
|
|
256
259
|
await (0, __stryke_fs_chmod_x.chmodX)(path);
|
|
@@ -269,7 +272,7 @@ const plugin = (options = {}) => {
|
|
|
269
272
|
},
|
|
270
273
|
async docs() {
|
|
271
274
|
this.debug("Rendering entrypoint modules for the Shell Shock `script` preset.");
|
|
272
|
-
const commands$1 = this.inputs.map((input) =>
|
|
275
|
+
const commands$1 = this.inputs.map((input) => require_get_command_tree.getCommandTree(this, input.segments)).filter(Boolean);
|
|
273
276
|
return (0, __powerlines_plugin_alloy_render.render)(this, (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core_components.For, {
|
|
274
277
|
get each() {
|
|
275
278
|
return Object.values(commands$1);
|