workflow-init

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

workflow-init

workflow-init

Initial setup of Vercel Workflow DevKit before
workflow
is installed. Fetch the official getting-started guide for the user's framework.
workflow
安装完成之前,完成Vercel Workflow DevKit的初始设置。为用户的框架获取官方入门指南。

Decision Flow

决策流程

0) Sanity check

0) 完整性检查

Read
package.json
. If
workflow
is already a dependency, tell the user to use
/workflow
instead (it reads versioned docs from
node_modules/workflow/docs/
). Only continue if workflow is missing.
读取
package.json
。如果
workflow
已经是依赖项,告知用户改用
/workflow
(它会从
node_modules/workflow/docs/
读取带版本的文档)。仅当workflow缺失时才继续。

1) Determine the framework

1) 确定框架

Non-interactive: If the user named a framework in their prompt, use it directly.
Auto-detect: Inspect
package.json
deps and config files. Use the first match:
  1. Next.js -
    next
    dep or
    next.config.*
  2. Nuxt -
    nuxt
    dep or
    nuxt.config.*
  3. SvelteKit -
    @sveltejs/kit
    dep or
    svelte.config.*
  4. Astro -
    astro
    dep or
    astro.config.*
  5. NestJS -
    @nestjs/core
    dep or
    nest-cli.json
  6. Nitro -
    nitro
    dep or
    nitro.config.*
  7. Express -
    express
    dep
  8. Fastify -
    fastify
    dep
  9. Hono -
    hono
    dep
  10. Vite -
    vite
    dep (and not matched above)
If no match or multiple matches, ask the user to pick.
非交互式: 如果用户在提示中指定了框架,直接使用该框架。
自动检测: 检查
package.json
依赖项和配置文件。使用第一个匹配项:
  1. Next.js - 存在
    next
    依赖或
    next.config.*
    文件
  2. Nuxt - 存在
    nuxt
    依赖或
    nuxt.config.*
    文件
  3. SvelteKit - 存在
    @sveltejs/kit
    依赖或
    svelte.config.*
    文件
  4. Astro - 存在
    astro
    依赖或
    astro.config.*
    文件
  5. NestJS - 存在
    @nestjs/core
    依赖或
    nest-cli.json
    文件
  6. Nitro - 存在
    nitro
    依赖或
    nitro.config.*
    文件
  7. Express - 存在
    express
    依赖
  8. Fastify - 存在
    fastify
    依赖
  9. Hono - 存在
    hono
    依赖
  10. Vite - 存在
    vite
    依赖(且未匹配上述框架)
如果没有匹配项或存在多个匹配项,请让用户选择。

2) Fetch and follow the getting-started guide

2) 获取并遵循入门指南

3) Verify setup

3) 验证设置

  • Start the dev server per the guide.
  • Trigger the example endpoint with the provided
    curl
    .
  • Confirm logs show the workflow and steps executing.
  • Optional:
    npx workflow web
    or
    npx workflow inspect runs
    .
  • 按照指南启动开发服务器。
  • 使用提供的
    curl
    命令触发示例端点。
  • 确认日志显示工作流和步骤正在执行。
  • 可选操作:
    npx workflow web
    npx workflow inspect runs

4) No framework yet?

4) 尚未选择框架?

If no framework exists, ask what the user wants:
  • Web app: Next.js / Nuxt / SvelteKit / Astro
  • API server: Express / Fastify / Hono
  • Minimal server: Nitro or Vite
Then follow the "Create Your Project" section of the chosen guide.
如果还没有框架,请询问用户需求:
  • Web应用:Next.js / Nuxt / SvelteKit / Astro
  • API服务器:Express / Fastify / Hono
  • 轻量服务器:Nitro或Vite
然后遵循所选指南中的“创建你的项目”部分。

Concept questions (pre-install)

概念问题(安装前)

Handoff

交接

When setup is complete, tell the user: Use
/workflow
for ongoing development
- it reads the versioned docs bundled in
node_modules/workflow/docs/
.
设置完成后,告知用户:后续开发请使用
/workflow
- 它会读取
node_modules/workflow/docs/
中捆绑的带版本文档。