Skip to content

Conversation

RamIdeas
Copy link
Contributor

@RamIdeas RamIdeas commented May 26, 2023

Fixes #3333 #3319

What this PR solves / how to test:

When wrangler init … -y delegates to C3, it now sets a hidden flag –wrangler-defaults which will skip all prompts in C3. Fixes #3333

Test by running wrangler init -y or wrangler init --from-dash test -y and confirm the process exits without user input.

Also, C3 now allows to use an existing directory if it is empty. Fixes #3319

Test by setting the project directory to 1. an empty directory, and 2. a non-empty directory. The former succeeds while the latter will fail

Associated docs issue(s)/PR(s):

  • [insert associated docs issue(s)/PR(s)]

Author has included the following, where applicable:

Reviewer is to perform the following, as applicable:

  • Checked for inclusion of relevant tests
  • Checked for inclusion of a relevant changeset
  • Checked for creation of associated docs updates
  • Manually pulled down the changes and spot-tested

RamIdeas added 3 commits May 26, 2023 18:25
to skip prompts if set

Fixes #3333

Allow existing directories if they are empty

Fixes #3319
@changeset-bot
Copy link

changeset-bot bot commented May 26, 2023

🦋 Changeset detected

Latest commit: 736ec96

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

This PR includes changesets to release 2 packages
Name Type
create-cloudflare Patch
wrangler 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

@github-actions
Copy link
Contributor

github-actions bot commented May 26, 2023

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/5221030979/npm-package-wrangler-3359

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

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

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/5221030979/npm-package-wrangler-3359 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/5221030979/npm-package-cloudflare-pages-shared-3359

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

@RamIdeas RamIdeas changed the title [C3 + wrangler] wrangler init ... -y delegates to C3 without prompts (respects the -y flag) [C3 + wrangler] wrangler init … -y delegates to C3 without prompts (respects the -y flag) May 26, 2023
@codecov
Copy link

codecov bot commented Jun 9, 2023

Codecov Report

Merging #3359 (736ec96) into main (23ed5f5) will increase coverage by 0.01%.
The diff coverage is 87.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3359      +/-   ##
==========================================
+ Coverage   75.43%   75.44%   +0.01%     
==========================================
  Files         182      182              
  Lines       11055    11060       +5     
  Branches     2898     2903       +5     
==========================================
+ Hits         8339     8344       +5     
  Misses       2716     2716              
Impacted Files Coverage Δ
packages/wrangler/src/init.ts 92.93% <87.50%> (-0.18%) ⬇️

... and 16 files with indirect coverage changes

@rozenmd
Copy link
Contributor

rozenmd commented Jun 9, 2023

Doesn't seem to work with the preview build:

rozenmd@xxxxx ~ % npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/5221030979/npm-package-wrangler-3359 init test-worker -y
 ⛅️ wrangler 0.0.0-4f9a6363 (update available 0.0.0-a719555a)
-----------------------------------------------------------------------
Using npm as package manager.
▲ [WARNING] The `init` command is no longer supported. Please use `npm create cloudflare@2 -- --wrangler-defaults` instead.

  The `init` command will be removed in a future version.


Running `npm create cloudflare@2 -- --wrangler-defaults`...
Need to install the following packages:
  [email protected]
Ok to proceed? (y) y

using create-cloudflare version 2.0.9

╭ Create an application with Cloudflare Step 1 of 3
│
╰ Where do you want to create your application? also used as application name
--lingering-resonance-9635

also might wanna update the text recommending npm create cloudflare@2 to npm create cloudflare@latest?

@RamIdeas
Copy link
Contributor Author

RamIdeas commented Jun 9, 2023

Doesn't seem to work with the preview build:

Ah yeah good catch wrangler calls out to npm create cloudflare@2 so won't use the create-cloudflare package in this monorepo (and the changes in this PR). We can test disjointedly by checking wrangler init -y sets the –wranger-defaults when it runs create-cloudflare. Then, separately, check create-cloudflare runs non-interactively when –wrangler-defaults is set.

also might wanna update the text recommending npm create cloudflare@2 to npm create cloudflare@latest?

Thanks for catching this. There is an ongoing convo with @petebacondarwin who is conscious of having outdated versions of wrangler@3 installed on machines running newer versions of C3 (>2) which may not be compatible with the expected behaviour. I'll factor this into the convo when we next bring it up

@RamIdeas RamIdeas merged commit 5eef992 into main Jun 9, 2023
@RamIdeas RamIdeas deleted the c3-wrangler-defaults branch June 9, 2023 15:15
@github-actions github-actions bot mentioned this pull request Jun 10, 2023
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: wrangler init does not respect --yes/-y flag when delegating to C3 🐛 BUG: selecting current directory (.) to output doesn't work with C3
3 participants