@adep/cli 0.0.9 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -38
- package/dist/index.js +2064 -1576
- package/dist/vite.js +2719 -0
- package/package.json +15 -5
package/README.md
CHANGED
|
@@ -28,11 +28,13 @@
|
|
|
28
28
|
|
|
29
29
|
- [`adep serve`](#adep-serve)
|
|
30
30
|
|
|
31
|
-
- [`adep
|
|
31
|
+
- [`adep publish`](#adep-publish)
|
|
32
|
+
|
|
33
|
+
- [`adep deploy`](#adep-deploy-deprecated)
|
|
32
34
|
|
|
33
35
|
- [`adep projects`](#adep-projects)
|
|
34
36
|
|
|
35
|
-
- [`adep functions`](#adep-functions)
|
|
37
|
+
- [`adep functions`](#adep-functions-deprecated)
|
|
36
38
|
|
|
37
39
|
- [`adep mcp`](#adep-mcp)
|
|
38
40
|
|
|
@@ -42,7 +44,7 @@
|
|
|
42
44
|
|
|
43
45
|
- [`adep storage`](#adep-storage)
|
|
44
46
|
|
|
45
|
-
- [`adep hosting`](#adep-hosting)
|
|
47
|
+
- [`adep hosting`](#adep-hosting-deprecated)
|
|
46
48
|
|
|
47
49
|
- [`adep export`](#adep-export)
|
|
48
50
|
|
|
@@ -91,11 +93,12 @@ cd my-app
|
|
|
91
93
|
adep dev
|
|
92
94
|
# → http://127.0.0.1:8787/hello
|
|
93
95
|
|
|
94
|
-
# 4.
|
|
95
|
-
adep
|
|
96
|
+
# 4. 部署上线(全栈:函数 + 前端)
|
|
97
|
+
adep publish
|
|
96
98
|
```
|
|
97
99
|
|
|
98
|
-
三步即可把本地 `functions/hello.ts`
|
|
100
|
+
三步即可把本地 `functions/hello.ts` 与 `web/` 前端发到线上并得到公网访问地址。
|
|
101
|
+
只发布函数:`adep publish --only functions`;只发布前端:`adep publish --only frontend`。
|
|
99
102
|
|
|
100
103
|
---
|
|
101
104
|
|
|
@@ -129,43 +132,51 @@ adep init --list # 从平台 GET /api/v1/templates 列出
|
|
|
129
132
|
adep init --list -s https://platform.example.com
|
|
130
133
|
```
|
|
131
134
|
|
|
132
|
-
产物结构(`fullstack`
|
|
135
|
+
产物结构(`fullstack` 模板,CLI-014:vite 工程根在项目根目录):
|
|
133
136
|
|
|
134
137
|
```
|
|
135
138
|
my-app/
|
|
136
|
-
├── package.json #
|
|
137
|
-
├──
|
|
139
|
+
├── package.json # 应用定义:@adep/cli + 前端依赖同根声明 + scripts(dev/build/site:deploy/serve/deploy/doctor)+ engines
|
|
140
|
+
├── vite.config.ts # vite 配置:vue 插件 + adep() 云函数插件;build.outDir = site/
|
|
141
|
+
├── index.html # vite 入口(引用 /web/src/main.ts)
|
|
142
|
+
├── adep.config.ts # 项目配置:name / template / functionsDir / functions_prefix(默认 /api)
|
|
138
143
|
├── tsconfig.json # 云函数 TypeScript 编辑器配置(strict + noEmit)
|
|
139
144
|
├── adep.d.ts # 云函数上下文环境类型声明(ctx: AdepContext 补全)
|
|
140
145
|
├── functions/
|
|
141
|
-
│ ├── hello.ts # 示例函数(deploy 后经 /hello 触发)
|
|
146
|
+
│ ├── hello.ts # 示例函数(deploy 后经 /api/hello 触发)
|
|
142
147
|
│ └── README.md
|
|
143
|
-
├── web/
|
|
144
|
-
│ ├──
|
|
145
|
-
│
|
|
146
|
-
|
|
147
|
-
│ └── src/{main.ts, App.vue}
|
|
148
|
+
├── web/src/ # 前端源码(Vue 3;与 Web IDE 的 web/ 工程共用同一份 src/)
|
|
149
|
+
│ ├── main.ts
|
|
150
|
+
│ └── App.vue
|
|
151
|
+
├── site/ # vite build 构建产物(站点托管目录,adep hosting deploy site 上传;已 gitignore)
|
|
148
152
|
├── database/
|
|
149
153
|
│ └── schema.sql # 数据库结构(占位;表由平台控制台 / adep db 管理)
|
|
150
154
|
├── README.md
|
|
151
|
-
└── .gitignore # 已忽略 node_modules/ data/ .adep/
|
|
155
|
+
└── .gitignore # 已忽略 node_modules/ data/ .adep/ site/
|
|
152
156
|
```
|
|
153
157
|
|
|
154
158
|
**根 package.json**:与导出的离线部署包(`adep export` / 平台自托管导出)的应用定义同构——
|
|
155
159
|
声明 `@adep/cli` 版本依赖(值来自 CLI 自身发布版本,不硬编码)与常用 scripts:
|
|
156
|
-
`pnpm dev`(= `
|
|
160
|
+
`pnpm dev`(= `vite`,全栈开发:前端 HMR + 云函数代理)/ `pnpm build`(= `vite build` → `site/`)/
|
|
161
|
+
`pnpm site:deploy`(= `adep hosting deploy site --spa`)/ `pnpm serve` / `pnpm deploy` / `pnpm doctor`。
|
|
162
|
+
|
|
163
|
+
**全栈开发(vite + 云函数代理)**:`pnpm dev` 启动 vite 后,`@adep/cli/vite` 插件在 vite 进程内
|
|
164
|
+
启动 `adep dev`(模拟运行时,函数热重载 / .env.local / cloud.* 全可用),并把
|
|
165
|
+
`/{functions_prefix}/*` 请求代理到云函数——默认前缀 `/api`(与线上函数路由对齐),
|
|
166
|
+
前端 `fetch('/api/hello')` 即调用 `functions/hello.ts`。
|
|
157
167
|
|
|
158
|
-
**functions_prefix
|
|
159
|
-
调试路由前缀(默认空):
|
|
168
|
+
**functions_prefix(云函数路由前缀)**:`adep.config.ts` 的 `functions_prefix`(**默认 `/api`**):
|
|
160
169
|
|
|
161
|
-
-
|
|
162
|
-
|
|
163
|
-
-
|
|
170
|
+
- `adep dev` 访问路径 `/{prefix}/{fnName}`(如 `/api/hello`);vite 插件按同一前缀代理。
|
|
171
|
+
- `adep serve` 为 `/api/{prefix}/{fnName}`(前缀拼接在 `/api/` 之后)。
|
|
172
|
+
- 留空(旧项目):`adep dev` 为 `/{fnName}`,`adep serve` 为 `/api/{fnName}`;
|
|
173
|
+
vite 插件在配置为空时强制 `/api` 并同步覆盖 dev 路由,保证代理与路由一致。
|
|
164
174
|
- **边界**:只影响本地 HTTP 入口路由;函数互调 `ctx.cloud.invoke('name')` 与线上部署路径
|
|
165
175
|
按函数名,不随前缀变化(与线上同构)。
|
|
166
176
|
|
|
167
|
-
|
|
168
|
-
|
|
177
|
+
**前端源码(web/src/)**:与 Web IDE 内 `web/` 工程的 `src/` 完全同构(同一份模板真相源);
|
|
178
|
+
vite 工程根在项目根目录(`vite.config.ts` / `index.html` / 根 `package.json`),构建产物输出到
|
|
179
|
+
`site/`(站点托管目录),`pnpm site:deploy` 上传部署。
|
|
169
180
|
|
|
170
181
|
**类型提示**:`adep init` 产出的项目自带 `tsconfig.json` 与 `adep.d.ts`,用 VSCode 打开即可在
|
|
171
182
|
`functions/` 下获得 `AdepContext` / `ctx.cloud.*` 补全,无需本机安装 `@adep/types`。
|
|
@@ -216,7 +227,40 @@ adep serve --static web # 指定静态托管目录(缺省 public/)
|
|
|
216
227
|
|
|
217
228
|
- 绑定非回环地址时给出对外暴露警告(它不带生产级加固)。
|
|
218
229
|
|
|
219
|
-
### `adep
|
|
230
|
+
### `adep publish`
|
|
231
|
+
|
|
232
|
+
全栈发布顶层命令(CLI-010):函数部署 + 前端构建托管一把梭。
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
adep publish # 缺省全栈:函数 deploy + 前端平台侧构建托管
|
|
236
|
+
adep publish --only functions # 只发布云函数
|
|
237
|
+
adep publish --only frontend # 只触发平台侧前端构建(FN-024)并切换站点版本
|
|
238
|
+
adep publish -p my-app # 显式指定目标 slug
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
- **函数部分**:扫描本地 `functions/` 计算内容哈希 → 调平台 `/api/v1/deploy/diff` 拿差异清单 →
|
|
242
|
+
仅上传变更函数 → 发布 → 输出访问域名(与 `adep deploy` 同一管线)。
|
|
243
|
+
|
|
244
|
+
- **前端部分**:调平台 `POST /api/v1/projects/:id/frontend/publish`(服务端真实构建 `web/` 草稿),
|
|
245
|
+
再读 `/frontend/versions` 取当前版本与 `siteUrl`。未登录由 `createClient` 统一抛 `NOT_LOGGED_IN`。
|
|
246
|
+
|
|
247
|
+
- 成功输出每个函数的名字 / 版本 / 访问地址,末尾汇总函数部署数 + 前端构建状态 + 站点 URL:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
hello v1 https://my-app.platform.example.com/api/hello
|
|
251
|
+
✓ 1 functions deployed in 3.2s
|
|
252
|
+
✓ frontend built v2 · https://my-app.platform.example.com
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
- `--json` 输出统一信封 `{ ok, command, data: { scope, functions?, frontend? } }`。
|
|
256
|
+
|
|
257
|
+
> 兼容别名:`adep deploy` / `adep functions deploy` / `adep hosting deploy` 保留原行为,
|
|
258
|
+
> 仅在 stderr 打印 deprecation 提示指向本命令(见下文)。
|
|
259
|
+
|
|
260
|
+
### `adep deploy`(deprecated)
|
|
261
|
+
|
|
262
|
+
> **已废弃**:推荐使用 `adep publish`(全栈)或 `adep publish --only functions`(仅函数)。
|
|
263
|
+
> 本命令保留向后兼容,运行时在 stderr 打印迁移提示。
|
|
220
264
|
|
|
221
265
|
增量部署:扫描本地 `functions/` 计算内容哈希 → 调平台 `/api/v1/deploy/diff` 拿差异清单 → 仅上传变更函数 → 发布 → 输出访问域名。
|
|
222
266
|
|
|
@@ -256,13 +300,16 @@ adep projects info game-arcade # id \t slug \t name \t url
|
|
|
256
300
|
|
|
257
301
|
- 未登录 / 会话失效 → 打印错误后附带 `提示:先执行 adep login`。
|
|
258
302
|
|
|
259
|
-
### `adep functions
|
|
303
|
+
### `adep functions`(deprecated)
|
|
304
|
+
|
|
305
|
+
> **`functions deploy` 已废弃**:推荐使用 `adep publish --only functions`(或 `adep publish --only functions -- <dir>` 等价语义)。
|
|
306
|
+
> `functions list` / `functions logs` 保留不变。
|
|
260
307
|
|
|
261
308
|
云函数子命令组:部署(可指定目录)/ 列出 / 查日志。
|
|
262
309
|
|
|
263
310
|
```bash
|
|
264
|
-
adep functions deploy ./handlers # 覆盖 adep.config.ts 的 functionsDir
|
|
265
|
-
adep functions deploy # 等价于 adep deploy
|
|
311
|
+
adep functions deploy ./handlers # 覆盖 adep.config.ts 的 functionsDir(deprecated)
|
|
312
|
+
adep functions deploy # 等价于 adep deploy(deprecated)
|
|
266
313
|
adep functions list -p my-app # name \t 访问地址
|
|
267
314
|
adep functions logs hello -p my-app --tail 50
|
|
268
315
|
```
|
|
@@ -348,14 +395,18 @@ adep storage rm avatars/a.png
|
|
|
348
395
|
|
|
349
396
|
- 所有命令都支持 `-p <slug>` 指定项目。
|
|
350
397
|
|
|
351
|
-
### `adep hosting
|
|
398
|
+
### `adep hosting`(deprecated)
|
|
399
|
+
|
|
400
|
+
> **`hosting deploy` 已废弃**:推荐使用 `adep publish --only frontend`(平台侧构建 `web/` 草稿)。
|
|
401
|
+
> 如确需上传预构建目录(如本地 `vite build` 产物),`hosting deploy <dir>` 仍可用,仅 stderr 提示迁移。
|
|
402
|
+
> `hosting info` / `pull` / `config` 保留(运维类操作不并入 publish)。
|
|
352
403
|
|
|
353
404
|
静态托管子命令组:查看 / 部署 / 拉取 / 配置。站点文件即项目桶 `site/` 前缀下的 public 文件。
|
|
354
405
|
|
|
355
406
|
```bash
|
|
356
407
|
adep hosting info # 查看托管配置、站点地址与文件树
|
|
357
|
-
adep hosting deploy ./dist # 递归上传目录到 site/
|
|
358
|
-
adep hosting deploy ./dist --spa # 同时启用 SPA
|
|
408
|
+
adep hosting deploy ./dist # 递归上传目录到 site/ 并打开托管(deprecated)
|
|
409
|
+
adep hosting deploy ./dist --spa # 同时启用 SPA 回退(deprecated)
|
|
359
410
|
adep hosting pull [-o ./site] # 拉取站点公开文件到本地(跳过 private 托管配置)
|
|
360
411
|
adep hosting config --enabled true --spa true # 更新托管开关 / SPA 回退(幂等)
|
|
361
412
|
```
|
|
@@ -401,19 +452,19 @@ export ADEP_HOME=~/.adep
|
|
|
401
452
|
`adep init` 生成的项目配置文件,CLI 的 `dev` / `serve` / `deploy` 按此识别项目(CLI 直接 import 后读 `default` 的字段,无需任何辅助包):
|
|
402
453
|
|
|
403
454
|
```ts
|
|
404
|
-
// adep 项目配置:CLI(dev / serve / deploy
|
|
455
|
+
// adep 项目配置:CLI(dev / serve / deploy)与云函数 vite 插件按 default export 读取。
|
|
405
456
|
export default {
|
|
406
457
|
name: 'my-app', // 项目名(deploy 的默认 slug)
|
|
407
458
|
template: 'fullstack', // 模板:empty | function | fullstack
|
|
408
459
|
functionsDir: 'functions', // 云函数目录
|
|
409
|
-
functions_prefix: '', //
|
|
460
|
+
functions_prefix: '/api', // 云函数路由前缀(默认 /api,与线上 /api/{fn} 对齐)
|
|
410
461
|
}
|
|
411
462
|
```
|
|
412
463
|
|
|
413
464
|
- `functionsDir`:云函数目录(`dev` / `serve` / `deploy` 读取,缺省 `functions/`)。
|
|
414
|
-
- `functions_prefix
|
|
415
|
-
|
|
416
|
-
|
|
465
|
+
- `functions_prefix`:**影响本地路由与 vite 插件代理前缀**(见上方 `adep init` 产物结构说明)——
|
|
466
|
+
默认 `/api`:`adep dev` 访问 `/{prefix}/{fnName}`、`adep serve` 访问 `/api/{prefix}/{fnName}`、
|
|
467
|
+
vite 插件按 `/{prefix}/*` 代理;函数互调与线上部署路径不随前缀变化。
|
|
417
468
|
|
|
418
469
|
---
|
|
419
470
|
|
|
@@ -440,11 +491,11 @@ adep storage upload ./logo.png --path assets/logo.png --visibility public
|
|
|
440
491
|
adep storage download assets/logo.png -o ./logo.png
|
|
441
492
|
|
|
442
493
|
# 静态托管:本地构建产物一键上线,随时拉回
|
|
443
|
-
adep hosting deploy ./dist
|
|
494
|
+
adep hosting deploy ./dist # deprecated:推荐 adep publish --only frontend
|
|
444
495
|
adep hosting pull -o ./site
|
|
445
496
|
|
|
446
497
|
# 以 JSON 输出(Agent / CI 可用)
|
|
447
|
-
adep --json
|
|
498
|
+
adep --json publish -p my-app
|
|
448
499
|
```
|
|
449
500
|
|
|
450
501
|
---
|