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

Should czg and cz-git must install root in monorepo? #68

Closed
2 tasks done
i7eo opened this issue Oct 11, 2022 · 6 comments
Closed
2 tasks done

Should czg and cz-git must install root in monorepo? #68

i7eo opened this issue Oct 11, 2022 · 6 comments
Assignees
Labels
not bug | wontfix This is't cz-git bug

Comments

@i7eo
Copy link

i7eo commented Oct 11, 2022

✅ Checklist

  • I am using the latest version
  • I have searched FAQ

📄 System Info

System:
    OS: macOS 12.6
    CPU: (10) arm64 Apple M1 Max
    Memory: 23.08 GB / 64.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.16.0/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
    Watchman: 2022.01.17.00 - /opt/homebrew/bin/watchman
  npmPackages:
    cz-git: 1.3.11 => 1.3.11 
    czg: 1.3.11 => 1.3.11

🔎 Description

Concise Description

我使用 pnpm 创建了一个 monorepo 项目,当我在根目录下安装 cz-git 与 czg 的时候一切正常。当我把与 commitlint 相关的操作封装成一个包放在 packages 目录下名为 commitlint-config 时,在根目录下执行 pnpm --filter=@mercur9/commitlint-config exec czg 时报错,报错如下:

no such file or directory, scandir '/xxx/_/commitlint-config/packages'

这个时候我尝试在 npmrc 中将 commitlint 的包全部提升至根部成功后,执行 pnpm exec czg 还是报同样的错误。

这很让人疑惑 😹

🔗 Reproduction link / repo:

No response

@i7eo i7eo added the bug Something isn't working label Oct 11, 2022
@i7eo
Copy link
Author

i7eo commented Oct 11, 2022

感觉是 czg 与 cz-git 必须安装在根目录下,即使使用 public-hoist-pattern 提升至根目录也不行

@i7eo i7eo changed the title [Bug report] Should czg and cz-git must install root in monorepo? Oct 11, 2022
@Zhengqbbb
Copy link
Owner

你的意思是想把 czg 依赖放在 sub package中?

不过为什么呢,如果你是想把配置项作为一个npm package,大可以直接写配置,根packages.json引用并继承使用
czg 和 cz-git 最好是放在根packages.json中使用,他两都是0依赖不会出现幽灵依赖的风险

@i7eo
Copy link
Author

i7eo commented Oct 11, 2022

你的意思是想把 czg 依赖放在 sub package中?

不过为什么呢,如果你是想把配置项作为一个npm package,大可以直接写配置,根packages.json引用并继承使用 czg 和 cz-git 最好是放在根packages.json中使用,他两都是0依赖不会出现幽灵依赖的风险

单独把 .commitlintrc.js 的配置放在 sub package 中。问题定位到了,是我这边自己的问题,我先解决下。感谢回复🙏

@Zhengqbbb
Copy link
Owner

这主要和 pnpm 使用有关与 node 运行特性有关:
问题:

  1. pnpm --filter=x exec ${command} 这里的 command 并不能运行.bin 下的 node 可执行文件,而是 packages.json 中的 scripts
  2. 是否能利用 .npmrc 导入package于根 pnpm exec ${command} 取决 czg 是否正常在根的 node_modules/.bin 文件夹中

image


基于以上两点:

  1. 你在debug的时候只要看czg是否在根 node_modules/.bin 中 在就能用啦~
  2. 其实不推荐把 czg 在放在 @mercur9/commitlint-config 中不然你维护还是要加 czg 依赖在其他项目中,中间还夹了pnpm寻找包,启动时间慢了,没必要
  3. 其实你大可以 @mercur9/commitlint-config 只写配置 根利用 commitlint 的 extends 进行继承,这样比较好

@Zhengqbbb Zhengqbbb added not bug | wontfix This is't cz-git bug and removed bug Something isn't working labels Oct 11, 2022
@Zhengqbbb
Copy link
Owner

Zhengqbbb commented Oct 11, 2022

好的~
下次有问题欢迎来 Discussions 找我~毕竟我还是比较想要小徽章的😎

@i7eo
Copy link
Author

i7eo commented Oct 11, 2022

好的~ 下次有问题欢迎来 Discussions 找我~毕竟我还是比较想要小徽章的😎

满足你🤪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not bug | wontfix This is't cz-git bug
Projects
None yet
Development

No branches or pull requests

2 participants