@rebasepro/cli 0.16.1-canary.ge71347e → 0.17.0

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.es.js CHANGED
@@ -2164,7 +2164,7 @@ async function applyHeadless(targetDirectory, headless) {
2164
2164
  recursive: true,
2165
2165
  force: true
2166
2166
  });
2167
- for (const stray of ["admin.d.ts", "frontend-assets.d.ts"]) fs.rmSync(path.join(targetDirectory, "config", stray), { force: true });
2167
+ for (const stray of ["cms.d.ts", "frontend-assets.d.ts"]) fs.rmSync(path.join(targetDirectory, "config", stray), { force: true });
2168
2168
  fs.rmSync(path.join(targetDirectory, "backend", "src", "schema.generated.ts"), { force: true });
2169
2169
  const overlayDir = path.resolve(cliRoot, "templates", "overlays", "baas");
2170
2170
  if (!fs.existsSync(overlayDir)) {
@@ -9204,6 +9204,23 @@ async function statusCommand(rawArgs) {
9204
9204
  reportError(e, "Failed to load status");
9205
9205
  }
9206
9206
  }
9207
+ /**
9208
+ * CPU with the ceiling it is a percentage of.
9209
+ *
9210
+ * A bare "0.2%" is unreadable without knowing 0.2% of what, and on a burstable
9211
+ * pod the answer is not obvious: these request 250m and may burst to 2 vCPU, so
9212
+ * a pod at 40% of its LIMIT is at over three times its guaranteed share and may
9213
+ * still be throttled. Naming both is the difference between a number and a
9214
+ * number that means something.
9215
+ */
9216
+ function cpuLine(m) {
9217
+ if (!m.cpu) return void 0;
9218
+ const limit = m.allocation?.cpuLimitMillicores;
9219
+ const request = m.allocation?.cpuRequestMillicores;
9220
+ if (limit == null && request == null) return m.cpu;
9221
+ const parts = [request != null ? `${request}m guaranteed` : null, limit != null ? `bursts to ${limit}m` : null].filter(Boolean).join(", ");
9222
+ return `${m.cpu} ${chalk.gray(`(${parts}, per instance)`)}`;
9223
+ }
9207
9224
  async function metricsCommand(rawArgs) {
9208
9225
  const { client } = await requireClient(rawArgs);
9209
9226
  const projectId = await requireProject(rawArgs, client);
@@ -9212,16 +9229,39 @@ async function metricsCommand(rawArgs) {
9212
9229
  method: "GET",
9213
9230
  path: projectId
9214
9231
  });
9232
+ const of = m.subject?.workload ? `${m.subject.workload}${m.subject.kind === "deployment" ? " (backend only — not the database)" : ""}` : void 0;
9233
+ const sampled = m.subject?.sampledInstances;
9234
+ const coverage = sampled === void 0 ? void 0 : sampled === 0 ? chalk.yellow("no instances reported yet") : `${sampled} instance${sampled === 1 ? "" : "s"}`;
9215
9235
  emit(() => {
9216
9236
  console.log("");
9217
9237
  console.log(chalk.bold(` 📊 Metrics — project ${displayProjectRef(rawArgs)}`));
9218
9238
  console.log("");
9219
9239
  keyValues([
9220
9240
  ["Status", m.status ? colorStatus(m.status === "running" ? "active" : m.status) : void 0],
9221
- ["CPU", m.cpu],
9241
+ ["Measuring", of],
9242
+ ["Sampled", coverage],
9243
+ ["CPU", cpuLine(m)],
9222
9244
  ["Memory", m.memory ? `${m.memory}${m.memoryPercent ? ` (${m.memoryPercent})` : ""}` : void 0],
9223
9245
  ["Disk", m.disk]
9224
9246
  ]);
9247
+ if (m.condition) {
9248
+ console.log("");
9249
+ console.error(chalk.red(` ✗ ${m.condition.reason ?? "Not healthy"}`));
9250
+ if (m.condition.message) note(` ${m.condition.message}`);
9251
+ }
9252
+ if (m.instances?.length) {
9253
+ console.log("");
9254
+ note(" Instances");
9255
+ for (const i of m.instances) {
9256
+ const cpu = i.cpuMillicores != null ? `${Math.round(i.cpuMillicores)}m` : "—";
9257
+ const mem = i.memoryBytes != null ? `${(i.memoryBytes / 1024 / 1024).toFixed(0)} MiB` : "—";
9258
+ const health = i.ready === false ? chalk.yellow(" not ready") : "";
9259
+ const restarts = i.restarts ? chalk.yellow(` ${i.restarts}×restarted`) : "";
9260
+ note(` ${(i.name ?? "?").padEnd(34)} ${cpu.padStart(6)} ${mem.padStart(9)}${health}${restarts}`);
9261
+ if (i.lastTerminationReason) note(chalk.gray(` last exit: ${i.lastTerminationReason}` + (i.lastTerminationExitCode != null ? ` (code ${i.lastTerminationExitCode})` : "")));
9262
+ if (i.waitingReason) note(chalk.gray(` waiting: ${i.waitingReason}`));
9263
+ }
9264
+ }
9225
9265
  console.log("");
9226
9266
  }, {
9227
9267
  projectId,
@@ -9229,7 +9269,11 @@ async function metricsCommand(rawArgs) {
9229
9269
  cpu: m.cpu ?? null,
9230
9270
  memory: m.memory ?? null,
9231
9271
  memoryPercent: m.memoryPercent ?? null,
9232
- disk: m.disk ?? null
9272
+ disk: m.disk ?? null,
9273
+ subject: m.subject ?? null,
9274
+ allocation: m.allocation ?? null,
9275
+ instances: m.instances ?? null,
9276
+ condition: m.condition ?? null
9233
9277
  });
9234
9278
  } catch (e) {
9235
9279
  reportError(e, "Failed to fetch metrics");