Skip to content

Conversation

@galargh
Copy link
Contributor

@galargh galargh commented Nov 20, 2024

  • Because this PR includes a bug fix, relevant tests have been included.
  • Because this PR includes a new feature, the change was previously discussed on an Issue or with someone from the team.
  • I didn't do anything of this.

Resolves #5954

  • Tests for installation of --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.
    • e.g. if you have viem already installed in the package, it just installs it again, potentially a different version
    • Maybe we should check this before even copying any file and fail
      • except for a hardhat clash, which will be common

Tests 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 and yarn 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 check dependencies 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.

@galargh galargh requested a review from kanej November 20, 2024 12:34
@changeset-bot
Copy link

changeset-bot bot commented Nov 20, 2024

⚠️ No Changeset found

Latest commit: 2d94531

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Nov 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hardhat ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 3, 2025 8:55pm

@alcuadrado alcuadrado self-requested a review December 3, 2024 22:04
@alcuadrado
Copy link
Member

Thanks, I'll review this one to make sure i understand the installation process

dav3yblaz3

This comment was marked as spam.

dav3yblaz3

This comment was marked as spam.

@schaable schaable added the v-next A Hardhat v3 development task label Dec 30, 2024
@alcuadrado
Copy link
Member

Let's move the telemetry consent prompt to be the last question before installation of dependencies

@galargh galargh added this pull request to the merge queue Jan 3, 2025
Merged via the queue into v-next with commit 22389d6 Jan 3, 2025
55 checks passed
@galargh galargh deleted the init-cleanup branch January 3, 2025 21:23
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

v-next A Hardhat v3 development task

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants