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

Add newline to prepended name and compatibility_date in wrangler.toml #5816

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nielsreijers
Copy link
Contributor

This was causing create-cloudflare to generate an incorrect wrangler.toml for templates that didn't include these attributes.

What this PR solves / how to test

When npm create cloudflare creates a project, it either updates name and compatibility_date properties in wrangler.toml, or adds them if they don't exist yet.
In that case they are added by prepending to the toml file, but this is done without a new line, which results in a broken toml file.

For example this:
npm create cloudflare@latest my-app -- --template xtuc/img-color-worker

Results in this wrangler.toml:

compatibility_date = "2024-05-12"name = "my-app"
type = "webpack"

account_id = ""
workers_dev = true
route = ""
zone_id = ""

Apparently in this case the template did have a name = , which was updated, but no compatibility_date = , so it was prepended to the file but without a new line.

The fix is pretty simple, and I've added a line to the corresponding unit test to parse the resulting toml to make sure it's valid.

Your CONTRIBUTING.md says it's ok to open a PR directly for trivial changes. I think this could be considered trivial, but course that depends on your definition. :-)
So if you'd like me to open an issue for this, then please let me know.

Author has addressed the following

  • Tests
    • TODO (before merge)
    • [X ] Included
    • Not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required / Maybe required
    • [ X] Not required because: Very small local bugfix, covered by extending an existing unit test
  • Changeset (Changeset guidelines)
    • TODO (before merge)
    • Included
    • [ X] Not necessary because: Trivial change
  • Public documentation

@nielsreijers nielsreijers requested a review from a team as a code owner May 14, 2024 04:12
Copy link

changeset-bot bot commented May 14, 2024

⚠️ No Changeset found

Latest commit: 676b2e6

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

@nielsreijers nielsreijers force-pushed the fix-wrangler-toml-in-some-generated-projects branch from 7dcb807 to 676b2e6 Compare June 30, 2024 09:16
@penalosa penalosa closed this Sep 12, 2024
@penalosa penalosa reopened this Sep 12, 2024
@penalosa penalosa requested a review from a team as a code owner September 12, 2024 02:00
Copy link
Contributor

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/10822770220/npm-package-wrangler-5816

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

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

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10822770220/npm-package-wrangler-5816 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10822770220/npm-package-create-cloudflare-5816 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10822770220/npm-package-cloudflare-kv-asset-handler-5816
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10822770220/npm-package-miniflare-5816
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10822770220/npm-package-cloudflare-pages-shared-5816
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10822770220/npm-package-cloudflare-vitest-pool-workers-5816
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10822770220/npm-package-cloudflare-workers-editor-shared-5816
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10822770220/npm-package-cloudflare-workers-shared-5816

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.20240821.2
workerd 1.20240909.0 1.20240909.0
workerd --version 1.20240909.0 2024-09-09

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

This was causing create-cloudflare to generate an incorrect wrangler.toml for templates that didn't include these attributes.
@penalosa penalosa force-pushed the fix-wrangler-toml-in-some-generated-projects branch from 676b2e6 to ccf01c9 Compare December 2, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Untriaged
Development

Successfully merging this pull request may close these issues.

2 participants