-
Notifications
You must be signed in to change notification settings - Fork 1k
Use autoconfig in c3 #11251
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
Use autoconfig in c3 #11251
Conversation
🦋 Changeset detectedLatest commit: 923d457 The changes in this PR will be included in the next version bump. 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 |
| `Running autoconfig with:\n${JSON.stringify(autoConfigDetails, null, 2)}...` | ||
| ); | ||
|
|
||
| startSection("Configuring your application for Cloudflare"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This output was a bit verbose
| logger.log({ | ||
| hasYarn, | ||
| hasNpm, | ||
| hasPnpm, | ||
| hasBun, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MattieTK I think this was a stray debugging log that got merged
| // check the user agent | ||
| if (userAgent === "npm" && hasNpm) { | ||
| logger.log("Using npm as package manager."); | ||
| logger.debug("Using npm as package manager."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These being .log() was getting very noisy
packages/wrangler/src/setup.ts
Outdated
| // Only run auto config if the project is not already configured | ||
| if (!details.configured) { | ||
| await runAutoConfig(details); | ||
| await runAutoConfig(details, { skipBuild: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wrangler setup shouldn't really be running a build, in my opinion.
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
c91c08f to
40c72d3
Compare
40c72d3 to
f634b16
Compare
…meworks we were injecting extra dev commands into package.json files, which meant that generated C3 projects often had both a `start` and a `develop` script.
ad59ecf to
076b75c
Compare
| deploy: | ||
| autoConfigDetails.framework?.deploy ?? | ||
| (autoConfigDetails.buildCommand | ||
| ? `${autoConfigDetails.buildCommand} && wrangler deploy` | ||
| : `wrangler deploy`), | ||
| preview: | ||
| autoConfigDetails.framework?.preview ?? | ||
| (autoConfigDetails.buildCommand | ||
| ? `${autoConfigDetails.buildCommand} && wrangler dev` | ||
| : `wrangler dev`), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mh.... I am not completely sure if we should modify the deploy and preview script for the user... it feels a bit invasive 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is invasive, but I think it's the right behaviour. It matches what C3 does, and (as with all the autconfig settings), a user could roll it back if they wanted to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a user could roll it back if they wanted to.
Yes for sure 👍
but I think it's the right behaviour
Ok, if you think so I am happy with it 🙂, it does feel a bit off to me... but it also does make sense...
Also including these scripts could be instrumental for handling the Next.js issue you raised (since our open-next adapter has its own preview and deploy commands)
| "create-cloudflare": minor | ||
| --- | ||
|
|
||
| When the `--experimental` flag is passed to `create-cloudflare`, use `wrangler setup` for configuring a project to work on Cloudflare rather than the existing `create-cloudflare` logic. Only Gatsby is supported right now, with more frameworks to be added in future. There should be no functional change to applications created via `create-cloudflare` when using the `--experimental` flag. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @petebacondarwin introduced the --experimental flag in C3, I'd be keen to hear if he's ok with the flag's repurposing (or if he had in mind other potential uses for it)
Personally I'd prefer a more clear and specific flag, but I'm ok with --experimental if everyone else is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I went with --experimental is that 1) it's currently not used for anything, and 2) it already has a bunch of infra set up (e.g. separate test runs) that's useful. I also think the semantic matches what we're doing here—we're changing the underlying implementation of C3 in an experimental way that we'll eventually turn on by default, which is exactly what we did with Assets.
| // so wait up to 3 mins for the dev-server to be ready. | ||
| await retry( | ||
| { times: 300, sleepMs: 5000 }, | ||
| { times: 30, sleepMs: 5000 }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why such reduction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO 25 minutes is way too long. The comment above mentioned 5 minutes, but I've changed them both to be a consistent 3 minutes, since that seems sufficiently long for a build in CI
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
30 times 5 seconds, isn't it 150 seconds? so 2.5 minutes?
I did also comment above as the numbers here are not matching up for me 😅
(maybe I would update the comment to say so wait for some time for the dev-server to be ready. so that we don't need to over-analyze be specific on the time?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO 25 minutes is way too long. The comment above mentioned 5 minutes
that's another reason as to why I would recommend to be a bit more generic with the comment, so that we avoid this sort of issues when the comment got outdate 🤔
(PS: 25 minutes does feel like a very long time, if reducing it works in CI, I'm totally happy with that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, sorry for the nit 😅👍
dario-piotrowicz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me! 🤩
Fixes https://jira.cfdata.org/browse/DEVX-2313
This repurposes the existing C3
--experimentalflag (which has associated filtering, logging and separate test runs) to configure frameworks with autoconfig (viawrangler setup) instead of using the existing C3 logic. Over time, this will expand to more frameworks, at which point autoconfig will become the default C3 flow