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 scopes getting all packages names as scope #3023

Closed
2 of 4 tasks
emredoganm opened this issue Feb 11, 2022 · 4 comments
Closed
2 of 4 tasks

Lerna scopes getting all packages names as scope #3023

emredoganm opened this issue Feb 11, 2022 · 4 comments
Labels

Comments

@emredoganm
Copy link
Contributor

Hi there,

I am using @commitlint/config-lerna-scopes for helping commitlint to find the scope of Lerna to create conventional commits. Today, I noticed that after I changed the workspace configuration from packages/* to packages/** to support nested packages inside the packages folder, the package gathers all packages dependencies like typescript.

Expected Behavior

It should gives me only my packages inside my monorepo while using a nested packages folder approach like packages/**
The output of the scopes should be like this:

✅ Prettied console output for expected scopes
[
  "release",
  "example-package",
  "ds-theme",
  "storybook-utils",
  "test-utils",
  "ui-utils",
  "ds-web-banner",
  "ds-web-button-group",
  "ds-web-context-menu",
  "ds-web-drawer",
  "ds-web-password-field",
  "ds-web-progress-bar",
  "ds-web-phone-number-field",
  "ds-web-select",
  "ds-web-select-with-additional-field",
  "ds-web-stepper",
  "ds-web-tile",
]

Current Behavior

It gives me all packages even the dependencies of my subfolder packages.
Output is like that:

🚨 Prettied console output for current situation for scope names
[
  "release",
  "example-package",
  "ds-theme",
  "storybook-utils",
  "test-utils",
  "ui-utils",
  "ds-web-banner",
  "ds-web-button-group",
  "ds-web-context-menu",
  "ds-web-drawer",
  "ds-web-password-field",
  "ds-web-progress-bar",
  "ds-web-phone-number-field",
  "ds-web-select",
  "ds-web-select-with-additional-field",
  "ds-web-stepper",
  "ds-web-tile",
  "typescript",
  "resolve-pathname",
  "history",
  "typescript",
  "value-equal",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "acorn-import-assertions",
  "commander",
  "acorn",
  "loader-runner",
  "serialize-javascript",
  "supports-color",
  "tapable",
  "jest-worker",
  "terser",
  "terser-webpack-plugin",
  "ts-loader",
  "typescript",
  "watchpack",
  "webpack",
  "webpack-cli",
  "webpack-sources",
  "acorn",
  "acorn-import-assertions",
  "commander",
  "jest-worker",
  "loader-runner",
  "serialize-javascript",
  "supports-color",
  "tapable",
  "terser",
  "terser-webpack-plugin",
  "ts-loader",
  "typescript",
  "watchpack",
  "webpack",
  "webpack-cli",
  "webpack-sources",
  "typescript",
  "typescript",
  "acorn",
  "typescript",
  "acorn-import-assertions",
  "jest-worker",
  "loader-runner",
  "serialize-javascript",
  "commander",
  "supports-color",
  "tapable",
  "terser",
  "terser-webpack-plugin",
  "ts-loader",
  "watchpack",
  "webpack",
  "typescript",
  "webpack-cli",
  "webpack-sources",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "typescript",
  "helper-wasm-section",
  "wasm-edit",
  "wast-printer",
  "wasm-opt",
  "configtest",
  "info",
  "serve",
  "bin",
  "dist",
  "helper-wasm-section",
  "wasm-opt",
  "wasm-edit",
  "wast-printer",
  "configtest",
  "info",
  "serve",
  "dist",
  "bin",
  "helper-wasm-section",
  "wasm-edit",
  "wast-printer",
  "wasm-opt",
  "configtest",
  "info",
  "serve",
  "bin",
  "dist",
  "commander",
  "source-map",
  "commander",
  "source-map",
  "commander",
  "source-map"
]
## Affected packages
  • cli
  • core
  • prompt
  • config-angular

Possible Solution

Steps to Reproduce (for bugs)

  1. Change your workspace configuration from workspaces: ['packages/*'] to workspaces: ['packages/**']
  2. You should see the scopes with the cli command if you give a wrong scope to your commit
🗂️ commitlint.config.js
  const { utils } = require('@commitlint/config-lerna-scopes');
  
  module.exports = {
    extends: [
      '@commitlint/config-conventional',
      '@commitlint/config-lerna-scopes',
    ],
    rules: {
      'scope-enum': async ctx => [
        2,
        'always',
        [...(await utils.getPackages(ctx)), 'release'],
      ],
    },
  };

Context

Your Environment

Executable Version
commitlint --version 16.0.2
git --version 2.35.1
node --version v14.18.0
@escapedcat escapedcat added the bug label Feb 12, 2022
@escapedcat
Copy link
Member

Hey @emredoganm , thanks for openeing this!
Would you be motivated and have time to try fixing this?

@emredoganm
Copy link
Contributor Author

Yeah, I think I found something relevant with this problem. I am on it and will create PR for it.

@emredoganm
Copy link
Contributor Author

@escapedcat The PR is ready for review 👋

@escapedcat
Copy link
Member

Published with 16.2.2

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

No branches or pull requests

2 participants