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.js
CHANGED
|
@@ -23,10 +23,50 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
mod
|
|
24
24
|
));
|
|
25
25
|
|
|
26
|
+
// src/cli/output.ts
|
|
27
|
+
function reportFailure(...messages) {
|
|
28
|
+
console.error(...messages);
|
|
29
|
+
process.exitCode = 1;
|
|
30
|
+
}
|
|
31
|
+
function printResult(result) {
|
|
32
|
+
console.log(JSON.stringify(result, null, 2));
|
|
33
|
+
if (!result || typeof result !== "object") return;
|
|
34
|
+
const response = result;
|
|
35
|
+
const code = response.ret?.code ?? response.rtnCode;
|
|
36
|
+
if (code !== void 0 && code !== 0 && code !== "0") {
|
|
37
|
+
reportFailure(`API request failed (code=${String(code)})`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
26
41
|
// src/cli/index.ts
|
|
27
42
|
var import_commander = require("commander");
|
|
28
|
-
var
|
|
29
|
-
var
|
|
43
|
+
var fs9 = __toESM(require("fs"));
|
|
44
|
+
var import_path7 = __toESM(require("path"));
|
|
45
|
+
|
|
46
|
+
// src/core/private-file.ts
|
|
47
|
+
var import_fs = __toESM(require("fs"));
|
|
48
|
+
function restrictPermissions(fd) {
|
|
49
|
+
if (process.platform !== "win32") import_fs.default.fchmodSync(fd, 384);
|
|
50
|
+
}
|
|
51
|
+
function readPrivateFile(file) {
|
|
52
|
+
const fd = import_fs.default.openSync(file, "r");
|
|
53
|
+
try {
|
|
54
|
+
restrictPermissions(fd);
|
|
55
|
+
return import_fs.default.readFileSync(fd, "utf8");
|
|
56
|
+
} finally {
|
|
57
|
+
import_fs.default.closeSync(fd);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function writePrivateFile(file, contents) {
|
|
61
|
+
const fd = import_fs.default.openSync(file, import_fs.default.constants.O_WRONLY | import_fs.default.constants.O_CREAT, 384);
|
|
62
|
+
try {
|
|
63
|
+
restrictPermissions(fd);
|
|
64
|
+
import_fs.default.ftruncateSync(fd, 0);
|
|
65
|
+
import_fs.default.writeFileSync(fd, contents, "utf8");
|
|
66
|
+
} finally {
|
|
67
|
+
import_fs.default.closeSync(fd);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
30
70
|
|
|
31
71
|
// src/services/auth.ts
|
|
32
72
|
var import_axios = __toESM(require("axios"));
|
|
@@ -35,9 +75,9 @@ var crypto = __toESM(require("crypto"));
|
|
|
35
75
|
// src/config/index.ts
|
|
36
76
|
var dotenv = __toESM(require("dotenv"));
|
|
37
77
|
var import_path = __toESM(require("path"));
|
|
38
|
-
var
|
|
78
|
+
var import_fs2 = __toESM(require("fs"));
|
|
39
79
|
var envPath = import_path.default.resolve(process.cwd(), ".env");
|
|
40
|
-
if (
|
|
80
|
+
if (import_fs2.default.existsSync(envPath)) {
|
|
41
81
|
dotenv.config({ path: envPath, quiet: true });
|
|
42
82
|
} else {
|
|
43
83
|
dotenv.config({ quiet: true });
|
|
@@ -52,12 +92,12 @@ var DEFAULT_OAUTH = {
|
|
|
52
92
|
};
|
|
53
93
|
function loadServiceAccountCredentials(filePath) {
|
|
54
94
|
const abs = import_path.default.isAbsolute(filePath) ? filePath : import_path.default.resolve(process.cwd(), filePath);
|
|
55
|
-
if (!
|
|
95
|
+
if (!import_fs2.default.existsSync(abs)) {
|
|
56
96
|
throw new Error(`Service Account credentials file not found: ${abs}`);
|
|
57
97
|
}
|
|
58
98
|
let raw;
|
|
59
99
|
try {
|
|
60
|
-
raw = JSON.parse(
|
|
100
|
+
raw = JSON.parse(import_fs2.default.readFileSync(abs, "utf8"));
|
|
61
101
|
} catch {
|
|
62
102
|
throw new Error(`Invalid Service Account credentials JSON: ${abs}`);
|
|
63
103
|
}
|
|
@@ -134,6 +174,7 @@ var AuthService = class {
|
|
|
134
174
|
client_secret: config2.clientSecret
|
|
135
175
|
};
|
|
136
176
|
const response = await import_axios.default.post(url, payload, {
|
|
177
|
+
maxRedirects: 0,
|
|
137
178
|
headers: {
|
|
138
179
|
"Content-Type": "application/json"
|
|
139
180
|
}
|
|
@@ -199,6 +240,7 @@ var AuthService = class {
|
|
|
199
240
|
const timeoutId = setTimeout(() => controller.abort(), 3e4);
|
|
200
241
|
try {
|
|
201
242
|
const res = await import_axios.default.post(cfg.oauth.tokenUrl, { code, redirectUri }, {
|
|
243
|
+
maxRedirects: 0,
|
|
202
244
|
headers: { "Content-Type": "application/json" },
|
|
203
245
|
signal: controller.signal
|
|
204
246
|
});
|
|
@@ -225,6 +267,7 @@ var AuthService = class {
|
|
|
225
267
|
const timeoutId = setTimeout(() => controller.abort(), 3e4);
|
|
226
268
|
try {
|
|
227
269
|
const res = await import_axios.default.post(cfg.oauth.refreshUrl, { refreshToken }, {
|
|
270
|
+
maxRedirects: 0,
|
|
228
271
|
headers: { "Content-Type": "application/json" },
|
|
229
272
|
signal: controller.signal
|
|
230
273
|
});
|
|
@@ -255,15 +298,15 @@ function normalizePem(privateKey) {
|
|
|
255
298
|
|
|
256
299
|
// src/core/oauth-team.ts
|
|
257
300
|
var import_axios2 = __toESM(require("axios"));
|
|
258
|
-
var
|
|
301
|
+
var import_fs3 = __toESM(require("fs"));
|
|
259
302
|
var import_path2 = __toESM(require("path"));
|
|
260
303
|
var import_os = __toESM(require("os"));
|
|
261
304
|
var TOKEN_FILE = import_path2.default.join(import_os.default.homedir(), ".connect-api-cli-token.json");
|
|
262
305
|
var cachedTeamId;
|
|
263
306
|
function readPersistedTeamId() {
|
|
264
307
|
try {
|
|
265
|
-
if (!
|
|
266
|
-
const data = JSON.parse(
|
|
308
|
+
if (!import_fs3.default.existsSync(TOKEN_FILE)) return void 0;
|
|
309
|
+
const data = JSON.parse(readPrivateFile(TOKEN_FILE));
|
|
267
310
|
return data.teamId || void 0;
|
|
268
311
|
} catch {
|
|
269
312
|
return void 0;
|
|
@@ -271,10 +314,10 @@ function readPersistedTeamId() {
|
|
|
271
314
|
}
|
|
272
315
|
function writePersistedTeamId(teamId) {
|
|
273
316
|
try {
|
|
274
|
-
if (!
|
|
275
|
-
const data = JSON.parse(
|
|
317
|
+
if (!import_fs3.default.existsSync(TOKEN_FILE)) return;
|
|
318
|
+
const data = JSON.parse(readPrivateFile(TOKEN_FILE));
|
|
276
319
|
data.teamId = teamId;
|
|
277
|
-
|
|
320
|
+
writePrivateFile(TOKEN_FILE, JSON.stringify(data, null, 2));
|
|
278
321
|
} catch {
|
|
279
322
|
}
|
|
280
323
|
}
|
|
@@ -297,7 +340,8 @@ async function resolveOAuthTeamId(cfg, accessToken) {
|
|
|
297
340
|
oauth2Token: accessToken,
|
|
298
341
|
"Content-Type": "application/json"
|
|
299
342
|
},
|
|
300
|
-
timeout: 3e4
|
|
343
|
+
timeout: 3e4,
|
|
344
|
+
maxRedirects: 0
|
|
301
345
|
}
|
|
302
346
|
);
|
|
303
347
|
const teams = res.data.teams || [];
|
|
@@ -333,7 +377,7 @@ function clearOAuthTeamIdCache() {
|
|
|
333
377
|
var crypto2 = __toESM(require("crypto"));
|
|
334
378
|
var http = __toESM(require("http"));
|
|
335
379
|
var import_child_process = require("child_process");
|
|
336
|
-
var
|
|
380
|
+
var import_fs4 = __toESM(require("fs"));
|
|
337
381
|
var import_path3 = __toESM(require("path"));
|
|
338
382
|
var import_os2 = __toESM(require("os"));
|
|
339
383
|
var AuthManager = class {
|
|
@@ -464,8 +508,8 @@ var AuthManager = class {
|
|
|
464
508
|
}
|
|
465
509
|
static readCache() {
|
|
466
510
|
try {
|
|
467
|
-
if (
|
|
468
|
-
const data =
|
|
511
|
+
if (import_fs4.default.existsSync(this.cacheFile)) {
|
|
512
|
+
const data = readPrivateFile(this.cacheFile);
|
|
469
513
|
return JSON.parse(data);
|
|
470
514
|
}
|
|
471
515
|
} catch (e) {
|
|
@@ -474,7 +518,7 @@ var AuthManager = class {
|
|
|
474
518
|
}
|
|
475
519
|
static writeCache(cache) {
|
|
476
520
|
try {
|
|
477
|
-
|
|
521
|
+
writePrivateFile(this.cacheFile, JSON.stringify(cache, null, 2));
|
|
478
522
|
} catch (e) {
|
|
479
523
|
}
|
|
480
524
|
}
|
|
@@ -484,8 +528,8 @@ var AuthManager = class {
|
|
|
484
528
|
static clearCache() {
|
|
485
529
|
clearOAuthTeamIdCache();
|
|
486
530
|
try {
|
|
487
|
-
if (
|
|
488
|
-
|
|
531
|
+
if (import_fs4.default.existsSync(this.cacheFile)) {
|
|
532
|
+
import_fs4.default.unlinkSync(this.cacheFile);
|
|
489
533
|
return true;
|
|
490
534
|
}
|
|
491
535
|
return false;
|
|
@@ -506,7 +550,182 @@ function openBrowser(url) {
|
|
|
506
550
|
|
|
507
551
|
// src/core/http.ts
|
|
508
552
|
var import_axios3 = __toESM(require("axios"));
|
|
509
|
-
|
|
553
|
+
|
|
554
|
+
// src/core/request-source.ts
|
|
555
|
+
var import_fs5 = __toESM(require("fs"));
|
|
556
|
+
var import_path4 = __toESM(require("path"));
|
|
557
|
+
var REQUEST_SOURCE_HEADER = "Request-Source";
|
|
558
|
+
var SOURCE_TOOL_NAME_HEADER = "Source-Tool-Name";
|
|
559
|
+
var SKILL_CHANNEL = "skill";
|
|
560
|
+
var CLI_CHANNEL = "cli";
|
|
561
|
+
var SKILL_TOOL_NAME = "hmos-connect-api-skill";
|
|
562
|
+
var CLI_TOOL_NAME = "connect-api-cli";
|
|
563
|
+
var TOOL_SPECIFIC_AGENTS = [
|
|
564
|
+
{
|
|
565
|
+
name: "codebuddy",
|
|
566
|
+
match: (env) => nonempty(env.CODEBUDDY) || nonempty(env.CODEBUDDY_SESSION_ID) || nonempty(env.CODEBUDDY_PROJECT_DIR)
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
name: "cursor",
|
|
570
|
+
match: (env) => nonempty(env.CURSOR_AGENT) || env.CURSOR_EXTENSION_HOST_ROLE === "agent-exec" || nonempty(env.CURSOR_SANDBOX)
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
// ZCode(智谱):桌面/CLI Agent 会注入 ZCODE_*(如 ZCODE_APP_VERSION、ZCODE_ENV);
|
|
574
|
+
// 通常不设 AI_AGENT,需靠 Tool-specific 指纹识别。
|
|
575
|
+
name: "zcode",
|
|
576
|
+
match: (env) => looksLikeZcode(env)
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
// TRAE:官方 Hook/Agent 文档常见 TRAE_PROJECT_DIR / TRAE_ENV_FILE;
|
|
580
|
+
// TRAE_AI_SHELL_ID 仅为部分检测库记录,实测 Agent 终端不一定注入。
|
|
581
|
+
name: "trae",
|
|
582
|
+
match: (env) => looksLikeTrae(env)
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
// 华为云码道 CodeArts Agent(OpenCode 定制分支):常只露出 OPENCODE_*,
|
|
586
|
+
// 需结合 codeartsdoer 路径 / 家目录,避免被后面的 opencode 抢走。
|
|
587
|
+
// 不把 CODEARTS_CLI_AK/SK 等鉴权变量当作身份。
|
|
588
|
+
name: "codearts",
|
|
589
|
+
match: (env) => looksLikeCodeArts(env)
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
name: "claude-code",
|
|
593
|
+
match: (env) => nonempty(env.CLAUDECODE) || nonempty(env.CLAUDE_CODE_ENTRYPOINT) || nonempty(env.CLAUDE_CODE_SESSION_ID) || nonempty(env.CLAUDE_CODE_EXECPATH)
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
name: "copilot",
|
|
597
|
+
match: (env) => nonempty(env.COPILOT_AGENT) || nonempty(env.COPILOT_CLI) || nonempty(env.COPILOT_AGENT_SESSION_ID) || nonempty(env.VSCODE_AGENT)
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
name: "gemini-cli",
|
|
601
|
+
match: (env) => nonempty(env.GEMINI_CLI)
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
name: "codex",
|
|
605
|
+
match: (env) => nonempty(env.CODEX_THREAD_ID) || nonempty(env.CODEX_SANDBOX) || nonempty(env.CODEX_CI)
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
// 原生 OpenCode:有 OPENCODE_* 且不像码道时才认
|
|
609
|
+
name: "opencode",
|
|
610
|
+
match: (env) => hasOpenCodeSignals(env) && !looksLikeCodeArts(env)
|
|
611
|
+
}
|
|
612
|
+
];
|
|
613
|
+
function injected(value) {
|
|
614
|
+
return typeof value === "string" ? value : "";
|
|
615
|
+
}
|
|
616
|
+
function nonempty(value) {
|
|
617
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
618
|
+
}
|
|
619
|
+
function isUnnamedAgentValue(value) {
|
|
620
|
+
return ["0", "false", "no", "off", "1", "true"].includes(value);
|
|
621
|
+
}
|
|
622
|
+
function envValueContains(env, pattern) {
|
|
623
|
+
for (const value of Object.values(env)) {
|
|
624
|
+
if (typeof value === "string" && pattern.test(value)) return true;
|
|
625
|
+
}
|
|
626
|
+
return false;
|
|
627
|
+
}
|
|
628
|
+
function hasOpenCodeSignals(env) {
|
|
629
|
+
return nonempty(env.OPENCODE) || nonempty(env.OPENCODE_PID) || nonempty(env.OPENCODE_BIN_PATH) || nonempty(env.OPENCODE_SERVER) || nonempty(env.OPENCODE_APP_INFO) || nonempty(env.OPENCODE_CLIENT) || nonempty(env.OPENCODE_MODES);
|
|
630
|
+
}
|
|
631
|
+
function looksLikeZcode(env = process.env) {
|
|
632
|
+
if (nonempty(env.ZCODE_APP_VERSION) || nonempty(env.ZCODE_ENV) || nonempty(env.ZCODE_RUNTIME_ENV) || nonempty(env.ZCODE_BASE_URL) || nonempty(env.ZCODE_WINDOWS_APP_INSTALL_DIR) || nonempty(env.ZCODE_PROCESS_LABEL) || nonempty(env.ZCODE_SERVER_WORKSPACE) || nonempty(env.ZCODE_DATA_BASE_DIR)) {
|
|
633
|
+
return true;
|
|
634
|
+
}
|
|
635
|
+
for (const [key, value] of Object.entries(env)) {
|
|
636
|
+
if (/^ZCODE[_-]/i.test(key) && nonempty(value)) return true;
|
|
637
|
+
}
|
|
638
|
+
if (envValueContains(env, /(?:^|[\\/])ZCode(?:[\\/]|$)/)) return true;
|
|
639
|
+
if (envValueContains(env, /(?:^|[\\/])\.zcode(?:[\\/]|$)/)) return true;
|
|
640
|
+
if (env.TERM_PROGRAM && /zcode/i.test(env.TERM_PROGRAM)) return true;
|
|
641
|
+
return false;
|
|
642
|
+
}
|
|
643
|
+
function looksLikeTrae(env = process.env) {
|
|
644
|
+
if (nonempty(env.TRAE_AI_SHELL_ID) || nonempty(env.TRAE_PROJECT_DIR) || nonempty(env.TRAE_ENV_FILE)) {
|
|
645
|
+
return true;
|
|
646
|
+
}
|
|
647
|
+
for (const [key, value] of Object.entries(env)) {
|
|
648
|
+
if (/^TRAE[_-]/i.test(key) && nonempty(value)) return true;
|
|
649
|
+
}
|
|
650
|
+
if (envValueContains(env, /(?:^|[\\/])Trae(?:[\\/]|$)/i)) return true;
|
|
651
|
+
if (env.TERM_PROGRAM && /trae/i.test(env.TERM_PROGRAM)) return true;
|
|
652
|
+
return false;
|
|
653
|
+
}
|
|
654
|
+
function looksLikeCodeArts(env = process.env) {
|
|
655
|
+
if (nonempty(env.CODEARTS_AGENT) || nonempty(env.CODEARTS_SESSION_ID) || nonempty(env.CODEARTS_DOER) || nonempty(env.CODEARTSDOER)) {
|
|
656
|
+
return true;
|
|
657
|
+
}
|
|
658
|
+
if (envValueContains(env, /codeartsdoer|codearts[-_]?agent/i)) return true;
|
|
659
|
+
return false;
|
|
660
|
+
}
|
|
661
|
+
function normalizeAgentSlug(raw) {
|
|
662
|
+
const v = raw.trim().toLowerCase();
|
|
663
|
+
if (!v || isUnnamedAgentValue(v)) return void 0;
|
|
664
|
+
let slug = v.replace(/_agent$/i, "");
|
|
665
|
+
const versionCut = slug.match(/^([a-z][a-z0-9_-]*?)(?:_\d)/);
|
|
666
|
+
if (versionCut) slug = versionCut[1];
|
|
667
|
+
slug = slug.replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
668
|
+
if (!slug) return void 0;
|
|
669
|
+
if (/^(?:codearts[-_]?agent|madao)$/.test(slug)) return "codearts";
|
|
670
|
+
return slug;
|
|
671
|
+
}
|
|
672
|
+
function detectAgentName(env = process.env) {
|
|
673
|
+
for (const key of ["AI_AGENT", "AGENT"]) {
|
|
674
|
+
const raw = env[key];
|
|
675
|
+
if (!nonempty(raw)) continue;
|
|
676
|
+
const trimmed = raw.trim();
|
|
677
|
+
if (isUnnamedAgentValue(trimmed.toLowerCase())) continue;
|
|
678
|
+
const slug = normalizeAgentSlug(trimmed);
|
|
679
|
+
if (slug) return slug;
|
|
680
|
+
}
|
|
681
|
+
for (const agent of TOOL_SPECIFIC_AGENTS) {
|
|
682
|
+
if (agent.match(env)) return agent.name;
|
|
683
|
+
}
|
|
684
|
+
return void 0;
|
|
685
|
+
}
|
|
686
|
+
function getSourceChannel() {
|
|
687
|
+
const raw = injected(true ? "cli" : void 0);
|
|
688
|
+
return raw === SKILL_CHANNEL ? SKILL_CHANNEL : CLI_CHANNEL;
|
|
689
|
+
}
|
|
690
|
+
function getRequestSource() {
|
|
691
|
+
if (getSourceChannel() !== SKILL_CHANNEL) return CLI_CHANNEL;
|
|
692
|
+
const agent = detectAgentName();
|
|
693
|
+
return agent ? `${agent}-skill` : SKILL_CHANNEL;
|
|
694
|
+
}
|
|
695
|
+
function readVersion() {
|
|
696
|
+
const fromBuild = injected(true ? "1.1.6" : void 0);
|
|
697
|
+
if (fromBuild) return fromBuild;
|
|
698
|
+
const candidates = [
|
|
699
|
+
import_path4.default.join(__dirname, "..", "..", "package.json"),
|
|
700
|
+
import_path4.default.join(__dirname, "..", "package.json")
|
|
701
|
+
];
|
|
702
|
+
for (const pkgPath of candidates) {
|
|
703
|
+
try {
|
|
704
|
+
const pkg = JSON.parse(import_fs5.default.readFileSync(pkgPath, "utf8"));
|
|
705
|
+
if (pkg.version) return pkg.version;
|
|
706
|
+
} catch {
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
return "0.0.0";
|
|
710
|
+
}
|
|
711
|
+
function getSourceToolName() {
|
|
712
|
+
const base = getSourceChannel() === SKILL_CHANNEL ? SKILL_TOOL_NAME : CLI_TOOL_NAME;
|
|
713
|
+
return `${base}-${readVersion()}`;
|
|
714
|
+
}
|
|
715
|
+
function applySourceHeaders(headers) {
|
|
716
|
+
const source = getRequestSource();
|
|
717
|
+
const toolName = getSourceToolName();
|
|
718
|
+
if (typeof headers?.set === "function") {
|
|
719
|
+
headers.set(REQUEST_SOURCE_HEADER, source);
|
|
720
|
+
headers.set(SOURCE_TOOL_NAME_HEADER, toolName);
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
headers[REQUEST_SOURCE_HEADER] = source;
|
|
724
|
+
headers[SOURCE_TOOL_NAME_HEADER] = toolName;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
// src/core/http.ts
|
|
728
|
+
var agcClient = import_axios3.default.create({ maxRedirects: 0 });
|
|
510
729
|
function setHeader(headers, name, value) {
|
|
511
730
|
if (typeof headers?.set === "function") {
|
|
512
731
|
headers.set(name, value);
|
|
@@ -551,6 +770,7 @@ agcClient.interceptors.request.use(async (config2) => {
|
|
|
551
770
|
if (!config2.headers) {
|
|
552
771
|
config2.headers = {};
|
|
553
772
|
}
|
|
773
|
+
applySourceHeaders(config2.headers);
|
|
554
774
|
applyAuthHeaders(config2.headers, token, cfg);
|
|
555
775
|
if (cfg.authMode === "oauth" && !getHeader(config2.headers, "teamId")) {
|
|
556
776
|
const teamId = await resolveOAuthTeamId(cfg, token);
|
|
@@ -613,17 +833,19 @@ var PublishService = class {
|
|
|
613
833
|
});
|
|
614
834
|
return response.data;
|
|
615
835
|
}
|
|
616
|
-
/**
|
|
836
|
+
/**
|
|
837
|
+
* 创建应用或元服务。
|
|
838
|
+
* projectId 为可选 query:不传时服务端先创建与应用同名的项目,再创建应用。
|
|
839
|
+
*/
|
|
617
840
|
static async createApp(req) {
|
|
618
841
|
const { projectId, packageName, ...rest } = req;
|
|
619
842
|
const body = { ...rest };
|
|
620
843
|
if (req.installationFree === 0 && packageName) {
|
|
621
844
|
body.packageName = packageName;
|
|
622
845
|
}
|
|
623
|
-
const response = await agcClient.post(
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
);
|
|
846
|
+
const response = projectId ? await agcClient.post("/api/publish/v3/app", body, {
|
|
847
|
+
params: { projectId }
|
|
848
|
+
}) : await agcClient.post("/api/publish/v3/app", body);
|
|
627
849
|
return response.data;
|
|
628
850
|
}
|
|
629
851
|
/** 查询团队账号下的成员角色列表 */
|
|
@@ -703,7 +925,7 @@ var PublishService = class {
|
|
|
703
925
|
);
|
|
704
926
|
return response.data;
|
|
705
927
|
}
|
|
706
|
-
/** 更新应用软件包信息(OBS 上传后上报,
|
|
928
|
+
/** 更新应用软件包信息(OBS 上传后上报,HarmonyOS 开发者中心才会出现记录) */
|
|
707
929
|
static async updateAppPackageInfo(req) {
|
|
708
930
|
const { appId, releaseType, releasePhase, fileName, objectId } = req;
|
|
709
931
|
const response = await agcClient.put(
|
|
@@ -1051,8 +1273,8 @@ var ProvisionService = class {
|
|
|
1051
1273
|
|
|
1052
1274
|
// src/services/upload.ts
|
|
1053
1275
|
var import_axios4 = __toESM(require("axios"));
|
|
1054
|
-
var
|
|
1055
|
-
var
|
|
1276
|
+
var import_fs6 = __toESM(require("fs"));
|
|
1277
|
+
var import_path5 = __toESM(require("path"));
|
|
1056
1278
|
function pickObjectId(res) {
|
|
1057
1279
|
return res.urlInfo?.objectId || res.objectId;
|
|
1058
1280
|
}
|
|
@@ -1088,11 +1310,11 @@ var UploadService = class {
|
|
|
1088
1310
|
/**
|
|
1089
1311
|
* 封装好的上传文件核心流程(支持根据文件大小自动单文件或分片上传)
|
|
1090
1312
|
* 文件大小 < 5MB 时使用单文件上传,否则使用分片上传。
|
|
1091
|
-
* 仅完成 OBS 落盘;HarmonyOS `.app` 还须调用更新应用软件包信息,
|
|
1313
|
+
* 仅完成 OBS 落盘;HarmonyOS `.app` 还须调用更新应用软件包信息,HarmonyOS 开发者中心才会有记录。
|
|
1092
1314
|
*/
|
|
1093
1315
|
static async uploadFile(options) {
|
|
1094
|
-
const stat =
|
|
1095
|
-
const fileName =
|
|
1316
|
+
const stat = import_fs6.default.statSync(options.filePath);
|
|
1317
|
+
const fileName = import_path5.default.basename(options.filePath) || "unknown";
|
|
1096
1318
|
if (stat.size < 5 * 1024 * 1024) {
|
|
1097
1319
|
return this.uploadSingleFile(options, fileName, stat.size);
|
|
1098
1320
|
}
|
|
@@ -1133,7 +1355,7 @@ var UploadService = class {
|
|
|
1133
1355
|
);
|
|
1134
1356
|
}
|
|
1135
1357
|
const { url, headers } = urlRes.urlInfo;
|
|
1136
|
-
const fileStream =
|
|
1358
|
+
const fileStream = import_fs6.default.createReadStream(options.filePath);
|
|
1137
1359
|
await import_axios4.default.put(url, fileStream, {
|
|
1138
1360
|
headers: this.buildObsPutHeaders(headers, contentLength),
|
|
1139
1361
|
maxBodyLength: Infinity,
|
|
@@ -1174,7 +1396,7 @@ var UploadService = class {
|
|
|
1174
1396
|
if (!uploadInfoMap) {
|
|
1175
1397
|
throw new Error(`Failed to get parts upload URL: ${JSON.stringify(partsRes.ret)}`);
|
|
1176
1398
|
}
|
|
1177
|
-
const fd =
|
|
1399
|
+
const fd = import_fs6.default.openSync(options.filePath, "r");
|
|
1178
1400
|
const composeReqBody = {};
|
|
1179
1401
|
for (let i = 1; i <= partsCount; i++) {
|
|
1180
1402
|
const propKey = `additionalProp${i}`;
|
|
@@ -1183,7 +1405,7 @@ var UploadService = class {
|
|
|
1183
1405
|
const end = Math.min(start + partSize, fileSize);
|
|
1184
1406
|
const length = end - start;
|
|
1185
1407
|
const buffer = Buffer.alloc(length);
|
|
1186
|
-
|
|
1408
|
+
import_fs6.default.readSync(fd, buffer, 0, length, start);
|
|
1187
1409
|
const res = await import_axios4.default.put(uploadInfo.url, buffer, {
|
|
1188
1410
|
headers: this.buildObsPutHeaders(uploadInfo.headers, length),
|
|
1189
1411
|
maxBodyLength: Infinity,
|
|
@@ -1195,7 +1417,7 @@ var UploadService = class {
|
|
|
1195
1417
|
etag
|
|
1196
1418
|
};
|
|
1197
1419
|
}
|
|
1198
|
-
|
|
1420
|
+
import_fs6.default.closeSync(fd);
|
|
1199
1421
|
await this.composeMultipart({
|
|
1200
1422
|
objectId,
|
|
1201
1423
|
nspUploadId,
|
|
@@ -1206,7 +1428,7 @@ var UploadService = class {
|
|
|
1206
1428
|
};
|
|
1207
1429
|
|
|
1208
1430
|
// src/services/domain.ts
|
|
1209
|
-
var
|
|
1431
|
+
var import_fs7 = __toESM(require("fs"));
|
|
1210
1432
|
var DomainService = class {
|
|
1211
1433
|
/**
|
|
1212
1434
|
* 查询元服务的域名配置信息
|
|
@@ -1259,7 +1481,7 @@ var DomainService = class {
|
|
|
1259
1481
|
}
|
|
1260
1482
|
);
|
|
1261
1483
|
return new Promise((resolve, reject) => {
|
|
1262
|
-
const writer =
|
|
1484
|
+
const writer = import_fs7.default.createWriteStream(outputPath);
|
|
1263
1485
|
response.data.pipe(writer);
|
|
1264
1486
|
let error = null;
|
|
1265
1487
|
writer.on("error", (err) => {
|
|
@@ -1290,8 +1512,8 @@ var DomainService = class {
|
|
|
1290
1512
|
};
|
|
1291
1513
|
|
|
1292
1514
|
// src/services/sign.ts
|
|
1293
|
-
var
|
|
1294
|
-
var
|
|
1515
|
+
var import_fs8 = __toESM(require("fs"));
|
|
1516
|
+
var import_path6 = __toESM(require("path"));
|
|
1295
1517
|
var import_child_process2 = require("child_process");
|
|
1296
1518
|
var import_crypto = __toESM(require("crypto"));
|
|
1297
1519
|
var DEFAULT_SIGN_OUT_DIR = ".certs";
|
|
@@ -1303,38 +1525,66 @@ var SIGN_FILE_PREFIX = {
|
|
|
1303
1525
|
};
|
|
1304
1526
|
var SignService = class {
|
|
1305
1527
|
static resolveSignOutputLayout(options) {
|
|
1306
|
-
const rootDir = options.outDir ?
|
|
1528
|
+
const rootDir = options.outDir ? import_path6.default.resolve(options.outDir) : import_path6.default.join(process.cwd(), DEFAULT_SIGN_OUT_DIR);
|
|
1307
1529
|
const signId = options.filename || this.createSignDefaultId();
|
|
1308
1530
|
return {
|
|
1309
1531
|
rootDir,
|
|
1310
|
-
bundleDir:
|
|
1532
|
+
bundleDir: import_path6.default.join(rootDir, signId),
|
|
1311
1533
|
filename: signId
|
|
1312
1534
|
};
|
|
1313
1535
|
}
|
|
1536
|
+
/** hap-sign-tool.jar 相对 SDK 根的位置 */
|
|
1537
|
+
static HAP_SIGN_TOOL_REL = ["default", "openharmony", "toolchains", "lib", "hap-sign-tool.jar"];
|
|
1538
|
+
/**
|
|
1539
|
+
* 只根据调用方给出的路径解析 SDK:`--sdk-path` → `DEVECO_HOME` 下的 `sdk/` 或 `Contents/sdk/`。
|
|
1540
|
+
* 不扫盘、不猜常见安装目录。
|
|
1541
|
+
*/
|
|
1542
|
+
static resolveHarmonySdkPath(explicit) {
|
|
1543
|
+
if (explicit) return explicit;
|
|
1544
|
+
return this.sdkPathFromDevEcoHome(process.env.DEVECO_HOME);
|
|
1545
|
+
}
|
|
1546
|
+
/** 仅检查 `DEVECO_HOME` 本身及其 `Contents/`,找不到就返回 undefined */
|
|
1547
|
+
static sdkPathFromDevEcoHome(home) {
|
|
1548
|
+
if (!home) return void 0;
|
|
1549
|
+
for (const sdk of [import_path6.default.join(home, "sdk"), import_path6.default.join(home, "Contents", "sdk")]) {
|
|
1550
|
+
if (import_fs8.default.existsSync(import_path6.default.join(sdk, ...this.HAP_SIGN_TOOL_REL))) return sdk;
|
|
1551
|
+
}
|
|
1552
|
+
return void 0;
|
|
1553
|
+
}
|
|
1314
1554
|
static async createSignP12AndCsr(options) {
|
|
1555
|
+
const pwd = options.pwd;
|
|
1556
|
+
if (!pwd) {
|
|
1557
|
+
throw new Error("pwd is required. Ask the user for the keystore password and pass --pwd.");
|
|
1558
|
+
}
|
|
1315
1559
|
const javaPath = options.javaPath || "java";
|
|
1316
|
-
const sdkPath = options.sdkPath
|
|
1560
|
+
const sdkPath = this.resolveHarmonySdkPath(options.sdkPath);
|
|
1317
1561
|
if (!sdkPath) {
|
|
1318
|
-
|
|
1562
|
+
if (process.env.DEVECO_HOME) {
|
|
1563
|
+
throw new Error(
|
|
1564
|
+
"DEVECO_HOME is set but HarmonyOS SDK was not found under it (expected sdk/ or Contents/sdk/). Ask the user to correct the DevEco Studio path; do not search the disk."
|
|
1565
|
+
);
|
|
1566
|
+
}
|
|
1567
|
+
throw new Error(
|
|
1568
|
+
"sdkPath is required. Provide it via --sdk-path or DEVECO_HOME in .env."
|
|
1569
|
+
);
|
|
1319
1570
|
}
|
|
1320
|
-
const signToolPath =
|
|
1321
|
-
if (!
|
|
1571
|
+
const signToolPath = import_path6.default.join(sdkPath, "default", "openharmony", "toolchains", "lib", "hap-sign-tool.jar");
|
|
1572
|
+
if (!import_fs8.default.existsSync(signToolPath)) {
|
|
1322
1573
|
throw new Error(`hap-sign-tool.jar not found at ${signToolPath}`);
|
|
1323
1574
|
}
|
|
1324
1575
|
const { rootDir, bundleDir, filename } = this.resolveSignOutputLayout(options);
|
|
1325
|
-
const createdBundleDir = !
|
|
1326
|
-
if (!
|
|
1327
|
-
|
|
1576
|
+
const createdBundleDir = !import_fs8.default.existsSync(bundleDir);
|
|
1577
|
+
if (!import_fs8.default.existsSync(rootDir)) {
|
|
1578
|
+
import_fs8.default.mkdirSync(rootDir, { recursive: true });
|
|
1328
1579
|
}
|
|
1329
|
-
|
|
1330
|
-
const p12FilePath =
|
|
1331
|
-
const csrFilePath =
|
|
1580
|
+
import_fs8.default.mkdirSync(bundleDir, { recursive: true });
|
|
1581
|
+
const p12FilePath = import_path6.default.join(bundleDir, this.signFileName(filename, "p12"));
|
|
1582
|
+
const csrFilePath = import_path6.default.join(bundleDir, this.signFileName(filename, "csr"));
|
|
1332
1583
|
const alias = options.alias;
|
|
1333
|
-
const pwd = options.pwd || this.createSignDefaultPassword();
|
|
1334
1584
|
try {
|
|
1335
1585
|
this.doCreateSignFileP12(javaPath, signToolPath, alias, pwd, p12FilePath);
|
|
1336
1586
|
this.doCreateSignFileCsr(javaPath, signToolPath, alias, pwd, p12FilePath, csrFilePath);
|
|
1337
|
-
const csrContent =
|
|
1587
|
+
const csrContent = import_fs8.default.readFileSync(csrFilePath, "utf8");
|
|
1338
1588
|
const materialPath = this.placeMaterialBesideStore(bundleDir);
|
|
1339
1589
|
return {
|
|
1340
1590
|
alias,
|
|
@@ -1344,13 +1594,13 @@ var SignService = class {
|
|
|
1344
1594
|
csrPath: csrFilePath,
|
|
1345
1595
|
csrContent,
|
|
1346
1596
|
storePath: bundleDir,
|
|
1347
|
-
cerPath:
|
|
1348
|
-
p7bPath:
|
|
1597
|
+
cerPath: import_path6.default.join(bundleDir, this.signFileName(filename, "cer")),
|
|
1598
|
+
p7bPath: import_path6.default.join(bundleDir, this.signFileName(filename, "p7b")),
|
|
1349
1599
|
...materialPath ? { materialPath } : {}
|
|
1350
1600
|
};
|
|
1351
1601
|
} catch (err) {
|
|
1352
1602
|
if (createdBundleDir) {
|
|
1353
|
-
|
|
1603
|
+
import_fs8.default.rmSync(bundleDir, { recursive: true, force: true });
|
|
1354
1604
|
}
|
|
1355
1605
|
throw err;
|
|
1356
1606
|
}
|
|
@@ -1372,19 +1622,19 @@ var SignService = class {
|
|
|
1372
1622
|
* 避免签名文件被拷到工程根目录才能编过。
|
|
1373
1623
|
*/
|
|
1374
1624
|
static placeMaterialBesideStore(bundleDir, configDir) {
|
|
1375
|
-
const dest =
|
|
1376
|
-
if (
|
|
1625
|
+
const dest = import_path6.default.join(bundleDir, "material");
|
|
1626
|
+
if (import_fs8.default.existsSync(dest)) {
|
|
1377
1627
|
return dest;
|
|
1378
1628
|
}
|
|
1379
1629
|
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
1380
|
-
const src =
|
|
1381
|
-
if (!
|
|
1630
|
+
const src = import_path6.default.resolve(configDir || import_path6.default.join(home, ".ohos", "config"), "material");
|
|
1631
|
+
if (!import_fs8.default.existsSync(src)) {
|
|
1382
1632
|
return void 0;
|
|
1383
1633
|
}
|
|
1384
1634
|
try {
|
|
1385
|
-
|
|
1635
|
+
import_fs8.default.symlinkSync(src, dest, process.platform === "win32" ? "junction" : "dir");
|
|
1386
1636
|
} catch {
|
|
1387
|
-
|
|
1637
|
+
import_fs8.default.cpSync(src, dest, { recursive: true });
|
|
1388
1638
|
}
|
|
1389
1639
|
return dest;
|
|
1390
1640
|
}
|
|
@@ -1446,12 +1696,12 @@ var SignService = class {
|
|
|
1446
1696
|
}
|
|
1447
1697
|
static COMPONENT = new Int8Array([49, 243, 9, 115, 214, 175, 91, 184, 211, 190, 177, 88, 101, 131, 192, 119]);
|
|
1448
1698
|
static readDirBytes(dirPath) {
|
|
1449
|
-
const entries =
|
|
1450
|
-
return new Int8Array(
|
|
1699
|
+
const entries = import_fs8.default.readdirSync(dirPath).filter((f) => f !== ".DS_Store");
|
|
1700
|
+
return new Int8Array(import_fs8.default.readFileSync(import_path6.default.resolve(dirPath, entries[0])));
|
|
1451
1701
|
}
|
|
1452
1702
|
static readFd(materialPath) {
|
|
1453
|
-
const fdDir =
|
|
1454
|
-
return
|
|
1703
|
+
const fdDir = import_path6.default.resolve(materialPath, "fd");
|
|
1704
|
+
return import_fs8.default.readdirSync(fdDir).filter((f) => f !== ".DS_Store").map((e) => this.readDirBytes(import_path6.default.resolve(fdDir, e)));
|
|
1455
1705
|
}
|
|
1456
1706
|
static xorBuffers(a, b) {
|
|
1457
1707
|
const result = new Int8Array(a.byteLength);
|
|
@@ -1482,22 +1732,22 @@ var SignService = class {
|
|
|
1482
1732
|
return Buffer.concat([header, iv, enc, tag]).toString("hex").toUpperCase();
|
|
1483
1733
|
}
|
|
1484
1734
|
static deriveEncryptionKey(configDir) {
|
|
1485
|
-
const materialDir =
|
|
1735
|
+
const materialDir = import_path6.default.resolve(configDir, "material");
|
|
1486
1736
|
const fd = this.readFd(materialDir);
|
|
1487
|
-
const salt = this.readDirBytes(
|
|
1737
|
+
const salt = this.readDirBytes(import_path6.default.resolve(materialDir, "ac"));
|
|
1488
1738
|
const rawKey = new Int8Array(
|
|
1489
1739
|
import_crypto.default.pbkdf2Sync(this.xorAll(fd.concat(this.COMPONENT)).toString(), salt, 1e4, 16, "sha256")
|
|
1490
1740
|
);
|
|
1491
|
-
return new Int8Array(this.aesDecrypt(rawKey, this.readDirBytes(
|
|
1741
|
+
return new Int8Array(this.aesDecrypt(rawKey, this.readDirBytes(import_path6.default.resolve(materialDir, "ce"))));
|
|
1492
1742
|
}
|
|
1493
1743
|
/**
|
|
1494
1744
|
* 使用 DevEco Studio 的加密密钥对密码进行 AES-128-GCM 加密,
|
|
1495
1745
|
* 生成 build-profile.json5 中 signingConfigs 所需的加密密码。
|
|
1496
1746
|
*/
|
|
1497
1747
|
static encryptPassword(password, configDir) {
|
|
1498
|
-
const dir = configDir ||
|
|
1499
|
-
if (!
|
|
1500
|
-
throw new Error(`\u672A\u627E\u5230\u52A0\u5BC6\u5BC6\u94A5\u76EE\u5F55: ${
|
|
1748
|
+
const dir = configDir || import_path6.default.join(process.env.HOME || "", ".ohos", "config");
|
|
1749
|
+
if (!import_fs8.default.existsSync(import_path6.default.resolve(dir, "material"))) {
|
|
1750
|
+
throw new Error(`\u672A\u627E\u5230\u52A0\u5BC6\u5BC6\u94A5\u76EE\u5F55: ${import_path6.default.resolve(dir, "material")}\u3002\u8BF7\u786E\u8BA4 DevEco Studio \u5DF2\u5B89\u88C5\u5E76\u751F\u6210\u8FC7\u7B7E\u540D\u914D\u7F6E\u3002`);
|
|
1501
1751
|
}
|
|
1502
1752
|
const key = this.deriveEncryptionKey(dir);
|
|
1503
1753
|
return {
|
|
@@ -1645,15 +1895,16 @@ var TestingService = class {
|
|
|
1645
1895
|
}
|
|
1646
1896
|
/** 查询测试群组成员 */
|
|
1647
1897
|
static async listGroupUsers(req) {
|
|
1648
|
-
const params = {
|
|
1649
|
-
groupId: req.groupId,
|
|
1650
|
-
appId: req.appId
|
|
1651
|
-
};
|
|
1898
|
+
const params = {};
|
|
1652
1899
|
if (req.current !== void 0) params.current = req.current;
|
|
1653
1900
|
if (req.pageSize !== void 0) params.pageSize = req.pageSize;
|
|
1654
1901
|
const response = await agcClient.get(
|
|
1655
1902
|
"/api/app-test/v1/test-user",
|
|
1656
|
-
{
|
|
1903
|
+
{
|
|
1904
|
+
params,
|
|
1905
|
+
// Connect 网关要求 groupId 走 header,query 会 400 Parameter is required
|
|
1906
|
+
headers: { ...appIdHeaders2(req.appId), groupId: req.groupId }
|
|
1907
|
+
}
|
|
1657
1908
|
);
|
|
1658
1909
|
return response.data;
|
|
1659
1910
|
}
|
|
@@ -1680,7 +1931,7 @@ var TestingService = class {
|
|
|
1680
1931
|
static async notifyUsers(req) {
|
|
1681
1932
|
const { appId, ...body } = req;
|
|
1682
1933
|
const response = await agcClient.post(
|
|
1683
|
-
"/api/publish/
|
|
1934
|
+
"/api/publish/v2/test/user/action/notify",
|
|
1684
1935
|
body,
|
|
1685
1936
|
{ headers: appIdHeaders2(appId) }
|
|
1686
1937
|
);
|
|
@@ -1783,80 +2034,21 @@ var TestingService = class {
|
|
|
1783
2034
|
}
|
|
1784
2035
|
};
|
|
1785
2036
|
|
|
1786
|
-
// src/cli/project-pick.ts
|
|
1787
|
-
var readline = __toESM(require("readline"));
|
|
1788
|
-
async function resolveProjectId(explicit) {
|
|
1789
|
-
if (explicit) return explicit;
|
|
1790
|
-
const res = await ProjectService.listProjects();
|
|
1791
|
-
if (res.ret?.code !== 0) {
|
|
1792
|
-
console.error(
|
|
1793
|
-
`Failed to list projects: ret.code=${res.ret?.code} msg=${res.ret?.msg ?? "(none)"}`
|
|
1794
|
-
);
|
|
1795
|
-
return void 0;
|
|
1796
|
-
}
|
|
1797
|
-
const list = res.projectList ?? [];
|
|
1798
|
-
if (list.length === 0) {
|
|
1799
|
-
console.error("No projects found. Create a project in AppGallery Connect first.");
|
|
1800
|
-
return void 0;
|
|
1801
|
-
}
|
|
1802
|
-
printProjectChoices(list);
|
|
1803
|
-
if (!process.stdin.isTTY) {
|
|
1804
|
-
console.error(
|
|
1805
|
-
"Non-interactive mode: pass --project-id <id> (from project list)."
|
|
1806
|
-
);
|
|
1807
|
-
return void 0;
|
|
1808
|
-
}
|
|
1809
|
-
const answer = (await promptStderr("Select project by number or paste projectId: ")).trim();
|
|
1810
|
-
if (!answer) {
|
|
1811
|
-
console.error("No project selected.");
|
|
1812
|
-
return void 0;
|
|
1813
|
-
}
|
|
1814
|
-
const byIndex = Number(answer);
|
|
1815
|
-
if (Number.isInteger(byIndex) && byIndex >= 1 && byIndex <= list.length) {
|
|
1816
|
-
const chosen = list[byIndex - 1];
|
|
1817
|
-
console.error(`Using projectId=${chosen.projectId} (${chosen.name ?? ""})`);
|
|
1818
|
-
return chosen.projectId;
|
|
1819
|
-
}
|
|
1820
|
-
const byId = list.find((p) => p.projectId === answer);
|
|
1821
|
-
if (byId) {
|
|
1822
|
-
console.error(`Using projectId=${byId.projectId} (${byId.name ?? ""})`);
|
|
1823
|
-
return byId.projectId;
|
|
1824
|
-
}
|
|
1825
|
-
console.error(`Invalid selection: ${answer}`);
|
|
1826
|
-
return void 0;
|
|
1827
|
-
}
|
|
1828
|
-
function printProjectChoices(list) {
|
|
1829
|
-
console.error("Available projects (use projectId for app-create --project-id):");
|
|
1830
|
-
list.forEach((p, i) => {
|
|
1831
|
-
const name = p.name ? ` ${p.name}` : "";
|
|
1832
|
-
console.error(` [${i + 1}] ${p.projectId}${name}`);
|
|
1833
|
-
});
|
|
1834
|
-
}
|
|
1835
|
-
function promptStderr(question) {
|
|
1836
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
1837
|
-
return new Promise((resolve) => {
|
|
1838
|
-
rl.question(question, (answer) => {
|
|
1839
|
-
rl.close();
|
|
1840
|
-
resolve(answer);
|
|
1841
|
-
});
|
|
1842
|
-
});
|
|
1843
|
-
}
|
|
1844
|
-
|
|
1845
2037
|
// src/cli/index.ts
|
|
1846
2038
|
var program = new import_commander.Command();
|
|
1847
2039
|
function readCliVersion() {
|
|
1848
|
-
if (
|
|
1849
|
-
return
|
|
2040
|
+
if ("1.1.6") {
|
|
2041
|
+
return "1.1.6";
|
|
1850
2042
|
}
|
|
1851
2043
|
try {
|
|
1852
|
-
const pkgPath =
|
|
1853
|
-
const pkg = JSON.parse(
|
|
2044
|
+
const pkgPath = import_path7.default.join(__dirname, "..", "package.json");
|
|
2045
|
+
const pkg = JSON.parse(fs9.readFileSync(pkgPath, "utf8"));
|
|
1854
2046
|
if (pkg.version) return pkg.version;
|
|
1855
2047
|
} catch {
|
|
1856
2048
|
}
|
|
1857
2049
|
return "0.0.0";
|
|
1858
2050
|
}
|
|
1859
|
-
program.name("connect-api-cli").description("
|
|
2051
|
+
program.name("connect-api-cli").description("HarmonyOS \u5F00\u53D1\u8005\u4E2D\u5FC3 API CLI Tool").version(readCliVersion());
|
|
1860
2052
|
var authCmd = program.command("auth").description("Authentication management");
|
|
1861
2053
|
authCmd.command("login").description("Login and cache token (client_credentials / service_account JWT / OAuth browser)").action(async () => {
|
|
1862
2054
|
try {
|
|
@@ -1864,7 +2056,7 @@ authCmd.command("login").description("Login and cache token (client_credentials
|
|
|
1864
2056
|
console.log("Successfully logged in. Token generated and cached.");
|
|
1865
2057
|
console.log(`Token snippet: ${token.substring(0, 10)}...`);
|
|
1866
2058
|
} catch (e) {
|
|
1867
|
-
|
|
2059
|
+
reportFailure("Login failed:", e.message);
|
|
1868
2060
|
}
|
|
1869
2061
|
});
|
|
1870
2062
|
authCmd.command("status").description("Show current auth mode and cached token status").action(() => {
|
|
@@ -1872,7 +2064,7 @@ authCmd.command("status").description("Show current auth mode and cached token s
|
|
|
1872
2064
|
try {
|
|
1873
2065
|
cfg = getConfig();
|
|
1874
2066
|
} catch (e) {
|
|
1875
|
-
|
|
2067
|
+
reportFailure(`Auth status unavailable: ${e.message}`);
|
|
1876
2068
|
process.exitCode = 1;
|
|
1877
2069
|
return;
|
|
1878
2070
|
}
|
|
@@ -1910,17 +2102,20 @@ authCmd.command("logout").description("Logout and clear cached access token").ac
|
|
|
1910
2102
|
});
|
|
1911
2103
|
var publishCmd = program.command("publish").description("Publishing API commands");
|
|
1912
2104
|
function readJsonFile(filePath) {
|
|
1913
|
-
return JSON.parse(
|
|
2105
|
+
return JSON.parse(fs9.readFileSync(filePath, "utf8"));
|
|
1914
2106
|
}
|
|
1915
2107
|
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) => {
|
|
1916
2108
|
try {
|
|
1917
2109
|
const res = await PublishService.getAppIdList(options.packageName, options.packageTypes);
|
|
1918
|
-
|
|
2110
|
+
printResult(res);
|
|
1919
2111
|
} catch (e) {
|
|
1920
|
-
|
|
2112
|
+
reportFailure("Request failed:", e.message);
|
|
1921
2113
|
}
|
|
1922
2114
|
});
|
|
1923
|
-
publishCmd.command("app-create").description("Create an app or meta-service (omit --project-id to
|
|
2115
|
+
publishCmd.command("app-create").description("Create an app or meta-service (omit --project-id to let the server create a same-named project)").option(
|
|
2116
|
+
"--project-id <projectId>",
|
|
2117
|
+
"Existing project ID; omit so the server creates a project named after the app"
|
|
2118
|
+
).requiredOption("--app-name <appName>", "App / meta-service name").option("-p, --package-name <packageName>", "Package name (required for app; omit for meta-service)").requiredOption(
|
|
1924
2119
|
"--parent-type <parentType>",
|
|
1925
2120
|
"Primary category: 2 game, 13 app"
|
|
1926
2121
|
).requiredOption(
|
|
@@ -1931,31 +2126,27 @@ publishCmd.command("app-create").description("Create an app or meta-service (omi
|
|
|
1931
2126
|
const parentType = Number(options.parentType);
|
|
1932
2127
|
const installationFree = Number(options.installationFree);
|
|
1933
2128
|
if (parentType !== 2 && parentType !== 13) {
|
|
1934
|
-
|
|
2129
|
+
reportFailure("Invalid --parent-type: must be 2 (game) or 13 (app)");
|
|
1935
2130
|
return;
|
|
1936
2131
|
}
|
|
1937
2132
|
if (installationFree !== 0 && installationFree !== 1) {
|
|
1938
|
-
|
|
2133
|
+
reportFailure("Invalid --installation-free: must be 0 (app) or 1 (meta-service)");
|
|
1939
2134
|
return;
|
|
1940
2135
|
}
|
|
1941
2136
|
if (installationFree === 0 && !options.packageName) {
|
|
1942
|
-
|
|
1943
|
-
return;
|
|
1944
|
-
}
|
|
1945
|
-
const projectId = await resolveProjectId(options.projectId);
|
|
1946
|
-
if (!projectId) {
|
|
2137
|
+
reportFailure("Missing -p/--package-name: required when creating an app (installation-free=0)");
|
|
1947
2138
|
return;
|
|
1948
2139
|
}
|
|
1949
2140
|
const res = await PublishService.createApp({
|
|
1950
|
-
projectId,
|
|
2141
|
+
...options.projectId ? { projectId: options.projectId } : {},
|
|
1951
2142
|
appName: options.appName,
|
|
1952
2143
|
...options.packageName ? { packageName: options.packageName } : {},
|
|
1953
2144
|
parentType,
|
|
1954
2145
|
installationFree
|
|
1955
2146
|
});
|
|
1956
|
-
|
|
2147
|
+
printResult(res);
|
|
1957
2148
|
} catch (e) {
|
|
1958
|
-
|
|
2149
|
+
reportFailure("Request failed:", e.message);
|
|
1959
2150
|
}
|
|
1960
2151
|
});
|
|
1961
2152
|
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) => {
|
|
@@ -1965,9 +2156,9 @@ publishCmd.command("members").description("List team members and roles").require
|
|
|
1965
2156
|
pageSize: Number(options.pageSize),
|
|
1966
2157
|
languageCode: options.lang
|
|
1967
2158
|
});
|
|
1968
|
-
|
|
2159
|
+
printResult(res);
|
|
1969
2160
|
} catch (e) {
|
|
1970
|
-
|
|
2161
|
+
reportFailure("Request failed:", e.message);
|
|
1971
2162
|
}
|
|
1972
2163
|
});
|
|
1973
2164
|
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) => {
|
|
@@ -1978,9 +2169,9 @@ publishCmd.command("app-info").description("Get App Info by App ID").requiredOpt
|
|
|
1978
2169
|
releaseType: options.releaseType ? Number(options.releaseType) : void 0,
|
|
1979
2170
|
versionId: options.versionId
|
|
1980
2171
|
});
|
|
1981
|
-
|
|
2172
|
+
printResult(res);
|
|
1982
2173
|
} catch (e) {
|
|
1983
|
-
|
|
2174
|
+
reportFailure("Request failed:", e.message);
|
|
1984
2175
|
}
|
|
1985
2176
|
});
|
|
1986
2177
|
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) => {
|
|
@@ -1992,9 +2183,9 @@ publishCmd.command("app-info-update").description("Update app basic info").requi
|
|
|
1992
2183
|
releasePhase: options.releasePhase ? Number(options.releasePhase) : void 0,
|
|
1993
2184
|
...body
|
|
1994
2185
|
});
|
|
1995
|
-
|
|
2186
|
+
printResult(res);
|
|
1996
2187
|
} catch (e) {
|
|
1997
|
-
|
|
2188
|
+
reportFailure("Request failed:", e.message);
|
|
1998
2189
|
}
|
|
1999
2190
|
});
|
|
2000
2191
|
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) => {
|
|
@@ -2006,9 +2197,9 @@ publishCmd.command("language-update").description("Update app language info").re
|
|
|
2006
2197
|
releasePhase: options.releasePhase ? Number(options.releasePhase) : void 0,
|
|
2007
2198
|
...body
|
|
2008
2199
|
});
|
|
2009
|
-
|
|
2200
|
+
printResult(res);
|
|
2010
2201
|
} catch (e) {
|
|
2011
|
-
|
|
2202
|
+
reportFailure("Request failed:", e.message);
|
|
2012
2203
|
}
|
|
2013
2204
|
});
|
|
2014
2205
|
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) => {
|
|
@@ -2018,9 +2209,9 @@ publishCmd.command("language-delete").description("Delete app language info").re
|
|
|
2018
2209
|
lang: options.lang,
|
|
2019
2210
|
releaseType: options.releaseType ? Number(options.releaseType) : void 0
|
|
2020
2211
|
});
|
|
2021
|
-
|
|
2212
|
+
printResult(res);
|
|
2022
2213
|
} catch (e) {
|
|
2023
|
-
|
|
2214
|
+
reportFailure("Request failed:", e.message);
|
|
2024
2215
|
}
|
|
2025
2216
|
});
|
|
2026
2217
|
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) => {
|
|
@@ -2032,12 +2223,12 @@ publishCmd.command("file-info-update").description("Update app file info (icons/
|
|
|
2032
2223
|
releasePhase: options.releasePhase ? Number(options.releasePhase) : void 0,
|
|
2033
2224
|
...body
|
|
2034
2225
|
});
|
|
2035
|
-
|
|
2226
|
+
printResult(res);
|
|
2036
2227
|
} catch (e) {
|
|
2037
|
-
|
|
2228
|
+
reportFailure("Request failed:", e.message);
|
|
2038
2229
|
}
|
|
2039
2230
|
});
|
|
2040
|
-
publishCmd.command("package-update").description("Report uploaded package to
|
|
2231
|
+
publishCmd.command("package-update").description("Report uploaded package to HarmonyOS \u5F00\u53D1\u8005\u4E2D\u5FC3 (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) => {
|
|
2041
2232
|
try {
|
|
2042
2233
|
const res = await PublishService.updateAppPackageInfo({
|
|
2043
2234
|
appId: options.appId,
|
|
@@ -2046,9 +2237,9 @@ publishCmd.command("package-update").description("Report uploaded package to AGC
|
|
|
2046
2237
|
releaseType: options.releaseType ? Number(options.releaseType) : void 0,
|
|
2047
2238
|
releasePhase: options.releasePhase ? Number(options.releasePhase) : void 0
|
|
2048
2239
|
});
|
|
2049
|
-
|
|
2240
|
+
printResult(res);
|
|
2050
2241
|
} catch (e) {
|
|
2051
|
-
|
|
2242
|
+
reportFailure("Request failed:", e.message);
|
|
2052
2243
|
}
|
|
2053
2244
|
});
|
|
2054
2245
|
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) => {
|
|
@@ -2059,18 +2250,18 @@ publishCmd.command("release-time").description("Update version on-shelf time").r
|
|
|
2059
2250
|
releaseTime: options.releaseTime,
|
|
2060
2251
|
releaseType: options.releaseType ? Number(options.releaseType) : void 0
|
|
2061
2252
|
});
|
|
2062
|
-
|
|
2253
|
+
printResult(res);
|
|
2063
2254
|
} catch (e) {
|
|
2064
|
-
|
|
2255
|
+
reportFailure("Request failed:", e.message);
|
|
2065
2256
|
}
|
|
2066
2257
|
});
|
|
2067
2258
|
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) => {
|
|
2068
2259
|
try {
|
|
2069
2260
|
const body = readJsonFile(options.body);
|
|
2070
2261
|
const res = await PublishService.updatePhasedRelease({ appId: options.appId, ...body });
|
|
2071
|
-
|
|
2262
|
+
printResult(res);
|
|
2072
2263
|
} catch (e) {
|
|
2073
|
-
|
|
2264
|
+
reportFailure("Request failed:", e.message);
|
|
2074
2265
|
}
|
|
2075
2266
|
});
|
|
2076
2267
|
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) => {
|
|
@@ -2079,9 +2270,9 @@ publishCmd.command("package-info").description("Query package info by package ID
|
|
|
2079
2270
|
appId: options.appId,
|
|
2080
2271
|
packageId: options.packageId
|
|
2081
2272
|
});
|
|
2082
|
-
|
|
2273
|
+
printResult(res);
|
|
2083
2274
|
} catch (e) {
|
|
2084
|
-
|
|
2275
|
+
reportFailure("Request failed:", e.message);
|
|
2085
2276
|
}
|
|
2086
2277
|
});
|
|
2087
2278
|
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) => {
|
|
@@ -2090,9 +2281,9 @@ publishCmd.command("compile-status").description("Query package compile/parse st
|
|
|
2090
2281
|
appId: options.appId,
|
|
2091
2282
|
pkgIds: options.pkgIds
|
|
2092
2283
|
});
|
|
2093
|
-
|
|
2284
|
+
printResult(res);
|
|
2094
2285
|
} catch (e) {
|
|
2095
|
-
|
|
2286
|
+
reportFailure("Request failed:", e.message);
|
|
2096
2287
|
}
|
|
2097
2288
|
});
|
|
2098
2289
|
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) => {
|
|
@@ -2102,35 +2293,35 @@ publishCmd.command("version-list").description("Query brief info list of all ver
|
|
|
2102
2293
|
packageName: options.packageName,
|
|
2103
2294
|
state: options.state
|
|
2104
2295
|
});
|
|
2105
|
-
|
|
2296
|
+
printResult(res);
|
|
2106
2297
|
} catch (e) {
|
|
2107
|
-
|
|
2298
|
+
reportFailure("Request failed:", e.message);
|
|
2108
2299
|
}
|
|
2109
2300
|
});
|
|
2110
2301
|
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) => {
|
|
2111
2302
|
try {
|
|
2112
2303
|
const body = options.body ? readJsonFile(options.body) : {};
|
|
2113
2304
|
const res = await PublishService.queryVersionVoc({ appId: options.appId, ...body });
|
|
2114
|
-
|
|
2305
|
+
printResult(res);
|
|
2115
2306
|
} catch (e) {
|
|
2116
|
-
|
|
2307
|
+
reportFailure("Request failed:", e.message);
|
|
2117
2308
|
}
|
|
2118
2309
|
});
|
|
2119
2310
|
publishCmd.command("qual-dependent").description("Query required qualification file definitions").action(async () => {
|
|
2120
2311
|
try {
|
|
2121
2312
|
const res = await PublishService.queryTagQualDependent();
|
|
2122
|
-
|
|
2313
|
+
printResult(res);
|
|
2123
2314
|
} catch (e) {
|
|
2124
|
-
|
|
2315
|
+
reportFailure("Request failed:", e.message);
|
|
2125
2316
|
}
|
|
2126
2317
|
});
|
|
2127
2318
|
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) => {
|
|
2128
2319
|
try {
|
|
2129
2320
|
const body = readJsonFile(options.body);
|
|
2130
2321
|
const res = await PublishService.submitQualificationReview({ appId: options.appId, ...body });
|
|
2131
|
-
|
|
2322
|
+
printResult(res);
|
|
2132
2323
|
} catch (e) {
|
|
2133
|
-
|
|
2324
|
+
reportFailure("Request failed:", e.message);
|
|
2134
2325
|
}
|
|
2135
2326
|
});
|
|
2136
2327
|
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) => {
|
|
@@ -2139,18 +2330,18 @@ publishCmd.command("qual-query").description("Query qualification review task de
|
|
|
2139
2330
|
appId: options.appId,
|
|
2140
2331
|
tagIds: options.tagIds
|
|
2141
2332
|
});
|
|
2142
|
-
|
|
2333
|
+
printResult(res);
|
|
2143
2334
|
} catch (e) {
|
|
2144
|
-
|
|
2335
|
+
reportFailure("Request failed:", e.message);
|
|
2145
2336
|
}
|
|
2146
2337
|
});
|
|
2147
2338
|
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) => {
|
|
2148
2339
|
try {
|
|
2149
2340
|
const body = readJsonFile(options.body);
|
|
2150
2341
|
const res = await PublishService.updateQualificationReview({ appId: options.appId, ...body });
|
|
2151
|
-
|
|
2342
|
+
printResult(res);
|
|
2152
2343
|
} catch (e) {
|
|
2153
|
-
|
|
2344
|
+
reportFailure("Request failed:", e.message);
|
|
2154
2345
|
}
|
|
2155
2346
|
});
|
|
2156
2347
|
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) => {
|
|
@@ -2159,9 +2350,9 @@ publishCmd.command("qual-cancel").description("Cancel qualification review task"
|
|
|
2159
2350
|
appId: options.appId,
|
|
2160
2351
|
taskId: options.taskId
|
|
2161
2352
|
});
|
|
2162
|
-
|
|
2353
|
+
printResult(res);
|
|
2163
2354
|
} catch (e) {
|
|
2164
|
-
|
|
2355
|
+
reportFailure("Request failed:", e.message);
|
|
2165
2356
|
}
|
|
2166
2357
|
});
|
|
2167
2358
|
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) => {
|
|
@@ -2170,18 +2361,18 @@ publishCmd.command("qual-delete").description("Delete qualification review task"
|
|
|
2170
2361
|
appId: options.appId,
|
|
2171
2362
|
tagIds: options.tagIds.split(",")
|
|
2172
2363
|
});
|
|
2173
|
-
|
|
2364
|
+
printResult(res);
|
|
2174
2365
|
} catch (e) {
|
|
2175
|
-
|
|
2366
|
+
reportFailure("Request failed:", e.message);
|
|
2176
2367
|
}
|
|
2177
2368
|
});
|
|
2178
2369
|
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) => {
|
|
2179
2370
|
try {
|
|
2180
2371
|
const body = readJsonFile(options.body);
|
|
2181
2372
|
const res = await PublishService.createAgreement({ appId: options.appId, ...body });
|
|
2182
|
-
|
|
2373
|
+
printResult(res);
|
|
2183
2374
|
} catch (e) {
|
|
2184
|
-
|
|
2375
|
+
reportFailure("Request failed:", e.message);
|
|
2185
2376
|
}
|
|
2186
2377
|
});
|
|
2187
2378
|
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) => {
|
|
@@ -2189,18 +2380,18 @@ publishCmd.command("agreement-list").description("List user/privacy agreements")
|
|
|
2189
2380
|
const body = options.body ? readJsonFile(options.body) : {};
|
|
2190
2381
|
if (options.type !== void 0) body.type = Number(options.type);
|
|
2191
2382
|
const res = await PublishService.listAgreements({ appId: options.appId, ...body });
|
|
2192
|
-
|
|
2383
|
+
printResult(res);
|
|
2193
2384
|
} catch (e) {
|
|
2194
|
-
|
|
2385
|
+
reportFailure("Request failed:", e.message);
|
|
2195
2386
|
}
|
|
2196
2387
|
});
|
|
2197
2388
|
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) => {
|
|
2198
2389
|
try {
|
|
2199
2390
|
const body = readJsonFile(options.body);
|
|
2200
2391
|
const res = await PublishService.updateAgreement({ appId: options.appId, ...body });
|
|
2201
|
-
|
|
2392
|
+
printResult(res);
|
|
2202
2393
|
} catch (e) {
|
|
2203
|
-
|
|
2394
|
+
reportFailure("Request failed:", e.message);
|
|
2204
2395
|
}
|
|
2205
2396
|
});
|
|
2206
2397
|
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) => {
|
|
@@ -2210,9 +2401,9 @@ publishCmd.command("privacy-submit").description("Submit privacy agreement for r
|
|
|
2210
2401
|
id: options.id,
|
|
2211
2402
|
requireConfirm: options.requireConfirm !== void 0 ? Number(options.requireConfirm) : void 0
|
|
2212
2403
|
});
|
|
2213
|
-
|
|
2404
|
+
printResult(res);
|
|
2214
2405
|
} catch (e) {
|
|
2215
|
-
|
|
2406
|
+
reportFailure("Request failed:", e.message);
|
|
2216
2407
|
}
|
|
2217
2408
|
});
|
|
2218
2409
|
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) => {
|
|
@@ -2224,9 +2415,9 @@ publishCmd.command("age-rating").description("Apply for age rating").requiredOpt
|
|
|
2224
2415
|
releasePhase: options.releasePhase ? Number(options.releasePhase) : void 0,
|
|
2225
2416
|
...body
|
|
2226
2417
|
});
|
|
2227
|
-
|
|
2418
|
+
printResult(res);
|
|
2228
2419
|
} catch (e) {
|
|
2229
|
-
|
|
2420
|
+
reportFailure("Request failed:", e.message);
|
|
2230
2421
|
}
|
|
2231
2422
|
});
|
|
2232
2423
|
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) => {
|
|
@@ -2237,9 +2428,9 @@ publishCmd.command("submit").description("Submit app for release review").requir
|
|
|
2237
2428
|
if (options.remark !== void 0) body.remark = options.remark;
|
|
2238
2429
|
if (options.releaseTime !== void 0) body.releaseTime = options.releaseTime;
|
|
2239
2430
|
const res = await PublishService.submitApp({ appId: options.appId, ...body });
|
|
2240
|
-
|
|
2431
|
+
printResult(res);
|
|
2241
2432
|
} catch (e) {
|
|
2242
|
-
|
|
2433
|
+
reportFailure("Request failed:", e.message);
|
|
2243
2434
|
}
|
|
2244
2435
|
});
|
|
2245
2436
|
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) => {
|
|
@@ -2248,9 +2439,9 @@ publishCmd.command("cancel-review").description("Cancel an in-review version").r
|
|
|
2248
2439
|
appId: options.appId,
|
|
2249
2440
|
versionId: options.versionId
|
|
2250
2441
|
});
|
|
2251
|
-
|
|
2442
|
+
printResult(res);
|
|
2252
2443
|
} catch (e) {
|
|
2253
|
-
|
|
2444
|
+
reportFailure("Request failed:", e.message);
|
|
2254
2445
|
}
|
|
2255
2446
|
});
|
|
2256
2447
|
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) => {
|
|
@@ -2260,16 +2451,16 @@ publishCmd.command("shelf-off").description("Take app off shelf").requiredOption
|
|
|
2260
2451
|
reason: options.reason,
|
|
2261
2452
|
releaseType: options.releaseType ? Number(options.releaseType) : void 0
|
|
2262
2453
|
});
|
|
2263
|
-
|
|
2454
|
+
printResult(res);
|
|
2264
2455
|
} catch (e) {
|
|
2265
|
-
|
|
2456
|
+
reportFailure("Request failed:", e.message);
|
|
2266
2457
|
}
|
|
2267
2458
|
});
|
|
2268
2459
|
var projectCmd = program.command("project").description("Project Management API commands");
|
|
2269
|
-
projectCmd.command("list").description("List
|
|
2460
|
+
projectCmd.command("list").description("List HarmonyOS \u5F00\u53D1\u8005\u4E2D\u5FC3 projects (optional --project-id for publish app-create)").action(async () => {
|
|
2270
2461
|
try {
|
|
2271
2462
|
const res = await ProjectService.listProjects();
|
|
2272
|
-
|
|
2463
|
+
printResult(res);
|
|
2273
2464
|
const list = res.projectList ?? [];
|
|
2274
2465
|
if (res.ret?.code === 0 && list.length > 0) {
|
|
2275
2466
|
console.error("projectId choices:");
|
|
@@ -2278,11 +2469,11 @@ projectCmd.command("list").description("List AGC projects (projectId for publish
|
|
|
2278
2469
|
}
|
|
2279
2470
|
}
|
|
2280
2471
|
} catch (e) {
|
|
2281
|
-
|
|
2472
|
+
reportFailure("Request failed:", e.message);
|
|
2282
2473
|
}
|
|
2283
2474
|
});
|
|
2284
2475
|
var uploadCmd = program.command("upload").description("Upload Management API commands");
|
|
2285
|
-
uploadCmd.command("file").description("Upload a file (APP, APK, images, etc.); .app is reported to
|
|
2476
|
+
uploadCmd.command("file").description("Upload a file (APP, APK, images, etc.); .app is reported to HarmonyOS \u5F00\u53D1\u8005\u4E2D\u5FC3 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 HarmonyOS \u5F00\u53D1\u8005\u4E2D\u5FC3").action(async (options) => {
|
|
2286
2477
|
try {
|
|
2287
2478
|
console.error(`Uploading file ${options.filePath}...`);
|
|
2288
2479
|
const releaseType = options.releaseType ? Number(options.releaseType) : void 0;
|
|
@@ -2292,7 +2483,7 @@ uploadCmd.command("file").description("Upload a file (APP, APK, images, etc.); .
|
|
|
2292
2483
|
releaseType,
|
|
2293
2484
|
chineseMainlandFlag: options.chineseMainland ? Number(options.chineseMainland) : void 0
|
|
2294
2485
|
});
|
|
2295
|
-
const ext =
|
|
2486
|
+
const ext = import_path7.default.extname(uploaded.fileName).toLowerCase();
|
|
2296
2487
|
const shouldBind = options.bind !== false && ext === ".app" && releaseType !== 6;
|
|
2297
2488
|
if (!shouldBind) {
|
|
2298
2489
|
console.log(JSON.stringify({
|
|
@@ -2303,7 +2494,7 @@ uploadCmd.command("file").description("Upload a file (APP, APK, images, etc.); .
|
|
|
2303
2494
|
}, null, 2));
|
|
2304
2495
|
return;
|
|
2305
2496
|
}
|
|
2306
|
-
console.error("Reporting package to
|
|
2497
|
+
console.error("Reporting package to HarmonyOS \u5F00\u53D1\u8005\u4E2D\u5FC3...");
|
|
2307
2498
|
const bindRes = await PublishService.updateAppPackageInfo({
|
|
2308
2499
|
appId: options.appId,
|
|
2309
2500
|
fileName: uploaded.fileName,
|
|
@@ -2317,17 +2508,17 @@ uploadCmd.command("file").description("Upload a file (APP, APK, images, etc.); .
|
|
|
2317
2508
|
bound: bindRes.ret?.code === 0
|
|
2318
2509
|
}, null, 2));
|
|
2319
2510
|
if (bindRes.ret?.code !== 0) {
|
|
2320
|
-
|
|
2321
|
-
"Package report failed (file is on OBS but
|
|
2511
|
+
reportFailure(
|
|
2512
|
+
"Package report failed (file is on OBS but HarmonyOS \u5F00\u53D1\u8005\u4E2D\u5FC3 has no record):",
|
|
2322
2513
|
bindRes.ret?.msg || JSON.stringify(bindRes.ret)
|
|
2323
2514
|
);
|
|
2324
2515
|
}
|
|
2325
2516
|
} catch (e) {
|
|
2326
|
-
|
|
2517
|
+
reportFailure("Upload failed:", e.message);
|
|
2327
2518
|
}
|
|
2328
2519
|
});
|
|
2329
2520
|
var provisionCmd = program.command("provision").description("Provisioning API commands");
|
|
2330
|
-
provisionCmd.command("csr-generate").description("Generate a new keypair and CSR file").requiredOption("--alias <alias>", "Key alias").
|
|
2521
|
+
provisionCmd.command("csr-generate").description("Generate a new keypair and CSR file").requiredOption("--alias <alias>", "Key alias").requiredOption("--pwd <pwd>", "Key password entered by the user").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 DEVECO_HOME in .env)").option("--java-path <javaPath>", "Path to java executable (default: java)").action(async (options) => {
|
|
2331
2522
|
try {
|
|
2332
2523
|
const res = await SignService.createSignP12AndCsr({
|
|
2333
2524
|
alias: options.alias,
|
|
@@ -2338,30 +2529,30 @@ provisionCmd.command("csr-generate").description("Generate a new keypair and CSR
|
|
|
2338
2529
|
javaPath: options.javaPath
|
|
2339
2530
|
});
|
|
2340
2531
|
console.error("CSR generation successful.");
|
|
2341
|
-
|
|
2532
|
+
printResult(res);
|
|
2342
2533
|
} catch (e) {
|
|
2343
|
-
|
|
2534
|
+
reportFailure("CSR generation failed:", e.message);
|
|
2344
2535
|
}
|
|
2345
2536
|
});
|
|
2346
2537
|
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) => {
|
|
2347
2538
|
try {
|
|
2348
2539
|
const res = SignService.encryptPassword(options.pwd, options.configDir);
|
|
2349
|
-
|
|
2540
|
+
printResult(res);
|
|
2350
2541
|
} catch (e) {
|
|
2351
|
-
|
|
2542
|
+
reportFailure("\u52A0\u5BC6\u5931\u8D25:", e.message);
|
|
2352
2543
|
}
|
|
2353
2544
|
});
|
|
2354
2545
|
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) => {
|
|
2355
2546
|
try {
|
|
2356
|
-
const csrContent =
|
|
2547
|
+
const csrContent = fs9.readFileSync(options.csr, "utf8");
|
|
2357
2548
|
const res = await ProvisionService.createCert({
|
|
2358
2549
|
csr: csrContent,
|
|
2359
2550
|
certName: options.certName,
|
|
2360
2551
|
certType: Number(options.certType)
|
|
2361
2552
|
});
|
|
2362
|
-
|
|
2553
|
+
printResult(res);
|
|
2363
2554
|
} catch (e) {
|
|
2364
|
-
|
|
2555
|
+
reportFailure("Request failed:", e.message);
|
|
2365
2556
|
}
|
|
2366
2557
|
});
|
|
2367
2558
|
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) => {
|
|
@@ -2370,9 +2561,9 @@ provisionCmd.command("cert-list").description("List certificates").option("-t, -
|
|
|
2370
2561
|
if (options.certType) req.certType = Number(options.certType);
|
|
2371
2562
|
if (options.certIds) req.certIds = options.certIds.split(",");
|
|
2372
2563
|
const res = await ProvisionService.getCertList(req);
|
|
2373
|
-
|
|
2564
|
+
printResult(res);
|
|
2374
2565
|
} catch (e) {
|
|
2375
|
-
|
|
2566
|
+
reportFailure("Request failed:", e.message);
|
|
2376
2567
|
}
|
|
2377
2568
|
});
|
|
2378
2569
|
provisionCmd.command("cert-delete").description("Delete certificates").requiredOption("--cert-ids <certIds>", "Comma separated certificate IDs to delete").action(async (options) => {
|
|
@@ -2380,19 +2571,19 @@ provisionCmd.command("cert-delete").description("Delete certificates").requiredO
|
|
|
2380
2571
|
const res = await ProvisionService.deleteCert({
|
|
2381
2572
|
certIds: options.certIds.split(",")
|
|
2382
2573
|
});
|
|
2383
|
-
|
|
2574
|
+
printResult(res);
|
|
2384
2575
|
} catch (e) {
|
|
2385
|
-
|
|
2576
|
+
reportFailure("Request failed:", e.message);
|
|
2386
2577
|
}
|
|
2387
2578
|
});
|
|
2388
2579
|
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) => {
|
|
2389
2580
|
try {
|
|
2390
|
-
const fileContent =
|
|
2581
|
+
const fileContent = fs9.readFileSync(options.devices, "utf8");
|
|
2391
2582
|
const deviceList = JSON.parse(fileContent);
|
|
2392
2583
|
const res = await ProvisionService.addDevice({ deviceList });
|
|
2393
|
-
|
|
2584
|
+
printResult(res);
|
|
2394
2585
|
} catch (e) {
|
|
2395
|
-
|
|
2586
|
+
reportFailure("Request failed:", e.message);
|
|
2396
2587
|
}
|
|
2397
2588
|
});
|
|
2398
2589
|
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) => {
|
|
@@ -2403,9 +2594,9 @@ provisionCmd.command("device-list").description("List devices").option("--device
|
|
|
2403
2594
|
if (options.max) req.maxReqCount = Number(options.max);
|
|
2404
2595
|
if (options.order) req.order = Number(options.order);
|
|
2405
2596
|
const res = await ProvisionService.getDeviceList(req);
|
|
2406
|
-
|
|
2597
|
+
printResult(res);
|
|
2407
2598
|
} catch (e) {
|
|
2408
|
-
|
|
2599
|
+
reportFailure("Request failed:", e.message);
|
|
2409
2600
|
}
|
|
2410
2601
|
});
|
|
2411
2602
|
provisionCmd.command("device-delete").description("Delete devices").requiredOption("--device-ids <deviceIdList>", "Comma separated device IDs to delete").action(async (options) => {
|
|
@@ -2413,9 +2604,9 @@ provisionCmd.command("device-delete").description("Delete devices").requiredOpti
|
|
|
2413
2604
|
const res = await ProvisionService.deleteDevice({
|
|
2414
2605
|
deviceIdList: options.deviceIds.split(",")
|
|
2415
2606
|
});
|
|
2416
|
-
|
|
2607
|
+
printResult(res);
|
|
2417
2608
|
} catch (e) {
|
|
2418
|
-
|
|
2609
|
+
reportFailure("Request failed:", e.message);
|
|
2419
2610
|
}
|
|
2420
2611
|
});
|
|
2421
2612
|
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) => {
|
|
@@ -2429,9 +2620,9 @@ provisionCmd.command("profile-create").description("Create a profile").requiredO
|
|
|
2429
2620
|
if (options.deviceIds) req.deviceIdList = options.deviceIds.split(",");
|
|
2430
2621
|
if (options.acls) req.aclPermissionList = options.acls.split(",");
|
|
2431
2622
|
const res = await ProvisionService.createProvision(req);
|
|
2432
|
-
|
|
2623
|
+
printResult(res);
|
|
2433
2624
|
} catch (e) {
|
|
2434
|
-
|
|
2625
|
+
reportFailure("Request failed:", e.message);
|
|
2435
2626
|
}
|
|
2436
2627
|
});
|
|
2437
2628
|
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) => {
|
|
@@ -2441,9 +2632,9 @@ provisionCmd.command("profile-list").description("List profiles").requiredOption
|
|
|
2441
2632
|
if (options.from) req.fromRecCount = Number(options.from);
|
|
2442
2633
|
if (options.max) req.maxReqCount = Number(options.max);
|
|
2443
2634
|
const res = await ProvisionService.getProvisionList(req);
|
|
2444
|
-
|
|
2635
|
+
printResult(res);
|
|
2445
2636
|
} catch (e) {
|
|
2446
|
-
|
|
2637
|
+
reportFailure("Request failed:", e.message);
|
|
2447
2638
|
}
|
|
2448
2639
|
});
|
|
2449
2640
|
provisionCmd.command("profile-update").description("Update profile devices").requiredOption("--id <provisionId>", "Profile ID").requiredOption("--device-ids <deviceIdList>", "Comma separated device IDs").action(async (options) => {
|
|
@@ -2452,17 +2643,17 @@ provisionCmd.command("profile-update").description("Update profile devices").req
|
|
|
2452
2643
|
provisionId: options.id,
|
|
2453
2644
|
deviceIdList: options.deviceIds.split(",")
|
|
2454
2645
|
});
|
|
2455
|
-
|
|
2646
|
+
printResult(res);
|
|
2456
2647
|
} catch (e) {
|
|
2457
|
-
|
|
2648
|
+
reportFailure("Request failed:", e.message);
|
|
2458
2649
|
}
|
|
2459
2650
|
});
|
|
2460
2651
|
provisionCmd.command("profile-delete").description("Delete a profile").requiredOption("--id <id>", "Profile ID to delete").action(async (options) => {
|
|
2461
2652
|
try {
|
|
2462
2653
|
const res = await ProvisionService.deleteProvision({ id: options.id });
|
|
2463
|
-
|
|
2654
|
+
printResult(res);
|
|
2464
2655
|
} catch (e) {
|
|
2465
|
-
|
|
2656
|
+
reportFailure("Request failed:", e.message);
|
|
2466
2657
|
}
|
|
2467
2658
|
});
|
|
2468
2659
|
provisionCmd.command("fp-add").description("Add certificate fingerprints").requiredOption("-a, --app-id <appId>", "App ID").requiredOption("--fps <fingerprintList>", "Comma separated fingerprints").action(async (options) => {
|
|
@@ -2471,17 +2662,17 @@ provisionCmd.command("fp-add").description("Add certificate fingerprints").requi
|
|
|
2471
2662
|
appId: options.appId,
|
|
2472
2663
|
fingerprintList: options.fps.split(",")
|
|
2473
2664
|
});
|
|
2474
|
-
|
|
2665
|
+
printResult(res);
|
|
2475
2666
|
} catch (e) {
|
|
2476
|
-
|
|
2667
|
+
reportFailure("Request failed:", e.message);
|
|
2477
2668
|
}
|
|
2478
2669
|
});
|
|
2479
2670
|
provisionCmd.command("fp-list").description("List certificate fingerprints").requiredOption("-a, --app-id <appId>", "App ID").action(async (options) => {
|
|
2480
2671
|
try {
|
|
2481
2672
|
const res = await ProvisionService.getFingerprintList({ appId: options.appId });
|
|
2482
|
-
|
|
2673
|
+
printResult(res);
|
|
2483
2674
|
} catch (e) {
|
|
2484
|
-
|
|
2675
|
+
reportFailure("Request failed:", e.message);
|
|
2485
2676
|
}
|
|
2486
2677
|
});
|
|
2487
2678
|
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) => {
|
|
@@ -2490,9 +2681,9 @@ provisionCmd.command("fp-delete").description("Delete certificate fingerprints")
|
|
|
2490
2681
|
appId: options.appId,
|
|
2491
2682
|
fingerprintList: options.fps.split(",")
|
|
2492
2683
|
});
|
|
2493
|
-
|
|
2684
|
+
printResult(res);
|
|
2494
2685
|
} catch (e) {
|
|
2495
|
-
|
|
2686
|
+
reportFailure("Request failed:", e.message);
|
|
2496
2687
|
}
|
|
2497
2688
|
});
|
|
2498
2689
|
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) => {
|
|
@@ -2503,37 +2694,37 @@ provisionCmd.command("acl-eligible").description("List eligible ACL permissions
|
|
|
2503
2694
|
start: options.start ? Number(options.start) : void 0,
|
|
2504
2695
|
pageSize: options.pageSize ? Number(options.pageSize) : void 0
|
|
2505
2696
|
});
|
|
2506
|
-
|
|
2697
|
+
printResult(res);
|
|
2507
2698
|
} catch (e) {
|
|
2508
|
-
|
|
2699
|
+
reportFailure("Request failed:", e.message);
|
|
2509
2700
|
}
|
|
2510
2701
|
});
|
|
2511
2702
|
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) => {
|
|
2512
2703
|
try {
|
|
2513
|
-
const fileContent =
|
|
2704
|
+
const fileContent = fs9.readFileSync(options.acls, "utf8");
|
|
2514
2705
|
const aclPermissionList = JSON.parse(fileContent);
|
|
2515
2706
|
const req = { appId: options.appId, aclPermissionList };
|
|
2516
2707
|
if (options.attachment) req.attachment = options.attachment;
|
|
2517
2708
|
const res = await ProvisionService.applyACL(req);
|
|
2518
|
-
|
|
2709
|
+
printResult(res);
|
|
2519
2710
|
} catch (e) {
|
|
2520
|
-
|
|
2711
|
+
reportFailure("Request failed:", e.message);
|
|
2521
2712
|
}
|
|
2522
2713
|
});
|
|
2523
2714
|
provisionCmd.command("acl-status").description("Check ACL permission apply status").requiredOption("-a, --app-id <appId>", "App ID").action(async (options) => {
|
|
2524
2715
|
try {
|
|
2525
2716
|
const res = await ProvisionService.getACLStatus({ appId: options.appId });
|
|
2526
|
-
|
|
2717
|
+
printResult(res);
|
|
2527
2718
|
} catch (e) {
|
|
2528
|
-
|
|
2719
|
+
reportFailure("Request failed:", e.message);
|
|
2529
2720
|
}
|
|
2530
2721
|
});
|
|
2531
2722
|
provisionCmd.command("acl-query").description("Query granted ACL permissions").requiredOption("-a, --app-id <appId>", "App ID").action(async (options) => {
|
|
2532
2723
|
try {
|
|
2533
2724
|
const res = await ProvisionService.getACLQuery({ appId: options.appId });
|
|
2534
|
-
|
|
2725
|
+
printResult(res);
|
|
2535
2726
|
} catch (e) {
|
|
2536
|
-
|
|
2727
|
+
reportFailure("Request failed:", e.message);
|
|
2537
2728
|
}
|
|
2538
2729
|
});
|
|
2539
2730
|
var domainCmd = program.command("domain").description("Domain Management API commands");
|
|
@@ -2543,23 +2734,23 @@ domainCmd.command("query").description("Query domain configuration").requiredOpt
|
|
|
2543
2734
|
appId: options.appId,
|
|
2544
2735
|
category: options.category
|
|
2545
2736
|
});
|
|
2546
|
-
|
|
2737
|
+
printResult(res);
|
|
2547
2738
|
} catch (e) {
|
|
2548
|
-
|
|
2739
|
+
reportFailure("Request failed:", e.message);
|
|
2549
2740
|
}
|
|
2550
2741
|
});
|
|
2551
2742
|
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) => {
|
|
2552
2743
|
try {
|
|
2553
|
-
const fileContent =
|
|
2744
|
+
const fileContent = fs9.readFileSync(options.domains, "utf8");
|
|
2554
2745
|
const domains = JSON.parse(fileContent);
|
|
2555
2746
|
const res = await DomainService.updateDomain({
|
|
2556
2747
|
appId: options.appId,
|
|
2557
2748
|
category: options.category,
|
|
2558
2749
|
domains
|
|
2559
2750
|
});
|
|
2560
|
-
|
|
2751
|
+
printResult(res);
|
|
2561
2752
|
} catch (e) {
|
|
2562
|
-
|
|
2753
|
+
reportFailure("Request failed:", e.message);
|
|
2563
2754
|
}
|
|
2564
2755
|
});
|
|
2565
2756
|
domainCmd.command("config").description("Query domain modification counts and limits").requiredOption("-a, --app-id <appId>", "App ID").action(async (options) => {
|
|
@@ -2567,9 +2758,9 @@ domainCmd.command("config").description("Query domain modification counts and li
|
|
|
2567
2758
|
const res = await DomainService.queryDomainConfig({
|
|
2568
2759
|
appId: options.appId
|
|
2569
2760
|
});
|
|
2570
|
-
|
|
2761
|
+
printResult(res);
|
|
2571
2762
|
} catch (e) {
|
|
2572
|
-
|
|
2763
|
+
reportFailure("Request failed:", e.message);
|
|
2573
2764
|
}
|
|
2574
2765
|
});
|
|
2575
2766
|
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) => {
|
|
@@ -2580,20 +2771,20 @@ domainCmd.command("verify-file").description("Download domain verify file").requ
|
|
|
2580
2771
|
}, options.output);
|
|
2581
2772
|
console.log("Download successful.");
|
|
2582
2773
|
} catch (e) {
|
|
2583
|
-
|
|
2774
|
+
reportFailure("Download failed:", e.message);
|
|
2584
2775
|
}
|
|
2585
2776
|
});
|
|
2586
2777
|
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) => {
|
|
2587
2778
|
try {
|
|
2588
|
-
const fileContent =
|
|
2779
|
+
const fileContent = fs9.readFileSync(options.domain, "utf8");
|
|
2589
2780
|
const domain = JSON.parse(fileContent);
|
|
2590
2781
|
const res = await DomainService.preCheckDomain({
|
|
2591
2782
|
appId: options.appId,
|
|
2592
2783
|
domain
|
|
2593
2784
|
});
|
|
2594
|
-
|
|
2785
|
+
printResult(res);
|
|
2595
2786
|
} catch (e) {
|
|
2596
|
-
|
|
2787
|
+
reportFailure("Request failed:", e.message);
|
|
2597
2788
|
}
|
|
2598
2789
|
});
|
|
2599
2790
|
var testCmd = program.command("test").description("Testing API commands (invite/open test versions, groups, invite codes)");
|
|
@@ -2606,9 +2797,9 @@ testCmd.command("version-create").description("Create a test version").requiredO
|
|
|
2606
2797
|
releaseType: options.releaseType ? Number(options.releaseType) : void 0,
|
|
2607
2798
|
onshelfSelfDetect: options.onshelfSelfDetect !== void 0 ? Number(options.onshelfSelfDetect) : void 0
|
|
2608
2799
|
});
|
|
2609
|
-
|
|
2800
|
+
printResult(res);
|
|
2610
2801
|
} catch (e) {
|
|
2611
|
-
|
|
2802
|
+
reportFailure("Request failed:", e.message);
|
|
2612
2803
|
}
|
|
2613
2804
|
});
|
|
2614
2805
|
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) => {
|
|
@@ -2617,9 +2808,9 @@ testCmd.command("version-detect").description("Query onshelf self-detect report"
|
|
|
2617
2808
|
appId: options.appId,
|
|
2618
2809
|
versionId: options.versionId
|
|
2619
2810
|
});
|
|
2620
|
-
|
|
2811
|
+
printResult(res);
|
|
2621
2812
|
} catch (e) {
|
|
2622
|
-
|
|
2813
|
+
reportFailure("Request failed:", e.message);
|
|
2623
2814
|
}
|
|
2624
2815
|
});
|
|
2625
2816
|
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) => {
|
|
@@ -2629,36 +2820,36 @@ testCmd.command("pkg-add").description("Add package to a test version (objectId
|
|
|
2629
2820
|
distributeMode: options.distributeMode ? Number(options.distributeMode) : void 0,
|
|
2630
2821
|
file: { fileName: options.fileName, objectId: options.objectId }
|
|
2631
2822
|
});
|
|
2632
|
-
|
|
2823
|
+
printResult(res);
|
|
2633
2824
|
} catch (e) {
|
|
2634
|
-
|
|
2825
|
+
reportFailure("Request failed:", e.message);
|
|
2635
2826
|
}
|
|
2636
2827
|
});
|
|
2637
2828
|
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) => {
|
|
2638
2829
|
try {
|
|
2639
2830
|
const body = readJsonFile(options.body);
|
|
2640
2831
|
const res = await TestingService.updateVersion({ appId: options.appId, ...body });
|
|
2641
|
-
|
|
2832
|
+
printResult(res);
|
|
2642
2833
|
} catch (e) {
|
|
2643
|
-
|
|
2834
|
+
reportFailure("Request failed:", e.message);
|
|
2644
2835
|
}
|
|
2645
2836
|
});
|
|
2646
2837
|
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) => {
|
|
2647
2838
|
try {
|
|
2648
2839
|
const body = readJsonFile(options.body);
|
|
2649
2840
|
const res = await TestingService.releaseVersion({ appId: options.appId, ...body });
|
|
2650
|
-
|
|
2841
|
+
printResult(res);
|
|
2651
2842
|
} catch (e) {
|
|
2652
|
-
|
|
2843
|
+
reportFailure("Request failed:", e.message);
|
|
2653
2844
|
}
|
|
2654
2845
|
});
|
|
2655
2846
|
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) => {
|
|
2656
2847
|
try {
|
|
2657
2848
|
const body = readJsonFile(options.body);
|
|
2658
2849
|
const res = await TestingService.updateOpenTest({ appId: options.appId, ...body });
|
|
2659
|
-
|
|
2850
|
+
printResult(res);
|
|
2660
2851
|
} catch (e) {
|
|
2661
|
-
|
|
2852
|
+
reportFailure("Request failed:", e.message);
|
|
2662
2853
|
}
|
|
2663
2854
|
});
|
|
2664
2855
|
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) => {
|
|
@@ -2667,9 +2858,9 @@ testCmd.command("version-submit").description("Submit a test version for review"
|
|
|
2667
2858
|
appId: options.appId,
|
|
2668
2859
|
versionId: options.versionId
|
|
2669
2860
|
});
|
|
2670
|
-
|
|
2861
|
+
printResult(res);
|
|
2671
2862
|
} catch (e) {
|
|
2672
|
-
|
|
2863
|
+
reportFailure("Request failed:", e.message);
|
|
2673
2864
|
}
|
|
2674
2865
|
});
|
|
2675
2866
|
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) => {
|
|
@@ -2678,9 +2869,9 @@ testCmd.command("version-stop").description("Stop a test version").requiredOptio
|
|
|
2678
2869
|
appId: options.appId,
|
|
2679
2870
|
versionId: options.versionId
|
|
2680
2871
|
});
|
|
2681
|
-
|
|
2872
|
+
printResult(res);
|
|
2682
2873
|
} catch (e) {
|
|
2683
|
-
|
|
2874
|
+
reportFailure("Request failed:", e.message);
|
|
2684
2875
|
}
|
|
2685
2876
|
});
|
|
2686
2877
|
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) => {
|
|
@@ -2689,9 +2880,9 @@ testCmd.command("version-delete").description("Delete a test version").requiredO
|
|
|
2689
2880
|
appId: options.appId,
|
|
2690
2881
|
versionId: options.versionId
|
|
2691
2882
|
});
|
|
2692
|
-
|
|
2883
|
+
printResult(res);
|
|
2693
2884
|
} catch (e) {
|
|
2694
|
-
|
|
2885
|
+
reportFailure("Request failed:", e.message);
|
|
2695
2886
|
}
|
|
2696
2887
|
});
|
|
2697
2888
|
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) => {
|
|
@@ -2701,9 +2892,9 @@ testCmd.command("group-add").description("Create a test group").requiredOption("
|
|
|
2701
2892
|
groupName: options.name,
|
|
2702
2893
|
groupType: options.type !== void 0 ? Number(options.type) : void 0
|
|
2703
2894
|
});
|
|
2704
|
-
|
|
2895
|
+
printResult(res);
|
|
2705
2896
|
} catch (e) {
|
|
2706
|
-
|
|
2897
|
+
reportFailure("Request failed:", e.message);
|
|
2707
2898
|
}
|
|
2708
2899
|
});
|
|
2709
2900
|
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) => {
|
|
@@ -2714,9 +2905,9 @@ testCmd.command("group-list").description("List test groups").requiredOption("-a
|
|
|
2714
2905
|
current: options.current ? Number(options.current) : void 0,
|
|
2715
2906
|
pageSize: options.pageSize ? Number(options.pageSize) : void 0
|
|
2716
2907
|
});
|
|
2717
|
-
|
|
2908
|
+
printResult(res);
|
|
2718
2909
|
} catch (e) {
|
|
2719
|
-
|
|
2910
|
+
reportFailure("Request failed:", e.message);
|
|
2720
2911
|
}
|
|
2721
2912
|
});
|
|
2722
2913
|
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) => {
|
|
@@ -2725,9 +2916,9 @@ testCmd.command("group-delete").description("Delete a test group").requiredOptio
|
|
|
2725
2916
|
appId: options.appId,
|
|
2726
2917
|
groupId: options.groupId
|
|
2727
2918
|
});
|
|
2728
|
-
|
|
2919
|
+
printResult(res);
|
|
2729
2920
|
} catch (e) {
|
|
2730
|
-
|
|
2921
|
+
reportFailure("Request failed:", e.message);
|
|
2731
2922
|
}
|
|
2732
2923
|
});
|
|
2733
2924
|
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) => {
|
|
@@ -2737,9 +2928,9 @@ testCmd.command("group-edit").description("Rename a test group").requiredOption(
|
|
|
2737
2928
|
groupId: options.groupId,
|
|
2738
2929
|
groupName: options.name
|
|
2739
2930
|
});
|
|
2740
|
-
|
|
2931
|
+
printResult(res);
|
|
2741
2932
|
} catch (e) {
|
|
2742
|
-
|
|
2933
|
+
reportFailure("Request failed:", e.message);
|
|
2743
2934
|
}
|
|
2744
2935
|
});
|
|
2745
2936
|
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) => {
|
|
@@ -2750,18 +2941,18 @@ testCmd.command("group-user-list").description("List members of a test group").r
|
|
|
2750
2941
|
current: options.current ? Number(options.current) : void 0,
|
|
2751
2942
|
pageSize: options.pageSize ? Number(options.pageSize) : void 0
|
|
2752
2943
|
});
|
|
2753
|
-
|
|
2944
|
+
printResult(res);
|
|
2754
2945
|
} catch (e) {
|
|
2755
|
-
|
|
2946
|
+
reportFailure("Request failed:", e.message);
|
|
2756
2947
|
}
|
|
2757
2948
|
});
|
|
2758
2949
|
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) => {
|
|
2759
2950
|
try {
|
|
2760
2951
|
const body = readJsonFile(options.body);
|
|
2761
2952
|
const res = await TestingService.addGroupUser({ appId: options.appId, ...body });
|
|
2762
|
-
|
|
2953
|
+
printResult(res);
|
|
2763
2954
|
} catch (e) {
|
|
2764
|
-
|
|
2955
|
+
reportFailure("Request failed:", e.message);
|
|
2765
2956
|
}
|
|
2766
2957
|
});
|
|
2767
2958
|
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) => {
|
|
@@ -2771,9 +2962,9 @@ testCmd.command("group-user-delete").description("Delete members from a test gro
|
|
|
2771
2962
|
groupId: options.groupId,
|
|
2772
2963
|
deleteTesterIds: options.testerIds.split(",")
|
|
2773
2964
|
});
|
|
2774
|
-
|
|
2965
|
+
printResult(res);
|
|
2775
2966
|
} catch (e) {
|
|
2776
|
-
|
|
2967
|
+
reportFailure("Request failed:", e.message);
|
|
2777
2968
|
}
|
|
2778
2969
|
});
|
|
2779
2970
|
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) => {
|
|
@@ -2783,9 +2974,9 @@ testCmd.command("group-notify").description("Send invite-test notification to gr
|
|
|
2783
2974
|
groupId: options.groupId,
|
|
2784
2975
|
testerIds: options.testerIds.split(",")
|
|
2785
2976
|
});
|
|
2786
|
-
|
|
2977
|
+
printResult(res);
|
|
2787
2978
|
} catch (e) {
|
|
2788
|
-
|
|
2979
|
+
reportFailure("Request failed:", e.message);
|
|
2789
2980
|
}
|
|
2790
2981
|
});
|
|
2791
2982
|
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) => {
|
|
@@ -2796,9 +2987,9 @@ testCmd.command("invite-code-create").description("Generate an invitation code f
|
|
|
2796
2987
|
invitationCodeValidDays: Number(options.validDays),
|
|
2797
2988
|
invitationCodeInviteLimit: Number(options.inviteLimit)
|
|
2798
2989
|
});
|
|
2799
|
-
|
|
2990
|
+
printResult(res);
|
|
2800
2991
|
} catch (e) {
|
|
2801
|
-
|
|
2992
|
+
reportFailure("Request failed:", e.message);
|
|
2802
2993
|
}
|
|
2803
2994
|
});
|
|
2804
2995
|
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) => {
|
|
@@ -2807,9 +2998,9 @@ testCmd.command("invite-code-list").description("Query invitation codes of a gro
|
|
|
2807
2998
|
appId: options.appId,
|
|
2808
2999
|
groupId: options.groupId
|
|
2809
3000
|
});
|
|
2810
|
-
|
|
3001
|
+
printResult(res);
|
|
2811
3002
|
} catch (e) {
|
|
2812
|
-
|
|
3003
|
+
reportFailure("Request failed:", e.message);
|
|
2813
3004
|
}
|
|
2814
3005
|
});
|
|
2815
3006
|
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) => {
|
|
@@ -2818,9 +3009,9 @@ testCmd.command("invite-code-stop").description("Stop an invitation code").requi
|
|
|
2818
3009
|
appId: options.appId,
|
|
2819
3010
|
invitationCodeId: options.codeId
|
|
2820
3011
|
});
|
|
2821
|
-
|
|
3012
|
+
printResult(res);
|
|
2822
3013
|
} catch (e) {
|
|
2823
|
-
|
|
3014
|
+
reportFailure("Request failed:", e.message);
|
|
2824
3015
|
}
|
|
2825
3016
|
});
|
|
2826
3017
|
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) => {
|
|
@@ -2829,9 +3020,9 @@ testCmd.command("invite-code-delete").description("Delete an invitation code").r
|
|
|
2829
3020
|
appId: options.appId,
|
|
2830
3021
|
invitationCodeId: options.codeId
|
|
2831
3022
|
});
|
|
2832
|
-
|
|
3023
|
+
printResult(res);
|
|
2833
3024
|
} catch (e) {
|
|
2834
|
-
|
|
3025
|
+
reportFailure("Request failed:", e.message);
|
|
2835
3026
|
}
|
|
2836
3027
|
});
|
|
2837
3028
|
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) => {
|
|
@@ -2841,9 +3032,9 @@ testCmd.command("public-link-create").description("Create a public test link for
|
|
|
2841
3032
|
groupId: options.groupId,
|
|
2842
3033
|
limit: Number(options.limit)
|
|
2843
3034
|
});
|
|
2844
|
-
|
|
3035
|
+
printResult(res);
|
|
2845
3036
|
} catch (e) {
|
|
2846
|
-
|
|
3037
|
+
reportFailure("Request failed:", e.message);
|
|
2847
3038
|
}
|
|
2848
3039
|
});
|
|
2849
3040
|
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) => {
|
|
@@ -2854,9 +3045,9 @@ testCmd.command("public-link-edit").description("Edit a public test link").requi
|
|
|
2854
3045
|
limit: options.limit !== void 0 ? Number(options.limit) : void 0,
|
|
2855
3046
|
status: options.status !== void 0 ? Number(options.status) : void 0
|
|
2856
3047
|
});
|
|
2857
|
-
|
|
3048
|
+
printResult(res);
|
|
2858
3049
|
} catch (e) {
|
|
2859
|
-
|
|
3050
|
+
reportFailure("Request failed:", e.message);
|
|
2860
3051
|
}
|
|
2861
3052
|
});
|
|
2862
3053
|
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) => {
|
|
@@ -2865,37 +3056,38 @@ testCmd.command("public-link-query").description("Query a public test link").req
|
|
|
2865
3056
|
appId: options.appId,
|
|
2866
3057
|
groupId: options.groupId
|
|
2867
3058
|
});
|
|
2868
|
-
|
|
3059
|
+
printResult(res);
|
|
2869
3060
|
} catch (e) {
|
|
2870
|
-
|
|
3061
|
+
reportFailure("Request failed:", e.message);
|
|
2871
3062
|
}
|
|
2872
3063
|
});
|
|
2873
3064
|
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) => {
|
|
2874
3065
|
try {
|
|
2875
3066
|
const body = readJsonFile(options.body);
|
|
2876
3067
|
const res = await TestingService.queryFeedbackDimension({ appId: options.appId, ...body });
|
|
2877
|
-
|
|
3068
|
+
printResult(res);
|
|
2878
3069
|
} catch (e) {
|
|
2879
|
-
|
|
3070
|
+
reportFailure("Request failed:", e.message);
|
|
2880
3071
|
}
|
|
2881
3072
|
});
|
|
2882
3073
|
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) => {
|
|
2883
3074
|
try {
|
|
2884
3075
|
const body = readJsonFile(options.body);
|
|
2885
3076
|
const res = await TestingService.queryFeedback({ appId: options.appId, ...body });
|
|
2886
|
-
|
|
3077
|
+
printResult(res);
|
|
2887
3078
|
} catch (e) {
|
|
2888
|
-
|
|
3079
|
+
reportFailure("Request failed:", e.message);
|
|
2889
3080
|
}
|
|
2890
3081
|
});
|
|
2891
3082
|
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) => {
|
|
2892
3083
|
try {
|
|
2893
3084
|
const body = readJsonFile(options.body);
|
|
2894
3085
|
const res = await TestingService.deleteFeedback({ appId: options.appId, ...body });
|
|
2895
|
-
|
|
3086
|
+
printResult(res);
|
|
2896
3087
|
} catch (e) {
|
|
2897
|
-
|
|
3088
|
+
reportFailure("Request failed:", e.message);
|
|
2898
3089
|
}
|
|
2899
3090
|
});
|
|
2900
|
-
program.
|
|
2901
|
-
|
|
3091
|
+
program.parseAsync(process.argv).catch((error) => {
|
|
3092
|
+
reportFailure(error instanceof Error ? error.message : String(error));
|
|
3093
|
+
});
|