@rebasepro/cli 0.26.0 → 0.28.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/{agent-setup-D9mHRZ5R.js → agent-setup-0uyfC7VX.js} +3 -3
- package/dist/{agent-setup-D9mHRZ5R.js.map → agent-setup-0uyfC7VX.js.map} +1 -1
- package/dist/{api-keys-CyJ26KEJ.js → api-keys-Dfw5-9s1.js} +23 -2
- package/dist/{api-keys-CyJ26KEJ.js.map → api-keys-Dfw5-9s1.js.map} +1 -1
- package/dist/{apps-CnLDV5b6.js → apps-BpYRGOaM.js} +3 -3
- package/dist/{apps-CnLDV5b6.js.map → apps-BpYRGOaM.js.map} +1 -1
- package/dist/{auth-dII2jCO1.js → auth-DifFaOyq.js} +2 -2
- package/dist/{auth-dII2jCO1.js.map → auth-DifFaOyq.js.map} +1 -1
- package/dist/{build-Cza7ZQrp.js → build-CS-Z75eK.js} +10 -10
- package/dist/build-CS-Z75eK.js.map +1 -0
- package/dist/{bundle-C6yEtMJ-.js → bundle-C0IBCVpV.js} +124 -22
- package/dist/bundle-C0IBCVpV.js.map +1 -0
- package/dist/bundle.d.ts +25 -11
- package/dist/{cloud-BdnmqQaZ.js → cloud-nwWkzAHu.js} +381 -47
- package/dist/cloud-nwWkzAHu.js.map +1 -0
- package/dist/commands/agent-setup.d.ts +2 -0
- package/dist/commands/cloud/auth.d.ts +13 -0
- package/dist/commands/cloud/bundle-deploy.d.ts +8 -15
- package/dist/commands/cloud/context.d.ts +18 -0
- package/dist/commands/cloud/guests.d.ts +11 -0
- package/dist/commands/cloud/index.d.ts +1 -0
- package/dist/commands/cloud/projects.d.ts +4 -0
- package/dist/commands/cloud/resources.d.ts +22 -0
- package/dist/commands/dev.d.ts +12 -0
- package/dist/commands/doctor.d.ts +10 -0
- package/dist/commands/schema-reconcile.d.ts +9 -0
- package/dist/commands/skills.d.ts +3 -0
- package/dist/{context-GUxkZm-S.js → context-DvIUbE-b.js} +39 -5
- package/dist/context-DvIUbE-b.js.map +1 -0
- package/dist/{dev-DTqVMgB3.js → dev-CzOazEHW.js} +17 -3
- package/dist/dev-CzOazEHW.js.map +1 -0
- package/dist/{doctor-BRWOlqeG.js → doctor-BuqSHNrd.js} +45 -26
- package/dist/doctor-BuqSHNrd.js.map +1 -0
- package/dist/doctor-environment.d.ts +7 -19
- package/dist/{fold-static-BnAK-anQ.js → fold-static-BMO8LC01.js} +3 -3
- package/dist/fold-static-BMO8LC01.js.map +1 -0
- package/dist/{generate_sdk-BvcWvoUh.js → generate_sdk-_SQuSbJW.js} +2 -2
- package/dist/{generate_sdk-BvcWvoUh.js.map → generate_sdk-_SQuSbJW.js.map} +1 -1
- package/dist/index.es.js +24 -24
- package/dist/index.es.js.map +1 -1
- package/dist/{init-CaU6GhwI.js → init-CHtpYLlh.js} +5 -4
- package/dist/init-CHtpYLlh.js.map +1 -0
- package/dist/{normalize-imports-D0zXlM6g.js → normalize-imports-BN0fzZS8.js} +2 -2
- package/dist/{normalize-imports-D0zXlM6g.js.map → normalize-imports-BN0fzZS8.js.map} +1 -1
- package/dist/schema-2A0dd-Bv.js +321 -0
- package/dist/schema-2A0dd-Bv.js.map +1 -0
- package/dist/schema-reconcile-C3ToVnHr.js +2 -0
- package/dist/{skills-BU2flMOy.js → skills-CbwV6vw_.js} +170 -5
- package/dist/skills-CbwV6vw_.js.map +1 -0
- package/dist/{start-mVb6upwY.js → start-21GRsZKc.js} +2 -2
- package/dist/{start-mVb6upwY.js.map → start-21GRsZKc.js.map} +1 -1
- package/dist/{storage-DtOXGflp.js → storage-CO9ouK76.js} +2 -2
- package/dist/{storage-DtOXGflp.js.map → storage-CO9ouK76.js.map} +1 -1
- package/dist/utils/bundle-lock.d.ts +9 -0
- package/dist/utils/libpq-url.d.ts +8 -0
- package/dist/utils/root-pointer.d.ts +43 -0
- package/package.json +8 -8
- package/templates/overlays/baas/README.md +2 -2
- package/templates/overlays/baas/ai-instructions.md +3 -2
- package/templates/overlays/baas/package.json +1 -0
- package/templates/overlays/baas/pnpm-workspace.yaml +4 -0
- package/templates/template/.cursorrules +10 -0
- package/templates/template/.env.example +1 -1
- package/templates/template/.github/copilot-instructions.md +10 -0
- package/templates/template/.windsurfrules +10 -0
- package/templates/template/AGENTS.md +10 -0
- package/templates/template/CLAUDE.md +10 -0
- package/templates/template/ai-instructions.md +5 -4
- package/templates/template/pnpm-workspace.yaml +4 -1
- package/dist/build-Cza7ZQrp.js.map +0 -1
- package/dist/bundle-C6yEtMJ-.js.map +0 -1
- package/dist/cloud-BdnmqQaZ.js.map +0 -1
- package/dist/context-GUxkZm-S.js.map +0 -1
- package/dist/dev-DTqVMgB3.js.map +0 -1
- package/dist/doctor-BRWOlqeG.js.map +0 -1
- package/dist/fold-static-BnAK-anQ.js.map +0 -1
- package/dist/init-CaU6GhwI.js.map +0 -1
- package/dist/schema-BSXwZSiI.js +0 -152
- package/dist/schema-BSXwZSiI.js.map +0 -1
- package/dist/skills-BU2flMOy.js.map +0 -1
|
@@ -2,11 +2,11 @@ import { i as recordEvent, l as durationBucket } from "./telemetry-CgwJPVMO.js";
|
|
|
2
2
|
import { C as switchOn, D as unknownCommandMessage, c as findProjectRoot, p as requireProjectRoot } from "./project-CasK56vN.js";
|
|
3
3
|
import { t as cliUserAgent } from "./version-Buyyo1ut.js";
|
|
4
4
|
import { _ as selectDeployApp, d as findBackendApp, f as formatAppAddress, l as cmsMountOf, p as loadManifest } from "./manifest-BtzDy7KQ.js";
|
|
5
|
-
import {
|
|
6
|
-
import { $ as resolveCloudUrl, A as lookupProjectId, B as projectLinkPath, C as grantForLink, D as isKnownControlPlane, E as isJsonMode, F as printGroupHelp, G as requireClient, H as refuseDirectLink, I as printJson, J as requireKnownAction, K as requireCloudRow, L as probeToken, M as noteBlank, N as openUrl, O as keyValues, P as parseCloudArgs, Q as resolveCloudTarget, R as projectDotenvSetsAppKey, S as getContextOrg, T as initOutputMode, U as removeLink, V as readLink, W as reportError, X as requireProjectRef, Y as requireProject, Z as requireSessionClient, _ as fail, _t as orgCapabilitiesInScopes, a as billingAccountIdOf, at as storedGrantForLink, b as forgetEphemeralGrant, bt as wantsRawError, c as colorStatus, ct as writeLink, d as displayProjectRef, dt as ORG_CAPABILITY_NAMES, et as resolveProjectRef, f as dotenvSets, ft as TOKEN_CAPABILITIES, g as ephemeralGrantFor, gt as isTokenCapability, h as envToken, ht as isOrgCapability, i as appKeyExpiryNote, it as setCurrentContext, j as note, k as linkedEphemeralGrant, l as confirmDestructive, lt as ALWAYS_SCOPES, m as emitHelp, mt as capabilitiesInScopes, n as GLOBAL_HELP_FLAGS, nt as saveEphemeralGrant, o as cloudRow, ot as success, p as emit, pt as TOKEN_CAPABILITY_NAMES, q as requireInteractive, r as TOKEN_ENV, rt as setContextOrg, s as cloudRows, st as warn, t as GLOBAL_CLOUD_FLAGS, tt as resolveTimeoutMs, u as createCloudClient, ut as ORG_CAPABILITIES, v as fetchDeployTargets, vt as scopesForCapabilities, w as grantProjectOf, x as freshAccessToken, y as fetchTenantBaseDomain, yt as scopesForOrgCapabilities, z as projectHost } from "./context-
|
|
7
|
-
import { n as foldFrontendIntoBundle, r as foldableApps } from "./fold-static-
|
|
5
|
+
import { C as toolStdio, n as UNVENDORED_COST, s as buildBundle, x as unvendoredReason } from "./bundle-C0IBCVpV.js";
|
|
6
|
+
import { $ as resolveCloudUrl, A as lookupProjectId, B as projectLinkPath, C as grantForLink, D as isKnownControlPlane, E as isJsonMode, F as printGroupHelp, G as requireClient, H as refuseDirectLink, I as printJson, J as requireKnownAction, K as requireCloudRow, L as probeToken, M as noteBlank, N as openUrl, O as keyValues, P as parseCloudArgs, Q as resolveCloudTarget, R as projectDotenvSetsAppKey, S as getContextOrg, T as initOutputMode, U as removeLink, V as readLink, W as reportError, X as requireProjectRef, Y as requireProject, Z as requireSessionClient, _ as fail, _t as orgCapabilitiesInScopes, a as billingAccountIdOf, at as storedGrantForLink, b as forgetEphemeralGrant, bt as wantsRawError, c as colorStatus, ct as writeLink, d as displayProjectRef, dt as ORG_CAPABILITY_NAMES, et as resolveProjectRef, f as dotenvSets, ft as TOKEN_CAPABILITIES, g as ephemeralGrantFor, gt as isTokenCapability, h as envToken, ht as isOrgCapability, i as appKeyExpiryNote, it as setCurrentContext, j as note, k as linkedEphemeralGrant, l as confirmDestructive, lt as ALWAYS_SCOPES, m as emitHelp, mt as capabilitiesInScopes, n as GLOBAL_HELP_FLAGS, nt as saveEphemeralGrant, o as cloudRow, ot as success, p as emit, pt as TOKEN_CAPABILITY_NAMES, q as requireInteractive, r as TOKEN_ENV, rt as setContextOrg, s as cloudRows, st as warn, t as GLOBAL_CLOUD_FLAGS, tt as resolveTimeoutMs, u as createCloudClient, ut as ORG_CAPABILITIES, v as fetchDeployTargets, vt as scopesForCapabilities, w as grantProjectOf, x as freshAccessToken, y as fetchTenantBaseDomain, yt as scopesForOrgCapabilities, z as projectHost } from "./context-DvIUbE-b.js";
|
|
7
|
+
import { n as foldFrontendIntoBundle, r as foldableApps } from "./fold-static-BMO8LC01.js";
|
|
8
8
|
import { n as deriveOptionsFor, r as deriveResourceGraph } from "./derive-ae9UOoOB.js";
|
|
9
|
-
import { t as buildAssetApp } from "./build-
|
|
9
|
+
import { t as buildAssetApp } from "./build-CS-Z75eK.js";
|
|
10
10
|
import chalk from "chalk";
|
|
11
11
|
import arg from "arg";
|
|
12
12
|
import fs from "fs";
|
|
@@ -16,6 +16,7 @@ import { execFileSync, spawn } from "child_process";
|
|
|
16
16
|
import dotenv from "dotenv";
|
|
17
17
|
import { DEFAULT_STORAGE_SOURCE_KEY } from "@rebasepro/types";
|
|
18
18
|
import inquirer from "inquirer";
|
|
19
|
+
import { RebaseApiError, createRebaseClient } from "@rebasepro/client";
|
|
19
20
|
import net from "node:net";
|
|
20
21
|
import { parse } from "acorn";
|
|
21
22
|
/**
|
|
@@ -731,6 +732,41 @@ async function whoamiToken(client, url) {
|
|
|
731
732
|
} : null
|
|
732
733
|
});
|
|
733
734
|
}
|
|
735
|
+
/**
|
|
736
|
+
* `rebase cloud access-token` — the bearer this CLI would send right now.
|
|
737
|
+
*
|
|
738
|
+
* For tools that reach the control plane on a person's behalf without a second
|
|
739
|
+
* login: the MCP server reads a project's data through the console's Studio
|
|
740
|
+
* proxy with it, so whoever is signed in to Rebase Cloud reaches every project
|
|
741
|
+
* their organizations hold, and no service key leaves the control plane. It is
|
|
742
|
+
* the same credential `requireClient` resolves — `REBASE_TOKEN`, the token
|
|
743
|
+
* `init --claim` stored for a linked project, or the login, refreshed first when
|
|
744
|
+
* it is close to expiry — so the control plane checks it exactly as it checks
|
|
745
|
+
* this CLI. The token is printed bare, so `$(rebase cloud access-token)` works.
|
|
746
|
+
*/
|
|
747
|
+
async function accessTokenCommand(rawArgs) {
|
|
748
|
+
parseCloudArgs({
|
|
749
|
+
spec: {},
|
|
750
|
+
rawArgs,
|
|
751
|
+
commandWords: 2,
|
|
752
|
+
command: "cloud access-token",
|
|
753
|
+
maxPositionals: 0
|
|
754
|
+
});
|
|
755
|
+
const { client, url } = await requireClient(rawArgs);
|
|
756
|
+
let token;
|
|
757
|
+
try {
|
|
758
|
+
token = await freshAccessToken(client);
|
|
759
|
+
} catch {
|
|
760
|
+
fail("The session could not be refreshed.", "Run `rebase cloud login` again.", "session_invalid");
|
|
761
|
+
}
|
|
762
|
+
const session = client.auth.getSession();
|
|
763
|
+
const expiresAt = session?.accessToken === token ? session.expiresAt : null;
|
|
764
|
+
emit(() => console.log(token), {
|
|
765
|
+
host: url,
|
|
766
|
+
accessToken: token,
|
|
767
|
+
expiresAt: expiresAt ? new Date(expiresAt).toISOString() : null
|
|
768
|
+
});
|
|
769
|
+
}
|
|
734
770
|
//#endregion
|
|
735
771
|
//#region src/commands/cloud/link.ts
|
|
736
772
|
/**
|
|
@@ -1260,6 +1296,27 @@ async function statusCommand(rawArgs) {
|
|
|
1260
1296
|
}
|
|
1261
1297
|
}
|
|
1262
1298
|
/**
|
|
1299
|
+
* One row per instance, under a header, for `cloud metrics`.
|
|
1300
|
+
*
|
|
1301
|
+
* Per instance because that is the question: where the sockets landed. A group
|
|
1302
|
+
* that stays on one instance shows as `skipped` climbing while `to bus` stays
|
|
1303
|
+
* flat, and both count from when that instance started.
|
|
1304
|
+
*/
|
|
1305
|
+
function realtimeTable(instances) {
|
|
1306
|
+
const row = (name, cells) => `${name.padEnd(34)} ${cells.map((cell, i) => String(cell ?? "—").padStart(i < 2 ? 8 : 9)).join(" ")}`;
|
|
1307
|
+
return [row("", [
|
|
1308
|
+
"sockets",
|
|
1309
|
+
"channels",
|
|
1310
|
+
"to bus",
|
|
1311
|
+
"skipped"
|
|
1312
|
+
]), ...instances.map(({ name, realtime: r }) => row(name ?? "?", [
|
|
1313
|
+
r?.sockets,
|
|
1314
|
+
r?.channels,
|
|
1315
|
+
r?.busFramesPublished,
|
|
1316
|
+
r?.busFramesSkipped
|
|
1317
|
+
]))];
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1263
1320
|
* CPU with the ceiling it is a percentage of.
|
|
1264
1321
|
*
|
|
1265
1322
|
* A bare "0.2%" is unreadable without knowing 0.2% of what, and on a burstable
|
|
@@ -1287,10 +1344,13 @@ async function metricsCommand(rawArgs) {
|
|
|
1287
1344
|
const { client } = await requireClient(rawArgs);
|
|
1288
1345
|
const projectId = await requireProject(rawArgs, client);
|
|
1289
1346
|
try {
|
|
1290
|
-
const m = await client.functions.invoke("metrics", void 0, {
|
|
1347
|
+
const [m, realtime] = await Promise.all([client.functions.invoke("metrics", void 0, {
|
|
1291
1348
|
method: "GET",
|
|
1292
1349
|
path: projectId
|
|
1293
|
-
})
|
|
1350
|
+
}), client.functions.invoke("metrics", void 0, {
|
|
1351
|
+
method: "GET",
|
|
1352
|
+
path: `${projectId}/realtime`
|
|
1353
|
+
}).catch(() => null)]);
|
|
1294
1354
|
const of = m.subject?.workload ? `${m.subject.workload}${m.subject.kind === "deployment" ? " (backend only — not the database)" : ""}` : void 0;
|
|
1295
1355
|
const sampled = m.subject?.sampledInstances;
|
|
1296
1356
|
const coverage = sampled === void 0 ? void 0 : sampled === 0 ? chalk.yellow("no instances reported yet") : `${sampled} instance${sampled === 1 ? "" : "s"}`;
|
|
@@ -1324,6 +1384,11 @@ async function metricsCommand(rawArgs) {
|
|
|
1324
1384
|
if (i.waitingReason) note(chalk.gray(` waiting: ${i.waitingReason}`));
|
|
1325
1385
|
}
|
|
1326
1386
|
}
|
|
1387
|
+
if (realtime?.instances?.length) {
|
|
1388
|
+
console.log("");
|
|
1389
|
+
note(" Realtime, since each instance started");
|
|
1390
|
+
for (const line of realtimeTable(realtime.instances)) note(` ${line}`);
|
|
1391
|
+
}
|
|
1327
1392
|
console.log("");
|
|
1328
1393
|
}, {
|
|
1329
1394
|
projectId,
|
|
@@ -1335,7 +1400,8 @@ async function metricsCommand(rawArgs) {
|
|
|
1335
1400
|
subject: m.subject ?? null,
|
|
1336
1401
|
allocation: m.allocation ?? null,
|
|
1337
1402
|
instances: m.instances ?? null,
|
|
1338
|
-
condition: m.condition ?? null
|
|
1403
|
+
condition: m.condition ?? null,
|
|
1404
|
+
realtime: realtime?.instances ?? null
|
|
1339
1405
|
});
|
|
1340
1406
|
} catch (e) {
|
|
1341
1407
|
reportError(e, "Failed to fetch metrics");
|
|
@@ -1470,21 +1536,23 @@ async function storageCreateCommand(rawArgs) {
|
|
|
1470
1536
|
const projectId = await requireProject(rawArgs, client);
|
|
1471
1537
|
try {
|
|
1472
1538
|
noteBlank();
|
|
1473
|
-
note(chalk.gray("Provisioning managed storage — this creates a bucket and
|
|
1539
|
+
note(chalk.gray("Provisioning managed storage — this creates a bucket and grants your project access to it..."));
|
|
1474
1540
|
const info = (await client.functions.invoke("storage-provision", void 0, {
|
|
1475
1541
|
method: "POST",
|
|
1476
1542
|
path: projectId
|
|
1477
1543
|
})).data;
|
|
1544
|
+
const access = info.access ?? (info.accessKeyId ? "s3-key" : "workload-identity");
|
|
1478
1545
|
success(`Managed storage provisioned for ${displayProjectRef(rawArgs)}.`);
|
|
1479
1546
|
emit(() => {
|
|
1480
1547
|
keyValues([
|
|
1481
1548
|
["Bucket", info.bucketName],
|
|
1482
1549
|
["Region", info.region],
|
|
1483
1550
|
["Endpoint", info.endpoint],
|
|
1484
|
-
["Access key", info.accessKeyId]
|
|
1551
|
+
["Access key", info.accessKeyId],
|
|
1552
|
+
["Access", access === "workload-identity" ? "workload identity (no key)" : void 0]
|
|
1485
1553
|
]);
|
|
1486
1554
|
noteBlank();
|
|
1487
|
-
note(chalk.gray("The secret key is stored encrypted and injected at deploy time; it is not displayed."));
|
|
1555
|
+
note(chalk.gray(access === "workload-identity" ? "The bucket is granted to your project's workload identity; there is no key to store or rotate." : "The secret key is stored encrypted and injected at deploy time; it is not displayed."));
|
|
1488
1556
|
note(chalk.gray("Redeploy for the tenant to pick it up: ") + chalk.bold("rebase cloud deploy"));
|
|
1489
1557
|
noteBlank();
|
|
1490
1558
|
}, {
|
|
@@ -1492,6 +1560,7 @@ async function storageCreateCommand(rawArgs) {
|
|
|
1492
1560
|
projectId,
|
|
1493
1561
|
bucketName: info.bucketName,
|
|
1494
1562
|
region: info.region,
|
|
1563
|
+
access,
|
|
1495
1564
|
endpoint: info.endpoint,
|
|
1496
1565
|
accessKeyId: info.accessKeyId,
|
|
1497
1566
|
secretAccessKey: null,
|
|
@@ -2199,6 +2268,8 @@ async function computeCommand(action, rawArgs) {
|
|
|
2199
2268
|
["App CPU", dialLine(project.cpu)],
|
|
2200
2269
|
["App memory", dialLine(project.memory)],
|
|
2201
2270
|
["App replicas", dialLine(project.replicaCount)],
|
|
2271
|
+
["Autoscale ceiling", project.autoscaleMaxReplicas === null || project.autoscaleMaxReplicas === void 0 ? chalk.gray("off") : dialLine(project.autoscaleMaxReplicas)],
|
|
2272
|
+
["Autoscale CPU target", project.autoscaleTargetCpuPercent === null || project.autoscaleTargetCpuPercent === void 0 ? dialLine(void 0) : `${dialLine(project.autoscaleTargetCpuPercent)}%`],
|
|
2202
2273
|
["Capacity", dialLine(project.preemptible, {
|
|
2203
2274
|
true: "spot",
|
|
2204
2275
|
false: "on demand"
|
|
@@ -2227,6 +2298,8 @@ async function computeCommand(action, rawArgs) {
|
|
|
2227
2298
|
cpu: project.cpu ?? null,
|
|
2228
2299
|
memory: project.memory ?? null,
|
|
2229
2300
|
replicaCount: project.replicaCount ?? null,
|
|
2301
|
+
autoscaleMaxReplicas: project.autoscaleMaxReplicas ?? null,
|
|
2302
|
+
autoscaleTargetCpuPercent: project.autoscaleTargetCpuPercent ?? null,
|
|
2230
2303
|
preemptible: project.preemptible ?? null,
|
|
2231
2304
|
scaleToZero: project.scaleToZero ?? null,
|
|
2232
2305
|
databaseInstances: project.databaseInstances ?? null,
|
|
@@ -3040,7 +3113,9 @@ async function backupCommand(rawArgs) {
|
|
|
3040
3113
|
console.log(chalk.bold(` 💾 Backups — project ${projectRef}`));
|
|
3041
3114
|
console.log("");
|
|
3042
3115
|
if (!res.backups?.length) {
|
|
3043
|
-
console.log(chalk.gray(" No backups
|
|
3116
|
+
console.log(chalk.gray(" No manual backups. Create one with `rebase cloud db backup create`."));
|
|
3117
|
+
console.log(chalk.gray(" Automated daily backups and point-in-time recovery are listed separately:"));
|
|
3118
|
+
console.log(chalk.gray(" `rebase cloud db backup status` and `rebase cloud db pitr status`."));
|
|
3044
3119
|
console.log("");
|
|
3045
3120
|
return;
|
|
3046
3121
|
}
|
|
@@ -3192,7 +3267,7 @@ function printDbHelp() {
|
|
|
3192
3267
|
{
|
|
3193
3268
|
action: "backup list",
|
|
3194
3269
|
section: "Backups",
|
|
3195
|
-
description: "List backups"
|
|
3270
|
+
description: "List manual backups"
|
|
3196
3271
|
},
|
|
3197
3272
|
{
|
|
3198
3273
|
action: "backup create",
|
|
@@ -3253,16 +3328,18 @@ function printDbHelp() {
|
|
|
3253
3328
|
/**
|
|
3254
3329
|
* `rebase cloud projects` — list / create / info / delete.
|
|
3255
3330
|
*/
|
|
3331
|
+
/** Documented in `action-help.ts`, and paired with it by `action-help.test.ts`. */
|
|
3332
|
+
var LIST_PROJECTS_FLAGS = { "--all-orgs": Boolean };
|
|
3256
3333
|
async function listProjects(rawArgs) {
|
|
3257
|
-
parseCloudArgs({
|
|
3258
|
-
spec:
|
|
3334
|
+
const { flags: args } = parseCloudArgs({
|
|
3335
|
+
spec: LIST_PROJECTS_FLAGS,
|
|
3259
3336
|
rawArgs,
|
|
3260
3337
|
commandWords: 3,
|
|
3261
3338
|
command: "cloud projects",
|
|
3262
3339
|
maxPositionals: 0
|
|
3263
3340
|
});
|
|
3264
3341
|
const { client, url } = await requireClient(rawArgs);
|
|
3265
|
-
const org = getContextOrg(url);
|
|
3342
|
+
const org = args["--all-orgs"] ? void 0 : getContextOrg(url);
|
|
3266
3343
|
try {
|
|
3267
3344
|
const [projects, baseDomain] = await Promise.all([client.data.collection("projects").find({
|
|
3268
3345
|
where: org ? { organization: ["==", org] } : void 0,
|
|
@@ -5557,6 +5634,7 @@ async function pullEnv(rawArgs) {
|
|
|
5557
5634
|
written.push(v.key);
|
|
5558
5635
|
}
|
|
5559
5636
|
fs.writeFileSync(outPath, lines.length ? lines.join("\n") + "\n" : "", { mode: 384 });
|
|
5637
|
+
fs.chmodSync(outPath, 384);
|
|
5560
5638
|
emit(() => {
|
|
5561
5639
|
success(`Wrote ${written.length} variable${written.length === 1 ? "" : "s"} to ${outPath}`);
|
|
5562
5640
|
if (skipped.length) {
|
|
@@ -6154,7 +6232,7 @@ function readBundleManifest(bundleDir) {
|
|
|
6154
6232
|
* The control plane's cap on an uploaded bundle: its `MAX_BUNDLE_BYTES`, which
|
|
6155
6233
|
* it checks before reading the body.
|
|
6156
6234
|
*/
|
|
6157
|
-
var MAX_BUNDLE_UPLOAD_BYTES =
|
|
6235
|
+
var MAX_BUNDLE_UPLOAD_BYTES = 1024 * 1024 * 1024;
|
|
6158
6236
|
/**
|
|
6159
6237
|
* Tar a built bundle into a gzipped archive.
|
|
6160
6238
|
*
|
|
@@ -6184,34 +6262,44 @@ function packBundle(bundleDir, outPath, options = {}) {
|
|
|
6184
6262
|
});
|
|
6185
6263
|
}
|
|
6186
6264
|
/**
|
|
6187
|
-
* Pack a bundle for upload
|
|
6265
|
+
* Pack a bundle for upload, with the dependency tree the build vendored for it.
|
|
6188
6266
|
*
|
|
6189
|
-
* Vendoring
|
|
6190
|
-
* every start in `npm install`,
|
|
6191
|
-
*
|
|
6192
|
-
*
|
|
6193
|
-
* into memory on every pod start, and a runtime rollout restarts every tenant's
|
|
6194
|
-
* pods at once. Bundles it was sized against are a few hundred kB; a vendored
|
|
6195
|
-
* one is tens of MB, up to the 100 MB cap — N pods starting together would hold
|
|
6196
|
-
* N of them. A slower cold start per pod is the status quo every deploy has
|
|
6197
|
-
* shipped with; a control plane out of memory is every tenant's outage. The
|
|
6198
|
-
* platform's own rebuilds build with `--no-vendor` for the same shape of
|
|
6199
|
-
* reason. When the control plane streams bundles, this is the one switch to
|
|
6200
|
-
* flip, and `rebase cloud deploy` builds with `vendor: false` until then.
|
|
6267
|
+
* Vendoring is what lets a pod untar and boot rather than spending 35-55s of
|
|
6268
|
+
* every start in `npm install`, which is the bulk of a new instance's time to
|
|
6269
|
+
* ready. The control plane streams an archive in both directions, so its size
|
|
6270
|
+
* costs that process nothing.
|
|
6201
6271
|
*
|
|
6202
|
-
*
|
|
6203
|
-
*
|
|
6272
|
+
* A vendored tree that takes the archive over the cap is left out rather than
|
|
6273
|
+
* failing the deploy: a bundle without its dependencies still boots, only more
|
|
6274
|
+
* slowly. `modulesLeftOut` says that happened.
|
|
6204
6275
|
*/
|
|
6205
6276
|
async function packBundleForUpload(bundleDir, outPath, manifest, maxBytes = MAX_BUNDLE_UPLOAD_BYTES) {
|
|
6206
|
-
|
|
6277
|
+
if (manifest.deps?.vendored === true) {
|
|
6278
|
+
await packBundle(bundleDir, outPath, { withModules: true });
|
|
6279
|
+
const bytes = fs.statSync(outPath).size;
|
|
6280
|
+
if (bytes <= maxBytes) return {
|
|
6281
|
+
bytes,
|
|
6282
|
+
modulesLeftOut: false
|
|
6283
|
+
};
|
|
6284
|
+
fs.rmSync(outPath, { force: true });
|
|
6285
|
+
await packBundle(bundleDir, outPath, { withModules: false });
|
|
6286
|
+
return {
|
|
6287
|
+
bytes: refuseOverCap(outPath, maxBytes),
|
|
6288
|
+
modulesLeftOut: true
|
|
6289
|
+
};
|
|
6290
|
+
}
|
|
6207
6291
|
await packBundle(bundleDir, outPath, { withModules: false });
|
|
6208
|
-
const bytes = fs.statSync(outPath).size;
|
|
6209
|
-
if (bytes > maxBytes) throw new Error(`The bundle is ${(bytes / 1024 / 1024).toFixed(1)} MB without its dependencies, over the ${Math.round(maxBytes / 1024 / 1024)} MB upload limit.`);
|
|
6210
6292
|
return {
|
|
6211
|
-
bytes,
|
|
6212
|
-
modulesLeftOut:
|
|
6293
|
+
bytes: refuseOverCap(outPath, maxBytes),
|
|
6294
|
+
modulesLeftOut: false
|
|
6213
6295
|
};
|
|
6214
6296
|
}
|
|
6297
|
+
/** The archive's size, or a refusal naming the limit: nothing can be left out of it now. */
|
|
6298
|
+
function refuseOverCap(archive, maxBytes) {
|
|
6299
|
+
const bytes = fs.statSync(archive).size;
|
|
6300
|
+
if (bytes > maxBytes) throw new Error(`The bundle is ${(bytes / 1024 / 1024).toFixed(1)} MB without its dependencies, over the ${Math.round(maxBytes / 1024 / 1024)} MB upload limit.`);
|
|
6301
|
+
return bytes;
|
|
6302
|
+
}
|
|
6215
6303
|
/**
|
|
6216
6304
|
* The commit HEAD is on, read here because here is the only place it exists.
|
|
6217
6305
|
*
|
|
@@ -6312,14 +6400,13 @@ function declaredAppsFrom(manifest) {
|
|
|
6312
6400
|
}
|
|
6313
6401
|
/** Upload a bundle archive; returns the control-plane bundle id. */
|
|
6314
6402
|
async function uploadBundle(url, token, projectId, tarPath) {
|
|
6315
|
-
const bytes = fs.readFileSync(tarPath);
|
|
6316
6403
|
const res = await fetch(`${url}/api/functions/deploy/bundle/upload?projectId=${encodeURIComponent(projectId)}`, {
|
|
6317
6404
|
method: "POST",
|
|
6318
6405
|
headers: {
|
|
6319
6406
|
Authorization: `Bearer ${token}`,
|
|
6320
6407
|
"Content-Type": "application/gzip"
|
|
6321
6408
|
},
|
|
6322
|
-
body:
|
|
6409
|
+
body: await fs.openAsBlob(tarPath)
|
|
6323
6410
|
});
|
|
6324
6411
|
if (!res.ok) {
|
|
6325
6412
|
const body = await res.text().catch(() => "");
|
|
@@ -8374,6 +8461,7 @@ async function uploadSource(url, token, projectId, tarPath) {
|
|
|
8374
8461
|
async function deployBundle(opts) {
|
|
8375
8462
|
const projectRoot = requireProjectRoot();
|
|
8376
8463
|
let bundleDir = opts.bundleDir ? path.resolve(process.cwd(), opts.bundleDir) : path.join(projectRoot, "dist-bundle");
|
|
8464
|
+
let releaseBuild;
|
|
8377
8465
|
if (!opts.bundleDir) {
|
|
8378
8466
|
let loaded;
|
|
8379
8467
|
try {
|
|
@@ -8431,7 +8519,6 @@ async function deployBundle(opts) {
|
|
|
8431
8519
|
resources: resourceGraph,
|
|
8432
8520
|
skipTypeCheck: opts.skipTypeCheck,
|
|
8433
8521
|
skipSchema: opts.skipSchema,
|
|
8434
|
-
vendor: false,
|
|
8435
8522
|
log: (m) => progress(chalk.gray(m)),
|
|
8436
8523
|
quietStdout: isJsonMode()
|
|
8437
8524
|
});
|
|
@@ -8439,6 +8526,7 @@ async function deployBundle(opts) {
|
|
|
8439
8526
|
fail(err instanceof Error ? err.message : String(err), void 0, "build_failed");
|
|
8440
8527
|
}
|
|
8441
8528
|
bundleDir = result.outDir;
|
|
8529
|
+
releaseBuild = result.release;
|
|
8442
8530
|
if (!opts.noStatic) {
|
|
8443
8531
|
try {
|
|
8444
8532
|
const folded = await foldFrontendIntoBundle({
|
|
@@ -8454,11 +8542,14 @@ async function deployBundle(opts) {
|
|
|
8454
8542
|
}
|
|
8455
8543
|
if (opts.verify) verifyStaticOutput(projectRoot, foldableApps(loaded.manifest).apps);
|
|
8456
8544
|
}
|
|
8545
|
+
const unvendored = unvendoredReason(result);
|
|
8546
|
+
if (unvendored) warn(`Dependencies not bundled: ${unvendored}`, UNVENDORED_COST);
|
|
8457
8547
|
}
|
|
8458
8548
|
await uploadAndTrigger({
|
|
8459
8549
|
...opts,
|
|
8460
8550
|
projectRoot,
|
|
8461
|
-
bundleDir
|
|
8551
|
+
bundleDir,
|
|
8552
|
+
onPacked: releaseBuild
|
|
8462
8553
|
});
|
|
8463
8554
|
}
|
|
8464
8555
|
/** Printed under a successful deploy: the way back, where it is needed. */
|
|
@@ -8529,7 +8620,8 @@ async function uploadAndTrigger(opts) {
|
|
|
8529
8620
|
try {
|
|
8530
8621
|
bundleId = await withTempArchive("rebase-bundle", async (tarPath) => {
|
|
8531
8622
|
const packed = await packBundleForUpload(bundleDir, tarPath, manifest);
|
|
8532
|
-
|
|
8623
|
+
opts.onPacked?.();
|
|
8624
|
+
if (packed.modulesLeftOut) warn("This bundle's dependencies would take it past the upload limit, so they were left out: each new instance installs them when it starts, which adds about a minute.", "Shrink the declared dependencies to get that minute back.");
|
|
8533
8625
|
const sizeMb = (packed.bytes / 1024 / 1024).toFixed(1);
|
|
8534
8626
|
progress(chalk.gray(` Uploading bundle (${sizeMb} MB)...`));
|
|
8535
8627
|
return uploadBundle(url, await uploadToken(client, url), projectId, tarPath);
|
|
@@ -9237,9 +9329,10 @@ async function deployCommand(rawArgs, projectRef) {
|
|
|
9237
9329
|
const { client, url } = await requireClient(rawArgs);
|
|
9238
9330
|
const projectId = await resolveProjectRef(projectRef, client);
|
|
9239
9331
|
await requirePaymentMethod(client, projectId);
|
|
9240
|
-
const
|
|
9241
|
-
|
|
9242
|
-
|
|
9332
|
+
const bundleFlag = args["--bundle"] ? "--bundle" : args["--bundle-dir"] ? "--bundle-dir" : void 0;
|
|
9333
|
+
const declaredManaged = !args["--source"] && !bundleFlag && declaresManagedRuntime(appName);
|
|
9334
|
+
if (bundleFlag || declaredManaged) {
|
|
9335
|
+
if (bundleFlag && args["--source"]) fail(`${bundleFlag} and --source cannot be combined: one is a managed bundle, the other a source build.`);
|
|
9243
9336
|
if (declaredManaged && !isJsonMode()) console.log(chalk.gray(" rebase.json declares runtime: managed — deploying a bundle."));
|
|
9244
9337
|
await deployBundle({
|
|
9245
9338
|
client,
|
|
@@ -11963,6 +12056,202 @@ async function serviceKeyCommand(rawArgs) {
|
|
|
11963
12056
|
}, rotation);
|
|
11964
12057
|
}
|
|
11965
12058
|
//#endregion
|
|
12059
|
+
//#region src/commands/cloud/guests.ts
|
|
12060
|
+
/**
|
|
12061
|
+
* `rebase cloud guests [delete <id> | prune --older-than <age>]`: the guest
|
|
12062
|
+
* users anonymous sign-in left behind on a project.
|
|
12063
|
+
*
|
|
12064
|
+
* Without an action, counts them and lists the ones last seen longest ago.
|
|
12065
|
+
* `delete` removes one. `prune` removes the ones not seen for an age: a dry run
|
|
12066
|
+
* that prints how many would go, deleting only with `--yes`.
|
|
12067
|
+
*
|
|
12068
|
+
* ## Which rows can go
|
|
12069
|
+
*
|
|
12070
|
+
* The app decides, not this command: `/api/admin/guests` only ever lists and
|
|
12071
|
+
* deletes a row that is anonymous with no password and no linked identity, in
|
|
12072
|
+
* the statement that deletes it. So nothing here can reach an account, even
|
|
12073
|
+
* with a stale list.
|
|
12074
|
+
*
|
|
12075
|
+
* ## How it reaches the app
|
|
12076
|
+
*
|
|
12077
|
+
* Two legs, like `rebase cloud cron`, with the service key where that has a
|
|
12078
|
+
* read-only platform token: deleting users is an administrator's act on the
|
|
12079
|
+
* app's own API. `POST env-vars/reveal` answers the key to an owner or admin of
|
|
12080
|
+
* the project, the same gate as `rebase cloud env reveal REBASE_SERVICE_KEY`;
|
|
12081
|
+
* it stays in memory for this command and goes only to the project's own public
|
|
12082
|
+
* address, which is why there is no `--host`.
|
|
12083
|
+
*
|
|
12084
|
+
* @module
|
|
12085
|
+
*/
|
|
12086
|
+
var GUESTS_FLAGS = {
|
|
12087
|
+
"--limit": String,
|
|
12088
|
+
"--older-than": String
|
|
12089
|
+
};
|
|
12090
|
+
var GUESTS_ACTIONS = ["delete", "prune"];
|
|
12091
|
+
var AGE_UNITS_MS = {
|
|
12092
|
+
m: 6e4,
|
|
12093
|
+
h: 36e5,
|
|
12094
|
+
d: 864e5,
|
|
12095
|
+
w: 6048e5
|
|
12096
|
+
};
|
|
12097
|
+
/**
|
|
12098
|
+
* `30d` as milliseconds, or undefined. A unit is required and the age cannot be
|
|
12099
|
+
* zero: `--older-than 30` is a typo for something, and `0d` would be everyone.
|
|
12100
|
+
*/
|
|
12101
|
+
function parseAge(value) {
|
|
12102
|
+
const match = /^(\d+)([mhdw])$/.exec(value.trim());
|
|
12103
|
+
if (!match) return void 0;
|
|
12104
|
+
const ms = Number(match[1]) * AGE_UNITS_MS[match[2]];
|
|
12105
|
+
return ms > 0 ? ms : void 0;
|
|
12106
|
+
}
|
|
12107
|
+
/** The instant `--older-than` names, or undefined when it was not given. */
|
|
12108
|
+
function lastSeenBeforeOf(value) {
|
|
12109
|
+
if (value === void 0) return void 0;
|
|
12110
|
+
const ms = parseAge(value);
|
|
12111
|
+
if (ms === void 0) fail(`--older-than takes an age with a unit, e.g. 30d, 12h or 2w (got "${value}").`, void 0, "usage");
|
|
12112
|
+
return new Date(Date.now() - ms);
|
|
12113
|
+
}
|
|
12114
|
+
/** The project's own API, holding its service key. */
|
|
12115
|
+
async function connectToApp(client, origin, projectId) {
|
|
12116
|
+
let serviceKey;
|
|
12117
|
+
try {
|
|
12118
|
+
serviceKey = (await client.functions.invoke("env-vars", {
|
|
12119
|
+
projectId,
|
|
12120
|
+
key: "REBASE_SERVICE_KEY"
|
|
12121
|
+
}, { path: "reveal" })).value;
|
|
12122
|
+
} catch (e) {
|
|
12123
|
+
reportError(e, "Failed to read the project's service key");
|
|
12124
|
+
}
|
|
12125
|
+
return createRebaseClient({
|
|
12126
|
+
baseUrl: origin,
|
|
12127
|
+
token: serviceKey,
|
|
12128
|
+
realtime: false,
|
|
12129
|
+
headers: { "User-Agent": cliUserAgent() },
|
|
12130
|
+
auth: {
|
|
12131
|
+
persistSession: false,
|
|
12132
|
+
autoRefresh: false
|
|
12133
|
+
}
|
|
12134
|
+
});
|
|
12135
|
+
}
|
|
12136
|
+
/**
|
|
12137
|
+
* Report a failed call to the app. An older runtime has no guest routes, and
|
|
12138
|
+
* its 404 is about the route, not about a guest; a repository without them (a
|
|
12139
|
+
* self-hosted Mongo backend) answers 501.
|
|
12140
|
+
*/
|
|
12141
|
+
function reportAppError(error, action, origin) {
|
|
12142
|
+
if (error instanceof RebaseApiError) {
|
|
12143
|
+
if (error.status === 404 && isMissingRoute(error.message)) fail(`The app at ${origin} needs a newer runtime: it has no guest routes yet.`, "`rebase cloud status` shows the runtime it is on.", "runtime_too_old");
|
|
12144
|
+
if (error.status === 501) fail(`The app at ${origin} cannot manage guests: ${error.message}`, void 0, "not_supported");
|
|
12145
|
+
if (error.status === 0 || error.code === "NETWORK_ERROR") fail(`Could not reach the app at ${origin}: ${error.message}`, "`rebase cloud debug health` checks whether the deployment is answering at all.", "runtime_unreachable");
|
|
12146
|
+
}
|
|
12147
|
+
reportError(error, action);
|
|
12148
|
+
}
|
|
12149
|
+
function printGuests(guests, total, label) {
|
|
12150
|
+
const count = `${total.toLocaleString()} guest${total === 1 ? "" : "s"}`;
|
|
12151
|
+
console.log("");
|
|
12152
|
+
console.log(chalk.bold(` 👤 ${count} — ${label}`));
|
|
12153
|
+
console.log("");
|
|
12154
|
+
for (const guest of guests) {
|
|
12155
|
+
const created = new Date(guest.createdAt).toLocaleString();
|
|
12156
|
+
const seen = new Date(guest.lastSeenAt).toLocaleString();
|
|
12157
|
+
console.log(` ${guest.uid} ${chalk.gray(`last seen ${seen}, created ${created}`)}`);
|
|
12158
|
+
}
|
|
12159
|
+
if (guests.length < total) console.log(chalk.gray(` … and ${(total - guests.length).toLocaleString()} more, seen more recently.`));
|
|
12160
|
+
if (guests.length > 0) console.log("");
|
|
12161
|
+
}
|
|
12162
|
+
/** Every batch of a prune, until no matching guest is left to try. */
|
|
12163
|
+
async function pruneAll(app, lastSeenBefore) {
|
|
12164
|
+
const pruned = {
|
|
12165
|
+
deleted: 0,
|
|
12166
|
+
skipped: []
|
|
12167
|
+
};
|
|
12168
|
+
let remaining;
|
|
12169
|
+
do {
|
|
12170
|
+
const batch = await app.admin.deleteGuests({
|
|
12171
|
+
lastSeenBefore,
|
|
12172
|
+
offset: pruned.skipped.length
|
|
12173
|
+
});
|
|
12174
|
+
pruned.deleted += batch.deleted;
|
|
12175
|
+
pruned.skipped.push(...batch.skipped);
|
|
12176
|
+
({remaining} = batch);
|
|
12177
|
+
} while (remaining > 0);
|
|
12178
|
+
return pruned;
|
|
12179
|
+
}
|
|
12180
|
+
async function prune(app, age, lastSeenBefore, yes, label) {
|
|
12181
|
+
const window = {
|
|
12182
|
+
olderThan: age,
|
|
12183
|
+
lastSeenBefore: lastSeenBefore.toISOString()
|
|
12184
|
+
};
|
|
12185
|
+
if (!yes) {
|
|
12186
|
+
const { total } = await app.admin.listGuests({
|
|
12187
|
+
lastSeenBefore,
|
|
12188
|
+
limit: 1
|
|
12189
|
+
});
|
|
12190
|
+
emit(() => {
|
|
12191
|
+
console.log("");
|
|
12192
|
+
console.log(` ${chalk.bold(total.toLocaleString())} guest${total === 1 ? "" : "s"} not seen for ${age} would go from ${label}. Nothing was deleted.`);
|
|
12193
|
+
if (total > 0) note(`Delete them with \`rebase cloud guests prune --older-than ${age} --yes\`.`);
|
|
12194
|
+
console.log("");
|
|
12195
|
+
}, {
|
|
12196
|
+
dryRun: true,
|
|
12197
|
+
...window,
|
|
12198
|
+
wouldDelete: total
|
|
12199
|
+
});
|
|
12200
|
+
return;
|
|
12201
|
+
}
|
|
12202
|
+
const pruned = await pruneAll(app, lastSeenBefore);
|
|
12203
|
+
emit(() => {
|
|
12204
|
+
success(`Deleted ${pruned.deleted.toLocaleString()} guest${pruned.deleted === 1 ? "" : "s"} not seen for ${age} from ${label}.`);
|
|
12205
|
+
if (pruned.skipped.length > 0) warn(`${pruned.skipped.length.toLocaleString()} could not go. The first: ${pruned.skipped[0].uid}: ${pruned.skipped[0].message}`);
|
|
12206
|
+
}, {
|
|
12207
|
+
dryRun: false,
|
|
12208
|
+
...window,
|
|
12209
|
+
...pruned
|
|
12210
|
+
});
|
|
12211
|
+
}
|
|
12212
|
+
async function guestsCommand(rawArgs) {
|
|
12213
|
+
const { flags, positionals } = parseCloudArgs({
|
|
12214
|
+
spec: GUESTS_FLAGS,
|
|
12215
|
+
rawArgs,
|
|
12216
|
+
commandWords: 2,
|
|
12217
|
+
command: "cloud guests",
|
|
12218
|
+
maxPositionals: 2
|
|
12219
|
+
});
|
|
12220
|
+
const [action, id] = positionals;
|
|
12221
|
+
requireKnownAction("guests", action, GUESTS_ACTIONS);
|
|
12222
|
+
if (action === "delete" && !id) fail("Name the guest to delete.", "Usage: rebase cloud guests delete <id>. `rebase cloud guests` lists them.", "usage");
|
|
12223
|
+
if (action !== "delete" && id) fail(`Unexpected argument: ${id}`, "Only `rebase cloud guests delete` takes an id.", "usage");
|
|
12224
|
+
if (action === "prune" && !flags["--older-than"]) fail("Say how old a guest has to be.", "Usage: rebase cloud guests prune --older-than 30d [--yes]", "usage");
|
|
12225
|
+
if (action === "delete" && flags["--older-than"]) fail("`rebase cloud guests delete` removes one guest, by id.", "`rebase cloud guests prune --older-than <age>` removes them by age.", "usage");
|
|
12226
|
+
if (action && flags["--limit"]) fail("--limit only applies to the list.", void 0, "usage");
|
|
12227
|
+
const age = flags["--older-than"];
|
|
12228
|
+
const lastSeenBefore = lastSeenBeforeOf(age);
|
|
12229
|
+
const limit = flags["--limit"] === void 0 ? void 0 : Number(flags["--limit"]);
|
|
12230
|
+
if (limit !== void 0 && (!Number.isInteger(limit) || limit < 1)) fail(`--limit takes a whole number above 0 (got "${flags["--limit"]}").`, void 0, "usage");
|
|
12231
|
+
const { client, url } = await requireClient(rawArgs);
|
|
12232
|
+
const projectId = await requireProject(rawArgs, client);
|
|
12233
|
+
const label = `project ${displayProjectRef(rawArgs) || projectId}`;
|
|
12234
|
+
if (action === "delete") await confirmDestructive({
|
|
12235
|
+
yes: Boolean(flags["--yes"]),
|
|
12236
|
+
prompt: `Delete guest ${id} from ${label}? Its sessions end, and whatever the project's own tables cascade from it goes too.`
|
|
12237
|
+
});
|
|
12238
|
+
const origin = await resolveOrigin(rawArgs, client, url, projectId);
|
|
12239
|
+
const app = await connectToApp(client, origin, projectId);
|
|
12240
|
+
try {
|
|
12241
|
+
if (action === "delete") emit(() => success(`Deleted guest ${id} from ${label}.`), await app.admin.deleteGuest(id));
|
|
12242
|
+
else if (action === "prune" && age && lastSeenBefore) await prune(app, age, lastSeenBefore, Boolean(flags["--yes"]), label);
|
|
12243
|
+
else {
|
|
12244
|
+
const listed = await app.admin.listGuests({
|
|
12245
|
+
limit,
|
|
12246
|
+
lastSeenBefore
|
|
12247
|
+
});
|
|
12248
|
+
emit(() => printGuests(listed.guests, listed.total, label), listed);
|
|
12249
|
+
}
|
|
12250
|
+
} catch (e) {
|
|
12251
|
+
reportAppError(e, "Failed to manage the project's guests", origin);
|
|
12252
|
+
}
|
|
12253
|
+
}
|
|
12254
|
+
//#endregion
|
|
11966
12255
|
//#region src/commands/cloud/activity.ts
|
|
11967
12256
|
/**
|
|
11968
12257
|
* `rebase cloud activity`: the selected organization's audit log — who
|
|
@@ -12441,9 +12730,10 @@ var ACTION_HELP = {
|
|
|
12441
12730
|
command: "cloud projects",
|
|
12442
12731
|
usage: "cloud projects <list|create|info|delete> [options]",
|
|
12443
12732
|
summary: "List, create, inspect and delete projects in the selected organization.",
|
|
12444
|
-
flags: [],
|
|
12733
|
+
flags: [["--all-orgs", "list: every organization you belong to, not only the selected one"]],
|
|
12445
12734
|
examples: [
|
|
12446
12735
|
"rebase cloud projects list",
|
|
12736
|
+
"rebase cloud projects list --all-orgs --json",
|
|
12447
12737
|
"rebase cloud projects create --help",
|
|
12448
12738
|
"rebase cloud projects info shop",
|
|
12449
12739
|
"rebase cloud projects delete shop --yes"
|
|
@@ -12914,6 +13204,24 @@ var ACTION_HELP = {
|
|
|
12914
13204
|
"It runs with your login: no access-token capability grants it, so REBASE_TOKEN is refused."
|
|
12915
13205
|
]
|
|
12916
13206
|
},
|
|
13207
|
+
guests: {
|
|
13208
|
+
command: "cloud guests",
|
|
13209
|
+
usage: "cloud guests [delete|prune] [<id>] [--older-than <age>] [--limit <n>]",
|
|
13210
|
+
summary: "The guest users anonymous sign-in left behind on the project. Without an action, counts them and lists the ones last seen longest ago. `delete` removes one. `prune` removes the ones not seen for an age: a dry run that prints how many would go, deleting only with --yes. Only guests can go: an account, or a guest that has become one, is refused by the app itself. Owners and admins.",
|
|
13211
|
+
flags: [["--older-than <age>", "With `prune`, or to count the list: not seen for this long, as 30d, 12h, 2w or 45m"], ["--limit <n>", "How many the list shows. Default: 25"]],
|
|
13212
|
+
examples: [
|
|
13213
|
+
"rebase cloud guests",
|
|
13214
|
+
"rebase cloud guests --older-than 30d --json",
|
|
13215
|
+
"rebase cloud guests delete 3f0c9a7e-1f3b-4c55-9d1e-7a2f4d6b8c10 --yes",
|
|
13216
|
+
"rebase cloud guests prune --older-than 30d",
|
|
13217
|
+
"rebase cloud guests prune --older-than 30d --yes --json"
|
|
13218
|
+
],
|
|
13219
|
+
notes: [
|
|
13220
|
+
"Last seen is when the guest's session was last issued or refreshed, so a guest who keeps coming back is not old.",
|
|
13221
|
+
"A row of the project's own that references a guest follows its foreign key: `ON DELETE CASCADE` deletes it, `SET NULL` empties it, and a required link (`RESTRICT`) keeps both the row and the guest, reported as skipped. A column without a foreign key keeps the id it holds.",
|
|
13222
|
+
"It reads REBASE_SERVICE_KEY the way `cloud env reveal` does, for this command only. A project on an older runtime is told it needs a newer one."
|
|
13223
|
+
]
|
|
13224
|
+
},
|
|
12917
13225
|
usage: {
|
|
12918
13226
|
command: "cloud usage",
|
|
12919
13227
|
usage: "cloud usage [org] [--month YYYY-MM]",
|
|
@@ -13043,6 +13351,14 @@ var ACTION_HELP = {
|
|
|
13043
13351
|
flags: [],
|
|
13044
13352
|
examples: ["rebase cloud whoami", "rebase cloud whoami --json"]
|
|
13045
13353
|
},
|
|
13354
|
+
"access-token": {
|
|
13355
|
+
command: "cloud access-token",
|
|
13356
|
+
usage: "cloud access-token",
|
|
13357
|
+
summary: "Print the bearer this CLI would send right now — REBASE_TOKEN, a linked project's claim token, or the login, refreshed first when it is close to expiry. Bare on stdout, so `$(rebase cloud access-token)` works; `--json` adds the host and when it expires.",
|
|
13358
|
+
flags: [],
|
|
13359
|
+
examples: ["rebase cloud access-token", "rebase cloud access-token --json"],
|
|
13360
|
+
notes: ["It is a credential: whoever holds it acts as you until it expires (about an hour for a login).", "The Rebase MCP server uses it to read any of your projects' data through the console's Studio proxy."]
|
|
13361
|
+
},
|
|
13046
13362
|
tokens: {
|
|
13047
13363
|
command: "cloud tokens",
|
|
13048
13364
|
usage: "cloud tokens <list|create|revoke> [options]",
|
|
@@ -13197,7 +13513,7 @@ var ACTION_HELP = {
|
|
|
13197
13513
|
metrics: {
|
|
13198
13514
|
command: "cloud metrics",
|
|
13199
13515
|
usage: "cloud metrics",
|
|
13200
|
-
summary: "Live CPU, memory and disk for the project's running units, as the control plane reports them.",
|
|
13516
|
+
summary: "Live CPU, memory and disk for the project's running units, and each instance's realtime counts, as the control plane reports them.",
|
|
13201
13517
|
flags: [],
|
|
13202
13518
|
examples: ["rebase cloud metrics", "rebase cloud metrics --json"]
|
|
13203
13519
|
}
|
|
@@ -13309,6 +13625,7 @@ var CLOUD_VALUE_FLAGS = {
|
|
|
13309
13625
|
"--message": String,
|
|
13310
13626
|
"--month": String,
|
|
13311
13627
|
"--name": String,
|
|
13628
|
+
"--older-than": String,
|
|
13312
13629
|
"--org": String,
|
|
13313
13630
|
"--output": String,
|
|
13314
13631
|
"--password": String,
|
|
@@ -13449,6 +13766,9 @@ async function cloudCommand(subcommand, rawArgs) {
|
|
|
13449
13766
|
case "whoami":
|
|
13450
13767
|
await whoamiCommand(rawArgs);
|
|
13451
13768
|
break;
|
|
13769
|
+
case "access-token":
|
|
13770
|
+
await accessTokenCommand(rawArgs);
|
|
13771
|
+
break;
|
|
13452
13772
|
case "tokens":
|
|
13453
13773
|
await tokensCommand(action, rawArgs);
|
|
13454
13774
|
break;
|
|
@@ -13561,6 +13881,9 @@ async function cloudCommand(subcommand, rawArgs) {
|
|
|
13561
13881
|
case "service-key":
|
|
13562
13882
|
await serviceKeyCommand(rawArgs);
|
|
13563
13883
|
break;
|
|
13884
|
+
case "guests":
|
|
13885
|
+
await guestsCommand(rawArgs);
|
|
13886
|
+
break;
|
|
13564
13887
|
case "activity":
|
|
13565
13888
|
await activityCommand(rawArgs);
|
|
13566
13889
|
break;
|
|
@@ -13634,6 +13957,11 @@ var CLOUD_GROUPS = [
|
|
|
13634
13957
|
section: "Auth",
|
|
13635
13958
|
description: "Show the current session, or what REBASE_TOKEN may do"
|
|
13636
13959
|
},
|
|
13960
|
+
{
|
|
13961
|
+
action: "access-token",
|
|
13962
|
+
section: "Auth",
|
|
13963
|
+
description: "Print the bearer this CLI would send now, refreshed if close to expiry"
|
|
13964
|
+
},
|
|
13637
13965
|
{
|
|
13638
13966
|
action: "tokens",
|
|
13639
13967
|
section: "Auth",
|
|
@@ -13795,6 +14123,12 @@ var CLOUD_GROUPS = [
|
|
|
13795
14123
|
section: "Data",
|
|
13796
14124
|
description: "The project's object storage"
|
|
13797
14125
|
},
|
|
14126
|
+
{
|
|
14127
|
+
action: "guests",
|
|
14128
|
+
section: "Data",
|
|
14129
|
+
args: "[delete|prune]",
|
|
14130
|
+
description: "The guest users anonymous sign-in left behind: count them, delete one, delete the old ones. Owners and admins"
|
|
14131
|
+
},
|
|
13798
14132
|
{
|
|
13799
14133
|
action: "notifications",
|
|
13800
14134
|
section: "Deploy & observe",
|
|
@@ -13850,4 +14184,4 @@ function printCloudHelp() {
|
|
|
13850
14184
|
//#endregion
|
|
13851
14185
|
export { CLOUD_GROUP_NAMES, GROUP_ALIASES, cloudCommand };
|
|
13852
14186
|
|
|
13853
|
-
//# sourceMappingURL=cloud-
|
|
14187
|
+
//# sourceMappingURL=cloud-nwWkzAHu.js.map
|