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

New check idea: DUPLICATE_PACKAGE_NAME #235

Open
kachkaev opened this issue Nov 4, 2024 · 2 comments
Open

New check idea: DUPLICATE_PACKAGE_NAME #235

kachkaev opened this issue Nov 4, 2024 · 2 comments

Comments

@kachkaev
Copy link

kachkaev commented Nov 4, 2024

I was creating a new package in a monorepo by copying an existing one. I forgot to change the name and ended up with two workspaces having identical names. pnpm install did not complain, manypkg did not either. It’d be great to see an error (DUPLICATE_PACKAGE_NAME?) in this case.

Here is an MWE for @manypkg/cli@0.22.0:
https://github.com/kachkaev/manypkg-issue-235

packages/a/package.json → "name": "a"
packages/b/package.json → "name": "b"
packages/c/package.json → "name": "a" ❗ should be "c"
pnpm manypkg check

## Recieved
☔️ success workspaces valid!

## Expected
☔️ error Workspaces at "packages/a" and "package/c" have the same name "a"
@kachkaev kachkaev changed the title New check idea: DUPLICATE_PACKAGE_NAME New check idea: DUPLICATE_PACKAGE_NAME Nov 4, 2024
@kachkaev
Copy link
Author

kachkaev commented Nov 4, 2024

Side observation: I removed "name" from packages/c/package.json just to see what happens. pnpm manypkg check produced this:

☔️ error PackageJsonMissingNameError: The following package.jsons are missing the "name" field:
☔️ error packages/c/package.json
☔️ error     at validatePackages (/path/to/project/node_modules/@manypkg/get-packages/dist/manypkg-get-packages.cjs.dev.js:57:11)
☔️ error     at Object.getPackages (/path/to/project/node_modules/@manypkg/get-packages/dist/manypkg-get-packages.cjs.dev.js:35:3)
☔️ error     at async /path/to/project/node_modules/@manypkg/cli/dist/manypkg-cli.cjs.dev.js:813:7 {
☔️ error   directories: [ 'packages/c/package.json' ]
☔️ error }

I was expecting to see INVALID_PACKAGE_NAME but got the crash instead. This is a pretty niche edge case, so not a big deal. Just flagging in case if a fix can be easily done simultaneously.

@Andarist
Copy link
Collaborator

Andarist commented Nov 4, 2024

Both should be improved/fixed. Thanks for raising an issue. I might not have time to implement this myself though - PRs are welcome 😉

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

No branches or pull requests

2 participants