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
@@ -1,18 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProvenanceError = void 0;
4
+ exports.resolveVersionWithProvenance = resolveVersionWithProvenance;
4
5
  exports.ensurePackageHasProvenance = ensurePackageHasProvenance;
5
6
  exports.getNxPackageGroup = getNxPackageGroup;
6
7
  const module_1 = require("module");
8
+ const semver_1 = require("semver");
7
9
  const fileutils_1 = require("./fileutils");
10
+ const policy_1 = require("./min-release-age/policy");
11
+ const resolve_1 = require("./min-release-age/resolve");
8
12
  const package_manager_1 = require("./package-manager");
9
- /*
10
- * Verifies that the given npm package has provenance attestations
11
- * generated by the GitHub Actions workflow at .github/workflows/publish.yml
12
- * in the nrwl/nx repository.
13
- *
14
- * Will throw if the package does not have valid provenance.
15
- */
13
+ const workspace_root_1 = require("./workspace-root");
16
14
  /**
17
15
  * A build the publish workflow cuts from master rather than from a tag:
18
16
  * `23.3.0-pr.36841.f66e88b` from a pull request, `23.2.0-canary.20260908-89f02c1`
@@ -22,11 +20,33 @@ const package_manager_1 = require("./package-manager");
22
20
  function isPublishedFromMaster(version) {
23
21
  return /-pr\.\d+\./.test(version) || /-canary\.\d/.test(version);
24
22
  }
23
+ /**
24
+ * Resolves `spec` to the version the workspace's package manager would
25
+ * install under its minimum-release-age policy, verifies that version's
26
+ * provenance, and returns it. Install the returned version, not `spec`.
27
+ */
28
+ async function resolveVersionWithProvenance(packageName, spec, root = workspace_root_1.workspaceRoot) {
29
+ let version = spec;
30
+ if (!(0, semver_1.valid)(spec)) {
31
+ const policy = await (0, policy_1.readMinReleaseAgePolicy)((0, package_manager_1.getPackageManagerConfigRoot)(root));
32
+ if (policy.outcome === 'active') {
33
+ version = (await (0, resolve_1.resolveCompliantVersion)(packageName, spec, policy.policy)).version;
34
+ }
35
+ }
36
+ return ensurePackageHasProvenance(packageName, version);
37
+ }
38
+ /**
39
+ * Verifies that the given npm package has provenance attestations
40
+ * generated by the GitHub Actions workflow at .github/workflows/publish.yml
41
+ * in the nrwl/nx repository, and resolves to the exact version it verified.
42
+ *
43
+ * Will throw if the package does not have valid provenance.
44
+ */
25
45
  async function ensurePackageHasProvenance(packageName, packageVersion) {
26
46
  // this is used for locally released versions without provenance
27
47
  // do not set this for other reasons or you might be exposed to security risks
28
- if (process.env.NX_SKIP_PROVENANCE_CHECK) {
29
- return;
48
+ if (process.env.NX_SKIP_PROVENANCE_CHECK === 'true') {
49
+ return packageVersion;
30
50
  }
31
51
  try {
32
52
  const result = await (0, package_manager_1.packageRegistryView)(packageName, packageVersion, [
@@ -47,6 +67,12 @@ async function ensurePackageHasProvenance(packageName, packageVersion) {
47
67
  const attURL = npmViewResult?.dist?.attestations?.url;
48
68
  if (!attURL)
49
69
  throw new ProvenanceError(packageName, packageVersion, 'No attestation URL found');
70
+ const verifiedVersion = npmViewResult.version;
71
+ const requestedVersion = (0, semver_1.valid)(packageVersion);
72
+ if (!(0, semver_1.valid)(verifiedVersion) ||
73
+ (requestedVersion && verifiedVersion !== requestedVersion)) {
74
+ throw new ProvenanceError(packageName, packageVersion, `Requested version ${packageVersion} but the registry returned ${verifiedVersion}`);
75
+ }
50
76
  const response = await fetch(attURL);
51
77
  if (!response.ok) {
52
78
  throw new ProvenanceError(packageName, packageVersion, `HTTP ${response.status}: ${response.statusText}`);
@@ -70,9 +96,14 @@ async function ensurePackageHasProvenance(packageName, packageVersion) {
70
96
  // master, so a tag for them does not exist and never will. Repository,
71
97
  // workflow path and the artifact digest are still checked, so this only
72
98
  // widens which ref of nrwl/nx is allowed to have built it.
73
- const allowedRefs = isPublishedFromMaster(npmViewResult.version)
74
- ? [`refs/tags/${npmViewResult.version}`, 'refs/heads/master']
75
- : [`refs/tags/${npmViewResult.version}`];
99
+ // Some older releases were tagged `v<version>`.
100
+ const tagRefs = [
101
+ `refs/tags/${verifiedVersion}`,
102
+ `refs/tags/v${verifiedVersion}`,
103
+ ];
104
+ const allowedRefs = isPublishedFromMaster(verifiedVersion)
105
+ ? [...tagRefs, 'refs/heads/master']
106
+ : tagRefs;
76
107
  if (!allowedRefs.includes(workflowParameters.ref)) {
77
108
  throw new ProvenanceError(packageName, packageVersion, `Version ref does not match ${allowedRefs.join(' or ')}`);
78
109
  }
@@ -82,7 +113,7 @@ async function ensurePackageHasProvenance(packageName, packageVersion) {
82
113
  if (distSha !== attestationSha) {
83
114
  throw new ProvenanceError(packageName, packageVersion, 'Integrity hash does not match attestation hash');
84
115
  }
85
- return;
116
+ return verifiedVersion;
86
117
  }
87
118
  catch (error) {
88
119
  if (error instanceof ProvenanceError) {
@@ -0,0 +1 @@
1
+ export declare function redactUrlCredentials(text: string): string;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.redactUrlCredentials = redactUrlCredentials;
4
+ // Masks the userinfo in a URL: `user`, `user:pass`, or a bare token.
5
+ function redactUrlCredentials(text) {
6
+ return text.replace(/([a-z][a-z0-9+.-]*:\/\/)[^/@\s]+@/gi, '$1***@');
7
+ }
@@ -1,8 +1,9 @@
1
1
  import type { NxJsonConfiguration } from '../config/nx-json';
2
2
  /**
3
- * The workspace's analytics identity: the Nx Cloud id when the workspace has
4
- * one (most stable — it survives repo moves and renames), else the repo key.
5
- * Null when neither is available, in which case nothing is reported.
3
+ * The workspace's identity: the Nx Cloud id when the workspace has one (most
4
+ * stable — it survives repo moves and renames), else the repo key. Null when
5
+ * neither is available. The Nx Cloud id or access token is returned raw, so
6
+ * hash it before it leaves the process.
6
7
  */
7
8
  export declare function generateWorkspaceId(root: string, nxJson: NxJsonConfiguration | null): string | null;
8
9
  /**
@@ -6,9 +6,10 @@ exports.computeRepoKey = computeRepoKey;
6
6
  const crypto_1 = require("crypto");
7
7
  const git_utils_1 = require("./git-utils");
8
8
  /**
9
- * The workspace's analytics identity: the Nx Cloud id when the workspace has
10
- * one (most stable — it survives repo moves and renames), else the repo key.
11
- * Null when neither is available, in which case nothing is reported.
9
+ * The workspace's identity: the Nx Cloud id when the workspace has one (most
10
+ * stable — it survives repo moves and renames), else the repo key. Null when
11
+ * neither is available. The Nx Cloud id or access token is returned raw, so
12
+ * hash it before it leaves the process.
12
13
  */
13
14
  function generateWorkspaceId(root, nxJson) {
14
15
  const nxCloudId = nxJson?.nxCloudId ?? nxJson?.nxCloudAccessToken;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "24.0.3",
3
+ "version": "24.0.4",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
@@ -150,16 +150,16 @@
150
150
  }
151
151
  },
152
152
  "optionalDependencies": {
153
- "@nx/nx-darwin-arm64": "24.0.3",
154
- "@nx/nx-darwin-x64": "24.0.3",
155
- "@nx/nx-freebsd-x64": "24.0.3",
156
- "@nx/nx-linux-arm-gnueabihf": "24.0.3",
157
- "@nx/nx-linux-arm64-gnu": "24.0.3",
158
- "@nx/nx-linux-arm64-musl": "24.0.3",
159
- "@nx/nx-linux-x64-gnu": "24.0.3",
160
- "@nx/nx-linux-x64-musl": "24.0.3",
161
- "@nx/nx-win32-arm64-msvc": "24.0.3",
162
- "@nx/nx-win32-x64-msvc": "24.0.3"
153
+ "@nx/nx-darwin-arm64": "24.0.4",
154
+ "@nx/nx-darwin-x64": "24.0.4",
155
+ "@nx/nx-freebsd-x64": "24.0.4",
156
+ "@nx/nx-linux-arm-gnueabihf": "24.0.4",
157
+ "@nx/nx-linux-arm64-gnu": "24.0.4",
158
+ "@nx/nx-linux-arm64-musl": "24.0.4",
159
+ "@nx/nx-linux-x64-gnu": "24.0.4",
160
+ "@nx/nx-linux-x64-musl": "24.0.4",
161
+ "@nx/nx-win32-arm64-msvc": "24.0.4",
162
+ "@nx/nx-win32-x64-msvc": "24.0.4"
163
163
  },
164
164
  "nx-migrations": {
165
165
  "migrations": "./migrations.json",