Open itsaryan72 opened 1 month ago
⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪ |
🧪 No relevant tests |
🔒 No security concerns identified |
⚡ Key issues to review Compatibility The preinstall script may not work correctly on Windows systems due to the use of Bash-specific syntax. |
Category | Suggestion | Score |
Enhancement |
Improve the accuracy of the package manager check in the preinstall script___ **Consider using a more robust check for PNPM by explicitly checking for 'pnpm/' atthe start of the user agent string. This will prevent false positives if 'pnpm' appears elsewhere in the user agent string.** [package.json [93]](https://github.com/keyshade-xyz/keyshade/pull/467/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R93-R93) ```diff -"preinstall": "if [[ \"$npm_config_user_agent\" != *pnpm* ]]; then echo 'This project uses pnpm. Please run using pnpm.'; exit 1; fi", +"preinstall": "if [[ \"$npm_config_user_agent\" != pnpm/* ]]; then echo 'This project uses pnpm. Please run using pnpm.'; exit 1; fi", ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 8Why: The suggestion improves the robustness of the check by ensuring that 'pnpm/' is at the start of the user agent string, reducing the chance of false positives. | 8 |
User experience |
Provide more helpful information in the error message of the preinstall script___ **Consider adding a more informative error message that includes instructions on howto install PNPM if it's not already installed.** [package.json [93]](https://github.com/keyshade-xyz/keyshade/pull/467/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R93-R93) ```diff -"preinstall": "if [[ \"$npm_config_user_agent\" != *pnpm* ]]; then echo 'This project uses pnpm. Please run using pnpm.'; exit 1; fi", +"preinstall": "if [[ \"$npm_config_user_agent\" != *pnpm* ]]; then echo 'This project uses pnpm. Please run using pnpm. To install pnpm, visit https://pnpm.io/installation'; exit 1; fi", ``` - [ ] **Apply this suggestion** Suggestion importance[1-10]: 7Why: Adding instructions on how to install PNPM enhances user experience by providing immediate guidance, though it is not crucial for functionality. | 7 |
💡 Need additional feedback ? start a PR chat
@kriptonian1
Hey @itsaryan72, it is returning Unsupported Protocol
error than returning the intended messages, can you look into this
Hello @kriptonian1 , Thanks for reviewing my work. I think the npm package depends on some other dependencies. In case of "yarn install" it gives the correct error "Error: Only pnpm is allowed. Please use pnpm instead.".
Tried removing all the workspace keyword and file but still it gives the same error. I seriously want to solve this error kindly help me.
Buddy, I checked it's still not working
User description
GENERAL: Only allow PNPM #366
description
Restriction on Package Manager Usage To ensure consistency in our project, I've added a preinstall script in package.json. "preinstall": "if [[ \"$npm_config_user_agent\" != pnpm ]]; then echo 'This project uses pnpm. Please run using pnpm.'; exit 1; fi",
This script checks the package manager before installation and displays an error if anything other than PNPM is used, promoting uniformity among contributors.
Fixes #366 GENERAL: Only allow PNPM #366
Dependencies
No additional packages or dependencies are required for the preinstall script
Developer's checklist
If changes are made in the code:
Documentation Update
PR Type
enhancement, configuration changes
Description
preinstall
script inpackage.json
to enforce the use of PNPM as the package manager.npm_config_user_agent
and exits with an error message if a package manager other than PNPM is used.Changes walkthrough 📝
package.json
Enforce PNPM as the package manager in preinstall script
package.json
preinstall
script to enforce the use of PNPM.PNPM.