@lark-apaas/miaoda-cli 0.1.3 → 0.1.4-alpha.abaa17f
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/app/api.js +3 -3
- package/dist/api/app/schemas.js +43 -43
- package/dist/api/db/api.js +398 -55
- package/dist/api/db/client.js +155 -28
- package/dist/api/db/index.js +12 -1
- package/dist/api/db/parsers.js +20 -20
- package/dist/api/db/sql-keywords.js +87 -87
- package/dist/api/deploy/api.js +5 -5
- package/dist/api/deploy/index.js +12 -1
- package/dist/api/deploy/modern-types.js +23 -0
- package/dist/api/deploy/modern.js +70 -0
- package/dist/api/deploy/plugin-instances-types.js +6 -0
- package/dist/api/deploy/plugin-instances.js +30 -0
- package/dist/api/deploy/schemas.js +32 -32
- package/dist/api/file/api.js +89 -87
- package/dist/api/file/client.js +62 -22
- package/dist/api/file/detect.js +3 -3
- package/dist/api/file/index.js +2 -1
- package/dist/api/file/parsers.js +18 -7
- package/dist/api/observability/api.js +6 -6
- package/dist/api/observability/schemas.js +14 -14
- package/dist/api/plugin/api.js +31 -31
- package/dist/cli/commands/app/index.js +94 -13
- package/dist/cli/commands/db/index.js +602 -54
- package/dist/cli/commands/deploy/index.js +28 -28
- package/dist/cli/commands/deploy/modern.js +48 -0
- package/dist/cli/commands/file/index.js +85 -58
- package/dist/cli/commands/index.js +31 -5
- package/dist/cli/commands/observability/index.js +69 -69
- package/dist/cli/commands/plugin/index.js +27 -27
- package/dist/cli/commands/shared.js +10 -10
- package/dist/cli/handlers/app/index.js +6 -1
- package/dist/cli/handlers/app/init.js +86 -0
- package/dist/cli/handlers/app/update.js +2 -2
- package/dist/cli/handlers/db/_destructive.js +67 -0
- package/dist/cli/handlers/db/_env.js +26 -0
- package/dist/cli/handlers/db/_operator.js +35 -0
- package/dist/cli/handlers/db/audit.js +383 -0
- package/dist/cli/handlers/db/changelog.js +160 -0
- package/dist/cli/handlers/db/data.js +32 -31
- package/dist/cli/handlers/db/index.js +17 -1
- package/dist/cli/handlers/db/migration.js +234 -0
- package/dist/cli/handlers/db/quota.js +68 -0
- package/dist/cli/handlers/db/recovery.js +413 -0
- package/dist/cli/handlers/db/schema.js +33 -33
- package/dist/cli/handlers/db/sql.js +69 -69
- package/dist/cli/handlers/deploy/deploy.js +4 -4
- package/dist/cli/handlers/deploy/error-log.js +1 -1
- package/dist/cli/handlers/deploy/get.js +3 -3
- package/dist/cli/handlers/deploy/modern.js +32 -0
- package/dist/cli/handlers/deploy/polling.js +11 -11
- package/dist/cli/handlers/file/cp.js +30 -30
- package/dist/cli/handlers/file/index.js +3 -1
- package/dist/cli/handlers/file/ls.js +5 -5
- package/dist/cli/handlers/file/quota.js +66 -0
- package/dist/cli/handlers/file/rm.js +32 -30
- package/dist/cli/handlers/file/sign.js +3 -3
- package/dist/cli/handlers/file/stat.js +10 -9
- package/dist/cli/handlers/observability/analytics.js +47 -47
- package/dist/cli/handlers/observability/helpers.js +2 -2
- package/dist/cli/handlers/observability/log.js +9 -9
- package/dist/cli/handlers/observability/metric.js +26 -26
- package/dist/cli/handlers/observability/trace.js +5 -5
- package/dist/cli/handlers/plugin/plugin-local.js +53 -53
- package/dist/cli/handlers/plugin/plugin.js +15 -15
- package/dist/cli/help.js +16 -16
- package/dist/main.js +12 -12
- package/dist/services/app/init/index.js +14 -0
- package/dist/services/app/init/install.js +101 -0
- package/dist/services/app/init/steering.js +74 -0
- package/dist/services/app/init/template.js +85 -0
- package/dist/services/deploy/modern/atoms/build.js +54 -0
- package/dist/services/deploy/modern/atoms/context.js +30 -0
- package/dist/services/deploy/modern/atoms/index.js +17 -0
- package/dist/services/deploy/modern/atoms/local-release.js +27 -0
- package/dist/services/deploy/modern/atoms/pre-release.js +13 -0
- package/dist/services/deploy/modern/atoms/save-plugin-instances.js +72 -0
- package/dist/services/deploy/modern/atoms/upload.js +192 -0
- package/dist/services/deploy/modern/check.js +58 -0
- package/dist/services/deploy/modern/constants.js +13 -0
- package/dist/services/deploy/modern/index.js +16 -0
- package/dist/services/deploy/modern/pipelines/index.js +5 -0
- package/dist/services/deploy/modern/pipelines/local.js +75 -0
- package/dist/services/deploy/modern/protocol.js +43 -0
- package/dist/services/deploy/modern/run-types.js +4 -0
- package/dist/services/deploy/modern/run.js +13 -0
- package/dist/services/deploy/modern/template-key-map.js +29 -0
- package/dist/utils/args.js +1 -1
- package/dist/utils/colors.js +2 -2
- package/dist/utils/config.js +2 -2
- package/dist/utils/devops-error.js +9 -9
- package/dist/utils/error.js +2 -2
- package/dist/utils/git.js +4 -4
- package/dist/utils/http.js +27 -21
- package/dist/utils/index.js +3 -1
- package/dist/utils/npm-pack.js +55 -0
- package/dist/utils/output.js +67 -45
- package/dist/utils/poll.js +35 -0
- package/dist/utils/render.js +27 -27
- package/dist/utils/spark-meta.js +48 -0
- package/dist/utils/spinner.js +46 -0
- package/dist/utils/time.js +47 -42
- package/package.json +1 -1
|
@@ -17,13 +17,13 @@ const COMMON_TIME_HELP = `
|
|
|
17
17
|
function registerDeployCommands(program) {
|
|
18
18
|
// PRD:`miaoda deploy` 自身即为触发发布;get / history / error-log 是子命令
|
|
19
19
|
const deployCmd = program
|
|
20
|
-
.command(
|
|
21
|
-
.description(
|
|
20
|
+
.command('deploy')
|
|
21
|
+
.description('触发发布;支持 --wait 阻塞到终态。子命令:get / history / error-log')
|
|
22
22
|
.addOption((0, shared_1.appIdOption)().hideHelp())
|
|
23
23
|
.addOption((0, shared_1.branchOption)().hideHelp())
|
|
24
|
-
.option(
|
|
25
|
-
.option(
|
|
26
|
-
.addHelpText(
|
|
24
|
+
.option('--wait', '阻塞直到流水线终态', false)
|
|
25
|
+
.option('--timeout <sec>', '--wait 最长等待秒数(默认 300)', parseTimeout, 300)
|
|
26
|
+
.addHelpText('after', `
|
|
27
27
|
不要用异步模式或后台模式调用 deploy(例如 &、nohup、后台 task、detached run,或任何会让命令提前返回的包装方式),否则调用可能提前结束,Agent 会误判发布已完成。
|
|
28
28
|
部署前置检查(Agent 必须执行)
|
|
29
29
|
miaoda deploy 跑的是当前分支的远端 HEAD——本地未 commit / 未 push 的代码不会进发布产物。
|
|
@@ -49,7 +49,7 @@ JSON 输出
|
|
|
49
49
|
$ miaoda deploy history --status failed
|
|
50
50
|
`);
|
|
51
51
|
deployCmd.action((0, shared_1.withHelp)(deployCmd, async (rawOpts) => {
|
|
52
|
-
(0, shared_1.rejectCliOverride)(deployCmd,
|
|
52
|
+
(0, shared_1.rejectCliOverride)(deployCmd, 'appId', 'branch');
|
|
53
53
|
await (0, index_1.handleDeploy)({
|
|
54
54
|
appId: (0, shared_1.resolveAppId)({ appId: rawOpts.appId }),
|
|
55
55
|
branch: rawOpts.branch,
|
|
@@ -63,11 +63,11 @@ JSON 输出
|
|
|
63
63
|
}
|
|
64
64
|
function registerDeployGet(parent) {
|
|
65
65
|
const cmd = parent
|
|
66
|
-
.command(
|
|
67
|
-
.description(
|
|
68
|
-
.argument(
|
|
66
|
+
.command('get')
|
|
67
|
+
.description('查看指定发布单的详情')
|
|
68
|
+
.argument('<deploy-id>', '发布单 ID')
|
|
69
69
|
.addOption((0, shared_1.appIdOption)().hideHelp())
|
|
70
|
-
.addHelpText(
|
|
70
|
+
.addHelpText('after', `
|
|
71
71
|
JSON 输出
|
|
72
72
|
{"data": {"ID": ..., "status": ..., "creator": "...", "createdAt": ..., "updatedAt": ..., ...}, "next_cursor": null, "has_more": false}
|
|
73
73
|
ID 即 deploy-id(== pipelineTaskID)
|
|
@@ -77,7 +77,7 @@ JSON 输出
|
|
|
77
77
|
$ miaoda deploy get 12345
|
|
78
78
|
`);
|
|
79
79
|
cmd.action((0, shared_1.withHelp)(cmd, async (deployId, rawOpts) => {
|
|
80
|
-
(0, shared_1.rejectCliOverride)(cmd,
|
|
80
|
+
(0, shared_1.rejectCliOverride)(cmd, 'appId');
|
|
81
81
|
await (0, index_1.handleDeployGet)({
|
|
82
82
|
deployId,
|
|
83
83
|
appId: (0, shared_1.resolveAppId)({ appId: rawOpts.appId }),
|
|
@@ -86,17 +86,17 @@ JSON 输出
|
|
|
86
86
|
}
|
|
87
87
|
function registerDeployHistory(parent) {
|
|
88
88
|
const cmd = parent
|
|
89
|
-
.command(
|
|
90
|
-
.description(
|
|
89
|
+
.command('history')
|
|
90
|
+
.description('查询发布历史(按时间倒序,分页)')
|
|
91
91
|
.addOption((0, shared_1.appIdOption)().hideHelp())
|
|
92
|
-
.addOption(new commander_1.Option(
|
|
93
|
-
.choices([
|
|
94
|
-
.argParser((0, shared_1.caseInsensitiveChoice)([
|
|
95
|
-
.option(
|
|
96
|
-
.option(
|
|
97
|
-
.option(
|
|
98
|
-
.option(
|
|
99
|
-
.addHelpText(
|
|
92
|
+
.addOption(new commander_1.Option('--status <status>', '状态过滤(pipeline 节点状态,大小写不敏感)')
|
|
93
|
+
.choices(['todo', 'running', 'success', 'failed', 'canceled', 'hold_on'])
|
|
94
|
+
.argParser((0, shared_1.caseInsensitiveChoice)(['todo', 'running', 'success', 'failed', 'canceled', 'hold_on'])))
|
|
95
|
+
.option('--since <time>', '起始时间')
|
|
96
|
+
.option('--until <time>', '截止时间')
|
|
97
|
+
.option('--limit <n>', '返回条数上限(1~100)', parseLimit, 50)
|
|
98
|
+
.option('--cursor <token>', '下一页游标')
|
|
99
|
+
.addHelpText('after', `${COMMON_TIME_HELP}
|
|
100
100
|
JSON 输出
|
|
101
101
|
{"data": [...], "next_cursor": "...", "has_more": true|false}
|
|
102
102
|
data[].status 为可读字符串;data[].status_code 为 BAM 原始数字枚举。
|
|
@@ -106,8 +106,8 @@ JSON 输出
|
|
|
106
106
|
$ miaoda deploy history --since 7d
|
|
107
107
|
`);
|
|
108
108
|
cmd.action((0, shared_1.withHelp)(cmd, async (rawOpts) => {
|
|
109
|
-
(0, shared_1.validateTimeOptions)(rawOpts,
|
|
110
|
-
(0, shared_1.rejectCliOverride)(cmd,
|
|
109
|
+
(0, shared_1.validateTimeOptions)(rawOpts, 'since', 'until');
|
|
110
|
+
(0, shared_1.rejectCliOverride)(cmd, 'appId');
|
|
111
111
|
await (0, index_1.handleDeployHistory)({
|
|
112
112
|
appId: (0, shared_1.resolveAppId)({ appId: rawOpts.appId }),
|
|
113
113
|
status: rawOpts.status,
|
|
@@ -120,11 +120,11 @@ JSON 输出
|
|
|
120
120
|
}
|
|
121
121
|
function registerDeployErrorLog(parent) {
|
|
122
122
|
const cmd = parent
|
|
123
|
-
.command(
|
|
124
|
-
.description(
|
|
125
|
-
.argument(
|
|
123
|
+
.command('error-log')
|
|
124
|
+
.description('查询指定发布的错误日志')
|
|
125
|
+
.argument('<deploy-id>', '发布单 ID')
|
|
126
126
|
.addOption((0, shared_1.appIdOption)().hideHelp())
|
|
127
|
-
.addHelpText(
|
|
127
|
+
.addHelpText('after', `
|
|
128
128
|
JSON 输出
|
|
129
129
|
{"data": [{"jobID": ..., "componentName": ..., "errorMsg": ...}], "next_cursor": null, "has_more": false}
|
|
130
130
|
|
|
@@ -132,7 +132,7 @@ JSON 输出
|
|
|
132
132
|
$ miaoda deploy error-log 12345 --json
|
|
133
133
|
`);
|
|
134
134
|
cmd.action((0, shared_1.withHelp)(cmd, async (deployId, rawOpts) => {
|
|
135
|
-
(0, shared_1.rejectCliOverride)(cmd,
|
|
135
|
+
(0, shared_1.rejectCliOverride)(cmd, 'appId');
|
|
136
136
|
await (0, index_1.handleDeployErrorLog)({
|
|
137
137
|
deployId,
|
|
138
138
|
appId: (0, shared_1.resolveAppId)({ appId: rawOpts.appId }),
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerDeployCommandsModern = registerDeployCommandsModern;
|
|
4
|
+
const shared_1 = require("../../../cli/commands/shared");
|
|
5
|
+
const modern_1 = require("../../../cli/handlers/deploy/modern");
|
|
6
|
+
/**
|
|
7
|
+
* modern scene (MIAODA_APP_TYPE=7) 专用 deploy 注册。
|
|
8
|
+
* 仅披露顶层 `miaoda deploy`,CLI 表面对齐 openclaw-cli:`--dir / --skip-build`。
|
|
9
|
+
*
|
|
10
|
+
* 与 default 的 registerDeployCommands 完全平行:两套实现 100% 隔离,
|
|
11
|
+
* 不共享分支、不互相依赖。后端调用与编排在 src/services/deploy/modern/。
|
|
12
|
+
*/
|
|
13
|
+
function registerDeployCommandsModern(program) {
|
|
14
|
+
const deployCmd = program
|
|
15
|
+
.command('deploy')
|
|
16
|
+
.description('触发 modern 应用发布:本地构建 + 本地部署(preRelease + localPublish)')
|
|
17
|
+
.option('--dir <path>', '项目目录', '.')
|
|
18
|
+
.option('--skip-build', '跳过 build 步骤(已构建好时使用)', false)
|
|
19
|
+
.addHelpText('after', `
|
|
20
|
+
不要用异步模式或后台模式调用 deploy,否则调用可能提前结束,Agent 会误判发布已完成。
|
|
21
|
+
|
|
22
|
+
前置要求
|
|
23
|
+
- 项目已 init(.spark/meta.json 含 appId / template)
|
|
24
|
+
- node_modules 已安装
|
|
25
|
+
- package.json 含 build script
|
|
26
|
+
- 沙箱内预装 tosutil(用于把构建产物上传到 TOS)
|
|
27
|
+
|
|
28
|
+
流程概览(stderr 进度提示)
|
|
29
|
+
1. prepareContext 2. preRelease 3. build
|
|
30
|
+
4. createLocalRelease 5. uploadArtifacts
|
|
31
|
+
6. savePluginInstances(扫描 dist/output_capabilities/*.json 批量注册)
|
|
32
|
+
7. finalizeLocalRelease(Finished|Failed)
|
|
33
|
+
|
|
34
|
+
JSON 输出(stdout)
|
|
35
|
+
{"data": {"appId": "...", "version": <n>, "url": "...", "releaseID": "...", "preReleaseID": "..."}}
|
|
36
|
+
|
|
37
|
+
示例
|
|
38
|
+
$ miaoda deploy
|
|
39
|
+
$ miaoda deploy --dir ./my-app
|
|
40
|
+
$ miaoda deploy --skip-build
|
|
41
|
+
`);
|
|
42
|
+
deployCmd.action((0, shared_1.withHelp)(deployCmd, async (rawOpts) => {
|
|
43
|
+
await (0, modern_1.handleDeployModern)({
|
|
44
|
+
dir: rawOpts.dir ?? '.',
|
|
45
|
+
skipBuild: rawOpts.skipBuild,
|
|
46
|
+
});
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
@@ -13,40 +13,40 @@ const shared_1 = require("../../../cli/commands/shared");
|
|
|
13
13
|
function parsePositiveInt(raw) {
|
|
14
14
|
const n = Number(raw);
|
|
15
15
|
if (!Number.isInteger(n) || n < 1) {
|
|
16
|
-
throw new error_1.AppError(
|
|
16
|
+
throw new error_1.AppError('ARGS_INVALID', `--limit must be a positive integer (got '${raw}')`);
|
|
17
17
|
}
|
|
18
18
|
return n;
|
|
19
19
|
}
|
|
20
20
|
function registerFileCommands(program) {
|
|
21
21
|
const fileCmd = program
|
|
22
|
-
.command(
|
|
23
|
-
.description(
|
|
24
|
-
|
|
25
|
-
.usage(
|
|
22
|
+
.command('file')
|
|
23
|
+
.description('应用文件存储(TOS)的命令行操作集合。操作对象是 UGC 资源(用户上传的文件、应用运行时\n' +
|
|
24
|
+
'生成的报表 / 导出文件等),不涉及代码仓库里的本地文件。')
|
|
25
|
+
.usage('<command> [flags]');
|
|
26
26
|
fileCmd.action(() => {
|
|
27
27
|
fileCmd.outputHelp();
|
|
28
28
|
});
|
|
29
29
|
fileCmd
|
|
30
|
-
.command(
|
|
31
|
-
.summary(
|
|
32
|
-
.description(
|
|
33
|
-
|
|
34
|
-
.usage(
|
|
35
|
-
.argument(
|
|
36
|
-
.option(
|
|
37
|
-
.option(
|
|
38
|
-
.option(
|
|
39
|
-
.option(
|
|
40
|
-
.option(
|
|
41
|
-
.option(
|
|
42
|
-
.option(
|
|
43
|
-
.option(
|
|
44
|
-
.option(
|
|
45
|
-
.option(
|
|
30
|
+
.command('ls')
|
|
31
|
+
.summary('列出 / 筛选文件')
|
|
32
|
+
.description('列出当前应用存储里的文件,支持按文件名、大小、上传时间筛选,以及游标分页。\n' +
|
|
33
|
+
'默认 pretty 输出省略 download_url(列宽限制),需获取请用 --json。')
|
|
34
|
+
.usage('[query] [flags]')
|
|
35
|
+
.argument('[query]', '筛选值:以 / 开头视为路径精确匹配,否则按文件名精确匹配')
|
|
36
|
+
.option('--path <path>', '按路径精确匹配')
|
|
37
|
+
.option('--name <name>', '按文件名精确匹配')
|
|
38
|
+
.option('--type <mime>', '按 MIME 类型筛选(如 image/png)')
|
|
39
|
+
.option('--size-gt <size>', '文件大小下限(支持 B / KB / MB / GB)')
|
|
40
|
+
.option('--size-lt <size>', '文件大小上限(支持 B / KB / MB / GB)')
|
|
41
|
+
.option('--uploaded-since <time>', '上传时间下限(晚于该时间)')
|
|
42
|
+
.option('--uploaded-until <time>', '上传时间上限(早于该时间)')
|
|
43
|
+
.option('--limit <n>', '单次返回上限(正整数,默认 50)', parsePositiveInt, 50)
|
|
44
|
+
.option('--cursor <token>', '分页游标,从上次响应的 next_cursor 取值')
|
|
45
|
+
.option('--all', '自动翻页返回全部结果')
|
|
46
46
|
.action(async (query, opts) => {
|
|
47
47
|
await (0, index_1.handleFileLs)({ ...opts, appId: (0, shared_1.resolveAppId)({}), query });
|
|
48
48
|
})
|
|
49
|
-
.addHelpText(
|
|
49
|
+
.addHelpText('after', `
|
|
50
50
|
Examples:
|
|
51
51
|
$ miaoda file ls
|
|
52
52
|
file_name path size type uploaded_at
|
|
@@ -62,16 +62,16 @@ Examples:
|
|
|
62
62
|
...
|
|
63
63
|
`);
|
|
64
64
|
fileCmd
|
|
65
|
-
.command(
|
|
66
|
-
.summary(
|
|
67
|
-
.description(
|
|
68
|
-
|
|
69
|
-
.usage(
|
|
70
|
-
.argument(
|
|
65
|
+
.command('stat')
|
|
66
|
+
.summary('查看单文件元数据')
|
|
67
|
+
.description('查看单文件完整元数据,含 download_url(应用内消费)。\n' +
|
|
68
|
+
'需要公网可访问的临时链接请用 `file sign` 生成 signed_url。')
|
|
69
|
+
.usage('<file> [flags]')
|
|
70
|
+
.argument('<file>', '文件的路径或文件名(自动识别)')
|
|
71
71
|
.action(async (file, opts) => {
|
|
72
72
|
await (0, index_1.handleFileStat)(file, { ...opts, appId: (0, shared_1.resolveAppId)({}) });
|
|
73
73
|
})
|
|
74
|
-
.addHelpText(
|
|
74
|
+
.addHelpText('after', `
|
|
75
75
|
Notes:
|
|
76
76
|
- <file> 可传 path(推荐,全局唯一)或 file_name。
|
|
77
77
|
- file_name 重名时报 AMBIGUOUS_FILE_NAME,需先 \`ls --name\` 拿到 path 再调用。
|
|
@@ -92,19 +92,19 @@ Examples:
|
|
|
92
92
|
hint: Use path instead. Run \`miaoda file ls --name logo.png\` to see candidates.
|
|
93
93
|
`);
|
|
94
94
|
fileCmd
|
|
95
|
-
.command(
|
|
96
|
-
.summary(
|
|
97
|
-
.description(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
.usage(
|
|
101
|
-
.argument(
|
|
102
|
-
.argument(
|
|
103
|
-
.option(
|
|
95
|
+
.command('cp')
|
|
96
|
+
.summary('上传或下载文件(方向由路径前缀自动判断)')
|
|
97
|
+
.description('上传或下载文件,方向由 src/dst 路径前缀自动判断:\n' +
|
|
98
|
+
' / 开头 → 远程 TOS 路径\n' +
|
|
99
|
+
' ./、~/、裸文件名 → 本地路径')
|
|
100
|
+
.usage('<src> <dst> [flags]')
|
|
101
|
+
.argument('<src>', '源:本地文件路径或远程文件路径 / 文件名')
|
|
102
|
+
.argument('<dst>', '目标:本地路径或远程路径')
|
|
103
|
+
.option('--rename <name>', '上传后在远端使用的新文件名')
|
|
104
104
|
.action(async (src, dst, opts) => {
|
|
105
105
|
await (0, index_1.handleFileCp)(src, dst, { ...opts, appId: (0, shared_1.resolveAppId)({}) });
|
|
106
106
|
})
|
|
107
|
-
.addHelpText(
|
|
107
|
+
.addHelpText('after', `
|
|
108
108
|
Notes:
|
|
109
109
|
- 单文件上限 100 MB,超过请拆分或用 web console 上传。
|
|
110
110
|
- 同目录下允许同 file_name 并存(每次上传生成新的 path),不会因重名失败。
|
|
@@ -139,18 +139,18 @@ Examples:
|
|
|
139
139
|
hint: Split the file, or use the web console for large uploads.
|
|
140
140
|
`);
|
|
141
141
|
fileCmd
|
|
142
|
-
.command(
|
|
143
|
-
.summary(
|
|
144
|
-
.description(
|
|
145
|
-
|
|
146
|
-
.usage(
|
|
147
|
-
.argument(
|
|
148
|
-
.option(
|
|
149
|
-
.option(
|
|
142
|
+
.command('rm')
|
|
143
|
+
.summary('删除一个或多个文件')
|
|
144
|
+
.description('删除一个或多个文件。<file> 可传 path(推荐)或 file_name,可混用。\n' +
|
|
145
|
+
'操作不可撤销(不进回收站),TTY 下默认会要求二次确认。')
|
|
146
|
+
.usage('[paths...] [flags]')
|
|
147
|
+
.argument('[paths...]', '要删除的文件,每项可填路径或文件名(自动识别)')
|
|
148
|
+
.option('-n, --name <name>', '按文件名删除(可重复指定)', (value, prev) => [...(prev ?? []), value])
|
|
149
|
+
.option('-y, --yes', '跳过交互确认;非交互场景必加')
|
|
150
150
|
.action(async (paths, opts) => {
|
|
151
151
|
await (0, index_1.handleFileRm)(paths, { ...opts, appId: (0, shared_1.resolveAppId)({}) });
|
|
152
152
|
})
|
|
153
|
-
.addHelpText(
|
|
153
|
+
.addHelpText('after', `
|
|
154
154
|
Notes:
|
|
155
155
|
- 删除不可撤销,没有回收站。
|
|
156
156
|
- 批量场景下失败项不影响其他项;全部成功退出码 0,任意一项失败退出码 1。
|
|
@@ -159,7 +159,7 @@ Notes:
|
|
|
159
159
|
Examples:
|
|
160
160
|
# 单文件删除(TTY 下需确认)
|
|
161
161
|
$ miaoda file rm /images/brand/1858537546760216.png
|
|
162
|
-
?
|
|
162
|
+
? Are you sure you want to permanently delete '/images/brand/1858537546760216.png'? (y/N) y
|
|
163
163
|
✓ Deleted /images/brand/1858537546760216.png
|
|
164
164
|
|
|
165
165
|
# 批量删除(混用 path 与 file_name)
|
|
@@ -182,18 +182,18 @@ Examples:
|
|
|
182
182
|
hint: Use path instead. Run \`miaoda file ls --name logo.png\` to see candidates.
|
|
183
183
|
`);
|
|
184
184
|
fileCmd
|
|
185
|
-
.command(
|
|
186
|
-
.summary(
|
|
187
|
-
.description(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
.usage(
|
|
191
|
-
.argument(
|
|
192
|
-
.option(
|
|
185
|
+
.command('sign')
|
|
186
|
+
.summary('生成公网可访问的临时下载链接')
|
|
187
|
+
.description('生成 signed_url——公网可直接访问的临时下载链接,带过期时间。\n' +
|
|
188
|
+
'仅在需要浏览器打开 / 公网分享时使用;应用代码内引用文件请用 download_url\n' +
|
|
189
|
+
'(来自 cp 或 stat),无需 sign。')
|
|
190
|
+
.usage('<file> [flags]')
|
|
191
|
+
.argument('<file>', '文件的路径或文件名')
|
|
192
|
+
.option('--expires <duration>', '链接有效期,支持 30m / 24h / 7d 等单位(默认 1d,最长 30d)')
|
|
193
193
|
.action(async (file, opts) => {
|
|
194
194
|
await (0, index_1.handleFileSign)(file, { ...opts, appId: (0, shared_1.resolveAppId)({}) });
|
|
195
195
|
})
|
|
196
|
-
.addHelpText(
|
|
196
|
+
.addHelpText('after', `
|
|
197
197
|
Notes:
|
|
198
198
|
- <file> 可传 path(推荐)或 file_name;重名报 AMBIGUOUS_FILE_NAME。
|
|
199
199
|
- signed_url 会过期,不要持久化到数据库。永久引用请用 download_url。
|
|
@@ -209,5 +209,32 @@ Examples:
|
|
|
209
209
|
$ miaoda file sign /images/brand/1858537546760216.png --expires 60d
|
|
210
210
|
Error: Expires duration '60d' exceeds the maximum of 30d
|
|
211
211
|
hint: Maximum allowed value is 30d. Use \`--expires 30d\` for the longest link.
|
|
212
|
+
`);
|
|
213
|
+
fileCmd
|
|
214
|
+
.command('quota')
|
|
215
|
+
.summary('查看文件存储的用量与配额')
|
|
216
|
+
.description('查看文件存储的用量与配额。')
|
|
217
|
+
.usage('[flags]')
|
|
218
|
+
.action(async function () {
|
|
219
|
+
await (0, index_1.handleFileQuota)(this.optsWithGlobals());
|
|
220
|
+
})
|
|
221
|
+
.addHelpText('after', `
|
|
222
|
+
Examples:
|
|
223
|
+
$ miaoda file quota
|
|
224
|
+
Storage: 150 MB / 1 GB (15%)
|
|
225
|
+
Files: 42
|
|
226
|
+
|
|
227
|
+
# --json
|
|
228
|
+
$ miaoda file quota --json
|
|
229
|
+
{
|
|
230
|
+
"data": {
|
|
231
|
+
"storage_used_bytes": 157286400,
|
|
232
|
+
"storage_quota_bytes": 1073741824,
|
|
233
|
+
"usage_percent": 15,
|
|
234
|
+
"files": 42
|
|
235
|
+
},
|
|
236
|
+
"next_cursor": null,
|
|
237
|
+
"has_more": false
|
|
238
|
+
}
|
|
212
239
|
`);
|
|
213
240
|
}
|
|
@@ -1,15 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveScene = resolveScene;
|
|
3
4
|
exports.registerCommands = registerCommands;
|
|
4
5
|
const index_1 = require("../../cli/commands/file/index");
|
|
5
6
|
const index_2 = require("../../cli/commands/db/index");
|
|
6
7
|
const index_3 = require("../../cli/commands/observability/index");
|
|
7
8
|
const index_4 = require("../../cli/commands/app/index");
|
|
8
9
|
const index_5 = require("../../cli/commands/deploy/index");
|
|
10
|
+
const modern_1 = require("../../cli/commands/deploy/modern");
|
|
11
|
+
function resolveScene(appType, _archType) {
|
|
12
|
+
if (appType === '7')
|
|
13
|
+
return 'modern';
|
|
14
|
+
return 'default';
|
|
15
|
+
}
|
|
16
|
+
const SCENE_REGISTRARS = {
|
|
17
|
+
default: (p) => {
|
|
18
|
+
(0, index_4.registerAppCommands)(p);
|
|
19
|
+
(0, index_5.registerDeployCommands)(p);
|
|
20
|
+
(0, index_2.registerDbCommands)(p);
|
|
21
|
+
(0, index_1.registerFileCommands)(p);
|
|
22
|
+
(0, index_3.registerObservabilityCommands)(p);
|
|
23
|
+
},
|
|
24
|
+
modern: (p) => {
|
|
25
|
+
(0, index_4.registerAppCommands)(p, { includeInit: true });
|
|
26
|
+
(0, modern_1.registerDeployCommandsModern)(p);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
function readEnv(name) {
|
|
30
|
+
const v = process.env[name]?.trim();
|
|
31
|
+
return v !== undefined && v !== '' ? v : undefined;
|
|
32
|
+
}
|
|
9
33
|
function registerCommands(program) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
(
|
|
13
|
-
(
|
|
14
|
-
(
|
|
34
|
+
const appType = readEnv('MIAODA_APP_TYPE');
|
|
35
|
+
const archType = readEnv('MIAODA_APP_ARCH_TYPE');
|
|
36
|
+
const scene = resolveScene(appType, archType);
|
|
37
|
+
SCENE_REGISTRARS[scene](program);
|
|
38
|
+
if (process.env.MIAODA_VERBOSE === '1' || process.argv.includes('--verbose')) {
|
|
39
|
+
process.stderr.write(`[miaoda] scene=${scene} app_type=${appType ?? '-'} arch_type=${archType ?? '-'}\n`);
|
|
40
|
+
}
|
|
15
41
|
}
|