@lark-apaas/miaoda-cli 0.1.19-alpha.6a5cefe → 0.1.19-alpha.7f0b693
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 +27 -0
- package/dist/api/deploy/index.js +3 -1
- package/dist/api/deploy/modern-types.js +4 -1
- package/dist/api/deploy/modern.js +8 -0
- package/dist/cli/commands/app/index.js +4 -2
- package/dist/cli/commands/db/index.js +3 -0
- package/dist/cli/commands/deploy/modern.js +32 -0
- package/dist/cli/commands/file/index.js +3 -4
- package/dist/cli/commands/index.js +13 -0
- package/dist/cli/commands/registry/index.js +102 -0
- package/dist/cli/handlers/app/init.js +6 -2
- package/dist/cli/handlers/app/migrate.js +0 -26
- package/dist/cli/handlers/deploy/index.js +3 -1
- package/dist/cli/handlers/deploy/patch.js +16 -0
- package/dist/cli/handlers/registry/add.js +54 -0
- package/dist/cli/handlers/registry/index.js +7 -0
- package/dist/cli/handlers/registry/list.js +48 -0
- package/dist/cli/handlers/registry/shared.js +25 -0
- package/dist/main.js +0 -3
- package/dist/services/app/init/template.js +1 -0
- package/dist/services/deploy/modern/atoms/design-build.js +41 -0
- package/dist/services/deploy/modern/atoms/design-upload.js +74 -0
- package/dist/services/deploy/modern/atoms/index.js +5 -1
- package/dist/services/deploy/modern/atoms/tosutil.js +246 -0
- package/dist/services/deploy/modern/atoms/upload.js +4 -127
- package/dist/services/deploy/modern/check.js +28 -16
- package/dist/services/deploy/modern/patch/actions.js +61 -0
- package/dist/services/deploy/modern/patch/content.js +18 -0
- package/dist/services/deploy/modern/patch/index.js +41 -0
- package/dist/services/deploy/modern/patch/routes.js +37 -0
- package/dist/services/deploy/modern/patch/source-scan.js +56 -0
- package/dist/services/deploy/modern/pipelines/design-local.js +47 -0
- package/dist/services/deploy/modern/pipelines/index.js +3 -1
- package/dist/services/deploy/modern/protocol.js +7 -0
- package/dist/services/deploy/modern/run.js +10 -4
- package/dist/services/deploy/modern/template-key-map.js +4 -0
- package/dist/services/registry/index.js +293 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,9 +41,36 @@ miaoda file ls --output json
|
|
|
41
41
|
| `miaoda file ...` | 文件操作:上传、下载、元数据、签名下载、批量删除 |
|
|
42
42
|
| `miaoda db ...` | 数据操作:SQL 执行、表结构查询、数据导入导出 |
|
|
43
43
|
| `miaoda observability ...` | 线上日志、链路、前端源码堆栈反查、监控指标、运营指标 |
|
|
44
|
+
| `miaoda registry ...` | 组件 registry:列出 / copy-in design-html SDK 文件(本地执行) |
|
|
44
45
|
|
|
45
46
|
完整命令通过 `miaoda --help` 或 `miaoda <domain> --help` 查看。
|
|
46
47
|
|
|
48
|
+
## 组件 registry(design-html)
|
|
49
|
+
|
|
50
|
+
`miaoda registry` 为 design-html 技术栈提供 shadcn 式的「组件 registry」:把 SDK 文件**拷进**当前项目(copy-in),而非作为依赖安装。registry 是独立 npm 包,按运行时分发(design-html → buildless runtime → `@lark-apaas/coding-registry-buildless`)。
|
|
51
|
+
|
|
52
|
+
前置:当前目录(或 `--dir`)已走过 `miaoda app init`,`.spark/meta.json` 含 `stack=design-html`。
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# 列出可用 SDK 条目(输出各文件 USAGE 注释块原文,便于 Agent 直接读用法)
|
|
56
|
+
miaoda registry list
|
|
57
|
+
miaoda registry list --json
|
|
58
|
+
|
|
59
|
+
# 把条目 copy-in 到当前项目(自动按 USAGE 块的 Depends 解析依赖闭包一并拷入)
|
|
60
|
+
miaoda registry add deck-slide
|
|
61
|
+
miaoda registry add foo.css theme --dry-run # 只报告将写 / 将跳,不落盘
|
|
62
|
+
miaoda registry add deck-slide --overwrite # 目标已存在时覆盖(默认跳过以保护改动)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
要点:
|
|
66
|
+
|
|
67
|
+
- **条目**:registry 包根 `components/` · `scripts/` · `stylesheets/` 三个顶层目录(任意深度)下的代码文件即条目。USAGE 注释块**可选**(有则提供描述 + Depends,无则空描述、无依赖);包根直放文件、其它目录、非代码文件都不算条目。
|
|
68
|
+
- **寻址**:`add` / `Depends` 的 token 可写三种形式 —— `name`(去扩展名,如 `foo`)/ 完整文件名(如 `foo.css`)/ relPath(如 `stylesheets/foo.css`)。`name` **不要求唯一**,`list --json` 的 `file`(relPath)是永远无歧义的 canonical 地址。
|
|
69
|
+
- **多匹配全拉**:token 命中多个同名条目时全部 copy-in(如 `add foo` 把 `foo.jsx` + `foo.css` 一起拉),想只要其一就用完整文件名或 relPath。
|
|
70
|
+
- **拍平落地**:所有文件**拍平**到项目根(`scripts/deck-slide.js` → 项目 `deck-slide.js`,不保留子目录);闭包内同名 basename 撞车时后者覆盖前者。
|
|
71
|
+
- **skip-by-disk**:项目已有同名(拍平后的 basename)文件默认跳过,`--overwrite` 才覆盖;不写任何安装记账文件,项目文件树即状态。
|
|
72
|
+
- `--version <ver>` 指定 registry 包版本或 dist-tag(缺省 `latest`),`--dir <path>` 指定项目目录(缺省当前目录)。
|
|
73
|
+
|
|
47
74
|
## 全局参数
|
|
48
75
|
|
|
49
76
|
- `--json [fields]`:输出结构化 JSON,可选字段级选择(如 `--json id,name`)。
|
package/dist/api/deploy/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NodeStatus = exports.nodeStatusFromText = exports.nodeStatusText = exports.errorJobSchema = exports.deployGetSchema = exports.deployHistorySchema = exports.batchSavePluginInstances = exports.LocalReleaseStatus = exports.getModernLastPublishedVersion = exports.getModernReleaseStatus = exports.createModernRelease = exports.callbackStatic = exports.updateLocalRelease = exports.createLocalRelease = exports.preRelease = exports.queryPipelineInstance = exports.getErrorLog = exports.listPipelineInstances = exports.createRelease = void 0;
|
|
3
|
+
exports.NodeStatus = exports.nodeStatusFromText = exports.nodeStatusText = exports.errorJobSchema = exports.deployGetSchema = exports.deployHistorySchema = exports.batchSavePluginInstances = exports.TosActionType = exports.LocalReleaseStatus = exports.applyTosDiff = exports.getModernLastPublishedVersion = exports.getModernReleaseStatus = exports.createModernRelease = exports.callbackStatic = exports.updateLocalRelease = exports.createLocalRelease = exports.preRelease = exports.queryPipelineInstance = exports.getErrorLog = exports.listPipelineInstances = exports.createRelease = void 0;
|
|
4
4
|
var api_1 = require("./api");
|
|
5
5
|
Object.defineProperty(exports, "createRelease", { enumerable: true, get: function () { return api_1.createRelease; } });
|
|
6
6
|
Object.defineProperty(exports, "listPipelineInstances", { enumerable: true, get: function () { return api_1.listPipelineInstances; } });
|
|
@@ -14,8 +14,10 @@ Object.defineProperty(exports, "callbackStatic", { enumerable: true, get: functi
|
|
|
14
14
|
Object.defineProperty(exports, "createModernRelease", { enumerable: true, get: function () { return modern_1.createRelease; } });
|
|
15
15
|
Object.defineProperty(exports, "getModernReleaseStatus", { enumerable: true, get: function () { return modern_1.getReleaseStatus; } });
|
|
16
16
|
Object.defineProperty(exports, "getModernLastPublishedVersion", { enumerable: true, get: function () { return modern_1.getLastPublishedVersion; } });
|
|
17
|
+
Object.defineProperty(exports, "applyTosDiff", { enumerable: true, get: function () { return modern_1.applyTosDiff; } });
|
|
17
18
|
var modern_types_1 = require("./modern-types");
|
|
18
19
|
Object.defineProperty(exports, "LocalReleaseStatus", { enumerable: true, get: function () { return modern_types_1.LocalReleaseStatus; } });
|
|
20
|
+
Object.defineProperty(exports, "TosActionType", { enumerable: true, get: function () { return modern_types_1.TosActionType; } });
|
|
19
21
|
var plugin_instances_1 = require("./plugin-instances");
|
|
20
22
|
Object.defineProperty(exports, "batchSavePluginInstances", { enumerable: true, get: function () { return plugin_instances_1.batchSavePluginInstances; } });
|
|
21
23
|
var schemas_1 = require("./schemas");
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
//
|
|
9
9
|
// 远端部署链路(B/C)所需的 release 接口先预留类型骨架,待 B/C 落地时启用。
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.LocalReleaseStatus = void 0;
|
|
11
|
+
exports.TosActionType = exports.LocalReleaseStatus = void 0;
|
|
12
12
|
/**
|
|
13
13
|
* localPublish 状态枚举(数值,与服务端 IDL 对齐)。
|
|
14
14
|
* CLI updateLocalRelease 只翻 Finished / Failed 两个终态;其它由后端流转。
|
|
@@ -21,3 +21,6 @@ exports.LocalReleaseStatus = {
|
|
|
21
21
|
Canceled: 4,
|
|
22
22
|
Rollback: 5,
|
|
23
23
|
};
|
|
24
|
+
// ── applyTosDiff(design-html 增量发布;后端应用 TOS diff) ──
|
|
25
|
+
/** 对齐 IDL publish.TosActionType(UNSPECIFIED=0 不用) */
|
|
26
|
+
exports.TosActionType = { CREATE: 1, UPDATE: 2, DELETE: 3 };
|
|
@@ -17,6 +17,7 @@ exports.callbackStatic = callbackStatic;
|
|
|
17
17
|
exports.createRelease = createRelease;
|
|
18
18
|
exports.getReleaseStatus = getReleaseStatus;
|
|
19
19
|
exports.getLastPublishedVersion = getLastPublishedVersion;
|
|
20
|
+
exports.applyTosDiff = applyTosDiff;
|
|
20
21
|
const http_1 = require("../../utils/http");
|
|
21
22
|
const devops_error_1 = require("../../utils/devops-error");
|
|
22
23
|
const DEFAULT_ERR_CODE = 'INTERNAL_DEVOPS_ERROR';
|
|
@@ -76,3 +77,10 @@ async function getLastPublishedVersion(req) {
|
|
|
76
77
|
const url = `/v1/devops/app/${encodeURIComponent(appID)}/last_published_version`;
|
|
77
78
|
return (0, http_1.postInnerApi)(url, {}, envelopeOpts('Failed to get last published version'));
|
|
78
79
|
}
|
|
80
|
+
// ── applyTosDiff ──
|
|
81
|
+
/** POST /v1/devops/app/:appID/apply_tos_diff —— 增量应用 TOS 文件 diff */
|
|
82
|
+
async function applyTosDiff(req) {
|
|
83
|
+
const { appID, ...body } = req;
|
|
84
|
+
const url = `/v1/devops/app/${encodeURIComponent(appID)}/apply_tos_diff`;
|
|
85
|
+
return (0, http_1.postInnerApi)(url, body, envelopeOpts('Failed to apply tos diff'));
|
|
86
|
+
}
|
|
@@ -164,7 +164,7 @@ function registerAppInit(parent) {
|
|
|
164
164
|
.command('init')
|
|
165
165
|
.description('初始化应用代码:抓 template 渲染、同步 upgrade/templates、装 .agent/steering/ skills、写 .spark/meta.json。.spark/meta.json 已存在则直接退出')
|
|
166
166
|
.option('--template <stack>', `技术栈短名(${index_1.SUPPORTED_STACKS.join(' / ')})`)
|
|
167
|
-
.option('--conf
|
|
167
|
+
.option('--conf [json]', 'init 配置 JSON。支持 {"version": "<template 版本>"},默认 latest')
|
|
168
168
|
.option('--skip-install', '跳过依赖安装', false)
|
|
169
169
|
.option('--async-install', '派发后台进程装依赖并立即返回(与 --skip-install 互斥)', false)
|
|
170
170
|
.addOption((0, shared_1.appIdOption)())
|
|
@@ -234,7 +234,9 @@ JSON 输出
|
|
|
234
234
|
}));
|
|
235
235
|
}
|
|
236
236
|
function parseInitConf(raw) {
|
|
237
|
-
|
|
237
|
+
// --conf 为可选值:未传(undefined)、裸 --conf(Commander 给 true)、空/纯空白字符串
|
|
238
|
+
// 一律视为不配置,回退默认(latest)。
|
|
239
|
+
if (raw === undefined || typeof raw === 'boolean' || raw.trim() === '')
|
|
238
240
|
return undefined;
|
|
239
241
|
let parsed;
|
|
240
242
|
try {
|
|
@@ -481,6 +481,7 @@ Examples:
|
|
|
481
481
|
'应用到 online;online 将无法直接更改数据库结构(仍可进行数据 DML 操作)。')
|
|
482
482
|
.usage('[flags]')
|
|
483
483
|
.option('--sync-data', '启用时将现有数据同步一份到 dev 环境')
|
|
484
|
+
.option('-y, --yes', '跳过确认提示直接执行')
|
|
484
485
|
.action(async function () {
|
|
485
486
|
await (0, index_1.handleDbMigrationInit)(this.optsWithGlobals());
|
|
486
487
|
})
|
|
@@ -561,6 +562,7 @@ Examples:
|
|
|
561
562
|
.summary('将 dev 的变更发布到 online(单事务原子)')
|
|
562
563
|
.description('将 dev 的变更发布到 online。')
|
|
563
564
|
.usage('[flags]')
|
|
565
|
+
.option('-y, --yes', '跳过确认提示直接执行')
|
|
564
566
|
.action(async function () {
|
|
565
567
|
await (0, index_1.handleDbMigrationApply)(this.optsWithGlobals());
|
|
566
568
|
})
|
|
@@ -679,6 +681,7 @@ Examples:
|
|
|
679
681
|
.description('将数据库恢复到指定时间点的状态。')
|
|
680
682
|
.usage('<timestamp> [flags]')
|
|
681
683
|
.argument('<timestamp>', '目标时间')
|
|
684
|
+
.option('-y, --yes', '跳过确认提示直接执行')
|
|
682
685
|
.action(async function (target) {
|
|
683
686
|
await (0, index_1.handleDbRecoveryApply)(target, this.optsWithGlobals());
|
|
684
687
|
})
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.registerDeployCommandsModern = registerDeployCommandsModern;
|
|
4
4
|
const shared_1 = require("../../../cli/commands/shared");
|
|
5
5
|
const modern_1 = require("../../../cli/handlers/deploy/modern");
|
|
6
|
+
const index_1 = require("../../../cli/handlers/deploy/index");
|
|
6
7
|
/**
|
|
7
8
|
* modern scene (MIAODA_APP_TYPE=7) 专用 deploy 注册。
|
|
8
9
|
* 仅披露顶层 `miaoda deploy`,CLI 表面对齐 openclaw-cli:`--dir / --skip-build`。
|
|
@@ -56,4 +57,35 @@ JSON 输出(stdout)
|
|
|
56
57
|
conf: rawOpts.conf,
|
|
57
58
|
});
|
|
58
59
|
}));
|
|
60
|
+
const patchCmd = deployCmd
|
|
61
|
+
.command('patch')
|
|
62
|
+
.description('design-html 增量发布:按文件 create/update/delete,.html 增删时同步 routes.json')
|
|
63
|
+
.option('--create <relpath>', '新增文件(可重复)', shared_1.collectRepeatedOption, [])
|
|
64
|
+
.option('--update <relpath>', '覆盖已有文件(可重复)', shared_1.collectRepeatedOption, [])
|
|
65
|
+
.option('--delete <relpath>', '删除文件(可重复)', shared_1.collectRepeatedOption, [])
|
|
66
|
+
.addHelpText('after', `
|
|
67
|
+
--dir 为项目目录(与 deploy 同名参数,默认当前目录)。
|
|
68
|
+
仅支持 design-html(design_local_deploy)。路径为工程根相对路径(= 服务端 latest 下 key),
|
|
69
|
+
禁绝对路径与 ".."。--create/--update 的本地文件必须存在。.html 被新增/删除(路由集合变化)
|
|
70
|
+
时自动重算并随包更新 routes.json;纯 --update 现有 .html 只改内容,不动 routes.json。
|
|
71
|
+
routes.json 每项为 {path, file}:path 为相对路径(不含 base 前缀,由消费侧拼接),file 为
|
|
72
|
+
对应源文件(如 / → index.html)。
|
|
73
|
+
|
|
74
|
+
JSON 输出
|
|
75
|
+
{"data": {"upsertCount": <n>, "deleteCount": <n>, "actionsSent": <n>, "routesRegenerated": <bool>}}
|
|
76
|
+
|
|
77
|
+
示例
|
|
78
|
+
$ miaoda deploy patch --update index.html
|
|
79
|
+
$ miaoda deploy patch --create blog/post.html --delete blog/old.html
|
|
80
|
+
$ miaoda deploy patch --update assets/app.js --update assets/app.css
|
|
81
|
+
`);
|
|
82
|
+
patchCmd.action((0, shared_1.withHelp)(patchCmd, async (rawOpts) => {
|
|
83
|
+
await (0, index_1.handleDeployPatch)({
|
|
84
|
+
appId: (0, shared_1.resolveAppId)({}),
|
|
85
|
+
dir: deployCmd.opts().dir ?? '.',
|
|
86
|
+
creates: rawOpts.create,
|
|
87
|
+
updates: rawOpts.update,
|
|
88
|
+
deletes: rawOpts.delete,
|
|
89
|
+
});
|
|
90
|
+
}));
|
|
59
91
|
}
|
|
@@ -146,10 +146,9 @@ Examples:
|
|
|
146
146
|
.usage('[paths...] [flags]')
|
|
147
147
|
.argument('[paths...]', '要删除的文件,每项可填路径或文件名(自动识别)')
|
|
148
148
|
.option('-n, --name <name>', '按文件名删除(可重复指定)', (value, prev) => [...(prev ?? []), value])
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
.
|
|
152
|
-
await (0, index_1.handleFileRm)(paths, { ...this.optsWithGlobals(), appId: (0, shared_1.resolveAppId)({}) });
|
|
149
|
+
.option('-y, --yes', '跳过交互确认;非交互场景必加')
|
|
150
|
+
.action(async (paths, opts) => {
|
|
151
|
+
await (0, index_1.handleFileRm)(paths, { ...opts, appId: (0, shared_1.resolveAppId)({}) });
|
|
153
152
|
})
|
|
154
153
|
.addHelpText('after', `
|
|
155
154
|
Notes:
|
|
@@ -9,11 +9,13 @@ const index_4 = require("../../cli/commands/app/index");
|
|
|
9
9
|
const index_5 = require("../../cli/commands/deploy/index");
|
|
10
10
|
const modern_1 = require("../../cli/commands/deploy/modern");
|
|
11
11
|
const index_6 = require("../../cli/commands/skills/index");
|
|
12
|
+
const index_7 = require("../../cli/commands/registry/index");
|
|
12
13
|
// scene 跟 dispatcher(MIAODA_APP_TYPE)同语义层级 —— app 业务类型维度,
|
|
13
14
|
// 对齐后端 devops app_common.AppType 枚举:
|
|
14
15
|
// 3 = AppType_APPLICATION(全栈应用,当前仅 nestjs-react-fullstack 一个 stack)
|
|
15
16
|
// 4 = AppType_DESIGN(design-stack,SSR 渲染、无业务逻辑、无数据库)
|
|
16
17
|
// 7 = miaoda-cli 自定义 modern 占位(后端枚举无 7,沙箱目前不传)
|
|
18
|
+
// 8 = AppType_DESIGN_HTML(design-html,buildless 静态 HTML,命令集同 modern)
|
|
17
19
|
// 其它(0/1/2/5/6 / 未设)→ default(命令全开,本地 dev / CI / 兼容回退)
|
|
18
20
|
// stack 维度(nestjs-react-fullstack / vite-react / ...)是正交的,
|
|
19
21
|
// skills sync 内部按 .spark/meta.json.stack 拉对应 coding-steering/steering/<stack>/ 子目录。
|
|
@@ -24,6 +26,8 @@ function resolveScene(appType, _archType) {
|
|
|
24
26
|
return 'application';
|
|
25
27
|
if (appType === '4')
|
|
26
28
|
return 'design';
|
|
29
|
+
if (appType === '8')
|
|
30
|
+
return 'design-html';
|
|
27
31
|
return 'default';
|
|
28
32
|
}
|
|
29
33
|
const SCENE_REGISTRARS = {
|
|
@@ -62,6 +66,15 @@ const SCENE_REGISTRARS = {
|
|
|
62
66
|
(0, index_3.registerObservabilityCommands)(p);
|
|
63
67
|
(0, index_6.registerSkillsCommands)(p);
|
|
64
68
|
},
|
|
69
|
+
// design-html scene(AppType_DESIGN_HTML=8):buildless 静态 HTML,
|
|
70
|
+
// 命令集与 modern 一致(app init/sync + modern 拆分版 deploy + skills),不挂 db/file/observability。
|
|
71
|
+
// 额外挂 registry(shadcn 式 copy-in SDK,design-html scene 专属)。
|
|
72
|
+
'design-html': (p) => {
|
|
73
|
+
(0, index_4.registerAppCommands)(p, { includeInit: true });
|
|
74
|
+
(0, modern_1.registerDeployCommandsModern)(p);
|
|
75
|
+
(0, index_6.registerSkillsCommands)(p);
|
|
76
|
+
(0, index_7.registerRegistryCommands)(p);
|
|
77
|
+
},
|
|
65
78
|
};
|
|
66
79
|
function readEnv(name) {
|
|
67
80
|
const v = process.env[name]?.trim();
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerRegistryCommands = registerRegistryCommands;
|
|
4
|
+
const shared_1 = require("../../../cli/commands/shared");
|
|
5
|
+
const index_1 = require("../../../cli/handlers/registry/index");
|
|
6
|
+
/**
|
|
7
|
+
* miaoda registry:design-html 技术栈的「组件 registry」(shadcn 式 copy-in)。
|
|
8
|
+
*
|
|
9
|
+
* registry 是独立 npm 包,按 runtime 命名分发(buildless runtime → @lark-apaas/coding-registry-buildless)。
|
|
10
|
+
* SDK 文件放在包根的 components/ · scripts/ · stylesheets/ 三个目录下(这三个顶层目录里的代码文件
|
|
11
|
+
* 才算条目);文件可带 USAGE 注释块(可选,声明描述 / 用法 / Depends)。CLI 抓 tarball、按
|
|
12
|
+
* .spark/meta.json.stack → runtime → 包名 选包,把 SDK 文件**拍平**copy-in 到用户项目根。
|
|
13
|
+
* 不写安装记账文件——项目文件树即状态(skip-by-disk)。
|
|
14
|
+
*/
|
|
15
|
+
function registerRegistryCommands(program) {
|
|
16
|
+
const registryCmd = program
|
|
17
|
+
.command('registry')
|
|
18
|
+
.description('组件 registry:列出 / copy-in design-html SDK 文件')
|
|
19
|
+
.usage('<command> [flags]');
|
|
20
|
+
registryCmd.action(() => {
|
|
21
|
+
registryCmd.outputHelp();
|
|
22
|
+
});
|
|
23
|
+
registryCmd.addHelpText('after', `
|
|
24
|
+
概念
|
|
25
|
+
- registry 包:独立 npm 包(按 runtime 命名)
|
|
26
|
+
- 条目 (entry):包根 components/ · scripts/ · stylesheets/ 顶层目录(任意深度)下的代码文件;
|
|
27
|
+
name = 文件名去扩展名(不要求唯一)。包根直放文件、其它目录、非代码文件都不算条目
|
|
28
|
+
- 寻址:add / Depends 的 token 可写三种形式——name(foo)/ 完整文件名(foo.css)/ relPath(stylesheets/foo.css)
|
|
29
|
+
- 多匹配全拉:token 命中多个同名条目时全部 copy-in(不报歧义);想只要其一就写完整文件名 / relPath
|
|
30
|
+
- USAGE 块:可选元数据,声明描述 / Exports / Usage / Depends;无 USAGE 也是条目(空描述、无依赖)
|
|
31
|
+
- Depends:从 USAGE 块解析的跨条目依赖,add 时传递解析、一并 copy-in
|
|
32
|
+
- add 落地:拍平到项目根(包根 scripts/x.js → 项目 x.js);同名 basename 撞车时后者覆盖前者
|
|
33
|
+
|
|
34
|
+
前置
|
|
35
|
+
当前目录(或 --dir)已走过 'miaoda app init'(.spark/meta.json 含 stack=design-html)
|
|
36
|
+
`);
|
|
37
|
+
registerRegistryList(registryCmd);
|
|
38
|
+
registerRegistryAdd(registryCmd);
|
|
39
|
+
}
|
|
40
|
+
function registerRegistryList(parent) {
|
|
41
|
+
const cmd = parent
|
|
42
|
+
.command('list')
|
|
43
|
+
.description('列出 registry 可用 SDK 条目,输出各文件的 USAGE 块原文')
|
|
44
|
+
.option('--dir <path>', '项目目录,默认当前目录', '.')
|
|
45
|
+
.option('--version <ver>', 'registry 包版本或 dist-tag,缺省 latest')
|
|
46
|
+
.addHelpText('after', `
|
|
47
|
+
输出
|
|
48
|
+
默认(pretty):各条目 USAGE 块原文拼接,带文件名分隔,给 Agent 直接读注释
|
|
49
|
+
|
|
50
|
+
JSON 输出
|
|
51
|
+
{"data": [{"name": "...", "file": "...", "usage": "<原文>", "dependsOn": [...]}, ...]}
|
|
52
|
+
(usage 保持 USAGE 块原文,不解析成结构化字段)
|
|
53
|
+
|
|
54
|
+
示例
|
|
55
|
+
$ miaoda registry list
|
|
56
|
+
$ miaoda registry list --json
|
|
57
|
+
`);
|
|
58
|
+
cmd.action((0, shared_1.withHelp)(cmd, async (rawOpts) => {
|
|
59
|
+
await (0, index_1.handleRegistryList)({
|
|
60
|
+
dir: rawOpts.dir,
|
|
61
|
+
version: rawOpts.version,
|
|
62
|
+
});
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
function registerRegistryAdd(parent) {
|
|
66
|
+
const cmd = parent
|
|
67
|
+
.command('add')
|
|
68
|
+
.description('把一个或多个 SDK 文件 copy-in 到当前项目(拍平到项目根,含 Depends 闭包)')
|
|
69
|
+
.argument('<token...>', 'name / 完整文件名 / relPath,可传多个;同名多匹配全拉,Depends 自动传递解析')
|
|
70
|
+
.option('--dir <path>', '项目目录,默认当前目录', '.')
|
|
71
|
+
.option('--version <ver>', 'registry 包版本或 dist-tag,缺省 latest')
|
|
72
|
+
.option('--overwrite', '目标文件已存在时覆盖(默认跳过以保护用户改动)', false)
|
|
73
|
+
.option('--dry-run', '只报告将写 / 将跳哪些文件,不落盘', false)
|
|
74
|
+
.addHelpText('after', `
|
|
75
|
+
行为
|
|
76
|
+
- token 寻址:name(foo)/ 完整文件名(foo.css)/ relPath(stylesheets/foo.css)任一形式
|
|
77
|
+
- 多匹配全拉:token 命中多个同名条目时全部 copy-in;想只要其一就写完整文件名 / relPath
|
|
78
|
+
- 解析 USAGE 块 Depends 传递闭包,把 SDK 文件**拍平**拷到项目根
|
|
79
|
+
(包根 scripts/deck-stage.js → 项目 deck-stage.js;同名 basename 撞车时后者覆盖前者)
|
|
80
|
+
- skip-by-disk:目标文件已存在默认跳过;--overwrite 才覆盖
|
|
81
|
+
- 不写任何安装记账文件(项目文件树即状态)
|
|
82
|
+
|
|
83
|
+
JSON 输出
|
|
84
|
+
{"data": {"registryVersion": "...", "requested": [...], "resolved": [...],
|
|
85
|
+
"added": [...], "skipped": [...], "dryRun": false}}
|
|
86
|
+
(resolved 为来源 relPath;added / skipped 为拍平后的落地 basename,如 deck-stage.js)
|
|
87
|
+
|
|
88
|
+
示例
|
|
89
|
+
$ miaoda registry add deck-slide
|
|
90
|
+
$ miaoda registry add deck-slide theme --dry-run
|
|
91
|
+
$ miaoda registry add deck-slide --overwrite --json
|
|
92
|
+
`);
|
|
93
|
+
cmd.action((0, shared_1.withHelp)(cmd, async (names, rawOpts) => {
|
|
94
|
+
await (0, index_1.handleRegistryAdd)({
|
|
95
|
+
names,
|
|
96
|
+
dir: rawOpts.dir,
|
|
97
|
+
version: rawOpts.version,
|
|
98
|
+
overwrite: rawOpts.overwrite,
|
|
99
|
+
dryRun: rawOpts.dryRun,
|
|
100
|
+
});
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
@@ -69,8 +69,12 @@ async function handleAppInit(opts) {
|
|
|
69
69
|
const projectName = node_path_1.default.basename(targetDir);
|
|
70
70
|
const tplResult = (0, index_1.renderTemplate)({ stack, version, targetDir, projectName });
|
|
71
71
|
// 先建 logs/,防止 user 跑 dev 之前 AI/工具 redirect 到 logs/*.log 因为父目录不存在直接挂
|
|
72
|
-
// (dev.js / dev-local.js 自己也建 logs/,但只在它启动后;启动前的 shell redirect 会先于此)
|
|
73
|
-
|
|
72
|
+
// (dev.js / dev-local.js 自己也建 logs/,但只在它启动后;启动前的 shell redirect 会先于此)。
|
|
73
|
+
// 仅本地开发需要:沙箱环境由平台 supervisor 拉起 dev,无 init 前的 shell redirect 场景,
|
|
74
|
+
// 不预建 logs/ 以免在沙箱工作区留空目录。
|
|
75
|
+
if (!(0, env_1.isSandboxEnv)()) {
|
|
76
|
+
(0, logs_dir_1.ensureLogsDir)(targetDir);
|
|
77
|
+
}
|
|
74
78
|
// skills 同步软失败:拉不到 coding-steering 包不该阻断 writeSparkMeta /
|
|
75
79
|
// activateGitHooks(之前会让 .spark/meta.json 没写,下次 init 半渲染状态又得重跑全套)。
|
|
76
80
|
// 按运行环境(isSandboxEnv:MIAODA_DEP_CACHE_DIR 非空)分流 outputLayout,不绑 stack:
|
|
@@ -135,32 +135,6 @@ async function handleAppMigrate(opts) {
|
|
|
135
135
|
installError = err instanceof Error ? err.message : String(err);
|
|
136
136
|
(0, logger_1.log)('migrate', `⚠ npm install failed (continuing): ${installError}`);
|
|
137
137
|
}
|
|
138
|
-
// 重启 dev process 前清 vite cache —— migrate 改了 package.json + lockfile,
|
|
139
|
-
// 老 vite 进程的 .vite/deps cache 的 lockfileHash 跟新 lockfile 不一致。
|
|
140
|
-
// 不清的话 supervisor 拉起的新 vite cold start 会立即 "Re-optimizing because
|
|
141
|
-
// lockfile has changed", re-optimize 期间 ModuleGraph transform cache 跟
|
|
142
|
-
// deps middleware metadata 短暂不同步, 浏览器请求老 hash 触发
|
|
143
|
-
// ERR_OUTDATED_OPTIMIZED_DEP → 504 死锁(详见 fullstack-plugin#1143 的 504
|
|
144
|
-
// ignoreOutdatedRequests fix 注释)。直接 rm -rf 让新 vite 从干净状态 cold
|
|
145
|
-
// optimize, 一次写到位 lockfile 一致的 metadata, 不再触发中途 re-optimize。
|
|
146
|
-
//
|
|
147
|
-
// - 只在 SANDBOX_ID 非空时做(本地一般不会撞这条链路)
|
|
148
|
-
// - 只在 install 成功时做(install 挂了 node_modules 状态不对, 清 cache 也救不回来)
|
|
149
|
-
// - 软失败:.vite 不存在 / 删失败都不阻断
|
|
150
|
-
if (installError === undefined &&
|
|
151
|
-
process.env.SANDBOX_ID !== undefined &&
|
|
152
|
-
process.env.SANDBOX_ID !== '') {
|
|
153
|
-
const viteCacheDir = node_path_1.default.join(targetDir, 'node_modules', '.vite');
|
|
154
|
-
if (node_fs_1.default.existsSync(viteCacheDir)) {
|
|
155
|
-
(0, logger_1.log)('migrate', '清理 node_modules/.vite (vite cache 跟新 lockfile 错位会 504)...');
|
|
156
|
-
try {
|
|
157
|
-
node_fs_1.default.rmSync(viteCacheDir, { recursive: true, force: true });
|
|
158
|
-
}
|
|
159
|
-
catch (err) {
|
|
160
|
-
(0, logger_1.log)('migrate', `⚠ 清 .vite 失败 (continuing): ${err instanceof Error ? err.message : String(err)}`);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
138
|
// 沙箱环境下重启 dev process —— scripts/dev.js 被 fullstack 版本覆盖了,但当前正在
|
|
165
139
|
// 跑的 node 进程仍按老逻辑工作(只起 vite,没起 nest),整体没切到 fullstack 模式。
|
|
166
140
|
// 通过 pkill 杀掉 dev.js 主进程,依赖沙箱平台 supervisor 自动重新 exec dev.sh → dev.js,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_POLL_INTERVAL_MS = exports.waitForPipeline = exports.handleDeployErrorLog = exports.handleDeployHistory = exports.handleDeployGet = exports.handleDeploy = void 0;
|
|
3
|
+
exports.handleDeployPatch = exports.DEFAULT_POLL_INTERVAL_MS = exports.waitForPipeline = exports.handleDeployErrorLog = exports.handleDeployHistory = exports.handleDeployGet = exports.handleDeploy = void 0;
|
|
4
4
|
var deploy_1 = require("./deploy");
|
|
5
5
|
Object.defineProperty(exports, "handleDeploy", { enumerable: true, get: function () { return deploy_1.handleDeploy; } });
|
|
6
6
|
var get_1 = require("./get");
|
|
@@ -12,3 +12,5 @@ Object.defineProperty(exports, "handleDeployErrorLog", { enumerable: true, get:
|
|
|
12
12
|
var polling_1 = require("./polling");
|
|
13
13
|
Object.defineProperty(exports, "waitForPipeline", { enumerable: true, get: function () { return polling_1.waitForPipeline; } });
|
|
14
14
|
Object.defineProperty(exports, "DEFAULT_POLL_INTERVAL_MS", { enumerable: true, get: function () { return polling_1.DEFAULT_POLL_INTERVAL_MS; } });
|
|
15
|
+
var patch_1 = require("./patch");
|
|
16
|
+
Object.defineProperty(exports, "handleDeployPatch", { enumerable: true, get: function () { return patch_1.handleDeployPatch; } });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleDeployPatch = handleDeployPatch;
|
|
4
|
+
const index_1 = require("../../../services/deploy/modern/patch/index");
|
|
5
|
+
const output_1 = require("../../../utils/output");
|
|
6
|
+
/** miaoda deploy patch —— design-html 文件级增量发布 */
|
|
7
|
+
async function handleDeployPatch(opts) {
|
|
8
|
+
const result = await (0, index_1.patchDesignDeploy)({
|
|
9
|
+
appId: opts.appId,
|
|
10
|
+
projectDir: opts.dir ?? process.cwd(),
|
|
11
|
+
creates: opts.creates,
|
|
12
|
+
updates: opts.updates,
|
|
13
|
+
deletes: opts.deletes,
|
|
14
|
+
});
|
|
15
|
+
(0, output_1.emit)({ data: result });
|
|
16
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.handleRegistryAdd = handleRegistryAdd;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const index_1 = require("../../../services/registry/index");
|
|
9
|
+
const shared_1 = require("./shared");
|
|
10
|
+
const error_1 = require("../../../utils/error");
|
|
11
|
+
const output_1 = require("../../../utils/output");
|
|
12
|
+
const logger_1 = require("../../../utils/logger");
|
|
13
|
+
/**
|
|
14
|
+
* miaoda registry add <name...> [--overwrite] [--dry-run] [--dir <path>] [--version <ver>]
|
|
15
|
+
*
|
|
16
|
+
* 解析 USAGE 块 Depends 传递闭包,把每个条目对应的 SDK 文件从 registry 包根的 <relPath>
|
|
17
|
+
* **保留相对路径**拷到项目根(--dir 指定目录的根)。
|
|
18
|
+
* skip-by-disk:目标已存在默认跳过,--overwrite 才覆盖。不写任何安装记账文件。
|
|
19
|
+
*/
|
|
20
|
+
async function handleRegistryAdd(opts) {
|
|
21
|
+
await Promise.resolve();
|
|
22
|
+
if (opts.names.length === 0) {
|
|
23
|
+
throw new error_1.AppError('ARGS_INVALID', 'registry add 至少需要一个条目名');
|
|
24
|
+
}
|
|
25
|
+
const targetDir = node_path_1.default.resolve(opts.dir ?? process.cwd());
|
|
26
|
+
const stack = (0, shared_1.resolveRegistryStack)(targetDir);
|
|
27
|
+
const reg = (0, index_1.loadRegistry)({ stack, version: opts.version });
|
|
28
|
+
try {
|
|
29
|
+
const plan = (0, index_1.planAdd)({
|
|
30
|
+
entries: reg.entries,
|
|
31
|
+
targetDir,
|
|
32
|
+
names: opts.names,
|
|
33
|
+
});
|
|
34
|
+
const result = (0, index_1.applyAdd)(plan.files, {
|
|
35
|
+
overwrite: opts.overwrite === true,
|
|
36
|
+
dryRun: opts.dryRun === true,
|
|
37
|
+
});
|
|
38
|
+
const verb = opts.dryRun === true ? 'Would add' : 'Added';
|
|
39
|
+
(0, logger_1.log)('registry', `${verb} ${String(result.added.length)} file(s), skipped ${String(result.skipped.length)} (registry@${reg.version})`);
|
|
40
|
+
(0, output_1.emit)({
|
|
41
|
+
data: {
|
|
42
|
+
registryVersion: reg.version,
|
|
43
|
+
requested: opts.names,
|
|
44
|
+
resolved: plan.entries.map((e) => e.relPath),
|
|
45
|
+
added: result.added,
|
|
46
|
+
skipped: result.skipped,
|
|
47
|
+
dryRun: opts.dryRun === true,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
reg.cleanup();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleRegistryAdd = exports.handleRegistryList = void 0;
|
|
4
|
+
var list_1 = require("./list");
|
|
5
|
+
Object.defineProperty(exports, "handleRegistryList", { enumerable: true, get: function () { return list_1.handleRegistryList; } });
|
|
6
|
+
var add_1 = require("./add");
|
|
7
|
+
Object.defineProperty(exports, "handleRegistryAdd", { enumerable: true, get: function () { return add_1.handleRegistryAdd; } });
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.handleRegistryList = handleRegistryList;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const index_1 = require("../../../services/registry/index");
|
|
9
|
+
const shared_1 = require("./shared");
|
|
10
|
+
const output_1 = require("../../../utils/output");
|
|
11
|
+
/**
|
|
12
|
+
* miaoda registry list [--dir <path>] [--version <ver>]
|
|
13
|
+
*
|
|
14
|
+
* 从 .spark/meta.json 读 stack → runtime → 包名,拉对应 registry 包,从包根递归扫含 USAGE 块的 SDK 文件。
|
|
15
|
+
*
|
|
16
|
+
* - 默认(pretty):输出各条目 USAGE 块原文,带文件名分隔,给 Agent 直接读注释。
|
|
17
|
+
* - --json:输出 [{name, file, usage(原文字符串), dependsOn[]}],usage 保持原文不解析成字段。
|
|
18
|
+
* file 是相对包根的路径(如 scripts/deck-stage.js),即 add 后的落地相对路径。
|
|
19
|
+
*/
|
|
20
|
+
async function handleRegistryList(opts) {
|
|
21
|
+
await Promise.resolve();
|
|
22
|
+
const targetDir = node_path_1.default.resolve(opts.dir ?? process.cwd());
|
|
23
|
+
const stack = (0, shared_1.resolveRegistryStack)(targetDir);
|
|
24
|
+
const reg = (0, index_1.loadRegistry)({ stack, version: opts.version });
|
|
25
|
+
try {
|
|
26
|
+
if ((0, output_1.isJsonMode)()) {
|
|
27
|
+
(0, output_1.emit)({
|
|
28
|
+
data: reg.entries.map((e) => ({
|
|
29
|
+
name: e.name,
|
|
30
|
+
file: e.relPath,
|
|
31
|
+
usage: e.usage,
|
|
32
|
+
dependsOn: e.dependsOn,
|
|
33
|
+
})),
|
|
34
|
+
});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
// pretty:各条目 USAGE 块原文拼接,带文件路径分隔(让 Agent 直接读注释)
|
|
38
|
+
if (reg.entries.length === 0) {
|
|
39
|
+
(0, output_1.emit)('(no registry entries)');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const blocks = reg.entries.map((e) => `# ${e.relPath}\n${e.usage}`);
|
|
43
|
+
(0, output_1.emit)(blocks.join('\n\n'));
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
reg.cleanup();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveRegistryStack = resolveRegistryStack;
|
|
4
|
+
const spark_meta_1 = require("../../../utils/spark-meta");
|
|
5
|
+
const index_1 = require("../../../services/registry/index");
|
|
6
|
+
const error_1 = require("../../../utils/error");
|
|
7
|
+
/**
|
|
8
|
+
* 从 <targetDir>/.spark/meta.json 读 stack,校验该 stack 有组件 registry。
|
|
9
|
+
* 缺 stack → 提示先 init;stack 无 registry(无对应 runtime / runtime 无 registry 包)→ 提示支持哪些 stack。
|
|
10
|
+
*
|
|
11
|
+
* 这里只做「stack 是否在支持列表」的早校验给用户友好提示;包名的两跳解析
|
|
12
|
+
* (stack → runtime → 包)由 loadRegistry/resolveRegistryPackage 负责。
|
|
13
|
+
*/
|
|
14
|
+
function resolveRegistryStack(targetDir) {
|
|
15
|
+
const meta = (0, spark_meta_1.readSparkMeta)(targetDir);
|
|
16
|
+
if (meta.stack === undefined || meta.stack === '') {
|
|
17
|
+
throw new error_1.AppError('REGISTRY_META_INCOMPLETE', '.spark/meta.json missing stack — run `miaoda app init` first');
|
|
18
|
+
}
|
|
19
|
+
if (!index_1.REGISTRY_SUPPORTED_STACKS.includes(meta.stack)) {
|
|
20
|
+
throw new error_1.AppError('REGISTRY_STACK_UNSUPPORTED', `stack "${meta.stack}" 没有组件 registry`, {
|
|
21
|
+
next_actions: [`支持 registry 的 stack:${index_1.REGISTRY_SUPPORTED_STACKS.join(', ') || '(none)'}`],
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return meta.stack;
|
|
25
|
+
}
|
package/dist/main.js
CHANGED
|
@@ -30,9 +30,6 @@ program
|
|
|
30
30
|
.argParser((0, shared_1.caseInsensitiveChoice)(['pretty', 'json']))
|
|
31
31
|
.default('pretty'))
|
|
32
32
|
.option('--verbose', 'debug 日志到 stderr')
|
|
33
|
-
// 全局接受 -y/--yes:作为 root 全局 option 下发到所有子命令解析(同 --json/--verbose),
|
|
34
|
-
// 让任意命令带 --yes 都不报 unknown option。对有确认门的破坏性命令生效,其余命令忽略。
|
|
35
|
-
.option('-y, --yes', '跳过确认提示(对有确认门的命令生效,其余命令忽略)')
|
|
36
33
|
.helpOption('-h, --help', '显示帮助信息')
|
|
37
34
|
.hook('preAction', (_thisCmd, actionCmd) => {
|
|
38
35
|
(0, log_id_1.generateLogId)();
|
|
@@ -15,6 +15,7 @@ exports.TEMPLATE_PACKAGE_BY_STACK = {
|
|
|
15
15
|
'vite-react': '@lark-apaas/coding-template-vite-react',
|
|
16
16
|
html: '@lark-apaas/coding-template-html',
|
|
17
17
|
'nestjs-react-fullstack': '@lark-apaas/coding-template-nestjs-react-fullstack',
|
|
18
|
+
'design-html': '@lark-apaas/coding-template-design-html',
|
|
18
19
|
};
|
|
19
20
|
/**
|
|
20
21
|
* 短名 → template 包钉版表。renderTemplate 默认按这张表取版本号,表外 stack 跟 npm latest。
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildDesignOutput = buildDesignOutput;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const error_1 = require("../../../../utils/error");
|
|
10
|
+
const logger_1 = require("../../../../utils/logger");
|
|
11
|
+
const constants_1 = require("../constants");
|
|
12
|
+
const source_scan_1 = require("../patch/source-scan");
|
|
13
|
+
const routes_1 = require("../patch/routes");
|
|
14
|
+
/**
|
|
15
|
+
* design-html buildless 闭环 build(替代模板 scripts/build.sh):
|
|
16
|
+
* 1. rm -rf <projectDir>/dist
|
|
17
|
+
* 2. 拷源码 → dist/output(套 EXCLUDES,与 routes 同一份 listSourceFiles)
|
|
18
|
+
* 3. 写 dist/output/routes.json = generateRoutes(projectDir)
|
|
19
|
+
* 不跑 npm run build、不依赖技术栈内 build.sh。
|
|
20
|
+
* fs / scan / routes 任何失败统一包成 AppError('DEPLOY_BUILD_FAILED'),与旧 runDesignBuild 对齐。
|
|
21
|
+
*/
|
|
22
|
+
function buildDesignOutput(opts) {
|
|
23
|
+
(0, logger_1.log)('deploy', 'Building (design, CLI)...');
|
|
24
|
+
try {
|
|
25
|
+
const distDir = node_path_1.default.join(opts.projectDir, constants_1.DIST_DIR);
|
|
26
|
+
const outputDir = node_path_1.default.join(distDir, constants_1.OUTPUT_DIR);
|
|
27
|
+
node_fs_1.default.rmSync(distDir, { recursive: true, force: true });
|
|
28
|
+
node_fs_1.default.mkdirSync(outputDir, { recursive: true });
|
|
29
|
+
for (const rel of (0, source_scan_1.listSourceFiles)(opts.projectDir)) {
|
|
30
|
+
const dest = node_path_1.default.join(outputDir, rel);
|
|
31
|
+
node_fs_1.default.mkdirSync(node_path_1.default.dirname(dest), { recursive: true });
|
|
32
|
+
node_fs_1.default.copyFileSync(node_path_1.default.join(opts.projectDir, rel), dest);
|
|
33
|
+
}
|
|
34
|
+
node_fs_1.default.writeFileSync(node_path_1.default.join(outputDir, 'routes.json'), (0, routes_1.generateRoutes)(opts.projectDir), 'utf-8');
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
if (err instanceof error_1.AppError)
|
|
38
|
+
throw err;
|
|
39
|
+
throw new error_1.AppError('DEPLOY_BUILD_FAILED', `design build failed: ${err.message}`);
|
|
40
|
+
}
|
|
41
|
+
}
|