Skip to content

Commit

Permalink
Add more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
penalosa committed Jan 9, 2025
1 parent a9fe2e1 commit f48adac
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/create-cloudflare/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const configure = async (ctx: C3Context) => {
await installWrangler();
await installWorkersTypes(ctx);

// Note: updateWranglerToml _must_ be called before the configure phase since
// Note: This _must_ be called before the configure phase since
// pre-existing workers assume its presence in their configure phase
await updateWranglerConfig(ctx);

Expand Down
2 changes: 1 addition & 1 deletion packages/create-cloudflare/src/helpers/compatDate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { C3Context } from "types";

/**
* Look up the latest release of workerd and use its date as the compatibility_date
* configuration value for wrangler.toml.
* configuration value for a wrangler config file.
*
* If the look up fails then we fall back to a well known date.
*
Expand Down
10 changes: 6 additions & 4 deletions packages/create-cloudflare/src/wrangler/__tests__/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,18 @@ describe("update wrangler config", () => {

const newConfig = vi.mocked(writeFile).mock.calls[0][1];
expect(newConfig).toMatchInlineSnapshot(`
"// For more details on how to configure Wrangler, refer to:
// https://developers.cloudflare.com/workers/wrangler/configuration/
"/**
* For more details on how to configure Wrangler, refer to:
* https://developers.cloudflare.com/workers/wrangler/configuration/
*/
{
"$schema": "node_modules/wrangler/config-schema.json",
"name": "test",
"main": "src/index.ts",
"compatibility_date": "2024-01-17",
"$schema": "node_modules/wrangler/config-schema.json",
"observability": {
"enabled": true
}
},
/**
* Smart Placement
* Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
Expand Down
10 changes: 5 additions & 5 deletions packages/create-cloudflare/src/wrangler/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ export const updateWranglerConfig = async (ctx: C3Context) => {
ensureNameExists(parsed, ctx.project.name),
);

const comment = `// For more details on how to configure Wrangler, refer to:\n// https://developers.cloudflare.com/workers/wrangler/configuration/\n`;
const comment = `/**\n * For more details on how to configure Wrangler, refer to:\n * https://developers.cloudflare.com/workers/wrangler/configuration/\n */\n{\n "$schema": "node_modules/wrangler/config-schema.json",`;

modified["$schema"] = "node_modules/wrangler/config-schema.json";
if (!modified["observability"]) {
modified["observability"] = { enabled: true };
}
const stringified = comment + JSON.stringify(modified, null, 2);
const stringified = comment + JSON.stringify(modified, null, 2).slice(1);

writeWranglerJson(
ctx,
stringified.slice(0, -1) +
` /**
stringified.slice(0, -2) +
`,
/**
* Smart Placement
* Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
*/
Expand Down

0 comments on commit f48adac

Please sign in to comment.