@lark-apaas/miaoda-cli 0.1.21-alpha.90df4a0 → 0.1.21
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 +2 -36
- package/dist/api/deploy/index.js +1 -3
- package/dist/api/deploy/modern-types.js +1 -4
- package/dist/api/deploy/modern.js +0 -8
- package/dist/api/index.js +1 -3
- package/dist/cli/commands/app/index.js +2 -4
- package/dist/cli/commands/db/index.js +0 -3
- package/dist/cli/commands/deploy/modern.js +0 -34
- package/dist/cli/commands/file/index.js +4 -3
- package/dist/cli/commands/index.js +0 -19
- package/dist/cli/handlers/app/init.js +2 -6
- package/dist/cli/handlers/app/migrate.js +26 -0
- package/dist/cli/handlers/deploy/index.js +1 -3
- package/dist/cli/handlers/skills/sync.js +4 -12
- package/dist/config/migrate-configs/vite-react-to-nestjs-react-fullstack.js +9 -0
- package/dist/main.js +3 -0
- package/dist/services/app/init/template.js +0 -1
- package/dist/services/deploy/modern/atoms/index.js +1 -6
- package/dist/services/deploy/modern/atoms/upload.js +127 -4
- package/dist/services/deploy/modern/check.js +16 -28
- package/dist/services/deploy/modern/pipelines/index.js +1 -3
- package/dist/services/deploy/modern/protocol.js +0 -7
- package/dist/services/deploy/modern/run.js +4 -10
- package/dist/services/deploy/modern/template-key-map.js +0 -4
- package/dist/utils/http.js +1 -1
- package/package.json +1 -1
- package/dist/api/comment/api.js +0 -24
- package/dist/api/comment/index.js +0 -6
- package/dist/api/comment/types.js +0 -6
- package/dist/cli/commands/comment/index.js +0 -55
- package/dist/cli/commands/registry/index.js +0 -114
- package/dist/cli/handlers/comment/index.js +0 -7
- package/dist/cli/handlers/comment/list.js +0 -132
- package/dist/cli/handlers/comment/resolve.js +0 -44
- package/dist/cli/handlers/deploy/patch.js +0 -17
- package/dist/cli/handlers/registry/add.js +0 -97
- package/dist/cli/handlers/registry/index.js +0 -7
- package/dist/cli/handlers/registry/list.js +0 -48
- package/dist/cli/handlers/registry/shared.js +0 -25
- package/dist/services/deploy/modern/atoms/design-build.js +0 -49
- package/dist/services/deploy/modern/atoms/design-upload.js +0 -74
- package/dist/services/deploy/modern/atoms/tosutil.js +0 -246
- package/dist/services/deploy/modern/patch/actions.js +0 -61
- package/dist/services/deploy/modern/patch/content.js +0 -18
- package/dist/services/deploy/modern/patch/index.js +0 -46
- package/dist/services/deploy/modern/patch/routes.js +0 -37
- package/dist/services/deploy/modern/patch/source-scan.js +0 -58
- package/dist/services/deploy/modern/pipelines/design-local.js +0 -56
- package/dist/services/registry/index.js +0 -293
|
@@ -5,13 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.uploadArtifacts = uploadArtifacts;
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
8
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const node_child_process_1 = require("node:child_process");
|
|
9
11
|
const index_1 = require("../../../../api/deploy/index");
|
|
10
12
|
const error_1 = require("../../../../utils/error");
|
|
11
13
|
const logger_1 = require("../../../../utils/logger");
|
|
12
14
|
const constants_1 = require("../constants");
|
|
13
15
|
const protocol_1 = require("../protocol");
|
|
14
|
-
const tosutil_1 = require("./tosutil");
|
|
15
16
|
const UPLOAD_PLAN = [
|
|
16
17
|
{
|
|
17
18
|
kind: 'tos',
|
|
@@ -31,6 +32,28 @@ const UPLOAD_PLAN = [
|
|
|
31
32
|
dataKey: protocol_1.DataKey.OUTPUT_STATIC_PAAS_STORAGE_CREDENTIAL,
|
|
32
33
|
},
|
|
33
34
|
];
|
|
35
|
+
function resolveTosutilPath() {
|
|
36
|
+
try {
|
|
37
|
+
const resolved = (0, node_child_process_1.execFileSync)('which', ['tosutil'], { encoding: 'utf-8' }).trim();
|
|
38
|
+
if (resolved)
|
|
39
|
+
return resolved;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
/* fallthrough */
|
|
43
|
+
}
|
|
44
|
+
throw new error_1.AppError('DEPLOY_TOSUTIL_MISSING', 'tosutil is not installed or not in PATH. modern deploy requires sandbox preinstalled tosutil.');
|
|
45
|
+
}
|
|
46
|
+
function tosutilUploadFromTos(cred) {
|
|
47
|
+
return {
|
|
48
|
+
accessKeyID: cred.accessKeyID,
|
|
49
|
+
secretAccessKey: cred.secretAccessKey,
|
|
50
|
+
sessionToken: cred.sessionToken,
|
|
51
|
+
endpoint: cred.endpoint,
|
|
52
|
+
region: cred.region,
|
|
53
|
+
bucket: cred.bucket,
|
|
54
|
+
prefix: cred.prefix,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
34
57
|
function tosutilUploadFromPaasStorage(cred, dataKey) {
|
|
35
58
|
const { bucket, prefix } = (0, protocol_1.parseTosUploadPrefix)(cred.uploadPrefix, dataKey);
|
|
36
59
|
return {
|
|
@@ -43,6 +66,106 @@ function tosutilUploadFromPaasStorage(cred, dataKey) {
|
|
|
43
66
|
prefix,
|
|
44
67
|
};
|
|
45
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* 写一个 tosutil 临时 config 文件,注入 STS 凭证 + endpoint + region。
|
|
71
|
+
* 返回 config 路径,调用方负责清理。
|
|
72
|
+
*/
|
|
73
|
+
function writeTosutilConfig(tosutilPath, cred, label) {
|
|
74
|
+
const confPath = node_path_1.default.join(node_os_1.default.tmpdir(), `.tosutilconfig-miaoda-${label}-${String(process.pid)}-${String(Date.now())}`);
|
|
75
|
+
node_fs_1.default.writeFileSync(confPath, '');
|
|
76
|
+
(0, node_child_process_1.execFileSync)(tosutilPath, [
|
|
77
|
+
'config',
|
|
78
|
+
'-conf',
|
|
79
|
+
confPath,
|
|
80
|
+
'-e',
|
|
81
|
+
cred.endpoint,
|
|
82
|
+
'-i',
|
|
83
|
+
cred.accessKeyID,
|
|
84
|
+
'-k',
|
|
85
|
+
cred.secretAccessKey,
|
|
86
|
+
'-t',
|
|
87
|
+
cred.sessionToken,
|
|
88
|
+
'-re',
|
|
89
|
+
cred.region,
|
|
90
|
+
], { stdio: 'pipe' });
|
|
91
|
+
return confPath;
|
|
92
|
+
}
|
|
93
|
+
/** 把 tosutil 进程的输出按行回放到 stderr,便于线上排查(沙箱里无法 attach 进程)。 */
|
|
94
|
+
function streamTosutilOutput(output) {
|
|
95
|
+
if (!output)
|
|
96
|
+
return;
|
|
97
|
+
for (const line of output.split('\n')) {
|
|
98
|
+
if (line.length === 0)
|
|
99
|
+
continue;
|
|
100
|
+
process.stderr.write(`[tosutil] ${line}\n`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function normalizeTosDest(bucket, prefix) {
|
|
104
|
+
const bucketPart = bucket.startsWith('tos://') ? bucket : `tos://${bucket}`;
|
|
105
|
+
const normalized = prefix.replace(/^\/+/, '');
|
|
106
|
+
return `${bucketPart.replace(/\/+$/, '')}/${normalized}`;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 用 tosutil 把目录批量上传到 tos://bucket/prefix(STS 凭证从 config 文件读取)。
|
|
110
|
+
*/
|
|
111
|
+
function uploadDirWithCredential(tosutilPath, sourceDir, cred, label) {
|
|
112
|
+
const entries = node_fs_1.default.readdirSync(sourceDir);
|
|
113
|
+
if (entries.length === 0) {
|
|
114
|
+
(0, logger_1.debug)(`upload: skip empty dir ${sourceDir}`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const dest = normalizeTosDest(cred.bucket, cred.prefix);
|
|
118
|
+
(0, logger_1.debug)(`upload: ${sourceDir} -> ${dest} (${String(entries.length)} entries)`);
|
|
119
|
+
const confPath = writeTosutilConfig(tosutilPath, cred, label);
|
|
120
|
+
let output;
|
|
121
|
+
try {
|
|
122
|
+
output = (0, node_child_process_1.execFileSync)(tosutilPath, [
|
|
123
|
+
'cp',
|
|
124
|
+
sourceDir,
|
|
125
|
+
dest,
|
|
126
|
+
'-r',
|
|
127
|
+
'-flat',
|
|
128
|
+
'-j',
|
|
129
|
+
'5',
|
|
130
|
+
'-p',
|
|
131
|
+
'3',
|
|
132
|
+
'-ps',
|
|
133
|
+
'10485760',
|
|
134
|
+
'-f',
|
|
135
|
+
'-conf',
|
|
136
|
+
confPath,
|
|
137
|
+
], { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
|
|
138
|
+
streamTosutilOutput(output);
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
const e = err;
|
|
142
|
+
const stderr = (e.stderr ?? '').trim();
|
|
143
|
+
const stdout = (e.stdout ?? '').trim();
|
|
144
|
+
streamTosutilOutput(stdout);
|
|
145
|
+
streamTosutilOutput(stderr);
|
|
146
|
+
throw new error_1.AppError('DEPLOY_UPLOAD_FAILED', `tosutil cp exited with status ${String(e.status ?? -1)} for ${sourceDir}\n` +
|
|
147
|
+
` stderr: ${stderr || '(empty)'}\n` +
|
|
148
|
+
` stdout: ${stdout.slice(0, 500) || '(empty)'}`);
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
try {
|
|
152
|
+
node_fs_1.default.unlinkSync(confPath);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
/* ignore */
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const succeedMatch = /Succeed count is:\s*(\d+)/.exec(output);
|
|
159
|
+
const failedMatch = /Failed count is:\s*(\d+)/.exec(output);
|
|
160
|
+
const succeedCount = succeedMatch ? Number.parseInt(succeedMatch[1], 10) : 0;
|
|
161
|
+
const failedCount = failedMatch ? Number.parseInt(failedMatch[1], 10) : 0;
|
|
162
|
+
if (failedCount > 0) {
|
|
163
|
+
throw new error_1.AppError('DEPLOY_UPLOAD_FAILED', `Upload failed: ${String(failedCount)} files failed, ${String(succeedCount)} succeeded. source=${sourceDir}`);
|
|
164
|
+
}
|
|
165
|
+
if (succeedCount === 0) {
|
|
166
|
+
throw new error_1.AppError('DEPLOY_UPLOAD_EMPTY', `Upload failed: 0 files uploaded. source=${sourceDir}. Check tosutil credentials and bucket permissions.`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
46
169
|
function uploadTosTarget(tosutilPath, target, localPath, data) {
|
|
47
170
|
const credRaw = target.required
|
|
48
171
|
? (0, protocol_1.requireDataKey)(data, target.dataKey)
|
|
@@ -53,7 +176,7 @@ function uploadTosTarget(tosutilPath, target, localPath, data) {
|
|
|
53
176
|
}
|
|
54
177
|
const cred = (0, protocol_1.parseTosUploadCredential)(credRaw, target.dataKey);
|
|
55
178
|
(0, logger_1.log)('deploy', `Uploading ${target.dir}...`);
|
|
56
|
-
|
|
179
|
+
uploadDirWithCredential(tosutilPath, localPath, tosutilUploadFromTos(cred), target.dir);
|
|
57
180
|
return true;
|
|
58
181
|
}
|
|
59
182
|
function uploadPaasStorageTarget(tosutilPath, target, localPath, data) {
|
|
@@ -65,7 +188,7 @@ function uploadPaasStorageTarget(tosutilPath, target, localPath, data) {
|
|
|
65
188
|
}
|
|
66
189
|
const cred = (0, protocol_1.parsePaasStorageCredential)((0, protocol_1.requireDataKey)(data, target.dataKey), target.dataKey);
|
|
67
190
|
(0, logger_1.log)('deploy', `Uploading ${target.dir}...`);
|
|
68
|
-
|
|
191
|
+
uploadDirWithCredential(tosutilPath, localPath, tosutilUploadFromPaasStorage(cred, target.dataKey), target.dir);
|
|
69
192
|
return cred;
|
|
70
193
|
}
|
|
71
194
|
/**
|
|
@@ -79,7 +202,7 @@ function uploadPaasStorageTarget(tosutilPath, target, localPath, data) {
|
|
|
79
202
|
* 目录不存在的可选项跳过;output 不存在或凭证缺失抛错。
|
|
80
203
|
*/
|
|
81
204
|
async function uploadArtifacts(opts) {
|
|
82
|
-
const tosutilPath =
|
|
205
|
+
const tosutilPath = resolveTosutilPath();
|
|
83
206
|
const distDir = node_path_1.default.join(opts.projectDir, constants_1.DIST_DIR);
|
|
84
207
|
const outcome = { uploaded: 0 };
|
|
85
208
|
for (const target of UPLOAD_PLAN) {
|
|
@@ -7,20 +7,16 @@ exports.runDeployChecks = runDeployChecks;
|
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
9
|
const error_1 = require("../../../utils/error");
|
|
10
|
-
const template_key_map_1 = require("./template-key-map");
|
|
11
10
|
/**
|
|
12
11
|
* 项目级 deploy 前置检查:node_modules / .spark/meta.json / package.json.scripts.build。
|
|
13
12
|
* 任一 error 级别失败抛 AppError,附错误码 DEPLOY_PROJECT_CHECK_FAILED。
|
|
14
|
-
*
|
|
15
|
-
* design buildless 链路(design_local_deploy,如 design-html)的 build 直接拷源码 + 生成
|
|
16
|
-
* routes.json(见 atoms/design-build.ts),不跑 `npm run build`、不读 package.json、不依赖
|
|
17
|
-
* node_modules,因此对其跳过 node_modules / package.json / build 脚本三项检查,只保留
|
|
18
|
-
* meta.json + stack 校验。
|
|
19
13
|
*/
|
|
20
14
|
function runDeployChecks(projectDir) {
|
|
21
15
|
const issues = [];
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const nodeModules = node_path_1.default.join(projectDir, 'node_modules');
|
|
17
|
+
if (!node_fs_1.default.existsSync(nodeModules)) {
|
|
18
|
+
issues.push('node_modules not found. Run `npm install` (or equivalent) first.');
|
|
19
|
+
}
|
|
24
20
|
const metaPath = node_path_1.default.join(projectDir, '.spark', 'meta.json');
|
|
25
21
|
if (!node_fs_1.default.existsSync(metaPath)) {
|
|
26
22
|
issues.push('.spark/meta.json not found. Run `miaoda app init` first.');
|
|
@@ -28,7 +24,6 @@ function runDeployChecks(projectDir) {
|
|
|
28
24
|
else {
|
|
29
25
|
try {
|
|
30
26
|
const meta = JSON.parse(node_fs_1.default.readFileSync(metaPath, 'utf-8'));
|
|
31
|
-
stack = meta.stack;
|
|
32
27
|
if (!meta.stack) {
|
|
33
28
|
issues.push('.spark/meta.json missing fields: stack');
|
|
34
29
|
}
|
|
@@ -37,27 +32,20 @@ function runDeployChecks(projectDir) {
|
|
|
37
32
|
issues.push('.spark/meta.json is not valid JSON.');
|
|
38
33
|
}
|
|
39
34
|
}
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
try {
|
|
52
|
-
const pkg = JSON.parse(node_fs_1.default.readFileSync(pkgPath, 'utf-8'));
|
|
53
|
-
if (!pkg.scripts?.build) {
|
|
54
|
-
issues.push('package.json missing "build" script.');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
issues.push('package.json is not valid JSON.');
|
|
35
|
+
const pkgPath = node_path_1.default.join(projectDir, 'package.json');
|
|
36
|
+
if (!node_fs_1.default.existsSync(pkgPath)) {
|
|
37
|
+
issues.push('package.json not found.');
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
try {
|
|
41
|
+
const pkg = JSON.parse(node_fs_1.default.readFileSync(pkgPath, 'utf-8'));
|
|
42
|
+
if (!pkg.scripts?.build) {
|
|
43
|
+
issues.push('package.json missing "build" script.');
|
|
59
44
|
}
|
|
60
45
|
}
|
|
46
|
+
catch {
|
|
47
|
+
issues.push('package.json is not valid JSON.');
|
|
48
|
+
}
|
|
61
49
|
}
|
|
62
50
|
if (issues.length > 0) {
|
|
63
51
|
throw new error_1.AppError('DEPLOY_PROJECT_CHECK_FAILED', `Project check failed:\n${issues.map((i) => ` - ${i}`).join('\n')}`);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.localBuildLocalPublishPipeline = void 0;
|
|
4
4
|
var local_1 = require("./local");
|
|
5
5
|
Object.defineProperty(exports, "localBuildLocalPublishPipeline", { enumerable: true, get: function () { return local_1.localBuildLocalPublishPipeline; } });
|
|
6
|
-
var design_local_1 = require("./design-local");
|
|
7
|
-
Object.defineProperty(exports, "designLocalPublishPipeline", { enumerable: true, get: function () { return design_local_1.designLocalPublishPipeline; } });
|
|
@@ -33,13 +33,6 @@ exports.DataKey = {
|
|
|
33
33
|
// downloadURLPrefix 替代原 static_cdn_prefix 注入 build env。
|
|
34
34
|
/** dist/output_static 上传凭证(仅当目录存在时使用) */
|
|
35
35
|
OUTPUT_STATIC_PAAS_STORAGE_CREDENTIAL: 'output_static_paas_storage_credential',
|
|
36
|
-
// ── design 部署专用(design_local_deploy) ──
|
|
37
|
-
/** 覆盖整个 {app_id} 文件夹的上传凭证(形态同 TosUploadCredential) */
|
|
38
|
-
OUTPUT_ALL_TOS_UPLOAD_CREDENTIAL: 'output_all_tos_upload_credential',
|
|
39
|
-
/** version/备份份真实路径(后端已替换 {app_id}/{version}) */
|
|
40
|
-
OUTPUT_BACKUP_PATH: 'output_backup_path',
|
|
41
|
-
/** latest 份真实路径(后端已替换 {app_id}/latest) */
|
|
42
|
-
OUTPUT_LATEST_PATH: 'output_latest_path',
|
|
43
36
|
};
|
|
44
37
|
/** 取必传 key,缺失抛 AppError(带 key 名,便于后端 tcc 配置排查) */
|
|
45
38
|
function requireDataKey(data, key) {
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// modern deploy 主入口(dispatch 层)。
|
|
3
3
|
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// pipeline 之间彼此独立、不共享中间状态。
|
|
4
|
+
// 当前阶段(Scope A)只接入"本地构建 + 本地部署"一条 pipeline;
|
|
5
|
+
// 后续接入"本地构建 + 远端部署 / 远端构建 + 远端部署"时,在此处按 template_key
|
|
6
|
+
// 或显式 flag 选不同 pipeline。pipeline 之间彼此独立、不共享中间状态。
|
|
8
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
8
|
exports.runModernDeploy = runModernDeploy;
|
|
10
|
-
const spark_meta_1 = require("../../../utils/spark-meta");
|
|
11
|
-
const template_key_map_1 = require("./template-key-map");
|
|
12
9
|
const index_1 = require("./pipelines/index");
|
|
13
10
|
async function runModernDeploy(opts) {
|
|
14
|
-
|
|
15
|
-
if ((0, template_key_map_1.resolveTemplateKey)(stack) === template_key_map_1.DESIGN_LOCAL_DEPLOY) {
|
|
16
|
-
return (0, index_1.designLocalPublishPipeline)(opts);
|
|
17
|
-
}
|
|
11
|
+
// 暂只支持本地构建 + 本地部署
|
|
18
12
|
return (0, index_1.localBuildLocalPublishPipeline)(opts);
|
|
19
13
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DESIGN_LOCAL_DEPLOY = void 0;
|
|
4
3
|
exports.resolveTemplateKey = resolveTemplateKey;
|
|
5
4
|
/**
|
|
6
5
|
* 本地 stack 短名 → 后端发布模板 key 的映射。
|
|
@@ -11,12 +10,9 @@ exports.resolveTemplateKey = resolveTemplateKey;
|
|
|
11
10
|
* 未来出现需要走别的 templateKey 的 stack,再在表里加一行覆盖默认。
|
|
12
11
|
*/
|
|
13
12
|
const DEFAULT_TEMPLATE_KEY = 'client_local_deploy';
|
|
14
|
-
/** design 部署 templateKey(run.ts 据此分流到 design pipeline) */
|
|
15
|
-
exports.DESIGN_LOCAL_DEPLOY = 'design_local_deploy';
|
|
16
13
|
const TEMPLATE_KEY_MAP = {
|
|
17
14
|
'vite-react': DEFAULT_TEMPLATE_KEY,
|
|
18
15
|
html: DEFAULT_TEMPLATE_KEY,
|
|
19
|
-
'design-html': exports.DESIGN_LOCAL_DEPLOY,
|
|
20
16
|
};
|
|
21
17
|
/**
|
|
22
18
|
* 把本地 stack 短名映射到后端 templateKey;未配置的 stack 走默认 client_local_deploy。
|
package/dist/utils/http.js
CHANGED
|
@@ -64,7 +64,7 @@ function createClient(opts) {
|
|
|
64
64
|
* 默认灰度泳道。当前 miaoda CLI 接入的新接口(modern deploy 等)只在该泳道生效,
|
|
65
65
|
* 缺省走这个。MIAODA_CANARY_HEADER 可显式覆盖;设为空字符串则去掉头。
|
|
66
66
|
*/
|
|
67
|
-
const DEFAULT_CANARY_HEADER = '
|
|
67
|
+
const DEFAULT_CANARY_HEADER = 'boe_miaoda_doubao';
|
|
68
68
|
/**
|
|
69
69
|
* 注入 x-tt-env 小流量头:env 显式设值 > DEFAULT_CANARY_HEADER。
|
|
70
70
|
*
|
package/package.json
CHANGED
package/dist/api/comment/api.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getComments = getComments;
|
|
4
|
-
exports.resolveComment = resolveComment;
|
|
5
|
-
const http_1 = require("../../utils/http");
|
|
6
|
-
/**
|
|
7
|
-
* 评论接口走管理端 inner-api(getHttpClient + 小写 status_code 信封),与 app / deploy /
|
|
8
|
-
* observability 等域一致:统一的 verbose 请求/响应日志、错误映射、信封解析,不再域内自实现。
|
|
9
|
-
*/
|
|
10
|
-
/** GET /api/v1/studio/innerapi/apps/:appID/comments — 获取应用评论列表 */
|
|
11
|
-
async function getComments(appID, onlyUnresolved = false) {
|
|
12
|
-
let url = `/api/v1/studio/innerapi/apps/${encodeURIComponent(appID)}/comments`;
|
|
13
|
-
if (onlyUnresolved)
|
|
14
|
-
url += '?onlyUnresolved=true';
|
|
15
|
-
const body = await (0, http_1.getInnerApi)(url, {
|
|
16
|
-
errPrefix: 'Failed to list comments',
|
|
17
|
-
});
|
|
18
|
-
return body.items ?? [];
|
|
19
|
-
}
|
|
20
|
-
/** POST /api/v1/studio/innerapi/apps/:appID/comments/:commentID/resolve — 解决评论 */
|
|
21
|
-
async function resolveComment(appID, commentID) {
|
|
22
|
-
const url = `/api/v1/studio/innerapi/apps/${encodeURIComponent(appID)}/comments/${encodeURIComponent(commentID)}/resolve`;
|
|
23
|
-
await (0, http_1.postInnerApi)(url, undefined, { errPrefix: 'Failed to resolve comment' });
|
|
24
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveComment = exports.getComments = void 0;
|
|
4
|
-
var api_1 = require("./api");
|
|
5
|
-
Object.defineProperty(exports, "getComments", { enumerable: true, get: function () { return api_1.getComments; } });
|
|
6
|
-
Object.defineProperty(exports, "resolveComment", { enumerable: true, get: function () { return api_1.resolveComment; } });
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.registerCommentCommands = registerCommentCommands;
|
|
4
|
-
const shared_1 = require("../../../cli/commands/shared");
|
|
5
|
-
const index_1 = require("../../../cli/handlers/comment/index");
|
|
6
|
-
function registerCommentCommands(program) {
|
|
7
|
-
const commentCmd = program
|
|
8
|
-
.command('comment')
|
|
9
|
-
.description('应用评论:查看评论列表、解决评论')
|
|
10
|
-
.usage('<command> [flags]');
|
|
11
|
-
commentCmd.action(() => {
|
|
12
|
-
commentCmd.outputHelp();
|
|
13
|
-
});
|
|
14
|
-
commentCmd.addHelpText('after', `
|
|
15
|
-
作用范围
|
|
16
|
-
操作当前应用的评论。应用上下文:--app-id <id> 或环境变量 MIAODA_APP_ID。
|
|
17
|
-
`);
|
|
18
|
-
const listCmd = commentCmd
|
|
19
|
-
.command('list')
|
|
20
|
-
.description('查看应用评论列表')
|
|
21
|
-
.addOption((0, shared_1.appIdOption)().hideHelp())
|
|
22
|
-
.option('--only-unresolved', '仅返回未解决的评论', false)
|
|
23
|
-
.addHelpText('after', `
|
|
24
|
-
JSON 输出
|
|
25
|
-
{"data": [{"comment_id": "...", "content": "...", "user_id": "...",
|
|
26
|
-
"finish": 0, "resolved": false, "create_time": 1700000000}]}
|
|
27
|
-
|
|
28
|
-
示例
|
|
29
|
-
$ miaoda comment list --json
|
|
30
|
-
$ miaoda comment list --only-unresolved --json
|
|
31
|
-
`);
|
|
32
|
-
listCmd.action((0, shared_1.withHelp)(listCmd, async (rawOpts) => {
|
|
33
|
-
(0, shared_1.rejectCliOverride)(listCmd, 'appId');
|
|
34
|
-
await (0, index_1.handleCommentList)({
|
|
35
|
-
appId: rawOpts.appId,
|
|
36
|
-
onlyUnresolved: rawOpts.onlyUnresolved,
|
|
37
|
-
});
|
|
38
|
-
}));
|
|
39
|
-
const resolveCmd = commentCmd
|
|
40
|
-
.command('resolve')
|
|
41
|
-
.description('把一条评论标记为已解决')
|
|
42
|
-
.argument('<commentID>', '待解决的评论 ID')
|
|
43
|
-
.addOption((0, shared_1.appIdOption)().hideHelp())
|
|
44
|
-
.addHelpText('after', `
|
|
45
|
-
JSON 输出
|
|
46
|
-
{"data": {"comment_id": "...", "resolved": true}}
|
|
47
|
-
|
|
48
|
-
示例
|
|
49
|
-
$ miaoda comment resolve 1703677660120110076 --json
|
|
50
|
-
`);
|
|
51
|
-
resolveCmd.action((0, shared_1.withHelp)(resolveCmd, async (commentId, rawOpts) => {
|
|
52
|
-
(0, shared_1.rejectCliOverride)(resolveCmd, 'appId');
|
|
53
|
-
await (0, index_1.handleCommentResolve)(commentId, { appId: rawOpts.appId });
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
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
|
-
输出(pretty,默认)
|
|
84
|
-
registry@<ver>
|
|
85
|
-
added: <落地 basename 逗号列表> # 含 Depends 闭包全部落地文件
|
|
86
|
-
skipped: <逗号列表> # 仅有跳过时出现
|
|
87
|
-
dry-run: true (no files written) # 仅 --dry-run 时出现
|
|
88
|
-
|
|
89
|
-
# <请求条目落地 basename>
|
|
90
|
-
<该条目 USAGE 块原文> # 只列你请求的条目,依赖不占 usage 位
|
|
91
|
-
|
|
92
|
-
JSON 输出(--json)
|
|
93
|
-
{"data": {"registryVersion": "...", "added": [...], "skipped": [...], "dryRun": false,
|
|
94
|
-
"entries": [{"name": "...", "file": "<来源 relPath>", "dest": "<落地 basename>",
|
|
95
|
-
"status": "added|skipped", "usage": "<USAGE 块原文>", "dependsOn": [...]}, ...]}}
|
|
96
|
-
(added / skipped 覆盖依赖闭包全部落地文件;entries 只列**你请求的条目**
|
|
97
|
-
(不含被 Depends 传递拉入的依赖),逐条给 usage / dependsOn,add 完直接读用法。
|
|
98
|
-
请求的条目即使已存在被 skip 也回带 usage,status 标 added / skipped)
|
|
99
|
-
|
|
100
|
-
示例
|
|
101
|
-
$ miaoda registry add deck-slide
|
|
102
|
-
$ miaoda registry add deck-slide theme --dry-run
|
|
103
|
-
$ miaoda registry add deck-slide --overwrite --json
|
|
104
|
-
`);
|
|
105
|
-
cmd.action((0, shared_1.withHelp)(cmd, async (names, rawOpts) => {
|
|
106
|
-
await (0, index_1.handleRegistryAdd)({
|
|
107
|
-
names,
|
|
108
|
-
dir: rawOpts.dir,
|
|
109
|
-
version: rawOpts.version,
|
|
110
|
-
overwrite: rawOpts.overwrite,
|
|
111
|
-
dryRun: rawOpts.dryRun,
|
|
112
|
-
});
|
|
113
|
-
}));
|
|
114
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handleCommentResolve = exports.handleCommentList = void 0;
|
|
4
|
-
var list_1 = require("./list");
|
|
5
|
-
Object.defineProperty(exports, "handleCommentList", { enumerable: true, get: function () { return list_1.handleCommentList; } });
|
|
6
|
-
var resolve_1 = require("./resolve");
|
|
7
|
-
Object.defineProperty(exports, "handleCommentResolve", { enumerable: true, get: function () { return resolve_1.handleCommentResolve; } });
|