Skip to content

Commit

Permalink
fix(core): fix nx migrate to the same version (#16626)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz authored Apr 28, 2023
1 parent f138a34 commit 08ecd81
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 8 additions & 5 deletions packages/nx/src/command-line/migrate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,15 @@ describe('Migration', () => {
});
});

it('should skip the versions <= currently installed', async () => {
it('should skip the versions < currently installed', async () => {
const packageJson = {
dependencies: { parent: '1.0.0', child: '2.0.0', grandchild: '3.0.0' },
};
const migrator = new Migrator({
packageJson: createPackageJson({
dependencies: { child: '1.0.0', grandchild: '2.0.0' },
}),
getInstalledPackageVersion: () => '1.0.0',
packageJson: createPackageJson(packageJson),
getInstalledPackageVersion: (name) => {
return packageJson.dependencies[name];
},
fetch: (p, _v) => {
if (p === 'parent') {
return Promise.resolve({
Expand Down
6 changes: 5 additions & 1 deletion packages/nx/src/command-line/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ export class Migrator {
for (const packageJsonUpdate of Object.values(packageJsonUpdates)) {
if (
!packageJsonUpdate.packages ||
this.lte(packageJsonUpdate.version, this.getPkgVersion(packageName)) ||
this.lt(packageJsonUpdate.version, this.getPkgVersion(packageName)) ||
this.gt(packageJsonUpdate.version, targetVersion)
) {
continue;
Expand Down Expand Up @@ -590,6 +590,10 @@ export class Migrator {
return gt(normalizeVersion(v1), normalizeVersion(v2));
}

private lt(v1: string, v2: string) {
return lt(normalizeVersion(v1), normalizeVersion(v2));
}

private lte(v1: string, v2: string) {
return lte(normalizeVersion(v1), normalizeVersion(v2));
}
Expand Down

1 comment on commit 08ecd81

@vercel
Copy link

@vercel vercel bot commented on 08ecd81 Apr 28, 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-five.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev
nx-dev-nrwl.vercel.app

Please sign in to comment.