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

output wrangler.jsonc in c3 #8024

Merged
merged 10 commits into from
Feb 11, 2025
Merged

output wrangler.jsonc in c3 #8024

merged 10 commits into from
Feb 11, 2025

Conversation

emily-shen
Copy link
Contributor

@emily-shen emily-shen commented Feb 4, 2025

Fixes #7948
Fixes #8030

  1. Generates wrangler.jsonc instead of wrangler.json, which supports comments
  2. Add a vscode setting that lets vscode know that wrangler.json can have comments
  3. use tabs in wrangler.jsonc

  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because:
  • E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because: no wrangler changes. (c3 tests will run without this being ticked)
  • Public documentation

Copy link

changeset-bot bot commented Feb 4, 2025

🦋 Changeset detected

Latest commit: 320847d

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 Minor

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

Copy link
Contributor

github-actions bot commented Feb 4, 2025

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/13265352200/npm-package-wrangler-8024

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

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

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13265352200/npm-package-wrangler-8024 dev path/to/script.js
Additional artifacts:

cloudflare-workers-bindings-extension:

wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13265352200/npm-package-cloudflare-workers-bindings-extension-8024 -O ./cloudflare-workers-bindings-extension.0.0.0-v40878168e.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-v40878168e.vsix

create-cloudflare:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13265352200/npm-package-create-cloudflare-8024 --no-auto-update

@cloudflare/kv-asset-handler:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13265352200/npm-package-cloudflare-kv-asset-handler-8024

miniflare:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13265352200/npm-package-miniflare-8024

@cloudflare/pages-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13265352200/npm-package-cloudflare-pages-shared-8024

@cloudflare/unenv-preset:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13265352200/npm-package-cloudflare-unenv-preset-8024

@cloudflare/vite-plugin:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13265352200/npm-package-cloudflare-vite-plugin-8024

@cloudflare/vitest-pool-workers:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13265352200/npm-package-cloudflare-vitest-pool-workers-8024

@cloudflare/workers-editor-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13265352200/npm-package-cloudflare-workers-editor-shared-8024

@cloudflare/workers-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13265352200/npm-package-cloudflare-workers-shared-8024

@cloudflare/workflows-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13265352200/npm-package-cloudflare-workflows-shared-8024

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.20250129.0
workerd 1.20250204.0 1.20250204.0
workerd --version 1.20250204.0 2025-02-04

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

@emily-shen emily-shen changed the title add vscode file association setting for wrangler.json output wrangler.jsonc in c3 Feb 5, 2025
@emily-shen emily-shen marked this pull request as ready for review February 5, 2025 15:54
@emily-shen emily-shen requested review from a team as code owners February 5, 2025 15:54
@emily-shen emily-shen force-pushed the emily/json-squiggles branch from ce8efc4 to 29d29c5 Compare February 5, 2025 17:11
@vicb
Copy link
Contributor

vicb commented Feb 6, 2025

Are we planning to update the docs site to use .jsonc insteaf of .json?

@emily-shen
Copy link
Contributor Author

Are we planning to update the docs site to use .jsonc insteaf of .json?

cloudflare/cloudflare-docs#19764

@@ -238,6 +238,14 @@ describe.skipIf(experimental || frameworkToTest || isQuarantineMode())(
`Cloning template from: cloudflare/templates/multiplayer-globe-template`,
);
expect(output).toContain(`template cloned and validated`);
expect(readFileSync(`${project.path}/.vscode/settings.json`, "utf8"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: should this use JSON.parse(...) so that we don't depend on the exact format which we don't really care about?

@@ -772,21 +772,21 @@ const runCli = async (
*/
const addTestVarsToWranglerToml = async (projectPath: string) => {
const wranglerTomlPath = join(projectPath, "wrangler.toml");
const wranglerJsonPath = join(projectPath, "wrangler.json");
const wranglerJsoncPath = join(projectPath, "wrangler.jsonc");
if (existsSync(wranglerTomlPath)) {
const wranglerToml = readToml(wranglerTomlPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: should wranglerToml / wranglerJson be renamed to just config (they are neither Toml nor json)

expect(jsonPath).toExist();
const config = readJSON(jsonPath) as { main?: string };
expect(jsoncPath).toExist();
const config = readJSON(jsoncPath) as { main?: string };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: don't we have the type for the config?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in C3, I don't think? It's defined in Wrangler, and right now there's no dependency between the two packages

Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

"create-cloudflare": minor
---

Output wrangler.jsonc instead of wrangler.json by default
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Output wrangler.jsonc instead of wrangler.json by default
Output wrangler.jsonc instead of wrangler.json

This isn't configurable, so I don't think we should use "default" language

expect(jsonPath).toExist();
const config = readJSON(jsonPath) as { main?: string };
expect(jsoncPath).toExist();
const config = readJSON(jsoncPath) as { main?: string };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in C3, I don't think? It's defined in Wrangler, and right now there's no dependency between the two packages

const settingsPath = `${ctx.project.path}/.vscode/settings.json`;

// don't override a user's existing settings
// as this is just a quick stop gap we'll just not bother if the file exists
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where the json-comment library is very nice!

@emily-shen emily-shen merged commit e8272b0 into main Feb 11, 2025
27 checks passed
@emily-shen emily-shen deleted the emily/json-squiggles branch February 11, 2025 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
4 participants