nx 16.7.1 → 16.7.3

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.
Files changed (39) hide show
  1. package/bin/nx.js +1 -1
  2. package/package.json +13 -13
  3. package/plugins/package-json-workspaces.d.ts +9 -3
  4. package/plugins/package-json-workspaces.js +14 -15
  5. package/plugins/package-json.d.ts +1 -1
  6. package/plugins/package-json.js +10 -2
  7. package/plugins/project-json.d.ts +4 -1
  8. package/plugins/project-json.js +38 -1
  9. package/schemas/nx-schema.json +1 -1
  10. package/schemas/project-schema.json +1 -1
  11. package/src/adapter/angular-json.d.ts +4 -6
  12. package/src/adapter/angular-json.js +11 -15
  13. package/src/devkit-internals.d.ts +5 -0
  14. package/src/devkit-internals.js +11 -1
  15. package/src/generators/internal-utils/format-changed-files-with-prettier-if-available.js +3 -1
  16. package/src/generators/utils/project-configuration.js +6 -7
  17. package/src/hasher/task-hasher.js +1 -1
  18. package/src/migrations/update-15-1-0/set-project-names.js +1 -1
  19. package/src/plugins/js/index.js +6 -2
  20. package/src/plugins/js/lock-file/yarn-parser.js +21 -9
  21. package/src/project-graph/affected/locators/project-glob-changes.js +3 -1
  22. package/src/project-graph/affected/locators/workspace-projects.js +1 -1
  23. package/src/project-graph/build-nodes/workspace-projects.js +0 -32
  24. package/src/project-graph/project-graph.d.ts +1 -1
  25. package/src/project-graph/project-graph.js +1 -1
  26. package/src/project-graph/utils/project-configuration-utils.d.ts +2 -1
  27. package/src/project-graph/utils/project-configuration-utils.js +59 -38
  28. package/src/project-graph/utils/retrieve-workspace-files.d.ts +1 -1
  29. package/src/project-graph/utils/retrieve-workspace-files.js +13 -10
  30. package/src/tasks-runner/forked-process-task-runner.js +1 -1
  31. package/src/utils/find-matching-projects.js +1 -1
  32. package/src/utils/nx-plugin.d.ts +0 -1
  33. package/src/utils/nx-plugin.js +7 -0
  34. package/src/utils/package-json.d.ts +1 -0
  35. package/src/utils/package-json.js +11 -1
  36. package/src/utils/package-manager.js +1 -3
  37. package/src/utils/project-graph-utils.d.ts +0 -2
  38. package/src/utils/project-graph-utils.js +1 -21
  39. package/src/utils/testing/mock-fs.js +12 -0
package/bin/nx.js CHANGED
@@ -85,7 +85,7 @@ function main() {
85
85
  * - .env.local
86
86
  */
87
87
  function loadDotEnvFiles() {
88
- for (const file of ['.env', '.local.env', '.env.local']) {
88
+ for (const file of ['.local.env', '.env.local', '.env']) {
89
89
  (0, dotenv_1.config)({
90
90
  path: file,
91
91
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "16.7.1",
3
+ "version": "16.7.3",
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.1",
35
+ "@nrwl/tao": "16.7.3",
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.1",
85
- "@nx/nx-darwin-x64": "16.7.1",
86
- "@nx/nx-freebsd-x64": "16.7.1",
87
- "@nx/nx-linux-arm-gnueabihf": "16.7.1",
88
- "@nx/nx-linux-arm64-gnu": "16.7.1",
89
- "@nx/nx-linux-arm64-musl": "16.7.1",
90
- "@nx/nx-linux-x64-gnu": "16.7.1",
91
- "@nx/nx-linux-x64-musl": "16.7.1",
92
- "@nx/nx-win32-arm64-msvc": "16.7.1",
93
- "@nx/nx-win32-x64-msvc": "16.7.1"
84
+ "@nx/nx-darwin-arm64": "16.7.3",
85
+ "@nx/nx-darwin-x64": "16.7.3",
86
+ "@nx/nx-freebsd-x64": "16.7.3",
87
+ "@nx/nx-linux-arm-gnueabihf": "16.7.3",
88
+ "@nx/nx-linux-arm64-gnu": "16.7.3",
89
+ "@nx/nx-linux-arm64-musl": "16.7.3",
90
+ "@nx/nx-linux-x64-gnu": "16.7.3",
91
+ "@nx/nx-linux-x64-musl": "16.7.3",
92
+ "@nx/nx-win32-arm64-msvc": "16.7.3",
93
+ "@nx/nx-win32-x64-msvc": "16.7.3"
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": "8b38708d6c18496711695499d07c95f3ecc31cc9"
180
+ "gitHead": "6ff5487c5f4ed9ed008df2af39e37d98fd289259"
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 buildProjectConfigurationFromPackageJson(packageJson: {
6
- name: string;
7
- }, path: string, nxJson: NxJsonConfiguration): ProjectConfiguration & {
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
- (pkgJsonPath) => {
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
- root: directory,
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 declare const projectFilePatterns: string[];
1
+ export {};
@@ -1,4 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.projectFilePatterns = void 0;
4
- exports.projectFilePatterns = ['package.json'];
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>;
@@ -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;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema",
3
- "$id": "https://nx.dev/core-concepts/configuration#nxjson",
3
+ "$id": "https://nx.dev/reference/nx-json",
4
4
  "title": "JSON schema for Nx configuration",
5
5
  "type": "object",
6
6
  "properties": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema",
3
- "$id": "https://nx.dev/project-schema",
3
+ "$id": "https://nx.dev/reference/project-configuration",
4
4
  "title": "JSON schema for Nx projects",
5
5
  "type": "object",
6
6
  "properties": {
@@ -1,11 +1,9 @@
1
- import { ProjectConfiguration, ProjectsConfigurations } from '../config/workspace-json-project-json';
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.mergeAngularJsonAndProjects = exports.isAngularPluginInstalled = exports.shouldMergeAngularProjects = void 0;
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) {
@@ -8,3 +8,8 @@ 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
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';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.retrieveProjectConfigurationsWithAngularProjects = 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
  *
@@ -16,3 +16,13 @@ var calculate_default_project_name_1 = require("./config/calculate-default-proje
16
16
  Object.defineProperty(exports, "calculateDefaultProjectName", { enumerable: true, get: function () { return calculate_default_project_name_1.calculateDefaultProjectName; } });
17
17
  var retrieve_workspace_files_1 = require("./project-graph/utils/retrieve-workspace-files");
18
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; } });
@@ -34,7 +34,9 @@ function formatChangedFilesWithPrettierIfAvailable(tree) {
34
34
  if (support.ignored || !support.inferredParser) {
35
35
  return;
36
36
  }
37
- tree.write(file.path, prettier.format(file.content.toString('utf-8'), options));
37
+ tree.write(file.path,
38
+ // In prettier v3 the format result is a promise
39
+ yield prettier.format(file.content.toString('utf-8'), options));
38
40
  }
39
41
  catch (e) {
40
42
  console.warn(`Could not format ${file.path}. Error: "${e.message}"`);
@@ -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
- return projectFiles.reduce((projects, projectFile) => {
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.mergeProjectConfigurationIntoProjectsConfigurations)(projects, rootMap, config, projectFile);
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.mergeProjectConfigurationIntoProjectsConfigurations)(projects, rootMap,
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
- return projects;
155
- }, {});
153
+ }
154
+ return (0, project_configuration_utils_1.readProjectConfigurationsFromRootMap)(rootMap);
156
155
  }
157
156
  /**
158
157
  * Used to ensure that projects created during
@@ -168,7 +167,7 @@ function findCreatedProjectFiles(tree, globPatterns) {
168
167
  for (const change of tree.listChanges()) {
169
168
  if (change.type === 'CREATE') {
170
169
  const fileName = (0, path_1.basename)(change.path);
171
- if (globPatterns.some((pattern) => minimatch(change.path, pattern))) {
170
+ if (globPatterns.some((pattern) => minimatch(change.path, pattern, { dot: true }))) {
172
171
  createdProjectFiles.push(change.path);
173
172
  }
174
173
  else if (fileName === 'package.json') {
@@ -222,7 +222,7 @@ class TaskHasherImpl {
222
222
  const { getFilesForOutputs } = require('../native');
223
223
  const outputFiles = getFilesForOutputs(workspace_root_1.workspaceRoot, outputs);
224
224
  const filteredFiles = outputFiles.filter((p) => p === dependentTasksOutputFiles ||
225
- minimatch(p, dependentTasksOutputFiles));
225
+ minimatch(p, dependentTasksOutputFiles, { dot: true }));
226
226
  const hashDetails = {};
227
227
  const hashes = [];
228
228
  for (const [file, hash] of yield this.fileHasher.hashFiles(filteredFiles.map((p) => (0, path_1.join)(workspace_root_1.workspaceRoot, p)))) {
@@ -9,7 +9,7 @@ const retrieve_workspace_files_1 = require("../../project-graph/utils/retrieve-w
9
9
  function default_1(tree) {
10
10
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
11
11
  const nxJson = (0, nx_json_1.readNxJson)(tree);
12
- const projectFiles = (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(tree.root, nxJson);
12
+ const projectFiles = yield (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(tree.root, nxJson);
13
13
  const projectJsons = projectFiles.filter((f) => f.endsWith('project.json'));
14
14
  for (let f of projectJsons) {
15
15
  const projectJson = (0, json_1.readJson)(tree, f);
@@ -23,12 +23,16 @@ const processProjectGraph = (graph, context) => tslib_1.__awaiter(void 0, void 0
23
23
  let parsedLockFile;
24
24
  if (lockFileNeedsReprocessing(lockHash)) {
25
25
  parsedLockFile = (0, lock_file_1.parseLockFile)();
26
- writeLastProcessedLockfileHash(lockHash, parsedLockFile);
26
+ if (parsedLockFile) {
27
+ writeLastProcessedLockfileHash(lockHash, parsedLockFile);
28
+ }
27
29
  }
28
30
  else {
29
31
  parsedLockFile = readParsedLockFile();
30
32
  }
31
- builder.mergeProjectGraph(parsedLockFile);
33
+ if (parsedLockFile) {
34
+ builder.mergeProjectGraph(parsedLockFile);
35
+ }
32
36
  }
33
37
  }
34
38
  perf_hooks_1.performance.mark('build typescript dependencies - start');
@@ -18,13 +18,18 @@ function parseYarnLockfile(lockFileContent, packageJson, builder) {
18
18
  addDependencies(groupedDependencies, builder, keyMap);
19
19
  }
20
20
  exports.parseYarnLockfile = parseYarnLockfile;
21
- function getPackageNames(keys) {
22
- const packageNames = new Set();
21
+ function getPackageNameKeyPairs(keys) {
22
+ const result = new Map();
23
23
  keys.split(', ').forEach((key) => {
24
24
  const packageName = key.slice(0, key.indexOf('@', 1));
25
- packageNames.add(packageName);
25
+ if (result.has(packageName)) {
26
+ result.get(packageName).add(key);
27
+ }
28
+ else {
29
+ result.set(packageName, new Set([key]));
30
+ }
26
31
  });
27
- return Array.from(packageNames);
32
+ return result;
28
33
  }
29
34
  function addNodes(dependencies, packageJson, builder, keyMap, isBerry) {
30
35
  const nodes = new Map();
@@ -34,10 +39,13 @@ function addNodes(dependencies, packageJson, builder, keyMap, isBerry) {
34
39
  if (snapshot.linkType === 'soft' || keys.includes('@patch:')) {
35
40
  return;
36
41
  }
37
- const packageNames = getPackageNames(keys);
38
- packageNames.forEach((packageName) => {
39
- const version = findVersion(packageName, keys.split(', ')[0], snapshot, isBerry);
40
- keys.split(', ').forEach((key) => {
42
+ const nameKeyPairs = getPackageNameKeyPairs(keys);
43
+ nameKeyPairs.forEach((keySet, packageName) => {
44
+ const keysArray = Array.from(keySet);
45
+ // use key relevant to the package name
46
+ const version = findVersion(packageName, keysArray[0], snapshot, isBerry);
47
+ // use keys linked to the extracted package name
48
+ keysArray.forEach((key) => {
41
49
  var _a;
42
50
  // we don't need to keep duplicates, we can just track the keys
43
51
  const existingNode = (_a = nodes.get(packageName)) === null || _a === void 0 ? void 0 : _a.get(version);
@@ -111,7 +119,7 @@ function findHoistedNode(packageName, versionMap, combinedDeps) {
111
119
  }
112
120
  }
113
121
  function findVersion(packageName, key, snapshot, isBerry) {
114
- const versionRange = key.slice(packageName.length + 1);
122
+ const versionRange = key.slice(key.indexOf('@', 1) + 1);
115
123
  // check for alias packages
116
124
  const isAlias = isBerry
117
125
  ? snapshot.resolution && !snapshot.resolution.startsWith(`${packageName}@`)
@@ -358,6 +366,10 @@ function findPatchedKeys(dependencies, node) {
358
366
  if (!keys[0].startsWith(`${node.data.packageName}@patch:`)) {
359
367
  continue;
360
368
  }
369
+ // local patches are currently not supported
370
+ if (keys[0].includes('.yarn/patches')) {
371
+ continue;
372
+ }
361
373
  if (snapshot.version === node.data.version) {
362
374
  return [keys, snapshot];
363
375
  }
@@ -14,7 +14,9 @@ const getTouchedProjectsFromProjectGlobChanges = (touchedFiles, projectGraphNode
14
14
  const globPattern = (0, globs_1.combineGlobPatterns)((0, retrieve_workspace_files_1.configurationGlobs)(workspace_root_1.workspaceRoot, yield (0, nx_plugin_1.loadNxPlugins)(nxJson === null || nxJson === void 0 ? void 0 : nxJson.plugins, (0, installation_directory_1.getNxRequirePaths)(workspace_root_1.workspaceRoot), workspace_root_1.workspaceRoot)));
15
15
  const touchedProjects = new Set();
16
16
  for (const touchedFile of touchedFiles) {
17
- const isProjectFile = minimatch(touchedFile.file, globPattern);
17
+ const isProjectFile = minimatch(touchedFile.file, globPattern, {
18
+ dot: true,
19
+ });
18
20
  if (isProjectFile) {
19
21
  // If the file no longer exists on disk, then it was deleted
20
22
  if (!(0, fs_1.existsSync)((0, path_1.join)(workspace_root_1.workspaceRoot, touchedFile.file))) {
@@ -34,7 +34,7 @@ const getImplicitlyTouchedProjects = (fileChanges, projectGraphNodes, nxJson) =>
34
34
  });
35
35
  const touched = new Set();
36
36
  for (const [pattern, projects] of Object.entries(implicits)) {
37
- const implicitDependencyWasChanged = fileChanges.some((f) => minimatch(f.file, pattern));
37
+ const implicitDependencyWasChanged = fileChanges.some((f) => minimatch(f.file, pattern, { dot: true }));
38
38
  if (!implicitDependencyWasChanged) {
39
39
  continue;
40
40
  }
@@ -2,11 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeImplicitDependencies = exports.normalizeProjectTargets = exports.normalizeProjectNodes = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const path_1 = require("path");
6
- const fs_1 = require("fs");
7
- const workspace_root_1 = require("../../utils/workspace-root");
8
- const project_graph_utils_1 = require("../../utils/project-graph-utils");
9
- const fileutils_1 = require("../../utils/fileutils");
10
5
  const find_matching_projects_1 = require("../../utils/find-matching-projects");
11
6
  const logger_1 = require("../../utils/logger");
12
7
  const project_configuration_utils_1 = require("../utils/project-configuration-utils");
@@ -27,33 +22,6 @@ function normalizeProjectNodes(ctx, builder, nxJson) {
27
22
  }, {});
28
23
  for (const key of projects) {
29
24
  const p = ctx.projectsConfigurations.projects[key];
30
- const projectRoot = (0, path_1.join)(workspace_root_1.workspaceRoot, p.root);
31
- // Todo(@AgentEnder) we can move a lot of this to
32
- // builtin plugin inside workspaces.ts, but there would be some functional differences
33
- // - The plugin would only apply to package.json files found via the workspaces globs
34
- // - This means that scripts / tags / etc from the `nx` property wouldn't be read if a project
35
- // is being found by project.json and not included in the workspaces configuration. Maybe this is fine?
36
- if ((0, fs_1.existsSync)((0, path_1.join)(projectRoot, 'package.json'))) {
37
- p.targets = (0, project_graph_utils_1.mergeNpmScriptsWithTargets)(projectRoot, p.targets);
38
- try {
39
- const { nx } = (0, fileutils_1.readJsonFile)((0, path_1.join)(projectRoot, 'package.json'));
40
- if (nx === null || nx === void 0 ? void 0 : nx.tags) {
41
- p.tags = [...(p.tags || []), ...nx.tags];
42
- }
43
- if (nx === null || nx === void 0 ? void 0 : nx.implicitDependencies) {
44
- p.implicitDependencies = [
45
- ...(p.implicitDependencies || []),
46
- ...nx.implicitDependencies,
47
- ];
48
- }
49
- if (nx === null || nx === void 0 ? void 0 : nx.namedInputs) {
50
- p.namedInputs = Object.assign(Object.assign({}, (p.namedInputs || {})), nx.namedInputs);
51
- }
52
- }
53
- catch (_c) {
54
- // ignore json parser errors
55
- }
56
- }
57
25
  p.implicitDependencies = normalizeImplicitDependencies(key, p.implicitDependencies, partialProjectGraphNodes);
58
26
  p.targets = normalizeProjectTargets(p, nxJson.targetDefaults, key);
59
27
  // TODO: remove in v16
@@ -21,7 +21,7 @@ export declare function buildProjectGraphWithoutDaemon(): Promise<ProjectGraph>;
21
21
  * * It is running in the docker container.
22
22
  * * The daemon process is disabled because of the previous error when starting the daemon.
23
23
  * * `NX_DAEMON` is set to `false`.
24
- * * `useDaemon` is set to false in `nx.json`
24
+ * * `useDaemonProcess` is set to false in the options of the tasks runner inside `nx.json`
25
25
  *
26
26
  * `NX_DAEMON` env variable takes precedence:
27
27
  * * If it is set to true, the daemon will always be used.
@@ -95,7 +95,7 @@ function handleProjectGraphError(opts, e) {
95
95
  * * It is running in the docker container.
96
96
  * * The daemon process is disabled because of the previous error when starting the daemon.
97
97
  * * `NX_DAEMON` is set to `false`.
98
- * * `useDaemon` is set to false in `nx.json`
98
+ * * `useDaemonProcess` is set to false in the options of the tasks runner inside `nx.json`
99
99
  *
100
100
  * `NX_DAEMON` env variable takes precedence:
101
101
  * * If it is set to true, the daemon will always be used.
@@ -2,12 +2,13 @@ import { NxJsonConfiguration, TargetDefaults } from '../../config/nx-json';
2
2
  import { ProjectGraphExternalNode } from '../../config/project-graph';
3
3
  import { ProjectConfiguration, TargetConfiguration } from '../../config/workspace-json-project-json';
4
4
  import { NxPluginV2 } from '../../utils/nx-plugin';
5
- export declare function mergeProjectConfigurationIntoProjectsConfigurations(existingProjects: Record<string, ProjectConfiguration>, existingProjectRootMap: Map<string, string>, project: ProjectConfiguration, file: string): void;
5
+ export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Map<string, ProjectConfiguration>, project: ProjectConfiguration, file: string): void;
6
6
  export declare function buildProjectsConfigurationsFromProjectPathsAndPlugins(nxJson: NxJsonConfiguration, projectFiles: string[], // making this parameter allows devkit to pick up newly created projects
7
7
  plugins: NxPluginV2[], root?: string): {
8
8
  projects: Record<string, ProjectConfiguration>;
9
9
  externalNodes: Record<string, ProjectGraphExternalNode>;
10
10
  };
11
+ export declare function readProjectConfigurationsFromRootMap(projectRootMap: Map<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
11
12
  export declare function mergeTargetConfigurations(projectConfiguration: ProjectConfiguration, target: string, targetDefaults: TargetDefaults[string]): TargetConfiguration;
12
13
  export declare function resolveNxTokensInOptions<T extends Object | Array<unknown>>(object: T, project: ProjectConfiguration, key: string): T;
13
14
  export declare function readTargetDefaultsForTarget(targetName: string, targetDefaults: TargetDefaults, executor?: string): TargetDefaults[string];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.mergeTargetConfigurations = exports.buildProjectsConfigurationsFromProjectPathsAndPlugins = exports.mergeProjectConfigurationIntoProjectsConfigurations = void 0;
3
+ exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.mergeTargetConfigurations = exports.readProjectConfigurationsFromRootMap = exports.buildProjectsConfigurationsFromProjectPathsAndPlugins = exports.mergeProjectConfigurationIntoRootMap = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const node_path_1 = require("node:path");
6
6
  const package_json_workspaces_1 = require("../../../plugins/package-json-workspaces");
@@ -8,38 +8,27 @@ const project_json_1 = require("../../../plugins/project-json");
8
8
  const logger_1 = require("../../utils/logger");
9
9
  const workspace_root_1 = require("../../utils/workspace-root");
10
10
  const minimatch = require("minimatch");
11
- function mergeProjectConfigurationIntoProjectsConfigurations(
12
- // projectName -> ProjectConfiguration
13
- existingProjects,
14
- // projectRoot -> projectName
15
- existingProjectRootMap, project,
11
+ function mergeProjectConfigurationIntoRootMap(projectRootMap, project,
16
12
  // project.json is a special case, so we need to detect it.
17
13
  file) {
18
- let matchingProjectName = existingProjectRootMap.get(project.root);
19
- if (!matchingProjectName) {
20
- existingProjects[project.name] = project;
21
- existingProjectRootMap.set(project.root, project.name);
14
+ const matchingProject = projectRootMap.get(project.root);
15
+ if (!matchingProject) {
16
+ projectRootMap.set(project.root, project);
22
17
  return;
23
- // There are some special cases for handling project.json - mainly
24
- // that it should override any name the project already has.
25
18
  }
26
19
  else if (project.name &&
27
- project.name !== matchingProjectName &&
20
+ project.name !== matchingProject.name &&
28
21
  (0, node_path_1.basename)(file) === 'project.json') {
29
- // Copy config to new name
30
- existingProjects[project.name] = existingProjects[matchingProjectName];
31
- // Update name in project config
32
- existingProjects[project.name].name = project.name;
33
- // Update root map to point to new name
34
- existingProjectRootMap[project.root] = project.name;
35
- // Remove entry for old name
36
- delete existingProjects[matchingProjectName];
37
- // Update name that config should be merged to
38
- matchingProjectName = project.name;
22
+ // `name` inside project.json overrides any names from
23
+ // inference plugins
24
+ matchingProject.name = project.name;
39
25
  }
40
- const matchingProject = existingProjects[matchingProjectName];
41
- // This handles top level properties that are overwritten. `srcRoot`, `projectType`, or fields that Nx doesn't know about.
42
- const updatedProjectConfiguration = Object.assign(Object.assign(Object.assign({}, matchingProject), project), { name: matchingProjectName });
26
+ // This handles top level properties that are overwritten.
27
+ // e.g. `srcRoot`, `projectType`, or other fields that shouldn't be extended
28
+ // Note: `name` is set specifically here to keep it from changing. The name is
29
+ // always determined by the first inference plugin to ID a project, unless it has
30
+ // a project.json in which case it was already updated above.
31
+ const updatedProjectConfiguration = Object.assign(Object.assign(Object.assign({}, matchingProject), project), { name: matchingProject.name });
43
32
  // The next blocks handle properties that should be themselves merged (e.g. targets, tags, and implicit dependencies)
44
33
  if (project.tags && matchingProject.tags) {
45
34
  updatedProjectConfiguration.tags = matchingProject.tags.concat(project.tags);
@@ -54,18 +43,14 @@ file) {
54
43
  if (project.targets && matchingProject.targets) {
55
44
  updatedProjectConfiguration.targets = Object.assign(Object.assign({}, matchingProject.targets), project.targets);
56
45
  }
57
- if (updatedProjectConfiguration.name !== matchingProject.name) {
58
- delete existingProjects[matchingProject.name];
59
- }
60
- existingProjects[updatedProjectConfiguration.name] =
61
- updatedProjectConfiguration;
46
+ projectRootMap.set(updatedProjectConfiguration.root, updatedProjectConfiguration);
62
47
  }
63
- exports.mergeProjectConfigurationIntoProjectsConfigurations = mergeProjectConfigurationIntoProjectsConfigurations;
48
+ exports.mergeProjectConfigurationIntoRootMap = mergeProjectConfigurationIntoRootMap;
64
49
  function buildProjectsConfigurationsFromProjectPathsAndPlugins(nxJson, projectFiles, // making this parameter allows devkit to pick up newly created projects
65
50
  plugins, root = workspace_root_1.workspaceRoot) {
66
- var _a;
51
+ var _a, _b;
52
+ var _c;
67
53
  const projectRootMap = new Map();
68
- const projects = {};
69
54
  const externalNodes = {};
70
55
  // We push the nx core node builder onto the end, s.t. it overwrites any user specified behavior
71
56
  plugins.push((0, package_json_workspaces_1.getNxPackageJsonWorkspacesPlugin)(root), (0, project_json_1.getNxProjectJsonPlugin)(root));
@@ -76,22 +61,58 @@ plugins, root = workspace_root_1.workspaceRoot) {
76
61
  continue;
77
62
  }
78
63
  for (const file of projectFiles) {
79
- if (minimatch(file, pattern)) {
64
+ if (minimatch(file, pattern, { dot: true })) {
80
65
  const { projects: projectNodes, externalNodes: pluginExternalNodes } = configurationConstructor(file, {
81
- projectsConfigurations: projects,
82
66
  nxJsonConfiguration: nxJson,
83
67
  workspaceRoot: root,
84
68
  });
85
69
  for (const node in projectNodes) {
86
- mergeProjectConfigurationIntoProjectsConfigurations(projects, projectRootMap, projectNodes[node], file);
70
+ (_b = (_c = projectNodes[node]).name) !== null && _b !== void 0 ? _b : (_c.name = node);
71
+ mergeProjectConfigurationIntoRootMap(projectRootMap, projectNodes[node], file);
87
72
  }
88
73
  Object.assign(externalNodes, pluginExternalNodes);
89
74
  }
90
75
  }
91
76
  }
92
- return { projects, externalNodes };
77
+ return {
78
+ projects: readProjectConfigurationsFromRootMap(projectRootMap),
79
+ externalNodes,
80
+ };
93
81
  }
94
82
  exports.buildProjectsConfigurationsFromProjectPathsAndPlugins = buildProjectsConfigurationsFromProjectPathsAndPlugins;
83
+ function readProjectConfigurationsFromRootMap(projectRootMap) {
84
+ var _a;
85
+ const projects = {};
86
+ // If there are projects that have the same name, that is an error.
87
+ // This object tracks name -> (all roots of projects with that name)
88
+ // to provide better error messaging.
89
+ const errors = new Map();
90
+ for (const [root, configuration] of projectRootMap.entries()) {
91
+ if (!configuration.name) {
92
+ throw new Error(`Project at ${root} has no name provided.`);
93
+ }
94
+ else if (configuration.name in projects) {
95
+ let rootErrors = (_a = errors.get(configuration.name)) !== null && _a !== void 0 ? _a : [
96
+ projects[configuration.name].root,
97
+ ];
98
+ rootErrors.push(root);
99
+ errors.set(configuration.name, rootErrors);
100
+ }
101
+ else {
102
+ projects[configuration.name] = configuration;
103
+ }
104
+ }
105
+ if (errors.size > 0) {
106
+ throw new Error([
107
+ `The following projects are defined in multiple locations:`,
108
+ ...Array.from(errors.entries()).map(([project, roots]) => [`- ${project}: `, ...roots.map((r) => ` - ${r}`)].join('\n')),
109
+ '',
110
+ "To fix this, set a unique name for each project in a project.json inside the project's root. If the project does not currently have a project.json, you can create one that contains only a name.",
111
+ ].join('\n'));
112
+ }
113
+ return projects;
114
+ }
115
+ exports.readProjectConfigurationsFromRootMap = readProjectConfigurationsFromRootMap;
95
116
  function mergeTargetConfigurations(projectConfiguration, target, targetDefaults) {
96
117
  var _a;
97
118
  const targetConfiguration = (_a = projectConfiguration.targets) === null || _a === void 0 ? void 0 : _a[target];
@@ -35,7 +35,7 @@ export declare function retrieveProjectConfigurationsSync(workspaceRoot: string,
35
35
  externalNodes: Record<string, ProjectGraphExternalNode>;
36
36
  projectNodes: Record<string, ProjectConfiguration>;
37
37
  };
38
- export declare function retrieveProjectConfigurationPaths(root: string, nxJson: NxJsonConfiguration): string[];
38
+ export declare function retrieveProjectConfigurationPaths(root: string, nxJson: NxJsonConfiguration): Promise<string[]>;
39
39
  export declare function retrieveProjectConfigurationPathsWithoutPluginInference(root: string): string[];
40
40
  export declare function retrieveProjectConfigurationsWithoutPluginInference(root: string): Record<string, ProjectConfiguration>;
41
41
  export declare function configurationGlobs(workspaceRoot: string, plugins: NxPluginV2[]): string[];
@@ -66,8 +66,12 @@ function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, nxJson)
66
66
  var _a;
67
67
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
68
68
  const plugins = yield (0, nx_plugin_1.loadNxPlugins)((_a = nxJson === null || nxJson === void 0 ? void 0 : nxJson.plugins) !== null && _a !== void 0 ? _a : [], (0, installation_directory_1.getNxRequirePaths)(workspaceRoot), workspaceRoot);
69
+ if ((0, angular_json_1.shouldMergeAngularProjects)(workspaceRoot, true) &&
70
+ !plugins.some((p) => p.name === angular_json_1.NX_ANGULAR_JSON_PLUGIN_NAME)) {
71
+ plugins.push(angular_json_1.NxAngularJsonPlugin);
72
+ }
69
73
  const globs = configurationGlobs(workspaceRoot, plugins);
70
- return _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins, globs, true);
74
+ return _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins, globs);
71
75
  });
72
76
  }
73
77
  exports.retrieveProjectConfigurationsWithAngularProjects = retrieveProjectConfigurationsWithAngularProjects;
@@ -81,10 +85,10 @@ function retrieveProjectConfigurationsSync(workspaceRoot, nxJson) {
81
85
  return _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins, globs);
82
86
  }
83
87
  exports.retrieveProjectConfigurationsSync = retrieveProjectConfigurationsSync;
84
- function _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins, globs, includeProjectsFromAngularJson = false) {
88
+ function _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins, globs) {
85
89
  const { getProjectConfigurations } = require('../../native');
86
90
  return getProjectConfigurations(workspaceRoot, globs, (configs) => {
87
- const projectConfigurations = createProjectConfigurations(workspaceRoot, nxJson, configs, plugins, includeProjectsFromAngularJson);
91
+ const projectConfigurations = createProjectConfigurations(workspaceRoot, nxJson, configs, plugins);
88
92
  return {
89
93
  projectNodes: projectConfigurations.projects,
90
94
  externalNodes: projectConfigurations.externalNodes,
@@ -93,9 +97,11 @@ function _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins, globs, i
93
97
  }
94
98
  function retrieveProjectConfigurationPaths(root, nxJson) {
95
99
  var _a;
96
- const projectGlobPatterns = configurationGlobs(root, (0, nx_plugin_1.loadNxPluginsSync)((_a = nxJson === null || nxJson === void 0 ? void 0 : nxJson.plugins) !== null && _a !== void 0 ? _a : [], (0, installation_directory_1.getNxRequirePaths)(root), root));
97
- const { getProjectConfigurationFiles } = require('../../native');
98
- return getProjectConfigurationFiles(root, projectGlobPatterns);
100
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
101
+ const projectGlobPatterns = configurationGlobs(root, yield (0, nx_plugin_1.loadNxPlugins)((_a = nxJson === null || nxJson === void 0 ? void 0 : nxJson.plugins) !== null && _a !== void 0 ? _a : [], (0, installation_directory_1.getNxRequirePaths)(root), root));
102
+ const { getProjectConfigurationFiles } = require('../../native');
103
+ return getProjectConfigurationFiles(root, projectGlobPatterns);
104
+ });
99
105
  }
100
106
  exports.retrieveProjectConfigurationPaths = retrieveProjectConfigurationPaths;
101
107
  function retrieveProjectConfigurationPathsWithoutPluginInference(root) {
@@ -131,13 +137,10 @@ function buildAllWorkspaceFiles(projectFileMap, globalFiles) {
131
137
  perf_hooks_1.performance.measure('get-all-workspace-files', 'get-all-workspace-files:start', 'get-all-workspace-files:end');
132
138
  return fileData;
133
139
  }
134
- function createProjectConfigurations(workspaceRoot, nxJson, configFiles, plugins, includeProjectsFromAngularJson = false) {
140
+ function createProjectConfigurations(workspaceRoot, nxJson, configFiles, plugins) {
135
141
  perf_hooks_1.performance.mark('build-project-configs:start');
136
142
  const { projects, externalNodes } = (0, project_configuration_utils_1.buildProjectsConfigurationsFromProjectPathsAndPlugins)(nxJson, configFiles, plugins, workspaceRoot);
137
143
  let projectConfigurations = projects;
138
- if ((0, angular_json_1.shouldMergeAngularProjects)(workspaceRoot, includeProjectsFromAngularJson)) {
139
- projectConfigurations = (0, angular_json_1.mergeAngularJsonAndProjects)(projectConfigurations, workspaceRoot);
140
- }
141
144
  perf_hooks_1.performance.mark('build-project-configs:end');
142
145
  perf_hooks_1.performance.measure('build-project-configs', 'build-project-configs:start', 'build-project-configs:end');
143
146
  return {
@@ -310,9 +310,9 @@ class ForkedProcessTaskRunner {
310
310
  `.env.${task.target.target}`,
311
311
  `.${task.target.target}.env`,
312
312
  // Load base DotEnv Files at workspace root
313
- `.env`,
314
313
  `.local.env`,
315
314
  `.env.local`,
315
+ `.env`,
316
316
  ];
317
317
  for (const file of dotEnvFiles) {
318
318
  (0, dotenv_1.config)({
@@ -161,7 +161,7 @@ exports.getMatchingStringsWithCache = (() => {
161
161
  }
162
162
  const patternCache = minimatchCache.get(pattern);
163
163
  if (!regexCache.has(pattern)) {
164
- const regex = minimatch.makeRe(pattern);
164
+ const regex = minimatch.makeRe(pattern, { dot: true });
165
165
  if (regex) {
166
166
  regexCache.set(pattern, regex);
167
167
  }
@@ -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
  }
@@ -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: useBerry
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.mergeNpmScriptsWithTargets = exports.projectHasTargetAndConfiguration = exports.projectHasTarget = void 0;
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
+ });