@rebasepro/cli 0.9.1-canary.baa7a6b → 0.9.1-canary.d198c11

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/bin/rebase.js CHANGED
@@ -1,70 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import { existsSync, readdirSync, statSync } from "node:fs";
3
- import { dirname, join } from "node:path";
4
- import { fileURLToPath } from "node:url";
5
-
6
- const here = dirname(fileURLToPath(import.meta.url));
7
- const distEntry = join(here, "..", "dist", "index.es.js");
8
- const srcDir = join(here, "..", "src");
9
-
10
- /**
11
- * Warn when the built CLI is older than the source it was built from.
12
- *
13
- * `rebase` runs `dist/`, and a global install of this package is usually a
14
- * symlink to a working checkout — so every agent and shell on the machine runs
15
- * whatever was last built, not what is in the code. A stale build is invisible:
16
- * the command works, it just silently lacks the subcommand you added, which
17
- * reads as "my change did nothing" rather than "you forgot to build".
18
- *
19
- * Development-only by construction: `src/` is not in the published `files`
20
- * list, so this is skipped entirely for installed copies.
21
- *
22
- * Writes to **stderr**. Agents parse stdout as JSON under `--json`, and a
23
- * warning there would corrupt the one guarantee those commands make.
24
- */
25
- function newestMtimeMs(dir, deadline) {
26
- let newest = 0;
27
- for (const entry of readdirSync(dir, { withFileTypes: true })) {
28
- if (Date.now() > deadline) break; // never let a warning cost real time
29
- if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
30
- const full = join(dir, entry.name);
31
- if (entry.isDirectory()) {
32
- newest = Math.max(newest, newestMtimeMs(full, deadline));
33
- } else if (/\.tsx?$/.test(entry.name) && !/\.(test|spec)\.tsx?$/.test(entry.name)) {
34
- // Tests are not bundled, so editing one does not make dist stale.
35
- // Counting them cried wolf on the ordinary edit-test-run loop.
36
- newest = Math.max(newest, statSync(full).mtimeMs);
37
- }
38
- }
39
- return newest;
40
- }
41
-
42
- function warnIfStale() {
43
- if (!existsSync(srcDir) || !existsSync(distEntry)) return;
44
- const builtAt = statSync(distEntry).mtimeMs;
45
- const editedAt = newestMtimeMs(srcDir, Date.now() + 150);
46
- // A couple of seconds of slack: a build writes dist while src is being
47
- // stat'd, and a sub-second delta is that race, not a stale build.
48
- const staleByMs = editedAt - builtAt;
49
- if (staleByMs <= 2000) return;
50
-
51
- const seconds = Math.round(staleByMs / 1000);
52
- const ago = seconds >= 3600
53
- ? `${Math.round(seconds / 3600)}h`
54
- : seconds >= 60 ? `${Math.round(seconds / 60)}m` : `${seconds}s`;
55
- process.stderr.write(
56
- `⚠ rebase CLI: dist/ is ${ago} older than src/ — you are running a stale build.\n` +
57
- ` Rebuild with: (cd ${join(here, "..")} && npm run build)\n`
58
- );
59
- }
60
-
61
- // A broken staleness check must never stop the CLI from running.
62
- try {
63
- warnIfStale();
64
- } catch {
65
- /* ignore */
66
- }
67
-
68
- const { entry } = await import("../dist/index.es.js");
2
+ import { entry } from "../dist/index.es.js";
69
3
 
70
4
  entry(process.argv);
@@ -1,6 +1,10 @@
1
1
  import { createRebaseClient } from "@rebasepro/client";
2
+ /** Default hosted control plane (the Rebase Cloud console origin). */
3
+ export declare const DEFAULT_CLOUD_URL = "https://app.rebase.pro";
2
4
  /** Project-local link file: <project>/.rebase/cloud.json */
3
5
  export declare function projectLinkPath(cwd?: string): string;
6
+ /** Host that a bare `rebase cloud` command should target, if any. */
7
+ export declare function currentContextUrl(): string | undefined;
4
8
  /** Persist the active organization id for a host. */
5
9
  export declare function setContextOrg(url: string, org: string | undefined): void;
6
10
  export declare function getContextOrg(url: string): string | undefined;
@@ -24,42 +28,9 @@ export declare function requireClient(rawArgs: string[]): Promise<{
24
28
  client: CloudClient;
25
29
  url: string;
26
30
  }>;
27
- export declare function fetchTenantBaseDomain(client: CloudClient, url: string): Promise<string | undefined>;
28
- /**
29
- * Public host for a project — `<subdomain>.<base>`, or the bare subdomain when
30
- * the base domain is unknown.
31
- *
32
- * It deliberately never falls back to a guessed domain. The user copies this
33
- * string into a browser, so a plausible-but-wrong hostname is worse than an
34
- * obviously incomplete one: `acme.rebase.pro` looks reachable and isn't, while
35
- * `acme` reads as "the subdomain is acme" and prompts no wasted debugging.
36
- */
37
- export declare function formatTenantHost(subdomain: string | undefined, baseDomain: string | undefined): string | undefined;
38
- /** The fields of a project row this module needs to render a host. */
39
- export interface HostableProject {
40
- subdomain?: string;
41
- /** Resolved server-side; absent on control planes older than the host hook. */
42
- host?: string;
43
- }
44
- /**
45
- * The host to display for a project.
46
- *
47
- * Prefers `host` off the record: the control plane resolves it through the same
48
- * `tenantHost()` the ingress uses, so it accounts for the project's *cluster*
49
- * base domain. The CLI cannot compute that itself — `clusters` is admin-only
50
- * under RLS, so a normal user's token cannot read `baseDomain`, and a project on
51
- * a second cluster is served somewhere the platform default does not name.
52
- *
53
- * `baseDomain` (from `platform-config`) remains the fallback for a control plane
54
- * that predates the hook — right for the single-cluster case, which is every
55
- * project today.
56
- */
57
- export declare function projectHost(project: HostableProject, baseDomain: string | undefined): string | undefined;
58
31
  export interface ProjectLink {
59
32
  url: string;
60
33
  projectId: string;
61
- /** The project's subdomain — the slug users see in console URLs and type into --project. */
62
- slug?: string;
63
34
  projectName?: string;
64
35
  orgId?: string;
65
36
  }
@@ -67,78 +38,17 @@ export declare function readLink(cwd?: string): ProjectLink | null;
67
38
  export declare function writeLink(link: ProjectLink, cwd?: string): void;
68
39
  export declare function removeLink(cwd?: string): boolean;
69
40
  /**
70
- * The raw project reference to operate on: explicit `--project` flag wins,
41
+ * Resolve the project id to operate on: explicit `--project` flag wins,
71
42
  * otherwise the linked project. Exits with guidance when neither is present.
72
- * The value is a slug (the project's subdomain, as shown in console URLs) or,
73
- * for old scripts and link files, a raw project UUID.
74
43
  */
75
- export declare function requireProjectRef(rawArgs: string[]): string;
76
- /**
77
- * Resolve a project reference — slug or UUID — to the internal id the API
78
- * takes, or undefined when no such project is visible. Slugs cost one lookup;
79
- * UUIDs pass through untouched so linked directories and old scripts skip the
80
- * round-trip.
81
- */
82
- export declare function lookupProjectId(ref: string, client: CloudClient): Promise<string | undefined>;
83
- /** Like `lookupProjectId`, but exits with guidance when the ref matches nothing. */
84
- export declare function resolveProjectRef(ref: string, client: CloudClient): Promise<string>;
85
- /** `requireProjectRef` + `resolveProjectRef` in one step. */
86
- export declare function requireProject(rawArgs: string[], client: CloudClient): Promise<string>;
87
- /**
88
- * The project reference to SHOW: the slug the user typed or the linked slug.
89
- * Never resolves — for human output only. Old link files predate `slug` and
90
- * fall back to the stored id.
91
- */
92
- export declare function displayProjectRef(rawArgs: string[]): string;
93
- /**
94
- * Resolve and latch the output mode for this invocation. Call once at the top of
95
- * `cloudCommand`, before anything can print or `fail`. Returns the resolved mode
96
- * (handy for tests, which otherwise leave it at its `false` default).
97
- */
98
- export declare function initOutputMode(rawArgs: string[]): boolean;
99
- /** Whether the current invocation is emitting machine-readable JSON. */
100
- export declare function isJsonMode(): boolean;
101
- /** Force the mode (tests only — production latches it via `initOutputMode`). */
102
- export declare function setJsonModeForTest(value: boolean): void;
103
- /**
104
- * The one output primitive every new command uses: in JSON mode emit `json`
105
- * (and nothing else); otherwise run `human`. Keeping the two behind a single
106
- * call is what guarantees a command can never print a table AND a JSON blob.
107
- */
108
- export declare function emit(human: () => void, json: unknown): void;
44
+ export declare function requireProjectId(rawArgs: string[]): string;
109
45
  /** Print an error (+ optional hint) and exit non-zero. Never returns. */
110
- export declare function fail(message: string, hint?: string, code?: string): never;
111
- /**
112
- * Confirm a destructive/irreversible action, respecting non-interactive use.
113
- *
114
- * With `--yes`/`-y` it proceeds silently. In JSON mode or a non-TTY it REFUSES
115
- * to prompt — a prompt that can hang is a known repo landmine — and fails,
116
- * telling the caller to pass `--yes`. Only an interactive terminal gets a real
117
- * confirm prompt; declining there aborts cleanly (exit 0).
118
- */
119
- export declare function confirmDestructive(opts: {
120
- yes: boolean;
121
- prompt: string;
122
- }): Promise<void>;
123
- /**
124
- * Positional tokens after `rebase cloud` — `[group, action, arg1, …]`.
125
- *
126
- * Deliberately NOT `arg({}, { permissive: true })._`: in permissive mode `arg`
127
- * pushes UNKNOWN FLAGS onto `_` too, so `rollback --yes --json` would report
128
- * `--yes` as the deployment id. Operand extraction must see operands only, so
129
- * anything starting with `-` is dropped — the same filter the db backup handler
130
- * has always used.
131
- */
132
- export declare function cloudPositionals(rawArgs: string[]): string[];
46
+ export declare function fail(message: string, hint?: string): never;
133
47
  export declare function success(message: string): void;
134
48
  /** Colorize a deployment / resource status token. */
135
49
  export declare function colorStatus(status: string | undefined): string;
136
- /**
137
- * Render a two-column key/value block with aligned keys. Empty rows are skipped
138
- * — including `null`, which the API sends for an unset column and which used to
139
- * print the literal string "null" (e.g. `Custom domain: null`).
140
- */
141
- export declare function keyValues(rows: Array<[string, string | null | undefined]>): void;
50
+ /** Render a two-column key/value block with aligned keys. */
51
+ export declare function keyValues(rows: Array<[string, string | undefined]>): void;
142
52
  /**
143
53
  * Surface an SDK/HTTP error consistently. The SDK throws RebaseApiError with
144
54
  * a `.status` and `.message`; anything else falls back to its string form.
@@ -1,2 +1,2 @@
1
- export declare function deployCommand(rawArgs: string[], projectRef: string): Promise<void>;
2
- export declare function logsCommand(rawArgs: string[], projectRef: string): Promise<void>;
1
+ export declare function deployCommand(rawArgs: string[], projectId: string): Promise<void>;
2
+ export declare function logsCommand(rawArgs: string[], projectId: string): Promise<void>;
@@ -1,8 +1,8 @@
1
1
  import { type CloudClient } from "./context";
2
2
  export declare function listProjects(rawArgs: string[]): Promise<void>;
3
3
  export declare function createProject(rawArgs: string[]): Promise<void>;
4
- export declare function projectInfo(rawArgs: string[], projectRef: string): Promise<void>;
5
- export declare function deleteProject(rawArgs: string[], projectRef: string): Promise<void>;
4
+ export declare function projectInfo(rawArgs: string[], projectId: string): Promise<void>;
5
+ export declare function deleteProject(rawArgs: string[], projectId: string): Promise<void>;
6
6
  export declare function firstRow(client: CloudClient, collection: string, projectId: string): Promise<Record<string, unknown> | undefined>;
7
7
  export declare function latestDeployment(client: CloudClient, projectId: string): Promise<{
8
8
  id: string | number;
@@ -1,6 +1,6 @@
1
1
  export declare function statusCommand(rawArgs: string[]): Promise<void>;
2
2
  export declare function metricsCommand(rawArgs: string[]): Promise<void>;
3
3
  export declare function webhooksCommand(subcommand: string | undefined, rawArgs: string[]): Promise<void>;
4
- export declare function storageCommand(action: string | undefined, rawArgs: string[]): Promise<void>;
4
+ export declare function storageCommand(rawArgs: string[]): Promise<void>;
5
5
  export declare function clustersCommand(rawArgs: string[]): Promise<void>;
6
6
  export declare function billingCommand(rawArgs: string[]): Promise<void>;
@@ -1,6 +1,4 @@
1
1
  import type { PackageManager, PMCommands } from "../utils/package-manager";
2
- /** Returns an error message, or null when the name is a valid package name. */
3
- export declare function validateProjectName(name: string): string | null;
4
2
  export type TemplatePreset = "blog" | "ecommerce" | "blank";
5
3
  /**
6
4
  * How much of Rebase to scaffold.
@@ -30,12 +28,6 @@ export interface InitOptions {
30
28
  pm: PackageManager;
31
29
  /** Command helpers for the detected PM. */
32
30
  pmCommands: PMCommands;
33
- /** Cloud project slug (its subdomain) to link the scaffold to. */
34
- cloudProject?: string;
35
- /** One-time setup key that authenticates the cloud link. */
36
- setupKey?: string;
37
- /** Control-plane URL the setup key is redeemed against. */
38
- cloudUrl?: string;
39
31
  }
40
32
  export interface BuildQuestionsParams {
41
33
  nameArg?: string;
@@ -1 +1 @@
1
- export declare function skillsCommand(subcommand: string | undefined, rawArgs: string[]): Promise<void>;
1
+ export declare function skillsCommand(subcommand: string | undefined, _args: string[]): Promise<void>;