@powerlines/nx 0.13.165 → 0.13.166
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/src/base/base-executor.js +16 -13
- package/dist/src/base/base-executor.mjs +17 -14
- package/dist/src/base/base-executor.mjs.map +1 -1
- package/dist/src/{base-executor-nribES6I.mjs → base-executor-BZOeOotB.mjs} +18 -15
- package/dist/src/base-executor-BZOeOotB.mjs.map +1 -0
- package/dist/src/{base-executor-BzcSvyaJ.js → base-executor-CghUpkYU.js} +16 -13
- package/dist/src/executors/build/executor.js +1 -1
- package/dist/src/executors/build/executor.mjs +1 -1
- package/dist/src/executors/clean/executor.js +1 -1
- package/dist/src/executors/clean/executor.mjs +1 -1
- package/dist/src/executors/docs/executor.js +1 -1
- package/dist/src/executors/docs/executor.mjs +1 -1
- package/dist/src/executors/lint/executor.js +1 -1
- package/dist/src/executors/lint/executor.mjs +1 -1
- package/dist/src/executors/prepare/executor.js +1 -1
- package/dist/src/executors/prepare/executor.mjs +1 -1
- package/package.json +3 -3
- package/dist/src/base-executor-nribES6I.mjs.map +0 -1
|
@@ -47,7 +47,6 @@ function withExecutor(command, executorFn, options = {}) {
|
|
|
47
47
|
workspaceConfig,
|
|
48
48
|
command,
|
|
49
49
|
inlineConfig: (0, defu.default)({
|
|
50
|
-
name: context.projectName,
|
|
51
50
|
command,
|
|
52
51
|
root: projectConfig.root,
|
|
53
52
|
configFile: options.configFile || options.config,
|
|
@@ -85,18 +84,22 @@ function withExecutor(command, executorFn, options = {}) {
|
|
|
85
84
|
"define",
|
|
86
85
|
"assets"
|
|
87
86
|
]))
|
|
88
|
-
}, context), async (inlineConfig) =>
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
87
|
+
}, context), async (inlineConfig) => {
|
|
88
|
+
const name = inlineConfig.name || context.projectName || await (0, powerlines_plugin_utils.getName)(context.root, projectConfig.root);
|
|
89
|
+
return api({
|
|
90
|
+
options: (0, defu.default)(defaultOptions, {
|
|
91
|
+
name,
|
|
92
|
+
executionId: (0, powerlines_plugin_utils.formatExecutionId)(name, command, options.configIndex ?? 0),
|
|
93
|
+
cwd: context.root,
|
|
94
|
+
root: projectConfig.root,
|
|
95
|
+
configFile: options.configFile || options.config || (0, _stryke_path_join.joinPaths)(projectConfig.root, `${(0, _stryke_string_format_kebab_case.kebabCase)(framework.name)}.config.ts`),
|
|
96
|
+
configIndex: options.configIndex,
|
|
97
|
+
framework
|
|
98
|
+
}),
|
|
99
|
+
command,
|
|
100
|
+
inlineConfig
|
|
101
|
+
});
|
|
102
|
+
}));
|
|
100
103
|
} catch (error) {
|
|
101
104
|
(0, _storm_software_config_tools_logger.writeError)(`An error occurred while executing the ${(0, _stryke_string_format_title_case.titleCase)(framework.name)} - ${(0, _stryke_string_format_title_case.titleCase)(command)} executor: ${(0, _stryke_type_checks_is_error.isError)(error) ? `${error.message}
|
|
102
105
|
|
|
@@ -10,7 +10,7 @@ import { isSetArray } from "@stryke/type-checks/is-set-array";
|
|
|
10
10
|
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
11
11
|
import defu from "defu";
|
|
12
12
|
import { createJiti } from "jiti";
|
|
13
|
-
import { formatExecutionId } from "powerlines/plugin-utils";
|
|
13
|
+
import { formatExecutionId, getName } from "powerlines/plugin-utils";
|
|
14
14
|
|
|
15
15
|
//#region src/base/base-executor.ts
|
|
16
16
|
/**
|
|
@@ -44,7 +44,6 @@ function withExecutor(command, executorFn, options = {}) {
|
|
|
44
44
|
workspaceConfig,
|
|
45
45
|
command,
|
|
46
46
|
inlineConfig: defu({
|
|
47
|
-
name: context.projectName,
|
|
48
47
|
command,
|
|
49
48
|
root: projectConfig.root,
|
|
50
49
|
configFile: options.configFile || options.config,
|
|
@@ -82,18 +81,22 @@ function withExecutor(command, executorFn, options = {}) {
|
|
|
82
81
|
"define",
|
|
83
82
|
"assets"
|
|
84
83
|
]))
|
|
85
|
-
}, context), async (inlineConfig) =>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
84
|
+
}, context), async (inlineConfig) => {
|
|
85
|
+
const name = inlineConfig.name || context.projectName || await getName(context.root, projectConfig.root);
|
|
86
|
+
return api({
|
|
87
|
+
options: defu(defaultOptions, {
|
|
88
|
+
name,
|
|
89
|
+
executionId: formatExecutionId(name, command, options.configIndex ?? 0),
|
|
90
|
+
cwd: context.root,
|
|
91
|
+
root: projectConfig.root,
|
|
92
|
+
configFile: options.configFile || options.config || joinPaths(projectConfig.root, `${kebabCase(framework.name)}.config.ts`),
|
|
93
|
+
configIndex: options.configIndex,
|
|
94
|
+
framework
|
|
95
|
+
}),
|
|
96
|
+
command,
|
|
97
|
+
inlineConfig
|
|
98
|
+
});
|
|
99
|
+
}));
|
|
97
100
|
} catch (error) {
|
|
98
101
|
writeError(`An error occurred while executing the ${titleCase(framework.name)} - ${titleCase(command)} executor: ${isError(error) ? `${error.message}
|
|
99
102
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-executor.mjs","names":[],"sources":["../../../src/base/base-executor.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\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/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ExecutorContext, PromiseExecutor } from \"@nx/devkit\";\nimport { writeError } from \"@storm-software/config-tools/logger\";\nimport type { StormWorkspaceConfig } from \"@storm-software/config/types\";\nimport { withRunExecutor } from \"@storm-software/workspace-tools/base/base-executor\";\nimport type { BaseExecutorResult } from \"@storm-software/workspace-tools/types\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isError } from \"@stryke/type-checks/is-error\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetArray } from \"@stryke/type-checks/is-set-array\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { DeepPartial } from \"@stryke/types/base\";\nimport defu from \"defu\";\nimport { createJiti } from \"jiti\";\nimport type {\n ExecutionApiParams,\n ExecutionOptions,\n FrameworkOptions,\n InlineConfig,\n Mode,\n OutputConfig\n} from \"powerlines\";\nimport { formatExecutionId } from \"powerlines/plugin-utils\";\nimport type { BaseExecutorSchema } from \"./base-executor.schema\";\n\nexport type PowerlinesExecutorContext<\n TExecutorSchema extends BaseExecutorSchema = BaseExecutorSchema\n> = ExecutorContext & {\n projectName: string;\n command: string;\n options: TExecutorSchema;\n inlineConfig: InlineConfig;\n workspaceConfig: StormWorkspaceConfig;\n};\n\nexport type PowerlinesExecutorApi = (\n inlineConfig: InlineConfig\n) => Promise<void>;\n\nexport interface WithExecutorOptions {\n /**\n * The import path for the executor API module, which is used to dynamically import the API function that will be called during execution. This value should be a string representing the module path, and it defaults to \"powerlines/api\" if not provided. The specified module should export a default function that matches the expected signature for the executor API, which will be invoked with the execution parameters when the executor is run.\n *\n * @defaultValue \"powerlines/api\"\n */\n importPath?: string;\n\n /**\n * Default options to be merged with the execution options, which can be used to provide default values for certain execution parameters or to override specific options for all executions of the executor. This value should be an object that matches the shape of the `ExecutionOptions` type, and it will be merged with the options provided during execution to create the final set of options that will be passed to the executor API function.\n *\n * @remarks\n * This can be useful for setting default values for options that are commonly used across multiple executions, or for providing a consistent set of options for all executions of the executor without requiring the caller to specify them each time.\n */\n defaultOptions?: DeepPartial<ExecutionOptions>;\n\n /**\n * Details about the framework being used in the current execution, which can be used by plugins and other parts of the system to customize behavior based on the framework.\n *\n * @remarks\n * This should only be used by framework plugins to ensure the correct framework name is applied\n *\n * @defaultValue\n * ```ts\n * {\n * name: \"powerlines\",\n * orgId: \"storm-software\"\n * }\n * ```\n */\n framework?: FrameworkOptions;\n}\n\n/**\n * A utility function to create a Powerlines executor that can be used with the `withRunExecutor` function.\n *\n * @remarks\n * This function is designed to simplify the creation of Powerlines executors by providing a consistent interface and error handling.\n *\n * @param command - The command that the executor will handle (e.g., \"new\", \"prepare\", \"build\", etc.).\n * @param executorFn - The function that will be executed when the command is run.\n * @param options - Additional options for configuring the executor, such as the import path for the API module and default execution options.\n * @returns A Promise that resolves to the result of the executor function.\n */\nexport function withExecutor<\n TExecutorSchema extends BaseExecutorSchema = BaseExecutorSchema\n>(\n command: string,\n executorFn: (\n context: PowerlinesExecutorContext<TExecutorSchema>,\n api: PowerlinesExecutorApi\n ) =>\n | Promise<BaseExecutorResult | null | undefined>\n | BaseExecutorResult\n | null\n | undefined,\n options: WithExecutorOptions = {}\n): PromiseExecutor<TExecutorSchema> {\n const {\n importPath = \"powerlines/api\",\n defaultOptions = {},\n framework = {} as FrameworkOptions\n } = options;\n\n framework.name ??= \"powerlines\";\n framework.orgId ??= \"storm-software\";\n\n return withRunExecutor(\n `${titleCase(framework.name)} - ${titleCase(command)} executor`,\n async (\n options: TExecutorSchema,\n context: ExecutorContext,\n workspaceConfig: StormWorkspaceConfig\n ): Promise<BaseExecutorResult | null | undefined> => {\n if (!context.projectName) {\n throw new Error(\n `The ${titleCase(framework.name)} - ${titleCase(\n command\n )} executor requires \\`projectName\\` on the context object.`\n );\n }\n\n if (\n !context.projectName ||\n !context.projectsConfigurations?.projects ||\n !context.projectsConfigurations.projects[context.projectName] ||\n !context.projectsConfigurations.projects[context.projectName]?.root\n ) {\n throw new Error(\n `The ${titleCase(framework.name)} - ${titleCase(\n command\n )} executor requires \\`projectsConfigurations\\` on the context object.`\n );\n }\n\n const projectConfig =\n context.projectsConfigurations.projects[context.projectName]!;\n\n const jiti = createJiti(context.root, {\n cache: false,\n tsconfigPaths: true\n });\n const api = await jiti\n .import<{\n default: (params: ExecutionApiParams) => Promise<void>;\n }>(jiti.esmResolve(importPath))\n .then(mod => mod.default);\n\n try {\n return await Promise.resolve(\n executorFn(\n defu(\n {\n projectName: context.projectName,\n options,\n workspaceConfig,\n command,\n inlineConfig: defu(\n {\n name: context.projectName,\n command,\n root: projectConfig.root,\n configFile: options.configFile || options.config,\n configIndex: options.configIndex,\n projectType: projectConfig.projectType,\n mode: options.mode as Mode,\n output: {\n path: options.outputPath,\n copy:\n options.copyPath === false\n ? false\n : {\n path: options.copyPath,\n assets: options.assets\n },\n minify: options.minify,\n sourceMap: options.sourceMap\n } as OutputConfig,\n resolve:\n isSetArray(options.external) ||\n isSetArray(options.noExternal) ||\n isSet(options.skipNodeModulesBundle)\n ? {\n external: isSetArray(options.external)\n ? options.external\n : undefined,\n noExternal: isSetArray(options.noExternal)\n ? options.noExternal\n : undefined,\n skipNodeModulesBundle: isSet(\n options.skipNodeModulesBundle\n )\n ? options.skipNodeModulesBundle\n : undefined\n }\n : undefined,\n define: isSetObject(options.define)\n ? options.define\n : undefined,\n assets: isSetObject(options.assets)\n ? options.assets\n : undefined\n },\n omit(options, [\n \"config\",\n \"configFile\",\n \"outputPath\",\n \"copyPath\",\n \"sourceMap\",\n \"minify\",\n \"format\",\n \"external\",\n \"noExternal\",\n \"skipNodeModulesBundle\",\n \"mode\",\n \"define\",\n \"assets\"\n ])\n ) as InlineConfig\n },\n context\n ),\n async (inlineConfig: InlineConfig) =>\n api({\n options: defu(defaultOptions, {\n executionId: formatExecutionId(\n inlineConfig.name ||\n context.projectName ||\n projectConfig.root,\n command,\n options.configIndex ?? 0\n ),\n cwd: context.root,\n root: projectConfig.root,\n configFile:\n options.configFile ||\n options.config ||\n joinPaths(\n projectConfig.root,\n `${kebabCase(framework.name)}.config.ts`\n ),\n configIndex: options.configIndex,\n framework\n }) as ExecutionOptions,\n command,\n inlineConfig\n })\n )\n );\n } catch (error) {\n writeError(\n `An error occurred while executing the ${titleCase(\n framework.name\n )} - ${titleCase(command)} executor: ${\n isError(error)\n ? `${error.message}\n\n${error.stack}`\n : \"Unknown error\"\n }`\n );\n\n return { success: false };\n }\n },\n {\n skipReadingConfig: false,\n hooks: {\n applyDefaultOptions: (options: Partial<TExecutorSchema>) => {\n options.copyPath ??= \"dist/{projectRoot}\";\n\n return options as TExecutorSchema;\n }\n }\n }\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuGA,SAAgB,aAGd,SACA,YAQA,UAA+B,CAAC,GACE;CAClC,MAAM,EACJ,aAAa,kBACb,iBAAiB,CAAC,GAClB,YAAY,CAAC,MACX;CAEJ,UAAU,SAAS;CACnB,UAAU,UAAU;CAEpB,OAAO,gBACL,GAAG,UAAU,UAAU,IAAI,EAAE,KAAK,UAAU,OAAO,EAAE,YACrD,OACE,SACA,SACA,oBACmD;EACnD,IAAI,CAAC,QAAQ,aACX,MAAM,IAAI,MACR,OAAO,UAAU,UAAU,IAAI,EAAE,KAAK,UACpC,OACF,EAAE,0DACJ;EAGF,IACE,CAAC,QAAQ,eACT,CAAC,QAAQ,wBAAwB,YACjC,CAAC,QAAQ,uBAAuB,SAAS,QAAQ,gBACjD,CAAC,QAAQ,uBAAuB,SAAS,QAAQ,YAAY,EAAE,MAE/D,MAAM,IAAI,MACR,OAAO,UAAU,UAAU,IAAI,EAAE,KAAK,UACpC,OACF,EAAE,qEACJ;EAGF,MAAM,gBACJ,QAAQ,uBAAuB,SAAS,QAAQ;EAElD,MAAM,OAAO,WAAW,QAAQ,MAAM;GACpC,OAAO;GACP,eAAe;EACjB,CAAC;EACD,MAAM,MAAM,MAAM,KACf,OAEE,KAAK,WAAW,UAAU,CAAC,CAA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CAAyC,UACvC,UAAU,IACZ,EAAE,KAAK,UAAU,OAAO,EAAE,aACxB,QAAQ,KAAK,IACT,GAAG,MAAM,QAAQ;;EAE/B,MAAM,UACQ,iBAER;GAEA,OAAO,EAAE,SAAS,MAAM;EAC1B;CACF,GACA;EACE,mBAAmB;EACnB,OAAO,EACL,sBAAsB,YAAsC;GAC1D,QAAQ,aAAa;GAErB,OAAO;EACT,EACF;CACF,CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"base-executor.mjs","names":[],"sources":["../../../src/base/base-executor.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\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/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ExecutorContext, PromiseExecutor } from \"@nx/devkit\";\nimport { writeError } from \"@storm-software/config-tools/logger\";\nimport type { StormWorkspaceConfig } from \"@storm-software/config/types\";\nimport { withRunExecutor } from \"@storm-software/workspace-tools/base/base-executor\";\nimport type { BaseExecutorResult } from \"@storm-software/workspace-tools/types\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isError } from \"@stryke/type-checks/is-error\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetArray } from \"@stryke/type-checks/is-set-array\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { DeepPartial } from \"@stryke/types/base\";\nimport defu from \"defu\";\nimport { createJiti } from \"jiti\";\nimport type {\n ExecutionApiParams,\n ExecutionOptions,\n FrameworkOptions,\n InlineConfig,\n Mode,\n OutputConfig\n} from \"powerlines\";\nimport { formatExecutionId, getName } from \"powerlines/plugin-utils\";\nimport type { BaseExecutorSchema } from \"./base-executor.schema\";\n\nexport type PowerlinesExecutorContext<\n TExecutorSchema extends BaseExecutorSchema = BaseExecutorSchema\n> = ExecutorContext & {\n projectName: string;\n command: string;\n options: TExecutorSchema;\n inlineConfig: InlineConfig;\n workspaceConfig: StormWorkspaceConfig;\n};\n\nexport type PowerlinesExecutorApi = (\n inlineConfig: InlineConfig\n) => Promise<void>;\n\nexport interface WithExecutorOptions {\n /**\n * The import path for the executor API module, which is used to dynamically import the API function that will be called during execution. This value should be a string representing the module path, and it defaults to \"powerlines/api\" if not provided. The specified module should export a default function that matches the expected signature for the executor API, which will be invoked with the execution parameters when the executor is run.\n *\n * @defaultValue \"powerlines/api\"\n */\n importPath?: string;\n\n /**\n * Default options to be merged with the execution options, which can be used to provide default values for certain execution parameters or to override specific options for all executions of the executor. This value should be an object that matches the shape of the `ExecutionOptions` type, and it will be merged with the options provided during execution to create the final set of options that will be passed to the executor API function.\n *\n * @remarks\n * This can be useful for setting default values for options that are commonly used across multiple executions, or for providing a consistent set of options for all executions of the executor without requiring the caller to specify them each time.\n */\n defaultOptions?: DeepPartial<ExecutionOptions>;\n\n /**\n * Details about the framework being used in the current execution, which can be used by plugins and other parts of the system to customize behavior based on the framework.\n *\n * @remarks\n * This should only be used by framework plugins to ensure the correct framework name is applied\n *\n * @defaultValue\n * ```ts\n * {\n * name: \"powerlines\",\n * orgId: \"storm-software\"\n * }\n * ```\n */\n framework?: FrameworkOptions;\n}\n\n/**\n * A utility function to create a Powerlines executor that can be used with the `withRunExecutor` function.\n *\n * @remarks\n * This function is designed to simplify the creation of Powerlines executors by providing a consistent interface and error handling.\n *\n * @param command - The command that the executor will handle (e.g., \"new\", \"prepare\", \"build\", etc.).\n * @param executorFn - The function that will be executed when the command is run.\n * @param options - Additional options for configuring the executor, such as the import path for the API module and default execution options.\n * @returns A Promise that resolves to the result of the executor function.\n */\nexport function withExecutor<\n TExecutorSchema extends BaseExecutorSchema = BaseExecutorSchema\n>(\n command: string,\n executorFn: (\n context: PowerlinesExecutorContext<TExecutorSchema>,\n api: PowerlinesExecutorApi\n ) =>\n | Promise<BaseExecutorResult | null | undefined>\n | BaseExecutorResult\n | null\n | undefined,\n options: WithExecutorOptions = {}\n): PromiseExecutor<TExecutorSchema> {\n const {\n importPath = \"powerlines/api\",\n defaultOptions = {},\n framework = {} as FrameworkOptions\n } = options;\n\n framework.name ??= \"powerlines\";\n framework.orgId ??= \"storm-software\";\n\n return withRunExecutor(\n `${titleCase(framework.name)} - ${titleCase(command)} executor`,\n async (\n options: TExecutorSchema,\n context: ExecutorContext,\n workspaceConfig: StormWorkspaceConfig\n ): Promise<BaseExecutorResult | null | undefined> => {\n if (!context.projectName) {\n throw new Error(\n `The ${titleCase(framework.name)} - ${titleCase(\n command\n )} executor requires \\`projectName\\` on the context object.`\n );\n }\n\n if (\n !context.projectName ||\n !context.projectsConfigurations?.projects ||\n !context.projectsConfigurations.projects[context.projectName] ||\n !context.projectsConfigurations.projects[context.projectName]?.root\n ) {\n throw new Error(\n `The ${titleCase(framework.name)} - ${titleCase(\n command\n )} executor requires \\`projectsConfigurations\\` on the context object.`\n );\n }\n\n const projectConfig =\n context.projectsConfigurations.projects[context.projectName]!;\n\n const jiti = createJiti(context.root, {\n cache: false,\n tsconfigPaths: true\n });\n const api = await jiti\n .import<{\n default: (params: ExecutionApiParams) => Promise<void>;\n }>(jiti.esmResolve(importPath))\n .then(mod => mod.default);\n\n try {\n return await Promise.resolve(\n executorFn(\n defu(\n {\n projectName: context.projectName,\n options,\n workspaceConfig,\n command,\n inlineConfig: defu(\n {\n command,\n root: projectConfig.root,\n configFile: options.configFile || options.config,\n configIndex: options.configIndex,\n projectType: projectConfig.projectType,\n mode: options.mode as Mode,\n output: {\n path: options.outputPath,\n copy:\n options.copyPath === false\n ? false\n : {\n path: options.copyPath,\n assets: options.assets\n },\n minify: options.minify,\n sourceMap: options.sourceMap\n } as OutputConfig,\n resolve:\n isSetArray(options.external) ||\n isSetArray(options.noExternal) ||\n isSet(options.skipNodeModulesBundle)\n ? {\n external: isSetArray(options.external)\n ? options.external\n : undefined,\n noExternal: isSetArray(options.noExternal)\n ? options.noExternal\n : undefined,\n skipNodeModulesBundle: isSet(\n options.skipNodeModulesBundle\n )\n ? options.skipNodeModulesBundle\n : undefined\n }\n : undefined,\n define: isSetObject(options.define)\n ? options.define\n : undefined,\n assets: isSetObject(options.assets)\n ? options.assets\n : undefined\n },\n omit(options, [\n \"config\",\n \"configFile\",\n \"outputPath\",\n \"copyPath\",\n \"sourceMap\",\n \"minify\",\n \"format\",\n \"external\",\n \"noExternal\",\n \"skipNodeModulesBundle\",\n \"mode\",\n \"define\",\n \"assets\"\n ])\n ) as InlineConfig\n },\n context\n ),\n async (inlineConfig: InlineConfig) => {\n const name =\n inlineConfig.name ||\n context.projectName ||\n (await getName(context.root, projectConfig.root));\n\n return api({\n options: defu(defaultOptions, {\n name,\n executionId: formatExecutionId(\n name,\n command,\n options.configIndex ?? 0\n ),\n cwd: context.root,\n root: projectConfig.root,\n configFile:\n options.configFile ||\n options.config ||\n joinPaths(\n projectConfig.root,\n `${kebabCase(framework.name)}.config.ts`\n ),\n configIndex: options.configIndex,\n framework\n }) as ExecutionOptions,\n command,\n inlineConfig\n });\n }\n )\n );\n } catch (error) {\n writeError(\n `An error occurred while executing the ${titleCase(\n framework.name\n )} - ${titleCase(command)} executor: ${\n isError(error)\n ? `${error.message}\n\n${error.stack}`\n : \"Unknown error\"\n }`\n );\n\n return { success: false };\n }\n },\n {\n skipReadingConfig: false,\n hooks: {\n applyDefaultOptions: (options: Partial<TExecutorSchema>) => {\n options.copyPath ??= \"dist/{projectRoot}\";\n\n return options as TExecutorSchema;\n }\n }\n }\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuGA,SAAgB,aAGd,SACA,YAQ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IAC/B;MACE,UAAU,WAAW,QAAQ,QAAQ,IACjC,QAAQ,WACR;MACJ,YAAY,WAAW,QAAQ,UAAU,IACrC,QAAQ,aACR;MACJ,uBAAuB,MACrB,QAAQ,qBACV,IACI,QAAQ,wBACR;KACN,IACA;KACN,QAAQ,YAAY,QAAQ,MAAM,IAC9B,QAAQ,SACR;KACJ,QAAQ,YAAY,QAAQ,MAAM,IAC9B,QAAQ,SACR;IACN,GACA,KAAK,SAAS;KACZ;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;IACF,CAAC,CACH;GACF,GACA,OACF,GACA,OAAO,iBAA+B;IACpC,MAAM,OACJ,aAAa,QACb,QAAQ,eACP,MAAM,QAAQ,QAAQ,MAAM,cAAc,IAAI;IAEjD,OAAO,IAAI;KACT,SAAS,KAAK,gBAAgB;MAC5B;MACA,aAAa,kBACX,MACA,SACA,QAAQ,eAAe,CACzB;MACA,KAAK,QAAQ;MACb,MAAM,cAAc;MACpB,YACE,QAAQ,cACR,QAAQ,UACR,UACE,cAAc,MACd,GAAG,UAAU,UAAU,IAAI,EAAE,WAC/B;MACF,aAAa,QAAQ;MACrB;KACF,CAAC;KACD;KACA;IACF,CAAC;GACH,CACF,CACF;EACF,SAAS,OAAO;GACd,WACE,yCAAyC,UACvC,UAAU,IACZ,EAAE,KAAK,UAAU,OAAO,EAAE,aACxB,QAAQ,KAAK,IACT,GAAG,MAAM,QAAQ;;EAE/B,MAAM,UACQ,iBAER;GAEA,OAAO,EAAE,SAAS,MAAM;EAC1B;CACF,GACA;EACE,mBAAmB;EACnB,OAAO,EACL,sBAAsB,YAAsC;GAC1D,QAAQ,aAAa;GAErB,OAAO;EACT,EACF;CACF,CACF;AACF"}
|
|
@@ -10,7 +10,7 @@ import { joinPaths } from "@stryke/path/join";
|
|
|
10
10
|
import { isSet } from "@stryke/type-checks/is-set";
|
|
11
11
|
import { isSetArray } from "@stryke/type-checks/is-set-array";
|
|
12
12
|
import { createJiti } from "jiti";
|
|
13
|
-
import { formatExecutionId } from "powerlines/plugin-utils";
|
|
13
|
+
import { formatExecutionId, getName } from "powerlines/plugin-utils";
|
|
14
14
|
|
|
15
15
|
//#region src/base/base-executor.ts
|
|
16
16
|
/**
|
|
@@ -44,7 +44,6 @@ function withExecutor(command, executorFn, options = {}) {
|
|
|
44
44
|
workspaceConfig,
|
|
45
45
|
command,
|
|
46
46
|
inlineConfig: defu({
|
|
47
|
-
name: context.projectName,
|
|
48
47
|
command,
|
|
49
48
|
root: projectConfig.root,
|
|
50
49
|
configFile: options.configFile || options.config,
|
|
@@ -82,18 +81,22 @@ function withExecutor(command, executorFn, options = {}) {
|
|
|
82
81
|
"define",
|
|
83
82
|
"assets"
|
|
84
83
|
]))
|
|
85
|
-
}, context), async (inlineConfig) =>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
84
|
+
}, context), async (inlineConfig) => {
|
|
85
|
+
const name = inlineConfig.name || context.projectName || await getName(context.root, projectConfig.root);
|
|
86
|
+
return api({
|
|
87
|
+
options: defu(defaultOptions, {
|
|
88
|
+
name,
|
|
89
|
+
executionId: formatExecutionId(name, command, options.configIndex ?? 0),
|
|
90
|
+
cwd: context.root,
|
|
91
|
+
root: projectConfig.root,
|
|
92
|
+
configFile: options.configFile || options.config || joinPaths(projectConfig.root, `${kebabCase(framework.name)}.config.ts`),
|
|
93
|
+
configIndex: options.configIndex,
|
|
94
|
+
framework
|
|
95
|
+
}),
|
|
96
|
+
command,
|
|
97
|
+
inlineConfig
|
|
98
|
+
});
|
|
99
|
+
}));
|
|
97
100
|
} catch (error) {
|
|
98
101
|
writeError(`An error occurred while executing the ${titleCase(framework.name)} - ${titleCase(command)} executor: ${isError(error) ? `${error.message}
|
|
99
102
|
|
|
@@ -111,4 +114,4 @@ ${error.stack}` : "Unknown error"}`);
|
|
|
111
114
|
|
|
112
115
|
//#endregion
|
|
113
116
|
export { withExecutor as t };
|
|
114
|
-
//# sourceMappingURL=base-executor-
|
|
117
|
+
//# sourceMappingURL=base-executor-BZOeOotB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-executor-BZOeOotB.mjs","names":[],"sources":["../../src/base/base-executor.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\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/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ExecutorContext, PromiseExecutor } from \"@nx/devkit\";\nimport { writeError } from \"@storm-software/config-tools/logger\";\nimport type { StormWorkspaceConfig } from \"@storm-software/config/types\";\nimport { withRunExecutor } from \"@storm-software/workspace-tools/base/base-executor\";\nimport type { BaseExecutorResult } from \"@storm-software/workspace-tools/types\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isError } from \"@stryke/type-checks/is-error\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetArray } from \"@stryke/type-checks/is-set-array\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { DeepPartial } from \"@stryke/types/base\";\nimport defu from \"defu\";\nimport { createJiti } from \"jiti\";\nimport type {\n ExecutionApiParams,\n ExecutionOptions,\n FrameworkOptions,\n InlineConfig,\n Mode,\n OutputConfig\n} from \"powerlines\";\nimport { formatExecutionId, getName } from \"powerlines/plugin-utils\";\nimport type { BaseExecutorSchema } from \"./base-executor.schema\";\n\nexport type PowerlinesExecutorContext<\n TExecutorSchema extends BaseExecutorSchema = BaseExecutorSchema\n> = ExecutorContext & {\n projectName: string;\n command: string;\n options: TExecutorSchema;\n inlineConfig: InlineConfig;\n workspaceConfig: StormWorkspaceConfig;\n};\n\nexport type PowerlinesExecutorApi = (\n inlineConfig: InlineConfig\n) => Promise<void>;\n\nexport interface WithExecutorOptions {\n /**\n * The import path for the executor API module, which is used to dynamically import the API function that will be called during execution. This value should be a string representing the module path, and it defaults to \"powerlines/api\" if not provided. The specified module should export a default function that matches the expected signature for the executor API, which will be invoked with the execution parameters when the executor is run.\n *\n * @defaultValue \"powerlines/api\"\n */\n importPath?: string;\n\n /**\n * Default options to be merged with the execution options, which can be used to provide default values for certain execution parameters or to override specific options for all executions of the executor. This value should be an object that matches the shape of the `ExecutionOptions` type, and it will be merged with the options provided during execution to create the final set of options that will be passed to the executor API function.\n *\n * @remarks\n * This can be useful for setting default values for options that are commonly used across multiple executions, or for providing a consistent set of options for all executions of the executor without requiring the caller to specify them each time.\n */\n defaultOptions?: DeepPartial<ExecutionOptions>;\n\n /**\n * Details about the framework being used in the current execution, which can be used by plugins and other parts of the system to customize behavior based on the framework.\n *\n * @remarks\n * This should only be used by framework plugins to ensure the correct framework name is applied\n *\n * @defaultValue\n * ```ts\n * {\n * name: \"powerlines\",\n * orgId: \"storm-software\"\n * }\n * ```\n */\n framework?: FrameworkOptions;\n}\n\n/**\n * A utility function to create a Powerlines executor that can be used with the `withRunExecutor` function.\n *\n * @remarks\n * This function is designed to simplify the creation of Powerlines executors by providing a consistent interface and error handling.\n *\n * @param command - The command that the executor will handle (e.g., \"new\", \"prepare\", \"build\", etc.).\n * @param executorFn - The function that will be executed when the command is run.\n * @param options - Additional options for configuring the executor, such as the import path for the API module and default execution options.\n * @returns A Promise that resolves to the result of the executor function.\n */\nexport function withExecutor<\n TExecutorSchema extends BaseExecutorSchema = BaseExecutorSchema\n>(\n command: string,\n executorFn: (\n context: PowerlinesExecutorContext<TExecutorSchema>,\n api: PowerlinesExecutorApi\n ) =>\n | Promise<BaseExecutorResult | null | undefined>\n | BaseExecutorResult\n | null\n | undefined,\n options: WithExecutorOptions = {}\n): PromiseExecutor<TExecutorSchema> {\n const {\n importPath = \"powerlines/api\",\n defaultOptions = {},\n framework = {} as FrameworkOptions\n } = options;\n\n framework.name ??= \"powerlines\";\n framework.orgId ??= \"storm-software\";\n\n return withRunExecutor(\n `${titleCase(framework.name)} - ${titleCase(command)} executor`,\n async (\n options: TExecutorSchema,\n context: ExecutorContext,\n workspaceConfig: StormWorkspaceConfig\n ): Promise<BaseExecutorResult | null | undefined> => {\n if (!context.projectName) {\n throw new Error(\n `The ${titleCase(framework.name)} - ${titleCase(\n command\n )} executor requires \\`projectName\\` on the context object.`\n );\n }\n\n if (\n !context.projectName ||\n !context.projectsConfigurations?.projects ||\n !context.projectsConfigurations.projects[context.projectName] ||\n !context.projectsConfigurations.projects[context.projectName]?.root\n ) {\n throw new Error(\n `The ${titleCase(framework.name)} - ${titleCase(\n command\n )} executor requires \\`projectsConfigurations\\` on the context object.`\n );\n }\n\n const projectConfig =\n context.projectsConfigurations.projects[context.projectName]!;\n\n const jiti = createJiti(context.root, {\n cache: false,\n tsconfigPaths: true\n });\n const api = await jiti\n .import<{\n default: (params: ExecutionApiParams) => Promise<void>;\n }>(jiti.esmResolve(importPath))\n .then(mod => mod.default);\n\n try {\n return await Promise.resolve(\n executorFn(\n defu(\n {\n projectName: context.projectName,\n options,\n workspaceConfig,\n command,\n inlineConfig: defu(\n {\n command,\n root: projectConfig.root,\n configFile: options.configFile || options.config,\n configIndex: options.configIndex,\n projectType: projectConfig.projectType,\n mode: options.mode as Mode,\n output: {\n path: options.outputPath,\n copy:\n options.copyPath === false\n ? false\n : {\n path: options.copyPath,\n assets: options.assets\n },\n minify: options.minify,\n sourceMap: options.sourceMap\n } as OutputConfig,\n resolve:\n isSetArray(options.external) ||\n isSetArray(options.noExternal) ||\n isSet(options.skipNodeModulesBundle)\n ? {\n external: isSetArray(options.external)\n ? options.external\n : undefined,\n noExternal: isSetArray(options.noExternal)\n ? options.noExternal\n : undefined,\n skipNodeModulesBundle: isSet(\n options.skipNodeModulesBundle\n )\n ? options.skipNodeModulesBundle\n : undefined\n }\n : undefined,\n define: isSetObject(options.define)\n ? options.define\n : undefined,\n assets: isSetObject(options.assets)\n ? options.assets\n : undefined\n },\n omit(options, [\n \"config\",\n \"configFile\",\n \"outputPath\",\n \"copyPath\",\n \"sourceMap\",\n \"minify\",\n \"format\",\n \"external\",\n \"noExternal\",\n \"skipNodeModulesBundle\",\n \"mode\",\n \"define\",\n \"assets\"\n ])\n ) as InlineConfig\n },\n context\n ),\n async (inlineConfig: InlineConfig) => {\n const name =\n inlineConfig.name ||\n context.projectName ||\n (await getName(context.root, projectConfig.root));\n\n return api({\n options: defu(defaultOptions, {\n name,\n executionId: formatExecutionId(\n name,\n command,\n options.configIndex ?? 0\n ),\n cwd: context.root,\n root: projectConfig.root,\n configFile:\n options.configFile ||\n options.config ||\n joinPaths(\n projectConfig.root,\n `${kebabCase(framework.name)}.config.ts`\n ),\n configIndex: options.configIndex,\n framework\n }) as ExecutionOptions,\n command,\n inlineConfig\n });\n }\n )\n );\n } catch (error) {\n writeError(\n `An error occurred while executing the ${titleCase(\n framework.name\n )} - ${titleCase(command)} executor: ${\n isError(error)\n ? `${error.message}\n\n${error.stack}`\n : \"Unknown error\"\n }`\n );\n\n return { success: false };\n }\n },\n {\n skipReadingConfig: false,\n hooks: {\n applyDefaultOptions: (options: Partial<TExecutorSchema>) => {\n options.copyPath ??= \"dist/{projectRoot}\";\n\n return options as TExecutorSchema;\n }\n }\n }\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuGA,SAAgB,aAGd,SACA,YAQA,UAA+B,CAAC,GACE;CAClC,MAAM,EACJ,aAAa,kBACb,iBAAiB,CAAC,GAClB,YAAY,CAAC,MACX;CAEJ,UAAU,SAA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;MACJ,uBAAuB,MACrB,QAAQ,qBACV,IACI,QAAQ,wBACR;KACN,IACA;KACN,QAAQ,YAAY,QAAQ,MAAM,IAC9B,QAAQ,SACR;KACJ,QAAQ,YAAY,QAAQ,MAAM,IAC9B,QAAQ,SACR;IACN,GACA,KAAK,SAAS;KACZ;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;IACF,CAAC,CACH;GACF,GACA,OACF,GACA,OAAO,iBAA+B;IACpC,MAAM,OACJ,aAAa,QACb,QAAQ,eACP,MAAM,QAAQ,QAAQ,MAAM,cAAc,IAAI;IAEjD,OAAO,IAAI;KACT,SAAS,KAAK,gBAAgB;MAC5B;MACA,aAAa,kBACX,MACA,SACA,QAAQ,eAAe,CACzB;MACA,KAAK,QAAQ;MACb,MAAM,cAAc;MACpB,YACE,QAAQ,cACR,QAAQ,UACR,UACE,cAAc,MACd,GAAG,UAAU,UAAU,IAAI,EAAE,WAC/B;MACF,aAAa,QAAQ;MACrB;KACF,CAAC;KACD;KACA;IACF,CAAC;GACH,CACF,CACF;EACF,SAAS,OAAO;GACd,WACE,yCAAyC,UACvC,UAAU,IACZ,EAAE,KAAK,UAAU,OAAO,EAAE,aACxB,QAAQ,KAAK,IACT,GAAG,MAAM,QAAQ;;EAE/B,MAAM,UACQ,iBAER;GAEA,OAAO,EAAE,SAAS,MAAM;EAC1B;CACF,GACA;EACE,mBAAmB;EACnB,OAAO,EACL,sBAAsB,YAAsC;GAC1D,QAAQ,aAAa;GAErB,OAAO;EACT,EACF;CACF,CACF;AACF"}
|
|
@@ -46,7 +46,6 @@ function withExecutor(command, executorFn, options = {}) {
|
|
|
46
46
|
workspaceConfig,
|
|
47
47
|
command,
|
|
48
48
|
inlineConfig: (0, defu.default)({
|
|
49
|
-
name: context.projectName,
|
|
50
49
|
command,
|
|
51
50
|
root: projectConfig.root,
|
|
52
51
|
configFile: options.configFile || options.config,
|
|
@@ -84,18 +83,22 @@ function withExecutor(command, executorFn, options = {}) {
|
|
|
84
83
|
"define",
|
|
85
84
|
"assets"
|
|
86
85
|
]))
|
|
87
|
-
}, context), async (inlineConfig) =>
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
86
|
+
}, context), async (inlineConfig) => {
|
|
87
|
+
const name = inlineConfig.name || context.projectName || await (0, powerlines_plugin_utils.getName)(context.root, projectConfig.root);
|
|
88
|
+
return api({
|
|
89
|
+
options: (0, defu.default)(defaultOptions, {
|
|
90
|
+
name,
|
|
91
|
+
executionId: (0, powerlines_plugin_utils.formatExecutionId)(name, command, options.configIndex ?? 0),
|
|
92
|
+
cwd: context.root,
|
|
93
|
+
root: projectConfig.root,
|
|
94
|
+
configFile: options.configFile || options.config || (0, _stryke_path_join.joinPaths)(projectConfig.root, `${(0, _stryke_string_format_kebab_case.kebabCase)(framework.name)}.config.ts`),
|
|
95
|
+
configIndex: options.configIndex,
|
|
96
|
+
framework
|
|
97
|
+
}),
|
|
98
|
+
command,
|
|
99
|
+
inlineConfig
|
|
100
|
+
});
|
|
101
|
+
}));
|
|
99
102
|
} catch (error) {
|
|
100
103
|
(0, _storm_software_config_tools_logger.writeError)(`An error occurred while executing the ${(0, _stryke_string_format_title_case.titleCase)(framework.name)} - ${(0, _stryke_string_format_title_case.titleCase)(command)} executor: ${(0, _stryke_type_checks_is_error.isError)(error) ? `${error.message}
|
|
101
104
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/nx",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.166",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A Nx plugin to support Powerlines development in Nx monorepos.",
|
|
6
6
|
"repository": {
|
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
"@stryke/type-checks": "^0.6.17",
|
|
188
188
|
"defu": "^6.1.7",
|
|
189
189
|
"jiti": "^2.7.0",
|
|
190
|
-
"powerlines": "^0.47.
|
|
190
|
+
"powerlines": "^0.47.127"
|
|
191
191
|
},
|
|
192
192
|
"devDependencies": {
|
|
193
193
|
"@nx/workspace": "22.7.5",
|
|
@@ -206,5 +206,5 @@
|
|
|
206
206
|
"publishConfig": { "access": "public" },
|
|
207
207
|
"executors": "./executors.json",
|
|
208
208
|
"generators": "./generators.json",
|
|
209
|
-
"gitHead": "
|
|
209
|
+
"gitHead": "157c1b4b9897ac88c7b753b0d5a01de30088f169"
|
|
210
210
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base-executor-nribES6I.mjs","names":[],"sources":["../../src/base/base-executor.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\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/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ExecutorContext, PromiseExecutor } from \"@nx/devkit\";\nimport { writeError } from \"@storm-software/config-tools/logger\";\nimport type { StormWorkspaceConfig } from \"@storm-software/config/types\";\nimport { withRunExecutor } from \"@storm-software/workspace-tools/base/base-executor\";\nimport type { BaseExecutorResult } from \"@storm-software/workspace-tools/types\";\nimport { omit } from \"@stryke/helpers/omit\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isError } from \"@stryke/type-checks/is-error\";\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetArray } from \"@stryke/type-checks/is-set-array\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { DeepPartial } from \"@stryke/types/base\";\nimport defu from \"defu\";\nimport { createJiti } from \"jiti\";\nimport type {\n ExecutionApiParams,\n ExecutionOptions,\n FrameworkOptions,\n InlineConfig,\n Mode,\n OutputConfig\n} from \"powerlines\";\nimport { formatExecutionId } from \"powerlines/plugin-utils\";\nimport type { BaseExecutorSchema } from \"./base-executor.schema\";\n\nexport type PowerlinesExecutorContext<\n TExecutorSchema extends BaseExecutorSchema = BaseExecutorSchema\n> = ExecutorContext & {\n projectName: string;\n command: string;\n options: TExecutorSchema;\n inlineConfig: InlineConfig;\n workspaceConfig: StormWorkspaceConfig;\n};\n\nexport type PowerlinesExecutorApi = (\n inlineConfig: InlineConfig\n) => Promise<void>;\n\nexport interface WithExecutorOptions {\n /**\n * The import path for the executor API module, which is used to dynamically import the API function that will be called during execution. This value should be a string representing the module path, and it defaults to \"powerlines/api\" if not provided. The specified module should export a default function that matches the expected signature for the executor API, which will be invoked with the execution parameters when the executor is run.\n *\n * @defaultValue \"powerlines/api\"\n */\n importPath?: string;\n\n /**\n * Default options to be merged with the execution options, which can be used to provide default values for certain execution parameters or to override specific options for all executions of the executor. This value should be an object that matches the shape of the `ExecutionOptions` type, and it will be merged with the options provided during execution to create the final set of options that will be passed to the executor API function.\n *\n * @remarks\n * This can be useful for setting default values for options that are commonly used across multiple executions, or for providing a consistent set of options for all executions of the executor without requiring the caller to specify them each time.\n */\n defaultOptions?: DeepPartial<ExecutionOptions>;\n\n /**\n * Details about the framework being used in the current execution, which can be used by plugins and other parts of the system to customize behavior based on the framework.\n *\n * @remarks\n * This should only be used by framework plugins to ensure the correct framework name is applied\n *\n * @defaultValue\n * ```ts\n * {\n * name: \"powerlines\",\n * orgId: \"storm-software\"\n * }\n * ```\n */\n framework?: FrameworkOptions;\n}\n\n/**\n * A utility function to create a Powerlines executor that can be used with the `withRunExecutor` function.\n *\n * @remarks\n * This function is designed to simplify the creation of Powerlines executors by providing a consistent interface and error handling.\n *\n * @param command - The command that the executor will handle (e.g., \"new\", \"prepare\", \"build\", etc.).\n * @param executorFn - The function that will be executed when the command is run.\n * @param options - Additional options for configuring the executor, such as the import path for the API module and default execution options.\n * @returns A Promise that resolves to the result of the executor function.\n */\nexport function withExecutor<\n TExecutorSchema extends BaseExecutorSchema = BaseExecutorSchema\n>(\n command: string,\n executorFn: (\n context: PowerlinesExecutorContext<TExecutorSchema>,\n api: PowerlinesExecutorApi\n ) =>\n | Promise<BaseExecutorResult | null | undefined>\n | BaseExecutorResult\n | null\n | undefined,\n options: WithExecutorOptions = {}\n): PromiseExecutor<TExecutorSchema> {\n const {\n importPath = \"powerlines/api\",\n defaultOptions = {},\n framework = {} as FrameworkOptions\n } = options;\n\n framework.name ??= \"powerlines\";\n framework.orgId ??= \"storm-software\";\n\n return withRunExecutor(\n `${titleCase(framework.name)} - ${titleCase(command)} executor`,\n async (\n options: TExecutorSchema,\n context: ExecutorContext,\n workspaceConfig: StormWorkspaceConfig\n ): Promise<BaseExecutorResult | null | undefined> => {\n if (!context.projectName) {\n throw new Error(\n `The ${titleCase(framework.name)} - ${titleCase(\n command\n )} executor requires \\`projectName\\` on the context object.`\n );\n }\n\n if (\n !context.projectName ||\n !context.projectsConfigurations?.projects ||\n !context.projectsConfigurations.projects[context.projectName] ||\n !context.projectsConfigurations.projects[context.projectName]?.root\n ) {\n throw new Error(\n `The ${titleCase(framework.name)} - ${titleCase(\n command\n )} executor requires \\`projectsConfigurations\\` on the context object.`\n );\n }\n\n const projectConfig =\n context.projectsConfigurations.projects[context.projectName]!;\n\n const jiti = createJiti(context.root, {\n cache: false,\n tsconfigPaths: true\n });\n const api = await jiti\n .import<{\n default: (params: ExecutionApiParams) => Promise<void>;\n }>(jiti.esmResolve(importPath))\n .then(mod => mod.default);\n\n try {\n return await Promise.resolve(\n executorFn(\n defu(\n {\n projectName: context.projectName,\n options,\n workspaceConfig,\n command,\n inlineConfig: defu(\n {\n name: context.projectName,\n command,\n root: projectConfig.root,\n configFile: options.configFile || options.config,\n configIndex: options.configIndex,\n projectType: projectConfig.projectType,\n mode: options.mode as Mode,\n output: {\n path: options.outputPath,\n copy:\n options.copyPath === false\n ? false\n : {\n path: options.copyPath,\n assets: options.assets\n },\n minify: options.minify,\n sourceMap: options.sourceMap\n } as OutputConfig,\n resolve:\n isSetArray(options.external) ||\n isSetArray(options.noExternal) ||\n isSet(options.skipNodeModulesBundle)\n ? {\n external: isSetArray(options.external)\n ? options.external\n : undefined,\n noExternal: isSetArray(options.noExternal)\n ? options.noExternal\n : undefined,\n skipNodeModulesBundle: isSet(\n options.skipNodeModulesBundle\n )\n ? options.skipNodeModulesBundle\n : undefined\n }\n : undefined,\n define: isSetObject(options.define)\n ? options.define\n : undefined,\n assets: isSetObject(options.assets)\n ? options.assets\n : undefined\n },\n omit(options, [\n \"config\",\n \"configFile\",\n \"outputPath\",\n \"copyPath\",\n \"sourceMap\",\n \"minify\",\n \"format\",\n \"external\",\n \"noExternal\",\n \"skipNodeModulesBundle\",\n \"mode\",\n \"define\",\n \"assets\"\n ])\n ) as InlineConfig\n },\n context\n ),\n async (inlineConfig: InlineConfig) =>\n api({\n options: defu(defaultOptions, {\n executionId: formatExecutionId(\n inlineConfig.name ||\n context.projectName ||\n projectConfig.root,\n command,\n options.configIndex ?? 0\n ),\n cwd: context.root,\n root: projectConfig.root,\n configFile:\n options.configFile ||\n options.config ||\n joinPaths(\n projectConfig.root,\n `${kebabCase(framework.name)}.config.ts`\n ),\n configIndex: options.configIndex,\n framework\n }) as ExecutionOptions,\n command,\n inlineConfig\n })\n )\n );\n } catch (error) {\n writeError(\n `An error occurred while executing the ${titleCase(\n framework.name\n )} - ${titleCase(command)} executor: ${\n isError(error)\n ? `${error.message}\n\n${error.stack}`\n : \"Unknown error\"\n }`\n );\n\n return { success: false };\n }\n },\n {\n skipReadingConfig: false,\n hooks: {\n applyDefaultOptions: (options: Partial<TExecutorSchema>) => {\n options.copyPath ??= \"dist/{projectRoot}\";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