@lark-apaas/miaoda-cli 0.1.2-alpha.ccfdc05 → 0.1.2-alpha.d0d2ae1

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.
Files changed (58) hide show
  1. package/README.md +7 -8
  2. package/dist/api/db/api.js +250 -6
  3. package/dist/api/db/client.js +36 -0
  4. package/dist/api/db/index.js +9 -1
  5. package/dist/api/file/api.js +15 -0
  6. package/dist/api/file/index.js +2 -1
  7. package/dist/api/index.js +1 -7
  8. package/dist/cli/commands/db/index.js +137 -0
  9. package/dist/cli/commands/file/index.js +7 -0
  10. package/dist/cli/commands/index.js +6 -10
  11. package/dist/cli/commands/shared.js +3 -81
  12. package/dist/cli/handlers/db/audit.js +285 -0
  13. package/dist/cli/handlers/db/changelog.js +117 -0
  14. package/dist/cli/handlers/db/data.js +1 -1
  15. package/dist/cli/handlers/db/index.js +17 -1
  16. package/dist/cli/handlers/db/migration.js +213 -0
  17. package/dist/cli/handlers/{app/update.js → db/quota.js} +29 -20
  18. package/dist/cli/handlers/db/recovery.js +228 -0
  19. package/dist/cli/handlers/file/index.js +3 -1
  20. package/dist/cli/handlers/{deploy/error-log.js → file/quota.js} +27 -22
  21. package/dist/main.js +7 -27
  22. package/dist/utils/http.js +0 -118
  23. package/dist/utils/index.js +1 -13
  24. package/dist/utils/output.js +29 -338
  25. package/package.json +5 -7
  26. package/dist/api/app/api.js +0 -25
  27. package/dist/api/app/index.js +0 -15
  28. package/dist/api/app/schemas.js +0 -79
  29. package/dist/api/app/types.js +0 -58
  30. package/dist/api/deploy/api.js +0 -60
  31. package/dist/api/deploy/index.js +0 -16
  32. package/dist/api/deploy/schemas.js +0 -103
  33. package/dist/api/deploy/types.js +0 -22
  34. package/dist/api/observability/api.js +0 -52
  35. package/dist/api/observability/index.js +0 -16
  36. package/dist/api/observability/schemas.js +0 -60
  37. package/dist/api/observability/types.js +0 -27
  38. package/dist/cli/commands/app/index.js +0 -62
  39. package/dist/cli/commands/deploy/index.js +0 -145
  40. package/dist/cli/commands/observability/index.js +0 -237
  41. package/dist/cli/handlers/app/get.js +0 -48
  42. package/dist/cli/handlers/app/index.js +0 -7
  43. package/dist/cli/handlers/deploy/deploy.js +0 -83
  44. package/dist/cli/handlers/deploy/get.js +0 -70
  45. package/dist/cli/handlers/deploy/helpers.js +0 -41
  46. package/dist/cli/handlers/deploy/history.js +0 -70
  47. package/dist/cli/handlers/deploy/index.js +0 -14
  48. package/dist/cli/handlers/deploy/polling.js +0 -139
  49. package/dist/cli/handlers/observability/analytics.js +0 -212
  50. package/dist/cli/handlers/observability/helpers.js +0 -66
  51. package/dist/cli/handlers/observability/index.js +0 -12
  52. package/dist/cli/handlers/observability/log.js +0 -94
  53. package/dist/cli/handlers/observability/metric.js +0 -208
  54. package/dist/cli/handlers/observability/trace.js +0 -102
  55. package/dist/cli/version.js +0 -15
  56. package/dist/utils/devops-error.js +0 -28
  57. package/dist/utils/git.js +0 -29
  58. package/dist/utils/time.js +0 -203
@@ -1,145 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerDeployCommands = registerDeployCommands;
4
- const commander_1 = require("commander");
5
- const shared_1 = require("../../../cli/commands/shared");
6
- const index_1 = require("../../../cli/handlers/deploy/index");
7
- const COMMON_TIME_HELP = `
8
- 时间格式:
9
- - 相对时间:30m(30 分钟前)、1h、2d、1w
10
- - 日期:2026-04-01(本地时区当日 00:00:00)
11
- - 本地日期+时间:2026-04-01T10:00:00(按本地时区,T 分隔)
12
- - 带时区 ISO:2026-04-01T10:00:00Z(UTC)或 2026-04-01T10:00:00+08:00(指定偏移)
13
- 备注:
14
- 1) 不带时区的形式与 pretty 输出闭环(同机器复制粘贴稳定);跨机器请带显式时区。
15
- 2) 必须用 T 分隔日期与时间,禁止空格——shell 会把不带引号的 'YYYY-MM-DD HH:mm:ss' 拆成两个参数。
16
- `;
17
- function registerDeployCommands(program) {
18
- // PRD:`miaoda deploy` 自身即为触发发布;get / history / error-log 是子命令
19
- const deployCmd = program
20
- .command("deploy")
21
- .description("触发发布;支持 --wait 阻塞到终态。子命令:get / history / error-log")
22
- .addOption((0, shared_1.appIdOption)().hideHelp())
23
- .addOption((0, shared_1.branchOption)().hideHelp())
24
- .option("--wait", "阻塞直到流水线终态", false)
25
- .option("--timeout <sec>", "--wait 最长等待秒数(默认 300)", parseTimeout, 300)
26
- .addHelpText("after", `
27
- 部署前置检查(Agent 必须执行)
28
- miaoda deploy 跑的是当前分支的远端 HEAD——本地未 commit / 未 push 的代码不会进发布产物。
29
- 调用前先 \`git status\` + \`git rev-list --count @{u}..HEAD\` 确认;有未提交 / 未推送时:
30
- - 是本次任务的产物 → 先 commit + push 再 deploy
31
- - 不能确定意图 → 用 AskUser 跟用户确认(不要默默继续)
32
-
33
- JSON 输出
34
- 不带 --wait:{"data": {"pipelineTaskID": "..."}}(pipelineTaskID 即 deploy-id)
35
- 带 --wait:data 额外包含 detail(pipeline 终态)
36
-
37
- 示例
38
- $ miaoda deploy
39
- $ miaoda deploy --wait --timeout 600
40
- $ miaoda deploy get 12345
41
- $ miaoda deploy history --status failed
42
- `);
43
- deployCmd.action((0, shared_1.withHelp)(deployCmd, async (rawOpts) => {
44
- (0, shared_1.rejectCliOverride)(deployCmd, "appId", "branch");
45
- await (0, index_1.handleDeploy)({
46
- appId: rawOpts.appId,
47
- branch: rawOpts.branch,
48
- wait: rawOpts.wait,
49
- timeout: rawOpts.timeout,
50
- });
51
- }));
52
- registerDeployGet(deployCmd);
53
- registerDeployHistory(deployCmd);
54
- registerDeployErrorLog(deployCmd);
55
- }
56
- function registerDeployGet(parent) {
57
- const cmd = parent
58
- .command("get")
59
- .description("查看指定发布单的详情")
60
- .argument("<deploy-id>", "发布单 ID")
61
- .addOption((0, shared_1.appIdOption)().hideHelp())
62
- .addHelpText("after", `
63
- JSON 输出
64
- {"data": {"ID": ..., "status": ..., "creator": "...", "createdAt": ..., "updatedAt": ..., ...}, "next_cursor": null, "has_more": false}
65
- ID 即 deploy-id(== pipelineTaskID)
66
-
67
- 示例
68
- $ miaoda deploy get 12345
69
- `);
70
- cmd.action((0, shared_1.withHelp)(cmd, async (deployId, rawOpts) => {
71
- (0, shared_1.rejectCliOverride)(cmd, "appId");
72
- await (0, index_1.handleDeployGet)({
73
- deployId,
74
- appId: rawOpts.appId,
75
- });
76
- }));
77
- }
78
- function registerDeployHistory(parent) {
79
- const cmd = parent
80
- .command("history")
81
- .description("查询发布历史(按时间倒序,分页)")
82
- .addOption((0, shared_1.appIdOption)().hideHelp())
83
- .addOption(new commander_1.Option("--status <status>", "状态过滤(pipeline 节点状态,大小写不敏感)")
84
- .choices(["todo", "running", "success", "failed", "canceled", "hold_on"])
85
- .argParser((0, shared_1.caseInsensitiveChoice)(["todo", "running", "success", "failed", "canceled", "hold_on"])))
86
- .option("--since <time>", "起始时间")
87
- .option("--until <time>", "截止时间")
88
- .option("--limit <n>", "返回条数上限(1~100)", parseLimit, 50)
89
- .option("--cursor <token>", "下一页游标")
90
- .addHelpText("after", `${COMMON_TIME_HELP}
91
- JSON 输出
92
- {"data": [...], "next_cursor": "...", "has_more": true|false}
93
-
94
- 示例
95
- $ miaoda deploy history --status failed
96
- $ miaoda deploy history --since 7d
97
- `);
98
- cmd.action((0, shared_1.withHelp)(cmd, async (rawOpts) => {
99
- (0, shared_1.validateTimeOptions)(rawOpts, "since", "until");
100
- (0, shared_1.rejectCliOverride)(cmd, "appId");
101
- await (0, index_1.handleDeployHistory)({
102
- appId: rawOpts.appId,
103
- status: rawOpts.status,
104
- since: rawOpts.since,
105
- until: rawOpts.until,
106
- limit: rawOpts.limit,
107
- cursor: rawOpts.cursor,
108
- });
109
- }));
110
- }
111
- function registerDeployErrorLog(parent) {
112
- const cmd = parent
113
- .command("error-log")
114
- .description("查询指定发布的错误日志")
115
- .argument("<deploy-id>", "发布单 ID")
116
- .addOption((0, shared_1.appIdOption)().hideHelp())
117
- .addHelpText("after", `
118
- JSON 输出
119
- {"data": [{"jobID": ..., "componentName": ..., "errorMsg": ...}], "next_cursor": null, "has_more": false}
120
-
121
- 示例
122
- $ miaoda deploy error-log 12345 --json
123
- `);
124
- cmd.action((0, shared_1.withHelp)(cmd, async (deployId, rawOpts) => {
125
- (0, shared_1.rejectCliOverride)(cmd, "appId");
126
- await (0, index_1.handleDeployErrorLog)({
127
- deployId,
128
- appId: rawOpts.appId,
129
- });
130
- }));
131
- }
132
- function parseLimit(value) {
133
- const n = Number(value);
134
- if (!Number.isFinite(n)) {
135
- throw new Error(`--limit 必须是数字,收到 '${value}'`);
136
- }
137
- return n;
138
- }
139
- function parseTimeout(value) {
140
- const n = Number(value);
141
- if (!Number.isFinite(n) || n <= 0) {
142
- throw new Error(`--timeout 必须是正数,收到 '${value}'`);
143
- }
144
- return n;
145
- }
@@ -1,237 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerObservabilityCommands = registerObservabilityCommands;
4
- const commander_1 = require("commander");
5
- const shared_1 = require("../../../cli/commands/shared");
6
- const index_1 = require("../../../cli/handlers/observability/index");
7
- const COMMON_TIME_HELP = `
8
- 时间格式:
9
- - 相对时间:30m(30 分钟前)、1h、2d、1w
10
- - 日期:2026-04-01(本地时区当日 00:00:00)
11
- - 本地日期+时间:2026-04-01T10:00:00(按本地时区,T 分隔)
12
- - 带时区 ISO:2026-04-01T10:00:00Z(UTC)或 2026-04-01T10:00:00+08:00(指定偏移)
13
- 备注:
14
- 1) 不带时区的形式与 pretty 输出闭环(同机器复制粘贴稳定);跨机器请带显式时区。
15
- 2) 必须用 T 分隔日期与时间,禁止空格——shell 会把不带引号的 'YYYY-MM-DD HH:mm:ss' 拆成两个参数。
16
- `;
17
- function registerObservabilityCommands(program) {
18
- const obCmd = program
19
- .command("observability")
20
- .description("可观测性:查询线上日志、链路、监控指标、运营指标");
21
- obCmd.action(() => {
22
- obCmd.outputHelp();
23
- });
24
- obCmd.addHelpText("after", `
25
- 作用范围
26
- 仅供 Agent 在妙搭沙箱内调用,查询当前应用的线上观测数据。所有命令为只读。
27
- 应用上下文:--app-id <id> 或环境变量 MIAODA_APP_ID。
28
-
29
- 应用环境
30
- 目前只支持线上环境。
31
- `);
32
- registerLog(obCmd);
33
- registerTrace(obCmd);
34
- registerMetric(obCmd);
35
- registerAnalytics(obCmd);
36
- }
37
- // ── log ──
38
- function registerLog(parent) {
39
- const cmd = parent
40
- .command("log")
41
- .description("查询线上运行日志(按时间倒序,分页)")
42
- .addOption((0, shared_1.appIdOption)().hideHelp())
43
- .addOption(new commander_1.Option("--level <level>", "日志级别(大小写不敏感)")
44
- .choices(["DEBUG", "INFO", "WARN", "ERROR"])
45
- .argParser((0, shared_1.caseInsensitiveChoice)(["DEBUG", "INFO", "WARN", "ERROR"])))
46
- .option("--since <time>", "开始时间")
47
- .option("--until <time>", "截止时间")
48
- .option("--trace-id <id>", "按 trace ID 过滤")
49
- .option("--grep <pattern>", "按关键字模糊搜索 body")
50
- .option("--module <name>", "按模块名过滤")
51
- .option("--user-id <user-id>", "按触发用户 ID 过滤")
52
- .option("--page <path>", "按页面路径过滤")
53
- .option("--api <path>", "按接口路径过滤")
54
- .option("--min-duration <ms>", "最小耗时过滤(毫秒)")
55
- .option("--max-duration <ms>", "最大耗时过滤(毫秒)")
56
- .option("--limit <n>", "返回条数上限(1~100)", parseLimit, 50)
57
- .option("--cursor <token>", "下一页游标,从上一次返回的 next_cursor 取值")
58
- .addHelpText("after", `${COMMON_TIME_HELP}
59
- JSON 输出
60
- {"data": [...], "next_cursor": "...", "has_more": true|false}
61
-
62
- 示例
63
- $ miaoda observability log --since 1h --level error --json
64
- $ miaoda observability log --trace-id 140ebb5ac9b... --json
65
- $ miaoda observability log --api /api/orders --min-duration 200 --json
66
- `);
67
- cmd.action((0, shared_1.withHelp)(cmd, async (rawOpts) => {
68
- (0, shared_1.validateTimeOptions)(rawOpts, "since", "until");
69
- (0, shared_1.rejectCliOverride)(cmd, "appId");
70
- await (0, index_1.handleObservabilityLog)({
71
- appId: rawOpts.appId,
72
- level: rawOpts.level,
73
- since: rawOpts.since,
74
- until: rawOpts.until,
75
- traceId: rawOpts.traceId,
76
- grep: rawOpts.grep,
77
- module: rawOpts.module,
78
- userId: rawOpts.userId,
79
- page: rawOpts.page,
80
- api: rawOpts.api,
81
- minDuration: rawOpts.minDuration,
82
- maxDuration: rawOpts.maxDuration,
83
- limit: rawOpts.limit,
84
- cursor: rawOpts.cursor,
85
- });
86
- }));
87
- }
88
- // ── trace ──
89
- function registerTrace(parent) {
90
- const traceCmd = parent.command("trace").description("链路追踪:列表 / 详情");
91
- traceCmd.action(() => {
92
- traceCmd.outputHelp();
93
- });
94
- const listCmd = traceCmd
95
- .command("list")
96
- .description("查询线上链路列表(按链路时间倒序,分页)")
97
- .addOption((0, shared_1.appIdOption)().hideHelp())
98
- .option("--since <time>", "开始时间")
99
- .option("--until <time>", "截止时间")
100
- .option("--trace-id <id>", "按 trace ID 过滤")
101
- .option("--root-span <span-name>", "按入口节点关键词过滤")
102
- .option("--user-id <user-id>", "按触发用户 ID 过滤")
103
- .option("--limit <n>", "返回条数上限(1~100)", parseLimit, 50)
104
- .option("--cursor <token>", "下一页游标")
105
- .addHelpText("after", `${COMMON_TIME_HELP}
106
- JSON 输出
107
- {"data": [...], "next_cursor": "...", "has_more": true|false}
108
-
109
- 示例
110
- $ miaoda observability trace list --since 1h --json
111
- $ miaoda observability trace list --root-span api-gateway --limit 20 --json
112
- `);
113
- listCmd.action((0, shared_1.withHelp)(listCmd, async (rawOpts) => {
114
- (0, shared_1.validateTimeOptions)(rawOpts, "since", "until");
115
- (0, shared_1.rejectCliOverride)(listCmd, "appId");
116
- await (0, index_1.handleObservabilityTraceList)({
117
- appId: rawOpts.appId,
118
- since: rawOpts.since,
119
- until: rawOpts.until,
120
- traceId: rawOpts.traceId,
121
- rootSpan: rawOpts.rootSpan,
122
- userId: rawOpts.userId,
123
- limit: rawOpts.limit,
124
- cursor: rawOpts.cursor,
125
- });
126
- }));
127
- const getCmd = traceCmd
128
- .command("get")
129
- .description("查询指定链路的完整详情")
130
- .argument("<trace-id>", "链路 ID")
131
- .addOption((0, shared_1.appIdOption)().hideHelp())
132
- .option("--with-log-severity-count", "返回每个 Span 各日志级别的数量", false)
133
- .addHelpText("after", `
134
- JSON 输出
135
- {"data": {"spans": [...], "isBreak": false}}
136
-
137
- 示例
138
- $ miaoda observability trace get 140ebb5ac9b55ed50d6ed1090cad4d --json
139
-
140
- # 报错:链路不存在
141
- $ miaoda observability trace get not-exist
142
- Error: Failed to get trace: 500 ...
143
- hint: 检查 trace-id 是否正确,或链路已超出保留时长
144
- `);
145
- getCmd.action((0, shared_1.withHelp)(getCmd, async (traceId, rawOpts) => {
146
- (0, shared_1.rejectCliOverride)(getCmd, "appId");
147
- await (0, index_1.handleObservabilityTraceGet)({
148
- traceId,
149
- appId: rawOpts.appId,
150
- withLogSeverityCount: rawOpts.withLogSeverityCount,
151
- });
152
- }));
153
- }
154
- // ── metric ──
155
- function registerMetric(parent) {
156
- const cmd = parent
157
- .command("metric")
158
- .description("查询监控指标:requests / latency / cpu / memory")
159
- .argument("<metric-name>", "指标名:requests | latency | cpu | memory")
160
- .addOption((0, shared_1.appIdOption)().hideHelp())
161
- .option("--page <path>", "按页面路径过滤(仅对 requests/latency 生效)")
162
- .option("--api <path>", "按接口路径过滤(仅对 requests/latency 生效)")
163
- .option("--series <name>", "过滤图表中的某条线:latency 取 p50/p99;requests 取 total/error;缺省返回所有相关线")
164
- .option("--since <time>", "开始时间")
165
- .option("--until <time>", "截止时间")
166
- .addOption(new commander_1.Option("--down-sample <duration>", "降采样粒度(1m=1分钟 / 1h=1小时 / 1d=1天,大小写不敏感)")
167
- .choices(["1m", "1h", "1d"])
168
- .argParser((0, shared_1.caseInsensitiveChoice)(["1m", "1h", "1d"]))
169
- .default("1m"))
170
- .addHelpText("after", `${COMMON_TIME_HELP}
171
- JSON 输出
172
- {"data": [{"metricName": "...", "dimensions": {...}, "dataPoints": [...]}], "next_cursor": null, "has_more": false}
173
-
174
- 示例
175
- $ miaoda observability metric latency --since 1h --json
176
- $ miaoda observability metric latency --since 1h --series p99 --json
177
- $ miaoda observability metric requests --api /api/users --json
178
- $ miaoda observability metric cpu --since 1d --down-sample 1d --json
179
- `);
180
- cmd.action((0, shared_1.withHelp)(cmd, async (metricName, rawOpts) => {
181
- (0, shared_1.validateTimeOptions)(rawOpts, "since", "until");
182
- (0, shared_1.rejectCliOverride)(cmd, "appId");
183
- await (0, index_1.handleObservabilityMetric)({
184
- metricName,
185
- appId: rawOpts.appId,
186
- page: rawOpts.page,
187
- api: rawOpts.api,
188
- series: rawOpts.series,
189
- since: rawOpts.since,
190
- until: rawOpts.until,
191
- downSample: rawOpts.downSample,
192
- });
193
- }));
194
- }
195
- // ── analytics ──
196
- function registerAnalytics(parent) {
197
- const cmd = parent
198
- .command("analytics")
199
- .description("查询运营指标:users(用户数)/ page-view(页面访问)")
200
- .argument("<analytics-name>", "指标名:users | page-view")
201
- .addOption((0, shared_1.appIdOption)().hideHelp())
202
- .option("--page <path>", "按页面路径过滤(仅对 page-view 生效)")
203
- .option("--series <name>", "过滤图表中的某条线:users 取 active/new/total(兼容 active-users/new-users/total-users);page-view 取 all/desktop/mobile(兼容 all-view/desktop-view/mobile-view)")
204
- .option("--since <time>", "开始时间")
205
- .option("--until <time>", "截止时间")
206
- .option("--granularity <duration>", "时间粒度:day | week | month", "day")
207
- .addHelpText("after", `${COMMON_TIME_HELP}
208
- JSON 输出
209
- {"data": [{"metricType": "...", "points": [{"timestampNs": "...", "value": ..., "dimensions": {...}}]}], "next_cursor": null, "has_more": false}
210
-
211
- 示例
212
- $ miaoda observability analytics users --json # 同时返回 active/new/total 三条线
213
- $ miaoda observability analytics users --series new --since 7d --json
214
- $ miaoda observability analytics page-view --granularity week --json
215
- `);
216
- cmd.action((0, shared_1.withHelp)(cmd, async (analyticsName, rawOpts) => {
217
- (0, shared_1.validateTimeOptions)(rawOpts, "since", "until");
218
- (0, shared_1.rejectCliOverride)(cmd, "appId");
219
- await (0, index_1.handleObservabilityAnalytics)({
220
- analyticsName,
221
- appId: rawOpts.appId,
222
- env: rawOpts.env,
223
- page: rawOpts.page,
224
- series: rawOpts.series,
225
- since: rawOpts.since,
226
- until: rawOpts.until,
227
- granularity: rawOpts.granularity,
228
- });
229
- }));
230
- }
231
- function parseLimit(value) {
232
- const n = Number(value);
233
- if (!Number.isFinite(n)) {
234
- throw new Error(`--limit 必须是数字,收到 '${value}'`);
235
- }
236
- return n;
237
- }
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.handleAppGet = handleAppGet;
37
- const api = __importStar(require("../../../api/index"));
38
- const output_1 = require("../../../utils/output");
39
- const shared_1 = require("../../../cli/commands/shared");
40
- const index_1 = require("../../../api/app/index");
41
- /** miaoda app get [--app-id <id>] */
42
- async function handleAppGet(opts) {
43
- const appID = (0, shared_1.resolveAppId)({ appId: opts.appId });
44
- const resp = await api.app.getAppInfo(appID);
45
- // BAM 在 status_code=0 时 data 字段含 appInfo;不存在则 fallback 空对象
46
- const meta = resp.appInfo?.appMeta ?? {};
47
- (0, output_1.emit)({ data: meta, next_cursor: null, has_more: false }, index_1.appMetaSchema);
48
- }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.handleAppUpdate = exports.handleAppGet = void 0;
4
- var get_1 = require("./get");
5
- Object.defineProperty(exports, "handleAppGet", { enumerable: true, get: function () { return get_1.handleAppGet; } });
6
- var update_1 = require("./update");
7
- Object.defineProperty(exports, "handleAppUpdate", { enumerable: true, get: function () { return update_1.handleAppUpdate; } });
@@ -1,83 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.handleDeploy = handleDeploy;
37
- const api = __importStar(require("../../../api/index"));
38
- const output_1 = require("../../../utils/output");
39
- const shared_1 = require("../../../cli/commands/shared");
40
- const index_1 = require("../../../api/deploy/index");
41
- const polling_1 = require("./polling");
42
- /** miaoda deploy [--branch ...] [--wait] [--timeout 300] */
43
- async function handleDeploy(opts) {
44
- const appID = (0, shared_1.resolveAppId)({ appId: opts.appId });
45
- const resp = await api.deploy.createRelease({ appID, branch: opts.branch });
46
- const pipelineTaskID = resp.pipelineTaskID ?? "";
47
- if (!opts.wait) {
48
- if (!(0, output_1.isJsonMode)()) {
49
- process.stdout.write(`✓ Deployment triggered. (deploy-id: ${pipelineTaskID})\n`);
50
- }
51
- (0, output_1.emit)({
52
- data: { pipelineTaskID },
53
- next_cursor: null,
54
- has_more: false,
55
- });
56
- return;
57
- }
58
- if (!(0, output_1.isJsonMode)()) {
59
- process.stdout.write(`Waiting for deployment to complete... (deploy-id: ${pipelineTaskID})\n`);
60
- }
61
- const detail = await (0, polling_1.waitForPipeline)({
62
- appID,
63
- pipelineTaskID,
64
- timeoutSec: opts.timeout ?? 300,
65
- });
66
- if (!(0, output_1.isJsonMode)()) {
67
- if (detail.status === index_1.NodeStatus.SUCCESS) {
68
- process.stdout.write("✓ 发布成功\n");
69
- }
70
- else if (detail.status === index_1.NodeStatus.FAILED) {
71
- process.stdout.write("✗ 发布失败\n");
72
- process.stdout.write(` hint: Run \`miaoda deploy error-log ${pipelineTaskID}\` to view error logs\n`);
73
- }
74
- else {
75
- process.stdout.write("• 发布已取消\n");
76
- }
77
- }
78
- (0, output_1.emit)({
79
- data: { pipelineTaskID, detail },
80
- next_cursor: null,
81
- has_more: false,
82
- });
83
- }
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.handleDeployGet = handleDeployGet;
37
- const api = __importStar(require("../../../api/index"));
38
- const output_1 = require("../../../utils/output");
39
- const shared_1 = require("../../../cli/commands/shared");
40
- const error_1 = require("../../../utils/error");
41
- const index_1 = require("../../../api/deploy/index");
42
- const helpers_1 = require("./helpers");
43
- /**
44
- * 单页拉取上限:BAM listPipelineInstances 限制 1~500,取 500 让 deploy get
45
- * 在最近 500 条记录里按 ID 命中。
46
- */
47
- const DEPLOY_GET_LOOKUP_LIMIT = 500;
48
- /**
49
- * miaoda deploy get <deploy-id>
50
- *
51
- * BAM 没有 by-ID 的查询接口,复用 listPipelineInstances 在最近窗口里按 ID 筛一条。
52
- * 命中失败时抛 DEPLOY_NOT_FOUND,提示用户用 history 查窗口。
53
- */
54
- async function handleDeployGet(opts) {
55
- if (!opts.deployId)
56
- (0, shared_1.failArgs)("<deploy-id> 必填");
57
- const appID = (0, shared_1.resolveAppId)({ appId: opts.appId });
58
- const deployId = (0, helpers_1.parseDeployId)(opts.deployId);
59
- const resp = await api.deploy.listPipelineInstances({
60
- appID,
61
- limit: DEPLOY_GET_LOOKUP_LIMIT,
62
- });
63
- const instance = resp.instances?.find((it) => Number(it.ID) === deployId);
64
- if (!instance) {
65
- throw new error_1.AppError("DEPLOY_NOT_FOUND", `未在最近 ${String(DEPLOY_GET_LOOKUP_LIMIT)} 条记录中找到 deploy-id=${opts.deployId}`, {
66
- next_actions: ["运行 `miaoda deploy history` 确认 deploy-id 是否在最近窗口内"],
67
- });
68
- }
69
- (0, output_1.emit)({ data: instance, next_cursor: null, has_more: false }, index_1.deployGetSchema);
70
- }
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseStatusFlag = parseStatusFlag;
4
- exports.validateLimit = validateLimit;
5
- exports.parseDeployId = parseDeployId;
6
- const shared_1 = require("../../../cli/commands/shared");
7
- const index_1 = require("../../../api/deploy/index");
8
- /**
9
- * 把 CLI --status 字符串映射成 BAM NodeStatus 数字;非法值抛 ARGS_INVALID。
10
- *
11
- * 历史接口(CliListPipelineInstances)返回 SimpleInstance,状态语义是 pipeline 节点状态,
12
- * 取值 todo / running / success / failed / canceled / hold_on。
13
- */
14
- function parseStatusFlag(text) {
15
- const value = (0, index_1.nodeStatusFromText)(text);
16
- if (value === undefined) {
17
- (0, shared_1.failArgs)(`--status 无效:'${text}'。可选值:todo | running | success | failed | canceled | hold_on`);
18
- }
19
- return value;
20
- }
21
- /** limit/pageSize 校验(API 限制 1~100) */
22
- function validateLimit(limit, defaultLimit = 50) {
23
- const n = Number.isFinite(limit) ? limit : defaultLimit;
24
- if (n <= 0 || n > 100) {
25
- (0, shared_1.failArgs)(`--limit 必须在 1~100 之间,收到 ${String(n)}`);
26
- }
27
- return n;
28
- }
29
- /**
30
- * 把 CLI <deploy-id> 字符串转成 i64 number。
31
- *
32
- * 语义上 deploy-id 即 pipelineTaskID(pipeline 实例 ID);BAM CLIGetReleaseLogs
33
- * IDL 历史命名为 releaseID,但传入的就是这同一个值。
34
- */
35
- function parseDeployId(text) {
36
- const n = Number(text);
37
- if (!Number.isFinite(n) || !/^\d+$/.test(text)) {
38
- (0, shared_1.failArgs)(`<deploy-id> 必须是数字 ID,收到 '${text}'`);
39
- }
40
- return n;
41
- }