@gpc-cli/cli 0.9.33 → 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 +21 -16
- package/dist/anomalies-QZJGQXTZ.js +59 -0
- package/dist/anomalies-QZJGQXTZ.js.map +1 -0
- 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 +14 -3
- 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-7BXCQKJG.js +37 -0
- package/dist/chunk-7BXCQKJG.js.map +1 -0
- package/dist/{chunk-DMMFPBYF.js → chunk-DDTPDKTB.js} +116 -31
- package/dist/chunk-DDTPDKTB.js.map +1 -0
- package/dist/{config-2L7QUYWP.js → config-REB7NINL.js} +14 -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-UZB2UB5X.js → doctor-QDIFTXNB.js} +54 -6
- 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-BBHF7BLZ.js → iap-MBDD7VWP.js} +6 -38
- package/dist/iap-MBDD7VWP.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/{listings-VSBHQY5H.js → listings-7TWCGGMS.js} +94 -9
- package/dist/listings-7TWCGGMS.js.map +1 -0
- package/dist/{migrate-XQV7P4R7.js → migrate-OHN2FDY6.js} +13 -3
- package/dist/migrate-OHN2FDY6.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-GJAQ5OVC.js → reviews-NN7YQITF.js} +59 -3
- package/dist/reviews-NN7YQITF.js.map +1 -0
- package/dist/{status-6Y2CHHVD.js → status-L5S2FGZ4.js} +45 -5
- 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-KSNAVN5F.js → vitals-LFL75LA6.js} +135 -4
- 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-DMMFPBYF.js.map +0 -1
- package/dist/config-2L7QUYWP.js.map +0 -1
- package/dist/data-safety-GDPKV5PN.js.map +0 -1
- package/dist/doctor-UZB2UB5X.js.map +0 -1
- package/dist/feedback-W5MZMRF2.js.map +0 -1
- package/dist/iap-BBHF7BLZ.js.map +0 -1
- package/dist/listings-VSBHQY5H.js.map +0 -1
- package/dist/migrate-XQV7P4R7.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-GJAQ5OVC.js.map +0 -1
- package/dist/status-6Y2CHHVD.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-KSNAVN5F.js.map +0 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ Releases, rollouts, metadata, vitals, reviews, subscriptions, reports, and more.
|
|
|
10
10
|
<p align="center">
|
|
11
11
|
<a href="https://www.npmjs.com/package/@gpc-cli/cli"><img src="https://img.shields.io/npm/v/@gpc-cli/cli?color=00D26A" alt="npm version"></a>
|
|
12
12
|
<a href="https://github.com/yasserstudio/gpc"><img src="https://img.shields.io/github/stars/yasserstudio/gpc" alt="GitHub Stars"></a>
|
|
13
|
-
<img src="https://img.shields.io/badge/Tests-
|
|
13
|
+
<img src="https://img.shields.io/badge/Tests-1504_passing-00D26A" alt="Tests">
|
|
14
14
|
<img src="https://img.shields.io/badge/License-MIT-yellow" alt="License">
|
|
15
15
|
</p>
|
|
16
16
|
|
|
@@ -27,12 +27,17 @@ brew install yasserstudio/tap/gpc
|
|
|
27
27
|
curl -fsSL https://raw.githubusercontent.com/yasserstudio/gpc/main/scripts/install.sh | sh
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
Free. Open-source. No account required beyond your existing Google Play service account.
|
|
31
|
+
|
|
30
32
|
## Quick Start
|
|
31
33
|
|
|
32
34
|
```bash
|
|
33
35
|
# Authenticate
|
|
34
36
|
gpc auth login --service-account path/to/key.json
|
|
35
37
|
|
|
38
|
+
# Verify your setup
|
|
39
|
+
gpc doctor
|
|
40
|
+
|
|
36
41
|
# App health at a glance — releases, vitals, and reviews in one command
|
|
37
42
|
gpc status
|
|
38
43
|
|
|
@@ -72,23 +77,23 @@ REVIEWS (last 30 days)
|
|
|
72
77
|
|
|
73
78
|
187 API endpoints across these command groups:
|
|
74
79
|
|
|
75
|
-
| Group |
|
|
76
|
-
| ----------------- |
|
|
77
|
-
| **Releases** |
|
|
78
|
-
| **Listings** |
|
|
79
|
-
| **Reviews** |
|
|
80
|
-
| **Vitals** |
|
|
81
|
-
| **Bundle** |
|
|
82
|
-
| **Subscriptions** |
|
|
83
|
-
| **IAP** |
|
|
84
|
-
| **Purchases** |
|
|
85
|
-
| **Reports** |
|
|
86
|
-
| **Testers** |
|
|
87
|
-
| **Users** |
|
|
80
|
+
| Group | What you can do |
|
|
81
|
+
| ----------------- | ------------------------------------------------------------------------------------- |
|
|
82
|
+
| **Releases** | Upload, promote, rollout increase/halt/resume, end-to-end `publish` |
|
|
83
|
+
| **Listings** | Pull and push store listings, upload screenshots — works with Fastlane metadata format |
|
|
84
|
+
| **Reviews** | Filter by stars, reply to users, export to CSV |
|
|
85
|
+
| **Vitals** | Crash rates, ANR, startup, rendering — with CI threshold gates |
|
|
86
|
+
| **Bundle** | Per-module size breakdown, build-to-build diff, size CI gates |
|
|
87
|
+
| **Subscriptions** | Create and manage base plans, offers, and pricing |
|
|
88
|
+
| **IAP** | Sync products from local files, batch get and update |
|
|
89
|
+
| **Purchases** | Verify, acknowledge, cancel, refund, list voided |
|
|
90
|
+
| **Reports** | Download financial and stats reports |
|
|
91
|
+
| **Testers** | Add, remove, import from CSV |
|
|
92
|
+
| **Users** | Invite, update, remove, manage per-app grants |
|
|
88
93
|
|
|
89
94
|
## CI/CD Ready
|
|
90
95
|
|
|
91
|
-
JSON output when piped. Formatted tables in your terminal. Semantic exit codes (0
|
|
96
|
+
JSON output when piped. Formatted tables in your terminal. Semantic exit codes (0–6) your CI can react to. Every write operation supports `--dry-run`.
|
|
92
97
|
|
|
93
98
|
```yaml
|
|
94
99
|
- name: Upload
|
|
@@ -100,7 +105,7 @@ JSON output when piped. Formatted tables in your terminal. Semantic exit codes (
|
|
|
100
105
|
gpc releases upload app.aab --track internal
|
|
101
106
|
```
|
|
102
107
|
|
|
103
|
-
|
|
108
|
+
Already on Fastlane? See the [migration guide](https://yasserstudio.github.io/gpc/migration/from-fastlane) — most commands map one-to-one.
|
|
104
109
|
|
|
105
110
|
## Part of the GPC Monorepo
|
|
106
111
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
getOutputFormat
|
|
4
|
+
} from "./chunk-ELXAK7GI.js";
|
|
5
|
+
|
|
6
|
+
// src/commands/anomalies.ts
|
|
7
|
+
import { loadConfig } from "@gpc-cli/config";
|
|
8
|
+
import { resolveAuth } from "@gpc-cli/auth";
|
|
9
|
+
import { createReportingClient } from "@gpc-cli/api";
|
|
10
|
+
import { getVitalsAnomalies, formatOutput } from "@gpc-cli/core";
|
|
11
|
+
function resolvePackageName(packageArg, config) {
|
|
12
|
+
const name = packageArg || config.app;
|
|
13
|
+
if (!name) {
|
|
14
|
+
console.error("Error: No package name. Use --app <package> or gpc config set app <package>");
|
|
15
|
+
process.exit(2);
|
|
16
|
+
}
|
|
17
|
+
return name;
|
|
18
|
+
}
|
|
19
|
+
async function getReportingClient(config) {
|
|
20
|
+
const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });
|
|
21
|
+
return createReportingClient({ auth });
|
|
22
|
+
}
|
|
23
|
+
function registerAnomaliesCommands(program) {
|
|
24
|
+
const anomalies = program.command("anomalies").description("Detect and list vitals anomalies");
|
|
25
|
+
anomalies.command("list").description("List detected vitals anomalies").action(async () => {
|
|
26
|
+
const config = await loadConfig();
|
|
27
|
+
const packageName = resolvePackageName(program.opts()["app"], config);
|
|
28
|
+
const reporting = await getReportingClient(config);
|
|
29
|
+
const format = getOutputFormat(program, config);
|
|
30
|
+
try {
|
|
31
|
+
const result = await getVitalsAnomalies(reporting, packageName);
|
|
32
|
+
const items = result["anomalies"];
|
|
33
|
+
if (format !== "json") {
|
|
34
|
+
if (!items || items.length === 0) {
|
|
35
|
+
console.log("No anomalies detected.");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const rows = items.map((item) => {
|
|
39
|
+
const a = item;
|
|
40
|
+
return {
|
|
41
|
+
name: String(a["name"] ?? "-"),
|
|
42
|
+
metricSet: String(a["metricSet"] ?? "-"),
|
|
43
|
+
aggregationPeriod: String(a["aggregationPeriod"] ?? "-")
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
console.log(formatOutput(rows, format));
|
|
47
|
+
} else {
|
|
48
|
+
console.log(formatOutput(result, format));
|
|
49
|
+
}
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
52
|
+
process.exit(4);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
registerAnomaliesCommands
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=anomalies-QZJGQXTZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/anomalies.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 { getVitalsAnomalies, formatOutput } from \"@gpc-cli/core\";\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 getReportingClient(config: GpcConfig) {\n const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });\n return createReportingClient({ auth });\n}\n\nexport function registerAnomaliesCommands(program: Command): void {\n const anomalies = program\n .command(\"anomalies\")\n .description(\"Detect and list vitals anomalies\");\n\n anomalies\n .command(\"list\")\n .description(\"List detected vitals anomalies\")\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 const items =\n (result as Record<string, unknown>)[\"anomalies\"] as unknown[] | undefined;\n\n if (format !== \"json\") {\n if (!items || items.length === 0) {\n console.log(\"No anomalies detected.\");\n return;\n }\n const rows = items.map((item) => {\n const a = item as Record<string, unknown>;\n return {\n name: String(a[\"name\"] ?? \"-\"),\n metricSet: String(a[\"metricSet\"] ?? \"-\"),\n aggregationPeriod: String(a[\"aggregationPeriod\"] ?? \"-\"),\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"],"mappings":";;;;;;AAEA,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AACtC,SAAS,oBAAoB,oBAAoB;AAGjD,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;AAEO,SAAS,0BAA0B,SAAwB;AAChE,QAAM,YAAY,QACf,QAAQ,WAAW,EACnB,YAAY,kCAAkC;AAEjD,YACG,QAAQ,MAAM,EACd,YAAY,gCAAgC,EAC5C,OAAO,YAAY;AAClB,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,cAAc,mBAAmB,QAAQ,KAAK,EAAE,KAAK,GAAG,MAAM;AACpE,UAAM,YAAY,MAAM,mBAAmB,MAAM;AACjD,UAAM,SAAS,gBAAgB,SAAS,MAAM;AAE9C,QAAI;AACF,YAAM,SAAS,MAAM,mBAAmB,WAAW,WAAW;AAC9D,YAAM,QACH,OAAmC,WAAW;AAEjD,UAAI,WAAW,QAAQ;AACrB,YAAI,CAAC,SAAS,MAAM,WAAW,GAAG;AAChC,kBAAQ,IAAI,wBAAwB;AACpC;AAAA,QACF;AACA,cAAM,OAAO,MAAM,IAAI,CAAC,SAAS;AAC/B,gBAAM,IAAI;AACV,iBAAO;AAAA,YACL,MAAM,OAAO,EAAE,MAAM,KAAK,GAAG;AAAA,YAC7B,WAAW,OAAO,EAAE,WAAW,KAAK,GAAG;AAAA,YACvC,mBAAmB,OAAO,EAAE,mBAAmB,KAAK,GAAG;AAAA,UACzD;AAAA,QACF,CAAC;AACD,gBAAQ,IAAI,aAAa,MAAM,MAAM,CAAC;AAAA,MACxC,OAAO;AACL,gBAAQ,IAAI,aAAa,QAAQ,MAAM,CAAC;AAAA,MAC1C;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;","names":[]}
|
|
@@ -82,7 +82,7 @@ function registerAppsCommands(program) {
|
|
|
82
82
|
process.exit(4);
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
|
-
apps.command("list").description("List configured applications").option("--limit <n>", "Maximum results to return").option("--next-page <token>", "Pagination token for next page").action(async (
|
|
85
|
+
apps.command("list").description("List configured applications").option("--limit <n>", "Maximum results to return").option("--next-page <token>", "Pagination token for next page").action(async (_options) => {
|
|
86
86
|
const config = await loadConfig();
|
|
87
87
|
const format = getOutputFormat(program, config);
|
|
88
88
|
if (config.app) {
|
|
@@ -102,4 +102,4 @@ function registerAppsCommands(program) {
|
|
|
102
102
|
export {
|
|
103
103
|
registerAppsCommands
|
|
104
104
|
};
|
|
105
|
-
//# sourceMappingURL=apps-
|
|
105
|
+
//# sourceMappingURL=apps-J2446UDA.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/apps.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { loadConfig } from \"@gpc-cli/config\";\nimport { resolveAuth } from \"@gpc-cli/auth\";\nimport { createApiClient } from \"@gpc-cli/api\";\nimport { getAppInfo, updateAppDetails } from \"@gpc-cli/core\";\nimport { formatOutput } from \"@gpc-cli/core\";\nimport { getOutputFormat } from \"../format.js\";\nimport { isDryRun, printDryRun } from \"../dry-run.js\";\n\nexport function registerAppsCommands(program: Command): void {\n const apps = program.command(\"apps\").description(\"Manage applications\");\n\n apps\n .command(\"info [package]\")\n .description(\"Show app details\")\n .action(async (packageArg?: string) => {\n const config = await loadConfig();\n const packageName = packageArg || config.app;\n\n if (!packageName) {\n console.error(\"Error: No package name provided.\");\n console.error(\"Usage: gpc apps info <package>\");\n console.error(\"Or set a default: gpc config set app com.example.app\");\n process.exit(2);\n }\n\n try {\n const auth = await resolveAuth({\n serviceAccountPath: config.auth?.serviceAccount,\n });\n const client = createApiClient({ auth });\n const info = await getAppInfo(client, packageName);\n const format = getOutputFormat(program, config);\n console.log(formatOutput(info, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n apps\n .command(\"update\")\n .description(\"Update app details\")\n .option(\"--email <email>\", \"Contact email\")\n .option(\"--phone <phone>\", \"Contact phone\")\n .option(\"--website <url>\", \"Contact website\")\n .option(\"--default-lang <lang>\", \"Default language\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = options[\"app\"] || program.opts()[\"app\"] || config.app;\n\n if (!packageName) {\n console.error(\"Error: No package name provided.\");\n console.error(\"Usage: gpc apps update --email user@example.com\");\n process.exit(2);\n }\n\n const data: Record<string, string> = {};\n if (options[\"email\"]) data[\"contactEmail\"] = options[\"email\"];\n if (options[\"phone\"]) data[\"contactPhone\"] = options[\"phone\"];\n if (options[\"website\"]) data[\"contactWebsite\"] = options[\"website\"];\n if (options[\"defaultLang\"]) data[\"defaultLanguage\"] = options[\"defaultLang\"];\n\n if (Object.keys(data).length === 0) {\n console.error(\n \"Error: Provide at least one field to update (--email, --phone, --website, --default-lang).\",\n );\n process.exit(2);\n }\n\n const format = getOutputFormat(program, config);\n\n if (isDryRun(program)) {\n printDryRun(\n {\n command: \"apps update\",\n action: \"update app details for\",\n target: packageName,\n details: data,\n },\n format,\n formatOutput,\n );\n return;\n }\n\n try {\n const auth = await resolveAuth({\n serviceAccountPath: config.auth?.serviceAccount,\n });\n const client = createApiClient({ auth });\n const result = await updateAppDetails(client, packageName, data);\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 apps\n .command(\"list\")\n .description(\"List configured applications\")\n .option(\"--limit <n>\", \"Maximum results to return\")\n .option(\"--next-page <token>\", \"Pagination token for next page\")\n .action(async (
|
|
1
|
+
{"version":3,"sources":["../src/commands/apps.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { loadConfig } from \"@gpc-cli/config\";\nimport { resolveAuth } from \"@gpc-cli/auth\";\nimport { createApiClient } from \"@gpc-cli/api\";\nimport { getAppInfo, updateAppDetails } from \"@gpc-cli/core\";\nimport { formatOutput } from \"@gpc-cli/core\";\nimport { getOutputFormat } from \"../format.js\";\nimport { isDryRun, printDryRun } from \"../dry-run.js\";\n\nexport function registerAppsCommands(program: Command): void {\n const apps = program.command(\"apps\").description(\"Manage applications\");\n\n apps\n .command(\"info [package]\")\n .description(\"Show app details\")\n .action(async (packageArg?: string) => {\n const config = await loadConfig();\n const packageName = packageArg || config.app;\n\n if (!packageName) {\n console.error(\"Error: No package name provided.\");\n console.error(\"Usage: gpc apps info <package>\");\n console.error(\"Or set a default: gpc config set app com.example.app\");\n process.exit(2);\n }\n\n try {\n const auth = await resolveAuth({\n serviceAccountPath: config.auth?.serviceAccount,\n });\n const client = createApiClient({ auth });\n const info = await getAppInfo(client, packageName);\n const format = getOutputFormat(program, config);\n console.log(formatOutput(info, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n apps\n .command(\"update\")\n .description(\"Update app details\")\n .option(\"--email <email>\", \"Contact email\")\n .option(\"--phone <phone>\", \"Contact phone\")\n .option(\"--website <url>\", \"Contact website\")\n .option(\"--default-lang <lang>\", \"Default language\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = options[\"app\"] || program.opts()[\"app\"] || config.app;\n\n if (!packageName) {\n console.error(\"Error: No package name provided.\");\n console.error(\"Usage: gpc apps update --email user@example.com\");\n process.exit(2);\n }\n\n const data: Record<string, string> = {};\n if (options[\"email\"]) data[\"contactEmail\"] = options[\"email\"];\n if (options[\"phone\"]) data[\"contactPhone\"] = options[\"phone\"];\n if (options[\"website\"]) data[\"contactWebsite\"] = options[\"website\"];\n if (options[\"defaultLang\"]) data[\"defaultLanguage\"] = options[\"defaultLang\"];\n\n if (Object.keys(data).length === 0) {\n console.error(\n \"Error: Provide at least one field to update (--email, --phone, --website, --default-lang).\",\n );\n process.exit(2);\n }\n\n const format = getOutputFormat(program, config);\n\n if (isDryRun(program)) {\n printDryRun(\n {\n command: \"apps update\",\n action: \"update app details for\",\n target: packageName,\n details: data,\n },\n format,\n formatOutput,\n );\n return;\n }\n\n try {\n const auth = await resolveAuth({\n serviceAccountPath: config.auth?.serviceAccount,\n });\n const client = createApiClient({ auth });\n const result = await updateAppDetails(client, packageName, data);\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 apps\n .command(\"list\")\n .description(\"List configured applications\")\n .option(\"--limit <n>\", \"Maximum results to return\")\n .option(\"--next-page <token>\", \"Pagination token for next page\")\n .action(async (_options) => {\n const config = await loadConfig();\n const format = getOutputFormat(program, config);\n\n if (config.app) {\n const apps = [{ packageName: config.app, source: \"config\" }];\n console.log(formatOutput(apps, format));\n } else {\n console.log(\"No apps configured.\");\n console.log(\"\");\n console.log(\"Set a default app:\");\n console.log(\" gpc config set app com.example.myapp\");\n console.log(\"\");\n console.log(\"Or use the --app flag:\");\n console.log(\" gpc apps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OAAO,OAAO,aAAa;AAC1B,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,SAAS,gBAAgB,SAAS,MAAM;AAE9C,QAAI,OAAO,KAAK;AACd,YAAMA,QAAO,CAAC,EAAE,aAAa,OAAO,KAAK,QAAQ,SAAS,CAAC;AAC3D,cAAQ,IAAI,aAAaA,OAAM,MAAM,CAAC;AAAA,IACxC,OAAO;AACL,cAAQ,IAAI,qBAAqB;AACjC,cAAQ,IAAI,EAAE;AACd,cAAQ,IAAI,oBAAoB;AAChC,cAAQ,IAAI,wCAAwC;AACpD,cAAQ,IAAI,EAAE;AACd,cAAQ,IAAI,wBAAwB;AACpC,cAAQ,IAAI,yCAAyC;AAAA,IACvD;AAAA,EACF,CAAC;AACL;","names":["apps"]}
|
|
@@ -96,8 +96,7 @@ function registerAuditCommands(program) {
|
|
|
96
96
|
});
|
|
97
97
|
audit.command("clear").description("Clear audit log entries").option("--before <date>", "Clear entries before date (ISO 8601)").option("--dry-run", "Preview what would be cleared").action(async (options, cmd) => {
|
|
98
98
|
const dryRun = options.dryRun || isDryRun(cmd);
|
|
99
|
-
|
|
100
|
-
const format = getOutputFormat(program, config);
|
|
99
|
+
await loadConfig();
|
|
101
100
|
initAudit(getConfigDir());
|
|
102
101
|
if (!dryRun && !options.before) {
|
|
103
102
|
await requireConfirm("Clear all audit log entries?", program);
|
|
@@ -121,4 +120,4 @@ function registerAuditCommands(program) {
|
|
|
121
120
|
export {
|
|
122
121
|
registerAuditCommands
|
|
123
122
|
};
|
|
124
|
-
//# sourceMappingURL=audit-
|
|
123
|
+
//# sourceMappingURL=audit-4UPTLW37.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/audit.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { loadConfig } from \"@gpc-cli/config\";\nimport { getConfigDir } from \"@gpc-cli/config\";\nimport {\n initAudit,\n listAuditEvents,\n searchAuditEvents,\n clearAuditLog,\n formatOutput,\n} from \"@gpc-cli/core\";\nimport { getOutputFormat } from \"../format.js\";\nimport { isDryRun } from \"../dry-run.js\";\nimport { requireConfirm } from \"../prompt.js\";\n\nfunction formatAuditTimestamp(iso: string): string {\n const date = new Date(iso);\n const now = new Date();\n const diffMs = now.getTime() - date.getTime();\n const diffMin = Math.floor(diffMs / 60000);\n if (diffMin < 60) return diffMin < 1 ? \"just now\" : `${diffMin} min ago`;\n const diffHr = Math.floor(diffMin / 60);\n if (diffHr < 24) return `${String(date.getHours()).padStart(2, \"0\")}:${String(date.getMinutes()).padStart(2, \"0\")}:${String(date.getSeconds()).padStart(2, \"0\")}`;\n const diffDays = Math.floor(diffHr / 24);\n if (diffDays < 7) {\n const days = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n return `${days[date.getDay()]} ${String(date.getHours()).padStart(2, \"0\")}:${String(date.getMinutes()).padStart(2, \"0\")}`;\n }\n const months = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n return `${months[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;\n}\n\nexport function registerAuditCommands(program: Command): void {\n const audit = program.command(\"audit\").description(\"Query and manage audit logs\");\n\n audit\n .command(\"list\")\n .description(\"List recent audit events\")\n .option(\"--limit <n>\", \"Maximum events to show\", parseInt, 50)\n .option(\"--since <date>\", \"Show events since date (ISO 8601)\")\n .option(\"--command <name>\", \"Filter by command name\")\n .action(async (options) => {\n const config = await loadConfig();\n const format = getOutputFormat(program, config);\n initAudit(getConfigDir());\n\n try {\n const events = await listAuditEvents({\n limit: options.limit,\n since: options.since,\n command: options.command,\n });\n if (events.length === 0 && format !== \"json\") {\n console.log(\"No audit events found.\");\n return;\n }\n if (format !== \"json\") {\n const rows = events.map((e) => ({\n timestamp: formatAuditTimestamp(e.timestamp),\n command: e.command,\n app: e.app || \"-\",\n success: e.success !== undefined ? String(e.success) : \"-\",\n durationMs: e.durationMs ?? \"-\",\n }));\n console.log(formatOutput(rows, format));\n } else {\n console.log(formatOutput(events, format));\n }\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n });\n\n audit\n .command(\"search <query>\")\n .description(\"Search audit events by keyword\")\n .action(async (query: string) => {\n const config = await loadConfig();\n const format = getOutputFormat(program, config);\n initAudit(getConfigDir());\n\n try {\n const events = await searchAuditEvents(query);\n if (events.length === 0 && format !== \"json\") {\n console.log(`No audit events matching \"${query}\".`);\n return;\n }\n if (format !== \"json\") {\n const rows = events.map((e) => ({\n timestamp: formatAuditTimestamp(e.timestamp),\n command: e.command,\n app: e.app || \"-\",\n success: e.success !== undefined ? String(e.success) : \"-\",\n }));\n console.log(formatOutput(rows, format));\n } else {\n console.log(formatOutput(events, format));\n }\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n });\n\n audit\n .command(\"clear\")\n .description(\"Clear audit log entries\")\n .option(\"--before <date>\", \"Clear entries before date (ISO 8601)\")\n .option(\"--dry-run\", \"Preview what would be cleared\")\n .action(async (options, cmd: Command) => {\n const dryRun = options.dryRun || isDryRun(cmd);\n
|
|
1
|
+
{"version":3,"sources":["../src/commands/audit.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { loadConfig } from \"@gpc-cli/config\";\nimport { getConfigDir } from \"@gpc-cli/config\";\nimport {\n initAudit,\n listAuditEvents,\n searchAuditEvents,\n clearAuditLog,\n formatOutput,\n} from \"@gpc-cli/core\";\nimport { getOutputFormat } from \"../format.js\";\nimport { isDryRun } from \"../dry-run.js\";\nimport { requireConfirm } from \"../prompt.js\";\n\nfunction formatAuditTimestamp(iso: string): string {\n const date = new Date(iso);\n const now = new Date();\n const diffMs = now.getTime() - date.getTime();\n const diffMin = Math.floor(diffMs / 60000);\n if (diffMin < 60) return diffMin < 1 ? \"just now\" : `${diffMin} min ago`;\n const diffHr = Math.floor(diffMin / 60);\n if (diffHr < 24) return `${String(date.getHours()).padStart(2, \"0\")}:${String(date.getMinutes()).padStart(2, \"0\")}:${String(date.getSeconds()).padStart(2, \"0\")}`;\n const diffDays = Math.floor(diffHr / 24);\n if (diffDays < 7) {\n const days = [\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"];\n return `${days[date.getDay()]} ${String(date.getHours()).padStart(2, \"0\")}:${String(date.getMinutes()).padStart(2, \"0\")}`;\n }\n const months = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"];\n return `${months[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;\n}\n\nexport function registerAuditCommands(program: Command): void {\n const audit = program.command(\"audit\").description(\"Query and manage audit logs\");\n\n audit\n .command(\"list\")\n .description(\"List recent audit events\")\n .option(\"--limit <n>\", \"Maximum events to show\", parseInt, 50)\n .option(\"--since <date>\", \"Show events since date (ISO 8601)\")\n .option(\"--command <name>\", \"Filter by command name\")\n .action(async (options) => {\n const config = await loadConfig();\n const format = getOutputFormat(program, config);\n initAudit(getConfigDir());\n\n try {\n const events = await listAuditEvents({\n limit: options.limit,\n since: options.since,\n command: options.command,\n });\n if (events.length === 0 && format !== \"json\") {\n console.log(\"No audit events found.\");\n return;\n }\n if (format !== \"json\") {\n const rows = events.map((e) => ({\n timestamp: formatAuditTimestamp(e.timestamp),\n command: e.command,\n app: e.app || \"-\",\n success: e.success !== undefined ? String(e.success) : \"-\",\n durationMs: e.durationMs ?? \"-\",\n }));\n console.log(formatOutput(rows, format));\n } else {\n console.log(formatOutput(events, format));\n }\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n });\n\n audit\n .command(\"search <query>\")\n .description(\"Search audit events by keyword\")\n .action(async (query: string) => {\n const config = await loadConfig();\n const format = getOutputFormat(program, config);\n initAudit(getConfigDir());\n\n try {\n const events = await searchAuditEvents(query);\n if (events.length === 0 && format !== \"json\") {\n console.log(`No audit events matching \"${query}\".`);\n return;\n }\n if (format !== \"json\") {\n const rows = events.map((e) => ({\n timestamp: formatAuditTimestamp(e.timestamp),\n command: e.command,\n app: e.app || \"-\",\n success: e.success !== undefined ? String(e.success) : \"-\",\n }));\n console.log(formatOutput(rows, format));\n } else {\n console.log(formatOutput(events, format));\n }\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n });\n\n audit\n .command(\"clear\")\n .description(\"Clear audit log entries\")\n .option(\"--before <date>\", \"Clear entries before date (ISO 8601)\")\n .option(\"--dry-run\", \"Preview what would be cleared\")\n .action(async (options, cmd: Command) => {\n const dryRun = options.dryRun || isDryRun(cmd);\n await loadConfig();\n initAudit(getConfigDir());\n\n if (!dryRun && !options.before) {\n await requireConfirm(\"Clear all audit log entries?\", program);\n }\n\n try {\n const result = await clearAuditLog({\n before: options.before,\n dryRun,\n });\n if (dryRun) {\n console.log(`[dry-run] Would delete ${result.deleted} entries, ${result.remaining} would remain.`);\n } else {\n console.log(`Deleted ${result.deleted} entries. ${result.remaining} remaining.`);\n }\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;AACA,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKP,SAAS,qBAAqB,KAAqB;AACjD,QAAM,OAAO,IAAI,KAAK,GAAG;AACzB,QAAM,MAAM,oBAAI,KAAK;AACrB,QAAM,SAAS,IAAI,QAAQ,IAAI,KAAK,QAAQ;AAC5C,QAAM,UAAU,KAAK,MAAM,SAAS,GAAK;AACzC,MAAI,UAAU,GAAI,QAAO,UAAU,IAAI,aAAa,GAAG,OAAO;AAC9D,QAAM,SAAS,KAAK,MAAM,UAAU,E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AACL,gBAAQ,IAAI,aAAa,QAAQ,MAAM,CAAC;AAAA,MAC1C;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;AAEH,QACG,QAAQ,OAAO,EACf,YAAY,yBAAyB,EACrC,OAAO,mBAAmB,sCAAsC,EAChE,OAAO,aAAa,+BAA+B,EACnD,OAAO,OAAO,SAAS,QAAiB;AACvC,UAAM,SAAS,QAAQ,UAAU,SAAS,GAAG;AAC7C,UAAM,WAAW;AACjB,cAAU,aAAa,CAAC;AAExB,QAAI,CAAC,UAAU,CAAC,QAAQ,QAAQ;AAC9B,YAAM,eAAe,gCAAgC,OAAO;AAAA,IAC9D;AAEA,QAAI;AACF,YAAM,SAAS,MAAM,cAAc;AAAA,QACjC,QAAQ,QAAQ;AAAA,QAChB;AAAA,MACF,CAAC;AACD,UAAI,QAAQ;AACV,gBAAQ,IAAI,0BAA0B,OAAO,OAAO,aAAa,OAAO,SAAS,gBAAgB;AAAA,MACnG,OAAO;AACL,gBAAQ,IAAI,WAAW,OAAO,OAAO,aAAa,OAAO,SAAS,aAAa;AAAA,MACjF;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;","names":[]}
|
|
@@ -4,9 +4,70 @@ import {
|
|
|
4
4
|
} from "./chunk-ELXAK7GI.js";
|
|
5
5
|
|
|
6
6
|
// src/commands/auth.ts
|
|
7
|
+
import { createInterface } from "readline";
|
|
8
|
+
import { access } from "fs/promises";
|
|
7
9
|
import { resolveAuth, loadServiceAccountKey, clearTokenCache, AuthError } from "@gpc-cli/auth";
|
|
8
10
|
import { loadConfig, getCacheDir } from "@gpc-cli/config";
|
|
9
11
|
import { formatOutput } from "@gpc-cli/core";
|
|
12
|
+
async function askQuestion(rl, question) {
|
|
13
|
+
return new Promise((resolve) => {
|
|
14
|
+
rl.question(question, (answer) => resolve(answer.trim()));
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
async function runLoginWizard() {
|
|
18
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
19
|
+
try {
|
|
20
|
+
console.log("\nGPC Authentication Setup");
|
|
21
|
+
console.log("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
22
|
+
console.log("\nAuthentication methods:");
|
|
23
|
+
console.log(" 1. Service account key file (recommended)");
|
|
24
|
+
console.log(" 2. Application Default Credentials (ADC)");
|
|
25
|
+
const method = await askQuestion(rl, "\nSelect method [1]: ");
|
|
26
|
+
const useAdc = method === "2";
|
|
27
|
+
if (useAdc) {
|
|
28
|
+
const { resolveAuth: ra } = await import("@gpc-cli/auth");
|
|
29
|
+
const client = await ra();
|
|
30
|
+
console.log(`
|
|
31
|
+
Authenticated via Application Default Credentials`);
|
|
32
|
+
console.log(`Account: ${client.getClientEmail()}`);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
let saPath = "";
|
|
36
|
+
while (!saPath) {
|
|
37
|
+
const input = await askQuestion(rl, "\nPath to service account JSON key: ");
|
|
38
|
+
if (!input) {
|
|
39
|
+
console.log(" Path is required.");
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
await access(input);
|
|
44
|
+
saPath = input;
|
|
45
|
+
} catch {
|
|
46
|
+
console.log(` File not found: ${input}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const profileName = await askQuestion(rl, "\nProfile name (optional, press Enter to skip): ");
|
|
50
|
+
const packageName = await askQuestion(rl, "Default package name (optional, e.g. com.example.app): ");
|
|
51
|
+
const { loadServiceAccountKey: loadKey } = await import("@gpc-cli/auth");
|
|
52
|
+
const key = await loadKey(saPath);
|
|
53
|
+
if (profileName) {
|
|
54
|
+
const { setProfileConfig } = await import("@gpc-cli/config");
|
|
55
|
+
await setProfileConfig(profileName, { auth: { serviceAccount: saPath }, ...packageName && { app: packageName } });
|
|
56
|
+
console.log(`
|
|
57
|
+
Profile "${profileName}" configured with ${key.client_email}`);
|
|
58
|
+
} else {
|
|
59
|
+
const { setConfigValue } = await import("@gpc-cli/config");
|
|
60
|
+
await setConfigValue("auth.serviceAccount", saPath);
|
|
61
|
+
if (packageName) await setConfigValue("app", packageName);
|
|
62
|
+
console.log(`
|
|
63
|
+
Authenticated as ${key.client_email}`);
|
|
64
|
+
}
|
|
65
|
+
console.log(`Project: ${key.project_id}`);
|
|
66
|
+
console.log("\nRun 'gpc doctor' to verify your setup.");
|
|
67
|
+
} finally {
|
|
68
|
+
rl.close();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
10
71
|
function registerAuthCommands(program) {
|
|
11
72
|
const auth = program.command("auth").description("Manage authentication");
|
|
12
73
|
auth.command("login").description("Authenticate with Google Play Developer API").option("--service-account <path>", "Path to service account JSON key file").option("--adc", "Use Application Default Credentials").option("--profile <name>", "Store credentials under a named profile").action(async (options) => {
|
|
@@ -30,14 +91,20 @@ function registerAuthCommands(program) {
|
|
|
30
91
|
console.log(`Authenticated via Application Default Credentials`);
|
|
31
92
|
console.log(`Account: ${client.getClientEmail()}`);
|
|
32
93
|
} else {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
94
|
+
const opts = program.opts();
|
|
95
|
+
const interactive = opts["interactive"] !== false && opts["ci"] !== true && process.stdin.isTTY;
|
|
96
|
+
if (interactive) {
|
|
97
|
+
await runLoginWizard();
|
|
98
|
+
} else {
|
|
99
|
+
console.log("Usage: gpc auth login --service-account <path>");
|
|
100
|
+
console.log("");
|
|
101
|
+
console.log("Authentication methods:");
|
|
102
|
+
console.log(" --service-account <path> Service account JSON key file");
|
|
103
|
+
console.log(" --adc Application Default Credentials");
|
|
104
|
+
console.log("");
|
|
105
|
+
console.log("Options:");
|
|
106
|
+
console.log(" --profile <name> Store under a named profile");
|
|
107
|
+
}
|
|
41
108
|
}
|
|
42
109
|
} catch (error) {
|
|
43
110
|
if (error instanceof AuthError) {
|
|
@@ -127,6 +194,31 @@ function registerAuthCommands(program) {
|
|
|
127
194
|
throw error;
|
|
128
195
|
}
|
|
129
196
|
});
|
|
197
|
+
auth.command("setup-gcp").description("Step-by-step guide to create a Google Cloud service account").action(() => {
|
|
198
|
+
console.log("\nGPC \u2014 Google Cloud Service Account Setup");
|
|
199
|
+
console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
|
|
200
|
+
console.log("\nStep 1: Open the Google Cloud Console");
|
|
201
|
+
console.log(" https://console.cloud.google.com/iam-admin/serviceaccounts");
|
|
202
|
+
console.log("\nStep 2: Create a service account");
|
|
203
|
+
console.log(" \u2022 Click 'Create Service Account'");
|
|
204
|
+
console.log(" \u2022 Name it: gpc-deploy (or any name you like)");
|
|
205
|
+
console.log(" \u2022 Description: GPC Google Play Console access");
|
|
206
|
+
console.log("\nStep 3: Grant roles");
|
|
207
|
+
console.log(" No GCP roles needed \u2014 permissions are managed in Google Play Console.");
|
|
208
|
+
console.log("\nStep 4: Download the JSON key");
|
|
209
|
+
console.log(" \u2022 Click your new service account \u2192 Keys \u2192 Add Key \u2192 Create new key \u2192 JSON");
|
|
210
|
+
console.log(" \u2022 Save as: ~/gpc-service-account.json");
|
|
211
|
+
console.log("\nStep 5: Add to Google Play Console");
|
|
212
|
+
console.log(" https://play.google.com/console/developers");
|
|
213
|
+
console.log(" \u2022 Users and Permissions \u2192 Invite new users");
|
|
214
|
+
console.log(" \u2022 Paste the service account email (ends with @...gserviceaccount.com)");
|
|
215
|
+
console.log(" \u2022 Grant: Release manager + View app info + Reply to reviews");
|
|
216
|
+
console.log("\nStep 6: Authenticate");
|
|
217
|
+
console.log(" gpc auth login --service-account ~/gpc-service-account.json");
|
|
218
|
+
console.log("\nStep 7: Verify");
|
|
219
|
+
console.log(" gpc doctor");
|
|
220
|
+
console.log("\nSee full docs: https://yasserstudio.github.io/gpc/guide/authentication");
|
|
221
|
+
});
|
|
130
222
|
auth.command("profiles").description("List configured profiles").action(async () => {
|
|
131
223
|
const { listProfiles } = await import("@gpc-cli/config");
|
|
132
224
|
const config = await loadConfig();
|
|
@@ -148,4 +240,4 @@ function registerAuthCommands(program) {
|
|
|
148
240
|
export {
|
|
149
241
|
registerAuthCommands
|
|
150
242
|
};
|
|
151
|
-
//# sourceMappingURL=auth-
|
|
243
|
+
//# sourceMappingURL=auth-KPVEGAWV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/auth.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { createInterface } from \"node:readline\";\nimport { access } from \"node:fs/promises\";\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\nasync function askQuestion(rl: ReturnType<typeof createInterface>, question: string): Promise<string> {\n return new Promise((resolve) => {\n rl.question(question, (answer) => resolve(answer.trim()));\n });\n}\n\nasync function runLoginWizard(): Promise<void> {\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n\n try {\n console.log(\"\\nGPC Authentication Setup\");\n console.log(\"─────────────────────────\");\n\n // Step 1: auth method\n console.log(\"\\nAuthentication methods:\");\n console.log(\" 1. Service account key file (recommended)\");\n console.log(\" 2. Application Default Credentials (ADC)\");\n const method = await askQuestion(rl, \"\\nSelect method [1]: \");\n const useAdc = method === \"2\";\n\n if (useAdc) {\n const { resolveAuth: ra } = await import(\"@gpc-cli/auth\");\n const client = await ra();\n console.log(`\\nAuthenticated via Application Default Credentials`);\n console.log(`Account: ${client.getClientEmail()}`);\n return;\n }\n\n // Step 2: credentials path with validation loop\n let saPath = \"\";\n while (!saPath) {\n const input = await askQuestion(rl, \"\\nPath to service account JSON key: \");\n if (!input) { console.log(\" Path is required.\"); continue; }\n try {\n await access(input);\n saPath = input;\n } catch {\n console.log(` File not found: ${input}`);\n }\n }\n\n // Step 3: optional profile name\n const profileName = await askQuestion(rl, \"\\nProfile name (optional, press Enter to skip): \");\n\n // Step 4: default package name\n const packageName = await askQuestion(rl, \"Default package name (optional, e.g. com.example.app): \");\n\n // Apply settings\n const { loadServiceAccountKey: loadKey } = await import(\"@gpc-cli/auth\");\n const key = await loadKey(saPath);\n\n if (profileName) {\n const { setProfileConfig } = await import(\"@gpc-cli/config\");\n await setProfileConfig(profileName, { auth: { serviceAccount: saPath }, ...(packageName && { app: packageName }) });\n console.log(`\\nProfile \"${profileName}\" configured with ${key.client_email}`);\n } else {\n const { setConfigValue } = await import(\"@gpc-cli/config\");\n await setConfigValue(\"auth.serviceAccount\", saPath);\n if (packageName) await setConfigValue(\"app\", packageName);\n console.log(`\\nAuthenticated as ${key.client_email}`);\n }\n console.log(`Project: ${key.project_id}`);\n console.log(\"\\nRun 'gpc doctor' to verify your setup.\");\n } finally {\n rl.close();\n }\n}\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 // Interactive wizard when no flags provided and in interactive mode\n const opts = program.opts();\n const interactive = opts[\"interactive\"] !== false && opts[\"ci\"] !== true && process.stdin.isTTY;\n if (interactive) {\n await runLoginWizard();\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 }\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(\"setup-gcp\")\n .description(\"Step-by-step guide to create a Google Cloud service account\")\n .action(() => {\n console.log(\"\\nGPC — Google Cloud Service Account Setup\");\n console.log(\"═══════════════════════════════════════════\");\n console.log(\"\\nStep 1: Open the Google Cloud Console\");\n console.log(\" https://console.cloud.google.com/iam-admin/serviceaccounts\");\n console.log(\"\\nStep 2: Create a service account\");\n console.log(\" • Click 'Create Service Account'\");\n console.log(\" • Name it: gpc-deploy (or any name you like)\");\n console.log(\" • Description: GPC Google Play Console access\");\n console.log(\"\\nStep 3: Grant roles\");\n console.log(\" No GCP roles needed — permissions are managed in Google Play Console.\");\n console.log(\"\\nStep 4: Download the JSON key\");\n console.log(\" • Click your new service account → Keys → Add Key → Create new key → JSON\");\n console.log(\" • Save as: ~/gpc-service-account.json\");\n console.log(\"\\nStep 5: Add to Google Play Console\");\n console.log(\" https://play.google.com/console/developers\");\n console.log(\" • Users and Permissions → Invite new users\");\n console.log(\" • Paste the service account email (ends with @...gserviceaccount.com)\");\n console.log(\" • Grant: Release manager + View app info + Reply to reviews\");\n console.log(\"\\nStep 6: Authenticate\");\n console.log(\" gpc auth login --service-account ~/gpc-service-account.json\");\n console.log(\"\\nStep 7: Verify\");\n console.log(\" gpc doctor\");\n console.log(\"\\nSee full docs: https://yasserstudio.github.io/gpc/guide/authentication\");\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,uBAAuB;AAChC,SAAS,cAAc;AACvB,SAAS,aAAa,uBAAuB,iBAAiB,iBAAiB;AAC/E,SAAS,YAAY,mBAAmB;AACxC,SAAS,oBAAoB;AAG7B,eAAe,YAAY,IAAwC,UAAmC;AACpG,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,OAAG,SAAS,UAAU,CAAC,WAAW,QAAQ,OAAO,KAAK,CAAC,CAAC;AAAA,EAC1D,CAAC;AACH;AAEA,eAAe,iBAAgC;AAC7C,QAAM,KAAK,gBAAgB,EA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AA0B,EACtC,OAAO,YAAY;AAClB,UAAM,EAAE,aAAa,IAAI,MAAM,OAAO,iBAAiB;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":[]}
|
package/dist/bin.js
CHANGED
|
@@ -3,12 +3,15 @@ import {
|
|
|
3
3
|
createProgram,
|
|
4
4
|
handleCliError,
|
|
5
5
|
loadPlugins
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DDTPDKTB.js";
|
|
7
7
|
import {
|
|
8
8
|
checkForUpdate,
|
|
9
9
|
formatUpdateNotification
|
|
10
10
|
} from "./chunk-4O4D5SGL.js";
|
|
11
11
|
|
|
12
|
+
// src/bin.ts
|
|
13
|
+
import { existsSync } from "fs";
|
|
14
|
+
|
|
12
15
|
// src/networking.ts
|
|
13
16
|
async function setupNetworking() {
|
|
14
17
|
const caCert = process.env["GPC_CA_CERT"];
|
|
@@ -29,11 +32,19 @@ async function setupNetworking() {
|
|
|
29
32
|
|
|
30
33
|
// src/bin.ts
|
|
31
34
|
import { initAudit, sendWebhook } from "@gpc-cli/core";
|
|
32
|
-
import { getConfigDir, loadConfig } from "@gpc-cli/config";
|
|
35
|
+
import { getConfigDir, loadConfig, getUserConfigPath } from "@gpc-cli/config";
|
|
33
36
|
if (process.env["GPC_NO_COLOR"] === "1") process.env["NO_COLOR"] = "1";
|
|
37
|
+
if (process.argv.includes("--no-color")) {
|
|
38
|
+
process.env["NO_COLOR"] = "1";
|
|
39
|
+
}
|
|
40
|
+
var _isJsonMode = process.argv.includes("--json") || process.argv.includes("-j") || process.argv.includes("--ci") || process.argv.includes("--output") && process.argv[process.argv.indexOf("--output") + 1] === "json" || process.argv.includes("-o") && process.argv[process.argv.indexOf("-o") + 1] === "json";
|
|
41
|
+
var _isQuiet = process.argv.includes("--quiet") || process.argv.includes("-q");
|
|
42
|
+
if (!_isJsonMode && !_isQuiet && !existsSync(getUserConfigPath())) {
|
|
43
|
+
process.stderr.write("\u2726 First time? Run gpc config init to get set up.\n\n");
|
|
44
|
+
}
|
|
34
45
|
await setupNetworking();
|
|
35
46
|
initAudit(getConfigDir());
|
|
36
|
-
var currentVersion =
|
|
47
|
+
var currentVersion = "0.9.35";
|
|
37
48
|
var isUpdateCommand = process.argv[2] === "update";
|
|
38
49
|
var updateCheckPromise = isUpdateCommand ? Promise.resolve(null) : checkForUpdate(currentVersion);
|
|
39
50
|
if (process.argv.includes("--ci")) {
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/bin.ts","../src/networking.ts"],"sourcesContent":["if (process.env[\"GPC_NO_COLOR\"] === \"1\") process.env[\"NO_COLOR\"] = \"1\";\nif (process.argv.includes(\"--no-color\")) {\n process.env[\"NO_COLOR\"] = \"1\";\n}\nimport { existsSync } from \"node:fs\";\nimport { setupNetworking } from \"./networking.js\";\nimport { createProgram } from \"./program.js\";\nimport { loadPlugins } from \"./plugins.js\";\nimport { handleCliError } from \"./error-handler.js\";\nimport { initAudit, sendWebhook } from \"@gpc-cli/core\";\nimport type { WebhookPayload } from \"@gpc-cli/core\";\nimport { getConfigDir, loadConfig, getUserConfigPath } from \"@gpc-cli/config\";\nimport { checkForUpdate, formatUpdateNotification } from \"./update-check.js\";\n\n// First-run banner\nconst _isJsonMode =\n process.argv.includes(\"--json\") ||\n process.argv.includes(\"-j\") ||\n process.argv.includes(\"--ci\") ||\n (process.argv.includes(\"--output\") &&\n process.argv[process.argv.indexOf(\"--output\") + 1] === \"json\") ||\n (process.argv.includes(\"-o\") &&\n process.argv[process.argv.indexOf(\"-o\") + 1] === \"json\");\nconst _isQuiet = process.argv.includes(\"--quiet\") || process.argv.includes(\"-q\");\n\nif (!_isJsonMode && !_isQuiet && !existsSync(getUserConfigPath())) {\n process.stderr.write(\"✦ First time? Run gpc config init to get set up.\\n\\n\");\n}\n\nawait setupNetworking();\ninitAudit(getConfigDir());\n\nconst currentVersion = process.env[\"__GPC_VERSION\"] || \"0.0.0\";\n\n// Skip passive update check when the user is explicitly running `gpc update` —\n// that command does its own check against the GitHub Releases API.\nconst isUpdateCommand = process.argv[2] === \"update\";\n\n// Start update check before command execution (non-blocking)\nconst updateCheckPromise = isUpdateCommand ? Promise.resolve(null) : checkForUpdate(currentVersion);\n\n// Handle --ci and --json flags early (before command parsing)\nif (process.argv.includes(\"--ci\")) {\n process.env[\"CI\"] = \"1\";\n // --ci implies --output json --no-interactive --no-color\n if (!process.argv.some((a) => a.startsWith(\"--output\") || a.startsWith(\"-o\"))) {\n process.argv.push(\"--output\", \"json\");\n }\n if (!process.argv.includes(\"--no-interactive\")) {\n process.argv.push(\"--no-interactive\");\n }\n if (!process.argv.includes(\"--no-color\")) {\n process.argv.push(\"--no-color\");\n }\n}\nif (process.argv.includes(\"--json\") || process.argv.includes(\"-j\")) {\n if (!process.argv.some((a) => a.startsWith(\"--output\") || a.startsWith(\"-o\"))) {\n process.argv.push(\"--output\", \"json\");\n }\n}\n\nconst pluginManager = await loadPlugins();\nconst program = await createProgram(pluginManager);\n\n// GPC_DEBUG=1 enables verbose mode without mutating process.argv\nif (process.env[\"GPC_DEBUG\"] === \"1\") {\n program.setOptionValueWithSource(\"verbose\", true, \"env\");\n}\n\nconst startTime = Date.now();\nlet commandSuccess = true;\nlet commandError: string | undefined;\n\nawait program.parseAsync(process.argv).catch((error: unknown) => {\n commandSuccess = false;\n commandError = error instanceof Error ? error.message : String(error);\n const exitCode = handleCliError(error);\n process.exit(exitCode);\n});\n\n// Send webhook notification if --notify was set\nconst notifyOpt = program.opts()[\"notify\"] as string | boolean | undefined;\nif (notifyOpt !== undefined && notifyOpt !== false) {\n try {\n const config = await loadConfig();\n if (config.webhooks) {\n const commandName = process.argv.slice(2).filter((a) => !a.startsWith(\"--notify\")).join(\" \");\n const payload: WebhookPayload = {\n command: commandName || \"unknown\",\n success: commandSuccess,\n duration: Date.now() - startTime,\n app: program.opts()[\"app\"] as string | undefined,\n error: commandError,\n };\n\n const target = typeof notifyOpt === \"string\" ? notifyOpt : undefined;\n // Fire-and-forget — do not block exit\n sendWebhook(config.webhooks, payload, target).catch(() => {});\n }\n } catch {\n // Never let webhook logic break the CLI\n }\n}\n\n// After command completes, show update notification if available\n// isUpdateCommand is declared above — update check was skipped for this command\ntry {\n const result = await Promise.race([\n updateCheckPromise,\n new Promise<null>((resolve) => setTimeout(() => resolve(null), 3000)),\n ]);\n\n if (\n result &&\n result.updateAvailable &&\n !isUpdateCommand &&\n process.stdout.isTTY &&\n !process.argv.includes(\"--json\") &&\n program.opts()[\"output\"] !== \"json\"\n ) {\n process.stderr.write(`\\n${formatUpdateNotification(result)}\\n`);\n }\n} catch {\n // Silently ignore update check failures\n}\n","/**\n * Set up proxy and custom CA certificate support.\n * Must be called before any fetch() calls.\n */\nexport async function setupNetworking(): Promise<void> {\n // Map GPC_CA_CERT to NODE_EXTRA_CA_CERTS (works in both Node and Bun)\n const caCert = process.env[\"GPC_CA_CERT\"];\n if (caCert && !process.env[\"NODE_EXTRA_CA_CERTS\"]) {\n process.env[\"NODE_EXTRA_CA_CERTS\"] = caCert;\n }\n\n // In standalone binary mode, Bun handles HTTPS_PROXY/HTTP_PROXY natively\n if (process.env[\"__GPC_BINARY\"] === \"1\") return;\n\n const proxyUrl =\n process.env[\"HTTPS_PROXY\"] ||\n process.env[\"https_proxy\"] ||\n process.env[\"HTTP_PROXY\"] ||\n process.env[\"http_proxy\"];\n if (proxyUrl) {\n try {\n // @ts-expect-error undici types not available in all environments\n const { ProxyAgent, setGlobalDispatcher } = await import(\"undici\");\n setGlobalDispatcher(new ProxyAgent(proxyUrl));\n } catch {\n console.error(\"Warning: Proxy support requires Node.js 20+. HTTPS_PROXY will be ignored.\");\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;AAIA,SAAS,kBAAkB;;;ACA3B,eAAsB,kBAAiC;AAErD,QAAM,SAAS,QAAQ,IAAI,aAAa;AACxC,MAAI,UAAU,CAAC,QAAQ,IAAI,qBAAqB,GAAG;AACjD,YAAQ,IAAI,qBAAqB,IAAI;AAAA,EACvC;AAGA,MAAI,QAAQ,IAAI,cAAc,MAAM,IAAK;AAEzC,QAAM,WACJ,QAAQ,IAAI,aAAa,KACzB,QAAQ,IAAI,aAAa,KACzB,QAAQ,IAAI,YAAY,KACxB,QAAQ,IAAI,YAAY;AAC1B,MAAI,UAAU;AACZ,QAAI;AAEF,YAAM,EAAE,YAAY,oBAAoB,IAAI,MAAM,OAAO,QAAQ;AACjE,0BAAoB,IAAI,WAAW,QAAQ,CAAC;AAAA,IAC9C,QAAQ;AACN,cAAQ,MAAM,2EAA2E;AAAA,IAC3F;AAAA,EACF;AACF;;;ADnBA,SAAS,WAAW,mBAAmB;AAEvC,SAAS,cAAc,YAAY,yBAAyB;AAX5D,IAAI,QAAQ,IAAI,cAAc,MAAM,IAAK,SAAQ,IAAI,UAAU,IAAI;AACnE,IAAI,QAAQ,KAAK,SAAS,YAAY,GAAG;AACvC,UAAQ,IAAI,UAAU,IAAI;AAC5B;AAYA,IAAM,cACJ,QAAQ,KAAK,SAAS,QAAQ,KAC9B,QAAQ,KAAK,SAAS,IAAI,KAC1B,QAAQ,KAAK,SAAS,MAAM,KAC3B,QAAQ,KAAK,SAAS,UAAU,KAC/B,QAAQ,KAAK,QAAQ,KAAK,QAAQ,UAAU,IAAI,CAAC,MAAM,UACxD,QAAQ,KAAK,SAAS,IAAI,KACzB,QAAQ,KAAK,QAAQ,KAAK,QAAQ,IAAI,IAAI,CA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6 +7,8 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
analyzeBundle,
|
|
9
9
|
compareBundles,
|
|
10
|
+
topFiles,
|
|
11
|
+
checkBundleSize,
|
|
10
12
|
formatOutput
|
|
11
13
|
} from "@gpc-cli/core";
|
|
12
14
|
function formatSize(bytes) {
|
|
@@ -22,7 +24,7 @@ function formatDelta(delta) {
|
|
|
22
24
|
}
|
|
23
25
|
function registerBundleCommands(program) {
|
|
24
26
|
const bundle = program.command("bundle").description("Analyze app bundles and APKs");
|
|
25
|
-
bundle.command("analyze <file>").description("Analyze size breakdown of an AAB or APK").option("--threshold <mb>", "Fail if compressed size exceeds threshold (MB)", parseFloat).action(async (file, opts) => {
|
|
27
|
+
bundle.command("analyze <file>").description("Analyze size breakdown of an AAB or APK").option("--threshold <mb>", "Fail if compressed size exceeds threshold (MB)", parseFloat).option("--top <n>", "Show top N largest files", (v) => parseInt(v, 10)).option("--config <file>", "Check against .bundlesize.json thresholds").action(async (file, opts) => {
|
|
26
28
|
const format = getOutputFormat(program, await getConfig());
|
|
27
29
|
try {
|
|
28
30
|
const analysis = await analyzeBundle(file);
|
|
@@ -82,6 +84,29 @@ File: ${analysis.filePath}`);
|
|
|
82
84
|
console.log("\nCategories:");
|
|
83
85
|
console.log(formatOutput(categoryRows, "table"));
|
|
84
86
|
}
|
|
87
|
+
if (opts.top !== void 0) {
|
|
88
|
+
const largest = topFiles(analysis, opts.top);
|
|
89
|
+
const topRows = largest.map((e) => ({
|
|
90
|
+
path: e.path,
|
|
91
|
+
compressed: formatSize(e.compressedSize),
|
|
92
|
+
uncompressed: formatSize(e.uncompressedSize),
|
|
93
|
+
category: e.category
|
|
94
|
+
}));
|
|
95
|
+
console.log(`
|
|
96
|
+
Top ${opts.top} files:`);
|
|
97
|
+
console.log(formatOutput(topRows, format === "json" ? "table" : format));
|
|
98
|
+
}
|
|
99
|
+
if (opts.config) {
|
|
100
|
+
const check = await checkBundleSize(analysis, opts.config);
|
|
101
|
+
if (!check.passed) {
|
|
102
|
+
console.error(`
|
|
103
|
+
Bundle size check failed:`);
|
|
104
|
+
for (const v of check.violations) {
|
|
105
|
+
console.error(` ${v.subject}: ${formatSize(v.actual)} > max ${formatSize(v.max)}`);
|
|
106
|
+
}
|
|
107
|
+
process.exit(6);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
85
110
|
if (opts.threshold !== void 0) {
|
|
86
111
|
const thresholdBytes = opts.threshold * 1024 * 1024;
|
|
87
112
|
if (analysis.totalCompressed > thresholdBytes) {
|
|
@@ -181,4 +206,4 @@ async function getConfig() {
|
|
|
181
206
|
export {
|
|
182
207
|
registerBundleCommands
|
|
183
208
|
};
|
|
184
|
-
//# sourceMappingURL=bundle-
|
|
209
|
+
//# sourceMappingURL=bundle-7XYHNVNF.js.map
|