Skip to content

Commit

Permalink
refactor!: drop support for lerna v2
Browse files Browse the repository at this point in the history
BREAKING CHANGE: remove lerna v2 support and tests
  • Loading branch information
escapedcat committed Sep 5, 2020
1 parent 3d4116d commit 59667b3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 964 deletions.
29 changes: 0 additions & 29 deletions @commitlint/config-lerna-scopes/index.test.js
@@ -1,6 +1,5 @@
import {lerna} from '@commitlint/test';
import config from '.';
import semver from 'semver';

test('exports rules key', () => {
expect(config).toHaveProperty('rules');
Expand Down Expand Up @@ -67,31 +66,3 @@ test('returns expected value for scoped lerna repository', async () => {
const [, , value] = await fn({cwd});
expect(value).toEqual(['a', 'b']);
});

test('works with lerna version < 3', async () => {
const {'scope-enum': fn} = config.rules;
const cwd = await lerna.bootstrap('lerna-two', __dirname);
const [, , value] = await fn({cwd});
expect(value).toEqual(['a2', 'b2']);
});

test('uses lerna version < 3 if installed', async () => {
const semverLt = jest.spyOn(semver, 'lt');
const cwd = await lerna.bootstrap('lerna-two', __dirname);
const packages = await config.utils.getPackages({cwd});

expect(packages).toEqual(['a2', 'b2']);
expect(semverLt).toHaveBeenLastCalledWith('2.11.0', '3.0.0');
expect(semverLt).toHaveLastReturnedWith(true);
});

test('uses lerna version >= 3 if installed', async () => {
const semverLt = jest.spyOn(semver, 'lt');
const cwd = await lerna.bootstrap('basic', __dirname);

const packages = await config.utils.getPackages({cwd});

expect(packages).toEqual(['a', 'b']);
expect(semverLt).toHaveBeenLastCalledWith('3.20.2', '3.0.0');
expect(semverLt).toHaveLastReturnedWith(false);
});
2 changes: 1 addition & 1 deletion @commitlint/config-lerna-scopes/package.json
Expand Up @@ -26,7 +26,7 @@
},
"homepage": "https://github.com/conventional-changelog/commitlint#readme",
"peerDependencies": {
"lerna": "^2.11.0 ^2.11.0"
"lerna": "^3.22.1"
},
"engines": {
"node": ">=v10.22.0"
Expand Down
8 changes: 6 additions & 2 deletions @packages/test/src/lerna.ts
Expand Up @@ -3,14 +3,18 @@ import fs from 'fs-extra';
import resolvePkg from 'resolve-pkg';
import * as fix from './fix';

export type LernaFixture = 'basic' | 'empty' | 'lerna-two' | 'scoped';
export type LernaFixture = 'basic' | 'empty' | 'scoped';

export async function bootstrap(
fixture: string,
directory: string
): Promise<string> {
const cwd = await fix.bootstrap(`fixtures/${fixture}`, directory);
const lerna = fixture === 'lerna-two' ? 'lerna-v2' : 'lerna-v3';
// this used to test lerna v2 and v3
// the v2 option is removed here, lerna version tests as well
// all the code to test differnt version is still in place
// cause i'm not sure how to remove this properly
const lerna = 'lerna-v3';
await fs.mkdirp(path.join(cwd, 'node_modules', '@lerna'));
await fs.symlink(
resolvePkg('@lerna/project')!,
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -90,7 +90,6 @@
"husky": "4.2.5",
"jest": "25.1.0",
"lerna": "^3.22.1",
"lerna-v2": "npm:lerna@2",
"lerna-v3": "npm:lerna@3",
"lint-staged": "10.3.0",
"prettier": "^2.0.5",
Expand Down

0 comments on commit 59667b3

Please sign in to comment.