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

address the follow-up tasks related to --init #5959

Open
wants to merge 4 commits into
base: v-next
Choose a base branch
from
Open

Conversation

galargh
Copy link
Member

@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
Copy link

changeset-bot bot commented Nov 20, 2024

⚠️ No Changeset found

Latest commit: 3751e97

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

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 Nov 20, 2024 0:34am

@github-actions github-actions bot added the status:ready This issue is ready to be worked on label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

1 participant