跳到主内容
@wquguru
精选90Cloudflare Workers(Changelog)客户端

Cloudflare CLI (cf) 1.0.0-rc.1:弃用旧命令名、强制依赖升级与破坏性变更

Workers, Cloudflare CLI - Cloudflare CLI (cf) 1.0 release candidate

原文
发到 X
推荐理由

自动化脚本重度用户必读:stdout/stderr 分离、kebab-case 转换及命令重命名将直接导致现有 CI/CD 流水线报错,请务必在 rc.1 生效前完成适配。

Cloudflare CLI (cf) 1.0.0-rc.1 is a release candidate for cf 1.0. cf has been in beta since late September. This is the release we recommend you try on your own projects, and we want your feedback before 1.0.

Cloudflare CLI (cf) 1.0.0-rc.1 是 cf 1.0 的候选版本。自 9 月下旬以来,cf 一直处于测试阶段。这是我们要推荐你在自己的项目中尝试的版本,我们希望在 1.0 正式发布前收到你的反馈。

To install or update to the latest release:

安装或更新到最新版本:

npmyarnpnpmbun

npm yarn pnpm bun

代码 · 1 行
npm install --global cf@latest
代码 · 1 行
yarn global add cf@latest
代码 · 1 行
pnpm add --global cf@latest
代码 · 1 行
bun add --global cf@latest

What is stable

稳定特性

We expect the following features to remain stable to cf 1.0:

我们预期以下功能在 cf 1.0 中将保持稳定:

  • The cloudflare.config.ts configuration format.
  • The Build Output format that cf build writes and cf deploy reads.
  • The commands that create, develop, build, and deploy projects, including cf init, cf dev, cf build, cf deploy, cf previews deploy, and cf workers versions create.
  • The large majority of commands generated from the Cloudflare API and used in the beta.
  • cloudflare.config.ts 配置格式。
  • cf build 写入且 cf deploy 读取的构建输出(Build Output)格式。
  • 用于创建、开发、构建和部署项目的命令,包括 cf init、cf dev、cf build、cf deploy、cf previews deploy 和 cf workers versions create。
  • 绝大多数在测试期间使用且由 Cloudflare API 生成的命令。

A small number of less commonly used API commands may still change before 1.0. cf generates these commands from the Cloudflare API schema, so their call path may still change before 1.0.

少数不常用的 API 命令在 1.0 之前可能仍会发生变化。cf 从 Cloudflare API 模式生成这些命令,因此它们的调用路径在 1.0 之前可能仍会改变。

Upgrade from a beta

从测试版升级

This release moves Build Output to version 1, in .cloudflare/output/v1/. cf deploy will automatically create a new build on first run in this location.

此版本将构建输出移至 v1 版本,位于 .cloudflare/output/v1/。首次在此位置运行时,cf deploy 会自动创建新的构建。

The release candidate also moves to caret (^) version ranges for its dependencies, requiring:

该候选版本也将其依赖项的版本范围改为插入符号 (^),要求:

  • @cloudflare/vite-plugin 2.0.0-rc.0 or later, for projects that build with Vite.
  • Wrangler 4.163.0 or later, for legacy projects that build with Wrangler.
  • @cloudflare/vite-plugin 2.0.0-rc.0 或更高版本,适用于使用 Vite 构建的项目。
  • Wrangler 4.163.0 或更高版本,适用于使用 Wrangler 构建的传统项目。

1.0.0-rc.1 renames a few generated API commands without aliases. For example, cf workers secrets bulk is now cf workers secrets bulk-edit. For the full list, refer to the release notes ↗︎.

1.0.0-rc.1 重命名了一些没有别名的生成 API 命令。例如,cf workers secrets bulk 现在变为 cf workers secrets bulk-edit。完整列表请参阅发行说明 ↗︎。

If you last updated early in the beta, these earlier changes may also affect you:

如果你上次更新是在测试版早期,这些较早的变化也可能影响你:

  • Prompts, progress, and status messages are written to stderr. Stdout holds only command output, so scripts that read messages from stdout must read stderr instead.
  • Commands generated from camelCase or snake_case API names use kebab-case. For example, cf accounts billing getCredits is now cf accounts billing get-credits.
  • cf previews deploy takes the Preview name as --preview-name instead of a positional argument.
  • Commands run with --local store state in the project's .cloudflare/state directory.
  • cf no longer saves your account choice between runs. Set accountId in cloudflare.config.ts or CLOUDFLARE_ACCOUNT_ID to skip the prompt.
  • Streaming tail consumers move to experimental.streamingTailConsumers in cloudflare.config.ts.
  • Destructive commands run without a terminal exit with an error unless you pass --force.
  • cf supports the latest versions of the Node.js LTS releases and the latest active release of Node.js.
  • 提示、进度和状态消息写入 stderr。stdout 仅包含命令输出,因此从 stdout 读取消息的脚本必须改为读取 stderr。
  • 由 camelCase 或 snake_case API 名称生成的命令使用 kebab-case。例如,cf accounts billing getCredits 现在变为 cf accounts billing get-credits。
  • cf previews deploy 接受 --preview-name 作为预览名称参数,而不是位置参数。
  • 使用 --local 运行的命令将状态存储在项目的 .cloudflare/state 目录中。
  • cf 不再在运行之间保存你的账户选择。在 cloudflare.config.ts 或 CLOUDFLARE_ACCOUNT_ID 中设置 accountId 以跳过提示。
  • 流式尾随消费者(Streaming tail consumers)移至 cloudflare.config.ts 中的 experimental.streamingTailConsumers。
  • 除非传递 --force,否则在没有终端的情况下运行破坏性命令会报错。
  • cf 支持最新的 Node.js LTS 版本和最新的活跃版 Node.js。

Stream live logs

实时流式传输日志

cf observability tail streams live logs and other observability events as newline-delimited JSON. Select a Worker with --worker, a zone and its subdomains with --zone, or every event in the account with --all. Narrow the results with --filters, as inline JSON or from a file:

cf observability tail 以换行符分隔的 JSON 格式流式传输实时日志和其他可观测性事件。使用 --worker 选择 Worker,使用 --zone 选择区域及其子域名,或使用 --all 选择账户中的所有事件。使用 --filters 缩小结果范围,可以是内联 JSON 或来自文件:

代码 · 2 行
cf observability tail --worker my-worker
cf observability tail --worker my-worker --filters @filters.json

Worker events require Workers Logs to be turned on for the Worker. For filter shapes and examples, run cf observability tail --help.

Worker 事件要求为 Worker 开启 Workers Logs。有关筛选形状和示例,请运行 cf observability tail --help。

What changed during the beta

Beta 期间发生了哪些变化

Deploy

部署

  • Deploy a directory of static assets with cf deploy ./dist. cf skips the build step and creates an assets-only Worker.
  • cf deploy --no-provision fails when a binding has no resource ID, instead of creating a new resource.
  • cf deploy --force deploys when the Worker was last deployed through the API, or when its remote configuration conflicts with your local Build Output.
  • Redeploying no longer removes secrets that you added outside cloudflare.config.ts.
  • Stack traces from deployed Workers show project paths such as src/index.ts.
  • Python Workers with vendored packages deploy correctly.
  • cf deploy applies SSH settings for Containers managed by Durable Objects.
  • cf deploy --dry-run shows the project setup changes it would make, without making them.
  • Set CLOUDFLARE_DEPENDENCIES_INSTRUMENTATION=false to stop uploading package dependency metadata with each deployment.
  • 使用 cf deploy ./dist 部署静态资产目录。cf 会跳过构建步骤并创建一个仅包含资产的 Worker。
  • 当绑定没有资源 ID 时,cf deploy --no-provision 会失败,而不是创建新资源。
  • 当 Worker 上次通过 API 部署时,或其远程配置与本地构建输出冲突时,cf deploy --force 会执行部署。
  • 重新部署不再移除在 cloudflare.config.ts 之外添加的密钥。
  • 已部署 Worker 的堆栈跟踪会显示项目路径,例如 src/index.ts。
  • 带有 vendored 包的 Python Worker 能正确部署。
  • cf deploy 应用由 Durable Objects 管理的容器的 SSH 设置。
  • cf deploy --dry-run 会显示它将进行的的项目设置更改,而不会实际执行这些更改。
  • 设置 CLOUDFLARE_DEPENDENCIES_INSTRUMENTATION=false 以停止在每次部署时上传包依赖元数据。

Develop

开发

  • cf init creates new Worker projects with Vite+, including checks, formatting, and tests that run in the Workers runtime.
  • cf dev and cf build run the Vite or Vite+ executable installed in your project, including dependencies hoisted in a workspace.
  • cf dev passes arguments such as --port and --host to your framework's development server.
  • cf dev --profile <name> passes the selected authentication profile to your development server.
  • cf dev, cf build, and cf deploy offer to run cf migrate when they find a Wrangler configuration file.
  • On Windows, Ctrl+C exits cleanly when your framework runs through npm, Wrangler and Vite start without spawn EFTYPE errors, and cf d1 migrations create rejects names that Windows cannot store.
  • cf init approves the build scripts that pnpm 11 and later block by default, so installation succeeds.
  • cf init 使用 Vite+ 创建新的 Worker 项目,包括在 Workers 运行时运行的检查、格式化和测试。
  • cf dev 和 cf build 运行项目中安装的 Vite 或 Vite+ 可执行文件,包括在工作区中提升的依赖项。
  • cf dev 将 --port 和 --host 等参数传递给框架的开发服务器。
  • cf dev --profile <name> 将选定的身份验证配置文件传递给开发服务器。
  • 当 cf dev、cf build 和 cf deploy 找到 Wrangler 配置文件时,它们会提示运行 cf migrate。
  • 在 Windows 上,当你的框架通过 npm 运行时,Wrangler 和 Vite start 在没有 spawn EFTYPE 错误的情况下启动,且 cf d1 migrations 创建的拒绝名称是 Windows 无法存储的,Ctrl+C 会干净地退出。
  • cf init 批准 pnpm 11 及更高版本默认阻止的构建脚本,从而使安装成功。

Sign in and accounts

登录和账户

  • Pass --temporary-account to create a short-lived account without signing in. cf prints a URL you can use to claim the account.
  • cf auth login summarizes the scopes you granted, and cf auth scopes lists them by product.
  • cf auth whoami, also available as cf whoami, prints a short summary in a terminal and full JSON for scripts and agents.
  • cf auth login now uses the system keyring where available.
  • Long-running commands, such as cf observability tail, refresh an expired OAuth login instead of failing.
  • cf auth whoami reports the status of scoped API tokens correctly.
  • Set CLOUDFLARE_API_HEADERS to send custom headers with API requests.
  • 使用 --temporary-account 创建一个无需登录的临时账户。cf 会打印一个可用于认领该账户的 URL。
  • cf auth login 会总结你授予的作用域,cf auth scopes 则按产品列出这些作用域。
  • cf auth whoami(也可用 cf whoami)在终端中打印简短摘要,并为脚本和代理提供完整的 JSON 数据。
  • cf auth login 现在在可用时使用系统密钥环。
  • 长时间运行的命令(如 cf observability tail)会在 OAuth 登录过期时刷新登录状态,而不是报错失败。
  • cf auth whoami 能正确报告作用域 API 令牌的状态。
  • 设置 CLOUDFLARE_API_HEADERS 以向 API 请求发送自定义头部。

API commands

API 命令

  • Every command accepts --dry-run to preview what it would do and it redacts sensitive fields in request previews.
  • cf checks --body input before it asks you to sign in or confirm, and rejects array bodies larger than the API allows instead of splitting them across several requests.
  • More request fields are available as flags, including JSON objects and maps, arrays of objects, and file uploads. For example, cf pages deployments create --worker-js @./_worker.js and cf ai to-markdown --files @first.html @second.pdf.
  • Error outputs have been improved with additional messages the API returns, such as the names of missing parameters.
  • cf workers commands accept --worker to select a Worker.
  • --zone finds zones by name in accounts with many zones.
  • cf tunnels quick-start --allowed-mail limits a temporary tunnel to the email addresses and domains you allow.
  • 所有命令均支持 --dry-run 以预览其执行操作,并在请求预览中隐藏敏感字段。
  • cf checks --body 在你要求登录或确认之前先检查输入内容,并拒绝超过 API 限制大小的数组主体,而不是将其拆分到多个请求中。
  • 更多请求字段可作为标志使用,包括 JSON 对象和映射、对象数组以及文件上传。例如:cf pages deployments create --worker-js @./_worker.js 和 cf ai to-markdown --files @first.html @second.pdf。
  • 错误输出已改进,增加了 API 返回的其他消息,例如缺失参数的名称。
  • cf workers 命令接受 --worker 参数以选择特定的 Worker。
  • --zone 可在拥有大量区域的账户中通过名称查找区域。
  • cf tunnels quick-start --allowed-mail 将临时隧道限制为你允许的电子邮件地址和域名。

Scripts and agents

脚本和代理

  • cf --version prints only the version number.
  • Shell completions and cf tools list every flag a command accepts.
  • cf cli search has reranked cf deploy and other key commands to improve their ranking for static site and Pages deployment searches.
  • cf docs search finds Cloudflare documentation from the terminal.
  • cf --version 仅打印版本号。
  • Shell 补全和 cf tools list 会列出每个命令接受的所有标志。
  • cf cli search 重新排序了 cf deploy 和其他关键命令,以提高它们在静态站点和 Pages 部署搜索中的排名。
  • cf docs search 可从终端搜索 Cloudflare 文档。

Send feedback

发送反馈

To report a bug or tell us what is missing, open an issue in the cf repository ↗︎. For every change in each release, refer to the Cloudflare CLI release notes ↗︎.

要报告错误或告知我们缺失的功能,请在 cf 仓库中提交问题 ↗︎。有关每次发布的每项更改,请参阅 Cloudflare CLI 发行说明 ↗︎。

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

关联信息,但可能不是同一事件