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

fix: correctly find the latest version of create-cloudflare #4771

Merged
merged 2 commits into from
Jan 24, 2024

Conversation

petebacondarwin
Copy link
Contributor

When create-cloudflare starts up, it checks to see if the version being run is the latest available on npm.

What this PR solves / how to test:

Previously this check used npm info to look up the version. But was prone to failing if that command returned additional unexpected output such as warnings.

Now we make a fetch request to the npm REST API directly for the latest version, which does not have the problem of unexpected warnings.

Since the same approach is used to compute the latest version of workerd, the function to do this has been put into a helper.

Fixes #4729

Author has addressed the following:

  • Tests
    • Included
    • Not necessary because:
  • Changeset (Changeset guidelines)
    • Included
    • Not necessary because:
  • Associated docs
    • Issue(s)/PR(s):
    • Not necessary because: no user facing change

Copy link

changeset-bot bot commented Jan 18, 2024

🦋 Changeset detected

Latest commit: b697d6f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-cloudflare Patch

Not sure what this means? Click here to learn what changesets are.

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

@petebacondarwin petebacondarwin marked this pull request as ready for review January 18, 2024 14:30
@petebacondarwin petebacondarwin requested a review from a team as a code owner January 18, 2024 14:30
Copy link
Contributor

github-actions bot commented Jan 18, 2024

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7646321039/npm-package-wrangler-4771

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/4771/npm-package-wrangler-4771

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7646321039/npm-package-wrangler-4771 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7646321039/npm-package-create-cloudflare-4771 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7646321039/npm-package-miniflare-4771
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7646321039/npm-package-cloudflare-pages-shared-4771

Note that these links will no longer work once the GitHub Actions artifact expires.


[email protected] includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20231218.3
workerd 1.20231218.0 1.20231218.0
workerd --version 1.20231218.0 2023-12-18

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

Copy link
Member

@dario-piotrowicz dario-piotrowicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 🤩👍

Copy link

codecov bot commented Jan 18, 2024

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (d031e75) 70.56% compared to head (b697d6f) 70.58%.
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4771      +/-   ##
==========================================
+ Coverage   70.56%   70.58%   +0.01%     
==========================================
  Files         290      290              
  Lines       15089    15100      +11     
  Branches     3828     3832       +4     
==========================================
+ Hits        10648    10658      +10     
- Misses       4441     4442       +1     
Files Coverage Δ
...s/wrangler/src/cloudchamber/client/core/OpenAPI.ts 100.00% <ø> (ø)
...s/wrangler/src/cloudchamber/client/core/request.ts 62.65% <100.00%> (+0.22%) ⬆️
packages/wrangler/src/cloudchamber/index.ts 92.30% <83.33%> (-2.70%) ⬇️
packages/wrangler/src/cloudchamber/common.ts 44.77% <54.54%> (-0.41%) ⬇️

... and 5 files with indirect coverage changes

@petebacondarwin petebacondarwin force-pushed the fetch-from-npm-api-rather-than-npm-info branch 2 times, most recently from e7cd02f to 34b1846 Compare January 19, 2024 13:37
Comment on lines +31 to +49
!process.env.VITEST &&
!process.env.CI &&
isInteractive() &&
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved these checks here to make it easier to test the isUpdateAvailable() function but also because it is not really nice having checks like that hidden deep down in the code.

Copy link
Contributor

@jculvey jculvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the tests!

@petebacondarwin petebacondarwin force-pushed the fetch-from-npm-api-rather-than-npm-info branch 5 times, most recently from 5588bd9 to bade19d Compare January 23, 2024 20:53
@petebacondarwin petebacondarwin requested a review from a team as a code owner January 23, 2024 20:53
@petebacondarwin petebacondarwin force-pushed the fetch-from-npm-api-rather-than-npm-info branch from bade19d to 5fb0ec0 Compare January 23, 2024 21:39
@petebacondarwin petebacondarwin marked this pull request as draft January 23, 2024 21:51
@petebacondarwin petebacondarwin force-pushed the fetch-from-npm-api-rather-than-npm-info branch 2 times, most recently from 186bc43 to f344b61 Compare January 24, 2024 09:40
When create-cloudflare starts up, it checks to see if the version being run
is the latest available on npm.

Previously this check used `npm info` to look up the version.
But was prone to failing if that command returned additional unexpected output
such as warnings.

Now we make a fetch request to the npm REST API directly for the latest version,
which does not have the problem of unexpected warnings.

Since the same approach is used to compute the latest version of workerd, the
function to do this has been put into a helper.

Fixes #4729
The yargs help info is set to error, so this makes it consistent
and simpler to spy on in tests.
@petebacondarwin petebacondarwin force-pushed the fetch-from-npm-api-rather-than-npm-info branch from 8006e0b to b697d6f Compare January 24, 2024 21:13
@petebacondarwin petebacondarwin marked this pull request as ready for review January 24, 2024 21:15
@petebacondarwin petebacondarwin merged commit f4f38fc into main Jan 24, 2024
22 checks passed
@petebacondarwin petebacondarwin deleted the fetch-from-npm-api-rather-than-npm-info branch January 24, 2024 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 BUG: C3 fails if npm info returns warning messages as well as the expected output
4 participants