migrate-app-to-flows
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMigrate App to Flows Infrastructure
将应用迁移至Flows基础设施
Orchestrates the full migration of a legacy Dune app to the new Flows app hosting (). Works through each area in order, skipping any already in the correct state.
appsApi统筹将旧版Dune应用迁移至新的Flows应用托管()的完整流程。按顺序处理各个环节,跳过已处于正确状态的部分。
appsApiStep 1 — Audit current state
步骤1 — 审核当前状态
Read , , , and (if present).
app.jsonpackage.jsonvite.config.tsmanifest.jsonReport a concise summary before making any changes:
Migration audit:
✗ app.json: missing infra field → will add "infra": "appsApi"
✗ Auth: DuneAuthProvider in use → will run setup-flows-auth
✗ manifest.json: missing → will create
✓ Deploy script: already uses @cognite/cliThen proceed through Steps 2–5.
读取、、以及(如果存在)。
app.jsonpackage.jsonvite.config.tsmanifest.json在进行任何更改前生成简洁的审核报告:
Migration audit:
✗ app.json: missing infra field → will add "infra": "appsApi"
✗ Auth: DuneAuthProvider in use → will run setup-flows-auth
✗ manifest.json: missing → will create
✓ Deploy script: already uses @cognite/cli然后继续执行步骤2至步骤5。
Step 2 — Update app.json
app.json步骤2 — 更新app.json
app.jsonIf is already , skip this step. Otherwise, add or update the field:
infra"appsApi"json
{
"name": "My App",
"externalId": "my-app",
"versionTag": "0.0.1",
"infra": "appsApi",
"deployments": [...]
}如果字段已设置为,则跳过此步骤。否则,添加或更新该字段:
infra"appsApi"json
{
"name": "My App",
"externalId": "my-app",
"versionTag": "0.0.1",
"infra": "appsApi",
"deployments": [...]
}Step 3 — Set up Flows auth
步骤3 — 配置Flows认证
Run the skill now. It handles everything auth-related: package installation, Vite plugin updates, entry file changes, and wiring up .
setup-flows-authconnectToHostApp立即运行工具。它会处理所有与认证相关的事宜:包安装、Vite插件更新、入口文件修改,以及配置。
setup-flows-authconnectToHostAppStep 4 — Create or update manifest.json
manifest.json步骤4 — 创建或更新manifest.json
manifest.jsonThe Flows host uses to enforce a Content Security Policy for the app. It must exist at the repo root.
manifest.jsonCreate if missing:
json
{
"manifestVersion": 1,
"permissions": {
"network": []
}
}Populate network permissions by scanning for outbound calls to external domains:
bash
grep -rn "fetch\|axios\|new XMLHttpRequest" src/ --include="*.ts" --include="*.tsx"For each group of external URLs found, add an entry to the array using the / shape:
networksourcesdirectivesjson
{
"manifestVersion": 1,
"permissions": {
"network": [
{
"sources": ["https://api.example.com", "https://maps.googleapis.com"],
"directives": ["connect-src"]
}
]
}
}Rules:
- Use full origin (scheme + hostname) in , not just the hostname.
sources - covers
"connect-src"/fetch. UseXMLHttpRequestfor image URLs,"img-src"for fonts."font-src" - The CDF cluster URL is allowed automatically; do not list it.
- If no external calls exist, leave .
"network": [] - Flag any dynamic URLs the user needs to verify manually.
Flows宿主环境使用为应用强制执行内容安全策略。该文件必须存在于仓库根目录。
manifest.json若文件缺失则创建:
json
{
"manifestVersion": 1,
"permissions": {
"network": []
}
}通过扫描外部域名的出站调用填充网络权限:
bash
grep -rn "fetch\|axios\|new XMLHttpRequest" src/ --include="*.ts" --include="*.tsx"对于找到的每一组外部URL,使用/格式将条目添加至数组:
sourcesdirectivesnetworkjson
{
"manifestVersion": 1,
"permissions": {
"network": [
{
"sources": ["https://api.example.com", "https://maps.googleapis.com"],
"directives": ["connect-src"]
}
]
}
}规则:
- 在中使用完整源(协议+主机名),而非仅主机名。
sources - 覆盖
"connect-src"/fetch。图片URL使用XMLHttpRequest,字体URL使用"img-src"。"font-src" - CDF集群URL会自动被允许;无需列出。
- 若不存在外部调用,保留。
"network": [] - 标记任何需要用户手动验证的动态URL。
Step 5 — Update deploy scripts
步骤5 — 更新部署脚本
Replace any or commands in :
dune deploynpx @cognite/dunepackage.jsonjson
{
"scripts": {
"deploy": "npx @cognite/cli@latest apps deploy --interactive --published",
"deploy-preview": "npx @cognite/cli@latest apps deploy --interactive"
}
}Keep all other scripts (, , , etc.) unchanged.
startbuildtest替换中所有或命令:
package.jsondune deploynpx @cognite/dunejson
{
"scripts": {
"deploy": "npx @cognite/cli@latest apps deploy --interactive --published",
"deploy-preview": "npx @cognite/cli@latest apps deploy --interactive"
}
}保留所有其他脚本(、、等)不变。
startbuildtestStep 6 — Final check
步骤6 — 最终检查
bash
grep -rn "DuneAuthProvider\|useDune\|@cognite/dune" src/ vite.config.ts 2>/dev/nullList any remaining hits for the user to resolve. Then report:
Migration complete:
✓ app.json: infra set to "appsApi"
✓ Auth: setup-flows-auth applied
✓ manifest.json: network permissions set
✓ Deploy scripts: updated to @cognite/clibash
grep -rn "DuneAuthProvider\|useDune\|@cognite/dune" src/ vite.config.ts 2>/dev/null列出所有剩余匹配项供用户解决。然后生成报告:
Migration complete:
✓ app.json: infra set to "appsApi"
✓ Auth: setup-flows-auth applied
✓ manifest.json: network permissions set
✓ Deploy scripts: updated to @cognite/cli