-
Notifications
You must be signed in to change notification settings - Fork 710
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
C3-workers-assets-experimental-templates #6678
Conversation
🦋 Changeset detectedLatest commit: 1ab2c79 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
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/10834033820/npm-package-wrangler-6678 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6678/npm-package-wrangler-6678 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10834033820/npm-package-wrangler-6678 dev path/to/script.js Additional artifacts:npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10834033820/npm-package-create-cloudflare-6678 --no-auto-update npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10834033820/npm-package-cloudflare-kv-asset-handler-6678 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10834033820/npm-package-miniflare-6678 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10834033820/npm-package-cloudflare-pages-shared-6678 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10834033820/npm-package-cloudflare-vitest-pool-workers-6678 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10834033820/npm-package-cloudflare-workers-editor-shared-6678 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10834033820/npm-package-cloudflare-workers-shared-6678 Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
67c4973
to
3021d43
Compare
vi.mocked(readFile).mockReturnValue(` | ||
experimental_assets = { directory = "./dist", binding = "ASSETS" } | ||
|
||
[[durable_objects.bindings]] |
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.
Arguably Durable Objects can be deployed if they have migrations setup.
But the previous state of affairs didn't support that, so it is out of scope for this PR to change that.
@@ -67,12 +68,11 @@ const isDeployable = async (ctx: C3Context) => { | |||
return true; | |||
} | |||
|
|||
const wranglerToml = readWranglerToml(ctx); | |||
if (wranglerToml.match(/(?<!#\s*)bindings?\s*=.*/m)) { |
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 approach was too simplistic because it also blocked Workers that have assets bindings, which can be deployed straight up.
] as keyof typeof clisPackageJson.dependencies; | ||
const version = clisPackageJson.dependencies[frameworkCli]; | ||
const frameworkCli = ctx.template | ||
.frameworkCli as keyof typeof frameworksPackageJson.dependencies; |
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 source of truth for mapping between frameworks and their CLI has moved to the c3.ts
template so that is all kept in one place, allowing us to remove that map from the frameworks/package.json
@@ -0,0 +1,3 @@ | |||
{ | |||
"extends": "../../tsconfig.json" |
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 file is needed so that VS Code (eslint) knows that the TS files in this folder are configured by TypeScript. The package.json in this directory makes eslint think this is a separate TS project.
@@ -98,9 +98,9 @@ export const gitCommit = async (ctx: C3Context) => { | |||
}; | |||
|
|||
const createCommitMessage = async (ctx: C3Context) => { | |||
const isPages = ctx.template.platform === "pages"; | |||
const framework = ctx.template.frameworkCli; |
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's not only Pages projects that can run Frameworks!
if (args?.experimental) { | ||
logRaw( | ||
blue( | ||
"You have selected experimental mode - the options below are filtered to those that support experimental mode.\n", |
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.
@tanushree-sharma - you might have a view on the copy here, but I wanted to call out to people that they would see a different list of frameworks/templates when the are running --experimental
mode.
3021d43
to
3df7947
Compare
f511ded
to
06258bf
Compare
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 haven't reviewed the templates-experimental
folder, but this looks good!
…atform This avoids C3 from trying to create a Pages project for them. Needed a bit of refactoring to ensure that these new templates still work even if not marked as "pages".
06258bf
to
1ab2c79
Compare
To try this out:
What this PR solves / how to test
Adds experimental support to C3 for generating Workers with Assets projects.
Author has addressed the following