@gpc-cli/cli 0.9.45 → 0.9.46

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.
Files changed (167) hide show
  1. package/dist/{anomalies-NU2IN2GJ.js → anomalies-UDE4NGHJ.js} +19 -24
  2. package/dist/anomalies-UDE4NGHJ.js.map +1 -0
  3. package/dist/{apps-J2446UDA.js → apps-FKD3ZG5X.js} +31 -35
  4. package/dist/apps-FKD3ZG5X.js.map +1 -0
  5. package/dist/{audit-N2CRHWUN.js → audit-JASSHRWN.js} +47 -62
  6. package/dist/audit-JASSHRWN.js.map +1 -0
  7. package/dist/{auth-XGSTT5G5.js → auth-OTA3SV3J.js} +145 -103
  8. package/dist/auth-OTA3SV3J.js.map +1 -0
  9. package/dist/bin.js +5 -3
  10. package/dist/bin.js.map +1 -1
  11. package/dist/bundle-F7MUVC5J.js +204 -0
  12. package/dist/bundle-F7MUVC5J.js.map +1 -0
  13. package/dist/{cache-SLNFRTI2.js → cache-XKPLZYEB.js} +4 -5
  14. package/dist/cache-XKPLZYEB.js.map +1 -0
  15. package/dist/changelog-7COFZO7Q.js +48 -0
  16. package/dist/changelog-7COFZO7Q.js.map +1 -0
  17. package/dist/{chunk-4O4D5SGL.js → chunk-3SJ6OXCZ.js} +4 -5
  18. package/dist/chunk-3SJ6OXCZ.js.map +1 -0
  19. package/dist/{chunk-SEVX56VN.js → chunk-6OWN6S6X.js} +52 -48
  20. package/dist/{chunk-SEVX56VN.js.map → chunk-6OWN6S6X.js.map} +1 -1
  21. package/dist/{chunk-U6ZTQ34I.js → chunk-BCBXQC7J.js} +45 -11
  22. package/dist/chunk-BCBXQC7J.js.map +1 -0
  23. package/dist/{chunk-AA577WVQ.js → chunk-NQH4G7BI.js} +9 -3
  24. package/dist/chunk-NQH4G7BI.js.map +1 -0
  25. package/dist/chunk-SLNJEAMK.js +23 -0
  26. package/dist/chunk-SLNJEAMK.js.map +1 -0
  27. package/dist/{chunk-NV75I5VP.js → chunk-YFUBD2XB.js} +10 -8
  28. package/dist/chunk-YFUBD2XB.js.map +1 -0
  29. package/dist/{config-BUXPDN7N.js → config-2FTCYEGD.js} +8 -5
  30. package/dist/config-2FTCYEGD.js.map +1 -0
  31. package/dist/{data-safety-Q7FTCEWU.js → data-safety-AFMD6MYI.js} +12 -27
  32. package/dist/data-safety-AFMD6MYI.js.map +1 -0
  33. package/dist/{device-tiers-MIOQEXYY.js → device-tiers-AQAMUQXI.js} +23 -38
  34. package/dist/device-tiers-AQAMUQXI.js.map +1 -0
  35. package/dist/diff-6EO4ID6W.js +91 -0
  36. package/dist/diff-6EO4ID6W.js.map +1 -0
  37. package/dist/{docs-7DUXIKA3.js → docs-4D2SJ4LY.js} +4 -3
  38. package/dist/docs-4D2SJ4LY.js.map +1 -0
  39. package/dist/doctor-H4X7Q57B.js +691 -0
  40. package/dist/doctor-H4X7Q57B.js.map +1 -0
  41. package/dist/{enterprise-7THXNBTC.js → enterprise-7PWXMSUN.js} +11 -21
  42. package/dist/enterprise-7PWXMSUN.js.map +1 -0
  43. package/dist/{external-transactions-2GWIMUVM.js → external-transactions-LCZALS3V.js} +12 -28
  44. package/dist/external-transactions-LCZALS3V.js.map +1 -0
  45. package/dist/{feedback-DPTO6DUT.js → feedback-XP765TOO.js} +3 -3
  46. package/dist/{games-BT777WUO.js → games-ZSNGEI7A.js} +17 -32
  47. package/dist/games-ZSNGEI7A.js.map +1 -0
  48. package/dist/{generated-apks-RJWTIX7L.js → generated-apks-RX2IUWSF.js} +30 -38
  49. package/dist/generated-apks-RX2IUWSF.js.map +1 -0
  50. package/dist/{grants-TKQJ3IER.js → grants-EBPECI26.js} +22 -40
  51. package/dist/grants-EBPECI26.js.map +1 -0
  52. package/dist/{iap-ICAEQLK5.js → iap-OUI5YYN4.js} +30 -51
  53. package/dist/iap-OUI5YYN4.js.map +1 -0
  54. package/dist/index.js +1 -1
  55. package/dist/{init-JZ2THPMS.js → init-WSTQTJOD.js} +5 -4
  56. package/dist/init-WSTQTJOD.js.map +1 -0
  57. package/dist/{install-skills-OV4HVANW.js → install-skills-6QDUXI5F.js} +5 -6
  58. package/dist/{install-skills-OV4HVANW.js.map → install-skills-6QDUXI5F.js.map} +1 -1
  59. package/dist/{internal-sharing-3U2XFHA4.js → internal-sharing-ONNIWIAT.js} +3 -4
  60. package/dist/{internal-sharing-3U2XFHA4.js.map → internal-sharing-ONNIWIAT.js.map} +1 -1
  61. package/dist/{listings-77HZW4S5.js → listings-7SGQ4SRX.js} +118 -157
  62. package/dist/listings-7SGQ4SRX.js.map +1 -0
  63. package/dist/migrate-ZQCJGQQS.js +138 -0
  64. package/dist/migrate-ZQCJGQQS.js.map +1 -0
  65. package/dist/{one-time-products-LHZAXQES.js → one-time-products-MGZTU7OM.js} +65 -120
  66. package/dist/one-time-products-MGZTU7OM.js.map +1 -0
  67. package/dist/{preflight-H3HEBYQW.js → preflight-N7ZRG2JI.js} +58 -55
  68. package/dist/preflight-N7ZRG2JI.js.map +1 -0
  69. package/dist/{pricing-XQSDTTK5.js → pricing-JJZFICFL.js} +8 -8
  70. package/dist/{pricing-XQSDTTK5.js.map → pricing-JJZFICFL.js.map} +1 -1
  71. package/dist/{prompt-BSV22CQZ.js → prompt-GXC2JSLA.js} +2 -2
  72. package/dist/{publish-Q5ZKEKZ5.js → publish-JPTI4EBT.js} +34 -30
  73. package/dist/publish-JPTI4EBT.js.map +1 -0
  74. package/dist/{purchase-options-CKRN4VIW.js → purchase-options-KFWW4JW2.js} +16 -11
  75. package/dist/purchase-options-KFWW4JW2.js.map +1 -0
  76. package/dist/{purchases-43AKV6HG.js → purchases-DAWTMXP6.js} +118 -193
  77. package/dist/purchases-DAWTMXP6.js.map +1 -0
  78. package/dist/{quickstart-4HB62YEL.js → quickstart-Z5Y3FYJU.js} +5 -3
  79. package/dist/quickstart-Z5Y3FYJU.js.map +1 -0
  80. package/dist/{quota-UHIQQYOY.js → quota-MZRWYJGR.js} +5 -15
  81. package/dist/quota-MZRWYJGR.js.map +1 -0
  82. package/dist/{recovery-5EV2R476.js → recovery-YE3Z7NIN.js} +32 -61
  83. package/dist/recovery-YE3Z7NIN.js.map +1 -0
  84. package/dist/{releases-C2WC2K4E.js → releases-2I3WBULC.js} +184 -185
  85. package/dist/releases-2I3WBULC.js.map +1 -0
  86. package/dist/{reports-2YX3RDOS.js → reports-CIB2T3XT.js} +19 -21
  87. package/dist/reports-CIB2T3XT.js.map +1 -0
  88. package/dist/reviews-BCCXIQ6C.js +188 -0
  89. package/dist/reviews-BCCXIQ6C.js.map +1 -0
  90. package/dist/{status-WHGLODGV.js → status-6LH5W4FU.js} +105 -83
  91. package/dist/status-6LH5W4FU.js.map +1 -0
  92. package/dist/{subscriptions-CI3JH3VQ.js → subscriptions-DZP3Y7O7.js} +142 -232
  93. package/dist/subscriptions-DZP3Y7O7.js.map +1 -0
  94. package/dist/{testers-NZOFA3EF.js → testers-LSMBXCA2.js} +24 -44
  95. package/dist/testers-LSMBXCA2.js.map +1 -0
  96. package/dist/tracks-YHMO2A6B.js +98 -0
  97. package/dist/tracks-YHMO2A6B.js.map +1 -0
  98. package/dist/{train-CJJVLY4B.js → train-MDD2EBHS.js} +35 -55
  99. package/dist/train-MDD2EBHS.js.map +1 -0
  100. package/dist/{update-NAK6CMUX.js → update-OMALGIBR.js} +29 -14
  101. package/dist/update-OMALGIBR.js.map +1 -0
  102. package/dist/{users-2YTC4Q36.js → users-UKG7VIQH.js} +45 -67
  103. package/dist/users-UKG7VIQH.js.map +1 -0
  104. package/dist/{validate-UOVTM6L3.js → validate-QIYSA3N7.js} +8 -10
  105. package/dist/validate-QIYSA3N7.js.map +1 -0
  106. package/dist/{version-N64UBW7A.js → version-NCSNXNVN.js} +3 -3
  107. package/dist/{vitals-A4CS4MSS.js → vitals-C23L2Y2E.js} +153 -172
  108. package/dist/vitals-C23L2Y2E.js.map +1 -0
  109. package/package.json +6 -6
  110. package/dist/anomalies-NU2IN2GJ.js.map +0 -1
  111. package/dist/apps-J2446UDA.js.map +0 -1
  112. package/dist/audit-N2CRHWUN.js.map +0 -1
  113. package/dist/auth-XGSTT5G5.js.map +0 -1
  114. package/dist/bundle-F43TD2BQ.js +0 -218
  115. package/dist/bundle-F43TD2BQ.js.map +0 -1
  116. package/dist/cache-SLNFRTI2.js.map +0 -1
  117. package/dist/changelog-ZYD6W5IV.js +0 -53
  118. package/dist/changelog-ZYD6W5IV.js.map +0 -1
  119. package/dist/chunk-4O4D5SGL.js.map +0 -1
  120. package/dist/chunk-AA577WVQ.js.map +0 -1
  121. package/dist/chunk-FWKYRLKY.js +0 -19
  122. package/dist/chunk-FWKYRLKY.js.map +0 -1
  123. package/dist/chunk-NV75I5VP.js.map +0 -1
  124. package/dist/chunk-U6ZTQ34I.js.map +0 -1
  125. package/dist/config-BUXPDN7N.js.map +0 -1
  126. package/dist/data-safety-Q7FTCEWU.js.map +0 -1
  127. package/dist/device-tiers-MIOQEXYY.js.map +0 -1
  128. package/dist/diff-V77SMKAQ.js +0 -96
  129. package/dist/diff-V77SMKAQ.js.map +0 -1
  130. package/dist/docs-7DUXIKA3.js.map +0 -1
  131. package/dist/doctor-3Z4ARPM2.js +0 -372
  132. package/dist/doctor-3Z4ARPM2.js.map +0 -1
  133. package/dist/enterprise-7THXNBTC.js.map +0 -1
  134. package/dist/external-transactions-2GWIMUVM.js.map +0 -1
  135. package/dist/games-BT777WUO.js.map +0 -1
  136. package/dist/generated-apks-RJWTIX7L.js.map +0 -1
  137. package/dist/grants-TKQJ3IER.js.map +0 -1
  138. package/dist/iap-ICAEQLK5.js.map +0 -1
  139. package/dist/init-JZ2THPMS.js.map +0 -1
  140. package/dist/listings-77HZW4S5.js.map +0 -1
  141. package/dist/migrate-SQT6RD6T.js +0 -143
  142. package/dist/migrate-SQT6RD6T.js.map +0 -1
  143. package/dist/one-time-products-LHZAXQES.js.map +0 -1
  144. package/dist/preflight-H3HEBYQW.js.map +0 -1
  145. package/dist/publish-Q5ZKEKZ5.js.map +0 -1
  146. package/dist/purchase-options-CKRN4VIW.js.map +0 -1
  147. package/dist/purchases-43AKV6HG.js.map +0 -1
  148. package/dist/quickstart-4HB62YEL.js.map +0 -1
  149. package/dist/quota-UHIQQYOY.js.map +0 -1
  150. package/dist/recovery-5EV2R476.js.map +0 -1
  151. package/dist/releases-C2WC2K4E.js.map +0 -1
  152. package/dist/reports-2YX3RDOS.js.map +0 -1
  153. package/dist/reviews-2CWOI5CV.js +0 -213
  154. package/dist/reviews-2CWOI5CV.js.map +0 -1
  155. package/dist/status-WHGLODGV.js.map +0 -1
  156. package/dist/subscriptions-CI3JH3VQ.js.map +0 -1
  157. package/dist/testers-NZOFA3EF.js.map +0 -1
  158. package/dist/tracks-NERFFEDT.js +0 -107
  159. package/dist/tracks-NERFFEDT.js.map +0 -1
  160. package/dist/train-CJJVLY4B.js.map +0 -1
  161. package/dist/update-NAK6CMUX.js.map +0 -1
  162. package/dist/users-2YTC4Q36.js.map +0 -1
  163. package/dist/validate-UOVTM6L3.js.map +0 -1
  164. package/dist/vitals-A4CS4MSS.js.map +0 -1
  165. /package/dist/{feedback-DPTO6DUT.js.map → feedback-XP765TOO.js.map} +0 -0
  166. /package/dist/{prompt-BSV22CQZ.js.map → prompt-GXC2JSLA.js.map} +0 -0
  167. /package/dist/{version-N64UBW7A.js.map → version-NCSNXNVN.js.map} +0 -0
@@ -1,218 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- getOutputFormat
4
- } from "./chunk-ELXAK7GI.js";
5
-
6
- // src/commands/bundle.ts
7
- import {
8
- analyzeBundle,
9
- compareBundles,
10
- topFiles,
11
- checkBundleSize,
12
- formatOutput
13
- } from "@gpc-cli/core";
14
- function formatSize(bytes) {
15
- const abs = Math.abs(bytes);
16
- const sign = bytes < 0 ? "-" : "";
17
- if (abs < 1024) return `${sign}${abs} B`;
18
- if (abs < 1024 * 1024) return `${sign}${(abs / 1024).toFixed(1)} KB`;
19
- return `${sign}${(abs / (1024 * 1024)).toFixed(2)} MB`;
20
- }
21
- function formatDelta(delta) {
22
- const prefix = delta > 0 ? "+" : "";
23
- return `${prefix}${formatSize(delta)}`;
24
- }
25
- function registerBundleCommands(program) {
26
- const bundle = program.command("bundle").description("Analyze app bundles and APKs");
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) => {
28
- const format = getOutputFormat(program, await getConfig());
29
- try {
30
- const analysis = await analyzeBundle(file);
31
- if (format === "json") {
32
- console.log(formatOutput(analysis, format));
33
- } else if (format === "markdown") {
34
- const moduleRows = analysis.modules.map((m) => ({
35
- module: m.name,
36
- compressed: formatSize(m.compressedSize),
37
- uncompressed: formatSize(m.uncompressedSize),
38
- entries: m.entries
39
- }));
40
- const categoryRows = analysis.categories.map((c) => ({
41
- category: c.name,
42
- compressed: formatSize(c.compressedSize),
43
- uncompressed: formatSize(c.uncompressedSize),
44
- entries: c.entries
45
- }));
46
- console.log(`## Bundle Analysis: \`${analysis.filePath}\``);
47
- console.log();
48
- console.log(`| Property | Value |`);
49
- console.log(`| --- | --- |`);
50
- console.log(`| Type | ${analysis.fileType.toUpperCase()} |`);
51
- console.log(`| Total compressed | ${formatSize(analysis.totalCompressed)} |`);
52
- console.log(`| Total uncompressed | ${formatSize(analysis.totalUncompressed)} |`);
53
- console.log(`| Entries | ${analysis.entryCount} |`);
54
- console.log();
55
- console.log(`### Modules`);
56
- console.log();
57
- console.log(formatOutput(moduleRows, "markdown"));
58
- console.log();
59
- console.log(`### Categories`);
60
- console.log();
61
- console.log(formatOutput(categoryRows, "markdown"));
62
- } else {
63
- console.log(`
64
- File: ${analysis.filePath}`);
65
- console.log(`Type: ${analysis.fileType.toUpperCase()}`);
66
- console.log(`Total compressed: ${formatSize(analysis.totalCompressed)}`);
67
- console.log(`Total uncompressed: ${formatSize(analysis.totalUncompressed)}`);
68
- console.log(`Entries: ${analysis.entryCount}
69
- `);
70
- const moduleRows = analysis.modules.map((m) => ({
71
- module: m.name,
72
- compressed: formatSize(m.compressedSize),
73
- uncompressed: formatSize(m.uncompressedSize),
74
- entries: m.entries
75
- }));
76
- console.log("Modules:");
77
- console.log(formatOutput(moduleRows, "table"));
78
- const categoryRows = analysis.categories.map((c) => ({
79
- category: c.name,
80
- compressed: formatSize(c.compressedSize),
81
- uncompressed: formatSize(c.uncompressedSize),
82
- entries: c.entries
83
- }));
84
- console.log("\nCategories:");
85
- console.log(formatOutput(categoryRows, "table"));
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
- }
110
- if (opts.threshold !== void 0) {
111
- const thresholdBytes = opts.threshold * 1024 * 1024;
112
- if (analysis.totalCompressed > thresholdBytes) {
113
- console.error(
114
- `
115
- Threshold breached: ${formatSize(analysis.totalCompressed)} > ${opts.threshold} MB`
116
- );
117
- process.exit(6);
118
- }
119
- }
120
- } catch (error) {
121
- console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
122
- process.exit(1);
123
- }
124
- });
125
- bundle.command("compare <file1> <file2>").description("Compare size differences between two bundles or APKs").action(async (file1, file2) => {
126
- const format = getOutputFormat(program, await getConfig());
127
- try {
128
- const [before, after] = await Promise.all([analyzeBundle(file1), analyzeBundle(file2)]);
129
- const comparison = compareBundles(before, after);
130
- if (format === "json") {
131
- console.log(formatOutput(comparison, format));
132
- } else if (format === "markdown") {
133
- const sign = comparison.sizeDelta >= 0 ? "+" : "";
134
- const moduleRows = comparison.moduleDeltas.filter((m) => m.delta !== 0).map((m) => ({
135
- module: m.module,
136
- before: formatSize(m.before),
137
- after: formatSize(m.after),
138
- delta: formatDelta(m.delta)
139
- }));
140
- const categoryRows = comparison.categoryDeltas.filter((c) => c.delta !== 0).map((c) => ({
141
- category: c.category,
142
- before: formatSize(c.before),
143
- after: formatSize(c.after),
144
- delta: formatDelta(c.delta)
145
- }));
146
- console.log(`## Bundle Comparison`);
147
- console.log();
148
- console.log(`| | Path | Size |`);
149
- console.log(`| --- | --- | --- |`);
150
- console.log(
151
- `| Before | \`${comparison.before.path}\` | ${formatSize(comparison.before.totalCompressed)} |`
152
- );
153
- console.log(
154
- `| After | \`${comparison.after.path}\` | ${formatSize(comparison.after.totalCompressed)} |`
155
- );
156
- console.log(
157
- `| **Delta** | | **${sign}${formatSize(comparison.sizeDelta)} (${sign}${comparison.sizeDeltaPercent}%)** |`
158
- );
159
- if (moduleRows.length > 0) {
160
- console.log();
161
- console.log(`### Module Changes`);
162
- console.log();
163
- console.log(formatOutput(moduleRows, "markdown"));
164
- }
165
- if (categoryRows.length > 0) {
166
- console.log();
167
- console.log(`### Category Changes`);
168
- console.log();
169
- console.log(formatOutput(categoryRows, "markdown"));
170
- }
171
- } else {
172
- const sign = comparison.sizeDelta >= 0 ? "+" : "";
173
- console.log(
174
- `
175
- Before: ${comparison.before.path} (${formatSize(comparison.before.totalCompressed)})`
176
- );
177
- console.log(
178
- `After: ${comparison.after.path} (${formatSize(comparison.after.totalCompressed)})`
179
- );
180
- console.log(
181
- `Delta: ${sign}${formatSize(comparison.sizeDelta)} (${sign}${comparison.sizeDeltaPercent}%)
182
- `
183
- );
184
- const moduleRows = comparison.moduleDeltas.filter((m) => m.delta !== 0).map((m) => ({
185
- module: m.module,
186
- before: formatSize(m.before),
187
- after: formatSize(m.after),
188
- delta: formatDelta(m.delta)
189
- }));
190
- if (moduleRows.length > 0) {
191
- console.log("Module changes:");
192
- console.log(formatOutput(moduleRows, "table"));
193
- }
194
- const categoryRows = comparison.categoryDeltas.filter((c) => c.delta !== 0).map((c) => ({
195
- category: c.category,
196
- before: formatSize(c.before),
197
- after: formatSize(c.after),
198
- delta: formatDelta(c.delta)
199
- }));
200
- if (categoryRows.length > 0) {
201
- console.log("\nCategory changes:");
202
- console.log(formatOutput(categoryRows, "table"));
203
- }
204
- }
205
- } catch (error) {
206
- console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
207
- process.exit(1);
208
- }
209
- });
210
- }
211
- async function getConfig() {
212
- const { loadConfig } = await import("@gpc-cli/config");
213
- return loadConfig();
214
- }
215
- export {
216
- registerBundleCommands
217
- };
218
- //# sourceMappingURL=bundle-F43TD2BQ.js.map
@@ -1 +0,0 @@
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 try {\n const analysis = await analyzeBundle(file);\n\n if (format === \"json\") {\n console.log(formatOutput(analysis, format));\n } else if (format === \"markdown\") {\n const moduleRows = analysis.modules.map((m) => ({\n module: m.name,\n compressed: formatSize(m.compressedSize),\n uncompressed: formatSize(m.uncompressedSize),\n entries: m.entries,\n }));\n const categoryRows = analysis.categories.map((c) => ({\n category: c.name,\n compressed: formatSize(c.compressedSize),\n uncompressed: formatSize(c.uncompressedSize),\n entries: c.entries,\n }));\n console.log(`## Bundle Analysis: \\`${analysis.filePath}\\``);\n console.log();\n console.log(`| Property | Value |`);\n console.log(`| --- | --- |`);\n console.log(`| Type | ${analysis.fileType.toUpperCase()} |`);\n console.log(`| Total compressed | ${formatSize(analysis.totalCompressed)} |`);\n console.log(`| Total uncompressed | ${formatSize(analysis.totalUncompressed)} |`);\n console.log(`| Entries | ${analysis.entryCount} |`);\n console.log();\n console.log(`### Modules`);\n console.log();\n console.log(formatOutput(moduleRows, \"markdown\"));\n console.log();\n console.log(`### Categories`);\n console.log();\n console.log(formatOutput(categoryRows, \"markdown\"));\n } else {\n console.log(`\\nFile: ${analysis.filePath}`);\n console.log(`Type: ${analysis.fileType.toUpperCase()}`);\n console.log(`Total compressed: ${formatSize(analysis.totalCompressed)}`);\n console.log(`Total uncompressed: ${formatSize(analysis.totalUncompressed)}`);\n console.log(`Entries: ${analysis.entryCount}\\n`);\n\n // Modules table\n const moduleRows = analysis.modules.map((m) => ({\n module: m.name,\n compressed: formatSize(m.compressedSize),\n uncompressed: formatSize(m.uncompressedSize),\n entries: m.entries,\n }));\n console.log(\"Modules:\");\n console.log(formatOutput(moduleRows, \"table\"));\n\n // Categories table\n const categoryRows = analysis.categories.map((c) => ({\n category: c.name,\n compressed: formatSize(c.compressedSize),\n uncompressed: formatSize(c.uncompressedSize),\n entries: c.entries,\n }));\n console.log(\"\\nCategories:\");\n console.log(formatOutput(categoryRows, \"table\"));\n }\n\n // 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 console.error(`\\nBundle size check failed:`);\n for (const v of check.violations) {\n console.error(` ${v.subject}: ${formatSize(v.actual)} > max ${formatSize(v.max)}`);\n }\n process.exit(6);\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 console.error(\n `\\nThreshold breached: ${formatSize(analysis.totalCompressed)} > ${opts.threshold} MB`,\n );\n process.exit(6);\n }\n }\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n });\n\n bundle\n .command(\"compare <file1> <file2>\")\n .description(\"Compare size differences between two bundles or APKs\")\n .action(async (file1: string, file2: string) => {\n const format = getOutputFormat(program, await getConfig());\n\n try {\n const [before, after] = await Promise.all([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 } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n }\n });\n}\n\nasync function getConfig() {\n const { loadConfig } = await import(\"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WAAW,EAAE,KAAK;AAAA,UACzB,OAAO,YAAY,EAAE,KAAK;AAAA,QAC5B,EAAE;AACJ,YAAI,WAAW,SAAS,GAAG;AACzB,kBAAQ,IAAI,iBAAiB;AAC7B,kBAAQ,IAAI,aAAa,YAAY,OAAO,CAAC;AAAA,QAC/C;AAGA,cAAM,eAAe,WAAW,eAC7B,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC,EAC3B,IAAI,CAAC,OAAO;AAAA,UACX,UAAU,EAAE;AAAA,UACZ,QAAQ,WAAW,EAAE,MAAM;AAAA,UAC3B,OAAO,WAAW,EAAE,KAAK;AAAA,UACzB,OAAO,YAAY,EAAE,KAAK;AAAA,QAC5B,EAAE;AACJ,YAAI,aAAa,SAAS,GAAG;AAC3B,kBAAQ,IAAI,qBAAqB;AACjC,kBAAQ,IAAI,aAAa,cAAc,OAAO,CAAC;AAAA,QACjD;AAAA,MACF;AAAA,IACF,SAAS,OAAO;AACd,cAAQ,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE;AAChF,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AACL;AAEA,eAAe,YAAY;AACzB,QAAM,EAAE,WAAW,IAAI,MAAM,OAAO,iBAAiB;AACrD,SAAO,WAAW;AACpB;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/cache.ts"],"sourcesContent":["import 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 console.error(\n `Error: Unknown cache type \"${opts.type}\". Valid types: ${Object.keys(FILE_TYPES).join(\", \")}`,\n );\n process.exit(2);\n }\n toDelete = allFiles.filter((f) => matcher(f.name));\n }\n\n if (toDelete.length === 0) {\n console.log(\"No cache files to remove.\");\n return;\n }\n\n if (!opts.force) {\n console.log(`About to remove ${toDelete.length} file(s) from ${cacheDir}:`);\n for (const f of toDelete) {\n console.log(` ${f.name} (${formatBytes(f.size)})`);\n }\n const { createInterface } = await import(\"node:readline\");\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n const answer = await new Promise<string>((resolve) =>\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++;\n } catch {\n /* ignore */\n }\n }\n console.log(`Removed ${removed} file(s).`);\n });\n}\n"],"mappings":";;;AACA,SAAS,SAAS,MAAM,cAAc;AACtC,SAAS,YAAY;AACrB,SAAS,mBAAmB;AAE5B,IAAM,aAAwD;AAAA,EAC5D,QAAQ,CAAC,SAAS,KAAK,WAAW,SAAS,KAAK,KAAK,SAAS,OAAO;AAAA,EACrE,OAAO,CAAC,SAAS,SAAS;AAAA,EAC1B,QAAQ,CAAC,SAAS,SAAS;AAC7B;AAEA,eAAe,cACb,UACsE;AACtE,MAAI;AACJ,MAAI;AACF,cAAU,MAAM,QAAQ,QAAQ;AAAA,EAClC,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AAEA,QAAM,QAAqE,CAAC;AAC5E,aAAW,SAAS,SAAS;AAC3B,QAAI,CAAC,MAAM,SAAS,OAAO,EAAG;AAC9B,UAAM,WAAW,KAAK,UAAU,KAAK;AACrC,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ACA,YAAM,EAAE,gBAAgB,IAAI,MAAM,OAAO,UAAe;AACxD,YAAM,KAAK,gBAAgB,EAAE,OAAO,QAAQ,OAAO,QAAQ,QAAQ,OAAO,CAAC;AAC3E,YAAM,SAAS,MAAM,IAAI;AAAA,QAAgB,CAAC,YACxC,GAAG,SAAS,mBAAmB,OAAO;AAAA,MACxC;AACA,SAAG,MAAM;AACT,UAAI,OAAO,YAAY,MAAM,KAAK;AAChC,gBAAQ,IAAI,UAAU;AACtB;AAAA,MACF;AAAA,IACF;AAEA,QAAI,UAAU;AACd,eAAW,KAAK,UAAU;AACxB,UAAI;AACF,cAAM,OAAO,EAAE,IAAI;AACnB;AAAA,MACF,QAAQ;AAAA,MAER;AAAA,IACF;AACA,YAAQ,IAAI,WAAW,OAAO,WAAW;AAAA,EAC3C,CAAC;AACL;","names":[]}
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- getOutputFormat
4
- } from "./chunk-ELXAK7GI.js";
5
-
6
- // src/commands/changelog.ts
7
- import { fetchChangelog, formatChangelogEntry } from "@gpc-cli/core";
8
- import { formatOutput } from "@gpc-cli/core";
9
- import { loadConfig } from "@gpc-cli/config";
10
- function registerChangelogCommand(program) {
11
- program.command("changelog").description("Show release history").option("-n, --limit <count>", "Number of releases to show", parseInt, 5).option("--version <tag>", "Show a specific version (e.g., v0.9.43)").option("--all", "Show all releases").action(async (opts) => {
12
- const config = await loadConfig();
13
- const format = getOutputFormat(program, config);
14
- try {
15
- const entries = await fetchChangelog({
16
- limit: opts.all ? 100 : opts.limit,
17
- version: opts.version
18
- });
19
- if (entries.length === 0) {
20
- console.log("No releases found.");
21
- return;
22
- }
23
- if (format === "json") {
24
- console.log(formatOutput(entries, "json"));
25
- return;
26
- }
27
- if (opts.version || entries.length === 1) {
28
- console.log(formatChangelogEntry(entries[0]));
29
- return;
30
- }
31
- const header = "VERSION DATE TITLE";
32
- const separator = "\u2500".repeat(header.length);
33
- console.log(header);
34
- console.log(separator);
35
- for (const entry of entries) {
36
- const version = entry.version.padEnd(12);
37
- const date = entry.date.padEnd(12);
38
- console.log(`${version} ${date} ${entry.title}`);
39
- }
40
- console.log("");
41
- console.log(
42
- `Showing ${entries.length} releases. Use --version <tag> for details, or --all for full history.`
43
- );
44
- } catch (error) {
45
- console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
46
- process.exit(4);
47
- }
48
- });
49
- }
50
- export {
51
- registerChangelogCommand
52
- };
53
- //# sourceMappingURL=changelog-ZYD6W5IV.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/changelog.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport { fetchChangelog, formatChangelogEntry } from \"@gpc-cli/core\";\nimport { formatOutput } from \"@gpc-cli/core\";\nimport { loadConfig } from \"@gpc-cli/config\";\nimport { getOutputFormat } from \"../format.js\";\n\nexport function registerChangelogCommand(program: Command): void {\n program\n .command(\"changelog\")\n .description(\"Show release history\")\n .option(\"-n, --limit <count>\", \"Number of releases to show\", parseInt, 5)\n .option(\"--version <tag>\", \"Show a specific version (e.g., v0.9.43)\")\n .option(\"--all\", \"Show all releases\")\n .action(async (opts: { limit: number; version?: string; all?: boolean }) => {\n const config = await loadConfig();\n const format = getOutputFormat(program, config);\n\n try {\n const entries = await fetchChangelog({\n limit: opts.all ? 100 : opts.limit,\n version: opts.version,\n });\n\n if (entries.length === 0) {\n console.log(\"No releases found.\");\n return;\n }\n\n if (format === \"json\") {\n console.log(formatOutput(entries, \"json\"));\n return;\n }\n\n // Single version — show full details\n if (opts.version || entries.length === 1) {\n console.log(formatChangelogEntry(entries[0]!));\n return;\n }\n\n // Multiple versions — table summary\n const header = \"VERSION DATE TITLE\";\n const separator = \"─\".repeat(header.length);\n console.log(header);\n console.log(separator);\n for (const entry of entries) {\n const version = entry.version.padEnd(12);\n const date = entry.date.padEnd(12);\n console.log(`${version} ${date} ${entry.title}`);\n }\n console.log(\"\");\n console.log(\n `Showing ${entries.length} releases. Use --version <tag> for details, or --all for full history.`,\n );\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n}\n"],"mappings":";;;;;;AACA,SAAS,gBAAgB,4BAA4B;AACrD,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAGpB,SAAS,yBAAyB,SAAwB;AAC/D,UACG,QAAQ,WAAW,EACnB,YAAY,sBAAsB,EAClC,OAAO,uBAAuB,8BAA8B,UAAU,CAAC,EACvE,OAAO,mBAAmB,yCAAyC,EACnE,OAAO,SAAS,mBAAmB,EACnC,OAAO,OAAO,SAA6D;AAC1E,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,SAAS,gBAAgB,SAAS,MAAM;AAE9C,QAAI;AACF,YAAM,UAAU,MAAM,eAAe;AAAA,QACnC,OAAO,KAAK,MAAM,MAAM,KAAK;AAAA,QAC7B,SAAS,KAAK;AAAA,MAChB,CAAC;AAED,UAAI,QAAQ,WAAW,GAAG;AACxB,gBAAQ,IAAI,oBAAoB;AAChC;AAAA,MACF;AAEA,UAAI,WAAW,QAAQ;AACrB,gBAAQ,IAAI,aAAa,SAAS,MAAM,CAAC;AACzC;AAAA,MACF;AAGA,UAAI,KAAK,WAAW,QAAQ,WAAW,GAAG;AACxC,gBAAQ,IAAI,qBAAqB,QAAQ,CAAC,CAAE,CAAC;AAC7C;AAAA,MACF;AAGA,YAAM,SAAS;AACf,YAAM,YAAY,SAAI,OAAO,OAAO,MAAM;AAC1C,cAAQ,IAAI,MAAM;AAClB,cAAQ,IAAI,SAAS;AACrB,iBAAW,SAAS,SAAS;AAC3B,cAAM,UAAU,MAAM,QAAQ,OAAO,EAAE;AACvC,cAAM,OAAO,MAAM,KAAK,OAAO,EAAE;AACjC,gBAAQ,IAAI,GAAG,OAAO,IAAI,IAAI,IAAI,MAAM,KAAK,EAAE;AAAA,MACjD;AACA,cAAQ,IAAI,EAAE;AACd,cAAQ;AAAA,QACN,WAAW,QAAQ,MAAM;AAAA,MAC3B;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":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/update-check.ts"],"sourcesContent":["import { join } from \"node:path\";\nimport { readFile, writeFile, mkdir } from \"node:fs/promises\";\nimport { getCacheDir } from \"@gpc-cli/config\";\n\nexport interface UpdateCheckResult {\n current: string;\n latest: string;\n updateAvailable: boolean;\n}\n\ninterface CacheData {\n latest: string;\n checkedAt: number;\n}\n\nconst CACHE_TTL_MS = 24 * 60 * 60 * 1000; // 24 hours\nconst FETCH_TIMEOUT_MS = 3000;\nconst REGISTRY_URL = \"https://registry.npmjs.org/@gpc-cli/cli/latest\";\n\nfunction getCacheFilePath(): string {\n return join(getCacheDir(), \"update-check.json\");\n}\n\n/**\n * Compare two semver strings numerically.\n * Returns true if `b` is newer than `a`.\n */\nexport function isNewerVersion(current: string, latest: string): boolean {\n const a = current.split(\".\").map(Number);\n const b = latest.split(\".\").map(Number);\n for (let i = 0; i < Math.max(a.length, b.length); i++) {\n const av = a[i] ?? 0;\n const bv = b[i] ?? 0;\n if (bv > av) return true;\n if (bv < av) return false;\n }\n return false;\n}\n\nasync function readCache(): Promise<CacheData | null> {\n try {\n const raw = await readFile(getCacheFilePath(), \"utf-8\");\n const data = JSON.parse(raw) as CacheData;\n if (typeof data.latest === \"string\" && typeof data.checkedAt === \"number\") {\n return data;\n }\n return null;\n } catch {\n return null;\n }\n}\n\nfunction writeCache(data: CacheData): void {\n const filePath = getCacheFilePath();\n const dir = join(filePath, \"..\");\n // Fire-and-forget: ignore write errors\n mkdir(dir, { recursive: true })\n .then(() => writeFile(filePath, JSON.stringify(data), \"utf-8\"))\n .catch(() => {});\n}\n\nasync function fetchLatestVersion(): Promise<string | null> {\n try {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);\n\n const response = await fetch(REGISTRY_URL, { signal: controller.signal });\n clearTimeout(timeout);\n\n if (!response.ok) return null;\n\n const body = (await response.json()) as { version?: string };\n if (typeof body.version !== \"string\") return null;\n\n return body.version;\n } catch {\n return null;\n }\n}\n\n/**\n * Check for a newer version of @gpc-cli/cli on npm.\n * Returns null if the check is skipped or fails.\n */\nexport async function checkForUpdate(currentVersion: string): Promise<UpdateCheckResult | null> {\n // Skip in non-interactive or CI environments\n if (process.env[\"GPC_NO_UPDATE_CHECK\"] === \"1\") return null;\n if (process.env[\"CI\"]) return null;\n if (!process.stdout.isTTY) return null;\n\n // Check cache first\n const cache = await readCache();\n if (cache && Date.now() - cache.checkedAt < CACHE_TTL_MS) {\n return {\n current: currentVersion,\n latest: cache.latest,\n updateAvailable: isNewerVersion(currentVersion, cache.latest),\n };\n }\n\n // Fetch from registry\n const latest = await fetchLatestVersion();\n if (!latest) return null;\n\n // Write cache (fire-and-forget)\n writeCache({ latest, checkedAt: Date.now() });\n\n return {\n current: currentVersion,\n latest,\n updateAvailable: isNewerVersion(currentVersion, latest),\n };\n}\n\n/**\n * Format a user-facing update notification string.\n */\nexport function formatUpdateNotification(result: UpdateCheckResult): string {\n return `Update available: ${result.current} \\u2192 ${result.latest} \\u2014 Run: gpc update`;\n}\n"],"mappings":";;;AAAA,SAAS,YAAY;AACrB,SAAS,UAAU,WAAW,aAAa;AAC3C,SAAS,mBAAmB;AAa5B,IAAM,eAAe,KAAK,KAAK,KAAK;AACpC,IAAM,mBAAmB;AACzB,IAAM,eAAe;AAErB,SAAS,mBAA2B;AAClC,SAAO,KAAK,YAAY,GAAG,mBAAmB;AAChD;AAMO,SAAS,eAAe,SAAiB,QAAyB;AACvE,QAAM,IAAI,QAAQ,MAAM,GAAG,EAAE,IAAI,MAAM;AACvC,QAAM,IAAI,OAAO,MAAM,GAAG,EAAE,IAAI,MAAM;AACtC,WAAS,IAAI,GAAG,IAAI,KAAK,IAAI,EAAE,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AO,MAAO,QAAO;AAGlC,QAAM,QAAQ,MAAM,UAAU;AAC9B,MAAI,SAAS,KAAK,IAAI,IAAI,MAAM,YAAY,cAAc;AACxD,WAAO;AAAA,MACL,SAAS;AAAA,MACT,QAAQ,MAAM;AAAA,MACd,iBAAiB,eAAe,gBAAgB,MAAM,MAAM;AAAA,IAC9D;AAAA,EACF;AAGA,QAAM,SAAS,MAAM,mBAAmB;AACxC,MAAI,CAAC,OAAQ,QAAO;AAGpB,aAAW,EAAE,QAAQ,WAAW,KAAK,IAAI,EAAE,CAAC;AAE5C,SAAO;AAAA,IACL,SAAS;AAAA,IACT;AAAA,IACA,iBAAiB,eAAe,gBAAgB,MAAM;AAAA,EACxD;AACF;AAKO,SAAS,yBAAyB,QAAmC;AAC1E,SAAO,qBAAqB,OAAO,OAAO,WAAW,OAAO,MAAM;AACpE;","names":[]}
@@ -1 +0,0 @@
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 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\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,YAAQ,MAAM,6EAA6E;AAC3F,YAAQ,KAAK,CAAC;AAAA,EAChB;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":[]}
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/json.ts
4
- async function readJsonFile(filePath) {
5
- const { readFile } = await import("fs/promises");
6
- try {
7
- return JSON.parse(await readFile(filePath, "utf-8"));
8
- } catch (err) {
9
- console.error(
10
- `Error: Could not read JSON from ${filePath}: ${err instanceof Error ? err.message : String(err)}`
11
- );
12
- process.exit(2);
13
- }
14
- }
15
-
16
- export {
17
- readJsonFile
18
- };
19
- //# sourceMappingURL=chunk-FWKYRLKY.js.map
@@ -1 +0,0 @@
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 console.error(\n `Error: Could not read JSON from ${filePath}: ${err instanceof Error ? err.message : String(err)}`,\n );\n process.exit(2);\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,YAAQ;AAAA,MACN,mCAAmC,QAAQ,KAAK,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG,CAAC;AAAA,IAClG;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/prompt.ts"],"sourcesContent":["import { createInterface } from \"node:readline\";\n\n/**\n * Check if interactive prompts are allowed.\n * Disabled by --no-interactive flag, GPC_NO_INTERACTIVE env, or non-TTY stdin.\n */\nexport function isInteractive(program?: { opts(): Record<string, unknown> }): boolean {\n // Commander's --no-interactive sets interactive = false\n if (program) {\n let root: { parent?: unknown; opts(): Record<string, unknown> } = program;\n while (root.parent) root = root.parent as typeof root;\n if (root.opts()[\"interactive\"] === false) return false;\n }\n\n if (process.env[\"GPC_NO_INTERACTIVE\"] === \"1\" || process.env[\"GPC_NO_INTERACTIVE\"] === \"true\") {\n return false;\n }\n\n if (process.env[\"CI\"] === \"true\" || process.env[\"CI\"] === \"1\") {\n return false;\n }\n\n return Boolean(process.stdin.isTTY);\n}\n\n/**\n * Check if --yes flag is set (skip confirmation prompts).\n */\nexport function skipConfirm(program?: { opts(): Record<string, unknown> }): boolean {\n if (!program) return false;\n let root: { parent?: unknown; opts(): Record<string, unknown> } = program;\n while (root.parent) root = root.parent as typeof root;\n return root.opts()[\"yes\"] === true;\n}\n\n/**\n * Require an option value: return existing value, prompt interactively, or exit with error.\n */\nexport async function requireOption(\n name: string,\n value: string | undefined,\n prompt: { message: string; choices?: string[]; default?: string },\n interactive: boolean,\n): Promise<string> {\n if (value) return value;\n if (interactive) {\n return prompt.choices\n ? promptSelect(prompt.message, prompt.choices, prompt.default)\n : promptInput(prompt.message, prompt.default);\n }\n process.stderr.write(`Error: Missing required option --${name}\\n`);\n process.stderr.write(\n `Suggestion: Provide --${name} or run interactively (remove --no-interactive)\\n`,\n );\n process.exit(2);\n}\n\n/**\n * Require confirmation for destructive operations.\n * Returns true if confirmed (or --yes flag is set / non-interactive).\n * Exits with code 0 if denied.\n */\nexport async function requireConfirm(\n message: string,\n program?: { opts(): Record<string, unknown> },\n): Promise<void> {\n if (skipConfirm(program)) return;\n if (!isInteractive(program)) return;\n const confirmed = await promptConfirm(message, false);\n if (!confirmed) {\n console.log(\"Aborted.\");\n process.exit(1);\n }\n}\n\n/**\n * Prompt for text input.\n */\nexport async function promptInput(message: string, defaultValue?: string): Promise<string> {\n const suffix = defaultValue ? ` (${defaultValue})` : \"\";\n const rl = createInterface({ input: process.stdin, output: process.stderr });\n\n return new Promise((resolve) => {\n rl.question(`${message}${suffix}: `, (answer) => {\n rl.close();\n resolve(answer.trim() || defaultValue || \"\");\n });\n });\n}\n\n/**\n * Prompt for selection from a list of choices.\n */\nexport async function promptSelect(\n message: string,\n choices: string[],\n defaultValue?: string,\n): Promise<string> {\n const rl = createInterface({ input: process.stdin, output: process.stderr });\n\n process.stderr.write(`${message}\\n`);\n for (let i = 0; i < choices.length; i++) {\n const marker = choices[i] === defaultValue ? \" (default)\" : \"\";\n process.stderr.write(` ${i + 1}) ${choices[i]}${marker}\\n`);\n }\n\n return new Promise((resolve) => {\n rl.question(\"Choice: \", (answer) => {\n rl.close();\n const trimmed = answer.trim();\n\n // Accept number\n const num = Number(trimmed);\n if (num >= 1 && num <= choices.length) {\n resolve(choices[num - 1] ?? \"\");\n return;\n }\n\n // Accept exact match\n if (choices.includes(trimmed)) {\n resolve(trimmed);\n return;\n }\n\n // Default\n resolve(defaultValue ?? choices[0] ?? \"\");\n });\n });\n}\n\n/**\n * Prompt for yes/no confirmation.\n */\nexport async function promptConfirm(message: string, defaultValue = true): Promise<boolean> {\n const hint = defaultValue ? \"Y/n\" : \"y/N\";\n const rl = createInterface({ input: process.stdin, output: process.stderr });\n\n return new Promise((resolve) => {\n rl.question(`${message} [${hint}]: `, (answer) => {\n rl.close();\n const trimmed = answer.trim().toLowerCase();\n if (trimmed === \"\") resolve(defaultValue);\n else resolve(trimmed === \"y\" || trimmed === \"yes\");\n });\n });\n}\n"],"mappings":";;;AAAA,SAAS,uBAAuB;AAMzB,SAAS,cAAc,SAAwD;AAEpF,MAAI,SAAS;AACX,QAAI,OAA8D;AAClE,WAAO,KAAK,OAAQ,QAAO,KAAK;AAChC,QAAI,KAAK,KAAK,EAAE,aAAa,MAAM,MAAO,QAAO;AAAA,EACnD;AAEA,MAAI,QAAQ,IAAI,oBAAoB,MAAM,OAAO,QAAQ,I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K;AAAA,IACnD,CAAC;AAAA,EACH,CAAC;AACH;","names":[]}
@@ -1 +0,0 @@
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 } 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 githubHeaders(): 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 // Support GPC_GITHUB_TOKEN for authenticated requests (avoids 60 req/hr limit\n // on shared CI runner IPs)\n if (process.env[\"GPC_GITHUB_TOKEN\"]) {\n headers[\"Authorization\"] = `Bearer ${process.env[\"GPC_GITHUB_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: githubHeaders(),\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 (response.status === 429) {\n throw Object.assign(\n new Error(\"GitHub API rate limit exceeded. Set GPC_GITHUB_TOKEN to increase the limit.\"),\n { code: \"UPDATE_RATE_LIMITED\", exitCode: 4 },\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: githubHeaders(),\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 * 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 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,YAAY;AAC5C,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;AAGA,MAAI,QAAQ,IAAI,mBAAmB,EAAG,QAAO;AAG7C,MAAI;AACF,UAAM,WAAW,aAAa,QAAQ,KAAK,CAAC,KAAK,EAAE,EAAE,YAAY;AACjE,QAAI,SAAS,SAAS,QAAQ,KAAK,SAAS,SAAS,UAAU,EAAG,QAAO;AACzE,QAAI,SAAS,SAAS,cAAc,EAAG,QAAO;AAAA,EAChD,QAAQ;AAAA,EAER;AAEA,SAAO;AACT;AAUO,SAAS,mBAAkC;AAChD,QAAM,OAAO,QAAQ,SAAS,UAAU,UAAU;AAClD,UAAQ,QAAQ,UAAU;AAAA,IACxB,KAAK;AACH,aAAO,cAAc,IAAI;AAAA,IAC3B,KAAK;AACH,aAAO,aAAa,IAAI;AAAA,IAC1B,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAWO,SAAS,uBAA+B;A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ACzC;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":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/config.ts"],"sourcesContent":["import type { Command } from \"commander\";\nimport type { GpcConfig } from \"@gpc-cli/config\";\nimport { loadConfig, setConfigValue, getUserConfigPath, initConfig } from \"@gpc-cli/config\";\nimport { formatOutput, writeAuditLog, createAuditEntry } from \"@gpc-cli/core\";\nimport { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { getOutputFormat } from \"../format.js\";\nimport { isInteractive, promptInput, promptSelect, promptConfirm } from \"../prompt.js\";\n\nconst ANDROID_PACKAGE_RE = /^[a-zA-Z][a-zA-Z0-9_]*(\\.[a-zA-Z][a-zA-Z0-9_]*)+$/;\n\nexport function registerConfigCommands(program: Command): void {\n const config = program.command(\"config\").description(\"Manage configuration\");\n\n config\n .command(\"init\")\n .description(\"Create a configuration file\")\n .option(\"--global\", \"Create in user config directory (~/.config/gpc/)\")\n .action(async (_options: { global?: boolean }) => {\n const initialConfig: Record<string, unknown> = {};\n\n if (isInteractive(program)) {\n console.log(\"\\nGPC Setup Wizard\\n\");\n\n // Package name\n const app = await promptInput(\"Default package name (e.g. com.example.app, blank to skip)\");\n if (app) {\n if (!ANDROID_PACKAGE_RE.test(app)) {\n console.error(\n ` Warning: \"${app}\" doesn't look like a valid Android package name — continuing anyway`,\n );\n }\n initialConfig[\"app\"] = app;\n }\n\n // Auth method\n const authMethod = await promptSelect(\n \"Authentication method:\",\n [\"service-account\", \"adc\", \"skip\"],\n \"service-account\",\n );\n\n if (authMethod === \"service-account\") {\n let saPath: string;\n while (true) {\n saPath = await promptInput(\"Path to service account JSON key file\");\n if (!saPath) {\n console.log(\" Skipping service account setup.\");\n break;\n }\n const resolved = resolve(saPath);\n if (existsSync(resolved)) {\n initialConfig[\"auth\"] = { serviceAccount: saPath };\n break;\n }\n console.error(` File not found: ${resolved}`);\n const retry = await promptConfirm(\"Try a different path?\");\n if (!retry) break;\n }\n } else if (authMethod === \"adc\") {\n console.log(\n \" Using Application Default Credentials — run `gcloud auth application-default login` if not already set up.\",\n );\n }\n\n // Output format\n const output = await promptSelect(\n \"Default output format:\",\n [\"table\", \"json\", \"yaml\", \"markdown\"],\n \"table\",\n );\n if (output !== \"table\") initialConfig[\"output\"] = output;\n }\n\n const path = await initConfig(initialConfig as GpcConfig);\n\n // Summary\n const configured: string[] = [];\n if (initialConfig[\"app\"]) configured.push(`app: ${initialConfig[\"app\"]}`);\n if (initialConfig[\"auth\"]) configured.push(\"auth: service account\");\n if (initialConfig[\"output\"]) configured.push(`output: ${initialConfig[\"output\"]}`);\n\n console.log(`\\nConfiguration file created: ${path}`);\n if (configured.length > 0) {\n console.log(` ${configured.join(\" · \")}`);\n }\n\n writeAuditLog(createAuditEntry(\"config init\", { path })).catch(() => {});\n\n // Run doctor inline to verify setup\n console.log(\"\\nVerifying setup...\");\n try {\n const { registerDoctorCommand } = await import(\"./doctor.js\");\n const { Command } = await import(\"commander\");\n const doctorProgram = new Command();\n doctorProgram\n .option(\"-o, --output <format>\", \"Output format\")\n .option(\"-j, --json\", \"JSON mode\");\n registerDoctorCommand(doctorProgram);\n await doctorProgram.parseAsync([\"node\", \"gpc\", \"doctor\"]);\n } catch {\n // Doctor failures should not prevent config init from succeeding\n console.log(\"Run `gpc doctor` to verify your setup.\");\n }\n });\n\n config\n .command(\"show\")\n .description(\"Display resolved configuration\")\n .action(async () => {\n const resolved = await loadConfig();\n const format = getOutputFormat(program, resolved);\n console.log(formatOutput(resolved, format));\n });\n\n config\n .command(\"set <key> <value>\")\n .description(\"Set a configuration value\")\n .action(async (key: string, value: string) => {\n await setConfigValue(key, value);\n console.log(`Set ${key} = ${value}`);\n });\n\n config\n .command(\"path\")\n .description(\"Show configuration file path\")\n .action(() => {\n console.log(getUserConfigPath());\n });\n}\n"],"mappings":";;;;;;;;;;;;AAEA,SAAS,YAAY,gBAAgB,mBAAmB,kBAAkB;AAC1E,SAAS,cAAc,eAAe,wBAAwB;AAC9D,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AAIxB,IAAM,qBAAqB;AAEpB,SAAS,uBAAuB,SAAwB;AAC7D,QAAM,SAAS,QAAQ,QAAQ,QAAQ,EAAE,YAAY,sBAAsB;AAE3E,SACG,QAAQ,MAAM,EACd,YAAY,6BAA6B,EACzC,OAAO,YAAY,kDAAkD,EACrE,OAAO,OAAO,aAAmC;AAChD,UAAM,gBAAyC,CAAC;AAEhD,QAAI,cAAc,OAAO,GAAG;AAC1B,cAAQ,IAAI,sBAAsB;AAGlC,YAAM,MAAM,MAAM,YAAY,4DAA4D;AAC1F,UAAI,KAAK;AACP,YAAI,CAAC,mBAAmB,KAAK,GAAG,GAAG;AACjC,kBAAQ;AAAA,YACN,eAAe,GAAG;AAAA,UACpB;AAAA,QACF;AACA,sBAAc,KAAK,IAAI;AAAA,MACzB;AAGA,YAAM,aAAa,MAAM;AAAA,QACvB;AAAA,QACA,CAAC,mBAAmB,OAAO,MAAM;AAAA,QACjC;AAAA,MACF;AAEA,UAAI,eAAe,mBAAmB;AACpC,YAAI;AACJ,eAAO,MAAM;AACX,mBAAS,MAAM,YAAY,uCAAuC;AAClE,cAAI,CAAC,QAAQ;AACX,oBAAQ,IAAI,mCAAmC;AAC/C;AAAA,UACF;AACA,gBAAM,WAAW,QAAQ,MAAM;AAC/B,cAAI,WAAW,QAAQ,GAAG;AACxB,0BAAc,MAAM,IAAI,EAAE,gBAAgB,OAAO;AACjD;AAAA,UACF;AACA,kBAAQ,MAAM,qBAAqB,QAAQ,EAAE;AAC7C,gBAA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C,OAAO,YAAY;AAClB,UAAM,WAAW,MAAM,WAAW;AAClC,UAAM,SAAS,gBAAgB,SAAS,QAAQ;AAChD,YAAQ,IAAI,aAAa,UAAU,MAAM,CAAC;AAAA,EAC5C,CAAC;AAEH,SACG,QAAQ,mBAAmB,EAC3B,YAAY,2BAA2B,EACvC,OAAO,OAAO,KAAa,UAAkB;AAC5C,UAAM,eAAe,KAAK,KAAK;AAC/B,YAAQ,IAAI,OAAO,GAAG,MAAM,KAAK,EAAE;AAAA,EACrC,CAAC;AAEH,SACG,QAAQ,MAAM,EACd,YAAY,8BAA8B,EAC1C,OAAO,MAAM;AACZ,YAAQ,IAAI,kBAAkB,CAAC;AAAA,EACjC,CAAC;AACL;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/data-safety.ts"],"sourcesContent":["import { resolvePackageName, getClient } from \"../resolve.js\";\nimport type { Command } from \"commander\";\nimport { loadConfig } from \"@gpc-cli/config\";\n\nimport { importDataSafety, formatOutput } from \"@gpc-cli/core\";\nimport { isDryRun, printDryRun } from \"../dry-run.js\";\nimport { getOutputFormat } from \"../format.js\";\n\n\n\nexport function registerDataSafetyCommands(program: Command): void {\n const dataSafety = program.command(\"data-safety\").description(\"Manage data safety declarations\");\n\n // Get — not supported by Google Play API (no GET endpoint for data safety)\n dataSafety\n .command(\"get\")\n .description(\"Get the current data safety declaration\")\n .action(async () => {\n console.error(\n \"Error: The Google Play Developer API does not provide a GET endpoint for data safety declarations.\",\n );\n console.error(\"\");\n console.error(\"Data safety labels can only be updated (not read) via the API.\");\n console.error(\"To view your current data safety declaration, use the Google Play Console:\");\n console.error(\" https://play.google.com/console → App content → Data safety\");\n console.error(\"\");\n console.error(\n \"To update data safety via the API, use: gpc data-safety update --file <csv-file>\",\n );\n process.exit(2);\n });\n\n // Update\n dataSafety\n .command(\"update\")\n .description(\"Update data safety declaration from a JSON file\")\n .requiredOption(\"--file <path>\", \"Path to data safety JSON file\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const format = getOutputFormat(program, config);\n\n if (isDryRun(program)) {\n printDryRun(\n {\n command: \"data-safety update\",\n action: \"update data safety from\",\n target: options.file,\n },\n format,\n formatOutput,\n );\n return;\n }\n\n const client = await getClient(config);\n\n try {\n const result = await importDataSafety(client, packageName, options.file);\n console.log(formatOutput(result, format));\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n\n // Export — not supported (no GET endpoint)\n dataSafety\n .command(\"export\")\n .description(\"Export data safety declaration to a JSON file\")\n .option(\"--output <path>\", \"Output file path\", \"data-safety.json\")\n .action(async () => {\n console.error(\n \"Error: The Google Play Developer API does not provide a GET endpoint for data safety declarations.\",\n );\n console.error(\"Data safety labels cannot be exported via the API.\");\n console.error(\"\");\n console.error(\"To export your data safety declaration, use the Google Play Console:\");\n console.error(\" App content → Data safety → Export to CSV\");\n process.exit(2);\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AAEA,SAAS,kBAAkB;AAE3B,SAAS,kBAAkB,oBAAoB;AAMxC,SAAS,2BAA2B,SAAwB;AACjE,QAAM,aAAa,QAAQ,QAAQ,aAAa,EAAE,YAAY,iCAAiC;AAG/F,aACG,QAAQ,KAAK,EACb,YAAY,yCAAyC,EACrD,OAAO,YAAY;AAClB,YAAQ;AAAA,MACN;AAAA,IACF;AACA,YAAQ,MAAM,EAAE;AAChB,YAAQ,MAAM,gEAAgE;AAC9E,YAAQ,MAAM,4EAA4E;AAC1F,YAAQ,MAAM,yEAA+D;AAC7E,YAAQ,MAAM,EAAE;AAChB,YAAQ;AAAA,MACN;AAAA,IACF;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AAGH,aACG,QAAQ,QAAQ,EAChB,YAAY,iDAAiD,EAC7D,eAAe,iBAAiB,+BAA+B,EAC/D,OAAO,OAAO,YAAY;AACzB,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,cAAc,mBAAmB,QAAQ,KAAK,EAAE,KAAK,GAAG,MAAM;AACpE,UAAM,SAAS,gBAAgB,SAAS,MAAM;AAE9C,QAAI,SAAS,OAAO,GAAG;AACrB;AAAA,QACE;AAAA,UACE,SAAS;AAAA,UACT,QAAQ;AAAA,UACR,QAAQ,QAAQ;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA;AAAA,IACF;AAEA,UAAM,SAAS,MAAM,UAAU,MAAM;AAErC,QAAI;AACF,YAAM,SAAS,MAAM,iBAAiB,QAAQ,aAAa,QAAQ,IAAI;AACvE,cAAQ,IAAI,aAAa,QAAQ,MAAM,CAAC;AAAA,IAC1C,SAAS,OAAO;AACd,cAAQ,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE;AAChF,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AAGH,aACG,QAAQ,QAAQ,EAChB,YAAY,+CAA+C,EAC3D,OAAO,mBAAmB,oBAAoB,kBAAkB,EAChE,OAAO,YAAY;AAClB,YAAQ;AAAA,MACN;AAAA,IACF;AACA,YAAQ,MAAM,oDAAoD;AAClE,YAAQ,MAAM,EAAE;AAChB,YAAQ,MAAM,sEAAsE;AACpF,YAAQ,MAAM,uDAA6C;AAC3D,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACL;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/device-tiers.ts"],"sourcesContent":["import { resolvePackageName, getClient } from \"../resolve.js\";\nimport type { Command } from \"commander\";\nimport { loadConfig } from \"@gpc-cli/config\";\n\nimport { listDeviceTiers, getDeviceTier, createDeviceTier, formatOutput } from \"@gpc-cli/core\";\nimport { getOutputFormat } from \"../format.js\";\nimport { isDryRun, printDryRun } from \"../dry-run.js\";\nimport { readFile } from \"node:fs/promises\";\n\n\n\nexport function registerDeviceTiersCommands(program: Command): void {\n const dt = program.command(\"device-tiers\").description(\"Manage device tier configurations\");\n\n dt.command(\"list\")\n .description(\"List device tier configurations\")\n .action(async () => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const client = await getClient(config);\n const format = getOutputFormat(program, config);\n\n try {\n const result = await listDeviceTiers(client, packageName);\n const configs = (result as unknown as Record<string, unknown>)[\"deviceTierConfigs\"] as\n | Record<string, unknown>[]\n | undefined;\n if (format !== \"json\" && (!configs || configs.length === 0)) {\n console.log(\"No device tier configs found.\");\n return;\n }\n if (format !== \"json\" && configs) {\n const rows = configs.map((c) => ({\n deviceTierConfigId: c[\"deviceTierConfigId\"] || \"-\",\n deviceGroups: Array.isArray(c[\"deviceGroups\"])\n ? (c[\"deviceGroups\"] as unknown[]).length\n : 0,\n deviceTierSet: c[\"deviceTierSet\"] ? \"yes\" : \"no\",\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 dt.command(\"get <config-id>\")\n .description(\"Get a device tier configuration\")\n .action(async (configId: string) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const client = await getClient(config);\n const format = getOutputFormat(program, config);\n\n try {\n const result = await getDeviceTier(client, packageName, configId);\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 dt.command(\"create\")\n .description(\"Create a device tier configuration from a JSON file\")\n .requiredOption(\"--file <path>\", \"Path to JSON config file\")\n .action(async (opts: { file: string }) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const format = getOutputFormat(program, config);\n\n if (isDryRun(program)) {\n printDryRun(\n {\n command: \"device-tiers create\",\n action: \"create device tier config from\",\n target: opts.file,\n },\n format,\n formatOutput,\n );\n return;\n }\n\n const client = await getClient(config);\n\n try {\n const raw = await readFile(opts.file, \"utf-8\");\n const tierConfig = JSON.parse(raw);\n const result = await createDeviceTier(client, packageName, tierConfig);\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"],"mappings":";;;;;;;;;;;;;;AAEA,SAAS,kBAAkB;AAE3B,SAAS,iBAAiB,eAAe,kBAAkB,oBAAoB;AAG/E,SAAS,gBAAgB;AAIlB,SAAS,4BAA4B,SAAwB;AAClE,QAAM,KAAK,QAAQ,QAAQ,cAAc,EAAE,YAAY,mCAAmC;AAE1F,KAAG,QAAQ,MAAM,EACd,YAAY,iCAAiC,EAC7C,OAAO,YAAY;AAClB,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,cAAc,mBAAmB,QAAQ,KAAK,EAAE,KAAK,GAAG,MAAM;AACpE,UAAM,SAAS,MAAM,UAAU,MAAM;AACrC,UAAM,SAAS,gBAAgB,SAAS,MAAM;AAE9C,QAAI;AACF,YAAM,SAAS,MAAM,gBAAgB,QAAQ,WAAW;AACxD,YAAM,UAAW,OAA8C,mBAAmB;AAGlF,UAAI,WAAW,WAAW,CAAC,WAAW,QAAQ,WAAW,IAAI;AAC3D,gBAAQ,IAAI,+BAA+B;AAC3C;AAAA,MACF;AACA,UAAI,WAAW,UAAU,SAAS;AAChC,cAAM,OAAO,QAAQ,IAAI,CAAC,OAAO;AAAA,UAC/B,oBAAoB,EAAE,oBAAoB,KAAK;AAAA,UAC/C,cAAc,MAAM,QAAQ,EAAE,cAAc,CAAC,IACxC,EAAE,cAAc,EAAgB,SACjC;AAAA,UACJ,eAAe,EAAE,eAAe,IAAI,QAAQ;AAAA,QAC9C,EAAE;AACF,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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,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC,EAAE;AAChF,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AACL;","names":[]}
@@ -1,96 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- resolvePackageName
4
- } from "./chunk-AA577WVQ.js";
5
- import {
6
- bold,
7
- dim,
8
- green,
9
- red,
10
- yellow
11
- } from "./chunk-FAN4ZITI.js";
12
- import {
13
- getOutputFormat
14
- } from "./chunk-ELXAK7GI.js";
15
-
16
- // src/commands/diff.ts
17
- import { loadConfig } from "@gpc-cli/config";
18
- import { resolveAuth } from "@gpc-cli/auth";
19
- import { createApiClient } from "@gpc-cli/api";
20
- import { getReleasesStatus, diffReleases, diffListingsCommand, formatOutput } from "@gpc-cli/core";
21
- function registerDiffCommand(program) {
22
- program.command("diff").description("Preview current release state and pending changes (read-only)").option("--from <track>", "Compare releases from this track").option("--to <track>", "Compare releases to this track").option("--metadata <dir>", "Compare local metadata directory vs remote listings").action(async (options) => {
23
- const config = await loadConfig();
24
- const packageName = resolvePackageName(program.opts()["app"], config);
25
- const format = getOutputFormat(program, config);
26
- const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });
27
- const client = createApiClient({ auth });
28
- try {
29
- const sections = {};
30
- const releases = await getReleasesStatus(client, packageName);
31
- sections["releases"] = releases;
32
- let trackDiff;
33
- if (options.from && options.to) {
34
- trackDiff = await diffReleases(client, packageName, options.from, options.to);
35
- sections["trackDiff"] = trackDiff;
36
- }
37
- let metadataDiff;
38
- if (options.metadata) {
39
- metadataDiff = await diffListingsCommand(client, packageName, options.metadata);
40
- sections["metadata"] = metadataDiff;
41
- }
42
- if (format === "json") {
43
- console.log(formatOutput(sections, format));
44
- return;
45
- }
46
- console.log(bold("GPC Diff \u2014 Current State"));
47
- console.log("");
48
- console.log(bold("Releases"));
49
- if (releases.length === 0) {
50
- console.log(dim(" No releases found"));
51
- } else {
52
- for (const r of releases) {
53
- const statusColor = r.status === "completed" ? green : r.status === "inProgress" ? yellow : dim;
54
- const fraction = r.userFraction ? ` ${yellow(`${Math.round(r.userFraction * 100)}%`)}` : "";
55
- const versions = r.versionCodes.join(", ");
56
- console.log(
57
- ` ${r.track.padEnd(14)} ${statusColor(r.status.padEnd(12))} v${versions}${fraction}`
58
- );
59
- }
60
- }
61
- console.log("");
62
- if (trackDiff) {
63
- console.log(bold(`Track Diff: ${trackDiff.fromTrack} \u2192 ${trackDiff.toTrack}`));
64
- if (trackDiff.diffs.length === 0) {
65
- console.log(dim(" No differences"));
66
- } else {
67
- for (const d of trackDiff.diffs) {
68
- console.log(
69
- ` ${d.field.padEnd(16)} ${red(d.track1Value || "(empty)")} \u2192 ${green(d.track2Value || "(empty)")}`
70
- );
71
- }
72
- }
73
- console.log("");
74
- }
75
- if (metadataDiff && Array.isArray(metadataDiff)) {
76
- console.log(bold("Metadata Diff (local vs remote)"));
77
- if (metadataDiff.length === 0) {
78
- console.log(dim(" No differences \u2014 local matches remote"));
79
- } else {
80
- for (const d of metadataDiff) {
81
- const icon = d.status === "added" ? green("+") : d.status === "removed" ? red("-") : yellow("~");
82
- console.log(` ${icon} ${d.language}/${d.field}: ${d.status}`);
83
- }
84
- }
85
- console.log("");
86
- }
87
- } catch (error) {
88
- console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
89
- process.exit(4);
90
- }
91
- });
92
- }
93
- export {
94
- registerDiffCommand
95
- };
96
- //# sourceMappingURL=diff-V77SMKAQ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/commands/diff.ts"],"sourcesContent":["import { resolvePackageName } from \"../resolve.js\";\n// Named exports only. No default export.\n\nimport type { Command } from \"commander\";\nimport { loadConfig } from \"@gpc-cli/config\";\nimport { resolveAuth } from \"@gpc-cli/auth\";\nimport { createApiClient } from \"@gpc-cli/api\";\nimport { getReleasesStatus, diffReleases, diffListingsCommand, formatOutput } from \"@gpc-cli/core\";\nimport type { ReleaseDiff } from \"@gpc-cli/core\";\nimport { getOutputFormat } from \"../format.js\";\nimport { green, red, yellow, dim, bold } from \"../colors.js\";\n\n\nexport function registerDiffCommand(program: Command): void {\n program\n .command(\"diff\")\n .description(\"Preview current release state and pending changes (read-only)\")\n .option(\"--from <track>\", \"Compare releases from this track\")\n .option(\"--to <track>\", \"Compare releases to this track\")\n .option(\"--metadata <dir>\", \"Compare local metadata directory vs remote listings\")\n .action(async (options) => {\n const config = await loadConfig();\n const packageName = resolvePackageName(program.opts()[\"app\"], config);\n const format = getOutputFormat(program, config);\n\n const auth = await resolveAuth({ serviceAccountPath: config.auth?.serviceAccount });\n const client = createApiClient({ auth });\n\n try {\n const sections: Record<string, unknown> = {};\n\n // Always show release status across all tracks\n const releases = await getReleasesStatus(client, packageName);\n sections[\"releases\"] = releases;\n\n // Track-to-track diff if specified\n let trackDiff: { fromTrack: string; toTrack: string; diffs: ReleaseDiff[] } | undefined;\n if (options.from && options.to) {\n trackDiff = await diffReleases(client, packageName, options.from, options.to);\n sections[\"trackDiff\"] = trackDiff;\n }\n\n // Metadata diff if specified\n let metadataDiff: unknown;\n if (options.metadata) {\n metadataDiff = await diffListingsCommand(client, packageName, options.metadata);\n sections[\"metadata\"] = metadataDiff;\n }\n\n if (format === \"json\") {\n console.log(formatOutput(sections, format));\n return;\n }\n\n // Human-readable output\n console.log(bold(\"GPC Diff — Current State\"));\n console.log(\"\");\n\n // Release status\n console.log(bold(\"Releases\"));\n if (releases.length === 0) {\n console.log(dim(\" No releases found\"));\n } else {\n for (const r of releases) {\n const statusColor =\n r.status === \"completed\" ? green : r.status === \"inProgress\" ? yellow : dim;\n const fraction = r.userFraction\n ? ` ${yellow(`${Math.round(r.userFraction * 100)}%`)}`\n : \"\";\n const versions = r.versionCodes.join(\", \");\n console.log(\n ` ${r.track.padEnd(14)} ${statusColor(r.status.padEnd(12))} v${versions}${fraction}`,\n );\n }\n }\n console.log(\"\");\n\n // Track diff\n if (trackDiff) {\n console.log(bold(`Track Diff: ${trackDiff.fromTrack} → ${trackDiff.toTrack}`));\n if (trackDiff.diffs.length === 0) {\n console.log(dim(\" No differences\"));\n } else {\n for (const d of trackDiff.diffs) {\n console.log(\n ` ${d.field.padEnd(16)} ${red(d.track1Value || \"(empty)\")} → ${green(d.track2Value || \"(empty)\")}`,\n );\n }\n }\n console.log(\"\");\n }\n\n // Metadata diff\n if (metadataDiff && Array.isArray(metadataDiff)) {\n console.log(bold(\"Metadata Diff (local vs remote)\"));\n if (metadataDiff.length === 0) {\n console.log(dim(\" No differences — local matches remote\"));\n } else {\n for (const d of metadataDiff as Array<{\n language: string;\n field: string;\n status: string;\n }>) {\n const icon =\n d.status === \"added\" ? green(\"+\") : d.status === \"removed\" ? red(\"-\") : yellow(\"~\");\n console.log(` ${icon} ${d.language}/${d.field}: ${d.status}`);\n }\n }\n console.log(\"\");\n }\n } catch (error) {\n console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(4);\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAIA,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,mBAAmB,cAAc,qBAAqB,oBAAoB;AAM5E,SAAS,oBAAoB,SAAwB;AAC1D,UACG,QAAQ,MAAM,EACd,YAAY,+DAA+D,EAC3E,OAAO,kBAAkB,kCAAkC,EAC3D,OAAO,gBAAgB,gCAAgC,EACvD,OAAO,oBAAoB,qDAAqD,EAChF,OAAO,OAAO,YAAY;AACzB,UAAM,SAAS,MAAM,WAAW;AAChC,UAAM,cAAc,mBAAmB,QAAQ,KAAK,EAAE,KAAK,GAAG,MAAM;AACpE,UAAM,SAAS,gBAAgB,SAAS,MAAM;AAE9C,UAAM,OAAO,MAAM,YAAY,EAAE,oBAAoB,OAAO,MAAM,eAAe,CAAC;AAClF,UAAM,SAAS,gBAAgB,EAAE,KAAK,CAAC;AAEvC,QAAI;AACF,YAAM,WAAoC,CAAC;AAG3C,YAAM,WAAW,MAAM,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