@shell-shock/core 0.11.0 → 0.12.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.d.cts +5 -5
- package/dist/components/docs.d.mts +5 -5
- package/dist/components/docs.d.mts.map +1 -1
- package/dist/components/helpers.cjs +9 -0
- package/dist/components/helpers.cjs.map +1 -1
- package/dist/components/helpers.d.cts +15 -7
- package/dist/components/helpers.d.cts.map +1 -1
- package/dist/components/helpers.d.mts +15 -7
- package/dist/components/helpers.d.mts.map +1 -1
- package/dist/components/helpers.mjs +9 -1
- package/dist/components/helpers.mjs.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 +142 -62
- package/dist/components/options-parser-logic.cjs.map +1 -1
- package/dist/components/options-parser-logic.d.cts +15 -15
- package/dist/components/options-parser-logic.d.cts.map +1 -1
- package/dist/components/options-parser-logic.d.mts +15 -15
- package/dist/components/options-parser-logic.d.mts.map +1 -1
- package/dist/components/options-parser-logic.mjs +143 -63
- package/dist/components/options-parser-logic.mjs.map +1 -1
- package/dist/components/usage.d.cts +2 -2
- package/dist/components/usage.d.mts +2 -2
- package/dist/components/utils-builtin.d.cts +9 -9
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts +9 -9
- package/dist/components/utils-builtin.d.mts.map +1 -1
- package/dist/plugin-utils/description-helpers.cjs +105 -0
- package/dist/plugin-utils/description-helpers.cjs.map +1 -0
- package/dist/plugin-utils/description-helpers.d.cts +44 -0
- package/dist/plugin-utils/description-helpers.d.cts.map +1 -0
- package/dist/plugin-utils/description-helpers.d.mts +44 -0
- package/dist/plugin-utils/description-helpers.d.mts.map +1 -0
- package/dist/plugin-utils/description-helpers.mjs +101 -0
- package/dist/plugin-utils/description-helpers.mjs.map +1 -0
- package/dist/plugin-utils/index.cjs +5 -0
- package/dist/plugin-utils/index.d.cts +2 -1
- package/dist/plugin-utils/index.d.mts +2 -1
- package/dist/plugin-utils/index.mjs +2 -1
- package/dist/plugin-utils/type-checks.d.mts.map +1 -1
- package/dist/plugin.cjs +4 -6
- 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 +4 -6
- package/dist/plugin.mjs.map +1 -1
- package/dist/resolver/deepkit.cjs +6 -3
- package/dist/resolver/deepkit.cjs.map +1 -1
- package/dist/resolver/deepkit.mjs +6 -3
- package/dist/resolver/deepkit.mjs.map +1 -1
- package/dist/resolver/helpers.cjs +15 -21
- package/dist/resolver/helpers.cjs.map +1 -1
- package/dist/resolver/helpers.mjs +15 -21
- package/dist/resolver/helpers.mjs.map +1 -1
- package/dist/resolver/resolve.cjs +13 -13
- package/dist/resolver/resolve.cjs.map +1 -1
- package/dist/resolver/resolve.mjs +13 -13
- package/dist/resolver/resolve.mjs.map +1 -1
- package/dist/types/config.cjs +5 -3
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.cts +7 -3
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +7 -3
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +5 -3
- package/dist/types/config.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -50,39 +50,39 @@ initialize.__type = [
|
|
|
50
50
|
"P\"w!2\"\"w#`/$"
|
|
51
51
|
];
|
|
52
52
|
async function postprocess(ctx) {
|
|
53
|
-
ctx.output.options = applyOptionsDefaults(ctx
|
|
54
|
-
ctx.output.args = applyArgsDefaults(ctx
|
|
55
|
-
ctx.output.args.forEach(__assignType((
|
|
56
|
-
const found = ctx.output.args.findIndex(__assignType((
|
|
57
|
-
"
|
|
53
|
+
ctx.output.options = applyOptionsDefaults(ctx);
|
|
54
|
+
ctx.output.args = applyArgsDefaults(ctx);
|
|
55
|
+
ctx.output.args.forEach(__assignType((arg, index) => {
|
|
56
|
+
const found = ctx.output.args.findIndex(__assignType((a) => a.name === arg.name, [
|
|
57
|
+
"a",
|
|
58
58
|
"",
|
|
59
59
|
"P\"2!\"/\""
|
|
60
60
|
]));
|
|
61
|
-
if (found !== -1 && found !== index || ctx.output.segments.some(__assignType((segment) => isDynamicPathSegment(segment) && getDynamicPathSegmentName(segment) ===
|
|
61
|
+
if (found !== -1 && found !== index || ctx.output.segments.some(__assignType((segment) => isDynamicPathSegment(segment) && getDynamicPathSegmentName(segment) === arg.name, [
|
|
62
62
|
"segment",
|
|
63
63
|
"",
|
|
64
64
|
"P\"2!\"/\""
|
|
65
65
|
]))) {
|
|
66
|
-
|
|
66
|
+
arg.name += `_${ctx.output.segments.filter(__assignType((segment) => isDynamicPathSegment(segment) && getDynamicPathSegmentName(segment).replace(/_\d+$/, "") === arg.name, [
|
|
67
67
|
"segment",
|
|
68
68
|
"",
|
|
69
69
|
"P\"2!\"/\""
|
|
70
|
-
])).length + ctx.output.args.filter(__assignType((
|
|
71
|
-
"
|
|
70
|
+
])).length + ctx.output.args.filter(__assignType((a) => a.name.replace(/_\d+$/, "") === arg.name, [
|
|
71
|
+
"a",
|
|
72
72
|
"",
|
|
73
73
|
"P\"2!\"/\""
|
|
74
74
|
])).length}`;
|
|
75
|
-
|
|
75
|
+
arg.env = arg.name ? arg.env || arg.env === false ? arg.env : ctx.input.context.config.autoAssignEnv ? constantCase(arg.name) : false : false;
|
|
76
76
|
}
|
|
77
77
|
}, [
|
|
78
|
-
"
|
|
78
|
+
"arg",
|
|
79
79
|
"index",
|
|
80
80
|
"",
|
|
81
81
|
"P\"2!\"2\"\"/#"
|
|
82
82
|
]));
|
|
83
83
|
applyDefaults(ctx);
|
|
84
84
|
if (ctx.input.context.env) {
|
|
85
|
-
if (isSetObject(ctx.output.options)) Object.values(ctx.output.options).filter(__assignType((option) => option.env
|
|
85
|
+
if (isSetObject(ctx.output.options)) Object.values(ctx.output.options).filter(__assignType((option) => Boolean(option.env), [
|
|
86
86
|
"option",
|
|
87
87
|
"",
|
|
88
88
|
"P\"2!\"/\""
|
|
@@ -113,7 +113,7 @@ async function postprocess(ctx) {
|
|
|
113
113
|
"",
|
|
114
114
|
"P\"2!\"/\""
|
|
115
115
|
]));
|
|
116
|
-
ctx.output.args.filter(__assignType((arg) => arg.env
|
|
116
|
+
ctx.output.args.filter(__assignType((arg) => Boolean(arg.env), [
|
|
117
117
|
"arg",
|
|
118
118
|
"",
|
|
119
119
|
"P\"2!\"/\""
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.mjs","names":[],"sources":["../../src/resolver/resolve.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 { esbuildPlugin } from \"@powerlines/deepkit/esbuild-plugin\";\nimport { ReflectionVisibility } from \"@powerlines/deepkit/vendor/type\";\nimport { resolveModule } from \"@powerlines/plugin-esbuild/helpers/resolve\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { getDefaultOptions } from \"../helpers/utilities\";\nimport {\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"../plugin-utils/context-helpers\";\nimport { extractType } from \"../plugin-utils/deepkit\";\nimport type { CommandModule, CommandTree, Context } from \"../types\";\nimport { resolveFromBytecode } from \"./deepkit\";\nimport {\n applyArgsDefaults,\n applyDefaults,\n applyOptionsDefaults,\n resolveVirtualCommand\n} from \"./helpers\";\nimport { resolveFromExports } from \"./module\";\nimport type { ResolverContext, ResolverInput } from \"./types\";\n\nasync function initialize<TContext extends Context = Context>(\n input: ResolverInput<TContext>\n): Promise<ResolverContext> {\n const { context, command, parent } = input;\n\n const title =\n command.title ||\n `${\n parent?.title\n ? `${\n parent.isVirtual\n ? parent.title.replace(/(?:c|C)ommands?$/, \"\").trim()\n : parent.title\n } - `\n : \"\"\n }${titleCase(command.name)}${command.isVirtual ? \" Commands\" : \"\"}`;\n\n const output = {\n alias: [],\n icon: parent?.icon,\n ...command,\n title,\n options: getDefaultOptions(context, command),\n args: [],\n parent: parent ?? null,\n children: {}\n } as CommandTree;\n\n const result: ResolverContext = {\n input,\n output\n };\n\n if (!command.isVirtual) {\n if (\n !command.entry.input?.file ||\n !context.fs.existsSync(command.entry.input.file)\n ) {\n throw new Error(\n `${\n !command.entry.input?.file ? \"Missing\" : \"Non-existent\"\n } command entry file for \"${command.name}\"`\n );\n }\n\n context.debug(\n `Adding reflection for user-defined command: ${command.id} (file: ${\n command.entry.input.file\n })`\n );\n\n result.module = await resolveModule<CommandModule>(\n context,\n command.entry.input,\n {\n plugins: [\n esbuildPlugin(context, {\n reflection: \"default\",\n reflectionLevel: \"verbose\"\n })\n ]\n }\n );\n }\n\n return result;\n}\n\nasync function postprocess<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n): Promise<CommandTree> {\n ctx.output.options = applyOptionsDefaults(ctx.output.options);\n ctx.output.args = applyArgsDefaults(ctx.output.args);\n\n // Ensure unique argument names by appending an index suffix to duplicates\n ctx.output.args.forEach((argument, index) => {\n const found = ctx.output.args.findIndex(arg => arg.name === argument.name);\n if (\n (found !== -1 && found !== index) ||\n ctx.output.segments.some(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment) === argument.name\n )\n ) {\n argument.name += `_${\n ctx.output.segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(/_\\d+$/, \"\") ===\n argument.name\n ).length +\n ctx.output.args.filter(\n arg => arg.name.replace(/_\\d+$/, \"\") === argument.name\n ).length\n }`;\n argument.env = constantCase(argument.name);\n }\n });\n\n applyDefaults(ctx);\n\n if (ctx.input.context.env) {\n if (isSetObject(ctx.output.options)) {\n Object.values(ctx.output.options)\n .filter(option => option.env !== false)\n .forEach(option => {\n ctx.input.context.env.types.env.addProperty({\n name: option.env as string,\n optional: option.optional ? true : undefined,\n description: option.description,\n visibility: ReflectionVisibility.public,\n type: extractType(option),\n default: option.default,\n tags: {\n title: option.title,\n alias: option.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n });\n });\n }\n\n ctx.output.args\n .filter(arg => arg.env !== false)\n .forEach(arg =>\n ctx.input.context.env.types.env.addProperty({\n name: arg.env as string,\n optional: arg.optional ? true : undefined,\n description: arg.description,\n visibility: ReflectionVisibility.public,\n type: extractType(arg),\n default: arg.default,\n tags: {\n alias: arg.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n })\n );\n }\n\n for (const input of ctx.input.context.inputs.filter(\n input =>\n input.segments.filter(segment => !isDynamicPathSegment(segment))\n .length ===\n ctx.input.command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n ).length +\n 1 &&\n input.segments\n .slice(0, ctx.input.command.segments.length)\n .every((value, index) => value === ctx.input.command.segments[index])\n )) {\n ctx.output.children[input.name] = await resolve<TContext>({\n context: ctx.input.context,\n command: input,\n parent: ctx.output\n });\n }\n\n return ctx.output;\n}\n\n/**\n * Resolves a command tree from the given resolver input.\n *\n * @param input - The resolver input containing the context, command, and optional parent command tree.\n * @returns A promise that resolves to the resolved command tree.\n */\nexport async function resolve<TContext extends Context = Context>(\n input: ResolverInput<TContext>\n): Promise<CommandTree> {\n const ctx = await initialize<TContext>(input);\n\n if (!ctx.output.isVirtual) {\n await resolveFromExports(ctx);\n resolveFromBytecode(ctx);\n } else {\n resolveVirtualC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AAA;CAAA"}
|
|
1
|
+
{"version":3,"file":"resolve.mjs","names":[],"sources":["../../src/resolver/resolve.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 { esbuildPlugin } from \"@powerlines/deepkit/esbuild-plugin\";\nimport { ReflectionVisibility } from \"@powerlines/deepkit/vendor/type\";\nimport { resolveModule } from \"@powerlines/plugin-esbuild/helpers/resolve\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { getDefaultOptions } from \"../helpers/utilities\";\nimport {\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"../plugin-utils/context-helpers\";\nimport { extractType } from \"../plugin-utils/deepkit\";\nimport type { CommandModule, CommandTree, Context } from \"../types\";\nimport { resolveFromBytecode } from \"./deepkit\";\nimport {\n applyArgsDefaults,\n applyDefaults,\n applyOptionsDefaults,\n resolveVirtualCommand\n} from \"./helpers\";\nimport { resolveFromExports } from \"./module\";\nimport type { ResolverContext, ResolverInput } from \"./types\";\n\nasync function initialize<TContext extends Context = Context>(\n input: ResolverInput<TContext>\n): Promise<ResolverContext> {\n const { context, command, parent } = input;\n\n const title =\n command.title ||\n `${\n parent?.title\n ? `${\n parent.isVirtual\n ? parent.title.replace(/(?:c|C)ommands?$/, \"\").trim()\n : parent.title\n } - `\n : \"\"\n }${titleCase(command.name)}${command.isVirtual ? \" Commands\" : \"\"}`;\n\n const output = {\n alias: [],\n icon: parent?.icon,\n ...command,\n title,\n options: getDefaultOptions(context, command),\n args: [],\n parent: parent ?? null,\n children: {}\n } as CommandTree;\n\n const result: ResolverContext = {\n input,\n output\n };\n\n if (!command.isVirtual) {\n if (\n !command.entry.input?.file ||\n !context.fs.existsSync(command.entry.input.file)\n ) {\n throw new Error(\n `${\n !command.entry.input?.file ? \"Missing\" : \"Non-existent\"\n } command entry file for \"${command.name}\"`\n );\n }\n\n context.debug(\n `Adding reflection for user-defined command: ${command.id} (file: ${\n command.entry.input.file\n })`\n );\n\n result.module = await resolveModule<CommandModule>(\n context,\n command.entry.input,\n {\n plugins: [\n esbuildPlugin(context, {\n reflection: \"default\",\n reflectionLevel: \"verbose\"\n })\n ]\n }\n );\n }\n\n return result;\n}\n\nasync function postprocess<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n): Promise<CommandTree> {\n ctx.output.options = applyOptionsDefaults(ctx);\n ctx.output.args = applyArgsDefaults(ctx);\n\n // Ensure unique argument names by appending an index suffix to duplicates\n ctx.output.args.forEach((arg, index) => {\n const found = ctx.output.args.findIndex(a => a.name === arg.name);\n if (\n (found !== -1 && found !== index) ||\n ctx.output.segments.some(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment) === arg.name\n )\n ) {\n arg.name += `_${\n ctx.output.segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(/_\\d+$/, \"\") === arg.name\n ).length +\n ctx.output.args.filter(a => a.name.replace(/_\\d+$/, \"\") === arg.name)\n .length\n }`;\n arg.env = arg.name\n ? arg.env || arg.env === false\n ? arg.env\n : ctx.input.context.config.autoAssignEnv\n ? constantCase(arg.name)\n : false\n : false;\n }\n });\n\n applyDefaults(ctx);\n\n if (ctx.input.context.env) {\n if (isSetObject(ctx.output.options)) {\n Object.values(ctx.output.options)\n .filter(option => Boolean(option.env))\n .forEach(option => {\n ctx.input.context.env.types.env.addProperty({\n name: option.env as string,\n optional: option.optional ? true : undefined,\n description: option.description,\n visibility: ReflectionVisibility.public,\n type: extractType(option),\n default: option.default,\n tags: {\n title: option.title,\n alias: option.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n });\n });\n }\n\n ctx.output.args\n .filter(arg => Boolean(arg.env))\n .forEach(arg =>\n ctx.input.context.env.types.env.addProperty({\n name: arg.env as string,\n optional: arg.optional ? true : undefined,\n description: arg.description,\n visibility: ReflectionVisibility.public,\n type: extractType(arg),\n default: arg.default,\n tags: {\n alias: arg.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n })\n );\n }\n\n for (const input of ctx.input.context.inputs.filter(\n input =>\n input.segments.filter(segment => !isDynamicPathSegment(segment))\n .length ===\n ctx.input.command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n ).length +\n 1 &&\n input.segments\n .slice(0, ctx.input.command.segments.length)\n .every((value, index) => value === ctx.input.command.segments[index])\n )) {\n ctx.output.children[input.name] = await resolve<TContext>({\n context: ctx.input.context,\n command: input,\n parent: ctx.output\n });\n }\n\n return ctx.output;\n}\n\n/**\n * Resolves a command tree from the given resolver input.\n *\n * @param input - The resolver input containing the context, command, and optional parent command tree.\n * @returns A promise that resolves to the resolved command tree.\n */\nexport async function resolve<TContext extends Context = Context>(\n input: ResolverInput<TContext>\n): Promise<CommandTree> {\n const ctx = await initialize<TContext>(input);\n\n if (!ctx.output.isVirtual) {\n await resolveFromExports(ctx);\n resolveFromBytecode(ctx);\n } else {\n resolveVirtualCommand(ctx);\n }\n\n return postprocess(ctx);\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AA+BX,eAAe,WAAI,OAAA;CACf,MAAM,EAAE,SAAG,SAAA,WAAA;CACX,MAAM,QAAQ,QAAI,SACd,GAAG,QAAQ,QACL,GAAG,OAAC,YACA,OAAO,MAAM,QAAQ,oBAAM,GAAA,CAAA,MA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IAAA;AAEtB,QAAO,YAAC,IAAA;;AAEZ,QAAI,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA"}
|
package/dist/types/config.cjs
CHANGED
|
@@ -66,9 +66,10 @@ const __ΩBaseOptions = [
|
|
|
66
66
|
"isCaseSensitive",
|
|
67
67
|
true,
|
|
68
68
|
"bin",
|
|
69
|
-
|
|
69
|
+
true,
|
|
70
|
+
"autoAssignEnv",
|
|
70
71
|
"BaseOptions",
|
|
71
|
-
"Pn\"o!\"PP\"w#FP\"w$2%\"w&2'\"w#F/(.)J4*8)4+8>,P&&FJ4-
|
|
72
|
+
"Pn\"o!\"PP\"w#FP\"w$2%\"w&2'\"w#F/(.)J4*8)4+8>,P&&FJ4-8P..&J4/8MKw0y"
|
|
72
73
|
];
|
|
73
74
|
const __ΩOptions = [
|
|
74
75
|
() => __ΩBaseOptions,
|
|
@@ -101,10 +102,11 @@ const __ΩResolvedConfig = [
|
|
|
101
102
|
"bin",
|
|
102
103
|
() => __ΩRecord,
|
|
103
104
|
"bin",
|
|
105
|
+
"appSpecificEnvPrefix",
|
|
104
106
|
() => __ΩUserConfig,
|
|
105
107
|
"userConfig",
|
|
106
108
|
"ResolvedConfig",
|
|
107
|
-
"P!!!n#.$o\"#o!\"P&&o%#4
|
|
109
|
+
"P!!!n#.$o\"#o!\"P&&o%#4&&4'n(4)MKw*y"
|
|
108
110
|
];
|
|
109
111
|
|
|
110
112
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.cjs","names":[],"sources":["../../src/types/config.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 { AutoMDPluginResolvedConfig } from \"@powerlines/plugin-automd/types/plugin\";\nimport type {\n NodeJsPluginOptions,\n NodeJsPluginResolvedConfig,\n NodeJsPluginUserConfig\n} from \"@powerlines/plugin-nodejs/types/plugin\";\nimport type {\n TsdownPluginResolvedConfig,\n TsdownPluginUserConfig\n} from \"@powerlines/plugin-tsdown/types/plugin\";\nimport type { OutputConfig as PowerlinesOutputConfig } from \"powerlines\";\nimport type { CommandBase, CommandOption } from \"./command\";\nimport type { Context } from \"./context\";\n\ntype BuildOptions = Pick<\n TsdownPluginUserConfig,\n | \"root\"\n | \"name\"\n | \"title\"\n | \"description\"\n | \"logLevel\"\n | \"mode\"\n | \"skipCache\"\n | \"autoInstall\"\n | \"plugins\"\n | \"tsconfig\"\n | \"tsconfigRaw\"\n>;\n\ntype BaseOptions = Partial<BuildOptions> & {\n /**\n * A set of default command options to apply to each command.\n *\n * @remarks\n * To disable the addition of these default options, set this property to `false`, or provide a custom set of options/a function that returns them.\n */\n defaultOptions?:\n | CommandOption[]\n | ((context: Context, input: CommandBase) => CommandOption[])\n | false;\n\n /**\n * Determines whether commands and option names are treated as case-sensitive.\n *\n * @defaultValue `false`\n */\n isCaseSensitive?: boolean;\n\n /**\n * The name of the binary (the {@link https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bin | \"bin\" field} in package.json) that will be used to run the application through NodeJs package managers (e.g., npm, yarn, pnpm).\n *\n * @remarks\n * If an array is provided, each binary will be linked to the same compiled output file. If not provided, the {@link Options.name | name} option will be used.\n *\n * @see https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bin\n * @see https://yarnpkg.com/cli/bin\n * @see https://pnpm.io/package_json#bin\n */\n bin?: string | string[];\n\n /**\n *
|
|
1
|
+
{"version":3,"file":"config.cjs","names":[],"sources":["../../src/types/config.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 { AutoMDPluginResolvedConfig } from \"@powerlines/plugin-automd/types/plugin\";\nimport type {\n NodeJsPluginOptions,\n NodeJsPluginResolvedConfig,\n NodeJsPluginUserConfig\n} from \"@powerlines/plugin-nodejs/types/plugin\";\nimport type {\n TsdownPluginResolvedConfig,\n TsdownPluginUserConfig\n} from \"@powerlines/plugin-tsdown/types/plugin\";\nimport type { OutputConfig as PowerlinesOutputConfig } from \"powerlines\";\nimport type { CommandBase, CommandOption } from \"./command\";\nimport type { Context } from \"./context\";\n\ntype BuildOptions = Pick<\n TsdownPluginUserConfig,\n | \"root\"\n | \"name\"\n | \"title\"\n | \"description\"\n | \"logLevel\"\n | \"mode\"\n | \"skipCache\"\n | \"autoInstall\"\n | \"plugins\"\n | \"tsconfig\"\n | \"tsconfigRaw\"\n>;\n\ntype BaseOptions = Partial<BuildOptions> & {\n /**\n * A set of default command options to apply to each command.\n *\n * @remarks\n * To disable the addition of these default options, set this property to `false`, or provide a custom set of options/a function that returns them.\n */\n defaultOptions?:\n | CommandOption[]\n | ((context: Context, input: CommandBase) => CommandOption[])\n | false;\n\n /**\n * Determines whether commands and option names are treated as case-sensitive.\n *\n * @defaultValue `false`\n */\n isCaseSensitive?: boolean;\n\n /**\n * The name of the binary (the {@link https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bin | \"bin\" field} in package.json) that will be used to run the application through NodeJs package managers (e.g., npm, yarn, pnpm).\n *\n * @remarks\n * If an array is provided, each binary will be linked to the same compiled output file. If not provided, the {@link Options.name | name} option will be used.\n *\n * @see https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bin\n * @see https://yarnpkg.com/cli/bin\n * @see https://pnpm.io/package_json#bin\n */\n bin?: string | string[];\n\n /**\n * Should Shell Shock attempt to automatically assign environment variables to manipulate default values for command options based on the option name?\n *\n * @remarks\n * If set to a string, Shell Shock will use the provided string as an application specific environment variable prefix, convert the option name to {@link https://stringcase.org/cases/constant/ | constant case}, and prepend the provided `string` value to determine the corresponding environment variable name. For example, if an option is named `\"configPath\"` and the `autoAssignEnv` is `\"MY_APP_\"`, Shell Shock will look for an environment variable named `\"MY_APP_CONFIG_PATH\"` and assign its value to the option if it exists. If set to `true`, Shell Shock will use a default environment variable prefix derived from the {@link Options.name | application name}.\n *\n * @see https://medium.com/chingu/an-introduction-to-environment-variables-and-how-to-use-them-f602f66d15fa\n * @see https://stringcase.org/cases/constant/\n */\n autoAssignEnv?: true | string;\n};\n\n/**\n * The plugin options for Shell Shock.\n */\nexport type Options = BaseOptions & Partial<NodeJsPluginOptions>;\n\n/**\n * The output configuration options for Shell Shock.\n */\nexport type OutputConfig = Pick<\n PowerlinesOutputConfig,\n \"outputPath\" | \"assets\" | \"storage\"\n> & {\n /**\n * An indicator specifying whether to generate TypeScript declaration files (.d.ts) during the build process.\n */\n dts?: false;\n};\n\n/**\n * The user configuration options for Shell Shock.\n */\nexport type UserConfig = BaseOptions &\n Partial<NodeJsPluginUserConfig> & {\n /**\n * Configuration for the output of the build process\n */\n output?: OutputConfig;\n };\n\n/**\n * The resolved configuration options for Shell Shock.\n */\nexport type ResolvedConfig = TsdownPluginResolvedConfig &\n AutoMDPluginResolvedConfig &\n NodeJsPluginResolvedConfig &\n Required<Omit<Options, \"bin\">> & {\n /**\n * The name of the binary (the {@link https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bin | \"bin\" field} in package.json) that will be used to run the application through NodeJs package managers (e.g., npm, yarn, pnpm).\n *\n * @remarks\n * If an array is provided, each binary will be linked to the same compiled output file. If not provided, the {@link Options.name | name} option will be used.\n *\n * @see https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bin\n * @see https://yarnpkg.com/cli/bin\n * @see https://pnpm.io/package_json#bin\n */\n bin: Record<string, string>;\n\n /**\n * The command-line application specific environment variable prefix used for automatically assigning environment variables to command options.\n */\n appSpecificEnvPrefix: string;\n\n /**\n * The user configuration for the Shell Shock process.\n */\n userConfig: UserConfig;\n };\n"],"mappings":";;AAAA,MAAM,UAAU;CAAC;CAAK;CAAK;CAAQ;CAA4B;;;;;;AAE/D,MAAM,cAAc;CAAC;CAAK;CAAY;CAAS;;;;;;;;;AAE/C,MAAM,YAAY;CAAC;CAAK;CAAK;CAAU;CAAyB;AAChE,MAAM,aAAa;CAAC;CAAK;CAAK;CAAW;CAA2B;AACpE,MAAM,kBAAkB;OAAO;CAAS;CAAQ;CAAQ;CAAS;CAAM;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AACvE,MAAM,iBAAiB;OAAO;OAAkB;CAAiB;CAAa;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAG9E,MAAM,kBAAkB;OAAO;CAAS;CAAc;CAAU;CAAO;CAAA;CAAA;CAAA;CAAA;AAEvE,MAAM,gBAAgB;OAAO;OAAsB;OAAQ;CAAA;CAAA;CAAA;CAAA;AAE3D,MAAM,oBAAoB;OAAO;OAAG;OAAA;CAAA;OAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA"}
|
package/dist/types/config.d.cts
CHANGED
|
@@ -33,15 +33,15 @@ type BaseOptions = Partial<BuildOptions> & {
|
|
|
33
33
|
*/
|
|
34
34
|
bin?: string | string[];
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Should Shell Shock attempt to automatically assign environment variables to manipulate default values for command options based on the option name?
|
|
37
37
|
*
|
|
38
38
|
* @remarks
|
|
39
|
-
* If
|
|
39
|
+
* If set to a string, Shell Shock will use the provided string as an application specific environment variable prefix, convert the option name to {@link https://stringcase.org/cases/constant/ | constant case}, and prepend the provided `string` value to determine the corresponding environment variable name. For example, if an option is named `"configPath"` and the `autoAssignEnv` is `"MY_APP_"`, Shell Shock will look for an environment variable named `"MY_APP_CONFIG_PATH"` and assign its value to the option if it exists. If set to `true`, Shell Shock will use a default environment variable prefix derived from the {@link Options.name | application name}.
|
|
40
40
|
*
|
|
41
41
|
* @see https://medium.com/chingu/an-introduction-to-environment-variables-and-how-to-use-them-f602f66d15fa
|
|
42
42
|
* @see https://stringcase.org/cases/constant/
|
|
43
43
|
*/
|
|
44
|
-
|
|
44
|
+
autoAssignEnv?: true | string;
|
|
45
45
|
};
|
|
46
46
|
/**
|
|
47
47
|
* The plugin options for Shell Shock.
|
|
@@ -80,6 +80,10 @@ type ResolvedConfig = TsdownPluginResolvedConfig & AutoMDPluginResolvedConfig &
|
|
|
80
80
|
* @see https://pnpm.io/package_json#bin
|
|
81
81
|
*/
|
|
82
82
|
bin: Record<string, string>;
|
|
83
|
+
/**
|
|
84
|
+
* The command-line application specific environment variable prefix used for automatically assigning environment variables to command options.
|
|
85
|
+
*/
|
|
86
|
+
appSpecificEnvPrefix: string;
|
|
83
87
|
/**
|
|
84
88
|
* The user configuration for the Shell Shock process.
|
|
85
89
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.cts","names":[],"sources":["../../src/types/config.ts"],"sourcesContent":[],"mappings":";;;;;;;;KAgCK,YAAA,GAAe,KAClB;KAcG,WAAA,GAAc,QAAQ;EAftB;AAAmB;;;;;EAwBS,cAAA,CAAA,EAD3B,aAC2B,EAAA,GAAA,CAAA,CAAA,OAAA,EAAhB,OAAgB,EAAA,KAAA,EAAA,WAAA,EAAA,GAAgB,aAAhB,EAAA,CAAA,GAAA,KAAA;EAAgB;;AAqCjD;;;EAAoC,eAAA,CAAA,EAAA,OAAA;EAAO;AAK3C;AAaA;;;;;;AAWA;;EACE,GAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA;EACA;;;;;;;;;;;;;;KA/BU,OAAA,GAAU,cAAc,QAAQ;;;;KAKhC,YAAA,GAAe,KACzB;;;;;;;;;KAYU,UAAA,GAAa,cACvB,QAAQ;;;;WAIG;;;;;KAMD,cAAA,GAAiB,6BAC3B,6BACA,6BACA,SAAS,KAAK;;;;;;;;;;;OAWP
|
|
1
|
+
{"version":3,"file":"config.d.cts","names":[],"sources":["../../src/types/config.ts"],"sourcesContent":[],"mappings":";;;;;;;;KAgCK,YAAA,GAAe,KAClB;KAcG,WAAA,GAAc,QAAQ;EAftB;AAAmB;;;;;EAwBS,cAAA,CAAA,EAD3B,aAC2B,EAAA,GAAA,CAAA,CAAA,OAAA,EAAhB,OAAgB,EAAA,KAAA,EAAA,WAAA,EAAA,GAAgB,aAAhB,EAAA,CAAA,GAAA,KAAA;EAAgB;;AAqCjD;;;EAAoC,eAAA,CAAA,EAAA,OAAA;EAAO;AAK3C;AAaA;;;;;;AAWA;;EACE,GAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA;EACA;;;;;;;;;;;;;;KA/BU,OAAA,GAAU,cAAc,QAAQ;;;;KAKhC,YAAA,GAAe,KACzB;;;;;;;;;KAYU,UAAA,GAAa,cACvB,QAAQ;;;;WAIG;;;;;KAMD,cAAA,GAAiB,6BAC3B,6BACA,6BACA,SAAS,KAAK;;;;;;;;;;;OAWP;;;;;;;;cAUO"}
|
package/dist/types/config.d.mts
CHANGED
|
@@ -33,15 +33,15 @@ type BaseOptions = Partial<BuildOptions> & {
|
|
|
33
33
|
*/
|
|
34
34
|
bin?: string | string[];
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* Should Shell Shock attempt to automatically assign environment variables to manipulate default values for command options based on the option name?
|
|
37
37
|
*
|
|
38
38
|
* @remarks
|
|
39
|
-
* If
|
|
39
|
+
* If set to a string, Shell Shock will use the provided string as an application specific environment variable prefix, convert the option name to {@link https://stringcase.org/cases/constant/ | constant case}, and prepend the provided `string` value to determine the corresponding environment variable name. For example, if an option is named `"configPath"` and the `autoAssignEnv` is `"MY_APP_"`, Shell Shock will look for an environment variable named `"MY_APP_CONFIG_PATH"` and assign its value to the option if it exists. If set to `true`, Shell Shock will use a default environment variable prefix derived from the {@link Options.name | application name}.
|
|
40
40
|
*
|
|
41
41
|
* @see https://medium.com/chingu/an-introduction-to-environment-variables-and-how-to-use-them-f602f66d15fa
|
|
42
42
|
* @see https://stringcase.org/cases/constant/
|
|
43
43
|
*/
|
|
44
|
-
|
|
44
|
+
autoAssignEnv?: true | string;
|
|
45
45
|
};
|
|
46
46
|
/**
|
|
47
47
|
* The plugin options for Shell Shock.
|
|
@@ -80,6 +80,10 @@ type ResolvedConfig = TsdownPluginResolvedConfig & AutoMDPluginResolvedConfig &
|
|
|
80
80
|
* @see https://pnpm.io/package_json#bin
|
|
81
81
|
*/
|
|
82
82
|
bin: Record<string, string>;
|
|
83
|
+
/**
|
|
84
|
+
* The command-line application specific environment variable prefix used for automatically assigning environment variables to command options.
|
|
85
|
+
*/
|
|
86
|
+
appSpecificEnvPrefix: string;
|
|
83
87
|
/**
|
|
84
88
|
* The user configuration for the Shell Shock process.
|
|
85
89
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.mts","names":[],"sources":["../../src/types/config.ts"],"sourcesContent":[],"mappings":";;;;;;;;KAgCK,YAAA,GAAe,KAClB;KAcG,WAAA,GAAc,QAAQ;EAftB;AAAmB;;;;;EAwBS,cAAA,CAAA,EAD3B,aAC2B,EAAA,GAAA,CAAA,CAAA,OAAA,EAAhB,OAAgB,EAAA,KAAA,EAAA,WAAA,EAAA,GAAgB,aAAhB,EAAA,CAAA,GAAA,KAAA;EAAgB;;AAqCjD;;;EAAoC,eAAA,CAAA,EAAA,OAAA;EAAO;AAK3C;AAaA;;;;;;AAWA;;EACE,GAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA;EACA;;;;;;;;;;;;;;KA/BU,OAAA,GAAU,cAAc,QAAQ;;;;KAKhC,YAAA,GAAe,KACzB;;;;;;;;;KAYU,UAAA,GAAa,cACvB,QAAQ;;;;WAIG;;;;;KAMD,cAAA,GAAiB,6BAC3B,6BACA,6BACA,SAAS,KAAK;;;;;;;;;;;OAWP
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../../src/types/config.ts"],"sourcesContent":[],"mappings":";;;;;;;;KAgCK,YAAA,GAAe,KAClB;KAcG,WAAA,GAAc,QAAQ;EAftB;AAAmB;;;;;EAwBS,cAAA,CAAA,EAD3B,aAC2B,EAAA,GAAA,CAAA,CAAA,OAAA,EAAhB,OAAgB,EAAA,KAAA,EAAA,WAAA,EAAA,GAAgB,aAAhB,EAAA,CAAA,GAAA,KAAA;EAAgB;;AAqCjD;;;EAAoC,eAAA,CAAA,EAAA,OAAA;EAAO;AAK3C;AAaA;;;;;;AAWA;;EACE,GAAA,CAAA,EAAA,MAAA,GAAA,MAAA,EAAA;EACA;;;;;;;;;;;;;;KA/BU,OAAA,GAAU,cAAc,QAAQ;;;;KAKhC,YAAA,GAAe,KACzB;;;;;;;;;KAYU,UAAA,GAAa,cACvB,QAAQ;;;;WAIG;;;;;KAMD,cAAA,GAAiB,6BAC3B,6BACA,6BACA,SAAS,KAAK;;;;;;;;;;;OAWP;;;;;;;;cAUO"}
|
package/dist/types/config.mjs
CHANGED
|
@@ -65,9 +65,10 @@ const __ΩBaseOptions = [
|
|
|
65
65
|
"isCaseSensitive",
|
|
66
66
|
true,
|
|
67
67
|
"bin",
|
|
68
|
-
|
|
68
|
+
true,
|
|
69
|
+
"autoAssignEnv",
|
|
69
70
|
"BaseOptions",
|
|
70
|
-
"Pn\"o!\"PP\"w#FP\"w$2%\"w&2'\"w#F/(.)J4*8)4+8>,P&&FJ4-
|
|
71
|
+
"Pn\"o!\"PP\"w#FP\"w$2%\"w&2'\"w#F/(.)J4*8)4+8>,P&&FJ4-8P..&J4/8MKw0y"
|
|
71
72
|
];
|
|
72
73
|
const __ΩOptions = [
|
|
73
74
|
() => __ΩBaseOptions,
|
|
@@ -100,10 +101,11 @@ const __ΩResolvedConfig = [
|
|
|
100
101
|
"bin",
|
|
101
102
|
() => __ΩRecord,
|
|
102
103
|
"bin",
|
|
104
|
+
"appSpecificEnvPrefix",
|
|
103
105
|
() => __ΩUserConfig,
|
|
104
106
|
"userConfig",
|
|
105
107
|
"ResolvedConfig",
|
|
106
|
-
"P!!!n#.$o\"#o!\"P&&o%#4
|
|
108
|
+
"P!!!n#.$o\"#o!\"P&&o%#4&&4'n(4)MKw*y"
|
|
107
109
|
];
|
|
108
110
|
|
|
109
111
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":[],"sources":["../../src/types/config.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 { AutoMDPluginResolvedConfig } from \"@powerlines/plugin-automd/types/plugin\";\nimport type {\n NodeJsPluginOptions,\n NodeJsPluginResolvedConfig,\n NodeJsPluginUserConfig\n} from \"@powerlines/plugin-nodejs/types/plugin\";\nimport type {\n TsdownPluginResolvedConfig,\n TsdownPluginUserConfig\n} from \"@powerlines/plugin-tsdown/types/plugin\";\nimport type { OutputConfig as PowerlinesOutputConfig } from \"powerlines\";\nimport type { CommandBase, CommandOption } from \"./command\";\nimport type { Context } from \"./context\";\n\ntype BuildOptions = Pick<\n TsdownPluginUserConfig,\n | \"root\"\n | \"name\"\n | \"title\"\n | \"description\"\n | \"logLevel\"\n | \"mode\"\n | \"skipCache\"\n | \"autoInstall\"\n | \"plugins\"\n | \"tsconfig\"\n | \"tsconfigRaw\"\n>;\n\ntype BaseOptions = Partial<BuildOptions> & {\n /**\n * A set of default command options to apply to each command.\n *\n * @remarks\n * To disable the addition of these default options, set this property to `false`, or provide a custom set of options/a function that returns them.\n */\n defaultOptions?:\n | CommandOption[]\n | ((context: Context, input: CommandBase) => CommandOption[])\n | false;\n\n /**\n * Determines whether commands and option names are treated as case-sensitive.\n *\n * @defaultValue `false`\n */\n isCaseSensitive?: boolean;\n\n /**\n * The name of the binary (the {@link https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bin | \"bin\" field} in package.json) that will be used to run the application through NodeJs package managers (e.g., npm, yarn, pnpm).\n *\n * @remarks\n * If an array is provided, each binary will be linked to the same compiled output file. If not provided, the {@link Options.name | name} option will be used.\n *\n * @see https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bin\n * @see https://yarnpkg.com/cli/bin\n * @see https://pnpm.io/package_json#bin\n */\n bin?: string | string[];\n\n /**\n *
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../../src/types/config.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 { AutoMDPluginResolvedConfig } from \"@powerlines/plugin-automd/types/plugin\";\nimport type {\n NodeJsPluginOptions,\n NodeJsPluginResolvedConfig,\n NodeJsPluginUserConfig\n} from \"@powerlines/plugin-nodejs/types/plugin\";\nimport type {\n TsdownPluginResolvedConfig,\n TsdownPluginUserConfig\n} from \"@powerlines/plugin-tsdown/types/plugin\";\nimport type { OutputConfig as PowerlinesOutputConfig } from \"powerlines\";\nimport type { CommandBase, CommandOption } from \"./command\";\nimport type { Context } from \"./context\";\n\ntype BuildOptions = Pick<\n TsdownPluginUserConfig,\n | \"root\"\n | \"name\"\n | \"title\"\n | \"description\"\n | \"logLevel\"\n | \"mode\"\n | \"skipCache\"\n | \"autoInstall\"\n | \"plugins\"\n | \"tsconfig\"\n | \"tsconfigRaw\"\n>;\n\ntype BaseOptions = Partial<BuildOptions> & {\n /**\n * A set of default command options to apply to each command.\n *\n * @remarks\n * To disable the addition of these default options, set this property to `false`, or provide a custom set of options/a function that returns them.\n */\n defaultOptions?:\n | CommandOption[]\n | ((context: Context, input: CommandBase) => CommandOption[])\n | false;\n\n /**\n * Determines whether commands and option names are treated as case-sensitive.\n *\n * @defaultValue `false`\n */\n isCaseSensitive?: boolean;\n\n /**\n * The name of the binary (the {@link https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bin | \"bin\" field} in package.json) that will be used to run the application through NodeJs package managers (e.g., npm, yarn, pnpm).\n *\n * @remarks\n * If an array is provided, each binary will be linked to the same compiled output file. If not provided, the {@link Options.name | name} option will be used.\n *\n * @see https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bin\n * @see https://yarnpkg.com/cli/bin\n * @see https://pnpm.io/package_json#bin\n */\n bin?: string | string[];\n\n /**\n * Should Shell Shock attempt to automatically assign environment variables to manipulate default values for command options based on the option name?\n *\n * @remarks\n * If set to a string, Shell Shock will use the provided string as an application specific environment variable prefix, convert the option name to {@link https://stringcase.org/cases/constant/ | constant case}, and prepend the provided `string` value to determine the corresponding environment variable name. For example, if an option is named `\"configPath\"` and the `autoAssignEnv` is `\"MY_APP_\"`, Shell Shock will look for an environment variable named `\"MY_APP_CONFIG_PATH\"` and assign its value to the option if it exists. If set to `true`, Shell Shock will use a default environment variable prefix derived from the {@link Options.name | application name}.\n *\n * @see https://medium.com/chingu/an-introduction-to-environment-variables-and-how-to-use-them-f602f66d15fa\n * @see https://stringcase.org/cases/constant/\n */\n autoAssignEnv?: true | string;\n};\n\n/**\n * The plugin options for Shell Shock.\n */\nexport type Options = BaseOptions & Partial<NodeJsPluginOptions>;\n\n/**\n * The output configuration options for Shell Shock.\n */\nexport type OutputConfig = Pick<\n PowerlinesOutputConfig,\n \"outputPath\" | \"assets\" | \"storage\"\n> & {\n /**\n * An indicator specifying whether to generate TypeScript declaration files (.d.ts) during the build process.\n */\n dts?: false;\n};\n\n/**\n * The user configuration options for Shell Shock.\n */\nexport type UserConfig = BaseOptions &\n Partial<NodeJsPluginUserConfig> & {\n /**\n * Configuration for the output of the build process\n */\n output?: OutputConfig;\n };\n\n/**\n * The resolved configuration options for Shell Shock.\n */\nexport type ResolvedConfig = TsdownPluginResolvedConfig &\n AutoMDPluginResolvedConfig &\n NodeJsPluginResolvedConfig &\n Required<Omit<Options, \"bin\">> & {\n /**\n * The name of the binary (the {@link https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bin | \"bin\" field} in package.json) that will be used to run the application through NodeJs package managers (e.g., npm, yarn, pnpm).\n *\n * @remarks\n * If an array is provided, each binary will be linked to the same compiled output file. If not provided, the {@link Options.name | name} option will be used.\n *\n * @see https://docs.npmjs.com/cli/v11/configuring-npm/package-json#bin\n * @see https://yarnpkg.com/cli/bin\n * @see https://pnpm.io/package_json#bin\n */\n bin: Record<string, string>;\n\n /**\n * The command-line application specific environment variable prefix used for automatically assigning environment variables to command options.\n */\n appSpecificEnvPrefix: string;\n\n /**\n * The user configuration for the Shell Shock process.\n */\n userConfig: UserConfig;\n };\n"],"mappings":";AAAA,MAAM,UAAU;CAAC;CAAK;CAAK;CAAQ;CAA4B;;;;;;AAE/D,MAAM,cAAc;CAAC;CAAK;CAAY;CAAS;;;;;;;;;AAE/C,MAAM,YAAY;CAAC;CAAK;CAAK;CAAU;CAAyB;AAChE,MAAM,aAAa;CAAC;CAAK;CAAK;CAAW;CAA2B;AACpE,MAAM,kBAAkB;OAAO;CAAS;CAAQ;CAAQ;CAAS;CAAM;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AACvE,MAAM,iBAAiB;OAAO;OAAkB;CAAiB;CAAa;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;AAG9E,MAAM,kBAAkB;OAAO;CAAS;CAAc;CAAU;CAAO;CAAA;CAAA;CAAA;CAAA;AAEvE,MAAM,gBAAgB;OAAO;OAAsB;OAAQ;CAAA;CAAA;CAAA;CAAA;AAE3D,MAAM,oBAAoB;OAAO;OAAG;OAAA;CAAA;OAAA;CAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shell-shock/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing the core Shell Shock functionality used to build and manage a command-line application.",
|
|
6
6
|
"repository": {
|
|
@@ -370,5 +370,5 @@
|
|
|
370
370
|
"zod": "^4.3.6"
|
|
371
371
|
},
|
|
372
372
|
"publishConfig": { "access": "public" },
|
|
373
|
-
"gitHead": "
|
|
373
|
+
"gitHead": "c38d304433a296936fb8ca58aa138a0039918931"
|
|
374
374
|
}
|