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
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.assertWorkspaceValidity = void 0;
|
|
4
4
|
const find_matching_projects_1 = require("./find-matching-projects");
|
|
5
5
|
const output_1 = require("./output");
|
|
6
|
-
function assertWorkspaceValidity(
|
|
7
|
-
const projectNames = Object.keys(
|
|
6
|
+
function assertWorkspaceValidity(projects, nxJson) {
|
|
7
|
+
const projectNames = Object.keys(projects);
|
|
8
8
|
const projectGraphNodes = projectNames.reduce((graph, project) => {
|
|
9
|
-
const projectConfiguration =
|
|
9
|
+
const projectConfiguration = projects[project];
|
|
10
10
|
graph[project] = {
|
|
11
11
|
name: project,
|
|
12
12
|
type: projectConfiguration.projectType === 'library' ? 'lib' : 'app',
|
|
@@ -14,7 +14,6 @@ function assertWorkspaceValidity(projectsConfigurations, nxJson) {
|
|
|
14
14
|
};
|
|
15
15
|
return graph;
|
|
16
16
|
}, {});
|
|
17
|
-
const projects = Object.assign({}, projectsConfigurations.projects);
|
|
18
17
|
const invalidImplicitDependencies = new Map();
|
|
19
18
|
if (nxJson.implicitDependencies) {
|
|
20
19
|
output_1.output.warn({
|
package/src/utils/nx-plugin.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ import { ProjectGraphDependencyWithFile } from '../project-graph/project-graph-b
|
|
|
8
8
|
* Context for {@link CreateNodesFunction}
|
|
9
9
|
*/
|
|
10
10
|
export interface CreateNodesContext {
|
|
11
|
-
readonly projectsConfigurations: Record<string, ProjectConfiguration>;
|
|
12
11
|
readonly nxJsonConfiguration: NxJsonConfiguration;
|
|
13
12
|
readonly workspaceRoot: string;
|
|
14
13
|
}
|
package/src/utils/nx-plugin.js
CHANGED
|
@@ -17,6 +17,7 @@ const installation_directory_1 = require("./installation-directory");
|
|
|
17
17
|
const typescript_1 = require("../plugins/js/utils/typescript");
|
|
18
18
|
const retrieve_workspace_files_1 = require("../project-graph/utils/retrieve-workspace-files");
|
|
19
19
|
const globs_1 = require("./globs");
|
|
20
|
+
const angular_json_1 = require("../adapter/angular-json");
|
|
20
21
|
tslib_1.__exportStar(require("./nx-plugin.deprecated"), exports);
|
|
21
22
|
// Short lived cache (cleared between cmd runs)
|
|
22
23
|
// holding resolved nx plugin objects.
|
|
@@ -113,6 +114,9 @@ function loadNxPlugins(plugins, paths = (0, installation_directory_1.getNxRequir
|
|
|
113
114
|
const jsPlugin = yield Promise.resolve().then(() => require('../plugins/js'));
|
|
114
115
|
jsPlugin.name = 'nx-js-graph-plugin';
|
|
115
116
|
result.push(jsPlugin);
|
|
117
|
+
if ((0, angular_json_1.shouldMergeAngularProjects)(root, false)) {
|
|
118
|
+
result.push(angular_json_1.NxAngularJsonPlugin);
|
|
119
|
+
}
|
|
116
120
|
plugins !== null && plugins !== void 0 ? plugins : (plugins = []);
|
|
117
121
|
for (const plugin of plugins) {
|
|
118
122
|
result.push(yield loadNxPluginAsync(plugin, paths, root));
|
|
@@ -122,6 +126,9 @@ function loadNxPlugins(plugins, paths = (0, installation_directory_1.getNxRequir
|
|
|
122
126
|
}
|
|
123
127
|
exports.loadNxPlugins = loadNxPlugins;
|
|
124
128
|
function ensurePluginIsV2(plugin) {
|
|
129
|
+
if (isNxPluginV2(plugin)) {
|
|
130
|
+
return plugin;
|
|
131
|
+
}
|
|
125
132
|
if (isNxPluginV1(plugin) && plugin.projectFilePatterns) {
|
|
126
133
|
return Object.assign(Object.assign({}, plugin), { createNodes: [
|
|
127
134
|
`*/**/${(0, globs_1.combineGlobPatterns)(plugin.projectFilePatterns)}`,
|
|
@@ -66,6 +66,7 @@ export declare function readNxMigrateConfig(json: Partial<PackageJson>): NxMigra
|
|
|
66
66
|
packageGroup?: ArrayPackageGroup;
|
|
67
67
|
};
|
|
68
68
|
export declare function buildTargetFromScript(script: string, nx: NxProjectPackageJsonConfiguration): TargetConfiguration;
|
|
69
|
+
export declare function readTargetsFromPackageJson({ scripts, nx }: PackageJson): Record<string, TargetConfiguration<any>>;
|
|
69
70
|
/**
|
|
70
71
|
* Uses `require.resolve` to read the package.json for a module.
|
|
71
72
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readModulePackageJson = exports.readModulePackageJsonWithoutFallbacks = exports.buildTargetFromScript = exports.readNxMigrateConfig = exports.normalizePackageGroup = void 0;
|
|
3
|
+
exports.readModulePackageJson = exports.readModulePackageJsonWithoutFallbacks = exports.readTargetsFromPackageJson = exports.buildTargetFromScript = exports.readNxMigrateConfig = exports.normalizePackageGroup = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const fileutils_1 = require("./fileutils");
|
|
@@ -35,6 +35,16 @@ function buildTargetFromScript(script, nx) {
|
|
|
35
35
|
return Object.assign(Object.assign({}, nxTargetConfiguration), { executor: 'nx:run-script', options: Object.assign(Object.assign({}, (nxTargetConfiguration.options || {})), { script }) });
|
|
36
36
|
}
|
|
37
37
|
exports.buildTargetFromScript = buildTargetFromScript;
|
|
38
|
+
function readTargetsFromPackageJson({ scripts, nx }) {
|
|
39
|
+
const res = {};
|
|
40
|
+
Object.keys(scripts || {}).forEach((script) => {
|
|
41
|
+
if (!(nx === null || nx === void 0 ? void 0 : nx.includedScripts) || (nx === null || nx === void 0 ? void 0 : nx.includedScripts.includes(script))) {
|
|
42
|
+
res[script] = buildTargetFromScript(script, nx);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return res;
|
|
46
|
+
}
|
|
47
|
+
exports.readTargetsFromPackageJson = readTargetsFromPackageJson;
|
|
38
48
|
/**
|
|
39
49
|
* Uses `require.resolve` to read the package.json for a module.
|
|
40
50
|
*
|
|
@@ -47,9 +47,7 @@ function getPackageManagerCommand(packageManager = detectPackageManager(), root
|
|
|
47
47
|
const yarnVersion = getPackageManagerVersion('yarn', root);
|
|
48
48
|
const useBerry = (0, semver_1.gte)(yarnVersion, '2.0.0');
|
|
49
49
|
return {
|
|
50
|
-
preInstall:
|
|
51
|
-
? 'yarn set version stable'
|
|
52
|
-
: 'yarn set version classic',
|
|
50
|
+
preInstall: `yarn set version ${yarnVersion}`,
|
|
53
51
|
install: 'yarn',
|
|
54
52
|
ciInstall: useBerry
|
|
55
53
|
? 'yarn install --immutable'
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { ProjectGraph, ProjectGraphProjectNode } from '../config/project-graph';
|
|
2
|
-
import { TargetConfiguration } from '../config/workspace-json-project-json';
|
|
3
2
|
export declare function projectHasTarget(project: ProjectGraphProjectNode, target: string): boolean;
|
|
4
3
|
export declare function projectHasTargetAndConfiguration(project: ProjectGraphProjectNode, target: string, configuration: string): any;
|
|
5
|
-
export declare function mergeNpmScriptsWithTargets(projectRoot: string, targets: any): Record<string, TargetConfiguration>;
|
|
6
4
|
export declare function getSourceDirOfDependentProjects(projectName: string, projectGraph?: ProjectGraph): [projectDirs: string[], warnings: string[]];
|
|
7
5
|
/**
|
|
8
6
|
* Find all internal project dependencies.
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findAllProjectNodeDependencies = exports.getSourceDirOfDependentProjects = exports.
|
|
4
|
-
const package_json_1 = require("./package-json");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const fileutils_1 = require("./fileutils");
|
|
3
|
+
exports.findAllProjectNodeDependencies = exports.getSourceDirOfDependentProjects = exports.projectHasTargetAndConfiguration = exports.projectHasTarget = void 0;
|
|
7
4
|
const project_graph_1 = require("../project-graph/project-graph");
|
|
8
5
|
function projectHasTarget(project, target) {
|
|
9
6
|
return !!(project.data &&
|
|
@@ -17,23 +14,6 @@ function projectHasTargetAndConfiguration(project, target, configuration) {
|
|
|
17
14
|
project.data.targets[target].configurations[configuration]);
|
|
18
15
|
}
|
|
19
16
|
exports.projectHasTargetAndConfiguration = projectHasTargetAndConfiguration;
|
|
20
|
-
function mergeNpmScriptsWithTargets(projectRoot, targets) {
|
|
21
|
-
try {
|
|
22
|
-
const { scripts, nx } = (0, fileutils_1.readJsonFile)((0, path_1.join)(projectRoot, 'package.json'));
|
|
23
|
-
const res = {};
|
|
24
|
-
// handle no scripts
|
|
25
|
-
Object.keys(scripts || {}).forEach((script) => {
|
|
26
|
-
if (!(nx === null || nx === void 0 ? void 0 : nx.includedScripts) || (nx === null || nx === void 0 ? void 0 : nx.includedScripts.includes(script))) {
|
|
27
|
-
res[script] = (0, package_json_1.buildTargetFromScript)(script, nx);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
return Object.assign(Object.assign({}, res), (targets || {}));
|
|
31
|
-
}
|
|
32
|
-
catch (e) {
|
|
33
|
-
return targets;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.mergeNpmScriptsWithTargets = mergeNpmScriptsWithTargets;
|
|
37
17
|
function getSourceDirOfDependentProjects(projectName, projectGraph = (0, project_graph_1.readCachedProjectGraph)()) {
|
|
38
18
|
if (!projectGraph.nodes[projectName]) {
|
|
39
19
|
throw new Error(`Couldn't find project "${projectName}" in this Nx workspace`);
|
|
@@ -10,3 +10,15 @@ jest.mock('fs', () => {
|
|
|
10
10
|
}
|
|
11
11
|
} });
|
|
12
12
|
});
|
|
13
|
+
// @ts-ignore
|
|
14
|
+
jest.mock('node:fs', () => {
|
|
15
|
+
const mockFs = require('memfs').fs;
|
|
16
|
+
return Object.assign(Object.assign({}, mockFs), { existsSync(path) {
|
|
17
|
+
if (path.endsWith('.node')) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return mockFs.existsSync(path);
|
|
22
|
+
}
|
|
23
|
+
} });
|
|
24
|
+
});
|