nx 16.6.0-beta.3 → 16.6.0-beta.5
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/package.json +13 -13
- package/src/adapter/angular-json.js +1 -0
- package/src/adapter/ngcli-adapter.d.ts +6 -0
- package/src/adapter/ngcli-adapter.js +132 -70
- 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 +8 -6
- package/src/command-line/generate/generator-utils.d.ts +16 -0
- package/src/command-line/generate/generator-utils.js +85 -0
- 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/new/new.js +2 -3
- 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 -21
- package/src/config/workspaces.js +7 -224
- 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/hash-task.d.ts +2 -3
- package/src/hasher/hash-task.js +6 -5
- package/src/hasher/task-hasher.js +29 -18
- 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 -0
- package/src/native/index.js +4 -1
- package/src/plugins/js/index.js +4 -0
- 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 +39 -13
- package/src/plugins/js/project-graph/build-dependencies/build-dependencies.js +13 -12
- package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.js +89 -5
- 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 +4 -4
- package/src/utils/ab-testing.js +1 -1
- package/src/utils/nx-plugin.js +5 -7
- package/src/utils/package-manager.d.ts +1 -1
- package/src/utils/package-manager.js +7 -4
- package/src/utils/testing/temp-fs.js +6 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.runOne = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const run_command_1 = require("../../tasks-runner/run-command");
|
|
6
6
|
const command_line_utils_1 = require("../../utils/command-line-utils");
|
|
@@ -11,6 +11,7 @@ const workspace_root_1 = require("../../utils/workspace-root");
|
|
|
11
11
|
const split_target_1 = require("../../utils/split-target");
|
|
12
12
|
const output_1 = require("../../utils/output");
|
|
13
13
|
const configuration_1 = require("../../config/configuration");
|
|
14
|
+
const calculate_default_project_name_1 = require("../../config/calculate-default-project-name");
|
|
14
15
|
const workspace_configuration_check_1 = require("../../utils/workspace-configuration-check");
|
|
15
16
|
const graph_1 = require("../graph/graph");
|
|
16
17
|
function runOne(cwd, args, extraTargetDependencies = {}, extraOptions = { excludeTaskDependencies: false, loadDotEnvFiles: true }) {
|
|
@@ -70,7 +71,7 @@ const targetAliases = {
|
|
|
70
71
|
t: 'test',
|
|
71
72
|
};
|
|
72
73
|
function parseRunOneOptions(cwd, parsedArgs, projectGraph, nxJson) {
|
|
73
|
-
const defaultProjectName = calculateDefaultProjectName(cwd, workspace_root_1.workspaceRoot, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph), nxJson);
|
|
74
|
+
const defaultProjectName = (0, calculate_default_project_name_1.calculateDefaultProjectName)(cwd, workspace_root_1.workspaceRoot, (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph), nxJson);
|
|
74
75
|
let project;
|
|
75
76
|
let target;
|
|
76
77
|
let configuration;
|
|
@@ -112,26 +113,3 @@ function parseRunOneOptions(cwd, parsedArgs, projectGraph, nxJson) {
|
|
|
112
113
|
delete parsedArgs['project'];
|
|
113
114
|
return res;
|
|
114
115
|
}
|
|
115
|
-
function calculateDefaultProjectName(cwd, root, projectsConfigurations, nxJsonConfiguration) {
|
|
116
|
-
var _a;
|
|
117
|
-
if (cwd && /^[A-Z]:/.test(cwd)) {
|
|
118
|
-
cwd = cwd.charAt(0).toLowerCase() + cwd.slice(1);
|
|
119
|
-
}
|
|
120
|
-
if (root && /^[A-Z]:/.test(root)) {
|
|
121
|
-
root = root.charAt(0).toLowerCase() + root.slice(1);
|
|
122
|
-
}
|
|
123
|
-
let relativeCwd = cwd.replace(/\\/g, '/').split(root.replace(/\\/g, '/'))[1];
|
|
124
|
-
relativeCwd = relativeCwd.startsWith('/')
|
|
125
|
-
? relativeCwd.substring(1)
|
|
126
|
-
: relativeCwd;
|
|
127
|
-
const matchingProject = Object.keys(projectsConfigurations.projects).find((p) => {
|
|
128
|
-
const projectRoot = projectsConfigurations.projects[p].root;
|
|
129
|
-
return (relativeCwd == projectRoot ||
|
|
130
|
-
(relativeCwd == '' && projectRoot == '.') ||
|
|
131
|
-
relativeCwd.startsWith(`${projectRoot}/`));
|
|
132
|
-
});
|
|
133
|
-
if (matchingProject)
|
|
134
|
-
return matchingProject;
|
|
135
|
-
return (((_a = nxJsonConfiguration.cli) === null || _a === void 0 ? void 0 : _a.defaultProjectName) || nxJsonConfiguration.defaultProject);
|
|
136
|
-
}
|
|
137
|
-
exports.calculateDefaultProjectName = calculateDefaultProjectName;
|
|
@@ -16,7 +16,8 @@ exports.yargsShowCommand = {
|
|
|
16
16
|
description: 'Output JSON',
|
|
17
17
|
})
|
|
18
18
|
.example('$0 show projects', 'Show a list of all projects in the workspace')
|
|
19
|
-
.example('$0 show
|
|
19
|
+
.example('$0 show projects --with-target serve', 'Show a list of all projects in the workspace that have a "serve" target')
|
|
20
|
+
.example('$0 show project [projectName]', 'Shows the resolved configuration for [projectName]'),
|
|
20
21
|
handler: (args) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
21
22
|
(0, yargs_1.showHelp)();
|
|
22
23
|
process.exit(1);
|
|
@@ -54,12 +55,12 @@ const showProjectsCommand = {
|
|
|
54
55
|
};
|
|
55
56
|
const showProjectCommand = {
|
|
56
57
|
command: 'project <projectName>',
|
|
57
|
-
describe: '
|
|
58
|
+
describe: 'Shows resolved project configuration for a given project.',
|
|
58
59
|
builder: (yargs) => yargs
|
|
59
60
|
.positional('projectName', {
|
|
60
61
|
type: 'string',
|
|
61
62
|
alias: 'p',
|
|
62
|
-
description: '
|
|
63
|
+
description: 'Which project should be viewed?',
|
|
63
64
|
})
|
|
64
65
|
.default('json', true)
|
|
65
66
|
.example('$0 show project my-app', 'View project information for my-app in JSON format'),
|
|
@@ -4,6 +4,7 @@ exports.showProjectHandler = exports.showProjectsHandler = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const affected_project_graph_1 = require("../../project-graph/affected/affected-project-graph");
|
|
6
6
|
const file_utils_1 = require("../../project-graph/file-utils");
|
|
7
|
+
const nx_json_1 = require("../../config/nx-json");
|
|
7
8
|
const command_line_utils_1 = require("../../utils/command-line-utils");
|
|
8
9
|
const project_graph_1 = require("../../project-graph/project-graph");
|
|
9
10
|
const find_matching_projects_1 = require("../../utils/find-matching-projects");
|
|
@@ -11,7 +12,7 @@ const all_file_data_1 = require("../../utils/all-file-data");
|
|
|
11
12
|
function showProjectsHandler(args) {
|
|
12
13
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
13
14
|
let graph = yield (0, project_graph_1.createProjectGraphAsync)();
|
|
14
|
-
const nxJson = (0,
|
|
15
|
+
const nxJson = (0, nx_json_1.readNxJson)();
|
|
15
16
|
const { nxArgs } = (0, command_line_utils_1.splitArgsIntoNxArgsAndOverrides)(args, 'affected', {
|
|
16
17
|
printWarnings: false,
|
|
17
18
|
}, nxJson);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { NxJsonConfiguration } from './nx-json';
|
|
2
|
+
import { ProjectConfiguration, ProjectsConfigurations } from './workspace-json-project-json';
|
|
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;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findMatchingProjectInCwd = exports.calculateDefaultProjectName = void 0;
|
|
4
|
+
const find_project_for_path_1 = require("../project-graph/utils/find-project-for-path");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
function calculateDefaultProjectName(cwd, root, { projects }, nxJson) {
|
|
7
|
+
var _a, _b, _c, _d;
|
|
8
|
+
const relativeCwd = (_a = (0, path_1.relative)(root, cwd).replace(/\\/g, '/')) !== null && _a !== void 0 ? _a : null;
|
|
9
|
+
if (relativeCwd !== null) {
|
|
10
|
+
const matchingProject = findMatchingProjectInCwd(projects, relativeCwd);
|
|
11
|
+
// We have found a project
|
|
12
|
+
if (matchingProject) {
|
|
13
|
+
// That is not at the root
|
|
14
|
+
if (projects[matchingProject].root !== '.' &&
|
|
15
|
+
projects[matchingProject].root !== '') {
|
|
16
|
+
return matchingProject;
|
|
17
|
+
// But its at the root, and NX_DEFAULT_PROJECT is set
|
|
18
|
+
}
|
|
19
|
+
else if (process.env.NX_DEFAULT_PROJECT) {
|
|
20
|
+
return process.env.NX_DEFAULT_PROJECT;
|
|
21
|
+
// Its root, and NX_DEFAULT_PROJECT is not set
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return matchingProject;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
// There was no matching project in cwd.
|
|
29
|
+
return ((_d = (_b = process.env.NX_DEFAULT_PROJECT) !== null && _b !== void 0 ? _b : (_c = nxJson.cli) === null || _c === void 0 ? void 0 : _c.defaultProjectName) !== null && _d !== void 0 ? _d : nxJson === null || nxJson === void 0 ? void 0 : nxJson.defaultProject);
|
|
30
|
+
}
|
|
31
|
+
exports.calculateDefaultProjectName = calculateDefaultProjectName;
|
|
32
|
+
function findMatchingProjectInCwd(projects, relativeCwd) {
|
|
33
|
+
const projectRootMappings = new Map();
|
|
34
|
+
for (const projectName of Object.keys(projects)) {
|
|
35
|
+
const { root } = projects[projectName];
|
|
36
|
+
projectRootMappings.set((0, find_project_for_path_1.normalizeProjectRoot)(root), projectName);
|
|
37
|
+
}
|
|
38
|
+
const matchingProject = (0, find_project_for_path_1.findProjectForPath)(relativeCwd, projectRootMappings);
|
|
39
|
+
return matchingProject;
|
|
40
|
+
}
|
|
41
|
+
exports.findMatchingProjectInCwd = findMatchingProjectInCwd;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { NxJsonConfiguration } from './nx-json';
|
|
2
2
|
import { ProjectsConfigurations } from './workspace-json-project-json';
|
|
3
|
-
export declare function readNxJson(): NxJsonConfiguration;
|
|
4
3
|
/**
|
|
5
4
|
* @deprecated Use readProjectsConfigurationFromProjectGraph(await createProjectGraphAsync())
|
|
6
5
|
*/
|
|
@@ -12,3 +11,4 @@ export declare function workspaceLayout(): {
|
|
|
12
11
|
appsDir: string;
|
|
13
12
|
libsDir: string;
|
|
14
13
|
};
|
|
14
|
+
export { readNxJson } from './nx-json';
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.readNxJson = exports.workspaceLayout = exports.readAllWorkspaceConfiguration = void 0;
|
|
4
4
|
const workspaces_1 = require("./workspaces");
|
|
5
5
|
const workspace_root_1 = require("../utils/workspace-root");
|
|
6
|
-
|
|
7
|
-
return new workspaces_1.Workspaces(workspace_root_1.workspaceRoot).readNxJson();
|
|
8
|
-
}
|
|
9
|
-
exports.readNxJson = readNxJson;
|
|
6
|
+
const nx_json_1 = require("./nx-json");
|
|
10
7
|
// TODO(vsavkin): Remove after Nx 16 is out
|
|
11
8
|
/**
|
|
12
9
|
* @deprecated Use readProjectsConfigurationFromProjectGraph(await createProjectGraphAsync())
|
|
@@ -20,10 +17,12 @@ exports.readAllWorkspaceConfiguration = readAllWorkspaceConfiguration;
|
|
|
20
17
|
*/
|
|
21
18
|
function workspaceLayout() {
|
|
22
19
|
var _a, _b, _c, _d;
|
|
23
|
-
const nxJson = readNxJson();
|
|
20
|
+
const nxJson = (0, nx_json_1.readNxJson)();
|
|
24
21
|
return {
|
|
25
22
|
appsDir: (_b = (_a = nxJson.workspaceLayout) === null || _a === void 0 ? void 0 : _a.appsDir) !== null && _b !== void 0 ? _b : 'apps',
|
|
26
23
|
libsDir: (_d = (_c = nxJson.workspaceLayout) === null || _c === void 0 ? void 0 : _c.libsDir) !== null && _d !== void 0 ? _d : 'libs',
|
|
27
24
|
};
|
|
28
25
|
}
|
|
29
26
|
exports.workspaceLayout = workspaceLayout;
|
|
27
|
+
var nx_json_2 = require("./nx-json");
|
|
28
|
+
Object.defineProperty(exports, "readNxJson", { enumerable: true, get: function () { return nx_json_2.readNxJson; } });
|
package/src/config/nx-json.d.ts
CHANGED
|
@@ -138,4 +138,6 @@ export interface NxJsonConfiguration<T = '*' | string[]> {
|
|
|
138
138
|
*/
|
|
139
139
|
installation?: NxInstallationConfiguration;
|
|
140
140
|
}
|
|
141
|
+
export declare function readNxJson(root?: string): NxJsonConfiguration;
|
|
142
|
+
export declare function hasNxJson(root: string): boolean;
|
|
141
143
|
export {};
|
package/src/config/nx-json.js
CHANGED
|
@@ -1,2 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasNxJson = exports.readNxJson = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const fileutils_1 = require("../utils/fileutils");
|
|
7
|
+
const workspace_root_1 = require("../utils/workspace-root");
|
|
8
|
+
function readNxJson(root = workspace_root_1.workspaceRoot) {
|
|
9
|
+
const nxJson = (0, path_1.join)(root, 'nx.json');
|
|
10
|
+
if ((0, fs_1.existsSync)(nxJson)) {
|
|
11
|
+
const nxJsonConfiguration = (0, fileutils_1.readJsonFile)(nxJson);
|
|
12
|
+
if (nxJsonConfiguration.extends) {
|
|
13
|
+
const extendedNxJsonPath = require.resolve(nxJsonConfiguration.extends, {
|
|
14
|
+
paths: [(0, path_1.dirname)(nxJson)],
|
|
15
|
+
});
|
|
16
|
+
const baseNxJson = (0, fileutils_1.readJsonFile)(extendedNxJsonPath);
|
|
17
|
+
return Object.assign(Object.assign({}, baseNxJson), nxJsonConfiguration);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return nxJsonConfiguration;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
try {
|
|
25
|
+
return (0, fileutils_1.readJsonFile)((0, path_1.join)(__dirname, '..', '..', 'presets', 'core.json'));
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.readNxJson = readNxJson;
|
|
33
|
+
function hasNxJson(root) {
|
|
34
|
+
const nxJson = (0, path_1.join)(root, 'nx.json');
|
|
35
|
+
return (0, fs_1.existsSync)(nxJson);
|
|
36
|
+
}
|
|
37
|
+
exports.hasNxJson = hasNxJson;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import type { NxJsonConfiguration, TargetDefaults } from './nx-json';
|
|
2
2
|
import { ProjectConfiguration, ProjectsConfigurations, TargetConfiguration } from './workspace-json-project-json';
|
|
3
|
-
import { Generator, GeneratorsJsonEntry } from './misc-interfaces';
|
|
4
3
|
export declare class Workspaces {
|
|
5
4
|
private root;
|
|
6
5
|
private cachedProjectsConfig;
|
|
7
6
|
constructor(root: string);
|
|
8
7
|
relativeCwd(cwd: string): string;
|
|
9
|
-
calculateDefaultProjectName(cwd: string, { projects }: ProjectsConfigurations, nxJson: NxJsonConfiguration): string;
|
|
10
8
|
/**
|
|
11
9
|
* @deprecated
|
|
12
10
|
*/
|
|
13
11
|
readProjectsConfigurations(opts?: {
|
|
14
|
-
_ignorePluginInference?: boolean;
|
|
15
12
|
_includeProjectsFromAngularJson?: boolean;
|
|
16
13
|
}): ProjectsConfigurations;
|
|
17
14
|
/**
|
|
@@ -22,23 +19,6 @@ export declare class Workspaces {
|
|
|
22
19
|
_includeProjectsFromAngularJson?: boolean;
|
|
23
20
|
}): ProjectsConfigurations & NxJsonConfiguration;
|
|
24
21
|
private mergeTargetDefaultsIntoProjectDescriptions;
|
|
25
|
-
isNxGenerator(collectionName: string, generatorName: string): boolean;
|
|
26
|
-
readGenerator(collectionName: string, generatorName: string): {
|
|
27
|
-
resolvedCollectionName: string;
|
|
28
|
-
normalizedGeneratorName: string;
|
|
29
|
-
schema: any;
|
|
30
|
-
implementationFactory: () => Generator<unknown>;
|
|
31
|
-
isNgCompat: boolean;
|
|
32
|
-
/**
|
|
33
|
-
* @deprecated(v16): This will be removed in v16, use generatorConfiguration.aliases
|
|
34
|
-
*/
|
|
35
|
-
aliases: string[];
|
|
36
|
-
generatorConfiguration: GeneratorsJsonEntry;
|
|
37
|
-
};
|
|
38
|
-
hasNxJson(): boolean;
|
|
39
|
-
readNxJson(): NxJsonConfiguration;
|
|
40
|
-
private readGeneratorsJson;
|
|
41
|
-
private resolvePaths;
|
|
42
22
|
}
|
|
43
23
|
/**
|
|
44
24
|
* Pulled from toFileName in names from @nx/devkit.
|
|
@@ -54,7 +34,6 @@ export declare function getGlobPatternsFromPluginsAsync(nxJson: NxJsonConfigurat
|
|
|
54
34
|
* Get the package.json globs from package manager workspaces
|
|
55
35
|
*/
|
|
56
36
|
export declare function getGlobPatternsFromPackageManagerWorkspaces(root: string): string[];
|
|
57
|
-
export declare function globForProjectFiles(root: string, pluginsGlobPatterns: string[], nxJson?: NxJsonConfiguration): string[];
|
|
58
37
|
/**
|
|
59
38
|
* @description Loops through files and reduces them to 1 file per project.
|
|
60
39
|
* @param files Array of files that may represent projects
|
package/src/config/workspaces.js
CHANGED
|
@@ -1,23 +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");
|
|
20
|
-
const schema_utils_1 = require("./schema-utils");
|
|
16
|
+
const retrieve_workspace_files_1 = require("../project-graph/utils/retrieve-workspace-files");
|
|
21
17
|
class Workspaces {
|
|
22
18
|
constructor(root) {
|
|
23
19
|
this.root = root;
|
|
@@ -25,31 +21,6 @@ class Workspaces {
|
|
|
25
21
|
relativeCwd(cwd) {
|
|
26
22
|
return path.relative(this.root, cwd).replace(/\\/g, '/') || null;
|
|
27
23
|
}
|
|
28
|
-
calculateDefaultProjectName(cwd, { projects }, nxJson) {
|
|
29
|
-
var _a;
|
|
30
|
-
const relativeCwd = this.relativeCwd(cwd);
|
|
31
|
-
if (relativeCwd) {
|
|
32
|
-
const matchingProject = findMatchingProjectInCwd(projects, relativeCwd);
|
|
33
|
-
// We have found a project
|
|
34
|
-
if (matchingProject) {
|
|
35
|
-
// That is not at the root
|
|
36
|
-
if (projects[matchingProject].root !== '.' &&
|
|
37
|
-
projects[matchingProject].root !== '') {
|
|
38
|
-
return matchingProject;
|
|
39
|
-
// But its at the root, and NX_DEFAULT_PROJECT is set
|
|
40
|
-
}
|
|
41
|
-
else if (process.env.NX_DEFAULT_PROJECT) {
|
|
42
|
-
return process.env.NX_DEFAULT_PROJECT;
|
|
43
|
-
// Its root, and NX_DEFAULT_PROJECT is not set
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
return matchingProject;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
// There was no matching project in cwd.
|
|
51
|
-
return (_a = process.env.NX_DEFAULT_PROJECT) !== null && _a !== void 0 ? _a : nxJson === null || nxJson === void 0 ? void 0 : nxJson.defaultProject;
|
|
52
|
-
}
|
|
53
24
|
/**
|
|
54
25
|
* @deprecated
|
|
55
26
|
*/
|
|
@@ -58,10 +29,9 @@ class Workspaces {
|
|
|
58
29
|
process.env.NX_CACHE_PROJECTS_CONFIG !== 'false') {
|
|
59
30
|
return this.cachedProjectsConfig;
|
|
60
31
|
}
|
|
61
|
-
const nxJson =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
: 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)));
|
|
65
35
|
if ((0, angular_json_1.shouldMergeAngularProjects)(this.root, opts === null || opts === void 0 ? void 0 : opts._includeProjectsFromAngularJson)) {
|
|
66
36
|
projectsConfigurations = (0, angular_json_1.mergeAngularJsonAndProjects)(projectsConfigurations, this.root);
|
|
67
37
|
}
|
|
@@ -75,7 +45,7 @@ class Workspaces {
|
|
|
75
45
|
* Deprecated. Use readProjectsConfigurations
|
|
76
46
|
*/
|
|
77
47
|
readWorkspaceConfiguration(opts) {
|
|
78
|
-
const nxJson =
|
|
48
|
+
const nxJson = (0, nx_json_1.readNxJson)(this.root);
|
|
79
49
|
return Object.assign(Object.assign({}, this.readProjectsConfigurations(opts)), nxJson);
|
|
80
50
|
}
|
|
81
51
|
mergeTargetDefaultsIntoProjectDescriptions(projects, nxJson) {
|
|
@@ -92,127 +62,8 @@ class Workspaces {
|
|
|
92
62
|
}
|
|
93
63
|
return projects;
|
|
94
64
|
}
|
|
95
|
-
isNxGenerator(collectionName, generatorName) {
|
|
96
|
-
return !this.readGenerator(collectionName, generatorName).isNgCompat;
|
|
97
|
-
}
|
|
98
|
-
readGenerator(collectionName, generatorName) {
|
|
99
|
-
var _a, _b, _c, _d;
|
|
100
|
-
try {
|
|
101
|
-
const { generatorsFilePath, generatorsJson, resolvedCollectionName, normalizedGeneratorName, } = this.readGeneratorsJson(collectionName, generatorName);
|
|
102
|
-
const generatorsDir = path.dirname(generatorsFilePath);
|
|
103
|
-
const generatorConfig = ((_a = generatorsJson.generators) === null || _a === void 0 ? void 0 : _a[normalizedGeneratorName]) ||
|
|
104
|
-
((_b = generatorsJson.schematics) === null || _b === void 0 ? void 0 : _b[normalizedGeneratorName]);
|
|
105
|
-
const isNgCompat = !((_c = generatorsJson.generators) === null || _c === void 0 ? void 0 : _c[normalizedGeneratorName]);
|
|
106
|
-
const schemaPath = (0, schema_utils_1.resolveSchema)(generatorConfig.schema, generatorsDir);
|
|
107
|
-
const schema = (0, fileutils_1.readJsonFile)(schemaPath);
|
|
108
|
-
if (!schema.properties || typeof schema.properties !== 'object') {
|
|
109
|
-
schema.properties = {};
|
|
110
|
-
}
|
|
111
|
-
generatorConfig.implementation =
|
|
112
|
-
generatorConfig.implementation || generatorConfig.factory;
|
|
113
|
-
const implementationFactory = (0, schema_utils_1.getImplementationFactory)(generatorConfig.implementation, generatorsDir);
|
|
114
|
-
const normalizedGeneratorConfiguration = Object.assign(Object.assign({}, generatorConfig), { aliases: (_d = generatorConfig.aliases) !== null && _d !== void 0 ? _d : [], hidden: !!generatorConfig.hidden });
|
|
115
|
-
return {
|
|
116
|
-
resolvedCollectionName,
|
|
117
|
-
normalizedGeneratorName,
|
|
118
|
-
schema,
|
|
119
|
-
implementationFactory,
|
|
120
|
-
isNgCompat,
|
|
121
|
-
aliases: generatorConfig.aliases || [],
|
|
122
|
-
generatorConfiguration: normalizedGeneratorConfiguration,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
catch (e) {
|
|
126
|
-
throw new Error(`Unable to resolve ${collectionName}:${generatorName}.\n${e.message}`);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
hasNxJson() {
|
|
130
|
-
const nxJson = path.join(this.root, 'nx.json');
|
|
131
|
-
return (0, fs_1.existsSync)(nxJson);
|
|
132
|
-
}
|
|
133
|
-
readNxJson() {
|
|
134
|
-
const nxJson = path.join(this.root, 'nx.json');
|
|
135
|
-
if ((0, fs_1.existsSync)(nxJson)) {
|
|
136
|
-
const nxJsonConfiguration = (0, fileutils_1.readJsonFile)(nxJson);
|
|
137
|
-
if (nxJsonConfiguration.extends) {
|
|
138
|
-
const extendedNxJsonPath = require.resolve(nxJsonConfiguration.extends, {
|
|
139
|
-
paths: [(0, path_1.dirname)(nxJson)],
|
|
140
|
-
});
|
|
141
|
-
const baseNxJson = (0, fileutils_1.readJsonFile)(extendedNxJsonPath);
|
|
142
|
-
return Object.assign(Object.assign({}, baseNxJson), nxJsonConfiguration);
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
return nxJsonConfiguration;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
try {
|
|
150
|
-
return (0, fileutils_1.readJsonFile)((0, path_1.join)(__dirname, '..', '..', 'presets', 'core.json'));
|
|
151
|
-
}
|
|
152
|
-
catch (e) {
|
|
153
|
-
return {};
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
readGeneratorsJson(collectionName, generator) {
|
|
158
|
-
var _a;
|
|
159
|
-
let generatorsFilePath;
|
|
160
|
-
if (collectionName.endsWith('.json')) {
|
|
161
|
-
generatorsFilePath = require.resolve(collectionName, {
|
|
162
|
-
paths: this.resolvePaths(),
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
const { json: packageJson, path: packageJsonPath } = (0, nx_plugin_1.readPluginPackageJson)(collectionName, this.resolvePaths());
|
|
167
|
-
const generatorsFile = (_a = packageJson.generators) !== null && _a !== void 0 ? _a : packageJson.schematics;
|
|
168
|
-
if (!generatorsFile) {
|
|
169
|
-
throw new Error(`The "${collectionName}" package does not support Nx generators.`);
|
|
170
|
-
}
|
|
171
|
-
generatorsFilePath = require.resolve(path.join(path.dirname(packageJsonPath), generatorsFile));
|
|
172
|
-
}
|
|
173
|
-
const generatorsJson = (0, fileutils_1.readJsonFile)(generatorsFilePath);
|
|
174
|
-
let normalizedGeneratorName = findFullGeneratorName(generator, generatorsJson.generators) ||
|
|
175
|
-
findFullGeneratorName(generator, generatorsJson.schematics);
|
|
176
|
-
if (!normalizedGeneratorName) {
|
|
177
|
-
for (let parent of generatorsJson.extends || []) {
|
|
178
|
-
try {
|
|
179
|
-
return this.readGeneratorsJson(parent, generator);
|
|
180
|
-
}
|
|
181
|
-
catch (e) { }
|
|
182
|
-
}
|
|
183
|
-
throw new Error(`Cannot find generator '${generator}' in ${generatorsFilePath}.`);
|
|
184
|
-
}
|
|
185
|
-
return {
|
|
186
|
-
generatorsFilePath,
|
|
187
|
-
generatorsJson,
|
|
188
|
-
normalizedGeneratorName,
|
|
189
|
-
resolvedCollectionName: collectionName,
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
resolvePaths() {
|
|
193
|
-
return this.root ? [this.root, __dirname] : [__dirname];
|
|
194
|
-
}
|
|
195
65
|
}
|
|
196
66
|
exports.Workspaces = Workspaces;
|
|
197
|
-
function findMatchingProjectInCwd(projects, relativeCwd) {
|
|
198
|
-
const projectRootMappings = new Map();
|
|
199
|
-
for (const projectName of Object.keys(projects)) {
|
|
200
|
-
const { root } = projects[projectName];
|
|
201
|
-
projectRootMappings.set((0, find_project_for_path_1.normalizeProjectRoot)(root), projectName);
|
|
202
|
-
}
|
|
203
|
-
const matchingProject = (0, find_project_for_path_1.findProjectForPath)(relativeCwd, projectRootMappings);
|
|
204
|
-
return matchingProject;
|
|
205
|
-
}
|
|
206
|
-
function findFullGeneratorName(name, generators) {
|
|
207
|
-
if (generators) {
|
|
208
|
-
for (let [key, data] of Object.entries(generators)) {
|
|
209
|
-
if (key === name ||
|
|
210
|
-
(data.aliases && data.aliases.includes(name))) {
|
|
211
|
-
return key;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
67
|
/**
|
|
217
68
|
* Pulled from toFileName in names from @nx/devkit.
|
|
218
69
|
* Todo: Should refactor, not duplicate.
|
|
@@ -222,8 +73,6 @@ function toProjectName(fileName) {
|
|
|
222
73
|
return parts[parts.length - 1].toLowerCase();
|
|
223
74
|
}
|
|
224
75
|
exports.toProjectName = toProjectName;
|
|
225
|
-
let projectGlobCache;
|
|
226
|
-
let projectGlobCacheKey;
|
|
227
76
|
/**
|
|
228
77
|
* @deprecated Use getGlobPatternsFromPluginsAsync instead.
|
|
229
78
|
*/
|
|
@@ -310,72 +159,6 @@ function normalizePatterns(patterns) {
|
|
|
310
159
|
function removeRelativePath(pattern) {
|
|
311
160
|
return pattern.startsWith('./') ? pattern.substring(2) : pattern;
|
|
312
161
|
}
|
|
313
|
-
function globForProjectFiles(root, pluginsGlobPatterns, nxJson) {
|
|
314
|
-
// Deal w/ Caching
|
|
315
|
-
const cacheKey = [root, ...pluginsGlobPatterns].join(',');
|
|
316
|
-
if (process.env.NX_PROJECT_GLOB_CACHE !== 'false' &&
|
|
317
|
-
projectGlobCache &&
|
|
318
|
-
cacheKey === projectGlobCacheKey) {
|
|
319
|
-
return projectGlobCache;
|
|
320
|
-
}
|
|
321
|
-
projectGlobCacheKey = cacheKey;
|
|
322
|
-
const _globPatternsFromPackageManagerWorkspaces = getGlobPatternsFromPackageManagerWorkspaces(root);
|
|
323
|
-
const globPatternsFromPackageManagerWorkspaces = _globPatternsFromPackageManagerWorkspaces !== null && _globPatternsFromPackageManagerWorkspaces !== void 0 ? _globPatternsFromPackageManagerWorkspaces : [];
|
|
324
|
-
const globsToInclude = globPatternsFromPackageManagerWorkspaces.filter((glob) => !glob.startsWith('!'));
|
|
325
|
-
const globsToExclude = globPatternsFromPackageManagerWorkspaces
|
|
326
|
-
.filter((glob) => glob.startsWith('!'))
|
|
327
|
-
.map((glob) => glob.substring(1))
|
|
328
|
-
.map((glob) => (glob.startsWith('/') ? glob.substring(1) : glob));
|
|
329
|
-
const projectGlobPatterns = [
|
|
330
|
-
'project.json',
|
|
331
|
-
'**/project.json',
|
|
332
|
-
...globsToInclude,
|
|
333
|
-
];
|
|
334
|
-
projectGlobPatterns.push(...pluginsGlobPatterns);
|
|
335
|
-
const combinedProjectGlobPattern = '{' + projectGlobPatterns.join(',') + '}';
|
|
336
|
-
perf_hooks_1.performance.mark('start-glob-for-projects');
|
|
337
|
-
/**
|
|
338
|
-
* This configures the files and directories which we always want to ignore as part of file watching
|
|
339
|
-
* and which we know the location of statically (meaning irrespective of user configuration files).
|
|
340
|
-
* This has the advantage of being ignored directly within globSync
|
|
341
|
-
*
|
|
342
|
-
* Other ignored entries will need to be determined dynamically by reading and evaluating the user's
|
|
343
|
-
* .gitignore and .nxignore files below.
|
|
344
|
-
*/
|
|
345
|
-
const staticIgnores = [
|
|
346
|
-
'node_modules',
|
|
347
|
-
'**/node_modules',
|
|
348
|
-
'dist',
|
|
349
|
-
'.git',
|
|
350
|
-
...globsToExclude,
|
|
351
|
-
...(0, ignore_1.getIgnoredGlobs)(root, false),
|
|
352
|
-
];
|
|
353
|
-
/**
|
|
354
|
-
* TODO: This utility has been implemented multiple times across the Nx codebase,
|
|
355
|
-
* discuss whether it should be moved to a shared location.
|
|
356
|
-
*/
|
|
357
|
-
const opts = {
|
|
358
|
-
ignore: staticIgnores,
|
|
359
|
-
absolute: false,
|
|
360
|
-
cwd: root,
|
|
361
|
-
dot: true,
|
|
362
|
-
suppressErrors: true,
|
|
363
|
-
};
|
|
364
|
-
const globResults = (0, fast_glob_1.sync)(combinedProjectGlobPattern, opts);
|
|
365
|
-
projectGlobCache = deduplicateProjectFiles(globResults);
|
|
366
|
-
// TODO @vsavkin remove after Nx 16
|
|
367
|
-
if (projectGlobCache.length === 0 &&
|
|
368
|
-
_globPatternsFromPackageManagerWorkspaces === undefined &&
|
|
369
|
-
(nxJson === null || nxJson === void 0 ? void 0 : nxJson.extends) === 'nx/presets/npm.json') {
|
|
370
|
-
output_1.output.warn({
|
|
371
|
-
title: 'Nx could not find any projects. Check if you need to configure workspaces in package.json or pnpm-workspace.yaml',
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
perf_hooks_1.performance.mark('finish-glob-for-projects');
|
|
375
|
-
perf_hooks_1.performance.measure('glob-for-project-files', 'start-glob-for-projects', 'finish-glob-for-projects');
|
|
376
|
-
return projectGlobCache;
|
|
377
|
-
}
|
|
378
|
-
exports.globForProjectFiles = globForProjectFiles;
|
|
379
162
|
/**
|
|
380
163
|
* @description Loops through files and reduces them to 1 file per project.
|
|
381
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
|