@gpc-cli/cli 0.9.34 → 0.9.35
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 +20 -15
- package/dist/{apps-CVBURB5V.js → apps-J2446UDA.js} +2 -2
- package/dist/{apps-CVBURB5V.js.map → apps-J2446UDA.js.map} +1 -1
- package/dist/{audit-A4BP27DN.js → audit-4UPTLW37.js} +2 -3
- package/dist/{audit-A4BP27DN.js.map → audit-4UPTLW37.js.map} +1 -1
- package/dist/{auth-QSDK7NUO.js → auth-KPVEGAWV.js} +101 -9
- package/dist/auth-KPVEGAWV.js.map +1 -0
- package/dist/bin.js +2 -2
- package/dist/bin.js.map +1 -1
- package/dist/{bundle-7IF5FIB4.js → bundle-7XYHNVNF.js} +27 -2
- package/dist/bundle-7XYHNVNF.js.map +1 -0
- package/dist/{cache-SHWAVON6.js → cache-K23N6GJR.js} +1 -1
- package/dist/cache-K23N6GJR.js.map +1 -0
- package/dist/{chunk-UH3TMIAL.js → chunk-43SH6XEJ.js} +5 -5
- package/dist/{chunk-UH3TMIAL.js.map → chunk-43SH6XEJ.js.map} +1 -1
- package/dist/{chunk-5CSWPQO6.js → chunk-DDTPDKTB.js} +101 -31
- package/dist/chunk-DDTPDKTB.js.map +1 -0
- package/dist/{config-7EOY5HGL.js → config-REB7NINL.js} +4 -4
- package/dist/config-REB7NINL.js.map +1 -0
- package/dist/{data-safety-GDPKV5PN.js → data-safety-GN5VBKAK.js} +1 -1
- package/dist/data-safety-GN5VBKAK.js.map +1 -0
- package/dist/{doctor-UKKOK55S.js → doctor-QDIFTXNB.js} +44 -2
- package/dist/doctor-QDIFTXNB.js.map +1 -0
- package/dist/enterprise-IH5HXYRB.js +65 -0
- package/dist/enterprise-IH5HXYRB.js.map +1 -0
- package/dist/{feedback-W5MZMRF2.js → feedback-NVGHRU7A.js} +3 -3
- package/dist/feedback-NVGHRU7A.js.map +1 -0
- package/dist/games-X57AGM3E.js +80 -0
- package/dist/games-X57AGM3E.js.map +1 -0
- package/dist/grants-CXTTYKR3.js +123 -0
- package/dist/grants-CXTTYKR3.js.map +1 -0
- package/dist/{iap-6XHJV5HX.js → iap-MBDD7VWP.js} +1 -1
- package/dist/iap-MBDD7VWP.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/{listings-TOYS6XBU.js → listings-7TWCGGMS.js} +90 -9
- package/dist/listings-7TWCGGMS.js.map +1 -0
- package/dist/{publish-I6WJGR4S.js → publish-XM43UA5R.js} +2 -1
- package/dist/publish-XM43UA5R.js.map +1 -0
- package/dist/{purchases-YRO6B7M6.js → purchases-WIDU3FDQ.js} +28 -1
- package/dist/purchases-WIDU3FDQ.js.map +1 -0
- package/dist/quickstart-N7FXM5RQ.js +87 -0
- package/dist/quickstart-N7FXM5RQ.js.map +1 -0
- package/dist/quota-SNUI75NM.js +53 -0
- package/dist/quota-SNUI75NM.js.map +1 -0
- package/dist/{releases-ANC54YWF.js → releases-YRYM7JXC.js} +5 -1
- package/dist/releases-YRYM7JXC.js.map +1 -0
- package/dist/{reports-N5X66IUN.js → reports-YOT4DQGL.js} +1 -1
- package/dist/reports-YOT4DQGL.js.map +1 -0
- package/dist/{reviews-UHK4FGK6.js → reviews-NN7YQITF.js} +55 -3
- package/dist/reviews-NN7YQITF.js.map +1 -0
- package/dist/{status-DQYZ7A6Y.js → status-L5S2FGZ4.js} +13 -3
- package/dist/status-L5S2FGZ4.js.map +1 -0
- package/dist/{subscriptions-Z5ZPVUFM.js → subscriptions-OXAE7SNS.js} +32 -1
- package/dist/subscriptions-OXAE7SNS.js.map +1 -0
- package/dist/{testers-UWSUGGVT.js → testers-SDLVWQ2Z.js} +1 -1
- package/dist/testers-SDLVWQ2Z.js.map +1 -0
- package/dist/{tracks-XFUN7JJX.js → tracks-NERFFEDT.js} +2 -2
- package/dist/tracks-NERFFEDT.js.map +1 -0
- package/dist/train-PX5Z26PQ.js +150 -0
- package/dist/train-PX5Z26PQ.js.map +1 -0
- package/dist/{update-NIVJLUNH.js → update-6XSZRXSU.js} +3 -3
- package/dist/{update-NIVJLUNH.js.map → update-6XSZRXSU.js.map} +1 -1
- package/dist/{validate-MHLPENCM.js → validate-NC4MWKOB.js} +9 -4
- package/dist/validate-NC4MWKOB.js.map +1 -0
- package/dist/{version-7AI5IHVK.js → version-2X32UAAE.js} +3 -3
- package/dist/version-2X32UAAE.js.map +1 -0
- package/dist/{vitals-QGWOFH7E.js → vitals-LFL75LA6.js} +113 -2
- package/dist/vitals-LFL75LA6.js.map +1 -0
- package/package.json +8 -4
- package/dist/auth-QSDK7NUO.js.map +0 -1
- package/dist/bundle-7IF5FIB4.js.map +0 -1
- package/dist/cache-SHWAVON6.js.map +0 -1
- package/dist/chunk-5CSWPQO6.js.map +0 -1
- package/dist/config-7EOY5HGL.js.map +0 -1
- package/dist/data-safety-GDPKV5PN.js.map +0 -1
- package/dist/doctor-UKKOK55S.js.map +0 -1
- package/dist/feedback-W5MZMRF2.js.map +0 -1
- package/dist/iap-6XHJV5HX.js.map +0 -1
- package/dist/listings-TOYS6XBU.js.map +0 -1
- package/dist/publish-I6WJGR4S.js.map +0 -1
- package/dist/purchases-YRO6B7M6.js.map +0 -1
- package/dist/releases-ANC54YWF.js.map +0 -1
- package/dist/reports-N5X66IUN.js.map +0 -1
- package/dist/reviews-UHK4FGK6.js.map +0 -1
- package/dist/status-DQYZ7A6Y.js.map +0 -1
- package/dist/subscriptions-Z5ZPVUFM.js.map +0 -1
- package/dist/testers-UWSUGGVT.js.map +0 -1
- package/dist/tracks-XFUN7JJX.js.map +0 -1
- package/dist/validate-MHLPENCM.js.map +0 -1
- package/dist/version-7AI5IHVK.js.map +0 -1
- package/dist/vitals-QGWOFH7E.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/update.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport {\n checkForUpdate,\n fetchChecksums,\n updateViaNpm,\n updateViaBrew,\n updateBinaryInPlace,\n getPlatformAsset,\n getCurrentBinaryPath,\n} from \"../updater.js\";\nimport { createSpinner } from \"@gpc-cli/core\";\n\nexport function registerUpdateCommand(program: Command): void {\n program\n .command(\"update\")\n .description(\"Update gpc to the latest version\")\n .option(\"--check\", \"Check for updates without installing (exits 0 always)\")\n .option(\"--force\", \"Update even if already on the latest version\")\n .action(async (opts: { check?: boolean; force?: boolean }, cmd) => {\n const parentOpts = (cmd.parent?.opts() ?? {}) as Record<string, unknown>;\n const jsonMode = !!(parentOpts[\"json\"] || parentOpts[\"output\"] === \"json\");\n const currentVersion = process.env[\"__GPC_VERSION\"] ?? \"0.0.0\";\n\n // Dev build guard\n if (currentVersion === \"0.0.0\") {\n if (jsonMode) {\n console.log(\n JSON.stringify({\n success: false,\n reason: \"Cannot update a development build\",\n current: currentVersion,\n }),\n );\n } else {\n console.log(\"Cannot update a development build (version: 0.0.0).\");\n }\n return;\n }\n\n const spinner = createSpinner(\"Checking for updates...\");\n spinner.start();\n\n let result;\n try {\n result = await checkForUpdate(currentVersion);\n } catch (err) {\n spinner.fail(\"Failed to check for updates\");\n throw err;\n }\n\n // --check mode: always exit 0, communicate via output\n if (opts.check) {\n spinner.stop();\n if (jsonMode) {\n console.log(\n JSON.stringify({\n current: result.current,\n latest: result.latest,\n updateAvailable: result.updateAvailable,\n installMethod: result.installMethod,\n releaseUrl: result.release.html_url,\n }),\n );\n } else if (result.updateAvailable) {\n console.log(`Update available: ${result.current} → ${result.latest}`);\n console.log(`Install method: ${result.installMethod}`);\n console.log(`Release: ${result.release.html_url}`);\n console.log(`\\nRun: gpc update`);\n } else {\n console.log(`Already on latest version: v${result.current}`);\n console.log(`Install method: ${result.installMethod}`);\n }\n return;\n }\n\n // Already up to date\n if (!result.updateAvailable && !opts.force) {\n spinner.stop(`Already on latest version: v${result.current}`);\n if (jsonMode) {\n console.log(\n JSON.stringify({\n success: true,\n current: result.current,\n latest: result.latest,\n updated: false,\n installMethod: result.installMethod,\n }),\n );\n }\n return;\n }\n\n spinner.update(\n `Updating v${result.current} → v${result.latest} (${result.installMethod})...`,\n );\n\n switch (result.installMethod) {\n case \"npm\":\n spinner.stop();\n await updateViaNpm({ silent: jsonMode });\n break;\n\n case \"homebrew\":\n spinner.stop();\n await updateViaBrew({ silent: jsonMode });\n break;\n\n case \"binary\": {\n const assetName = getPlatformAsset();\n if (!assetName) {\n spinner.fail();\n console.error(\n `Error: Unsupported platform: ${process.platform}/${process.arch}`,\n );\n console.error(\n `Download manually: ${result.release.html_url}`,\n );\n process.exit(1);\n }\n\n const assetObj = result.release.assets.find((a) => a.name === assetName);\n if (!assetObj) {\n spinner.fail();\n console.error(\n `Error: No binary found for ${assetName} in release ${result.latestTag}`,\n );\n console.error(`Check: ${result.release.html_url}`);\n process.exit(1);\n }\n\n const sizeMB = (assetObj.size / (1024 * 1024)).toFixed(1);\n spinner.stop();\n\n const checksums = await fetchChecksums(result.release);\n const expectedHash = checksums.get(assetName) ?? \"\";\n const binaryPath = getCurrentBinaryPath();\n\n if (jsonMode) {\n await updateBinaryInPlace(assetObj.browser_download_url, expectedHash, binaryPath);\n } else {\n // Show live download progress on a single overwriting line\n const label = `Downloading ${assetName} (${sizeMB} MB)`;\n process.stdout.write(`${label}...\\n`);\n let lastPct = -1;\n await updateBinaryInPlace(assetObj.browser_download_url, expectedHash, binaryPath, {\n onProgress(downloaded, total) {\n if (total <= 0) return;\n const pct = Math.min(100, Math.round((downloaded / total) * 100));\n if (pct === lastPct) return; // avoid redundant writes\n lastPct = pct;\n const dlMB = (downloaded / (1024 * 1024)).toFixed(1);\n process.stdout.write(\n `\\r${label} ${dlMB} / ${sizeMB} MB (${String(pct).padStart(3)}%) `,\n );\n },\n });\n process.stdout.write(\"\\n\");\n }\n break;\n }\n\n case \"unknown\":\n spinner.fail();\n console.error(\"Error: Could not detect install method. Update manually:\");\n console.error(` npm: npm install -g @gpc-cli/cli@latest`);\n console.error(` Homebrew: brew upgrade yasserstudio/tap/gpc`);\n console.error(` Binary: https://github.com/yasserstudio/gpc/releases/latest`);\n process.exit(1);\n }\n\n if (jsonMode) {\n console.log(\n JSON.stringify({\n success: true,\n previous: result.current,\n current: result.latest,\n method: result.installMethod,\n }),\n );\n } else {\n console.log(`\\n✔ Updated to v${result.latest}`);\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAUA,SAAS,qBAAqB;AAEvB,SAAS,sBAAsB,SAAwB;AAC5D,UACG,QAAQ,QAAQ,EAChB,YAAY,kCAAkC,EAC9C,OAAO,WAAW,uDAAuD,EACzE,OAAO,WAAW,8CAA8C,EAChE,OAAO,OAAO,MAA4C,QAAQ;AACjE,UAAM,aAAc,IAAI,QAAQ,KAAK,KAAK,CAAC;AAC3C,UAAM,WAAW,CAAC,EAAE,WAAW,MAAM,KAAK,WAAW,QAAQ,MAAM;AACnE,UAAM,iBAAiB
|
|
1
|
+
{"version":3,"sources":["../src/commands/update.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport {\n checkForUpdate,\n fetchChecksums,\n updateViaNpm,\n updateViaBrew,\n updateBinaryInPlace,\n getPlatformAsset,\n getCurrentBinaryPath,\n} from \"../updater.js\";\nimport { createSpinner } from \"@gpc-cli/core\";\n\nexport function registerUpdateCommand(program: Command): void {\n program\n .command(\"update\")\n .description(\"Update gpc to the latest version\")\n .option(\"--check\", \"Check for updates without installing (exits 0 always)\")\n .option(\"--force\", \"Update even if already on the latest version\")\n .action(async (opts: { check?: boolean; force?: boolean }, cmd) => {\n const parentOpts = (cmd.parent?.opts() ?? {}) as Record<string, unknown>;\n const jsonMode = !!(parentOpts[\"json\"] || parentOpts[\"output\"] === \"json\");\n const currentVersion = process.env[\"__GPC_VERSION\"] ?? \"0.0.0\";\n\n // Dev build guard\n if (currentVersion === \"0.0.0\") {\n if (jsonMode) {\n console.log(\n JSON.stringify({\n success: false,\n reason: \"Cannot update a development build\",\n current: currentVersion,\n }),\n );\n } else {\n console.log(\"Cannot update a development build (version: 0.0.0).\");\n }\n return;\n }\n\n const spinner = createSpinner(\"Checking for updates...\");\n spinner.start();\n\n let result;\n try {\n result = await checkForUpdate(currentVersion);\n } catch (err) {\n spinner.fail(\"Failed to check for updates\");\n throw err;\n }\n\n // --check mode: always exit 0, communicate via output\n if (opts.check) {\n spinner.stop();\n if (jsonMode) {\n console.log(\n JSON.stringify({\n current: result.current,\n latest: result.latest,\n updateAvailable: result.updateAvailable,\n installMethod: result.installMethod,\n releaseUrl: result.release.html_url,\n }),\n );\n } else if (result.updateAvailable) {\n console.log(`Update available: ${result.current} → ${result.latest}`);\n console.log(`Install method: ${result.installMethod}`);\n console.log(`Release: ${result.release.html_url}`);\n console.log(`\\nRun: gpc update`);\n } else {\n console.log(`Already on latest version: v${result.current}`);\n console.log(`Install method: ${result.installMethod}`);\n }\n return;\n }\n\n // Already up to date\n if (!result.updateAvailable && !opts.force) {\n spinner.stop(`Already on latest version: v${result.current}`);\n if (jsonMode) {\n console.log(\n JSON.stringify({\n success: true,\n current: result.current,\n latest: result.latest,\n updated: false,\n installMethod: result.installMethod,\n }),\n );\n }\n return;\n }\n\n spinner.update(\n `Updating v${result.current} → v${result.latest} (${result.installMethod})...`,\n );\n\n switch (result.installMethod) {\n case \"npm\":\n spinner.stop();\n await updateViaNpm({ silent: jsonMode });\n break;\n\n case \"homebrew\":\n spinner.stop();\n await updateViaBrew({ silent: jsonMode });\n break;\n\n case \"binary\": {\n const assetName = getPlatformAsset();\n if (!assetName) {\n spinner.fail();\n console.error(\n `Error: Unsupported platform: ${process.platform}/${process.arch}`,\n );\n console.error(\n `Download manually: ${result.release.html_url}`,\n );\n process.exit(1);\n }\n\n const assetObj = result.release.assets.find((a) => a.name === assetName);\n if (!assetObj) {\n spinner.fail();\n console.error(\n `Error: No binary found for ${assetName} in release ${result.latestTag}`,\n );\n console.error(`Check: ${result.release.html_url}`);\n process.exit(1);\n }\n\n const sizeMB = (assetObj.size / (1024 * 1024)).toFixed(1);\n spinner.stop();\n\n const checksums = await fetchChecksums(result.release);\n const expectedHash = checksums.get(assetName) ?? \"\";\n const binaryPath = getCurrentBinaryPath();\n\n if (jsonMode) {\n await updateBinaryInPlace(assetObj.browser_download_url, expectedHash, binaryPath);\n } else {\n // Show live download progress on a single overwriting line\n const label = `Downloading ${assetName} (${sizeMB} MB)`;\n process.stdout.write(`${label}...\\n`);\n let lastPct = -1;\n await updateBinaryInPlace(assetObj.browser_download_url, expectedHash, binaryPath, {\n onProgress(downloaded, total) {\n if (total <= 0) return;\n const pct = Math.min(100, Math.round((downloaded / total) * 100));\n if (pct === lastPct) return; // avoid redundant writes\n lastPct = pct;\n const dlMB = (downloaded / (1024 * 1024)).toFixed(1);\n process.stdout.write(\n `\\r${label} ${dlMB} / ${sizeMB} MB (${String(pct).padStart(3)}%) `,\n );\n },\n });\n process.stdout.write(\"\\n\");\n }\n break;\n }\n\n case \"unknown\":\n spinner.fail();\n console.error(\"Error: Could not detect install method. Update manually:\");\n console.error(` npm: npm install -g @gpc-cli/cli@latest`);\n console.error(` Homebrew: brew upgrade yasserstudio/tap/gpc`);\n console.error(` Binary: https://github.com/yasserstudio/gpc/releases/latest`);\n process.exit(1);\n }\n\n if (jsonMode) {\n console.log(\n JSON.stringify({\n success: true,\n previous: result.current,\n current: result.latest,\n method: result.installMethod,\n }),\n );\n } else {\n console.log(`\\n✔ Updated to v${result.latest}`);\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAUA,SAAS,qBAAqB;AAEvB,SAAS,sBAAsB,SAAwB;AAC5D,UACG,QAAQ,QAAQ,EAChB,YAAY,kCAAkC,EAC9C,OAAO,WAAW,uDAAuD,EACzE,OAAO,WAAW,8CAA8C,EAChE,OAAO,OAAO,MAA4C,QAAQ;AACjE,UAAM,aAAc,IAAI,QAAQ,KAAK,KAAK,CAAC;AAC3C,UAAM,WAAW,CAAC,EAAE,WAAW,MAAM,KAAK,WAAW,QAAQ,MAAM;AACnE,UAAM,iBAAiB;AAGvB,QAAI,mBAAmB,SAAS;AAC9B,UAAI,UAAU;AACZ,gBAAQ;AAAA,UACN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 -37,18 +42,18 @@ function registerValidateCommand(program) {
|
|
|
37
42
|
} else {
|
|
38
43
|
const checkRows = result.checks.map((c) => ({
|
|
39
44
|
check: c.name,
|
|
40
|
-
passed: c.passed ? "pass" : "FAIL",
|
|
45
|
+
passed: c.passed ? green("\u2713 pass") : red("\u2717 FAIL"),
|
|
41
46
|
message: c.message
|
|
42
47
|
}));
|
|
43
48
|
console.log(formatOutput(checkRows, format));
|
|
44
49
|
if (result.warnings.length > 0) {
|
|
45
50
|
console.log("\nWarnings:");
|
|
46
51
|
for (const w of result.warnings) {
|
|
47
|
-
console.log(` ${w}`);
|
|
52
|
+
console.log(` ${yellow("\u26A0")} ${w}`);
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
55
|
console.log(`
|
|
51
|
-
${result.valid ? "Valid" : "Invalid"}`);
|
|
56
|
+
${result.valid ? green("\u2713 Valid") : red("\u2717 Invalid")}`);
|
|
52
57
|
}
|
|
53
58
|
process.exit(result.valid ? 0 : 1);
|
|
54
59
|
});
|
|
@@ -56,4 +61,4 @@ ${result.valid ? "Valid" : "Invalid"}`);
|
|
|
56
61
|
export {
|
|
57
62
|
registerValidateCommand
|
|
58
63
|
};
|
|
59
|
-
//# sourceMappingURL=validate-
|
|
64
|
+
//# sourceMappingURL=validate-NC4MWKOB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/validate.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { loadConfig } from \"@gpc-cli/config\";\nimport { validatePreSubmission, readReleaseNotesFromDir } from \"@gpc-cli/core\";\nimport { formatOutput } from \"@gpc-cli/core\";\nimport { getOutputFormat } from \"../format.js\";\nimport { green, red, yellow } from \"../colors.js\";\n\nexport function registerValidateCommand(program: Command): void {\n program\n .command(\"validate <file>\")\n .description(\"Pre-submission validation checks\")\n .option(\"--track <track>\", \"Target track to validate\")\n .option(\"--mapping <file>\", \"ProGuard/R8 mapping file\")\n .option(\"--notes <text>\", \"Release notes (en-US)\")\n .option(\"--notes-dir <dir>\", \"Read release notes from directory (<dir>/<lang>.txt)\")\n .action(async (file: string, options) => {\n if (options.notes && options.notesDir) {\n console.error(\"Error: Cannot use both --notes and --notes-dir\");\n process.exit(2);\n }\n\n const config = await loadConfig();\n const format = getOutputFormat(program, config);\n\n let notes: { language: string; text: string }[] | undefined;\n if (options.notesDir) {\n try {\n notes = await readReleaseNotesFromDir(options.notesDir);\n } catch (err) {\n console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);\n process.exit(1);\n }\n } else if (options.notes) {\n notes = [{ language: \"en-US\", text: options.notes }];\n }\n\n const result = await validatePreSubmission({\n filePath: file,\n mappingFile: options.mapping,\n track: options.track,\n notes,\n });\n\n if (format === \"json\") {\n console.log(formatOutput(result, format));\n } else {\n const checkRows = result.checks.map((c) => ({\n check: c.name,\n passed: c.passed ? green(\"✓ pass\") : red(\"✗ FAIL\"),\n message: c.message,\n }));\n console.log(formatOutput(checkRows, format));\n if (result.warnings.length > 0) {\n console.log(\"\\nWarnings:\");\n for (const w of result.warnings) {\n console.log(` ${yellow(\"⚠\")} ${w}`);\n }\n }\n console.log(`\\n${result.valid ? green(\"✓ Valid\") : red(\"✗ Invalid\")}`);\n }\n process.exit(result.valid ? 0 : 1);\n });\n}\n"],"mappings":";;;;;;;;;;;AACA,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB,+BAA+B;AAC/D,SAAS,oBAAoB;AAItB,SAAS,wBAAwB,SAAwB;AAC9D,UACG,QAAQ,iBAAiB,EACzB,YAAY,kCAAkC,EAC9C,OAAO,mBAAmB,0BAA0B,EACpD,OAAO,oBAAoB,0BAA0B,EACrD,OAAO,kBAAkB,uBAAuB,EAChD,OAAO,qBAAqB,sDAAsD,EAClF,OAAO,OAAO,MAAc,YAAY;AACvC,QAAI,QAAQ,SAAS,QAAQ,UAAU;AACrC,cAAQ,MAAM,gDAAgD;AAC9D,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,UAAM,SAAS,MAA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
2
|
import {
|
|
3
3
|
detectInstallMethod
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-43SH6XEJ.js";
|
|
5
5
|
import "./chunk-4O4D5SGL.js";
|
|
6
6
|
|
|
7
7
|
// src/commands/version.ts
|
|
8
8
|
function registerVersionCommand(program) {
|
|
9
9
|
program.command("version").description("Show version information").action(() => {
|
|
10
|
-
const version =
|
|
10
|
+
const version = "0.9.35";
|
|
11
11
|
if (program.opts()["output"] === "json") {
|
|
12
12
|
console.log(JSON.stringify({
|
|
13
13
|
version,
|
|
@@ -23,4 +23,4 @@ function registerVersionCommand(program) {
|
|
|
23
23
|
export {
|
|
24
24
|
registerVersionCommand
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=version-
|
|
26
|
+
//# sourceMappingURL=version-2X32UAAE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/version.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { detectInstallMethod } from \"../updater.js\";\n\nexport function registerVersionCommand(program: Command): void {\n program\n .command(\"version\")\n .description(\"Show version information\")\n .action(() => {\n const version = process.env[\"__GPC_VERSION\"] || \"0.0.0\";\n if (program.opts()[\"output\"] === \"json\") {\n console.log(JSON.stringify({\n version,\n node: process.version,\n platform: `${process.platform}/${process.arch}`,\n installMethod: detectInstallMethod(),\n }));\n } else {\n console.log(version);\n }\n });\n}\n"],"mappings":";;;;;;;AAGO,SAAS,uBAAuB,SAAwB;AAC7D,UACG,QAAQ,SAAS,EACjB,YAAY,0BAA0B,EACtC,OAAO,MAAM;AACZ,UAAM,UAAU;AAChB,QAAI,QAAQ,KAAK,EAAE,QAAQ,MAAM,QAAQ;AACvC,cAAQ,IAAI,KAAK,UAAU;AAAA,QACzB;AAAA,QACA,MAAM,QAAQ;AAAA,QACd,UAAU,GAAG,QAAQ,QAAQ,IAAI,QAAQ,IAAI;AAAA,QAC7C,eAAe,oBAAoB;AAAA,MACrC,CAAC,CAAC;AAAA,IACJ,OAAO;AACL,cAAQ,IAAI,OAAO;AAAA,IACrB;AAAA,EACF,CAAC;AACL;","names":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
green,
|
|
3
4
|
red,
|
|
4
5
|
yellow
|
|
5
6
|
} from "./chunk-7BXCQKJG.js";
|
|
@@ -19,9 +20,12 @@ import {
|
|
|
19
20
|
getVitalsRendering,
|
|
20
21
|
getVitalsBattery,
|
|
21
22
|
getVitalsMemory,
|
|
23
|
+
getVitalsLmk,
|
|
22
24
|
getVitalsAnomalies,
|
|
23
25
|
searchVitalsErrors,
|
|
24
26
|
compareVitalsTrend,
|
|
27
|
+
compareVersionVitals,
|
|
28
|
+
watchVitalsWithAutoHalt,
|
|
25
29
|
checkThreshold,
|
|
26
30
|
formatOutput
|
|
27
31
|
} from "@gpc-cli/core";
|
|
@@ -197,7 +201,7 @@ function registerVitalsCommands(program) {
|
|
|
197
201
|
vitals,
|
|
198
202
|
"lmk",
|
|
199
203
|
"Query low-memory kill (stuck wakelock) metrics",
|
|
200
|
-
|
|
204
|
+
getVitalsLmk,
|
|
201
205
|
program
|
|
202
206
|
);
|
|
203
207
|
vitals.command("anomalies").description("Detect anomalies in app vitals").action(async () => {
|
|
@@ -263,8 +267,115 @@ function registerVitalsCommands(program) {
|
|
|
263
267
|
process.exit(4);
|
|
264
268
|
}
|
|
265
269
|
});
|
|
270
|
+
vitals.command("compare-versions <v1> <v2>").description("Compare vitals side-by-side for two version codes").option("--days <n>", "Number of days to query", (v) => parseInt(v, 10), 30).action(async (v1, v2, options) => {
|
|
271
|
+
const config = await loadConfig();
|
|
272
|
+
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
273
|
+
const reporting = await getReportingClient(config);
|
|
274
|
+
const format = getOutputFormat(program, config);
|
|
275
|
+
try {
|
|
276
|
+
const result = await compareVersionVitals(reporting, packageName, v1, v2, {
|
|
277
|
+
days: options.days
|
|
278
|
+
});
|
|
279
|
+
if (format === "json") {
|
|
280
|
+
console.log(formatOutput(result, format));
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const metrics = [
|
|
284
|
+
["crashRate", "Crash Rate"],
|
|
285
|
+
["anrRate", "ANR Rate"],
|
|
286
|
+
["slowStartRate", "Slow Start Rate"],
|
|
287
|
+
["slowRenderingRate", "Slow Rendering Rate"]
|
|
288
|
+
];
|
|
289
|
+
console.log(`
|
|
290
|
+
Version Comparison \u2014 ${packageName}`);
|
|
291
|
+
console.log(`${"\u2500".repeat(60)}`);
|
|
292
|
+
console.log(`${"Metric".padEnd(22)} ${"v" + v1.padEnd(14)} ${"v" + v2.padEnd(14)} Change`);
|
|
293
|
+
console.log(`${"\u2500".repeat(60)}`);
|
|
294
|
+
for (const [key, label] of metrics) {
|
|
295
|
+
const val1 = result.v1[key];
|
|
296
|
+
const val2 = result.v2[key];
|
|
297
|
+
const s1 = val1 !== void 0 ? (val1 * 100).toFixed(3) + "%" : "N/A";
|
|
298
|
+
const s2 = val2 !== void 0 ? (val2 * 100).toFixed(3) + "%" : "N/A";
|
|
299
|
+
const isRegression = result.regressions.includes(key);
|
|
300
|
+
const change = val1 !== void 0 && val2 !== void 0 ? (val2 - val1) / val1 * 100 : void 0;
|
|
301
|
+
const changeStr = change !== void 0 ? (change > 0 ? "+" : "") + change.toFixed(1) + "%" : "N/A";
|
|
302
|
+
const colorFn = isRegression ? red : change !== void 0 && change < -1 ? green : (s) => s;
|
|
303
|
+
console.log(
|
|
304
|
+
`${label.padEnd(22)} ${s1.padEnd(15)} ${colorFn(s2.padEnd(15))} ${colorFn(changeStr)}`
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
if (result.regressions.length > 0) {
|
|
308
|
+
console.log(`
|
|
309
|
+
${red("\u2717")} Regressions detected: ${result.regressions.join(", ")}`);
|
|
310
|
+
} else {
|
|
311
|
+
console.log(`
|
|
312
|
+
${green("\u2713")} No regressions detected.`);
|
|
313
|
+
}
|
|
314
|
+
} catch (error) {
|
|
315
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
316
|
+
process.exit(4);
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
vitals.command("watch").description("Monitor vitals continuously and optionally auto-halt rollout on breach").requiredOption("--threshold <value>", "Breach threshold value", parseFloat).option("--metric <name>", "Metric to monitor (crashes, anr, startup, rendering, battery, memory)", "crashes").option("--interval <seconds>", "Polling interval in seconds", (v) => parseInt(v, 10), 300).option("--auto-halt-rollout", "Automatically halt rollout if threshold is breached").option("--track <name>", "Track to halt rollout on (required with --auto-halt-rollout)").action(async (options) => {
|
|
320
|
+
const metricSet = METRIC_MAP[options.metric];
|
|
321
|
+
if (!metricSet) {
|
|
322
|
+
console.error(
|
|
323
|
+
`Error: Unknown metric "${options.metric}". Use: ${Object.keys(METRIC_MAP).join(", ")}`
|
|
324
|
+
);
|
|
325
|
+
process.exit(2);
|
|
326
|
+
}
|
|
327
|
+
if (options.autoHaltRollout && !options.track) {
|
|
328
|
+
console.error("Error: --track <name> is required when using --auto-halt-rollout");
|
|
329
|
+
process.exit(2);
|
|
330
|
+
}
|
|
331
|
+
const config = await loadConfig();
|
|
332
|
+
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
333
|
+
const reporting = await getReportingClient(config);
|
|
334
|
+
const intervalMs = options.interval * 1e3;
|
|
335
|
+
console.log(`Watching ${options.metric} for ${packageName}`);
|
|
336
|
+
console.log(`Threshold: ${options.threshold} Interval: ${options.interval}s`);
|
|
337
|
+
if (options.autoHaltRollout) {
|
|
338
|
+
console.log(`Auto-halt enabled on track: ${options.track}`);
|
|
339
|
+
}
|
|
340
|
+
console.log("Press Ctrl+C to stop.\n");
|
|
341
|
+
const stop = watchVitalsWithAutoHalt(reporting, packageName, {
|
|
342
|
+
intervalMs,
|
|
343
|
+
threshold: options.threshold,
|
|
344
|
+
metricSet,
|
|
345
|
+
onPoll: (value, breached) => {
|
|
346
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
347
|
+
const valStr = value !== void 0 ? (value * 100).toFixed(3) + "%" : "N/A";
|
|
348
|
+
const indicator = breached ? red("\u2717 BREACH") : green("\u2713 OK");
|
|
349
|
+
console.log(`[${ts}] ${options.metric}: ${valStr} \u2014 ${indicator}`);
|
|
350
|
+
},
|
|
351
|
+
onHalt: options.autoHaltRollout ? async (value) => {
|
|
352
|
+
console.error(
|
|
353
|
+
`
|
|
354
|
+
${red("\u2717")} Threshold breached (${(value * 100).toFixed(3)}% > ${options.threshold}%). Halting rollout on track "${options.track}"...`
|
|
355
|
+
);
|
|
356
|
+
try {
|
|
357
|
+
const { resolveAuth: resolveAuth2 } = await import("@gpc-cli/auth");
|
|
358
|
+
const { createApiClient } = await import("@gpc-cli/api");
|
|
359
|
+
const { updateRollout } = await import("@gpc-cli/core");
|
|
360
|
+
const auth = await resolveAuth2({ serviceAccountPath: config.auth?.serviceAccount });
|
|
361
|
+
const apiClient = createApiClient({ auth });
|
|
362
|
+
await updateRollout(apiClient, packageName, options.track, 0);
|
|
363
|
+
console.error(`${red("\u26A0")} Rollout halted on track "${options.track}".`);
|
|
364
|
+
} catch (err) {
|
|
365
|
+
console.error(`Failed to halt rollout: ${err instanceof Error ? err.message : String(err)}`);
|
|
366
|
+
}
|
|
367
|
+
stop();
|
|
368
|
+
process.exit(6);
|
|
369
|
+
} : void 0
|
|
370
|
+
});
|
|
371
|
+
process.on("SIGINT", () => {
|
|
372
|
+
stop();
|
|
373
|
+
console.log("\nWatch stopped.");
|
|
374
|
+
process.exit(0);
|
|
375
|
+
});
|
|
376
|
+
});
|
|
266
377
|
}
|
|
267
378
|
export {
|
|
268
379
|
registerVitalsCommands
|
|
269
380
|
};
|
|
270
|
-
//# sourceMappingURL=vitals-
|
|
381
|
+
//# sourceMappingURL=vitals-LFL75LA6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/vitals.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport type { GpcConfig } from \"@gpc-cli/config\";\nimport { loadConfig } from \"@gpc-cli/config\";\nimport { resolveAuth } from \"@gpc-cli/auth\";\nimport { createReportingClient } from \"@gpc-cli/api\";\nimport type { ReportingDimension } from \"@gpc-cli/api\";\nimport type { VitalsMetricSet } from \"@gpc-cli/api\";\nimport {\n getVitalsOverview,\n getVitalsCrashes,\n getVitalsAnr,\n getVitalsStartup,\n getVitalsRendering,\n getVitalsBattery,\n getVitalsMemory,\n getVitalsLmk,\n getVitalsAnomalies,\n searchVitalsErrors,\n compareVitalsTrend,\n compareVersionVitals,\n watchVitalsWithAutoHalt,\n checkThreshold,\n formatOutput,\n} from \"@gpc-cli/core\";\nimport { getOutputFormat } from \"../format.js\";\nimport { red, yellow, green } from \"../colors.js\";\n\nfunction resolvePackageName(packageArg: string | undefined, config: GpcConfig): string {\n const name = packageArg || config.app;\n if (!name) {\n console.error(\"Error: No package name. Use --app <package> or gpc config set app <package>\");\n process.exit(2);\n }\n return name;\n}\n\nasync function getReportingClient(config: GpcConfig) {\n const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });\n return createReportingClient({ auth });\n}\n\nconst VALID_DIMENSIONS: ReportingDimension[] = [\n \"apiLevel\",\n \"versionCode\",\n \"deviceModel\",\n \"deviceType\",\n \"countryCode\",\n \"deviceRamBucket\",\n \"deviceSocName\",\n \"deviceCpuMakeModel\",\n \"deviceGlEsVersion\",\n \"deviceVulkanVersion\",\n \"deviceOpenGlVersion\",\n \"deviceBrand\",\n];\n\nconst THRESHOLD_CONFIG_KEYS: Record<string, string> = {\n crashes: \"crashRate\",\n anr: \"anrRate\",\n startup: \"slowStartRate\",\n rendering: \"slowRenderingRate\",\n battery: \"excessiveWakeupRate\",\n memory: \"stuckWakelockRate\",\n wakeup: \"excessiveWakeupRate\",\n lmk: \"stuckWakelockRate\",\n};\n\nfunction validateDimension(dim: string): ReportingDimension {\n if (!VALID_DIMENSIONS.includes(dim as ReportingDimension)) {\n console.error(`Error: Invalid dimension \"${dim}\".`);\n console.error(`Valid dimensions: ${VALID_DIMENSIONS.join(\", \")}`);\n process.exit(2);\n }\n return dim as ReportingDimension;\n}\n\ntype MetricFn = typeof getVitalsCrashes;\n\nfunction registerMetricCommand(\n parent: Command,\n name: string,\n description: string,\n fn: MetricFn,\n program: Command,\n): void {\n parent\n .command(name)\n .description(description)\n .option(\"--dim <dimension>\", \"Group by dimension\")\n .option(\"--days <n>\", \"Number of days to query\", parseInt)\n .option(\"--threshold <value>\", \"Threshold value for CI alerting\", parseFloat)\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const reporting = await getReportingClient(config);\n const format = getOutputFormat(program, config);\n\n try {\n const result = await fn(reporting, packageName, {\n dimension: options.dim ? validateDimension(options.dim) : undefined,\n days: options.days,\n });\n if (format !== \"json\" && (!result.rows || result.rows.length === 0)) {\n console.log(`${yellow(\"⚠\")} No vitals data available.`);\n return;\n }\n if (format !== \"json\" && result.rows) {\n const rows = result.rows.map((row: Record<string, unknown>) => {\n const startTime = row[\"startTime\"] as Record<string, unknown> | undefined;\n const metrics = row[\"metrics\"] as Record<string, Record<string, unknown>> | undefined;\n const flat: Record<string, unknown> = {\n date: startTime ? `${startTime[\"year\"]}-${String(startTime[\"month\"]).padStart(2, \"0\")}-${String(startTime[\"day\"]).padStart(2, \"0\")}` : \"-\",\n };\n if (metrics) {\n for (const [key, val] of Object.entries(metrics)) {\n flat[key] = val?.[\"decimalValue\"]?.[\"value\"] ?? \"-\";\n }\n }\n const dims = row[\"dimensions\"] as Record<string, unknown> | undefined;\n if (dims) {\n for (const [key, val] of Object.entries(dims)) {\n flat[key] = (val as Record<string, unknown>)?.[\"stringValue\"] ?? \"-\";\n }\n }\n return flat;\n });\n console.log(formatOutput(rows, format));\n } else {\n console.log(formatOutput(result, format));\n }\n\n // Check threshold from flag or config\n const configKey = THRESHOLD_CONFIG_KEYS[name];\n const configThreshold = configKey\n ? (config as Record<string, unknown>)[\"vitals\"]\n ? ((config as Record<string, unknown>)[\"vitals\"] as Record<string, unknown>)[\"thresholds\"]\n ? (((config as Record<string, unknown>)[\"vitals\"] as Record<string, unknown>)[\"thresholds\"] as Record<string, unknown>)[configKey]\n : undefined\n : undefined\n : undefined;\n const threshold = options.threshold ?? (configThreshold !== undefined ? Number(configThreshold) : undefined);\n if (threshold !== undefined) {\n const latestRow = result.rows?.[result.rows.length - 1];\n const metricKeys = latestRow?.metrics ? Object.keys(latestRow.metrics) : [];\n const firstMetric = metricKeys[0];\n const value = firstMetric\n ? Number(latestRow?.metrics[firstMetric]?.decimalValue?.value)\n : undefined;\n const check = checkThreshold(value, threshold);\n if (check.breached) {\n console.error(`${red(\"✗\")} Threshold breached: ${check.value} > ${check.threshold}`);\n process.exit(6);\n }\n }\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n}\n\nexport function registerVitalsCommands(program: Command): void {\n const vitals = program\n .command(\"vitals\")\n .description(\"Monitor app vitals, crash rates, and performance metrics\");\n\n vitals\n .command(\"overview\")\n .description(\"Dashboard summary of all vital metrics\")\n .action(async () => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const reporting = await getReportingClient(config);\n const format = getOutputFormat(program, config);\n\n try {\n const result = await getVitalsOverview(reporting, packageName);\n if (Object.keys(result).length === 0) {\n if (format === \"json\") {\n console.log(formatOutput({ vitals: [], message: \"No vitals data available\" }, format));\n } else {\n console.log(\"No vitals data available.\");\n }\n return;\n }\n if (format !== \"json\") {\n const overview = result as Record<string, unknown>;\n const rows = Object.entries(overview).map(([metric, data]) => {\n const metricRows = data as Record<string, unknown>[] | undefined;\n const latest = metricRows?.[metricRows.length - 1];\n const metrics = latest?.[\"metrics\"] as Record<string, Record<string, unknown>> | undefined;\n const firstKey = metrics ? Object.keys(metrics)[0] : undefined;\n const value = firstKey ? metrics?.[firstKey]?.[\"decimalValue\"]?.[\"value\"] : undefined;\n return {\n metric,\n dataPoints: metricRows?.length || 0,\n latestValue: value ?? \"-\",\n };\n });\n console.log(formatOutput(rows, format));\n } else {\n console.log(formatOutput(result, format));\n }\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n registerMetricCommand(vitals, \"crashes\", \"Query crash rate metrics\", getVitalsCrashes, program);\n registerMetricCommand(vitals, \"anr\", \"Query ANR rate metrics\", getVitalsAnr, program);\n registerMetricCommand(vitals, \"startup\", \"Query slow startup metrics\", getVitalsStartup, program);\n registerMetricCommand(\n vitals,\n \"rendering\",\n \"Query slow rendering metrics\",\n getVitalsRendering,\n program,\n );\n registerMetricCommand(\n vitals,\n \"battery\",\n \"Query excessive wakeup metrics\",\n getVitalsBattery,\n program,\n );\n registerMetricCommand(vitals, \"memory\", \"Query stuck wakelock metrics\", getVitalsMemory, program);\n registerMetricCommand(\n vitals,\n \"wakeup\",\n \"Query excessive wakeup rate metrics\",\n getVitalsBattery,\n program,\n );\n registerMetricCommand(\n vitals,\n \"lmk\",\n \"Query low-memory kill (stuck wakelock) metrics\",\n getVitalsLmk,\n program,\n );\n\n vitals\n .command(\"anomalies\")\n .description(\"Detect anomalies in app vitals\")\n .action(async () => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const reporting = await getReportingClient(config);\n const format = getOutputFormat(program, config);\n\n try {\n const result = await getVitalsAnomalies(reporting, packageName);\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n const errors = vitals.command(\"errors\").description(\"Search and view error issues\");\n\n errors\n .command(\"search\")\n .description(\"Search error issues\")\n .option(\"--filter <text>\", \"Filter expression\")\n .option(\"--max <n>\", \"Maximum results\", parseInt)\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const reporting = await getReportingClient(config);\n const format = getOutputFormat(program, config);\n\n try {\n const result = await searchVitalsErrors(reporting, packageName, {\n filter: options.filter,\n maxResults: options.max,\n });\n const issues = (result as Record<string, unknown>)[\"errorIssues\"] as unknown[] | undefined;\n if (format !== \"json\" && (!issues || issues.length === 0)) {\n console.log(\"No error issues found.\");\n return;\n }\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n const METRIC_MAP: Record<string, VitalsMetricSet> = {\n crashes: \"crashRateMetricSet\",\n anr: \"anrRateMetricSet\",\n startup: \"slowStartRateMetricSet\",\n rendering: \"slowRenderingRateMetricSet\",\n battery: \"excessiveWakeupRateMetricSet\",\n memory: \"stuckBackgroundWakelockRateMetricSet\",\n };\n\n vitals\n .command(\"compare <metric>\")\n .description(\"Compare metric trend: this period vs previous period\")\n .option(\"--days <n>\", \"Period length in days\", (v) => parseInt(v, 10), 7)\n .action(async (metric: string, options) => {\n const metricSet = METRIC_MAP[metric];\n if (!metricSet) {\n console.error(\n `Error: Unknown metric \"${metric}\". Use: ${Object.keys(METRIC_MAP).join(\", \")}`,\n );\n process.exit(2);\n }\n\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const reporting = await getReportingClient(config);\n const format = getOutputFormat(program, config);\n\n try {\n const result = await compareVitalsTrend(reporting, packageName, metricSet, options.days);\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n vitals\n .command(\"compare-versions <v1> <v2>\")\n .description(\"Compare vitals side-by-side for two version codes\")\n .option(\"--days <n>\", \"Number of days to query\", (v) => parseInt(v, 10), 30)\n .action(async (v1: string, v2: string, options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const reporting = await getReportingClient(config);\n const format = getOutputFormat(program, config);\n\n try {\n const result = await compareVersionVitals(reporting, packageName, v1, v2, {\n days: options.days,\n });\n\n if (format === \"json\") {\n console.log(formatOutput(result, format));\n return;\n }\n\n const metrics: [keyof typeof result.v1, string][] = [\n [\"crashRate\", \"Crash Rate\"],\n [\"anrRate\", \"ANR Rate\"],\n [\"slowStartRate\", \"Slow Start Rate\"],\n [\"slowRenderingRate\", \"Slow Rendering Rate\"],\n ];\n\n console.log(`\\nVersion Comparison — ${packageName}`);\n console.log(`${\"─\".repeat(60)}`);\n console.log(`${\"Metric\".padEnd(22)} ${\"v\" + v1.padEnd(14)} ${\"v\" + v2.padEnd(14)} Change`);\n console.log(`${\"─\".repeat(60)}`);\n\n for (const [key, label] of metrics) {\n const val1 = result.v1[key];\n const val2 = result.v2[key];\n const s1 = val1 !== undefined ? (val1 * 100).toFixed(3) + \"%\" : \"N/A\";\n const s2 = val2 !== undefined ? (val2 * 100).toFixed(3) + \"%\" : \"N/A\";\n const isRegression = result.regressions.includes(key as string);\n const change =\n val1 !== undefined && val2 !== undefined\n ? ((val2 - val1) / val1) * 100\n : undefined;\n const changeStr =\n change !== undefined\n ? (change > 0 ? \"+\" : \"\") + change.toFixed(1) + \"%\"\n : \"N/A\";\n const colorFn = isRegression ? red : change !== undefined && change < -1 ? green : (s: string) => s;\n console.log(\n `${label.padEnd(22)} ${s1.padEnd(15)} ${colorFn(s2.padEnd(15))} ${colorFn(changeStr)}`,\n );\n }\n\n if (result.regressions.length > 0) {\n console.log(`\\n${red(\"✗\")} Regressions detected: ${result.regressions.join(\", \")}`);\n } else {\n console.log(`\\n${green(\"✓\")} No regressions detected.`);\n }\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n vitals\n .command(\"watch\")\n .description(\"Monitor vitals continuously and optionally auto-halt rollout on breach\")\n .requiredOption(\"--threshold <value>\", \"Breach threshold value\", parseFloat)\n .option(\"--metric <name>\", \"Metric to monitor (crashes, anr, startup, rendering, battery, memory)\", \"crashes\")\n .option(\"--interval <seconds>\", \"Polling interval in seconds\", (v) => parseInt(v, 10), 300)\n .option(\"--auto-halt-rollout\", \"Automatically halt rollout if threshold is breached\")\n .option(\"--track <name>\", \"Track to halt rollout on (required with --auto-halt-rollout)\")\n .action(async (options) => {\n const metricSet = METRIC_MAP[options.metric as string];\n if (!metricSet) {\n console.error(\n `Error: Unknown metric \"${options.metric}\". Use: ${Object.keys(METRIC_MAP).join(\", \")}`,\n );\n process.exit(2);\n }\n\n if (options.autoHaltRollout && !options.track) {\n console.error(\"Error: --track <name> is required when using --auto-halt-rollout\");\n process.exit(2);\n }\n\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const reporting = await getReportingClient(config);\n const intervalMs = (options.interval as number) * 1000;\n\n console.log(`Watching ${options.metric} for ${packageName}`);\n console.log(`Threshold: ${options.threshold} Interval: ${options.interval}s`);\n if (options.autoHaltRollout) {\n console.log(`Auto-halt enabled on track: ${options.track}`);\n }\n console.log(\"Press Ctrl+C to stop.\\n\");\n\n const stop = watchVitalsWithAutoHalt(reporting, packageName, {\n intervalMs,\n threshold: options.threshold as number,\n metricSet,\n onPoll: (value, breached) => {\n const ts = new Date().toISOString();\n const valStr = value !== undefined ? (value * 100).toFixed(3) + \"%\" : \"N/A\";\n const indicator = breached ? red(\"✗ BREACH\") : green(\"✓ OK\");\n console.log(`[${ts}] ${options.metric}: ${valStr} — ${indicator}`);\n },\n onHalt: options.autoHaltRollout\n ? async (value: number) => {\n console.error(\n `\\n${red(\"✗\")} Threshold breached (${(value * 100).toFixed(3)}% > ${options.threshold}%). Halting rollout on track \"${options.track}\"...`,\n );\n try {\n const { resolveAuth } = await import(\"@gpc-cli/auth\");\n const { createApiClient } = await import(\"@gpc-cli/api\");\n const { updateRollout } = await import(\"@gpc-cli/core\");\n const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });\n const apiClient = createApiClient({ auth });\n await updateRollout(apiClient, packageName, options.track as string, 0);\n console.error(`${red(\"⚠\")} Rollout halted on track \"${options.track}\".`);\n } catch (err) {\n console.error(`Failed to halt rollout: ${err instanceof Error ? err.message : String(err)}`);\n }\n stop();\n process.exit(6);\n }\n : undefined,\n });\n\n process.on(\"SIGINT\", () => {\n stop();\n console.log(\"\\nWatch stopped.\");\n process.exit(0);\n });\n });\n}\n"],"mappings":";;;;;;;;;;;AAEA,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAGtC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAIP,SAAS,mBAAmB,YAAgC,QAA2B;AACrF,QAAM,OAAO,cAAc,OAAO;AAClC,MAAI,CAAC,MAAM;AACT,YAAQ,MAAM,6EAA6E;AAC3F,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,SAAO;AACT;AAEA,eAAe,mBAAmB,QAAmB;AACnD,QAAM,OAAO,MAAM,YAAY,EAAE,oBAAoB,OAAO,MAAM,eAAe,CAAC;AAClF,SAAO,sBAAsB,EAAE,KAAK,CAAC;AACvC;AAEA,IAAM,mBAAyC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,wBAAgD;AAAA,EACpD,SAAS;AAAA,EACT,KAAK;AAAA,EACL,SAAS;AAAA,EACT,WAAW;AAAA,EACX,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,KAAK;AACP;AAEA,SAAS,kBAAkB,KAAiC;AAC1D,MAAI,CAAC,iBAAiB,SAAS,GAAyB,GAAG;AACzD,YAAQ,MAAM,6BAA6B,GAAG,IAAI;AAClD,YAAQ,MAAM,qBAAqB,iBAAiB,KAAK,IAAI,CAAC,EAAE;AAChE,YAA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E;AAAA,MACnE;AAAA,MACA,QAAQ,QAAQ,kBACZ,OAAO,UAAkB;AACvB,gBAAQ;AAAA,UACN;AAAA,EAAK,IAAI,QAAG,CAAC,yBAAyB,QAAQ,KAAK,QAAQ,CAAC,CAAC,OAAO,QAAQ,SAAS,iCAAiC,QAAQ,KAAK;AAAA,QACrI;AACA,YAAI;AACF,gBAAM,EAAE,aAAAA,aAAY,IAAI,MAAM,OAAO,eAAe;AACpD,gBAAM,EAAE,gBAAgB,IAAI,MAAM,OAAO,cAAc;AACvD,gBAAM,EAAE,cAAc,IAAI,MAAM,OAAO,eAAe;AACtD,gBAAM,OAAO,MAAMA,aAAY,EAAE,oBAAoB,OAAO,MAAM,eAAe,CAAC;AAClF,gBAAM,YAAY,gBAAgB,EAAE,KAAK,CAAC;AAC1C,gBAAM,cAAc,WAAW,aAAa,QAAQ,OAAiB,CAAC;AACtE,kBAAQ,MAAM,GAAG,IAAI,QAAG,CAAC,6BAA6B,QAAQ,KAAK,IAAI;AAAA,QACzE,SAAS,KAAK;AACZ,kBAAQ,MAAM,2BAA2B,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC,EAAE;AAAA,QAC7F;AACA,aAAK;AACL,gBAAQ,KAAK,CAAC;AAAA,MAChB,IACA;AAAA,IACN,CAAC;AAED,YAAQ,GAAG,UAAU,MAAM;AACzB,WAAK;AACL,cAAQ,IAAI,kBAAkB;AAC9B,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAAA,EACH,CAAC;AACL;","names":["resolveAuth"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gpc-cli/cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.35",
|
|
4
4
|
"description": "GPC — Google Play Console CLI. 187 API endpoints, one tool.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"commander": "^14.0.3",
|
|
22
|
-
"@gpc-cli/api": "1.0.
|
|
22
|
+
"@gpc-cli/api": "1.0.19",
|
|
23
23
|
"@gpc-cli/auth": "^0.9.10",
|
|
24
24
|
"@gpc-cli/config": "0.9.9",
|
|
25
|
-
"@gpc-cli/
|
|
26
|
-
"@gpc-cli/
|
|
25
|
+
"@gpc-cli/core": "0.9.29",
|
|
26
|
+
"@gpc-cli/plugin-sdk": "0.9.7"
|
|
27
27
|
},
|
|
28
28
|
"keywords": [
|
|
29
29
|
"google-play",
|
|
@@ -48,6 +48,10 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/node": "^25.3.5"
|
|
50
50
|
},
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "https://github.com/yasserstudio/gpc"
|
|
54
|
+
},
|
|
51
55
|
"scripts": {
|
|
52
56
|
"build": "tsup",
|
|
53
57
|
"dev": "tsup --watch",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/auth.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { resolveAuth, loadServiceAccountKey, clearTokenCache, AuthError } from \"@gpc-cli/auth\";\nimport { loadConfig, getCacheDir } from \"@gpc-cli/config\";\nimport { formatOutput } from \"@gpc-cli/core\";\nimport { getOutputFormat } from \"../format.js\";\n\nexport function registerAuthCommands(program: Command): void {\n const auth = program.command(\"auth\").description(\"Manage authentication\");\n\n auth\n .command(\"login\")\n .description(\"Authenticate with Google Play Developer API\")\n .option(\"--service-account <path>\", \"Path to service account JSON key file\")\n .option(\"--adc\", \"Use Application Default Credentials\")\n .option(\"--profile <name>\", \"Store credentials under a named profile\")\n .action(async (options: { serviceAccount?: string; adc?: boolean; profile?: string }) => {\n try {\n if (options.serviceAccount) {\n const key = await loadServiceAccountKey(options.serviceAccount);\n\n if (options.profile) {\n const { setProfileConfig } = await import(\"@gpc-cli/config\");\n await setProfileConfig(options.profile, {\n auth: { serviceAccount: options.serviceAccount },\n });\n console.log(`Profile \"${options.profile}\" configured with ${key.client_email}`);\n } else {\n const { setConfigValue } = await import(\"@gpc-cli/config\");\n await setConfigValue(\"auth.serviceAccount\", options.serviceAccount);\n console.log(`Authenticated as ${key.client_email}`);\n }\n console.log(`Project: ${key.project_id}`);\n } else if (options.adc) {\n const client = await resolveAuth();\n console.log(`Authenticated via Application Default Credentials`);\n console.log(`Account: ${client.getClientEmail()}`);\n } else {\n console.log(\"Usage: gpc auth login --service-account <path>\");\n console.log(\"\");\n console.log(\"Authentication methods:\");\n console.log(\" --service-account <path> Service account JSON key file\");\n console.log(\" --adc Application Default Credentials\");\n console.log(\"\");\n console.log(\"Options:\");\n console.log(\" --profile <name> Store under a named profile\");\n }\n } catch (error) {\n if (error instanceof AuthError) {\n console.error(`Error: ${error.message}`);\n if (error.suggestion) console.error(`Suggestion: ${error.suggestion}`);\n process.exit(3);\n }\n throw error;\n }\n });\n\n auth\n .command(\"status\")\n .description(\"Show current authentication status\")\n .action(async () => {\n const config = await loadConfig();\n try {\n const client = await resolveAuth({\n serviceAccountPath: config.auth?.serviceAccount,\n cachePath: getCacheDir(),\n });\n const format = getOutputFormat(program, config);\n const data = {\n authenticated: true,\n account: client.getClientEmail(),\n project: client.getProjectId(),\n ...(config.profile && { profile: config.profile }),\n };\n console.log(formatOutput(data, format));\n } catch (error) {\n if (error instanceof AuthError) {\n const format = getOutputFormat(program, config);\n const data = {\n authenticated: false,\n error: error.message,\n suggestion: error.suggestion,\n };\n console.log(formatOutput(data, format));\n process.exit(3);\n }\n throw error;\n }\n });\n\n auth\n .command(\"logout\")\n .description(\"Clear stored credentials and token cache\")\n .action(async () => {\n const { setConfigValue } = await import(\"@gpc-cli/config\");\n await setConfigValue(\"auth.serviceAccount\", \"\");\n await clearTokenCache(getCacheDir());\n console.log(\"Credentials and token cache cleared.\");\n });\n\n auth\n .command(\"whoami\")\n .description(\"Show current authenticated identity\")\n .action(async () => {\n try {\n const config = await loadConfig();\n const client = await resolveAuth({\n serviceAccountPath: config.auth?.serviceAccount,\n cachePath: getCacheDir(),\n });\n console.log(client.getClientEmail());\n } catch {\n console.error(\"Not authenticated. Run: gpc auth login\");\n process.exit(3);\n }\n });\n\n auth\n .command(\"switch <profile>\")\n .description(\"Switch to a named profile\")\n .action(async (profile: string) => {\n try {\n // Verify profile exists\n const config = await loadConfig({ profile });\n const { setConfigValue } = await import(\"@gpc-cli/config\");\n await setConfigValue(\"profile\", profile);\n console.log(`Switched to profile \"${profile}\"`);\n if (config.auth?.serviceAccount) {\n console.log(`Service account: ${config.auth.serviceAccount}`);\n }\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(2);\n }\n });\n\n auth\n .command(\"token\")\n .description(\"Print the current access token (useful for manual API calls)\")\n .action(async () => {\n try {\n const config = await loadConfig();\n const authClient = await resolveAuth({\n serviceAccountPath: config.auth?.serviceAccount,\n cachePath: getCacheDir(),\n });\n const token = await authClient.getAccessToken();\n console.log(token);\n } catch (error) {\n if (error instanceof AuthError) {\n console.error(`Error: ${error.message}`);\n process.exit(3);\n }\n throw error;\n }\n });\n\n auth\n .command(\"profiles\")\n .description(\"List configured profiles\")\n .action(async () => {\n const { listProfiles } = await import(\"@gpc-cli/config\");\n const config = await loadConfig();\n const profiles = await listProfiles();\n const format = getOutputFormat(program, config);\n\n if (profiles.length === 0) {\n console.log(\n \"No profiles configured. Use: gpc auth login --service-account <path> --profile <name>\",\n );\n return;\n }\n\n const data = profiles.map((name) => ({\n name,\n active: name === config.profile,\n }));\n console.log(formatOutput(data, format));\n });\n}\n"],"mappings":";;;;;;AACA,SAAS,aAAa,uBAAuB,iBAAiB,iBAAiB;AAC/E,SAAS,YAAY,mBAAmB;AACxC,SAAS,oBAAoB;AAGtB,SAAS,qBAAqB,SAAwB;AAC3D,QAAM,OAAO,QAAQ,QAAQ,MAAM,EAAE,YAAY,uBAAuB;AAExE,OACG,QAAQ,OAAO,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AACvD,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,WAAW,MAAM,aAAa;AACpC,UAAM,SAAS,gBAAgB,SAAS,MAAM;AAE9C,QAAI,SAAS,WAAW,GAAG;AACzB,cAAQ;AAAA,QACN;AAAA,MACF;AACA;AAAA,IACF;AAEA,UAAM,OAAO,SAAS,IAAI,CAAC,UAAU;AAAA,MACnC;AAAA,MACA,QAAQ,SAAS,OAAO;AAAA,IAC1B,EAAE;AACF,YAAQ,IAAI,aAAa,MAAM,MAAM,CAAC;AAAA,EACxC,CAAC;AACL;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/bundle.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport {\n analyzeBundle,\n compareBundles,\n formatOutput,\n} from \"@gpc-cli/core\";\nimport { getOutputFormat } from \"../format.js\";\n\nfunction formatSize(bytes: number): string {\n const abs = Math.abs(bytes);\n const sign = bytes < 0 ? \"-\" : \"\";\n if (abs < 1024) return `${sign}${abs} B`;\n if (abs < 1024 * 1024) return `${sign}${(abs / 1024).toFixed(1)} KB`;\n return `${sign}${(abs / (1024 * 1024)).toFixed(2)} MB`;\n}\n\nfunction formatDelta(delta: number): string {\n const prefix = delta > 0 ? \"+\" : \"\";\n return `${prefix}${formatSize(delta)}`;\n}\n\nexport function registerBundleCommands(program: Command): void {\n const bundle = program.command(\"bundle\").description(\"Analyze app bundles and APKs\");\n\n bundle\n .command(\"analyze <file>\")\n .description(\"Analyze size breakdown of an AAB or APK\")\n .option(\"--threshold <mb>\", \"Fail if compressed size exceeds threshold (MB)\", parseFloat)\n .action(async (file: string, opts: { threshold?: number }) => {\n const format = getOutputFormat(program, await getConfig());\n\n try {\n const analysis = await analyzeBundle(file);\n\n if (format === \"json\") {\n console.log(formatOutput(analysis, format));\n } else if (format === \"markdown\") {\n const moduleRows = analysis.modules.map((m) => ({\n module: m.name,\n compressed: formatSize(m.compressedSize),\n uncompressed: formatSize(m.uncompressedSize),\n entries: m.entries,\n }));\n const categoryRows = analysis.categories.map((c) => ({\n category: c.name,\n compressed: formatSize(c.compressedSize),\n uncompressed: formatSize(c.uncompressedSize),\n entries: c.entries,\n }));\n console.log(`## Bundle Analysis: \\`${analysis.filePath}\\``);\n console.log();\n console.log(`| Property | Value |`);\n console.log(`| --- | --- |`);\n console.log(`| Type | ${analysis.fileType.toUpperCase()} |`);\n console.log(`| Total compressed | ${formatSize(analysis.totalCompressed)} |`);\n console.log(`| Total uncompressed | ${formatSize(analysis.totalUncompressed)} |`);\n console.log(`| Entries | ${analysis.entryCount} |`);\n console.log();\n console.log(`### Modules`);\n console.log();\n console.log(formatOutput(moduleRows, \"markdown\"));\n console.log();\n console.log(`### Categories`);\n console.log();\n console.log(formatOutput(categoryRows, \"markdown\"));\n } else {\n console.log(`\\nFile: ${analysis.filePath}`);\n console.log(`Type: ${analysis.fileType.toUpperCase()}`);\n console.log(`Total compressed: ${formatSize(analysis.totalCompressed)}`);\n console.log(`Total uncompressed: ${formatSize(analysis.totalUncompressed)}`);\n console.log(`Entries: ${analysis.entryCount}\\n`);\n\n // Modules table\n const moduleRows = analysis.modules.map((m) => ({\n module: m.name,\n compressed: formatSize(m.compressedSize),\n uncompressed: formatSize(m.uncompressedSize),\n entries: m.entries,\n }));\n console.log(\"Modules:\");\n console.log(formatOutput(moduleRows, \"table\"));\n\n // Categories table\n const categoryRows = analysis.categories.map((c) => ({\n category: c.name,\n compressed: formatSize(c.compressedSize),\n uncompressed: formatSize(c.uncompressedSize),\n entries: c.entries,\n }));\n console.log(\"\\nCategories:\");\n console.log(formatOutput(categoryRows, \"table\"));\n }\n\n // Threshold check\n if (opts.threshold !== undefined) {\n const thresholdBytes = opts.threshold * 1024 * 1024;\n if (analysis.totalCompressed > thresholdBytes) {\n console.error(\n `\\nThreshold breached: ${formatSize(analysis.totalCompressed)} > ${opts.threshold} MB`,\n );\n process.exit(6);\n }\n }\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n });\n\n bundle\n .command(\"compare <file1> <file2>\")\n .description(\"Compare size differences between two bundles or APKs\")\n .action(async (file1: string, file2: string) => {\n const format = getOutputFormat(program, await getConfig());\n\n try {\n const [before, after] = await Promise.all([\n analyzeBundle(file1),\n analyzeBundle(file2),\n ]);\n const comparison = compareBundles(before, after);\n\n if (format === \"json\") {\n console.log(formatOutput(comparison, format));\n } else if (format === \"markdown\") {\n const sign = comparison.sizeDelta >= 0 ? \"+\" : \"\";\n const moduleRows = comparison.moduleDeltas\n .filter((m) => m.delta !== 0)\n .map((m) => ({\n module: m.module,\n before: formatSize(m.before),\n after: formatSize(m.after),\n delta: formatDelta(m.delta),\n }));\n const categoryRows = comparison.categoryDeltas\n .filter((c) => c.delta !== 0)\n .map((c) => ({\n category: c.category,\n before: formatSize(c.before),\n after: formatSize(c.after),\n delta: formatDelta(c.delta),\n }));\n console.log(`## Bundle Comparison`);\n console.log();\n console.log(`| | Path | Size |`);\n console.log(`| --- | --- | --- |`);\n console.log(`| Before | \\`${comparison.before.path}\\` | ${formatSize(comparison.before.totalCompressed)} |`);\n console.log(`| After | \\`${comparison.after.path}\\` | ${formatSize(comparison.after.totalCompressed)} |`);\n console.log(`| **Delta** | | **${sign}${formatSize(comparison.sizeDelta)} (${sign}${comparison.sizeDeltaPercent}%)** |`);\n if (moduleRows.length > 0) {\n console.log();\n console.log(`### Module Changes`);\n console.log();\n console.log(formatOutput(moduleRows, \"markdown\"));\n }\n if (categoryRows.length > 0) {\n console.log();\n console.log(`### Category Changes`);\n console.log();\n console.log(formatOutput(categoryRows, \"markdown\"));\n }\n } else {\n const sign = comparison.sizeDelta >= 0 ? \"+\" : \"\";\n console.log(`\\nBefore: ${comparison.before.path} (${formatSize(comparison.before.totalCompressed)})`);\n console.log(`After: ${comparison.after.path} (${formatSize(comparison.after.totalCompressed)})`);\n console.log(`Delta: ${sign}${formatSize(comparison.sizeDelta)} (${sign}${comparison.sizeDeltaPercent}%)\\n`);\n\n // Module deltas\n const moduleRows = comparison.moduleDeltas\n .filter((m) => m.delta !== 0)\n .map((m) => ({\n module: m.module,\n before: formatSize(m.before),\n after: formatSize(m.after),\n delta: formatDelta(m.delta),\n }));\n if (moduleRows.length > 0) {\n console.log(\"Module changes:\");\n console.log(formatOutput(moduleRows, \"table\"));\n }\n\n // Category deltas\n const categoryRows = comparison.categoryDeltas\n .filter((c) => c.delta !== 0)\n .map((c) => ({\n category: c.category,\n before: formatSize(c.before),\n after: formatSize(c.after),\n delta: formatDelta(c.delta),\n }));\n if (categoryRows.length > 0) {\n console.log(\"\\nCategory changes:\");\n console.log(formatOutput(categoryRows, \"table\"));\n }\n }\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n });\n}\n\nasync function getConfig() {\n const { loadConfig } = await import(\"@gpc-cli/config\");\n return loadConfig();\n}\n"],"mappings":";;;;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,WAAW,OAAuB;AACzC,QAAM,MAAM,KAAK,IAAI,KAAK;AAC1B,QAAM,OAAO,QAAQ,IAAI,MAAM;AAC/B,MAAI,MAAM,KAAM,QAAO,GAAG,IAAI,GAAG,GAAG;AACpC,MAAI,MAAM,OAAO,KAAM,QAAO,GAAG,IAAI,IAAI,MAAM,MAAM,QAAQ,CAAC,CAAC;AAC/D,SAAO,GAAG,IAAI,IAAI,OAAO,OAAO,OAAO,QAAQ,CAAC,CAAC;AACnD;AAEA,SAAS,YAAY,OAAuB;AAC1C,QAAM,SAAS,QAAQ,IAAI,MAAM;AACjC,SAAO,GAAG,MAAM,GAAG,WAAW,KAAK,CAAC;AACtC;AAEO,SAAS,uBAAuB,SAAwB;AAC7D,QAAM,SAAS,QAAQ,QAAQ,QAAQ,EAAE,YAAY,8BAA8B;AAEnF,SACG,QAAQ,gBAAgB,EACxB,YAAY,yCAAyC,EACrD,OAAO,oBAAoB,kDAAkD,UAAU,EACvF,OAAO,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,OAAO,WAAW,EAAE,KAAK;AAAA,UACzB,OAAO,YAAY,EAAE,KAAK;AAAA,QAC5B,EAAE;AACJ,YAAI,aAAa,SAAS,GAAG;AAC3B,kBAAQ,IAAI,qBAAqB;AACjC,kBAAQ,IAAI,aAAa,cAAc,OAAO,CAAC;AAAA,QACjD;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AACd,cAAQ,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE;AAChF,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AACL;AAEA,eAAe,YAAY;AACzB,QAAM,EAAE,WAAW,IAAI,MAAM,OAAO,iBAAiB;AACrD,SAAO,WAAW;AACpB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/cache.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { readdir, stat, unlink, rm } from \"node:fs/promises\";\nimport { join, extname, basename } from \"node:path\";\nimport { getCacheDir } from \"@gpc-cli/config\";\n\nconst FILE_TYPES: Record<string, (name: string) => boolean> = {\n status: (name) => name.startsWith(\"status-\") && name.endsWith(\".json\"),\n token: (name) => name === \"token-cache.json\",\n update: (name) => name === \"update-check.json\",\n};\n\nasync function getCacheFiles(cacheDir: string): Promise<{ name: string; path: string; size: number; mtime: Date }[]> {\n let entries: string[];\n try {\n entries = await readdir(cacheDir);\n } catch {\n return [];\n }\n\n const files: { name: string; path: string; size: number; mtime: Date }[] = [];\n for (const entry of entries) {\n if (!entry.endsWith(\".json\")) continue;\n const filePath = join(cacheDir, entry);\n try {\n const info = await stat(filePath);\n if (info.isFile()) {\n files.push({ name: entry, path: filePath, size: info.size, mtime: info.mtime });\n }\n } catch { /* ignore */ }\n }\n return files;\n}\n\nfunction formatBytes(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\nfunction fileType(name: string): string {\n for (const [type, matcher] of Object.entries(FILE_TYPES)) {\n if (matcher(name)) return type;\n }\n return \"other\";\n}\n\nexport function registerCacheCommand(program: Command): void {\n const cache = program.command(\"cache\").description(\"Manage local cache files\");\n\n cache\n .command(\"info\")\n .description(\"Show cache directory and total size\")\n .action(async () => {\n const cacheDir = getCacheDir();\n const files = await getCacheFiles(cacheDir);\n const totalSize = files.reduce((sum, f) => sum + f.size, 0);\n console.log(`Cache directory: ${cacheDir}`);\n console.log(`Files: ${files.length}`);\n console.log(`Total size: ${formatBytes(totalSize)}`);\n });\n\n cache\n .command(\"list\")\n .description(\"List all cache files with size and age\")\n .action(async () => {\n const cacheDir = getCacheDir();\n const files = await getCacheFiles(cacheDir);\n if (files.length === 0) {\n console.log(\"No cache files found.\");\n return;\n }\n const now = Date.now();\n for (const f of files) {\n const ageMs = now - f.mtime.getTime();\n const ageMins = Math.floor(ageMs / 60000);\n const ageStr = ageMins < 60\n ? `${ageMins}m ago`\n : ageMins < 1440\n ? `${Math.floor(ageMins / 60)}h ago`\n : `${Math.floor(ageMins / 1440)}d ago`;\n const type = fileType(f.name);\n console.log(` ${f.name} [${type}] ${formatBytes(f.size)} ${ageStr}`);\n }\n });\n\n cache\n .command(\"clear\")\n .description(\"Remove cache files\")\n .option(\"--force\", \"Skip confirmation prompt\")\n .option(\"--type <type>\", \"Remove only files of this type (status|token|update)\")\n .action(async (opts) => {\n const cacheDir = getCacheDir();\n const allFiles = await getCacheFiles(cacheDir);\n\n let toDelete = allFiles;\n if (opts.type) {\n const matcher = FILE_TYPES[opts.type];\n if (!matcher) {\n console.error(`Error: Unknown cache type \"${opts.type}\". Valid types: ${Object.keys(FILE_TYPES).join(\", \")}`);\n process.exit(2);\n }\n toDelete = allFiles.filter((f) => matcher(f.name));\n }\n\n if (toDelete.length === 0) {\n console.log(\"No cache files to remove.\");\n return;\n }\n\n if (!opts.force) {\n console.log(`About to remove ${toDelete.length} file(s) from ${cacheDir}:`);\n for (const f of toDelete) {\n console.log(` ${f.name} (${formatBytes(f.size)})`);\n }\n const { createInterface } = await import(\"node:readline\");\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n const answer = await new Promise<string>((resolve) => rl.question(\"Proceed? [y/N] \", resolve));\n rl.close();\n if (answer.toLowerCase() !== \"y\") {\n console.log(\"Aborted.\");\n return;\n }\n }\n\n let removed = 0;\n for (const f of toDelete) {\n try {\n await unlink(f.path);\n removed++;\n } catch { /* ignore */ }\n }\n console.log(`Removed ${removed} file(s).`);\n });\n}\n"],"mappings":";;;AACA,SAAS,SAAS,MAAM,cAAkB;AAC1C,SAAS,YAA+B;AACxC,SAAS,mBAAmB;AAE5B,IAAM,aAAwD;AAAA,EAC5D,QAAQ,CAAC,SAAS,KAAK,WAAW,SAAS,KAAK,KAAK,SAAS,OAAO;AAAA,EACrE,OAAO,CAAC,SAAS,SAAS;AAAA,EAC1B,QAAQ,CAAC,SAAS,SAAS;AAC7B;AAEA,eAAe,cAAc,UAAwF;AACnH,MAAI;AACJ,MAAI;AACF,cAAU,MAAM,QAAQ,QAAQ;AAAA,EAClC,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AAEA,QAAM,QAAqE,CAAC;AAC5E,aAAW,SAAS,SAAS;AAC3B,QAAI,CAAC,MAAM,SAAS,OAAO,EAAG;AAC9B,UAAM,WAAW,KAAK,UAAU,KAAK;AACrC,QAAI;AACF,YAAM,OAAO,MAAM,KAAK,QAAQ;AAChC,UAAI,KAAK,OAAO,GAAG;AACjB,cAAM,KAAK,EAAE,MAAM,OAAO,MAAM,UAAU,MAAM,KAAK,MAAM,OAAO,KAAK,MAAM,CAAC;AAAA,MAChF;AAAA,IACF,QAAQ;AAAA,IAAe;AAAA,EACzB;AACA,SAAO;AACT;AAEA,SAAS,YAAY,OAAuB;AAC1C,MAAI,QAAQ,KAAM,QAAO,GAAG,KAAK;AACjC,MAAI,QAAQ,OAAO,KAAM,QAAO,IAAI,QAAQ,M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ACxB,UAAI;AACF,cAAM,OAAO,EAAE,IAAI;AACnB;AAAA,MACF,QAAQ;AAAA,MAAe;AAAA,IACzB;AACA,YAAQ,IAAI,WAAW,OAAO,WAAW;AAAA,EAC3C,CAAC;AACL;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
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(\"GPC — Google Play Console CLI\")\n .version(process.env[\"__GPC_VERSION\"] || \"0.0.0\", \"-V, --version\")\n .option(\"-o, --output <format>\", \"Output format: table, json, yaml, markdown, junit\")\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 .option(\"--ci\", \"Force CI mode (JSON output, no prompts, strict exit codes)\")\n .option(\"-j, --json\", \"Shorthand for --output json\")\n .showSuggestionAfterError(false);\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 update: async () => {\n (await import(\"./commands/update.js\")).registerUpdateCommand(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 \"device-tiers\": async () => {\n (await import(\"./commands/device-tiers.js\")).registerDeviceTiersCommands(program);\n },\n \"one-time-products\": async () => {\n (await import(\"./commands/one-time-products.js\")).registerOneTimeProductsCommands(program);\n },\n \"internal-sharing\": async () => {\n (await import(\"./commands/internal-sharing.js\")).registerInternalSharingCommands(program);\n },\n \"generated-apks\": async () => {\n (await import(\"./commands/generated-apks.js\")).registerGeneratedApksCommands(program);\n },\n \"purchase-options\": async () => {\n (await import(\"./commands/purchase-options.js\")).registerPurchaseOptionsCommands(program);\n },\n bundle: async () => {\n (await import(\"./commands/bundle.js\")).registerBundleCommands(program);\n },\n audit: async () => {\n (await import(\"./commands/audit.js\")).registerAuditCommands(program);\n },\n migrate: async () => {\n (await import(\"./commands/migrate.js\")).registerMigrateCommands(program);\n },\n anomalies: async () => {\n (await import(\"./commands/anomalies.js\")).registerAnomaliesCommands(program);\n },\n \"install-skills\": async () => {\n (await import(\"./commands/install-skills.js\")).registerInstallSkillsCommand(program);\n },\n version: async () => {\n (await import(\"./commands/version.js\")).registerVersionCommand(program);\n },\n cache: async () => {\n (await import(\"./commands/cache.js\")).registerCacheCommand(program);\n },\n feedback: async () => {\n (await import(\"./commands/feedback.js\")).registerFeedbackCommand(program);\n },\n plugins: async () => {\n registerPluginsCommand(program, pluginManager);\n },\n };\n\n // \"Did you mean?\" suggestions for unknown commands\n function levenshtein(a: string, b: string): number {\n const m = a.length, n = b.length;\n const dp: number[][] = Array.from({ length: m + 1 }, (_, i) =>\n Array.from({ length: n + 1 }, (_, j) => (i === 0 ? j : j === 0 ? i : 0))\n );\n for (let i = 1; i <= m; i++) {\n for (let j = 1; j <= n; j++) {\n const row = dp[i]!;\n const prevRow = dp[i - 1]!;\n row[j] = a[i - 1] === b[j - 1]\n ? prevRow[j - 1]!\n : 1 + Math.min(prevRow[j]!, row[j - 1]!, prevRow[j - 1]!);\n }\n }\n return dp[m]![n]!;\n }\n\n program.on(\"command:*\", (operands: string[]) => {\n const cmd = operands[0] ?? \"\";\n const names = Object.keys(commandLoaders);\n const best = names.map(name => ({ name, d: levenshtein(cmd, name) })).sort((a, b) => a.d - b.d)[0];\n console.error(`Error: Unknown command \"${cmd}\".`);\n if (best && best.d <= 3) console.error(`Did you mean: gpc ${best.name}?`);\n console.error(`Run \"gpc --help\" to see all commands.`);\n process.exit(2);\n });\n\n // Resolve command aliases for lazy loading\n const commandAliases: Record<string, string> = {\n \"ext-txn\": \"external-transactions\",\n otp: \"one-time-products\",\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\nconst AUTH_KEYWORDS = [\"AUTH\", \"UNAUTHENTICATED\", \"PERMISSION_DENIED\", \"401\", \"403\"];\n\nfunction isAuthRelatedError(error: unknown): boolean {\n if (isTypedError(error)) {\n if (error.exitCode === 3) return true;\n if (error.code && AUTH_KEYWORDS.some((k) => error.code!.includes(k))) return true;\n }\n const msg = error instanceof Error ? error.message : String(error);\n return AUTH_KEYWORDS.some((k) => msg.includes(k));\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 const authHint = isAuthRelatedError(error)\n ? \"\\n→ Run gpc doctor to diagnose your credentials.\"\n : \"\";\n\n if (isTypedError(error)) {\n console.error(`Error [${error.code}]: ${error.message}`);\n if (error.suggestion) {\n console.error(`Suggestion: ${error.suggestion}`);\n }\n if (authHint) console.error(authHint);\n return error.exitCode ?? 1;\n }\n\n const message = error instanceof Error ? error.message : String(error);\n console.error(`Error: ${message}`);\n if (authHint) console.error(authHint);\n return 1;\n}\n"],"mappings":";;;AAAA,SAAS,eAAe,uBAAuB;AAS/C,eAAsB,cAAsC;AAC1D,QAAM,UA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|
|
|
1
|
-
{"version":3,"sources":["../src/commands/config.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { loadConfig, setConfigValue, getUserConfigPath, initConfig } from \"@gpc-cli/config\";\nimport type { GpcConfig } from \"@gpc-cli/config\";\nimport { formatOutput, writeAuditLog, createAuditEntry } from \"@gpc-cli/core\";\nimport { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { getOutputFormat } from \"../format.js\";\nimport { isInteractive, promptInput, promptSelect, promptConfirm } from \"../prompt.js\";\n\nconst ANDROID_PACKAGE_RE = /^[a-zA-Z][a-zA-Z0-9_]*(\\.[a-zA-Z][a-zA-Z0-9_]*)+$/;\n\nexport function registerConfigCommands(program: Command): void {\n const config = program.command(\"config\").description(\"Manage configuration\");\n\n config\n .command(\"init\")\n .description(\"Create a configuration file\")\n .option(\"--global\", \"Create in user config directory (~/.config/gpc/)\")\n .action(async (_options: { global?: boolean }) => {\n const initialConfig: Record<string, unknown> = {};\n\n if (isInteractive(program)) {\n console.log(\"\\nGPC Setup Wizard\\n\");\n\n // Package name\n let app = await promptInput(\"Default package name (e.g. com.example.app, blank to skip)\");\n if (app) {\n if (!ANDROID_PACKAGE_RE.test(app)) {\n console.error(\n ` Warning: \"${app}\" doesn't look like a valid Android package name — continuing anyway`,\n );\n }\n initialConfig[\"app\"] = app;\n }\n\n // Auth method\n const authMethod = await promptSelect(\n \"Authentication method:\",\n [\"service-account\", \"adc\", \"skip\"],\n \"service-account\",\n );\n\n if (authMethod === \"service-account\") {\n let saPath = \"\";\n while (true) {\n saPath = await promptInput(\"Path to service account JSON key file\");\n if (!saPath) {\n console.log(\" Skipping service account setup.\");\n break;\n }\n const resolved = resolve(saPath);\n if (existsSync(resolved)) {\n initialConfig[\"auth\"] = { serviceAccount: saPath };\n break;\n }\n console.error(` File not found: ${resolved}`);\n const retry = await promptConfirm(\"Try a different path?\");\n if (!retry) break;\n }\n } else if (authMethod === \"adc\") {\n console.log(\n \" Using Application Default Credentials — run `gcloud auth application-default login` if not already set up.\",\n );\n }\n\n // Output format\n const output = await promptSelect(\n \"Default output format:\",\n [\"table\", \"json\", \"yaml\", \"markdown\"],\n \"table\",\n );\n if (output !== \"table\") initialConfig[\"output\"] = output;\n }\n\n const path = await initConfig(initialConfig as GpcConfig);\n\n // Summary\n const configured: string[] = [];\n if (initialConfig[\"app\"]) configured.push(`app: ${initialConfig[\"app\"]}`);\n if (initialConfig[\"auth\"]) configured.push(\"auth: service account\");\n if (initialConfig[\"output\"]) configured.push(`output: ${initialConfig[\"output\"]}`);\n\n console.log(`\\nConfiguration file created: ${path}`);\n if (configured.length > 0) {\n console.log(` ${configured.join(\" · \")}`);\n }\n\n writeAuditLog(createAuditEntry(\"config init\", { path })).catch(() => {});\n\n // Run doctor inline to verify setup\n console.log(\"\\nVerifying setup...\");\n try {\n const { registerDoctorCommand } = await import(\"./doctor.js\");\n const { Command } = await import(\"commander\");\n const doctorProgram = new Command();\n doctorProgram\n .option(\"-o, --output <format>\", \"Output format\")\n .option(\"-j, --json\", \"JSON mode\");\n registerDoctorCommand(doctorProgram);\n await doctorProgram.parseAsync([\"node\", \"gpc\", \"doctor\"]);\n } catch {\n // Doctor failures should not prevent config init from succeeding\n console.log(\"Run `gpc doctor` to verify your setup.\");\n }\n });\n\n config\n .command(\"show\")\n .description(\"Display resolved configuration\")\n .action(async () => {\n const resolved = await loadConfig();\n const format = getOutputFormat(program, resolved);\n console.log(formatOutput(resolved, format));\n });\n\n config\n .command(\"set <key> <value>\")\n .description(\"Set a configuration value\")\n .action(async (key: string, value: string) => {\n await setConfigValue(key, value);\n console.log(`Set ${key} = ${value}`);\n });\n\n config\n .command(\"path\")\n .description(\"Show configuration file path\")\n .action(() => {\n console.log(getUserConfigPath());\n });\n}\n"],"mappings":";;;;;;;;;;;;AACA,SAAS,YAAY,gBAAgB,mBAAmB,kBAAkB;AAE1E,SAAS,cAAc,eAAe,wBAAwB;AAC9D,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AAIx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AE;AAAA,EACrC,CAAC;AAEH,SACG,QAAQ,MAAM,EACd,YAAY,8BAA8B,EAC1C,OAAO,MAAM;AACZ,YAAQ,IAAI,kBAAkB,CAAC;AAAA,EACjC,CAAC;AACL;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/data-safety.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport type { GpcConfig } from \"@gpc-cli/config\";\nimport { loadConfig } from \"@gpc-cli/config\";\nimport { resolveAuth } from \"@gpc-cli/auth\";\nimport { createApiClient } from \"@gpc-cli/api\";\nimport {\n getDataSafety,\n updateDataSafety,\n exportDataSafety,\n importDataSafety,\n formatOutput,\n} from \"@gpc-cli/core\";\nimport { isDryRun, printDryRun } from \"../dry-run.js\";\nimport { getOutputFormat } from \"../format.js\";\n\nfunction resolvePackageName(packageArg: string | undefined, config: GpcConfig): string {\n const name = packageArg || config.app;\n if (!name) {\n console.error(\"Error: No package name. Use --app <package> or gpc config set app <package>\");\n process.exit(2);\n }\n return name;\n}\n\nasync function getClient(config: GpcConfig) {\n const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });\n return createApiClient({ auth });\n}\n\nexport function registerDataSafetyCommands(program: Command): void {\n const dataSafety = program\n .command(\"data-safety\")\n .description(\"Manage data safety declarations\");\n\n // Get — not supported by Google Play API (no GET endpoint for data safety)\n dataSafety\n .command(\"get\")\n .description(\"Get the current data safety declaration\")\n .action(async () => {\n console.error(\"Error: The Google Play Developer API does not provide a GET endpoint for data safety declarations.\");\n console.error(\"\");\n console.error(\"Data safety labels can only be updated (not read) via the API.\");\n console.error(\"To view your current data safety declaration, use the Google Play Console:\");\n console.error(\" https://play.google.com/console → App content → Data safety\");\n console.error(\"\");\n console.error(\"To update data safety via the API, use: gpc data-safety update --file <csv-file>\");\n process.exit(2);\n });\n\n // Update\n dataSafety\n .command(\"update\")\n .description(\"Update data safety declaration from a JSON file\")\n .requiredOption(\"--file <path>\", \"Path to data safety JSON file\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const format = getOutputFormat(program, config);\n\n if (isDryRun(program)) {\n printDryRun(\n {\n command: \"data-safety update\",\n action: \"update data safety from\",\n target: options.file,\n },\n format,\n formatOutput,\n );\n return;\n }\n\n const client = await getClient(config);\n\n try {\n const result = await importDataSafety(client, packageName, options.file);\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n // Export — not supported (no GET endpoint)\n dataSafety\n .command(\"export\")\n .description(\"Export data safety declaration to a JSON file\")\n .option(\"--output <path>\", \"Output file path\", \"data-safety.json\")\n .action(async () => {\n console.error(\"Error: The Google Play Developer API does not provide a GET endpoint for data safety declarations.\");\n console.error(\"Data safety labels cannot be exported via the API.\");\n console.error(\"\");\n console.error(\"To export your data safety declaration, use the Google Play Console:\");\n console.error(\" App content → Data safety → Export to CSV\");\n process.exit(2);\n });\n}\n"],"mappings":";;;;;;;;;;AAEA,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC;AAAA,EAIE;AAAA,EACA;AAAA,OACK;AAIP,SAAS,mBAAmB,YAAgC,QAA2B;AACrF,QAAM,OAAO,cAAc,OAAO;AAClC,MAAI,CAAC,MAAM;AACT,YAAQ,MAAM,6EAA6E;AAC3F,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,SAAO;AACT;AAEA,eAAe,UAAU,QAAmB;AAC1C,QAAM,OAAO,MAAM,YAAY,EAAE,oBAAoB,OAAO,MAAM,eAAe,CAAC;AAClF,SAAO,gBAAgB,EAAE,KAAK,CAAC;AACjC;AAEO,SAAS,2BAA2B,SAAwB;AACjE,QAAM,aAAa,QAChB,QAAQ,aAAa,EACrB,YAAY,iCAAiC;AAGhD,aACG,QAAQ,KAAK,EACb,YAAY,yCAAyC,EACrD,OAAO,YAAY;AAClB,YAAQ,MAAM,oG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