Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .changeset/workers-sdk-config-rc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
"cf": minor
---

Support the Cloudflare config 1.0 release candidate and Build Output v1

cf now reads and writes Build Output under `.cloudflare/output/v1/`. The root
`config.json` keeps account settings under `settings` and records cf as its
`producer`. Output in the older v0 format is rejected, so rebuild projects
before deploying them with this release.

Container `max_instances` defaults to 20 when the config leaves it unset,
matching Wrangler.

`cf dev`, `cf build`, `cf deploy` and `cf previews deploy` now require
`@cloudflare/vite-plugin` 2.0.0-rc.0 or newer, and `cf init` scaffolds new
projects with `@cloudflare/vite-plugin@^2.0.0-rc.0`.

Use the published Workers SDK packages, including Wrangler 4.163.0 or newer
for the Wrangler delegate to produce compatible Build Output.
6 changes: 3 additions & 3 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ the complete generated and hand-written `_meta/commands.json` catalogue (see
| `local.ts` | Dependency-free `--local` lazy runtime loading |
| `local-runtime.ts` | Local request rewriting, runtime lifecycle, and explorer dispatch; dynamically imported |
| `delegate.ts` | local-install delegation (Wrangler-2 style): global cf re-execs a project-pinned local cf. `CF_DELEGATION` sentinel + `CF_DELEGATION_PID` (global cf's process ID; telemetry counts a run as delegated only when it matches the direct parent, or is absent from an older global cf) + `CF_DELEGATING_CLI_VERSION` (global version, read by telemetry) + realpath self-check + ephemeral-npx/dlx guard |
| `build-output.ts` | combines `readBuildOutput()`'s root config and `workers.default` from `.cloudflare/output/v0/workers/default/worker.config.json` and converts them into the deploy-helpers/Wrangler config shape (`convertToWranglerConfig` + `normalizeAndValidateConfig`) before deployment; owns `BuildOutputConfigError`, re-exports the package's `BuildOutputError` |
| `build-output.ts` | combines `readBuildOutput()`'s root config and `workers.default` from `.cloudflare/output/v1/workers/default/worker.config.json` and converts them into the deploy-helpers/Wrangler config shape (`convertToWranglerConfig` + `normalizeAndValidateConfig`) before deployment; owns `BuildOutputConfigError`, re-exports the package's `BuildOutputError` |
| `deploy-context.ts` | builds the `DeployHelpersContext` (fetch/logger/confirm/prompt closures) bridging cf auth/UX to deploy-helpers' module globals |
| `deploy-input.ts` | assembles `DeployProps` / `WorkerBuildResult` from build output (module-type mapping, routes, assets) |
| `dialog.ts` | cf prompt/dialog adapter shared by hand-written orchestration |
Expand Down Expand Up @@ -414,7 +414,7 @@ What cf DOES read:
the project's Miniflare resources for `--local`, matching the Cloudflare Vite
plugin's default for `cf dev`. `--persist-to` overrides it and is required
outside a project.
- **Build Output under `.cloudflare/output/v0/`** for `cf build`, `cf deploy`, `cf previews deploy`, `cf workers versions create`, `cf workers check`, and `cf workers triggers deploy`. A required top-level `config.json` carries account settings and `buildContext`; Worker directories contain `worker.config.json` and at least one of `bundle/` or `assets/`; Container directories contain `container.config.json`. The output Worker config has output-only manifest fields and no source entrypoint. `@cloudflare/build-output-utils` accepts additional Worker directories; `cf deploy`, `cf previews deploy`, `cf workers versions create`, `cf workers triggers deploy`, and `cf workers check` select one by configured name with `--worker <name>`, otherwise cf consumes the required `workers.default`. Always use `readBuildOutput()` rather than composing paths by hand. When `CLOUDFLARE_CI_OVERRIDE_WORKER_NAME` is set, `cf deploy`, `cf previews deploy`, `cf workers versions create`, and `cf workers triggers deploy` deploy the selected Worker under that name and warn if it differs from the configured one. Workers Builds sets it to the connected Worker, as `WRANGLER_CI_OVERRIDE_NAME` does for Wrangler. Only the deployed name changes; bindings that name the configured Worker keep their targets. `cf deploy` and `cf workers versions create` also check the deployed Worker's tag against `CLOUDFLARE_CI_MATCH_WORKER_TAG`, the equivalent of `WRANGLER_CI_MATCH_TAG`.
- **Build Output under `.cloudflare/output/v1/`** for `cf build`, `cf deploy`, `cf previews deploy`, `cf workers versions create`, `cf workers check`, and `cf workers triggers deploy`. A required top-level `config.json` carries `buildContext`, optional account `settings` (`accountId`, `complianceRegion`), and an optional `producer` (cf records its own name and version); readers reject output in the older v0 format; Worker directories contain `worker.config.json` and at least one of `bundle/` or `assets/`; Container directories contain `container.config.json`. The output Worker config has output-only manifest fields and no source entrypoint. `@cloudflare/build-output-utils` accepts additional Worker directories; `cf deploy`, `cf previews deploy`, `cf workers versions create`, `cf workers triggers deploy`, and `cf workers check` select one by configured name with `--worker <name>`, otherwise cf consumes the required `workers.default`. Always use `readBuildOutput()` rather than composing paths by hand. When `CLOUDFLARE_CI_OVERRIDE_WORKER_NAME` is set, `cf deploy`, `cf previews deploy`, `cf workers versions create`, and `cf workers triggers deploy` deploy the selected Worker under that name and warn if it differs from the configured one. Workers Builds sets it to the connected Worker, as `WRANGLER_CI_OVERRIDE_NAME` does for Wrangler. Only the deployed name changes; bindings that name the configured Worker keep their targets. `cf deploy` and `cf workers versions create` also check the deployed Worker's tag against `CLOUDFLARE_CI_MATCH_WORKER_TAG`, the equivalent of `WRANGLER_CI_MATCH_TAG`.

What cf does NOT read:

Expand Down Expand Up @@ -615,7 +615,7 @@ merely because a spec happens to be thin.

Generalising the runtime-schema pattern into a forge annotation is deliberately deferred until there are four or more such examples. That threshold does not combine unrelated Build Output or migration workflows.

`cf init [directory]` is the single explicit setup entry point; there is no separate `cf setup` or `cf workers setup`. It currently behaves exactly like `cf init workers [directory]`, the first product initializer, which `cf init --help` lists as `[default]`; other products can later add `cf init <product>` subcommands, and bare `cf init` is expected to become a selection menu of what to create. When the directory is omitted, cf asks for it (defaulting to the current directory); non-interactive runs must pass one, such as `.`. cf shows the absolute target directory (hidden by `--quiet`) before the package-manager choice or autoconfig, and every successful run ends with a `Next steps` list led by `cf dev` (`npx cf dev` when cf itself ran through `npx` or `pnpm dlx`). A missing directory, an empty directory, or one containing only `.git` receives the hello-world Worker scaffold (`cloudflare.config.ts` with a `WORLD` text binding, `vite.config.ts`, `vitest.config.ts`, `src/index.ts`, `test/index.test.ts`, `tsconfig.json`, `package.json`, `.gitignore`, plus `pnpm-workspace.yaml` for pnpm or `.yarnrc.yml` for Yarn) built on the `@cloudflare/vite-plugin` v2 beta without Wrangler; dependencies are installed by default with a prompted or `--package-manager` choice. After a successful install, cf generates `.cloudflare/types/index.d.ts` through `commands/workers/types/generate.ts`, the generator behind `cf workers types`; a failure there is a warning, not an error. The template's `typecheck` script runs `cf workers types && vp check --no-fmt --no-lint`, and its `tsconfig.json` includes `.cloudflare/types`. Any other non-empty directory is handed to autoconfig after cf changes into it, because autoconfig's package installs use the process working directory. `cf dev` and `cf build` still run autoconfig implicitly. Tunnel log streaming is the process-backed `cf tunnels tail` command; the generated tail-create API command only creates a tail descriptor.
`cf init [directory]` is the single explicit setup entry point; there is no separate `cf setup` or `cf workers setup`. It currently behaves exactly like `cf init workers [directory]`, the first product initializer, which `cf init --help` lists as `[default]`; other products can later add `cf init <product>` subcommands, and bare `cf init` is expected to become a selection menu of what to create. When the directory is omitted, cf asks for it (defaulting to the current directory); non-interactive runs must pass one, such as `.`. cf shows the absolute target directory (hidden by `--quiet`) before the package-manager choice or autoconfig, and every successful run ends with a `Next steps` list led by `cf dev` (`npx cf dev` when cf itself ran through `npx` or `pnpm dlx`). A missing directory, an empty directory, or one containing only `.git` receives the hello-world Worker scaffold (`cloudflare.config.ts` with a `WORLD` text binding, `vite.config.ts`, `vitest.config.ts`, `src/index.ts`, `test/index.test.ts`, `tsconfig.json`, `package.json`, `.gitignore`, plus `pnpm-workspace.yaml` for pnpm or `.yarnrc.yml` for Yarn) built on the `@cloudflare/vite-plugin` v2 release candidate (`^2.0.0-rc.0`) without Wrangler; dependencies are installed by default with a prompted or `--package-manager` choice. After a successful install, cf generates `.cloudflare/types/index.d.ts` through `commands/workers/types/generate.ts`, the generator behind `cf workers types`; a failure there is a warning, not an error. The template's `typecheck` script runs `cf workers types && vp check --no-fmt --no-lint`, and its `tsconfig.json` includes `.cloudflare/types`. Any other non-empty directory is handed to autoconfig after cf changes into it, because autoconfig's package installs use the process working directory. `cf dev` and `cf build` still run autoconfig implicitly. Tunnel log streaming is the process-backed `cf tunnels tail` command; the generated tail-create API command only creates a tail descriptor.

Hand-written commands with no generated parent (`auth/`, `build/`, `cli/`,
`completions/`, `dev/`, `deploy/`, `init/`, `previews/`, plus top-level
Expand Down
6 changes: 3 additions & 3 deletions fixtures/vite-container-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"check:type": "vp run task:check:type"
},
"devDependencies": {
"@cloudflare/vite-plugin": "2.0.0-beta.v.17",
"@cloudflare/workers-types": "5.20261115.1",
"@cloudflare/vite-plugin": "2.0.0-rc.0",
"@cloudflare/workers-types": "5.20261116.1",
"cf": "workspace:*",
"vite": "catalog:",
"wrangler": "4.162.0"
"wrangler": "4.163.0"
}
}
6 changes: 3 additions & 3 deletions fixtures/vite-plugin-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"dev": "vp dev"
},
"devDependencies": {
"@cloudflare/vite-plugin": "2.0.0-beta.v.17",
"@cloudflare/workers-types": "5.20261115.1",
"@cloudflare/vite-plugin": "2.0.0-rc.0",
"@cloudflare/workers-types": "5.20261116.1",
"cf": "workspace:*",
"vite": "catalog:",
"wrangler": "4.162.0"
"wrangler": "4.163.0"
}
}
2 changes: 1 addition & 1 deletion fixtures/wrangler-bundler-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"type": "module",
"dependencies": {
"cf": "workspace:*",
"wrangler": "4.162.0"
"wrangler": "4.163.0"
}
}
4 changes: 2 additions & 2 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ named profiles. `cf auth login` and `cf auth logout` manage the default profile.
commands and Cloudflare dev-server implementations through
`CLOUDFLARE_AUTH_PROFILE`, overriding any inherited value. The development
server needs `@cloudflare/workers-auth` 0.17.0 or newer to use the selected
credentials. Cloudflare delegates require Wrangler 4.161.0 or newer, or Vite
plugin v2 starting at 2.0.0-beta.v.13; older delegates fail with an upgrade hint.
credentials. Cloudflare delegates require Wrangler 4.163.0 or newer, or Vite
plugin v2 starting at 2.0.0-rc.0; older delegates fail with an upgrade hint.

Use `cf auth login --use-keyring` to encrypt OAuth credentials with a key stored
in your OS keychain. The choice is saved across invocations and applies to all
Expand Down
22 changes: 11 additions & 11 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,25 @@
"test:imports": "vp run task:test:imports"
},
"dependencies": {
"@cloudflare/build-output-utils": "0.9.14",
"@cloudflare/config": "0.32.1",
"@cloudflare/runtime-types": "0.1.28",
"@cloudflare/build-output-utils": "1.0.0-rc.0",
"@cloudflare/config": "1.0.0-rc.0",
"@cloudflare/runtime-types": "0.1.29",
"blake3-wasm": "2.1.5",
"miniflare": "5.20261113.0-beta"
"miniflare": "5.20261116.0-beta"
},
"devDependencies": {
"@bomb.sh/tab": "0.0.22",
"@bytecodealliance/jco": "1.41.0",
"@clack/core": "1.5.1",
"@clack/prompts": "^1.8.1",
"@cloudflare/autoconfig": "0.12.1",
"@cloudflare/cli-shared-helpers": "0.3.8",
"@cloudflare/codemods": "0.7.8",
"@cloudflare/containers-shared": "0.26.1",
"@cloudflare/deploy-helpers": "0.27.0",
"@cloudflare/autoconfig": "0.13.0",
"@cloudflare/cli-shared-helpers": "0.3.9",
"@cloudflare/codemods": "0.8.0",
"@cloudflare/containers-shared": "0.26.2",
"@cloudflare/deploy-helpers": "0.27.1",
"@cloudflare/forge": "https://pkg.pr.new/cloudflare/forge/@cloudflare/forge@00ee1dcab3a0511bd91829922aef27edb0d422e2",
"@cloudflare/workers-auth": "0.18.2",
"@cloudflare/workers-utils": "0.54.0",
"@cloudflare/workers-auth": "0.18.3",
"@cloudflare/workers-utils": "0.54.1",
"@types/node": "26.6.6",
"@types/semver": "7.8.0",
"@types/shell-quote": "^1.7.5",
Expand Down
22 changes: 11 additions & 11 deletions packages/cli/src/__tests__/commands/build/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,27 @@ describe("cf build", () => {
const result = await runCf(["build"]);

expect(result.exitCode).toBe(1);
expect(std.err).toMatch(/wrangler@4\.161\.0 or newer/);
expect(std.err).toMatch(/wrangler@4\.163\.0 or newer/);
expect(unframe(std.err)).not.toMatch(/wrangler .* is not installed/);
});

it("uses the vite delegate when vite and wrangler are both declared", async () => {
await seed({
"package.json": JSON.stringify({
devDependencies: {
"@cloudflare/vite-plugin": "beta",
"@cloudflare/vite-plugin": "^2.0.0-rc.0",
wrangler: "^4.0.0",
},
}),
"node_modules/@cloudflare/vite-plugin/package.json": JSON.stringify({
name: "@cloudflare/vite-plugin",
version: "2.0.0-beta.v.13",
version: "2.0.0-rc.0",
}),
"node_modules/@cloudflare/vite-plugin/bin/cf-vite":
buildScript("vite-worker"),
"node_modules/wrangler/package.json": JSON.stringify({
name: "wrangler",
version: "4.161.0",
version: "4.163.0",
}),
"node_modules/wrangler/bin/cf-wrangler.js": nodeScript(
'require("node:fs").writeFileSync("wrangler-argv.out", process.argv.slice(2).join("\\n") + "\\n"); process.exit(99);'
Expand All @@ -88,7 +88,7 @@ describe("cf build", () => {
}),
"node_modules/wrangler/package.json": JSON.stringify({
name: "wrangler",
version: "4.161.0",
version: "4.163.0",
}),
"node_modules/wrangler/bin/cf-wrangler.js":
buildScript("wrangler-worker"),
Expand All @@ -108,7 +108,7 @@ describe("cf build", () => {
}),
"node_modules/wrangler/package.json": JSON.stringify({
name: "wrangler",
version: "4.161.0",
version: "4.163.0",
}),
"node_modules/wrangler/bin/cf-wrangler.js":
buildScript("wrangler-worker"),
Expand Down Expand Up @@ -145,7 +145,7 @@ describe("cf build", () => {
}),
"node_modules/wrangler/package.json": JSON.stringify({
name: "wrangler",
version: "4.161.0",
version: "4.163.0",
}),
"node_modules/wrangler/bin/cf-wrangler.js": buildScript("mode-worker"),
});
Expand Down Expand Up @@ -355,7 +355,7 @@ describe("cf build", () => {
}),
"node_modules/wrangler/package.json": JSON.stringify({
name: "wrangler",
version: "4.161.0",
version: "4.163.0",
}),
"node_modules/wrangler/bin/cf-wrangler.js": nodeScript(
'require("node:fs").writeFileSync("argv.out", process.argv.slice(2).join("\\n") + "\\n"); process.exit(17);'
Expand All @@ -376,7 +376,7 @@ describe("cf build", () => {
}),
"node_modules/wrangler/package.json": JSON.stringify({
name: "wrangler",
version: "4.161.0",
version: "4.163.0",
}),
"node_modules/wrangler/bin/cf-wrangler.js": nodeScript(
'require("node:fs").writeFileSync("argv.out", process.argv.slice(2).join("\\n") + "\\n");'
Expand All @@ -389,13 +389,13 @@ describe("cf build", () => {
});

function buildScript(workerName: string, extra = ""): string {
const workerDir = ".cloudflare/output/v0/workers/default";
const workerDir = ".cloudflare/output/v1/workers/default";
return nodeScript(
[
'const fs = require("node:fs");',
'fs.writeFileSync("argv.out", process.argv.slice(2).join("\\n") + "\\n");',
`fs.mkdirSync(${JSON.stringify(`${workerDir}/bundle`)}, { recursive: true });`,
`fs.writeFileSync(".cloudflare/output/v0/config.json", ${JSON.stringify(buildOutputRootConfig())});`,
`fs.writeFileSync(".cloudflare/output/v1/config.json", ${JSON.stringify(buildOutputRootConfig())});`,
`fs.writeFileSync(${JSON.stringify(`${workerDir}/worker.config.json`)}, ${JSON.stringify(workerConfig({ name: workerName }))});`,
`fs.writeFileSync(${JSON.stringify(`${workerDir}/bundle/index.js`)}, "export default {}");`,
extra,
Expand Down
Loading
Loading