connect-api-cli 1.1.3 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -19
- package/dist/cli.js +523 -331
- package/dist/index.d.mts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +234 -30
- package/dist/index.mjs +1379 -10
- package/package.json +11 -7
- package/dist/chunk-3WGV37EN.mjs +0 -1187
- package/dist/chunk-3WGV37EN.mjs.map +0 -1
- package/dist/cli.d.mts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/cli.mjs +0 -1711
- package/dist/cli.mjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/cli.mjs
DELETED
|
@@ -1,1711 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
AuthManager,
|
|
4
|
-
ProjectService,
|
|
5
|
-
ProvisionService,
|
|
6
|
-
PublishService,
|
|
7
|
-
UploadService,
|
|
8
|
-
agcClient,
|
|
9
|
-
getCachedOAuthTeamId,
|
|
10
|
-
getConfig
|
|
11
|
-
} from "./chunk-3WGV37EN.mjs";
|
|
12
|
-
|
|
13
|
-
// src/cli/index.ts
|
|
14
|
-
import { Command } from "commander";
|
|
15
|
-
import * as fs3 from "fs";
|
|
16
|
-
import path2 from "path";
|
|
17
|
-
|
|
18
|
-
// src/services/domain.ts
|
|
19
|
-
import fs from "fs";
|
|
20
|
-
var DomainService = class {
|
|
21
|
-
/**
|
|
22
|
-
* 查询元服务的域名配置信息
|
|
23
|
-
*/
|
|
24
|
-
static async queryDomain(req) {
|
|
25
|
-
const response = await agcClient.get(
|
|
26
|
-
"/api/dms/domain-manage/v1/app/domain",
|
|
27
|
-
{
|
|
28
|
-
params: { category: req.category },
|
|
29
|
-
headers: { appId: req.appId }
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
return response.data;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* 新增/更新元服务的域名配置信息
|
|
36
|
-
*/
|
|
37
|
-
static async updateDomain(req) {
|
|
38
|
-
const response = await agcClient.post(
|
|
39
|
-
"/api/dms/domain-manage/v1/app/domain",
|
|
40
|
-
{ domains: req.domains },
|
|
41
|
-
{
|
|
42
|
-
params: { category: req.category },
|
|
43
|
-
headers: { appId: req.appId }
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
return response.data;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* 查询域名修改次数/配置上限
|
|
50
|
-
*/
|
|
51
|
-
static async queryDomainConfig(req) {
|
|
52
|
-
const response = await agcClient.get(
|
|
53
|
-
"/api/dms/domain-manage/v1/app/domain/config",
|
|
54
|
-
{
|
|
55
|
-
params: { appId: req.appId }
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
return response.data;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* 下载域名配置文件
|
|
62
|
-
*/
|
|
63
|
-
static async verifyFile(req, outputPath) {
|
|
64
|
-
const response = await agcClient.get(
|
|
65
|
-
"/api/dms/domain-manage/v1/app/domain/verify-file",
|
|
66
|
-
{
|
|
67
|
-
headers: { appId: req.appId },
|
|
68
|
-
responseType: "stream"
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
return new Promise((resolve, reject) => {
|
|
72
|
-
const writer = fs.createWriteStream(outputPath);
|
|
73
|
-
response.data.pipe(writer);
|
|
74
|
-
let error = null;
|
|
75
|
-
writer.on("error", (err) => {
|
|
76
|
-
error = err;
|
|
77
|
-
writer.close();
|
|
78
|
-
reject(err);
|
|
79
|
-
});
|
|
80
|
-
writer.on("close", () => {
|
|
81
|
-
if (!error) {
|
|
82
|
-
resolve();
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* 预检查业务域名配置
|
|
89
|
-
*/
|
|
90
|
-
static async preCheckDomain(req) {
|
|
91
|
-
const response = await agcClient.post(
|
|
92
|
-
"/api/dms/domain-manage/v1/app/domain/pre-check",
|
|
93
|
-
{ domain: req.domain },
|
|
94
|
-
{
|
|
95
|
-
headers: { appId: req.appId }
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
return response.data;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// src/services/sign.ts
|
|
103
|
-
import fs2 from "fs";
|
|
104
|
-
import path from "path";
|
|
105
|
-
import { execFileSync } from "child_process";
|
|
106
|
-
import crypto from "crypto";
|
|
107
|
-
var DEFAULT_SIGN_OUT_DIR = ".certs";
|
|
108
|
-
var SIGN_FILE_PREFIX = {
|
|
109
|
-
p12: "key_",
|
|
110
|
-
csr: "key_",
|
|
111
|
-
cer: "cert_",
|
|
112
|
-
p7b: "profile_"
|
|
113
|
-
};
|
|
114
|
-
var SignService = class {
|
|
115
|
-
static resolveSignOutputLayout(options) {
|
|
116
|
-
const rootDir = options.outDir ? path.resolve(options.outDir) : path.join(process.cwd(), DEFAULT_SIGN_OUT_DIR);
|
|
117
|
-
const signId = options.filename || this.createSignDefaultId();
|
|
118
|
-
return {
|
|
119
|
-
rootDir,
|
|
120
|
-
bundleDir: path.join(rootDir, signId),
|
|
121
|
-
filename: signId
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
static async createSignP12AndCsr(options) {
|
|
125
|
-
const javaPath = options.javaPath || "java";
|
|
126
|
-
const sdkPath = options.sdkPath || process.env.HARMONYOS_SDK_PATH;
|
|
127
|
-
if (!sdkPath) {
|
|
128
|
-
throw new Error("sdkPath is required. Provide it via --sdk-path or HARMONYOS_SDK_PATH env var.");
|
|
129
|
-
}
|
|
130
|
-
const signToolPath = path.join(sdkPath, "default", "openharmony", "toolchains", "lib", "hap-sign-tool.jar");
|
|
131
|
-
if (!fs2.existsSync(signToolPath)) {
|
|
132
|
-
throw new Error(`hap-sign-tool.jar not found at ${signToolPath}`);
|
|
133
|
-
}
|
|
134
|
-
const { rootDir, bundleDir, filename } = this.resolveSignOutputLayout(options);
|
|
135
|
-
const createdBundleDir = !fs2.existsSync(bundleDir);
|
|
136
|
-
if (!fs2.existsSync(rootDir)) {
|
|
137
|
-
fs2.mkdirSync(rootDir, { recursive: true });
|
|
138
|
-
}
|
|
139
|
-
fs2.mkdirSync(bundleDir, { recursive: true });
|
|
140
|
-
const p12FilePath = path.join(bundleDir, this.signFileName(filename, "p12"));
|
|
141
|
-
const csrFilePath = path.join(bundleDir, this.signFileName(filename, "csr"));
|
|
142
|
-
const alias = options.alias;
|
|
143
|
-
const pwd = options.pwd || this.createSignDefaultPassword();
|
|
144
|
-
try {
|
|
145
|
-
this.doCreateSignFileP12(javaPath, signToolPath, alias, pwd, p12FilePath);
|
|
146
|
-
this.doCreateSignFileCsr(javaPath, signToolPath, alias, pwd, p12FilePath, csrFilePath);
|
|
147
|
-
const csrContent = fs2.readFileSync(csrFilePath, "utf8");
|
|
148
|
-
const materialPath = this.placeMaterialBesideStore(bundleDir);
|
|
149
|
-
return {
|
|
150
|
-
alias,
|
|
151
|
-
filename,
|
|
152
|
-
pwd,
|
|
153
|
-
p12Path: p12FilePath,
|
|
154
|
-
csrPath: csrFilePath,
|
|
155
|
-
csrContent,
|
|
156
|
-
storePath: bundleDir,
|
|
157
|
-
cerPath: path.join(bundleDir, this.signFileName(filename, "cer")),
|
|
158
|
-
p7bPath: path.join(bundleDir, this.signFileName(filename, "p7b")),
|
|
159
|
-
...materialPath ? { materialPath } : {}
|
|
160
|
-
};
|
|
161
|
-
} catch (err) {
|
|
162
|
-
if (createdBundleDir) {
|
|
163
|
-
fs2.rmSync(bundleDir, { recursive: true, force: true });
|
|
164
|
-
}
|
|
165
|
-
throw err;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
/** 目录名与各文件共用的安全随机数(32 hex) */
|
|
169
|
-
static createSignDefaultId() {
|
|
170
|
-
return crypto.randomBytes(16).toString("hex");
|
|
171
|
-
}
|
|
172
|
-
/** `key_<id>.p12` / `cert_<id>.cer` / `profile_<id>.p7b` 等 */
|
|
173
|
-
static signFileName(id, ext) {
|
|
174
|
-
return `${SIGN_FILE_PREFIX[ext]}${id}.${ext}`;
|
|
175
|
-
}
|
|
176
|
-
/** 密钥库密码:16 字节 CSPRNG → 32 hex(字母+数字,满足 hap-sign-tool 约束) */
|
|
177
|
-
static createSignDefaultPassword() {
|
|
178
|
-
return crypto.randomBytes(16).toString("hex");
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* hvigor 在 `.p12` 同级目录找 `material/`。把 DevEco 的加密材料放到本套证书目录,
|
|
182
|
-
* 避免签名文件被拷到工程根目录才能编过。
|
|
183
|
-
*/
|
|
184
|
-
static placeMaterialBesideStore(bundleDir, configDir) {
|
|
185
|
-
const dest = path.join(bundleDir, "material");
|
|
186
|
-
if (fs2.existsSync(dest)) {
|
|
187
|
-
return dest;
|
|
188
|
-
}
|
|
189
|
-
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
190
|
-
const src = path.resolve(configDir || path.join(home, ".ohos", "config"), "material");
|
|
191
|
-
if (!fs2.existsSync(src)) {
|
|
192
|
-
return void 0;
|
|
193
|
-
}
|
|
194
|
-
try {
|
|
195
|
-
fs2.symlinkSync(src, dest, process.platform === "win32" ? "junction" : "dir");
|
|
196
|
-
} catch {
|
|
197
|
-
fs2.cpSync(src, dest, { recursive: true });
|
|
198
|
-
}
|
|
199
|
-
return dest;
|
|
200
|
-
}
|
|
201
|
-
/** 需要在日志中遮蔽的敏感参数名 */
|
|
202
|
-
static SENSITIVE_ARGS = /* @__PURE__ */ new Set(["-keyPwd", "-keystorePwd"]);
|
|
203
|
-
/** 打印命令行时隐去密码值,避免明文泄露 */
|
|
204
|
-
static maskArgs(args) {
|
|
205
|
-
return args.map((arg, i) => i > 0 && this.SENSITIVE_ARGS.has(args[i - 1]) ? "******" : arg).join(" ");
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* 执行签名工具:命令行与子进程输出统一走 stderr,
|
|
209
|
-
* 保证 stdout 只有 CLI 的 JSON 结果,便于 jq 等下游解析。
|
|
210
|
-
*/
|
|
211
|
-
static runSignTool(javaPath, args) {
|
|
212
|
-
console.error(`Executing: ${javaPath} ${this.maskArgs(args)}`);
|
|
213
|
-
execFileSync(javaPath, args, { stdio: ["ignore", 2, "inherit"] });
|
|
214
|
-
}
|
|
215
|
-
static doCreateSignFileP12(javaPath, signToolPath, alias, pwd, outFilePath) {
|
|
216
|
-
const args = [
|
|
217
|
-
"-jar",
|
|
218
|
-
signToolPath,
|
|
219
|
-
"generate-keypair",
|
|
220
|
-
"-keyAlias",
|
|
221
|
-
alias,
|
|
222
|
-
"-keyPwd",
|
|
223
|
-
pwd,
|
|
224
|
-
"-keyAlg",
|
|
225
|
-
"ECC",
|
|
226
|
-
"-keySize",
|
|
227
|
-
"NIST-P-256",
|
|
228
|
-
"-keystoreFile",
|
|
229
|
-
outFilePath,
|
|
230
|
-
"-keystorePwd",
|
|
231
|
-
pwd
|
|
232
|
-
];
|
|
233
|
-
this.runSignTool(javaPath, args);
|
|
234
|
-
}
|
|
235
|
-
static doCreateSignFileCsr(javaPath, signToolPath, alias, pwd, p12Path, outFilePath) {
|
|
236
|
-
const args = [
|
|
237
|
-
"-jar",
|
|
238
|
-
signToolPath,
|
|
239
|
-
"generate-csr",
|
|
240
|
-
"-keyAlias",
|
|
241
|
-
alias,
|
|
242
|
-
"-keyPwd",
|
|
243
|
-
pwd,
|
|
244
|
-
"-subject",
|
|
245
|
-
"C=CN,O=OpenHarmony,OU=OpenHarmony Community,CN=App Release",
|
|
246
|
-
"-signAlg",
|
|
247
|
-
"SHA256withECDSA",
|
|
248
|
-
"-keystoreFile",
|
|
249
|
-
p12Path,
|
|
250
|
-
"-keystorePwd",
|
|
251
|
-
pwd,
|
|
252
|
-
"-outFile",
|
|
253
|
-
outFilePath
|
|
254
|
-
];
|
|
255
|
-
this.runSignTool(javaPath, args);
|
|
256
|
-
}
|
|
257
|
-
static COMPONENT = new Int8Array([49, 243, 9, 115, 214, 175, 91, 184, 211, 190, 177, 88, 101, 131, 192, 119]);
|
|
258
|
-
static readDirBytes(dirPath) {
|
|
259
|
-
const entries = fs2.readdirSync(dirPath).filter((f) => f !== ".DS_Store");
|
|
260
|
-
return new Int8Array(fs2.readFileSync(path.resolve(dirPath, entries[0])));
|
|
261
|
-
}
|
|
262
|
-
static readFd(materialPath) {
|
|
263
|
-
const fdDir = path.resolve(materialPath, "fd");
|
|
264
|
-
return fs2.readdirSync(fdDir).filter((f) => f !== ".DS_Store").map((e) => this.readDirBytes(path.resolve(fdDir, e)));
|
|
265
|
-
}
|
|
266
|
-
static xorBuffers(a, b) {
|
|
267
|
-
const result = new Int8Array(a.byteLength);
|
|
268
|
-
for (let i = 0; i < a.byteLength; i++) result[i] = a[i] ^ b[i];
|
|
269
|
-
return result;
|
|
270
|
-
}
|
|
271
|
-
static xorAll(components) {
|
|
272
|
-
let result = this.xorBuffers(components[0], components[1]);
|
|
273
|
-
for (let i = 2; i < components.length; i++) result = this.xorBuffers(result, components[i]);
|
|
274
|
-
return Buffer.from(result);
|
|
275
|
-
}
|
|
276
|
-
static aesDecrypt(key, data) {
|
|
277
|
-
const d = Buffer.from(data);
|
|
278
|
-
const tagLen = (255 & d[0]) << 24 | (255 & d[1]) << 16 | (255 & d[2]) << 8 | 255 & d[3];
|
|
279
|
-
const ivLen = d.length - 4 - tagLen;
|
|
280
|
-
const iv = d.subarray(4, 4 + ivLen);
|
|
281
|
-
const decipher = crypto.createDecipheriv("aes-128-gcm", key, iv);
|
|
282
|
-
decipher.setAuthTag(d.subarray(d.length - 16));
|
|
283
|
-
return Buffer.concat([decipher.update(d.subarray(4 + ivLen, d.length - 16)), decipher.final()]);
|
|
284
|
-
}
|
|
285
|
-
static aesEncrypt(key, plaintext) {
|
|
286
|
-
const iv = crypto.randomBytes(12);
|
|
287
|
-
const cipher = crypto.createCipheriv("aes-128-gcm", key, iv);
|
|
288
|
-
const enc = Buffer.concat([cipher.update(plaintext, "utf-8"), cipher.final()]);
|
|
289
|
-
const tag = cipher.getAuthTag();
|
|
290
|
-
const header = Buffer.alloc(4);
|
|
291
|
-
header.writeUInt32BE(enc.length + 16, 0);
|
|
292
|
-
return Buffer.concat([header, iv, enc, tag]).toString("hex").toUpperCase();
|
|
293
|
-
}
|
|
294
|
-
static deriveEncryptionKey(configDir) {
|
|
295
|
-
const materialDir = path.resolve(configDir, "material");
|
|
296
|
-
const fd = this.readFd(materialDir);
|
|
297
|
-
const salt = this.readDirBytes(path.resolve(materialDir, "ac"));
|
|
298
|
-
const rawKey = new Int8Array(
|
|
299
|
-
crypto.pbkdf2Sync(this.xorAll(fd.concat(this.COMPONENT)).toString(), salt, 1e4, 16, "sha256")
|
|
300
|
-
);
|
|
301
|
-
return new Int8Array(this.aesDecrypt(rawKey, this.readDirBytes(path.resolve(materialDir, "ce"))));
|
|
302
|
-
}
|
|
303
|
-
/**
|
|
304
|
-
* 使用 DevEco Studio 的加密密钥对密码进行 AES-128-GCM 加密,
|
|
305
|
-
* 生成 build-profile.json5 中 signingConfigs 所需的加密密码。
|
|
306
|
-
*/
|
|
307
|
-
static encryptPassword(password, configDir) {
|
|
308
|
-
const dir = configDir || path.join(process.env.HOME || "", ".ohos", "config");
|
|
309
|
-
if (!fs2.existsSync(path.resolve(dir, "material"))) {
|
|
310
|
-
throw new Error(`\u672A\u627E\u5230\u52A0\u5BC6\u5BC6\u94A5\u76EE\u5F55: ${path.resolve(dir, "material")}\u3002\u8BF7\u786E\u8BA4 DevEco Studio \u5DF2\u5B89\u88C5\u5E76\u751F\u6210\u8FC7\u7B7E\u540D\u914D\u7F6E\u3002`);
|
|
311
|
-
}
|
|
312
|
-
const key = this.deriveEncryptionKey(dir);
|
|
313
|
-
return {
|
|
314
|
-
keyPassword: this.aesEncrypt(key, password),
|
|
315
|
-
storePassword: this.aesEncrypt(key, password)
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
// src/services/testing.ts
|
|
321
|
-
function appIdHeaders(appId) {
|
|
322
|
-
return { appId };
|
|
323
|
-
}
|
|
324
|
-
var TestingService = class {
|
|
325
|
-
// ---- 测试版本 ----
|
|
326
|
-
/** 新建测试版本 */
|
|
327
|
-
static async createVersion(req) {
|
|
328
|
-
const { appId, ...body } = req;
|
|
329
|
-
const response = await agcClient.post(
|
|
330
|
-
"/api/publish/v2/test/app/version",
|
|
331
|
-
{
|
|
332
|
-
releaseType: body.releaseType ?? 6,
|
|
333
|
-
testType: body.testType,
|
|
334
|
-
testDesc: body.testDesc,
|
|
335
|
-
...body.onshelfSelfDetect !== void 0 ? { onshelfSelfDetect: body.onshelfSelfDetect } : {}
|
|
336
|
-
},
|
|
337
|
-
{ params: { appId } }
|
|
338
|
-
);
|
|
339
|
-
return response.data;
|
|
340
|
-
}
|
|
341
|
-
/** 查询上架自检报告信息 */
|
|
342
|
-
static async getDetectReport(req) {
|
|
343
|
-
const response = await agcClient.get(
|
|
344
|
-
"/api/publish/v2/test/app/version/detect-report",
|
|
345
|
-
{ params: { appId: req.appId, versionId: req.versionId } }
|
|
346
|
-
);
|
|
347
|
-
return response.data;
|
|
348
|
-
}
|
|
349
|
-
/** 添加软件包到测试版本 */
|
|
350
|
-
static async addPackage(req) {
|
|
351
|
-
const { appId, ...body } = req;
|
|
352
|
-
const response = await agcClient.post(
|
|
353
|
-
"/api/publish/v2/test/version/pkg",
|
|
354
|
-
body,
|
|
355
|
-
{ params: { appId } }
|
|
356
|
-
);
|
|
357
|
-
return response.data;
|
|
358
|
-
}
|
|
359
|
-
/** 更新测试版本(绑包、群组、多语言等) */
|
|
360
|
-
static async updateVersion(req) {
|
|
361
|
-
const { appId, ...body } = req;
|
|
362
|
-
const response = await agcClient.put(
|
|
363
|
-
"/api/publish/v2/test/app/version",
|
|
364
|
-
body,
|
|
365
|
-
{ params: { appId } }
|
|
366
|
-
);
|
|
367
|
-
return response.data;
|
|
368
|
-
}
|
|
369
|
-
/** 更新测试生效版本 */
|
|
370
|
-
static async releaseVersion(req) {
|
|
371
|
-
const { appId, ...body } = req;
|
|
372
|
-
const response = await agcClient.put(
|
|
373
|
-
"/api/publish/v2/test/version/release",
|
|
374
|
-
body,
|
|
375
|
-
{ params: { appId } }
|
|
376
|
-
);
|
|
377
|
-
return response.data;
|
|
378
|
-
}
|
|
379
|
-
/** 更新有效期内的测试版本时间和额度信息 */
|
|
380
|
-
static async updateOpenTest(req) {
|
|
381
|
-
const { appId, ...body } = req;
|
|
382
|
-
const response = await agcClient.put(
|
|
383
|
-
"/api/publish/v2/test/version/open-test",
|
|
384
|
-
body,
|
|
385
|
-
{ params: { appId } }
|
|
386
|
-
);
|
|
387
|
-
return response.data;
|
|
388
|
-
}
|
|
389
|
-
/** 提交测试版本 */
|
|
390
|
-
static async submitVersion(req) {
|
|
391
|
-
const response = await agcClient.post(
|
|
392
|
-
"/api/publish/v2/test/app/version/submit",
|
|
393
|
-
{ versionId: req.versionId },
|
|
394
|
-
{ params: { appId: req.appId } }
|
|
395
|
-
);
|
|
396
|
-
return response.data;
|
|
397
|
-
}
|
|
398
|
-
/** 停止测试版本 */
|
|
399
|
-
static async stopVersion(req) {
|
|
400
|
-
const response = await agcClient.post(
|
|
401
|
-
"/api/publish/v2/test/version/stop",
|
|
402
|
-
{ versionId: req.versionId },
|
|
403
|
-
{ params: { appId: req.appId } }
|
|
404
|
-
);
|
|
405
|
-
return response.data;
|
|
406
|
-
}
|
|
407
|
-
/** 删除测试版本 */
|
|
408
|
-
static async deleteVersion(req) {
|
|
409
|
-
const response = await agcClient.delete(
|
|
410
|
-
"/api/publish/v2/test/app/version",
|
|
411
|
-
{ params: { appId: req.appId, versionId: req.versionId } }
|
|
412
|
-
);
|
|
413
|
-
return response.data;
|
|
414
|
-
}
|
|
415
|
-
// ---- 测试群组 ----
|
|
416
|
-
/** 新增测试群组 */
|
|
417
|
-
static async addGroup(req) {
|
|
418
|
-
const { appId, ...body } = req;
|
|
419
|
-
const response = await agcClient.post(
|
|
420
|
-
"/api/app-test/v1/test-group",
|
|
421
|
-
body,
|
|
422
|
-
{ headers: appIdHeaders(appId) }
|
|
423
|
-
);
|
|
424
|
-
return response.data;
|
|
425
|
-
}
|
|
426
|
-
/** 查询测试群组列表 */
|
|
427
|
-
static async listGroups(req) {
|
|
428
|
-
const params = {};
|
|
429
|
-
if (req.groupType !== void 0) params.groupType = req.groupType;
|
|
430
|
-
if (req.current !== void 0) params.current = req.current;
|
|
431
|
-
if (req.pageSize !== void 0) params.pageSize = req.pageSize;
|
|
432
|
-
const response = await agcClient.get(
|
|
433
|
-
"/api/app-test/v1/test-group/list",
|
|
434
|
-
{ params, headers: appIdHeaders(req.appId) }
|
|
435
|
-
);
|
|
436
|
-
return response.data;
|
|
437
|
-
}
|
|
438
|
-
/** 删除测试群组 */
|
|
439
|
-
static async deleteGroup(req) {
|
|
440
|
-
const response = await agcClient.delete(
|
|
441
|
-
"/api/app-test/v1/publish-api/test-group",
|
|
442
|
-
{ params: { groupId: req.groupId }, headers: appIdHeaders(req.appId) }
|
|
443
|
-
);
|
|
444
|
-
return response.data;
|
|
445
|
-
}
|
|
446
|
-
/** 修改测试群组 */
|
|
447
|
-
static async editGroup(req) {
|
|
448
|
-
const { appId, ...body } = req;
|
|
449
|
-
const response = await agcClient.put(
|
|
450
|
-
"/api/app-test/v2/test-group",
|
|
451
|
-
body,
|
|
452
|
-
{ headers: appIdHeaders(appId) }
|
|
453
|
-
);
|
|
454
|
-
return response.data;
|
|
455
|
-
}
|
|
456
|
-
/** 查询测试群组成员 */
|
|
457
|
-
static async listGroupUsers(req) {
|
|
458
|
-
const params = {
|
|
459
|
-
groupId: req.groupId,
|
|
460
|
-
appId: req.appId
|
|
461
|
-
};
|
|
462
|
-
if (req.current !== void 0) params.current = req.current;
|
|
463
|
-
if (req.pageSize !== void 0) params.pageSize = req.pageSize;
|
|
464
|
-
const response = await agcClient.get(
|
|
465
|
-
"/api/app-test/v1/test-user",
|
|
466
|
-
{ params, headers: appIdHeaders(req.appId) }
|
|
467
|
-
);
|
|
468
|
-
return response.data;
|
|
469
|
-
}
|
|
470
|
-
/** 新增测试群组成员 */
|
|
471
|
-
static async addGroupUser(req) {
|
|
472
|
-
const { appId, ...body } = req;
|
|
473
|
-
const response = await agcClient.post(
|
|
474
|
-
"/api/publish/v2/test/user",
|
|
475
|
-
body,
|
|
476
|
-
{ headers: appIdHeaders(appId) }
|
|
477
|
-
);
|
|
478
|
-
return response.data;
|
|
479
|
-
}
|
|
480
|
-
/** 删除测试群组成员 */
|
|
481
|
-
static async deleteGroupUser(req) {
|
|
482
|
-
const { appId, ...body } = req;
|
|
483
|
-
const response = await agcClient.delete(
|
|
484
|
-
"/api/publish/v2/test/user",
|
|
485
|
-
{ data: body, headers: appIdHeaders(appId) }
|
|
486
|
-
);
|
|
487
|
-
return response.data;
|
|
488
|
-
}
|
|
489
|
-
/** 发送邀请测试通知 */
|
|
490
|
-
static async notifyUsers(req) {
|
|
491
|
-
const { appId, ...body } = req;
|
|
492
|
-
const response = await agcClient.post(
|
|
493
|
-
"/api/publish/v1/test/user/action/notify",
|
|
494
|
-
body,
|
|
495
|
-
{ headers: appIdHeaders(appId) }
|
|
496
|
-
);
|
|
497
|
-
return response.data;
|
|
498
|
-
}
|
|
499
|
-
// ---- 邀请码 ----
|
|
500
|
-
/** 生成邀请码 */
|
|
501
|
-
static async createInviteCode(req) {
|
|
502
|
-
const { appId, ...body } = req;
|
|
503
|
-
const response = await agcClient.post(
|
|
504
|
-
"/api/app-test/v1/invitation-code",
|
|
505
|
-
body,
|
|
506
|
-
{ headers: appIdHeaders(appId) }
|
|
507
|
-
);
|
|
508
|
-
return response.data;
|
|
509
|
-
}
|
|
510
|
-
/** 查询测试群组邀请码 */
|
|
511
|
-
static async getInviteCode(req) {
|
|
512
|
-
const response = await agcClient.get(
|
|
513
|
-
"/api/app-test/v1/test-group/invitation-code",
|
|
514
|
-
{ params: { groupId: req.groupId }, headers: appIdHeaders(req.appId) }
|
|
515
|
-
);
|
|
516
|
-
return response.data;
|
|
517
|
-
}
|
|
518
|
-
/** 停止邀请码 */
|
|
519
|
-
static async stopInviteCode(req) {
|
|
520
|
-
const response = await agcClient.post(
|
|
521
|
-
"/api/app-test/v1/invitation-code/action/stop",
|
|
522
|
-
{ invitationCodeId: req.invitationCodeId },
|
|
523
|
-
{ headers: appIdHeaders(req.appId) }
|
|
524
|
-
);
|
|
525
|
-
return response.data;
|
|
526
|
-
}
|
|
527
|
-
/** 删除邀请码 */
|
|
528
|
-
static async deleteInviteCode(req) {
|
|
529
|
-
const response = await agcClient.delete(
|
|
530
|
-
"/api/app-test/v1/invitation-code",
|
|
531
|
-
{ params: { invitationCodeId: req.invitationCodeId }, headers: appIdHeaders(req.appId) }
|
|
532
|
-
);
|
|
533
|
-
return response.data;
|
|
534
|
-
}
|
|
535
|
-
// ---- 公开链接 ----
|
|
536
|
-
/** 创建公开链接 */
|
|
537
|
-
static async createPublicLink(req) {
|
|
538
|
-
const { appId, ...body } = req;
|
|
539
|
-
const response = await agcClient.post(
|
|
540
|
-
"/api/app-test/v1/test-group/public-link",
|
|
541
|
-
body,
|
|
542
|
-
{ headers: appIdHeaders(appId) }
|
|
543
|
-
);
|
|
544
|
-
return response.data;
|
|
545
|
-
}
|
|
546
|
-
/** 修改公开链接 */
|
|
547
|
-
static async editPublicLink(req) {
|
|
548
|
-
const { appId, ...body } = req;
|
|
549
|
-
const response = await agcClient.put(
|
|
550
|
-
"/api/app-test/v1/test-group/public-link",
|
|
551
|
-
body,
|
|
552
|
-
{ headers: appIdHeaders(appId) }
|
|
553
|
-
);
|
|
554
|
-
return response.data;
|
|
555
|
-
}
|
|
556
|
-
/** 查询公开链接 */
|
|
557
|
-
static async queryPublicLink(req) {
|
|
558
|
-
const response = await agcClient.get(
|
|
559
|
-
"/api/app-test/v1/test-group/public-link",
|
|
560
|
-
{ params: { groupId: req.groupId }, headers: appIdHeaders(req.appId) }
|
|
561
|
-
);
|
|
562
|
-
return response.data;
|
|
563
|
-
}
|
|
564
|
-
// ---- 问题反馈 ----
|
|
565
|
-
/** 查询测试问题反馈维度 */
|
|
566
|
-
static async queryFeedbackDimension(req) {
|
|
567
|
-
const { appId, ...body } = req;
|
|
568
|
-
const response = await agcClient.post(
|
|
569
|
-
"/api/app-test/v1/mgmt/tester-feedback-dimension/action/query",
|
|
570
|
-
body,
|
|
571
|
-
{ headers: appIdHeaders(appId) }
|
|
572
|
-
);
|
|
573
|
-
return response.data;
|
|
574
|
-
}
|
|
575
|
-
/** 查询测试问题反馈 */
|
|
576
|
-
static async queryFeedback(req) {
|
|
577
|
-
const { appId, ...body } = req;
|
|
578
|
-
const response = await agcClient.post(
|
|
579
|
-
"/api/app-test/v1/mgmt/tester-feedback/action/query",
|
|
580
|
-
body,
|
|
581
|
-
{ headers: appIdHeaders(appId) }
|
|
582
|
-
);
|
|
583
|
-
return response.data;
|
|
584
|
-
}
|
|
585
|
-
/** 删除测试问题反馈 */
|
|
586
|
-
static async deleteFeedback(req) {
|
|
587
|
-
const { appId, ...body } = req;
|
|
588
|
-
const response = await agcClient.delete(
|
|
589
|
-
"/api/app-test/v1/mgmt/tester-feedback",
|
|
590
|
-
{ data: body, headers: appIdHeaders(appId) }
|
|
591
|
-
);
|
|
592
|
-
return response.data;
|
|
593
|
-
}
|
|
594
|
-
};
|
|
595
|
-
|
|
596
|
-
// src/cli/project-pick.ts
|
|
597
|
-
import * as readline from "readline";
|
|
598
|
-
async function resolveProjectId(explicit) {
|
|
599
|
-
if (explicit) return explicit;
|
|
600
|
-
const res = await ProjectService.listProjects();
|
|
601
|
-
if (res.ret?.code !== 0) {
|
|
602
|
-
console.error(
|
|
603
|
-
`Failed to list projects: ret.code=${res.ret?.code} msg=${res.ret?.msg ?? "(none)"}`
|
|
604
|
-
);
|
|
605
|
-
return void 0;
|
|
606
|
-
}
|
|
607
|
-
const list = res.projectList ?? [];
|
|
608
|
-
if (list.length === 0) {
|
|
609
|
-
console.error("No projects found. Create a project in AppGallery Connect first.");
|
|
610
|
-
return void 0;
|
|
611
|
-
}
|
|
612
|
-
printProjectChoices(list);
|
|
613
|
-
if (!process.stdin.isTTY) {
|
|
614
|
-
console.error(
|
|
615
|
-
"Non-interactive mode: pass --project-id <id> (from project list)."
|
|
616
|
-
);
|
|
617
|
-
return void 0;
|
|
618
|
-
}
|
|
619
|
-
const answer = (await promptStderr("Select project by number or paste projectId: ")).trim();
|
|
620
|
-
if (!answer) {
|
|
621
|
-
console.error("No project selected.");
|
|
622
|
-
return void 0;
|
|
623
|
-
}
|
|
624
|
-
const byIndex = Number(answer);
|
|
625
|
-
if (Number.isInteger(byIndex) && byIndex >= 1 && byIndex <= list.length) {
|
|
626
|
-
const chosen = list[byIndex - 1];
|
|
627
|
-
console.error(`Using projectId=${chosen.projectId} (${chosen.name ?? ""})`);
|
|
628
|
-
return chosen.projectId;
|
|
629
|
-
}
|
|
630
|
-
const byId = list.find((p) => p.projectId === answer);
|
|
631
|
-
if (byId) {
|
|
632
|
-
console.error(`Using projectId=${byId.projectId} (${byId.name ?? ""})`);
|
|
633
|
-
return byId.projectId;
|
|
634
|
-
}
|
|
635
|
-
console.error(`Invalid selection: ${answer}`);
|
|
636
|
-
return void 0;
|
|
637
|
-
}
|
|
638
|
-
function printProjectChoices(list) {
|
|
639
|
-
console.error("Available projects (use projectId for app-create --project-id):");
|
|
640
|
-
list.forEach((p, i) => {
|
|
641
|
-
const name = p.name ? ` ${p.name}` : "";
|
|
642
|
-
console.error(` [${i + 1}] ${p.projectId}${name}`);
|
|
643
|
-
});
|
|
644
|
-
}
|
|
645
|
-
function promptStderr(question) {
|
|
646
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
647
|
-
return new Promise((resolve) => {
|
|
648
|
-
rl.question(question, (answer) => {
|
|
649
|
-
rl.close();
|
|
650
|
-
resolve(answer);
|
|
651
|
-
});
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
// src/cli/index.ts
|
|
656
|
-
var program = new Command();
|
|
657
|
-
function readCliVersion() {
|
|
658
|
-
if (typeof __CLI_VERSION__ === "string" && __CLI_VERSION__) {
|
|
659
|
-
return __CLI_VERSION__;
|
|
660
|
-
}
|
|
661
|
-
try {
|
|
662
|
-
const pkgPath = path2.join(__dirname, "..", "package.json");
|
|
663
|
-
const pkg = JSON.parse(fs3.readFileSync(pkgPath, "utf8"));
|
|
664
|
-
if (pkg.version) return pkg.version;
|
|
665
|
-
} catch {
|
|
666
|
-
}
|
|
667
|
-
return "0.0.0";
|
|
668
|
-
}
|
|
669
|
-
program.name("connect-api-cli").description("AppGallery Connect API CLI Tool").version(readCliVersion());
|
|
670
|
-
var authCmd = program.command("auth").description("Authentication management");
|
|
671
|
-
authCmd.command("login").description("Login and cache token (client_credentials / service_account JWT / OAuth browser)").action(async () => {
|
|
672
|
-
try {
|
|
673
|
-
const token = await AuthManager.login();
|
|
674
|
-
console.log("Successfully logged in. Token generated and cached.");
|
|
675
|
-
console.log(`Token snippet: ${token.substring(0, 10)}...`);
|
|
676
|
-
} catch (e) {
|
|
677
|
-
console.error("Login failed:", e.message);
|
|
678
|
-
}
|
|
679
|
-
});
|
|
680
|
-
authCmd.command("status").description("Show current auth mode and cached token status").action(() => {
|
|
681
|
-
let cfg;
|
|
682
|
-
try {
|
|
683
|
-
cfg = getConfig();
|
|
684
|
-
} catch (e) {
|
|
685
|
-
console.error(`Auth status unavailable: ${e.message}`);
|
|
686
|
-
process.exitCode = 1;
|
|
687
|
-
return;
|
|
688
|
-
}
|
|
689
|
-
const status = AuthManager.getStatus();
|
|
690
|
-
console.log(`Auth mode: ${cfg.authMode}`);
|
|
691
|
-
if (cfg.authMode === "service_account") {
|
|
692
|
-
console.log(`Key ID: ${cfg.clientId}`);
|
|
693
|
-
if (cfg.serviceAccount) {
|
|
694
|
-
console.log(`Credentials: ${cfg.serviceAccount.credentialsPath}`);
|
|
695
|
-
}
|
|
696
|
-
} else {
|
|
697
|
-
console.log(`Client ID: ${cfg.clientId}`);
|
|
698
|
-
}
|
|
699
|
-
if (cfg.authMode === "oauth") {
|
|
700
|
-
const teamId = cfg.teamId || getCachedOAuthTeamId();
|
|
701
|
-
console.log(`Team ID: ${teamId || "(auto on first API call; or set AGC_TEAM_ID)"}`);
|
|
702
|
-
}
|
|
703
|
-
if (status) {
|
|
704
|
-
const remaining = Math.max(0, Math.floor((status.expiresAt - Date.now()) / 1e3));
|
|
705
|
-
console.log("Token cached: yes");
|
|
706
|
-
console.log(`Expires in: ${Math.floor(remaining / 60)}m ${remaining % 60}s`);
|
|
707
|
-
const autoRefresh = cfg.authMode === "oauth" && !!status.refreshToken || cfg.authMode === "service_account" || cfg.authMode === "client_credentials";
|
|
708
|
-
console.log(`Auto-refresh: ${autoRefresh ? "enabled" : "n/a"}`);
|
|
709
|
-
} else {
|
|
710
|
-
console.log("Token cached: no");
|
|
711
|
-
}
|
|
712
|
-
});
|
|
713
|
-
authCmd.command("logout").description("Logout and clear cached access token").action(() => {
|
|
714
|
-
const cleared = AuthManager.clearCache();
|
|
715
|
-
if (cleared) {
|
|
716
|
-
console.log("Successfully logged out. Token cache cleared.");
|
|
717
|
-
} else {
|
|
718
|
-
console.log("Already logged out. No token cache found.");
|
|
719
|
-
}
|
|
720
|
-
});
|
|
721
|
-
var publishCmd = program.command("publish").description("Publishing API commands");
|
|
722
|
-
function readJsonFile(filePath) {
|
|
723
|
-
return JSON.parse(fs3.readFileSync(filePath, "utf8"));
|
|
724
|
-
}
|
|
725
|
-
publishCmd.command("app-id").description("Get App ID by package name").requiredOption("-p, --package-name <packageName>", "Package name (comma-separated, max 50)").option("--package-types <packageTypes>", "Optional package types filter").action(async (options) => {
|
|
726
|
-
try {
|
|
727
|
-
const res = await PublishService.getAppIdList(options.packageName, options.packageTypes);
|
|
728
|
-
console.log(JSON.stringify(res, null, 2));
|
|
729
|
-
} catch (e) {
|
|
730
|
-
console.error("Request failed:", e.message);
|
|
731
|
-
}
|
|
732
|
-
});
|
|
733
|
-
publishCmd.command("app-create").description("Create an app or meta-service (omit --project-id to pick from project list)").option("--project-id <projectId>", "AGC project ID (interactive pick if omitted)").requiredOption("--app-name <appName>", "App / meta-service name").option("-p, --package-name <packageName>", "Package name (required for app; omit for meta-service)").requiredOption(
|
|
734
|
-
"--parent-type <parentType>",
|
|
735
|
-
"Primary category: 2 game, 13 app"
|
|
736
|
-
).requiredOption(
|
|
737
|
-
"--installation-free <installationFree>",
|
|
738
|
-
"0 app, 1 meta-service"
|
|
739
|
-
).action(async (options) => {
|
|
740
|
-
try {
|
|
741
|
-
const parentType = Number(options.parentType);
|
|
742
|
-
const installationFree = Number(options.installationFree);
|
|
743
|
-
if (parentType !== 2 && parentType !== 13) {
|
|
744
|
-
console.error("Invalid --parent-type: must be 2 (game) or 13 (app)");
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
747
|
-
if (installationFree !== 0 && installationFree !== 1) {
|
|
748
|
-
console.error("Invalid --installation-free: must be 0 (app) or 1 (meta-service)");
|
|
749
|
-
return;
|
|
750
|
-
}
|
|
751
|
-
if (installationFree === 0 && !options.packageName) {
|
|
752
|
-
console.error("Missing -p/--package-name: required when creating an app (installation-free=0)");
|
|
753
|
-
return;
|
|
754
|
-
}
|
|
755
|
-
const projectId = await resolveProjectId(options.projectId);
|
|
756
|
-
if (!projectId) {
|
|
757
|
-
return;
|
|
758
|
-
}
|
|
759
|
-
const res = await PublishService.createApp({
|
|
760
|
-
projectId,
|
|
761
|
-
appName: options.appName,
|
|
762
|
-
...options.packageName ? { packageName: options.packageName } : {},
|
|
763
|
-
parentType,
|
|
764
|
-
installationFree
|
|
765
|
-
});
|
|
766
|
-
console.log(JSON.stringify(res, null, 2));
|
|
767
|
-
} catch (e) {
|
|
768
|
-
console.error("Request failed:", e.message);
|
|
769
|
-
}
|
|
770
|
-
});
|
|
771
|
-
publishCmd.command("members").description("List team members and roles").requiredOption("--from-page <fromPage>", "Start page (>=1)").requiredOption("--page-size <pageSize>", "Page size (1-50)").requiredOption("--lang <languageCode>", "Language code: zh_cn / en_us / ru_ru").action(async (options) => {
|
|
772
|
-
try {
|
|
773
|
-
const res = await PublishService.getMembersRoleList({
|
|
774
|
-
fromPage: Number(options.fromPage),
|
|
775
|
-
pageSize: Number(options.pageSize),
|
|
776
|
-
languageCode: options.lang
|
|
777
|
-
});
|
|
778
|
-
console.log(JSON.stringify(res, null, 2));
|
|
779
|
-
} catch (e) {
|
|
780
|
-
console.error("Request failed:", e.message);
|
|
781
|
-
}
|
|
782
|
-
});
|
|
783
|
-
publishCmd.command("app-info").description("Get App Info by App ID").requiredOption("-a, --app-id <appId>", "App ID").option("-l, --lang <lang>", "Language, e.g. zh-CN").option("-r, --release-type <releaseType>", "1 full, 6 HarmonyOS test").option("-v, --version-id <versionId>", "Version ID (required when releaseType=6)").action(async (options) => {
|
|
784
|
-
try {
|
|
785
|
-
const res = await PublishService.getAppInfo({
|
|
786
|
-
appId: options.appId,
|
|
787
|
-
lang: options.lang,
|
|
788
|
-
releaseType: options.releaseType ? Number(options.releaseType) : void 0,
|
|
789
|
-
versionId: options.versionId
|
|
790
|
-
});
|
|
791
|
-
console.log(JSON.stringify(res, null, 2));
|
|
792
|
-
} catch (e) {
|
|
793
|
-
console.error("Request failed:", e.message);
|
|
794
|
-
}
|
|
795
|
-
});
|
|
796
|
-
publishCmd.command("app-info-update").description("Update app basic info").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--body <bodyFile>", "JSON body of app basic fields").option("-r, --release-type <releaseType>", "Release type").option("--release-phase <releasePhase>", "Release phase").action(async (options) => {
|
|
797
|
-
try {
|
|
798
|
-
const body = readJsonFile(options.body);
|
|
799
|
-
const res = await PublishService.updateAppInfo({
|
|
800
|
-
appId: options.appId,
|
|
801
|
-
releaseType: options.releaseType ? Number(options.releaseType) : void 0,
|
|
802
|
-
releasePhase: options.releasePhase ? Number(options.releasePhase) : void 0,
|
|
803
|
-
...body
|
|
804
|
-
});
|
|
805
|
-
console.log(JSON.stringify(res, null, 2));
|
|
806
|
-
} catch (e) {
|
|
807
|
-
console.error("Request failed:", e.message);
|
|
808
|
-
}
|
|
809
|
-
});
|
|
810
|
-
publishCmd.command("language-update").description("Update app language info").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--body <bodyFile>", "JSON body (must include lang)").option("-r, --release-type <releaseType>", "Release type").option("--release-phase <releasePhase>", "Release phase").action(async (options) => {
|
|
811
|
-
try {
|
|
812
|
-
const body = readJsonFile(options.body);
|
|
813
|
-
const res = await PublishService.updateLanguageInfo({
|
|
814
|
-
appId: options.appId,
|
|
815
|
-
releaseType: options.releaseType ? Number(options.releaseType) : void 0,
|
|
816
|
-
releasePhase: options.releasePhase ? Number(options.releasePhase) : void 0,
|
|
817
|
-
...body
|
|
818
|
-
});
|
|
819
|
-
console.log(JSON.stringify(res, null, 2));
|
|
820
|
-
} catch (e) {
|
|
821
|
-
console.error("Request failed:", e.message);
|
|
822
|
-
}
|
|
823
|
-
});
|
|
824
|
-
publishCmd.command("language-delete").description("Delete app language info").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-l, --lang <lang>", "Language to delete, e.g. zh-CN").option("-r, --release-type <releaseType>", "Release type").action(async (options) => {
|
|
825
|
-
try {
|
|
826
|
-
const res = await PublishService.deleteLanguageInfo({
|
|
827
|
-
appId: options.appId,
|
|
828
|
-
lang: options.lang,
|
|
829
|
-
releaseType: options.releaseType ? Number(options.releaseType) : void 0
|
|
830
|
-
});
|
|
831
|
-
console.log(JSON.stringify(res, null, 2));
|
|
832
|
-
} catch (e) {
|
|
833
|
-
console.error("Request failed:", e.message);
|
|
834
|
-
}
|
|
835
|
-
});
|
|
836
|
-
publishCmd.command("file-info-update").description("Update app file info (icons/screenshots/videos)").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--body <bodyFile>", "JSON body of file lists").option("-r, --release-type <releaseType>", "Release type").option("--release-phase <releasePhase>", "Release phase").action(async (options) => {
|
|
837
|
-
try {
|
|
838
|
-
const body = readJsonFile(options.body);
|
|
839
|
-
const res = await PublishService.updateAppFileInfo({
|
|
840
|
-
appId: options.appId,
|
|
841
|
-
releaseType: options.releaseType ? Number(options.releaseType) : void 0,
|
|
842
|
-
releasePhase: options.releasePhase ? Number(options.releasePhase) : void 0,
|
|
843
|
-
...body
|
|
844
|
-
});
|
|
845
|
-
console.log(JSON.stringify(res, null, 2));
|
|
846
|
-
} catch (e) {
|
|
847
|
-
console.error("Request failed:", e.message);
|
|
848
|
-
}
|
|
849
|
-
});
|
|
850
|
-
publishCmd.command("package-update").description("Report uploaded package to AGC (call after OBS upload if upload file used --no-bind)").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--file-name <fileName>", "Uploaded file name").requiredOption("--object-id <objectId>", "Uploaded object ID").option("-r, --release-type <releaseType>", "Release type").option("--release-phase <releasePhase>", "Release phase").action(async (options) => {
|
|
851
|
-
try {
|
|
852
|
-
const res = await PublishService.updateAppPackageInfo({
|
|
853
|
-
appId: options.appId,
|
|
854
|
-
fileName: options.fileName,
|
|
855
|
-
objectId: options.objectId,
|
|
856
|
-
releaseType: options.releaseType ? Number(options.releaseType) : void 0,
|
|
857
|
-
releasePhase: options.releasePhase ? Number(options.releasePhase) : void 0
|
|
858
|
-
});
|
|
859
|
-
console.log(JSON.stringify(res, null, 2));
|
|
860
|
-
} catch (e) {
|
|
861
|
-
console.error("Request failed:", e.message);
|
|
862
|
-
}
|
|
863
|
-
});
|
|
864
|
-
publishCmd.command("release-time").description("Update version on-shelf time").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--change-type <changeType>", "2 immediate, 3 change scheduled time").option("--release-time <releaseTime>", "UTC time yyyy-MM-ddTHH:mm:ssZZ").option("-r, --release-type <releaseType>", "Release type (default 1)").action(async (options) => {
|
|
865
|
-
try {
|
|
866
|
-
const res = await PublishService.updateReleaseTime({
|
|
867
|
-
appId: options.appId,
|
|
868
|
-
changeType: Number(options.changeType),
|
|
869
|
-
releaseTime: options.releaseTime,
|
|
870
|
-
releaseType: options.releaseType ? Number(options.releaseType) : void 0
|
|
871
|
-
});
|
|
872
|
-
console.log(JSON.stringify(res, null, 2));
|
|
873
|
-
} catch (e) {
|
|
874
|
-
console.error("Request failed:", e.message);
|
|
875
|
-
}
|
|
876
|
-
});
|
|
877
|
-
publishCmd.command("phased-release").description("Update phased release settings").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--body <bodyFile>", "JSON body (versionId, releasePhase, state, ...)").action(async (options) => {
|
|
878
|
-
try {
|
|
879
|
-
const body = readJsonFile(options.body);
|
|
880
|
-
const res = await PublishService.updatePhasedRelease({ appId: options.appId, ...body });
|
|
881
|
-
console.log(JSON.stringify(res, null, 2));
|
|
882
|
-
} catch (e) {
|
|
883
|
-
console.error("Request failed:", e.message);
|
|
884
|
-
}
|
|
885
|
-
});
|
|
886
|
-
publishCmd.command("package-info").description("Query package info by package ID").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--package-id <packageId>", "Package ID").action(async (options) => {
|
|
887
|
-
try {
|
|
888
|
-
const res = await PublishService.getPackageInfo({
|
|
889
|
-
appId: options.appId,
|
|
890
|
-
packageId: options.packageId
|
|
891
|
-
});
|
|
892
|
-
console.log(JSON.stringify(res, null, 2));
|
|
893
|
-
} catch (e) {
|
|
894
|
-
console.error("Request failed:", e.message);
|
|
895
|
-
}
|
|
896
|
-
});
|
|
897
|
-
publishCmd.command("compile-status").description("Query package compile/parse status").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--pkg-ids <pkgIds>", "Comma separated package IDs").action(async (options) => {
|
|
898
|
-
try {
|
|
899
|
-
const res = await PublishService.getCompileStatus({
|
|
900
|
-
appId: options.appId,
|
|
901
|
-
pkgIds: options.pkgIds
|
|
902
|
-
});
|
|
903
|
-
console.log(JSON.stringify(res, null, 2));
|
|
904
|
-
} catch (e) {
|
|
905
|
-
console.error("Request failed:", e.message);
|
|
906
|
-
}
|
|
907
|
-
});
|
|
908
|
-
publishCmd.command("version-list").description("Query brief info list of all version types (commercial + test)").requiredOption("-a, --app-id <appId>", "App ID").option("-p, --package-name <packageName>", "Package name").option("--state <state>", "Version state filter (comma-separated)").action(async (options) => {
|
|
909
|
-
try {
|
|
910
|
-
const res = await PublishService.queryBriefInfoList({
|
|
911
|
-
appId: options.appId,
|
|
912
|
-
packageName: options.packageName,
|
|
913
|
-
state: options.state
|
|
914
|
-
});
|
|
915
|
-
console.log(JSON.stringify(res, null, 2));
|
|
916
|
-
} catch (e) {
|
|
917
|
-
console.error("Request failed:", e.message);
|
|
918
|
-
}
|
|
919
|
-
});
|
|
920
|
-
publishCmd.command("version-voc").description("Query unresolved version VOC tickets").requiredOption("-a, --app-id <appId>", "App ID").option("--body <bodyFile>", "Optional JSON filter (vocId/vocDesc/pageNo/pageSize)").action(async (options) => {
|
|
921
|
-
try {
|
|
922
|
-
const body = options.body ? readJsonFile(options.body) : {};
|
|
923
|
-
const res = await PublishService.queryVersionVoc({ appId: options.appId, ...body });
|
|
924
|
-
console.log(JSON.stringify(res, null, 2));
|
|
925
|
-
} catch (e) {
|
|
926
|
-
console.error("Request failed:", e.message);
|
|
927
|
-
}
|
|
928
|
-
});
|
|
929
|
-
publishCmd.command("qual-dependent").description("Query required qualification file definitions").action(async () => {
|
|
930
|
-
try {
|
|
931
|
-
const res = await PublishService.queryTagQualDependent();
|
|
932
|
-
console.log(JSON.stringify(res, null, 2));
|
|
933
|
-
} catch (e) {
|
|
934
|
-
console.error("Request failed:", e.message);
|
|
935
|
-
}
|
|
936
|
-
});
|
|
937
|
-
publishCmd.command("qual-submit").description("Submit qualification review task").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--body <bodyFile>", "JSON body with tagQualInfos").action(async (options) => {
|
|
938
|
-
try {
|
|
939
|
-
const body = readJsonFile(options.body);
|
|
940
|
-
const res = await PublishService.submitQualificationReview({ appId: options.appId, ...body });
|
|
941
|
-
console.log(JSON.stringify(res, null, 2));
|
|
942
|
-
} catch (e) {
|
|
943
|
-
console.error("Request failed:", e.message);
|
|
944
|
-
}
|
|
945
|
-
});
|
|
946
|
-
publishCmd.command("qual-query").description("Query qualification review task details").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--tag-ids <tagIds>", "Comma separated tag IDs").action(async (options) => {
|
|
947
|
-
try {
|
|
948
|
-
const res = await PublishService.getQualificationReview({
|
|
949
|
-
appId: options.appId,
|
|
950
|
-
tagIds: options.tagIds
|
|
951
|
-
});
|
|
952
|
-
console.log(JSON.stringify(res, null, 2));
|
|
953
|
-
} catch (e) {
|
|
954
|
-
console.error("Request failed:", e.message);
|
|
955
|
-
}
|
|
956
|
-
});
|
|
957
|
-
publishCmd.command("qual-update").description("Update qualification review task").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--body <bodyFile>", "JSON body with tagQualInfos").action(async (options) => {
|
|
958
|
-
try {
|
|
959
|
-
const body = readJsonFile(options.body);
|
|
960
|
-
const res = await PublishService.updateQualificationReview({ appId: options.appId, ...body });
|
|
961
|
-
console.log(JSON.stringify(res, null, 2));
|
|
962
|
-
} catch (e) {
|
|
963
|
-
console.error("Request failed:", e.message);
|
|
964
|
-
}
|
|
965
|
-
});
|
|
966
|
-
publishCmd.command("qual-cancel").description("Cancel qualification review task").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--task-id <taskId>", "Task ID").action(async (options) => {
|
|
967
|
-
try {
|
|
968
|
-
const res = await PublishService.cancelQualificationReview({
|
|
969
|
-
appId: options.appId,
|
|
970
|
-
taskId: options.taskId
|
|
971
|
-
});
|
|
972
|
-
console.log(JSON.stringify(res, null, 2));
|
|
973
|
-
} catch (e) {
|
|
974
|
-
console.error("Request failed:", e.message);
|
|
975
|
-
}
|
|
976
|
-
});
|
|
977
|
-
publishCmd.command("qual-delete").description("Delete qualification review task").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--tag-ids <tagIds>", "Comma separated tag IDs").action(async (options) => {
|
|
978
|
-
try {
|
|
979
|
-
const res = await PublishService.deleteQualificationReview({
|
|
980
|
-
appId: options.appId,
|
|
981
|
-
tagIds: options.tagIds.split(",")
|
|
982
|
-
});
|
|
983
|
-
console.log(JSON.stringify(res, null, 2));
|
|
984
|
-
} catch (e) {
|
|
985
|
-
console.error("Request failed:", e.message);
|
|
986
|
-
}
|
|
987
|
-
});
|
|
988
|
-
publishCmd.command("agreement-create").description("Create user agreement or privacy agreement (type in body)").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--body <bodyFile>", "JSON body (type: 1 privacy / 2 user agreement, ...)").action(async (options) => {
|
|
989
|
-
try {
|
|
990
|
-
const body = readJsonFile(options.body);
|
|
991
|
-
const res = await PublishService.createAgreement({ appId: options.appId, ...body });
|
|
992
|
-
console.log(JSON.stringify(res, null, 2));
|
|
993
|
-
} catch (e) {
|
|
994
|
-
console.error("Request failed:", e.message);
|
|
995
|
-
}
|
|
996
|
-
});
|
|
997
|
-
publishCmd.command("agreement-list").description("List user/privacy agreements").requiredOption("-a, --app-id <appId>", "App ID").option("--body <bodyFile>", "Optional JSON filter (type/status/name/...)").option("--type <type>", "1 privacy, 2 user agreement").action(async (options) => {
|
|
998
|
-
try {
|
|
999
|
-
const body = options.body ? readJsonFile(options.body) : {};
|
|
1000
|
-
if (options.type !== void 0) body.type = Number(options.type);
|
|
1001
|
-
const res = await PublishService.listAgreements({ appId: options.appId, ...body });
|
|
1002
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1003
|
-
} catch (e) {
|
|
1004
|
-
console.error("Request failed:", e.message);
|
|
1005
|
-
}
|
|
1006
|
-
});
|
|
1007
|
-
publishCmd.command("agreement-update").description("Update user/privacy agreement").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--body <bodyFile>", "JSON body (id, defaultLang, agreementInfos, ...)").action(async (options) => {
|
|
1008
|
-
try {
|
|
1009
|
-
const body = readJsonFile(options.body);
|
|
1010
|
-
const res = await PublishService.updateAgreement({ appId: options.appId, ...body });
|
|
1011
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1012
|
-
} catch (e) {
|
|
1013
|
-
console.error("Request failed:", e.message);
|
|
1014
|
-
}
|
|
1015
|
-
});
|
|
1016
|
-
publishCmd.command("privacy-submit").description("Submit privacy agreement for review").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--id <agreementId>", "Agreement ID").option("--require-confirm <flag>", "requireConfirm: 0 or 1").action(async (options) => {
|
|
1017
|
-
try {
|
|
1018
|
-
const res = await PublishService.submitPrivacyAgreement({
|
|
1019
|
-
appId: options.appId,
|
|
1020
|
-
id: options.id,
|
|
1021
|
-
requireConfirm: options.requireConfirm !== void 0 ? Number(options.requireConfirm) : void 0
|
|
1022
|
-
});
|
|
1023
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1024
|
-
} catch (e) {
|
|
1025
|
-
console.error("Request failed:", e.message);
|
|
1026
|
-
}
|
|
1027
|
-
});
|
|
1028
|
-
publishCmd.command("age-rating").description("Apply for age rating").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--body <bodyFile>", "JSON body (feedback/expectedRating/...)").option("-r, --release-type <releaseType>", "Release type").option("--release-phase <releasePhase>", "Release phase").action(async (options) => {
|
|
1029
|
-
try {
|
|
1030
|
-
const body = readJsonFile(options.body);
|
|
1031
|
-
const res = await PublishService.applyAgeRating({
|
|
1032
|
-
appId: options.appId,
|
|
1033
|
-
releaseType: options.releaseType ? Number(options.releaseType) : void 0,
|
|
1034
|
-
releasePhase: options.releasePhase ? Number(options.releasePhase) : void 0,
|
|
1035
|
-
...body
|
|
1036
|
-
});
|
|
1037
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1038
|
-
} catch (e) {
|
|
1039
|
-
console.error("Request failed:", e.message);
|
|
1040
|
-
}
|
|
1041
|
-
});
|
|
1042
|
-
publishCmd.command("submit").description("Submit app for release review").requiredOption("-a, --app-id <appId>", "App ID").option("--body <bodyFile>", "Optional JSON (releaseTime/remark/releaseType/releasePhase/...)").option("-r, --release-type <releaseType>", "Release type").option("--release-phase <releasePhase>", "Release phase").option("--remark <remark>", "Submit remark").option("--release-time <releaseTime>", "UTC release time").action(async (options) => {
|
|
1043
|
-
try {
|
|
1044
|
-
const body = options.body ? readJsonFile(options.body) : {};
|
|
1045
|
-
if (options.releaseType !== void 0) body.releaseType = Number(options.releaseType);
|
|
1046
|
-
if (options.releasePhase !== void 0) body.releasePhase = Number(options.releasePhase);
|
|
1047
|
-
if (options.remark !== void 0) body.remark = options.remark;
|
|
1048
|
-
if (options.releaseTime !== void 0) body.releaseTime = options.releaseTime;
|
|
1049
|
-
const res = await PublishService.submitApp({ appId: options.appId, ...body });
|
|
1050
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1051
|
-
} catch (e) {
|
|
1052
|
-
console.error("Request failed:", e.message);
|
|
1053
|
-
}
|
|
1054
|
-
});
|
|
1055
|
-
publishCmd.command("cancel-review").description("Cancel an in-review version").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-v, --version-id <versionId>", "Version ID").action(async (options) => {
|
|
1056
|
-
try {
|
|
1057
|
-
const res = await PublishService.cancelReview({
|
|
1058
|
-
appId: options.appId,
|
|
1059
|
-
versionId: options.versionId
|
|
1060
|
-
});
|
|
1061
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1062
|
-
} catch (e) {
|
|
1063
|
-
console.error("Request failed:", e.message);
|
|
1064
|
-
}
|
|
1065
|
-
});
|
|
1066
|
-
publishCmd.command("shelf-off").description("Take app off shelf").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--reason <reason>", "Off-shelf reason").option("-r, --release-type <releaseType>", "Release type").action(async (options) => {
|
|
1067
|
-
try {
|
|
1068
|
-
const res = await PublishService.shelfOff({
|
|
1069
|
-
appId: options.appId,
|
|
1070
|
-
reason: options.reason,
|
|
1071
|
-
releaseType: options.releaseType ? Number(options.releaseType) : void 0
|
|
1072
|
-
});
|
|
1073
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1074
|
-
} catch (e) {
|
|
1075
|
-
console.error("Request failed:", e.message);
|
|
1076
|
-
}
|
|
1077
|
-
});
|
|
1078
|
-
var projectCmd = program.command("project").description("Project Management API commands");
|
|
1079
|
-
projectCmd.command("list").description("List AGC projects (projectId for publish app-create)").action(async () => {
|
|
1080
|
-
try {
|
|
1081
|
-
const res = await ProjectService.listProjects();
|
|
1082
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1083
|
-
const list = res.projectList ?? [];
|
|
1084
|
-
if (res.ret?.code === 0 && list.length > 0) {
|
|
1085
|
-
console.error("projectId choices:");
|
|
1086
|
-
for (const p of list) {
|
|
1087
|
-
console.error(` ${p.projectId}${p.name ? ` ${p.name}` : ""}`);
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
} catch (e) {
|
|
1091
|
-
console.error("Request failed:", e.message);
|
|
1092
|
-
}
|
|
1093
|
-
});
|
|
1094
|
-
var uploadCmd = program.command("upload").description("Upload Management API commands");
|
|
1095
|
-
uploadCmd.command("file").description("Upload a file (APP, APK, images, etc.); .app is reported to AGC unless --no-bind or -r 6").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-f, --file-path <filePath>", "Path to the local file to upload").option("-r, --release-type <releaseType>", "Release type: 1 for Full, 6 for HarmonyOS Test").option("-c, --chinese-mainland <flag>", "Chinese mainland flag: 0 or 1").option("--no-bind", "OBS upload only; skip reporting the package so it will not appear in AGC").action(async (options) => {
|
|
1096
|
-
try {
|
|
1097
|
-
console.error(`Uploading file ${options.filePath}...`);
|
|
1098
|
-
const releaseType = options.releaseType ? Number(options.releaseType) : void 0;
|
|
1099
|
-
const uploaded = await UploadService.uploadFile({
|
|
1100
|
-
appId: options.appId,
|
|
1101
|
-
filePath: options.filePath,
|
|
1102
|
-
releaseType,
|
|
1103
|
-
chineseMainlandFlag: options.chineseMainland ? Number(options.chineseMainland) : void 0
|
|
1104
|
-
});
|
|
1105
|
-
const ext = path2.extname(uploaded.fileName).toLowerCase();
|
|
1106
|
-
const shouldBind = options.bind !== false && ext === ".app" && releaseType !== 6;
|
|
1107
|
-
if (!shouldBind) {
|
|
1108
|
-
console.log(JSON.stringify({
|
|
1109
|
-
ret: { code: 0, msg: "success" },
|
|
1110
|
-
fileName: uploaded.fileName,
|
|
1111
|
-
objectId: uploaded.objectId,
|
|
1112
|
-
bound: false
|
|
1113
|
-
}, null, 2));
|
|
1114
|
-
return;
|
|
1115
|
-
}
|
|
1116
|
-
console.error("Reporting package to AGC...");
|
|
1117
|
-
const bindRes = await PublishService.updateAppPackageInfo({
|
|
1118
|
-
appId: options.appId,
|
|
1119
|
-
fileName: uploaded.fileName,
|
|
1120
|
-
objectId: uploaded.objectId,
|
|
1121
|
-
releaseType
|
|
1122
|
-
});
|
|
1123
|
-
console.log(JSON.stringify({
|
|
1124
|
-
...bindRes,
|
|
1125
|
-
fileName: uploaded.fileName,
|
|
1126
|
-
objectId: uploaded.objectId,
|
|
1127
|
-
bound: bindRes.ret?.code === 0
|
|
1128
|
-
}, null, 2));
|
|
1129
|
-
if (bindRes.ret?.code !== 0) {
|
|
1130
|
-
console.error(
|
|
1131
|
-
"Package report failed (file is on OBS but AGC has no record):",
|
|
1132
|
-
bindRes.ret?.msg || JSON.stringify(bindRes.ret)
|
|
1133
|
-
);
|
|
1134
|
-
}
|
|
1135
|
-
} catch (e) {
|
|
1136
|
-
console.error("Upload failed:", e.message);
|
|
1137
|
-
}
|
|
1138
|
-
});
|
|
1139
|
-
var provisionCmd = program.command("provision").description("Provisioning API commands");
|
|
1140
|
-
provisionCmd.command("csr-generate").description("Generate a new keypair and CSR file").requiredOption("--alias <alias>", "Key alias").option("--pwd <pwd>", "Key password (default: CSPRNG hex, returned as .pwd; not written to disk)").option("--out-dir <outDir>", "Root output directory (default: ./.certs; each run adds a CSPRNG subdirectory)").option("--filename <filename>", "Shared random id for the cert subdirectory (files get key_/cert_/profile_ prefixes)").option("--sdk-path <sdkPath>", "Path to HarmonyOS SDK (or set HARMONYOS_SDK_PATH env var)").option("--java-path <javaPath>", "Path to java executable (default: java)").action(async (options) => {
|
|
1141
|
-
try {
|
|
1142
|
-
const res = await SignService.createSignP12AndCsr({
|
|
1143
|
-
alias: options.alias,
|
|
1144
|
-
pwd: options.pwd,
|
|
1145
|
-
outDir: options.outDir,
|
|
1146
|
-
filename: options.filename,
|
|
1147
|
-
sdkPath: options.sdkPath,
|
|
1148
|
-
javaPath: options.javaPath
|
|
1149
|
-
});
|
|
1150
|
-
console.error("CSR generation successful.");
|
|
1151
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1152
|
-
} catch (e) {
|
|
1153
|
-
console.error("CSR generation failed:", e.message);
|
|
1154
|
-
}
|
|
1155
|
-
});
|
|
1156
|
-
provisionCmd.command("encrypt-pwd").description("\u52A0\u5BC6 P12 \u5BC6\u7801\uFF0C\u751F\u6210 build-profile.json5 \u6240\u9700\u7684 keyPassword / storePassword").requiredOption("--pwd <password>", "P12 \u5BC6\u7801\u660E\u6587").option("--config-dir <configDir>", "DevEco Studio \u914D\u7F6E\u76EE\u5F55 (\u9ED8\u8BA4 ~/.ohos/config)").action(async (options) => {
|
|
1157
|
-
try {
|
|
1158
|
-
const res = SignService.encryptPassword(options.pwd, options.configDir);
|
|
1159
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1160
|
-
} catch (e) {
|
|
1161
|
-
console.error("\u52A0\u5BC6\u5931\u8D25:", e.message);
|
|
1162
|
-
}
|
|
1163
|
-
});
|
|
1164
|
-
provisionCmd.command("cert-create").description("Create a certificate").requiredOption("--csr <csrFile>", "Path to CSR file").requiredOption("--cert-name <certName>", "Certificate name").requiredOption("--cert-type <certType>", "Certificate type (1: debug, 2: release, 3: in-house, 4: binary)").action(async (options) => {
|
|
1165
|
-
try {
|
|
1166
|
-
const csrContent = fs3.readFileSync(options.csr, "utf8");
|
|
1167
|
-
const res = await ProvisionService.createCert({
|
|
1168
|
-
csr: csrContent,
|
|
1169
|
-
certName: options.certName,
|
|
1170
|
-
certType: Number(options.certType)
|
|
1171
|
-
});
|
|
1172
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1173
|
-
} catch (e) {
|
|
1174
|
-
console.error("Request failed:", e.message);
|
|
1175
|
-
}
|
|
1176
|
-
});
|
|
1177
|
-
provisionCmd.command("cert-list").description("List certificates").option("-t, --cert-type <certType>", "Certificate type").option("--cert-ids <certIds>", "Comma separated certificate IDs").action(async (options) => {
|
|
1178
|
-
try {
|
|
1179
|
-
const req = {};
|
|
1180
|
-
if (options.certType) req.certType = Number(options.certType);
|
|
1181
|
-
if (options.certIds) req.certIds = options.certIds.split(",");
|
|
1182
|
-
const res = await ProvisionService.getCertList(req);
|
|
1183
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1184
|
-
} catch (e) {
|
|
1185
|
-
console.error("Request failed:", e.message);
|
|
1186
|
-
}
|
|
1187
|
-
});
|
|
1188
|
-
provisionCmd.command("cert-delete").description("Delete certificates").requiredOption("--cert-ids <certIds>", "Comma separated certificate IDs to delete").action(async (options) => {
|
|
1189
|
-
try {
|
|
1190
|
-
const res = await ProvisionService.deleteCert({
|
|
1191
|
-
certIds: options.certIds.split(",")
|
|
1192
|
-
});
|
|
1193
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1194
|
-
} catch (e) {
|
|
1195
|
-
console.error("Request failed:", e.message);
|
|
1196
|
-
}
|
|
1197
|
-
});
|
|
1198
|
-
provisionCmd.command("device-add").description("Add new devices").requiredOption("--devices <devicesFile>", 'Path to JSON file containing devices array [{"deviceName":"name","udid":"udid","deviceType":1}]').action(async (options) => {
|
|
1199
|
-
try {
|
|
1200
|
-
const fileContent = fs3.readFileSync(options.devices, "utf8");
|
|
1201
|
-
const deviceList = JSON.parse(fileContent);
|
|
1202
|
-
const res = await ProvisionService.addDevice({ deviceList });
|
|
1203
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1204
|
-
} catch (e) {
|
|
1205
|
-
console.error("Request failed:", e.message);
|
|
1206
|
-
}
|
|
1207
|
-
});
|
|
1208
|
-
provisionCmd.command("device-list").description("List devices").option("--device-name <deviceName>", "Device name to search").option("--from <fromRecCount>", "Starting page").option("--max <maxReqCount>", "Max items per page").option("--order <order>", "1: create time desc, 2: name asc").action(async (options) => {
|
|
1209
|
-
try {
|
|
1210
|
-
const req = {};
|
|
1211
|
-
if (options.deviceName) req.deviceName = options.deviceName;
|
|
1212
|
-
if (options.from) req.fromRecCount = Number(options.from);
|
|
1213
|
-
if (options.max) req.maxReqCount = Number(options.max);
|
|
1214
|
-
if (options.order) req.order = Number(options.order);
|
|
1215
|
-
const res = await ProvisionService.getDeviceList(req);
|
|
1216
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1217
|
-
} catch (e) {
|
|
1218
|
-
console.error("Request failed:", e.message);
|
|
1219
|
-
}
|
|
1220
|
-
});
|
|
1221
|
-
provisionCmd.command("device-delete").description("Delete devices").requiredOption("--device-ids <deviceIdList>", "Comma separated device IDs to delete").action(async (options) => {
|
|
1222
|
-
try {
|
|
1223
|
-
const res = await ProvisionService.deleteDevice({
|
|
1224
|
-
deviceIdList: options.deviceIds.split(",")
|
|
1225
|
-
});
|
|
1226
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1227
|
-
} catch (e) {
|
|
1228
|
-
console.error("Request failed:", e.message);
|
|
1229
|
-
}
|
|
1230
|
-
});
|
|
1231
|
-
provisionCmd.command("profile-create").description("Create a profile").requiredOption("--name <provisionName>", "Profile name").requiredOption("--type <provisionType>", "Profile type (1:debug, 2:release, 3:in-house, 6:specific device)").requiredOption("--cert <certId>", "Certificate ID").requiredOption("-a, --app-id <appId>", "App ID").option("--device-ids <deviceIdList>", "Comma separated device IDs").option("--acls <aclPermissionList>", "Comma separated ACL permissions").action(async (options) => {
|
|
1232
|
-
try {
|
|
1233
|
-
const req = {
|
|
1234
|
-
provisionName: options.name,
|
|
1235
|
-
provisionType: Number(options.type),
|
|
1236
|
-
certId: options.cert,
|
|
1237
|
-
appId: options.appId
|
|
1238
|
-
};
|
|
1239
|
-
if (options.deviceIds) req.deviceIdList = options.deviceIds.split(",");
|
|
1240
|
-
if (options.acls) req.aclPermissionList = options.acls.split(",");
|
|
1241
|
-
const res = await ProvisionService.createProvision(req);
|
|
1242
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1243
|
-
} catch (e) {
|
|
1244
|
-
console.error("Request failed:", e.message);
|
|
1245
|
-
}
|
|
1246
|
-
});
|
|
1247
|
-
provisionCmd.command("profile-list").description("List profiles").requiredOption("-a, --app-id <appId>", "App ID").option("--profile-id <provisionId>", "Profile ID").option("--from <fromRecCount>", "Starting page").option("--max <maxReqCount>", "Max items per page").action(async (options) => {
|
|
1248
|
-
try {
|
|
1249
|
-
const req = { appId: options.appId };
|
|
1250
|
-
if (options.profileId) req.provisionId = options.profileId;
|
|
1251
|
-
if (options.from) req.fromRecCount = Number(options.from);
|
|
1252
|
-
if (options.max) req.maxReqCount = Number(options.max);
|
|
1253
|
-
const res = await ProvisionService.getProvisionList(req);
|
|
1254
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1255
|
-
} catch (e) {
|
|
1256
|
-
console.error("Request failed:", e.message);
|
|
1257
|
-
}
|
|
1258
|
-
});
|
|
1259
|
-
provisionCmd.command("profile-update").description("Update profile devices").requiredOption("--id <provisionId>", "Profile ID").requiredOption("--device-ids <deviceIdList>", "Comma separated device IDs").action(async (options) => {
|
|
1260
|
-
try {
|
|
1261
|
-
const res = await ProvisionService.updateProvision({
|
|
1262
|
-
provisionId: options.id,
|
|
1263
|
-
deviceIdList: options.deviceIds.split(",")
|
|
1264
|
-
});
|
|
1265
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1266
|
-
} catch (e) {
|
|
1267
|
-
console.error("Request failed:", e.message);
|
|
1268
|
-
}
|
|
1269
|
-
});
|
|
1270
|
-
provisionCmd.command("profile-delete").description("Delete a profile").requiredOption("--id <id>", "Profile ID to delete").action(async (options) => {
|
|
1271
|
-
try {
|
|
1272
|
-
const res = await ProvisionService.deleteProvision({ id: options.id });
|
|
1273
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1274
|
-
} catch (e) {
|
|
1275
|
-
console.error("Request failed:", e.message);
|
|
1276
|
-
}
|
|
1277
|
-
});
|
|
1278
|
-
provisionCmd.command("fp-add").description("Add certificate fingerprints").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--fps <fingerprintList>", "Comma separated fingerprints").action(async (options) => {
|
|
1279
|
-
try {
|
|
1280
|
-
const res = await ProvisionService.addFingerprint({
|
|
1281
|
-
appId: options.appId,
|
|
1282
|
-
fingerprintList: options.fps.split(",")
|
|
1283
|
-
});
|
|
1284
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1285
|
-
} catch (e) {
|
|
1286
|
-
console.error("Request failed:", e.message);
|
|
1287
|
-
}
|
|
1288
|
-
});
|
|
1289
|
-
provisionCmd.command("fp-list").description("List certificate fingerprints").requiredOption("-a, --app-id <appId>", "App ID").action(async (options) => {
|
|
1290
|
-
try {
|
|
1291
|
-
const res = await ProvisionService.getFingerprintList({ appId: options.appId });
|
|
1292
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1293
|
-
} catch (e) {
|
|
1294
|
-
console.error("Request failed:", e.message);
|
|
1295
|
-
}
|
|
1296
|
-
});
|
|
1297
|
-
provisionCmd.command("fp-delete").description("Delete certificate fingerprints").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--fps <fingerprintList>", "Comma separated fingerprints to delete").action(async (options) => {
|
|
1298
|
-
try {
|
|
1299
|
-
const res = await ProvisionService.deleteFingerprint({
|
|
1300
|
-
appId: options.appId,
|
|
1301
|
-
fingerprintList: options.fps.split(",")
|
|
1302
|
-
});
|
|
1303
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1304
|
-
} catch (e) {
|
|
1305
|
-
console.error("Request failed:", e.message);
|
|
1306
|
-
}
|
|
1307
|
-
});
|
|
1308
|
-
provisionCmd.command("acl-eligible").description("List eligible ACL permissions that can be applied for").requiredOption("-a, --app-id <appId>", "App ID").option("-l, --lang <lang>", "Language: zh / en / ru (default zh)").option("--start <start>", "Start page (default 1)").option("--page-size <pageSize>", "Page size 1-1000 (default 10)").action(async (options) => {
|
|
1309
|
-
try {
|
|
1310
|
-
const res = await ProvisionService.getEligibleACL({
|
|
1311
|
-
appId: options.appId,
|
|
1312
|
-
lang: options.lang,
|
|
1313
|
-
start: options.start ? Number(options.start) : void 0,
|
|
1314
|
-
pageSize: options.pageSize ? Number(options.pageSize) : void 0
|
|
1315
|
-
});
|
|
1316
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1317
|
-
} catch (e) {
|
|
1318
|
-
console.error("Request failed:", e.message);
|
|
1319
|
-
}
|
|
1320
|
-
});
|
|
1321
|
-
provisionCmd.command("acl-apply").description("Apply for restricted ACL permissions").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--acls <aclsFile>", 'Path to JSON file containing ACL permissions [{"name":"name","reason":"reason"}]').option("--attachment <attachment>", "Attachment object ID").action(async (options) => {
|
|
1322
|
-
try {
|
|
1323
|
-
const fileContent = fs3.readFileSync(options.acls, "utf8");
|
|
1324
|
-
const aclPermissionList = JSON.parse(fileContent);
|
|
1325
|
-
const req = { appId: options.appId, aclPermissionList };
|
|
1326
|
-
if (options.attachment) req.attachment = options.attachment;
|
|
1327
|
-
const res = await ProvisionService.applyACL(req);
|
|
1328
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1329
|
-
} catch (e) {
|
|
1330
|
-
console.error("Request failed:", e.message);
|
|
1331
|
-
}
|
|
1332
|
-
});
|
|
1333
|
-
provisionCmd.command("acl-status").description("Check ACL permission apply status").requiredOption("-a, --app-id <appId>", "App ID").action(async (options) => {
|
|
1334
|
-
try {
|
|
1335
|
-
const res = await ProvisionService.getACLStatus({ appId: options.appId });
|
|
1336
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1337
|
-
} catch (e) {
|
|
1338
|
-
console.error("Request failed:", e.message);
|
|
1339
|
-
}
|
|
1340
|
-
});
|
|
1341
|
-
provisionCmd.command("acl-query").description("Query granted ACL permissions").requiredOption("-a, --app-id <appId>", "App ID").action(async (options) => {
|
|
1342
|
-
try {
|
|
1343
|
-
const res = await ProvisionService.getACLQuery({ appId: options.appId });
|
|
1344
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1345
|
-
} catch (e) {
|
|
1346
|
-
console.error("Request failed:", e.message);
|
|
1347
|
-
}
|
|
1348
|
-
});
|
|
1349
|
-
var domainCmd = program.command("domain").description("Domain Management API commands");
|
|
1350
|
-
domainCmd.command("query").description("Query domain configuration").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-c, --category <category>", "Category: server or business").action(async (options) => {
|
|
1351
|
-
try {
|
|
1352
|
-
const res = await DomainService.queryDomain({
|
|
1353
|
-
appId: options.appId,
|
|
1354
|
-
category: options.category
|
|
1355
|
-
});
|
|
1356
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1357
|
-
} catch (e) {
|
|
1358
|
-
console.error("Request failed:", e.message);
|
|
1359
|
-
}
|
|
1360
|
-
});
|
|
1361
|
-
domainCmd.command("update").description("Add or update domain configuration").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-c, --category <category>", "Category: server or business").requiredOption("--domains <domainsFile>", 'Path to JSON file containing domains array [{"type":"httpRequest","value":"https://..."}]').action(async (options) => {
|
|
1362
|
-
try {
|
|
1363
|
-
const fileContent = fs3.readFileSync(options.domains, "utf8");
|
|
1364
|
-
const domains = JSON.parse(fileContent);
|
|
1365
|
-
const res = await DomainService.updateDomain({
|
|
1366
|
-
appId: options.appId,
|
|
1367
|
-
category: options.category,
|
|
1368
|
-
domains
|
|
1369
|
-
});
|
|
1370
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1371
|
-
} catch (e) {
|
|
1372
|
-
console.error("Request failed:", e.message);
|
|
1373
|
-
}
|
|
1374
|
-
});
|
|
1375
|
-
domainCmd.command("config").description("Query domain modification counts and limits").requiredOption("-a, --app-id <appId>", "App ID").action(async (options) => {
|
|
1376
|
-
try {
|
|
1377
|
-
const res = await DomainService.queryDomainConfig({
|
|
1378
|
-
appId: options.appId
|
|
1379
|
-
});
|
|
1380
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1381
|
-
} catch (e) {
|
|
1382
|
-
console.error("Request failed:", e.message);
|
|
1383
|
-
}
|
|
1384
|
-
});
|
|
1385
|
-
domainCmd.command("verify-file").description("Download domain verify file").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-o, --output <outputPath>", "Output file path").action(async (options) => {
|
|
1386
|
-
try {
|
|
1387
|
-
console.error(`Downloading verify file to ${options.output}...`);
|
|
1388
|
-
await DomainService.verifyFile({
|
|
1389
|
-
appId: options.appId
|
|
1390
|
-
}, options.output);
|
|
1391
|
-
console.log("Download successful.");
|
|
1392
|
-
} catch (e) {
|
|
1393
|
-
console.error("Download failed:", e.message);
|
|
1394
|
-
}
|
|
1395
|
-
});
|
|
1396
|
-
domainCmd.command("pre-check").description("Pre-check business domain configuration").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--domain <domainFile>", 'Path to JSON file containing domain object {"type":"webView","value":"https://..."}').action(async (options) => {
|
|
1397
|
-
try {
|
|
1398
|
-
const fileContent = fs3.readFileSync(options.domain, "utf8");
|
|
1399
|
-
const domain = JSON.parse(fileContent);
|
|
1400
|
-
const res = await DomainService.preCheckDomain({
|
|
1401
|
-
appId: options.appId,
|
|
1402
|
-
domain
|
|
1403
|
-
});
|
|
1404
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1405
|
-
} catch (e) {
|
|
1406
|
-
console.error("Request failed:", e.message);
|
|
1407
|
-
}
|
|
1408
|
-
});
|
|
1409
|
-
var testCmd = program.command("test").description("Testing API commands (invite/open test versions, groups, invite codes)");
|
|
1410
|
-
testCmd.command("version-create").description("Create a test version").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--test-type <testType>", "Test type: 3 invite, 4 open").requiredOption("--test-desc <testDesc>", "Test description (max 50 chars)").option("-r, --release-type <releaseType>", "Release type (default 6)").option("--onshelf-self-detect <flag>", "Onshelf self detect: 0 or 1").action(async (options) => {
|
|
1411
|
-
try {
|
|
1412
|
-
const res = await TestingService.createVersion({
|
|
1413
|
-
appId: options.appId,
|
|
1414
|
-
testType: Number(options.testType),
|
|
1415
|
-
testDesc: options.testDesc,
|
|
1416
|
-
releaseType: options.releaseType ? Number(options.releaseType) : void 0,
|
|
1417
|
-
onshelfSelfDetect: options.onshelfSelfDetect !== void 0 ? Number(options.onshelfSelfDetect) : void 0
|
|
1418
|
-
});
|
|
1419
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1420
|
-
} catch (e) {
|
|
1421
|
-
console.error("Request failed:", e.message);
|
|
1422
|
-
}
|
|
1423
|
-
});
|
|
1424
|
-
testCmd.command("version-detect").description("Query onshelf self-detect report").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-v, --version-id <versionId>", "Test version ID").action(async (options) => {
|
|
1425
|
-
try {
|
|
1426
|
-
const res = await TestingService.getDetectReport({
|
|
1427
|
-
appId: options.appId,
|
|
1428
|
-
versionId: options.versionId
|
|
1429
|
-
});
|
|
1430
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1431
|
-
} catch (e) {
|
|
1432
|
-
console.error("Request failed:", e.message);
|
|
1433
|
-
}
|
|
1434
|
-
});
|
|
1435
|
-
testCmd.command("pkg-add").description("Add package to a test version (objectId from upload)").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--file-name <fileName>", "Uploaded file name").requiredOption("--object-id <objectId>", "Uploaded object ID").option("--distribute-mode <mode>", "1: test zone, 2: AppGallery").action(async (options) => {
|
|
1436
|
-
try {
|
|
1437
|
-
const res = await TestingService.addPackage({
|
|
1438
|
-
appId: options.appId,
|
|
1439
|
-
distributeMode: options.distributeMode ? Number(options.distributeMode) : void 0,
|
|
1440
|
-
file: { fileName: options.fileName, objectId: options.objectId }
|
|
1441
|
-
});
|
|
1442
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1443
|
-
} catch (e) {
|
|
1444
|
-
console.error("Request failed:", e.message);
|
|
1445
|
-
}
|
|
1446
|
-
});
|
|
1447
|
-
testCmd.command("version-update").description("Update a test version (bind pkg/groups/languages via JSON body)").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--body <bodyFile>", "JSON body (must include versionId; optional pkgId, openTestInfo, ...)").action(async (options) => {
|
|
1448
|
-
try {
|
|
1449
|
-
const body = readJsonFile(options.body);
|
|
1450
|
-
const res = await TestingService.updateVersion({ appId: options.appId, ...body });
|
|
1451
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1452
|
-
} catch (e) {
|
|
1453
|
-
console.error("Request failed:", e.message);
|
|
1454
|
-
}
|
|
1455
|
-
});
|
|
1456
|
-
testCmd.command("version-release").description("Update effective/release settings of a test version").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--body <bodyFile>", "JSON body (must include versionId)").action(async (options) => {
|
|
1457
|
-
try {
|
|
1458
|
-
const body = readJsonFile(options.body);
|
|
1459
|
-
const res = await TestingService.releaseVersion({ appId: options.appId, ...body });
|
|
1460
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1461
|
-
} catch (e) {
|
|
1462
|
-
console.error("Request failed:", e.message);
|
|
1463
|
-
}
|
|
1464
|
-
});
|
|
1465
|
-
testCmd.command("version-opentest").description("Update open-test time window / install quota / bind groups").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--body <bodyFile>", "JSON body (must include versionId)").action(async (options) => {
|
|
1466
|
-
try {
|
|
1467
|
-
const body = readJsonFile(options.body);
|
|
1468
|
-
const res = await TestingService.updateOpenTest({ appId: options.appId, ...body });
|
|
1469
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1470
|
-
} catch (e) {
|
|
1471
|
-
console.error("Request failed:", e.message);
|
|
1472
|
-
}
|
|
1473
|
-
});
|
|
1474
|
-
testCmd.command("version-submit").description("Submit a test version for review").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-v, --version-id <versionId>", "Test version ID").action(async (options) => {
|
|
1475
|
-
try {
|
|
1476
|
-
const res = await TestingService.submitVersion({
|
|
1477
|
-
appId: options.appId,
|
|
1478
|
-
versionId: options.versionId
|
|
1479
|
-
});
|
|
1480
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1481
|
-
} catch (e) {
|
|
1482
|
-
console.error("Request failed:", e.message);
|
|
1483
|
-
}
|
|
1484
|
-
});
|
|
1485
|
-
testCmd.command("version-stop").description("Stop a test version").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-v, --version-id <versionId>", "Test version ID").action(async (options) => {
|
|
1486
|
-
try {
|
|
1487
|
-
const res = await TestingService.stopVersion({
|
|
1488
|
-
appId: options.appId,
|
|
1489
|
-
versionId: options.versionId
|
|
1490
|
-
});
|
|
1491
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1492
|
-
} catch (e) {
|
|
1493
|
-
console.error("Request failed:", e.message);
|
|
1494
|
-
}
|
|
1495
|
-
});
|
|
1496
|
-
testCmd.command("version-delete").description("Delete a test version").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-v, --version-id <versionId>", "Test version ID").action(async (options) => {
|
|
1497
|
-
try {
|
|
1498
|
-
const res = await TestingService.deleteVersion({
|
|
1499
|
-
appId: options.appId,
|
|
1500
|
-
versionId: options.versionId
|
|
1501
|
-
});
|
|
1502
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1503
|
-
} catch (e) {
|
|
1504
|
-
console.error("Request failed:", e.message);
|
|
1505
|
-
}
|
|
1506
|
-
});
|
|
1507
|
-
testCmd.command("group-add").description("Create a test group").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--name <groupName>", "Group name").option("--type <groupType>", "0 external (default), 1 internal").action(async (options) => {
|
|
1508
|
-
try {
|
|
1509
|
-
const res = await TestingService.addGroup({
|
|
1510
|
-
appId: options.appId,
|
|
1511
|
-
groupName: options.name,
|
|
1512
|
-
groupType: options.type !== void 0 ? Number(options.type) : void 0
|
|
1513
|
-
});
|
|
1514
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1515
|
-
} catch (e) {
|
|
1516
|
-
console.error("Request failed:", e.message);
|
|
1517
|
-
}
|
|
1518
|
-
});
|
|
1519
|
-
testCmd.command("group-list").description("List test groups").requiredOption("-a, --app-id <appId>", "App ID").option("--type <groupType>", "0 external, 1 internal").option("--current <current>", "Page number").option("--page-size <pageSize>", "Page size").action(async (options) => {
|
|
1520
|
-
try {
|
|
1521
|
-
const res = await TestingService.listGroups({
|
|
1522
|
-
appId: options.appId,
|
|
1523
|
-
groupType: options.type !== void 0 ? Number(options.type) : void 0,
|
|
1524
|
-
current: options.current ? Number(options.current) : void 0,
|
|
1525
|
-
pageSize: options.pageSize ? Number(options.pageSize) : void 0
|
|
1526
|
-
});
|
|
1527
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1528
|
-
} catch (e) {
|
|
1529
|
-
console.error("Request failed:", e.message);
|
|
1530
|
-
}
|
|
1531
|
-
});
|
|
1532
|
-
testCmd.command("group-delete").description("Delete a test group").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-g, --group-id <groupId>", "Group ID").action(async (options) => {
|
|
1533
|
-
try {
|
|
1534
|
-
const res = await TestingService.deleteGroup({
|
|
1535
|
-
appId: options.appId,
|
|
1536
|
-
groupId: options.groupId
|
|
1537
|
-
});
|
|
1538
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1539
|
-
} catch (e) {
|
|
1540
|
-
console.error("Request failed:", e.message);
|
|
1541
|
-
}
|
|
1542
|
-
});
|
|
1543
|
-
testCmd.command("group-edit").description("Rename a test group").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-g, --group-id <groupId>", "Group ID").requiredOption("--name <groupName>", "New group name").action(async (options) => {
|
|
1544
|
-
try {
|
|
1545
|
-
const res = await TestingService.editGroup({
|
|
1546
|
-
appId: options.appId,
|
|
1547
|
-
groupId: options.groupId,
|
|
1548
|
-
groupName: options.name
|
|
1549
|
-
});
|
|
1550
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1551
|
-
} catch (e) {
|
|
1552
|
-
console.error("Request failed:", e.message);
|
|
1553
|
-
}
|
|
1554
|
-
});
|
|
1555
|
-
testCmd.command("group-user-list").description("List members of a test group").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-g, --group-id <groupId>", "Group ID").option("--current <current>", "Page number").option("--page-size <pageSize>", "Page size").action(async (options) => {
|
|
1556
|
-
try {
|
|
1557
|
-
const res = await TestingService.listGroupUsers({
|
|
1558
|
-
appId: options.appId,
|
|
1559
|
-
groupId: options.groupId,
|
|
1560
|
-
current: options.current ? Number(options.current) : void 0,
|
|
1561
|
-
pageSize: options.pageSize ? Number(options.pageSize) : void 0
|
|
1562
|
-
});
|
|
1563
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1564
|
-
} catch (e) {
|
|
1565
|
-
console.error("Request failed:", e.message);
|
|
1566
|
-
}
|
|
1567
|
-
});
|
|
1568
|
-
testCmd.command("group-user-add").description("Add a member to a test group").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--body <bodyFile>", "JSON body: groupId, nickName/hwAccount/uid, ...").action(async (options) => {
|
|
1569
|
-
try {
|
|
1570
|
-
const body = readJsonFile(options.body);
|
|
1571
|
-
const res = await TestingService.addGroupUser({ appId: options.appId, ...body });
|
|
1572
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1573
|
-
} catch (e) {
|
|
1574
|
-
console.error("Request failed:", e.message);
|
|
1575
|
-
}
|
|
1576
|
-
});
|
|
1577
|
-
testCmd.command("group-user-delete").description("Delete members from a test group").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-g, --group-id <groupId>", "Group ID").requiredOption("--tester-ids <testerIds>", "Comma separated tester IDs").action(async (options) => {
|
|
1578
|
-
try {
|
|
1579
|
-
const res = await TestingService.deleteGroupUser({
|
|
1580
|
-
appId: options.appId,
|
|
1581
|
-
groupId: options.groupId,
|
|
1582
|
-
deleteTesterIds: options.testerIds.split(",")
|
|
1583
|
-
});
|
|
1584
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1585
|
-
} catch (e) {
|
|
1586
|
-
console.error("Request failed:", e.message);
|
|
1587
|
-
}
|
|
1588
|
-
});
|
|
1589
|
-
testCmd.command("group-notify").description("Send invite-test notification to group members").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-g, --group-id <groupId>", "Group ID").requiredOption("--tester-ids <testerIds>", "Comma separated tester IDs").action(async (options) => {
|
|
1590
|
-
try {
|
|
1591
|
-
const res = await TestingService.notifyUsers({
|
|
1592
|
-
appId: options.appId,
|
|
1593
|
-
groupId: options.groupId,
|
|
1594
|
-
testerIds: options.testerIds.split(",")
|
|
1595
|
-
});
|
|
1596
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1597
|
-
} catch (e) {
|
|
1598
|
-
console.error("Request failed:", e.message);
|
|
1599
|
-
}
|
|
1600
|
-
});
|
|
1601
|
-
testCmd.command("invite-code-create").description("Generate an invitation code for a group").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-g, --group-id <groupId>", "Group ID").requiredOption("--valid-days <days>", "Valid days (max 30)").requiredOption("--invite-limit <limit>", "Invite limit (max 10000)").action(async (options) => {
|
|
1602
|
-
try {
|
|
1603
|
-
const res = await TestingService.createInviteCode({
|
|
1604
|
-
appId: options.appId,
|
|
1605
|
-
groupId: options.groupId,
|
|
1606
|
-
invitationCodeValidDays: Number(options.validDays),
|
|
1607
|
-
invitationCodeInviteLimit: Number(options.inviteLimit)
|
|
1608
|
-
});
|
|
1609
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1610
|
-
} catch (e) {
|
|
1611
|
-
console.error("Request failed:", e.message);
|
|
1612
|
-
}
|
|
1613
|
-
});
|
|
1614
|
-
testCmd.command("invite-code-list").description("Query invitation codes of a group").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-g, --group-id <groupId>", "Group ID").action(async (options) => {
|
|
1615
|
-
try {
|
|
1616
|
-
const res = await TestingService.getInviteCode({
|
|
1617
|
-
appId: options.appId,
|
|
1618
|
-
groupId: options.groupId
|
|
1619
|
-
});
|
|
1620
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1621
|
-
} catch (e) {
|
|
1622
|
-
console.error("Request failed:", e.message);
|
|
1623
|
-
}
|
|
1624
|
-
});
|
|
1625
|
-
testCmd.command("invite-code-stop").description("Stop an invitation code").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--code-id <invitationCodeId>", "Invitation code ID").action(async (options) => {
|
|
1626
|
-
try {
|
|
1627
|
-
const res = await TestingService.stopInviteCode({
|
|
1628
|
-
appId: options.appId,
|
|
1629
|
-
invitationCodeId: options.codeId
|
|
1630
|
-
});
|
|
1631
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1632
|
-
} catch (e) {
|
|
1633
|
-
console.error("Request failed:", e.message);
|
|
1634
|
-
}
|
|
1635
|
-
});
|
|
1636
|
-
testCmd.command("invite-code-delete").description("Delete an invitation code").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--code-id <invitationCodeId>", "Invitation code ID").action(async (options) => {
|
|
1637
|
-
try {
|
|
1638
|
-
const res = await TestingService.deleteInviteCode({
|
|
1639
|
-
appId: options.appId,
|
|
1640
|
-
invitationCodeId: options.codeId
|
|
1641
|
-
});
|
|
1642
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1643
|
-
} catch (e) {
|
|
1644
|
-
console.error("Request failed:", e.message);
|
|
1645
|
-
}
|
|
1646
|
-
});
|
|
1647
|
-
testCmd.command("public-link-create").description("Create a public test link for a group").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-g, --group-id <groupId>", "Group ID").requiredOption("--limit <limit>", "Install/limit count").action(async (options) => {
|
|
1648
|
-
try {
|
|
1649
|
-
const res = await TestingService.createPublicLink({
|
|
1650
|
-
appId: options.appId,
|
|
1651
|
-
groupId: options.groupId,
|
|
1652
|
-
limit: Number(options.limit)
|
|
1653
|
-
});
|
|
1654
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1655
|
-
} catch (e) {
|
|
1656
|
-
console.error("Request failed:", e.message);
|
|
1657
|
-
}
|
|
1658
|
-
});
|
|
1659
|
-
testCmd.command("public-link-edit").description("Edit a public test link").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-g, --group-id <groupId>", "Group ID").option("--limit <limit>", "Install/limit count").option("--status <status>", "Link status").action(async (options) => {
|
|
1660
|
-
try {
|
|
1661
|
-
const res = await TestingService.editPublicLink({
|
|
1662
|
-
appId: options.appId,
|
|
1663
|
-
groupId: options.groupId,
|
|
1664
|
-
limit: options.limit !== void 0 ? Number(options.limit) : void 0,
|
|
1665
|
-
status: options.status !== void 0 ? Number(options.status) : void 0
|
|
1666
|
-
});
|
|
1667
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1668
|
-
} catch (e) {
|
|
1669
|
-
console.error("Request failed:", e.message);
|
|
1670
|
-
}
|
|
1671
|
-
});
|
|
1672
|
-
testCmd.command("public-link-query").description("Query a public test link").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("-g, --group-id <groupId>", "Group ID").action(async (options) => {
|
|
1673
|
-
try {
|
|
1674
|
-
const res = await TestingService.queryPublicLink({
|
|
1675
|
-
appId: options.appId,
|
|
1676
|
-
groupId: options.groupId
|
|
1677
|
-
});
|
|
1678
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1679
|
-
} catch (e) {
|
|
1680
|
-
console.error("Request failed:", e.message);
|
|
1681
|
-
}
|
|
1682
|
-
});
|
|
1683
|
-
testCmd.command("feedback-dimension").description("Query tester feedback dimensions").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--body <bodyFile>", "JSON filter body (startTime/endTime/...)").action(async (options) => {
|
|
1684
|
-
try {
|
|
1685
|
-
const body = readJsonFile(options.body);
|
|
1686
|
-
const res = await TestingService.queryFeedbackDimension({ appId: options.appId, ...body });
|
|
1687
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1688
|
-
} catch (e) {
|
|
1689
|
-
console.error("Request failed:", e.message);
|
|
1690
|
-
}
|
|
1691
|
-
});
|
|
1692
|
-
testCmd.command("feedback-query").description("Query tester feedback list").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--body <bodyFile>", "JSON filter body (startTime/endTime/currentPage/...)").action(async (options) => {
|
|
1693
|
-
try {
|
|
1694
|
-
const body = readJsonFile(options.body);
|
|
1695
|
-
const res = await TestingService.queryFeedback({ appId: options.appId, ...body });
|
|
1696
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1697
|
-
} catch (e) {
|
|
1698
|
-
console.error("Request failed:", e.message);
|
|
1699
|
-
}
|
|
1700
|
-
});
|
|
1701
|
-
testCmd.command("feedback-delete").description("Delete tester feedback").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--body <bodyFile>", "JSON body: delFeedBackInfos, deleteMode").action(async (options) => {
|
|
1702
|
-
try {
|
|
1703
|
-
const body = readJsonFile(options.body);
|
|
1704
|
-
const res = await TestingService.deleteFeedback({ appId: options.appId, ...body });
|
|
1705
|
-
console.log(JSON.stringify(res, null, 2));
|
|
1706
|
-
} catch (e) {
|
|
1707
|
-
console.error("Request failed:", e.message);
|
|
1708
|
-
}
|
|
1709
|
-
});
|
|
1710
|
-
program.parse(process.argv);
|
|
1711
|
-
//# sourceMappingURL=cli.mjs.map
|