Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lerna v4 uses named imports #2452

Closed
1 task done
johngnapp opened this issue Feb 15, 2021 · 6 comments
Closed
1 task done

Lerna v4 uses named imports #2452

johngnapp opened this issue Feb 15, 2021 · 6 comments

Comments

@johngnapp
Copy link

johngnapp commented Feb 15, 2021

After upgrading my project to use Lerna v4.0.0, I can no longer run commitlint.

Expected Behavior

Commit checks should run as usual when using Lerna v4.0.0

Current Behavior

Commitlint blows up when running the commit hooks. The following error occurs in @commitlint\config-lerna-scopes\index.js:47:20 - "TypeError: Project is not a constructor".

Affected packages

  • config-lerna-scopes

Possible Solution

Add another check for lerna version in the getPackages function:

const lernaVersion = getLernaVersion(cwd);
if (semver.lt(lernaVersion, '3.0.0')) {
	const Repository = importFrom(cwd, 'lerna/lib/Repository');
	const PackageUtilities = importFrom(cwd, 'lerna/lib/PackageUtilities');

	const repository = new Repository(cwd);
	return PackageUtilities.getPackages({
		packageConfigs: repository.packageConfigs,
		rootPath: cwd,
	});
}

// New check for less than v4.0.0
if (semver.lt(lernaVersion, '4.0.0')) {
	const Project = importFrom(cwd, '@lerna/project');
	const project = new Project(cwd);
	return project.getPackages();
}

const { getPackages } = importFrom(cwd, '@lerna/project');
return getPackages();

Steps to Reproduce (for bugs)

  1. First step - upgrade solution to use Lerna v4.0.0
  2. Second step - run pre-commit checks

Context

This issue prevents me from running pre-commit checks, so I can only commit code by skipping the checks with the --no-verify flag.

Your Environment

Executable Version
commitlint --version @commitlint/cli@12.0.0
git --version git version 2.29.2.windows.2
node --version v14.15.1
@escapedcat
Copy link
Member

escapedcat commented Feb 16, 2021

Thanks, lerna v4 just came out and we haven't added support yet.

@escapedcat
Copy link
Member

Relates to #2447

@armano2
Copy link
Contributor

armano2 commented Mar 5, 2021

@escapedcat this issue will be resolved with next release and can be now closed

@escapedcat
Copy link
Member

Yup, thanks!

@escapedcat
Copy link
Member

v12.1.0 is released under the next-tag. Please give it a try.

@johngnapp
Copy link
Author

Works like a dream, great work everyone! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants