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

fix(config-lerna-scopes): remove deprecated @lerna/project dependency #4284

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion @commitlint/config-lerna-scopes/fixtures/basic/lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"lerna": "4",
"lerna": "8",
"version": "1.0.0",
"packages": ["packages/*"]
}
3 changes: 1 addition & 2 deletions @commitlint/config-lerna-scopes/fixtures/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "basic",
"version": "1.0.0",
"devDependencies": {
"lerna": "^4.0.0",
"@lerna/project": "^4.0.0"
"lerna": "^8.1.9"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "a",
"name": "@commitlint-lerna-scopes/basic-a",
"version": "1.0.0"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "b",
"name": "@commitlint-lerna-scopes/basic-b",
"version": "1.0.0"
}
2 changes: 1 addition & 1 deletion @commitlint/config-lerna-scopes/fixtures/empty/lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"lerna": "4",
"lerna": "8",
"version": "1.0.0",
"packages": ["packages/*"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "empty",
"version": "1.0.0",
"devDependencies": {
"lerna": "^4.0.0",
"lerna": "^8.1.9",
"@lerna/project": "^4.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"lerna": "4",
"lerna": "8",
"version": "1.0.0",
"packages": ["packages/*"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "basic",
"version": "1.0.0",
"devDependencies": {
"lerna": "^4.0.0",
"@lerna/project": "^4.0.0"
"lerna": "^8.1.9"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "a",
"name": "@commitlint-lerna-scopes/modules-a",
"version": "1.0.0"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@packages/nested-a",
"name": "@commitlint-lerna-scopes/nested-a",
"version": "1.0.0"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@packages/nested-b",
"name": "@commitlint-lerna-scopes/nested-b",
"version": "1.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lerna": "8",
"version": "1.0.0",
"packages": ["packages/**"]
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"name": "nested-workspaces",
"version": "1.0.0",
"workspaces": [
"@packages/**"
],
"devDependencies": {
"lerna": "^4.0.0",
"@lerna/project": "^4.0.0"
"lerna": "^8.1.9"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@packages/a",
"name": "@commitlint-lerna-scopes/scoped-a",
"version": "1.0.0"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@packages/b",
"name": "@commitlint-lerna-scopes/scoped-b",
"version": "1.0.0"
}
2 changes: 1 addition & 1 deletion @commitlint/config-lerna-scopes/fixtures/scoped/lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"lerna": "4",
"lerna": "8",
"version": "1.0.0",
"packages": ["@packages/*"]
}
3 changes: 1 addition & 2 deletions @commitlint/config-lerna-scopes/fixtures/scoped/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "scoped",
"version": "1.0.0",
"devDependencies": {
"lerna": "^4.0.0",
"@lerna/project": "^4.0.0"
"lerna": "^8.1.9"
}
}

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions @commitlint/config-lerna-scopes/fixtures/yarn/package.json

This file was deleted.

75 changes: 18 additions & 57 deletions @commitlint/config-lerna-scopes/index.js
Original file line number Diff line number Diff line change
@@ -1,70 +1,31 @@
import {createRequire} from 'module';
import Path from 'path';

import {globSync} from 'glob';
import importFrom from 'import-from';
import semver from 'semver';

const require = createRequire(import.meta.url);

export default {
utils: {getPackages},
utils: {
getPackages,
},
rules: {
'scope-enum': (ctx) =>
getPackages(ctx).then((packages) => [2, 'always', packages]),
},
};

function getPackages(context) {
return Promise.resolve()
.then(() => {
const ctx = context || {};
const cwd = ctx.cwd || process.cwd();

const {workspaces} = require(Path.join(cwd, 'package.json'));
if (Array.isArray(workspaces) && workspaces.length) {
// use yarn workspaces
async function getPackages(context) {
const ctx = context || {};
const cwd = ctx.cwd || process.cwd();

const wsGlobs = workspaces.flatMap((ws) => {
const path = Path.posix.join(ws, 'package.json');
return globSync(path, {cwd, ignore: ['**/node_modules/**']});
});
// https://lerna.js.org/docs/api-reference/utilities#detectprojects
const {detectProjects} = importFrom(cwd, 'lerna/utils');
// https://github.com/lerna/lerna/blob/main/libs/core/src/lib/project-graph-with-packages.ts#L14
const projectGraph = await detectProjects(cwd);

Check failure on line 20 in @commitlint/config-lerna-scopes/index.js

View workflow job for this annotation

GitHub Actions / NodeJS installed from stock Ubuntu-LTS packages (not external sources)

@commitlint/load/src/load.test.ts > rules should be loaded from local

ProjectGraphError: Failed to process project graph. ❯ validateAndNormalizeProjectRootMap node_modules/nx/src/project-graph/utils/project-configuration-utils.js:455:15 ❯ mergeCreateNodesResults node_modules/nx/src/project-graph/utils/project-configuration-utils.js:341:9 ❯ node_modules/nx/src/project-graph/utils/project-configuration-utils.js:285:85 ❯ buildProjectGraphAndSourceMapsWithoutDaemon node_modules/nx/src/project-graph/project-graph.js:87:31 ❯ createProjectGraphAndSourceMapsAsync node_modules/nx/src/project-graph/project-graph.js:271:25 ❯ createProjectGraphAsync node_modules/nx/src/project-graph/project-graph.js:219:39 ❯ detectProjects node_modules/lerna/dist/utils/index.js:3729:25 ❯ getPackages @commitlint/config-lerna-scopes/index.js:20:23 ❯ execute @commitlint/execute-rule/src/index.ts:20:16 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errors: [ { stack: 'MultipleProjectsWithSameNameError: The following projects are defined in multiple locations:\n- a: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/a\n - nx/a\n- b: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/b\n - nx/b\n- c: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/c\n - nx/c\n- d: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/d\n - nx/d\n- e: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/e\n - nx/e\n- f: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/f\n - nx/f\n- g: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/g\n - nx/g\n- h: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/h\n - nx/h\n\nTo fix this, set a unique name for each project in a project.json inside the project\'s root. If the project does not currently have a project.json, you can create one that contains only a name.\n at validateAndNormalizeProjectRootMap (/__w/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:455:15)\n at mergeCreateNodesResults (/__w/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:341:9)\n at /__w/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:285:85\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at buildProjectGraphAndSourceMapsWithoutDaemon (/__w/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:87:31)\n at createProjectGraphAndSourceMapsAsync (/__w/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:271:25)\n at createProjectGraphAsync (/__w/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:219:39)\n at detectProjects (/__w/commitlint/commitlint/node_modules/lerna/dist/utils/index.js:3729:25)\n at getPackages (/__w/commitlint/commitlint/@commitlint/config-lerna-scopes/index.js:20:23)\n at execute (/__w/commitlint/commitlint/@commitlint/execute-rule/src/index.ts:20:16)', message: 'The following projects are defined in multiple locations:\n- a: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/a\n - nx/a\n- b: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/b\n - nx/b\n- c: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/c\n - nx/c\n- d: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/d\n - nx/d\n- e: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/e\n - nx/e\n- f: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/f\n - nx/f\n- g: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/g\n - nx/g\n- h: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/h\n - nx/h\n\nTo fix this, set a unique name for each project in a project.json inside the project\'s root. If the project does not currently have a project.json, you can create one that contains only a name.', conflicts: { constructor: 'Function<Map>', get: 'Function<get>', set: 'Function<set>', has: 'Function<has>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', keys: 'Function<keys>', size: 8, values: 'Function<values>' }, projects: { commitlint: { root: '@alias/commitlint', sourceRoot: '@alias/commitlin

Check failure on line 20 in @commitlint/config-lerna-scopes/index.js

View workflow job for this annotation

GitHub Actions / NodeJS installed from stock Ubuntu-LTS packages (not external sources)

@commitlint/load/src/load.test.ts > plugins should be loaded from local

ProjectGraphError: Failed to process project graph. ❯ validateAndNormalizeProjectRootMap node_modules/nx/src/project-graph/utils/project-configuration-utils.js:455:15 ❯ mergeCreateNodesResults node_modules/nx/src/project-graph/utils/project-configuration-utils.js:341:9 ❯ node_modules/nx/src/project-graph/utils/project-configuration-utils.js:285:85 ❯ buildProjectGraphAndSourceMapsWithoutDaemon node_modules/nx/src/project-graph/project-graph.js:87:31 ❯ createProjectGraphAndSourceMapsAsync node_modules/nx/src/project-graph/project-graph.js:271:25 ❯ createProjectGraphAsync node_modules/nx/src/project-graph/project-graph.js:219:39 ❯ detectProjects node_modules/lerna/dist/utils/index.js:3729:25 ❯ getPackages @commitlint/config-lerna-scopes/index.js:20:23 ❯ execute @commitlint/execute-rule/src/index.ts:20:16 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errors: [ { stack: 'MultipleProjectsWithSameNameError: The following projects are defined in multiple locations:\n- a: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/a\n - nx/a\n- b: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/b\n - nx/b\n- c: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/c\n - nx/c\n- d: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/d\n - nx/d\n- e: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/e\n - nx/e\n- f: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/f\n - nx/f\n- g: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/g\n - nx/g\n- h: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/h\n - nx/h\n\nTo fix this, set a unique name for each project in a project.json inside the project\'s root. If the project does not currently have a project.json, you can create one that contains only a name.\n at validateAndNormalizeProjectRootMap (/__w/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:455:15)\n at mergeCreateNodesResults (/__w/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:341:9)\n at /__w/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:285:85\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at buildProjectGraphAndSourceMapsWithoutDaemon (/__w/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:87:31)\n at createProjectGraphAndSourceMapsAsync (/__w/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:271:25)\n at createProjectGraphAsync (/__w/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:219:39)\n at detectProjects (/__w/commitlint/commitlint/node_modules/lerna/dist/utils/index.js:3729:25)\n at getPackages (/__w/commitlint/commitlint/@commitlint/config-lerna-scopes/index.js:20:23)\n at execute (/__w/commitlint/commitlint/@commitlint/execute-rule/src/index.ts:20:16)', message: 'The following projects are defined in multiple locations:\n- a: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/a\n - nx/a\n- b: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/b\n - nx/b\n- c: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/c\n - nx/c\n- d: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/d\n - nx/d\n- e: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/e\n - nx/e\n- f: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/f\n - nx/f\n- g: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/g\n - nx/g\n- h: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/h\n - nx/h\n\nTo fix this, set a unique name for each project in a project.json inside the project\'s root. If the project does not currently have a project.json, you can create one that contains only a name.', conflicts: { constructor: 'Function<Map>', get: 'Function<get>', set: 'Function<set>', has: 'Function<has>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', keys: 'Function<keys>', size: 8, values: 'Function<values>' }, projects: { commitlint: { root: '@alias/commitlint', sourceRoot: '@alias/commitlin

Check failure on line 20 in @commitlint/config-lerna-scopes/index.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 18)

@commitlint/load/src/load.test.ts > rules should be loaded from local

ProjectGraphError: Failed to process project graph. ❯ validateAndNormalizeProjectRootMap node_modules/nx/src/project-graph/utils/project-configuration-utils.js:455:15 ❯ mergeCreateNodesResults node_modules/nx/src/project-graph/utils/project-configuration-utils.js:341:9 ❯ node_modules/nx/src/project-graph/utils/project-configuration-utils.js:285:85 ❯ buildProjectGraphAndSourceMapsWithoutDaemon node_modules/nx/src/project-graph/project-graph.js:87:31 ❯ createProjectGraphAndSourceMapsAsync node_modules/nx/src/project-graph/project-graph.js:271:25 ❯ createProjectGraphAsync node_modules/nx/src/project-graph/project-graph.js:219:39 ❯ detectProjects node_modules/lerna/dist/utils/index.js:3729:25 ❯ getPackages @commitlint/config-lerna-scopes/index.js:20:23 ❯ execute @commitlint/execute-rule/src/index.ts:20:16 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errors: [ { stack: 'MultipleProjectsWithSameNameError: The following projects are defined in multiple locations:\n- a: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/a\n - nx/a\n- b: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/b\n - nx/b\n- c: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/c\n - nx/c\n- d: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/d\n - nx/d\n- e: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/e\n - nx/e\n- f: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/f\n - nx/f\n- g: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/g\n - nx/g\n- h: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/h\n - nx/h\n\nTo fix this, set a unique name for each project in a project.json inside the project\'s root. If the project does not currently have a project.json, you can create one that contains only a name.\n at validateAndNormalizeProjectRootMap (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:455:15)\n at mergeCreateNodesResults (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:341:9)\n at /home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:285:85\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at buildProjectGraphAndSourceMapsWithoutDaemon (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:87:31)\n at createProjectGraphAndSourceMapsAsync (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:271:25)\n at createProjectGraphAsync (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:219:39)\n at detectProjects (/home/runner/work/commitlint/commitlint/node_modules/lerna/dist/utils/index.js:3729:25)\n at getPackages (/home/runner/work/commitlint/commitlint/@commitlint/config-lerna-scopes/index.js:20:23)\n at execute (/home/runner/work/commitlint/commitlint/@commitlint/execute-rule/src/index.ts:20:16)', message: 'The following projects are defined in multiple locations:\n- a: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/a\n - nx/a\n- b: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/b\n - nx/b\n- c: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/c\n - nx/c\n- d: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/d\n - nx/d\n- e: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/e\n - nx/e\n- f: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/f\n - nx/f\n- g: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/g\n - nx/g\n- h: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/h\n - nx/h\n\nTo fix this, set a unique name for each project in a project.json inside the project\'s root. If the project does not currently have a project.json, you can create one that contains only a name.', conflicts: { constructor: 'Function<Map>', get: 'Function<get>', set: 'Function<set>', has: 'Function<has>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', keys: 'Function<keys>', size

Check failure on line 20 in @commitlint/config-lerna-scopes/index.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 18)

@commitlint/load/src/load.test.ts > plugins should be loaded from local

ProjectGraphError: Failed to process project graph. ❯ validateAndNormalizeProjectRootMap node_modules/nx/src/project-graph/utils/project-configuration-utils.js:455:15 ❯ mergeCreateNodesResults node_modules/nx/src/project-graph/utils/project-configuration-utils.js:341:9 ❯ node_modules/nx/src/project-graph/utils/project-configuration-utils.js:285:85 ❯ buildProjectGraphAndSourceMapsWithoutDaemon node_modules/nx/src/project-graph/project-graph.js:87:31 ❯ createProjectGraphAndSourceMapsAsync node_modules/nx/src/project-graph/project-graph.js:271:25 ❯ createProjectGraphAsync node_modules/nx/src/project-graph/project-graph.js:219:39 ❯ detectProjects node_modules/lerna/dist/utils/index.js:3729:25 ❯ getPackages @commitlint/config-lerna-scopes/index.js:20:23 ❯ execute @commitlint/execute-rule/src/index.ts:20:16 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errors: [ { stack: 'MultipleProjectsWithSameNameError: The following projects are defined in multiple locations:\n- a: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/a\n - nx/a\n- b: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/b\n - nx/b\n- c: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/c\n - nx/c\n- d: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/d\n - nx/d\n- e: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/e\n - nx/e\n- f: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/f\n - nx/f\n- g: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/g\n - nx/g\n- h: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/h\n - nx/h\n\nTo fix this, set a unique name for each project in a project.json inside the project\'s root. If the project does not currently have a project.json, you can create one that contains only a name.\n at validateAndNormalizeProjectRootMap (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:455:15)\n at mergeCreateNodesResults (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:341:9)\n at /home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:285:85\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at buildProjectGraphAndSourceMapsWithoutDaemon (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:87:31)\n at createProjectGraphAndSourceMapsAsync (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:271:25)\n at createProjectGraphAsync (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:219:39)\n at detectProjects (/home/runner/work/commitlint/commitlint/node_modules/lerna/dist/utils/index.js:3729:25)\n at getPackages (/home/runner/work/commitlint/commitlint/@commitlint/config-lerna-scopes/index.js:20:23)\n at execute (/home/runner/work/commitlint/commitlint/@commitlint/execute-rule/src/index.ts:20:16)', message: 'The following projects are defined in multiple locations:\n- a: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/a\n - nx/a\n- b: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/b\n - nx/b\n- c: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/c\n - nx/c\n- d: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/d\n - nx/d\n- e: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/e\n - nx/e\n- f: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/f\n - nx/f\n- g: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/g\n - nx/g\n- h: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/h\n - nx/h\n\nTo fix this, set a unique name for each project in a project.json inside the project\'s root. If the project does not currently have a project.json, you can create one that contains only a name.', conflicts: { constructor: 'Function<Map>', get: 'Function<get>', set: 'Function<set>', has: 'Function<has>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', keys: 'Function<keys>', size

Check failure on line 20 in @commitlint/config-lerna-scopes/index.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 20)

@commitlint/load/src/load.test.ts > rules should be loaded from local

ProjectGraphError: Failed to process project graph. ❯ validateAndNormalizeProjectRootMap node_modules/nx/src/project-graph/utils/project-configuration-utils.js:455:15 ❯ mergeCreateNodesResults node_modules/nx/src/project-graph/utils/project-configuration-utils.js:341:9 ❯ node_modules/nx/src/project-graph/utils/project-configuration-utils.js:285:85 ❯ buildProjectGraphAndSourceMapsWithoutDaemon node_modules/nx/src/project-graph/project-graph.js:87:31 ❯ createProjectGraphAndSourceMapsAsync node_modules/nx/src/project-graph/project-graph.js:271:25 ❯ createProjectGraphAsync node_modules/nx/src/project-graph/project-graph.js:219:39 ❯ detectProjects node_modules/lerna/dist/utils/index.js:3729:25 ❯ getPackages @commitlint/config-lerna-scopes/index.js:20:23 ❯ execute @commitlint/execute-rule/src/index.ts:20:16 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errors: [ { stack: 'MultipleProjectsWithSameNameError: The following projects are defined in multiple locations:\n- a: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/a\n - nx/a\n- b: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/b\n - nx/b\n- c: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/c\n - nx/c\n- d: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/d\n - nx/d\n- e: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/e\n - nx/e\n- f: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/f\n - nx/f\n- g: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/g\n - nx/g\n- h: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/h\n - nx/h\n\nTo fix this, set a unique name for each project in a project.json inside the project\'s root. If the project does not currently have a project.json, you can create one that contains only a name.\n at validateAndNormalizeProjectRootMap (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:455:15)\n at mergeCreateNodesResults (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:341:9)\n at /home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:285:85\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at buildProjectGraphAndSourceMapsWithoutDaemon (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:87:31)\n at createProjectGraphAndSourceMapsAsync (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:271:25)\n at createProjectGraphAsync (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:219:39)\n at detectProjects (/home/runner/work/commitlint/commitlint/node_modules/lerna/dist/utils/index.js:3729:25)\n at getPackages (/home/runner/work/commitlint/commitlint/@commitlint/config-lerna-scopes/index.js:20:23)\n at execute (/home/runner/work/commitlint/commitlint/@commitlint/execute-rule/src/index.ts:20:16)', message: 'The following projects are defined in multiple locations:\n- a: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/a\n - nx/a\n- b: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/b\n - nx/b\n- c: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/c\n - nx/c\n- d: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/d\n - nx/d\n- e: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/e\n - nx/e\n- f: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/f\n - nx/f\n- g: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/g\n - nx/g\n- h: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/h\n - nx/h\n\nTo fix this, set a unique name for each project in a project.json inside the project\'s root. If the project does not currently have a project.json, you can create one that contains only a name.', conflicts: { constructor: 'Function<Map>', get: 'Function<get>', set: 'Function<set>', has: 'Function<has>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', keys: 'Function<keys>', size

Check failure on line 20 in @commitlint/config-lerna-scopes/index.js

View workflow job for this annotation

GitHub Actions / build (ubuntu-22.04, 20)

@commitlint/load/src/load.test.ts > plugins should be loaded from local

ProjectGraphError: Failed to process project graph. ❯ validateAndNormalizeProjectRootMap node_modules/nx/src/project-graph/utils/project-configuration-utils.js:455:15 ❯ mergeCreateNodesResults node_modules/nx/src/project-graph/utils/project-configuration-utils.js:341:9 ❯ node_modules/nx/src/project-graph/utils/project-configuration-utils.js:285:85 ❯ buildProjectGraphAndSourceMapsWithoutDaemon node_modules/nx/src/project-graph/project-graph.js:87:31 ❯ createProjectGraphAndSourceMapsAsync node_modules/nx/src/project-graph/project-graph.js:271:25 ❯ createProjectGraphAsync node_modules/nx/src/project-graph/project-graph.js:219:39 ❯ detectProjects node_modules/lerna/dist/utils/index.js:3729:25 ❯ getPackages @commitlint/config-lerna-scopes/index.js:20:23 ❯ execute @commitlint/execute-rule/src/index.ts:20:16 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Serialized Error: { errors: [ { stack: 'MultipleProjectsWithSameNameError: The following projects are defined in multiple locations:\n- a: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/a\n - nx/a\n- b: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/b\n - nx/b\n- c: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/c\n - nx/c\n- d: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/d\n - nx/d\n- e: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/e\n - nx/e\n- f: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/f\n - nx/f\n- g: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/g\n - nx/g\n- h: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/h\n - nx/h\n\nTo fix this, set a unique name for each project in a project.json inside the project\'s root. If the project does not currently have a project.json, you can create one that contains only a name.\n at validateAndNormalizeProjectRootMap (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:455:15)\n at mergeCreateNodesResults (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:341:9)\n at /home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/utils/project-configuration-utils.js:285:85\n at processTicksAndRejections (node:internal/process/task_queues:95:5)\n at buildProjectGraphAndSourceMapsWithoutDaemon (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:87:31)\n at createProjectGraphAndSourceMapsAsync (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:271:25)\n at createProjectGraphAsync (/home/runner/work/commitlint/commitlint/node_modules/nx/src/project-graph/project-graph.js:219:39)\n at detectProjects (/home/runner/work/commitlint/commitlint/node_modules/lerna/dist/utils/index.js:3729:25)\n at getPackages (/home/runner/work/commitlint/commitlint/@commitlint/config-lerna-scopes/index.js:20:23)\n at execute (/home/runner/work/commitlint/commitlint/@commitlint/execute-rule/src/index.ts:20:16)', message: 'The following projects are defined in multiple locations:\n- a: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/a\n - nx/a\n- b: \n - @commitlint/config-nx-scopes/fixtures/basic/nx/b\n - nx/b\n- c: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/c\n - nx/c\n- d: \n - @commitlint/config-nx-scopes/fixtures/nx14/nx/d\n - nx/d\n- e: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/e\n - nx/e\n- f: \n - @commitlint/config-nx-scopes/fixtures/nx15/nx/f\n - nx/f\n- g: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/g\n - nx/g\n- h: \n - @commitlint/config-nx-scopes/fixtures/nx17/nx/h\n - nx/h\n\nTo fix this, set a unique name for each project in a project.json inside the project\'s root. If the project does not currently have a project.json, you can create one that contains only a name.', conflicts: { constructor: 'Function<Map>', get: 'Function<get>', set: 'Function<set>', has: 'Function<has>', delete: 'Function<delete>', clear: 'Function<clear>', entries: 'Function<entries>', forEach: 'Function<forEach>', keys: 'Function<keys>', size
const packages = Object.values(projectGraph.nodes)
.map((node) => node.package)
.filter(Boolean);

return wsGlobs.map((pJson) => require(Path.join(cwd, pJson)));
}

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,
});
}

const {getPackages} = importFrom(cwd, '@lerna/project');
return getPackages(cwd);
})
.then((packages) => {
return packages
.map((pkg) => pkg.name)
.filter(Boolean)
.map((name) => (name.charAt(0) === '@' ? name.split('/')[1] : name));
});
}
console.log('>>>>>> PACKAGES', packages);

function getLernaVersion(cwd) {
const moduleEntrypoint = require.resolve('lerna', {
paths: [cwd],
});
const moduleDir = Path.join(
moduleEntrypoint.slice(0, moduleEntrypoint.lastIndexOf('node_modules')),
'node_modules',
'lerna'
);
const modulePackageJson = Path.join(moduleDir, 'package.json');
return require(modulePackageJson).version;
return packages
.map((pkg) => pkg.name)
.filter(Boolean)
.map((name) => (name.charAt(0) === '@' ? name.split('/')[1] : name));
}
22 changes: 2 additions & 20 deletions @commitlint/config-lerna-scopes/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ test('returns empty value for empty lerna repository', async () => {
expect(value).toEqual([]);
});

test('returns expected value for basic lerna repository', async () => {
test.only('returns expected value for basic lerna repository', async () => {
const {'scope-enum': fn} = config.rules;
const cwd = await npm.bootstrap('fixtures/basic', __dirname);

const [, , value] = await fn({cwd});
expect(value).toEqual(['a', 'b']);
expect(value).toEqual(['a', 'b', 'c']);
});

test('returns expected value for lerna repository containing modules', async () => {
Expand All @@ -81,21 +81,3 @@ test('returns expected value for scoped lerna repository', async () => {
const [, , value] = await fn({cwd});
expect(value).toEqual(['a', 'b']);
});

test('returns expected value for yarn workspaces', async () => {
const {'scope-enum': fn} = config.rules;
const cwd = path.join(__dirname, 'fixtures', 'yarn');
const [, , value] = await fn({cwd});
expect(value.sort()).toEqual(['a', 'b']);
});

test('returns expected value for yarn workspaces has nested packages', async () => {
const {'scope-enum': fn} = config.rules;
const cwd = await npm.bootstrap('fixtures/nested-workspaces', __dirname);

const [, , value] = await fn({cwd});
expect(value).toEqual(expect.arrayContaining(['nested-a', 'nested-b']));
expect(value).toEqual(
expect.not.arrayContaining(['dependency-a', 'dependency-b'])
);
});
9 changes: 5 additions & 4 deletions @commitlint/config-lerna-scopes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
"lerna"
],
"author": "Mario Nebl <[email protected]>",
"contributors": [
"Jan Biasi (https://github.com/janbiasi)"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/conventional-changelog/commitlint/issues"
},
"homepage": "https://commitlint.js.org/",
"peerDependencies": {
"lerna": ">=5 <9"
"lerna": ">=7.1.0"
},
"peerDependenciesMeta": {
"lerna": {
Expand All @@ -40,15 +43,13 @@
"node": ">=v18"
},
"dependencies": {
"@lerna/project": "^6.0.0",
"glob": "^10.3.10",
"import-from": "^4.0.0",
"semver": "^7.6.0"
},
"devDependencies": {
"@commitlint/test": "^19.5.0",
"@commitlint/utils": "^19.5.0",
"@types/glob": "^8.1.0"
"lerna": "^8.1.9"
},
"gitHead": "70f7f4688b51774e7ac5e40e896cdaa3f132b2bc"
}
3 changes: 1 addition & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"lerna": "4",
"lerna": "8",
"npmClient": "yarn",
"useWorkspaces": true,
"version": "19.7.1"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"eslint-plugin-jest": "^28.8.2",
"globals": "^15.13.0",
"husky": "^9.1.5",
"lerna": "^6.0.0",
"lerna": "^8.1.9",
"lint-staged": "15.4.3",
"prettier": "^2.8.8",
"typescript": "^5.2.2",
Expand Down
Loading
Loading