nx 24.0.3 → 24.0.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.
Files changed (55) hide show
  1. package/dist/release/changelog-renderer/index.js +12 -5
  2. package/dist/src/ai/clone-ai-config-repo.d.ts +2 -1
  3. package/dist/src/ai/clone-ai-config-repo.js +48 -11
  4. package/dist/src/ai/set-up-ai-agents/set-up-ai-agents.js +25 -7
  5. package/dist/src/analytics/analytics.js +7 -2
  6. package/dist/src/command-line/ai/ai-output.js +3 -3
  7. package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +2 -2
  8. package/dist/src/command-line/graph/graph.d.ts +10 -0
  9. package/dist/src/command-line/graph/graph.js +61 -2
  10. package/dist/src/command-line/import/import.js +18 -30
  11. package/dist/src/command-line/import/utils/merge-remote-source.d.ts +1 -0
  12. package/dist/src/command-line/import/utils/merge-remote-source.js +10 -1
  13. package/dist/src/command-line/init/implementation/angular/legacy-angular-versions.js +17 -5
  14. package/dist/src/command-line/init/init-v1.js +2 -2
  15. package/dist/src/command-line/init/init-v2.js +4 -4
  16. package/dist/src/command-line/migrate/migrate.js +6 -7
  17. package/dist/src/command-line/nx-cloud/record/record.js +3 -2
  18. package/dist/src/command-line/nx-commands.js +3 -1
  19. package/dist/src/command-line/release/changelog/version-plan-filtering.js +4 -1
  20. package/dist/src/command-line/release/changelog.js +2 -1
  21. package/dist/src/command-line/release/config/version-plans.js +29 -29
  22. package/dist/src/command-line/release/utils/git.d.ts +2 -0
  23. package/dist/src/command-line/release/utils/git.js +49 -26
  24. package/dist/src/command-line/release/utils/markdown.js +4 -1
  25. package/dist/src/command-line/release/utils/remote-release-clients/github.js +18 -7
  26. package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +3 -1
  27. package/dist/src/command-line/release/version/derive-specifier-from-conventional-commits.js +1 -1
  28. package/dist/src/command-line/release/version.js +2 -1
  29. package/dist/src/core/graph/styles.js +1 -1
  30. package/dist/src/daemon/server/latest-nx.js +2 -2
  31. package/dist/src/hasher/native-task-hasher-impl.js +5 -2
  32. package/dist/src/native/index.d.ts +11 -1
  33. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  34. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  35. package/dist/src/nx-cloud/generators/connect-to-nx-cloud/connect-to-nx-cloud.js +5 -6
  36. package/dist/src/nx-cloud/utilities/get-cloud-options.d.ts +1 -1
  37. package/dist/src/nx-cloud/utilities/get-cloud-options.js +5 -2
  38. package/dist/src/nx-cloud/utilities/is-workspace-claimed.js +1 -1
  39. package/dist/src/nx-cloud/utilities/url-shorten.d.ts +1 -1
  40. package/dist/src/nx-cloud/utilities/url-shorten.js +4 -4
  41. package/dist/src/plugins/js/lock-file/yarn-parser.js +49 -2
  42. package/dist/src/tasks-runner/cache.js +24 -8
  43. package/dist/src/tasks-runner/default-tasks-runner.js +21 -13
  44. package/dist/src/tasks-runner/life-cycles/performance-report.js +2 -2
  45. package/dist/src/utils/git-utils.js +3 -3
  46. package/dist/src/utils/git-utils.tree-filter.js +102 -24
  47. package/dist/src/utils/package-manager.d.ts +7 -2
  48. package/dist/src/utils/package-manager.js +22 -22
  49. package/dist/src/utils/provenance.d.ts +14 -1
  50. package/dist/src/utils/provenance.js +44 -13
  51. package/dist/src/utils/redact-url-credentials.d.ts +1 -0
  52. package/dist/src/utils/redact-url-credentials.js +7 -0
  53. package/dist/src/utils/workspace-id.d.ts +4 -3
  54. package/dist/src/utils/workspace-id.js +4 -3
  55. package/package.json +11 -11
@@ -4,7 +4,6 @@ exports.initHandler = initHandler;
4
4
  const child_process_1 = require("child_process");
5
5
  const prompt_helpers_1 = require("../../utils/prompt-helpers");
6
6
  const fs_1 = require("fs");
7
- const semver_1 = require("semver");
8
7
  const add_nx_to_monorepo_1 = require("./implementation/add-nx-to-monorepo");
9
8
  const add_nx_to_nest_1 = require("./implementation/add-nx-to-nest");
10
9
  const add_nx_to_npm_repo_1 = require("./implementation/add-nx-to-npm-repo");
@@ -18,7 +17,8 @@ const format_1 = require("./implementation/format");
18
17
  async function initHandler(options) {
19
18
  // strip the 'init' command itself so we don't forward it
20
19
  const args = process.argv.slice(3).join(' ');
21
- const version = process.env.NX_VERSION ?? ((0, semver_1.prerelease)(versions_1.nxVersion) ? versions_1.nxVersion : 'latest');
20
+ // Resolving `latest` here would install a version nothing has verified.
21
+ const version = process.env.NX_VERSION ?? versions_1.nxVersion;
22
22
  if (process.env.NX_VERSION) {
23
23
  console.log(`Using version ${process.env.NX_VERSION}`);
24
24
  }
@@ -6,7 +6,6 @@ exports.detectPlugins = detectPlugins;
6
6
  const fs_1 = require("fs");
7
7
  const path_1 = require("path");
8
8
  const prompt_helpers_1 = require("../../utils/prompt-helpers");
9
- const semver_1 = require("semver");
10
9
  const nx_json_1 = require("../../config/nx-json");
11
10
  const fileutils_1 = require("../../utils/fileutils");
12
11
  const get_package_name_from_import_path_1 = require("../../utils/get-package-name-from-import-path");
@@ -45,8 +44,8 @@ async function initHandler(options, inner = false) {
45
44
  }
46
45
  let cleanup;
47
46
  try {
48
- await (0, provenance_1.ensurePackageHasProvenance)('nx', 'latest');
49
- const packageInstallResults = (0, package_json_1.installPackageToTmp)('nx', 'latest', (0, package_manager_1.detectPackageManager)(process.cwd()));
47
+ const version = await (0, provenance_1.resolveVersionWithProvenance)('nx', 'latest', process.cwd());
48
+ const packageInstallResults = (0, package_json_1.installPackageToTmp)('nx', version, (0, package_manager_1.detectPackageManager)(process.cwd()));
50
49
  cleanup = packageInstallResults.cleanup;
51
50
  let modulePath = require.resolve('nx/src/command-line/init/init-v2.js', {
52
51
  paths: [packageInstallResults.tempDir],
@@ -116,7 +115,8 @@ async function initHandlerImpl(options) {
116
115
  }
117
116
  }
118
117
  async function runInit(options, baseMeta) {
119
- const version = process.env.NX_VERSION ?? ((0, semver_1.prerelease)(versions_1.nxVersion) ? versions_1.nxVersion : 'latest');
118
+ // Resolving `latest` here would install a version nothing has verified.
119
+ const version = process.env.NX_VERSION ?? versions_1.nxVersion;
120
120
  if (process.env.NX_VERSION) {
121
121
  output_1.output.log({ title: `Using version ${process.env.NX_VERSION}` });
122
122
  }
@@ -1394,11 +1394,11 @@ async function getPackageMigrationsUsingInstall(packageName, packageVersion, pmc
1394
1394
  async function getPackageMigrationsUsingInstallImpl(packageName, packageVersion, pmc) {
1395
1395
  const { dir, cleanup } = (0, package_manager_1.createTempNpmDirectory)();
1396
1396
  let result;
1397
- if ((0, provenance_1.getNxPackageGroup)().includes(packageName)) {
1398
- await (0, provenance_1.ensurePackageHasProvenance)(packageName, packageVersion);
1399
- }
1397
+ const installVersion = (0, provenance_1.getNxPackageGroup)().includes(packageName)
1398
+ ? await (0, provenance_1.resolveVersionWithProvenance)(packageName, packageVersion)
1399
+ : packageVersion;
1400
1400
  try {
1401
- const addCommand = `${pmc.add} ${packageName}@${packageVersion}`;
1401
+ const addCommand = `${pmc.add} ${packageName}@${installVersion}`;
1402
1402
  try {
1403
1403
  await execAsync(addCommand, {
1404
1404
  cwd: dir,
@@ -2895,9 +2895,9 @@ async function runMigration() {
2895
2895
  });
2896
2896
  }
2897
2897
  async function nxCliPath(nxWorkspaceRoot) {
2898
- const version = process.env.NX_MIGRATE_CLI_VERSION || 'latest';
2899
2898
  const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
2900
- await (0, provenance_1.ensurePackageHasProvenance)('nx', version);
2899
+ const root = nxWorkspaceRoot ?? workspace_root_1.workspaceRoot;
2900
+ const version = await (0, provenance_1.resolveVersionWithProvenance)('nx', process.env.NX_MIGRATE_CLI_VERSION || 'latest', root);
2901
2901
  try {
2902
2902
  const packageManager = (0, package_manager_1.detectPackageManager)();
2903
2903
  const pmc = (0, package_manager_1.getPackageManagerCommand)(packageManager);
@@ -2909,7 +2909,6 @@ async function nxCliPath(nxWorkspaceRoot) {
2909
2909
  },
2910
2910
  license: 'MIT',
2911
2911
  });
2912
- const root = nxWorkspaceRoot ?? workspace_root_1.workspaceRoot;
2913
2912
  const isNonJs = !(0, fs_1.existsSync)((0, path_1.join)(root, 'package.json'));
2914
2913
  (0, package_manager_1.copyPackageManagerConfigurationFiles)(isNonJs ? (0, installation_directory_1.getNxInstallationPath)(root) : root, tmpDir);
2915
2914
  // Let's print the output of the install process to the console when verbose
@@ -5,14 +5,15 @@ const child_process_1 = require("child_process");
5
5
  const nx_json_1 = require("../../../config/nx-json");
6
6
  const output_1 = require("../../../utils/output");
7
7
  const nx_cloud_utils_1 = require("../../../utils/nx-cloud-utils");
8
+ const shell_quoting_1 = require("../../../utils/shell-quoting");
8
9
  const utils_1 = require("../utils");
9
10
  function recordHandler(args) {
10
11
  if (!(0, nx_cloud_utils_1.isNxCloudUsed)((0, nx_json_1.readNxJson)())) {
11
12
  let exitCode = 0;
12
13
  const commandArgs = args['--'];
13
14
  if (commandArgs && commandArgs.length > 0) {
14
- const [cmd, ...cmdArgs] = commandArgs;
15
- const result = (0, child_process_1.spawnSync)(cmd, cmdArgs, {
15
+ const [cmd, ...cmdArgs] = commandArgs.map(String);
16
+ const result = (0, child_process_1.spawnSync)(cmd, cmdArgs.map(shell_quoting_1.quoteShellArg), {
16
17
  stdio: 'inherit',
17
18
  shell: true,
18
19
  encoding: 'utf-8',
@@ -118,8 +118,10 @@ exports.commandsObject = yargs
118
118
  return;
119
119
  }
120
120
  const context = exports.commandsObject.getInternalMethods().getContext();
121
+ // The infix command (`nx <target> [project]`) has no name of its own, and
122
+ // its target and `_` hold user input, so report it as `run`.
121
123
  const command = (context.commands ?? []).join(' ') ||
122
- (args._ ?? []).slice(0, 1).join(' ');
124
+ (args.target && args.target !== 'undefined' ? 'run' : '');
123
125
  // Internal commands (e.g. `_migrate`) are spawned by their public
124
126
  // wrapper, which already reported the run - skip to avoid double counts.
125
127
  if (command && !command.startsWith('_')) {
@@ -7,6 +7,7 @@ exports.extractPreidFromVersion = extractPreidFromVersion;
7
7
  exports.extractProjectsPreidFromVersionData = extractProjectsPreidFromVersionData;
8
8
  const path_1 = require("path");
9
9
  const semver_1 = require("semver");
10
+ const git_revision_1 = require("../../../utils/git-revision");
10
11
  const workspace_root_1 = require("../../../utils/workspace-root");
11
12
  const exec_command_1 = require("../utils/exec-command");
12
13
  const git_1 = require("../utils/git");
@@ -48,6 +49,8 @@ async function filterVersionPlansByCommitRange(versionPlans, fromSHA, toSHA, isV
48
49
  * @returns Set of absolute file paths that were added in the range
49
50
  */
50
51
  async function getFilesAddedInCommitRange(fromSHA, toSHA, isVerbose) {
52
+ (0, git_revision_1.assertValidGitRevision)(fromSHA);
53
+ (0, git_revision_1.assertValidGitRevision)(toSHA);
51
54
  try {
52
55
  // Use git log to get version plan files added within the commit range
53
56
  // --name-only shows just the file paths
@@ -102,7 +105,7 @@ async function resolveChangelogFromSHA({ fromRef, tagPattern, tagPatternValues,
102
105
  strictPreid,
103
106
  });
104
107
  if (latestTag?.tag) {
105
- return await (0, git_1.getCommitHash)(latestTag.tag);
108
+ return await (0, git_1.getCommitHash)(`refs/tags/${latestTag.tag}`);
106
109
  }
107
110
  // Finally, if automatic from ref is enabled, use the first commit as a fallback.
108
111
  // When a projectRoot is provided, scope the fallback to the project's first commit
@@ -17,6 +17,7 @@ const interpolate_release_config_1 = require("./utils/interpolate-release-config
17
17
  const handle_errors_1 = require("../../utils/handle-errors");
18
18
  const is_ci_1 = require("../../utils/is-ci");
19
19
  const output_1 = require("../../utils/output");
20
+ const redact_url_credentials_1 = require("../../utils/redact-url-credentials");
20
21
  const path_1 = require("../../utils/path");
21
22
  const workspace_root_1 = require("../../utils/workspace-root");
22
23
  const commit_utils_1 = require("./changelog/commit-utils");
@@ -579,7 +580,7 @@ async function applyChangesAndExit(args, nxReleaseConfig, tree, toSHA, postGitTa
579
580
  }
580
581
  }
581
582
  if (args.gitPush ?? nxReleaseConfig.changelog.git.push) {
582
- output_1.output.logSingleLine(`Pushing to git remote "${args.gitRemote ?? 'origin'}"`);
583
+ output_1.output.logSingleLine(`Pushing to git remote "${(0, redact_url_credentials_1.redactUrlCredentials)(args.gitRemote ?? 'origin')}"`);
583
584
  await (0, git_1.gitPush)({
584
585
  gitRemote: args.gitRemote,
585
586
  dryRun: args.dryRun,
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readRawVersionPlans = readRawVersionPlans;
4
4
  exports.setResolvedVersionPlansOnGroups = setResolvedVersionPlansOnGroups;
5
5
  exports.getVersionPlansAbsolutePath = getVersionPlansAbsolutePath;
6
- const node_child_process_1 = require("node:child_process");
7
6
  const node_fs_1 = require("node:fs");
8
7
  const promises_1 = require("node:fs/promises");
9
8
  const path_1 = require("path");
10
9
  const semver_1 = require("semver");
11
10
  const workspace_root_1 = require("../../../utils/workspace-root");
11
+ const exec_command_1 = require("../utils/exec-command");
12
12
  const config_1 = require("./config");
13
13
  const { load } = require('@zkochan/js-yaml');
14
14
  // Ported from https://github.com/jxson/front-matter/blob/master/index.js
@@ -247,32 +247,32 @@ function isReleaseType(value) {
247
247
  return semver_1.RELEASE_TYPES.includes(value);
248
248
  }
249
249
  async function getCommitForVersionPlanFile(rawVersionPlan, isVerbose) {
250
- return new Promise((resolve) => {
251
- (0, node_child_process_1.exec)(`git log --diff-filter=A --pretty=format:"%s|%h|%an|%ae|%b" -n 1 -- ${rawVersionPlan.absolutePath}`, {
252
- windowsHide: true,
253
- }, (error, stdout, stderr) => {
254
- if (error) {
255
- if (isVerbose) {
256
- console.error(`Error executing git command for ${rawVersionPlan.relativePath}: ${error.message}`);
257
- }
258
- return resolve(null);
259
- }
260
- if (stderr) {
261
- if (isVerbose) {
262
- console.error(`Git command stderr for ${rawVersionPlan.relativePath}: ${stderr}`);
263
- }
264
- return resolve(null);
265
- }
266
- const [message, shortHash, authorName, authorEmail, ...body] = stdout
267
- .trim()
268
- .split('|');
269
- const commitDetails = {
270
- message: message || '',
271
- shortHash: shortHash || '',
272
- author: { name: authorName || '', email: authorEmail || '' },
273
- body: body.join('|') || '', // Handle case where body might be empty or contain multiple '|'
274
- };
275
- return resolve(commitDetails);
276
- });
277
- });
250
+ let stdout;
251
+ try {
252
+ stdout = await (0, exec_command_1.execCommand)('git', [
253
+ '--literal-pathspecs',
254
+ 'log',
255
+ '--diff-filter=A',
256
+ '--pretty=format:%s%x00%h%x00%an%x00%ae%x00%b',
257
+ '-n',
258
+ '1',
259
+ '--',
260
+ rawVersionPlan.absolutePath,
261
+ ]);
262
+ }
263
+ catch (error) {
264
+ if (isVerbose) {
265
+ console.error(`Error executing git command for ${rawVersionPlan.relativePath}: ${error?.message ?? error}`);
266
+ }
267
+ return null;
268
+ }
269
+ const [message, shortHash, authorName, authorEmail, body] = stdout
270
+ .trim()
271
+ .split('\0');
272
+ return {
273
+ message: message || '',
274
+ shortHash: shortHash || '',
275
+ author: { name: authorName || '', email: authorEmail || '' },
276
+ body: body || '',
277
+ };
278
278
  }
@@ -8,6 +8,8 @@ export interface RawGitCommit {
8
8
  body: string;
9
9
  shortHash: string;
10
10
  author: GitCommitAuthor;
11
+ /** Git's --name-status output, free of commit-author text. */
12
+ nameStatus?: string;
11
13
  }
12
14
  export interface Reference {
13
15
  type: 'hash' | 'issue' | 'pull-request';
@@ -23,6 +23,8 @@ exports.getFirstProjectCommit = getFirstProjectCommit;
23
23
  const node_path_1 = require("node:path");
24
24
  const semver_1 = require("semver");
25
25
  const interpolate_release_config_1 = require("./interpolate-release-config");
26
+ const git_revision_1 = require("../../../utils/git-revision");
27
+ const redact_url_credentials_1 = require("../../../utils/redact-url-credentials");
26
28
  const workspace_root_1 = require("../../../utils/workspace-root");
27
29
  const exec_command_1 = require("./exec-command");
28
30
  const shared_1 = require("./shared");
@@ -189,6 +191,10 @@ async function getLatestGitTagForPattern(releaseTagPattern, additionalInterpolat
189
191
  }
190
192
  }
191
193
  async function getGitDiff(from, to = 'HEAD') {
194
+ if (from) {
195
+ (0, git_revision_1.assertValidGitRevision)(from);
196
+ }
197
+ (0, git_revision_1.assertValidGitRevision)(to);
192
198
  let range = '';
193
199
  if (!from || from === to) {
194
200
  range = to;
@@ -196,15 +202,15 @@ async function getGitDiff(from, to = 'HEAD') {
196
202
  else {
197
203
  range = `${from}..${to}`;
198
204
  }
199
- // Use unique enough separators that we can be relatively certain will not occur within the commit message itself
200
- const commitMetadataSeparator = '§§§';
201
- const commitsSeparator = '|@-------@|';
205
+ // Git rejects NUL in commit messages, so commit text cannot forge a field boundary.
206
+ // Each commit prints a fixed number of fields; --name-status lands in the last one.
207
+ const fieldsPerCommit = 6;
202
208
  // https://git-scm.com/docs/pretty-formats
203
209
  const args = [
204
210
  '--no-pager',
205
211
  'log',
206
212
  range,
207
- `--pretty="${commitsSeparator}%n%s${commitMetadataSeparator}%h${commitMetadataSeparator}%an${commitMetadataSeparator}%ae%n%b"`,
213
+ `--pretty="%x00%s%x00%h%x00%an%x00%ae%x00%b"%x00`,
208
214
  '--name-status',
209
215
  ];
210
216
  // Support cases where the nx workspace root is located at a nested path within the git repo
@@ -213,20 +219,19 @@ async function getGitDiff(from, to = 'HEAD') {
213
219
  args.push(`--relative=${relativePath}`);
214
220
  }
215
221
  const r = await (0, exec_command_1.execCommand)('git', args);
216
- return r
217
- .split(`${commitsSeparator}\n`)
218
- .splice(1)
219
- .map((line) => {
220
- const [firstLine, ..._body] = line.split('\n');
221
- const [message, shortHash, authorName, authorEmail] = firstLine.split(commitMetadataSeparator);
222
- const r = {
222
+ const fields = r.split('\0').slice(1);
223
+ const commits = [];
224
+ for (let i = 0; i + fieldsPerCommit <= fields.length; i += fieldsPerCommit) {
225
+ const [message, shortHash, authorName, authorEmail, body, nameStatus] = fields.slice(i, i + fieldsPerCommit);
226
+ commits.push({
223
227
  message,
224
228
  shortHash,
225
229
  author: { name: authorName, email: authorEmail },
226
- body: _body.join('\n'),
227
- };
228
- return r;
229
- });
230
+ body: body + nameStatus,
231
+ nameStatus,
232
+ });
233
+ }
234
+ return commits;
230
235
  }
231
236
  async function getChangedTrackedFiles(cwd) {
232
237
  const result = await (0, exec_command_1.execCommand)('git', ['status', '--porcelain'], {
@@ -394,7 +399,7 @@ async function gitPush({ gitRemote, dryRun, verbose, additionalArgs, }) {
394
399
  console.log(dryRun
395
400
  ? `Would push the current branch to the remote with the following command, but --dry-run was set:`
396
401
  : `Pushing the current branch to the remote with the following command:`);
397
- console.log(`git ${commandArgs.join(' ')}`);
402
+ console.log((0, redact_url_credentials_1.redactUrlCredentials)(`git ${commandArgs.join(' ')}`));
398
403
  }
399
404
  if (dryRun) {
400
405
  return;
@@ -403,7 +408,7 @@ async function gitPush({ gitRemote, dryRun, verbose, additionalArgs, }) {
403
408
  await (0, exec_command_1.execCommand)('git', commandArgs);
404
409
  }
405
410
  catch (err) {
406
- throw new Error(`Unexpected git push error: ${err}`);
411
+ throw new Error((0, redact_url_credentials_1.redactUrlCredentials)(`Unexpected git push error: ${err}`));
407
412
  }
408
413
  }
409
414
  function parseCommits(commits) {
@@ -459,18 +464,36 @@ function extractReferencesFromCommit(commit) {
459
464
  function getAllAuthorsForCommit(commit) {
460
465
  const authors = [commit.author];
461
466
  // Additional authors can be specified in the commit body (depending on the VCS provider)
462
- for (const match of commit.body.matchAll(CoAuthoredByRegex)) {
463
- authors.push({
464
- name: (match.groups.name || '').trim(),
465
- email: (match.groups.email || '').trim(),
466
- });
467
+ for (const line of commit.body.split(LineTerminatorRE)) {
468
+ const coAuthor = parseCoAuthoredByLine(line);
469
+ if (coAuthor) {
470
+ authors.push(coAuthor);
471
+ }
467
472
  }
468
473
  return authors;
469
474
  }
475
+ // Parsed with string scans rather than a regex to stay linear on long lines.
476
+ function parseCoAuthoredByLine(line) {
477
+ const prefix = CoAuthoredByRE.exec(line);
478
+ if (!prefix) {
479
+ return null;
480
+ }
481
+ const value = line.slice(prefix.index + prefix[0].length);
482
+ const emailEnd = value.lastIndexOf('>');
483
+ const emailStart = emailEnd < 2 ? -1 : value.lastIndexOf('<', emailEnd - 2);
484
+ if (emailStart < 1) {
485
+ return null;
486
+ }
487
+ return {
488
+ name: value.slice(0, emailStart).trim(),
489
+ email: value.slice(emailStart + 1, emailEnd).trim(),
490
+ };
491
+ }
470
492
  // https://www.conventionalcommits.org/en/v1.0.0/
471
493
  // https://regex101.com/r/FSfNvA/1
472
494
  const ConventionalCommitRegex = /^(?<type>[^\s():!]+)(?:\s*\((?<scope>.+)\))?(?<breaking>!)?: (?<description>.+)$/u;
473
- const CoAuthoredByRegex = /co-authored-by:\s*(?<name>.+)(<(?<email>.+)>)/gim;
495
+ const CoAuthoredByRE = /co-authored-by:/i;
496
+ const LineTerminatorRE = /\r\n|[\n\r\u2028\u2029]/;
474
497
  // GitHub style PR references
475
498
  const PullRequestRE = /\([ a-z]*(#\d+)\s*\)/gm;
476
499
  // GitLab style merge request references
@@ -511,8 +534,7 @@ function parseGitCommit(commit) {
511
534
  }
512
535
  // Find all authors
513
536
  const authors = getAllAuthorsForCommit(commit);
514
- // Extract file changes from commit body
515
- const affectedFiles = Array.from(commit.body.matchAll(ChangedFileRegex)).reduce((prev, [fullLine, changeType, file1, file2]) =>
537
+ const affectedFiles = Array.from((commit.nameStatus ?? '').matchAll(ChangedFileRegex)).reduce((prev, [fullLine, changeType, file1, file2]) =>
516
538
  // file2 only exists for some change types, such as renames
517
539
  file2 ? [...prev, file1, file2] : [...prev, file1], []);
518
540
  return {
@@ -528,8 +550,9 @@ function parseGitCommit(commit) {
528
550
  };
529
551
  }
530
552
  async function getCommitHash(ref) {
553
+ (0, git_revision_1.assertValidGitRevision)(ref);
531
554
  try {
532
- return (await (0, exec_command_1.execCommand)('git', ['rev-parse', ref])).trim();
555
+ return (await (0, exec_command_1.execCommand)('git', ['rev-parse', '--verify', ref])).trim();
533
556
  }
534
557
  catch (e) {
535
558
  throw new Error(`Unknown revision: ${ref}`);
@@ -6,8 +6,11 @@ function parseChangelogMarkdown(contents) {
6
6
  * The release header may include prerelease identifiers (e.g., -alpha.13),
7
7
  * and major releases may use a single #, instead of the standard ## used
8
8
  * for minor and patch releases. This regex matches all of these cases.
9
+ *
10
+ * Headings must follow a \n. The m flag would also match after \r, U+2028
11
+ * and U+2029, which commit text can carry mid-line.
9
12
  */
10
- const CHANGELOG_RELEASE_HEAD_RE = new RegExp('^#+\\s*\\[?(\\d+\\.\\d+\\.\\d+(?:-[a-zA-Z0-9\\.]+)?)\\]?', 'gm');
13
+ const CHANGELOG_RELEASE_HEAD_RE = new RegExp('(?<=^|\\n)#+\\s*\\[?(\\d+\\.\\d+\\.\\d+(?:-[a-zA-Z0-9\\.]+)?)\\]?', 'g');
11
14
  const headings = [...contents.matchAll(CHANGELOG_RELEASE_HEAD_RE)];
12
15
  const releases = [];
13
16
  for (let i = 0; i < headings.length; i++) {
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GithubRemoteReleaseClient = exports.defaultCreateReleaseProvider = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const node_util_1 = require("node:util");
5
6
  const pc = tslib_1.__importStar(require("picocolors"));
6
7
  const prompt_helpers_1 = require("../../../../utils/prompt-helpers");
7
8
  const node_child_process_1 = require("node:child_process");
@@ -9,10 +10,18 @@ const native_1 = require("../../../../native");
9
10
  const node_fs_1 = require("node:fs");
10
11
  const node_os_1 = require("node:os");
11
12
  const output_1 = require("../../../../utils/output");
13
+ const redact_url_credentials_1 = require("../../../../utils/redact-url-credentials");
12
14
  const path_1 = require("../../../../utils/path");
13
15
  const extract_repo_slug_1 = require("./extract-repo-slug");
14
16
  const remote_release_client_1 = require("./remote-release-client");
15
17
  const http_client_1 = require("../../../../utils/http-client");
18
+ // Logins, plus the "_shortcode" suffix of Enterprise Managed Users and "[bot]".
19
+ const GithubUsernameRegex = /^[a-z\d_-]+(?:\[bot\])?$/i;
20
+ function toGithubUsername(value) {
21
+ return typeof value === 'string' && GithubUsernameRegex.test(value)
22
+ ? value
23
+ : null;
24
+ }
16
25
  exports.defaultCreateReleaseProvider = {
17
26
  provider: 'github',
18
27
  hostname: 'github.com',
@@ -51,7 +60,7 @@ class GithubRemoteReleaseClient extends remote_release_client_1.RemoteReleaseCli
51
60
  }
52
61
  catch (error) {
53
62
  if (process.env.NX_VERBOSE_LOGGING === 'true') {
54
- console.error(error);
63
+ console.error((0, redact_url_credentials_1.redactUrlCredentials)((0, node_util_1.inspect)(error)));
55
64
  }
56
65
  return null;
57
66
  }
@@ -80,7 +89,7 @@ class GithubRemoteReleaseClient extends remote_release_client_1.RemoteReleaseCli
80
89
  if (ghCLIConfig[hostname].user &&
81
90
  (ghCLIConfig[hostname].git_protocol === 'ssh' ||
82
91
  ghCLIConfig[hostname].git_protocol === 'https')) {
83
- const token = (0, node_child_process_1.execSync)(`gh auth token`, {
92
+ const token = (0, node_child_process_1.execFileSync)('gh', ['auth', 'token', '--hostname', hostname], {
84
93
  encoding: 'utf8',
85
94
  stdio: 'pipe',
86
95
  windowsHide: true,
@@ -112,14 +121,16 @@ class GithubRemoteReleaseClient extends remote_release_client_1.RemoteReleaseCli
112
121
  }
113
122
  if (email.endsWith('@users.noreply.github.com')) {
114
123
  const match = email.match(/^(\d+\+)?([^@]+)@users\.noreply\.github\.com$/);
115
- if (match && match[2]) {
116
- meta.username = match[2];
124
+ const usernameFromEmail = toGithubUsername(match?.[2]);
125
+ if (usernameFromEmail) {
126
+ meta.username = usernameFromEmail;
117
127
  break;
118
128
  }
119
129
  }
120
130
  const { data } = await (0, http_client_1.httpRequest)(`https://ungh.cc/users/find/${email}`).catch(() => ({ data: { user: null } }));
121
- if (data?.user?.username) {
122
- meta.username = data.user.username;
131
+ const usernameFromUngh = toGithubUsername(data?.user?.username);
132
+ if (usernameFromUngh) {
133
+ meta.username = usernameFromUngh;
123
134
  break;
124
135
  }
125
136
  const usernameFromGhCli = this.resolveUsernameFromGhCli(email);
@@ -152,7 +163,7 @@ class GithubRemoteReleaseClient extends remote_release_client_1.RemoteReleaseCli
152
163
  return null;
153
164
  }
154
165
  const data = JSON.parse(stdout);
155
- return data.items?.[0]?.login ?? null;
166
+ return toGithubUsername(data.items?.[0]?.login);
156
167
  }
157
168
  catch (error) {
158
169
  if (process.env.NX_VERBOSE_LOGGING === 'true') {
@@ -2,11 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GitLabRemoteReleaseClient = exports.defaultCreateReleaseProvider = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const node_util_1 = require("node:util");
5
6
  const pc = tslib_1.__importStar(require("picocolors"));
6
7
  const prompt_helpers_1 = require("../../../../utils/prompt-helpers");
7
8
  const node_child_process_1 = require("node:child_process");
8
9
  const native_1 = require("../../../../native");
9
10
  const output_1 = require("../../../../utils/output");
11
+ const redact_url_credentials_1 = require("../../../../utils/redact-url-credentials");
10
12
  const extract_repo_slug_1 = require("./extract-repo-slug");
11
13
  const remote_release_client_1 = require("./remote-release-client");
12
14
  exports.defaultCreateReleaseProvider = {
@@ -54,7 +56,7 @@ class GitLabRemoteReleaseClient extends remote_release_client_1.RemoteReleaseCli
54
56
  }
55
57
  catch (err) {
56
58
  if (process.env.NX_VERBOSE_LOGGING === 'true') {
57
- console.error(err);
59
+ console.error((0, redact_url_credentials_1.redactUrlCredentials)((0, node_util_1.inspect)(err)));
58
60
  }
59
61
  return null;
60
62
  }
@@ -18,7 +18,7 @@ isPrerelease, latestMatchingGitTag, releaseGraph, fallbackCurrentVersionResolver
18
18
  // In this case, use the first commit that touched this project rather than the repo's first commit,
19
19
  // to avoid scanning the entire git history for projects that were added after the repo was created.
20
20
  const previousVersionRef = latestMatchingGitTag
21
- ? latestMatchingGitTag.tag
21
+ ? `refs/tags/${latestMatchingGitTag.tag}`
22
22
  : fallbackCurrentVersionResolver === 'disk'
23
23
  ? await (0, git_1.getFirstProjectCommit)(projectGraphNode.data.root)
24
24
  : undefined;
@@ -15,6 +15,7 @@ const file_map_utils_1 = require("../../project-graph/file-map-utils");
15
15
  const project_graph_1 = require("../../project-graph/project-graph");
16
16
  const handle_errors_1 = require("../../utils/handle-errors");
17
17
  const output_1 = require("../../utils/output");
18
+ const redact_url_credentials_1 = require("../../utils/redact-url-credentials");
18
19
  const path_1 = require("../../utils/path");
19
20
  const workspace_root_1 = require("../../utils/workspace-root");
20
21
  const config_1 = require("./config/config");
@@ -291,7 +292,7 @@ function createAPI(overrideReleaseConfig, ignoreNxJsonConfig) {
291
292
  }
292
293
  }
293
294
  if (args.gitPush ?? nxReleaseConfig.version.git.push) {
294
- output_1.output.logSingleLine(`Pushing to git remote "${args.gitRemote ?? 'origin'}"`);
295
+ output_1.output.logSingleLine(`Pushing to git remote "${(0, redact_url_credentials_1.redactUrlCredentials)(args.gitRemote ?? 'origin')}"`);
295
296
  await (0, git_1.gitPush)({
296
297
  gitRemote: args.gitRemote,
297
298
  dryRun: args.dryRun,
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_nx_graph_client=self.webpackChunk_nx_graph_client||[]).push([[869],{1740(){}},e=>{e(1740)}]);
1
+ "use strict";(self.webpackChunk_nx_graph_client=self.webpackChunk_nx_graph_client||[]).push([[869],{8516(){}},e=>{e(8516)}]);
@@ -30,8 +30,8 @@ async function getLatestNxTmpPath() {
30
30
  installPromise = (async () => {
31
31
  try {
32
32
  logger_1.serverLogger.log('[LATEST-NX]: Pulling latest Nx...');
33
- await (0, provenance_1.ensurePackageHasProvenance)('nx', 'latest');
34
- const result = await (0, package_json_1.installPackageToTmpAsync)('nx', 'latest', (0, package_manager_1.detectPackageManager)(workspace_root_1.workspaceRoot));
33
+ const version = await (0, provenance_1.resolveVersionWithProvenance)('nx', 'latest');
34
+ const result = await (0, package_json_1.installPackageToTmpAsync)('nx', version, (0, package_manager_1.detectPackageManager)(workspace_root_1.workspaceRoot));
35
35
  latestNxTmpPath = result.tempDir;
36
36
  cleanupFn = result.cleanup;
37
37
  logger_1.serverLogger.log('[LATEST-NX]: Successfully pulled latest Nx to', latestNxTmpPath);
@@ -4,6 +4,7 @@ exports.NativeTaskHasherImpl = void 0;
4
4
  const native_1 = require("../native");
5
5
  const transform_objects_1 = require("../native/transform-objects");
6
6
  const typescript_1 = require("../plugins/js/utils/typescript");
7
+ const prune_task_graph_1 = require("../tasks-runner/prune-task-graph");
7
8
  const task_io_service_1 = require("../tasks-runner/task-io-service");
8
9
  const fileutils_1 = require("../utils/fileutils");
9
10
  const overrides_1 = require("../ultracache/overrides");
@@ -65,10 +66,12 @@ class NativeTaskHasherImpl {
65
66
  * planner's eligibility walk withholds their entries.
66
67
  */
67
68
  plan(taskIds, taskGraph, ultracacheConfigurations) {
69
+ // N-API converts each task's result fields too, which the planner never reads.
70
+ const prunedGraph = (0, prune_task_graph_1.pruneTaskGraph)(taskGraph);
68
71
  if (!ultracacheConfigurations) {
69
- return this.planner.getPlansReference(taskIds, taskGraph);
72
+ return this.planner.getPlansReference(taskIds, prunedGraph);
70
73
  }
71
- return this.planner.getPlansReference(taskIds, taskGraph, ultracacheConfigurations, (0, overrides_1.ultracacheEligibilityOptions)(this.projectGraph, taskGraph));
74
+ return this.planner.getPlansReference(taskIds, prunedGraph, ultracacheConfigurations, (0, overrides_1.ultracacheEligibilityOptions)(this.projectGraph, taskGraph));
72
75
  }
73
76
  async hashTasksUpfront(tasks, taskGraph, perTaskEnvs, cwd, collectInputs, ultracacheConfigurations) {
74
77
  const plans = this.plan(tasks.map((t) => t.id), taskGraph, ultracacheConfigurations);
@@ -148,7 +148,12 @@ export declare class NxCache {
148
148
  */
149
149
  getBatch(hashes: Array<string>): Array<CachedResult | undefined | null>
150
150
  put(hash: string, terminalOutput: string, outputs: Array<string>, code: number): CachedOutputs
151
- applyRemoteCacheResults(hash: string, result: CachedResult, outputs?: Array<string> | undefined | null): void
151
+ /**
152
+ * Restores and records a result fetched from a remote cache. Returns
153
+ * false, discarding the artifact, when it holds a link that leaves the
154
+ * output it sits in.
155
+ */
156
+ applyRemoteCacheResults(hash: string, result: CachedResult, outputs?: Array<string> | undefined | null): boolean
152
157
  /**
153
158
  * Register terminal outputs that were written without a cache entry —
154
159
  * uncacheable tasks, and cacheable ones run with `--skip-nx-cache`.
@@ -614,6 +619,11 @@ export interface CachedOutputs {
614
619
  expandedOutputs: Array<string>
615
620
  /** Each file copied, stamped as it is in the workspace. */
616
621
  files: Array<OutputFile>
622
+ /**
623
+ * Outputs that exist only through a linked directory. When there are
624
+ * any, nothing is stored and the task is not cached.
625
+ */
626
+ outputsBelowALink: Array<string>
617
627
  }
618
628
 
619
629
  export interface CachedPluginCapabilities {
Binary file