workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

Add newline to prepended name and compatibility_date in wrangler.toml

Open nielsreijers opened this issue 1 year ago • 1 comments

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 avatar May 14 '24 04:05 nielsreijers

🦋 Changeset detected

Latest commit: 289c0c5cf43eeff0e65966a558478d739c456fc6

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

changeset-bot[bot] avatar May 14 '24 04:05 changeset-bot[bot]

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/12240909657/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/12240909657/npm-package-wrangler-5816 dev path/to/script.js
Additional artifacts:
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12240909657/npm-package-create-cloudflare-5816 --no-auto-update
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12240909657/npm-package-cloudflare-kv-asset-handler-5816
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12240909657/npm-package-miniflare-5816
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12240909657/npm-package-cloudflare-pages-shared-5816
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12240909657/npm-package-cloudflare-vitest-pool-workers-5816
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12240909657/npm-package-cloudflare-workers-editor-shared-5816
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12240909657/npm-package-cloudflare-workers-shared-5816
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/12240909657/npm-package-cloudflare-workflows-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.20241205.0
workerd 1.20241205.0 1.20241205.0
workerd --version 1.20241205.0 2024-12-05

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

github-actions[bot] avatar Sep 12 '24 02:09 github-actions[bot]

hi @nielsreijers,

this was fixed in https://github.com/cloudflare/workers-sdk/pull/7457. I didn't realise we had 2 open PRs that are fixing the same issue 😢 . I scanned through our open PRs this morning from newest to oldest, and am just coming across your PR now. I'm so terribly sorry about that 🙏 🙇 .

I'll go ahead and close this, but sending much ❤️ your way (if that helps) for putting all the effort into this PR, and for helping us improve wrangler 🙏

♥️♥️♥️

CarmenPopoviciu avatar Dec 10 '24 15:12 CarmenPopoviciu