nx 16.5.2 → 16.5.4

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.
@@ -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* () {
@@ -132,7 +132,7 @@ function getOutputsForTargetAndConfiguration(task, node) {
132
132
  options,
133
133
  });
134
134
  })
135
- .filter((output) => !!output && !output.match(/{.*}/));
135
+ .filter((output) => !!output && !output.match(/{(projectRoot|workspaceRoot|(options.*))}/));
136
136
  }
137
137
  // Keep backwards compatibility in case `outputs` doesn't exist
138
138
  if (options.outputPath) {
@@ -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
  /**
@@ -10,7 +10,7 @@ const fs_1 = require("fs");
10
10
  class TempFs {
11
11
  constructor(dirname, overrideWorkspaceRoot = true) {
12
12
  this.dirname = dirname;
13
- this.tempDir = (0, fs_extra_1.mkdtempSync)((0, path_1.join)((0, os_1.tmpdir)(), this.dirname));
13
+ this.tempDir = (0, fs_extra_1.realpathSync)((0, fs_extra_1.mkdtempSync)((0, path_1.join)((0, os_1.tmpdir)(), this.dirname)));
14
14
  if (overrideWorkspaceRoot) {
15
15
  process.env.NX_WORKSPACE_ROOT_PATH = this.tempDir;
16
16
  }
@@ -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* () {