nx 23.1.0-beta.0 → 23.1.0-beta.2

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.
@@ -105,5 +105,6 @@ export default class DefaultChangelogRenderer {
105
105
  protected groupChangesByType(): Record<string, ChangelogChange[]>;
106
106
  protected groupChangesByScope(changes: ChangelogChange[]): Record<string, ChangelogChange[]>;
107
107
  protected extractBreakingChangeExplanation(message: string): string | null;
108
+ private isBreakingChangeBoundary;
108
109
  protected formatName(name?: string): string;
109
110
  }
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const semver_1 = require("semver");
4
+ // Stripped from breaking change explanations (e.g. bot/session markers).
5
+ const HtmlCommentRegex = /<!--[\s\S]*?-->/g;
4
6
  class DefaultChangelogRenderer {
5
7
  /**
6
8
  * A ChangelogRenderer class takes in the determined changes and other relevant metadata
@@ -342,20 +344,33 @@ class DefaultChangelogRenderer {
342
344
  return null;
343
345
  }
344
346
  const startOfBreakingChange = startIndex + breakingChangeIdentifier.length;
345
- // Extract all text after BREAKING CHANGE: until we hit a Co-authored-by section or git metadata
346
- let endOfBreakingChange = message.length;
347
- const coAuthoredBySection = message.indexOf('---------\n\nCo-authored-by:');
348
- if (coAuthoredBySection !== -1) {
349
- endOfBreakingChange = coAuthoredBySection;
350
- }
351
- else {
352
- // Look for the git metadata delimiter (a line with just ")
353
- const gitMetadataMarker = message.indexOf('"\n', startOfBreakingChange);
354
- if (gitMetadataMarker !== -1) {
355
- endOfBreakingChange = gitMetadataMarker;
347
+ // A squash-merged PR body can trail the note with template sections,
348
+ // trailers, and git metadata. Strip comments (they can appear anywhere),
349
+ // then keep lines until the first boundary.
350
+ const lines = message
351
+ .slice(startOfBreakingChange)
352
+ .replace(HtmlCommentRegex, '')
353
+ .split('\n');
354
+ // The rest of the "BREAKING CHANGE:" line is always kept; scan from the next.
355
+ const explanationLines = [lines[0]];
356
+ for (let i = 1; i < lines.length; i++) {
357
+ if (this.isBreakingChangeBoundary(lines[i])) {
358
+ break;
356
359
  }
360
+ explanationLines.push(lines[i]);
357
361
  }
358
- return message.substring(startOfBreakingChange, endOfBreakingChange).trim();
362
+ return explanationLines.join('\n').trim();
363
+ }
364
+ isBreakingChangeBoundary(line) {
365
+ const trimmed = line.trim();
366
+ return (
367
+ // Markdown heading (e.g. "## Related issues")
368
+ /^#{1,6}\s/.test(trimmed) ||
369
+ // Horizontal rule / separator
370
+ /^-{3,}$/.test(trimmed) ||
371
+ /^Co-authored-by:/i.test(trimmed) ||
372
+ // Git metadata delimiter following the body
373
+ trimmed === '"');
359
374
  }
360
375
  formatName(name = '') {
361
376
  return name
@@ -80,9 +80,10 @@ function buildScopeRules(mode) {
80
80
  return [
81
81
  `<scope_rules>`,
82
82
  `- Apply only the changes the migration prompt asks for.`,
83
- `- Do not refactor, reformat, or update dependencies beyond what the migration prompt directs.`,
83
+ `- Do not refactor or update dependencies beyond what the migration prompt directs, and do not reformat files you did not change.`,
84
+ `- After applying your changes and before writing the handoff, format the files you created or modified so they match the workspace's style. If the workspace uses Prettier, run \`nx format:write\`, which formats your uncommitted changes; if it has no formatter configured, skip this.`,
84
85
  `- Do not modify files outside the workspace root.`,
85
- `- Do not run other \`nx\` commands that mutate workspace state (\`nx migrate\`, \`nx reset\`, \`nx run-many\`, generators, etc.). Read-only inspection (\`nx show\`, \`nx graph --file\`, reading files) is fine.`,
86
+ `- Do not run other \`nx\` commands that mutate workspace state (\`nx migrate\`, \`nx reset\`, \`nx run-many\`, generators, etc.), except \`nx format:write\` to format the files you changed. Read-only inspection (\`nx show\`, \`nx graph --file\`, reading files) is fine.`,
86
87
  `- If the migration instructions are unclear, internally inconsistent, or conflict with the current workspace state, ask the user for direction (see the handoff contract). Do not guess.`,
87
88
  `</scope_rules>`,
88
89
  ].join('\n');
@@ -1413,7 +1413,8 @@ async function generateMigrationsJsonAndUpdatePackageJson(root, opts, fetch) {
1413
1413
  // the user already has. Drop those before writing; nx migrate is
1414
1414
  // forward-only, never a downgrade.
1415
1415
  phase = 'package_updates';
1416
- const writableUpdates = (0, update_filters_1.filterDowngradedUpdates)(packageUpdates, originalPackageJson, installedPackageVersions);
1416
+ // Resolve catalog: specifiers first so the filter compares real versions.
1417
+ const writableUpdates = (0, update_filters_1.filterDowngradedUpdates)(packageUpdates, (0, catalog_1.resolveCatalogSpecifiers)(originalPackageJson), installedPackageVersions);
1417
1418
  const wrotePackageJson = await updatePackageJson(root, writableUpdates);
1418
1419
  const wroteNxJsonInstallation = await updateInstallationDetails(root, writableUpdates);
1419
1420
  const promptMigrationFiles = (0, prompt_files_1.writePromptMigrationFiles)(root, migrations, promptContents ?? {}, packageUpdates[walkedTargetPackage].version);
@@ -35,7 +35,8 @@ function filterDowngradedUpdates(packageUpdates, packageJson, getInstalledVersio
35
35
  if (!specifier) {
36
36
  continue;
37
37
  }
38
- const floor = (0, semver_1.minVersion)(specifier);
38
+ // Skip specifiers that aren't semver ranges (workspace:/npm:/git/file).
39
+ const floor = (0, semver_1.validRange)(specifier) ? (0, semver_1.minVersion)(specifier) : null;
39
40
  if (floor && (0, semver_1.lt)(floor.version, resolvedNorm)) {
40
41
  result[name] = update;
41
42
  }
Binary file
@@ -1,4 +1,5 @@
1
1
  import type { Tree } from '../../generators/tree';
2
+ import type { PackageJson } from '../package-json';
2
3
  import type { CatalogManager } from './manager';
3
4
  import { getCatalogManager } from './manager-factory';
4
5
  export { type CatalogManager, getCatalogManager };
@@ -8,6 +9,12 @@ export { type CatalogManager, getCatalogManager };
8
9
  * applies). Throws when the reference cannot be resolved.
9
10
  */
10
11
  export declare function resolveCatalogReferenceIfNeeded(packageName: string, version: string): string;
12
+ /**
13
+ * Resolves a package.json's `catalog:` dependency / devDependency specifiers to
14
+ * their declared version range. Non-catalog or unresolvable specifiers are
15
+ * returned unchanged.
16
+ */
17
+ export declare function resolveCatalogSpecifiers(packageJson: PackageJson | null): PackageJson | null;
11
18
  /**
12
19
  * Detects which packages in a package.json use catalog references
13
20
  * Returns Map of package name -> catalog name (undefined for default catalog)
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCatalogManager = void 0;
4
4
  exports.resolveCatalogReferenceIfNeeded = resolveCatalogReferenceIfNeeded;
5
+ exports.resolveCatalogSpecifiers = resolveCatalogSpecifiers;
5
6
  exports.getCatalogDependenciesFromPackageJson = getCatalogDependenciesFromPackageJson;
6
7
  const json_1 = require("../../generators/utils/json");
7
8
  const workspace_root_1 = require("../workspace-root");
@@ -23,6 +24,36 @@ function resolveCatalogReferenceIfNeeded(packageName, version) {
23
24
  }
24
25
  return resolvedVersion;
25
26
  }
27
+ /**
28
+ * Resolves a package.json's `catalog:` dependency / devDependency specifiers to
29
+ * their declared version range. Non-catalog or unresolvable specifiers are
30
+ * returned unchanged.
31
+ */
32
+ function resolveCatalogSpecifiers(packageJson) {
33
+ if (!packageJson) {
34
+ return packageJson;
35
+ }
36
+ const resolveSection = (section) => {
37
+ const resolved = {};
38
+ for (const [name, specifier] of Object.entries(section)) {
39
+ try {
40
+ resolved[name] = resolveCatalogReferenceIfNeeded(name, specifier);
41
+ }
42
+ catch {
43
+ resolved[name] = specifier;
44
+ }
45
+ }
46
+ return resolved;
47
+ };
48
+ const result = { ...packageJson };
49
+ if (packageJson.dependencies) {
50
+ result.dependencies = resolveSection(packageJson.dependencies);
51
+ }
52
+ if (packageJson.devDependencies) {
53
+ result.devDependencies = resolveSection(packageJson.devDependencies);
54
+ }
55
+ return result;
56
+ }
26
57
  /**
27
58
  * Detects which packages in a package.json use catalog references
28
59
  * Returns Map of package name -> catalog name (undefined for default catalog)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx",
3
- "version": "23.1.0-beta.0",
3
+ "version": "23.1.0-beta.2",
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.",
@@ -172,16 +172,16 @@
172
172
  }
173
173
  },
174
174
  "optionalDependencies": {
175
- "@nx/nx-darwin-arm64": "23.1.0-beta.0",
176
- "@nx/nx-darwin-x64": "23.1.0-beta.0",
177
- "@nx/nx-freebsd-x64": "23.1.0-beta.0",
178
- "@nx/nx-linux-arm-gnueabihf": "23.1.0-beta.0",
179
- "@nx/nx-linux-arm64-gnu": "23.1.0-beta.0",
180
- "@nx/nx-linux-arm64-musl": "23.1.0-beta.0",
181
- "@nx/nx-linux-x64-gnu": "23.1.0-beta.0",
182
- "@nx/nx-linux-x64-musl": "23.1.0-beta.0",
183
- "@nx/nx-win32-arm64-msvc": "23.1.0-beta.0",
184
- "@nx/nx-win32-x64-msvc": "23.1.0-beta.0"
175
+ "@nx/nx-darwin-arm64": "23.1.0-beta.2",
176
+ "@nx/nx-darwin-x64": "23.1.0-beta.2",
177
+ "@nx/nx-freebsd-x64": "23.1.0-beta.2",
178
+ "@nx/nx-linux-arm-gnueabihf": "23.1.0-beta.2",
179
+ "@nx/nx-linux-arm64-gnu": "23.1.0-beta.2",
180
+ "@nx/nx-linux-arm64-musl": "23.1.0-beta.2",
181
+ "@nx/nx-linux-x64-gnu": "23.1.0-beta.2",
182
+ "@nx/nx-linux-x64-musl": "23.1.0-beta.2",
183
+ "@nx/nx-win32-arm64-msvc": "23.1.0-beta.2",
184
+ "@nx/nx-win32-x64-msvc": "23.1.0-beta.2"
185
185
  },
186
186
  "nx-migrations": {
187
187
  "migrations": "./migrations.json",