@odla-ai/cli 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  exitCodeFor,
4
4
  runCli
5
- } from "./chunk-DINDRUDA.js";
5
+ } from "./chunk-RZDRUVBT.js";
6
6
 
7
7
  // src/bin.ts
8
8
  runCli().catch((err) => {
@@ -7367,6 +7367,7 @@ function chooseIdMode(options, rows) {
7367
7367
  async function appImport(options) {
7368
7368
  const cfg = await loadProjectConfig(options.configPath);
7369
7369
  const out = options.stdout ?? console;
7370
+ const say = options.json ? (line) => out.error(line) : (line) => out.log(line);
7370
7371
  const doFetch = options.fetch ?? fetch;
7371
7372
  const { tenant } = resolveTenant(cfg, options.env);
7372
7373
  const text = options.file === "-" ? (options.readStdin ?? (() => readFileSync7(0, "utf8")))() : readFileSync7(options.file, "utf8");
@@ -7388,10 +7389,10 @@ ${detail}${more}`);
7388
7389
  }
7389
7390
  const chunks = planImportChunks(ops);
7390
7391
  const result = { tenant, rows: ops.length, chunks: chunks.length, committed: 0, duplicate: 0, txIds: [], ignored };
7391
- if (ignored.length > 0) out.log(`ignoring server-maintained field(s): ${ignored.join(", ")} \u2014 odla-db stamps these on write`);
7392
+ if (ignored.length > 0) say(`ignoring server-maintained field(s): ${ignored.join(", ")} \u2014 odla-db stamps these on write`);
7392
7393
  if (options.dryRun || options.yes !== true) {
7393
7394
  const why = options.dryRun ? "--dry-run" : "no --yes";
7394
- out.log(`${tenant}: would upsert ${ops.length} row(s) across ${chunks.length} transaction(s) \u2014 nothing written (${why})`);
7395
+ say(`${tenant}: would upsert ${ops.length} row(s) across ${chunks.length} transaction(s) \u2014 nothing written (${why})`);
7395
7396
  if (options.json) out.log(JSON.stringify(result, null, 2));
7396
7397
  return result;
7397
7398
  }
@@ -7600,6 +7601,7 @@ function printPlan(out, verb, pre, opts) {
7600
7601
  async function appTransfer(options) {
7601
7602
  const cfg = await loadProjectConfig(options.configPath);
7602
7603
  const out = options.stdout ?? console;
7604
+ const say = options.json ? (line) => out.error(line) : (line) => out.log(line);
7603
7605
  const doFetch = options.fetch ?? fetch;
7604
7606
  const tenants = bothTenants(cfg);
7605
7607
  const route2 = endpointsFor(options.verb, tenants);
@@ -7620,7 +7622,7 @@ async function appTransfer(options) {
7620
7622
  throw new Error(`pre-flight failed${pre.body.error?.code ? ` (${pre.body.error.code})` : ""}: ${pre.body.error?.message ?? pre.status}`);
7621
7623
  }
7622
7624
  const plan = pre.body;
7623
- printPlan(out, options.verb, plan, options);
7625
+ printPlan({ log: say }, options.verb, plan, options);
7624
7626
  if (options.verb === "go-live" && !plan.targetEmpty) {
7625
7627
  throw new Error(
7626
7628
  `${route2.target} already has data \u2014 go-live has already happened. Use \`odla-ai app promote --yes\` to push schema and rules, or \`odla-ai app refresh-sandbox --yes\` to pull live back down.`
@@ -7628,7 +7630,7 @@ async function appTransfer(options) {
7628
7630
  }
7629
7631
  if (plan.blockers.length > 0) throw new Error(`cannot ${options.verb}: ${plan.blockers.map((b) => b.message).join("; ")}`);
7630
7632
  if (options.dryRun || options.yes !== true) {
7631
- out.log(`nothing written (${options.dryRun ? "--dry-run" : "no --yes"})`);
7633
+ say(`nothing written (${options.dryRun ? "--dry-run" : "no --yes"})`);
7632
7634
  if (options.json) out.log(JSON.stringify(plan, null, 2));
7633
7635
  return { ok: true, plan };
7634
7636
  }
@@ -7642,7 +7644,7 @@ async function appTransfer(options) {
7642
7644
  );
7643
7645
  if (res2.status !== 200) throw new Error(`promote failed${res2.body.error?.code ? ` (${res2.body.error.code})` : ""}: ${res2.body.error?.message ?? res2.status}`);
7644
7646
  if (options.json) out.log(JSON.stringify(res2.body, null, 2));
7645
- else out.log(`${route2.target}: promoted ${(res2.body.applied ?? []).join(", ")}`);
7647
+ else say(`${route2.target}: promoted ${(res2.body.applied ?? []).join(", ")}`);
7646
7648
  return { ok: true, plan, result: res2.body };
7647
7649
  }
7648
7650
  const res = await api(
@@ -7661,7 +7663,7 @@ async function appTransfer(options) {
7661
7663
  doFetch
7662
7664
  );
7663
7665
  if (res.status !== 200) throw new Error(`${options.verb} failed${res.body.error?.code ? ` (${res.body.error.code})` : ""}: ${res.body.error?.message ?? res.status}`);
7664
- out.log(`${route2.target}: replaced from ${route2.source} (tx ${res.body.destination?.maxTx}, epoch ${res.body.destination?.epoch}) \u2014 connected clients resync automatically`);
7666
+ say(`${route2.target}: replaced from ${route2.source} (tx ${res.body.destination?.maxTx}, epoch ${res.body.destination?.epoch}) \u2014 connected clients resync automatically`);
7665
7667
  if (options.includeFiles) await copyFiles(cfg, token, route2, doFetch, out);
7666
7668
  if (options.json) out.log(JSON.stringify(res.body, null, 2));
7667
7669
  return { ok: true, plan, result: res.body };
@@ -9747,4 +9749,4 @@ export {
9747
9749
  exitCodeFor,
9748
9750
  runCli
9749
9751
  };
9750
- //# sourceMappingURL=chunk-DINDRUDA.js.map
9752
+ //# sourceMappingURL=chunk-RZDRUVBT.js.map