@rebasepro/cli 0.25.1 → 0.26.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/README.md +2 -1
- package/bin/rebase.js +143 -4
- package/dist/{agent-setup-BYb2Tbdz.js → agent-setup-D9mHRZ5R.js} +125 -3
- package/dist/agent-setup-D9mHRZ5R.js.map +1 -0
- package/dist/{api-keys-CSMbsmAn.js → api-keys-CyJ26KEJ.js} +41 -9
- package/dist/api-keys-CyJ26KEJ.js.map +1 -0
- package/dist/{apps-iBXNZhVN.js → apps-CnLDV5b6.js} +6 -6
- package/dist/{apps-iBXNZhVN.js.map → apps-CnLDV5b6.js.map} +1 -1
- package/dist/{atlas-dev-database-BusbHP6n.js → atlas-dev-database-BODqdCWt.js} +2 -2
- package/dist/{atlas-dev-database-BusbHP6n.js.map → atlas-dev-database-BODqdCWt.js.map} +1 -1
- package/dist/{auth-DRsTWPky.js → auth-dII2jCO1.js} +10 -7
- package/dist/auth-dII2jCO1.js.map +1 -0
- package/dist/{branch-pointer-Bn_FjNld.js → branch-pointer-BQUF6lYa.js} +1 -1
- package/dist/{build-et7Rccxi.js → build-Cza7ZQrp.js} +6 -6
- package/dist/{build-et7Rccxi.js.map → build-Cza7ZQrp.js.map} +1 -1
- package/dist/{bundle-DlqkDYSe.js → bundle-C6yEtMJ-.js} +53 -5
- package/dist/bundle-C6yEtMJ-.js.map +1 -0
- package/dist/bundle.d.ts +14 -0
- package/dist/{cloud-B-ZIjHrA.js → cloud-BdnmqQaZ.js} +8527 -4340
- package/dist/cloud-BdnmqQaZ.js.map +1 -0
- package/dist/collections-dir-DlvDhime.js +69 -0
- package/dist/collections-dir-DlvDhime.js.map +1 -0
- package/dist/commands/agent-setup.d.ts +58 -0
- package/dist/commands/api-keys.d.ts +13 -0
- package/dist/commands/cloud/activity.d.ts +25 -0
- package/dist/commands/cloud/app-key.d.ts +18 -0
- package/dist/commands/cloud/auth.d.ts +1 -0
- package/dist/commands/cloud/billing-invoices.d.ts +39 -0
- package/dist/commands/cloud/claim.d.ts +7 -0
- package/dist/commands/cloud/context.d.ts +115 -6
- package/dist/commands/cloud/deploy-summary.d.ts +162 -0
- package/dist/commands/cloud/deploy.d.ts +64 -0
- package/dist/commands/cloud/env.d.ts +24 -0
- package/dist/commands/cloud/index.d.ts +13 -1
- package/dist/commands/cloud/init.d.ts +143 -0
- package/dist/commands/cloud/login-flow.d.ts +51 -0
- package/dist/commands/cloud/notifications.d.ts +28 -0
- package/dist/commands/cloud/orgs.d.ts +13 -0
- package/dist/commands/cloud/previews.d.ts +123 -0
- package/dist/commands/cloud/resources.d.ts +68 -14
- package/dist/commands/cloud/runtime-logs.d.ts +176 -0
- package/dist/commands/cloud/service-key.d.ts +15 -0
- package/dist/commands/cloud/token-capabilities.d.ts +61 -8
- package/dist/commands/cloud/tokens.d.ts +18 -3
- package/dist/commands/cloud/usage.d.ts +63 -0
- package/dist/commands/dev.d.ts +10 -0
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/generate-view.d.ts +94 -0
- package/dist/commands/generate_sdk.d.ts +15 -0
- package/dist/commands/skills.d.ts +4 -3
- package/dist/commands/storage.d.ts +4 -0
- package/dist/commands/verify.d.ts +96 -0
- package/dist/{consent-BaB-eQKG.js → consent-BD7F29T3.js} +2 -2
- package/dist/{consent-BaB-eQKG.js.map → consent-BD7F29T3.js.map} +1 -1
- package/dist/{console-BlD9kjFW.js → console-BXB6-8GT.js} +12 -6
- package/dist/console-BXB6-8GT.js.map +1 -0
- package/dist/{context-DHiiiJ5C.js → context-GUxkZm-S.js} +481 -24
- package/dist/context-GUxkZm-S.js.map +1 -0
- package/dist/{daemon-DDMRbz4T.js → daemon-Cp7oNXth.js} +2 -2
- package/dist/{daemon-DDMRbz4T.js.map → daemon-Cp7oNXth.js.map} +1 -1
- package/dist/{db-9P6MnmdC.js → db-KzlqddGD.js} +37 -30
- package/dist/db-KzlqddGD.js.map +1 -0
- package/dist/{derive-MTdClnkc.js → derive-ae9UOoOB.js} +2 -2
- package/dist/{derive-MTdClnkc.js.map → derive-ae9UOoOB.js.map} +1 -1
- package/dist/{dev-BDN_OKXA.js → dev-DTqVMgB3.js} +59 -32
- package/dist/dev-DTqVMgB3.js.map +1 -0
- package/dist/{dev-preflight-FT9GbJVj.js → dev-preflight-Cxv3TiD1.js} +2 -2
- package/dist/{dev-preflight-FT9GbJVj.js.map → dev-preflight-Cxv3TiD1.js.map} +1 -1
- package/dist/{dev-server-CIZwAfZa.js → dev-server-OJsUGZEB.js} +2 -2
- package/dist/{dev-server-CIZwAfZa.js.map → dev-server-OJsUGZEB.js.map} +1 -1
- package/dist/{doctor-D8YXz7df.js → doctor-BRWOlqeG.js} +13 -11
- package/dist/doctor-BRWOlqeG.js.map +1 -0
- package/dist/{eject-izG2KjMo.js → eject-DABcDnPN.js} +3 -3
- package/dist/{eject-izG2KjMo.js.map → eject-DABcDnPN.js.map} +1 -1
- package/dist/{fold-static-CybSay_W.js → fold-static-BnAK-anQ.js} +3 -3
- package/dist/{fold-static-CybSay_W.js.map → fold-static-BnAK-anQ.js.map} +1 -1
- package/dist/generate-view-IFwCADvb.js +662 -0
- package/dist/generate-view-IFwCADvb.js.map +1 -0
- package/dist/{generate_sdk-B4R65oUV.js → generate_sdk-BvcWvoUh.js} +33 -7
- package/dist/generate_sdk-BvcWvoUh.js.map +1 -0
- package/dist/index.es.js +57 -38
- package/dist/index.es.js.map +1 -1
- package/dist/{init-DYaeppEN.js → init-CaU6GhwI.js} +8 -8
- package/dist/{init-DYaeppEN.js.map → init-CaU6GhwI.js.map} +1 -1
- package/dist/last-dev-database-DpW5dfoX.js +2 -0
- package/dist/{manifest-nvPdLlJY.js → manifest-BtzDy7KQ.js} +36 -3
- package/dist/{manifest-nvPdLlJY.js.map → manifest-BtzDy7KQ.js.map} +1 -1
- package/dist/{normalize-imports-BYw8ad87.js → normalize-imports-D0zXlM6g.js} +3 -3
- package/dist/{normalize-imports-BYw8ad87.js.map → normalize-imports-D0zXlM6g.js.map} +1 -1
- package/dist/{path-flags-BFgG9V6y.js → path-flags-DNvtEi2-.js} +5 -4
- package/dist/path-flags-DNvtEi2-.js.map +1 -0
- package/dist/{prepare-1rVNd2PF.js → prepare-CTw9NEkh.js} +4 -4
- package/dist/{prepare-1rVNd2PF.js.map → prepare-CTw9NEkh.js.map} +1 -1
- package/dist/{project-g4K6kV1t.js → project-CasK56vN.js} +2 -2
- package/dist/{project-g4K6kV1t.js.map → project-CasK56vN.js.map} +1 -1
- package/dist/resolve-D647F1LA.js +2 -0
- package/dist/{resources-CovP8AZ-.js → resources-CPSC5Kcu.js} +4 -4
- package/dist/{resources-CovP8AZ-.js.map → resources-CPSC5Kcu.js.map} +1 -1
- package/dist/{schema-nuxvvc50.js → schema-BSXwZSiI.js} +9 -7
- package/dist/schema-BSXwZSiI.js.map +1 -0
- package/dist/{skills-DeUIsZcT.js → skills-BU2flMOy.js} +52 -7
- package/dist/skills-BU2flMOy.js.map +1 -0
- package/dist/{start-RzZqDroW.js → start-mVb6upwY.js} +5 -5
- package/dist/{start-RzZqDroW.js.map → start-mVb6upwY.js.map} +1 -1
- package/dist/static-syntax-check.d.ts +64 -0
- package/dist/{status-D9Zm88NZ.js → status-BREvtzJm.js} +7 -7
- package/dist/{status-D9Zm88NZ.js.map → status-BREvtzJm.js.map} +1 -1
- package/dist/{storage-BB3umRfw.js → storage-DtOXGflp.js} +159 -15
- package/dist/storage-DtOXGflp.js.map +1 -0
- package/dist/{telemetry-HfU5uAh1.js → telemetry-CgwJPVMO.js} +2 -2
- package/dist/{telemetry-HfU5uAh1.js.map → telemetry-CgwJPVMO.js.map} +1 -1
- package/dist/{telemetry-TseNLk6X.js → telemetry-DwK5RQJl.js} +4 -4
- package/dist/{telemetry-TseNLk6X.js.map → telemetry-DwK5RQJl.js.map} +1 -1
- package/dist/{upgrade-apiPKKE_.js → upgrade-B7sVwL8S.js} +4 -4
- package/dist/{upgrade-apiPKKE_.js.map → upgrade-B7sVwL8S.js.map} +1 -1
- package/dist/utils/collections-dir.d.ts +14 -0
- package/dist/utils/path-flags.d.ts +2 -1
- package/dist/utils/tool-stdio.d.ts +1 -1
- package/dist/verify-D7UsV_qe.js +730 -0
- package/dist/verify-D7UsV_qe.js.map +1 -0
- package/package.json +9 -7
- package/templates/eject/backend/src/index.ts +9 -1
- package/templates/generated-schemas/ecommerce.ts +3 -0
- package/templates/overlays/baas/ai-instructions.md +13 -0
- package/templates/template/.claude/hooks/post-edit-collection.sh +99 -0
- package/templates/template/.claude/settings.json +17 -0
- package/templates/template/.env.example +10 -1
- package/templates/template/ai-instructions.md +21 -1
- package/templates/template/config/collections/presets/ecommerce/index.ts +23 -0
- package/templates/template/docker-compose.yml +4 -1
- package/templates/template/frontend/package.json +1 -0
- package/templates/views/AppView.tsx.tmpl +138 -0
- package/templates/views/EntityView.tsx.tmpl +64 -0
- package/templates/views/index.ts.tmpl +8 -0
- package/dist/agent-setup-BYb2Tbdz.js.map +0 -1
- package/dist/api-keys-CSMbsmAn.js.map +0 -1
- package/dist/auth-DRsTWPky.js.map +0 -1
- package/dist/bundle-DlqkDYSe.js.map +0 -1
- package/dist/cloud-B-ZIjHrA.js.map +0 -1
- package/dist/console-BlD9kjFW.js.map +0 -1
- package/dist/context-DHiiiJ5C.js.map +0 -1
- package/dist/db-9P6MnmdC.js.map +0 -1
- package/dist/dev-BDN_OKXA.js.map +0 -1
- package/dist/doctor-D8YXz7df.js.map +0 -1
- package/dist/generate_sdk-B4R65oUV.js.map +0 -1
- package/dist/last-dev-database-B_75fxZC.js +0 -2
- package/dist/path-flags-BFgG9V6y.js.map +0 -1
- package/dist/resolve-BQUAC3Wi.js +0 -2
- package/dist/schema-nuxvvc50.js.map +0 -1
- package/dist/skills-DeUIsZcT.js.map +0 -1
- package/dist/storage-BB3umRfw.js.map +0 -1
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*
|
|
22
22
|
* `homeMarkers` are the directories under `~` that say the assistant is
|
|
23
23
|
* installed on this machine. They answer a different question from
|
|
24
|
-
* `detectDir`: a fresh scaffold has no `.claude
|
|
24
|
+
* `detectDir`: a fresh scaffold has no `.claude/skills` of its own, so `rebase init`
|
|
25
25
|
* asks the machine which assistants the developer has and pre-selects those.
|
|
26
26
|
*
|
|
27
27
|
* `mcp` is where the assistant reads a *project-level* MCP server list, and in
|
|
@@ -52,7 +52,7 @@ export declare const AGENTS: {
|
|
|
52
52
|
};
|
|
53
53
|
readonly claude: {
|
|
54
54
|
readonly label: "Claude Code";
|
|
55
|
-
readonly detectDir: ".claude";
|
|
55
|
+
readonly detectDir: ".claude/skills";
|
|
56
56
|
readonly homeMarkers: readonly [".claude"];
|
|
57
57
|
readonly targetDir: ".claude/skills";
|
|
58
58
|
readonly flatLayout: false;
|
|
@@ -257,10 +257,11 @@ export declare function skillsCommand(subcommand: string | undefined, rawArgs: s
|
|
|
257
257
|
* given.
|
|
258
258
|
*/
|
|
259
259
|
export declare function parseAgentFlags(rawArgs: string[]): AgentKey[] | null;
|
|
260
|
-
/** `rebase skills install`'s whole line: the agents it names, `--mcp` and `--force`. */
|
|
260
|
+
/** `rebase skills install`'s whole line: the agents it names, `--mcp`, `--hooks` and `--force`. */
|
|
261
261
|
export declare function parseSkillsInstallLine(rawArgs: string[]): {
|
|
262
262
|
agents: AgentKey[] | null;
|
|
263
263
|
mcp: boolean;
|
|
264
|
+
hooks: boolean;
|
|
264
265
|
force: boolean;
|
|
265
266
|
};
|
|
266
267
|
/**
|
|
@@ -35,6 +35,10 @@ export interface OrphanReport {
|
|
|
35
35
|
reason: string;
|
|
36
36
|
}[];
|
|
37
37
|
}
|
|
38
|
+
/** How often a running scan is asked about. A setting so the tests need not wait. */
|
|
39
|
+
export declare const orphanScanPolling: {
|
|
40
|
+
intervalMs: number;
|
|
41
|
+
};
|
|
38
42
|
/** Bytes, as a person reads them. */
|
|
39
43
|
export declare function formatBytes(bytes: number): string;
|
|
40
44
|
/**
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/** The flags `rebase verify` takes. */
|
|
2
|
+
export declare const VERIFY_FLAGS: {
|
|
3
|
+
readonly "--collections": StringConstructor;
|
|
4
|
+
readonly "-c": "--collections";
|
|
5
|
+
readonly "--json": BooleanConstructor;
|
|
6
|
+
readonly "--quiet": BooleanConstructor;
|
|
7
|
+
readonly "-q": "--quiet";
|
|
8
|
+
readonly "--live": BooleanConstructor;
|
|
9
|
+
readonly "--database-url": StringConstructor;
|
|
10
|
+
readonly "--docker": BooleanConstructor;
|
|
11
|
+
};
|
|
12
|
+
export type VerifyStepId = "config" | "rls" | "migrations" | "live";
|
|
13
|
+
export interface VerifyFinding {
|
|
14
|
+
step: VerifyStepId;
|
|
15
|
+
/** Stable, kebab-case: what kind of problem. An agent can branch on it. */
|
|
16
|
+
check: string;
|
|
17
|
+
severity: "error" | "warning";
|
|
18
|
+
message: string;
|
|
19
|
+
/** What to change, when there is one thing to change. */
|
|
20
|
+
fix?: string;
|
|
21
|
+
/** The collection's slug. */
|
|
22
|
+
collection?: string;
|
|
23
|
+
/** The file to open, relative to the project root. */
|
|
24
|
+
file?: string;
|
|
25
|
+
/** Dotted path into the collection config — `posts.properties.title.widget`. */
|
|
26
|
+
path?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface VerifyStep {
|
|
29
|
+
id: VerifyStepId;
|
|
30
|
+
title: string;
|
|
31
|
+
status: "passed" | "failed" | "warnings" | "skipped";
|
|
32
|
+
/** Why a step was skipped, or what it covered. */
|
|
33
|
+
detail?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface VerifyReport {
|
|
36
|
+
ok: boolean;
|
|
37
|
+
/** Relative to the project root. */
|
|
38
|
+
collectionsDir: string;
|
|
39
|
+
steps: VerifyStep[];
|
|
40
|
+
findings: VerifyFinding[];
|
|
41
|
+
summary: {
|
|
42
|
+
errors: number;
|
|
43
|
+
warnings: number;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export interface VerifyOptions {
|
|
47
|
+
projectRoot: string;
|
|
48
|
+
collectionsDir: string;
|
|
49
|
+
/** The backend package, where `drizzle/migrations` lives. Null for a project without one. */
|
|
50
|
+
backendDir: string | null;
|
|
51
|
+
live: boolean;
|
|
52
|
+
databaseUrl?: string;
|
|
53
|
+
/** Why no `databaseUrl` could be resolved for `--live`, when resolving it failed. */
|
|
54
|
+
databaseUnavailable?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the backend refuses a request with no token (`AUTH_REQUIRE`, on
|
|
57
|
+
* unless set to `false`). Decides how a Rebase-compiled public read reads.
|
|
58
|
+
* Defaults to true, the runtime's default.
|
|
59
|
+
*/
|
|
60
|
+
authRequired?: boolean;
|
|
61
|
+
}
|
|
62
|
+
/** One row of `rebase.atlas_schema_revisions`, as far as "applied" needs it. */
|
|
63
|
+
export interface AppliedRevision {
|
|
64
|
+
version: string;
|
|
65
|
+
/** Atlas's revision type, a bit set: 1 baseline, 2 executed, 4 resolved (`migrate set`). */
|
|
66
|
+
type: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The migration files the database has not run, as Atlas's own `migrate status`
|
|
70
|
+
* counts them.
|
|
71
|
+
*
|
|
72
|
+
* A file is applied when its version has a row, or when it is at or behind the
|
|
73
|
+
* newest *baseline* row: `migrate apply --baseline V` records V alone, and
|
|
74
|
+
* means "everything up to V is already here". `rebase db migrate --baseline` is
|
|
75
|
+
* what the CLI prescribes for a booted database, so set membership alone
|
|
76
|
+
* reported the earlier migrations of every baselined database as not applied —
|
|
77
|
+
* and prescribed `rebase db migrate`, which answers "No migration files to
|
|
78
|
+
* execute". That run failed forever.
|
|
79
|
+
*/
|
|
80
|
+
export declare function pendingMigrations(files: readonly string[], revisions: readonly AppliedRevision[], compare: (a: string, b: string) => number, versionOf: (file: string) => string): string[];
|
|
81
|
+
/**
|
|
82
|
+
* Run every step and return the report. Prints nothing and never exits, so a
|
|
83
|
+
* caller — the command, a test — decides what to do with it.
|
|
84
|
+
*/
|
|
85
|
+
export declare function runVerify(options: VerifyOptions): Promise<VerifyReport>;
|
|
86
|
+
export declare function printReport(report: VerifyReport, quiet: boolean): void;
|
|
87
|
+
/**
|
|
88
|
+
* Whether the backend refuses a request with no token: `AUTH_REQUIRE` from the
|
|
89
|
+
* environment, else `.env`, read as every boolean env var is read
|
|
90
|
+
* (`parseEnvBoolean`: `false`/`0`/`no`/`off` turn it off). On unless one of
|
|
91
|
+
* those says otherwise — the runtime's default. Compared raw, `AUTH_REQUIRE=0`
|
|
92
|
+
* read as "on", and a compiled public read was reported as token-gated on a
|
|
93
|
+
* backend that serves it to anyone.
|
|
94
|
+
*/
|
|
95
|
+
export declare function authRequiredFrom(environment: Record<string, string | undefined>, envFile: Record<string, string | undefined>): boolean;
|
|
96
|
+
export declare function verifyCommand(rawArgs: string[]): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as setConsent, c as buildEvent, f as readConfig, o as suppressionReason } from "./telemetry-
|
|
1
|
+
import { a as setConsent, c as buildEvent, f as readConfig, o as suppressionReason } from "./telemetry-CgwJPVMO.js";
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import inquirer from "inquirer";
|
|
4
4
|
//#region src/telemetry/consent.ts
|
|
@@ -73,4 +73,4 @@ function describeState(env = process.env) {
|
|
|
73
73
|
//#endregion
|
|
74
74
|
export { promptForConsent as n, renderPreview as r, describeState as t };
|
|
75
75
|
|
|
76
|
-
//# sourceMappingURL=consent-
|
|
76
|
+
//# sourceMappingURL=consent-BD7F29T3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consent-
|
|
1
|
+
{"version":3,"file":"consent-BD7F29T3.js","names":[],"sources":["../src/telemetry/consent.ts"],"sourcesContent":["import chalk from \"chalk\";\nimport inquirer from \"inquirer\";\n\nimport { buildEvent, TELEMETRY_SCHEMA_VERSION, TelemetryEventName } from \"./payload\";\nimport { readConfig } from \"./identity\";\nimport { setConsent, suppressionReason } from \"./index\";\n\n/**\n * Asking, and what the question looks like.\n *\n * ## Why the prompt comes *after* the work\n *\n * The first `rebase init` on a machine is the event most worth having, and it\n * is the one where no consent exists yet. Asking before scaffolding puts a\n * privacy negotiation in front of someone who has not yet seen the tool do\n * anything — the worst possible moment, and a reliable way to get a reflexive\n * no.\n *\n * So the question is asked once the project exists and the user has seen it\n * work. The event's data is still in memory at that point, so nothing is lost\n * by waiting, and — this is the part that matters — **nothing has been\n * transmitted or written**. Declining leaves no id, no file, no record.\n *\n * ## Why the payload is shown rather than described\n *\n * \"Anonymous usage data\" is a phrase that has been used to mean almost\n * anything. Printing the exact JSON costs four lines of output and replaces a\n * claim the user has to take on faith with something they can read. It is also\n * the same builder the sender uses, so it cannot drift into a comfortable\n * fiction.\n */\n\n/** Where the question is being asked from, which decides how often it may be. */\nexport interface PromptOptions {\n /**\n * Ask again even though this machine already declined.\n *\n * Set by `rebase init`, and only there. Scaffolding a project is a\n * deliberate, occasional act with a natural pause in it — not something\n * anyone does in a loop — so asking each time is an offer rather than\n * nagging, and it reaches the person whose first answer was a reflex before\n * they had seen the tool do anything.\n *\n * It does **not** re-ask someone who accepted: they are already sharing, so\n * the only thing another prompt could do is talk them out of it.\n *\n * Nothing else changes. `DO_NOT_TRACK`, `REBASE_TELEMETRY_DISABLED`, `CI`\n * and a project's `\"telemetry\": false` are answers, not questions, and they\n * still suppress the prompt entirely — a re-ask that could override a\n * committed repository policy would be exactly the consent-by-proxy the\n * policy exists to prevent.\n */\n reAskDeclined?: boolean;\n}\n\n/** True when we may ask: nothing forbids it, and there is a question to ask. */\nexport function shouldPrompt(\n env: NodeJS.ProcessEnv = process.env,\n { reAskDeclined = false }: PromptOptions = {}\n): boolean {\n if (!process.stdin.isTTY) return false;\n\n const reason = suppressionReason(env);\n // `not_asked` is the only reason that is a question rather than an answer.\n // A user who set DO_NOT_TRACK, or is on CI, has already told us — and so\n // has one who is already sharing (`null`), whom we never re-ask.\n if (reason === \"not_asked\") return true;\n return reAskDeclined && reason === \"declined\";\n}\n\nexport function renderPreview(event: TelemetryEventName, properties: Record<string, unknown>): string {\n const preview = buildEvent(event, properties, {\n machineId: \"<random uuid, generated only if you say yes>\",\n projectId: \"<random uuid, per checkout>\"\n });\n return JSON.stringify(preview, null, 2);\n}\n\n/**\n * Ask, record the answer, and report it.\n *\n * Never throws and never blocks a non-interactive run: `rebase init --yes` in\n * CI must behave exactly as it does today, which means not asking and not\n * sending.\n */\nexport async function promptForConsent(options: PromptOptions = {}): Promise<boolean> {\n if (!shouldPrompt(process.env, options)) return false;\n\n // Only true when this is a second (or later) asking, which the closing line\n // needs to know: \"you will not be asked again\" is false at `init`.\n const askedBefore = suppressionReason(process.env) === \"declined\";\n\n try {\n console.log(\"\");\n console.log(chalk.bold(\"Help improve Rebase?\"));\n console.log(\"\");\n console.log(chalk.gray(\" Rebase is self-hosted, so we only learn what works if you tell us.\"));\n console.log(chalk.gray(\" Anonymous: random ids, the CLI version, your OS, and which template and\"));\n console.log(chalk.gray(\" package manager you used. Never project names, paths, schemas, URLs or\"));\n console.log(chalk.gray(\" error messages.\"));\n console.log(\"\");\n console.log(chalk.gray(` Print the exact payload with ${chalk.cyan(\"rebase telemetry show\")}; change your mind`));\n console.log(chalk.gray(` any time with ${chalk.cyan(\"rebase telemetry disable\")}.`));\n if (askedBefore) {\n console.log(\"\");\n console.log(chalk.gray(\" You declined before; that stands unless you change it here.\"));\n }\n console.log(\"\");\n\n const { accepted } = await inquirer.prompt([\n {\n type: \"confirm\",\n name: \"accepted\",\n message: \"Share anonymous usage data?\",\n // Defaults to no. Telemetry is off until somebody says yes, and\n // a bare Enter is the commonest answer to any prompt — so a\n // pre-selected yes would make pressing through `init` the\n // consent. `y` is one keystroke, and `rebase telemetry enable`\n // is the same answer later.\n default: false\n }\n ] as Parameters<typeof inquirer.prompt>[0]) as { accepted: boolean };\n\n setConsent(Boolean(accepted));\n\n console.log(\n accepted\n ? chalk.green(\" Thank you — sharing enabled.\")\n : chalk.gray(\n \" Nothing will be sent.\"\n + (options.reAskDeclined\n ? \" You will be asked again the next time you scaffold a project.\"\n : \" You will not be asked again.\")\n )\n );\n console.log(\"\");\n return Boolean(accepted);\n } catch {\n // A prompt that fails (piped stdin, a terminal that went away) is a\n // decline, and specifically a decline we do not persist — the user\n // never actually saw the question, so they should still get to answer\n // it another day.\n return false;\n }\n}\n\n/** Human-readable current state, for `rebase telemetry status`. */\nexport function describeState(env: NodeJS.ProcessEnv = process.env): string {\n const reason = suppressionReason(env);\n const config = readConfig();\n switch (reason) {\n case null:\n return `${chalk.green(\"enabled\")} — schema v${TELEMETRY_SCHEMA_VERSION}, machine id ${chalk.gray(config.machineId ?? \"unset\")}`;\n case \"not_asked\":\n return `${chalk.yellow(\"not configured\")} — nothing has been sent, and you have not been asked yet`;\n case \"declined\":\n return `${chalk.gray(\"disabled\")} — you declined${config.decidedAt ? ` on ${config.decidedAt.slice(0, 10)}` : \"\"}`;\n case \"do_not_track\":\n return `${chalk.gray(\"disabled\")} — the ${chalk.cyan(\"DO_NOT_TRACK\")} environment variable is set`;\n case \"rebase_telemetry_disabled\":\n return `${chalk.gray(\"disabled\")} — the ${chalk.cyan(\"REBASE_TELEMETRY_DISABLED\")} environment variable is set`;\n case \"ci\":\n return `${chalk.gray(\"disabled\")} — this looks like CI (${chalk.cyan(\"CI\")} is set), which is never counted`;\n case \"project_opt_out\":\n return `${chalk.gray(\"disabled\")} — this project's ${chalk.cyan(\"rebase.json\")} sets ${chalk.cyan('\"telemetry\": false')}`;\n }\n}\n"],"mappings":";;;;;AAwDA,SAAgB,aACZ,MAAyB,QAAQ,KACjC,EAAE,gBAAgB,UAAyB,CAAC,GACrC;CACP,IAAI,CAAC,QAAQ,MAAM,OAAO,OAAO;CAEjC,MAAM,SAAS,kBAAkB,GAAG;CAIpC,IAAI,WAAW,aAAa,OAAO;CACnC,OAAO,iBAAiB,WAAW;AACvC;AAEA,SAAgB,cAAc,OAA2B,YAA6C;CAClG,MAAM,UAAU,WAAW,OAAO,YAAY;EAC1C,WAAW;EACX,WAAW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AW;CAC1B,QAAQ,QAAR;EACI,KAAK,MACD,OAAO,GAAG,MAAM,MAAM,SAAS,EAAE,2BAAqD,MAAM,KAAK,OAAO,aAAa,OAAO;EAChI,KAAK,aACD,OAAO,GAAG,MAAM,OAAO,gBAAgB,EAAE;EAC7C,KAAK,YACD,OAAO,GAAG,MAAM,KAAK,UAAU,EAAE,iBAAiB,OAAO,YAAY,OAAO,OAAO,UAAU,MAAM,GAAG,EAAE,MAAM;EAClH,KAAK,gBACD,OAAO,GAAG,MAAM,KAAK,UAAU,EAAE,SAAS,MAAM,KAAK,cAAc,EAAE;EACzE,KAAK,6BACD,OAAO,GAAG,MAAM,KAAK,UAAU,EAAE,SAAS,MAAM,KAAK,2BAA2B,EAAE;EACtF,KAAK,MACD,OAAO,GAAG,MAAM,KAAK,UAAU,EAAE,yBAAyB,MAAM,KAAK,IAAI,EAAE;EAC/E,KAAK,mBACD,OAAO,GAAG,MAAM,KAAK,UAAU,EAAE,oBAAoB,MAAM,KAAK,aAAa,EAAE,QAAQ,MAAM,KAAK,sBAAoB;CAC9H;AACJ"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { w as wantsHelp, x as parseCommandArgs } from "./project-CasK56vN.js";
|
|
2
|
+
import { i as refuseMissingCollectionsPath, t as COLLECTIONS_FLAG_HELP } from "./path-flags-DNvtEi2-.js";
|
|
3
|
+
import { collectionsDirArgs } from "./collections-dir-DlvDhime.js";
|
|
4
|
+
import { DEV_DATABASE_KIND_ENV, managedNotices, prepareDatabaseEnv } from "./prepare-CTw9NEkh.js";
|
|
5
|
+
import { absolutizeLocalPathArgs, ensureDockerDatabase, n as argsFromCommand, resolveDriverCli, spawnDriverCli, t as reportSpawnFailure } from "./db-KzlqddGD.js";
|
|
5
6
|
import chalk from "chalk";
|
|
6
7
|
import path from "path";
|
|
7
8
|
//#region src/commands/console.ts
|
|
@@ -89,7 +90,12 @@ async function consoleCommand(rawArgs) {
|
|
|
89
90
|
Object.assign(resolved.env, prepared.env);
|
|
90
91
|
resolved.env[DEV_DATABASE_KIND_ENV] = prepared.database.kind;
|
|
91
92
|
for (const line of managedNotices(prepared)) say(line);
|
|
92
|
-
const
|
|
93
|
+
const typedArgs = absolutizeLocalPathArgs(argsFromCommand(rawArgs, "console"), process.cwd());
|
|
94
|
+
const childArgs = [
|
|
95
|
+
...typedArgs,
|
|
96
|
+
...collectionsDirArgs(projectRoot, typedArgs),
|
|
97
|
+
`--history=${consoleHistoryPath(projectRoot)}`
|
|
98
|
+
];
|
|
93
99
|
try {
|
|
94
100
|
await spawnDriverCli(resolved, childArgs);
|
|
95
101
|
} catch (error) {
|
|
@@ -100,4 +106,4 @@ async function consoleCommand(rawArgs) {
|
|
|
100
106
|
//#endregion
|
|
101
107
|
export { consoleCommand };
|
|
102
108
|
|
|
103
|
-
//# sourceMappingURL=console-
|
|
109
|
+
//# sourceMappingURL=console-BXB6-8GT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console-BXB6-8GT.js","names":[],"sources":["../src/commands/console.ts"],"sourcesContent":["/**\n * CLI command: rebase console\n *\n * A Node REPL with the project open — `rebase` (what `openRebase` from\n * `@rebasepro/server-postgres` returns: `dataAsAdmin`, `sql`, `withAuth`) and\n * `collections` in scope — or, with `--eval`, one piece of code run and its\n * result printed as JSON.\n *\n * Resolved like `rebase db push`: the same project and `.env`, the same\n * database (the managed one started if that is what the project uses), the\n * same `--collections` loader — the driver's, spawned in `backend/`. Opening\n * the database changes nothing in it.\n */\nimport chalk from \"chalk\";\nimport path from \"path\";\nimport { parseCommandArgs, wantsHelp } from \"../utils/args\";\nimport { argsFromCommand } from \"../utils/command-words\";\nimport { COLLECTIONS_FLAG_HELP, refuseMissingCollectionsPath } from \"../utils/path-flags\";\nimport { collectionsDirArgs } from \"../utils/collections-dir\";\nimport { reportSpawnFailure } from \"../utils/spawn-error\";\nimport { DEV_DATABASE_KIND_ENV, managedNotices, prepareDatabaseEnv } from \"../dev-db/prepare\";\nimport { absolutizeLocalPathArgs, ensureDockerDatabase, resolveDriverCli, spawnDriverCli } from \"./db\";\n\nexport const CONSOLE_FLAGS = {\n \"--eval\": String,\n \"-e\": \"--eval\",\n \"--collections\": String,\n \"-c\": \"--collections\",\n \"--database-url\": String,\n \"--docker\": Boolean\n} as const;\n\n/** What each long flag above does, for the Options block. */\nconst CONSOLE_FLAG_HELP: Record<string, string> = {\n \"--eval\": \"Run this code instead of the REPL, print its awaited result as JSON, and exit 1 if it throws\",\n \"--collections\": COLLECTIONS_FLAG_HELP,\n \"--database-url\": \"Open this database instead of the project's\",\n \"--docker\": \"Use the database from docker compose, starting it if needed\"\n};\n\n/** Where the REPL keeps its history: the project's own `.rebase/`, which the scaffold ignores. */\nexport function consoleHistoryPath(projectRoot: string): string {\n return path.join(projectRoot, \".rebase\", \"console_history\");\n}\n\nfunction flagLabel(flag: string): string {\n const aliases = Object.entries(CONSOLE_FLAGS)\n .filter(([, target]) => target === flag)\n .map(([alias]) => alias);\n return [flag, ...aliases].join(\", \");\n}\n\nexport function printConsoleHelp(): void {\n console.log(`\n${chalk.bold(\"rebase console\")} — Explore the project's data from a REPL\n\n${chalk.green.bold(\"Usage\")}\n rebase console [options]\n\n${chalk.green.bold(\"Options\")}\n${Object.keys(CONSOLE_FLAG_HELP)\n .map(flag => ` ${chalk.blue(flagLabel(flag).padEnd(22))} ${CONSOLE_FLAG_HELP[flag]}`)\n .join(\"\\n\")}\n\nIn scope:\n rebase dataAsAdmin, sql(query, { params }), withAuth(user) → { data }, close()\n collections the project's collections\n\nTop-level await works. Opening the database changes nothing in it: no table,\nrole or trigger is created. withAuth runs as the user under row-level security.\n\n${chalk.green.bold(\"Examples\")}\n rebase console\n rebase console -e \"rebase.dataAsAdmin.posts.find({ limit: 5 })\"\n rebase console -e \"(await rebase.withAuth({ uid: 'u1', roles: ['user'] })).data.posts.find()\"\n rebase console -e \"rebase.sql('select count(*) from posts')\"\n`);\n}\n\nexport async function consoleCommand(rawArgs: string[]): Promise<void> {\n if (wantsHelp(rawArgs)) {\n printConsoleHelp();\n return;\n }\n\n // Strictly, before the line is relayed: the driver would otherwise be the\n // first to see a mistyped flag, after a database had been started for it.\n const { flags } = parseCommandArgs({\n spec: CONSOLE_FLAGS,\n rawArgs,\n commandWords: 1,\n command: \"console\",\n maxPositionals: 0\n });\n\n const resolved = await resolveDriverCli();\n const { projectRoot, backendDir } = resolved;\n refuseMissingCollectionsPath(rawArgs, process.cwd(), backendDir, \"console\");\n await ensureDockerDatabase(projectRoot, rawArgs);\n\n // With --eval, stdout is the result and nothing else, so it can be piped\n // into `jq`; piped into the REPL, it is the REPL's answers. Either way what\n // the database resolution has to say goes to stderr.\n const say = flags[\"--eval\"] === undefined && process.stdin.isTTY\n ? (line: string) => console.log(chalk.gray(` ${line}`))\n : (line: string) => console.error(chalk.gray(` ${line}`));\n const prepared = await prepareDatabaseEnv(projectRoot, {\n flagUrl: flags[\"--database-url\"] ?? null,\n flagDocker: flags[\"--docker\"] === true,\n onProgress: say\n });\n Object.assign(resolved.env, prepared.env);\n // The database this run resolved, flags included, so the driver words a\n // failure to open it for that one — a managed database that has no free\n // connection is not \"is your Postgres running?\".\n resolved.env[DEV_DATABASE_KIND_ENV] = prepared.database.kind;\n for (const line of managedNotices(prepared)) say(line);\n\n const typedArgs = absolutizeLocalPathArgs(argsFromCommand(rawArgs, \"console\"), process.cwd());\n const childArgs = [\n ...typedArgs,\n ...collectionsDirArgs(projectRoot, typedArgs),\n `--history=${consoleHistoryPath(projectRoot)}`\n ];\n\n try {\n await spawnDriverCli(resolved, childArgs);\n } catch (error) {\n // A child that exited non-zero has already said why, on the terminal it\n // shares — an `--eval` that threw, a database that refused.\n reportSpawnFailure(error);\n process.exit(1);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuBA,IAAa,gBAAgB;CACzB,UAAU;CACV,MAAM;CACN,iBAAiB;C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