@rebasepro/cli 0.34.0 → 0.34.1

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.
Files changed (130) hide show
  1. package/dist/{agent-setup-CGeAuP0Q.js → agent-setup-kjdKozkF.js} +3 -3
  2. package/dist/{agent-setup-CGeAuP0Q.js.map → agent-setup-kjdKozkF.js.map} +1 -1
  3. package/dist/{api-zx1wSK5a.js → api-CQh_qTyQ.js} +2 -2
  4. package/dist/{api-zx1wSK5a.js.map → api-CQh_qTyQ.js.map} +1 -1
  5. package/dist/{api-keys-DaWN8dyI.js → api-keys-CG2IpknI.js} +5 -5
  6. package/dist/{api-keys-DaWN8dyI.js.map → api-keys-CG2IpknI.js.map} +1 -1
  7. package/dist/{apps-D6vtDrkJ.js → apps-DaaWvv3o.js} +6 -6
  8. package/dist/{apps-D6vtDrkJ.js.map → apps-DaaWvv3o.js.map} +1 -1
  9. package/dist/{atlas-dev-database-D6h65f2x.js → atlas-dev-database-BiDMUr9W.js} +2 -2
  10. package/dist/{atlas-dev-database-D6h65f2x.js.map → atlas-dev-database-BiDMUr9W.js.map} +1 -1
  11. package/dist/{auth-DY7kU0z-.js → auth-bi8x2YX1.js} +12 -12
  12. package/dist/{auth-DY7kU0z-.js.map → auth-bi8x2YX1.js.map} +1 -1
  13. package/dist/{auth-session-DCG96UGH.js → auth-session-BVoxE5tp.js} +4 -4
  14. package/dist/{auth-session-DCG96UGH.js.map → auth-session-BVoxE5tp.js.map} +1 -1
  15. package/dist/{backend-guard-Cf8eMK_f.js → backend-guard--SW3MTSh.js} +2 -2
  16. package/dist/{backend-guard-Cf8eMK_f.js.map → backend-guard--SW3MTSh.js.map} +1 -1
  17. package/dist/{branch-pointer-BJOF2Ubv.js → branch-pointer-BjKUoENm.js} +1 -1
  18. package/dist/{build-D0egCUfU.js → build-D-0VCmbU.js} +11 -11
  19. package/dist/build-D-0VCmbU.js.map +1 -0
  20. package/dist/{bundle-DhdhtD8K.js → bundle-BDTVS9XE.js} +6 -6
  21. package/dist/{bundle-DhdhtD8K.js.map → bundle-BDTVS9XE.js.map} +1 -1
  22. package/dist/{cloud-DOR7bxDw.js → cloud-CR6Hps3B.js} +12 -12
  23. package/dist/{cloud-DOR7bxDw.js.map → cloud-CR6Hps3B.js.map} +1 -1
  24. package/dist/{cms-directories-BaV-Is9a.js → cms-directories-AGHvFwH7.js} +2 -2
  25. package/dist/{cms-directories-BaV-Is9a.js.map → cms-directories-AGHvFwH7.js.map} +1 -1
  26. package/dist/{command-BzSP5gBh.js → command-nWgittn1.js} +3 -3
  27. package/dist/{command-BzSP5gBh.js.map → command-nWgittn1.js.map} +1 -1
  28. package/dist/commands/build.d.ts +2 -1
  29. package/dist/{consent-UV6ObCME.js → consent-C8_Ik_GK.js} +3 -3
  30. package/dist/{consent-UV6ObCME.js.map → consent-C8_Ik_GK.js.map} +1 -1
  31. package/dist/{console-BVoYOLAO.js → console-BBGRHOFg.js} +5 -5
  32. package/dist/{console-BVoYOLAO.js.map → console-BBGRHOFg.js.map} +1 -1
  33. package/dist/{context-xt20FMFA.js → context-C9lz1vTS.js} +2 -2
  34. package/dist/{context-xt20FMFA.js.map → context-C9lz1vTS.js.map} +1 -1
  35. package/dist/{cron-CJ6Xk42E.js → cron-BzzNxkBH.js} +3 -3
  36. package/dist/{cron-CJ6Xk42E.js.map → cron-BzzNxkBH.js.map} +1 -1
  37. package/dist/{cron-BGkXIB1N.js → cron-DuZ3Svjq.js} +4 -4
  38. package/dist/{cron-BGkXIB1N.js.map → cron-DuZ3Svjq.js.map} +1 -1
  39. package/dist/{daemon-D5gdG7gx.js → daemon-BCBMn8hE.js} +2 -2
  40. package/dist/{daemon-D5gdG7gx.js.map → daemon-BCBMn8hE.js.map} +1 -1
  41. package/dist/{data-BpkvtCUe.js → data-1eipHbxJ.js} +3 -3
  42. package/dist/{data-BpkvtCUe.js.map → data-1eipHbxJ.js.map} +1 -1
  43. package/dist/{db-D_iF4E-v.js → db-DAotpOxs.js} +28 -28
  44. package/dist/{db-D_iF4E-v.js.map → db-DAotpOxs.js.map} +1 -1
  45. package/dist/{debug-C7Ss34XB.js → debug-CkiOcfsU.js} +2 -2
  46. package/dist/{debug-C7Ss34XB.js.map → debug-CkiOcfsU.js.map} +1 -1
  47. package/dist/{derive-ChP6vgfi.js → derive-BU5kvcOP.js} +2 -2
  48. package/dist/{derive-ChP6vgfi.js.map → derive-BU5kvcOP.js.map} +1 -1
  49. package/dist/{dev-C7n36E6f.js → dev-Ce9PVQS8.js} +13 -13
  50. package/dist/{dev-C7n36E6f.js.map → dev-Ce9PVQS8.js.map} +1 -1
  51. package/dist/{dev-preflight-BMOf2N6r.js → dev-preflight-DROlafgr.js} +2 -2
  52. package/dist/{dev-preflight-BMOf2N6r.js.map → dev-preflight-DROlafgr.js.map} +1 -1
  53. package/dist/{dev-server-2XHSHM_q.js → dev-server-dsabI0UT.js} +2 -2
  54. package/dist/{dev-server-2XHSHM_q.js.map → dev-server-dsabI0UT.js.map} +1 -1
  55. package/dist/{doctor-D0o54XSQ.js → doctor-Cdu3Llrw.js} +7 -7
  56. package/dist/{doctor-D0o54XSQ.js.map → doctor-Cdu3Llrw.js.map} +1 -1
  57. package/dist/{eject-DK_M9kor.js → eject-Dy-qRYhW.js} +3 -3
  58. package/dist/{eject-DK_M9kor.js.map → eject-Dy-qRYhW.js.map} +1 -1
  59. package/dist/{fold-static-DTpaqbB0.js → fold-static-DzV3EJZm.js} +4 -4
  60. package/dist/{fold-static-DTpaqbB0.js.map → fold-static-DzV3EJZm.js.map} +1 -1
  61. package/dist/{functions-DLuuldt2.js → functions-BCEJnISw.js} +4 -4
  62. package/dist/{functions-DLuuldt2.js.map → functions-BCEJnISw.js.map} +1 -1
  63. package/dist/{generate-view-BMaLQm8H.js → generate-view-CZ0SmsJc.js} +4 -4
  64. package/dist/{generate-view-BMaLQm8H.js.map → generate-view-CZ0SmsJc.js.map} +1 -1
  65. package/dist/{generate_sdk-UT1lwwRT.js → generate_sdk-MAbUUZoK.js} +6 -6
  66. package/dist/{generate_sdk-UT1lwwRT.js.map → generate_sdk-MAbUUZoK.js.map} +1 -1
  67. package/dist/index.es.js +54 -54
  68. package/dist/{init-u5Xmr1Ct.js → init-BctfWO3w.js} +44 -24
  69. package/dist/init-BctfWO3w.js.map +1 -0
  70. package/dist/last-dev-database-w-r9T5Xm.js +2 -0
  71. package/dist/{legacy-layout-DI2VeQSV.js → legacy-layout-CiXWalS6.js} +2 -2
  72. package/dist/{legacy-layout-DI2VeQSV.js.map → legacy-layout-CiXWalS6.js.map} +1 -1
  73. package/dist/{logs-DBYRSs6W.js → logs-B_mS4gCn.js} +4 -4
  74. package/dist/{logs-DBYRSs6W.js.map → logs-B_mS4gCn.js.map} +1 -1
  75. package/dist/{manifest-RjqxfCpb.js → manifest-D6B4LA8x.js} +3 -3
  76. package/dist/{manifest-RjqxfCpb.js.map → manifest-D6B4LA8x.js.map} +1 -1
  77. package/dist/{migrate-Cw1FkvUK.js → migrate-DdcgLMyL.js} +3 -3
  78. package/dist/{migrate-Cw1FkvUK.js.map → migrate-DdcgLMyL.js.map} +1 -1
  79. package/dist/{normalize-imports-E4yA1HfW.js → normalize-imports-CVjOssZ2.js} +2 -2
  80. package/dist/{normalize-imports-E4yA1HfW.js.map → normalize-imports-CVjOssZ2.js.map} +1 -1
  81. package/dist/{package-manager-DSEOwTqM.js → package-manager-DTNNGHyK.js} +29 -12
  82. package/dist/package-manager-DTNNGHyK.js.map +1 -0
  83. package/dist/{path-flags-ekLdkbra.js → path-flags-B7Ydt5nv.js} +2 -2
  84. package/dist/{path-flags-ekLdkbra.js.map → path-flags-B7Ydt5nv.js.map} +1 -1
  85. package/dist/{prepare-BaJe0Zik.js → prepare-CFpYl1Nt.js} +4 -4
  86. package/dist/{prepare-BaJe0Zik.js.map → prepare-CFpYl1Nt.js.map} +1 -1
  87. package/dist/{project-DALmhb5R.js → project-CQ5nKddJ.js} +2 -2
  88. package/dist/{project-DALmhb5R.js.map → project-CQ5nKddJ.js.map} +1 -1
  89. package/dist/{project-command-7EGMemEy.js → project-command-5wM_bJQt.js} +7 -7
  90. package/dist/{project-command-7EGMemEy.js.map → project-command-5wM_bJQt.js.map} +1 -1
  91. package/dist/resolve-GDRel2ne.js +2 -0
  92. package/dist/{resources-CE6BeL94.js → resources-ecA0MEjy.js} +4 -4
  93. package/dist/{resources-CE6BeL94.js.map → resources-ecA0MEjy.js.map} +1 -1
  94. package/dist/{rls-BxWLfEKl.js → rls-B4zGbTKY.js} +3 -3
  95. package/dist/{rls-BxWLfEKl.js.map → rls-B4zGbTKY.js.map} +1 -1
  96. package/dist/{schema-D8xFSBbN.js → schema-CWzzn0cY.js} +11 -11
  97. package/dist/{schema-D8xFSBbN.js.map → schema-CWzzn0cY.js.map} +1 -1
  98. package/dist/{schema-dir-ChcYfWjP.js → schema-dir-Dd1Pzqq5.js} +2 -2
  99. package/dist/{schema-dir-ChcYfWjP.js.map → schema-dir-Dd1Pzqq5.js.map} +1 -1
  100. package/dist/schema-reconcile-DGEMmYJI.js +2 -0
  101. package/dist/{schema-show-C7bY7SgE.js → schema-show-DwYtOp4S.js} +5 -5
  102. package/dist/{schema-show-C7bY7SgE.js.map → schema-show-DwYtOp4S.js.map} +1 -1
  103. package/dist/{skills-C8WdRTFg.js → skills-CWmBTCRW.js} +5 -5
  104. package/dist/{skills-C8WdRTFg.js.map → skills-CWmBTCRW.js.map} +1 -1
  105. package/dist/{start-CN_9C205.js → start-4uhCu_md.js} +6 -6
  106. package/dist/{start-CN_9C205.js.map → start-4uhCu_md.js.map} +1 -1
  107. package/dist/{status-HWlZbY1E.js → status-CVEzoSwX.js} +7 -7
  108. package/dist/{status-HWlZbY1E.js.map → status-CVEzoSwX.js.map} +1 -1
  109. package/dist/{storage-DBE8lgH-.js → storage-Dqf5tyhs.js} +9 -9
  110. package/dist/{storage-DBE8lgH-.js.map → storage-Dqf5tyhs.js.map} +1 -1
  111. package/dist/{storage-objects-ljDmtuH7.js → storage-objects-DbFsemMV.js} +3 -3
  112. package/dist/{storage-objects-ljDmtuH7.js.map → storage-objects-DbFsemMV.js.map} +1 -1
  113. package/dist/{telemetry-DZU2-NCm.js → telemetry-B5RSeQIc.js} +3 -3
  114. package/dist/{telemetry-DZU2-NCm.js.map → telemetry-B5RSeQIc.js.map} +1 -1
  115. package/dist/{telemetry-EVtASbKb.js → telemetry-CJbrRuG3.js} +2 -2
  116. package/dist/{telemetry-EVtASbKb.js.map → telemetry-CJbrRuG3.js.map} +1 -1
  117. package/dist/{upgrade-ZASvgxWM.js → upgrade-CepjhRrz.js} +6 -6
  118. package/dist/{upgrade-ZASvgxWM.js.map → upgrade-CepjhRrz.js.map} +1 -1
  119. package/dist/{users-DrJEtL9k.js → users-Cx5HuaTn.js} +3 -3
  120. package/dist/{users-DrJEtL9k.js.map → users-Cx5HuaTn.js.map} +1 -1
  121. package/dist/utils/package-manager.d.ts +12 -13
  122. package/dist/{verify-BdeqNb-V.js → verify-D-1y5HQS.js} +8 -8
  123. package/dist/{verify-BdeqNb-V.js.map → verify-D-1y5HQS.js.map} +1 -1
  124. package/package.json +10 -10
  125. package/dist/build-D0egCUfU.js.map +0 -1
  126. package/dist/init-u5Xmr1Ct.js.map +0 -1
  127. package/dist/last-dev-database-CBVkEUEl.js +0 -2
  128. package/dist/package-manager-DSEOwTqM.js.map +0 -1
  129. package/dist/resolve-C36px9tR.js +0 -2
  130. package/dist/schema-reconcile-D_wvZY91.js +0 -2
@@ -1,4 +1,5 @@
1
1
  import type { RebaseAppConfig } from "@rebasepro/types";
2
+ import { type PMCommands } from "../utils/package-manager.js";
2
3
  /**
3
4
  * The two commands that turn a custom-runtime app into an image.
4
5
  *
@@ -24,7 +25,7 @@ import type { RebaseAppConfig } from "@rebasepro/types";
24
25
  export declare function dockerBuildHint(projectRoot: string, name: string, app: {
25
26
  dockerfile?: string;
26
27
  context?: string;
27
- }): string[];
28
+ }, pm?: PMCommands): string[];
28
29
  export declare function buildCommand(rawArgs?: string[]): Promise<void>;
29
30
  /**
30
31
  * Build a static app and package it into a static bundle.
@@ -1,4 +1,4 @@
1
- import { a as setConsent, c as buildEvent, f as readConfig, o as suppressionReason } from "./telemetry-EVtASbKb.js";
1
+ import { a as setConsent, c as buildEvent, f as readConfig, o as suppressionReason } from "./telemetry-CJbrRuG3.js";
2
2
  import chalk from "chalk";
3
3
  import inquirer from "inquirer";
4
4
  //#region src/telemetry/consent.ts
@@ -46,7 +46,7 @@ async function promptForConsent(options = {}) {
46
46
  type: "confirm",
47
47
  name: "accepted",
48
48
  message: "Share anonymous usage data?",
49
- default: false
49
+ default: true
50
50
  }]);
51
51
  setConsent(Boolean(accepted));
52
52
  console.log(accepted ? chalk.green(" Thank you — sharing enabled.") : chalk.gray(" Nothing will be sent." + (options.reAskDeclined ? " You will be asked again the next time you scaffold a project." : " You will not be asked again.")));
@@ -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-UV6ObCME.js.map
76
+ //# sourceMappingURL=consent-C8_Ik_GK.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"consent-UV6ObCME.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;CACf,CAAC;CACD,OAAO,KAAK,UAAU,SAAS,MAAM,CAAC;AAC1C;;;;;;;;AASA,eAAsB,iBAAiB,UAAyB,CAAC,GAAqB;CAClF,IAAI,CAAC,aAAa,QAAQ,KAAK,OAAO,GAAG,OAAO;CAIhD,MAAM,cAAc,kBAAkB,QAAQ,GAAG,MAAM;CAEvD,IAAI;EACA,QAAQ,IAAI,EAAE;EACd,QAAQ,IAAI,MAAM,KAAK,sBAAsB,CAAC;EAC9C,QAAQ,IAAI,EAAE;EACd,QAAQ,IAAI,MAAM,KAAK,sEAAsE,CAAC;EAC9F,QAAQ,IAAI,MAAM,KAAK,2EAA2E,CAAC;EACnG,QAAQ,IAAI,MAAM,KAAK,0EAA0E,CAAC;EAClG,QAAQ,IAAI,MAAM,KAAK,mBAAmB,CAAC;EAC3C,QAAQ,IAAI,EAAE;EACd,QAAQ,IAAI,MAAM,KAAK,kCAAkC,MAAM,KAAK,uBAAuB,EAAE,mBAAmB,CAAC;EACjH,QAAQ,IAAI,MAAM,KAAK,mBAAmB,MAAM,KAAK,0BAA0B,EAAE,EAAE,CAAC;EACpF,IAAI,aAAa;GACb,QAAQ,IAAI,EAAE;GACd,QAAQ,IAAI,MAAM,KAAK,+DAA+D,CAAC;EAC3F;EACA,QAAQ,IAAI,EAAE;EAEd,MAAM,EAAE,aAAa,MAAM,SAAS,OAAO,CACvC;GACI,MAAM;GACN,MAAM;GACN,SAAS;GAMT,SAAS;EACb,CACJ,CAA0C;EAE1C,WAAW,QAAQ,QAAQ,CAAC;EAE5B,QAAQ,IACJ,WACM,MAAM,MAAM,gCAAgC,IAC5C,MAAM,KACJ,6BACG,QAAQ,gBACL,mEACA,gCACV,CACR;EACA,QAAQ,IAAI,EAAE;EACd,OAAO,QAAQ,QAAQ;CAC3B,QAAQ;EAKJ,OAAO;CACX;AACJ;;AAGA,SAAgB,cAAc,MAAyB,QAAQ,KAAa;CACxE,MAAM,SAAS,kBAAkB,GAAG;CACpC,MAAM,SAAS,WAAW;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
+ {"version":3,"file":"consent-C8_Ik_GK.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 yes. The question is still asked, with the\n // payload described above it, and nothing is sent before an\n // answer; `n` is one keystroke, and `rebase telemetry disable`\n // is the same answer later. DO_NOT_TRACK, CI and a project's\n // `\"telemetry\": false` still suppress the prompt entirely.\n default: true\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;CACf,CAAC;CACD,OAAO,KAAK,UAAU,SAAS,MAAM,CAAC;AAC1C;;;;;;;;AASA,eAAsB,iBAAiB,UAAyB,CAAC,GAAqB;CAClF,IAAI,CAAC,aAAa,QAAQ,KAAK,OAAO,GAAG,OAAO;CAIhD,MAAM,cAAc,kBAAkB,QAAQ,GAAG,MAAM;CAEvD,IAAI;EACA,QAAQ,IAAI,EAAE;EACd,QAAQ,IAAI,MAAM,KAAK,sBAAsB,CAAC;EAC9C,QAAQ,IAAI,EAAE;EACd,QAAQ,IAAI,MAAM,KAAK,sEAAsE,CAAC;EAC9F,QAAQ,IAAI,MAAM,KAAK,2EAA2E,CAAC;EACnG,QAAQ,IAAI,MAAM,KAAK,0EAA0E,CAAC;EAClG,QAAQ,IAAI,MAAM,KAAK,mBAAmB,CAAC;EAC3C,QAAQ,IAAI,EAAE;EACd,QAAQ,IAAI,MAAM,KAAK,kCAAkC,MAAM,KAAK,uBAAuB,EAAE,mBAAmB,CAAC;EACjH,QAAQ,IAAI,MAAM,KAAK,mBAAmB,MAAM,KAAK,0BAA0B,EAAE,EAAE,CAAC;EACpF,IAAI,aAAa;GACb,QAAQ,IAAI,EAAE;GACd,QAAQ,IAAI,MAAM,KAAK,+DAA+D,CAAC;EAC3F;EACA,QAAQ,IAAI,EAAE;EAEd,MAAM,EAAE,aAAa,MAAM,SAAS,OAAO,CACvC;GACI,MAAM;GACN,MAAM;GACN,SAAS;GAMT,SAAS;EACb,CACJ,CAA0C;EAE1C,WAAW,QAAQ,QAAQ,CAAC;EAE5B,QAAQ,IACJ,WACM,MAAM,MAAM,gCAAgC,IAC5C,MAAM,KACJ,6BACG,QAAQ,gBACL,mEACA,gCACV,CACR;EACA,QAAQ,IAAI,EAAE;EACd,OAAO,QAAQ,QAAQ;CAC3B,QAAQ;EAKJ,OAAO;CACX;AACJ;;AAGA,SAAgB,cAAc,MAAyB,QAAQ,KAAa;CACxE,MAAM,SAAS,kBAAkB,GAAG;CACpC,MAAM,SAAS,WAAW;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,8 +1,8 @@
1
1
  import { a as wantsHelp, n as parseCommandArgs } from "./args-DHyrshtI.js";
2
- import { r as schemaDirArgs } from "./schema-dir-ChcYfWjP.js";
3
- import { a as refuseRemovedCollectionsFlag, i as refuseMissingSchemaDir, n as SCHEMA_DIR_FLAG_HELP } from "./path-flags-ekLdkbra.js";
4
- import { DEV_DATABASE_KIND_ENV, managedNotices, prepareDatabaseEnv } from "./prepare-BaJe0Zik.js";
5
- import { absolutizeLocalPathArgs, ensureDockerDatabase, n as argsFromCommand, resolveDriverCli, spawnDriverCli, t as reportSpawnFailure } from "./db-D_iF4E-v.js";
2
+ import { r as schemaDirArgs } from "./schema-dir-Dd1Pzqq5.js";
3
+ import { a as refuseRemovedCollectionsFlag, i as refuseMissingSchemaDir, n as SCHEMA_DIR_FLAG_HELP } from "./path-flags-B7Ydt5nv.js";
4
+ import { DEV_DATABASE_KIND_ENV, managedNotices, prepareDatabaseEnv } from "./prepare-CFpYl1Nt.js";
5
+ import { absolutizeLocalPathArgs, ensureDockerDatabase, n as argsFromCommand, resolveDriverCli, spawnDriverCli, t as reportSpawnFailure } from "./db-DAotpOxs.js";
6
6
  import chalk from "chalk";
7
7
  import path from "path";
8
8
  //#region src/commands/console.ts
@@ -106,4 +106,4 @@ async function consoleCommand(rawArgs) {
106
106
  //#endregion
107
107
  export { consoleCommand };
108
108
 
109
- //# sourceMappingURL=console-BVoYOLAO.js.map
109
+ //# sourceMappingURL=console-BBGRHOFg.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"console-BVoYOLAO.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 * `tables` 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 `backend/schema` 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 { SCHEMA_DIR_FLAG_HELP, refuseMissingSchemaDir, refuseRemovedCollectionsFlag } from \"../utils/path-flags\";\nimport { schemaDirArgs } from \"../utils/schema-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 \"--schema-dir\": String,\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 \"--schema-dir\": SCHEMA_DIR_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 tables the project's tables, as their descriptors\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 refuseRemovedCollectionsFlag(rawArgs.slice(2), \"console\");\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 refuseMissingSchemaDir(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 ...schemaDirArgs(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,gBAAgB;CAChB,kBAAkB;CAClB,YAAY;AAChB;;AAGA,IAAM,oBAA4C;CAC9C,UAAU;CACV,gBAAgB;CAChB,kBAAkB;CAClB,YAAY;AAChB;;AAGA,SAAgB,mBAAmB,aAA6B;CAC5D,OAAO,KAAK,KAAK,aAAa,WAAW,iBAAiB;AAC9D;AAEA,SAAS,UAAU,MAAsB;CAIrC,OAAO,CAAC,MAAM,GAHE,OAAO,QAAQ,aAAa,CAAC,CACxC,QAAQ,GAAG,YAAY,WAAW,IAAI,CAAC,CACvC,KAAK,CAAC,WAAW,KACL,CAAO,CAAC,CAAC,KAAK,IAAI;AACvC;AAEA,SAAgB,mBAAyB;CACrC,QAAQ,IAAI;EACd,MAAM,KAAK,gBAAgB,EAAE;;EAE7B,MAAM,MAAM,KAAK,OAAO,EAAE;;;EAG1B,MAAM,MAAM,KAAK,SAAS,EAAE;EAC5B,OAAO,KAAK,iBAAiB,CAAC,CACvB,KAAI,SAAQ,KAAK,MAAM,KAAK,UAAU,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,GAAG,kBAAkB,OAAO,CAAC,CACrF,KAAK,IAAI,EAAE;;;;;;;;;EASlB,MAAM,MAAM,KAAK,UAAU,EAAE;;;;;CAK9B;AACD;AAEA,eAAsB,eAAe,SAAkC;CACnE,IAAI,UAAU,OAAO,GAAG;EACpB,iBAAiB;EACjB;CACJ;CAIA,6BAA6B,QAAQ,MAAM,CAAC,GAAG,SAAS;CACxD,MAAM,EAAE,UAAU,iBAAiB;EAC/B,MAAM;EACN;EACA,cAAc;EACd,SAAS;EACT,gBAAgB;CACpB,CAAC;CAED,MAAM,WAAW,MAAM,iBAAiB;CACxC,MAAM,EAAE,aAAa,eAAe;CACpC,uBAAuB,SAAS,QAAQ,IAAI,GAAG,YAAY,SAAS;CACpE,MAAM,qBAAqB,aAAa,OAAO;CAK/C,MAAM,MAAM,MAAM,cAAc,KAAA,KAAa,QAAQ,MAAM,SACpD,SAAiB,QAAQ,IAAI,MAAM,KAAK,KAAK,MAAM,CAAC,KACpD,SAAiB,QAAQ,MAAM,MAAM,KAAK,KAAK,MAAM,CAAC;CAC7D,MAAM,WAAW,MAAM,mBAAmB,aAAa;EACnD,SAAS,MAAM,qBAAqB;EACpC,YAAY,MAAM,gBAAgB;EAClC,YAAY;CAChB,CAAC;CACD,OAAO,OAAO,SAAS,KAAK,SAAS,GAAG;CAIxC,SAAS,IAAI,yBAAyB,SAAS,SAAS;CACxD,KAAK,MAAM,QAAQ,eAAe,QAAQ,GAAG,IAAI,IAAI;CAErD,MAAM,YAAY,wBAAwB,gBAAgB,SAAS,SAAS,GAAG,QAAQ,IAAI,CAAC;CAC5F,MAAM,YAAY;EACd,GAAG;EACH,GAAG,cAAc,aAAa,SAAS;EACvC,aAAa,mBAAmB,WAAW;CAC/C;CAEA,IAAI;EACA,MAAM,eAAe,UAAU,SAAS;CAC5C,SAAS,OAAO;EAGZ,mBAAmB,KAAK;EACxB,QAAQ,KAAK,CAAC;CAClB;AACJ"}
1
+ {"version":3,"file":"console-BBGRHOFg.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 * `tables` 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 `backend/schema` 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 { SCHEMA_DIR_FLAG_HELP, refuseMissingSchemaDir, refuseRemovedCollectionsFlag } from \"../utils/path-flags\";\nimport { schemaDirArgs } from \"../utils/schema-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 \"--schema-dir\": String,\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 \"--schema-dir\": SCHEMA_DIR_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 tables the project's tables, as their descriptors\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 refuseRemovedCollectionsFlag(rawArgs.slice(2), \"console\");\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 refuseMissingSchemaDir(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 ...schemaDirArgs(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,gBAAgB;CAChB,kBAAkB;CAClB,YAAY;AAChB;;AAGA,IAAM,oBAA4C;CAC9C,UAAU;CACV,gBAAgB;CAChB,kBAAkB;CAClB,YAAY;AAChB;;AAGA,SAAgB,mBAAmB,aAA6B;CAC5D,OAAO,KAAK,KAAK,aAAa,WAAW,iBAAiB;AAC9D;AAEA,SAAS,UAAU,MAAsB;CAIrC,OAAO,CAAC,MAAM,GAHE,OAAO,QAAQ,aAAa,CAAC,CACxC,QAAQ,GAAG,YAAY,WAAW,IAAI,CAAC,CACvC,KAAK,CAAC,WAAW,KACL,CAAO,CAAC,CAAC,KAAK,IAAI;AACvC;AAEA,SAAgB,mBAAyB;CACrC,QAAQ,IAAI;EACd,MAAM,KAAK,gBAAgB,EAAE;;EAE7B,MAAM,MAAM,KAAK,OAAO,EAAE;;;EAG1B,MAAM,MAAM,KAAK,SAAS,EAAE;EAC5B,OAAO,KAAK,iBAAiB,CAAC,CACvB,KAAI,SAAQ,KAAK,MAAM,KAAK,UAAU,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,GAAG,kBAAkB,OAAO,CAAC,CACrF,KAAK,IAAI,EAAE;;;;;;;;;EASlB,MAAM,MAAM,KAAK,UAAU,EAAE;;;;;CAK9B;AACD;AAEA,eAAsB,eAAe,SAAkC;CACnE,IAAI,UAAU,OAAO,GAAG;EACpB,iBAAiB;EACjB;CACJ;CAIA,6BAA6B,QAAQ,MAAM,CAAC,GAAG,SAAS;CACxD,MAAM,EAAE,UAAU,iBAAiB;EAC/B,MAAM;EACN;EACA,cAAc;EACd,SAAS;EACT,gBAAgB;CACpB,CAAC;CAED,MAAM,WAAW,MAAM,iBAAiB;CACxC,MAAM,EAAE,aAAa,eAAe;CACpC,uBAAuB,SAAS,QAAQ,IAAI,GAAG,YAAY,SAAS;CACpE,MAAM,qBAAqB,aAAa,OAAO;CAK/C,MAAM,MAAM,MAAM,cAAc,KAAA,KAAa,QAAQ,MAAM,SACpD,SAAiB,QAAQ,IAAI,MAAM,KAAK,KAAK,MAAM,CAAC,KACpD,SAAiB,QAAQ,MAAM,MAAM,KAAK,KAAK,MAAM,CAAC;CAC7D,MAAM,WAAW,MAAM,mBAAmB,aAAa;EACnD,SAAS,MAAM,qBAAqB;EACpC,YAAY,MAAM,gBAAgB;EAClC,YAAY;CAChB,CAAC;CACD,OAAO,OAAO,SAAS,KAAK,SAAS,GAAG;CAIxC,SAAS,IAAI,yBAAyB,SAAS,SAAS;CACxD,KAAK,MAAM,QAAQ,eAAe,QAAQ,GAAG,IAAI,IAAI;CAErD,MAAM,YAAY,wBAAwB,gBAAgB,SAAS,SAAS,GAAG,QAAQ,IAAI,CAAC;CAC5F,MAAM,YAAY;EACd,GAAG;EACH,GAAG,cAAc,aAAa,SAAS;EACvC,aAAa,mBAAmB,WAAW;CAC/C;CAEA,IAAI;EACA,MAAM,eAAe,UAAU,SAAS;CAC5C,SAAS,OAAO;EAGZ,mBAAmB,KAAK;EACxB,QAAQ,KAAK,CAAC;CAClB;AACJ"}
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
2
  import { i as switchOn, n as parseCommandArgs } from "./args-DHyrshtI.js";
3
- import { c as findProjectRoot } from "./project-DALmhb5R.js";
3
+ import { c as findProjectRoot } from "./project-CQ5nKddJ.js";
4
4
  import { t as cliUserAgent } from "./version-ONIeo7jl.js";
5
5
  import chalk from "chalk";
6
6
  import arg from "arg";
@@ -1798,4 +1798,4 @@ function requireCloudRow(row, what) {
1798
1798
  //#endregion
1799
1799
  export { resolveCloudTarget as $, linkedEphemeralGrant as A, projectHost as B, getContextOrg as C, isJsonMode as D, initOutputMode as E, parseCloudArgs as F, reportError as G, readLink as H, printGroupHelp as I, requireInteractive as J, requireClient as K, printJson as L, note as M, noteBlank as N, isKnownControlPlane as O, openUrl as P, requireSessionClient as Q, probeToken as R, freshAccessToken as S, grantProjectOf as T, refuseDirectLink as U, projectLinkPath as V, removeLink as W, requireProject as X, requireKnownAction as Y, requireProjectRef as Z, ephemeralGrantFor as _, isTokenCapability as _t, billingAccountIdOf as a, setCurrentContext as at, fetchTenantBaseDomain as b, scopesForOrgCapabilities as bt, colorStatus as c, warn as ct, createCloudClient as d, ORG_CAPABILITIES as dt, resolveCloudUrl as et, displayProjectRef as f, ORG_CAPABILITY_NAMES as ft, envToken as g, isOrgCapability as gt, emitHelp as h, capabilitiesInScopes as ht, appKeyExpiryNote as i, setContextOrg as it, lookupProjectId as j, keyValues as k, confirmDestructive as l, writeLink as lt, emit as m, TOKEN_CAPABILITY_NAMES as mt, GLOBAL_HELP_FLAGS as n, resolveTimeoutMs as nt, cloudRow as o, storedGrantForLink as ot, dotenvSets as p, TOKEN_CAPABILITIES as pt, requireCloudRow as q, TOKEN_ENV as r, saveEphemeralGrant as rt, cloudRows as s, success as st, GLOBAL_CLOUD_FLAGS as t, resolveProjectRef as tt, context_exports as u, ALWAYS_SCOPES as ut, fail as v, orgCapabilitiesInScopes as vt, grantForLink as w, forgetEphemeralGrant as x, wantsRawError as xt, fetchDeployTargets as y, scopesForCapabilities as yt, projectDotenvSetsAppKey as z };
1800
1800
 
1801
- //# sourceMappingURL=context-xt20FMFA.js.map
1801
+ //# sourceMappingURL=context-C9lz1vTS.js.map