@shell-shock/core 0.10.0 → 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/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.cts.map +1 -1
- 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/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.d.mts +2 -2
- package/dist/components/usage.mjs +4 -4
- package/dist/components/usage.mjs.map +1 -1
- package/dist/components/utils-builtin.cjs +2 -2
- package/dist/components/utils-builtin.cjs.map +1 -1
- package/dist/components/utils-builtin.mjs +5 -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/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 +4 -4
- package/dist/helpers/update-package-json.cjs.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 -11
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- 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 +28 -24
- 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 +12 -8
- 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 +127 -104
- package/dist/types/command.cjs.map +1 -1
- package/dist/types/command.d.cts +39 -78
- package/dist/types/command.d.cts.map +1 -1
- package/dist/types/command.d.mts +39 -78
- package/dist/types/command.d.mts.map +1 -1
- package/dist/types/command.mjs +115 -95
- package/dist/types/command.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 +2 -2
- package/dist/types/context.d.cts.map +1 -1
- package/dist/types/context.d.mts +2 -2
- 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 -10
- 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 +24 -75
- package/dist/helpers/resolve-command.cjs +0 -430
- package/dist/helpers/resolve-command.cjs.map +0 -1
- package/dist/helpers/resolve-command.mjs +0 -425
- package/dist/helpers/resolve-command.mjs.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_types_command = require('../types/command.cjs');
|
|
2
3
|
let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
|
|
3
4
|
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
4
5
|
let defu = require("defu");
|
|
5
6
|
defu = require_rolldown_runtime.__toESM(defu);
|
|
6
7
|
let __alloy_js_core = require("@alloy-js/core");
|
|
7
|
-
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
8
8
|
|
|
9
9
|
//#region src/contexts/options.ts
|
|
10
10
|
function __assignType(fn, args) {
|
|
@@ -30,7 +30,7 @@ useExistingOptions.__type = ["useExistingOptions", "P\"/!"];
|
|
|
30
30
|
function computedOptions(command) {
|
|
31
31
|
return Object.entries(command.options).reduce(__assignType((ret, [name, option]) => {
|
|
32
32
|
ret[(0, __stryke_string_format_camel_case.camelCase)(name)] ??= (0, defu.default)({ name: (0, __stryke_string_format_camel_case.camelCase)(name) }, ret[name] ?? {}, option);
|
|
33
|
-
if (option.kind ===
|
|
33
|
+
if (option.kind === require_types_command.CommandParameterKinds.boolean && option.isNegativeOf) ret[(0, __stryke_string_format_camel_case.camelCase)(option.isNegativeOf)] = (0, defu.default)({ name: (0, __stryke_string_format_camel_case.camelCase)(option.isNegativeOf) }, ret[option.isNegativeOf] ?? {}, {
|
|
34
34
|
...option,
|
|
35
35
|
env: (0, __stryke_type_checks_is_set_string.isSetString)(option.env) ? `NO_${option.env}` : false,
|
|
36
36
|
description: `${option.description.replace(/\.+$/, "")}. This property is the negative form of ${name}.`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.cjs","names":[],"sources":["../../src/contexts/options.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 { ComponentContext } from \"@alloy-js/core\";\nimport { createNamedContext, useContext } from \"@alloy-js/core\";\nimport {
|
|
1
|
+
{"version":3,"file":"options.cjs","names":[],"sources":["../../src/contexts/options.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 { ComponentContext } from \"@alloy-js/core\";\nimport { createNamedContext, useContext } from \"@alloy-js/core\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport type {\n BooleanCommandOption,\n CommandOption,\n CommandTree\n} from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\n\n/**\n * The reflection parameter context used in template rendering.\n */\nexport const ExistingOptionsContext: ComponentContext<string[]> =\n createNamedContext<string[]>(\"ExistingOptions\", []);\n\n/**\n * Hook to access the ExistingOptions context.\n *\n * @remarks\n * This context provides a list of option names that already exist on the interface definition.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useExistingOptions() {\n return useContext<string[]>(ExistingOptionsContext)!;\n}\n\nexport function computedOptions(command: CommandTree) {\n return Object.entries(command.options).reduce(\n (ret, [name, option]) => {\n ret[camelCase(name)] ??= defu(\n {\n name: camelCase(name)\n },\n ret[name] ?? {},\n option\n ) as CommandOption;\n\n if (\n option.kind === CommandParameterKinds.boolean &&\n option.isNegativeOf\n ) {\n ret[camelCase(option.isNegativeOf)] = defu(\n {\n name: camelCase(option.isNegativeOf)\n },\n ret[option.isNegativeOf] ?? {},\n {\n ...option,\n env: isSetString(option.env) ? `NO_${option.env}` : false,\n description: `${option.description.replace(\n /\\.+$/,\n \"\"\n )}. This property is the negative form of ${name}.`,\n isNegativeOf: camelCase(name),\n default: !option.default\n }\n ) as BooleanCommandOption;\n }\n\n return ret;\n },\n {} as Record<string, CommandOption>\n );\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;AAUX,MAAa,0BAA0B,mCAAmB,IAAC,CAAA,CAAA,KAAA,CAAA,0CAAA,mBAAA,EAAA,CAAA;;;;;;;;;AAS3D,SAAgB,qBAAqB;AACjC,QAAQ,2BAAW,IAAA,CAAA,CAAA,KAAA,CAAA,kCAAA,uBAAA;;AAEvB,mBAAmB,SAAG,CAAA,sBAAA,QAAA;AACtB,SAAe,gBAAA,SAAA;AACX,QAAO,OAAC,QAAA,QAAA,QAAA,CAAA,OAAA,cAAA,KAAA,CAAA,MAAA,YAAA;AACJ,uDAAc,KAAG,wBAAA,EACb,uDAAgB,KAAI;AAE9B,MAAA,OAAA,SAAA,4CAAA,WACU,OAAO,aACjB,sDAAA,OAAA,aAAA,sBAAA,EACc,uDAAgB,OAAO,aAAY,EACtC,EAAE,IAAI,OAAO,iBAAiB,EAAE,EAAE;;GAE7C,yDAAA,OAAA,IAAA,GAAA,MAAA,OAAA,QAAA;GACc,aAAa,GAAG,OAAO,YAAM,QAAA,QAAA,GAAA,CAAA,0CAAA,KAAA;GAC5C,+DAAA,KAAA;GACS,SAAA,CAAA,OAAA;GACG,CAAC;AAEN,SAAO;IACb;EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,EAAA,EAAA,CAAA;;AAEF,gBAAgB,SAAS;CAAC;CAAe;CAAW;CAAE;CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CommandOption, CommandTree } from "../types/command.cjs";
|
|
2
|
-
import "../types/index.cjs";
|
|
3
2
|
import { ComponentContext } from "@alloy-js/core";
|
|
4
3
|
|
|
5
4
|
//#region src/contexts/options.d.ts
|
|
5
|
+
|
|
6
6
|
/**
|
|
7
7
|
* The reflection parameter context used in template rendering.
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.cts","names":[],"sources":["../../src/contexts/options.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"options.d.cts","names":[],"sources":["../../src/contexts/options.ts"],"sourcesContent":[],"mappings":";;;;;;;AAiCA;AAWgB,cAXH,sBAWqB,EAXG,gBAWH,CAAA,MAAA,EAAA,CAAA;AAIlC;;;;;;;;iBAJgB,kBAAA,CAAA;iBAIA,eAAA,UAAyB,cAAW,eAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CommandOption, CommandTree } from "../types/command.mjs";
|
|
2
|
-
import "../types/index.mjs";
|
|
3
2
|
import { ComponentContext } from "@alloy-js/core";
|
|
4
3
|
|
|
5
4
|
//#region src/contexts/options.d.ts
|
|
5
|
+
|
|
6
6
|
/**
|
|
7
7
|
* The reflection parameter context used in template rendering.
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.mts","names":[],"sources":["../../src/contexts/options.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"options.d.mts","names":[],"sources":["../../src/contexts/options.ts"],"sourcesContent":[],"mappings":";;;;;;;AAiCA;AAWgB,cAXH,sBAWqB,EAXG,gBAWH,CAAA,MAAA,EAAA,CAAA;AAIlC;;;;;;;;iBAJgB,kBAAA,CAAA;iBAIA,eAAA,UAAyB,cAAW,eAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { CommandParameterKinds } from "../types/command.mjs";
|
|
1
2
|
import { camelCase } from "@stryke/string-format/camel-case";
|
|
2
3
|
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
3
|
-
import defu
|
|
4
|
+
import defu from "defu";
|
|
4
5
|
import { createNamedContext, useContext } from "@alloy-js/core";
|
|
5
|
-
import { ReflectionKind } from "@powerlines/deepkit/vendor/type";
|
|
6
6
|
|
|
7
7
|
//#region src/contexts/options.ts
|
|
8
8
|
function __assignType(fn, args) {
|
|
@@ -27,8 +27,8 @@ function useExistingOptions() {
|
|
|
27
27
|
useExistingOptions.__type = ["useExistingOptions", "P\"/!"];
|
|
28
28
|
function computedOptions(command) {
|
|
29
29
|
return Object.entries(command.options).reduce(__assignType((ret, [name, option]) => {
|
|
30
|
-
ret[camelCase(name)] ??= defu
|
|
31
|
-
if (option.kind ===
|
|
30
|
+
ret[camelCase(name)] ??= defu({ name: camelCase(name) }, ret[name] ?? {}, option);
|
|
31
|
+
if (option.kind === CommandParameterKinds.boolean && option.isNegativeOf) ret[camelCase(option.isNegativeOf)] = defu({ name: camelCase(option.isNegativeOf) }, ret[option.isNegativeOf] ?? {}, {
|
|
32
32
|
...option,
|
|
33
33
|
env: isSetString(option.env) ? `NO_${option.env}` : false,
|
|
34
34
|
description: `${option.description.replace(/\.+$/, "")}. This property is the negative form of ${name}.`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.mjs","names":[],"sources":["../../src/contexts/options.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 { ComponentContext } from \"@alloy-js/core\";\nimport { createNamedContext, useContext } from \"@alloy-js/core\";\nimport {
|
|
1
|
+
{"version":3,"file":"options.mjs","names":[],"sources":["../../src/contexts/options.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 { ComponentContext } from \"@alloy-js/core\";\nimport { createNamedContext, useContext } from \"@alloy-js/core\";\nimport { camelCase } from \"@stryke/string-format/camel-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport defu from \"defu\";\nimport type {\n BooleanCommandOption,\n CommandOption,\n CommandTree\n} from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\n\n/**\n * The reflection parameter context used in template rendering.\n */\nexport const ExistingOptionsContext: ComponentContext<string[]> =\n createNamedContext<string[]>(\"ExistingOptions\", []);\n\n/**\n * Hook to access the ExistingOptions context.\n *\n * @remarks\n * This context provides a list of option names that already exist on the interface definition.\n *\n * @returns A reactive version of the current reflection.\n */\nexport function useExistingOptions() {\n return useContext<string[]>(ExistingOptionsContext)!;\n}\n\nexport function computedOptions(command: CommandTree) {\n return Object.entries(command.options).reduce(\n (ret, [name, option]) => {\n ret[camelCase(name)] ??= defu(\n {\n name: camelCase(name)\n },\n ret[name] ?? {},\n option\n ) as CommandOption;\n\n if (\n option.kind === CommandParameterKinds.boolean &&\n option.isNegativeOf\n ) {\n ret[camelCase(option.isNegativeOf)] = defu(\n {\n name: camelCase(option.isNegativeOf)\n },\n ret[option.isNegativeOf] ?? {},\n {\n ...option,\n env: isSetString(option.env) ? `NO_${option.env}` : false,\n description: `${option.description.replace(\n /\\.+$/,\n \"\"\n )}. This property is the negative form of ${name}.`,\n isNegativeOf: camelCase(name),\n default: !option.default\n }\n ) as BooleanCommandOption;\n }\n\n return ret;\n },\n {} as Record<string, CommandOption>\n );\n}\n"],"mappings":";;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;AAUX,MAAa,0BAA0B,mBAAmB,IAAC,CAAA,CAAA,KAAA,CAAA,EAAA,mBAAA,mBAAA,EAAA,CAAA;;;;;;;;;AAS3D,SAAgB,qBAAqB;AACjC,QAAQ,WAAW,IAAA,CAAA,CAAA,KAAA,CAAA,EAAA,WAAA,uBAAA;;AAEvB,mBAAmB,SAAG,CAAA,sBAAA,QAAA;AACtB,SAAe,gBAAA,SAAA;AACX,QAAO,OAAC,QAAA,QAAA,QAAA,CAAA,OAAA,cAAA,KAAA,CAAA,MAAA,YAAA;AACJ,MAAI,UAAU,KAAG,MAAA,KAAA,EACb,MAAM,UAAU,KAAI;AAE9B,MAAA,OAAA,SAAA,sBAAA,WACU,OAAO,aACjB,KAAA,UAAA,OAAA,aAAA,IAAA,KAAA,EACc,MAAM,UAAU,OAAO,aAAY,EACtC,EAAE,IAAI,OAAO,iBAAiB,EAAE,EAAE;;GAE7C,KAAA,YAAA,OAAA,IAAA,GAAA,MAAA,OAAA,QAAA;GACc,aAAa,GAAG,OAAO,YAAM,QAAA,QAAA,GAAA,CAAA,0CAAA,KAAA;GAC5C,cAAA,UAAA,KAAA;GACS,SAAA,CAAA,OAAA;GACG,CAAC;AAEN,SAAO;IACb;EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,EAAA,EAAA,CAAA;;AAEF,gBAAgB,SAAS;CAAC;CAAe;CAAW;CAAE;CAAA"}
|
package/dist/helpers/automd.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const
|
|
2
|
+
const require_context_helpers = require('../plugin-utils/context-helpers.cjs');
|
|
3
3
|
const require_components_docs = require('../components/docs.cjs');
|
|
4
4
|
require('../plugin-utils/index.cjs');
|
|
5
5
|
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
@@ -28,7 +28,7 @@ const commands = (context) => (0, automd.defineGenerator)({
|
|
|
28
28
|
children: "Commands"
|
|
29
29
|
}),
|
|
30
30
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
31
|
-
(0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`The following commands are available in the ${
|
|
31
|
+
(0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`The following commands are available in the ${require_context_helpers.getAppTitle(context)} CLI application:`),
|
|
32
32
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
33
33
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core_components.For, {
|
|
34
34
|
get each() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automd.cjs","names":["code","For","Show","Heading","renderString","defineGenerator","CommandDocs","getAppTitle","
|
|
1
|
+
{"version":3,"file":"automd.cjs","names":["code","For","Show","Heading","Spacing","renderString","defineGenerator","CommandDocs","getAppTitle","commands","context","name","generate","contents","_$createComponent","level","children","_$memo","each","Object","values","doubleHardline","child","when","isVirtual","command","levelOffset"],"sources":["../../src/helpers/automd.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport { For, Show } from \"@alloy-js/core/components\";\nimport { Heading } from \"@alloy-js/markdown\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { renderString } from \"@powerlines/plugin-alloy/render\";\nimport { defineGenerator } from \"automd\";\nimport { CommandDocs } from \"../components/docs\";\nimport { getAppTitle } from \"../plugin-utils\";\nimport type { Context } from \"../types/context\";\n\n/**\n * AutoMD generator to generate CLI command documentation\n *\n * @see https://automd.unjs.io/\n *\n * @param context - The generator context.\n * @returns The generated documentation content.\n */\nexport const commands = (context: Context) =>\n defineGenerator({\n name: \"commands\",\n async generate() {\n return {\n contents: renderString(\n context,\n <>\n <Heading level={2}>Commands</Heading>\n <Spacing />\n {code`The following commands are available in the ${getAppTitle(\n context\n )} CLI application:`}\n <Spacing />\n <For each={Object.values(context.commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocs command={child} levelOffset={2} />\n </Show>\n )}\n </For>\n <Spacing />\n </>\n )\n };\n }\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoCA,MAAaS,YAAYC,wCACP;CACdC,MAAM;CACN,MAAMC,WAAW;AACf,SAAO,EACLC,6DACEH,SAAO;oDAEJP,6BAAO;IAACY,OAAO;IAACC,UAAA;IAAA,CAAA;oDAChBZ,2DAAO,EAAA,CAAA;+CACPJ,oBAAI,+CAA+CQ,oCAClDE,QACD,CAAA,mBAAmB;oDACnBN,2DAAO,EAAA,CAAA;oDACPH,gCAAG;IAAA,IAACiB,OAAI;AAAA,YAAEC,OAAOC,OAAOV,QAAQD,SAAS;;IAAEY,gBAAc;IAAAL,WACvDM,2DACEpB,iCAAI;KAAA,IAACqB,OAAI;AAAA,aAAE,CAACD,MAAME;;KAAS,IAAAR,WAAA;AAAA,8DACzBT,qCAAW;OAACkB,SAASH;OAAOI,aAAa;OAAC,CAAA;;KAAA,CAAA;IAE9C,CAAA;oDAEFtB,2DAAO,EAAA,CAAA;GAEZ,CAAA,EACD;;CAEJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automd.mjs","names":["code","For","Show","Heading","renderString","defineGenerator","CommandDocs","getAppTitle","
|
|
1
|
+
{"version":3,"file":"automd.mjs","names":["code","For","Show","Heading","Spacing","renderString","defineGenerator","CommandDocs","getAppTitle","commands","context","name","generate","contents","_$createComponent","level","children","_$memo","each","Object","values","doubleHardline","child","when","isVirtual","command","levelOffset"],"sources":["../../src/helpers/automd.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code } from \"@alloy-js/core\";\nimport { For, Show } from \"@alloy-js/core/components\";\nimport { Heading } from \"@alloy-js/markdown\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { renderString } from \"@powerlines/plugin-alloy/render\";\nimport { defineGenerator } from \"automd\";\nimport { CommandDocs } from \"../components/docs\";\nimport { getAppTitle } from \"../plugin-utils\";\nimport type { Context } from \"../types/context\";\n\n/**\n * AutoMD generator to generate CLI command documentation\n *\n * @see https://automd.unjs.io/\n *\n * @param context - The generator context.\n * @returns The generated documentation content.\n */\nexport const commands = (context: Context) =>\n defineGenerator({\n name: \"commands\",\n async generate() {\n return {\n contents: renderString(\n context,\n <>\n <Heading level={2}>Commands</Heading>\n <Spacing />\n {code`The following commands are available in the ${getAppTitle(\n context\n )} CLI application:`}\n <Spacing />\n <For each={Object.values(context.commands)} doubleHardline>\n {child => (\n <Show when={!child.isVirtual}>\n <CommandDocs command={child} levelOffset={2} />\n </Show>\n )}\n </For>\n <Spacing />\n </>\n )\n };\n }\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,MAAaS,YAAYC,YACvBJ,gBAAgB;CACdK,MAAM;CACN,MAAMC,WAAW;AACf,SAAO,EACLC,UAAUR,aACRK,SAAO;GAAAI,gBAEJX,SAAO;IAACY,OAAO;IAACC,UAAA;IAAA,CAAA;GAAAF,gBAChBV,SAAO,EAAA,CAAA;GAAAa,WACPjB,IAAI,+CAA+CQ,YAClDE,QACD,CAAA,mBAAmB;GAAAI,gBACnBV,SAAO,EAAA,CAAA;GAAAU,gBACPb,KAAG;IAAA,IAACiB,OAAI;AAAA,YAAEC,OAAOC,OAAOV,QAAQD,SAAS;;IAAEY,gBAAc;IAAAL,WACvDM,UAAKR,gBACHZ,MAAI;KAAA,IAACqB,OAAI;AAAA,aAAE,CAACD,MAAME;;KAAS,IAAAR,WAAA;AAAA,aAAAF,gBACzBP,aAAW;OAACkB,SAASH;OAAOI,aAAa;OAAC,CAAA;;KAAA,CAAA;IAE9C,CAAA;GAAAZ,gBAEFV,SAAO,EAAA,CAAA;GAEZ,CAAA,EACD;;CAEJ,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_context_helpers = require('../plugin-utils/context-helpers.cjs');
|
|
3
|
+
let __stryke_path_append = require("@stryke/path/append");
|
|
4
|
+
let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
5
|
+
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
6
|
+
let __stryke_path_replace = require("@stryke/path/replace");
|
|
7
|
+
let __stryke_path_resolve_parent_path = require("@stryke/path/resolve-parent-path");
|
|
8
|
+
let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
9
|
+
let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
10
|
+
let powerlines_utils = require("powerlines/utils");
|
|
11
|
+
let __stryke_path_common = require("@stryke/path/common");
|
|
12
|
+
let __stryke_path_normalize = require("@stryke/path/normalize");
|
|
13
|
+
let node_fs = require("node:fs");
|
|
14
|
+
|
|
15
|
+
//#region src/helpers/paths.ts
|
|
16
|
+
function __assignType(fn, args) {
|
|
17
|
+
fn.__type = args;
|
|
18
|
+
return fn;
|
|
19
|
+
}
|
|
20
|
+
function resolveCommandId(context, file) {
|
|
21
|
+
return (0, __stryke_path_replace.replacePath)((0, __stryke_path_file_path_fns.findFilePath)(file), context.commandsPath).split("/").filter(__assignType((p) => Boolean(p) && !require_context_helpers.isDynamicPathSegment(p), [
|
|
22
|
+
"p",
|
|
23
|
+
"",
|
|
24
|
+
"P\"2!\"/\""
|
|
25
|
+
])).join("/").replaceAll(/^\/+/g, "").replaceAll(/\/+$/g, "").replaceAll("/", "-");
|
|
26
|
+
}
|
|
27
|
+
resolveCommandId.__type = [
|
|
28
|
+
"Context",
|
|
29
|
+
"context",
|
|
30
|
+
"file",
|
|
31
|
+
"resolveCommandId",
|
|
32
|
+
"P\"w!2\"&2#&/$"
|
|
33
|
+
];
|
|
34
|
+
/**
|
|
35
|
+
* Finds the command name from the given file path.
|
|
36
|
+
*
|
|
37
|
+
* @param file - The file path to extract the command name from.
|
|
38
|
+
* @returns The command name.
|
|
39
|
+
*/
|
|
40
|
+
function resolveCommandName(file) {
|
|
41
|
+
let path = (0, __stryke_path_file_path_fns.findFilePath)(file);
|
|
42
|
+
let name = (0, __stryke_path_file_path_fns.findFolderName)(file, { requireExtension: true });
|
|
43
|
+
while (require_context_helpers.isDynamicPathSegment(name)) {
|
|
44
|
+
path = (0, __stryke_path_resolve_parent_path.resolveParentPath)(path);
|
|
45
|
+
name = (0, __stryke_path_file_path_fns.findFolderName)(path, { requireExtension: true });
|
|
46
|
+
}
|
|
47
|
+
return name;
|
|
48
|
+
}
|
|
49
|
+
resolveCommandName.__type = [
|
|
50
|
+
"file",
|
|
51
|
+
"resolveCommandName",
|
|
52
|
+
"P&2!\"/\""
|
|
53
|
+
];
|
|
54
|
+
function resolveCommandPath(context, file) {
|
|
55
|
+
return (0, __stryke_path_replace.replacePath)((0, __stryke_path_file_path_fns.findFilePath)(file), context.commandsPath).replaceAll(/^\/+/g, "").replaceAll(/\/+$/g, "").split("/").filter(__assignType((path) => path && !require_context_helpers.isPathSegmentGroup(path), [
|
|
56
|
+
"path",
|
|
57
|
+
"",
|
|
58
|
+
"P\"2!\"/\""
|
|
59
|
+
])).join("/");
|
|
60
|
+
}
|
|
61
|
+
resolveCommandPath.__type = [
|
|
62
|
+
"Context",
|
|
63
|
+
"context",
|
|
64
|
+
"file",
|
|
65
|
+
"resolveCommandPath",
|
|
66
|
+
"P\"w!2\"&2#&/$"
|
|
67
|
+
];
|
|
68
|
+
function resolveCommandDynamicPathSegments(context, file) {
|
|
69
|
+
return (0, __stryke_path_replace.replacePath)((0, __stryke_path_file_path_fns.findFilePath)(file), context.commandsPath).split("/").filter(__assignType((path) => Boolean(path) && require_context_helpers.isDynamicPathSegment(path), [
|
|
70
|
+
"path",
|
|
71
|
+
"",
|
|
72
|
+
"P\"2!\"/\""
|
|
73
|
+
])).map(__assignType((path) => require_context_helpers.getDynamicPathSegmentName(path), [
|
|
74
|
+
"path",
|
|
75
|
+
"",
|
|
76
|
+
"P\"2!\"/\""
|
|
77
|
+
]));
|
|
78
|
+
}
|
|
79
|
+
resolveCommandDynamicPathSegments.__type = [
|
|
80
|
+
"Context",
|
|
81
|
+
"context",
|
|
82
|
+
"file",
|
|
83
|
+
"resolveCommandDynamicPathSegments",
|
|
84
|
+
"P\"w!2\"&2#&F/$"
|
|
85
|
+
];
|
|
86
|
+
function findCommandsRoot(context) {
|
|
87
|
+
if ((0, __stryke_type_checks_is_set_string.isSetString)(context.config.input)) return (0, __stryke_path_append.appendPath)((0, __stryke_path_append.appendPath)((0, __stryke_path_normalize.stripStars)(context.config.input), context.config.root), context.workspaceConfig.workspaceRoot);
|
|
88
|
+
else if ((0, powerlines_utils.isTypeDefinition)(context.config.input)) return (0, __stryke_path_append.appendPath)((0, __stryke_path_append.appendPath)((0, __stryke_path_normalize.stripStars)(context.config.input.file), context.config.root), context.workspaceConfig.workspaceRoot);
|
|
89
|
+
else if (Array.isArray(context.config.input) && context.config.input.length > 0) return (0, __stryke_path_common.commonPath)(context.config.input.map(__assignType((input) => (0, __stryke_path_append.appendPath)((0, __stryke_path_append.appendPath)((0, __stryke_path_normalize.stripStars)((0, __stryke_type_checks_is_set_string.isSetString)(input) ? input : input.file), context.config.root), context.workspaceConfig.workspaceRoot), [
|
|
90
|
+
"input",
|
|
91
|
+
"",
|
|
92
|
+
"P\"2!\"/\""
|
|
93
|
+
])));
|
|
94
|
+
else if ((0, __stryke_type_checks_is_set_object.isSetObject)(context.config.input)) return (0, __stryke_path_common.commonPath)(Object.values(context.config.input).map(__assignType((input) => Array.isArray(input) ? (0, __stryke_path_common.commonPath)(input.map(__assignType((i) => (0, __stryke_path_append.appendPath)((0, __stryke_path_append.appendPath)((0, __stryke_path_normalize.stripStars)((0, __stryke_type_checks_is_set_string.isSetString)(i) ? i : i.file), context.config.root), context.workspaceConfig.workspaceRoot), [
|
|
95
|
+
"i",
|
|
96
|
+
"",
|
|
97
|
+
"P\"2!\"/\""
|
|
98
|
+
]))) : (0, __stryke_path_append.appendPath)((0, __stryke_path_append.appendPath)((0, __stryke_path_normalize.stripStars)((0, __stryke_type_checks_is_set_string.isSetString)(input) ? input : input.file), context.config.root), context.workspaceConfig.workspaceRoot), [
|
|
99
|
+
"input",
|
|
100
|
+
"",
|
|
101
|
+
"P\"2!\"/\""
|
|
102
|
+
])));
|
|
103
|
+
let commandsPath = (0, __stryke_path_join_paths.joinPaths)(context.config.root, "src/commands");
|
|
104
|
+
if (!(0, node_fs.existsSync)(commandsPath)) {
|
|
105
|
+
commandsPath = (0, __stryke_path_join_paths.joinPaths)(context.config.root, "commands");
|
|
106
|
+
if (!(0, node_fs.existsSync)(commandsPath)) {
|
|
107
|
+
commandsPath = (0, __stryke_path_join_paths.joinPaths)(context.config.root, "src");
|
|
108
|
+
if (!(0, node_fs.existsSync)(commandsPath)) commandsPath = context.config.root;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return (0, __stryke_path_append.appendPath)(commandsPath, context.workspaceConfig.workspaceRoot);
|
|
112
|
+
}
|
|
113
|
+
findCommandsRoot.__type = [
|
|
114
|
+
"Context",
|
|
115
|
+
"context",
|
|
116
|
+
"findCommandsRoot",
|
|
117
|
+
"P\"w!2\"&/#"
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
exports.findCommandsRoot = findCommandsRoot;
|
|
122
|
+
exports.resolveCommandId = resolveCommandId;
|
|
123
|
+
exports.resolveCommandName = resolveCommandName;
|
|
124
|
+
exports.resolveCommandPath = resolveCommandPath;
|
|
125
|
+
//# sourceMappingURL=paths.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.cjs","names":[],"sources":["../../src/helpers/paths.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 { appendPath } from \"@stryke/path/append\";\nimport { commonPath } from \"@stryke/path/common\";\nimport { findFilePath, findFolderName } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { stripStars } from \"@stryke/path/normalize\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { existsSync } from \"node:fs\";\nimport { isTypeDefinition } from \"powerlines/utils\";\nimport {\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"../plugin-utils/context-helpers\";\nimport type { Context } from \"../types/context\";\n\nexport function resolveCommandId(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(p => Boolean(p) && !isDynamicPathSegment(p))\n .join(\"/\")\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .replaceAll(\"/\", \"-\");\n}\n\n/**\n * Finds the command name from the given file path.\n *\n * @param file - The file path to extract the command name from.\n * @returns The command name.\n */\nexport function resolveCommandName(file: string) {\n let path = findFilePath(file);\n let name = findFolderName(file, {\n requireExtension: true\n });\n\n while (isDynamicPathSegment(name)) {\n path = resolveParentPath(path);\n name = findFolderName(path, {\n requireExtension: true\n });\n }\n\n return name;\n}\n\nexport function resolveCommandPath(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .split(\"/\")\n .filter(path => path && !isPathSegmentGroup(path))\n .join(\"/\");\n}\n\nexport function resolveCommandDynamicPathSegments(\n context: Context,\n file: string\n): string[] {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(path => Boolean(path) && isDynamicPathSegment(path))\n .map(path => getDynamicPathSegmentName(path));\n}\n\nexport function findCommandsRoot(context: Context): string {\n if (isSetString(context.config.input)) {\n return appendPath(\n appendPath(stripStars(context.config.input), context.config.root),\n context.workspaceConfig.workspaceRoot\n );\n } else if (isTypeDefinition(context.config.input)) {\n return appendPath(\n appendPath(stripStars(context.config.input.file), context.config.root),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n Array.isArray(context.config.input) &&\n context.config.input.length > 0\n ) {\n return commonPath(\n context.config.input.map(input =>\n appendPath(\n appendPath(\n stripStars(isSetString(input) ? input : input.file),\n context.config.root\n ),\n context.workspaceConfig.workspaceRoot\n )\n )\n );\n } else if (isSetObject(context.config.input)) {\n return commonPath(\n Object.values(context.config.input).map(input =>\n Array.isArray(input)\n ? commonPath(\n input.map(i =>\n appendPath(\n appendPath(\n stripStars(isSetString(i) ? i : i.file),\n context.config.root\n ),\n context.workspaceConfig.workspaceRoot\n )\n )\n )\n : appendPath(\n appendPath(\n stripStars(isSetString(input) ? input : input.file),\n context.config.root\n ),\n context.workspaceConfig.workspaceRoot\n )\n )\n );\n }\n\n let commandsPath = joinPaths(context.config.root, \"src/commands\");\n if (!existsSync(commandsPath)) {\n commandsPath = joinPaths(context.config.root, \"commands\");\n if (!existsSync(commandsPath)) {\n commandsPath = joinPaths(context.config.root, \"src\");\n if (!existsSync(commandsPath)) {\n commandsPath = context.config.root;\n }\n }\n }\n\n return appendPath(commandsPath, context.workspaceConfig.workspaceRoot);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AA+BX,SAAgB,iBAAiB,SAAO,MAAA;AACpC,6FAAgC,KAAK,EAAE,QAAI,aAAA,YAEtC,OAAO,cAAa,MAAK,QAAQ,EAAE,IAAI,CAAC,6CAAqB,EAAE,EAAC;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAChE,KAAK,IAAI,CACT,WAAK,SAAA,GAAA,CACL,WAAW,SAAS,GAAG,CACvB,WAAI,KAAA,IAAA;;AAEb,iBAAiB,SAAS;CAAC;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAO3B,SAAgB,mBAAmB,MAAM;CACrC,IAAI,qDAAoB,KAAA;CAC1B,IAAA,uDAAA,MAAA,EACM,kBAAkB,MACrB,CAAC;AACF,QAAO,6CAAqB,KAAE,EAAA;AAC1B,kEAAiB,KAAA;AACrB,yDAAA,MAAA,0BAEK,CAAC;;AAEN,QAAO;;AAEX,mBAAM,SAAA;CAAA;CAAA;CAAA;CAAA;AACN,SAAE,mBAAA,SAAA,MAAA;0HAEO,WAAI,SAAA,GAAA,CACb,WAAA,SAAA,GAAA,YAES,OAAO,cAAa,SAAQ,QAAQ,CAAC,2CAAmB,KAAK,EAAE;EAAC;EAAE;EAAA;EAAA,CAAA,CAAA,CAClE,KAAK,IAAI;;AAElB,mBAAmB,SAAQ;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAC3B,SAAc,kCAAA,SAAA,MAAA;AACV,6FAAgC,KAAK,EAAE,QAAQ,aAAE,CAC5C,MAAK,IAAA,CACd,OAAA,cAAA,SAAA,QAAA,KAAA,IAAA,6CAAA,KAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA;;;;;;AAGA,kCAAkB,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAClB,SAAa,iBAAA,SAAA;AACT,yDAAQ,QAAA,OAAA,MAAA,CACJ,0HAAwC,QAAQ,OAAK,MAAA,EAAA,QAAA,OAAA,KAAA,EAAA,QAAA,gBAAA,cAAA;iDAE/B,QAAQ,OAAO,MAAM,CAC3C,0HAAwC,QAAC,OAAA,MAAA,KAAA,EAAA,QAAA,OAAA,KAAA,EAAA,QAAA,gBAAA,cAAA;iDAGzC,QAAQ,OAAO,MAAM,SAAS,EAC9B,6CAAkB,QAAQ,OAAO,MAAA,IAAA,cAAA,gLAAA,MAAA,GAAA,QAAA,MAAA,KAAA,EAAA,QAAA,OAAA,KAAA,EAAA,QAAA,gBAAA,cAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;8DAEhB,QAAQ,OAAO,MAAM,CACtC,6CAAkB,OAAO,OAAO,QAAE,OAAA,MAAA,CAAA,IAAA,cAAA,UAAA,MAAA,QAAA,MAAA,wCACrC,MAAA,IAAA,cAAA,4KAAA,EAAA,GAAA,IAAA,EAAA,KAAA,EAAA,QAAA,OAAA,KAAA,EAAA,QAAA,gBAAA,cAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,yKACgD,MAAA,GAAA,QAAA,MAAA,KAAA,EAAA,QAAA,OAAA,KAAA,EAAA,QAAA,gBAAA,cAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;CAEjD,IAAI,uDAAyB,QAAQ,OAAO,MAAM,eAAe;AACjE,KAAI,yBAAY,aAAa,EAAE;AAC9B,yDAAA,QAAA,OAAA,MAAA,WAAA;AACG,MAAI,yBAAA,aAAA,EAAA;AACA,0DAAyB,QAAI,OAAA,MAAA,MAAA;AAC7B,OAAI,yBAAY,aAAM,CAC9B,gBAAA,QAAA,OAAA;;;AAIA,6CAAgB,cAAA,QAAA,gBAAA,cAAA;;AAEpB,iBAAiB,SAAS;CAAC;CAAG;CAAA;CAAA;CAAA"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { getDynamicPathSegmentName, isDynamicPathSegment, isPathSegmentGroup } from "../plugin-utils/context-helpers.mjs";
|
|
2
|
+
import { appendPath } from "@stryke/path/append";
|
|
3
|
+
import { findFilePath, findFolderName } from "@stryke/path/file-path-fns";
|
|
4
|
+
import { joinPaths } from "@stryke/path/join-paths";
|
|
5
|
+
import { replacePath } from "@stryke/path/replace";
|
|
6
|
+
import { resolveParentPath } from "@stryke/path/resolve-parent-path";
|
|
7
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
8
|
+
import { isSetString } from "@stryke/type-checks/is-set-string";
|
|
9
|
+
import { isTypeDefinition } from "powerlines/utils";
|
|
10
|
+
import { commonPath } from "@stryke/path/common";
|
|
11
|
+
import { stripStars } from "@stryke/path/normalize";
|
|
12
|
+
import { existsSync } from "node:fs";
|
|
13
|
+
|
|
14
|
+
//#region src/helpers/paths.ts
|
|
15
|
+
function __assignType(fn, args) {
|
|
16
|
+
fn.__type = args;
|
|
17
|
+
return fn;
|
|
18
|
+
}
|
|
19
|
+
function resolveCommandId(context, file) {
|
|
20
|
+
return replacePath(findFilePath(file), context.commandsPath).split("/").filter(__assignType((p) => Boolean(p) && !isDynamicPathSegment(p), [
|
|
21
|
+
"p",
|
|
22
|
+
"",
|
|
23
|
+
"P\"2!\"/\""
|
|
24
|
+
])).join("/").replaceAll(/^\/+/g, "").replaceAll(/\/+$/g, "").replaceAll("/", "-");
|
|
25
|
+
}
|
|
26
|
+
resolveCommandId.__type = [
|
|
27
|
+
"Context",
|
|
28
|
+
"context",
|
|
29
|
+
"file",
|
|
30
|
+
"resolveCommandId",
|
|
31
|
+
"P\"w!2\"&2#&/$"
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* Finds the command name from the given file path.
|
|
35
|
+
*
|
|
36
|
+
* @param file - The file path to extract the command name from.
|
|
37
|
+
* @returns The command name.
|
|
38
|
+
*/
|
|
39
|
+
function resolveCommandName(file) {
|
|
40
|
+
let path = findFilePath(file);
|
|
41
|
+
let name = findFolderName(file, { requireExtension: true });
|
|
42
|
+
while (isDynamicPathSegment(name)) {
|
|
43
|
+
path = resolveParentPath(path);
|
|
44
|
+
name = findFolderName(path, { requireExtension: true });
|
|
45
|
+
}
|
|
46
|
+
return name;
|
|
47
|
+
}
|
|
48
|
+
resolveCommandName.__type = [
|
|
49
|
+
"file",
|
|
50
|
+
"resolveCommandName",
|
|
51
|
+
"P&2!\"/\""
|
|
52
|
+
];
|
|
53
|
+
function resolveCommandPath(context, file) {
|
|
54
|
+
return replacePath(findFilePath(file), context.commandsPath).replaceAll(/^\/+/g, "").replaceAll(/\/+$/g, "").split("/").filter(__assignType((path) => path && !isPathSegmentGroup(path), [
|
|
55
|
+
"path",
|
|
56
|
+
"",
|
|
57
|
+
"P\"2!\"/\""
|
|
58
|
+
])).join("/");
|
|
59
|
+
}
|
|
60
|
+
resolveCommandPath.__type = [
|
|
61
|
+
"Context",
|
|
62
|
+
"context",
|
|
63
|
+
"file",
|
|
64
|
+
"resolveCommandPath",
|
|
65
|
+
"P\"w!2\"&2#&/$"
|
|
66
|
+
];
|
|
67
|
+
function resolveCommandDynamicPathSegments(context, file) {
|
|
68
|
+
return replacePath(findFilePath(file), context.commandsPath).split("/").filter(__assignType((path) => Boolean(path) && isDynamicPathSegment(path), [
|
|
69
|
+
"path",
|
|
70
|
+
"",
|
|
71
|
+
"P\"2!\"/\""
|
|
72
|
+
])).map(__assignType((path) => getDynamicPathSegmentName(path), [
|
|
73
|
+
"path",
|
|
74
|
+
"",
|
|
75
|
+
"P\"2!\"/\""
|
|
76
|
+
]));
|
|
77
|
+
}
|
|
78
|
+
resolveCommandDynamicPathSegments.__type = [
|
|
79
|
+
"Context",
|
|
80
|
+
"context",
|
|
81
|
+
"file",
|
|
82
|
+
"resolveCommandDynamicPathSegments",
|
|
83
|
+
"P\"w!2\"&2#&F/$"
|
|
84
|
+
];
|
|
85
|
+
function findCommandsRoot(context) {
|
|
86
|
+
if (isSetString(context.config.input)) return appendPath(appendPath(stripStars(context.config.input), context.config.root), context.workspaceConfig.workspaceRoot);
|
|
87
|
+
else if (isTypeDefinition(context.config.input)) return appendPath(appendPath(stripStars(context.config.input.file), context.config.root), context.workspaceConfig.workspaceRoot);
|
|
88
|
+
else if (Array.isArray(context.config.input) && context.config.input.length > 0) return commonPath(context.config.input.map(__assignType((input) => appendPath(appendPath(stripStars(isSetString(input) ? input : input.file), context.config.root), context.workspaceConfig.workspaceRoot), [
|
|
89
|
+
"input",
|
|
90
|
+
"",
|
|
91
|
+
"P\"2!\"/\""
|
|
92
|
+
])));
|
|
93
|
+
else if (isSetObject(context.config.input)) return commonPath(Object.values(context.config.input).map(__assignType((input) => Array.isArray(input) ? commonPath(input.map(__assignType((i) => appendPath(appendPath(stripStars(isSetString(i) ? i : i.file), context.config.root), context.workspaceConfig.workspaceRoot), [
|
|
94
|
+
"i",
|
|
95
|
+
"",
|
|
96
|
+
"P\"2!\"/\""
|
|
97
|
+
]))) : appendPath(appendPath(stripStars(isSetString(input) ? input : input.file), context.config.root), context.workspaceConfig.workspaceRoot), [
|
|
98
|
+
"input",
|
|
99
|
+
"",
|
|
100
|
+
"P\"2!\"/\""
|
|
101
|
+
])));
|
|
102
|
+
let commandsPath = joinPaths(context.config.root, "src/commands");
|
|
103
|
+
if (!existsSync(commandsPath)) {
|
|
104
|
+
commandsPath = joinPaths(context.config.root, "commands");
|
|
105
|
+
if (!existsSync(commandsPath)) {
|
|
106
|
+
commandsPath = joinPaths(context.config.root, "src");
|
|
107
|
+
if (!existsSync(commandsPath)) commandsPath = context.config.root;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return appendPath(commandsPath, context.workspaceConfig.workspaceRoot);
|
|
111
|
+
}
|
|
112
|
+
findCommandsRoot.__type = [
|
|
113
|
+
"Context",
|
|
114
|
+
"context",
|
|
115
|
+
"findCommandsRoot",
|
|
116
|
+
"P\"w!2\"&/#"
|
|
117
|
+
];
|
|
118
|
+
|
|
119
|
+
//#endregion
|
|
120
|
+
export { findCommandsRoot, resolveCommandId, resolveCommandName, resolveCommandPath };
|
|
121
|
+
//# sourceMappingURL=paths.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.mjs","names":[],"sources":["../../src/helpers/paths.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 { appendPath } from \"@stryke/path/append\";\nimport { commonPath } from \"@stryke/path/common\";\nimport { findFilePath, findFolderName } from \"@stryke/path/file-path-fns\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { stripStars } from \"@stryke/path/normalize\";\nimport { replacePath } from \"@stryke/path/replace\";\nimport { resolveParentPath } from \"@stryke/path/resolve-parent-path\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { existsSync } from \"node:fs\";\nimport { isTypeDefinition } from \"powerlines/utils\";\nimport {\n getDynamicPathSegmentName,\n isDynamicPathSegment,\n isPathSegmentGroup\n} from \"../plugin-utils/context-helpers\";\nimport type { Context } from \"../types/context\";\n\nexport function resolveCommandId(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(p => Boolean(p) && !isDynamicPathSegment(p))\n .join(\"/\")\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .replaceAll(\"/\", \"-\");\n}\n\n/**\n * Finds the command name from the given file path.\n *\n * @param file - The file path to extract the command name from.\n * @returns The command name.\n */\nexport function resolveCommandName(file: string) {\n let path = findFilePath(file);\n let name = findFolderName(file, {\n requireExtension: true\n });\n\n while (isDynamicPathSegment(name)) {\n path = resolveParentPath(path);\n name = findFolderName(path, {\n requireExtension: true\n });\n }\n\n return name;\n}\n\nexport function resolveCommandPath(context: Context, file: string): string {\n return replacePath(findFilePath(file), context.commandsPath)\n .replaceAll(/^\\/+/g, \"\")\n .replaceAll(/\\/+$/g, \"\")\n .split(\"/\")\n .filter(path => path && !isPathSegmentGroup(path))\n .join(\"/\");\n}\n\nexport function resolveCommandDynamicPathSegments(\n context: Context,\n file: string\n): string[] {\n return replacePath(findFilePath(file), context.commandsPath)\n .split(\"/\")\n .filter(path => Boolean(path) && isDynamicPathSegment(path))\n .map(path => getDynamicPathSegmentName(path));\n}\n\nexport function findCommandsRoot(context: Context): string {\n if (isSetString(context.config.input)) {\n return appendPath(\n appendPath(stripStars(context.config.input), context.config.root),\n context.workspaceConfig.workspaceRoot\n );\n } else if (isTypeDefinition(context.config.input)) {\n return appendPath(\n appendPath(stripStars(context.config.input.file), context.config.root),\n context.workspaceConfig.workspaceRoot\n );\n } else if (\n Array.isArray(context.config.input) &&\n context.config.input.length > 0\n ) {\n return commonPath(\n context.config.input.map(input =>\n appendPath(\n appendPath(\n stripStars(isSetString(input) ? input : input.file),\n context.config.root\n ),\n context.workspaceConfig.workspaceRoot\n )\n )\n );\n } else if (isSetObject(context.config.input)) {\n return commonPath(\n Object.values(context.config.input).map(input =>\n Array.isArray(input)\n ? commonPath(\n input.map(i =>\n appendPath(\n appendPath(\n stripStars(isSetString(i) ? i : i.file),\n context.config.root\n ),\n context.workspaceConfig.workspaceRoot\n )\n )\n )\n : appendPath(\n appendPath(\n stripStars(isSetString(input) ? input : input.file),\n context.config.root\n ),\n context.workspaceConfig.workspaceRoot\n )\n )\n );\n }\n\n let commandsPath = joinPaths(context.config.root, \"src/commands\");\n if (!existsSync(commandsPath)) {\n commandsPath = joinPaths(context.config.root, \"commands\");\n if (!existsSync(commandsPath)) {\n commandsPath = joinPaths(context.config.root, \"src\");\n if (!existsSync(commandsPath)) {\n commandsPath = context.config.root;\n }\n }\n }\n\n return appendPath(commandsPath, context.workspaceConfig.workspaceRoot);\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AA+BX,SAAgB,iBAAiB,SAAO,MAAA;AACpC,QAAO,YAAY,aAAa,KAAK,EAAE,QAAI,aAAA,YAEtC,OAAO,cAAa,MAAK,QAAQ,EAAE,IAAI,CAAC,qBAAqB,EAAE,EAAC;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAChE,KAAK,IAAI,CACT,WAAK,SAAA,GAAA,CACL,WAAW,SAAS,GAAG,CACvB,WAAI,KAAA,IAAA;;AAEb,iBAAiB,SAAS;CAAC;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAO3B,SAAgB,mBAAmB,MAAM;CACrC,IAAI,OAAO,aAAa,KAAA;CAC1B,IAAA,OAAA,eAAA,MAAA,EACM,kBAAkB,MACrB,CAAC;AACF,QAAO,qBAAqB,KAAE,EAAA;AAC1B,SAAO,kBAAU,KAAA;AACrB,SAAA,eAAA,MAAA,0BAEK,CAAC;;AAEN,QAAO;;AAEX,mBAAM,SAAA;CAAA;CAAA;CAAA;CAAA;AACN,SAAE,mBAAA,SAAA,MAAA;8DAEO,WAAI,SAAA,GAAA,CACb,WAAA,SAAA,GAAA,YAES,OAAO,cAAa,SAAQ,QAAQ,CAAC,mBAAmB,KAAK,EAAE;EAAC;EAAE;EAAA;EAAA,CAAA,CAAA,CAClE,KAAK,IAAI;;AAElB,mBAAmB,SAAQ;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAC3B,SAAc,kCAAA,SAAA,MAAA;AACV,QAAO,YAAY,aAAa,KAAK,EAAE,QAAQ,aAAE,CAC5C,MAAK,IAAA,CACd,OAAA,cAAA,SAAA,QAAA,KAAA,IAAA,qBAAA,KAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA;;;;;;AAGA,kCAAkB,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AAClB,SAAa,iBAAA,SAAA;AACT,KAAI,YAAI,QAAA,OAAA,MAAA,CACJ,QAAO,WAAW,WAAW,WAAW,QAAQ,OAAK,MAAA,EAAA,QAAA,OAAA,KAAA,EAAA,QAAA,gBAAA,cAAA;UAEhD,iBAAiB,QAAQ,OAAO,MAAM,CAC3C,QAAO,WAAW,WAAW,WAAW,QAAC,OAAA,MAAA,KAAA,EAAA,QAAA,OAAA,KAAA,EAAA,QAAA,gBAAA,cAAA;iDAGzC,QAAQ,OAAO,MAAM,SAAS,EAC9B,QAAO,WAAW,QAAQ,OAAO,MAAA,IAAA,cAAA,UAAA,WAAA,WAAA,WAAA,YAAA,MAAA,GAAA,QAAA,MAAA,KAAA,EAAA,QAAA,OAAA,KAAA,EAAA,QAAA,gBAAA,cAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;UAE5B,YAAY,QAAQ,OAAO,MAAM,CACtC,QAAO,WAAW,OAAO,OAAO,QAAE,OAAA,MAAA,CAAA,IAAA,cAAA,UAAA,MAAA,QAAA,MAAA,GACrC,WAAA,MAAA,IAAA,cAAA,MAAA,WAAA,WAAA,WAAA,YAAA,EAAA,GAAA,IAAA,EAAA,KAAA,EAAA,QAAA,OAAA,KAAA,EAAA,QAAA,gBAAA,cAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA,GACS,WAAW,WAAW,WAAW,YAAM,MAAA,GAAA,QAAA,MAAA,KAAA,EAAA,QAAA,OAAA,KAAA,EAAA,QAAA,gBAAA,cAAA,EAAA;EAAA;EAAA;EAAA;EAAA,CAAA,CAAA,CAAA;CAEjD,IAAI,eAAe,UAAU,QAAQ,OAAO,MAAM,eAAe;AACjE,KAAI,CAAC,WAAW,aAAa,EAAE;AAC9B,iBAAA,UAAA,QAAA,OAAA,MAAA,WAAA;AACG,MAAI,CAAA,WAAA,aAAA,EAAA;AACA,kBAAe,UAAU,QAAI,OAAA,MAAA,MAAA;AAC7B,OAAI,CAAC,WAAW,aAAM,CAC9B,gBAAA,QAAA,OAAA;;;AAIA,QAAO,WAAS,cAAA,QAAA,gBAAA,cAAA;;AAEpB,iBAAiB,SAAS;CAAC;CAAG;CAAA;CAAA;CAAA"}
|