nx 16.5.2 → 16.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "16.5.2",
3
+ "version": "16.5.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.5.2",
35
+ "@nrwl/tao": "16.5.3",
36
36
  "@parcel/watcher": "2.0.4",
37
37
  "@yarnpkg/lockfile": "^1.1.0",
38
38
  "@yarnpkg/parsers": "3.0.0-rc.46",
@@ -80,16 +80,16 @@
80
80
  }
81
81
  },
82
82
  "optionalDependencies": {
83
- "@nx/nx-darwin-arm64": "16.5.2",
84
- "@nx/nx-darwin-x64": "16.5.2",
85
- "@nx/nx-freebsd-x64": "16.5.2",
86
- "@nx/nx-linux-arm-gnueabihf": "16.5.2",
87
- "@nx/nx-linux-arm64-gnu": "16.5.2",
88
- "@nx/nx-linux-arm64-musl": "16.5.2",
89
- "@nx/nx-linux-x64-gnu": "16.5.2",
90
- "@nx/nx-linux-x64-musl": "16.5.2",
91
- "@nx/nx-win32-arm64-msvc": "16.5.2",
92
- "@nx/nx-win32-x64-msvc": "16.5.2"
83
+ "@nx/nx-darwin-arm64": "16.5.3",
84
+ "@nx/nx-darwin-x64": "16.5.3",
85
+ "@nx/nx-freebsd-x64": "16.5.3",
86
+ "@nx/nx-linux-arm-gnueabihf": "16.5.3",
87
+ "@nx/nx-linux-arm64-gnu": "16.5.3",
88
+ "@nx/nx-linux-arm64-musl": "16.5.3",
89
+ "@nx/nx-linux-x64-gnu": "16.5.3",
90
+ "@nx/nx-linux-x64-musl": "16.5.3",
91
+ "@nx/nx-win32-arm64-msvc": "16.5.3",
92
+ "@nx/nx-win32-x64-msvc": "16.5.3"
93
93
  },
94
94
  "nx-migrations": {
95
95
  "migrations": "./migrations.json",
@@ -175,5 +175,5 @@
175
175
  },
176
176
  "main": "./bin/nx.js",
177
177
  "types": "./bin/nx.d.ts",
178
- "gitHead": "928273940d11aa7dea87cb625a92f2c3ec62e726"
178
+ "gitHead": "e886dc76e203b05908b1a1b8872dee834cc4d2c8"
179
179
  }
@@ -73,7 +73,7 @@ export declare function inferProjectFromNonStandardFile(file: string): ProjectCo
73
73
  name: string;
74
74
  };
75
75
  export declare function buildProjectsConfigurationsFromProjectPaths(nxJson: NxJsonConfiguration, projectFiles: string[], // making this parameter allows devkit to pick up newly created projects
76
- readJson?: <T extends Object>(string: any) => T): ProjectsConfigurations;
76
+ readJson?: <T extends Object>(string: any) => T): Record<string, ProjectConfiguration>;
77
77
  export declare function mergeTargetConfigurations(projectConfiguration: ProjectConfiguration, target: string, targetDefaults: TargetDefaults[string]): TargetConfiguration;
78
78
  export declare function readTargetDefaultsForTarget(targetName: string, targetDefaults: TargetDefaults, executor?: string): TargetDefaults[string];
79
79
  export declare function renamePropertyWithStableKeys(obj: any, from: string, to: string): void;
@@ -58,13 +58,16 @@ class Workspaces {
58
58
  return this.cachedProjectsConfig;
59
59
  }
60
60
  const nxJson = this.readNxJson();
61
- const projectsConfigurations = buildProjectsConfigurationsFromProjectPaths(nxJson, globForProjectFiles(this.root, (opts === null || opts === void 0 ? void 0 : opts._ignorePluginInference)
61
+ let projectsConfigurations = buildProjectsConfigurationsFromProjectPaths(nxJson, globForProjectFiles(this.root, (opts === null || opts === void 0 ? void 0 : opts._ignorePluginInference)
62
62
  ? []
63
63
  : getGlobPatternsFromPlugins(nxJson, (0, installation_directory_1.getNxRequirePaths)(this.root), this.root), nxJson), (path) => (0, fileutils_1.readJsonFile)((0, path_1.join)(this.root, path)));
64
64
  if ((0, angular_json_1.shouldMergeAngularProjects)(this.root, opts === null || opts === void 0 ? void 0 : opts._includeProjectsFromAngularJson)) {
65
- projectsConfigurations.projects = (0, angular_json_1.mergeAngularJsonAndProjects)(projectsConfigurations.projects, this.root);
65
+ projectsConfigurations = (0, angular_json_1.mergeAngularJsonAndProjects)(projectsConfigurations, this.root);
66
66
  }
67
- this.cachedProjectsConfig = this.mergeTargetDefaultsIntoProjectDescriptions(projectsConfigurations, nxJson);
67
+ this.cachedProjectsConfig = {
68
+ version: 2,
69
+ projects: this.mergeTargetDefaultsIntoProjectDescriptions(projectsConfigurations, nxJson),
70
+ };
68
71
  return this.cachedProjectsConfig;
69
72
  }
70
73
  /**
@@ -74,8 +77,8 @@ class Workspaces {
74
77
  const nxJson = this.readNxJson();
75
78
  return Object.assign(Object.assign({}, this.readProjectsConfigurations(opts)), nxJson);
76
79
  }
77
- mergeTargetDefaultsIntoProjectDescriptions(config, nxJson) {
78
- for (const proj of Object.values(config.projects)) {
80
+ mergeTargetDefaultsIntoProjectDescriptions(projects, nxJson) {
81
+ for (const proj of Object.values(projects)) {
79
82
  if (proj.targets) {
80
83
  for (const targetName of Object.keys(proj.targets)) {
81
84
  const projectTargetDefinition = proj.targets[targetName];
@@ -86,7 +89,7 @@ class Workspaces {
86
89
  }
87
90
  }
88
91
  }
89
- return config;
92
+ return projects;
90
93
  }
91
94
  isNxExecutor(nodeModule, executor) {
92
95
  return !this.readExecutor(nodeModule, executor).isNgCompat;
@@ -565,10 +568,7 @@ readJson = (string) => (0, fileutils_1.readJsonFile)(string) // making this an a
565
568
  }
566
569
  }
567
570
  }
568
- return {
569
- version: 2,
570
- projects: projects,
571
- };
571
+ return projects;
572
572
  }
573
573
  exports.buildProjectsConfigurationsFromProjectPaths = buildProjectsConfigurationsFromProjectPaths;
574
574
  function mergeTargetConfigurations(projectConfiguration, target, targetDefaults) {
@@ -87,7 +87,10 @@ function addUpdatedAndDeletedFiles(createdFiles, updatedFiles, deletedFiles) {
87
87
  }
88
88
  exports.addUpdatedAndDeletedFiles = addUpdatedAndDeletedFiles;
89
89
  function computeWorkspaceConfigHash(projectsConfigurations) {
90
- return (0, file_hasher_1.hashArray)([JSON.stringify(projectsConfigurations)]);
90
+ const projectConfigurationStrings = Object.entries(projectsConfigurations)
91
+ .sort(([projectNameA], [projectNameB]) => projectNameA.localeCompare(projectNameB))
92
+ .map(([projectName, projectConfig]) => `${projectName}:${JSON.stringify(projectConfig)}`);
93
+ return (0, file_hasher_1.hashArray)(projectConfigurationStrings);
91
94
  }
92
95
  /**
93
96
  * Temporary work around to handle nested gitignores. The parcel file watcher doesn't handle them well,
@@ -119,7 +119,7 @@ function readAndCombineAllProjectConfigurations(tree) {
119
119
  const createdFiles = findCreatedProjectFiles(tree);
120
120
  const deletedFiles = findDeletedProjectFiles(tree);
121
121
  const projectFiles = [...globbedFiles, ...createdFiles].filter((r) => deletedFiles.indexOf(r) === -1);
122
- return (0, workspaces_1.buildProjectsConfigurationsFromProjectPaths)(nxJson, projectFiles, (file) => (0, json_1.readJson)(tree, file)).projects;
122
+ return (0, workspaces_1.buildProjectsConfigurationsFromProjectPaths)(nxJson, projectFiles, (file) => (0, json_1.readJson)(tree, file));
123
123
  }
124
124
  /**
125
125
  * Used to ensure that projects created during
@@ -37,14 +37,13 @@ export const enum WorkspaceErrors {
37
37
  Generic = 'Generic'
38
38
  }
39
39
  /** Get workspace config files based on provided globs */
40
- export function getConfigFiles(workspaceRoot: string, globs: Array<string>): Array<string>
40
+ export function getProjectConfigurations(workspaceRoot: string, globs: Array<string>, parseConfigurations: (arg0: Array<string>) => Record<string, object>): Record<string, object>
41
41
  export interface NxWorkspaceFiles {
42
42
  projectFileMap: Record<string, Array<FileData>>
43
43
  globalFiles: Array<FileData>
44
- configFiles: Array<string>
44
+ projectConfigurations: Record<string, object>
45
45
  }
46
- /** Throws exceptions */
47
- export function getWorkspaceFilesNative(workspaceRoot: string, globs: Array<string>): NxWorkspaceFiles
46
+ export function getWorkspaceFilesNative(workspaceRoot: string, globs: Array<string>, parseConfigurations: (arg0: Array<string>) => Record<string, object>): NxWorkspaceFiles
48
47
  export class Watcher {
49
48
  origin: string
50
49
  /**
@@ -246,7 +246,7 @@ if (!nativeBinding) {
246
246
  throw new Error(`Failed to load native binding`)
247
247
  }
248
248
 
249
- const { expandOutputs, remove, copy, hashArray, hashFile, hashFiles, hashFilesMatchingGlobs, EventType, Watcher, WorkspaceErrors, getConfigFiles, getWorkspaceFilesNative } = nativeBinding
249
+ const { expandOutputs, remove, copy, hashArray, hashFile, hashFiles, hashFilesMatchingGlobs, EventType, Watcher, WorkspaceErrors, getProjectConfigurations, getWorkspaceFilesNative } = nativeBinding
250
250
 
251
251
  module.exports.expandOutputs = expandOutputs
252
252
  module.exports.remove = remove
@@ -258,5 +258,5 @@ module.exports.hashFilesMatchingGlobs = hashFilesMatchingGlobs
258
258
  module.exports.EventType = EventType
259
259
  module.exports.Watcher = Watcher
260
260
  module.exports.WorkspaceErrors = WorkspaceErrors
261
- module.exports.getConfigFiles = getConfigFiles
261
+ module.exports.getProjectConfigurations = getProjectConfigurations
262
262
  module.exports.getWorkspaceFilesNative = getWorkspaceFilesNative
@@ -1,11 +1,11 @@
1
1
  import { FileData, ProjectFileMap, ProjectGraph } from '../config/project-graph';
2
- import { ProjectsConfigurations } from '../config/workspace-json-project-json';
2
+ import { ProjectConfiguration, ProjectsConfigurations } from '../config/workspace-json-project-json';
3
3
  export declare function createProjectFileMapUsingProjectGraph(graph: ProjectGraph): Promise<ProjectFileMap>;
4
4
  export declare function createProjectFileMap(projectsConfigurations: ProjectsConfigurations, allWorkspaceFiles: FileData[]): {
5
5
  projectFileMap: ProjectFileMap;
6
6
  allWorkspaceFiles: FileData[];
7
7
  };
8
- export declare function updateProjectFileMap(projectsConfigurations: ProjectsConfigurations, projectFileMap: ProjectFileMap, allWorkspaceFiles: FileData[], updatedFiles: Map<string, string>, deletedFiles: string[]): {
8
+ export declare function updateProjectFileMap(projectsConfigurations: Record<string, ProjectConfiguration>, projectFileMap: ProjectFileMap, allWorkspaceFiles: FileData[], updatedFiles: Map<string, string>, deletedFiles: string[]): {
9
9
  projectFileMap: ProjectFileMap;
10
10
  allWorkspaceFiles: FileData[];
11
11
  };
@@ -40,7 +40,7 @@ function createProjectFileMap(projectsConfigurations, allWorkspaceFiles) {
40
40
  exports.createProjectFileMap = createProjectFileMap;
41
41
  function updateProjectFileMap(projectsConfigurations, projectFileMap, allWorkspaceFiles, updatedFiles, deletedFiles) {
42
42
  var _a, _b;
43
- const projectRootMappings = (0, find_project_for_path_1.createProjectRootMappingsFromProjectConfigurations)(projectsConfigurations.projects);
43
+ const projectRootMappings = (0, find_project_for_path_1.createProjectRootMappingsFromProjectConfigurations)(projectsConfigurations);
44
44
  for (const f of updatedFiles.keys()) {
45
45
  const matchingProjectFiles = (_a = projectFileMap[(0, find_project_for_path_1.findProjectForPath)(f, projectRootMappings)]) !== null && _a !== void 0 ? _a : [];
46
46
  if (matchingProjectFiles) {
@@ -1,4 +1,4 @@
1
- import { ProjectsConfigurations } from '../../config/workspace-json-project-json';
1
+ import { ProjectConfiguration, ProjectsConfigurations } from '../../config/workspace-json-project-json';
2
2
  import { NxJsonConfiguration } from '../../config/nx-json';
3
3
  import { FileData } from '../../config/project-graph';
4
4
  /**
@@ -18,4 +18,4 @@ export declare function retrieveWorkspaceFiles(workspaceRoot: string, nxJson: Nx
18
18
  * @param workspaceRoot
19
19
  * @param nxJson
20
20
  */
21
- export declare function retrieveProjectConfigurations(workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<ProjectsConfigurations>;
21
+ export declare function retrieveProjectConfigurations(workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<Record<string, ProjectConfiguration>>;
@@ -22,27 +22,19 @@ function retrieveWorkspaceFiles(workspaceRoot, nxJson) {
22
22
  perf_hooks_1.performance.mark('native-file-deps:end');
23
23
  perf_hooks_1.performance.measure('native-file-deps', 'native-file-deps:start', 'native-file-deps:end');
24
24
  perf_hooks_1.performance.mark('get-workspace-files:start');
25
- let workspaceFiles;
26
- try {
27
- workspaceFiles = getWorkspaceFilesNative(workspaceRoot, globs);
28
- }
29
- catch (e) {
30
- // If the error is a parse error from Rust, then use the JS readJsonFile function to write a pretty error message
31
- if (e.code === "ParseError" /* WorkspaceErrors.ParseError */) {
32
- (0, fileutils_1.readJsonFile)((0, path_1.join)(workspaceRoot, e.message));
33
- // readJsonFile should always fail, but if it doesn't, then throw the original error
34
- throw e;
35
- }
36
- else {
37
- throw e;
38
- }
39
- }
25
+ const { projectConfigurations, projectFileMap, globalFiles } = getWorkspaceFilesNative(workspaceRoot, globs, (configs) => {
26
+ const projectConfigurations = createProjectConfigurations(workspaceRoot, nxJson, configs);
27
+ return projectConfigurations.projects;
28
+ });
40
29
  perf_hooks_1.performance.mark('get-workspace-files:end');
41
30
  perf_hooks_1.performance.measure('get-workspace-files', 'get-workspace-files:start', 'get-workspace-files:end');
42
31
  return {
43
- allWorkspaceFiles: buildAllWorkspaceFiles(workspaceFiles.projectFileMap, workspaceFiles.globalFiles),
44
- projectFileMap: workspaceFiles.projectFileMap,
45
- projectConfigurations: createProjectConfigurations(workspaceRoot, nxJson, workspaceFiles.configFiles),
32
+ allWorkspaceFiles: buildAllWorkspaceFiles(projectFileMap, globalFiles),
33
+ projectFileMap,
34
+ projectConfigurations: {
35
+ version: 2,
36
+ projects: projectConfigurations,
37
+ },
46
38
  };
47
39
  });
48
40
  }
@@ -55,10 +47,12 @@ exports.retrieveWorkspaceFiles = retrieveWorkspaceFiles;
55
47
  */
56
48
  function retrieveProjectConfigurations(workspaceRoot, nxJson) {
57
49
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
58
- const { getConfigFiles } = require('../../native');
50
+ const { getProjectConfigurations } = require('../../native');
59
51
  const globs = yield configurationGlobs(workspaceRoot, nxJson);
60
- const configPaths = getConfigFiles(workspaceRoot, globs);
61
- return createProjectConfigurations(workspaceRoot, nxJson, configPaths);
52
+ return getProjectConfigurations(workspaceRoot, globs, (configs) => {
53
+ const projectConfigurations = createProjectConfigurations(workspaceRoot, nxJson, configs);
54
+ return projectConfigurations.projects;
55
+ });
62
56
  });
63
57
  }
64
58
  exports.retrieveProjectConfigurations = retrieveProjectConfigurations;
@@ -74,14 +68,17 @@ function createProjectConfigurations(workspaceRoot, nxJson, configFiles) {
74
68
  perf_hooks_1.performance.mark('build-project-configs:start');
75
69
  let projectConfigurations = mergeTargetDefaultsIntoProjectDescriptions((0, workspaces_1.buildProjectsConfigurationsFromProjectPaths)(nxJson, configFiles, (path) => (0, fileutils_1.readJsonFile)((0, path_1.join)(workspaceRoot, path))), nxJson);
76
70
  if ((0, angular_json_1.shouldMergeAngularProjects)(workspaceRoot, false)) {
77
- projectConfigurations.projects = (0, angular_json_1.mergeAngularJsonAndProjects)(projectConfigurations.projects, workspaceRoot);
71
+ projectConfigurations = (0, angular_json_1.mergeAngularJsonAndProjects)(projectConfigurations, workspaceRoot);
78
72
  }
79
73
  perf_hooks_1.performance.mark('build-project-configs:end');
80
74
  perf_hooks_1.performance.measure('build-project-configs', 'build-project-configs:start', 'build-project-configs:end');
81
- return projectConfigurations;
75
+ return {
76
+ version: 2,
77
+ projects: projectConfigurations,
78
+ };
82
79
  }
83
- function mergeTargetDefaultsIntoProjectDescriptions(config, nxJson) {
84
- for (const proj of Object.values(config.projects)) {
80
+ function mergeTargetDefaultsIntoProjectDescriptions(projects, nxJson) {
81
+ for (const proj of Object.values(projects)) {
85
82
  if (proj.targets) {
86
83
  for (const targetName of Object.keys(proj.targets)) {
87
84
  const projectTargetDefinition = proj.targets[targetName];
@@ -92,7 +89,7 @@ function mergeTargetDefaultsIntoProjectDescriptions(config, nxJson) {
92
89
  }
93
90
  }
94
91
  }
95
- return config;
92
+ return projects;
96
93
  }
97
94
  function configurationGlobs(workspaceRoot, nxJson) {
98
95
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -52,7 +52,7 @@ function recordStat(opts) {
52
52
  if (process.env.NX_VERBOSE_LOGGING === 'true') {
53
53
  console.log(`Record stat. Major: ${major}`);
54
54
  }
55
- if (major < 10 || major > 15)
55
+ if (major < 10 || major > 16)
56
56
  return; // test version, skip it
57
57
  const axios = require('axios');
58
58
  yield ((_a = axios['default']) !== null && _a !== void 0 ? _a : axios)
@@ -34,7 +34,7 @@ export declare function getPackageManagerCommand(packageManager?: PackageManager
34
34
  * By default, the package manager is derived based on the lock file,
35
35
  * but it can also be passed in explicitly.
36
36
  */
37
- export declare function getPackageManagerVersion(packageManager?: PackageManager): string;
37
+ export declare function getPackageManagerVersion(packageManager?: PackageManager, cwd?: string): string;
38
38
  /**
39
39
  * Checks for a project level npmrc file by crawling up the file tree until
40
40
  * hitting a package.json file, as this is how npm finds them as well.
@@ -44,7 +44,7 @@ exports.detectPackageManager = detectPackageManager;
44
44
  function getPackageManagerCommand(packageManager = detectPackageManager(), root = workspace_root_1.workspaceRoot) {
45
45
  const commands = {
46
46
  yarn: () => {
47
- const yarnVersion = getPackageManagerVersion('yarn');
47
+ const yarnVersion = getPackageManagerVersion('yarn', root);
48
48
  const useBerry = (0, semver_1.gte)(yarnVersion, '2.0.0');
49
49
  return {
50
50
  preInstall: useBerry
@@ -63,7 +63,7 @@ function getPackageManagerCommand(packageManager = detectPackageManager(), root
63
63
  };
64
64
  },
65
65
  pnpm: () => {
66
- const pnpmVersion = getPackageManagerVersion('pnpm');
66
+ const pnpmVersion = getPackageManagerVersion('pnpm', root);
67
67
  const useExec = (0, semver_1.gte)(pnpmVersion, '6.13.0');
68
68
  const includeDoubleDashBeforeArgs = (0, semver_1.lt)(pnpmVersion, '7.0.0');
69
69
  const isPnpmWorkspace = (0, fs_1.existsSync)((0, path_1.join)(root, 'pnpm-workspace.yaml'));
@@ -105,8 +105,11 @@ exports.getPackageManagerCommand = getPackageManagerCommand;
105
105
  * By default, the package manager is derived based on the lock file,
106
106
  * but it can also be passed in explicitly.
107
107
  */
108
- function getPackageManagerVersion(packageManager = detectPackageManager()) {
109
- return (0, child_process_1.execSync)(`${packageManager} --version`).toString('utf-8').trim();
108
+ function getPackageManagerVersion(packageManager = detectPackageManager(), cwd = process.cwd()) {
109
+ return (0, child_process_1.execSync)(`${packageManager} --version`, {
110
+ cwd,
111
+ encoding: 'utf-8',
112
+ }).trim();
110
113
  }
111
114
  exports.getPackageManagerVersion = getPackageManagerVersion;
112
115
  /**
@@ -33,7 +33,11 @@ class TempFs {
33
33
  });
34
34
  }
35
35
  createFileSync(filePath, content) {
36
- (0, fs_extra_1.outputFileSync)((0, path_2.joinPathFragments)(this.tempDir, filePath), content);
36
+ let dir = (0, path_2.joinPathFragments)(this.tempDir, (0, path_1.dirname)(filePath));
37
+ if (!(0, fs_1.existsSync)(dir)) {
38
+ (0, fs_extra_1.mkdirpSync)(dir);
39
+ }
40
+ (0, fs_1.writeFileSync)((0, path_2.joinPathFragments)(this.tempDir, filePath), content);
37
41
  }
38
42
  readFile(filePath) {
39
43
  return tslib_1.__awaiter(this, void 0, void 0, function* () {