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

Support isolated folder for monorepo #628

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hanzhangyu
Copy link

@hanzhangyu hanzhangyu commented Apr 22, 2024

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

For the business-oriented of monorepo repository, the folders under packages are usually owned by different business teams. There is no relationship between the business teams whether the code is repeated with other teams. Each business group only concerns its global capabilities, or whether the infrastructure is repeated.

Therefore, I want to extend a skipIsolated field to prevent duplication detection between isolated folders.

monorepo/
├─ .monorepo.config.json
├─ node_modules/
├─ packages/
│  ├─ businessA/ // for TEAM A only
│  ├─ businessB/ // for TEAM B only
├─ globals/
├─ infra /
  • What is the current behavior? (You can also link to an open issue here)

the clones between packages/businessA with packages/businessB will be detected.

  • What is the new behavior (if this is a feature change)?

the clones between packages/businessA with packages/businessB will be skipped.

  • Other information:

This change is Reviewable

Copy link
Owner

@kucherenko kucherenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Excellent idea 👍🏻

__dirname + '/../fixtures'
],
skipIsolated: [
['packages/businessA', 'packages/businessB', 'packages/businessC'],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR, it is a brilliant idea!

May I suggest some changes, we have a similar option named --skipLocal for show duplications across the folders, the --skipLocal used path array from options to define folders, I guess we should use the same way here, what do you think?

The result will be like:

(async () => {
  const clones = await detectClones({
    path: [
      'packages/businessA', 
      'packages/businessB', 
      'packages/businessC'
    ],
    skipIsolated: true,
    silent: true
  });
  console.log(clones);
})()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kucherenko Thank you for your advice. Sorry, I didn't describe it clearly.

--skipIsolated means that submodules (packages/businessA, packages/businessB etc) can be isolated from each other when the detect path is the monorepo home project. And, other folders still want to be included in the clone code statistics normally.

(async () => {
  const clones = await detectClones({
    path: ['./'], // e.g. detect clones from packages/businessA + globals + libs
    skipIsolated: [
        [ 'packages/businessA', 'packages/businessB', 'packages/businessC'],
    ],
    silent: true
  });
  console.log(clones);
})()

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, sounds good, will merge the PR and publish new version

@hanzhangyu
Copy link
Author

hanzhangyu commented Apr 24, 2024 via email

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

Successfully merging this pull request may close these issues.

None yet

2 participants