nx 19.5.0-beta.3 → 19.5.0-beta.4
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +12 -12
- package/plugins/package-json.js +2 -2
- package/src/command-line/run/command-object.js +6 -0
- package/src/generators/utils/project-configuration.js +3 -3
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/{package-json-workspaces → package-json}/create-nodes.d.ts +2 -2
- package/src/plugins/{package-json-workspaces → package-json}/create-nodes.js +33 -11
- package/src/plugins/package-json/index.d.ts +2 -0
- package/src/plugins/{package-json-workspaces → package-json}/index.js +1 -1
- package/src/plugins/project-json/build-nodes/project-json.js +12 -9
- package/src/project-graph/file-utils.js +3 -3
- package/src/project-graph/plugins/internal-api.js +1 -4
- package/src/project-graph/plugins/loader.js +3 -1
- package/src/project-graph/plugins/utils.js +3 -1
- package/src/utils/nx-plugin.deprecated.js +1 -1
- package/src/plugins/package-json-workspaces/index.d.ts +0 -2
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +0 -3
- package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +0 -57
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "19.5.0-beta.
|
3
|
+
"version": "19.5.0-beta.4",
|
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": {
|
@@ -71,7 +71,7 @@
|
|
71
71
|
"yargs-parser": "21.1.1",
|
72
72
|
"node-machine-id": "1.1.12",
|
73
73
|
"ora": "5.3.0",
|
74
|
-
"@nrwl/tao": "19.5.0-beta.
|
74
|
+
"@nrwl/tao": "19.5.0-beta.4"
|
75
75
|
},
|
76
76
|
"peerDependencies": {
|
77
77
|
"@swc-node/register": "^1.8.0",
|
@@ -86,16 +86,16 @@
|
|
86
86
|
}
|
87
87
|
},
|
88
88
|
"optionalDependencies": {
|
89
|
-
"@nx/nx-darwin-x64": "19.5.0-beta.
|
90
|
-
"@nx/nx-darwin-arm64": "19.5.0-beta.
|
91
|
-
"@nx/nx-linux-x64-gnu": "19.5.0-beta.
|
92
|
-
"@nx/nx-linux-x64-musl": "19.5.0-beta.
|
93
|
-
"@nx/nx-win32-x64-msvc": "19.5.0-beta.
|
94
|
-
"@nx/nx-linux-arm64-gnu": "19.5.0-beta.
|
95
|
-
"@nx/nx-linux-arm64-musl": "19.5.0-beta.
|
96
|
-
"@nx/nx-linux-arm-gnueabihf": "19.5.0-beta.
|
97
|
-
"@nx/nx-win32-arm64-msvc": "19.5.0-beta.
|
98
|
-
"@nx/nx-freebsd-x64": "19.5.0-beta.
|
89
|
+
"@nx/nx-darwin-x64": "19.5.0-beta.4",
|
90
|
+
"@nx/nx-darwin-arm64": "19.5.0-beta.4",
|
91
|
+
"@nx/nx-linux-x64-gnu": "19.5.0-beta.4",
|
92
|
+
"@nx/nx-linux-x64-musl": "19.5.0-beta.4",
|
93
|
+
"@nx/nx-win32-x64-msvc": "19.5.0-beta.4",
|
94
|
+
"@nx/nx-linux-arm64-gnu": "19.5.0-beta.4",
|
95
|
+
"@nx/nx-linux-arm64-musl": "19.5.0-beta.4",
|
96
|
+
"@nx/nx-linux-arm-gnueabihf": "19.5.0-beta.4",
|
97
|
+
"@nx/nx-win32-arm64-msvc": "19.5.0-beta.4",
|
98
|
+
"@nx/nx-freebsd-x64": "19.5.0-beta.4"
|
99
99
|
},
|
100
100
|
"nx-migrations": {
|
101
101
|
"migrations": "./migrations.json",
|
package/plugins/package-json.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const workspace_root_1 = require("../src/utils/workspace-root");
|
4
|
-
const
|
4
|
+
const package_json_1 = require("../src/plugins/package-json");
|
5
5
|
const plugin = {
|
6
6
|
name: 'nx-all-package-jsons-plugin',
|
7
7
|
createNodes: [
|
8
8
|
'*/**/package.json',
|
9
|
-
(f) => (0,
|
9
|
+
(f) => (0, package_json_1.createNodeFromPackageJson)(f, workspace_root_1.workspaceRoot),
|
10
10
|
],
|
11
11
|
};
|
12
12
|
module.exports = plugin;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.yargsNxInfixCommand = exports.yargsRunCommand = void 0;
|
4
|
+
const yargs_1 = require("yargs");
|
4
5
|
const shared_options_1 = require("../yargs-utils/shared-options");
|
5
6
|
const params_1 = require("../../utils/params");
|
6
7
|
exports.yargsRunCommand = {
|
@@ -29,6 +30,11 @@ exports.yargsNxInfixCommand = {
|
|
29
30
|
describe: 'Run a target for a project',
|
30
31
|
handler: async (args) => {
|
31
32
|
const exitCode = await (0, params_1.handleErrors)(args.verbose ?? process.env.NX_VERBOSE_LOGGING === 'true', async () => {
|
33
|
+
// Yargs parses <target> as 'undefined' if running just 'nx'
|
34
|
+
if (!args.target || args.target === 'undefined') {
|
35
|
+
(0, yargs_1.showHelp)();
|
36
|
+
process.exit(1);
|
37
|
+
}
|
32
38
|
return (await Promise.resolve().then(() => require('./run-one'))).runOne(process.cwd(), (0, shared_options_1.withOverrides)(args, 0));
|
33
39
|
});
|
34
40
|
process.exit(exitCode);
|
@@ -9,7 +9,7 @@ exports.getProjects = getProjects;
|
|
9
9
|
exports.getRelativeProjectJsonSchemaPath = getRelativeProjectJsonSchemaPath;
|
10
10
|
const minimatch_1 = require("minimatch");
|
11
11
|
const path_1 = require("path");
|
12
|
-
const
|
12
|
+
const package_json_1 = require("../../plugins/package-json");
|
13
13
|
const project_json_1 = require("../../plugins/project-json/build-nodes/project-json");
|
14
14
|
const angular_json_1 = require("../../adapter/angular-json");
|
15
15
|
const project_configuration_utils_1 = require("../../project-graph/utils/project-configuration-utils");
|
@@ -132,7 +132,7 @@ function readAndCombineAllProjectConfigurations(tree) {
|
|
132
132
|
const patterns = [
|
133
133
|
'**/project.json',
|
134
134
|
'project.json',
|
135
|
-
...(0,
|
135
|
+
...(0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (p) => (0, json_1.readJson)(tree, p, { expectComments: true })),
|
136
136
|
];
|
137
137
|
const globbedFiles = (0, workspace_context_1.globWithWorkspaceContextSync)(tree.root, patterns);
|
138
138
|
const createdFiles = findCreatedProjectFiles(tree, patterns);
|
@@ -147,7 +147,7 @@ function readAndCombineAllProjectConfigurations(tree) {
|
|
147
147
|
}
|
148
148
|
else if ((0, path_1.basename)(projectFile) === 'package.json') {
|
149
149
|
const packageJson = (0, json_1.readJson)(tree, projectFile);
|
150
|
-
const config = (0,
|
150
|
+
const config = (0, package_json_1.buildProjectConfigurationFromPackageJson)(packageJson, tree.root, projectFile, (0, nx_json_1.readNxJson)(tree));
|
151
151
|
if (!rootMap[config.root]) {
|
152
152
|
(0, project_configuration_utils_1.mergeProjectConfigurationIntoRootMap)(rootMap,
|
153
153
|
// Inferred targets, tags, etc don't show up when running generators
|
Binary file
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { NxJsonConfiguration } from '../../config/nx-json';
|
2
2
|
import { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
3
3
|
import { PackageJson } from '../../utils/package-json';
|
4
|
-
import {
|
5
|
-
export declare const
|
4
|
+
import { CreateNodesV2 } from '../../project-graph/plugins';
|
5
|
+
export declare const createNodesV2: CreateNodesV2;
|
6
6
|
export declare function buildPackageJsonWorkspacesMatcher(workspaceRoot: string, readJson: (string: any) => any): (p: string) => boolean;
|
7
7
|
export declare function createNodeFromPackageJson(pkgJsonPath: string, workspaceRoot: string): {
|
8
8
|
projects: {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.createNodesV2 = void 0;
|
4
4
|
exports.buildPackageJsonWorkspacesMatcher = buildPackageJsonWorkspacesMatcher;
|
5
5
|
exports.createNodeFromPackageJson = createNodeFromPackageJson;
|
6
6
|
exports.buildProjectConfigurationFromPackageJson = buildProjectConfigurationFromPackageJson;
|
@@ -16,18 +16,40 @@ const logger_1 = require("../../utils/logger");
|
|
16
16
|
const output_1 = require("../../utils/output");
|
17
17
|
const package_json_1 = require("../../utils/package-json");
|
18
18
|
const path_1 = require("../../utils/path");
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
19
|
+
const plugins_1 = require("../../project-graph/plugins");
|
20
|
+
const path_2 = require("path");
|
21
|
+
exports.createNodesV2 = [
|
22
|
+
(0, globs_1.combineGlobPatterns)('package.json', '**/package.json', 'project.json', '**/project.json'),
|
23
|
+
(configFiles, _, context) => {
|
24
|
+
const { packageJsons, projectJsonRoots } = splitConfigFiles(configFiles);
|
25
|
+
const readJson = (f) => (0, fileutils_1.readJsonFile)((0, node_path_1.join)(context.workspaceRoot, f));
|
26
|
+
const isInPackageJsonWorkspaces = buildPackageJsonWorkspacesMatcher(context.workspaceRoot, readJson);
|
27
|
+
const isNextToProjectJson = (packageJsonPath) => {
|
28
|
+
return projectJsonRoots.has((0, node_path_1.dirname)(packageJsonPath));
|
29
|
+
};
|
30
|
+
return (0, plugins_1.createNodesFromFiles)((packageJsonPath, options, context) => {
|
31
|
+
if (!isInPackageJsonWorkspaces(packageJsonPath) &&
|
32
|
+
!isNextToProjectJson(packageJsonPath)) {
|
33
|
+
// Skip if package.json is not part of the package.json workspaces and not next to a project.json.
|
34
|
+
return null;
|
35
|
+
}
|
36
|
+
return createNodeFromPackageJson(packageJsonPath, context.workspaceRoot);
|
37
|
+
}, packageJsons, _, context);
|
29
38
|
},
|
30
39
|
];
|
40
|
+
function splitConfigFiles(configFiles) {
|
41
|
+
const packageJsons = [];
|
42
|
+
const projectJsonRoots = new Set();
|
43
|
+
for (const configFile of configFiles) {
|
44
|
+
if ((0, path_2.basename)(configFile) === 'package.json') {
|
45
|
+
packageJsons.push(configFile);
|
46
|
+
}
|
47
|
+
else {
|
48
|
+
projectJsonRoots.add((0, node_path_1.dirname)(configFile));
|
49
|
+
}
|
50
|
+
}
|
51
|
+
return { packageJsons, projectJsonRoots };
|
52
|
+
}
|
31
53
|
function buildPackageJsonWorkspacesMatcher(workspaceRoot, readJson) {
|
32
54
|
const patterns = getGlobPatternsFromPackageManagerWorkspaces(workspaceRoot, readJson);
|
33
55
|
const negativePatterns = patterns.filter((p) => p.startsWith('!'));
|
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.name = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
tslib_1.__exportStar(require("./create-nodes"), exports);
|
6
|
-
exports.name = 'nx/core/package-json
|
6
|
+
exports.name = 'nx/core/package-json';
|
@@ -6,18 +6,21 @@ exports.readNameFromPackageJson = readNameFromPackageJson;
|
|
6
6
|
const node_path_1 = require("node:path");
|
7
7
|
const to_project_name_1 = require("../../../config/to-project-name");
|
8
8
|
const fileutils_1 = require("../../../utils/fileutils");
|
9
|
+
const plugins_1 = require("../../../project-graph/plugins");
|
9
10
|
exports.ProjectJsonProjectsPlugin = {
|
10
11
|
name: 'nx/core/project-json',
|
11
|
-
|
12
|
+
createNodesV2: [
|
12
13
|
'{project.json,**/project.json}',
|
13
|
-
(
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
(configFiles, _, context) => {
|
15
|
+
return (0, plugins_1.createNodesFromFiles)((file) => {
|
16
|
+
const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(context.workspaceRoot, file));
|
17
|
+
const project = buildProjectFromProjectJson(json, file);
|
18
|
+
return {
|
19
|
+
projects: {
|
20
|
+
[project.root]: project,
|
21
|
+
},
|
22
|
+
};
|
23
|
+
}, configFiles, _, context);
|
21
24
|
},
|
22
25
|
],
|
23
26
|
};
|
@@ -18,7 +18,7 @@ const project_graph_1 = require("./project-graph");
|
|
18
18
|
const angular_json_1 = require("../adapter/angular-json");
|
19
19
|
const ignore_1 = require("../utils/ignore");
|
20
20
|
const project_configuration_utils_1 = require("./utils/project-configuration-utils");
|
21
|
-
const
|
21
|
+
const package_json_1 = require("../plugins/package-json");
|
22
22
|
const workspace_context_1 = require("../utils/workspace-context");
|
23
23
|
const project_json_1 = require("../plugins/project-json/build-nodes/project-json");
|
24
24
|
class WholeFileChange {
|
@@ -150,7 +150,7 @@ function getProjectsSync(root, nxJson) {
|
|
150
150
|
const patterns = [
|
151
151
|
'**/project.json',
|
152
152
|
'project.json',
|
153
|
-
...(0,
|
153
|
+
...(0, package_json_1.getGlobPatternsFromPackageManagerWorkspaces)(root, fileutils_1.readJsonFile),
|
154
154
|
];
|
155
155
|
const projectFiles = (0, workspace_context_1.globWithWorkspaceContextSync)(root, patterns);
|
156
156
|
const rootMap = {};
|
@@ -162,7 +162,7 @@ function getProjectsSync(root, nxJson) {
|
|
162
162
|
}
|
163
163
|
else if ((0, path_1.basename)(projectFile) === 'package.json') {
|
164
164
|
const packageJson = (0, fileutils_1.readJsonFile)(projectFile);
|
165
|
-
const config = (0,
|
165
|
+
const config = (0, package_json_1.buildProjectConfigurationFromPackageJson)(packageJson, root, projectFile, nxJson);
|
166
166
|
if (!rootMap[config.root]) {
|
167
167
|
(0, project_configuration_utils_1.mergeProjectConfigurationIntoRootMap)(rootMap,
|
168
168
|
// Inferred targets, tags, etc don't show up when running generators
|
@@ -101,9 +101,6 @@ async function loadNxPlugins(plugins, root = workspace_root_1.workspaceRoot) {
|
|
101
101
|
async function normalizePlugins(plugins, root) {
|
102
102
|
plugins ??= [];
|
103
103
|
return [
|
104
|
-
// This plugin adds targets that we want to be able to overwrite
|
105
|
-
// in any user-land plugin, so it has to be first :).
|
106
|
-
(0, path_1.join)(__dirname, '../../plugins/project-json/build-nodes/package-json-next-to-project-json'),
|
107
104
|
...plugins,
|
108
105
|
// Most of the nx core node plugins go on the end, s.t. it overwrites any other plugins
|
109
106
|
...(await getDefaultPlugins(root)),
|
@@ -115,7 +112,7 @@ async function getDefaultPlugins(root) {
|
|
115
112
|
...((0, angular_json_1.shouldMergeAngularProjects)(root, false)
|
116
113
|
? [(0, path_1.join)(__dirname, '../../adapter/angular-json')]
|
117
114
|
: []),
|
118
|
-
(0, path_1.join)(__dirname, '../../plugins/package-json
|
115
|
+
(0, path_1.join)(__dirname, '../../plugins/package-json'),
|
119
116
|
(0, path_1.join)(__dirname, '../../plugins/project-json/build-nodes/project-json'),
|
120
117
|
];
|
121
118
|
}
|
@@ -211,7 +211,9 @@ async function loadNxPluginAsync(pluginConfiguration, paths, root) {
|
|
211
211
|
async function importPluginModule(pluginPath) {
|
212
212
|
const m = await Promise.resolve(`${pluginPath}`).then(s => require(s));
|
213
213
|
if (m.default &&
|
214
|
-
('createNodes' in m.default ||
|
214
|
+
('createNodes' in m.default ||
|
215
|
+
'createNodesV2' in m.default ||
|
216
|
+
'createDependencies' in m.default)) {
|
215
217
|
return m.default;
|
216
218
|
}
|
217
219
|
return m;
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDefaultPluginsSync = getDefaultPluginsSync;
|
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
|
-
const PackageJsonWorkspacesPlugin = require("../plugins/package-json
|
6
|
+
const PackageJsonWorkspacesPlugin = require("../plugins/package-json");
|
7
7
|
/**
|
8
8
|
* @todo(@agentender) v20: Remove this fn when we remove readWorkspaceConfig
|
9
9
|
*/
|
@@ -1,57 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.PackageJsonProjectsNextToProjectJsonPlugin = void 0;
|
4
|
-
const path_1 = require("path");
|
5
|
-
const fs_1 = require("fs");
|
6
|
-
const fileutils_1 = require("../../../utils/fileutils");
|
7
|
-
const package_json_1 = require("../../../utils/package-json");
|
8
|
-
const package_json_workspaces_1 = require("../../package-json-workspaces");
|
9
|
-
// TODO: Remove this one day, this should not need to be done.
|
10
|
-
exports.PackageJsonProjectsNextToProjectJsonPlugin = {
|
11
|
-
// Its not a problem if plugins happen to have same name, and this
|
12
|
-
// will look least confusing in the source map.
|
13
|
-
name: 'nx/core/package-json',
|
14
|
-
createNodes: [
|
15
|
-
'{project.json,**/project.json}',
|
16
|
-
(file, _, { workspaceRoot }) => {
|
17
|
-
const project = createProjectFromPackageJsonNextToProjectJson(file, workspaceRoot);
|
18
|
-
return project
|
19
|
-
? {
|
20
|
-
projects: {
|
21
|
-
[project.name]: project,
|
22
|
-
},
|
23
|
-
}
|
24
|
-
: {};
|
25
|
-
},
|
26
|
-
],
|
27
|
-
};
|
28
|
-
exports.default = exports.PackageJsonProjectsNextToProjectJsonPlugin;
|
29
|
-
function createProjectFromPackageJsonNextToProjectJson(projectJsonPath, workspaceRoot) {
|
30
|
-
const root = (0, path_1.dirname)(projectJsonPath);
|
31
|
-
const relativePackageJsonPath = (0, path_1.join)(root, 'package.json');
|
32
|
-
const packageJsonPath = (0, path_1.join)(workspaceRoot, relativePackageJsonPath);
|
33
|
-
const readJson = (f) => (0, fileutils_1.readJsonFile)((0, path_1.join)(workspaceRoot, f));
|
34
|
-
// Do not create projects for package.json files
|
35
|
-
// that are part of the package manager workspaces
|
36
|
-
// Those package.json files will be processed later on
|
37
|
-
const matcher = (0, package_json_workspaces_1.buildPackageJsonWorkspacesMatcher)(workspaceRoot, readJson);
|
38
|
-
if (!(0, fs_1.existsSync)(packageJsonPath) || matcher(relativePackageJsonPath)) {
|
39
|
-
return null;
|
40
|
-
}
|
41
|
-
try {
|
42
|
-
const packageJson = (0, fileutils_1.readJsonFile)(packageJsonPath);
|
43
|
-
let { nx, name } = packageJson;
|
44
|
-
return {
|
45
|
-
...nx,
|
46
|
-
name,
|
47
|
-
root,
|
48
|
-
targets: (0, package_json_1.readTargetsFromPackageJson)(packageJson),
|
49
|
-
metadata: (0, package_json_1.getMetadataFromPackageJson)(packageJson),
|
50
|
-
tags: (0, package_json_1.getTagsFromPackageJson)(packageJson),
|
51
|
-
};
|
52
|
-
}
|
53
|
-
catch (e) {
|
54
|
-
console.log(e);
|
55
|
-
return null;
|
56
|
-
}
|
57
|
-
}
|