nx 18.3.0-canary.20240412-d1584f8 → 18.3.0-canary.20240416-2ee9650
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/package.json +12 -12
- package/src/command-line/init/implementation/add-nx-to-monorepo.js +1 -1
- package/src/command-line/init/implementation/add-nx-to-npm-repo.js +1 -1
- package/src/command-line/init/implementation/utils.d.ts +1 -1
- package/src/command-line/init/implementation/utils.js +2 -7
- package/src/command-line/init/init-v2.js +29 -37
- package/src/command-line/release/command-object.js +1 -1
- package/src/devkit-internals.d.ts +3 -0
- package/src/devkit-internals.js +7 -1
- package/src/project-graph/error-types.d.ts +13 -2
- package/src/project-graph/error-types.js +36 -1
- package/src/project-graph/plugins/utils.js +12 -20
- package/src/project-graph/project-graph.d.ts +3 -3
- package/src/project-graph/utils/project-configuration-utils.js +25 -12
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +3 -3
- package/src/project-graph/utils/retrieve-workspace-files.js +5 -9
- package/src/utils/is-ci.js +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "18.3.0-canary.
|
3
|
+
"version": "18.3.0-canary.20240416-2ee9650",
|
4
4
|
"private": false,
|
5
5
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
6
6
|
"repository": {
|
@@ -66,7 +66,7 @@
|
|
66
66
|
"yargs-parser": "21.1.1",
|
67
67
|
"node-machine-id": "1.1.12",
|
68
68
|
"ora": "5.3.0",
|
69
|
-
"@nrwl/tao": "18.3.0-canary.
|
69
|
+
"@nrwl/tao": "18.3.0-canary.20240416-2ee9650"
|
70
70
|
},
|
71
71
|
"peerDependencies": {
|
72
72
|
"@swc-node/register": "^1.8.0",
|
@@ -81,16 +81,16 @@
|
|
81
81
|
}
|
82
82
|
},
|
83
83
|
"optionalDependencies": {
|
84
|
-
"@nx/nx-darwin-x64": "18.3.0-canary.
|
85
|
-
"@nx/nx-darwin-arm64": "18.3.0-canary.
|
86
|
-
"@nx/nx-linux-x64-gnu": "18.3.0-canary.
|
87
|
-
"@nx/nx-linux-x64-musl": "18.3.0-canary.
|
88
|
-
"@nx/nx-win32-x64-msvc": "18.3.0-canary.
|
89
|
-
"@nx/nx-linux-arm64-gnu": "18.3.0-canary.
|
90
|
-
"@nx/nx-linux-arm64-musl": "18.3.0-canary.
|
91
|
-
"@nx/nx-linux-arm-gnueabihf": "18.3.0-canary.
|
92
|
-
"@nx/nx-win32-arm64-msvc": "18.3.0-canary.
|
93
|
-
"@nx/nx-freebsd-x64": "18.3.0-canary.
|
84
|
+
"@nx/nx-darwin-x64": "18.3.0-canary.20240416-2ee9650",
|
85
|
+
"@nx/nx-darwin-arm64": "18.3.0-canary.20240416-2ee9650",
|
86
|
+
"@nx/nx-linux-x64-gnu": "18.3.0-canary.20240416-2ee9650",
|
87
|
+
"@nx/nx-linux-x64-musl": "18.3.0-canary.20240416-2ee9650",
|
88
|
+
"@nx/nx-win32-x64-msvc": "18.3.0-canary.20240416-2ee9650",
|
89
|
+
"@nx/nx-linux-arm64-gnu": "18.3.0-canary.20240416-2ee9650",
|
90
|
+
"@nx/nx-linux-arm64-musl": "18.3.0-canary.20240416-2ee9650",
|
91
|
+
"@nx/nx-linux-arm-gnueabihf": "18.3.0-canary.20240416-2ee9650",
|
92
|
+
"@nx/nx-win32-arm64-msvc": "18.3.0-canary.20240416-2ee9650",
|
93
|
+
"@nx/nx-freebsd-x64": "18.3.0-canary.20240416-2ee9650"
|
94
94
|
},
|
95
95
|
"nx-migrations": {
|
96
96
|
"migrations": "./migrations.json",
|
@@ -63,7 +63,7 @@ async function addNxToMonorepo(options) {
|
|
63
63
|
(0, utils_1.createNxJsonFile)(repoRoot, targetDefaults, cacheableOperations, scriptOutputs);
|
64
64
|
if (!options.legacy) {
|
65
65
|
packageJsonFiles.forEach((packageJsonPath) => {
|
66
|
-
(0, utils_1.markPackageJsonAsNxProject)((0, path_1.join)(repoRoot, packageJsonPath)
|
66
|
+
(0, utils_1.markPackageJsonAsNxProject)((0, path_1.join)(repoRoot, packageJsonPath));
|
67
67
|
});
|
68
68
|
}
|
69
69
|
(0, utils_1.updateGitIgnore)(repoRoot);
|
@@ -57,7 +57,7 @@ async function addNxToNpmRepo(options) {
|
|
57
57
|
(0, utils_1.markRootPackageJsonAsNxProjectLegacy)(repoRoot, cacheableOperations, pmc);
|
58
58
|
}
|
59
59
|
else {
|
60
|
-
(0, utils_1.markPackageJsonAsNxProject)((0, path_1.join)(repoRoot, 'package.json')
|
60
|
+
(0, utils_1.markPackageJsonAsNxProject)((0, path_1.join)(repoRoot, 'package.json'));
|
61
61
|
}
|
62
62
|
output_1.output.log({ title: '📦 Installing dependencies' });
|
63
63
|
(0, utils_1.runInstall)(repoRoot, pmc);
|
@@ -9,7 +9,7 @@ export declare function runInstall(repoRoot: string, pmc?: PackageManagerCommand
|
|
9
9
|
export declare function initCloud(repoRoot: string, installationSource: 'nx-init-angular' | 'nx-init-cra' | 'nx-init-monorepo' | 'nx-init-nest' | 'nx-init-npm-repo'): void;
|
10
10
|
export declare function addVsCodeRecommendedExtensions(repoRoot: string, extensions: string[]): void;
|
11
11
|
export declare function markRootPackageJsonAsNxProjectLegacy(repoRoot: string, cacheableScripts: string[], pmc: PackageManagerCommands): void;
|
12
|
-
export declare function markPackageJsonAsNxProject(packageJsonPath: string
|
12
|
+
export declare function markPackageJsonAsNxProject(packageJsonPath: string): void;
|
13
13
|
export declare function printFinalMessage({ learnMoreLink, bodyLines, }: {
|
14
14
|
learnMoreLink?: string;
|
15
15
|
bodyLines?: string[];
|
@@ -154,17 +154,12 @@ function markRootPackageJsonAsNxProjectLegacy(repoRoot, cacheableScripts, pmc) {
|
|
154
154
|
(0, fileutils_1.writeJsonFile)(`package.json`, json);
|
155
155
|
}
|
156
156
|
exports.markRootPackageJsonAsNxProjectLegacy = markRootPackageJsonAsNxProjectLegacy;
|
157
|
-
function markPackageJsonAsNxProject(packageJsonPath
|
157
|
+
function markPackageJsonAsNxProject(packageJsonPath) {
|
158
158
|
const json = (0, fileutils_1.readJsonFile)(packageJsonPath);
|
159
159
|
if (!json.scripts) {
|
160
160
|
return;
|
161
161
|
}
|
162
|
-
json.nx = {
|
163
|
-
for (let script of cacheableScripts) {
|
164
|
-
if (json.scripts[script]) {
|
165
|
-
json.nx.includedScripts.push(script);
|
166
|
-
}
|
167
|
-
}
|
162
|
+
json.nx = {};
|
168
163
|
(0, fileutils_1.writeJsonFile)(packageJsonPath, json);
|
169
164
|
}
|
170
165
|
exports.markPackageJsonAsNxProject = markPackageJsonAsNxProject;
|
@@ -17,7 +17,6 @@ const workspace_context_1 = require("../../utils/workspace-context");
|
|
17
17
|
const connect_to_nx_cloud_1 = require("../connect/connect-to-nx-cloud");
|
18
18
|
const add_nx_to_npm_repo_1 = require("./implementation/add-nx-to-npm-repo");
|
19
19
|
const add_nx_to_monorepo_1 = require("./implementation/add-nx-to-monorepo");
|
20
|
-
const path_1 = require("path");
|
21
20
|
async function initHandler(options) {
|
22
21
|
process.env.NX_RUNNING_NX_INIT = 'true';
|
23
22
|
const version = process.env.NX_VERSION ?? ((0, semver_1.prerelease)(versions_1.nxVersion) ? 'next' : 'latest');
|
@@ -52,29 +51,29 @@ async function initHandler(options) {
|
|
52
51
|
}
|
53
52
|
output_1.output.log({ title: '🧐 Checking dependencies' });
|
54
53
|
const { plugins, updatePackageScripts } = await detectPlugins();
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
}
|
62
|
-
else {
|
63
|
-
await (0, add_nx_to_npm_repo_1.addNxToNpmRepo)({ interactive: options.interactive });
|
64
|
-
}
|
54
|
+
const packageJson = (0, fileutils_1.readJsonFile)('package.json');
|
55
|
+
if ((0, utils_1.isMonorepo)(packageJson)) {
|
56
|
+
await (0, add_nx_to_monorepo_1.addNxToMonorepo)({
|
57
|
+
interactive: options.interactive,
|
58
|
+
nxCloud: false,
|
59
|
+
});
|
65
60
|
}
|
66
61
|
else {
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
(0,
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
62
|
+
await (0, add_nx_to_npm_repo_1.addNxToNpmRepo)({
|
63
|
+
interactive: options.interactive,
|
64
|
+
nxCloud: false,
|
65
|
+
});
|
66
|
+
}
|
67
|
+
const useNxCloud = options.nxCloud ??
|
68
|
+
(options.interactive ? await (0, connect_to_nx_cloud_1.connectExistingRepoToNxCloudPrompt)() : false);
|
69
|
+
const repoRoot = process.cwd();
|
70
|
+
const pmc = (0, package_manager_1.getPackageManagerCommand)();
|
71
|
+
(0, utils_1.createNxJsonFile)(repoRoot, [], [], {});
|
72
|
+
(0, utils_1.updateGitIgnore)(repoRoot);
|
73
|
+
(0, utils_1.addDepsToPackageJson)(repoRoot, plugins);
|
74
|
+
output_1.output.log({ title: '📦 Installing Nx' });
|
75
|
+
(0, utils_1.runInstall)(repoRoot, pmc);
|
76
|
+
if (plugins.length > 0) {
|
78
77
|
output_1.output.log({ title: '🔨 Configuring plugins' });
|
79
78
|
for (const plugin of plugins) {
|
80
79
|
(0, child_process_2.execSync)(`${pmc.exec} nx g ${plugin}:init --keepExistingVersions ${updatePackageScripts ? '--updatePackageScripts' : ''} --no-interactive`, {
|
@@ -82,19 +81,13 @@ async function initHandler(options) {
|
|
82
81
|
cwd: repoRoot,
|
83
82
|
});
|
84
83
|
}
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
output_1.output.log({ title: '🛠️ Setting up Nx Cloud' });
|
93
|
-
(0, child_process_2.execSync)(`${pmc.exec} nx g nx:connect-to-nx-cloud --installationSource=nx-init --quiet --hideFormatLogs --no-interactive`, {
|
94
|
-
stdio: [0, 1, 2],
|
95
|
-
cwd: repoRoot,
|
96
|
-
});
|
97
|
-
}
|
84
|
+
}
|
85
|
+
if (useNxCloud) {
|
86
|
+
output_1.output.log({ title: '🛠️ Setting up Nx Cloud' });
|
87
|
+
(0, child_process_2.execSync)(`${pmc.exec} nx g nx:connect-to-nx-cloud --installationSource=nx-init --quiet --hideFormatLogs --no-interactive`, {
|
88
|
+
stdio: [0, 1, 2],
|
89
|
+
cwd: repoRoot,
|
90
|
+
});
|
98
91
|
}
|
99
92
|
output_1.output.log({
|
100
93
|
title: '👀 Explore Your Workspace',
|
@@ -170,9 +163,8 @@ async function detectPlugins() {
|
|
170
163
|
{
|
171
164
|
name: 'plugins',
|
172
165
|
type: 'multiselect',
|
173
|
-
message: `Which plugins would you like to add
|
166
|
+
message: `Which plugins would you like to add? Press <Space> to select and <Enter> to submit.`,
|
174
167
|
choices: plugins.map((p) => ({ name: p, value: p })),
|
175
|
-
initial: plugins.map((_, i) => i), // casting to avoid type error due to bad d.ts file from enquirer
|
176
168
|
},
|
177
169
|
]).then((r) => r.plugins);
|
178
170
|
if (pluginsToInstall?.length === 0)
|
@@ -107,7 +107,7 @@ const versionCommand = {
|
|
107
107
|
})
|
108
108
|
.option('preid', {
|
109
109
|
type: 'string',
|
110
|
-
describe: 'The optional prerelease identifier to apply to the version, in the case that specifier has been set to prerelease
|
110
|
+
describe: 'The optional prerelease identifier to apply to the version, in the case that the specifier argument has been set to `prerelease`.',
|
111
111
|
default: '',
|
112
112
|
})
|
113
113
|
.option('stage-changes', {
|
@@ -17,4 +17,7 @@ export { splitByColons } from './utils/split-target';
|
|
17
17
|
export { hashObject } from './hasher/file-hasher';
|
18
18
|
export { hashWithWorkspaceContext } from './utils/workspace-context';
|
19
19
|
export { createProjectRootMappingsFromProjectConfigurations, findProjectForPath, } from './project-graph/utils/find-project-for-path';
|
20
|
+
export { retrieveProjectConfigurations } from './project-graph/utils/retrieve-workspace-files';
|
21
|
+
export { LoadedNxPlugin } from './project-graph/plugins/internal-api';
|
22
|
+
export * from './project-graph/error-types';
|
20
23
|
export { registerTsProject } from './plugins/js/utils/register';
|
package/src/devkit-internals.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.registerTsProject = exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
|
3
|
+
exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
4
5
|
/**
|
5
6
|
* Note to developers: STOP! These exports are available via requireNx in @nx/devkit.
|
6
7
|
*
|
@@ -35,5 +36,10 @@ Object.defineProperty(exports, "hashWithWorkspaceContext", { enumerable: true, g
|
|
35
36
|
var find_project_for_path_1 = require("./project-graph/utils/find-project-for-path");
|
36
37
|
Object.defineProperty(exports, "createProjectRootMappingsFromProjectConfigurations", { enumerable: true, get: function () { return find_project_for_path_1.createProjectRootMappingsFromProjectConfigurations; } });
|
37
38
|
Object.defineProperty(exports, "findProjectForPath", { enumerable: true, get: function () { return find_project_for_path_1.findProjectForPath; } });
|
39
|
+
var retrieve_workspace_files_2 = require("./project-graph/utils/retrieve-workspace-files");
|
40
|
+
Object.defineProperty(exports, "retrieveProjectConfigurations", { enumerable: true, get: function () { return retrieve_workspace_files_2.retrieveProjectConfigurations; } });
|
41
|
+
var internal_api_1 = require("./project-graph/plugins/internal-api");
|
42
|
+
Object.defineProperty(exports, "LoadedNxPlugin", { enumerable: true, get: function () { return internal_api_1.LoadedNxPlugin; } });
|
43
|
+
tslib_1.__exportStar(require("./project-graph/error-types"), exports);
|
38
44
|
var register_1 = require("./plugins/js/utils/register");
|
39
45
|
Object.defineProperty(exports, "registerTsProject", { enumerable: true, get: function () { return register_1.registerTsProject; } });
|
@@ -1,9 +1,20 @@
|
|
1
1
|
import { CreateNodesResultWithContext } from './plugins/internal-api';
|
2
2
|
import { ConfigurationResult } from './utils/project-configuration-utils';
|
3
|
+
import { ProjectConfiguration } from '../config/workspace-json-project-json';
|
4
|
+
export declare class ProjectsWithConflictingNamesError extends Error {
|
5
|
+
projects: Record<string, ProjectConfiguration>;
|
6
|
+
constructor(conflicts: Map<string, string[]>, projects: Record<string, ProjectConfiguration>);
|
7
|
+
}
|
8
|
+
export declare function isProjectsWithConflictingNamesError(e: unknown): e is ProjectsWithConflictingNamesError;
|
9
|
+
export declare class ProjectsWithNoNameError extends Error {
|
10
|
+
projects: Record<string, ProjectConfiguration>;
|
11
|
+
constructor(projectRoots: string[], projects: Record<string, ProjectConfiguration>);
|
12
|
+
}
|
13
|
+
export declare function isProjectsWithNoNameError(e: unknown): e is ProjectsWithNoNameError;
|
3
14
|
export declare class ProjectConfigurationsError extends Error {
|
4
|
-
readonly errors: Array<MergeNodesError | CreateNodesError>;
|
15
|
+
readonly errors: Array<MergeNodesError | CreateNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError>;
|
5
16
|
readonly partialProjectConfigurationsResult: ConfigurationResult;
|
6
|
-
constructor(errors: Array<MergeNodesError | CreateNodesError>, partialProjectConfigurationsResult: ConfigurationResult);
|
17
|
+
constructor(errors: Array<MergeNodesError | CreateNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError>, partialProjectConfigurationsResult: ConfigurationResult);
|
7
18
|
}
|
8
19
|
export declare class CreateNodesError extends Error {
|
9
20
|
file: string;
|
@@ -1,6 +1,41 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.isMergeNodesError = exports.isAggregateCreateNodesError = exports.isCreateNodesError = exports.MergeNodesError = exports.AggregateCreateNodesError = exports.CreateNodesError = exports.ProjectConfigurationsError = void 0;
|
3
|
+
exports.isMergeNodesError = exports.isAggregateCreateNodesError = exports.isCreateNodesError = exports.MergeNodesError = exports.AggregateCreateNodesError = exports.CreateNodesError = exports.ProjectConfigurationsError = exports.isProjectsWithNoNameError = exports.ProjectsWithNoNameError = exports.isProjectsWithConflictingNamesError = exports.ProjectsWithConflictingNamesError = void 0;
|
4
|
+
class ProjectsWithConflictingNamesError extends Error {
|
5
|
+
constructor(conflicts, projects) {
|
6
|
+
super([
|
7
|
+
`The following projects are defined in multiple locations:`,
|
8
|
+
...Array.from(conflicts.entries()).map(([project, roots]) => [`- ${project}: `, ...roots.map((r) => ` - ${r}`)].join('\n')),
|
9
|
+
'',
|
10
|
+
"To fix this, set a unique name for each project in a project.json inside the project's root. If the project does not currently have a project.json, you can create one that contains only a name.",
|
11
|
+
].join('\n'));
|
12
|
+
this.projects = projects;
|
13
|
+
this.name = this.constructor.name;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
exports.ProjectsWithConflictingNamesError = ProjectsWithConflictingNamesError;
|
17
|
+
function isProjectsWithConflictingNamesError(e) {
|
18
|
+
return (e instanceof ProjectsWithConflictingNamesError ||
|
19
|
+
(typeof e === 'object' &&
|
20
|
+
'name' in e &&
|
21
|
+
e?.name === ProjectsWithConflictingNamesError.prototype.name));
|
22
|
+
}
|
23
|
+
exports.isProjectsWithConflictingNamesError = isProjectsWithConflictingNamesError;
|
24
|
+
class ProjectsWithNoNameError extends Error {
|
25
|
+
constructor(projectRoots, projects) {
|
26
|
+
super(`The projects in the following directories have no name provided:\n - ${projectRoots.join('\n - ')}`);
|
27
|
+
this.projects = projects;
|
28
|
+
this.name = this.constructor.name;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
exports.ProjectsWithNoNameError = ProjectsWithNoNameError;
|
32
|
+
function isProjectsWithNoNameError(e) {
|
33
|
+
return (e instanceof ProjectsWithNoNameError ||
|
34
|
+
(typeof e === 'object' &&
|
35
|
+
'name' in e &&
|
36
|
+
e?.name === ProjectsWithNoNameError.prototype.name));
|
37
|
+
}
|
38
|
+
exports.isProjectsWithNoNameError = isProjectsWithNoNameError;
|
4
39
|
class ProjectConfigurationsError extends Error {
|
5
40
|
constructor(errors, partialProjectConfigurationsResult) {
|
6
41
|
super('Failed to create project configurations');
|
@@ -41,6 +41,8 @@ function normalizeNxPlugin(plugin) {
|
|
41
41
|
exports.normalizeNxPlugin = normalizeNxPlugin;
|
42
42
|
async function runCreateNodesInParallel(configFiles, plugin, options, context) {
|
43
43
|
performance.mark(`${plugin.name}:createNodes - start`);
|
44
|
+
const errors = [];
|
45
|
+
const results = [];
|
44
46
|
const promises = configFiles.map((file) => {
|
45
47
|
performance.mark(`${plugin.name}:createNodes:${file} - start`);
|
46
48
|
// Result is either static or a promise, using Promise.resolve lets us
|
@@ -49,40 +51,30 @@ async function runCreateNodesInParallel(configFiles, plugin, options, context) {
|
|
49
51
|
return value
|
50
52
|
.catch((e) => {
|
51
53
|
performance.mark(`${plugin.name}:createNodes:${file} - end`);
|
52
|
-
|
54
|
+
errors.push(new error_types_1.CreateNodesError({
|
53
55
|
error: e,
|
54
56
|
pluginName: plugin.name,
|
55
57
|
file,
|
56
|
-
});
|
58
|
+
}));
|
59
|
+
return null;
|
57
60
|
})
|
58
61
|
.then((r) => {
|
59
62
|
performance.mark(`${plugin.name}:createNodes:${file} - end`);
|
60
63
|
performance.measure(`${plugin.name}:createNodes:${file}`, `${plugin.name}:createNodes:${file} - start`, `${plugin.name}:createNodes:${file} - end`);
|
61
|
-
|
64
|
+
// Existing behavior is to ignore null results of
|
65
|
+
// createNodes function.
|
66
|
+
if (r) {
|
67
|
+
results.push(r);
|
68
|
+
}
|
62
69
|
});
|
63
70
|
});
|
64
|
-
|
71
|
+
await Promise.all(promises).then(() => {
|
65
72
|
performance.mark(`${plugin.name}:createNodes - end`);
|
66
73
|
performance.measure(`${plugin.name}:createNodes`, `${plugin.name}:createNodes - start`, `${plugin.name}:createNodes - end`);
|
67
|
-
return results;
|
68
74
|
});
|
69
|
-
const [errors, successful] = partition(results, (r) => r instanceof error_types_1.CreateNodesError);
|
70
75
|
if (errors.length > 0) {
|
71
|
-
throw new error_types_1.AggregateCreateNodesError(plugin.name, errors,
|
76
|
+
throw new error_types_1.AggregateCreateNodesError(plugin.name, errors, results);
|
72
77
|
}
|
73
78
|
return results;
|
74
79
|
}
|
75
80
|
exports.runCreateNodesInParallel = runCreateNodesInParallel;
|
76
|
-
function partition(arr, test) {
|
77
|
-
const pass = [];
|
78
|
-
const fail = [];
|
79
|
-
for (const item of arr) {
|
80
|
-
if (test(item)) {
|
81
|
-
pass.push(item);
|
82
|
-
}
|
83
|
-
else {
|
84
|
-
fail.push(item);
|
85
|
-
}
|
86
|
-
}
|
87
|
-
return [pass, fail];
|
88
|
-
}
|
@@ -2,7 +2,7 @@ import { ProcessDependenciesError, ProcessProjectGraphError } from './build-proj
|
|
2
2
|
import { ProjectGraph } from '../config/project-graph';
|
3
3
|
import { ProjectConfiguration, ProjectsConfigurations } from '../config/workspace-json-project-json';
|
4
4
|
import { ConfigurationSourceMaps } from './utils/project-configuration-utils';
|
5
|
-
import { CreateNodesError, MergeNodesError } from './error-types';
|
5
|
+
import { CreateNodesError, MergeNodesError, ProjectsWithNoNameError, ProjectsWithConflictingNamesError } from './error-types';
|
6
6
|
import { DaemonProjectGraphError } from '../daemon/daemon-project-graph-error';
|
7
7
|
/**
|
8
8
|
* Synchronously reads the latest cached copy of the workspace's ProjectGraph.
|
@@ -20,7 +20,7 @@ export declare function buildProjectGraphAndSourceMapsWithoutDaemon(): Promise<{
|
|
20
20
|
}>;
|
21
21
|
export declare class ProjectGraphError extends Error {
|
22
22
|
#private;
|
23
|
-
constructor(errors: Array<CreateNodesError | MergeNodesError | ProcessDependenciesError | ProcessProjectGraphError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
|
23
|
+
constructor(errors: Array<CreateNodesError | MergeNodesError | ProjectsWithNoNameError | ProjectsWithConflictingNamesError | ProcessDependenciesError | ProcessProjectGraphError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
|
24
24
|
/**
|
25
25
|
* The daemon cannot throw errors which contain methods as they are not serializable.
|
26
26
|
*
|
@@ -34,7 +34,7 @@ export declare class ProjectGraphError extends Error {
|
|
34
34
|
*/
|
35
35
|
getPartialProjectGraph(): ProjectGraph;
|
36
36
|
getPartialSourcemaps(): ConfigurationSourceMaps;
|
37
|
-
getErrors(): (CreateNodesError | ProcessDependenciesError | ProcessProjectGraphError)[];
|
37
|
+
getErrors(): (ProjectsWithConflictingNamesError | ProjectsWithNoNameError | MergeNodesError | CreateNodesError | ProcessDependenciesError | ProcessProjectGraphError)[];
|
38
38
|
}
|
39
39
|
/**
|
40
40
|
* Computes and returns a ProjectGraph.
|
@@ -291,7 +291,20 @@ plugins) {
|
|
291
291
|
}
|
292
292
|
Object.assign(externalNodes, pluginExternalNodes);
|
293
293
|
}
|
294
|
-
|
294
|
+
let projects;
|
295
|
+
try {
|
296
|
+
projects = readProjectConfigurationsFromRootMap(projectRootMap);
|
297
|
+
}
|
298
|
+
catch (e) {
|
299
|
+
if ((0, error_types_1.isProjectsWithNoNameError)(e) ||
|
300
|
+
(0, error_types_1.isProjectsWithConflictingNamesError)(e)) {
|
301
|
+
projects = e.projects;
|
302
|
+
errors.push(e);
|
303
|
+
}
|
304
|
+
else {
|
305
|
+
throw e;
|
306
|
+
}
|
307
|
+
}
|
295
308
|
const rootMap = createRootMap(projectRootMap);
|
296
309
|
perf_hooks_1.performance.mark('createNodes:merge - end');
|
297
310
|
perf_hooks_1.performance.measure('createNodes:merge', 'createNodes:merge - start', 'createNodes:merge - end');
|
@@ -321,7 +334,8 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
|
|
321
334
|
// If there are projects that have the same name, that is an error.
|
322
335
|
// This object tracks name -> (all roots of projects with that name)
|
323
336
|
// to provide better error messaging.
|
324
|
-
const
|
337
|
+
const conflicts = new Map();
|
338
|
+
const projectRootsWithNoName = [];
|
325
339
|
for (const [root, configuration] of projectRootMap.entries()) {
|
326
340
|
// We're setting `// targets` as a comment `targets` is empty due to Project Crystal.
|
327
341
|
// Strip it before returning configuration for usage.
|
@@ -333,27 +347,26 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
|
|
333
347
|
configuration.name = name;
|
334
348
|
}
|
335
349
|
catch {
|
336
|
-
|
350
|
+
projectRootsWithNoName.push(root);
|
337
351
|
}
|
338
352
|
}
|
339
353
|
if (configuration.name in projects) {
|
340
|
-
let rootErrors =
|
354
|
+
let rootErrors = conflicts.get(configuration.name) ?? [
|
341
355
|
projects[configuration.name].root,
|
342
356
|
];
|
343
357
|
rootErrors.push(root);
|
344
|
-
|
358
|
+
conflicts.set(configuration.name, rootErrors);
|
359
|
+
projects[configuration.name] = configuration;
|
345
360
|
}
|
346
361
|
else {
|
347
362
|
projects[configuration.name] = configuration;
|
348
363
|
}
|
349
364
|
}
|
350
|
-
if (
|
351
|
-
throw new
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
"To fix this, set a unique name for each project in a project.json inside the project's root. If the project does not currently have a project.json, you can create one that contains only a name.",
|
356
|
-
].join('\n'));
|
365
|
+
if (conflicts.size > 0) {
|
366
|
+
throw new error_types_1.ProjectsWithConflictingNamesError(conflicts, projects);
|
367
|
+
}
|
368
|
+
if (projectRootsWithNoName.length > 0) {
|
369
|
+
throw new error_types_1.ProjectsWithNoNameError(projectRootsWithNoName, projects);
|
357
370
|
}
|
358
371
|
return projects;
|
359
372
|
}
|
@@ -9,12 +9,12 @@ import { LoadedNxPlugin } from '../plugins/internal-api';
|
|
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.
|
@@ -36,9 +36,10 @@ exports.retrieveWorkspaceFiles = retrieveWorkspaceFiles;
|
|
36
36
|
/**
|
37
37
|
* Walk through the workspace and return `ProjectConfigurations`. Only use this if the projectFileMap is not needed.
|
38
38
|
*/
|
39
|
-
|
40
|
-
const
|
41
|
-
|
39
|
+
function retrieveProjectConfigurations(plugins, workspaceRoot, nxJson) {
|
40
|
+
const globPatterns = configurationGlobs(plugins);
|
41
|
+
const workspaceFiles = (0, workspace_context_1.globWithWorkspaceContext)(workspaceRoot, globPatterns);
|
42
|
+
return (0, project_configuration_utils_1.createProjectConfigurations)(workspaceRoot, nxJson, workspaceFiles, plugins);
|
42
43
|
}
|
43
44
|
exports.retrieveProjectConfigurations = retrieveProjectConfigurations;
|
44
45
|
async function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, nxJson) {
|
@@ -49,16 +50,11 @@ async function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, n
|
|
49
50
|
pluginsToLoad.push((0, path_1.join)(__dirname, '../../adapter/angular-json'));
|
50
51
|
}
|
51
52
|
const [plugins, cleanup] = await (0, internal_api_1.loadNxPlugins)(nxJson?.plugins ?? [], workspaceRoot);
|
52
|
-
const res =
|
53
|
+
const res = retrieveProjectConfigurations(plugins, workspaceRoot, nxJson);
|
53
54
|
cleanup();
|
54
55
|
return res;
|
55
56
|
}
|
56
57
|
exports.retrieveProjectConfigurationsWithAngularProjects = retrieveProjectConfigurationsWithAngularProjects;
|
57
|
-
function _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins) {
|
58
|
-
const globPatterns = configurationGlobs(plugins);
|
59
|
-
const workspaceFiles = (0, workspace_context_1.globWithWorkspaceContext)(workspaceRoot, globPatterns);
|
60
|
-
return (0, project_configuration_utils_1.createProjectConfigurations)(workspaceRoot, nxJson, workspaceFiles, plugins);
|
61
|
-
}
|
62
58
|
function retrieveProjectConfigurationPaths(root, plugins) {
|
63
59
|
const projectGlobPatterns = configurationGlobs(plugins);
|
64
60
|
return (0, workspace_context_1.globWithWorkspaceContext)(root, projectGlobPatterns);
|
package/src/utils/is-ci.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.isCI = void 0;
|
4
4
|
function isCI() {
|
5
|
-
return (process.env.CI
|
5
|
+
return ((process.env.CI && process.env.CI !== 'false') ||
|
6
6
|
process.env.TF_BUILD === 'true' ||
|
7
7
|
process.env.GITHUB_ACTIONS === 'true' ||
|
8
8
|
process.env.BUILDKITE === 'true' ||
|