nx 16.7.0 → 16.7.2
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 +13 -13
- package/plugins/package-json-workspaces.d.ts +9 -3
- package/plugins/package-json-workspaces.js +14 -15
- package/plugins/package-json.d.ts +1 -1
- package/plugins/package-json.js +10 -2
- package/plugins/project-json.d.ts +4 -1
- package/plugins/project-json.js +38 -1
- package/schemas/nx-schema.json +1 -1
- package/schemas/project-schema.json +1 -1
- package/src/adapter/angular-json.d.ts +4 -6
- package/src/adapter/angular-json.js +11 -15
- package/src/config/calculate-default-project-name.d.ts +1 -3
- package/src/config/configuration.d.ts +0 -6
- package/src/config/configuration.js +1 -11
- package/src/config/workspaces.d.ts +5 -13
- package/src/config/workspaces.js +8 -42
- package/src/daemon/server/project-graph-incremental-recomputation.js +3 -4
- package/src/devkit-exports.d.ts +2 -2
- package/src/devkit-exports.js +3 -2
- package/src/devkit-internals.d.ts +6 -0
- package/src/devkit-internals.js +13 -1
- package/src/executors/utils/convert-nx-executor.js +5 -3
- package/src/generators/utils/project-configuration.js +5 -6
- package/src/hasher/task-hasher.js +1 -0
- package/src/plugins/js/index.js +6 -2
- package/src/plugins/js/lock-file/yarn-parser.js +17 -9
- package/src/project-graph/build-nodes/workspace-projects.js +1 -35
- package/src/project-graph/build-project-graph.d.ts +2 -2
- package/src/project-graph/build-project-graph.js +12 -9
- package/src/project-graph/file-utils.d.ts +5 -1
- package/src/project-graph/file-utils.js +13 -6
- package/src/project-graph/nx-deps-cache.d.ts +2 -2
- package/src/project-graph/nx-deps-cache.js +1 -1
- package/src/project-graph/project-graph.d.ts +4 -1
- package/src/project-graph/project-graph.js +5 -2
- package/src/project-graph/utils/project-configuration-utils.d.ts +2 -1
- package/src/project-graph/utils/project-configuration-utils.js +58 -37
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +11 -0
- package/src/project-graph/utils/retrieve-workspace-files.js +35 -12
- package/src/tasks-runner/life-cycles/task-profiling-life-cycle.js +2 -3
- package/src/utils/assert-workspace-validity.d.ts +2 -2
- package/src/utils/assert-workspace-validity.js +3 -4
- package/src/utils/nx-plugin.d.ts +0 -1
- package/src/utils/nx-plugin.js +7 -0
- package/src/utils/package-json.d.ts +1 -0
- package/src/utils/package-json.js +11 -1
- package/src/utils/package-manager.js +1 -3
- package/src/utils/project-graph-utils.d.ts +0 -2
- package/src/utils/project-graph-utils.js +1 -21
- package/src/utils/testing/mock-fs.js +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nx",
|
|
3
|
-
"version": "16.7.
|
|
3
|
+
"version": "16.7.2",
|
|
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": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://nx.dev",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@nrwl/tao": "16.7.
|
|
35
|
+
"@nrwl/tao": "16.7.2",
|
|
36
36
|
"@parcel/watcher": "2.0.4",
|
|
37
37
|
"@yarnpkg/lockfile": "^1.1.0",
|
|
38
38
|
"@yarnpkg/parsers": "3.0.0-rc.46",
|
|
@@ -81,16 +81,16 @@
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"optionalDependencies": {
|
|
84
|
-
"@nx/nx-darwin-arm64": "16.7.
|
|
85
|
-
"@nx/nx-darwin-x64": "16.7.
|
|
86
|
-
"@nx/nx-freebsd-x64": "16.7.
|
|
87
|
-
"@nx/nx-linux-arm-gnueabihf": "16.7.
|
|
88
|
-
"@nx/nx-linux-arm64-gnu": "16.7.
|
|
89
|
-
"@nx/nx-linux-arm64-musl": "16.7.
|
|
90
|
-
"@nx/nx-linux-x64-gnu": "16.7.
|
|
91
|
-
"@nx/nx-linux-x64-musl": "16.7.
|
|
92
|
-
"@nx/nx-win32-arm64-msvc": "16.7.
|
|
93
|
-
"@nx/nx-win32-x64-msvc": "16.7.
|
|
84
|
+
"@nx/nx-darwin-arm64": "16.7.2",
|
|
85
|
+
"@nx/nx-darwin-x64": "16.7.2",
|
|
86
|
+
"@nx/nx-freebsd-x64": "16.7.2",
|
|
87
|
+
"@nx/nx-linux-arm-gnueabihf": "16.7.2",
|
|
88
|
+
"@nx/nx-linux-arm64-gnu": "16.7.2",
|
|
89
|
+
"@nx/nx-linux-arm64-musl": "16.7.2",
|
|
90
|
+
"@nx/nx-linux-x64-gnu": "16.7.2",
|
|
91
|
+
"@nx/nx-linux-x64-musl": "16.7.2",
|
|
92
|
+
"@nx/nx-win32-arm64-msvc": "16.7.2",
|
|
93
|
+
"@nx/nx-win32-x64-msvc": "16.7.2"
|
|
94
94
|
},
|
|
95
95
|
"nx-migrations": {
|
|
96
96
|
"migrations": "./migrations.json",
|
|
@@ -177,5 +177,5 @@
|
|
|
177
177
|
},
|
|
178
178
|
"main": "./bin/nx.js",
|
|
179
179
|
"type": "commonjs",
|
|
180
|
-
"gitHead": "
|
|
180
|
+
"gitHead": "b024f44a1ad4e1773e80f6dc72f9d22766b950f9"
|
|
181
181
|
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { NxJsonConfiguration } from '../src/config/nx-json';
|
|
2
2
|
import { ProjectConfiguration } from '../src/config/workspace-json-project-json';
|
|
3
3
|
import { NxPluginV2 } from '../src/utils/nx-plugin';
|
|
4
|
+
import { PackageJson } from '../src/utils/package-json';
|
|
4
5
|
export declare function getNxPackageJsonWorkspacesPlugin(root: string): NxPluginV2;
|
|
5
|
-
export declare function
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
export declare function createNodeFromPackageJson(pkgJsonPath: string, root: string): {
|
|
7
|
+
projects: {
|
|
8
|
+
[x: string]: ProjectConfiguration & {
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare function buildProjectConfigurationFromPackageJson(packageJson: PackageJson, path: string, nxJson: NxJsonConfiguration): ProjectConfiguration & {
|
|
8
14
|
name: string;
|
|
9
15
|
};
|
|
10
16
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGlobPatternsFromPackageManagerWorkspaces = exports.buildProjectConfigurationFromPackageJson = exports.getNxPackageJsonWorkspacesPlugin = void 0;
|
|
3
|
+
exports.getGlobPatternsFromPackageManagerWorkspaces = exports.buildProjectConfigurationFromPackageJson = exports.createNodeFromPackageJson = exports.getNxPackageJsonWorkspacesPlugin = void 0;
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
6
|
const nx_json_1 = require("../src/config/nx-json");
|
|
@@ -9,6 +9,7 @@ const fileutils_1 = require("../src/utils/fileutils");
|
|
|
9
9
|
const globs_1 = require("../src/utils/globs");
|
|
10
10
|
const logger_1 = require("../src/utils/logger");
|
|
11
11
|
const output_1 = require("../src/utils/output");
|
|
12
|
+
const package_json_1 = require("../src/utils/package-json");
|
|
12
13
|
const path_1 = require("../src/utils/path");
|
|
13
14
|
function getNxPackageJsonWorkspacesPlugin(root) {
|
|
14
15
|
const readJson = (f) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, f));
|
|
@@ -16,18 +17,20 @@ function getNxPackageJsonWorkspacesPlugin(root) {
|
|
|
16
17
|
name: 'nx-core-build-package-json-nodes',
|
|
17
18
|
createNodes: [
|
|
18
19
|
(0, globs_1.combineGlobPatterns)(getGlobPatternsFromPackageManagerWorkspaces(root, readJson)),
|
|
19
|
-
(
|
|
20
|
-
const json = readJson(pkgJsonPath);
|
|
21
|
-
return {
|
|
22
|
-
projects: {
|
|
23
|
-
[json.name]: buildProjectConfigurationFromPackageJson(json, pkgJsonPath, (0, nx_json_1.readNxJson)(root)),
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
},
|
|
20
|
+
(p) => createNodeFromPackageJson(p, root),
|
|
27
21
|
],
|
|
28
22
|
};
|
|
29
23
|
}
|
|
30
24
|
exports.getNxPackageJsonWorkspacesPlugin = getNxPackageJsonWorkspacesPlugin;
|
|
25
|
+
function createNodeFromPackageJson(pkgJsonPath, root) {
|
|
26
|
+
const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, pkgJsonPath));
|
|
27
|
+
return {
|
|
28
|
+
projects: {
|
|
29
|
+
[json.name]: buildProjectConfigurationFromPackageJson(json, pkgJsonPath, (0, nx_json_1.readNxJson)(root)),
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
exports.createNodeFromPackageJson = createNodeFromPackageJson;
|
|
31
34
|
function buildProjectConfigurationFromPackageJson(packageJson, path, nxJson) {
|
|
32
35
|
var _a, _b, _c, _d;
|
|
33
36
|
const normalizedPath = path.split('\\').join('/');
|
|
@@ -47,12 +50,8 @@ function buildProjectConfigurationFromPackageJson(packageJson, path, nxJson) {
|
|
|
47
50
|
directory.startsWith(nxJson.workspaceLayout.appsDir)
|
|
48
51
|
? 'application'
|
|
49
52
|
: 'library';
|
|
50
|
-
return {
|
|
51
|
-
|
|
52
|
-
sourceRoot: directory,
|
|
53
|
-
name,
|
|
54
|
-
projectType,
|
|
55
|
-
};
|
|
53
|
+
return Object.assign(Object.assign({ root: directory, sourceRoot: directory, name,
|
|
54
|
+
projectType }, packageJson.nx), { targets: (0, package_json_1.readTargetsFromPackageJson)(packageJson) });
|
|
56
55
|
}
|
|
57
56
|
exports.buildProjectConfigurationFromPackageJson = buildProjectConfigurationFromPackageJson;
|
|
58
57
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
package/plugins/package-json.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const workspace_root_1 = require("../src/utils/workspace-root");
|
|
4
|
+
const package_json_workspaces_1 = require("./package-json-workspaces");
|
|
5
|
+
const plugin = {
|
|
6
|
+
name: 'nx-all-package-jsons-plugin',
|
|
7
|
+
createNodes: [
|
|
8
|
+
'*/**/package.json',
|
|
9
|
+
(f) => (0, package_json_workspaces_1.createNodeFromPackageJson)(f, workspace_root_1.workspaceRoot),
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
module.exports = plugin;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { ProjectConfiguration } from '../src/config/workspace-json-project-json';
|
|
1
|
+
import { ProjectConfiguration, TargetConfiguration } from '../src/config/workspace-json-project-json';
|
|
2
2
|
import { NxPluginV2 } from '../src/utils/nx-plugin';
|
|
3
|
+
import { PackageJson } from '../src/utils/package-json';
|
|
3
4
|
export declare function getNxProjectJsonPlugin(root: string): NxPluginV2;
|
|
4
5
|
export declare function buildProjectFromProjectJson(json: Partial<ProjectConfiguration>, path: string): ProjectConfiguration;
|
|
6
|
+
export declare function mergePackageJsonConfigurationWithProjectJson(p: ProjectConfiguration, root: string): void;
|
|
7
|
+
export declare function mergeNpmScriptsWithTargets(packageJson: PackageJson, targets: Record<string, TargetConfiguration>): Record<string, TargetConfiguration>;
|
package/plugins/project-json.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildProjectFromProjectJson = exports.getNxProjectJsonPlugin = void 0;
|
|
3
|
+
exports.mergeNpmScriptsWithTargets = exports.mergePackageJsonConfigurationWithProjectJson = exports.buildProjectFromProjectJson = exports.getNxProjectJsonPlugin = void 0;
|
|
4
4
|
const node_path_1 = require("node:path");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
5
6
|
const workspaces_1 = require("../src/config/workspaces");
|
|
6
7
|
const fileutils_1 = require("../src/utils/fileutils");
|
|
8
|
+
const package_json_1 = require("../src/utils/package-json");
|
|
7
9
|
function getNxProjectJsonPlugin(root) {
|
|
8
10
|
return {
|
|
9
11
|
name: 'nx-core-build-project-json-nodes',
|
|
@@ -12,6 +14,7 @@ function getNxProjectJsonPlugin(root) {
|
|
|
12
14
|
(file) => {
|
|
13
15
|
const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, file));
|
|
14
16
|
const project = buildProjectFromProjectJson(json, file);
|
|
17
|
+
mergePackageJsonConfigurationWithProjectJson(project, root);
|
|
15
18
|
return {
|
|
16
19
|
projects: {
|
|
17
20
|
[project.name]: project,
|
|
@@ -26,3 +29,37 @@ function buildProjectFromProjectJson(json, path) {
|
|
|
26
29
|
return Object.assign({ name: (0, workspaces_1.toProjectName)(path), root: (0, node_path_1.dirname)(path) }, json);
|
|
27
30
|
}
|
|
28
31
|
exports.buildProjectFromProjectJson = buildProjectFromProjectJson;
|
|
32
|
+
function mergePackageJsonConfigurationWithProjectJson(p, root) {
|
|
33
|
+
if ((0, node_fs_1.existsSync)((0, node_path_1.join)(root, p.root, 'package.json'))) {
|
|
34
|
+
try {
|
|
35
|
+
const packageJson = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(root, p.root, 'package.json'));
|
|
36
|
+
p.targets = mergeNpmScriptsWithTargets(packageJson, p.targets);
|
|
37
|
+
const { nx } = packageJson;
|
|
38
|
+
if (nx === null || nx === void 0 ? void 0 : nx.tags) {
|
|
39
|
+
p.tags = [...(p.tags || []), ...nx.tags];
|
|
40
|
+
}
|
|
41
|
+
if (nx === null || nx === void 0 ? void 0 : nx.implicitDependencies) {
|
|
42
|
+
p.implicitDependencies = [
|
|
43
|
+
...(p.implicitDependencies || []),
|
|
44
|
+
...nx.implicitDependencies,
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
if (nx === null || nx === void 0 ? void 0 : nx.namedInputs) {
|
|
48
|
+
p.namedInputs = Object.assign(Object.assign({}, (p.namedInputs || {})), nx.namedInputs);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
// ignore json parser errors
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.mergePackageJsonConfigurationWithProjectJson = mergePackageJsonConfigurationWithProjectJson;
|
|
57
|
+
function mergeNpmScriptsWithTargets(packageJson, targets) {
|
|
58
|
+
try {
|
|
59
|
+
return Object.assign(Object.assign({}, (0, package_json_1.readTargetsFromPackageJson)(packageJson)), (targets || {}));
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
return targets;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.mergeNpmScriptsWithTargets = mergeNpmScriptsWithTargets;
|
package/schemas/nx-schema.json
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ProjectsConfigurations } from '../config/workspace-json-project-json';
|
|
2
|
+
import { NxPluginV2 } from '../devkit-exports';
|
|
3
|
+
export declare const NX_ANGULAR_JSON_PLUGIN_NAME = "nx-angular-json-plugin";
|
|
4
|
+
export declare const NxAngularJsonPlugin: NxPluginV2;
|
|
2
5
|
export declare function shouldMergeAngularProjects(root: string, includeProjectsFromAngularJson: boolean): boolean;
|
|
3
6
|
export declare function isAngularPluginInstalled(): boolean;
|
|
4
|
-
export declare function mergeAngularJsonAndProjects(projects: {
|
|
5
|
-
[name: string]: ProjectConfiguration;
|
|
6
|
-
}, angularCliWorkspaceRoot: string): {
|
|
7
|
-
[name: string]: ProjectConfiguration;
|
|
8
|
-
};
|
|
9
7
|
export declare function toNewFormat(w: any): ProjectsConfigurations;
|
|
10
8
|
export declare function toOldFormat(w: any): any;
|
|
11
9
|
export declare function renamePropertyWithStableKeys(obj: any, from: string, to: string): void;
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renamePropertyWithStableKeys = exports.toOldFormat = exports.toNewFormat = exports.
|
|
3
|
+
exports.renamePropertyWithStableKeys = exports.toOldFormat = exports.toNewFormat = exports.isAngularPluginInstalled = exports.shouldMergeAngularProjects = exports.NxAngularJsonPlugin = exports.NX_ANGULAR_JSON_PLUGIN_NAME = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const fileutils_1 = require("../utils/fileutils");
|
|
7
|
+
exports.NX_ANGULAR_JSON_PLUGIN_NAME = 'nx-angular-json-plugin';
|
|
8
|
+
exports.NxAngularJsonPlugin = {
|
|
9
|
+
name: exports.NX_ANGULAR_JSON_PLUGIN_NAME,
|
|
10
|
+
createNodes: [
|
|
11
|
+
'angular.json',
|
|
12
|
+
(f, ctx) => ({
|
|
13
|
+
projects: readAngularJson(ctx.workspaceRoot),
|
|
14
|
+
}),
|
|
15
|
+
],
|
|
16
|
+
};
|
|
7
17
|
function shouldMergeAngularProjects(root, includeProjectsFromAngularJson) {
|
|
8
18
|
if ((0, fs_1.existsSync)(path.join(root, 'angular.json')) &&
|
|
9
19
|
// Include projects from angular.json if explicitly required.
|
|
@@ -38,20 +48,6 @@ exports.isAngularPluginInstalled = isAngularPluginInstalled;
|
|
|
38
48
|
function readAngularJson(angularCliWorkspaceRoot) {
|
|
39
49
|
return toNewFormat((0, fileutils_1.readJsonFile)(path.join(angularCliWorkspaceRoot, 'angular.json'))).projects;
|
|
40
50
|
}
|
|
41
|
-
function mergeAngularJsonAndProjects(projects, angularCliWorkspaceRoot) {
|
|
42
|
-
const res = readAngularJson(angularCliWorkspaceRoot);
|
|
43
|
-
const folders = new Set();
|
|
44
|
-
for (let k of Object.keys(res)) {
|
|
45
|
-
folders.add(res[k].root);
|
|
46
|
-
}
|
|
47
|
-
for (let k of Object.keys(projects)) {
|
|
48
|
-
if (!folders.has(projects[k].root)) {
|
|
49
|
-
res[k] = projects[k];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return res;
|
|
53
|
-
}
|
|
54
|
-
exports.mergeAngularJsonAndProjects = mergeAngularJsonAndProjects;
|
|
55
51
|
function toNewFormat(w) {
|
|
56
52
|
Object.values(w.projects || {}).forEach((projectConfig) => {
|
|
57
53
|
if (projectConfig.architect) {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { NxJsonConfiguration } from './nx-json';
|
|
2
2
|
import { ProjectConfiguration, ProjectsConfigurations } from './workspace-json-project-json';
|
|
3
3
|
export declare function calculateDefaultProjectName(cwd: string, root: string, { projects }: ProjectsConfigurations, nxJson: NxJsonConfiguration): string;
|
|
4
|
-
export declare function findMatchingProjectInCwd(projects:
|
|
5
|
-
[projectName: string]: ProjectConfiguration;
|
|
6
|
-
}, relativeCwd: string): string | undefined;
|
|
4
|
+
export declare function findMatchingProjectInCwd(projects: Record<string, ProjectConfiguration>, relativeCwd: string): string | undefined;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { NxJsonConfiguration } from './nx-json';
|
|
2
|
-
import { ProjectsConfigurations } from './workspace-json-project-json';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated Use readProjectsConfigurationFromProjectGraph(await createProjectGraphAsync())
|
|
5
|
-
*/
|
|
6
|
-
export declare function readAllWorkspaceConfiguration(): ProjectsConfigurations & NxJsonConfiguration;
|
|
7
1
|
/**
|
|
8
2
|
* Returns information about where apps and libs will be created.
|
|
9
3
|
*/
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readNxJson = exports.workspaceLayout =
|
|
4
|
-
const workspaces_1 = require("./workspaces");
|
|
5
|
-
const workspace_root_1 = require("../utils/workspace-root");
|
|
3
|
+
exports.readNxJson = exports.workspaceLayout = void 0;
|
|
6
4
|
const nx_json_1 = require("./nx-json");
|
|
7
|
-
// TODO(vsavkin): Remove after Nx 16 is out
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated Use readProjectsConfigurationFromProjectGraph(await createProjectGraphAsync())
|
|
10
|
-
*/
|
|
11
|
-
function readAllWorkspaceConfiguration() {
|
|
12
|
-
return new workspaces_1.Workspaces(workspace_root_1.workspaceRoot).readProjectsConfigurations();
|
|
13
|
-
}
|
|
14
|
-
exports.readAllWorkspaceConfiguration = readAllWorkspaceConfiguration;
|
|
15
5
|
/**
|
|
16
6
|
* Returns information about where apps and libs will be created.
|
|
17
7
|
*/
|
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
import type { NxJsonConfiguration } from './nx-json';
|
|
2
2
|
import { ProjectsConfigurations } from './workspace-json-project-json';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated This will be removed in v18. Use {@link readProjectsConfigurationFromProjectGraph} instead.
|
|
5
|
+
*/
|
|
3
6
|
export declare class Workspaces {
|
|
4
7
|
private root;
|
|
5
|
-
private cachedProjectsConfig;
|
|
6
8
|
constructor(root: string);
|
|
7
9
|
/**
|
|
8
|
-
* @deprecated
|
|
9
|
-
*/
|
|
10
|
-
readProjectsConfigurations(opts?: {
|
|
11
|
-
_includeProjectsFromAngularJson?: boolean;
|
|
12
|
-
}): ProjectsConfigurations;
|
|
13
|
-
/**
|
|
14
|
-
* Deprecated. Use readProjectsConfigurations
|
|
10
|
+
* @deprecated Use {@link readProjectsConfigurationFromProjectGraph} instead.
|
|
15
11
|
*/
|
|
16
|
-
readWorkspaceConfiguration(
|
|
17
|
-
_ignorePluginInference?: boolean;
|
|
18
|
-
_includeProjectsFromAngularJson?: boolean;
|
|
19
|
-
}): ProjectsConfigurations & NxJsonConfiguration;
|
|
20
|
-
private mergeTargetDefaultsIntoProjectDescriptions;
|
|
12
|
+
readWorkspaceConfiguration(): ProjectsConfigurations & NxJsonConfiguration;
|
|
21
13
|
}
|
|
22
14
|
/**
|
|
23
15
|
* Pulled from toFileName in names from @nx/devkit.
|
package/src/config/workspaces.js
CHANGED
|
@@ -2,57 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toProjectName = exports.Workspaces = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
-
const installation_directory_1 = require("../utils/installation-directory");
|
|
6
|
-
const nx_plugin_1 = require("../utils/nx-plugin");
|
|
7
5
|
const nx_json_1 = require("./nx-json");
|
|
8
|
-
const angular_json_1 = require("../adapter/angular-json");
|
|
9
6
|
const retrieve_workspace_files_1 = require("../project-graph/utils/retrieve-workspace-files");
|
|
10
|
-
|
|
7
|
+
// TODO(v18): remove this class
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated This will be removed in v18. Use {@link readProjectsConfigurationFromProjectGraph} instead.
|
|
10
|
+
*/
|
|
11
11
|
class Workspaces {
|
|
12
12
|
constructor(root) {
|
|
13
13
|
this.root = root;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* @deprecated
|
|
16
|
+
* @deprecated Use {@link readProjectsConfigurationFromProjectGraph} instead.
|
|
17
17
|
*/
|
|
18
|
-
|
|
19
|
-
if (this.cachedProjectsConfig &&
|
|
20
|
-
process.env.NX_CACHE_PROJECTS_CONFIG !== 'false') {
|
|
21
|
-
return this.cachedProjectsConfig;
|
|
22
|
-
}
|
|
18
|
+
readWorkspaceConfiguration() {
|
|
23
19
|
const nxJson = (0, nx_json_1.readNxJson)(this.root);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if ((0, angular_json_1.shouldMergeAngularProjects)(this.root, opts === null || opts === void 0 ? void 0 : opts._includeProjectsFromAngularJson)) {
|
|
27
|
-
projectsConfigurations = (0, angular_json_1.mergeAngularJsonAndProjects)(projectsConfigurations, this.root);
|
|
28
|
-
}
|
|
29
|
-
this.cachedProjectsConfig = {
|
|
30
|
-
version: 2,
|
|
31
|
-
projects: projectsConfigurations,
|
|
32
|
-
};
|
|
33
|
-
return this.cachedProjectsConfig;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Deprecated. Use readProjectsConfigurations
|
|
37
|
-
*/
|
|
38
|
-
readWorkspaceConfiguration(opts) {
|
|
39
|
-
const nxJson = (0, nx_json_1.readNxJson)(this.root);
|
|
40
|
-
return Object.assign(Object.assign({}, this.readProjectsConfigurations(opts)), nxJson);
|
|
41
|
-
}
|
|
42
|
-
mergeTargetDefaultsIntoProjectDescriptions(projects, nxJson) {
|
|
43
|
-
var _a;
|
|
44
|
-
for (const proj of Object.values(projects)) {
|
|
45
|
-
if (proj.targets) {
|
|
46
|
-
for (const targetName of Object.keys((_a = proj.targets) !== null && _a !== void 0 ? _a : {})) {
|
|
47
|
-
const projectTargetDefinition = proj.targets[targetName];
|
|
48
|
-
const defaults = (0, project_configuration_utils_1.readTargetDefaultsForTarget)(targetName, nxJson.targetDefaults, projectTargetDefinition.executor);
|
|
49
|
-
if (defaults) {
|
|
50
|
-
proj.targets[targetName] = (0, project_configuration_utils_1.mergeTargetConfigurations)(proj, targetName, defaults);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return projects;
|
|
20
|
+
return Object.assign({ version: 2, projects: (0, retrieve_workspace_files_1.retrieveProjectConfigurationsSync)(this.root, nxJson)
|
|
21
|
+
.projectNodes }, nxJson);
|
|
56
22
|
}
|
|
57
23
|
}
|
|
58
24
|
exports.Workspaces = Workspaces;
|
|
@@ -9,7 +9,6 @@ const nx_deps_cache_1 = require("../../project-graph/nx-deps-cache");
|
|
|
9
9
|
const fileutils_1 = require("../../utils/fileutils");
|
|
10
10
|
const file_watcher_sockets_1 = require("./file-watching/file-watcher-sockets");
|
|
11
11
|
const logger_1 = require("./logger");
|
|
12
|
-
const workspaces_1 = require("../../config/workspaces");
|
|
13
12
|
const workspace_root_1 = require("../../utils/workspace-root");
|
|
14
13
|
const child_process_1 = require("child_process");
|
|
15
14
|
const file_hasher_1 = require("../../hasher/file-hasher");
|
|
@@ -128,7 +127,7 @@ function processCollectedUpdatedAndDeletedFiles() {
|
|
|
128
127
|
perf_hooks_1.performance.mark('hash-watched-changes-end');
|
|
129
128
|
perf_hooks_1.performance.measure('hash changed files from watcher', 'hash-watched-changes-start', 'hash-watched-changes-end');
|
|
130
129
|
file_hasher_1.fileHasher.incrementalUpdate(updatedFiles, deletedFiles);
|
|
131
|
-
|
|
130
|
+
const nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
|
|
132
131
|
const { projectNodes } = yield (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(workspace_root_1.workspaceRoot, nxJson);
|
|
133
132
|
const workspaceConfigHash = computeWorkspaceConfigHash(projectNodes);
|
|
134
133
|
logger_1.serverLogger.requestLog(`Updated file-hasher based on watched changes, recomputing project graph...`);
|
|
@@ -195,10 +194,10 @@ function createAndSerializeProjectGraph() {
|
|
|
195
194
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
196
195
|
try {
|
|
197
196
|
perf_hooks_1.performance.mark('create-project-graph-start');
|
|
198
|
-
const
|
|
197
|
+
const projectConfigurations = yield (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(workspace_root_1.workspaceRoot, (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot));
|
|
199
198
|
const projectFileMap = copyFileMap(exports.projectFileMapWithFiles.projectFileMap);
|
|
200
199
|
const allWorkspaceFiles = copyFileData(exports.projectFileMapWithFiles.allWorkspaceFiles);
|
|
201
|
-
const { projectGraph, projectFileMapCache } = yield (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(
|
|
200
|
+
const { projectGraph, projectFileMapCache } = yield (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projectConfigurations.projectNodes, knownExternalNodes, projectFileMap, allWorkspaceFiles, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readProjectFileMapCache)(), true);
|
|
202
201
|
exports.currentProjectFileMapCache = projectFileMapCache;
|
|
203
202
|
exports.currentProjectGraph = projectGraph;
|
|
204
203
|
perf_hooks_1.performance.mark('create-project-graph-end');
|
package/src/devkit-exports.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export type { Generator, GeneratorCallback, Executor, ExecutorContext, TaskGraph
|
|
|
18
18
|
* @category Workspace
|
|
19
19
|
*/
|
|
20
20
|
export { Workspaces } from './config/workspaces';
|
|
21
|
-
export {
|
|
21
|
+
export { workspaceLayout } from './config/configuration';
|
|
22
22
|
export type { NxPlugin, NxPluginV1, NxPluginV2, ProjectTargetConfigurator, CreateNodes, CreateNodesFunction, CreateNodesContext, CreateDependencies, CreateDependenciesContext, } from './utils/nx-plugin';
|
|
23
23
|
/**
|
|
24
24
|
* @category Workspace
|
|
@@ -108,7 +108,7 @@ export { reverse } from './project-graph/operators';
|
|
|
108
108
|
/**
|
|
109
109
|
* @category Utils
|
|
110
110
|
*/
|
|
111
|
-
export { createProjectGraphAsync, readCachedProjectGraph, } from './project-graph/project-graph';
|
|
111
|
+
export { createProjectGraphAsync, readCachedProjectGraph, readProjectsConfigurationFromProjectGraph, } from './project-graph/project-graph';
|
|
112
112
|
/**
|
|
113
113
|
* @category Utils
|
|
114
114
|
*/
|
package/src/devkit-exports.js
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* Try hard to not add to this API to reduce the surface area we need to maintain.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.appRootPath = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.updateJson = exports.writeJson = exports.readJson = exports.validateDependency = exports.ProjectGraphBuilder = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.getWorkspacePath = exports.isStandaloneProject = exports.updateWorkspaceConfiguration = exports.readWorkspaceConfiguration = exports.getProjects = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.addProjectConfiguration = exports.runExecutor = exports.getPackageManagerVersion = exports.detectPackageManager = exports.getPackageManagerCommand = exports.output = exports.logger = exports.workspaceLayout = exports.
|
|
7
|
+
exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.appRootPath = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.updateJson = exports.writeJson = exports.readJson = exports.validateDependency = exports.ProjectGraphBuilder = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.getWorkspacePath = exports.isStandaloneProject = exports.updateWorkspaceConfiguration = exports.readWorkspaceConfiguration = exports.getProjects = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.addProjectConfiguration = exports.runExecutor = exports.getPackageManagerVersion = exports.detectPackageManager = exports.getPackageManagerCommand = exports.output = exports.logger = exports.workspaceLayout = exports.Workspaces = void 0;
|
|
8
|
+
// TODO(v18): Remove this export
|
|
8
9
|
/**
|
|
9
10
|
* @category Workspace
|
|
10
11
|
*/
|
|
11
12
|
var workspaces_1 = require("./config/workspaces");
|
|
12
13
|
Object.defineProperty(exports, "Workspaces", { enumerable: true, get: function () { return workspaces_1.Workspaces; } });
|
|
13
14
|
var configuration_1 = require("./config/configuration");
|
|
14
|
-
Object.defineProperty(exports, "readAllWorkspaceConfiguration", { enumerable: true, get: function () { return configuration_1.readAllWorkspaceConfiguration; } });
|
|
15
15
|
Object.defineProperty(exports, "workspaceLayout", { enumerable: true, get: function () { return configuration_1.workspaceLayout; } });
|
|
16
16
|
/**
|
|
17
17
|
* @category Logger
|
|
@@ -115,6 +115,7 @@ Object.defineProperty(exports, "reverse", { enumerable: true, get: function () {
|
|
|
115
115
|
var project_graph_2 = require("./project-graph/project-graph");
|
|
116
116
|
Object.defineProperty(exports, "createProjectGraphAsync", { enumerable: true, get: function () { return project_graph_2.createProjectGraphAsync; } });
|
|
117
117
|
Object.defineProperty(exports, "readCachedProjectGraph", { enumerable: true, get: function () { return project_graph_2.readCachedProjectGraph; } });
|
|
118
|
+
Object.defineProperty(exports, "readProjectsConfigurationFromProjectGraph", { enumerable: true, get: function () { return project_graph_2.readProjectsConfigurationFromProjectGraph; } });
|
|
118
119
|
/**
|
|
119
120
|
* @category Utils
|
|
120
121
|
*/
|
|
@@ -7,3 +7,9 @@ export { createTempNpmDirectory } from './utils/package-manager';
|
|
|
7
7
|
export { getExecutorInformation } from './command-line/run/executor-utils';
|
|
8
8
|
export { readNxJson as readNxJsonFromDisk } from './config/nx-json';
|
|
9
9
|
export { calculateDefaultProjectName } from './config/calculate-default-project-name';
|
|
10
|
+
export { retrieveProjectConfigurationsWithAngularProjects } from './project-graph/utils/retrieve-workspace-files';
|
|
11
|
+
export { splitTarget } from './utils/split-target';
|
|
12
|
+
export { combineOptionsForExecutor } from './utils/params';
|
|
13
|
+
export { sortObjectByKeys } from './utils/object-sort';
|
|
14
|
+
export { stripIndent } from './utils/logger';
|
|
15
|
+
export { readModulePackageJson } from './utils/package-json';
|
package/src/devkit-internals.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
|
|
3
|
+
exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Note to developers: STOP! These exports are available via requireNx in @nx/devkit.
|
|
6
6
|
*
|
|
@@ -14,3 +14,15 @@ var nx_json_1 = require("./config/nx-json");
|
|
|
14
14
|
Object.defineProperty(exports, "readNxJsonFromDisk", { enumerable: true, get: function () { return nx_json_1.readNxJson; } });
|
|
15
15
|
var calculate_default_project_name_1 = require("./config/calculate-default-project-name");
|
|
16
16
|
Object.defineProperty(exports, "calculateDefaultProjectName", { enumerable: true, get: function () { return calculate_default_project_name_1.calculateDefaultProjectName; } });
|
|
17
|
+
var retrieve_workspace_files_1 = require("./project-graph/utils/retrieve-workspace-files");
|
|
18
|
+
Object.defineProperty(exports, "retrieveProjectConfigurationsWithAngularProjects", { enumerable: true, get: function () { return retrieve_workspace_files_1.retrieveProjectConfigurationsWithAngularProjects; } });
|
|
19
|
+
var split_target_1 = require("./utils/split-target");
|
|
20
|
+
Object.defineProperty(exports, "splitTarget", { enumerable: true, get: function () { return split_target_1.splitTarget; } });
|
|
21
|
+
var params_1 = require("./utils/params");
|
|
22
|
+
Object.defineProperty(exports, "combineOptionsForExecutor", { enumerable: true, get: function () { return params_1.combineOptionsForExecutor; } });
|
|
23
|
+
var object_sort_1 = require("./utils/object-sort");
|
|
24
|
+
Object.defineProperty(exports, "sortObjectByKeys", { enumerable: true, get: function () { return object_sort_1.sortObjectByKeys; } });
|
|
25
|
+
var logger_1 = require("./utils/logger");
|
|
26
|
+
Object.defineProperty(exports, "stripIndent", { enumerable: true, get: function () { return logger_1.stripIndent; } });
|
|
27
|
+
var package_json_1 = require("./utils/package-json");
|
|
28
|
+
Object.defineProperty(exports, "readModulePackageJson", { enumerable: true, get: function () { return package_json_1.readModulePackageJson; } });
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.convertNxExecutor = void 0;
|
|
7
7
|
const tslib_1 = require("tslib");
|
|
8
|
-
const workspaces_1 = require("../../config/workspaces");
|
|
9
8
|
const nx_json_1 = require("../../config/nx-json");
|
|
9
|
+
const retrieve_workspace_files_1 = require("../../project-graph/utils/retrieve-workspace-files");
|
|
10
10
|
/**
|
|
11
11
|
* Convert an Nx Executor into an Angular Devkit Builder
|
|
12
12
|
*
|
|
@@ -14,10 +14,12 @@ const nx_json_1 = require("../../config/nx-json");
|
|
|
14
14
|
*/
|
|
15
15
|
function convertNxExecutor(executor) {
|
|
16
16
|
const builderFunction = (options, builderContext) => {
|
|
17
|
-
const workspaces = new workspaces_1.Workspaces(builderContext.workspaceRoot);
|
|
18
|
-
const projectsConfigurations = workspaces.readProjectsConfigurations();
|
|
19
17
|
const promise = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
20
18
|
const nxJsonConfiguration = (0, nx_json_1.readNxJson)(builderContext.workspaceRoot);
|
|
19
|
+
const projectsConfigurations = {
|
|
20
|
+
version: 2,
|
|
21
|
+
projects: (yield (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(builderContext.workspaceRoot, nxJsonConfiguration)).projectNodes,
|
|
22
|
+
};
|
|
21
23
|
const context = {
|
|
22
24
|
root: builderContext.workspaceRoot,
|
|
23
25
|
projectName: builderContext.target.project,
|
|
@@ -118,7 +118,6 @@ function getRelativeProjectJsonSchemaPath(tree, project) {
|
|
|
118
118
|
}
|
|
119
119
|
exports.getRelativeProjectJsonSchemaPath = getRelativeProjectJsonSchemaPath;
|
|
120
120
|
function readAndCombineAllProjectConfigurations(tree) {
|
|
121
|
-
const nxJson = (0, nx_json_1.readNxJson)(tree);
|
|
122
121
|
/**
|
|
123
122
|
* We can't update projects that come from plugins anyways, so we are going
|
|
124
123
|
* to ignore them for now. Plugins should add their own add/create/update methods
|
|
@@ -134,16 +133,16 @@ function readAndCombineAllProjectConfigurations(tree) {
|
|
|
134
133
|
const deletedFiles = findDeletedProjectFiles(tree, patterns);
|
|
135
134
|
const projectFiles = [...globbedFiles, ...createdFiles].filter((r) => deletedFiles.indexOf(r) === -1);
|
|
136
135
|
const rootMap = new Map();
|
|
137
|
-
|
|
136
|
+
for (const projectFile of projectFiles) {
|
|
138
137
|
if ((0, path_1.basename)(projectFile) === 'project.json') {
|
|
139
138
|
const json = (0, json_1.readJson)(tree, projectFile);
|
|
140
139
|
const config = (0, project_json_1.buildProjectFromProjectJson)(json, projectFile);
|
|
141
|
-
(0, project_configuration_utils_1.
|
|
140
|
+
(0, project_configuration_utils_1.mergeProjectConfigurationIntoRootMap)(rootMap, config, projectFile);
|
|
142
141
|
}
|
|
143
142
|
else {
|
|
144
143
|
const packageJson = (0, json_1.readJson)(tree, projectFile);
|
|
145
144
|
const config = (0, package_json_workspaces_1.buildProjectConfigurationFromPackageJson)(packageJson, projectFile, (0, nx_json_1.readNxJson)(tree));
|
|
146
|
-
(0, project_configuration_utils_1.
|
|
145
|
+
(0, project_configuration_utils_1.mergeProjectConfigurationIntoRootMap)(rootMap,
|
|
147
146
|
// Inferred targets, tags, etc don't show up when running generators
|
|
148
147
|
// This is to help avoid running into issues when trying to update the workspace
|
|
149
148
|
{
|
|
@@ -151,8 +150,8 @@ function readAndCombineAllProjectConfigurations(tree) {
|
|
|
151
150
|
root: config.root,
|
|
152
151
|
}, projectFile);
|
|
153
152
|
}
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
}
|
|
154
|
+
return (0, project_configuration_utils_1.readProjectConfigurationsFromRootMap)(rootMap);
|
|
156
155
|
}
|
|
157
156
|
/**
|
|
158
157
|
* Used to ensure that projects created during
|
|
@@ -490,6 +490,7 @@ class TaskHasherImpl {
|
|
|
490
490
|
this.runtimeHashes[mapKey] = new Promise((res, rej) => {
|
|
491
491
|
(0, child_process_1.exec)(runtime, {
|
|
492
492
|
windowsHide: true,
|
|
493
|
+
cwd: workspace_root_1.workspaceRoot,
|
|
493
494
|
}, (err, stdout, stderr) => {
|
|
494
495
|
if (err) {
|
|
495
496
|
rej(new Error(`Nx failed to execute {runtime: '${runtime}'}. ${err}.`));
|