@lark-apaas/miaoda-cli 0.1.2-alpha.45db14c → 0.1.2-alpha.4e370b6
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/dist/api/db/api.js +250 -6
- package/dist/api/db/client.js +36 -0
- package/dist/api/db/index.js +9 -1
- package/dist/api/file/api.js +15 -0
- package/dist/api/file/index.js +2 -1
- package/dist/api/index.js +1 -7
- package/dist/cli/commands/db/index.js +137 -0
- package/dist/cli/commands/file/index.js +7 -0
- package/dist/cli/commands/index.js +0 -6
- package/dist/cli/commands/shared.js +3 -61
- package/dist/cli/handlers/db/audit.js +285 -0
- package/dist/cli/handlers/db/changelog.js +117 -0
- package/dist/cli/handlers/db/data.js +1 -1
- package/dist/cli/handlers/db/index.js +17 -1
- package/dist/cli/handlers/db/migration.js +213 -0
- package/dist/cli/handlers/{app/update.js → db/quota.js} +29 -20
- package/dist/cli/handlers/db/recovery.js +188 -0
- package/dist/cli/handlers/file/index.js +3 -1
- package/dist/cli/handlers/{deploy/error-log.js → file/quota.js} +27 -22
- package/dist/utils/http.js +0 -86
- package/dist/utils/index.js +1 -13
- package/dist/utils/output.js +29 -338
- package/package.json +5 -7
- package/dist/api/app/api.js +0 -25
- package/dist/api/app/index.js +0 -15
- package/dist/api/app/schemas.js +0 -79
- package/dist/api/app/types.js +0 -58
- package/dist/api/deploy/api.js +0 -60
- package/dist/api/deploy/index.js +0 -16
- package/dist/api/deploy/schemas.js +0 -103
- package/dist/api/deploy/types.js +0 -22
- package/dist/api/observability/api.js +0 -52
- package/dist/api/observability/index.js +0 -16
- package/dist/api/observability/schemas.js +0 -39
- package/dist/api/observability/types.js +0 -27
- package/dist/cli/commands/app/index.js +0 -62
- package/dist/cli/commands/deploy/index.js +0 -140
- package/dist/cli/commands/observability/index.js +0 -229
- package/dist/cli/handlers/app/get.js +0 -48
- package/dist/cli/handlers/app/index.js +0 -7
- package/dist/cli/handlers/deploy/deploy.js +0 -83
- package/dist/cli/handlers/deploy/get.js +0 -70
- package/dist/cli/handlers/deploy/helpers.js +0 -41
- package/dist/cli/handlers/deploy/history.js +0 -70
- package/dist/cli/handlers/deploy/index.js +0 -14
- package/dist/cli/handlers/deploy/polling.js +0 -139
- package/dist/cli/handlers/observability/analytics.js +0 -190
- package/dist/cli/handlers/observability/helpers.js +0 -66
- package/dist/cli/handlers/observability/index.js +0 -12
- package/dist/cli/handlers/observability/log.js +0 -94
- package/dist/cli/handlers/observability/metric.js +0 -208
- package/dist/cli/handlers/observability/trace.js +0 -102
- package/dist/utils/devops-error.js +0 -28
- package/dist/utils/git.js +0 -29
- package/dist/utils/time.js +0 -132
package/dist/api/deploy/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NodeStatus = exports.nodeStatusFromText = exports.nodeStatusText = exports.errorJobSchema = exports.deployGetSchema = exports.deployHistorySchema = exports.queryPipelineInstance = exports.getErrorLog = exports.listPipelineInstances = exports.createRelease = void 0;
|
|
4
|
-
var api_1 = require("./api");
|
|
5
|
-
Object.defineProperty(exports, "createRelease", { enumerable: true, get: function () { return api_1.createRelease; } });
|
|
6
|
-
Object.defineProperty(exports, "listPipelineInstances", { enumerable: true, get: function () { return api_1.listPipelineInstances; } });
|
|
7
|
-
Object.defineProperty(exports, "getErrorLog", { enumerable: true, get: function () { return api_1.getErrorLog; } });
|
|
8
|
-
Object.defineProperty(exports, "queryPipelineInstance", { enumerable: true, get: function () { return api_1.queryPipelineInstance; } });
|
|
9
|
-
var schemas_1 = require("./schemas");
|
|
10
|
-
Object.defineProperty(exports, "deployHistorySchema", { enumerable: true, get: function () { return schemas_1.deployHistorySchema; } });
|
|
11
|
-
Object.defineProperty(exports, "deployGetSchema", { enumerable: true, get: function () { return schemas_1.deployGetSchema; } });
|
|
12
|
-
Object.defineProperty(exports, "errorJobSchema", { enumerable: true, get: function () { return schemas_1.errorJobSchema; } });
|
|
13
|
-
Object.defineProperty(exports, "nodeStatusText", { enumerable: true, get: function () { return schemas_1.nodeStatusText; } });
|
|
14
|
-
Object.defineProperty(exports, "nodeStatusFromText", { enumerable: true, get: function () { return schemas_1.nodeStatusFromText; } });
|
|
15
|
-
var types_1 = require("./types");
|
|
16
|
-
Object.defineProperty(exports, "NodeStatus", { enumerable: true, get: function () { return types_1.NodeStatus; } });
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.errorJobSchema = exports.deployGetSchema = exports.deployHistorySchema = void 0;
|
|
4
|
-
exports.nodeStatusText = nodeStatusText;
|
|
5
|
-
exports.nodeStatusFromText = nodeStatusFromText;
|
|
6
|
-
const output_1 = require("../../utils/output");
|
|
7
|
-
const types_1 = require("./types");
|
|
8
|
-
const NODE_STATUS_TEXT = {
|
|
9
|
-
[types_1.NodeStatus.UNSPECIFIED]: "unknown",
|
|
10
|
-
[types_1.NodeStatus.TODO]: "todo",
|
|
11
|
-
[types_1.NodeStatus.RUNNING]: "running",
|
|
12
|
-
[types_1.NodeStatus.SUCCESS]: "success",
|
|
13
|
-
[types_1.NodeStatus.FAILED]: "failed",
|
|
14
|
-
[types_1.NodeStatus.CANCELED]: "canceled",
|
|
15
|
-
[types_1.NodeStatus.HOLD_ON]: "hold_on",
|
|
16
|
-
};
|
|
17
|
-
function nodeStatusText(v) {
|
|
18
|
-
if (typeof v !== "number")
|
|
19
|
-
return undefined;
|
|
20
|
-
return NODE_STATUS_TEXT[v];
|
|
21
|
-
}
|
|
22
|
-
/** NodeStatus 文本(CLI flag 字符串)→ 枚举数值 */
|
|
23
|
-
function nodeStatusFromText(text) {
|
|
24
|
-
const lower = text.toLowerCase();
|
|
25
|
-
for (const [num, label] of Object.entries(NODE_STATUS_TEXT)) {
|
|
26
|
-
if (label === lower)
|
|
27
|
-
return Number(num);
|
|
28
|
-
}
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
function pipelineDurationMs(row) {
|
|
32
|
-
// SimpleInstance.createdAt / updatedAt:BAM IDL 未注单位,e2e 看是 ms。
|
|
33
|
-
const start = Number(row.createdAt);
|
|
34
|
-
const end = Number(row.updatedAt);
|
|
35
|
-
if (!Number.isFinite(start) || !Number.isFinite(end))
|
|
36
|
-
return undefined;
|
|
37
|
-
return end - start;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* deploy history 列表的 pretty 渲染契约。
|
|
41
|
-
*
|
|
42
|
-
* BAM 返回 SimpleInstance(pipeline 实例),状态走 NodeStatus。
|
|
43
|
-
* 默认列:deploy-id(=ID)/ status / creator / created-at / duration(updatedAt-createdAt)。
|
|
44
|
-
*/
|
|
45
|
-
exports.deployHistorySchema = {
|
|
46
|
-
columns: [
|
|
47
|
-
{ key: "ID", label: "deploy-id" },
|
|
48
|
-
{
|
|
49
|
-
key: "status_text",
|
|
50
|
-
label: "status",
|
|
51
|
-
derive: (row) => nodeStatusText(row.status),
|
|
52
|
-
},
|
|
53
|
-
{ key: "creator", label: "creator" },
|
|
54
|
-
{ key: "createdAt", label: "created-at", format: output_1.fmt.ms() },
|
|
55
|
-
{
|
|
56
|
-
key: "duration",
|
|
57
|
-
label: "duration",
|
|
58
|
-
format: output_1.fmt.durationMs(),
|
|
59
|
-
derive: pipelineDurationMs,
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
strict: true,
|
|
63
|
-
};
|
|
64
|
-
/**
|
|
65
|
-
* deploy get 单条详情的 key-value 渲染契约(基于 SimpleInstance)。
|
|
66
|
-
*
|
|
67
|
-
* 由于 BAM 没有 by-ID 的查询接口,handler 用 listPipelineInstances 在最近窗口
|
|
68
|
-
* 里筛一条 SimpleInstance 透传过来。
|
|
69
|
-
*/
|
|
70
|
-
exports.deployGetSchema = {
|
|
71
|
-
columns: [
|
|
72
|
-
{ key: "ID", label: "deploy-id" },
|
|
73
|
-
{
|
|
74
|
-
key: "status_text",
|
|
75
|
-
label: "status",
|
|
76
|
-
derive: (row) => nodeStatusText(row.status),
|
|
77
|
-
},
|
|
78
|
-
{ key: "creator", label: "creator" },
|
|
79
|
-
{ key: "updater", label: "updater" },
|
|
80
|
-
{ key: "createdAt", label: "created-at", format: output_1.fmt.ms() },
|
|
81
|
-
{ key: "updatedAt", label: "updated-at", format: output_1.fmt.ms() },
|
|
82
|
-
{
|
|
83
|
-
key: "duration",
|
|
84
|
-
label: "duration",
|
|
85
|
-
format: output_1.fmt.durationMs(),
|
|
86
|
-
derive: pipelineDurationMs,
|
|
87
|
-
},
|
|
88
|
-
{ key: "templateID", label: "template" },
|
|
89
|
-
{ key: "description" },
|
|
90
|
-
{ key: "parameters" },
|
|
91
|
-
{ key: "envVariables", label: "env-vars" },
|
|
92
|
-
],
|
|
93
|
-
strict: true,
|
|
94
|
-
};
|
|
95
|
-
/** deploy error-log 表格渲染契约 */
|
|
96
|
-
exports.errorJobSchema = {
|
|
97
|
-
columns: [
|
|
98
|
-
{ key: "jobID", label: "job-id" },
|
|
99
|
-
{ key: "componentName", label: "component" },
|
|
100
|
-
{ key: "errorMsg", label: "error", format: output_1.fmt.truncate(120) },
|
|
101
|
-
],
|
|
102
|
-
strict: true,
|
|
103
|
-
};
|
package/dist/api/deploy/types.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// 与 BAM lark.apaas.devops v1.0.326 / 1.0.327 + lark.apaas.devops_platform v1.0.247 对齐:
|
|
3
|
-
// - CLICreateForceRelease (4070318) 创建发布 lark.apaas.devops
|
|
4
|
-
// - CliQueryPipelineInstance (4069872) 轮询发布状态 lark.apaas.devops_platform
|
|
5
|
-
// - CliListPipelineInstances (4073969) 分页获取发布历史 lark.apaas.devops_platform
|
|
6
|
-
// - CliGetToolInstanceErrorJobs (4073972) 获取发布错误日志 lark.apaas.devops_platform
|
|
7
|
-
//
|
|
8
|
-
// 发布单的唯一标识是 pipelineTaskID,对外即 deploy-id;error-log 等接口直接用它做
|
|
9
|
-
// URL 路径段(instanceID)。曾经的 Release/releaseID 概念已全面废弃。
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.NodeStatus = void 0;
|
|
12
|
-
/** Pipeline 节点状态(devops_platform) */
|
|
13
|
-
var NodeStatus;
|
|
14
|
-
(function (NodeStatus) {
|
|
15
|
-
NodeStatus[NodeStatus["UNSPECIFIED"] = 0] = "UNSPECIFIED";
|
|
16
|
-
NodeStatus[NodeStatus["TODO"] = 1] = "TODO";
|
|
17
|
-
NodeStatus[NodeStatus["RUNNING"] = 2] = "RUNNING";
|
|
18
|
-
NodeStatus[NodeStatus["SUCCESS"] = 3] = "SUCCESS";
|
|
19
|
-
NodeStatus[NodeStatus["FAILED"] = 4] = "FAILED";
|
|
20
|
-
NodeStatus[NodeStatus["CANCELED"] = 5] = "CANCELED";
|
|
21
|
-
NodeStatus[NodeStatus["HOLD_ON"] = 6] = "HOLD_ON";
|
|
22
|
-
})(NodeStatus || (exports.NodeStatus = NodeStatus = {}));
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.searchLogs = searchLogs;
|
|
4
|
-
exports.searchTraces = searchTraces;
|
|
5
|
-
exports.getTraces = getTraces;
|
|
6
|
-
exports.queryMetricsData = queryMetricsData;
|
|
7
|
-
exports.queryAnalyticsData = queryAnalyticsData;
|
|
8
|
-
const http_1 = require("../../utils/http");
|
|
9
|
-
const DEFAULT_ERR_CODE = "INTERNAL_OB_ERROR";
|
|
10
|
-
// ── 日志 ──
|
|
11
|
-
async function searchLogs(req) {
|
|
12
|
-
const url = `/v1/observability/app/${encodeURIComponent(req.appID)}/logs/search`;
|
|
13
|
-
return (0, http_1.postInnerApi)(url, req, {
|
|
14
|
-
errPrefix: "Failed to search logs",
|
|
15
|
-
defaultErrCode: DEFAULT_ERR_CODE,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
// ── 链路 ──
|
|
19
|
-
async function searchTraces(req) {
|
|
20
|
-
const url = `/v1/observability/app/${encodeURIComponent(req.appID)}/traces/search`;
|
|
21
|
-
return (0, http_1.postInnerApi)(url, req, {
|
|
22
|
-
errPrefix: "Failed to search traces",
|
|
23
|
-
defaultErrCode: DEFAULT_ERR_CODE,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
async function getTraces(req) {
|
|
27
|
-
const url = `/v1/observability/app/${encodeURIComponent(req.appID)}/traces/${encodeURIComponent(req.traceID)}`;
|
|
28
|
-
return (0, http_1.postInnerApi)(url, req, {
|
|
29
|
-
errPrefix: "Failed to get trace",
|
|
30
|
-
defaultErrCode: DEFAULT_ERR_CODE,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
// ── 监控指标 ──
|
|
34
|
-
async function queryMetricsData(req) {
|
|
35
|
-
const url = `/v1/observability/app/${encodeURIComponent(req.appID)}/metrics/data/query`;
|
|
36
|
-
return (0, http_1.postInnerApi)(url, req, {
|
|
37
|
-
errPrefix: "Failed to query metrics",
|
|
38
|
-
defaultErrCode: DEFAULT_ERR_CODE,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
// ── 运营指标 ──
|
|
42
|
-
//
|
|
43
|
-
// 走 BAM v1.0.122 起的批量端点 CLIBatchQueryAnalyticsData:
|
|
44
|
-
// - 路径 /analytics/data/batch_query(旧版 /analytics/data/query 已废弃)
|
|
45
|
-
// - 支持 metricTypes 数组,单次拉多个指标
|
|
46
|
-
async function queryAnalyticsData(req) {
|
|
47
|
-
const url = `/v1/observability/app/${encodeURIComponent(req.appID)}/analytics/data/batch_query`;
|
|
48
|
-
return (0, http_1.postInnerApi)(url, req, {
|
|
49
|
-
errPrefix: "Failed to query analytics",
|
|
50
|
-
defaultErrCode: DEFAULT_ERR_CODE,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StatusCode = exports.SpanKind = exports.WordOperator = exports.spanSchema = exports.logItemSchema = exports.queryAnalyticsData = exports.queryMetricsData = exports.getTraces = exports.searchTraces = exports.searchLogs = void 0;
|
|
4
|
-
var api_1 = require("./api");
|
|
5
|
-
Object.defineProperty(exports, "searchLogs", { enumerable: true, get: function () { return api_1.searchLogs; } });
|
|
6
|
-
Object.defineProperty(exports, "searchTraces", { enumerable: true, get: function () { return api_1.searchTraces; } });
|
|
7
|
-
Object.defineProperty(exports, "getTraces", { enumerable: true, get: function () { return api_1.getTraces; } });
|
|
8
|
-
Object.defineProperty(exports, "queryMetricsData", { enumerable: true, get: function () { return api_1.queryMetricsData; } });
|
|
9
|
-
Object.defineProperty(exports, "queryAnalyticsData", { enumerable: true, get: function () { return api_1.queryAnalyticsData; } });
|
|
10
|
-
var schemas_1 = require("./schemas");
|
|
11
|
-
Object.defineProperty(exports, "logItemSchema", { enumerable: true, get: function () { return schemas_1.logItemSchema; } });
|
|
12
|
-
Object.defineProperty(exports, "spanSchema", { enumerable: true, get: function () { return schemas_1.spanSchema; } });
|
|
13
|
-
var types_1 = require("./types");
|
|
14
|
-
Object.defineProperty(exports, "WordOperator", { enumerable: true, get: function () { return types_1.WordOperator; } });
|
|
15
|
-
Object.defineProperty(exports, "SpanKind", { enumerable: true, get: function () { return types_1.SpanKind; } });
|
|
16
|
-
Object.defineProperty(exports, "StatusCode", { enumerable: true, get: function () { return types_1.StatusCode; } });
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.spanSchema = exports.logItemSchema = void 0;
|
|
4
|
-
const output_1 = require("../../utils/output");
|
|
5
|
-
/** LogItem 渲染契约(log search) */
|
|
6
|
-
exports.logItemSchema = {
|
|
7
|
-
columns: [
|
|
8
|
-
{ key: "timestampNs", label: "time", format: output_1.fmt.ns("yyyy-MM-dd HH:mm:ss.SSS") },
|
|
9
|
-
{ key: "severityText", label: "level" },
|
|
10
|
-
{ key: "body" },
|
|
11
|
-
],
|
|
12
|
-
strict: true,
|
|
13
|
-
};
|
|
14
|
-
/** Span 渲染契约(trace list / trace get 复用)。
|
|
15
|
-
* duration 是 client-derived(BAM 只给 start/end,没有原生 durationNs 字段)。 */
|
|
16
|
-
exports.spanSchema = {
|
|
17
|
-
columns: [
|
|
18
|
-
{ key: "startTimeUnixNano", label: "start-time", format: output_1.fmt.ns("yyyy-MM-dd HH:mm:ss.SSS") },
|
|
19
|
-
{ key: "name", label: "root-span" },
|
|
20
|
-
{
|
|
21
|
-
key: "user-id",
|
|
22
|
-
derive: (row) => {
|
|
23
|
-
return row.attributes?.user_id;
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
key: "duration",
|
|
28
|
-
label: "duration",
|
|
29
|
-
format: output_1.fmt.durationMs(),
|
|
30
|
-
derive: (row) => {
|
|
31
|
-
return row.attributes?.duration_ms;
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
{ key: "traceID", label: "trace-id" },
|
|
35
|
-
],
|
|
36
|
-
strict: true,
|
|
37
|
-
};
|
|
38
|
-
// metric / analytics 都改用 BAM v1.0.123 起的合并响应(points: {timestamp, values}),
|
|
39
|
-
// pretty 渲染走 handler 内 pivot 后的临时 schema;不再导出固定 schema。
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// ── 通用结构 ──
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.StatusCode = exports.SpanKind = exports.WordOperator = void 0;
|
|
5
|
-
/** 模糊搜索词运算符(对应后端 WordOperator) */
|
|
6
|
-
var WordOperator;
|
|
7
|
-
(function (WordOperator) {
|
|
8
|
-
WordOperator[WordOperator["AND"] = 0] = "AND";
|
|
9
|
-
WordOperator[WordOperator["OR"] = 1] = "OR";
|
|
10
|
-
})(WordOperator || (exports.WordOperator = WordOperator = {}));
|
|
11
|
-
/** OpenTelemetry SpanKind(BAM 透传) */
|
|
12
|
-
var SpanKind;
|
|
13
|
-
(function (SpanKind) {
|
|
14
|
-
SpanKind[SpanKind["UNSPECIFIED"] = 0] = "UNSPECIFIED";
|
|
15
|
-
SpanKind[SpanKind["INTERNAL"] = 1] = "INTERNAL";
|
|
16
|
-
SpanKind[SpanKind["SERVER"] = 2] = "SERVER";
|
|
17
|
-
SpanKind[SpanKind["CLIENT"] = 3] = "CLIENT";
|
|
18
|
-
SpanKind[SpanKind["PRODUCER"] = 4] = "PRODUCER";
|
|
19
|
-
SpanKind[SpanKind["CONSUMER"] = 5] = "CONSUMER";
|
|
20
|
-
})(SpanKind || (exports.SpanKind = SpanKind = {}));
|
|
21
|
-
/** Span 状态码(BAM 透传) */
|
|
22
|
-
var StatusCode;
|
|
23
|
-
(function (StatusCode) {
|
|
24
|
-
StatusCode[StatusCode["UNSET"] = 0] = "UNSET";
|
|
25
|
-
StatusCode[StatusCode["OK"] = 1] = "OK";
|
|
26
|
-
StatusCode[StatusCode["ERROR"] = 2] = "ERROR";
|
|
27
|
-
})(StatusCode || (exports.StatusCode = StatusCode = {}));
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.registerAppCommands = registerAppCommands;
|
|
4
|
-
const shared_1 = require("../../../cli/commands/shared");
|
|
5
|
-
const index_1 = require("../../../cli/handlers/app/index");
|
|
6
|
-
function registerAppCommands(program) {
|
|
7
|
-
const appCmd = program.command("app").description("应用元数据管理:查看 / 修改");
|
|
8
|
-
appCmd.action(() => {
|
|
9
|
-
appCmd.outputHelp();
|
|
10
|
-
});
|
|
11
|
-
appCmd.addHelpText("after", `
|
|
12
|
-
作用范围
|
|
13
|
-
仅供 Agent 在妙搭沙箱内调用。
|
|
14
|
-
应用上下文:沙箱内的默认应用。
|
|
15
|
-
`);
|
|
16
|
-
registerAppGet(appCmd);
|
|
17
|
-
registerAppUpdate(appCmd);
|
|
18
|
-
}
|
|
19
|
-
function registerAppGet(parent) {
|
|
20
|
-
const cmd = parent
|
|
21
|
-
.command("get")
|
|
22
|
-
.description("查看应用元数据(status / type / mode / branch / 时间戳 等)")
|
|
23
|
-
.addOption((0, shared_1.appIdOption)().hideHelp())
|
|
24
|
-
.addHelpText("after", `
|
|
25
|
-
JSON 输出
|
|
26
|
-
{"data": {"appID": "...", "name": "...", ...}}
|
|
27
|
-
|
|
28
|
-
示例
|
|
29
|
-
$ miaoda app get
|
|
30
|
-
$ miaoda app get --json
|
|
31
|
-
`);
|
|
32
|
-
cmd.action((0, shared_1.withHelp)(cmd, async (rawOpts) => {
|
|
33
|
-
(0, shared_1.rejectCliOverride)(cmd, "appId");
|
|
34
|
-
await (0, index_1.handleAppGet)({
|
|
35
|
-
appId: rawOpts.appId,
|
|
36
|
-
});
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
function registerAppUpdate(parent) {
|
|
40
|
-
const cmd = parent
|
|
41
|
-
.command("update")
|
|
42
|
-
.description("修改应用名称 / 描述(至少传 --name 或 --description)")
|
|
43
|
-
.addOption((0, shared_1.appIdOption)().hideHelp())
|
|
44
|
-
.option("--name <name>", "新应用名称")
|
|
45
|
-
.option("--description <desc>", "新应用描述")
|
|
46
|
-
.addHelpText("after", `
|
|
47
|
-
JSON 输出
|
|
48
|
-
与 'app get' 一致:{"data": {...新 meta...}, "next_cursor": null, "has_more": false}
|
|
49
|
-
|
|
50
|
-
示例
|
|
51
|
-
$ miaoda app update --name my-store
|
|
52
|
-
$ miaoda app update --description "在线商城应用"
|
|
53
|
-
`);
|
|
54
|
-
cmd.action((0, shared_1.withHelp)(cmd, async (rawOpts) => {
|
|
55
|
-
(0, shared_1.rejectCliOverride)(cmd, "appId");
|
|
56
|
-
await (0, index_1.handleAppUpdate)({
|
|
57
|
-
appId: rawOpts.appId,
|
|
58
|
-
name: rawOpts.name,
|
|
59
|
-
description: rawOpts.description,
|
|
60
|
-
});
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
@@ -1,140 +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
|
-
- 相对时间:1h(1 小时前)、2d(2 天前)、1w(1 周前)、30m(30 分钟前)
|
|
10
|
-
- 日期:2026-04-01(按当日 00:00:00 UTC)
|
|
11
|
-
- ISO 8601:2026-04-01T10:00:00Z
|
|
12
|
-
`;
|
|
13
|
-
function registerDeployCommands(program) {
|
|
14
|
-
// PRD:`miaoda deploy` 自身即为触发发布;get / history / error-log 是子命令
|
|
15
|
-
const deployCmd = program
|
|
16
|
-
.command("deploy")
|
|
17
|
-
.description("触发发布;支持 --wait 阻塞到终态。子命令:get / history / error-log")
|
|
18
|
-
.addOption((0, shared_1.appIdOption)().hideHelp())
|
|
19
|
-
.addOption((0, shared_1.branchOption)().hideHelp())
|
|
20
|
-
.option("--wait", "阻塞直到流水线终态", false)
|
|
21
|
-
.option("--timeout <sec>", "--wait 最长等待秒数(默认 300)", parseTimeout, 300)
|
|
22
|
-
.addHelpText("after", `
|
|
23
|
-
部署前置检查(Agent 必须执行)
|
|
24
|
-
miaoda deploy 跑的是当前分支的远端 HEAD——本地未 commit / 未 push 的代码不会进发布产物。
|
|
25
|
-
调用前先 \`git status\` + \`git rev-list --count @{u}..HEAD\` 确认;有未提交 / 未推送时:
|
|
26
|
-
- 是本次任务的产物 → 先 commit + push 再 deploy
|
|
27
|
-
- 不能确定意图 → 用 AskUser 跟用户确认(不要默默继续)
|
|
28
|
-
|
|
29
|
-
JSON 输出
|
|
30
|
-
不带 --wait:{"data": {"pipelineTaskID": "..."}}(pipelineTaskID 即 deploy-id)
|
|
31
|
-
带 --wait:data 额外包含 detail(pipeline 终态)
|
|
32
|
-
|
|
33
|
-
示例
|
|
34
|
-
$ miaoda deploy
|
|
35
|
-
$ miaoda deploy --wait --timeout 600
|
|
36
|
-
$ miaoda deploy get 12345
|
|
37
|
-
$ miaoda deploy history --status failed
|
|
38
|
-
`);
|
|
39
|
-
deployCmd.action((0, shared_1.withHelp)(deployCmd, async (rawOpts) => {
|
|
40
|
-
(0, shared_1.rejectCliOverride)(deployCmd, "appId", "branch");
|
|
41
|
-
await (0, index_1.handleDeploy)({
|
|
42
|
-
appId: rawOpts.appId,
|
|
43
|
-
branch: rawOpts.branch,
|
|
44
|
-
wait: rawOpts.wait,
|
|
45
|
-
timeout: rawOpts.timeout,
|
|
46
|
-
});
|
|
47
|
-
}));
|
|
48
|
-
registerDeployGet(deployCmd);
|
|
49
|
-
registerDeployHistory(deployCmd);
|
|
50
|
-
registerDeployErrorLog(deployCmd);
|
|
51
|
-
}
|
|
52
|
-
function registerDeployGet(parent) {
|
|
53
|
-
const cmd = parent
|
|
54
|
-
.command("get")
|
|
55
|
-
.description("查看指定发布单的详情")
|
|
56
|
-
.argument("<deploy-id>", "发布单 ID")
|
|
57
|
-
.addOption((0, shared_1.appIdOption)().hideHelp())
|
|
58
|
-
.addHelpText("after", `
|
|
59
|
-
JSON 输出
|
|
60
|
-
{"data": {"ID": ..., "status": ..., "creator": "...", "createdAt": ..., "updatedAt": ..., ...}, "next_cursor": null, "has_more": false}
|
|
61
|
-
ID 即 deploy-id(== pipelineTaskID)
|
|
62
|
-
|
|
63
|
-
示例
|
|
64
|
-
$ miaoda deploy get 12345
|
|
65
|
-
`);
|
|
66
|
-
cmd.action((0, shared_1.withHelp)(cmd, async (deployId, rawOpts) => {
|
|
67
|
-
(0, shared_1.rejectCliOverride)(cmd, "appId");
|
|
68
|
-
await (0, index_1.handleDeployGet)({
|
|
69
|
-
deployId,
|
|
70
|
-
appId: rawOpts.appId,
|
|
71
|
-
});
|
|
72
|
-
}));
|
|
73
|
-
}
|
|
74
|
-
function registerDeployHistory(parent) {
|
|
75
|
-
const cmd = parent
|
|
76
|
-
.command("history")
|
|
77
|
-
.description("查询发布历史(按时间倒序,分页)")
|
|
78
|
-
.addOption((0, shared_1.appIdOption)().hideHelp())
|
|
79
|
-
.addOption(new commander_1.Option("--status <status>", "状态过滤(pipeline 节点状态,大小写不敏感)")
|
|
80
|
-
.choices(["todo", "running", "success", "failed", "canceled", "hold_on"])
|
|
81
|
-
.argParser((0, shared_1.caseInsensitiveChoice)(["todo", "running", "success", "failed", "canceled", "hold_on"])))
|
|
82
|
-
.option("--since <time>", "起始时间")
|
|
83
|
-
.option("--until <time>", "截止时间")
|
|
84
|
-
.option("--limit <n>", "返回条数上限(1~100)", parseLimit, 50)
|
|
85
|
-
.option("--cursor <token>", "下一页游标")
|
|
86
|
-
.addHelpText("after", `${COMMON_TIME_HELP}
|
|
87
|
-
JSON 输出
|
|
88
|
-
{"data": [...], "next_cursor": "...", "has_more": true|false}
|
|
89
|
-
|
|
90
|
-
示例
|
|
91
|
-
$ miaoda deploy history --status failed
|
|
92
|
-
$ miaoda deploy history --since 7d
|
|
93
|
-
`);
|
|
94
|
-
cmd.action((0, shared_1.withHelp)(cmd, async (rawOpts) => {
|
|
95
|
-
(0, shared_1.rejectCliOverride)(cmd, "appId");
|
|
96
|
-
await (0, index_1.handleDeployHistory)({
|
|
97
|
-
appId: rawOpts.appId,
|
|
98
|
-
status: rawOpts.status,
|
|
99
|
-
since: rawOpts.since,
|
|
100
|
-
until: rawOpts.until,
|
|
101
|
-
limit: rawOpts.limit,
|
|
102
|
-
cursor: rawOpts.cursor,
|
|
103
|
-
});
|
|
104
|
-
}));
|
|
105
|
-
}
|
|
106
|
-
function registerDeployErrorLog(parent) {
|
|
107
|
-
const cmd = parent
|
|
108
|
-
.command("error-log")
|
|
109
|
-
.description("查询指定发布的错误日志")
|
|
110
|
-
.argument("<deploy-id>", "发布单 ID")
|
|
111
|
-
.addOption((0, shared_1.appIdOption)().hideHelp())
|
|
112
|
-
.addHelpText("after", `
|
|
113
|
-
JSON 输出
|
|
114
|
-
{"data": [{"jobID": ..., "componentName": ..., "errorMsg": ...}], "next_cursor": null, "has_more": false}
|
|
115
|
-
|
|
116
|
-
示例
|
|
117
|
-
$ miaoda deploy error-log 12345 --json
|
|
118
|
-
`);
|
|
119
|
-
cmd.action((0, shared_1.withHelp)(cmd, async (deployId, rawOpts) => {
|
|
120
|
-
(0, shared_1.rejectCliOverride)(cmd, "appId");
|
|
121
|
-
await (0, index_1.handleDeployErrorLog)({
|
|
122
|
-
deployId,
|
|
123
|
-
appId: rawOpts.appId,
|
|
124
|
-
});
|
|
125
|
-
}));
|
|
126
|
-
}
|
|
127
|
-
function parseLimit(value) {
|
|
128
|
-
const n = Number(value);
|
|
129
|
-
if (!Number.isFinite(n)) {
|
|
130
|
-
throw new Error(`--limit 必须是数字,收到 '${value}'`);
|
|
131
|
-
}
|
|
132
|
-
return n;
|
|
133
|
-
}
|
|
134
|
-
function parseTimeout(value) {
|
|
135
|
-
const n = Number(value);
|
|
136
|
-
if (!Number.isFinite(n) || n <= 0) {
|
|
137
|
-
throw new Error(`--timeout 必须是正数,收到 '${value}'`);
|
|
138
|
-
}
|
|
139
|
-
return n;
|
|
140
|
-
}
|