-
Notifications
You must be signed in to change notification settings - Fork 0
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
chore(package.json): fix settings allowing developers to only use pnpm #673
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We tried running the `npm i` command on this project. We found some problems, which we will fix. + Add `--yes` option to `npx only-allow pnpm` command The npx command prompts before installing a non-existent package. To suppress this prompt, the `--yes` option must be added. + Add incorrect `engines` field for npm and yarn The `npm install` command executes the `preinstall` script after downloading the dependencies. Thus, after waiting for the dependencies to download, the developer learns that he/she/they should use pnpm instead of npm for this project. This is a waste of time. So we set an incorrect value in the `engines` field. npm will display a warning that the `engines` field is invalid while downloading dependencies. Thus, the developer can abort the dependency download. see https://zenn.dev/uttk/articles/create-pnpm-monorepo Note: If we set the `engine-strict` config flag, npm will automatically abort the dependency download. However, error messages reporting incorrect `engines` fields are never easy to read. The developer will have difficulty knowing why the `npm install` command is failing. Error messages displayed by the `npx --yes only-allow pnpm` command are better.
…command The `npx` command included with npm v6 does not allow the `--yes` option. However, the `npx` command included with npm v7 and later will print a prompt if the `--yes` option is not added. To solve this problem, we decided to include `only-allow` in the dev dependencies for this project. This will ensure that `only-allow` is executed correctly in each version of the `npx` command: + If using npm v6, the `--yes` option is not necessary. npx will run `only-allow` without prompting. + If using npm v7 or later, the `npm install` command will install the dependencies before running the `preinstall` script. `only-allow` is included in the dependencies, so npx will not fetch `only-allow` from remote. Therefore, npx will not print a prompt.
…option with the `npx` command With yarn, the `preinstall` script is run before the dependencies are installed. In this case, the npx command will print a prompt if npm v7 or later is installed in the development environment. This reverts commit fe4cb64.
…nto stdin of the `npx` command The `npx` command included with npm v6 does not allow the `--yes` option. However, the `npx` command included with npm v7 and later will print a prompt if the `--yes` option is not added. To solve this problem, we decided to automatically input "y" into the stdin of the `npx` command. This is the same solution as using the `yes` command in Unix. However, the `yes` command is not available on Windows, so the `node` command is used to output "y" instead of it. Note: The `npx` command included with npm v7 and later seems not to print a prompt just the Unix pipeline is connected. see https://github.com/npm/cli/blob/libnpmexec-v5.0.11/workspaces/libnpmexec/lib/index.js#L245-L262 see https://github.com/npm/cli/blob/libnpmexec-v5.0.11/workspaces/libnpmexec/test/prompt.js#L167-L186 Thus, without outputting "y", this problem can be solved with the following simple command: `node -e "" | npx only-allow pnpm` However, this behavior may not be the same for future `npx` commands.
Code Climate has analyzed commit 19872e0 and detected 0 issues on this pull request. View more on Code Climate. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We tried running the
npm i
command on this project. We found some problems, which we will fix.Automatically inputs "y" into the stdin of the
npx only-allow pnpm
commandThe
npx
command prompts before installing a non-existent package.This prompt will continue if type "y". Thus, we have fixed it to automatically input "y".
Add incorrect
engines
field for npm and yarnIn npm v7 and later, the
npm install
command executes thepreinstall
script after downloading the dependencies.Thus, after waiting for the dependencies to download, the developer learns that he/she/they should use pnpm instead of npm for this project.
This is a waste of time.
So we set an incorrect value in the
engines
field.npm will display a warning that the
engines
field is invalid while downloading dependencies.Thus, the developer can abort the dependency download.
see https://zenn.dev/uttk/articles/create-pnpm-monorepo