@gpc-cli/cli 0.9.5 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +126 -6
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-BXJ75Q7M.js → chunk-LQ7FJ4QA.js} +46 -13
- package/dist/chunk-LQ7FJ4QA.js.map +1 -0
- package/dist/completion-3UYUJD6S.js +495 -0
- package/dist/completion-3UYUJD6S.js.map +1 -0
- package/dist/data-safety-M2SFKQ3U.js +91 -0
- package/dist/data-safety-M2SFKQ3U.js.map +1 -0
- package/dist/external-transactions-YRK5CI2D.js +131 -0
- package/dist/external-transactions-YRK5CI2D.js.map +1 -0
- package/dist/{iap-W4UDJMGY.js → iap-ZZS5NVFN.js} +7 -3
- package/dist/iap-ZZS5NVFN.js.map +1 -0
- package/dist/index.d.ts +14 -1
- package/dist/index.js +5 -3
- package/dist/{listings-42GCDAJU.js → listings-FYNMWTIE.js} +31 -1
- package/dist/listings-FYNMWTIE.js.map +1 -0
- package/dist/{publish-LYU35P5S.js → publish-YP7U64T2.js} +38 -29
- package/dist/publish-YP7U64T2.js.map +1 -0
- package/dist/recovery-ZANX3WIQ.js +118 -0
- package/dist/recovery-ZANX3WIQ.js.map +1 -0
- package/dist/{releases-CDWBN25U.js → releases-GUMQZRFC.js} +26 -19
- package/dist/releases-GUMQZRFC.js.map +1 -0
- package/dist/{reviews-SBR5FGEF.js → reviews-G3HZG3AS.js} +6 -4
- package/dist/reviews-G3HZG3AS.js.map +1 -0
- package/dist/{subscriptions-GSXDPXA4.js → subscriptions-CHQU5VXT.js} +7 -3
- package/dist/subscriptions-CHQU5VXT.js.map +1 -0
- package/dist/{testers-GSONKJAW.js → testers-SB77565D.js} +8 -2
- package/dist/testers-SB77565D.js.map +1 -0
- package/dist/{users-L57T4MCQ.js → users-N2TK6KI7.js} +7 -3
- package/dist/users-N2TK6KI7.js.map +1 -0
- package/package.json +6 -6
- package/dist/chunk-BXJ75Q7M.js.map +0 -1
- package/dist/completion-IHVLP7OK.js +0 -145
- package/dist/completion-IHVLP7OK.js.map +0 -1
- package/dist/iap-W4UDJMGY.js.map +0 -1
- package/dist/listings-42GCDAJU.js.map +0 -1
- package/dist/publish-LYU35P5S.js.map +0 -1
- package/dist/releases-CDWBN25U.js.map +0 -1
- package/dist/reviews-SBR5FGEF.js.map +0 -1
- package/dist/subscriptions-GSXDPXA4.js.map +0 -1
- package/dist/testers-GSONKJAW.js.map +0 -1
- package/dist/users-L57T4MCQ.js.map +0 -1
package/dist/bin.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
createProgram,
|
|
4
|
+
handleCliError,
|
|
4
5
|
loadPlugins
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LQ7FJ4QA.js";
|
|
6
7
|
|
|
7
8
|
// src/networking.ts
|
|
8
9
|
async function setupNetworking() {
|
|
@@ -23,14 +24,133 @@ async function setupNetworking() {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
// src/bin.ts
|
|
26
|
-
import { initAudit } from "@gpc-cli/core";
|
|
27
|
-
import { getConfigDir } from "@gpc-cli/config";
|
|
27
|
+
import { initAudit, sendWebhook } from "@gpc-cli/core";
|
|
28
|
+
import { getConfigDir, loadConfig } from "@gpc-cli/config";
|
|
29
|
+
|
|
30
|
+
// src/update-check.ts
|
|
31
|
+
import { join } from "path";
|
|
32
|
+
import { readFile, writeFile, mkdir } from "fs/promises";
|
|
33
|
+
import { getCacheDir } from "@gpc-cli/config";
|
|
34
|
+
var CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
35
|
+
var FETCH_TIMEOUT_MS = 3e3;
|
|
36
|
+
var REGISTRY_URL = "https://registry.npmjs.org/@gpc-cli/cli/latest";
|
|
37
|
+
function getCacheFilePath() {
|
|
38
|
+
return join(getCacheDir(), "update-check.json");
|
|
39
|
+
}
|
|
40
|
+
function isNewerVersion(current, latest) {
|
|
41
|
+
const a = current.split(".").map(Number);
|
|
42
|
+
const b = latest.split(".").map(Number);
|
|
43
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
44
|
+
const av = a[i] ?? 0;
|
|
45
|
+
const bv = b[i] ?? 0;
|
|
46
|
+
if (bv > av) return true;
|
|
47
|
+
if (bv < av) return false;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
async function readCache() {
|
|
52
|
+
try {
|
|
53
|
+
const raw = await readFile(getCacheFilePath(), "utf-8");
|
|
54
|
+
const data = JSON.parse(raw);
|
|
55
|
+
if (typeof data.latest === "string" && typeof data.checkedAt === "number") {
|
|
56
|
+
return data;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
} catch {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function writeCache(data) {
|
|
64
|
+
const filePath = getCacheFilePath();
|
|
65
|
+
const dir = join(filePath, "..");
|
|
66
|
+
mkdir(dir, { recursive: true }).then(() => writeFile(filePath, JSON.stringify(data), "utf-8")).catch(() => {
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
async function fetchLatestVersion() {
|
|
70
|
+
try {
|
|
71
|
+
const controller = new AbortController();
|
|
72
|
+
const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
73
|
+
const response = await fetch(REGISTRY_URL, { signal: controller.signal });
|
|
74
|
+
clearTimeout(timeout);
|
|
75
|
+
if (!response.ok) return null;
|
|
76
|
+
const body = await response.json();
|
|
77
|
+
if (typeof body.version !== "string") return null;
|
|
78
|
+
return body.version;
|
|
79
|
+
} catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async function checkForUpdate(currentVersion2) {
|
|
84
|
+
if (process.env["GPC_NO_UPDATE_CHECK"] === "1") return null;
|
|
85
|
+
if (process.env["CI"]) return null;
|
|
86
|
+
if (!process.stdout.isTTY) return null;
|
|
87
|
+
const cache = await readCache();
|
|
88
|
+
if (cache && Date.now() - cache.checkedAt < CACHE_TTL_MS) {
|
|
89
|
+
return {
|
|
90
|
+
current: currentVersion2,
|
|
91
|
+
latest: cache.latest,
|
|
92
|
+
updateAvailable: isNewerVersion(currentVersion2, cache.latest)
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const latest = await fetchLatestVersion();
|
|
96
|
+
if (!latest) return null;
|
|
97
|
+
writeCache({ latest, checkedAt: Date.now() });
|
|
98
|
+
return {
|
|
99
|
+
current: currentVersion2,
|
|
100
|
+
latest,
|
|
101
|
+
updateAvailable: isNewerVersion(currentVersion2, latest)
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function formatUpdateNotification(result) {
|
|
105
|
+
return `Update available: ${result.current} \u2192 ${result.latest} \u2014 npm install -g @gpc-cli/cli`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// src/bin.ts
|
|
28
109
|
await setupNetworking();
|
|
29
110
|
initAudit(getConfigDir());
|
|
111
|
+
var currentVersion = process.env["__GPC_VERSION"] || "0.0.0";
|
|
112
|
+
var updateCheckPromise = checkForUpdate(currentVersion);
|
|
30
113
|
var pluginManager = await loadPlugins();
|
|
31
114
|
var program = await createProgram(pluginManager);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
115
|
+
var startTime = Date.now();
|
|
116
|
+
var commandSuccess = true;
|
|
117
|
+
var commandError;
|
|
118
|
+
await program.parseAsync(process.argv).catch((error) => {
|
|
119
|
+
commandSuccess = false;
|
|
120
|
+
commandError = error instanceof Error ? error.message : String(error);
|
|
121
|
+
const exitCode = handleCliError(error);
|
|
122
|
+
process.exit(exitCode);
|
|
35
123
|
});
|
|
124
|
+
var notifyOpt = program.opts()["notify"];
|
|
125
|
+
if (notifyOpt !== void 0 && notifyOpt !== false) {
|
|
126
|
+
try {
|
|
127
|
+
const config = await loadConfig();
|
|
128
|
+
if (config.webhooks) {
|
|
129
|
+
const commandName = process.argv.slice(2).filter((a) => !a.startsWith("--notify")).join(" ");
|
|
130
|
+
const payload = {
|
|
131
|
+
command: commandName || "unknown",
|
|
132
|
+
success: commandSuccess,
|
|
133
|
+
duration: Date.now() - startTime,
|
|
134
|
+
app: program.opts()["app"],
|
|
135
|
+
error: commandError
|
|
136
|
+
};
|
|
137
|
+
const target = typeof notifyOpt === "string" ? notifyOpt : void 0;
|
|
138
|
+
sendWebhook(config.webhooks, payload, target).catch(() => {
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
} catch {
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
const result = await Promise.race([
|
|
146
|
+
updateCheckPromise,
|
|
147
|
+
new Promise((resolve) => setTimeout(() => resolve(null), 3e3))
|
|
148
|
+
]);
|
|
149
|
+
if (result && result.updateAvailable && process.stdout.isTTY && !process.argv.includes("--json") && program.opts()["output"] !== "json") {
|
|
150
|
+
process.stderr.write(`
|
|
151
|
+
${formatUpdateNotification(result)}
|
|
152
|
+
`);
|
|
153
|
+
}
|
|
154
|
+
} catch {
|
|
155
|
+
}
|
|
36
156
|
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/networking.ts","../src/bin.ts"],"sourcesContent":["/**\n * Set up proxy and custom CA certificate support.\n * Must be called before any fetch() calls.\n */\nexport async function setupNetworking(): Promise<void> {\n // Map GPC_CA_CERT to NODE_EXTRA_CA_CERTS (works in both Node and Bun)\n const caCert = process.env[\"GPC_CA_CERT\"];\n if (caCert && !process.env[\"NODE_EXTRA_CA_CERTS\"]) {\n process.env[\"NODE_EXTRA_CA_CERTS\"] = caCert;\n }\n\n // In standalone binary mode, Bun handles HTTPS_PROXY/HTTP_PROXY natively\n if (process.env[\"__GPC_BINARY\"] === \"1\") return;\n\n const proxyUrl =\n process.env[\"HTTPS_PROXY\"] ||\n process.env[\"https_proxy\"] ||\n process.env[\"HTTP_PROXY\"] ||\n process.env[\"http_proxy\"];\n if (proxyUrl) {\n try {\n // @ts-expect-error undici types not available in all environments\n const { ProxyAgent, setGlobalDispatcher } = await import(\"undici\");\n setGlobalDispatcher(new ProxyAgent(proxyUrl));\n } catch {\n console.error(\"Warning: Proxy support requires Node.js 20+. HTTPS_PROXY will be ignored.\");\n }\n }\n}\n","import { setupNetworking } from \"./networking.js\";\nimport { createProgram } from \"./program.js\";\nimport { loadPlugins } from \"./plugins.js\";\nimport { initAudit } from \"@gpc-cli/core\";\nimport { getConfigDir } from \"@gpc-cli/config\";\n\nawait setupNetworking();\ninitAudit(getConfigDir());\nconst pluginManager = await loadPlugins();\nconst program = await createProgram(pluginManager);\nprogram.parseAsync(process.argv).catch((error: unknown) => {\n console.error(error instanceof Error ? error.message : String(error));\n process.exit(1);\n});\n"],"mappings":";;;;;;;AAIA,eAAsB,kBAAiC;AAErD,QAAM,SAAS,QAAQ,IAAI,aAAa;AACxC,MAAI,UAAU,CAAC,QAAQ,IAAI,qBAAqB,GAAG;AACjD,YAAQ,IAAI,qBAAqB,IAAI;AAAA,EACvC;AAGA,MAAI,QAAQ,IAAI,cAAc,MAAM,IAAK;AAEzC,QAAM,WACJ,QAAQ,IAAI,aAAa,KACzB,QAAQ,IAAI,aAAa,KACzB,QAAQ,IAAI,YAAY,KACxB,QAAQ,IAAI,YAAY;AAC1B,MAAI,UAAU;AACZ,QAAI;AAEF,YAAM,EAAE,YAAY,oBAAoB,IAAI,MAAM,OAAO,QAAQ;AACjE,0BAAoB,IAAI,WAAW,QAAQ,CAAC;AAAA,IAC9C,QAAQ;AACN,cAAQ,MAAM,2EAA2E;AAAA,IAC3F;AAAA,EACF;AACF;;;ACzBA,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAE7B,MAAM,gBAAgB;AACtB,UAAU,aAAa,CAAC;AACxB,IAAM,gBAAgB,MAAM,YAAY;AACxC,IAAM,UAAU,MAAM,cAAc,aAAa;AACjD,QAAQ,WAAW,QAAQ,IAAI,EAAE,MAAM,CAAC,UAAmB;AACzD,UAAQ,MAAM,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AACpE,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/networking.ts","../src/bin.ts","../src/update-check.ts"],"sourcesContent":["/**\n * Set up proxy and custom CA certificate support.\n * Must be called before any fetch() calls.\n */\nexport async function setupNetworking(): Promise<void> {\n // Map GPC_CA_CERT to NODE_EXTRA_CA_CERTS (works in both Node and Bun)\n const caCert = process.env[\"GPC_CA_CERT\"];\n if (caCert && !process.env[\"NODE_EXTRA_CA_CERTS\"]) {\n process.env[\"NODE_EXTRA_CA_CERTS\"] = caCert;\n }\n\n // In standalone binary mode, Bun handles HTTPS_PROXY/HTTP_PROXY natively\n if (process.env[\"__GPC_BINARY\"] === \"1\") return;\n\n const proxyUrl =\n process.env[\"HTTPS_PROXY\"] ||\n process.env[\"https_proxy\"] ||\n process.env[\"HTTP_PROXY\"] ||\n process.env[\"http_proxy\"];\n if (proxyUrl) {\n try {\n // @ts-expect-error undici types not available in all environments\n const { ProxyAgent, setGlobalDispatcher } = await import(\"undici\");\n setGlobalDispatcher(new ProxyAgent(proxyUrl));\n } catch {\n console.error(\"Warning: Proxy support requires Node.js 20+. HTTPS_PROXY will be ignored.\");\n }\n }\n}\n","import { setupNetworking } from \"./networking.js\";\nimport { createProgram } from \"./program.js\";\nimport { loadPlugins } from \"./plugins.js\";\nimport { handleCliError } from \"./error-handler.js\";\nimport { initAudit, sendWebhook } from \"@gpc-cli/core\";\nimport type { WebhookPayload } from \"@gpc-cli/core\";\nimport { getConfigDir, loadConfig } from \"@gpc-cli/config\";\nimport { checkForUpdate, formatUpdateNotification } from \"./update-check.js\";\n\nawait setupNetworking();\ninitAudit(getConfigDir());\n\nconst currentVersion = process.env[\"__GPC_VERSION\"] || \"0.0.0\";\n\n// Start update check before command execution (non-blocking)\nconst updateCheckPromise = checkForUpdate(currentVersion);\n\nconst pluginManager = await loadPlugins();\nconst program = await createProgram(pluginManager);\n\nconst startTime = Date.now();\nlet commandSuccess = true;\nlet commandError: string | undefined;\n\nawait program.parseAsync(process.argv).catch((error: unknown) => {\n commandSuccess = false;\n commandError = error instanceof Error ? error.message : String(error);\n const exitCode = handleCliError(error);\n process.exit(exitCode);\n});\n\n// Send webhook notification if --notify was set\nconst notifyOpt = program.opts()[\"notify\"] as string | boolean | undefined;\nif (notifyOpt !== undefined && notifyOpt !== false) {\n try {\n const config = await loadConfig();\n if (config.webhooks) {\n const commandName = process.argv.slice(2).filter((a) => !a.startsWith(\"--notify\")).join(\" \");\n const payload: WebhookPayload = {\n command: commandName || \"unknown\",\n success: commandSuccess,\n duration: Date.now() - startTime,\n app: program.opts()[\"app\"] as string | undefined,\n error: commandError,\n };\n\n const target = typeof notifyOpt === \"string\" ? notifyOpt : undefined;\n // Fire-and-forget — do not block exit\n sendWebhook(config.webhooks, payload, target).catch(() => {});\n }\n } catch {\n // Never let webhook logic break the CLI\n }\n}\n\n// After command completes, show update notification if available\ntry {\n const result = await Promise.race([\n updateCheckPromise,\n new Promise<null>((resolve) => setTimeout(() => resolve(null), 3000)),\n ]);\n\n if (\n result &&\n result.updateAvailable &&\n process.stdout.isTTY &&\n !process.argv.includes(\"--json\") &&\n program.opts()[\"output\"] !== \"json\"\n ) {\n process.stderr.write(`\\n${formatUpdateNotification(result)}\\n`);\n }\n} catch {\n // Silently ignore update check failures\n}\n","import { join } from \"node:path\";\nimport { readFile, writeFile, mkdir } from \"node:fs/promises\";\nimport { getCacheDir } from \"@gpc-cli/config\";\n\nexport interface UpdateCheckResult {\n current: string;\n latest: string;\n updateAvailable: boolean;\n}\n\ninterface CacheData {\n latest: string;\n checkedAt: number;\n}\n\nconst CACHE_TTL_MS = 24 * 60 * 60 * 1000; // 24 hours\nconst FETCH_TIMEOUT_MS = 3000;\nconst REGISTRY_URL = \"https://registry.npmjs.org/@gpc-cli/cli/latest\";\n\nfunction getCacheFilePath(): string {\n return join(getCacheDir(), \"update-check.json\");\n}\n\n/**\n * Compare two semver strings numerically.\n * Returns true if `b` is newer than `a`.\n */\nexport function isNewerVersion(current: string, latest: string): boolean {\n const a = current.split(\".\").map(Number);\n const b = latest.split(\".\").map(Number);\n for (let i = 0; i < Math.max(a.length, b.length); i++) {\n const av = a[i] ?? 0;\n const bv = b[i] ?? 0;\n if (bv > av) return true;\n if (bv < av) return false;\n }\n return false;\n}\n\nasync function readCache(): Promise<CacheData | null> {\n try {\n const raw = await readFile(getCacheFilePath(), \"utf-8\");\n const data = JSON.parse(raw) as CacheData;\n if (typeof data.latest === \"string\" && typeof data.checkedAt === \"number\") {\n return data;\n }\n return null;\n } catch {\n return null;\n }\n}\n\nfunction writeCache(data: CacheData): void {\n const filePath = getCacheFilePath();\n const dir = join(filePath, \"..\");\n // Fire-and-forget: ignore write errors\n mkdir(dir, { recursive: true })\n .then(() => writeFile(filePath, JSON.stringify(data), \"utf-8\"))\n .catch(() => {});\n}\n\nasync function fetchLatestVersion(): Promise<string | null> {\n try {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);\n\n const response = await fetch(REGISTRY_URL, { signal: controller.signal });\n clearTimeout(timeout);\n\n if (!response.ok) return null;\n\n const body = (await response.json()) as { version?: string };\n if (typeof body.version !== \"string\") return null;\n\n return body.version;\n } catch {\n return null;\n }\n}\n\n/**\n * Check for a newer version of @gpc-cli/cli on npm.\n * Returns null if the check is skipped or fails.\n */\nexport async function checkForUpdate(currentVersion: string): Promise<UpdateCheckResult | null> {\n // Skip in non-interactive or CI environments\n if (process.env[\"GPC_NO_UPDATE_CHECK\"] === \"1\") return null;\n if (process.env[\"CI\"]) return null;\n if (!process.stdout.isTTY) return null;\n\n // Check cache first\n const cache = await readCache();\n if (cache && Date.now() - cache.checkedAt < CACHE_TTL_MS) {\n return {\n current: currentVersion,\n latest: cache.latest,\n updateAvailable: isNewerVersion(currentVersion, cache.latest),\n };\n }\n\n // Fetch from registry\n const latest = await fetchLatestVersion();\n if (!latest) return null;\n\n // Write cache (fire-and-forget)\n writeCache({ latest, checkedAt: Date.now() });\n\n return {\n current: currentVersion,\n latest,\n updateAvailable: isNewerVersion(currentVersion, latest),\n };\n}\n\n/**\n * Format a user-facing update notification string.\n */\nexport function formatUpdateNotification(result: UpdateCheckResult): string {\n return `Update available: ${result.current} \\u2192 ${result.latest} \\u2014 npm install -g @gpc-cli/cli`;\n}\n"],"mappings":";;;;;;;;AAIA,eAAsB,kBAAiC;AAErD,QAAM,SAAS,QAAQ,IAAI,aAAa;AACxC,MAAI,UAAU,CAAC,QAAQ,IAAI,qBAAqB,GAAG;AACjD,YAAQ,IAAI,qBAAqB,IAAI;AAAA,EACvC;AAGA,MAAI,QAAQ,IAAI,cAAc,MAAM,IAAK;AAEzC,QAAM,WACJ,QAAQ,IAAI,aAAa,KACzB,QAAQ,IAAI,aAAa,KACzB,QAAQ,IAAI,YAAY,KACxB,QAAQ,IAAI,YAAY;AAC1B,MAAI,UAAU;AACZ,QAAI;AAEF,YAAM,EAAE,YAAY,oBAAoB,IAAI,MAAM,OAAO,QAAQ;AACjE,0BAAoB,IAAI,WAAW,QAAQ,CAAC;AAAA,IAC9C,QAAQ;AACN,cAAQ,MAAM,2EAA2E;AAAA,IAC3F;AAAA,EACF;AACF;;;ACxBA,SAAS,WAAW,mBAAmB;AAEvC,SAAS,cAAc,kBAAkB;;;ACNzC,SAAS,YAAY;AACrB,SAAS,UAAU,WAAW,aAAa;AAC3C,SAAS,mBAAmB;AAa5B,IAAM,eAAe,KAAK,KAAK,KAAK;AACpC,IAAM,mBAAmB;AACzB,IAAM,eAAe;AAErB,SAAS,mBAA2B;AAClC,SAAO,KAAK,YAAY,GAAG,mBAAmB;AAChD;AAMO,SAAS,eAAe,SAAiB,QAAyB;AACvE,QAAM,IAAI,QAAQ,MAAM,GAAG,EAAE,IAAI,MAAM;AACvC,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UAAU;AACnB,YAAM,cAAc,QAAQ,KAAK,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,UAAU,CAAC,EAAE,KAAK,GAAG;AAC3F,YAAM,UAA0B;AAAA,QAC9B,SAAS,eAAe;AAAA,QACxB,SAAS;AAAA,QACT,UAAU,KAAK,IAAI,IAAI;AAAA,QACvB,KAAK,QAAQ,KAAK,EAAE,KAAK;AAAA,QACzB,OAAO;AAAA,MACT;AAEA,YAAM,SAAS,OAAO,cAAc,WAAW,YAAY;AAE3D,kBAAY,OAAO,UAAU,SAAS,MAAM,EAAE,MAAM,MAAM;AAAA,MAAC,CAAC;AAAA,IAC9D;AAAA,EACF,QAAQ;AAAA,EAER;AACF;AAGA,IAAI;AACF,QAAM,SAAS,MAAM,QAAQ,KAAK;AAAA,IAChC;AAAA,IACA,IAAI,QAAc,CAAC,YAAY,WAAW,MAAM,QAAQ,IAAI,GAAG,GAAI,CAAC;AAAA,EACtE,CAAC;AAED,MACE,UACA,OAAO,mBACP,QAAQ,OAAO,SACf,CAAC,QAAQ,KAAK,SAAS,QAAQ,KAC/B,QAAQ,KAAK,EAAE,QAAQ,MAAM,QAC7B;AACA,YAAQ,OAAO,MAAM;AAAA,EAAK,yBAAyB,MAAM,CAAC;AAAA,CAAI;AAAA,EAChE;AACF,QAAQ;AAER;","names":["currentVersion"]}
|
|
@@ -67,7 +67,7 @@ function registerPluginCommands(program, manager) {
|
|
|
67
67
|
import { Command } from "commander";
|
|
68
68
|
async function createProgram(pluginManager) {
|
|
69
69
|
const program = new Command();
|
|
70
|
-
program.name("gpc").description("The complete Google Play CLI").version(process.env["__GPC_VERSION"] || "0.0.0", "-V, --version").option("-o, --output <format>", "Output format: table, json, yaml, markdown").option("-v, --verbose", "Enable debug logging").option("-q, --quiet", "Suppress non-essential output").option("-a, --app <package>", "App package name").option("-p, --profile <name>", "Auth profile name").option("--no-color", "Disable colored output").option("--no-interactive", "Disable interactive prompts").option("-y, --yes", "Skip confirmation prompts").option("--dry-run", "Preview changes without executing");
|
|
70
|
+
program.name("gpc").description("The complete Google Play CLI").version(process.env["__GPC_VERSION"] || "0.0.0", "-V, --version").option("-o, --output <format>", "Output format: table, json, yaml, markdown").option("-v, --verbose", "Enable debug logging").option("-q, --quiet", "Suppress non-essential output").option("-a, --app <package>", "App package name").option("-p, --profile <name>", "Auth profile name").option("--no-color", "Disable colored output").option("--no-interactive", "Disable interactive prompts").option("-y, --yes", "Skip confirmation prompts").option("--dry-run", "Preview changes without executing").option("--notify [target]", "Send webhook notification on completion (slack, discord, custom)");
|
|
71
71
|
const commandLoaders = {
|
|
72
72
|
auth: async () => {
|
|
73
73
|
(await import("./auth-CIITFC3C.js")).registerAuthCommands(program);
|
|
@@ -82,13 +82,13 @@ async function createProgram(pluginManager) {
|
|
|
82
82
|
(await import("./docs-CVTWIVMS.js")).registerDocsCommand(program);
|
|
83
83
|
},
|
|
84
84
|
completion: async () => {
|
|
85
|
-
(await import("./completion-
|
|
85
|
+
(await import("./completion-3UYUJD6S.js")).registerCompletionCommand(program);
|
|
86
86
|
},
|
|
87
87
|
apps: async () => {
|
|
88
88
|
(await import("./apps-TZG5GEDW.js")).registerAppsCommands(program);
|
|
89
89
|
},
|
|
90
90
|
releases: async () => {
|
|
91
|
-
(await import("./releases-
|
|
91
|
+
(await import("./releases-GUMQZRFC.js")).registerReleasesCommands(program);
|
|
92
92
|
},
|
|
93
93
|
tracks: async () => {
|
|
94
94
|
(await import("./tracks-HMJ3F55N.js")).registerTracksCommands(program);
|
|
@@ -97,19 +97,19 @@ async function createProgram(pluginManager) {
|
|
|
97
97
|
(await import("./status-TBPVS7YR.js")).registerStatusCommand(program);
|
|
98
98
|
},
|
|
99
99
|
listings: async () => {
|
|
100
|
-
(await import("./listings-
|
|
100
|
+
(await import("./listings-FYNMWTIE.js")).registerListingsCommands(program);
|
|
101
101
|
},
|
|
102
102
|
reviews: async () => {
|
|
103
|
-
(await import("./reviews-
|
|
103
|
+
(await import("./reviews-G3HZG3AS.js")).registerReviewsCommands(program);
|
|
104
104
|
},
|
|
105
105
|
vitals: async () => {
|
|
106
106
|
(await import("./vitals-VP2GKG3G.js")).registerVitalsCommands(program);
|
|
107
107
|
},
|
|
108
108
|
subscriptions: async () => {
|
|
109
|
-
(await import("./subscriptions-
|
|
109
|
+
(await import("./subscriptions-CHQU5VXT.js")).registerSubscriptionsCommands(program);
|
|
110
110
|
},
|
|
111
111
|
iap: async () => {
|
|
112
|
-
(await import("./iap-
|
|
112
|
+
(await import("./iap-ZZS5NVFN.js")).registerIapCommands(program);
|
|
113
113
|
},
|
|
114
114
|
purchases: async () => {
|
|
115
115
|
(await import("./purchases-KKSXVEWB.js")).registerPurchasesCommands(program);
|
|
@@ -121,22 +121,37 @@ async function createProgram(pluginManager) {
|
|
|
121
121
|
(await import("./reports-OJSCABN6.js")).registerReportsCommands(program);
|
|
122
122
|
},
|
|
123
123
|
users: async () => {
|
|
124
|
-
(await import("./users-
|
|
124
|
+
(await import("./users-N2TK6KI7.js")).registerUsersCommands(program);
|
|
125
125
|
},
|
|
126
126
|
testers: async () => {
|
|
127
|
-
(await import("./testers-
|
|
127
|
+
(await import("./testers-SB77565D.js")).registerTestersCommands(program);
|
|
128
128
|
},
|
|
129
129
|
validate: async () => {
|
|
130
130
|
(await import("./validate-TPKVSIMR.js")).registerValidateCommand(program);
|
|
131
131
|
},
|
|
132
132
|
publish: async () => {
|
|
133
|
-
(await import("./publish-
|
|
133
|
+
(await import("./publish-YP7U64T2.js")).registerPublishCommand(program);
|
|
134
|
+
},
|
|
135
|
+
recovery: async () => {
|
|
136
|
+
(await import("./recovery-ZANX3WIQ.js")).registerRecoveryCommands(program);
|
|
137
|
+
},
|
|
138
|
+
"data-safety": async () => {
|
|
139
|
+
(await import("./data-safety-M2SFKQ3U.js")).registerDataSafetyCommands(program);
|
|
140
|
+
},
|
|
141
|
+
"external-transactions": async () => {
|
|
142
|
+
(await import("./external-transactions-YRK5CI2D.js")).registerExternalTransactionsCommands(
|
|
143
|
+
program
|
|
144
|
+
);
|
|
134
145
|
},
|
|
135
146
|
plugins: async () => {
|
|
136
147
|
registerPluginsCommand(program, pluginManager);
|
|
137
148
|
}
|
|
138
149
|
};
|
|
139
|
-
const
|
|
150
|
+
const commandAliases = {
|
|
151
|
+
"ext-txn": "external-transactions"
|
|
152
|
+
};
|
|
153
|
+
const rawTarget = process.argv[2];
|
|
154
|
+
const target = rawTarget ? commandAliases[rawTarget] ?? rawTarget : void 0;
|
|
140
155
|
const loader = target ? commandLoaders[target] : void 0;
|
|
141
156
|
if (loader) {
|
|
142
157
|
await loader();
|
|
@@ -243,8 +258,26 @@ function getFullCommandName(cmd) {
|
|
|
243
258
|
return parts.join(" ");
|
|
244
259
|
}
|
|
245
260
|
|
|
261
|
+
// src/error-handler.ts
|
|
262
|
+
function isTypedError(error) {
|
|
263
|
+
return error instanceof Error && "code" in error && typeof error.code === "string";
|
|
264
|
+
}
|
|
265
|
+
function handleCliError(error) {
|
|
266
|
+
if (isTypedError(error)) {
|
|
267
|
+
console.error(`Error [${error.code}]: ${error.message}`);
|
|
268
|
+
if (error.suggestion) {
|
|
269
|
+
console.error(`Suggestion: ${error.suggestion}`);
|
|
270
|
+
}
|
|
271
|
+
return error.exitCode ?? 1;
|
|
272
|
+
}
|
|
273
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
274
|
+
console.error(`Error: ${message}`);
|
|
275
|
+
return 1;
|
|
276
|
+
}
|
|
277
|
+
|
|
246
278
|
export {
|
|
247
279
|
loadPlugins,
|
|
248
|
-
createProgram
|
|
280
|
+
createProgram,
|
|
281
|
+
handleCliError
|
|
249
282
|
};
|
|
250
|
-
//# sourceMappingURL=chunk-
|
|
283
|
+
//# sourceMappingURL=chunk-LQ7FJ4QA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugins.ts","../src/program.ts","../src/error-handler.ts"],"sourcesContent":["import { PluginManager, discoverPlugins } from \"@gpc-cli/core\";\nimport type { Command } from \"commander\";\n\n/**\n * Load and initialize all plugins.\n * First-party plugins (@gpc-cli/*) are auto-trusted.\n * Third-party plugins require prior approval stored in config.\n * Plugin loading is disabled in standalone binary mode.\n */\nexport async function loadPlugins(): Promise<PluginManager> {\n const manager = new PluginManager();\n\n // Standalone binary cannot resolve external npm packages at runtime\n if (process.env[\"__GPC_BINARY\"] === \"1\") {\n return manager;\n }\n\n try {\n const { loadConfig } = await import(\"@gpc-cli/config\");\n const config = await loadConfig();\n const plugins = await discoverPlugins({ configPlugins: config.plugins });\n const approved = new Set(config.approvedPlugins ?? []);\n\n for (const plugin of plugins) {\n const isTrusted = plugin.name.startsWith(\"@gpc-cli/\");\n\n if (!isTrusted && !approved.has(plugin.name)) {\n // Skip unapproved third-party plugins silently in non-interactive mode\n // In interactive mode, the user would run `gpc plugins approve <name>` first\n const isQuiet = process.argv.includes(\"--quiet\") || process.argv.includes(\"-q\");\n if (!isQuiet) {\n console.error(\n `Plugin \"${plugin.name}\" is not approved. Run: gpc plugins approve ${plugin.name}`,\n );\n }\n continue;\n }\n\n try {\n await manager.load(plugin);\n } catch {\n // Skip plugins that fail to load — don't block the CLI\n }\n }\n } catch {\n // Config loading failure shouldn't block plugin-free commands\n }\n\n return manager;\n}\n\n/**\n * Register plugin-defined commands with the Commander program.\n */\nexport function registerPluginCommands(program: Command, manager: PluginManager): void {\n for (const def of manager.getRegisteredCommands()) {\n const cmd = program.command(def.name).description(def.description);\n\n if (def.arguments) {\n for (const arg of def.arguments) {\n const syntax = arg.required ? `<${arg.name}>` : `[${arg.name}]`;\n cmd.argument(syntax, arg.description);\n }\n }\n\n if (def.options) {\n for (const opt of def.options) {\n cmd.option(\n opt.flags,\n opt.description,\n opt.defaultValue as string | boolean | string[] | undefined,\n );\n }\n }\n\n cmd.action(async (...rawArgs: unknown[]) => {\n const opts = rawArgs[rawArgs.length - 2] as Record<string, unknown>;\n const args: Record<string, unknown> = {};\n\n if (def.arguments) {\n def.arguments.forEach((argDef, i) => {\n args[argDef.name] = rawArgs[i];\n });\n }\n\n await def.action(args, opts);\n });\n }\n}\n","import { Command } from \"commander\";\nimport type { PluginManager } from \"@gpc-cli/core\";\nimport type { CommandEvent, CommandResult } from \"@gpc-cli/plugin-sdk\";\nimport { registerPluginCommands } from \"./plugins.js\";\n\nexport async function createProgram(pluginManager?: PluginManager): Promise<Command> {\n const program = new Command();\n\n program\n .name(\"gpc\")\n .description(\"The complete Google Play CLI\")\n .version(process.env[\"__GPC_VERSION\"] || \"0.0.0\", \"-V, --version\")\n .option(\"-o, --output <format>\", \"Output format: table, json, yaml, markdown\")\n .option(\"-v, --verbose\", \"Enable debug logging\")\n .option(\"-q, --quiet\", \"Suppress non-essential output\")\n .option(\"-a, --app <package>\", \"App package name\")\n .option(\"-p, --profile <name>\", \"Auth profile name\")\n .option(\"--no-color\", \"Disable colored output\")\n .option(\"--no-interactive\", \"Disable interactive prompts\")\n .option(\"-y, --yes\", \"Skip confirmation prompts\")\n .option(\"--dry-run\", \"Preview changes without executing\")\n .option(\"--notify [target]\", \"Send webhook notification on completion (slack, discord, custom)\");\n\n const commandLoaders: Record<string, () => Promise<void>> = {\n auth: async () => {\n (await import(\"./commands/auth.js\")).registerAuthCommands(program);\n },\n config: async () => {\n (await import(\"./commands/config.js\")).registerConfigCommands(program);\n },\n doctor: async () => {\n (await import(\"./commands/doctor.js\")).registerDoctorCommand(program);\n },\n docs: async () => {\n (await import(\"./commands/docs.js\")).registerDocsCommand(program);\n },\n completion: async () => {\n (await import(\"./commands/completion.js\")).registerCompletionCommand(program);\n },\n apps: async () => {\n (await import(\"./commands/apps.js\")).registerAppsCommands(program);\n },\n releases: async () => {\n (await import(\"./commands/releases.js\")).registerReleasesCommands(program);\n },\n tracks: async () => {\n (await import(\"./commands/tracks.js\")).registerTracksCommands(program);\n },\n status: async () => {\n (await import(\"./commands/status.js\")).registerStatusCommand(program);\n },\n listings: async () => {\n (await import(\"./commands/listings.js\")).registerListingsCommands(program);\n },\n reviews: async () => {\n (await import(\"./commands/reviews.js\")).registerReviewsCommands(program);\n },\n vitals: async () => {\n (await import(\"./commands/vitals.js\")).registerVitalsCommands(program);\n },\n subscriptions: async () => {\n (await import(\"./commands/subscriptions.js\")).registerSubscriptionsCommands(program);\n },\n iap: async () => {\n (await import(\"./commands/iap.js\")).registerIapCommands(program);\n },\n purchases: async () => {\n (await import(\"./commands/purchases.js\")).registerPurchasesCommands(program);\n },\n pricing: async () => {\n (await import(\"./commands/pricing.js\")).registerPricingCommands(program);\n },\n reports: async () => {\n (await import(\"./commands/reports.js\")).registerReportsCommands(program);\n },\n users: async () => {\n (await import(\"./commands/users.js\")).registerUsersCommands(program);\n },\n testers: async () => {\n (await import(\"./commands/testers.js\")).registerTestersCommands(program);\n },\n validate: async () => {\n (await import(\"./commands/validate.js\")).registerValidateCommand(program);\n },\n publish: async () => {\n (await import(\"./commands/publish.js\")).registerPublishCommand(program);\n },\n recovery: async () => {\n (await import(\"./commands/recovery.js\")).registerRecoveryCommands(program);\n },\n \"data-safety\": async () => {\n (await import(\"./commands/data-safety.js\")).registerDataSafetyCommands(program);\n },\n \"external-transactions\": async () => {\n (await import(\"./commands/external-transactions.js\")).registerExternalTransactionsCommands(\n program,\n );\n },\n plugins: async () => {\n registerPluginsCommand(program, pluginManager);\n },\n };\n\n // Resolve command aliases for lazy loading\n const commandAliases: Record<string, string> = {\n \"ext-txn\": \"external-transactions\",\n };\n\n const rawTarget = process.argv[2];\n const target = rawTarget ? (commandAliases[rawTarget] ?? rawTarget) : undefined;\n\n const loader = target ? commandLoaders[target] : undefined;\n if (loader) {\n await loader();\n } else {\n await Promise.all(Object.values(commandLoaders).map((loader) => loader()));\n }\n\n // Register plugin-defined commands\n if (pluginManager) {\n registerPluginCommands(program, pluginManager);\n }\n\n // Wire plugin lifecycle hooks around command execution\n if (pluginManager) {\n wrapCommandHooks(program, pluginManager);\n }\n\n return program;\n}\n\n/**\n * `gpc plugins` — manage plugins.\n */\nfunction registerPluginsCommand(program: Command, manager?: PluginManager): void {\n const cmd = program.command(\"plugins\").description(\"Manage plugins\");\n\n cmd\n .command(\"list\")\n .description(\"List loaded plugins\")\n .action(() => {\n const plugins = manager?.getLoadedPlugins() ?? [];\n const opts = program.opts();\n\n if (opts[\"output\"] === \"json\") {\n console.log(JSON.stringify(plugins, null, 2));\n return;\n }\n\n if (plugins.length === 0) {\n console.log(\"No plugins loaded.\");\n console.log('\\nConfigure plugins in .gpcrc.json: { \"plugins\": [\"@gpc-cli/plugin-ci\"] }');\n return;\n }\n\n console.log(\"Loaded plugins:\\n\");\n for (const p of plugins) {\n const trust = p.trusted ? \"trusted\" : \"third-party\";\n console.log(` ${p.name}@${p.version} (${trust})`);\n }\n\n const commands = manager?.getRegisteredCommands() ?? [];\n if (commands.length > 0) {\n console.log(\"\\nPlugin commands:\\n\");\n for (const c of commands) {\n console.log(` gpc ${c.name} — ${c.description}`);\n }\n }\n });\n\n cmd\n .command(\"init <name>\")\n .description(\"Scaffold a new plugin project\")\n .option(\"-d, --dir <path>\", \"Output directory (defaults to ./gpc-plugin-<name>)\")\n .option(\"--description <text>\", \"Plugin description\")\n .action(async (name: string, opts: { dir?: string; description?: string }) => {\n const { scaffoldPlugin } = await import(\"@gpc-cli/core\");\n const pluginName = name.startsWith(\"gpc-plugin-\") ? name : `gpc-plugin-${name}`;\n const dir = opts.dir ?? `./${pluginName}`;\n\n const result = await scaffoldPlugin({ name, dir, description: opts.description });\n\n console.log(`Plugin scaffolded at ${result.dir}/\\n`);\n console.log(\"Files created:\");\n for (const f of result.files) {\n console.log(` ${f}`);\n }\n console.log(`\\nNext steps:`);\n console.log(` cd ${pluginName}`);\n console.log(` npm install`);\n console.log(` npm run build`);\n console.log(` npm test`);\n });\n\n cmd\n .command(\"approve <name>\")\n .description(\"Approve a third-party plugin for loading\")\n .action(async (name: string) => {\n const { approvePlugin } = await import(\"@gpc-cli/config\");\n await approvePlugin(name);\n console.log(`Plugin \"${name}\" approved. It will be loaded on next run.`);\n });\n\n cmd\n .command(\"revoke <name>\")\n .description(\"Revoke approval for a third-party plugin\")\n .action(async (name: string) => {\n const { revokePluginApproval } = await import(\"@gpc-cli/config\");\n const removed = await revokePluginApproval(name);\n if (removed) {\n console.log(`Plugin \"${name}\" approval revoked.`);\n } else {\n console.log(`Plugin \"${name}\" was not in the approved list.`);\n }\n });\n}\n\n/**\n * Wrap all registered commands so plugin hooks fire before/after each command.\n */\nfunction wrapCommandHooks(program: Command, manager: PluginManager): void {\n program.hook(\"preAction\", async (thisCommand) => {\n const event: CommandEvent = {\n command: getFullCommandName(thisCommand),\n args: thisCommand.opts(),\n app: program.opts()[\"app\"] as string | undefined,\n startedAt: new Date(),\n };\n\n // Store on the command for afterCommand/onError\n (thisCommand as unknown as Record<string, unknown>)[\"__pluginEvent\"] = event;\n\n await manager.runBeforeCommand(event);\n });\n\n program.hook(\"postAction\", async (thisCommand) => {\n const event: CommandEvent = (thisCommand as unknown as Record<string, unknown>)[\n \"__pluginEvent\"\n ] as CommandEvent;\n if (!event) return;\n\n const result: CommandResult = {\n success: true,\n durationMs: Date.now() - event.startedAt.getTime(),\n exitCode: 0,\n };\n\n await manager.runAfterCommand(event, result);\n });\n}\n\nfunction getFullCommandName(cmd: Command): string {\n const parts: string[] = [];\n let current: Command | null = cmd;\n while (current && current.name() !== \"gpc\") {\n parts.unshift(current.name());\n current = current.parent;\n }\n return parts.join(\" \");\n}\n","/**\n * Shared error formatting for CLI output.\n * Extracts error code, message, and suggestion from typed errors (GpcError, AuthError, ApiError, ConfigError).\n */\n\ninterface TypedError {\n message: string;\n code?: string;\n suggestion?: string;\n exitCode?: number;\n}\n\nfunction isTypedError(error: unknown): error is Error & TypedError {\n return error instanceof Error && \"code\" in error && typeof (error as TypedError).code === \"string\";\n}\n\n/**\n * Format an error for CLI output. Prints:\n * Error [CODE]: message\n * Suggestion: suggestion (if available)\n *\n * Returns the appropriate exit code.\n */\nexport function handleCliError(error: unknown): number {\n if (isTypedError(error)) {\n console.error(`Error [${error.code}]: ${error.message}`);\n if (error.suggestion) {\n console.error(`Suggestion: ${error.suggestion}`);\n }\n return error.exitCode ?? 1;\n }\n\n const message = error instanceof Error ? error.message : String(error);\n console.error(`Error: ${message}`);\n return 1;\n}\n"],"mappings":";;;AAAA,SAAS,eAAe,uBAAuB;AAS/C,eAAsB,cAAsC;AAC1D,QAAM,UAAU,IAAI,cAAc;AAGlC,MAAI,QAAQ,IAAI,cAAc,MAAM,KAAK;AACvC,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,EAAE,WAAW,IAAI,MAAM,OAAO,iBAAiB;AACrD,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,UAAU,MAAM,gBAAgB,EAAE,eAAe,OAAO,QAAQ,CAAC;AACvE,UAAM,WAAW,IAAI,IAAI,OAAO,mBAAmB,CAAC,CAAC;AAErD,eAAW,UAAU,SAAS;AAC5B,YAAM,YAAY,OAAO,KAAK,WAAW,WAAW;AAEpD,UAAI,CAAC,aAAa,CAAC,SAAS,IAAI,OAAO,IAAI,GAAG;AAG5C,cAAM,UAAU,QAAQ,KAAK,SAAS,SAAS,KAAK,QAAQ,KAAK,SAAS,IAAI;AAC9E,YAAI,CAAC,SAAS;AACZ,kBAAQ;AAAA,YACN,WAAW,OAAO,IAAI,+CAA+C,OAAO,IAAI;AAAA,UAClF;AAAA,QACF;AACA;AAAA,MACF;AAEA,UAAI;AACF,cAAM,QAAQ,KAAK,MAAM;AAAA,MAC3B,QAAQ;AAAA,MAER;AAAA,IACF;AAAA,EACF,QAAQ;AAAA,EAER;AAEA,SAAO;AACT;AAKO,SAAS,uBAAuB,SAAkB,SAA8B;AACrF,aAAW,OAAO,QAAQ,sBAAsB,GAAG;AACjD,UAAM,MAAM,QAAQ,QAAQ,IAAI,IAAI,EAAE,YAAY,IAAI,WAAW;AAEjE,QAAI,IAAI,WAAW;AACjB,iBAAW,OAAO,IAAI,WAAW;AAC/B,cAAM,SAAS,IAAI,WAAW,IAAI,IAAI,IAAI,MA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