@powerlines/nx 0.10.22 → 0.10.24

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 (38) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/chunk-4QIKRF4D.mjs +339 -0
  3. package/dist/chunk-676DOF5H.js +347 -0
  4. package/dist/{chunk-JZFLLKX7.js → chunk-AQAUVXZI.js} +2 -2
  5. package/dist/{chunk-Z6JAOALZ.js → chunk-BGLSTX6F.js} +2 -2
  6. package/dist/{chunk-JFEKW6WO.mjs → chunk-ECQAG447.mjs} +1 -1
  7. package/dist/{chunk-7JI7SNPI.js → chunk-EYCHNX35.js} +2 -2
  8. package/dist/chunk-GFUZORW3.js +10 -0
  9. package/dist/{chunk-OY7HISJN.mjs → chunk-HJUENOPY.mjs} +3 -484
  10. package/dist/{chunk-C7YXZ6X3.mjs → chunk-JV366LTN.mjs} +1 -1
  11. package/dist/{chunk-SJ6WM4OK.js → chunk-N5IOYNUV.js} +2 -2
  12. package/dist/{chunk-NQA6VVBG.mjs → chunk-PNGMBVSP.mjs} +1 -1
  13. package/dist/{chunk-SBOWIOOS.js → chunk-PZGSOSV4.js} +2 -2
  14. package/dist/{chunk-IPVB7OAF.js → chunk-RAUJ3U2D.js} +2 -483
  15. package/dist/{chunk-XL4OPEOX.mjs → chunk-RCEEHPJE.mjs} +1 -1
  16. package/dist/chunk-SAVSMAFN.mjs +8 -0
  17. package/dist/{chunk-IZ2DVA7V.mjs → chunk-TSJZC5A3.mjs} +1 -1
  18. package/dist/executors.js +11 -11
  19. package/dist/executors.mjs +6 -6
  20. package/dist/index.js +18 -18
  21. package/dist/index.mjs +9 -9
  22. package/dist/src/base/base-executor.js +2 -2
  23. package/dist/src/base/base-executor.mjs +1 -1
  24. package/dist/src/executors/build/executor.js +4 -4
  25. package/dist/src/executors/build/executor.mjs +2 -2
  26. package/dist/src/executors/clean/executor.js +4 -4
  27. package/dist/src/executors/clean/executor.mjs +2 -2
  28. package/dist/src/executors/docs/executor.js +4 -4
  29. package/dist/src/executors/docs/executor.mjs +2 -2
  30. package/dist/src/executors/lint/executor.js +4 -4
  31. package/dist/src/executors/lint/executor.mjs +2 -2
  32. package/dist/src/executors/prepare/executor.js +4 -4
  33. package/dist/src/executors/prepare/executor.mjs +2 -2
  34. package/dist/src/helpers/plugin-utilities.js +5 -5
  35. package/dist/src/helpers/plugin-utilities.mjs +2 -2
  36. package/dist/src/plugin/index.js +4 -4
  37. package/dist/src/plugin/index.mjs +3 -3
  38. package/package.json +3 -3
@@ -0,0 +1,347 @@
1
+ 'use strict';
2
+
3
+ var chunkVIU4CXA3_js = require('./chunk-VIU4CXA3.js');
4
+ var chunkLTCZN4I4_js = require('./chunk-LTCZN4I4.js');
5
+ var chunkSHUYVCID_js = require('./chunk-SHUYVCID.js');
6
+ var devkit = require('@nx/devkit');
7
+ var nxJson = require('@storm-software/workspace-tools/utils/nx-json');
8
+ var pluginHelpers = require('@storm-software/workspace-tools/utils/plugin-helpers');
9
+ var projectTags = require('@storm-software/workspace-tools/utils/project-tags');
10
+ var getEnvPaths = require('@stryke/env/get-env-paths');
11
+ var exists = require('@stryke/fs/exists');
12
+ var murmurhash = require('@stryke/hash/murmurhash');
13
+ var joinPaths = require('@stryke/path/join-paths');
14
+ var kebabCase = require('@stryke/string-format/kebab-case');
15
+ var titleCase = require('@stryke/string-format/title-case');
16
+ var isError = require('@stryke/type-checks/is-error');
17
+ var defu = require('defu');
18
+ var jiti = require('jiti');
19
+ var promises = require('fs/promises');
20
+ var nxJson_js = require('nx/src/config/nx-json.js');
21
+ var packageJson_js = require('nx/src/utils/package-json.js');
22
+
23
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
24
+
25
+ var defu__default = /*#__PURE__*/_interopDefault(defu);
26
+
27
+ function getNxTargetInputs(framework) {
28
+ return chunkVIU4CXA3_js.CONFIG_INPUTS.map((input) => input.replace("{framework}", framework));
29
+ }
30
+ chunkSHUYVCID_js.__name(getNxTargetInputs, "getNxTargetInputs");
31
+ function getNxPluginInputs(framework) {
32
+ return `**/{${getNxTargetInputs(framework).map((input) => input.replace("{projectRoot}/", "")).join(",")}}`;
33
+ }
34
+ chunkSHUYVCID_js.__name(getNxPluginInputs, "getNxPluginInputs");
35
+ function createNxPlugin(opts) {
36
+ const framework = opts?.framework || "powerlines";
37
+ const name = opts?.name || `${framework}/nx/plugin`;
38
+ const artifactsFolder = opts?.artifactsFolder || `{projectRoot}/.${framework}`;
39
+ const targetInputs = getNxTargetInputs(framework);
40
+ const pluginInputs = getNxPluginInputs(framework);
41
+ console.debug(`[${name}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Initializing the ${titleCase.titleCase(framework)} Nx plugin for the following inputs: ${pluginInputs}`);
42
+ return [
43
+ pluginInputs,
44
+ async (configFiles, options, contextV2) => {
45
+ const envPaths = getEnvPaths.getEnvPaths({
46
+ orgId: "storm-software",
47
+ appId: framework,
48
+ workspaceRoot: contextV2.workspaceRoot
49
+ });
50
+ if (!envPaths.cache) {
51
+ throw new Error("The cache directory could not be determined.");
52
+ }
53
+ const nxJson$1 = nxJson_js.readNxJson(contextV2.workspaceRoot);
54
+ return devkit.createNodesFromFiles(async (configFile, _, context) => {
55
+ try {
56
+ const projectRoot = pluginHelpers.getProjectRoot(configFile, contextV2.workspaceRoot);
57
+ if (!projectRoot) {
58
+ console.error(`[${name}] - ${(/* @__PURE__ */ new Date()).toISOString()} - package.json and ${framework} configuration files (i.e. ${framework}.config.ts) must be located in the project root directory: ${configFile}`);
59
+ return {};
60
+ }
61
+ const root = pluginHelpers.getRoot(projectRoot, context);
62
+ const cacheDir = joinPaths.joinPaths(envPaths.cache, "nx-plugin", murmurhash.murmurhash(contextV2.workspaceRoot, {
63
+ maxLength: chunkLTCZN4I4_js.PROJECT_ROOT_HASH_LENGTH
64
+ }));
65
+ const jiti$1 = jiti.createJiti(joinPaths.joinPaths(contextV2.workspaceRoot, projectRoot), {
66
+ interopDefault: true,
67
+ fsCache: joinPaths.joinPaths(cacheDir, "jiti"),
68
+ moduleCache: true
69
+ });
70
+ console.debug(`[${name}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Loading ${framework} user configuration for project in root directory ${projectRoot}.`);
71
+ const userConfig = await chunkLTCZN4I4_js.loadUserConfigFile(joinPaths.joinPaths(contextV2.workspaceRoot, projectRoot), jiti$1, "build", "development", joinPaths.joinPaths(contextV2.workspaceRoot, configFile), framework);
72
+ if (!exists.existsSync(joinPaths.joinPaths(contextV2.workspaceRoot, projectRoot, "package.json"))) {
73
+ console.warn(`[${name}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Cannot find \`package.json\` file in the project's root directory (path: "${joinPaths.joinPaths(contextV2.workspaceRoot, projectRoot)}"). Skipping project configuration.`);
74
+ return {};
75
+ }
76
+ const packageJsonContent = await promises.readFile(joinPaths.joinPaths(contextV2.workspaceRoot, projectRoot, "package.json"), "utf8");
77
+ if (!packageJsonContent) {
78
+ console.warn(`[${name}] - ${(/* @__PURE__ */ new Date()).toISOString()} - No package.json file found for project in root directory ${projectRoot}`);
79
+ return {};
80
+ }
81
+ const packageJson = JSON.parse(packageJsonContent);
82
+ if (!userConfig.configFile && !packageJson?.storm) {
83
+ console.debug(`[${name}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Skipping ${projectRoot} - no ${framework} configuration found for project in root directory.`);
84
+ return {};
85
+ }
86
+ const projectConfig = pluginHelpers.getProjectConfigFromProjectRoot(projectRoot, packageJson);
87
+ if (!projectConfig) {
88
+ console.warn(`[${name}] - ${(/* @__PURE__ */ new Date()).toISOString()} - No project configuration found for project in root directory ${projectRoot}`);
89
+ return {};
90
+ }
91
+ const tsconfig = userConfig?.tsconfig || (exists.existsSync(joinPaths.joinPaths(projectRoot, "tsconfig.json")) ? joinPaths.joinPaths(projectRoot, "tsconfig.json") : void 0);
92
+ const targets = packageJson_js.readTargetsFromPackageJson(packageJson, nxJson$1, projectRoot, context.workspaceRoot);
93
+ console.debug(`[${name}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Preparing Nx targets for project in root directory ${projectRoot}.`);
94
+ if (options?.clean !== false && !targets[options?.clean?.targetName || "clean"]) {
95
+ targets[options?.clean?.targetName || "clean"] = {
96
+ inputs: Array.isArray(options?.clean?.inputs) ? options.clean.inputs : nxJson.withNamedInputs(targetInputs, [
97
+ options?.clean?.inputs || "typescript"
98
+ ]),
99
+ outputs: options?.clean?.outputs,
100
+ executor: options?.clean?.executor || `@${framework}/nx:${options?.clean?.targetName || "clean"}`,
101
+ dependsOn: [
102
+ `^${options?.clean?.targetName || "clean"}`
103
+ ],
104
+ defaultConfiguration: options?.clean?.defaultConfiguration || "production",
105
+ options: {
106
+ outputPath: userConfig.output?.outputPath || "dist/{projectRoot}",
107
+ projectType: projectConfig.projectType || userConfig.type,
108
+ skipInstalls: userConfig.skipInstalls
109
+ },
110
+ configurations: {
111
+ production: {
112
+ mode: "production"
113
+ },
114
+ test: {
115
+ mode: "test"
116
+ },
117
+ development: {
118
+ mode: "development",
119
+ skipCache: true
120
+ }
121
+ }
122
+ };
123
+ }
124
+ if (options?.prepare !== false && !targets[options?.prepare?.targetName || "prepare"]) {
125
+ targets[options?.prepare?.targetName || "prepare"] = {
126
+ cache: true,
127
+ inputs: Array.isArray(options?.prepare?.inputs) ? options.prepare.inputs : nxJson.withNamedInputs(targetInputs, [
128
+ options?.prepare?.inputs || "typescript"
129
+ ]),
130
+ outputs: options?.prepare?.outputs ?? [
131
+ artifactsFolder
132
+ ],
133
+ executor: options?.prepare?.executor || `@${framework}/nx:${options?.prepare?.targetName || "prepare"}`,
134
+ dependsOn: [
135
+ `^${options?.prepare?.targetName || "prepare"}`,
136
+ "clean"
137
+ ],
138
+ defaultConfiguration: options?.prepare?.defaultConfiguration || "production",
139
+ options: {
140
+ entry: userConfig.entry || "{sourceRoot}/index.ts",
141
+ projectType: projectConfig.projectType || userConfig.type,
142
+ tsconfig,
143
+ skipInstalls: userConfig.skipInstalls,
144
+ skipCache: userConfig.skipCache
145
+ },
146
+ configurations: {
147
+ production: {
148
+ mode: "production"
149
+ },
150
+ test: {
151
+ mode: "test"
152
+ },
153
+ development: {
154
+ mode: "development",
155
+ skipCache: true
156
+ }
157
+ }
158
+ };
159
+ }
160
+ if (options?.build !== false && !targets[options?.build?.targetName || "build"]) {
161
+ targets[options?.build?.targetName || "build"] = {
162
+ inputs: Array.isArray(options?.build?.inputs) ? options.build.inputs : nxJson.withNamedInputs(targetInputs, [
163
+ options?.build?.inputs || "typescript"
164
+ ]),
165
+ outputs: options?.build?.outputs ?? [
166
+ "{options.outputPath}"
167
+ ],
168
+ executor: options?.build?.executor || `@${framework}/nx:${options?.build?.targetName || "build"}`,
169
+ dependsOn: [
170
+ `^${options?.build?.targetName || "build"}`,
171
+ options?.prepare !== false && `^${options?.prepare?.targetName || "prepare"}`
172
+ ].filter(Boolean),
173
+ defaultConfiguration: options?.build?.defaultConfiguration || "production",
174
+ options: {
175
+ entry: userConfig.entry || "{sourceRoot}/index.ts",
176
+ outputPath: userConfig.output?.outputPath || "dist/{projectRoot}",
177
+ projectType: projectConfig.projectType || userConfig.type,
178
+ tsconfig,
179
+ skipInstalls: userConfig.skipInstalls,
180
+ skipCache: userConfig.skipCache
181
+ },
182
+ configurations: {
183
+ production: {
184
+ mode: "production"
185
+ },
186
+ test: {
187
+ mode: "test"
188
+ },
189
+ development: {
190
+ mode: "development",
191
+ skipCache: true
192
+ }
193
+ }
194
+ };
195
+ }
196
+ if (options?.lint !== false && !targets[options?.lint?.targetName || "lint"]) {
197
+ targets[options?.lint?.targetName || "lint"] = {
198
+ inputs: Array.isArray(options?.lint?.inputs) ? options.lint.inputs : nxJson.withNamedInputs([
199
+ ...targetInputs,
200
+ artifactsFolder
201
+ ], options?.lint?.inputs ? [
202
+ options.lint.inputs
203
+ ] : [
204
+ "linting",
205
+ "typescript"
206
+ ]),
207
+ outputs: options?.lint?.outputs ?? [
208
+ "{options.outputPath}"
209
+ ],
210
+ executor: options?.lint?.executor || `@${framework}/nx:${options?.lint?.targetName || "lint"}`,
211
+ dependsOn: [
212
+ `^${options?.lint?.targetName || "lint"}`,
213
+ options?.prepare !== false && `^${options?.prepare?.targetName || "prepare"}`
214
+ ].filter(Boolean),
215
+ defaultConfiguration: options?.lint?.defaultConfiguration || "production",
216
+ options: {
217
+ entry: userConfig.entry || "{sourceRoot}/index.ts",
218
+ projectType: projectConfig.projectType || userConfig.type,
219
+ tsconfig,
220
+ skipInstalls: userConfig.skipInstalls,
221
+ skipCache: userConfig.skipCache
222
+ },
223
+ configurations: {
224
+ production: {
225
+ mode: "production"
226
+ },
227
+ test: {
228
+ mode: "test"
229
+ },
230
+ development: {
231
+ mode: "development",
232
+ skipCache: true
233
+ }
234
+ }
235
+ };
236
+ }
237
+ if (options?.docs !== false && !targets[options?.docs?.targetName || "docs"]) {
238
+ targets[options?.docs?.targetName || "docs"] = {
239
+ inputs: Array.isArray(options?.docs?.inputs) ? options.docs.inputs : nxJson.withNamedInputs([
240
+ ...targetInputs,
241
+ artifactsFolder
242
+ ], options?.docs?.inputs ? [
243
+ options.docs.inputs
244
+ ] : [
245
+ "documentation",
246
+ "typescript"
247
+ ]),
248
+ outputs: options?.docs?.outputs ?? [
249
+ "{options.outputPath}"
250
+ ],
251
+ executor: options?.docs?.executor || `@${framework}/nx:${options?.docs?.targetName || "docs"}`,
252
+ dependsOn: [
253
+ `^${options?.docs?.targetName || "docs"}`,
254
+ options?.build !== false && `^${options?.build?.targetName || "build"}`
255
+ ].filter(Boolean),
256
+ defaultConfiguration: options?.docs?.defaultConfiguration || "production",
257
+ options: {
258
+ entry: userConfig.entry || "{sourceRoot}/index.ts",
259
+ projectType: projectConfig.projectType || userConfig.type,
260
+ tsconfig,
261
+ skipInstalls: userConfig.skipInstalls,
262
+ skipCache: userConfig.skipCache
263
+ },
264
+ configurations: {
265
+ production: {
266
+ mode: "production"
267
+ },
268
+ test: {
269
+ mode: "test"
270
+ },
271
+ development: {
272
+ mode: "development",
273
+ skipCache: true
274
+ }
275
+ }
276
+ };
277
+ }
278
+ if (options?.deploy !== false && !targets[options?.deploy?.targetName || "deploy"]) {
279
+ targets[options?.deploy?.targetName || "deploy"] = {
280
+ inputs: Array.isArray(options?.deploy?.inputs) ? options.deploy.inputs : nxJson.withNamedInputs([
281
+ ...targetInputs,
282
+ artifactsFolder
283
+ ], options?.deploy?.inputs ? [
284
+ options.deploy.inputs
285
+ ] : [
286
+ "documentation",
287
+ "typescript"
288
+ ]),
289
+ outputs: options?.deploy?.outputs ?? [
290
+ "{options.outputPath}"
291
+ ],
292
+ executor: options?.deploy?.executor || `@${framework}/nx:${options?.deploy?.targetName || "deploy"}`,
293
+ dependsOn: [
294
+ `^${options?.deploy?.targetName || "deploy"}`,
295
+ options?.build !== false && `^${options?.build?.targetName || "build"}`
296
+ ].filter(Boolean),
297
+ defaultConfiguration: options?.deploy?.defaultConfiguration || "production",
298
+ options: {
299
+ entry: userConfig.entry || "{sourceRoot}/index.ts",
300
+ projectType: projectConfig.projectType || userConfig.type,
301
+ tsconfig,
302
+ skipInstalls: userConfig.skipInstalls,
303
+ skipCache: userConfig.skipCache
304
+ },
305
+ configurations: {
306
+ production: {
307
+ mode: "production"
308
+ },
309
+ test: {
310
+ mode: "test"
311
+ },
312
+ development: {
313
+ mode: "development",
314
+ skipCache: true
315
+ }
316
+ }
317
+ };
318
+ }
319
+ projectTags.setDefaultProjectTags(projectConfig, name);
320
+ projectTags.addProjectTag(projectConfig, framework, projectConfig.projectType || userConfig.type || "library", {
321
+ overwrite: true
322
+ });
323
+ console.debug(`[${name}] - ${(/* @__PURE__ */ new Date()).toISOString()} - Completed preparing Nx configuration for project in root directory ${projectRoot}.`);
324
+ return {
325
+ projects: {
326
+ [root]: defu__default.default(projectConfig, {
327
+ name: kebabCase.kebabCase(userConfig.name),
328
+ projectType: userConfig.type || "library",
329
+ root,
330
+ sourceRoot: joinPaths.joinPaths(root, "src"),
331
+ targets
332
+ })
333
+ }
334
+ };
335
+ } catch (error) {
336
+ console.error(`[${name}] - ${(/* @__PURE__ */ new Date()).toISOString()} - ${isError.isError(error) ? error.message : "Unknown fatal error"}`);
337
+ return {};
338
+ }
339
+ }, configFiles, options, contextV2);
340
+ }
341
+ ];
342
+ }
343
+ chunkSHUYVCID_js.__name(createNxPlugin, "createNxPlugin");
344
+
345
+ exports.createNxPlugin = createNxPlugin;
346
+ exports.getNxPluginInputs = getNxPluginInputs;
347
+ exports.getNxTargetInputs = getNxTargetInputs;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkIPVB7OAF_js = require('./chunk-IPVB7OAF.js');
3
+ var chunkRAUJ3U2D_js = require('./chunk-RAUJ3U2D.js');
4
4
  var chunkSHUYVCID_js = require('./chunk-SHUYVCID.js');
5
5
 
6
6
  // src/executors/clean/executor.ts
@@ -11,7 +11,7 @@ async function executorFn(context, api) {
11
11
  };
12
12
  }
13
13
  chunkSHUYVCID_js.__name(executorFn, "executorFn");
14
- var executor = chunkIPVB7OAF_js.withExecutor("clean", executorFn);
14
+ var executor = chunkRAUJ3U2D_js.withExecutor("clean", executorFn);
15
15
  var executor_default = executor;
16
16
 
17
17
  exports.executorFn = executorFn;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkIPVB7OAF_js = require('./chunk-IPVB7OAF.js');
3
+ var chunkRAUJ3U2D_js = require('./chunk-RAUJ3U2D.js');
4
4
  var chunkSHUYVCID_js = require('./chunk-SHUYVCID.js');
5
5
 
6
6
  // src/executors/docs/executor.ts
@@ -11,7 +11,7 @@ async function executorFn(context, api) {
11
11
  };
12
12
  }
13
13
  chunkSHUYVCID_js.__name(executorFn, "executorFn");
14
- var executor = chunkIPVB7OAF_js.withExecutor("docs", executorFn);
14
+ var executor = chunkRAUJ3U2D_js.withExecutor("docs", executorFn);
15
15
  var executor_default = executor;
16
16
 
17
17
  exports.executorFn = executorFn;
@@ -1,4 +1,4 @@
1
- import { withExecutor } from './chunk-OY7HISJN.mjs';
1
+ import { withExecutor } from './chunk-HJUENOPY.mjs';
2
2
  import { __name } from './chunk-O6YSETKJ.mjs';
3
3
  import defu from 'defu';
4
4
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkIPVB7OAF_js = require('./chunk-IPVB7OAF.js');
3
+ var chunkRAUJ3U2D_js = require('./chunk-RAUJ3U2D.js');
4
4
  var chunkSHUYVCID_js = require('./chunk-SHUYVCID.js');
5
5
  var defu = require('defu');
6
6
 
@@ -19,7 +19,7 @@ async function executorFn(context, api) {
19
19
  };
20
20
  }
21
21
  chunkSHUYVCID_js.__name(executorFn, "executorFn");
22
- var executor = chunkIPVB7OAF_js.withExecutor("build", executorFn);
22
+ var executor = chunkRAUJ3U2D_js.withExecutor("build", executorFn);
23
23
  var executor_default = executor;
24
24
 
25
25
  exports.executorFn = executorFn;
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+
3
+ var chunk676DOF5H_js = require('./chunk-676DOF5H.js');
4
+
5
+ // src/plugin/index.ts
6
+ var createNodesV2 = chunk676DOF5H_js.createNxPlugin({
7
+ framework: "powerlines"
8
+ });
9
+
10
+ exports.createNodesV2 = createNodesV2;