Skip to content

Commit

Permalink
fix(core): reintroduce misaligned packages check (#14648)
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Feb 7, 2023
1 parent de05e68 commit a65ea6e
Show file tree
Hide file tree
Showing 6 changed files with 616 additions and 325 deletions.
11 changes: 7 additions & 4 deletions e2e/nx-misc/src/misc.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
cleanupProject,
getPublishedVersion,
isNotWindows,
newProject,
readFile,
Expand All @@ -12,7 +13,6 @@ import {
updateFile,
} from '@nrwl/e2e/utils';
import { renameSync } from 'fs';
import { packagesWeCareAbout } from 'nx/src/command-line/report';
import * as path from 'path';

describe('Nx Commands', () => {
Expand Down Expand Up @@ -44,9 +44,12 @@ describe('Nx Commands', () => {
it(`should report package versions`, async () => {
const reportOutput = runCLI('report');

packagesWeCareAbout.forEach((p) => {
expect(reportOutput).toContain(p);
});
expect(reportOutput).toEqual(
expect.stringMatching(
new RegExp(`\@nrwl\/workspace.*:.*${getPublishedVersion()}`)
)
);
expect(reportOutput).toContain('@nrwl/workspace');
}, 120000);

it(`should list plugins`, async () => {
Expand Down
45 changes: 32 additions & 13 deletions packages/nx/src/command-line/migrate.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as enquirer from 'enquirer';
import { PackageJson } from '../utils/package-json';
import { Migrator, normalizeVersion, parseMigrationsOptions } from './migrate';
import {
Migrator,
normalizeVersion,
parseMigrationsOptions,
ResolvedMigrationConfiguration,
} from './migrate';

const createPackageJson = (
overrides: Partial<PackageJson> = {}
Expand Down Expand Up @@ -366,23 +371,27 @@ describe('Migration', () => {
return {
version: '2.0.0',
packageGroup: [
'@my-company/lib-1',
'@my-company/lib-2',
'@my-company/lib-3',
{ package: '@my-company/lib-1', version: '*' },
{ package: '@my-company/lib-2', version: '*' },
{ package: '@my-company/lib-3', version: '*' },
{ package: '@my-company/lib-4', version: 'latest' },
],
};
}
if (pkg === '@my-company/lib-6') {
return {
version: '2.0.0',
packageGroup: ['@my-company/nx-workspace'],
packageGroup: [
{ version: '*', package: '@my-company/nx-workspace' },
],
};
}
if (pkg === '@my-company/lib-3') {
return {
version: '2.0.0',
packageGroup: ['@my-company/lib-3-child'],
packageGroup: [
{ version: '*', package: '@my-company/lib-3-child' },
],
};
}
if (version === 'latest') {
Expand Down Expand Up @@ -440,19 +449,26 @@ describe('Migration', () => {
if (pkg === '@my-company/nx-workspace' && version === '3.0.0') {
return {
version: '3.0.0',
packageGroup: ['@my-company/lib-1', '@my-company/lib-2'],
packageGroup: [
{ package: '@my-company/lib-1', version: '*' },
{ package: '@my-company/lib-2', version: '*' },
],
};
}
if (pkg === '@my-company/lib-1' && version === 'latest') {
return {
version: '3.0.0',
packageGroup: ['@my-company/nx-workspace'],
packageGroup: [
{ package: '@my-company/nx-workspace', version: '*' },
],
};
}
if (pkg === '@my-company/lib-1' && version === '3.0.0') {
return {
version: '3.0.0',
packageGroup: ['@my-company/nx-workspace'],
packageGroup: [
{ package: '@my-company/nx-workspace', version: '*' },
],
};
}
if (pkg === '@my-company/lib-2' && version === '3.0.0') {
Expand Down Expand Up @@ -827,7 +843,7 @@ describe('Migration', () => {
},
}),
getInstalledPackageVersion: () => '1.0.0',
fetch: (p) => {
fetch: (p): Promise<ResolvedMigrationConfiguration> => {
if (p === 'mypackage') {
return Promise.resolve({
version: '2.0.0',
Expand All @@ -837,7 +853,10 @@ describe('Migration', () => {
packages: { child1: { version: '3.0.0' } },
},
},
packageGroup: ['pkg1', 'pkg2'],
packageGroup: [
{ package: 'pkg1', version: '*' },
{ package: 'pkg2', version: '*' },
],
});
} else if (p === 'pkg1') {
// add a delay to showcase the dependent requirement will wait for it
Expand Down Expand Up @@ -1008,7 +1027,7 @@ describe('Migration', () => {
if (p === 'child') return '1.0.0';
return null;
},
fetch: (p, _v) => {
fetch: (p: string): Promise<ResolvedMigrationConfiguration> => {
if (p === 'parent') {
return Promise.resolve({
version: '2.0.0',
Expand Down Expand Up @@ -1089,7 +1108,7 @@ describe('Migration', () => {
if (p === 'newChild') return '1.0.0'; // installed as a transitive dep, not a top-level dep
return null;
},
fetch: (p, _v) => {
fetch: (p: string): Promise<ResolvedMigrationConfiguration> => {
if (p === 'parent') {
return Promise.resolve({
version: '2.0.0',
Expand Down
Loading

1 comment on commit a65ea6e

@vercel
Copy link

@vercel vercel bot commented on a65ea6e Feb 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx.dev

Please sign in to comment.