nb 命令行 / 常用命令
常用命令
nb 既是 CLI,也是总服务。所有 nb <file> 都在 ~/.nb/apps/<name>/ 的沙箱里执行。
开发
nb init hono my-app
nb i
nb app.js
nb app.js --name demo
nb init支持 hono / native / arpc / arpc_new / shop / cms / im / mall / space / formx / ai / agent / office / app / phone_server。nb i是内置轻量安装器,不需要 Node。nb app.js等价于nb run app.js。
应用
nb apps
nb history demo
nb rollback demo 3
nb source demo --out ./demo.js
nb logs demo --limit 50
nb files demo
nb db demo --exec64 <base64-sql> --json
nb online demo
nb offline demo
nb remove demo
远程
nb login -r
nb whoami -r
nb app.js -r
nb logout -r
远程部署默认发到 https://app.nbjs.ai,可用 NB_REMOTE 覆盖。
定时任务
在应用里导出 cron:
export default {
fetch() { return new Response("ok"); },
cron: {
"0 3 * * *": async () => {
await sql`DELETE FROM tmp WHERE created_at < ${Date.now() - 86400000}`;
},
},
};
查看:nb cron list demo --json。
统计
nb stats demo --days 7 --json
nb usage --json