nx 18.2.4 → 18.3.0-beta.1
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/bin/init-local.js +1 -1
- package/bin/post-install.js +7 -5
- package/package.json +12 -12
- package/src/adapter/angular-json.d.ts +2 -1
- package/src/adapter/angular-json.js +1 -0
- package/src/adapter/ngcli-adapter.js +3 -3
- package/src/command-line/generate/generator-utils.js +2 -2
- package/src/command-line/init/implementation/react/index.js +1 -1
- package/src/command-line/run/executor-utils.js +2 -2
- package/src/config/nx-json.d.ts +2 -1
- package/src/config/schema-utils.js +2 -2
- package/src/config/workspace-json-project-json.d.ts +16 -4
- package/src/daemon/server/plugins.d.ts +3 -0
- package/src/daemon/server/plugins.js +22 -0
- package/src/daemon/server/project-graph-incremental-recomputation.js +10 -9
- package/src/daemon/server/shutdown-utils.js +2 -0
- package/src/devkit-exports.d.ts +3 -2
- package/src/executors/run-commands/run-commands.impl.js +1 -1
- package/src/executors/utils/convert-nx-executor.js +4 -1
- package/src/generators/utils/project-configuration.js +2 -2
- package/src/migrations/update-15-1-0/set-project-names.js +4 -2
- package/src/native/assert-supported-platform.js +1 -1
- package/src/plugins/js/index.d.ts +1 -1
- package/src/plugins/js/lock-file/lock-file.d.ts +1 -1
- package/src/plugins/js/lock-file/npm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/pnpm-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +1 -1
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +1 -1
- package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
- package/src/plugins/package-json-workspaces/create-nodes.js +24 -31
- package/src/plugins/package-json-workspaces/index.d.ts +1 -0
- package/src/plugins/package-json-workspaces/index.js +2 -0
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +2 -1
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +1 -0
- package/src/plugins/project-json/build-nodes/project-json.d.ts +2 -1
- package/src/plugins/project-json/build-nodes/project-json.js +1 -0
- package/src/plugins/target-defaults/symbols.d.ts +17 -0
- package/src/plugins/target-defaults/symbols.js +20 -0
- package/src/plugins/target-defaults/target-defaults-plugin.d.ts +2 -18
- package/src/plugins/target-defaults/target-defaults-plugin.js +5 -20
- package/src/project-graph/affected/locators/project-glob-changes.js +3 -3
- package/src/project-graph/build-project-graph.d.ts +2 -1
- package/src/project-graph/build-project-graph.js +11 -13
- package/src/project-graph/error-types.d.ts +34 -0
- package/src/project-graph/error-types.js +65 -0
- package/src/project-graph/file-utils.js +3 -3
- package/src/project-graph/plugins/index.d.ts +2 -0
- package/src/project-graph/plugins/index.js +8 -0
- package/src/project-graph/plugins/internal-api.d.ts +28 -0
- package/src/project-graph/plugins/internal-api.js +85 -0
- package/src/project-graph/plugins/isolation/index.d.ts +3 -0
- package/src/project-graph/plugins/isolation/index.js +16 -0
- package/src/project-graph/plugins/isolation/messaging.d.ts +94 -0
- package/src/project-graph/plugins/isolation/messaging.js +23 -0
- package/src/project-graph/plugins/isolation/plugin-pool.d.ts +3 -0
- package/src/project-graph/plugins/isolation/plugin-pool.js +189 -0
- package/src/project-graph/plugins/isolation/plugin-worker.d.ts +1 -0
- package/src/project-graph/plugins/isolation/plugin-worker.js +81 -0
- package/src/project-graph/plugins/loader.d.ts +24 -0
- package/src/project-graph/plugins/loader.js +206 -0
- package/src/{utils/nx-plugin.d.ts → project-graph/plugins/public-api.d.ts} +8 -44
- package/src/project-graph/plugins/public-api.js +4 -0
- package/src/project-graph/plugins/utils.d.ts +7 -0
- package/src/project-graph/plugins/utils.js +88 -0
- package/src/project-graph/project-graph-builder.d.ts +1 -1
- package/src/project-graph/project-graph.d.ts +3 -2
- package/src/project-graph/project-graph.js +9 -7
- package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
- package/src/project-graph/utils/project-configuration-utils.d.ts +3 -26
- package/src/project-graph/utils/project-configuration-utils.js +89 -151
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +11 -10
- package/src/project-graph/utils/retrieve-workspace-files.js +18 -21
- package/src/tasks-runner/cache.js +1 -1
- package/src/utils/logger.d.ts +1 -0
- package/src/utils/logger.js +5 -0
- package/src/utils/nx-plugin.deprecated.d.ts +2 -2
- package/src/utils/nx-plugin.deprecated.js +5 -7
- package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
- package/src/utils/plugins/plugin-capabilities.js +18 -12
- package/src/utils/nx-plugin.js +0 -309
@@ -1,13 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.isCompatibleTarget = exports.mergeTargetConfigurations = exports.
|
3
|
+
exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.isCompatibleTarget = exports.mergeTargetConfigurations = exports.readProjectConfigurationsFromRootMap = exports.createProjectConfigurations = exports.mergeProjectConfigurationIntoRootMap = void 0;
|
4
4
|
const logger_1 = require("../../utils/logger");
|
5
5
|
const fileutils_1 = require("../../utils/fileutils");
|
6
6
|
const workspace_root_1 = require("../../utils/workspace-root");
|
7
|
-
const
|
7
|
+
const symbols_1 = require("../../plugins/target-defaults/symbols");
|
8
8
|
const minimatch_1 = require("minimatch");
|
9
9
|
const path_1 = require("path");
|
10
10
|
const perf_hooks_1 = require("perf_hooks");
|
11
|
+
const error_types_1 = require("../error-types");
|
11
12
|
function mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, sourceInformation,
|
12
13
|
// This function is used when reading project configuration
|
13
14
|
// in generators, where we don't want to do this.
|
@@ -104,6 +105,9 @@ skipCommandNormalization) {
|
|
104
105
|
}
|
105
106
|
}
|
106
107
|
}
|
108
|
+
if (project.metadata) {
|
109
|
+
updatedProjectConfiguration.metadata = mergeMetadata(sourceMap, sourceInformation, 'metadata', project.metadata, matchingProject.metadata);
|
110
|
+
}
|
107
111
|
if (project.targets) {
|
108
112
|
// We merge the targets with special handling, so clear this back to the
|
109
113
|
// targets as defined originally before merging.
|
@@ -116,12 +120,12 @@ skipCommandNormalization) {
|
|
116
120
|
// Always set source map info for the target, but don't overwrite info already there
|
117
121
|
// if augmenting an existing target.
|
118
122
|
const target = project.targets?.[targetName];
|
119
|
-
if (sourceMap && !target?.[
|
123
|
+
if (sourceMap && !target?.[symbols_1.ONLY_MODIFIES_EXISTING_TARGET]) {
|
120
124
|
sourceMap[`targets.${targetName}`] = sourceInformation;
|
121
125
|
}
|
122
126
|
// If ONLY_MODIFIES_EXISTING_TARGET is true, and its not on the matching project
|
123
127
|
// we shouldn't merge its info into the graph
|
124
|
-
if (target?.[
|
128
|
+
if (target?.[symbols_1.ONLY_MODIFIES_EXISTING_TARGET] &&
|
125
129
|
!matchingProject.targets?.[targetName]) {
|
126
130
|
continue;
|
127
131
|
}
|
@@ -129,73 +133,74 @@ skipCommandNormalization) {
|
|
129
133
|
? target
|
130
134
|
: resolveCommandSyntacticSugar(target, project.root), matchingProject.targets?.[targetName], sourceMap, sourceInformation, `targets.${targetName}`);
|
131
135
|
// We don't want the symbol to live on past the merge process
|
132
|
-
if (mergedTarget?.[
|
133
|
-
delete mergedTarget?.[
|
136
|
+
if (mergedTarget?.[symbols_1.ONLY_MODIFIES_EXISTING_TARGET])
|
137
|
+
delete mergedTarget?.[symbols_1.ONLY_MODIFIES_EXISTING_TARGET];
|
134
138
|
updatedProjectConfiguration.targets[targetName] = mergedTarget;
|
135
139
|
}
|
136
140
|
}
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
141
|
+
projectRootMap.set(updatedProjectConfiguration.root, updatedProjectConfiguration);
|
142
|
+
}
|
143
|
+
exports.mergeProjectConfigurationIntoRootMap = mergeProjectConfigurationIntoRootMap;
|
144
|
+
function mergeMetadata(sourceMap, sourceInformation, baseSourceMapPath, metadata, matchingMetadata) {
|
145
|
+
const result = {
|
146
|
+
...(matchingMetadata ?? {}),
|
147
|
+
};
|
148
|
+
for (const [metadataKey, value] of Object.entries(metadata)) {
|
149
|
+
const existingValue = matchingMetadata?.[metadataKey];
|
150
|
+
if (Array.isArray(value) && Array.isArray(existingValue)) {
|
151
|
+
for (const item of [...value]) {
|
152
|
+
const newLength = result[metadataKey].push(item);
|
153
|
+
if (sourceMap) {
|
154
|
+
sourceMap[`${baseSourceMapPath}.${metadataKey}.${newLength - 1}`] =
|
155
|
+
sourceInformation;
|
152
156
|
}
|
153
157
|
}
|
154
|
-
|
155
|
-
|
156
|
-
|
158
|
+
}
|
159
|
+
else if (Array.isArray(value) && existingValue === undefined) {
|
160
|
+
result[metadataKey] ??= value;
|
161
|
+
if (sourceMap) {
|
162
|
+
sourceMap[`${baseSourceMapPath}.${metadataKey}`] = sourceInformation;
|
163
|
+
}
|
164
|
+
for (let i = 0; i < value.length; i++) {
|
157
165
|
if (sourceMap) {
|
158
|
-
sourceMap[
|
159
|
-
|
160
|
-
for (let i = 0; i < value.length; i++) {
|
161
|
-
if (sourceMap) {
|
162
|
-
sourceMap[`metadata.${metadataKey}.${i}`] = sourceInformation;
|
163
|
-
}
|
166
|
+
sourceMap[`${baseSourceMapPath}.${metadataKey}.${i}`] =
|
167
|
+
sourceInformation;
|
164
168
|
}
|
165
169
|
}
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
if (sourceMap) {
|
174
|
-
sourceMap[`metadata.${metadataKey}.${key}.${i - 1}`] =
|
175
|
-
sourceInformation;
|
176
|
-
}
|
177
|
-
}
|
178
|
-
}
|
179
|
-
else {
|
180
|
-
updatedProjectConfiguration.metadata[metadataKey] = value;
|
170
|
+
}
|
171
|
+
else if (typeof value === 'object' && typeof existingValue === 'object') {
|
172
|
+
for (const key in value) {
|
173
|
+
const existingValue = matchingMetadata?.[metadataKey]?.[key];
|
174
|
+
if (Array.isArray(value[key]) && Array.isArray(existingValue)) {
|
175
|
+
for (const item of value[key]) {
|
176
|
+
const i = result[metadataKey][key].push(item);
|
181
177
|
if (sourceMap) {
|
182
|
-
sourceMap[
|
178
|
+
sourceMap[`${baseSourceMapPath}.${metadataKey}.${key}.${i - 1}`] =
|
179
|
+
sourceInformation;
|
183
180
|
}
|
184
181
|
}
|
185
182
|
}
|
183
|
+
else {
|
184
|
+
result[metadataKey] = value;
|
185
|
+
if (sourceMap) {
|
186
|
+
sourceMap[`${baseSourceMapPath}.${metadataKey}`] =
|
187
|
+
sourceInformation;
|
188
|
+
}
|
189
|
+
}
|
186
190
|
}
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
}
|
191
|
+
}
|
192
|
+
else {
|
193
|
+
result[metadataKey] = value;
|
194
|
+
if (sourceMap) {
|
195
|
+
sourceMap[`${baseSourceMapPath}.${metadataKey}`] = sourceInformation;
|
196
|
+
if (typeof value === 'object') {
|
197
|
+
for (const k in value) {
|
198
|
+
sourceMap[`${baseSourceMapPath}.${metadataKey}.${k}`] =
|
199
|
+
sourceInformation;
|
200
|
+
if (Array.isArray(value[k])) {
|
201
|
+
for (let i = 0; i < value[k].length; i++) {
|
202
|
+
sourceMap[`${baseSourceMapPath}.${metadataKey}.${k}.${i}`] =
|
203
|
+
sourceInformation;
|
199
204
|
}
|
200
205
|
}
|
201
206
|
}
|
@@ -203,9 +208,8 @@ skipCommandNormalization) {
|
|
203
208
|
}
|
204
209
|
}
|
205
210
|
}
|
206
|
-
|
211
|
+
return result;
|
207
212
|
}
|
208
|
-
exports.mergeProjectConfigurationIntoRootMap = mergeProjectConfigurationIntoRootMap;
|
209
213
|
/**
|
210
214
|
* Transforms a list of project paths into a map of project configurations.
|
211
215
|
*
|
@@ -214,21 +218,19 @@ exports.mergeProjectConfigurationIntoRootMap = mergeProjectConfigurationIntoRoot
|
|
214
218
|
* @param workspaceFiles A list of non-ignored workspace files
|
215
219
|
* @param plugins The plugins that should be used to infer project configuration
|
216
220
|
*/
|
217
|
-
function createProjectConfigurations(root = workspace_root_1.workspaceRoot, nxJson,
|
221
|
+
async function createProjectConfigurations(root = workspace_root_1.workspaceRoot, nxJson, projectFiles, // making this parameter allows devkit to pick up newly created projects
|
218
222
|
plugins) {
|
219
223
|
perf_hooks_1.performance.mark('build-project-configs:start');
|
220
224
|
const results = [];
|
221
225
|
const errors = [];
|
222
226
|
// We iterate over plugins first - this ensures that plugins specified first take precedence.
|
223
|
-
for (const {
|
224
|
-
const [pattern, createNodes] =
|
225
|
-
const pluginResults = [];
|
226
|
-
perf_hooks_1.performance.mark(`${plugin.name}:createNodes - start`);
|
227
|
+
for (const { name: pluginName, createNodes: createNodesTuple, include, exclude, } of plugins) {
|
228
|
+
const [pattern, createNodes] = createNodesTuple ?? [];
|
227
229
|
if (!pattern) {
|
228
230
|
continue;
|
229
231
|
}
|
230
232
|
const matchingConfigFiles = [];
|
231
|
-
for (const file of
|
233
|
+
for (const file of projectFiles) {
|
232
234
|
if ((0, minimatch_1.minimatch)(file, pattern, { dot: true })) {
|
233
235
|
if (include) {
|
234
236
|
const included = include.some((includedPattern) => (0, minimatch_1.minimatch)(file, includedPattern, { dot: true }));
|
@@ -237,7 +239,7 @@ plugins) {
|
|
237
239
|
}
|
238
240
|
}
|
239
241
|
if (exclude) {
|
240
|
-
const excluded =
|
242
|
+
const excluded = exclude.some((excludedPattern) => (0, minimatch_1.minimatch)(file, excludedPattern, { dot: true }));
|
241
243
|
if (excluded) {
|
242
244
|
continue;
|
243
245
|
}
|
@@ -245,56 +247,20 @@ plugins) {
|
|
245
247
|
matchingConfigFiles.push(file);
|
246
248
|
}
|
247
249
|
}
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
if (r instanceof Promise) {
|
257
|
-
pluginResults.push(r
|
258
|
-
.catch((error) => {
|
259
|
-
perf_hooks_1.performance.mark(`${plugin.name}:createNodes:${file} - end`);
|
260
|
-
errors.push(new CreateNodesError({
|
261
|
-
file,
|
262
|
-
pluginName: plugin.name,
|
263
|
-
error,
|
264
|
-
}));
|
265
|
-
return {
|
266
|
-
projects: {},
|
267
|
-
};
|
268
|
-
})
|
269
|
-
.then((r) => {
|
270
|
-
perf_hooks_1.performance.mark(`${plugin.name}:createNodes:${file} - end`);
|
271
|
-
perf_hooks_1.performance.measure(`${plugin.name}:createNodes:${file}`, `${plugin.name}:createNodes:${file} - start`, `${plugin.name}:createNodes:${file} - end`);
|
272
|
-
return { ...r, file, pluginName: plugin.name };
|
273
|
-
}));
|
274
|
-
}
|
275
|
-
else {
|
276
|
-
perf_hooks_1.performance.mark(`${plugin.name}:createNodes:${file} - end`);
|
277
|
-
perf_hooks_1.performance.measure(`${plugin.name}:createNodes:${file}`, `${plugin.name}:createNodes:${file} - start`, `${plugin.name}:createNodes:${file} - end`);
|
278
|
-
pluginResults.push({
|
279
|
-
...r,
|
280
|
-
file,
|
281
|
-
pluginName: plugin.name,
|
282
|
-
});
|
283
|
-
}
|
250
|
+
let r = createNodes(matchingConfigFiles, {
|
251
|
+
nxJsonConfiguration: nxJson,
|
252
|
+
workspaceRoot: root,
|
253
|
+
configFiles: matchingConfigFiles,
|
254
|
+
}).catch((e) => {
|
255
|
+
if ((0, error_types_1.isAggregateCreateNodesError)(e)) {
|
256
|
+
errors.push(...e.errors);
|
257
|
+
return e.partialResults;
|
284
258
|
}
|
285
|
-
|
286
|
-
|
287
|
-
file,
|
288
|
-
pluginName: plugin.name,
|
289
|
-
error,
|
290
|
-
}));
|
259
|
+
else {
|
260
|
+
throw e;
|
291
261
|
}
|
292
|
-
}
|
293
|
-
results.push(
|
294
|
-
perf_hooks_1.performance.mark(`${plugin.name}:createNodes - end`);
|
295
|
-
perf_hooks_1.performance.measure(`${plugin.name}:createNodes`, `${plugin.name}:createNodes - start`, `${plugin.name}:createNodes - end`);
|
296
|
-
return results;
|
297
|
-
}));
|
262
|
+
});
|
263
|
+
results.push(r);
|
298
264
|
}
|
299
265
|
return Promise.all(results).then((results) => {
|
300
266
|
perf_hooks_1.performance.mark('createNodes:merge - start');
|
@@ -304,8 +270,8 @@ plugins) {
|
|
304
270
|
for (const result of results.flat()) {
|
305
271
|
const { projects: projectNodes, externalNodes: pluginExternalNodes, file, pluginName, } = result;
|
306
272
|
const sourceInfo = [file, pluginName];
|
307
|
-
if (result[
|
308
|
-
sourceInfo[0] = result[
|
273
|
+
if (result[symbols_1.OVERRIDE_SOURCE_FILE]) {
|
274
|
+
sourceInfo[0] = result[symbols_1.OVERRIDE_SOURCE_FILE];
|
309
275
|
}
|
310
276
|
for (const node in projectNodes) {
|
311
277
|
const project = {
|
@@ -316,7 +282,7 @@ plugins) {
|
|
316
282
|
mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, sourceInfo);
|
317
283
|
}
|
318
284
|
catch (error) {
|
319
|
-
errors.push(new MergeNodesError({
|
285
|
+
errors.push(new error_types_1.MergeNodesError({
|
320
286
|
file,
|
321
287
|
pluginName,
|
322
288
|
error,
|
@@ -340,7 +306,7 @@ plugins) {
|
|
340
306
|
};
|
341
307
|
}
|
342
308
|
else {
|
343
|
-
throw new ProjectConfigurationsError(errors, {
|
309
|
+
throw new error_types_1.ProjectConfigurationsError(errors, {
|
344
310
|
projects,
|
345
311
|
externalNodes,
|
346
312
|
projectRootMap: rootMap,
|
@@ -392,37 +358,6 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
|
|
392
358
|
return projects;
|
393
359
|
}
|
394
360
|
exports.readProjectConfigurationsFromRootMap = readProjectConfigurationsFromRootMap;
|
395
|
-
class ProjectConfigurationsError extends Error {
|
396
|
-
constructor(errors, partialProjectConfigurationsResult) {
|
397
|
-
super('Failed to create project configurations');
|
398
|
-
this.errors = errors;
|
399
|
-
this.partialProjectConfigurationsResult = partialProjectConfigurationsResult;
|
400
|
-
this.name = this.constructor.name;
|
401
|
-
}
|
402
|
-
}
|
403
|
-
exports.ProjectConfigurationsError = ProjectConfigurationsError;
|
404
|
-
class CreateNodesError extends Error {
|
405
|
-
constructor({ file, pluginName, error, }) {
|
406
|
-
const msg = `The "${pluginName}" plugin threw an error while creating nodes from ${file}:`;
|
407
|
-
super(msg, { cause: error });
|
408
|
-
this.name = this.constructor.name;
|
409
|
-
this.file = file;
|
410
|
-
this.pluginName = pluginName;
|
411
|
-
this.stack = `${this.message}\n ${error.stack.split('\n').join('\n ')}`;
|
412
|
-
}
|
413
|
-
}
|
414
|
-
exports.CreateNodesError = CreateNodesError;
|
415
|
-
class MergeNodesError extends Error {
|
416
|
-
constructor({ file, pluginName, error, }) {
|
417
|
-
const msg = `The nodes created from ${file} by the "${pluginName}" could not be merged into the project graph:`;
|
418
|
-
super(msg, { cause: error });
|
419
|
-
this.name = this.constructor.name;
|
420
|
-
this.file = file;
|
421
|
-
this.pluginName = pluginName;
|
422
|
-
this.stack = `${this.message}\n ${error.stack.split('\n').join('\n ')}`;
|
423
|
-
}
|
424
|
-
}
|
425
|
-
exports.MergeNodesError = MergeNodesError;
|
426
361
|
/**
|
427
362
|
* Merges two targets.
|
428
363
|
*
|
@@ -445,7 +380,7 @@ function mergeTargetConfigurations(target, baseTarget, projectConfigSourceMap, s
|
|
445
380
|
// with the new one. However, we have a special case for targets that have the
|
446
381
|
// ONLY_MODIFIES_EXISTING_TARGET symbol set. This prevents the merged target
|
447
382
|
// equaling info that should have only been used to modify the existing target.
|
448
|
-
if (!isCompatible && target[
|
383
|
+
if (!isCompatible && target[symbols_1.ONLY_MODIFIES_EXISTING_TARGET]) {
|
449
384
|
return baseTarget;
|
450
385
|
}
|
451
386
|
if (!isCompatible && projectConfigSourceMap) {
|
@@ -481,6 +416,9 @@ function mergeTargetConfigurations(target, baseTarget, projectConfigSourceMap, s
|
|
481
416
|
if (target.configurations || defaultConfigurations) {
|
482
417
|
result.configurations = mergeConfigurations(target.configurations, isCompatible ? defaultConfigurations : undefined, projectConfigSourceMap, sourceInformation, targetIdentifier);
|
483
418
|
}
|
419
|
+
if (target.metadata) {
|
420
|
+
result.metadata = mergeMetadata(projectConfigSourceMap, sourceInformation, `${targetIdentifier}.metadata`, target.metadata, baseTarget?.metadata);
|
421
|
+
}
|
484
422
|
return result;
|
485
423
|
}
|
486
424
|
exports.mergeTargetConfigurations = mergeTargetConfigurations;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
2
2
|
import { NxJsonConfiguration } from '../../config/nx-json';
|
3
3
|
import { ConfigurationResult } from './project-configuration-utils';
|
4
|
-
import { LoadedNxPlugin } from '
|
4
|
+
import { LoadedNxPlugin } from '../plugins/internal-api';
|
5
5
|
/**
|
6
6
|
* Walks the workspace directory to create the `projectFileMap`, `ProjectConfigurations` and `allWorkspaceFiles`
|
7
7
|
* @throws
|
@@ -9,21 +9,22 @@ import { LoadedNxPlugin } from '../../utils/nx-plugin';
|
|
9
9
|
* @param nxJson
|
10
10
|
*/
|
11
11
|
export declare function retrieveWorkspaceFiles(workspaceRoot: string, projectRootMap: Record<string, string>): Promise<{
|
12
|
-
allWorkspaceFiles: import("
|
12
|
+
allWorkspaceFiles: import("../file-utils").FileData[];
|
13
13
|
fileMap: {
|
14
14
|
projectFileMap: ProjectFiles;
|
15
|
-
nonProjectFiles: import("
|
15
|
+
nonProjectFiles: import("../../native").FileData[];
|
16
16
|
};
|
17
|
-
rustReferences: import("
|
17
|
+
rustReferences: import("../../native").NxWorkspaceFilesExternals;
|
18
18
|
}>;
|
19
19
|
/**
|
20
20
|
* Walk through the workspace and return `ProjectConfigurations`. Only use this if the projectFileMap is not needed.
|
21
|
-
*
|
22
|
-
* @param workspaceRoot
|
23
|
-
* @param nxJson
|
24
21
|
*/
|
25
|
-
export declare function retrieveProjectConfigurations(workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<ConfigurationResult>;
|
22
|
+
export declare function retrieveProjectConfigurations(plugins: LoadedNxPlugin[], workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<ConfigurationResult>;
|
26
23
|
export declare function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<ConfigurationResult>;
|
27
|
-
export declare function retrieveProjectConfigurationPaths(root: string, plugins:
|
24
|
+
export declare function retrieveProjectConfigurationPaths(root: string, plugins: Array<{
|
25
|
+
createNodes?: readonly [string, ...unknown[]];
|
26
|
+
} & unknown>): string[];
|
28
27
|
export declare function retrieveProjectConfigurationsWithoutPluginInference(root: string): Promise<Record<string, ProjectConfiguration>>;
|
29
|
-
export declare function configurationGlobs(plugins:
|
28
|
+
export declare function configurationGlobs(plugins: Array<{
|
29
|
+
createNodes?: readonly [string, ...unknown[]];
|
30
|
+
}>): string[];
|
@@ -2,15 +2,13 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.configurationGlobs = exports.retrieveProjectConfigurationsWithoutPluginInference = exports.retrieveProjectConfigurationPaths = exports.retrieveProjectConfigurationsWithAngularProjects = exports.retrieveProjectConfigurations = exports.retrieveWorkspaceFiles = void 0;
|
4
4
|
const perf_hooks_1 = require("perf_hooks");
|
5
|
-
const installation_directory_1 = require("../../utils/installation-directory");
|
6
5
|
const angular_json_1 = require("../../adapter/angular-json");
|
7
6
|
const nx_json_1 = require("../../config/nx-json");
|
8
|
-
const package_json_workspaces_1 = require("../../plugins/package-json-workspaces");
|
9
7
|
const project_configuration_utils_1 = require("./project-configuration-utils");
|
10
|
-
const
|
11
|
-
const project_json_1 = require("../../plugins/project-json/build-nodes/project-json");
|
8
|
+
const internal_api_1 = require("../plugins/internal-api");
|
12
9
|
const workspace_context_1 = require("../../utils/workspace-context");
|
13
10
|
const build_all_workspace_files_1 = require("./build-all-workspace-files");
|
11
|
+
const path_1 = require("path");
|
14
12
|
/**
|
15
13
|
* Walks the workspace directory to create the `projectFileMap`, `ProjectConfigurations` and `allWorkspaceFiles`
|
16
14
|
* @throws
|
@@ -37,22 +35,23 @@ async function retrieveWorkspaceFiles(workspaceRoot, projectRootMap) {
|
|
37
35
|
exports.retrieveWorkspaceFiles = retrieveWorkspaceFiles;
|
38
36
|
/**
|
39
37
|
* Walk through the workspace and return `ProjectConfigurations`. Only use this if the projectFileMap is not needed.
|
40
|
-
*
|
41
|
-
* @param workspaceRoot
|
42
|
-
* @param nxJson
|
43
38
|
*/
|
44
|
-
async function retrieveProjectConfigurations(workspaceRoot, nxJson) {
|
45
|
-
const
|
46
|
-
return
|
39
|
+
async function retrieveProjectConfigurations(plugins, workspaceRoot, nxJson) {
|
40
|
+
const projects = await _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins);
|
41
|
+
return projects;
|
47
42
|
}
|
48
43
|
exports.retrieveProjectConfigurations = retrieveProjectConfigurations;
|
49
44
|
async function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, nxJson) {
|
50
|
-
const
|
45
|
+
const pluginsToLoad = nxJson?.plugins ?? [];
|
51
46
|
if ((0, angular_json_1.shouldMergeAngularProjects)(workspaceRoot, true) &&
|
52
|
-
!
|
53
|
-
|
47
|
+
!pluginsToLoad.some((p) => p === angular_json_1.NX_ANGULAR_JSON_PLUGIN_NAME ||
|
48
|
+
(typeof p === 'object' && p.plugin === angular_json_1.NX_ANGULAR_JSON_PLUGIN_NAME))) {
|
49
|
+
pluginsToLoad.push((0, path_1.join)(__dirname, '../../adapter/angular-json'));
|
54
50
|
}
|
55
|
-
|
51
|
+
const [plugins, cleanup] = await (0, internal_api_1.loadNxPlugins)(nxJson?.plugins ?? [], workspaceRoot);
|
52
|
+
const res = _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins);
|
53
|
+
cleanup();
|
54
|
+
return res;
|
56
55
|
}
|
57
56
|
exports.retrieveProjectConfigurationsWithAngularProjects = retrieveProjectConfigurationsWithAngularProjects;
|
58
57
|
function _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins) {
|
@@ -69,25 +68,23 @@ const projectsWithoutPluginCache = new Map();
|
|
69
68
|
// TODO: This function is called way too often, it should be optimized without this cache
|
70
69
|
async function retrieveProjectConfigurationsWithoutPluginInference(root) {
|
71
70
|
const nxJson = (0, nx_json_1.readNxJson)(root);
|
72
|
-
const plugins = await (0,
|
71
|
+
const [plugins, cleanup] = await (0, internal_api_1.loadNxPlugins)([]); // only load default plugins
|
73
72
|
const projectGlobPatterns = retrieveProjectConfigurationPaths(root, plugins);
|
74
73
|
const cacheKey = root + ',' + projectGlobPatterns.join(',');
|
75
74
|
if (projectsWithoutPluginCache.has(cacheKey)) {
|
76
75
|
return projectsWithoutPluginCache.get(cacheKey);
|
77
76
|
}
|
78
77
|
const projectFiles = (0, workspace_context_1.globWithWorkspaceContext)(root, projectGlobPatterns) ?? [];
|
79
|
-
const { projects } = await (0, project_configuration_utils_1.createProjectConfigurations)(root, nxJson, projectFiles,
|
80
|
-
{ plugin: (0, package_json_workspaces_1.getNxPackageJsonWorkspacesPlugin)(root) },
|
81
|
-
{ plugin: project_json_1.ProjectJsonProjectsPlugin },
|
82
|
-
]);
|
78
|
+
const { projects } = await (0, project_configuration_utils_1.createProjectConfigurations)(root, nxJson, projectFiles, plugins);
|
83
79
|
projectsWithoutPluginCache.set(cacheKey, projects);
|
80
|
+
cleanup();
|
84
81
|
return projects;
|
85
82
|
}
|
86
83
|
exports.retrieveProjectConfigurationsWithoutPluginInference = retrieveProjectConfigurationsWithoutPluginInference;
|
87
84
|
function configurationGlobs(plugins) {
|
88
85
|
const globPatterns = [];
|
89
|
-
for (const
|
90
|
-
if (plugin.createNodes) {
|
86
|
+
for (const plugin of plugins) {
|
87
|
+
if ('createNodes' in plugin && plugin.createNodes) {
|
91
88
|
globPatterns.push(plugin.createNodes[0]);
|
92
89
|
}
|
93
90
|
}
|
@@ -197,7 +197,7 @@ class Cache {
|
|
197
197
|
`The local cache artifact in "${td}" was not generated on this machine.`,
|
198
198
|
`As a result, the cache's content integrity cannot be confirmed, which may make cache restoration potentially unsafe.`,
|
199
199
|
`If your machine ID has changed since the artifact was cached, run "nx reset" to fix this issue.`,
|
200
|
-
`Read about the error and how to address it here: https://nx.dev/
|
200
|
+
`Read about the error and how to address it here: https://nx.dev/troubleshooting/unknown-local-cache`,
|
201
201
|
``,
|
202
202
|
].join('\n');
|
203
203
|
throw new Error(error);
|
package/src/utils/logger.d.ts
CHANGED
package/src/utils/logger.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { ProjectGraphProcessor } from '../config/project-graph';
|
2
2
|
import { TargetConfiguration } from '../config/workspace-json-project-json';
|
3
|
-
import {
|
3
|
+
import { NxPluginV2 } from '../project-graph/plugins';
|
4
4
|
/**
|
5
5
|
* @deprecated Add targets to the projects in a {@link CreateNodes} function instead. This will be removed in Nx 19
|
6
6
|
*/
|
@@ -28,4 +28,4 @@ export type NxPluginV1 = {
|
|
28
28
|
/**
|
29
29
|
* @todo(@agentender) v19: Remove this fn when we remove readWorkspaceConfig
|
30
30
|
*/
|
31
|
-
export declare function getDefaultPluginsSync(root: string):
|
31
|
+
export declare function getDefaultPluginsSync(root: string): NxPluginV2[];
|
@@ -4,7 +4,7 @@ exports.getDefaultPluginsSync = void 0;
|
|
4
4
|
const angular_json_1 = require("../adapter/angular-json");
|
5
5
|
const project_json_1 = require("../plugins/project-json/build-nodes/project-json");
|
6
6
|
const target_defaults_plugin_1 = require("../plugins/target-defaults/target-defaults-plugin");
|
7
|
-
const
|
7
|
+
const PackageJsonWorkspacesPlugin = require("../plugins/package-json-workspaces");
|
8
8
|
/**
|
9
9
|
* @todo(@agentender) v19: Remove this fn when we remove readWorkspaceConfig
|
10
10
|
*/
|
@@ -14,12 +14,10 @@ function getDefaultPluginsSync(root) {
|
|
14
14
|
...((0, angular_json_1.shouldMergeAngularProjects)(root, false)
|
15
15
|
? [require('../adapter/angular-json').NxAngularJsonPlugin]
|
16
16
|
: []),
|
17
|
-
target_defaults_plugin_1.
|
18
|
-
|
19
|
-
project_json_1.
|
17
|
+
target_defaults_plugin_1.default,
|
18
|
+
PackageJsonWorkspacesPlugin,
|
19
|
+
project_json_1.default,
|
20
20
|
];
|
21
|
-
return plugins
|
22
|
-
plugin: p,
|
23
|
-
}));
|
21
|
+
return plugins;
|
24
22
|
}
|
25
23
|
exports.getDefaultPluginsSync = getDefaultPluginsSync;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { PluginCapabilities } from './models';
|
2
1
|
import { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
2
|
+
import type { PluginCapabilities } from './models';
|
3
3
|
export declare function getPluginCapabilities(workspaceRoot: string, pluginName: string, projects: Record<string, ProjectConfiguration>, includeRuntimeCapabilities?: boolean): Promise<PluginCapabilities | null>;
|
4
4
|
export declare function listPluginCapabilities(pluginName: string, projects: Record<string, ProjectConfiguration>): Promise<void>;
|
@@ -1,15 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.listPluginCapabilities = exports.getPluginCapabilities = void 0;
|
4
|
-
const workspace_root_1 = require("../workspace-root");
|
5
4
|
const chalk = require("chalk");
|
6
5
|
const path_1 = require("path");
|
7
|
-
const
|
8
|
-
const
|
6
|
+
const plugins_1 = require("../../project-graph/plugins");
|
7
|
+
const loader_1 = require("../../project-graph/plugins/loader");
|
9
8
|
const fileutils_1 = require("../fileutils");
|
10
|
-
const package_manager_1 = require("../package-manager");
|
11
|
-
const nx_plugin_1 = require("../nx-plugin");
|
12
9
|
const installation_directory_1 = require("../installation-directory");
|
10
|
+
const output_1 = require("../output");
|
11
|
+
const package_manager_1 = require("../package-manager");
|
12
|
+
const workspace_root_1 = require("../workspace-root");
|
13
|
+
const shared_1 = require("./shared");
|
13
14
|
function tryGetCollection(packageJsonPath, collectionFile, propName) {
|
14
15
|
if (!collectionFile) {
|
15
16
|
return null;
|
@@ -24,9 +25,9 @@ function tryGetCollection(packageJsonPath, collectionFile, propName) {
|
|
24
25
|
}
|
25
26
|
async function getPluginCapabilities(workspaceRoot, pluginName, projects, includeRuntimeCapabilities = false) {
|
26
27
|
try {
|
27
|
-
const { json: packageJson, path: packageJsonPath } = await (0,
|
28
|
+
const { json: packageJson, path: packageJsonPath } = await (0, plugins_1.readPluginPackageJson)(pluginName, projects, (0, installation_directory_1.getNxRequirePaths)(workspaceRoot));
|
28
29
|
const pluginModule = includeRuntimeCapabilities
|
29
|
-
? await tryGetModule(packageJson, workspaceRoot
|
30
|
+
? await tryGetModule(packageJson, workspaceRoot)
|
30
31
|
: {};
|
31
32
|
return {
|
32
33
|
name: pluginName,
|
@@ -56,17 +57,22 @@ async function getPluginCapabilities(workspaceRoot, pluginName, projects, includ
|
|
56
57
|
}
|
57
58
|
}
|
58
59
|
exports.getPluginCapabilities = getPluginCapabilities;
|
59
|
-
async function tryGetModule(packageJson, workspaceRoot
|
60
|
+
async function tryGetModule(packageJson, workspaceRoot) {
|
60
61
|
try {
|
61
|
-
|
62
|
+
if (packageJson.generators ??
|
62
63
|
packageJson.executors ??
|
63
64
|
packageJson['nx-migrations'] ??
|
64
65
|
packageJson['schematics'] ??
|
65
|
-
packageJson['builders'])
|
66
|
-
|
67
|
-
|
66
|
+
packageJson['builders']) {
|
67
|
+
const [pluginPromise] = (0, loader_1.loadNxPlugin)(packageJson.name, workspaceRoot);
|
68
|
+
const plugin = await pluginPromise;
|
69
|
+
return plugin;
|
70
|
+
}
|
71
|
+
else {
|
72
|
+
return {
|
68
73
|
name: packageJson.name,
|
69
74
|
};
|
75
|
+
}
|
70
76
|
}
|
71
77
|
catch {
|
72
78
|
return null;
|