address the follow-up tasks related to --init #5959
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.
Resolves #5954
--init
, this doesn't need to be e2e but it should test at a minimum it should prove that spawn works on different platforms.--init
doesn’t show “help us improve…”--init
doesn’t check for existing dependencies.viem
already installed in the package, it just installs it again, potentially a different versionTests for installation
We had the test for installation committed, but marked as skipped. I now enabled it, but I added a conditional skip statement to that test.
Now, if a flag
HARDHAT_DISABLE_SLOW_TESTS=true
is present, the long running tests will be skipped.The test I reenabled tests installing dependencies for all the templates using
npm
(pnpm
andyarn
remain untested for now).Help us improve...
I added the telemetry consent question as the first one in the init flow (immediately after the welcome message). My thinking is that it will allow us to collect data about aborted init flows.
Please let me know if you prefer me to move the question to the end of the flow.
Existing dependencies handling
Checking if a dependency already exists before proceeding with installation was already put in place. The behaviour that I opted for in the original version was to skip installation of the dependencies that are already installed. There are some adjustments that I introduced in this PR.
Firstly, we used to only browse the
devDependencies
when checking if a dependency is installed or not. Now, we'll also checkdependencies
just in case.Secondly, I added version checks. Now, if a dependency is already installed, we'll check if the installed version (or a version range) satisfies the version (or a version range) specified in the template. If it doesn't, we'll suggest upgrading/downgrading the installed version to the version from the template. I intentionally kept the updates separate from the installs of completely new dependencies because I think it is quite likely a user might want to proceed with one while skipping the other. Also, I suspect the messaging around both will evolve in slightly different directions.