@gpc-cli/core 0.9.67 → 0.9.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  validateUploadFile,
29
29
  waitForBundle,
30
30
  waitForBundleProcessing
31
- } from "./chunk-4KDWLQB3.js";
31
+ } from "./chunk-7EVJN7FZ.js";
32
32
 
33
33
  // src/output.ts
34
34
  import process2 from "process";
@@ -71,6 +71,55 @@ function formatOutput(data, format, redact = true) {
71
71
  return formatJson(safe);
72
72
  }
73
73
  }
74
+ function annotateListResult(result, itemsKey, emptyMessage) {
75
+ const source = result;
76
+ const items = Array.isArray(source[itemsKey]) ? source[itemsKey] : [];
77
+ const annotated = {
78
+ ...source,
79
+ nextPageToken: source["nextPageToken"] ?? null,
80
+ meta: { count: items.length }
81
+ };
82
+ if (items.length === 0) annotated["message"] = emptyMessage;
83
+ return annotated;
84
+ }
85
+ function moreResultsFooter(nextPageToken) {
86
+ if (!nextPageToken) return void 0;
87
+ return dim(`More results available. Re-run this command with --next-page ${nextPageToken}`);
88
+ }
89
+ var CURRENCY_DECIMALS = {
90
+ // Zero-decimal currencies
91
+ JPY: 0,
92
+ KRW: 0,
93
+ VND: 0,
94
+ CLP: 0,
95
+ ISK: 0,
96
+ XAF: 0,
97
+ XOF: 0,
98
+ XPF: 0,
99
+ BIF: 0,
100
+ DJF: 0,
101
+ GNF: 0,
102
+ KMF: 0,
103
+ RWF: 0,
104
+ UGX: 0,
105
+ VUV: 0,
106
+ PYG: 0,
107
+ // Three-decimal currencies
108
+ BHD: 3,
109
+ IQD: 3,
110
+ JOD: 3,
111
+ KWD: 3,
112
+ LYD: 3,
113
+ OMR: 3,
114
+ TND: 3
115
+ };
116
+ function formatMoney(units, nanos, currencyCode) {
117
+ const decimals = currencyCode ? CURRENCY_DECIMALS[currencyCode.toUpperCase()] ?? 2 : 2;
118
+ const whole = String(units ?? "0");
119
+ if (decimals === 0) return whole;
120
+ const frac = String(Math.abs(nanos ?? 0)).padStart(9, "0").slice(0, decimals);
121
+ return `${whole}.${frac}`;
122
+ }
74
123
  var SENSITIVE_KEYS = /* @__PURE__ */ new Set([
75
124
  "private_key",
76
125
  "privateKey",
@@ -238,10 +287,11 @@ ${separator}
238
287
  ${body}`;
239
288
  }
240
289
  function escapeCsvField(val) {
241
- if (val.includes(",") || val.includes('"') || val.includes("\n") || val.includes("\r")) {
242
- return `"${val.replace(/"/g, '""')}"`;
290
+ let out = /^[=+\-@\t\r]/.test(val) ? `'${val}` : val;
291
+ if (out.includes(",") || out.includes('"') || out.includes("\n") || out.includes("\r")) {
292
+ out = `"${out.replace(/"/g, '""')}"`;
243
293
  }
244
- return val;
294
+ return out;
245
295
  }
246
296
  function formatCsv(data) {
247
297
  const rows = toRows(data);
@@ -262,7 +312,10 @@ function formatTsv(data) {
262
312
  if (!firstRow) return "";
263
313
  const keys = Object.keys(firstRow);
264
314
  if (keys.length === 0) return "";
265
- const escape = (val) => val.replace(/\t/g, "\\t").replace(/\r/g, "\\r").replace(/\n/g, "\\n");
315
+ const escape = (val) => {
316
+ const guarded = /^[=+\-@]/.test(val) ? `'${val}` : val;
317
+ return guarded.replace(/\t/g, "\\t").replace(/\r/g, "\\r").replace(/\n/g, "\\n");
318
+ };
266
319
  const header = keys.join(" ");
267
320
  const body = rows.map((row) => keys.map((key) => escape(cellValue(row[key]))).join(" ")).join("\n");
268
321
  return `${header}
@@ -1933,8 +1986,9 @@ function analyzeReviews(reviews) {
1933
1986
  // src/commands/reviews.ts
1934
1987
  async function listReviews(client, packageName, options) {
1935
1988
  let reviews;
1989
+ let nextPageToken;
1936
1990
  if (options?.all) {
1937
- const { items } = await paginateAll(
1991
+ const { items, nextPageToken: token } = await paginateAll(
1938
1992
  async (pageToken) => {
1939
1993
  const apiOptions = { token: pageToken };
1940
1994
  if (options?.translationLanguage)
@@ -1949,6 +2003,7 @@ async function listReviews(client, packageName, options) {
1949
2003
  { limit: options?.limit }
1950
2004
  );
1951
2005
  reviews = items;
2006
+ nextPageToken = token;
1952
2007
  } else {
1953
2008
  const apiOptions = {};
1954
2009
  if (options?.translationLanguage) apiOptions.translationLanguage = options.translationLanguage;
@@ -1956,6 +2011,7 @@ async function listReviews(client, packageName, options) {
1956
2011
  if (options?.nextPage) apiOptions.token = options.nextPage;
1957
2012
  const response = await client.reviews.list(packageName, apiOptions);
1958
2013
  reviews = response.reviews || [];
2014
+ nextPageToken = response.tokenPagination?.nextPageToken;
1959
2015
  }
1960
2016
  if (options?.stars !== void 0) {
1961
2017
  reviews = reviews.filter((r) => {
@@ -1976,7 +2032,7 @@ async function listReviews(client, packageName, options) {
1976
2032
  return userComment && Number(userComment.lastModified.seconds) >= sinceTime;
1977
2033
  });
1978
2034
  }
1979
- return reviews;
2035
+ return { reviews, nextPageToken };
1980
2036
  }
1981
2037
  async function getReview(client, packageName, reviewId, translationLanguage) {
1982
2038
  return client.reviews.get(packageName, reviewId, translationLanguage);
@@ -2065,7 +2121,7 @@ function csvEscape(value) {
2065
2121
  return safe;
2066
2122
  }
2067
2123
  async function analyzeReviews2(client, packageName, options) {
2068
- const reviews = await listReviews(client, packageName, options);
2124
+ const { reviews } = await listReviews(client, packageName, options);
2069
2125
  const items = reviews.map((r) => {
2070
2126
  const uc = r.comments?.[0]?.userComment;
2071
2127
  return {
@@ -2832,7 +2888,7 @@ async function getAppStatus(client, reporting, packageName, options = {}) {
2832
2888
  sections.has("vitals") ? queryVitalWithTrend(reporting, packageName, "anrRateMetricSet", days) : Promise.resolve(SKIPPED_VITAL),
2833
2889
  sections.has("vitals") ? queryVitalWithTrend(reporting, packageName, "slowStartRateMetricSet", days) : Promise.resolve(SKIPPED_VITAL),
2834
2890
  sections.has("vitals") ? queryVitalWithTrend(reporting, packageName, "slowRenderingRateMetricSet", days) : Promise.resolve(SKIPPED_VITAL),
2835
- sections.has("reviews") ? listReviews(client, packageName, { maxResults: 500 }) : Promise.resolve([])
2891
+ sections.has("reviews") ? listReviews(client, packageName, { maxResults: 500 }) : Promise.resolve({ reviews: [] })
2836
2892
  ]);
2837
2893
  const sectionErrors = [];
2838
2894
  const rawReleases = releasesResult.status === "fulfilled" ? releasesResult.value : [];
@@ -2856,7 +2912,7 @@ async function getAppStatus(client, reporting, packageName, options = {}) {
2856
2912
  const slowRender = slowRenderResult.status === "fulfilled" ? slowRenderResult.value : SKIPPED_VITAL;
2857
2913
  if (slowRenderResult.status === "rejected")
2858
2914
  sectionErrors.push(`vitals/slowRender: ${String(slowRenderResult.reason)}`);
2859
- const rawReviews = reviewsResult.status === "fulfilled" ? reviewsResult.value : [];
2915
+ const rawReviews = reviewsResult.status === "fulfilled" ? reviewsResult.value.reviews : [];
2860
2916
  if (reviewsResult.status === "rejected")
2861
2917
  sectionErrors.push(`reviews: ${String(reviewsResult.reason)}`);
2862
2918
  const reviews = computeReviewSentiment(rawReviews, reviewDays);
@@ -3275,7 +3331,7 @@ async function handleBreach(event, config, client) {
3275
3331
  }
3276
3332
  case "halt": {
3277
3333
  try {
3278
- const { updateRollout: updateRollout2 } = await import("./releases-OAKWPEAC.js");
3334
+ const { updateRollout: updateRollout2 } = await import("./releases-GKSVPYT7.js");
3279
3335
  await updateRollout2(client, config.packageName, config.track, "halt");
3280
3336
  halted = true;
3281
3337
  } catch {
@@ -3606,7 +3662,7 @@ async function listVoidedPurchases(client, packageName, options) {
3606
3662
  if (options?.limit || options?.nextPage) {
3607
3663
  const result = await paginateAll4(
3608
3664
  async (pageToken) => {
3609
- const resp = await client.purchases.listVoided(packageName, {
3665
+ const resp2 = await client.purchases.listVoided(packageName, {
3610
3666
  startTime: options?.startTime,
3611
3667
  endTime: options?.endTime,
3612
3668
  type: options?.type,
@@ -3615,15 +3671,19 @@ async function listVoidedPurchases(client, packageName, options) {
3615
3671
  token: pageToken
3616
3672
  });
3617
3673
  return {
3618
- items: resp.voidedPurchases || [],
3619
- nextPageToken: resp.tokenPagination?.nextPageToken
3674
+ items: resp2.voidedPurchases || [],
3675
+ nextPageToken: resp2.tokenPagination?.nextPageToken
3620
3676
  };
3621
3677
  },
3622
3678
  { limit: options.limit, startPageToken: options.nextPage }
3623
3679
  );
3624
3680
  return { voidedPurchases: result.items, nextPageToken: result.nextPageToken };
3625
3681
  }
3626
- return client.purchases.listVoided(packageName, options);
3682
+ const resp = await client.purchases.listVoided(packageName, options);
3683
+ return {
3684
+ voidedPurchases: resp.voidedPurchases || [],
3685
+ nextPageToken: resp.tokenPagination?.nextPageToken
3686
+ };
3627
3687
  }
3628
3688
  async function refundOrder(client, packageName, orderId, options) {
3629
3689
  validatePackageName(packageName);
@@ -7191,15 +7251,30 @@ async function fetchChangelog(options) {
7191
7251
  signal: controller.signal
7192
7252
  });
7193
7253
  } catch {
7194
- throw new GpcError(`Could not fetch changelog.`, "CHANGELOG_FETCH_FAILED", 5, `View online: ${DOCS_CHANGELOG_URL}`);
7254
+ throw new GpcError(
7255
+ `Could not fetch changelog.`,
7256
+ "CHANGELOG_FETCH_FAILED",
7257
+ 5,
7258
+ `View online: ${DOCS_CHANGELOG_URL}`
7259
+ );
7195
7260
  } finally {
7196
7261
  clearTimeout(timer);
7197
7262
  }
7198
7263
  if (!response.ok) {
7199
7264
  if (response.status === 404 && options?.version) {
7200
- throw new GpcError(`Version ${options.version} not found.`, "CHANGELOG_VERSION_NOT_FOUND", 1, `Run: gpc changelog --limit 10`);
7265
+ throw new GpcError(
7266
+ `Version ${options.version} not found.`,
7267
+ "CHANGELOG_VERSION_NOT_FOUND",
7268
+ 1,
7269
+ `Run: gpc changelog --limit 10`
7270
+ );
7201
7271
  }
7202
- throw new GpcError(`GitHub API returned ${response.status}.`, "CHANGELOG_FETCH_FAILED", 5, `View online: ${DOCS_CHANGELOG_URL}`);
7272
+ throw new GpcError(
7273
+ `GitHub API returned ${response.status}.`,
7274
+ "CHANGELOG_FETCH_FAILED",
7275
+ 5,
7276
+ `View online: ${DOCS_CHANGELOG_URL}`
7277
+ );
7203
7278
  }
7204
7279
  const data = await response.json();
7205
7280
  const releases = Array.isArray(data) ? data : [data];
@@ -8849,6 +8924,7 @@ export {
8849
8924
  analyzeBundle,
8850
8925
  analyzeRemoteListings,
8851
8926
  analyzeReviews2 as analyzeReviews,
8927
+ annotateListResult,
8852
8928
  applyReleaseNotes,
8853
8929
  assignRelease,
8854
8930
  batchGetOrders,
@@ -8924,6 +9000,7 @@ export {
8924
9000
  formatCustomPayload,
8925
9001
  formatDiscordPayload,
8926
9002
  formatJunit,
9003
+ formatMoney,
8927
9004
  formatNotification,
8928
9005
  formatOutput,
8929
9006
  formatPathLabel,
@@ -9010,6 +9087,7 @@ export {
9010
9087
  loadStatusCache,
9011
9088
  maybePaginate,
9012
9089
  migratePrices,
9090
+ moreResultsFooter,
9013
9091
  normalizeFingerprint,
9014
9092
  parseAppfile,
9015
9093
  parseCommit,