nx 16.7.0 → 16.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "16.7.0",
3
+ "version": "16.7.1",
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.0",
35
+ "@nrwl/tao": "16.7.1",
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.0",
85
- "@nx/nx-darwin-x64": "16.7.0",
86
- "@nx/nx-freebsd-x64": "16.7.0",
87
- "@nx/nx-linux-arm-gnueabihf": "16.7.0",
88
- "@nx/nx-linux-arm64-gnu": "16.7.0",
89
- "@nx/nx-linux-arm64-musl": "16.7.0",
90
- "@nx/nx-linux-x64-gnu": "16.7.0",
91
- "@nx/nx-linux-x64-musl": "16.7.0",
92
- "@nx/nx-win32-arm64-msvc": "16.7.0",
93
- "@nx/nx-win32-x64-msvc": "16.7.0"
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"
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": "37fd20b7063be8fe23a45892f5a21c2703bc53a6"
180
+ "gitHead": "8b38708d6c18496711695499d07c95f3ecc31cc9"
181
181
  }
@@ -1,6 +1,4 @@
1
1
  import type { NxJsonConfiguration } from './nx-json';
2
2
  import { ProjectConfiguration, ProjectsConfigurations } from './workspace-json-project-json';
3
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;
4
+ export declare function findMatchingProjectInCwd(projects: Record<string, ProjectConfiguration>, relativeCwd: string): string | undefined;
@@ -1,9 +1,3 @@
1
- import { NxJsonConfiguration } from './nx-json';
2
- import { ProjectsConfigurations } from './workspace-json-project-json';
3
- /**
4
- * @deprecated Use readProjectsConfigurationFromProjectGraph(await createProjectGraphAsync())
5
- */
6
- export declare function readAllWorkspaceConfiguration(): ProjectsConfigurations & NxJsonConfiguration;
7
1
  /**
8
2
  * Returns information about where apps and libs will be created.
9
3
  */
@@ -1,17 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readNxJson = exports.workspaceLayout = exports.readAllWorkspaceConfiguration = void 0;
4
- const workspaces_1 = require("./workspaces");
5
- const workspace_root_1 = require("../utils/workspace-root");
3
+ exports.readNxJson = exports.workspaceLayout = void 0;
6
4
  const nx_json_1 = require("./nx-json");
7
- // TODO(vsavkin): Remove after Nx 16 is out
8
- /**
9
- * @deprecated Use readProjectsConfigurationFromProjectGraph(await createProjectGraphAsync())
10
- */
11
- function readAllWorkspaceConfiguration() {
12
- return new workspaces_1.Workspaces(workspace_root_1.workspaceRoot).readProjectsConfigurations();
13
- }
14
- exports.readAllWorkspaceConfiguration = readAllWorkspaceConfiguration;
15
5
  /**
16
6
  * Returns information about where apps and libs will be created.
17
7
  */
@@ -1,23 +1,15 @@
1
1
  import type { NxJsonConfiguration } from './nx-json';
2
2
  import { ProjectsConfigurations } from './workspace-json-project-json';
3
+ /**
4
+ * @deprecated This will be removed in v18. Use {@link readProjectsConfigurationFromProjectGraph} instead.
5
+ */
3
6
  export declare class Workspaces {
4
7
  private root;
5
- private cachedProjectsConfig;
6
8
  constructor(root: string);
7
9
  /**
8
- * @deprecated
9
- */
10
- readProjectsConfigurations(opts?: {
11
- _includeProjectsFromAngularJson?: boolean;
12
- }): ProjectsConfigurations;
13
- /**
14
- * Deprecated. Use readProjectsConfigurations
10
+ * @deprecated Use {@link readProjectsConfigurationFromProjectGraph} instead.
15
11
  */
16
- readWorkspaceConfiguration(opts?: {
17
- _ignorePluginInference?: boolean;
18
- _includeProjectsFromAngularJson?: boolean;
19
- }): ProjectsConfigurations & NxJsonConfiguration;
20
- private mergeTargetDefaultsIntoProjectDescriptions;
12
+ readWorkspaceConfiguration(): ProjectsConfigurations & NxJsonConfiguration;
21
13
  }
22
14
  /**
23
15
  * Pulled from toFileName in names from @nx/devkit.
@@ -2,57 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toProjectName = exports.Workspaces = void 0;
4
4
  const path_1 = require("path");
5
- const installation_directory_1 = require("../utils/installation-directory");
6
- const nx_plugin_1 = require("../utils/nx-plugin");
7
5
  const nx_json_1 = require("./nx-json");
8
- const angular_json_1 = require("../adapter/angular-json");
9
6
  const retrieve_workspace_files_1 = require("../project-graph/utils/retrieve-workspace-files");
10
- const project_configuration_utils_1 = require("../project-graph/utils/project-configuration-utils");
7
+ // TODO(v18): remove this class
8
+ /**
9
+ * @deprecated This will be removed in v18. Use {@link readProjectsConfigurationFromProjectGraph} instead.
10
+ */
11
11
  class Workspaces {
12
12
  constructor(root) {
13
13
  this.root = root;
14
14
  }
15
15
  /**
16
- * @deprecated
16
+ * @deprecated Use {@link readProjectsConfigurationFromProjectGraph} instead.
17
17
  */
18
- readProjectsConfigurations(opts) {
19
- if (this.cachedProjectsConfig &&
20
- process.env.NX_CACHE_PROJECTS_CONFIG !== 'false') {
21
- return this.cachedProjectsConfig;
22
- }
18
+ readWorkspaceConfiguration() {
23
19
  const nxJson = (0, nx_json_1.readNxJson)(this.root);
24
- const projectPaths = (0, retrieve_workspace_files_1.retrieveProjectConfigurationPaths)(this.root, nxJson);
25
- let projectsConfigurations = (0, project_configuration_utils_1.buildProjectsConfigurationsFromProjectPathsAndPlugins)(nxJson, projectPaths, (0, nx_plugin_1.loadNxPluginsSync)(nxJson.plugins, (0, installation_directory_1.getNxRequirePaths)(this.root), this.root), this.root).projects;
26
- if ((0, angular_json_1.shouldMergeAngularProjects)(this.root, opts === null || opts === void 0 ? void 0 : opts._includeProjectsFromAngularJson)) {
27
- projectsConfigurations = (0, angular_json_1.mergeAngularJsonAndProjects)(projectsConfigurations, this.root);
28
- }
29
- this.cachedProjectsConfig = {
30
- version: 2,
31
- projects: projectsConfigurations,
32
- };
33
- return this.cachedProjectsConfig;
34
- }
35
- /**
36
- * Deprecated. Use readProjectsConfigurations
37
- */
38
- readWorkspaceConfiguration(opts) {
39
- const nxJson = (0, nx_json_1.readNxJson)(this.root);
40
- return Object.assign(Object.assign({}, this.readProjectsConfigurations(opts)), nxJson);
41
- }
42
- mergeTargetDefaultsIntoProjectDescriptions(projects, nxJson) {
43
- var _a;
44
- for (const proj of Object.values(projects)) {
45
- if (proj.targets) {
46
- for (const targetName of Object.keys((_a = proj.targets) !== null && _a !== void 0 ? _a : {})) {
47
- const projectTargetDefinition = proj.targets[targetName];
48
- const defaults = (0, project_configuration_utils_1.readTargetDefaultsForTarget)(targetName, nxJson.targetDefaults, projectTargetDefinition.executor);
49
- if (defaults) {
50
- proj.targets[targetName] = (0, project_configuration_utils_1.mergeTargetConfigurations)(proj, targetName, defaults);
51
- }
52
- }
53
- }
54
- }
55
- return projects;
20
+ return Object.assign({ version: 2, projects: (0, retrieve_workspace_files_1.retrieveProjectConfigurationsSync)(this.root, nxJson)
21
+ .projectNodes }, nxJson);
56
22
  }
57
23
  }
58
24
  exports.Workspaces = Workspaces;
@@ -9,7 +9,6 @@ const nx_deps_cache_1 = require("../../project-graph/nx-deps-cache");
9
9
  const fileutils_1 = require("../../utils/fileutils");
10
10
  const file_watcher_sockets_1 = require("./file-watching/file-watcher-sockets");
11
11
  const logger_1 = require("./logger");
12
- const workspaces_1 = require("../../config/workspaces");
13
12
  const workspace_root_1 = require("../../utils/workspace-root");
14
13
  const child_process_1 = require("child_process");
15
14
  const file_hasher_1 = require("../../hasher/file-hasher");
@@ -128,7 +127,7 @@ function processCollectedUpdatedAndDeletedFiles() {
128
127
  perf_hooks_1.performance.mark('hash-watched-changes-end');
129
128
  perf_hooks_1.performance.measure('hash changed files from watcher', 'hash-watched-changes-start', 'hash-watched-changes-end');
130
129
  file_hasher_1.fileHasher.incrementalUpdate(updatedFiles, deletedFiles);
131
- let nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
130
+ const nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
132
131
  const { projectNodes } = yield (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(workspace_root_1.workspaceRoot, nxJson);
133
132
  const workspaceConfigHash = computeWorkspaceConfigHash(projectNodes);
134
133
  logger_1.serverLogger.requestLog(`Updated file-hasher based on watched changes, recomputing project graph...`);
@@ -195,10 +194,10 @@ function createAndSerializeProjectGraph() {
195
194
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
196
195
  try {
197
196
  perf_hooks_1.performance.mark('create-project-graph-start');
198
- const projectsConfigurations = new workspaces_1.Workspaces(workspace_root_1.workspaceRoot).readProjectsConfigurations();
197
+ const projectConfigurations = yield (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(workspace_root_1.workspaceRoot, (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot));
199
198
  const projectFileMap = copyFileMap(exports.projectFileMapWithFiles.projectFileMap);
200
199
  const allWorkspaceFiles = copyFileData(exports.projectFileMapWithFiles.allWorkspaceFiles);
201
- const { projectGraph, projectFileMapCache } = yield (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projectsConfigurations, knownExternalNodes, projectFileMap, allWorkspaceFiles, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readProjectFileMapCache)(), true);
200
+ const { projectGraph, projectFileMapCache } = yield (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projectConfigurations.projectNodes, knownExternalNodes, projectFileMap, allWorkspaceFiles, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readProjectFileMapCache)(), true);
202
201
  exports.currentProjectFileMapCache = projectFileMapCache;
203
202
  exports.currentProjectGraph = projectGraph;
204
203
  perf_hooks_1.performance.mark('create-project-graph-end');
@@ -18,7 +18,7 @@ export type { Generator, GeneratorCallback, Executor, ExecutorContext, TaskGraph
18
18
  * @category Workspace
19
19
  */
20
20
  export { Workspaces } from './config/workspaces';
21
- export { readAllWorkspaceConfiguration, workspaceLayout, } from './config/configuration';
21
+ export { workspaceLayout } from './config/configuration';
22
22
  export type { NxPlugin, NxPluginV1, NxPluginV2, ProjectTargetConfigurator, CreateNodes, CreateNodesFunction, CreateNodesContext, CreateDependencies, CreateDependenciesContext, } from './utils/nx-plugin';
23
23
  /**
24
24
  * @category Workspace
@@ -108,7 +108,7 @@ export { reverse } from './project-graph/operators';
108
108
  /**
109
109
  * @category Utils
110
110
  */
111
- export { createProjectGraphAsync, readCachedProjectGraph, } from './project-graph/project-graph';
111
+ export { createProjectGraphAsync, readCachedProjectGraph, readProjectsConfigurationFromProjectGraph, } from './project-graph/project-graph';
112
112
  /**
113
113
  * @category Utils
114
114
  */
@@ -4,14 +4,14 @@
4
4
  * Try hard to not add to this API to reduce the surface area we need to maintain.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.appRootPath = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.updateJson = exports.writeJson = exports.readJson = exports.validateDependency = exports.ProjectGraphBuilder = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.getWorkspacePath = exports.isStandaloneProject = exports.updateWorkspaceConfiguration = exports.readWorkspaceConfiguration = exports.getProjects = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.addProjectConfiguration = exports.runExecutor = exports.getPackageManagerVersion = exports.detectPackageManager = exports.getPackageManagerCommand = exports.output = exports.logger = exports.workspaceLayout = exports.readAllWorkspaceConfiguration = exports.Workspaces = void 0;
7
+ exports.createProjectFileMapUsingProjectGraph = exports.cacheDir = exports.hashArray = exports.defaultTasksRunner = exports.getOutputsForTargetAndConfiguration = exports.readProjectsConfigurationFromProjectGraph = exports.readCachedProjectGraph = exports.createProjectGraphAsync = exports.reverse = exports.appRootPath = exports.workspaceRoot = exports.normalizePath = exports.joinPathFragments = exports.stripIndents = exports.writeJsonFile = exports.readJsonFile = exports.stripJsonComments = exports.serializeJson = exports.parseJson = exports.updateJson = exports.writeJson = exports.readJson = exports.validateDependency = exports.ProjectGraphBuilder = exports.DependencyType = exports.updateNxJson = exports.readNxJson = exports.getWorkspacePath = exports.isStandaloneProject = exports.updateWorkspaceConfiguration = exports.readWorkspaceConfiguration = exports.getProjects = exports.updateProjectConfiguration = exports.removeProjectConfiguration = exports.readProjectConfiguration = exports.addProjectConfiguration = exports.runExecutor = exports.getPackageManagerVersion = exports.detectPackageManager = exports.getPackageManagerCommand = exports.output = exports.logger = exports.workspaceLayout = exports.Workspaces = void 0;
8
+ // TODO(v18): Remove this export
8
9
  /**
9
10
  * @category Workspace
10
11
  */
11
12
  var workspaces_1 = require("./config/workspaces");
12
13
  Object.defineProperty(exports, "Workspaces", { enumerable: true, get: function () { return workspaces_1.Workspaces; } });
13
14
  var configuration_1 = require("./config/configuration");
14
- Object.defineProperty(exports, "readAllWorkspaceConfiguration", { enumerable: true, get: function () { return configuration_1.readAllWorkspaceConfiguration; } });
15
15
  Object.defineProperty(exports, "workspaceLayout", { enumerable: true, get: function () { return configuration_1.workspaceLayout; } });
16
16
  /**
17
17
  * @category Logger
@@ -115,6 +115,7 @@ Object.defineProperty(exports, "reverse", { enumerable: true, get: function () {
115
115
  var project_graph_2 = require("./project-graph/project-graph");
116
116
  Object.defineProperty(exports, "createProjectGraphAsync", { enumerable: true, get: function () { return project_graph_2.createProjectGraphAsync; } });
117
117
  Object.defineProperty(exports, "readCachedProjectGraph", { enumerable: true, get: function () { return project_graph_2.readCachedProjectGraph; } });
118
+ Object.defineProperty(exports, "readProjectsConfigurationFromProjectGraph", { enumerable: true, get: function () { return project_graph_2.readProjectsConfigurationFromProjectGraph; } });
118
119
  /**
119
120
  * @category Utils
120
121
  */
@@ -7,3 +7,4 @@ export { createTempNpmDirectory } from './utils/package-manager';
7
7
  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
+ export { retrieveProjectConfigurationsWithAngularProjects } from './project-graph/utils/retrieve-workspace-files';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
3
+ 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
  *
@@ -14,3 +14,5 @@ var nx_json_1 = require("./config/nx-json");
14
14
  Object.defineProperty(exports, "readNxJsonFromDisk", { enumerable: true, get: function () { return nx_json_1.readNxJson; } });
15
15
  var calculate_default_project_name_1 = require("./config/calculate-default-project-name");
16
16
  Object.defineProperty(exports, "calculateDefaultProjectName", { enumerable: true, get: function () { return calculate_default_project_name_1.calculateDefaultProjectName; } });
17
+ var retrieve_workspace_files_1 = require("./project-graph/utils/retrieve-workspace-files");
18
+ Object.defineProperty(exports, "retrieveProjectConfigurationsWithAngularProjects", { enumerable: true, get: function () { return retrieve_workspace_files_1.retrieveProjectConfigurationsWithAngularProjects; } });
@@ -5,8 +5,8 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.convertNxExecutor = void 0;
7
7
  const tslib_1 = require("tslib");
8
- const workspaces_1 = require("../../config/workspaces");
9
8
  const nx_json_1 = require("../../config/nx-json");
9
+ const retrieve_workspace_files_1 = require("../../project-graph/utils/retrieve-workspace-files");
10
10
  /**
11
11
  * Convert an Nx Executor into an Angular Devkit Builder
12
12
  *
@@ -14,10 +14,12 @@ const nx_json_1 = require("../../config/nx-json");
14
14
  */
15
15
  function convertNxExecutor(executor) {
16
16
  const builderFunction = (options, builderContext) => {
17
- const workspaces = new workspaces_1.Workspaces(builderContext.workspaceRoot);
18
- const projectsConfigurations = workspaces.readProjectsConfigurations();
19
17
  const promise = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
20
18
  const nxJsonConfiguration = (0, nx_json_1.readNxJson)(builderContext.workspaceRoot);
19
+ const projectsConfigurations = {
20
+ version: 2,
21
+ projects: (yield (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(builderContext.workspaceRoot, nxJsonConfiguration)).projectNodes,
22
+ };
21
23
  const context = {
22
24
  root: builderContext.workspaceRoot,
23
25
  projectName: builderContext.target.project,
@@ -490,6 +490,7 @@ class TaskHasherImpl {
490
490
  this.runtimeHashes[mapKey] = new Promise((res, rej) => {
491
491
  (0, child_process_1.exec)(runtime, {
492
492
  windowsHide: true,
493
+ cwd: workspace_root_1.workspaceRoot,
493
494
  }, (err, stdout, stderr) => {
494
495
  if (err) {
495
496
  rej(new Error(`Nx failed to execute {runtime: '${runtime}'}. ${err}.`));
@@ -98,9 +98,7 @@ function normalizeProjectTargets(project, targetDefaults, projectName) {
98
98
  for (const target in targets) {
99
99
  // We need to know the executor for use in readTargetDefaultsForTarget,
100
100
  // but we haven't resolved the `command` syntactic sugar yet.
101
- const executor = ((_b = targets[target].executor) !== null && _b !== void 0 ? _b : targets[target].command)
102
- ? 'nx:run-commands'
103
- : null;
101
+ const executor = (_b = targets[target].executor) !== null && _b !== void 0 ? _b : (targets[target].command ? 'nx:run-commands' : null);
104
102
  // Allows things like { targetDefaults: { build: { command: tsc } } }
105
103
  const defaults = resolveCommandSyntacticSugar((0, project_configuration_utils_1.readTargetDefaultsForTarget)(target, targetDefaults, executor), `targetDefaults:${target}`);
106
104
  targets[target] = resolveCommandSyntacticSugar(targets[target], `${projectName}:${target}`);
@@ -1,12 +1,12 @@
1
1
  import { FileData } from './file-utils';
2
2
  import { ProjectFileMapCache } from './nx-deps-cache';
3
3
  import { ProjectFileMap, ProjectGraph, ProjectGraphExternalNode } from '../config/project-graph';
4
- import { ProjectsConfigurations } from '../config/workspace-json-project-json';
4
+ import { ProjectConfiguration } from '../config/workspace-json-project-json';
5
5
  export declare function getProjectFileMap(): {
6
6
  projectFileMap: ProjectFileMap;
7
7
  allWorkspaceFiles: FileData[];
8
8
  };
9
- export declare function buildProjectGraphUsingProjectFileMap(projectsConfigurations: ProjectsConfigurations, externalNodes: Record<string, ProjectGraphExternalNode>, projectFileMap: ProjectFileMap, allWorkspaceFiles: FileData[], fileMap: ProjectFileMapCache | null, shouldWriteCache: boolean): Promise<{
9
+ export declare function buildProjectGraphUsingProjectFileMap(projects: Record<string, ProjectConfiguration>, externalNodes: Record<string, ProjectGraphExternalNode>, projectFileMap: ProjectFileMap, allWorkspaceFiles: FileData[], fileMap: ProjectFileMapCache | null, shouldWriteCache: boolean): Promise<{
10
10
  projectGraph: ProjectGraph;
11
11
  projectFileMapCache: ProjectFileMapCache;
12
12
  }>;
@@ -29,19 +29,19 @@ function getProjectFileMap() {
29
29
  }
30
30
  }
31
31
  exports.getProjectFileMap = getProjectFileMap;
32
- function buildProjectGraphUsingProjectFileMap(projectsConfigurations, externalNodes, projectFileMap, allWorkspaceFiles, fileMap, shouldWriteCache) {
32
+ function buildProjectGraphUsingProjectFileMap(projects, externalNodes, projectFileMap, allWorkspaceFiles, fileMap, shouldWriteCache) {
33
33
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
34
34
  storedProjectFileMap = projectFileMap;
35
35
  storedAllWorkspaceFiles = allWorkspaceFiles;
36
36
  const nxJson = (0, configuration_1.readNxJson)();
37
37
  const projectGraphVersion = '6.0';
38
- (0, assert_workspace_validity_1.assertWorkspaceValidity)(projectsConfigurations, nxJson);
38
+ (0, assert_workspace_validity_1.assertWorkspaceValidity)(projects, nxJson);
39
39
  const packageJsonDeps = readCombinedDeps();
40
40
  const rootTsConfig = readRootTsConfig();
41
41
  let filesToProcess;
42
42
  let cachedFileData;
43
43
  const useCacheData = fileMap &&
44
- !(0, nx_deps_cache_1.shouldRecomputeWholeGraph)(fileMap, packageJsonDeps, projectsConfigurations, nxJson, rootTsConfig);
44
+ !(0, nx_deps_cache_1.shouldRecomputeWholeGraph)(fileMap, packageJsonDeps, projects, nxJson, rootTsConfig);
45
45
  if (useCacheData) {
46
46
  const fromCache = (0, nx_deps_cache_1.extractCachedFileData)(projectFileMap, fileMap);
47
47
  filesToProcess = fromCache.filesToProcess;
@@ -51,7 +51,7 @@ function buildProjectGraphUsingProjectFileMap(projectsConfigurations, externalNo
51
51
  filesToProcess = projectFileMap;
52
52
  cachedFileData = {};
53
53
  }
54
- const context = createContext(projectsConfigurations, nxJson, projectFileMap, filesToProcess);
54
+ const context = createContext(projects, nxJson, projectFileMap, filesToProcess);
55
55
  let projectGraph = yield buildProjectGraphUsingContext(nxJson, externalNodes, context, cachedFileData, projectGraphVersion);
56
56
  const projectFileMapCache = (0, nx_deps_cache_1.createProjectFileMapCache)(nxJson, packageJsonDeps, projectFileMap, rootTsConfig);
57
57
  if (shouldWriteCache) {
@@ -102,15 +102,18 @@ function buildProjectGraphUsingContext(nxJson, knownExternalNodes, ctx, cachedFi
102
102
  return finalGraph;
103
103
  });
104
104
  }
105
- function createContext(projectsConfigurations, nxJson, fileMap, filesToProcess) {
106
- const projects = Object.keys(projectsConfigurations.projects).reduce((map, projectName) => {
107
- map[projectName] = Object.assign({}, projectsConfigurations.projects[projectName]);
105
+ function createContext(projects, nxJson, fileMap, filesToProcess) {
106
+ const clonedProjects = Object.keys(projects).reduce((map, projectName) => {
107
+ map[projectName] = Object.assign({}, projects[projectName]);
108
108
  return map;
109
109
  }, {});
110
110
  return {
111
111
  nxJsonConfiguration: nxJson,
112
- projectsConfigurations,
113
- workspace: Object.assign(Object.assign(Object.assign({}, projectsConfigurations), nxJson), { projects }),
112
+ workspace: Object.assign({ version: 2, projects: clonedProjects }, nxJson),
113
+ projectsConfigurations: {
114
+ version: 2,
115
+ projects: clonedProjects,
116
+ },
114
117
  fileMap,
115
118
  filesToProcess,
116
119
  };
@@ -17,6 +17,10 @@ export declare function isWholeFileChange(change: Change): change is WholeFileCh
17
17
  export declare function isDeletedFileChange(change: Change): change is DeletedFileChange;
18
18
  export declare function calculateFileChanges(files: string[], allWorkspaceFiles: FileData[], nxArgs?: NxArgs, readFileAtRevision?: (f: string, r: void | string) => string, ignore?: any): FileChange[];
19
19
  export declare const TEN_MEGABYTES: number;
20
+ /**
21
+ * TODO(v18): Remove this function
22
+ * @deprecated To get projects use {@link retrieveProjectConfigurations} instead
23
+ */
20
24
  export declare function readWorkspaceConfig(opts: {
21
25
  format: 'angularCli' | 'nx';
22
26
  path?: string;
@@ -24,4 +28,4 @@ export declare function readWorkspaceConfig(opts: {
24
28
  export declare function defaultFileRead(filePath: string): string | null;
25
29
  export declare function readPackageJson(): any;
26
30
  export { FileData };
27
- export { readNxJson, readAllWorkspaceConfiguration, workspaceLayout, } from '../config/configuration';
31
+ export { readNxJson, workspaceLayout } from '../config/configuration';
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.workspaceLayout = exports.readAllWorkspaceConfiguration = exports.readNxJson = exports.readPackageJson = exports.defaultFileRead = exports.readWorkspaceConfig = exports.TEN_MEGABYTES = exports.calculateFileChanges = exports.isDeletedFileChange = exports.isWholeFileChange = exports.DeletedFileChange = exports.WholeFileChange = void 0;
4
- const workspaces_1 = require("../config/workspaces");
3
+ exports.workspaceLayout = exports.readNxJson = exports.readPackageJson = exports.defaultFileRead = exports.readWorkspaceConfig = exports.TEN_MEGABYTES = exports.calculateFileChanges = exports.isDeletedFileChange = exports.isWholeFileChange = exports.DeletedFileChange = exports.WholeFileChange = void 0;
5
4
  const child_process_1 = require("child_process");
6
5
  const fs_1 = require("fs");
7
6
  const path_1 = require("path");
@@ -12,6 +11,7 @@ const json_diff_1 = require("../utils/json-diff");
12
11
  const project_graph_1 = require("./project-graph");
13
12
  const angular_json_1 = require("../adapter/angular-json");
14
13
  const ignore_1 = require("../utils/ignore");
14
+ const retrieve_workspace_files_1 = require("./utils/retrieve-workspace-files");
15
15
  class WholeFileChange {
16
16
  constructor() {
17
17
  this.type = 'WholeFileChange';
@@ -93,15 +93,23 @@ function defaultReadFileAtRevision(file, revision) {
93
93
  return '';
94
94
  }
95
95
  }
96
+ /**
97
+ * TODO(v18): Remove this function
98
+ * @deprecated To get projects use {@link retrieveProjectConfigurations} instead
99
+ */
96
100
  function readWorkspaceConfig(opts) {
97
101
  let configuration = null;
102
+ const root = opts.path || process.cwd();
103
+ const nxJson = (0, configuration_1.readNxJson)(root);
98
104
  try {
99
105
  const projectGraph = (0, project_graph_1.readCachedProjectGraph)();
100
- configuration = Object.assign(Object.assign({}, (0, configuration_1.readNxJson)()), (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph));
106
+ configuration = Object.assign(Object.assign({}, nxJson), (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(projectGraph));
101
107
  }
102
108
  catch (_a) {
103
- const ws = new workspaces_1.Workspaces(opts.path || process.cwd());
104
- configuration = ws.readProjectsConfigurations();
109
+ configuration = {
110
+ version: 2,
111
+ projects: (0, retrieve_workspace_files_1.retrieveProjectConfigurationsSync)(root, nxJson).projectNodes,
112
+ };
105
113
  }
106
114
  if (opts.format === 'angularCli') {
107
115
  return (0, angular_json_1.toOldFormat)(configuration);
@@ -127,5 +135,4 @@ exports.readPackageJson = readPackageJson;
127
135
  // TODO(17): Remove these exports
128
136
  var configuration_2 = require("../config/configuration");
129
137
  Object.defineProperty(exports, "readNxJson", { enumerable: true, get: function () { return configuration_2.readNxJson; } });
130
- Object.defineProperty(exports, "readAllWorkspaceConfiguration", { enumerable: true, get: function () { return configuration_2.readAllWorkspaceConfiguration; } });
131
138
  Object.defineProperty(exports, "workspaceLayout", { enumerable: true, get: function () { return configuration_2.workspaceLayout; } });
@@ -1,6 +1,6 @@
1
1
  import { NxJsonConfiguration } from '../config/nx-json';
2
2
  import { FileData, ProjectFileMap, ProjectGraph } from '../config/project-graph';
3
- import { ProjectsConfigurations } from '../config/workspace-json-project-json';
3
+ import { ProjectConfiguration } from '../config/workspace-json-project-json';
4
4
  export interface ProjectFileMapCache {
5
5
  version: string;
6
6
  nxVersion: string;
@@ -26,7 +26,7 @@ export declare function createProjectFileMapCache(nxJson: NxJsonConfiguration<'*
26
26
  };
27
27
  }): ProjectFileMapCache;
28
28
  export declare function writeCache(cache: ProjectFileMapCache, projectGraph: ProjectGraph): void;
29
- export declare function shouldRecomputeWholeGraph(cache: ProjectFileMapCache, packageJsonDeps: Record<string, string>, projects: ProjectsConfigurations, nxJson: NxJsonConfiguration, tsConfig: {
29
+ export declare function shouldRecomputeWholeGraph(cache: ProjectFileMapCache, packageJsonDeps: Record<string, string>, projects: Record<string, ProjectConfiguration>, nxJson: NxJsonConfiguration, tsConfig: {
30
30
  compilerOptions: {
31
31
  paths: {
32
32
  [k: string]: any;
@@ -131,7 +131,7 @@ function shouldRecomputeWholeGraph(cache, packageJsonDeps, projects, nxJson, tsC
131
131
  }
132
132
  // we have a cached project that is no longer present
133
133
  const cachedNodes = Object.keys(cache.projectFileMap);
134
- if (cachedNodes.some((p) => projects.projects[p] === undefined)) {
134
+ if (cachedNodes.some((p) => projects[p] === undefined)) {
135
135
  return true;
136
136
  }
137
137
  // a path mapping for an existing project has changed
@@ -6,6 +6,9 @@ import { ProjectConfiguration, ProjectsConfigurations } from '../config/workspac
6
6
  */
7
7
  export declare function readCachedProjectGraph(): ProjectGraph;
8
8
  export declare function readCachedProjectConfiguration(projectName: string): ProjectConfiguration;
9
+ /**
10
+ * Get the {@link ProjectsConfigurations} from the {@link ProjectGraph}
11
+ */
9
12
  export declare function readProjectsConfigurationFromProjectGraph(projectGraph: ProjectGraph): ProjectsConfigurations;
10
13
  export declare function buildProjectGraphWithoutDaemon(): Promise<ProjectGraph>;
11
14
  /**
@@ -47,6 +47,9 @@ function readCachedProjectConfiguration(projectName) {
47
47
  return node.data;
48
48
  }
49
49
  exports.readCachedProjectConfiguration = readCachedProjectConfiguration;
50
+ /**
51
+ * Get the {@link ProjectsConfigurations} from the {@link ProjectGraph}
52
+ */
50
53
  function readProjectsConfigurationFromProjectGraph(projectGraph) {
51
54
  return {
52
55
  projects: Object.fromEntries(Object.entries(projectGraph.nodes).map(([project, { data }]) => [
@@ -62,7 +65,7 @@ function buildProjectGraphWithoutDaemon() {
62
65
  const nxJson = (0, nx_json_1.readNxJson)();
63
66
  const { allWorkspaceFiles, projectFileMap, projectConfigurations, externalNodes, } = yield (0, retrieve_workspace_files_1.retrieveWorkspaceFiles)(workspace_root_1.workspaceRoot, nxJson);
64
67
  const cacheEnabled = process.env.NX_CACHE_PROJECT_GRAPH !== 'false';
65
- return (yield (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projectConfigurations, externalNodes, projectFileMap, allWorkspaceFiles, cacheEnabled ? (0, nx_deps_cache_1.readProjectFileMapCache)() : null, cacheEnabled)).projectGraph;
68
+ return (yield (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projectConfigurations.projects, externalNodes, projectFileMap, allWorkspaceFiles, cacheEnabled ? (0, nx_deps_cache_1.readProjectFileMapCache)() : null, cacheEnabled)).projectGraph;
66
69
  });
67
70
  }
68
71
  exports.buildProjectGraphWithoutDaemon = buildProjectGraphWithoutDaemon;
@@ -24,6 +24,17 @@ export declare function retrieveProjectConfigurations(workspaceRoot: string, nxJ
24
24
  externalNodes: Record<string, ProjectGraphExternalNode>;
25
25
  projectNodes: Record<string, ProjectConfiguration>;
26
26
  }>;
27
+ export declare function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<{
28
+ externalNodes: Record<string, ProjectGraphExternalNode>;
29
+ projectNodes: Record<string, ProjectConfiguration>;
30
+ }>;
31
+ /**
32
+ * @deprecated Use {@link retrieveProjectConfigurations} instead.
33
+ */
34
+ export declare function retrieveProjectConfigurationsSync(workspaceRoot: string, nxJson: NxJsonConfiguration): {
35
+ externalNodes: Record<string, ProjectGraphExternalNode>;
36
+ projectNodes: Record<string, ProjectConfiguration>;
37
+ };
27
38
  export declare function retrieveProjectConfigurationPaths(root: string, nxJson: NxJsonConfiguration): string[];
28
39
  export declare function retrieveProjectConfigurationPathsWithoutPluginInference(root: string): string[];
29
40
  export declare function retrieveProjectConfigurationsWithoutPluginInference(root: string): Record<string, ProjectConfiguration>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configurationGlobs = exports.retrieveProjectConfigurationsWithoutPluginInference = exports.retrieveProjectConfigurationPathsWithoutPluginInference = exports.retrieveProjectConfigurationPaths = exports.retrieveProjectConfigurations = exports.retrieveWorkspaceFiles = void 0;
3
+ exports.configurationGlobs = exports.retrieveProjectConfigurationsWithoutPluginInference = exports.retrieveProjectConfigurationPathsWithoutPluginInference = exports.retrieveProjectConfigurationPaths = exports.retrieveProjectConfigurationsSync = exports.retrieveProjectConfigurationsWithAngularProjects = exports.retrieveProjectConfigurations = exports.retrieveWorkspaceFiles = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const perf_hooks_1 = require("perf_hooks");
6
6
  const installation_directory_1 = require("../../utils/installation-directory");
@@ -56,19 +56,41 @@ exports.retrieveWorkspaceFiles = retrieveWorkspaceFiles;
56
56
  function retrieveProjectConfigurations(workspaceRoot, nxJson) {
57
57
  var _a;
58
58
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
59
- const { getProjectConfigurations } = require('../../native');
60
59
  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);
61
60
  const globs = configurationGlobs(workspaceRoot, plugins);
62
- return getProjectConfigurations(workspaceRoot, globs, (configs) => {
63
- const projectConfigurations = createProjectConfigurations(workspaceRoot, nxJson, configs, plugins);
64
- return {
65
- projectNodes: projectConfigurations.projects,
66
- externalNodes: projectConfigurations.externalNodes,
67
- };
68
- });
61
+ return _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins, globs);
69
62
  });
70
63
  }
71
64
  exports.retrieveProjectConfigurations = retrieveProjectConfigurations;
65
+ function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, nxJson) {
66
+ var _a;
67
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
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
+ const globs = configurationGlobs(workspaceRoot, plugins);
70
+ return _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins, globs, true);
71
+ });
72
+ }
73
+ exports.retrieveProjectConfigurationsWithAngularProjects = retrieveProjectConfigurationsWithAngularProjects;
74
+ /**
75
+ * @deprecated Use {@link retrieveProjectConfigurations} instead.
76
+ */
77
+ function retrieveProjectConfigurationsSync(workspaceRoot, nxJson) {
78
+ var _a;
79
+ const plugins = (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)(workspaceRoot), workspaceRoot);
80
+ const globs = configurationGlobs(workspaceRoot, plugins);
81
+ return _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins, globs);
82
+ }
83
+ exports.retrieveProjectConfigurationsSync = retrieveProjectConfigurationsSync;
84
+ function _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins, globs, includeProjectsFromAngularJson = false) {
85
+ const { getProjectConfigurations } = require('../../native');
86
+ return getProjectConfigurations(workspaceRoot, globs, (configs) => {
87
+ const projectConfigurations = createProjectConfigurations(workspaceRoot, nxJson, configs, plugins, includeProjectsFromAngularJson);
88
+ return {
89
+ projectNodes: projectConfigurations.projects,
90
+ externalNodes: projectConfigurations.externalNodes,
91
+ };
92
+ });
93
+ }
72
94
  function retrieveProjectConfigurationPaths(root, nxJson) {
73
95
  var _a;
74
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));
@@ -109,11 +131,11 @@ function buildAllWorkspaceFiles(projectFileMap, globalFiles) {
109
131
  perf_hooks_1.performance.measure('get-all-workspace-files', 'get-all-workspace-files:start', 'get-all-workspace-files:end');
110
132
  return fileData;
111
133
  }
112
- function createProjectConfigurations(workspaceRoot, nxJson, configFiles, plugins) {
134
+ function createProjectConfigurations(workspaceRoot, nxJson, configFiles, plugins, includeProjectsFromAngularJson = false) {
113
135
  perf_hooks_1.performance.mark('build-project-configs:start');
114
136
  const { projects, externalNodes } = (0, project_configuration_utils_1.buildProjectsConfigurationsFromProjectPathsAndPlugins)(nxJson, configFiles, plugins, workspaceRoot);
115
137
  let projectConfigurations = projects;
116
- if ((0, angular_json_1.shouldMergeAngularProjects)(workspaceRoot, false)) {
138
+ if ((0, angular_json_1.shouldMergeAngularProjects)(workspaceRoot, includeProjectsFromAngularJson)) {
117
139
  projectConfigurations = (0, angular_json_1.mergeAngularJsonAndProjects)(projectConfigurations, workspaceRoot);
118
140
  }
119
141
  perf_hooks_1.performance.mark('build-project-configs:end');
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TaskProfilingLifeCycle = void 0;
4
- const perf_hooks_1 = require("perf_hooks");
5
4
  const path_1 = require("path");
6
5
  const fileutils_1 = require("../../utils/fileutils");
7
6
  class TaskProfilingLifeCycle {
@@ -17,7 +16,7 @@ class TaskProfilingLifeCycle {
17
16
  }
18
17
  for (let t of tasks) {
19
18
  this.timings[t.id] = {
20
- perfStart: perf_hooks_1.performance.now(),
19
+ perfStart: Date.now(),
21
20
  };
22
21
  }
23
22
  }
@@ -30,7 +29,7 @@ class TaskProfilingLifeCycle {
30
29
  this.timings[tr.task.id].perfEnd = tr.task.endTime;
31
30
  }
32
31
  else {
33
- this.timings[tr.task.id].perfEnd = perf_hooks_1.performance.now();
32
+ this.timings[tr.task.id].perfEnd = Date.now();
34
33
  }
35
34
  }
36
35
  this.recordTaskCompletions(taskResults, metadata);
@@ -1,3 +1,3 @@
1
- import { ProjectsConfigurations } from '../config/workspace-json-project-json';
1
+ import { ProjectConfiguration } from '../config/workspace-json-project-json';
2
2
  import { NxJsonConfiguration } from '../config/nx-json';
3
- export declare function assertWorkspaceValidity(projectsConfigurations: ProjectsConfigurations, nxJson: NxJsonConfiguration): void;
3
+ export declare function assertWorkspaceValidity(projects: Record<string, ProjectConfiguration>, nxJson: NxJsonConfiguration): void;
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assertWorkspaceValidity = void 0;
4
4
  const find_matching_projects_1 = require("./find-matching-projects");
5
5
  const output_1 = require("./output");
6
- function assertWorkspaceValidity(projectsConfigurations, nxJson) {
7
- const projectNames = Object.keys(projectsConfigurations.projects);
6
+ function assertWorkspaceValidity(projects, nxJson) {
7
+ const projectNames = Object.keys(projects);
8
8
  const projectGraphNodes = projectNames.reduce((graph, project) => {
9
- const projectConfiguration = projectsConfigurations.projects[project];
9
+ const projectConfiguration = projects[project];
10
10
  graph[project] = {
11
11
  name: project,
12
12
  type: projectConfiguration.projectType === 'library' ? 'lib' : 'app',
@@ -14,7 +14,6 @@ function assertWorkspaceValidity(projectsConfigurations, nxJson) {
14
14
  };
15
15
  return graph;
16
16
  }, {});
17
- const projects = Object.assign({}, projectsConfigurations.projects);
18
17
  const invalidImplicitDependencies = new Map();
19
18
  if (nxJson.implicitDependencies) {
20
19
  output_1.output.warn({