feat(core): support --skip-third-party flag in nx migrate#35497
feat(core): support --skip-third-party flag in nx migrate#35497leosvelperez wants to merge 2 commits intomasterfrom
Conversation
✅ Deploy Preview for nx-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
View your CI Pipeline Execution ↗ for commit 3217b02
☁️ Nx Cloud last updated this comment at |
136ec94 to
1c34504
Compare
There was a problem hiding this comment.
Nx Cloud is proposing a fix for your failed CI:
We added writable: true to all Object.defineProperty calls in the resolveMode test block to fix cross-suite pollution in Jest workers. Without this flag, process.stdin.isTTY was being made non-writable, causing analytics-prompt.spec.ts tests that use direct property assignment to throw TypeError: Cannot assign to read only property 'isTTY'.
Warning
❌ We could not verify this fix.
Suggested Fix changes
diff --git a/packages/nx/src/command-line/migrate/migrate.spec.ts b/packages/nx/src/command-line/migrate/migrate.spec.ts
index 39f7efefef..6f66022d09 100644
--- a/packages/nx/src/command-line/migrate/migrate.spec.ts
+++ b/packages/nx/src/command-line/migrate/migrate.spec.ts
@@ -2268,6 +2268,7 @@ describe('Migration', () => {
Object.defineProperty(process.stdin, 'isTTY', {
value: originalTty,
configurable: true,
+ writable: true,
});
});
@@ -2275,6 +2276,7 @@ describe('Migration', () => {
Object.defineProperty(process.stdin, 'isTTY', {
value: true,
configurable: true,
+ writable: true,
});
process.env.CI = 'false';
const result = await resolveMode('first-party');
@@ -2286,6 +2288,7 @@ describe('Migration', () => {
Object.defineProperty(process.stdin, 'isTTY', {
value: false,
configurable: true,
+ writable: true,
});
process.env.CI = 'false';
const result = await resolveMode(undefined);
@@ -2297,6 +2300,7 @@ describe('Migration', () => {
Object.defineProperty(process.stdin, 'isTTY', {
value: true,
configurable: true,
+ writable: true,
});
process.env.CI = 'true';
const result = await resolveMode(undefined);
@@ -2308,6 +2312,7 @@ describe('Migration', () => {
Object.defineProperty(process.stdin, 'isTTY', {
value: true,
configurable: true,
+ writable: true,
});
process.env.CI = 'false';
mockPrompt.mockReturnValueOnce(Promise.resolve({ mode: 'first-party' }));
🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.
Or Apply changes locally with:
npx nx-cloud apply-locally x9D8-9EnX
Apply fix locally with your editor ↗ View interactive diff ↗
🎓 Learn more about Self-Healing CI on nx.dev
Current Behavior
nx migrate <target>always processes every entry in the resolvedpackageJsonUpdates, including third-party packages outside the target'snx.packageGroup. There is no way to scope a migration run to the target package and its package group.Expected Behavior
Adds an opt-in
--skip-third-partyflag tonx migrate:packageJsonUpdatesis filtered down to packages in the target version's fetchednx.packageGroup(plus the target itself andnx). Third-party packages are dropped before they enter the result, and entries that contain only third-party packages collapse to empty and are dropped.package name ∈ targetPackageGroup, so the flag works for any target whose metadata defines apackageGroup.This lets users migrate Nx (or any framework that ships a package group) to a new version without bumping any third-party packages whose updates Nx happens to manage.