@gpc-cli/cli 0.9.53 → 0.9.55
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 +19 -19
- package/dist/{anomalies-V3AFS4LD.js → anomalies-I5P6QQAZ.js} +14 -5
- package/dist/anomalies-I5P6QQAZ.js.map +1 -0
- package/dist/{apps-4GP3FD7O.js → apps-WPUQOQLL.js} +2 -2
- package/dist/{audit-VTWXTXC6.js → audit-M7GYID74.js} +2 -2
- package/dist/{auth-BA4FE2PO.js → auth-4DRT7ZH2.js} +10 -4
- package/dist/auth-4DRT7ZH2.js.map +1 -0
- package/dist/bin.js +17 -2
- package/dist/bin.js.map +1 -1
- package/dist/{bundle-F7MUVC5J.js → bundle-PFTE7XMU.js} +4 -2
- package/dist/bundle-PFTE7XMU.js.map +1 -0
- package/dist/{cache-XKPLZYEB.js → cache-FGNP7Y37.js} +6 -2
- package/dist/cache-FGNP7Y37.js.map +1 -0
- package/dist/{chunk-SLNJEAMK.js → chunk-22XCOLZX.js} +4 -2
- package/dist/chunk-22XCOLZX.js.map +1 -0
- package/dist/{chunk-BCBXQC7J.js → chunk-E7SVZ7RF.js} +1 -1
- package/dist/chunk-E7SVZ7RF.js.map +1 -0
- package/dist/{chunk-NQH4G7BI.js → chunk-JDRY7HK5.js} +6 -9
- package/dist/chunk-JDRY7HK5.js.map +1 -0
- package/dist/{chunk-YFUBD2XB.js → chunk-RZQSEDKI.js} +6 -9
- package/dist/chunk-RZQSEDKI.js.map +1 -0
- package/dist/{chunk-A7VRCCNS.js → chunk-WSLFHX5X.js} +3 -3
- package/dist/chunk-WSLFHX5X.js.map +1 -0
- package/dist/{chunk-GQVZ2VCT.js → chunk-YI665FMH.js} +48 -45
- package/dist/chunk-YI665FMH.js.map +1 -0
- package/dist/{config-KT3PIL52.js → config-MMDIHSOC.js} +3 -3
- package/dist/{data-safety-AFMD6MYI.js → data-safety-46VY64OO.js} +12 -4
- package/dist/data-safety-46VY64OO.js.map +1 -0
- package/dist/{device-tiers-AQAMUQXI.js → device-tiers-MNZYMG3Y.js} +2 -2
- package/dist/device-tiers-MNZYMG3Y.js.map +1 -0
- package/dist/{diff-6EO4ID6W.js → diff-OBSHUSTL.js} +2 -2
- package/dist/diff-OBSHUSTL.js.map +1 -0
- package/dist/{docs-GMFN6V4K.js → docs-GP6AEX4N.js} +8 -4
- package/dist/docs-GP6AEX4N.js.map +1 -0
- package/dist/{doctor-GNI44SIP.js → doctor-CGTWTJL5.js} +5 -5
- package/dist/doctor-CGTWTJL5.js.map +1 -0
- package/dist/{external-transactions-LCZALS3V.js → external-transactions-JL3G4IG5.js} +11 -5
- package/dist/external-transactions-JL3G4IG5.js.map +1 -0
- package/dist/{feedback-XVTGMIBB.js → feedback-U33XJWEE.js} +3 -3
- package/dist/feedback-U33XJWEE.js.map +1 -0
- package/dist/{games-ZSNGEI7A.js → games-SVFN2YIS.js} +2 -2
- package/dist/games-SVFN2YIS.js.map +1 -0
- package/dist/{generated-apks-RX2IUWSF.js → generated-apks-TC33S2YN.js} +2 -2
- package/dist/generated-apks-TC33S2YN.js.map +1 -0
- package/dist/{grants-EBPECI26.js → grants-UHNBPIFD.js} +10 -3
- package/dist/grants-UHNBPIFD.js.map +1 -0
- package/dist/{iap-OUI5YYN4.js → iap-ETOL7OAC.js} +4 -4
- package/dist/iap-ETOL7OAC.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/{init-WSTQTJOD.js → init-6CCSVJC2.js} +7 -3
- package/dist/init-6CCSVJC2.js.map +1 -0
- package/dist/{install-skills-JKPYZHYS.js → install-skills-S342NJ7T.js} +7 -3
- package/dist/{install-skills-JKPYZHYS.js.map → install-skills-S342NJ7T.js.map} +1 -1
- package/dist/{internal-sharing-ONNIWIAT.js → internal-sharing-KW6YENDG.js} +2 -2
- package/dist/internal-sharing-KW6YENDG.js.map +1 -0
- package/dist/{listings-LNX6MQYN.js → listings-MOHHHNE6.js} +27 -7
- package/dist/listings-MOHHHNE6.js.map +1 -0
- package/dist/one-time-products-Y5RNIPV2.js +472 -0
- package/dist/one-time-products-Y5RNIPV2.js.map +1 -0
- package/dist/{preflight-W3JAJ4GO.js → preflight-KIWZPFTX.js} +4 -13
- package/dist/preflight-KIWZPFTX.js.map +1 -0
- package/dist/{pricing-JJZFICFL.js → pricing-HYQRXKNO.js} +3 -3
- package/dist/pricing-HYQRXKNO.js.map +1 -0
- package/dist/{prompt-GXC2JSLA.js → prompt-HJXNXXAR.js} +2 -2
- package/dist/{publish-P5KIGSLI.js → publish-26SSZ2W3.js} +11 -5
- package/dist/publish-26SSZ2W3.js.map +1 -0
- package/dist/{purchases-UBFLNYZC.js → purchases-AHWGLW6V.js} +35 -32
- package/dist/purchases-AHWGLW6V.js.map +1 -0
- package/dist/{quickstart-Z5Y3FYJU.js → quickstart-FOWM3OKT.js} +7 -2
- package/dist/quickstart-FOWM3OKT.js.map +1 -0
- package/dist/{recovery-YE3Z7NIN.js → recovery-B7DZQ6XG.js} +28 -12
- package/dist/recovery-B7DZQ6XG.js.map +1 -0
- package/dist/{releases-LUAHKIMY.js → releases-XY57V22L.js} +33 -8
- package/dist/releases-XY57V22L.js.map +1 -0
- package/dist/{reviews-YCBBM656.js → reviews-P4M6BEJI.js} +4 -6
- package/dist/reviews-P4M6BEJI.js.map +1 -0
- package/dist/{rtdn-LID2B7XZ.js → rtdn-YII4H6SD.js} +29 -21
- package/dist/rtdn-YII4H6SD.js.map +1 -0
- package/dist/{status-3HXBBXG6.js → status-32AJ7A6O.js} +13 -32
- package/dist/status-32AJ7A6O.js.map +1 -0
- package/dist/{subscriptions-LURZFPGJ.js → subscriptions-GTVJB4HX.js} +49 -12
- package/dist/subscriptions-GTVJB4HX.js.map +1 -0
- package/dist/system-apks-L6M7QYB3.js +111 -0
- package/dist/system-apks-L6M7QYB3.js.map +1 -0
- package/dist/{testers-6CQL4KQV.js → testers-QUWZHO6M.js} +25 -7
- package/dist/testers-QUWZHO6M.js.map +1 -0
- package/dist/{tracks-I4QZNZ3M.js → tracks-RH3RKVFB.js} +9 -3
- package/dist/{tracks-I4QZNZ3M.js.map → tracks-RH3RKVFB.js.map} +1 -1
- package/dist/{train-MDD2EBHS.js → train-D2NKUW3M.js} +3 -3
- package/dist/train-D2NKUW3M.js.map +1 -0
- package/dist/{update-QPPKXWI5.js → update-XDZNCXX5.js} +8 -11
- package/dist/{update-QPPKXWI5.js.map → update-XDZNCXX5.js.map} +1 -1
- package/dist/{users-UKG7VIQH.js → users-FOMAT7DY.js} +2 -2
- package/dist/{validate-QIYSA3N7.js → validate-RHWEZYD2.js} +6 -2
- package/dist/validate-RHWEZYD2.js.map +1 -0
- package/dist/{verify-UUQNQMPG.js → verify-H4ZUVHMZ.js} +5 -13
- package/dist/verify-H4ZUVHMZ.js.map +1 -0
- package/dist/{version-KUWLAZGT.js → version-N3SIB5Z4.js} +3 -3
- package/dist/{vitals-PJEQUUAK.js → vitals-PRBPNMVC.js} +26 -8
- package/dist/vitals-PRBPNMVC.js.map +1 -0
- package/package.json +7 -7
- package/dist/anomalies-V3AFS4LD.js.map +0 -1
- package/dist/auth-BA4FE2PO.js.map +0 -1
- package/dist/bundle-F7MUVC5J.js.map +0 -1
- package/dist/cache-XKPLZYEB.js.map +0 -1
- package/dist/chunk-A7VRCCNS.js.map +0 -1
- package/dist/chunk-BCBXQC7J.js.map +0 -1
- package/dist/chunk-GQVZ2VCT.js.map +0 -1
- package/dist/chunk-NQH4G7BI.js.map +0 -1
- package/dist/chunk-SLNJEAMK.js.map +0 -1
- package/dist/chunk-YFUBD2XB.js.map +0 -1
- package/dist/data-safety-AFMD6MYI.js.map +0 -1
- package/dist/device-tiers-AQAMUQXI.js.map +0 -1
- package/dist/diff-6EO4ID6W.js.map +0 -1
- package/dist/docs-GMFN6V4K.js.map +0 -1
- package/dist/doctor-GNI44SIP.js.map +0 -1
- package/dist/external-transactions-LCZALS3V.js.map +0 -1
- package/dist/feedback-XVTGMIBB.js.map +0 -1
- package/dist/games-ZSNGEI7A.js.map +0 -1
- package/dist/generated-apks-RX2IUWSF.js.map +0 -1
- package/dist/grants-EBPECI26.js.map +0 -1
- package/dist/iap-OUI5YYN4.js.map +0 -1
- package/dist/init-WSTQTJOD.js.map +0 -1
- package/dist/internal-sharing-ONNIWIAT.js.map +0 -1
- package/dist/listings-LNX6MQYN.js.map +0 -1
- package/dist/one-time-products-MGZTU7OM.js +0 -254
- package/dist/one-time-products-MGZTU7OM.js.map +0 -1
- package/dist/preflight-W3JAJ4GO.js.map +0 -1
- package/dist/pricing-JJZFICFL.js.map +0 -1
- package/dist/publish-P5KIGSLI.js.map +0 -1
- package/dist/purchases-UBFLNYZC.js.map +0 -1
- package/dist/quickstart-Z5Y3FYJU.js.map +0 -1
- package/dist/recovery-YE3Z7NIN.js.map +0 -1
- package/dist/releases-LUAHKIMY.js.map +0 -1
- package/dist/reviews-YCBBM656.js.map +0 -1
- package/dist/rtdn-LID2B7XZ.js.map +0 -1
- package/dist/status-3HXBBXG6.js.map +0 -1
- package/dist/subscriptions-LURZFPGJ.js.map +0 -1
- package/dist/testers-6CQL4KQV.js.map +0 -1
- package/dist/train-MDD2EBHS.js.map +0 -1
- package/dist/validate-QIYSA3N7.js.map +0 -1
- package/dist/verify-UUQNQMPG.js.map +0 -1
- package/dist/vitals-PJEQUUAK.js.map +0 -1
- /package/dist/{apps-4GP3FD7O.js.map → apps-WPUQOQLL.js.map} +0 -0
- /package/dist/{audit-VTWXTXC6.js.map → audit-M7GYID74.js.map} +0 -0
- /package/dist/{config-KT3PIL52.js.map → config-MMDIHSOC.js.map} +0 -0
- /package/dist/{prompt-GXC2JSLA.js.map → prompt-HJXNXXAR.js.map} +0 -0
- /package/dist/{users-UKG7VIQH.js.map → users-FOMAT7DY.js.map} +0 -0
- /package/dist/{version-KUWLAZGT.js.map → version-N3SIB5Z4.js.map} +0 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**Ship Android apps from your terminal.** The complete CLI for the Google Play Developer API.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
215 API endpoints. No Ruby. No browser. No ceremony.
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install -g @gpc-cli/cli
|
|
@@ -23,15 +23,15 @@ gpc doctor # 20 setup checks
|
|
|
23
23
|
|
|
24
24
|
## Why this over Fastlane?
|
|
25
25
|
|
|
26
|
-
| | **GPC** | Fastlane supply
|
|
27
|
-
| ----------------- | ----------------- |
|
|
28
|
-
| API coverage | **
|
|
29
|
-
| Runtime | Node.js or binary | Ruby + Bundler
|
|
30
|
-
| Cold start | <500ms | 2-3s
|
|
31
|
-
| Reviews & Vitals | Yes | No
|
|
32
|
-
| Subscriptions | Yes | No
|
|
33
|
-
| Preflight scanner | 9 offline checks | No
|
|
34
|
-
| CI/CD native | JSON + exit codes | Partial
|
|
26
|
+
| | **GPC** | Fastlane supply |
|
|
27
|
+
| ----------------- | ----------------- | --------------- |
|
|
28
|
+
| API coverage | **215 endpoints** | ~20 |
|
|
29
|
+
| Runtime | Node.js or binary | Ruby + Bundler |
|
|
30
|
+
| Cold start | <500ms | 2-3s |
|
|
31
|
+
| Reviews & Vitals | Yes | No |
|
|
32
|
+
| Subscriptions | Yes | No |
|
|
33
|
+
| Preflight scanner | 9 offline checks | No |
|
|
34
|
+
| CI/CD native | JSON + exit codes | Partial |
|
|
35
35
|
|
|
36
36
|
[Migration guide](https://yasserstudio.github.io/gpc/migration/from-fastlane) with one-to-one command mapping.
|
|
37
37
|
|
|
@@ -69,14 +69,14 @@ curl -fsSL https://raw.githubusercontent.com/yasserstudio/gpc/main/scripts/insta
|
|
|
69
69
|
|
|
70
70
|
## Related packages
|
|
71
71
|
|
|
72
|
-
| Package
|
|
73
|
-
|
|
|
74
|
-
| [@gpc-cli/api](https://www.npmjs.com/package/@gpc-cli/api)
|
|
75
|
-
| [@gpc-cli/auth](https://www.npmjs.com/package/@gpc-cli/auth)
|
|
76
|
-
| [@gpc-cli/core](https://www.npmjs.com/package/@gpc-cli/core)
|
|
77
|
-
| [@gpc-cli/config](https://www.npmjs.com/package/@gpc-cli/config)
|
|
78
|
-
| [@gpc-cli/plugin-sdk](https://www.npmjs.com/package/@gpc-cli/plugin-sdk) | Plugin interface
|
|
79
|
-
| [@gpc-cli/plugin-ci](https://www.npmjs.com/package/@gpc-cli/plugin-ci)
|
|
72
|
+
| Package | What it does |
|
|
73
|
+
| ------------------------------------------------------------------------ | ------------------------------------------------ |
|
|
74
|
+
| [@gpc-cli/api](https://www.npmjs.com/package/@gpc-cli/api) | Typed Google Play API v3 client (standalone SDK) |
|
|
75
|
+
| [@gpc-cli/auth](https://www.npmjs.com/package/@gpc-cli/auth) | Authentication (service account, OAuth, ADC) |
|
|
76
|
+
| [@gpc-cli/core](https://www.npmjs.com/package/@gpc-cli/core) | Business logic and orchestration |
|
|
77
|
+
| [@gpc-cli/config](https://www.npmjs.com/package/@gpc-cli/config) | Configuration and profiles |
|
|
78
|
+
| [@gpc-cli/plugin-sdk](https://www.npmjs.com/package/@gpc-cli/plugin-sdk) | Plugin interface |
|
|
79
|
+
| [@gpc-cli/plugin-ci](https://www.npmjs.com/package/@gpc-cli/plugin-ci) | CI/CD helpers |
|
|
80
80
|
|
|
81
81
|
## Links
|
|
82
82
|
|
|
@@ -85,7 +85,7 @@ curl -fsSL https://raw.githubusercontent.com/yasserstudio/gpc/main/scripts/insta
|
|
|
85
85
|
- [Commands reference](https://yasserstudio.github.io/gpc/commands/)
|
|
86
86
|
- [CI/CD recipes](https://yasserstudio.github.io/gpc/ci-cd/)
|
|
87
87
|
|
|
88
|
-
Free to use. 1,
|
|
88
|
+
Free to use. 1,874 tests. 90%+ coverage. Every write operation supports `--dry-run`.
|
|
89
89
|
|
|
90
90
|
## License
|
|
91
91
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
resolvePackageName
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-JDRY7HK5.js";
|
|
5
5
|
import {
|
|
6
6
|
yellow
|
|
7
7
|
} from "./chunk-FAN4ZITI.js";
|
|
@@ -31,10 +31,19 @@ function registerAnomaliesCommands(program) {
|
|
|
31
31
|
} catch (err) {
|
|
32
32
|
if (err instanceof PlayApiError && err.statusCode === 403) {
|
|
33
33
|
if (format === "json") {
|
|
34
|
-
console.log(
|
|
34
|
+
console.log(
|
|
35
|
+
formatOutput(
|
|
36
|
+
{ anomalies: [], message: "Reporting API not enabled or insufficient permissions" },
|
|
37
|
+
format
|
|
38
|
+
)
|
|
39
|
+
);
|
|
35
40
|
} else {
|
|
36
|
-
console.log(
|
|
37
|
-
|
|
41
|
+
console.log(
|
|
42
|
+
`${yellow("\u26A0")} No anomaly data available. The Reporting API may not be enabled for this project.`
|
|
43
|
+
);
|
|
44
|
+
console.log(
|
|
45
|
+
` Enable it at: https://console.cloud.google.com/apis/library/playdeveloperreporting.googleapis.com`
|
|
46
|
+
);
|
|
38
47
|
}
|
|
39
48
|
return;
|
|
40
49
|
}
|
|
@@ -63,4 +72,4 @@ function registerAnomaliesCommands(program) {
|
|
|
63
72
|
export {
|
|
64
73
|
registerAnomaliesCommands
|
|
65
74
|
};
|
|
66
|
-
//# sourceMappingURL=anomalies-
|
|
75
|
+
//# sourceMappingURL=anomalies-I5P6QQAZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/anomalies.ts"],"sourcesContent":["import { resolvePackageName } from \"../resolve.js\";\nimport 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, PlayApiError } from \"@gpc-cli/api\";\nimport { getVitalsAnomalies, formatOutput } from \"@gpc-cli/core\";\nimport { getOutputFormat } from \"../format.js\";\nimport { yellow } from \"../colors.js\";\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.command(\"anomalies\").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 let result;\n try {\n result = await getVitalsAnomalies(reporting, packageName);\n } catch (err) {\n if (err instanceof PlayApiError && err.statusCode === 403) {\n if (format === \"json\") {\n console.log(\n formatOutput(\n { anomalies: [], message: \"Reporting API not enabled or insufficient permissions\" },\n format,\n ),\n );\n } else {\n console.log(\n `${yellow(\"⚠\")} No anomaly data available. The Reporting API may not be enabled for this project.`,\n );\n console.log(\n ` Enable it at: https://console.cloud.google.com/apis/library/playdeveloperreporting.googleapis.com`,\n );\n }\n return;\n }\n throw err;\n }\n const items = (result as unknown as Record<string, unknown>)[\"anomalies\"] as\n | unknown[]\n | 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 });\n}\n"],"mappings":";;;;;;;;;;;;AAGA,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB,oBAAoB;AACpD,SAAS,oBAAoB,oBAAoB;AAIjD,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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ACF,CAAC;AACL;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
buildCommitOptions
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WSLFHX5X.js";
|
|
5
5
|
import {
|
|
6
6
|
isDryRun,
|
|
7
7
|
printDryRun
|
|
@@ -101,4 +101,4 @@ function registerAppsCommands(program) {
|
|
|
101
101
|
export {
|
|
102
102
|
registerAppsCommands
|
|
103
103
|
};
|
|
104
|
-
//# sourceMappingURL=apps-
|
|
104
|
+
//# sourceMappingURL=apps-WPUQOQLL.js.map
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./chunk-ELXAK7GI.js";
|
|
8
8
|
import {
|
|
9
9
|
requireConfirm
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-RZQSEDKI.js";
|
|
11
11
|
|
|
12
12
|
// src/commands/audit.ts
|
|
13
13
|
import { loadConfig } from "@gpc-cli/config";
|
|
@@ -122,4 +122,4 @@ function registerAuditCommands(program) {
|
|
|
122
122
|
export {
|
|
123
123
|
registerAuditCommands
|
|
124
124
|
};
|
|
125
|
-
//# sourceMappingURL=audit-
|
|
125
|
+
//# sourceMappingURL=audit-M7GYID74.js.map
|
|
@@ -34,7 +34,9 @@ async function runLoginWizard(program) {
|
|
|
34
34
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
35
35
|
try {
|
|
36
36
|
console.log("\nGPC Authentication Setup");
|
|
37
|
-
console.log(
|
|
37
|
+
console.log(
|
|
38
|
+
"\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"
|
|
39
|
+
);
|
|
38
40
|
console.log("\nAuthentication methods:");
|
|
39
41
|
console.log(" 1. Service account key file (recommended)");
|
|
40
42
|
console.log(" 2. Application Default Credentials (ADC)");
|
|
@@ -258,7 +260,9 @@ function registerAuthCommands(program) {
|
|
|
258
260
|
console.log("\nStep 3: Grant roles");
|
|
259
261
|
console.log(" No GCP roles needed \u2014 permissions are managed in Google Play Console.");
|
|
260
262
|
console.log("\nStep 4: Download the JSON key");
|
|
261
|
-
console.log(
|
|
263
|
+
console.log(
|
|
264
|
+
" \u2022 Click your new service account \u2192 Keys \u2192 Add Key \u2192 Create new key \u2192 JSON"
|
|
265
|
+
);
|
|
262
266
|
console.log(" \u2022 Save as: ~/gpc-service-account.json");
|
|
263
267
|
console.log("\nStep 5: Add to Google Play Console");
|
|
264
268
|
console.log(" https://play.google.com/console/developers");
|
|
@@ -319,7 +323,9 @@ Step 6: Authenticating...`);
|
|
|
319
323
|
await setConfigValue2("auth.serviceAccount", absPath);
|
|
320
324
|
console.log(`\u2713 Authenticated and saved to config`);
|
|
321
325
|
} catch (err) {
|
|
322
|
-
console.error(
|
|
326
|
+
console.error(
|
|
327
|
+
`\u2717 Authentication failed: ${err instanceof Error ? err.message : String(err)}`
|
|
328
|
+
);
|
|
323
329
|
console.log(`
|
|
324
330
|
Try manually: gpc auth login --service-account ${absPath}`);
|
|
325
331
|
return;
|
|
@@ -349,4 +355,4 @@ Step 7: Verifying setup...`);
|
|
|
349
355
|
export {
|
|
350
356
|
registerAuthCommands
|
|
351
357
|
};
|
|
352
|
-
//# sourceMappingURL=auth-
|
|
358
|
+
//# sourceMappingURL=auth-4DRT7ZH2.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 { resolve } from \"node:path\";\nimport { resolveAuth, loadServiceAccountKey, clearTokenCache, AuthError } from \"@gpc-cli/auth\";\nimport { loadConfig, getCacheDir, deleteConfigValue, setConfigValue } from \"@gpc-cli/config\";\nimport { formatOutput } from \"@gpc-cli/core\";\nimport { getOutputFormat } from \"../format.js\";\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nasync function askQuestion(\n rl: ReturnType<typeof createInterface>,\n question: string,\n): Promise<string> {\n return new Promise((resolve) => {\n rl.question(question, (answer) => resolve(answer.trim()));\n });\n}\n\n/** Resolve a path to absolute (prevents CWD-dependent config). */\nfunction toAbsolutePath(pathStr: string): string {\n return resolve(pathStr);\n}\n\n/** Verify that the saved credentials can acquire a token. */\nasync function verifyToken(\n serviceAccountPath?: string,\n): Promise<{ email: string; ok: boolean; error?: string }> {\n try {\n const client = await resolveAuth({ serviceAccountPath });\n const email = client.getClientEmail();\n await client.getAccessToken();\n return { email, ok: true };\n } catch (err) {\n const email = \"unknown\";\n const msg = err instanceof Error ? err.message : String(err);\n return { email, ok: false, error: msg };\n }\n}\n\n// ---------------------------------------------------------------------------\n// Interactive login wizard\n// ---------------------------------------------------------------------------\n\nasync function runLoginWizard(program: Command): 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 \"\\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\",\n );\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 client = await resolveAuth();\n const email = client.getClientEmail();\n // Verify token works\n await client.getAccessToken();\n outputLoginResult(program, { account: email, method: \"adc\", verified: true });\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) {\n console.log(\" Path is required.\");\n continue;\n }\n try {\n await access(input);\n saPath = toAbsolutePath(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(\n rl,\n \"Default package name (optional, e.g. com.example.app): \",\n );\n\n // Apply settings\n const key = await loadServiceAccountKey(saPath);\n\n if (profileName) {\n const { setProfileConfig } = await import(\"@gpc-cli/config\");\n await setProfileConfig(profileName, {\n auth: { serviceAccount: saPath },\n ...(packageName && { app: packageName }),\n });\n } else {\n await setConfigValue(\"auth.serviceAccount\", saPath);\n if (packageName) await setConfigValue(\"app\", packageName);\n }\n\n // Verify token\n const verification = await verifyToken(saPath);\n\n outputLoginResult(program, {\n account: key.client_email,\n project: key.project_id,\n method: \"service-account\",\n profile: profileName || undefined,\n verified: verification.ok,\n verifyError: verification.error,\n });\n } finally {\n rl.close();\n }\n}\n\n// ---------------------------------------------------------------------------\n// Structured login output\n// ---------------------------------------------------------------------------\n\ninterface LoginResult {\n account: string;\n project?: string;\n method: string;\n profile?: string;\n verified: boolean;\n verifyError?: string;\n}\n\nfunction outputLoginResult(program: Command, result: LoginResult): void {\n const parentOpts = program.opts() ?? {};\n const jsonMode = !!(parentOpts[\"json\"] || parentOpts[\"output\"] === \"json\");\n\n if (jsonMode) {\n console.log(\n JSON.stringify({\n success: true,\n account: result.account,\n project: result.project,\n method: result.method,\n profile: result.profile,\n verified: result.verified,\n ...(result.verifyError && { verifyError: result.verifyError }),\n }),\n );\n return;\n }\n\n if (result.profile) {\n console.log(`\\nProfile \"${result.profile}\" configured with ${result.account}`);\n } else if (result.method === \"adc\") {\n console.log(`\\nAuthenticated via Application Default Credentials`);\n console.log(`Account: ${result.account}`);\n } else {\n console.log(`\\nAuthenticated as ${result.account}`);\n }\n if (result.project) console.log(`Project: ${result.project}`);\n\n if (result.verified) {\n console.log(\"Verified: token acquired successfully\");\n } else if (result.verifyError) {\n console.log(`Warning: token verification failed: ${result.verifyError}`);\n console.log(\"Credentials saved, but check your setup with: gpc doctor\");\n }\n\n if (!result.verifyError) {\n console.log(\"\\nRun 'gpc doctor' to verify your full setup.\");\n }\n}\n\n// ---------------------------------------------------------------------------\n// Command registration\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 if (options.serviceAccount) {\n const absolutePath = toAbsolutePath(options.serviceAccount);\n const key = await loadServiceAccountKey(absolutePath);\n\n if (options.profile) {\n const { setProfileConfig } = await import(\"@gpc-cli/config\");\n await setProfileConfig(options.profile, {\n auth: { serviceAccount: absolutePath },\n });\n } else {\n await setConfigValue(\"auth.serviceAccount\", absolutePath);\n }\n\n // Verify token works\n const verification = await verifyToken(absolutePath);\n\n outputLoginResult(program, {\n account: key.client_email,\n project: key.project_id,\n method: \"service-account\",\n profile: options.profile,\n verified: verification.ok,\n verifyError: verification.error,\n });\n } else if (options.adc) {\n const client = await resolveAuth();\n const email = client.getClientEmail();\n await client.getAccessToken();\n outputLoginResult(program, { account: email, method: \"adc\", verified: true });\n } else {\n // Interactive wizard when no flags provided and in interactive mode\n const opts = program.opts();\n const interactive =\n opts[\"interactive\"] !== false && opts[\"ci\"] !== true && process.stdin.isTTY;\n if (interactive) {\n await runLoginWizard(program);\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 });\n\n auth\n .command(\"status\")\n .description(\"Show current authentication status\")\n .action(async () => {\n const config = await loadConfig();\n const format = getOutputFormat(program, config);\n try {\n const client = await resolveAuth({\n serviceAccountPath: config.auth?.serviceAccount,\n cachePath: getCacheDir(),\n });\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 data = {\n authenticated: false,\n error: error.message,\n suggestion: error.suggestion,\n };\n console.log(formatOutput(data, format));\n }\n throw error; // Let error handler set exit code 3\n }\n });\n\n auth\n .command(\"logout\")\n .description(\"Clear stored credentials and token cache\")\n .option(\"--profile <name>\", \"Clear credentials for a specific profile\")\n .action(async (options: { profile?: string }) => {\n if (options.profile) {\n const { deleteProfile } = await import(\"@gpc-cli/config\");\n const deleted = await deleteProfile(options.profile);\n if (deleted) {\n console.log(`Profile \"${options.profile}\" removed.`);\n } else {\n console.log(`Profile \"${options.profile}\" not found.`);\n }\n } else {\n await deleteConfigValue(\"auth.serviceAccount\");\n console.log(\"Credentials cleared.\");\n }\n await clearTokenCache(getCacheDir());\n console.log(\"Token cache cleared.\");\n });\n\n auth\n .command(\"whoami\")\n .description(\"Show current authenticated identity\")\n .action(async () => {\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 });\n\n auth\n .command(\"switch <profile>\")\n .description(\"Switch to a named profile\")\n .action(async (profile: string) => {\n // loadConfig with the profile will throw ConfigError if profile doesn't exist\n const config = await loadConfig({ profile });\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 });\n\n auth\n .command(\"token\")\n .description(\"Print the current access token (useful for manual API calls)\")\n .action(async () => {\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 });\n\n auth\n .command(\"setup-gcp\")\n .description(\"Step-by-step guide to create a Google Cloud service account\")\n .option(\"--key <path>\", \"Path to an already-downloaded service account JSON key\")\n .action(async (options: { key?: string }) => {\n const { existsSync, readFileSync } = await import(\"node:fs\");\n const { resolve } = await import(\"node:path\");\n\n console.log(\"\\nGPC \\u2014 Google Cloud Service Account Setup\");\n console.log(\"\\u2550\".repeat(50));\n\n // If key path provided or user already has one, skip to validation\n let keyPath = options.key;\n\n if (!keyPath) {\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(\" \\u2022 Click 'Create Service Account'\");\n console.log(\" \\u2022 Name it: gpc-deploy (or any name you like)\");\n console.log(\" \\u2022 Description: GPC Google Play Console access\");\n console.log(\"\\nStep 3: Grant roles\");\n console.log(\" No GCP roles needed \\u2014 permissions are managed in Google Play Console.\");\n console.log(\"\\nStep 4: Download the JSON key\");\n console.log(\n \" \\u2022 Click your new service account \\u2192 Keys \\u2192 Add Key \\u2192 Create new key \\u2192 JSON\",\n );\n console.log(\" \\u2022 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(\" \\u2022 Users and Permissions \\u2192 Invite new users\");\n console.log(\" \\u2022 Paste the service account email (ends with @...gserviceaccount.com)\");\n console.log(\" \\u2022 Grant: Release manager + View app info + Reply to reviews\");\n\n // Try to auto-detect a key file\n const commonPaths = [\n \"~/gpc-service-account.json\",\n \"./service-account.json\",\n \"./gpc-service-account.json\",\n \"~/.config/gpc/service-account.json\",\n ].map((p) => resolve(p.replace(\"~\", process.env[\"HOME\"] || \"\")));\n\n for (const p of commonPaths) {\n if (existsSync(p)) {\n console.log(`\\n\\u2713 Found key file: ${p}`);\n keyPath = p;\n break;\n }\n }\n\n if (!keyPath) {\n console.log(\"\\nOnce you've downloaded the key, run:\");\n console.log(\" gpc auth setup-gcp --key <path/to/key.json>\");\n console.log(\"\\nOr authenticate directly:\");\n console.log(\" gpc auth login --service-account <path/to/key.json>\");\n console.log(\"\\nSee full docs: https://yasserstudio.github.io/gpc/guide/authentication\");\n return;\n }\n }\n\n // Validate the key file\n const absPath = resolve(keyPath.replace(\"~\", process.env[\"HOME\"] || \"\"));\n if (!existsSync(absPath)) {\n console.error(`\\n\\u2717 File not found: ${absPath}`);\n return;\n }\n\n try {\n const content = JSON.parse(readFileSync(absPath, \"utf-8\"));\n if (content.type !== \"service_account\") {\n console.error(`\\n\\u2717 Not a service account key (type: ${content.type})`);\n return;\n }\n console.log(`\\n\\u2713 Valid service account key`);\n console.log(` Email: ${content.client_email}`);\n console.log(` Project: ${content.project_id}`);\n } catch {\n console.error(`\\n\\u2717 Invalid JSON file: ${absPath}`);\n return;\n }\n\n // Auto-login\n console.log(`\\nStep 6: Authenticating...`);\n try {\n const auth = await resolveAuth({ serviceAccountPath: absPath });\n await auth.getAccessToken();\n const { setConfigValue } = await import(\"@gpc-cli/config\");\n await setConfigValue(\"auth.serviceAccount\", absPath);\n console.log(`\\u2713 Authenticated and saved to config`);\n } catch (err) {\n console.error(\n `\\u2717 Authentication failed: ${err instanceof Error ? err.message : String(err)}`,\n );\n console.log(`\\nTry manually: gpc auth login --service-account ${absPath}`);\n return;\n }\n\n // Auto-run doctor\n console.log(`\\nStep 7: Verifying setup...`);\n console.log(` Run: gpc doctor`);\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"],"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OAAO,EAAE;AACtD;AAAA,IACF;AAGA,YAAQ,IAAI;AAAA,0BAA6B;AACzC,QAAI;AACF,YAAMC,QAAO,MAAM,YAAY,EAAE,oBAAoB,QAAQ,CAAC;AAC9D,YAAMA,MAAK,eAAe;AAC1B,YAAM,EAAE,gBAAAC,gBAAe,IAAI,MAAM,OAAO,iBAAiB;AACzD,YAAMA,gBAAe,uBAAuB,OAAO;AACnD,cAAQ,IAAI,0CAA0C;AAAA,IACxD,SAAS,KAAK;AACZ,cAAQ;AAAA,QACN,iCAAiC,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,MACnF;AACA,cAAQ,IAAI;AAAA,iDAAoD,OAAO,EAAE;AACzE;AAAA,IACF;AAGA,YAAQ,IAAI;AAAA,2BAA8B;AAC1C,YAAQ,IAAI,mBAAmB;AAAA,EACjC,CAAC;AAEH,OACG,QAAQ,UAAU,EAClB,YAAY,0BAA0B,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":["resolve","auth","setConfigValue"]}
|
package/dist/bin.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createProgram,
|
|
4
4
|
handleCliError,
|
|
5
5
|
loadPlugins
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YI665FMH.js";
|
|
7
7
|
import {
|
|
8
8
|
checkForUpdate,
|
|
9
9
|
formatUpdateNotification
|
|
@@ -33,6 +33,17 @@ async function setupNetworking() {
|
|
|
33
33
|
// src/bin.ts
|
|
34
34
|
import { initAudit, sendWebhook } from "@gpc-cli/core";
|
|
35
35
|
import { getConfigDir, loadConfig, getUserConfigPath } from "@gpc-cli/config";
|
|
36
|
+
|
|
37
|
+
// src/argv-profile.ts
|
|
38
|
+
function extractProfileFromArgv(argv) {
|
|
39
|
+
const idx = Math.max(argv.indexOf("--profile"), argv.indexOf("-p"));
|
|
40
|
+
if (idx === -1 || idx + 1 >= argv.length) return void 0;
|
|
41
|
+
const val = argv[idx + 1];
|
|
42
|
+
if (!val || val.startsWith("-")) return void 0;
|
|
43
|
+
return val;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/bin.ts
|
|
36
47
|
if (process.env["GPC_NO_COLOR"] === "1") process.env["NO_COLOR"] = "1";
|
|
37
48
|
if (process.argv.includes("--no-color")) {
|
|
38
49
|
process.env["NO_COLOR"] = "1";
|
|
@@ -46,7 +57,7 @@ if (!_isJsonMode && !_isQuiet && !_isSetupCommand && !existsSync(getUserConfigPa
|
|
|
46
57
|
}
|
|
47
58
|
await setupNetworking();
|
|
48
59
|
initAudit(getConfigDir());
|
|
49
|
-
var currentVersion = "0.9.
|
|
60
|
+
var currentVersion = "0.9.55";
|
|
50
61
|
var isUpdateCommand = process.argv[2] === "update";
|
|
51
62
|
var updateCheckPromise = isUpdateCommand ? Promise.resolve(null) : checkForUpdate(currentVersion);
|
|
52
63
|
if (process.argv.includes("--ci")) {
|
|
@@ -66,6 +77,10 @@ if (process.argv.includes("--json") || process.argv.includes("-j")) {
|
|
|
66
77
|
process.argv.push("--output", "json");
|
|
67
78
|
}
|
|
68
79
|
}
|
|
80
|
+
{
|
|
81
|
+
const profile = extractProfileFromArgv(process.argv);
|
|
82
|
+
if (profile) process.env["GPC_PROFILE"] = profile;
|
|
83
|
+
}
|
|
69
84
|
var pluginManager = await loadPlugins();
|
|
70
85
|
var program = await createProgram(pluginManager);
|
|
71
86
|
if (process.env["GPC_DEBUG"] === "1") {
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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\") && process.argv[process.argv.indexOf(\"-o\") + 1] === \"json\");\nconst _isQuiet = process.argv.includes(\"--quiet\") || process.argv.includes(\"-q\");\n\nconst _setupCommands = new Set([\"config\", \"auth\", \"quickstart\", \"doctor\", \"init\", \"setup-gcp\"]);\nconst _isSetupCommand = _setupCommands.has(process.argv[2] ?? \"\");\n\nif (!_isJsonMode && !_isQuiet && !_isSetupCommand && !existsSync(getUserConfigPath())) {\n process.stderr.write(\"\\u2726 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\n .slice(2)\n .filter((a) => !a.startsWith(\"--notify\"))\n .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,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,KAAK,EAAE,QAAQ;AACzC,IAAI,cAAc,UAAa,cAAc,OAAO;AAClD,MAAI;AACF,UAAM,SAAS,MAAM,WAAW;AAChC,QAAI,OAAO,UAAU;AACnB,YAAM,cAAc,QAAQ,KACzB,MAAM,CAAC,EACP,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,UAAU,CAAC,EACvC,KAAK,GAAG;AACX,YAAM,UAA0B;AAAA,QAC9B,SAAS,eAAe;AAAA,QACxB,SAAS;AAAA,QACT,UAAU,KAAK,IAAI,IAAI;AAAA,QACvB,KAAK,QAAQ,KAAK,EAAE,KAAK;AAAA,QACzB,OAAO;AAAA,MACT;AAEA,YAAM,SAAS,OAAO,cAAc,WAAW,YAAY;AAE3D,kBAAY,OAAO,UAAU,SAAS,MAAM,EAAE,MAAM,MAAM;AAAA,MAAC,CAAC;AAAA,IAC9D;AAAA,EACF,QAAQ;AAAA,EAER;AACF;AAIA,IAAI;AACF,QAAM,SAAS,MAAM,QAAQ,KAAK;AAAA,IAChC;AAAA,IACA,IAAI,QAAc,CAAC,YAAY,WAAW,MAAM,QAAQ,IAAI,GAAG,GAAI,CAAC;AAAA,EACtE,CAAC;AAED,MACE,UACA,OAAO,mBACP,CAAC,mBACD,QAAQ,OAAO,SACf,CAAC,QAAQ,KAAK,SAAS,QAAQ,KAC/B,QAAQ,KAAK,EAAE,QAAQ,MAAM,QAC7B;AACA,YAAQ,OAAO,MAAM;AAAA,EAAK,yBAAyB,MAAM,CAAC;AAAA,CAAI;AAAA,EAChE;AACF,QAAQ;AAER;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/bin.ts","../src/networking.ts","../src/argv-profile.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\") && process.argv[process.argv.indexOf(\"-o\") + 1] === \"json\");\nconst _isQuiet = process.argv.includes(\"--quiet\") || process.argv.includes(\"-q\");\n\nconst _setupCommands = new Set([\"config\", \"auth\", \"quickstart\", \"doctor\", \"init\", \"setup-gcp\"]);\nconst _isSetupCommand = _setupCommands.has(process.argv[2] ?? \"\");\n\nif (!_isJsonMode && !_isQuiet && !_isSetupCommand && !existsSync(getUserConfigPath())) {\n process.stderr.write(\"\\u2726 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\n// Propagate --profile / -p to GPC_PROFILE env var so loadConfig() picks it up.\n// Must run before any loadConfig() call (commands read env, not program.opts).\nimport { extractProfileFromArgv } from \"./argv-profile.js\";\n{\n const profile = extractProfileFromArgv(process.argv);\n if (profile) process.env[\"GPC_PROFILE\"] = profile;\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\n .slice(2)\n .filter((a) => !a.startsWith(\"--notify\"))\n .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","/**\n * Extract the value of --profile or -p from argv, if present.\n * Returns undefined if the flag is missing or its value looks like another flag.\n */\nexport function extractProfileFromArgv(argv: readonly string[]): string | undefined {\n const idx = Math.max(argv.indexOf(\"--profile\"), argv.indexOf(\"-p\"));\n if (idx === -1 || idx + 1 >= argv.length) return undefined;\n const val = argv[idx + 1];\n if (!val || val.startsWith(\"-\")) return undefined;\n return val;\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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O,SACf,CAAC,QAAQ,KAAK,SAAS,QAAQ,KAC/B,QAAQ,KAAK,EAAE,QAAQ,MAAM,QAC7B;AACA,YAAQ,OAAO,MAAM;AAAA,EAAK,yBAAyB,MAAM,CAAC;AAAA,CAAI;AAAA,EAChE;AACF,QAAQ;AAER;","names":[]}
|
|
@@ -107,7 +107,9 @@ Top ${opts.top} files:`);
|
|
|
107
107
|
if (opts.threshold !== void 0) {
|
|
108
108
|
const thresholdBytes = opts.threshold * 1024 * 1024;
|
|
109
109
|
if (analysis.totalCompressed > thresholdBytes) {
|
|
110
|
-
const err = new Error(
|
|
110
|
+
const err = new Error(
|
|
111
|
+
`Threshold breached: ${formatSize(analysis.totalCompressed)} > ${opts.threshold} MB`
|
|
112
|
+
);
|
|
111
113
|
Object.assign(err, { code: "THRESHOLD_BREACH", exitCode: 6 });
|
|
112
114
|
throw err;
|
|
113
115
|
}
|
|
@@ -201,4 +203,4 @@ async function getConfig() {
|
|
|
201
203
|
export {
|
|
202
204
|
registerBundleCommands
|
|
203
205
|
};
|
|
204
|
-
//# sourceMappingURL=bundle-
|
|
206
|
+
//# sourceMappingURL=bundle-PFTE7XMU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/bundle.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport {\n analyzeBundle,\n compareBundles,\n topFiles,\n checkBundleSize,\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 .option(\"--top <n>\", \"Show top N largest files\", (v) => parseInt(v, 10))\n .option(\"--config <file>\", \"Check against .bundlesize.json thresholds\")\n .action(async (file: string, opts: { threshold?: number; top?: number; config?: string }) => {\n const format = getOutputFormat(program, await getConfig());\n\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 // Top N files\n if (opts.top !== undefined) {\n const largest = topFiles(analysis, opts.top);\n const topRows = largest.map((e) => ({\n path: e.path,\n compressed: formatSize(e.compressedSize),\n uncompressed: formatSize(e.uncompressedSize),\n category: e.category,\n }));\n console.log(`\\nTop ${opts.top} files:`);\n console.log(formatOutput(topRows, format === \"json\" ? \"table\" : format));\n }\n\n // .bundlesize.json config check\n if (opts.config) {\n const check = await checkBundleSize(analysis, opts.config);\n if (!check.passed) {\n const violations = check.violations\n .map((v) => `${v.subject}: ${formatSize(v.actual)} > max ${formatSize(v.max)}`)\n .join(\"; \");\n const err = new Error(`Bundle size check failed: ${violations}`);\n Object.assign(err, { code: \"THRESHOLD_BREACH\", exitCode: 6 });\n throw err;\n }\n }\n\n // Legacy --threshold check\n if (opts.threshold !== undefined) {\n const thresholdBytes = opts.threshold * 1024 * 1024;\n if (analysis.totalCompressed > thresholdBytes) {\n const err = new Error(\n `Threshold breached: ${formatSize(analysis.totalCompressed)} > ${opts.threshold} MB`,\n );\n Object.assign(err, { code: \"THRESHOLD_BREACH\", exitCode: 6 });\n throw err;\n }\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 const [before, after] = await Promise.all([analyzeBundle(file1), analyzeBundle(file2)]);\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(\n `| Before | \\`${comparison.before.path}\\` | ${formatSize(comparison.before.totalCompressed)} |`,\n );\n console.log(\n `| After | \\`${comparison.after.path}\\` | ${formatSize(comparison.after.totalCompressed)} |`,\n );\n console.log(\n `| **Delta** | | **${sign}${formatSize(comparison.sizeDelta)} (${sign}${comparison.sizeDeltaPercent}%)** |`,\n );\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(\n `\\nBefore: ${comparison.before.path} (${formatSize(comparison.before.totalCompressed)})`,\n );\n console.log(\n `After: ${comparison.after.path} (${formatSize(comparison.after.totalCompressed)})`,\n );\n console.log(\n `Delta: ${sign}${formatSize(comparison.sizeDelta)} (${sign}${comparison.sizeDeltaPercent}%)\\n`,\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 });\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,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,aAAa,4BAA4B,CAAC,MAAM,SAAS,GAAG,EAAE,CAAC,EACtE,OAAO,mBAAmB,2CAA2C,EACrE,OAAO,OAAO,MAAc,SAAgE;AAC3F,UAAM,SAAS,gBAAgB,SAAS,MAAM,UAAU,CAAC;AAEzD,UAAM,WAAW,MAAM,cAAc,IAAI;AAEzC,QAAI,WAAW,QAAQ;AACrB,cAAQ,IAAI,aAAa,UAAU,MAAM,CAAC;AAAA,IAC5C,WAAW,WAAW,YAAY;AAChC,YAAM,aAAa,SAAS,QAA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,OAAO;AAAA,QACX,QAAQ,EAAE;AAAA,QACV,QAAQ,WAAW,EAAE,MAAM;AAAA,QAC3B,OAAO,WAAW,EAAE,KAAK;AAAA,QACzB,OAAO,YAAY,EAAE,KAAK;AAAA,MAC5B,EAAE;AACJ,UAAI,WAAW,SAAS,GAAG;AACzB,gBAAQ,IAAI,iBAAiB;AAC7B,gBAAQ,IAAI,aAAa,YAAY,OAAO,CAAC;AAAA,MAC/C;AAGA,YAAM,eAAe,WAAW,eAC7B,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,EAC3B,IAAI,CAAC,OAAO;AAAA,QACX,UAAU,EAAE;AAAA,QACZ,QAAQ,WAAW,EAAE,MAAM;AAAA,QAC3B,OAAO,WAAW,EAAE,KAAK;AAAA,QACzB,OAAO,YAAY,EAAE,KAAK;AAAA,MAC5B,EAAE;AACJ,UAAI,aAAa,SAAS,GAAG;AAC3B,gBAAQ,IAAI,qBAAqB;AACjC,gBAAQ,IAAI,aAAa,cAAc,OAAO,CAAC;AAAA,MACjD;AAAA,IACF;AAAA,EACF,CAAC;AACL;AAEA,eAAe,YAAY;AACzB,QAAM,EAAE,WAAW,IAAI,MAAM,OAAO,iBAAiB;AACrD,SAAO,WAAW;AACpB;","names":[]}
|
|
@@ -75,7 +75,11 @@ function registerCacheCommand(program) {
|
|
|
75
75
|
const matcher = FILE_TYPES[opts.type];
|
|
76
76
|
if (!matcher) {
|
|
77
77
|
const err = new Error(`Unknown cache type "${opts.type}".`);
|
|
78
|
-
Object.assign(err, {
|
|
78
|
+
Object.assign(err, {
|
|
79
|
+
code: "USAGE_ERROR",
|
|
80
|
+
exitCode: 2,
|
|
81
|
+
suggestion: `Valid types: ${Object.keys(FILE_TYPES).join(", ")}`
|
|
82
|
+
});
|
|
79
83
|
throw err;
|
|
80
84
|
}
|
|
81
85
|
toDelete = allFiles.filter((f) => matcher(f.name));
|
|
@@ -114,4 +118,4 @@ function registerCacheCommand(program) {
|
|
|
114
118
|
export {
|
|
115
119
|
registerCacheCommand
|
|
116
120
|
};
|
|
117
|
-
//# sourceMappingURL=cache-
|
|
121
|
+
//# sourceMappingURL=cache-FGNP7Y37.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/cache.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { readdir, stat, unlink } from \"node:fs/promises\";\nimport { join } 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(\n cacheDir: string,\n): 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 {\n /* ignore */\n }\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 =\n 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 const err = new Error(`Unknown cache type \"${opts.type}\".`);\n Object.assign(err, {\n code: \"USAGE_ERROR\",\n exitCode: 2,\n suggestion: `Valid types: ${Object.keys(FILE_TYPES).join(\", \")}`,\n });\n throw err;\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) =>\n rl.question(\"Proceed? [y/N] \", resolve),\n );\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++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
|
return JSON.parse(await readFile(filePath, "utf-8"));
|
|
8
8
|
} catch (err) {
|
|
9
9
|
throw Object.assign(
|
|
10
|
-
new Error(
|
|
10
|
+
new Error(
|
|
11
|
+
`Could not read JSON from ${filePath}: ${err instanceof Error ? err.message : String(err)}`
|
|
12
|
+
),
|
|
11
13
|
{
|
|
12
14
|
code: "INVALID_JSON_FILE",
|
|
13
15
|
exitCode: 2,
|
|
@@ -20,4 +22,4 @@ async function readJsonFile(filePath) {
|
|
|
20
22
|
export {
|
|
21
23
|
readJsonFile
|
|
22
24
|
};
|
|
23
|
-
//# sourceMappingURL=chunk-
|
|
25
|
+
//# sourceMappingURL=chunk-22XCOLZX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/json.ts"],"sourcesContent":["export async function readJsonFile(filePath: string): Promise<unknown> {\n const { readFile } = await import(\"node:fs/promises\");\n try {\n return JSON.parse(await readFile(filePath, \"utf-8\"));\n } catch (err) {\n throw Object.assign(\n new Error(\n `Could not read JSON from ${filePath}: ${err instanceof Error ? err.message : String(err)}`,\n ),\n {\n code: \"INVALID_JSON_FILE\",\n exitCode: 2,\n suggestion: `Check that ${filePath} exists and contains valid JSON`,\n },\n );\n }\n}\n"],"mappings":";;;AAAA,eAAsB,aAAa,UAAoC;AACrE,QAAM,EAAE,SAAS,IAAI,MAAM,OAAO,aAAkB;AACpD,MAAI;AACF,WAAO,KAAK,MAAM,MAAM,SAAS,UAAU,OAAO,CAAC;AAAA,EACrD,SAAS,KAAK;AACZ,UAAM,OAAO;AAAA,MACX,IAAI;AAAA,QACF,4BAA4B,QAAQ,KAAK,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,MAC3F;AAAA,MACA;AAAA,QACE,MAAM;AAAA,QACN,UAAU;AAAA,QACV,YAAY,cAAc,QAAQ;AAAA,MACpC;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/updater.ts"],"sourcesContent":["/**\n * Self-update logic for `gpc update`.\n *\n * All functions here are pure / testable — no Commander.js dependency.\n * The command layer in commands/update.ts handles output and flags.\n */\n\nimport { createWriteStream } from \"node:fs\";\nimport { rename, chmod, unlink, stat, readdir } from \"node:fs/promises\";\nimport { realpathSync } from \"node:fs\";\nimport { join, dirname } from \"node:path\";\nimport { createHash } from \"node:crypto\";\nimport { pipeline } from \"node:stream/promises\";\nimport { Readable, Transform } from \"node:stream\";\nimport { spawn } from \"node:child_process\";\nimport { isNewerVersion } from \"./update-check.js\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport type InstallMethod = \"npm\" | \"homebrew\" | \"binary\" | \"unknown\";\n\nexport interface GithubAsset {\n name: string;\n browser_download_url: string;\n size: number;\n}\n\nexport interface GithubRelease {\n tag_name: string;\n html_url: string;\n assets: GithubAsset[];\n}\n\nexport interface UpdateCheckResult {\n current: string;\n latest: string;\n latestTag: string;\n updateAvailable: boolean;\n installMethod: InstallMethod;\n release: GithubRelease;\n}\n\nconst GITHUB_API_URL = \"https://api.github.com/repos/yasserstudio/gpc/releases/latest\";\nconst GITHUB_TIMEOUT_MS = 10_000;\nconst DOWNLOAD_TIMEOUT_MS = 120_000;\n\n// ---------------------------------------------------------------------------\n// Install method detection\n// ---------------------------------------------------------------------------\n\n/**\n * Detect how gpc was installed.\n *\n * Priority:\n * 1. __GPC_BINARY env var (injected by esbuild at compile time) → \"binary\"\n * 2. npm_config_prefix env var → \"npm\"\n * 3. realpathSync(process.argv[1]) contains \"cellar\" or \"homebrew\" → \"homebrew\"\n * 4. realpathSync(process.argv[1]) contains \"node_modules\" → \"npm\"\n * 5. fallback → \"unknown\"\n *\n * Using realpathSync(process.argv[1]) instead of shelling to `which gpc`:\n * - No child process spawn\n * - Works on Windows without `where.exe`\n * - Resolves symlinks — critical for Intel Mac Homebrew where the bin path\n * is a symlink but the real path contains \"Cellar\"\n */\nexport function detectInstallMethod(): InstallMethod {\n // 1. Compiled binary — but Homebrew also distributes as compiled binary, check execPath\n if (process.env[\"__GPC_BINARY\"] === \"1\") {\n try {\n const resolved = realpathSync(process.execPath).toLowerCase();\n if (resolved.includes(\"cellar\") || resolved.includes(\"homebrew\")) return \"homebrew\";\n } catch {\n /* ignore */\n }\n return \"binary\";\n }\n\n // 2. npm global install\n if (process.env[\"npm_config_prefix\"]) return \"npm\";\n\n // 3. Resolve symlinks and inspect path\n try {\n const resolved = realpathSync(process.argv[1] ?? \"\").toLowerCase();\n if (resolved.includes(\"cellar\") || resolved.includes(\"homebrew\")) return \"homebrew\";\n if (resolved.includes(\"node_modules\")) return \"npm\";\n } catch {\n // realpathSync can throw if the path doesn't exist — fall through to unknown\n }\n\n return \"unknown\";\n}\n\n// ---------------------------------------------------------------------------\n// Platform asset mapping\n// ---------------------------------------------------------------------------\n\n/**\n * Returns the GitHub release asset name for the current platform/arch,\n * matching the names produced by scripts/build-binary.ts TARGETS map.\n */\nexport function getPlatformAsset(): string | null {\n const arch = process.arch === \"arm64\" ? \"arm64\" : \"x64\";\n switch (process.platform) {\n case \"darwin\":\n return `gpc-darwin-${arch}`;\n case \"linux\":\n return `gpc-linux-${arch}`;\n case \"win32\":\n return \"gpc-windows-x64.exe\";\n default:\n return null;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Current binary path\n// ---------------------------------------------------------------------------\n\n/**\n * Returns the path of the currently running gpc binary.\n * For compiled binaries, process.execPath IS the binary.\n * For npm/dev installs, process.argv[1] is the script entrypoint.\n */\nexport function getCurrentBinaryPath(): string {\n if (process.env[\"__GPC_BINARY\"] === \"1\") return process.execPath;\n return process.argv[1] ?? process.execPath;\n}\n\n// ---------------------------------------------------------------------------\n// GitHub Releases API\n// ---------------------------------------------------------------------------\n\nfunction getGithubToken(): string | undefined {\n return process.env[\"GPC_GITHUB_TOKEN\"] || process.env[\"GITHUB_TOKEN\"] || undefined;\n}\n\nfunction githubApiHeaders(): Record<string, string> {\n const headers: Record<string, string> = {\n \"User-Agent\": \"gpc-cli\",\n Accept: \"application/vnd.github+json\",\n \"X-GitHub-Api-Version\": \"2022-11-28\",\n };\n const token = getGithubToken();\n if (token) {\n headers[\"Authorization\"] = `Bearer ${token}`;\n }\n return headers;\n}\n\nfunction githubDownloadHeaders(): Record<string, string> {\n const headers: Record<string, string> = {\n \"User-Agent\": \"gpc-cli\",\n };\n const token = getGithubToken();\n if (token) {\n headers[\"Authorization\"] = `Bearer ${token}`;\n }\n return headers;\n}\n\nexport async function fetchLatestRelease(): Promise<GithubRelease> {\n let response: Response;\n try {\n response = await fetch(GITHUB_API_URL, {\n headers: githubApiHeaders(),\n signal: AbortSignal.timeout(GITHUB_TIMEOUT_MS),\n });\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw Object.assign(new Error(`Network error checking for updates: ${msg}`), {\n code: \"NETWORK_ERROR\",\n exitCode: 5,\n });\n }\n\n if (\n response.status === 429 ||\n (response.status === 403 && response.headers.get(\"x-ratelimit-remaining\") === \"0\")\n ) {\n throw Object.assign(\n new Error(\n \"GitHub API rate limit exceeded. Set GPC_GITHUB_TOKEN or GITHUB_TOKEN to increase the limit.\",\n ),\n {\n code: \"UPDATE_RATE_LIMITED\",\n exitCode: 4,\n suggestion: \"export GPC_GITHUB_TOKEN=ghp_... (a personal access token with no scopes)\",\n },\n );\n }\n\n if (!response.ok) {\n throw Object.assign(new Error(`GitHub API returned HTTP ${response.status}`), {\n code: \"UPDATE_API_ERROR\",\n exitCode: 4,\n });\n }\n\n return (await response.json()) as GithubRelease;\n}\n\n/**\n * Fetch and parse checksums.txt from the release assets.\n * Returns a Map of filename → lowercase sha256 hex.\n * Returns an empty Map if the asset is missing or the fetch fails.\n */\nexport async function fetchChecksums(release: GithubRelease): Promise<Map<string, string>> {\n const asset = release.assets.find((a) => a.name === \"checksums.txt\");\n if (!asset) return new Map();\n\n try {\n const response = await fetch(asset.browser_download_url, {\n headers: githubDownloadHeaders(),\n signal: AbortSignal.timeout(GITHUB_TIMEOUT_MS),\n });\n if (!response.ok) return new Map();\n\n const map = new Map<string, string>();\n for (const line of (await response.text()).split(\"\\n\")) {\n const parts = line.trim().split(/\\s+/);\n const hash = parts[0];\n const name = parts[1];\n if (hash && name) map.set(name, hash.toLowerCase());\n }\n return map;\n } catch {\n return new Map();\n }\n}\n\n// ---------------------------------------------------------------------------\n// High-level update check\n// ---------------------------------------------------------------------------\n\nexport async function checkForUpdate(currentVersion: string): Promise<UpdateCheckResult> {\n const release = await fetchLatestRelease();\n const latest = release.tag_name.replace(/^v/, \"\");\n return {\n current: currentVersion,\n latest,\n latestTag: release.tag_name,\n updateAvailable: isNewerVersion(currentVersion, latest),\n installMethod: detectInstallMethod(),\n release,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Update execution paths\n// ---------------------------------------------------------------------------\n\nexport async function updateViaNpm(options: { silent?: boolean } = {}): Promise<void> {\n return new Promise((resolve, reject) => {\n const proc = spawn(\"npm\", [\"install\", \"-g\", \"@gpc-cli/cli@latest\"], {\n // In silent (JSON) mode, redirect npm's stdout to stderr so it doesn't\n // pollute the machine-readable JSON that gpc writes to stdout.\n stdio: options.silent ? [\"inherit\", process.stderr, process.stderr] : \"inherit\",\n shell: false,\n });\n proc.on(\"close\", (code) => {\n if (code === 0) {\n resolve();\n } else {\n reject(\n Object.assign(new Error(`npm exited with code ${code}`), {\n code: \"UPDATE_NPM_FAILED\",\n exitCode: 1,\n suggestion: \"Run manually: npm install -g @gpc-cli/cli@latest\",\n }),\n );\n }\n });\n proc.on(\"error\", (err) => {\n reject(\n Object.assign(new Error(`Failed to run npm: ${err.message}`), {\n code: \"UPDATE_NPM_SPAWN_FAILED\",\n exitCode: 1,\n suggestion: \"Ensure npm is in your PATH\",\n }),\n );\n });\n });\n}\n\nexport async function updateViaBrew(options: { silent?: boolean } = {}): Promise<void> {\n return new Promise((resolve, reject) => {\n const proc = spawn(\"brew\", [\"upgrade\", \"yasserstudio/tap/gpc\"], {\n // In silent (JSON) mode, redirect brew's stdout to stderr so it doesn't\n // pollute the machine-readable JSON that gpc writes to stdout.\n stdio: options.silent ? [\"inherit\", process.stderr, process.stderr] : \"inherit\",\n shell: false,\n });\n proc.on(\"close\", (code) => {\n if (code === 0) {\n resolve();\n } else {\n reject(\n Object.assign(new Error(`brew exited with code ${code}`), {\n code: \"UPDATE_BREW_FAILED\",\n exitCode: 1,\n suggestion: \"Run manually: brew upgrade yasserstudio/tap/gpc\",\n }),\n );\n }\n });\n proc.on(\"error\", (err) => {\n reject(\n Object.assign(new Error(`Failed to run brew: ${err.message}`), {\n code: \"UPDATE_BREW_SPAWN_FAILED\",\n exitCode: 1,\n suggestion: \"Ensure Homebrew is installed: https://brew.sh\",\n }),\n );\n });\n });\n}\n\n// ---------------------------------------------------------------------------\n// Binary in-place replace\n// ---------------------------------------------------------------------------\n\nfunction isPermissionError(err: unknown): boolean {\n return err instanceof Error && \"code\" in err && (err.code === \"EACCES\" || err.code === \"EPERM\");\n}\n\nasync function sha256File(filePath: string): Promise<string> {\n const hash = createHash(\"sha256\");\n const { size } = await stat(filePath);\n if (size === 0) return hash.digest(\"hex\");\n\n // Read in 64 KB chunks\n const { createReadStream } = await import(\"node:fs\");\n const stream = createReadStream(filePath);\n await new Promise<void>((resolve, reject) => {\n stream.on(\"data\", (chunk: Buffer) => hash.update(chunk));\n stream.on(\"end\", resolve);\n stream.on(\"error\", reject);\n });\n return hash.digest(\"hex\");\n}\n\n/**\n * Clean up stale `.gpc-old-*` and `.gpc-update-*.tmp` files left by\n * previous update attempts (e.g. Windows EBUSY on unlink).\n * Fire-and-forget — errors are silently ignored.\n */\nexport function cleanupStaleUpdateFiles(binaryPath: string): void {\n const dir = dirname(binaryPath);\n readdir(dir)\n .then((files) => {\n for (const f of files) {\n if (f.startsWith(\".gpc-old-\") || f.startsWith(\".gpc-update-\")) {\n unlink(join(dir, f)).catch(() => {});\n }\n }\n })\n .catch(() => {});\n}\n\n/**\n * Download a new binary and atomically replace the current one.\n *\n * macOS/Linux: rename(tmp, current) — safe because open files can be replaced\n * Windows: rename(current, .old) then rename(tmp, current) — avoids EBUSY\n * because Windows locks running executables\n */\nexport async function updateBinaryInPlace(\n assetUrl: string,\n expectedSha256: string,\n currentBinaryPath: string,\n options: { onProgress?: (downloaded: number, total: number) => void } = {},\n): Promise<void> {\n const dir = dirname(currentBinaryPath);\n const tmpPath = join(dir, `.gpc-update-${process.pid}.tmp`);\n const oldPath = join(dir, `.gpc-old-${process.pid}`);\n\n try {\n // 1. Download\n let response: Response;\n try {\n response = await fetch(assetUrl, {\n headers: githubDownloadHeaders(),\n signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS),\n });\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err);\n throw Object.assign(new Error(`Download failed: ${msg}`), {\n code: \"UPDATE_DOWNLOAD_FAILED\",\n exitCode: 5,\n });\n }\n\n if (!response.ok) {\n throw Object.assign(new Error(`Download failed: HTTP ${response.status}`), {\n code: \"UPDATE_DOWNLOAD_FAILED\",\n exitCode: 4,\n });\n }\n if (!response.body) {\n throw Object.assign(new Error(\"Empty response body\"), {\n code: \"UPDATE_DOWNLOAD_FAILED\",\n exitCode: 4,\n });\n }\n\n const contentLength = response.headers.get(\"content-length\");\n const total = contentLength ? parseInt(contentLength, 10) : 0;\n let downloaded = 0;\n\n const dest = createWriteStream(tmpPath);\n const { onProgress } = options;\n\n if (onProgress) {\n const tracker = new Transform({\n transform(chunk: Buffer, _enc, cb) {\n downloaded += chunk.length;\n onProgress(downloaded, total);\n cb(null, chunk);\n },\n });\n await pipeline(\n Readable.fromWeb(response.body as Parameters<typeof Readable.fromWeb>[0]),\n tracker,\n dest,\n );\n } else {\n await pipeline(\n Readable.fromWeb(response.body as Parameters<typeof Readable.fromWeb>[0]),\n dest,\n );\n }\n\n // 2. Verify checksum (skip if no checksum available)\n if (expectedSha256) {\n const actual = await sha256File(tmpPath);\n if (actual !== expectedSha256.toLowerCase()) {\n throw Object.assign(\n new Error(`Checksum mismatch — expected ${expectedSha256}, got ${actual}`),\n {\n code: \"UPDATE_CHECKSUM_MISMATCH\",\n exitCode: 1,\n suggestion: \"The download may be corrupt. Try again.\",\n },\n );\n }\n }\n\n // 3. Set executable bit (no-op on Windows)\n if (process.platform !== \"win32\") {\n await chmod(tmpPath, 0o755);\n }\n\n // 4. Atomic replace\n if (process.platform === \"win32\") {\n // Windows locks running executables, so we rename the current binary\n // out of the way first, then move the new one into place\n await rename(currentBinaryPath, oldPath);\n try {\n await rename(tmpPath, currentBinaryPath);\n } catch (renameErr) {\n // Roll back — restore original binary\n await rename(oldPath, currentBinaryPath).catch(() => {});\n throw renameErr;\n }\n // Delete the old binary in the background (best-effort)\n unlink(oldPath).catch(() => {});\n } else {\n await rename(tmpPath, currentBinaryPath);\n }\n } catch (err) {\n // Clean up temp file on any error\n await unlink(tmpPath).catch(() => {});\n\n if (isPermissionError(err)) {\n throw Object.assign(new Error(`Permission denied replacing ${currentBinaryPath}`), {\n code: \"UPDATE_PERMISSION_DENIED\",\n exitCode: 1,\n suggestion: `Run with elevated permissions: sudo gpc update`,\n });\n }\n throw err;\n }\n}\n"],"mappings":";;;;;;AAOA,SAAS,yBAAyB;AAClC,SAAS,QAAQ,OAAO,QAAQ,MAAM,eAAe;AACrD,SAAS,oBAAoB;AAC7B,SAAS,MAAM,eAAe;AAC9B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,SAAS,UAAU,iBAAiB;AACpC,SAAS,aAAa;AA8BtB,IAAM,iBAAiB;AACvB,IAAM,oBAAoB;AAC1B,IAAM,sBAAsB;AAsBrB,SAAS,sBAAqC;AAEnD,MAAI,QAAQ,IAAI,cAAc,MAAM,KAAK;AACvC,QAAI;AACF,YAAM,WAAW,aAAa,QAAQ,QAAQ,EAAE,YAAY;AAC5D,UAAI,SAAS,SAAS,QAAQ,KAAK,SAAS,SAAS,UAAU,EAAG,QAAO;AAAA,IAC3E,QAAQ;AAAA,IAER;AACA,WAAO;AAAA,EACT;AAG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,SAAS,iBAAiB;AAAA,IACzC;AAAA,EACF,SAAS,KAAK;AAEZ,UAAM,OAAO,OAAO,EAAE,MAAM,MAAM;AAAA,IAAC,CAAC;AAEpC,QAAI,kBAAkB,GAAG,GAAG;AAC1B,YAAM,OAAO,OAAO,IAAI,MAAM,+BAA+B,iBAAiB,EAAE,GAAG;AAAA,QACjF,MAAM;AAAA,QACN,UAAU;AAAA,QACV,YAAY;AAAA,MACd,CAAC;AAAA,IACH;AACA,UAAM;AAAA,EACR;AACF;","names":[]}
|
|
@@ -6,14 +6,11 @@ import { createApiClient, createReportingClient } from "@gpc-cli/api";
|
|
|
6
6
|
function resolvePackageName(packageArg, config) {
|
|
7
7
|
const name = packageArg || config.app || process.env["GPC_APP"];
|
|
8
8
|
if (!name) {
|
|
9
|
-
throw Object.assign(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
suggestion: "Use --app <package> or gpc config set app <package>"
|
|
15
|
-
}
|
|
16
|
-
);
|
|
9
|
+
throw Object.assign(new Error("No package name"), {
|
|
10
|
+
code: "MISSING_PACKAGE_NAME",
|
|
11
|
+
exitCode: 2,
|
|
12
|
+
suggestion: "Use --app <package> or gpc config set app <package>"
|
|
13
|
+
});
|
|
17
14
|
}
|
|
18
15
|
return name;
|
|
19
16
|
}
|
|
@@ -26,4 +23,4 @@ export {
|
|
|
26
23
|
resolvePackageName,
|
|
27
24
|
getClient
|
|
28
25
|
};
|
|
29
|
-
//# sourceMappingURL=chunk-
|
|
26
|
+
//# sourceMappingURL=chunk-JDRY7HK5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/resolve.ts"],"sourcesContent":["// Named exports only. No default export.\n\nimport type { GpcConfig } from \"@gpc-cli/config\";\nimport { resolveAuth } from \"@gpc-cli/auth\";\nimport { createApiClient, createReportingClient } from \"@gpc-cli/api\";\n\nexport function resolvePackageName(\n packageArg: string | undefined,\n config: { app?: string },\n): string {\n const name = packageArg || config.app || process.env[\"GPC_APP\"];\n if (!name) {\n throw Object.assign(new Error(\"No package name\"), {\n code: \"MISSING_PACKAGE_NAME\",\n exitCode: 2,\n suggestion: \"Use --app <package> or gpc config set app <package>\",\n });\n }\n return name;\n}\n\nexport async function getClient(config: GpcConfig) {\n const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });\n return createApiClient({ auth });\n}\n\nexport async function getReportingClient(config: GpcConfig) {\n const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });\n return createReportingClient({ auth });\n}\n"],"mappings":";;;AAGA,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB,6BAA6B;AAEhD,SAAS,mBACd,YACA,QACQ;AACR,QAAM,OAAO,cAAc,OAAO,OAAO,QAAQ,IAAI,SAAS;AAC9D,MAAI,CAAC,MAAM;AACT,UAAM,OAAO,OAAO,IAAI,MAAM,iBAAiB,GAAG;AAAA,MAChD,MAAM;AAAA,MACN,UAAU;AAAA,MACV,YAAY;AAAA,IACd,CAAC;AAAA,EACH;AACA,SAAO;AACT;AAEA,eAAsB,UAAU,QAAmB;AACjD,QAAM,OAAO,MAAM,YAAY,EAAE,oBAAoB,OAAO,MAAM,eAAe,CAAC;AAClF,SAAO,gBAAgB,EAAE,KAAK,CAAC;AACjC;","names":[]}
|
|
@@ -27,14 +27,11 @@ async function requireOption(name, value, prompt, interactive) {
|
|
|
27
27
|
if (interactive) {
|
|
28
28
|
return prompt.choices ? promptSelect(prompt.message, prompt.choices, prompt.default) : promptInput(prompt.message, prompt.default);
|
|
29
29
|
}
|
|
30
|
-
throw Object.assign(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
suggestion: `Provide --${name} or run interactively (remove --no-interactive)`
|
|
36
|
-
}
|
|
37
|
-
);
|
|
30
|
+
throw Object.assign(new Error(`Missing required option --${name}`), {
|
|
31
|
+
code: "MISSING_REQUIRED_OPTION",
|
|
32
|
+
exitCode: 2,
|
|
33
|
+
suggestion: `Provide --${name} or run interactively (remove --no-interactive)`
|
|
34
|
+
});
|
|
38
35
|
}
|
|
39
36
|
async function requireConfirm(message, program) {
|
|
40
37
|
if (skipConfirm(program)) return;
|
|
@@ -104,4 +101,4 @@ export {
|
|
|
104
101
|
promptSelect,
|
|
105
102
|
promptConfirm
|
|
106
103
|
};
|
|
107
|
-
//# sourceMappingURL=chunk-
|
|
104
|
+
//# sourceMappingURL=chunk-RZQSEDKI.js.map
|