nx 16.6.0-beta.4 → 16.6.0-beta.6
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/.eslintrc.json +30 -0
- package/migrations.json +6 -0
- package/package.json +13 -13
- package/src/command-line/affected/print-affected.js +1 -4
- package/src/command-line/exec/exec.js +2 -2
- package/src/command-line/generate/generate.js +2 -1
- package/src/command-line/init/implementation/angular/index.js +1 -1
- package/src/command-line/init/implementation/angular/legacy-angular-versions.js +1 -1
- package/src/command-line/init/implementation/react/index.js +1 -1
- package/src/command-line/migrate/migrate.js +1 -1
- package/src/command-line/run/run-one.d.ts +1 -3
- package/src/command-line/run/run-one.js +3 -25
- package/src/command-line/show/command-object.js +4 -3
- package/src/command-line/show/show.js +2 -1
- package/src/config/calculate-default-project-name.d.ts +6 -0
- package/src/config/calculate-default-project-name.js +41 -0
- package/src/config/configuration.d.ts +1 -1
- package/src/config/configuration.js +5 -6
- package/src/config/nx-json.d.ts +2 -0
- package/src/config/nx-json.js +35 -0
- package/src/config/workspaces.d.ts +0 -5
- package/src/config/workspaces.js +7 -141
- package/src/core/graph/3rdpartylicenses.txt +25 -0
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/polyfills.js +1 -1
- package/src/core/graph/styles.css +2 -2
- package/src/daemon/client/client.d.ts +3 -1
- package/src/daemon/client/client.js +37 -19
- package/src/daemon/server/project-graph-incremental-recomputation.js +2 -1
- package/src/devkit-exports.d.ts +1 -1
- package/src/devkit-exports.js +3 -4
- package/src/devkit-internals.d.ts +2 -0
- package/src/devkit-internals.js +5 -1
- package/src/executors/utils/convert-nx-executor.js +2 -1
- package/src/generators/utils/nx-json.js +2 -2
- package/src/generators/utils/project-configuration.js +2 -2
- package/src/hasher/file-hasher.d.ts +0 -1
- package/src/hasher/file-hasher.js +0 -5
- package/src/hasher/hash-task.d.ts +2 -3
- package/src/hasher/hash-task.js +6 -5
- package/src/hasher/task-hasher.js +141 -101
- package/src/migrations/update-15-0-0/prefix-outputs.js +13 -8
- package/src/migrations/update-15-1-0/set-project-names.js +2 -3
- package/src/native/assert-supported-platform.js +1 -1
- package/src/native/index.d.ts +9 -3
- package/src/native/index.js +3 -2
- package/src/plugins/js/hasher/hasher.js +1 -1
- package/src/plugins/js/lock-file/lock-file.js +5 -2
- package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
- package/src/plugins/js/lock-file/yarn-parser.js +66 -33
- package/src/project-graph/file-utils.js +1 -1
- package/src/project-graph/project-graph.js +2 -2
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +2 -0
- package/src/project-graph/utils/retrieve-workspace-files.js +43 -15
- package/src/tasks-runner/cache.js +1 -1
- package/src/tasks-runner/run-command.js +1 -2
- package/src/tasks-runner/task-orchestrator.d.ts +0 -2
- package/src/tasks-runner/task-orchestrator.js +2 -6
- package/src/tasks-runner/tasks-schedule.d.ts +1 -5
- package/src/tasks-runner/tasks-schedule.js +3 -5
- package/src/tasks-runner/utils.d.ts +3 -4
- package/src/tasks-runner/utils.js +6 -5
- package/src/utils/nx-plugin.js +5 -7
- package/src/utils/package-manager.js +1 -1
- package/src/utils/testing/temp-fs.js +1 -1
- package/src/utils/workspace-root.d.ts +0 -1
- package/src/utils/workspace-root.js +1 -5
package/src/config/workspaces.js
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renamePropertyWithStableKeys = exports.readTargetDefaultsForTarget = exports.mergeTargetConfigurations = exports.buildProjectsConfigurationsFromProjectPaths = exports.inferProjectFromNonStandardFile = exports.deduplicateProjectFiles = exports.
|
|
3
|
+
exports.renamePropertyWithStableKeys = exports.readTargetDefaultsForTarget = exports.mergeTargetConfigurations = exports.buildProjectsConfigurationsFromProjectPaths = exports.inferProjectFromNonStandardFile = exports.deduplicateProjectFiles = exports.getGlobPatternsFromPackageManagerWorkspaces = exports.getGlobPatternsFromPluginsAsync = exports.getGlobPatternsFromPlugins = exports.toProjectName = exports.Workspaces = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const fast_glob_1 = require("fast-glob");
|
|
6
5
|
const fs_1 = require("fs");
|
|
7
6
|
const path = require("path");
|
|
8
7
|
const path_1 = require("path");
|
|
9
|
-
const perf_hooks_1 = require("perf_hooks");
|
|
10
8
|
const workspace_root_1 = require("../utils/workspace-root");
|
|
11
9
|
const fileutils_1 = require("../utils/fileutils");
|
|
12
10
|
const logger_1 = require("../utils/logger");
|
|
13
11
|
const nx_plugin_1 = require("../utils/nx-plugin");
|
|
12
|
+
const nx_json_1 = require("./nx-json");
|
|
14
13
|
const output_1 = require("../utils/output");
|
|
15
14
|
const path_2 = require("../utils/path");
|
|
16
15
|
const angular_json_1 = require("../adapter/angular-json");
|
|
17
|
-
const
|
|
18
|
-
const ignore_1 = require("../utils/ignore");
|
|
19
|
-
const find_project_for_path_1 = require("../project-graph/utils/find-project-for-path");
|
|
16
|
+
const retrieve_workspace_files_1 = require("../project-graph/utils/retrieve-workspace-files");
|
|
20
17
|
class Workspaces {
|
|
21
18
|
constructor(root) {
|
|
22
19
|
this.root = root;
|
|
@@ -24,31 +21,6 @@ class Workspaces {
|
|
|
24
21
|
relativeCwd(cwd) {
|
|
25
22
|
return path.relative(this.root, cwd).replace(/\\/g, '/') || null;
|
|
26
23
|
}
|
|
27
|
-
calculateDefaultProjectName(cwd, { projects }, nxJson) {
|
|
28
|
-
var _a;
|
|
29
|
-
const relativeCwd = this.relativeCwd(cwd);
|
|
30
|
-
if (relativeCwd) {
|
|
31
|
-
const matchingProject = findMatchingProjectInCwd(projects, relativeCwd);
|
|
32
|
-
// We have found a project
|
|
33
|
-
if (matchingProject) {
|
|
34
|
-
// That is not at the root
|
|
35
|
-
if (projects[matchingProject].root !== '.' &&
|
|
36
|
-
projects[matchingProject].root !== '') {
|
|
37
|
-
return matchingProject;
|
|
38
|
-
// But its at the root, and NX_DEFAULT_PROJECT is set
|
|
39
|
-
}
|
|
40
|
-
else if (process.env.NX_DEFAULT_PROJECT) {
|
|
41
|
-
return process.env.NX_DEFAULT_PROJECT;
|
|
42
|
-
// Its root, and NX_DEFAULT_PROJECT is not set
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
return matchingProject;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
// There was no matching project in cwd.
|
|
50
|
-
return (_a = process.env.NX_DEFAULT_PROJECT) !== null && _a !== void 0 ? _a : nxJson === null || nxJson === void 0 ? void 0 : nxJson.defaultProject;
|
|
51
|
-
}
|
|
52
24
|
/**
|
|
53
25
|
* @deprecated
|
|
54
26
|
*/
|
|
@@ -57,10 +29,9 @@ class Workspaces {
|
|
|
57
29
|
process.env.NX_CACHE_PROJECTS_CONFIG !== 'false') {
|
|
58
30
|
return this.cachedProjectsConfig;
|
|
59
31
|
}
|
|
60
|
-
const nxJson =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
: getGlobPatternsFromPlugins(nxJson, (0, installation_directory_1.getNxRequirePaths)(this.root), this.root), nxJson), (path) => (0, fileutils_1.readJsonFile)((0, path_1.join)(this.root, path)));
|
|
32
|
+
const nxJson = (0, nx_json_1.readNxJson)(this.root);
|
|
33
|
+
const projectPaths = (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(this.root, nxJson);
|
|
34
|
+
let projectsConfigurations = buildProjectsConfigurationsFromProjectPaths(nxJson, projectPaths, (path) => (0, fileutils_1.readJsonFile)((0, path_1.join)(this.root, path)));
|
|
64
35
|
if ((0, angular_json_1.shouldMergeAngularProjects)(this.root, opts === null || opts === void 0 ? void 0 : opts._includeProjectsFromAngularJson)) {
|
|
65
36
|
projectsConfigurations = (0, angular_json_1.mergeAngularJsonAndProjects)(projectsConfigurations, this.root);
|
|
66
37
|
}
|
|
@@ -74,7 +45,7 @@ class Workspaces {
|
|
|
74
45
|
* Deprecated. Use readProjectsConfigurations
|
|
75
46
|
*/
|
|
76
47
|
readWorkspaceConfiguration(opts) {
|
|
77
|
-
const nxJson =
|
|
48
|
+
const nxJson = (0, nx_json_1.readNxJson)(this.root);
|
|
78
49
|
return Object.assign(Object.assign({}, this.readProjectsConfigurations(opts)), nxJson);
|
|
79
50
|
}
|
|
80
51
|
mergeTargetDefaultsIntoProjectDescriptions(projects, nxJson) {
|
|
@@ -91,45 +62,8 @@ class Workspaces {
|
|
|
91
62
|
}
|
|
92
63
|
return projects;
|
|
93
64
|
}
|
|
94
|
-
hasNxJson() {
|
|
95
|
-
const nxJson = path.join(this.root, 'nx.json');
|
|
96
|
-
return (0, fs_1.existsSync)(nxJson);
|
|
97
|
-
}
|
|
98
|
-
readNxJson() {
|
|
99
|
-
const nxJson = path.join(this.root, 'nx.json');
|
|
100
|
-
if ((0, fs_1.existsSync)(nxJson)) {
|
|
101
|
-
const nxJsonConfiguration = (0, fileutils_1.readJsonFile)(nxJson);
|
|
102
|
-
if (nxJsonConfiguration.extends) {
|
|
103
|
-
const extendedNxJsonPath = require.resolve(nxJsonConfiguration.extends, {
|
|
104
|
-
paths: [(0, path_1.dirname)(nxJson)],
|
|
105
|
-
});
|
|
106
|
-
const baseNxJson = (0, fileutils_1.readJsonFile)(extendedNxJsonPath);
|
|
107
|
-
return Object.assign(Object.assign({}, baseNxJson), nxJsonConfiguration);
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
return nxJsonConfiguration;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
try {
|
|
115
|
-
return (0, fileutils_1.readJsonFile)((0, path_1.join)(__dirname, '..', '..', 'presets', 'core.json'));
|
|
116
|
-
}
|
|
117
|
-
catch (e) {
|
|
118
|
-
return {};
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
65
|
}
|
|
123
66
|
exports.Workspaces = Workspaces;
|
|
124
|
-
function findMatchingProjectInCwd(projects, relativeCwd) {
|
|
125
|
-
const projectRootMappings = new Map();
|
|
126
|
-
for (const projectName of Object.keys(projects)) {
|
|
127
|
-
const { root } = projects[projectName];
|
|
128
|
-
projectRootMappings.set((0, find_project_for_path_1.normalizeProjectRoot)(root), projectName);
|
|
129
|
-
}
|
|
130
|
-
const matchingProject = (0, find_project_for_path_1.findProjectForPath)(relativeCwd, projectRootMappings);
|
|
131
|
-
return matchingProject;
|
|
132
|
-
}
|
|
133
67
|
/**
|
|
134
68
|
* Pulled from toFileName in names from @nx/devkit.
|
|
135
69
|
* Todo: Should refactor, not duplicate.
|
|
@@ -139,8 +73,6 @@ function toProjectName(fileName) {
|
|
|
139
73
|
return parts[parts.length - 1].toLowerCase();
|
|
140
74
|
}
|
|
141
75
|
exports.toProjectName = toProjectName;
|
|
142
|
-
let projectGlobCache;
|
|
143
|
-
let projectGlobCacheKey;
|
|
144
76
|
/**
|
|
145
77
|
* @deprecated Use getGlobPatternsFromPluginsAsync instead.
|
|
146
78
|
*/
|
|
@@ -227,72 +159,6 @@ function normalizePatterns(patterns) {
|
|
|
227
159
|
function removeRelativePath(pattern) {
|
|
228
160
|
return pattern.startsWith('./') ? pattern.substring(2) : pattern;
|
|
229
161
|
}
|
|
230
|
-
function globForProjectFiles(root, pluginsGlobPatterns, nxJson) {
|
|
231
|
-
// Deal w/ Caching
|
|
232
|
-
const cacheKey = [root, ...pluginsGlobPatterns].join(',');
|
|
233
|
-
if (process.env.NX_PROJECT_GLOB_CACHE !== 'false' &&
|
|
234
|
-
projectGlobCache &&
|
|
235
|
-
cacheKey === projectGlobCacheKey) {
|
|
236
|
-
return projectGlobCache;
|
|
237
|
-
}
|
|
238
|
-
projectGlobCacheKey = cacheKey;
|
|
239
|
-
const _globPatternsFromPackageManagerWorkspaces = getGlobPatternsFromPackageManagerWorkspaces(root);
|
|
240
|
-
const globPatternsFromPackageManagerWorkspaces = _globPatternsFromPackageManagerWorkspaces !== null && _globPatternsFromPackageManagerWorkspaces !== void 0 ? _globPatternsFromPackageManagerWorkspaces : [];
|
|
241
|
-
const globsToInclude = globPatternsFromPackageManagerWorkspaces.filter((glob) => !glob.startsWith('!'));
|
|
242
|
-
const globsToExclude = globPatternsFromPackageManagerWorkspaces
|
|
243
|
-
.filter((glob) => glob.startsWith('!'))
|
|
244
|
-
.map((glob) => glob.substring(1))
|
|
245
|
-
.map((glob) => (glob.startsWith('/') ? glob.substring(1) : glob));
|
|
246
|
-
const projectGlobPatterns = [
|
|
247
|
-
'project.json',
|
|
248
|
-
'**/project.json',
|
|
249
|
-
...globsToInclude,
|
|
250
|
-
];
|
|
251
|
-
projectGlobPatterns.push(...pluginsGlobPatterns);
|
|
252
|
-
const combinedProjectGlobPattern = '{' + projectGlobPatterns.join(',') + '}';
|
|
253
|
-
perf_hooks_1.performance.mark('start-glob-for-projects');
|
|
254
|
-
/**
|
|
255
|
-
* This configures the files and directories which we always want to ignore as part of file watching
|
|
256
|
-
* and which we know the location of statically (meaning irrespective of user configuration files).
|
|
257
|
-
* This has the advantage of being ignored directly within globSync
|
|
258
|
-
*
|
|
259
|
-
* Other ignored entries will need to be determined dynamically by reading and evaluating the user's
|
|
260
|
-
* .gitignore and .nxignore files below.
|
|
261
|
-
*/
|
|
262
|
-
const staticIgnores = [
|
|
263
|
-
'node_modules',
|
|
264
|
-
'**/node_modules',
|
|
265
|
-
'dist',
|
|
266
|
-
'.git',
|
|
267
|
-
...globsToExclude,
|
|
268
|
-
...(0, ignore_1.getIgnoredGlobs)(root, false),
|
|
269
|
-
];
|
|
270
|
-
/**
|
|
271
|
-
* TODO: This utility has been implemented multiple times across the Nx codebase,
|
|
272
|
-
* discuss whether it should be moved to a shared location.
|
|
273
|
-
*/
|
|
274
|
-
const opts = {
|
|
275
|
-
ignore: staticIgnores,
|
|
276
|
-
absolute: false,
|
|
277
|
-
cwd: root,
|
|
278
|
-
dot: true,
|
|
279
|
-
suppressErrors: true,
|
|
280
|
-
};
|
|
281
|
-
const globResults = (0, fast_glob_1.sync)(combinedProjectGlobPattern, opts);
|
|
282
|
-
projectGlobCache = deduplicateProjectFiles(globResults);
|
|
283
|
-
// TODO @vsavkin remove after Nx 16
|
|
284
|
-
if (projectGlobCache.length === 0 &&
|
|
285
|
-
_globPatternsFromPackageManagerWorkspaces === undefined &&
|
|
286
|
-
(nxJson === null || nxJson === void 0 ? void 0 : nxJson.extends) === 'nx/presets/npm.json') {
|
|
287
|
-
output_1.output.warn({
|
|
288
|
-
title: 'Nx could not find any projects. Check if you need to configure workspaces in package.json or pnpm-workspace.yaml',
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
perf_hooks_1.performance.mark('finish-glob-for-projects');
|
|
292
|
-
perf_hooks_1.performance.measure('glob-for-project-files', 'start-glob-for-projects', 'finish-glob-for-projects');
|
|
293
|
-
return projectGlobCache;
|
|
294
|
-
}
|
|
295
|
-
exports.globForProjectFiles = globForProjectFiles;
|
|
296
162
|
/**
|
|
297
163
|
* @description Loops through files and reduces them to 1 file per project.
|
|
298
164
|
* @param files Array of files that may represent projects
|
|
@@ -590,6 +590,31 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
590
590
|
SOFTWARE.
|
|
591
591
|
|
|
592
592
|
|
|
593
|
+
regenerator-runtime
|
|
594
|
+
MIT
|
|
595
|
+
MIT License
|
|
596
|
+
|
|
597
|
+
Copyright (c) 2014-present, Facebook, Inc.
|
|
598
|
+
|
|
599
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
600
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
601
|
+
in the Software without restriction, including without limitation the rights
|
|
602
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
603
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
604
|
+
furnished to do so, subject to the following conditions:
|
|
605
|
+
|
|
606
|
+
The above copyright notice and this permission notice shall be included in all
|
|
607
|
+
copies or substantial portions of the Software.
|
|
608
|
+
|
|
609
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
610
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
611
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
612
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
613
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
614
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
615
|
+
SOFTWARE.
|
|
616
|
+
|
|
617
|
+
|
|
593
618
|
use-isomorphic-layout-effect
|
|
594
619
|
MIT
|
|
595
620
|
MIT License
|