@gpc-cli/core 0.9.24 → 0.9.26

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.d.ts CHANGED
@@ -757,6 +757,7 @@ interface AppStatus {
757
757
  packageName: string;
758
758
  fetchedAt: string;
759
759
  cached: boolean;
760
+ sections: string[];
760
761
  releases: StatusRelease[];
761
762
  vitals: {
762
763
  windowDays: number;
package/dist/index.js CHANGED
@@ -3988,7 +3988,12 @@ async function loadStatusCache(packageName, ttlSeconds = DEFAULT_TTL_SECONDS) {
3988
3988
  const entry = JSON.parse(raw);
3989
3989
  const age = (Date.now() - new Date(entry.fetchedAt).getTime()) / 1e3;
3990
3990
  if (age > (entry.ttl ?? ttlSeconds)) return null;
3991
- return { ...entry.data, cached: true };
3991
+ const data = entry.data;
3992
+ return {
3993
+ ...data,
3994
+ sections: data.sections ?? ["releases", "vitals", "reviews"],
3995
+ cached: true
3996
+ };
3992
3997
  } catch {
3993
3998
  return null;
3994
3999
  }
@@ -4134,6 +4139,7 @@ async function getAppStatus(client, reporting, packageName, options = {}) {
4134
4139
  packageName,
4135
4140
  fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
4136
4141
  cached: false,
4142
+ sections: [...sections],
4137
4143
  releases,
4138
4144
  vitals: {
4139
4145
  windowDays: days,
@@ -4183,53 +4189,69 @@ function formatTrend(current, previous) {
4183
4189
  if (current < previous) return ` \u2193 from ${previous.toFixed(1)}`;
4184
4190
  return "";
4185
4191
  }
4192
+ function relativeTime(isoString) {
4193
+ const diffMs = Date.now() - new Date(isoString).getTime();
4194
+ const diffMin = Math.floor(diffMs / 6e4);
4195
+ if (diffMin < 1) return "just now";
4196
+ if (diffMin < 60) return `${diffMin} min ago`;
4197
+ const diffHr = Math.floor(diffMin / 60);
4198
+ if (diffHr < 24) return `${diffHr}h ago`;
4199
+ return `${Math.floor(diffHr / 24)}d ago`;
4200
+ }
4186
4201
  function allVitalsUnknown(vitals) {
4187
4202
  return vitals.crashes.status === "unknown" && vitals.anr.status === "unknown" && vitals.slowStarts.status === "unknown" && vitals.slowRender.status === "unknown";
4188
4203
  }
4189
4204
  function formatStatusTable(status) {
4190
4205
  const lines = [];
4191
- const cachedLabel = status.cached ? ` (cached ${new Date(status.fetchedAt).toLocaleTimeString()})` : ` (fetched ${new Date(status.fetchedAt).toLocaleTimeString()})`;
4206
+ const sectionSet = new Set(status.sections);
4207
+ const cachedLabel = status.cached ? ` (cached ${relativeTime(status.fetchedAt)})` : ` (fetched ${relativeTime(status.fetchedAt)})`;
4192
4208
  lines.push(`App: ${status.packageName}${cachedLabel}`);
4193
- lines.push("");
4194
- lines.push("RELEASES");
4195
- if (status.releases.length === 0) {
4196
- lines.push(" No releases found.");
4197
- } else {
4198
- const trackW = Math.max(10, ...status.releases.map((r) => r.track.length));
4199
- const versionW = Math.max(7, ...status.releases.map((r) => r.versionCode.length));
4200
- const statusW = Math.max(8, ...status.releases.map((r) => r.status.length));
4201
- for (const r of status.releases) {
4209
+ if (sectionSet.has("releases")) {
4210
+ lines.push("");
4211
+ lines.push("RELEASES");
4212
+ if (status.releases.length === 0) {
4213
+ lines.push(" No releases found.");
4214
+ } else {
4215
+ const trackW = Math.max(10, ...status.releases.map((r) => r.track.length));
4216
+ const versionW = Math.max(7, ...status.releases.map((r) => r.versionCode.length));
4217
+ const statusW = Math.max(8, ...status.releases.map((r) => r.status.length));
4218
+ for (const r of status.releases) {
4219
+ lines.push(
4220
+ ` ${r.track.padEnd(trackW)} ${r.versionCode.padEnd(versionW)} ${r.status.padEnd(statusW)} ${formatFraction(r.userFraction)}`
4221
+ );
4222
+ }
4223
+ }
4224
+ }
4225
+ if (sectionSet.has("vitals")) {
4226
+ lines.push("");
4227
+ lines.push(`VITALS (last ${status.vitals.windowDays} days)`);
4228
+ if (allVitalsUnknown(status.vitals)) {
4229
+ lines.push(" No vitals data available for this period.");
4230
+ } else {
4231
+ const { crashes, anr, slowStarts, slowRender } = status.vitals;
4232
+ const crashVal = `${formatVitalValue(crashes)}${vitalTrendArrow(crashes)}`;
4233
+ const anrVal = `${formatVitalValue(anr)}${vitalTrendArrow(anr)}`;
4234
+ const slowStartVal = `${formatVitalValue(slowStarts)}${vitalTrendArrow(slowStarts)}`;
4235
+ const slowRenderVal = `${formatVitalValue(slowRender)}${vitalTrendArrow(slowRender)}`;
4202
4236
  lines.push(
4203
- ` ${r.track.padEnd(trackW)} ${r.versionCode.padEnd(versionW)} ${r.status.padEnd(statusW)} ${formatFraction(r.userFraction)}`
4237
+ ` crashes ${crashVal.padEnd(10)} ${vitalIndicator(crashes)} anr ${anrVal.padEnd(10)} ${vitalIndicator(anr)}`
4238
+ );
4239
+ lines.push(
4240
+ ` slow starts ${slowStartVal.padEnd(10)} ${vitalIndicator(slowStarts)} slow render ${slowRenderVal.padEnd(10)} ${vitalIndicator(slowRender)}`
4204
4241
  );
4205
4242
  }
4206
4243
  }
4207
- lines.push("");
4208
- lines.push(`VITALS (last ${status.vitals.windowDays} days)`);
4209
- if (allVitalsUnknown(status.vitals)) {
4210
- lines.push(" No vitals data available for this period.");
4211
- } else {
4212
- const { crashes, anr, slowStarts, slowRender } = status.vitals;
4213
- const crashVal = `${formatVitalValue(crashes)}${vitalTrendArrow(crashes)}`;
4214
- const anrVal = `${formatVitalValue(anr)}${vitalTrendArrow(anr)}`;
4215
- const slowStartVal = `${formatVitalValue(slowStarts)}${vitalTrendArrow(slowStarts)}`;
4216
- const slowRenderVal = `${formatVitalValue(slowRender)}${vitalTrendArrow(slowRender)}`;
4217
- lines.push(
4218
- ` crashes ${crashVal.padEnd(10)} ${vitalIndicator(crashes)} anr ${anrVal.padEnd(10)} ${vitalIndicator(anr)}`
4219
- );
4220
- lines.push(
4221
- ` slow starts ${slowStartVal.padEnd(10)} ${vitalIndicator(slowStarts)} slow render ${slowRenderVal.padEnd(10)} ${vitalIndicator(slowRender)}`
4222
- );
4223
- }
4224
- lines.push("");
4225
- lines.push(`REVIEWS (last ${status.reviews.windowDays} days)`);
4226
- const { averageRating, previousAverageRating, totalNew, positivePercent } = status.reviews;
4227
- if (totalNew === 0 && averageRating === void 0) {
4228
- lines.push(" No reviews in this period.");
4229
- } else {
4230
- const trend = formatTrend(averageRating, previousAverageRating);
4231
- const positiveStr = positivePercent !== void 0 ? ` ${positivePercent}% positive` : "";
4232
- lines.push(` ${formatRating(averageRating)} ${totalNew} new${positiveStr}${trend}`);
4244
+ if (sectionSet.has("reviews")) {
4245
+ lines.push("");
4246
+ lines.push(`REVIEWS (last ${status.reviews.windowDays} days)`);
4247
+ const { averageRating, previousAverageRating, totalNew, positivePercent } = status.reviews;
4248
+ if (totalNew === 0 && averageRating === void 0) {
4249
+ lines.push(" No reviews in this period.");
4250
+ } else {
4251
+ const trend = formatTrend(averageRating, previousAverageRating);
4252
+ const positiveStr = positivePercent !== void 0 ? ` ${positivePercent}% positive` : "";
4253
+ lines.push(` ${formatRating(averageRating)} ${totalNew} new${positiveStr}${trend}`);
4254
+ }
4233
4255
  }
4234
4256
  return lines.join("\n");
4235
4257
  }