@powerlines/nx 0.13.249 → 0.13.250

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.
Files changed (85) hide show
  1. package/dist/src/base/base-executor.d.mts +2 -60
  2. package/dist/src/base/base-executor.d.ts +2 -60
  3. package/dist/src/base/base-executor.js +7 -4
  4. package/dist/src/base/base-executor.mjs +5 -2
  5. package/dist/src/base/base-executor.mjs.map +1 -1
  6. package/dist/src/base/base-executor.untyped.d.mts +2 -5
  7. package/dist/src/base/base-executor.untyped.d.ts +2 -4
  8. package/dist/src/base/index.d.mts +1 -1
  9. package/dist/src/base/index.d.ts +1 -1
  10. package/dist/src/base-executor-BCcpfw61.d.ts +60 -0
  11. package/dist/src/base-executor-BCcpfw61.d.ts.map +1 -0
  12. package/dist/src/base-executor-C9j1WGyX.d.mts +60 -0
  13. package/dist/src/base-executor-C9j1WGyX.d.mts.map +1 -0
  14. package/dist/src/base-executor.untyped-DJ2f40oh.d.mts +5 -0
  15. package/dist/src/base-executor.untyped-DJ2f40oh.d.mts.map +1 -0
  16. package/dist/src/base-executor.untyped-DJ2f40oh.d.ts +5 -0
  17. package/dist/src/base-executor.untyped-DJ2f40oh.d.ts.map +1 -0
  18. package/dist/src/constants-QuvxQ1Kt.d.mts +8 -0
  19. package/dist/src/constants-QuvxQ1Kt.d.mts.map +1 -0
  20. package/dist/src/constants-QuvxQ1Kt.d.ts +8 -0
  21. package/dist/src/constants-QuvxQ1Kt.d.ts.map +1 -0
  22. package/dist/src/executors/build/executor.js +2 -2
  23. package/dist/src/executors/build/executor.mjs +1 -1
  24. package/dist/src/executors/clean/executor.js +2 -2
  25. package/dist/src/executors/clean/executor.mjs +1 -1
  26. package/dist/src/executors/clean/untyped.js +2 -2
  27. package/dist/src/executors/clean/untyped.mjs +1 -1
  28. package/dist/src/executors/docs/executor.js +2 -2
  29. package/dist/src/executors/docs/executor.mjs +1 -1
  30. package/dist/src/executors/lint/executor.js +2 -2
  31. package/dist/src/executors/lint/executor.mjs +1 -1
  32. package/dist/src/executors/prepare/executor.js +2 -2
  33. package/dist/src/executors/prepare/executor.mjs +1 -1
  34. package/dist/src/executors/prepare/untyped.js +2 -2
  35. package/dist/src/executors/prepare/untyped.mjs +1 -1
  36. package/dist/src/helpers/constants.d.mts +2 -8
  37. package/dist/src/helpers/constants.d.ts +2 -8
  38. package/dist/src/helpers/index.d.mts +2 -2
  39. package/dist/src/helpers/index.d.ts +2 -2
  40. package/dist/src/helpers/plugin-utilities.d.mts +2 -56
  41. package/dist/src/helpers/plugin-utilities.d.ts +2 -56
  42. package/dist/src/helpers/plugin-utilities.js +2 -2
  43. package/dist/src/helpers/plugin-utilities.mjs +2 -2
  44. package/dist/src/helpers/plugin-utilities.mjs.map +1 -1
  45. package/dist/src/index.d.mts +4 -4
  46. package/dist/src/index.d.ts +4 -4
  47. package/dist/src/index.js +1 -0
  48. package/dist/src/index.mjs +1 -0
  49. package/dist/src/plugin/index.d.mts +1 -286
  50. package/dist/src/plugin/index.d.mts.map +1 -1
  51. package/dist/src/plugin/index.d.ts +1 -286
  52. package/dist/src/plugin/index.d.ts.map +1 -1
  53. package/dist/src/plugin/index.js +2 -284
  54. package/dist/src/plugin/index.mjs +1 -281
  55. package/dist/src/plugin/index.mjs.map +1 -1
  56. package/dist/src/plugin-B94-9IvO.d.mts +288 -0
  57. package/dist/src/plugin-B94-9IvO.d.mts.map +1 -0
  58. package/dist/src/plugin-B94-9IvO.d.ts +288 -0
  59. package/dist/src/plugin-B94-9IvO.d.ts.map +1 -0
  60. package/dist/src/plugin-utilities-TozKPwW0.d.ts +56 -0
  61. package/dist/src/plugin-utilities-TozKPwW0.d.ts.map +1 -0
  62. package/dist/src/plugin-utilities-dOdjrrHD.d.mts +56 -0
  63. package/dist/src/plugin-utilities-dOdjrrHD.d.mts.map +1 -0
  64. package/dist/src/types/index.d.mts +1 -1
  65. package/dist/src/types/index.d.ts +1 -1
  66. package/dist/src/types/plugin.d.mts +2 -288
  67. package/dist/src/types/plugin.d.ts +2 -288
  68. package/package.json +3 -3
  69. package/dist/src/_virtual/_rolldown/runtime.js +0 -28
  70. package/dist/src/base/base-executor.d.mts.map +0 -1
  71. package/dist/src/base/base-executor.d.ts.map +0 -1
  72. package/dist/src/base/base-executor.untyped.d.mts.map +0 -1
  73. package/dist/src/base/base-executor.untyped.d.ts.map +0 -1
  74. package/dist/src/base-executor-BVYmsZ3I.mjs +0 -114
  75. package/dist/src/base-executor-BVYmsZ3I.mjs.map +0 -1
  76. package/dist/src/base-executor-CBgW5wY1.js +0 -120
  77. package/dist/src/base-executor.untyped-But-48Iy.js +0 -183
  78. package/dist/src/base-executor.untyped-Bz2f75UY.mjs +0 -179
  79. package/dist/src/base-executor.untyped-Bz2f75UY.mjs.map +0 -1
  80. package/dist/src/helpers/constants.d.mts.map +0 -1
  81. package/dist/src/helpers/constants.d.ts.map +0 -1
  82. package/dist/src/helpers/plugin-utilities.d.mts.map +0 -1
  83. package/dist/src/helpers/plugin-utilities.d.ts.map +0 -1
  84. package/dist/src/types/plugin.d.mts.map +0 -1
  85. package/dist/src/types/plugin.d.ts.map +0 -1
@@ -1,290 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_rolldown_runtime = require('../rolldown-runtime-C24Yb2bl.js');
3
- let _nx_devkit = require("@nx/devkit");
4
- let _storm_software_workspace_tools_utils_nx_json = require("@storm-software/workspace-tools/utils/nx-json");
5
- let _storm_software_workspace_tools_utils_plugin_helpers = require("@storm-software/workspace-tools/utils/plugin-helpers");
6
- let _storm_software_workspace_tools_utils_project_tags = require("@storm-software/workspace-tools/utils/project-tags");
7
- let _stryke_env_environment_checks = require("@stryke/env/environment-checks");
8
- let _stryke_env_get_env_paths = require("@stryke/env/get-env-paths");
9
- let _stryke_fs_exists = require("@stryke/fs/exists");
10
- let _stryke_path_join_paths = require("@stryke/path/join-paths");
11
- let _stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
12
- let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
13
- let _stryke_type_checks_is_error = require("@stryke/type-checks/is-error");
14
- let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
15
- let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
16
- let defu = require("defu");
17
- defu = require_rolldown_runtime.__toESM(defu);
18
- let node_fs_promises = require("node:fs/promises");
19
- let nx_src_config_nx_json_js = require("nx/src/config/nx-json.js");
20
- let nx_src_utils_package_json_js = require("nx/src/utils/package-json.js");
21
- let nx_src_utils_package_manager_js = require("nx/src/utils/package-manager.js");
2
+ const require_helpers_plugin_utilities = require('../helpers/plugin-utilities.js');
22
3
 
23
- //#region src/helpers/constants.ts
24
- /**
25
- * A list of Nx input strings that describe the Powerlines configuration file
26
- */
27
- const CONFIG_INPUTS = [
28
- "{projectRoot}/{framework}.json",
29
- "{projectRoot}/{framework}.*.json",
30
- "{projectRoot}/{framework}.jsonc",
31
- "{projectRoot}/{framework}.*.jsonc",
32
- "{projectRoot}/{framework}.json5",
33
- "{projectRoot}/{framework}.*.json5",
34
- "{projectRoot}/{framework}.yaml",
35
- "{projectRoot}/{framework}.*.yaml",
36
- "{projectRoot}/{framework}.yml",
37
- "{projectRoot}/{framework}.*.yml",
38
- "{projectRoot}/{framework}.toml",
39
- "{projectRoot}/{framework}.*.toml",
40
- "{projectRoot}/{framework}.config.js",
41
- "{projectRoot}/{framework}.*.config.js",
42
- "{projectRoot}/{framework}.config.cjs",
43
- "{projectRoot}/{framework}.*.config.cjs",
44
- "{projectRoot}/{framework}.config.mjs",
45
- "{projectRoot}/{framework}.*.config.mjs",
46
- "{projectRoot}/{framework}.config.ts",
47
- "{projectRoot}/{framework}.*.config.ts",
48
- "{projectRoot}/{framework}.config.cts",
49
- "{projectRoot}/{framework}.*.config.cts",
50
- "{projectRoot}/{framework}.config.mts",
51
- "{projectRoot}/{framework}.*.config.mts"
52
- ];
53
-
54
- //#endregion
55
- //#region src/helpers/plugin-utilities.ts
56
- /**
57
- * Generates Nx input strings for the Powerlines configuration file, replacing the `{framework}` placeholder with the specified framework name.
58
- *
59
- * @param framework - The framework name to use in the input strings
60
- * @returns An array of Nx input strings for the configuration file
61
- */
62
- function getNxTargetInputs(framework) {
63
- return CONFIG_INPUTS.map((input) => input.replace("{framework}", framework));
64
- }
65
- /**
66
- * Generates Nx input strings for the Powerlines configuration file, replacing the `{framework}` placeholder with the specified framework name.
67
- *
68
- * @param framework - The framework name to use in the input strings
69
- * @returns An array of Nx input strings for the configuration file
70
- */
71
- function getNxPluginInputs(framework) {
72
- return `**/{${getNxTargetInputs(framework).map((input) => input.replace("{projectRoot}/", "")).join(",")}}`;
73
- }
74
- /**
75
- * Creates an Nx plugin that integrates Powerlines into the Nx build process.
76
- *
77
- * @param opts - Options for creating the Nx plugin
78
- * @returns A CreateNodesV2 function that can be used as an Nx plugin
79
- */
80
- function createNxPlugin(opts) {
81
- const framework = (0, _stryke_string_format_kebab_case.kebabCase)(opts?.framework) || "powerlines";
82
- const title = `${(0, _stryke_string_format_title_case.titleCase)(framework)} Nx Plugin`;
83
- try {
84
- const name = opts?.name || `${framework}/nx/plugin`;
85
- const artifactsFolder = opts?.artifactsFolder || `{projectRoot}/.${framework}`;
86
- const targetInputs = getNxTargetInputs(framework);
87
- const pluginInputs = getNxPluginInputs(framework);
88
- return [pluginInputs, async (configFiles, options, contextV2) => {
89
- if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Initializing the ${title} for the following inputs: ${pluginInputs}`);
90
- if (!(0, _stryke_env_get_env_paths.getEnvPaths)({
91
- orgId: "storm-software",
92
- appId: framework,
93
- workspaceRoot: contextV2.workspaceRoot
94
- }).cache) throw new Error("The cache directory could not be determined.");
95
- const nxJson = (0, nx_src_config_nx_json_js.readNxJson)(contextV2.workspaceRoot);
96
- const packageManagerCommand = (0, nx_src_utils_package_manager_js.getPackageManagerCommand)((0, nx_src_utils_package_manager_js.detectPackageManager)(contextV2.workspaceRoot), contextV2.workspaceRoot);
97
- return (0, _nx_devkit.createNodesFromFiles)(async (configFile, _, context) => {
98
- try {
99
- const projectRoot = (0, _storm_software_workspace_tools_utils_plugin_helpers.getProjectRoot)(configFile, contextV2.workspaceRoot);
100
- if (!projectRoot) {
101
- console.error(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - package.json and ${framework} configuration files (i.e. ${framework}.config.ts) must be located in the project root directory: ${configFile}`);
102
- return {};
103
- }
104
- const root = (0, _storm_software_workspace_tools_utils_plugin_helpers.getRoot)(projectRoot, context);
105
- if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Loading ${framework} user configuration for project in root directory ${projectRoot}.`);
106
- if (!(0, _stryke_fs_exists.existsSync)((0, _stryke_path_join_paths.joinPaths)(contextV2.workspaceRoot, projectRoot, "package.json"))) {
107
- if (options?.verboseOutput) console.warn(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Cannot find \`package.json\` file in the project's root directory (path: "${(0, _stryke_path_join_paths.joinPaths)(contextV2.workspaceRoot, projectRoot)}"). Skipping project configuration.`);
108
- return {};
109
- }
110
- const packageJsonContent = await (0, node_fs_promises.readFile)((0, _stryke_path_join_paths.joinPaths)(contextV2.workspaceRoot, projectRoot, "package.json"), "utf8");
111
- if (!packageJsonContent) {
112
- if (options?.verboseOutput) console.warn(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - No package.json file found for project in root directory ${projectRoot}`);
113
- return {};
114
- }
115
- const packageJson = JSON.parse(packageJsonContent);
116
- const projectConfig = (0, _storm_software_workspace_tools_utils_plugin_helpers.getProjectConfigFromProjectRoot)(projectRoot, packageJson);
117
- if (!projectConfig) {
118
- if (options?.verboseOutput) console.warn(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - No project configuration found for project in root directory ${projectRoot}`);
119
- return {};
120
- }
121
- const targets = (0, nx_src_utils_package_json_js.readTargetsFromPackageJson)(packageJson, nxJson, projectRoot, context.workspaceRoot, packageManagerCommand);
122
- if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Preparing Nx targets for project in root directory ${projectRoot}.`);
123
- if (options?.clean !== false && !targets[options?.clean?.targetName || "clean"]) targets[options?.clean?.targetName || "clean"] = {
124
- cache: options?.clean?.cache ?? options?.cache ?? true,
125
- inputs: Array.isArray(options?.clean?.inputs) ? options.clean.inputs : (0, _storm_software_workspace_tools_utils_nx_json.withNamedInputs)(targetInputs, [options?.clean?.inputs || "typescript"]),
126
- outputs: options?.clean?.outputs,
127
- executor: options?.clean?.executor || `@${framework}/nx:${options?.clean?.targetName || "clean"}`,
128
- dependsOn: options?.clean?.dependsOn ?? [`^${options?.clean?.targetName || "clean"}`],
129
- defaultConfiguration: options?.clean?.defaultConfiguration || "production",
130
- options: {
131
- root: projectRoot,
132
- configFile,
133
- projectType: projectConfig.projectType,
134
- outputPath: `{workspaceRoot}/${projectRoot}/dist`,
135
- copyPath: `{workspaceRoot}/dist/${projectRoot}`
136
- },
137
- configurations: {
138
- production: { mode: "production" },
139
- test: { mode: "test" },
140
- development: {
141
- mode: "development",
142
- skipCache: true
143
- }
144
- }
145
- };
146
- if (options?.prepare !== false && !targets[options?.prepare?.targetName || "prepare"]) targets[options?.prepare?.targetName || "prepare"] = {
147
- cache: options?.prepare?.cache ?? options?.cache ?? true,
148
- inputs: Array.isArray(options?.prepare?.inputs) ? options.prepare.inputs : (0, _storm_software_workspace_tools_utils_nx_json.withNamedInputs)(targetInputs, [options?.prepare?.inputs || "typescript"]),
149
- outputs: options?.prepare?.outputs ?? [artifactsFolder],
150
- executor: options?.prepare?.executor || `@${framework}/nx:${options?.prepare?.targetName || "prepare"}`,
151
- dependsOn: options?.prepare?.dependsOn ?? [`^${options?.prepare?.targetName || "build"}`].filter(Boolean),
152
- defaultConfiguration: options?.prepare?.defaultConfiguration || "production",
153
- options: {
154
- projectType: projectConfig.projectType,
155
- configFile,
156
- outputPath: `{workspaceRoot}/${projectRoot}/dist`,
157
- copyPath: `{workspaceRoot}/dist/${projectRoot}`
158
- },
159
- configurations: {
160
- production: { mode: "production" },
161
- test: { mode: "test" },
162
- development: {
163
- mode: "development",
164
- skipCache: true
165
- }
166
- }
167
- };
168
- if (options?.build !== false && !targets[options?.build?.targetName || "build"]) targets[options?.build?.targetName || "build"] = {
169
- cache: options?.build?.cache ?? options?.cache ?? true,
170
- inputs: Array.isArray(options?.build?.inputs) ? options.build.inputs : (0, _storm_software_workspace_tools_utils_nx_json.withNamedInputs)(targetInputs, [options?.build?.inputs || "typescript"]),
171
- outputs: options?.build?.outputs ?? ["{options.outputPath}"],
172
- executor: options?.build?.executor || `@${framework}/nx:${options?.build?.targetName || "build"}`,
173
- dependsOn: options?.build?.dependsOn ?? [`^${options?.build?.targetName || "build"}`, _stryke_env_environment_checks.isDevelopment ? void 0 : (0, _stryke_type_checks_is_set_object.isSetObject)(options?.prepare) && options?.prepare?.targetName ? options?.prepare?.targetName : "prepare"].filter(Boolean),
174
- defaultConfiguration: options?.build?.defaultConfiguration || "production",
175
- options: {
176
- projectType: projectConfig.projectType,
177
- configFile,
178
- outputPath: `{workspaceRoot}/${projectRoot}/dist`,
179
- copyPath: `{workspaceRoot}/dist/${projectRoot}`
180
- },
181
- configurations: {
182
- production: { mode: "production" },
183
- test: { mode: "test" },
184
- development: {
185
- mode: "development",
186
- skipCache: true
187
- }
188
- }
189
- };
190
- if (options?.lint !== false && !targets[options?.lint?.targetName || "lint"]) targets[options?.lint?.targetName || "lint"] = {
191
- cache: options?.lint?.cache ?? options?.cache ?? true,
192
- inputs: Array.isArray(options?.lint?.inputs) ? options.lint.inputs : (0, _storm_software_workspace_tools_utils_nx_json.withNamedInputs)([...targetInputs, artifactsFolder], options?.lint?.inputs ? [options.lint.inputs] : ["linting", "typescript"]),
193
- outputs: options?.lint?.outputs ?? ["{options.outputPath}"],
194
- executor: options?.lint?.executor || `@${framework}/nx:${options?.lint?.targetName || "lint"}`,
195
- dependsOn: options?.lint?.dependsOn ?? [`^${options?.lint?.targetName || "lint"}`, _stryke_env_environment_checks.isDevelopment ? void 0 : (0, _stryke_type_checks_is_set_object.isSetObject)(options?.prepare) && options?.prepare?.targetName ? options?.prepare?.targetName : "prepare"].filter(Boolean),
196
- defaultConfiguration: options?.lint?.defaultConfiguration || "production",
197
- options: {
198
- projectType: projectConfig.projectType,
199
- configFile,
200
- outputPath: `{workspaceRoot}/${projectRoot}/dist`,
201
- copyPath: `{workspaceRoot}/dist/${projectRoot}`
202
- },
203
- configurations: {
204
- production: { mode: "production" },
205
- test: { mode: "test" },
206
- development: {
207
- mode: "development",
208
- skipCache: true
209
- }
210
- }
211
- };
212
- if (options?.docs !== false && !targets[options?.docs?.targetName || "docs"]) targets[options?.docs?.targetName || "docs"] = {
213
- cache: options?.docs?.cache ?? options?.cache ?? true,
214
- inputs: Array.isArray(options?.docs?.inputs) ? options.docs.inputs : (0, _storm_software_workspace_tools_utils_nx_json.withNamedInputs)([...targetInputs, artifactsFolder], options?.docs?.inputs ? [options.docs.inputs] : ["documentation", "typescript"]),
215
- outputs: options?.docs?.outputs ?? ["{options.outputPath}"],
216
- executor: options?.docs?.executor || `@${framework}/nx:${options?.docs?.targetName || "docs"}`,
217
- dependsOn: options?.docs?.dependsOn ?? [
218
- `^${options?.docs?.targetName || "docs"}`,
219
- options?.build !== false && `${options?.build?.targetName || "build"}`,
220
- _stryke_env_environment_checks.isDevelopment ? void 0 : (0, _stryke_type_checks_is_set_object.isSetObject)(options?.prepare) && options?.prepare?.targetName ? options?.prepare?.targetName : "prepare"
221
- ].filter(Boolean),
222
- defaultConfiguration: options?.docs?.defaultConfiguration || "production",
223
- options: {
224
- projectType: projectConfig.projectType,
225
- configFile,
226
- outputPath: `{workspaceRoot}/${projectRoot}/dist`,
227
- copyPath: `{workspaceRoot}/dist/${projectRoot}`
228
- },
229
- configurations: {
230
- production: { mode: "production" },
231
- test: { mode: "test" },
232
- development: {
233
- mode: "development",
234
- skipCache: true
235
- }
236
- }
237
- };
238
- if (options?.deploy !== false && !targets[options?.deploy?.targetName || "deploy"]) targets[options?.deploy?.targetName || "deploy"] = {
239
- cache: options?.deploy?.cache ?? false,
240
- inputs: Array.isArray(options?.deploy?.inputs) ? options.deploy.inputs : (0, _storm_software_workspace_tools_utils_nx_json.withNamedInputs)([...targetInputs, artifactsFolder], options?.deploy?.inputs ? [options.deploy.inputs] : ["documentation", "typescript"]),
241
- outputs: options?.deploy?.outputs ?? ["{options.outputPath}"],
242
- executor: options?.deploy?.executor || `@${framework}/nx:${options?.deploy?.targetName || "deploy"}`,
243
- dependsOn: options?.deploy?.dependsOn ?? [
244
- `^${options?.deploy?.targetName || "deploy"}`,
245
- options?.build !== false && `${options?.build?.targetName || "build"}`,
246
- _stryke_env_environment_checks.isDevelopment ? void 0 : (0, _stryke_type_checks_is_set_object.isSetObject)(options?.prepare) && options?.prepare?.targetName ? options?.prepare?.targetName : "prepare"
247
- ].filter(Boolean),
248
- defaultConfiguration: options?.deploy?.defaultConfiguration || "production",
249
- options: {
250
- projectType: projectConfig.projectType,
251
- configFile,
252
- outputPath: `{workspaceRoot}/${projectRoot}/dist`,
253
- copyPath: `{workspaceRoot}/dist/${projectRoot}`
254
- },
255
- configurations: {
256
- production: { mode: "production" },
257
- test: { mode: "test" },
258
- development: {
259
- mode: "development",
260
- skipCache: true
261
- }
262
- }
263
- };
264
- (0, _storm_software_workspace_tools_utils_project_tags.setDefaultProjectTags)(projectConfig, name);
265
- (0, _storm_software_workspace_tools_utils_project_tags.addProjectTag)(projectConfig, framework, projectConfig.projectType || "library", { overwrite: true });
266
- if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Completed preparing Nx configuration for project in root directory ${projectRoot}.`);
267
- return { projects: { [root]: (0, defu.default)(projectConfig, {
268
- projectType: projectConfig.projectType || "library",
269
- root,
270
- sourceRoot: (0, _stryke_path_join_paths.joinPaths)(root, "src"),
271
- targets
272
- }) } };
273
- } catch (error) {
274
- console.error(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Failed to process the project configuration for file "${configFile}" - ${(0, _stryke_type_checks_is_error.isError)(error) ? error.message : (0, _stryke_type_checks_is_set_string.isSetString)(error) ? error : "Unknown fatal error"}`);
275
- return {};
276
- }
277
- }, configFiles, options, contextV2);
278
- }];
279
- } catch (error) {
280
- console.error(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - ${(0, _stryke_type_checks_is_error.isError)(error) ? error.message : (0, _stryke_type_checks_is_set_string.isSetString)(error) ? error : "Unknown fatal error during plugin initialization"}`);
281
- throw new Error(`Failed to initialize the ${title} - ${(0, _stryke_type_checks_is_error.isError)(error) ? error.message : (0, _stryke_type_checks_is_set_string.isSetString)(error) ? error : "See previous logs for more details"}`, { cause: error instanceof Error ? error : void 0 });
282
- }
283
- }
284
-
285
- //#endregion
286
4
  //#region src/plugin/index.ts
287
- const createNodesV2 = createNxPlugin({ framework: "powerlines" });
5
+ const createNodesV2 = require_helpers_plugin_utilities.createNxPlugin({ framework: "powerlines" });
288
6
 
289
7
  //#endregion
290
8
  exports.createNodesV2 = createNodesV2;
@@ -1,285 +1,5 @@
1
- import { createNodesFromFiles } from "@nx/devkit";
2
- import { withNamedInputs } from "@storm-software/workspace-tools/utils/nx-json";
3
- import { getProjectConfigFromProjectRoot, getProjectRoot, getRoot } from "@storm-software/workspace-tools/utils/plugin-helpers";
4
- import { addProjectTag, setDefaultProjectTags } from "@storm-software/workspace-tools/utils/project-tags";
5
- import { isDevelopment } from "@stryke/env/environment-checks";
6
- import { getEnvPaths } from "@stryke/env/get-env-paths";
7
- import { existsSync } from "@stryke/fs/exists";
8
- import { joinPaths } from "@stryke/path/join-paths";
9
- import { kebabCase } from "@stryke/string-format/kebab-case";
10
- import { titleCase } from "@stryke/string-format/title-case";
11
- import { isError } from "@stryke/type-checks/is-error";
12
- import { isSetObject } from "@stryke/type-checks/is-set-object";
13
- import { isSetString } from "@stryke/type-checks/is-set-string";
14
- import defu from "defu";
15
- import { readFile } from "node:fs/promises";
16
- import { readNxJson as readNxJson$1 } from "nx/src/config/nx-json.js";
17
- import { readTargetsFromPackageJson } from "nx/src/utils/package-json.js";
18
- import { detectPackageManager, getPackageManagerCommand } from "nx/src/utils/package-manager.js";
1
+ import { createNxPlugin } from "../helpers/plugin-utilities.mjs";
19
2
 
20
- //#region src/helpers/constants.ts
21
- /**
22
- * A list of Nx input strings that describe the Powerlines configuration file
23
- */
24
- const CONFIG_INPUTS = [
25
- "{projectRoot}/{framework}.json",
26
- "{projectRoot}/{framework}.*.json",
27
- "{projectRoot}/{framework}.jsonc",
28
- "{projectRoot}/{framework}.*.jsonc",
29
- "{projectRoot}/{framework}.json5",
30
- "{projectRoot}/{framework}.*.json5",
31
- "{projectRoot}/{framework}.yaml",
32
- "{projectRoot}/{framework}.*.yaml",
33
- "{projectRoot}/{framework}.yml",
34
- "{projectRoot}/{framework}.*.yml",
35
- "{projectRoot}/{framework}.toml",
36
- "{projectRoot}/{framework}.*.toml",
37
- "{projectRoot}/{framework}.config.js",
38
- "{projectRoot}/{framework}.*.config.js",
39
- "{projectRoot}/{framework}.config.cjs",
40
- "{projectRoot}/{framework}.*.config.cjs",
41
- "{projectRoot}/{framework}.config.mjs",
42
- "{projectRoot}/{framework}.*.config.mjs",
43
- "{projectRoot}/{framework}.config.ts",
44
- "{projectRoot}/{framework}.*.config.ts",
45
- "{projectRoot}/{framework}.config.cts",
46
- "{projectRoot}/{framework}.*.config.cts",
47
- "{projectRoot}/{framework}.config.mts",
48
- "{projectRoot}/{framework}.*.config.mts"
49
- ];
50
-
51
- //#endregion
52
- //#region src/helpers/plugin-utilities.ts
53
- /**
54
- * Generates Nx input strings for the Powerlines configuration file, replacing the `{framework}` placeholder with the specified framework name.
55
- *
56
- * @param framework - The framework name to use in the input strings
57
- * @returns An array of Nx input strings for the configuration file
58
- */
59
- function getNxTargetInputs(framework) {
60
- return CONFIG_INPUTS.map((input) => input.replace("{framework}", framework));
61
- }
62
- /**
63
- * Generates Nx input strings for the Powerlines configuration file, replacing the `{framework}` placeholder with the specified framework name.
64
- *
65
- * @param framework - The framework name to use in the input strings
66
- * @returns An array of Nx input strings for the configuration file
67
- */
68
- function getNxPluginInputs(framework) {
69
- return `**/{${getNxTargetInputs(framework).map((input) => input.replace("{projectRoot}/", "")).join(",")}}`;
70
- }
71
- /**
72
- * Creates an Nx plugin that integrates Powerlines into the Nx build process.
73
- *
74
- * @param opts - Options for creating the Nx plugin
75
- * @returns A CreateNodesV2 function that can be used as an Nx plugin
76
- */
77
- function createNxPlugin(opts) {
78
- const framework = kebabCase(opts?.framework) || "powerlines";
79
- const title = `${titleCase(framework)} Nx Plugin`;
80
- try {
81
- const name = opts?.name || `${framework}/nx/plugin`;
82
- const artifactsFolder = opts?.artifactsFolder || `{projectRoot}/.${framework}`;
83
- const targetInputs = getNxTargetInputs(framework);
84
- const pluginInputs = getNxPluginInputs(framework);
85
- return [pluginInputs, async (configFiles, options, contextV2) => {
86
- if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Initializing the ${title} for the following inputs: ${pluginInputs}`);
87
- if (!getEnvPaths({
88
- orgId: "storm-software",
89
- appId: framework,
90
- workspaceRoot: contextV2.workspaceRoot
91
- }).cache) throw new Error("The cache directory could not be determined.");
92
- const nxJson = readNxJson$1(contextV2.workspaceRoot);
93
- const packageManagerCommand = getPackageManagerCommand(detectPackageManager(contextV2.workspaceRoot), contextV2.workspaceRoot);
94
- return createNodesFromFiles(async (configFile, _, context) => {
95
- try {
96
- const projectRoot = getProjectRoot(configFile, contextV2.workspaceRoot);
97
- if (!projectRoot) {
98
- console.error(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - package.json and ${framework} configuration files (i.e. ${framework}.config.ts) must be located in the project root directory: ${configFile}`);
99
- return {};
100
- }
101
- const root = getRoot(projectRoot, context);
102
- if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Loading ${framework} user configuration for project in root directory ${projectRoot}.`);
103
- if (!existsSync(joinPaths(contextV2.workspaceRoot, projectRoot, "package.json"))) {
104
- if (options?.verboseOutput) console.warn(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Cannot find \`package.json\` file in the project's root directory (path: "${joinPaths(contextV2.workspaceRoot, projectRoot)}"). Skipping project configuration.`);
105
- return {};
106
- }
107
- const packageJsonContent = await readFile(joinPaths(contextV2.workspaceRoot, projectRoot, "package.json"), "utf8");
108
- if (!packageJsonContent) {
109
- if (options?.verboseOutput) console.warn(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - No package.json file found for project in root directory ${projectRoot}`);
110
- return {};
111
- }
112
- const packageJson = JSON.parse(packageJsonContent);
113
- const projectConfig = getProjectConfigFromProjectRoot(projectRoot, packageJson);
114
- if (!projectConfig) {
115
- if (options?.verboseOutput) console.warn(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - No project configuration found for project in root directory ${projectRoot}`);
116
- return {};
117
- }
118
- const targets = readTargetsFromPackageJson(packageJson, nxJson, projectRoot, context.workspaceRoot, packageManagerCommand);
119
- if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Preparing Nx targets for project in root directory ${projectRoot}.`);
120
- if (options?.clean !== false && !targets[options?.clean?.targetName || "clean"]) targets[options?.clean?.targetName || "clean"] = {
121
- cache: options?.clean?.cache ?? options?.cache ?? true,
122
- inputs: Array.isArray(options?.clean?.inputs) ? options.clean.inputs : withNamedInputs(targetInputs, [options?.clean?.inputs || "typescript"]),
123
- outputs: options?.clean?.outputs,
124
- executor: options?.clean?.executor || `@${framework}/nx:${options?.clean?.targetName || "clean"}`,
125
- dependsOn: options?.clean?.dependsOn ?? [`^${options?.clean?.targetName || "clean"}`],
126
- defaultConfiguration: options?.clean?.defaultConfiguration || "production",
127
- options: {
128
- root: projectRoot,
129
- configFile,
130
- projectType: projectConfig.projectType,
131
- outputPath: `{workspaceRoot}/${projectRoot}/dist`,
132
- copyPath: `{workspaceRoot}/dist/${projectRoot}`
133
- },
134
- configurations: {
135
- production: { mode: "production" },
136
- test: { mode: "test" },
137
- development: {
138
- mode: "development",
139
- skipCache: true
140
- }
141
- }
142
- };
143
- if (options?.prepare !== false && !targets[options?.prepare?.targetName || "prepare"]) targets[options?.prepare?.targetName || "prepare"] = {
144
- cache: options?.prepare?.cache ?? options?.cache ?? true,
145
- inputs: Array.isArray(options?.prepare?.inputs) ? options.prepare.inputs : withNamedInputs(targetInputs, [options?.prepare?.inputs || "typescript"]),
146
- outputs: options?.prepare?.outputs ?? [artifactsFolder],
147
- executor: options?.prepare?.executor || `@${framework}/nx:${options?.prepare?.targetName || "prepare"}`,
148
- dependsOn: options?.prepare?.dependsOn ?? [`^${options?.prepare?.targetName || "build"}`].filter(Boolean),
149
- defaultConfiguration: options?.prepare?.defaultConfiguration || "production",
150
- options: {
151
- projectType: projectConfig.projectType,
152
- configFile,
153
- outputPath: `{workspaceRoot}/${projectRoot}/dist`,
154
- copyPath: `{workspaceRoot}/dist/${projectRoot}`
155
- },
156
- configurations: {
157
- production: { mode: "production" },
158
- test: { mode: "test" },
159
- development: {
160
- mode: "development",
161
- skipCache: true
162
- }
163
- }
164
- };
165
- if (options?.build !== false && !targets[options?.build?.targetName || "build"]) targets[options?.build?.targetName || "build"] = {
166
- cache: options?.build?.cache ?? options?.cache ?? true,
167
- inputs: Array.isArray(options?.build?.inputs) ? options.build.inputs : withNamedInputs(targetInputs, [options?.build?.inputs || "typescript"]),
168
- outputs: options?.build?.outputs ?? ["{options.outputPath}"],
169
- executor: options?.build?.executor || `@${framework}/nx:${options?.build?.targetName || "build"}`,
170
- dependsOn: options?.build?.dependsOn ?? [`^${options?.build?.targetName || "build"}`, isDevelopment ? void 0 : isSetObject(options?.prepare) && options?.prepare?.targetName ? options?.prepare?.targetName : "prepare"].filter(Boolean),
171
- defaultConfiguration: options?.build?.defaultConfiguration || "production",
172
- options: {
173
- projectType: projectConfig.projectType,
174
- configFile,
175
- outputPath: `{workspaceRoot}/${projectRoot}/dist`,
176
- copyPath: `{workspaceRoot}/dist/${projectRoot}`
177
- },
178
- configurations: {
179
- production: { mode: "production" },
180
- test: { mode: "test" },
181
- development: {
182
- mode: "development",
183
- skipCache: true
184
- }
185
- }
186
- };
187
- if (options?.lint !== false && !targets[options?.lint?.targetName || "lint"]) targets[options?.lint?.targetName || "lint"] = {
188
- cache: options?.lint?.cache ?? options?.cache ?? true,
189
- inputs: Array.isArray(options?.lint?.inputs) ? options.lint.inputs : withNamedInputs([...targetInputs, artifactsFolder], options?.lint?.inputs ? [options.lint.inputs] : ["linting", "typescript"]),
190
- outputs: options?.lint?.outputs ?? ["{options.outputPath}"],
191
- executor: options?.lint?.executor || `@${framework}/nx:${options?.lint?.targetName || "lint"}`,
192
- dependsOn: options?.lint?.dependsOn ?? [`^${options?.lint?.targetName || "lint"}`, isDevelopment ? void 0 : isSetObject(options?.prepare) && options?.prepare?.targetName ? options?.prepare?.targetName : "prepare"].filter(Boolean),
193
- defaultConfiguration: options?.lint?.defaultConfiguration || "production",
194
- options: {
195
- projectType: projectConfig.projectType,
196
- configFile,
197
- outputPath: `{workspaceRoot}/${projectRoot}/dist`,
198
- copyPath: `{workspaceRoot}/dist/${projectRoot}`
199
- },
200
- configurations: {
201
- production: { mode: "production" },
202
- test: { mode: "test" },
203
- development: {
204
- mode: "development",
205
- skipCache: true
206
- }
207
- }
208
- };
209
- if (options?.docs !== false && !targets[options?.docs?.targetName || "docs"]) targets[options?.docs?.targetName || "docs"] = {
210
- cache: options?.docs?.cache ?? options?.cache ?? true,
211
- inputs: Array.isArray(options?.docs?.inputs) ? options.docs.inputs : withNamedInputs([...targetInputs, artifactsFolder], options?.docs?.inputs ? [options.docs.inputs] : ["documentation", "typescript"]),
212
- outputs: options?.docs?.outputs ?? ["{options.outputPath}"],
213
- executor: options?.docs?.executor || `@${framework}/nx:${options?.docs?.targetName || "docs"}`,
214
- dependsOn: options?.docs?.dependsOn ?? [
215
- `^${options?.docs?.targetName || "docs"}`,
216
- options?.build !== false && `${options?.build?.targetName || "build"}`,
217
- isDevelopment ? void 0 : isSetObject(options?.prepare) && options?.prepare?.targetName ? options?.prepare?.targetName : "prepare"
218
- ].filter(Boolean),
219
- defaultConfiguration: options?.docs?.defaultConfiguration || "production",
220
- options: {
221
- projectType: projectConfig.projectType,
222
- configFile,
223
- outputPath: `{workspaceRoot}/${projectRoot}/dist`,
224
- copyPath: `{workspaceRoot}/dist/${projectRoot}`
225
- },
226
- configurations: {
227
- production: { mode: "production" },
228
- test: { mode: "test" },
229
- development: {
230
- mode: "development",
231
- skipCache: true
232
- }
233
- }
234
- };
235
- if (options?.deploy !== false && !targets[options?.deploy?.targetName || "deploy"]) targets[options?.deploy?.targetName || "deploy"] = {
236
- cache: options?.deploy?.cache ?? false,
237
- inputs: Array.isArray(options?.deploy?.inputs) ? options.deploy.inputs : withNamedInputs([...targetInputs, artifactsFolder], options?.deploy?.inputs ? [options.deploy.inputs] : ["documentation", "typescript"]),
238
- outputs: options?.deploy?.outputs ?? ["{options.outputPath}"],
239
- executor: options?.deploy?.executor || `@${framework}/nx:${options?.deploy?.targetName || "deploy"}`,
240
- dependsOn: options?.deploy?.dependsOn ?? [
241
- `^${options?.deploy?.targetName || "deploy"}`,
242
- options?.build !== false && `${options?.build?.targetName || "build"}`,
243
- isDevelopment ? void 0 : isSetObject(options?.prepare) && options?.prepare?.targetName ? options?.prepare?.targetName : "prepare"
244
- ].filter(Boolean),
245
- defaultConfiguration: options?.deploy?.defaultConfiguration || "production",
246
- options: {
247
- projectType: projectConfig.projectType,
248
- configFile,
249
- outputPath: `{workspaceRoot}/${projectRoot}/dist`,
250
- copyPath: `{workspaceRoot}/dist/${projectRoot}`
251
- },
252
- configurations: {
253
- production: { mode: "production" },
254
- test: { mode: "test" },
255
- development: {
256
- mode: "development",
257
- skipCache: true
258
- }
259
- }
260
- };
261
- setDefaultProjectTags(projectConfig, name);
262
- addProjectTag(projectConfig, framework, projectConfig.projectType || "library", { overwrite: true });
263
- if (options?.verboseOutput) console.debug(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Completed preparing Nx configuration for project in root directory ${projectRoot}.`);
264
- return { projects: { [root]: defu(projectConfig, {
265
- projectType: projectConfig.projectType || "library",
266
- root,
267
- sourceRoot: joinPaths(root, "src"),
268
- targets
269
- }) } };
270
- } catch (error) {
271
- console.error(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Failed to process the project configuration for file "${configFile}" - ${isError(error) ? error.message : isSetString(error) ? error : "Unknown fatal error"}`);
272
- return {};
273
- }
274
- }, configFiles, options, contextV2);
275
- }];
276
- } catch (error) {
277
- console.error(`[${title}] - ${(/* @__PURE__ */ new Date()).toISOString()} - ${isError(error) ? error.message : isSetString(error) ? error : "Unknown fatal error during plugin initialization"}`);
278
- throw new Error(`Failed to initialize the ${title} - ${isError(error) ? error.message : isSetString(error) ? error : "See previous logs for more details"}`, { cause: error instanceof Error ? error : void 0 });
279
- }
280
- }
281
-
282
- //#endregion
283
3
  //#region src/plugin/index.ts
284
4
  const createNodesV2 = createNxPlugin({ framework: "powerlines" });
285
5