ardent-cli 0.0.15 → 0.0.16

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 (2) hide show
  1. package/dist/index.js +65 -274
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -57,13 +57,6 @@ function getApiUrl() {
57
57
  function getToken() {
58
58
  return getConfig("token") || process.env.ARDENT_TOKEN;
59
59
  }
60
- function getBranches() {
61
- const cached = getCacheEntry("branches");
62
- return cached?.data || [];
63
- }
64
- function getBranchByName(name) {
65
- return getBranches().find((branch) => branch.name === name);
66
- }
67
60
  function setCacheEntry(key, data) {
68
61
  const config = loadConfig();
69
62
  if (!config.cache) config.cache = {};
@@ -188,9 +181,9 @@ var ApiClient = class {
188
181
  getHeaders() {
189
182
  const token = getToken();
190
183
  if (!token) {
191
- const green3 = "\x1B[32m";
192
- const reset3 = "\x1B[0m";
193
- console.error(`\u2717 Not authenticated. Run: ${green3}ardent login${reset3}`);
184
+ const green2 = "\x1B[32m";
185
+ const reset2 = "\x1B[0m";
186
+ console.error(`\u2717 Not authenticated. Run: ${green2}ardent login${reset2}`);
194
187
  process.exit(1);
195
188
  }
196
189
  return {
@@ -421,22 +414,22 @@ async function listAction() {
421
414
  return;
422
415
  }
423
416
  const current = getCurrentBranch();
424
- const green3 = "\x1B[32m";
425
- const dim3 = "\x1B[2m";
426
- const reset3 = "\x1B[0m";
417
+ const green2 = "\x1B[32m";
418
+ const dim2 = "\x1B[2m";
419
+ const reset2 = "\x1B[0m";
427
420
  console.log("Branches:\n");
428
421
  for (const branch of branches) {
429
422
  const isCurrent = branch.name === current;
430
- const icon = branch.status === "active" || branch.status === "active_degraded" ? "\u25CF" : "\u25CB";
423
+ const icon = branch.status === "active" ? "\u25CF" : "\u25CB";
431
424
  if (isCurrent) {
432
- console.log(`${green3}* ${icon} ${branch.name}${reset3}`);
425
+ console.log(`${green2}* ${icon} ${branch.name}${reset2}`);
433
426
  if (branch.branch_url) {
434
- console.log(`${green3} ${branch.branch_url}${reset3}`);
427
+ console.log(`${green2} ${branch.branch_url}${reset2}`);
435
428
  }
436
429
  } else {
437
430
  console.log(` ${icon} ${branch.name}`);
438
431
  if (branch.branch_url) {
439
- console.log(`${dim3} ${branch.branch_url}${reset3}`);
432
+ console.log(`${dim2} ${branch.branch_url}${reset2}`);
440
433
  }
441
434
  }
442
435
  console.log();
@@ -547,219 +540,21 @@ ${branch.branch_url}`);
547
540
  }
548
541
 
549
542
  // src/commands/branch/diff.ts
550
- var green = "\x1B[32m";
551
- var red = "\x1B[31m";
552
- var yellow = "\x1B[33m";
553
- var cyan = "\x1B[36m";
554
- var dim = "\x1B[2m";
555
- var bold = "\x1B[1m";
556
- var reset = "\x1B[0m";
557
- var MAX_COL_WIDTH = 24;
558
- var MAX_COLUMNS = 6;
559
- function truncate(str, maxLen) {
560
- if (str.length <= maxLen) return str;
561
- return str.slice(0, maxLen - 2) + "..";
562
- }
563
- function parseDiffRow(raw) {
564
- return {
565
- schema_name: raw.schema_name,
566
- table_name: raw.table_name,
567
- primary_key: raw.primary_key,
568
- first_op: raw.first_op,
569
- last_op: raw.last_op,
570
- first_data: raw.original_values ? JSON.parse(raw.original_values) : null,
571
- last_data: raw.final_values ? JSON.parse(raw.final_values) : null
572
- };
573
- }
574
- async function diffAction(options) {
575
- let branch;
576
- if (options.branch) {
577
- branch = getBranchByName(options.branch);
578
- } else {
579
- const currentName = getCurrentBranch();
580
- if (currentName) {
581
- branch = getBranchByName(currentName);
582
- }
583
- }
584
- if (!branch) {
585
- const current = getCurrentBranch();
586
- if (current) {
587
- console.error(`\u2717 Branch "${current}" not found in cache`);
588
- console.log(" Run: ardent branch list");
589
- } else {
590
- console.error("\u2717 No current branch set");
591
- console.log(" Run: ardent branch switch <name> or ardent branch create <name>");
592
- }
593
- return;
594
- }
595
- try {
596
- const stateRaw = await api.get(`/v1/branches/${branch.id}/state`);
597
- if (!stateRaw || Object.keys(stateRaw).length === 0) {
598
- console.log("No changes captured");
599
- return;
600
- }
601
- for (const [_branchId, branchStateRaw] of Object.entries(stateRaw)) {
602
- const ddl = branchStateRaw.ddl;
603
- const replay_sql = branchStateRaw.replay_sql;
604
- const diff = (branchStateRaw.diff || []).map(parseDiffRow);
605
- if (options.sql) {
606
- if (replay_sql) {
607
- console.log(replay_sql);
608
- } else {
609
- console.log("-- No replay SQL generated");
610
- }
611
- continue;
612
- }
613
- if (ddl && ddl.length > 0) {
614
- console.log(`${bold}Schema Changes${reset} ${dim}(${ddl.length} DDL)${reset}
615
- `);
616
- for (const change of ddl) {
617
- const color = change.command_tag.includes("DROP") ? red : change.command_tag.includes("CREATE") ? green : yellow;
618
- console.log(` ${color}${change.command_tag}${reset} ${change.object_name}`);
619
- if (change.ddl_command && change.ddl_command.length < 100) {
620
- console.log(` ${dim}${change.ddl_command}${reset}`);
621
- }
622
- }
623
- console.log();
624
- }
625
- if (diff && diff.length > 0) {
626
- const byTable = /* @__PURE__ */ new Map();
627
- for (const row of diff) {
628
- const tableName = row.table_name || `${row.schema_name}.unknown`;
629
- if (!byTable.has(tableName)) {
630
- byTable.set(tableName, []);
631
- }
632
- byTable.get(tableName).push(row);
633
- }
634
- const inserts = diff.filter((r) => r.last_op === "INSERT").length;
635
- const updates = diff.filter((r) => r.last_op === "UPDATE").length;
636
- const deletes = diff.filter((r) => r.last_op === "DELETE").length;
637
- const summary = [
638
- inserts > 0 ? `${green}+${inserts} added${reset}` : "",
639
- updates > 0 ? `${yellow}~${updates} modified${reset}` : "",
640
- deletes > 0 ? `${red}-${deletes} deleted${reset}` : ""
641
- ].filter(Boolean).join(" ");
642
- console.log(`${bold}Data Changes${reset} ${dim}(${byTable.size} table${byTable.size > 1 ? "s" : ""})${reset} ${summary}
643
- `);
644
- for (const [tableName, rows] of byTable) {
645
- const tableInserts = rows.filter((r) => r.last_op === "INSERT").length;
646
- const tableUpdates = rows.filter((r) => r.last_op === "UPDATE").length;
647
- const tableDeletes = rows.filter((r) => r.last_op === "DELETE").length;
648
- const tableSummary = [
649
- tableInserts > 0 ? `${green}+${tableInserts}${reset}` : "",
650
- tableUpdates > 0 ? `${yellow}~${tableUpdates}${reset}` : "",
651
- tableDeletes > 0 ? `${red}-${tableDeletes}${reset}` : ""
652
- ].filter(Boolean).join(" ");
653
- console.log(`${cyan}${tableName}${reset} ${tableSummary}`);
654
- console.log();
655
- const allColumns = /* @__PURE__ */ new Set();
656
- for (const row of rows) {
657
- const data = row.last_data || row.first_data || {};
658
- Object.keys(data).forEach((k) => allColumns.add(k));
659
- if (row.first_data) {
660
- Object.keys(row.first_data).forEach((k) => allColumns.add(k));
661
- }
662
- }
663
- let columns = Array.from(allColumns);
664
- let hiddenColumns = 0;
665
- if (columns.length > MAX_COLUMNS) {
666
- const changedCols = /* @__PURE__ */ new Set();
667
- for (const row of rows) {
668
- if (row.last_op === "UPDATE" && row.first_data && row.last_data) {
669
- for (const col of columns) {
670
- if (row.first_data[col] !== row.last_data[col]) {
671
- changedCols.add(col);
672
- }
673
- }
674
- }
675
- }
676
- const prioritized = [
677
- ...columns.filter((c) => changedCols.has(c)),
678
- ...columns.filter((c) => !changedCols.has(c))
679
- ];
680
- hiddenColumns = prioritized.length - MAX_COLUMNS;
681
- columns = prioritized.slice(0, MAX_COLUMNS);
682
- }
683
- const colWidths = { Op: 2 };
684
- for (const col of columns) {
685
- colWidths[col] = Math.min(col.length, MAX_COL_WIDTH);
686
- }
687
- for (const row of rows) {
688
- const data = row.last_data || row.first_data || {};
689
- for (const col of columns) {
690
- const val = data[col];
691
- const valStr = val === void 0 ? "" : typeof val === "string" ? val : String(val);
692
- colWidths[col] = Math.min(MAX_COL_WIDTH, Math.max(colWidths[col], valStr.length));
693
- }
694
- }
695
- const vLine = `${dim}\u2502${reset}`;
696
- const topParts = [
697
- "\u2500".repeat(colWidths["Op"]),
698
- ...columns.map((col) => "\u2500".repeat(colWidths[col]))
699
- ];
700
- const hiddenNote = hiddenColumns > 0 ? ` ${dim}+${hiddenColumns} more${reset}` : "";
701
- console.log(` ${dim}\u250C\u2500${topParts.join("\u2500\u252C\u2500")}\u2500\u2510${reset}${hiddenNote}`);
702
- const headerParts = [
703
- `${"Op".padEnd(colWidths["Op"])}`,
704
- ...columns.map((col) => truncate(col, colWidths[col]).padEnd(colWidths[col]))
705
- ];
706
- console.log(` ${dim}\u2502 ${headerParts.join(" \u2502 ")} \u2502${reset}`);
707
- const sepParts = [
708
- "\u2500".repeat(colWidths["Op"]),
709
- ...columns.map((col) => "\u2500".repeat(colWidths[col]))
710
- ];
711
- console.log(` ${dim}\u251C\u2500${sepParts.join("\u2500\u253C\u2500")}\u2500\u2524${reset}`);
712
- for (const row of rows) {
713
- const op = row.last_op;
714
- const opColor = op === "INSERT" ? green : op === "DELETE" ? red : yellow;
715
- const opSymbol = op === "INSERT" ? "+" : op === "DELETE" ? "-" : "~";
716
- const cellParts = [];
717
- cellParts.push(`${opColor}${opSymbol.padEnd(colWidths["Op"])}${reset}`);
718
- for (const col of columns) {
719
- const width = colWidths[col];
720
- if (op === "UPDATE" && row.first_data && row.last_data) {
721
- const oldVal = row.first_data[col];
722
- const newVal = row.last_data[col];
723
- if (oldVal !== newVal) {
724
- const halfWidth = Math.floor((width - 1) / 2);
725
- const oldStr = truncate(oldVal === void 0 ? "" : typeof oldVal === "string" ? oldVal : String(oldVal), halfWidth);
726
- const newStr = truncate(newVal === void 0 ? "" : typeof newVal === "string" ? newVal : String(newVal), halfWidth);
727
- cellParts.push(`${red}${oldStr.padEnd(halfWidth)}${reset}\u2192${green}${newStr.padEnd(width - halfWidth - 1)}${reset}`);
728
- } else {
729
- const valStr = newVal === void 0 ? "" : typeof newVal === "string" ? newVal : String(newVal);
730
- cellParts.push(`${dim}${truncate(valStr, width).padEnd(width)}${reset}`);
731
- }
732
- } else {
733
- const data = row.last_data || row.first_data || {};
734
- const val = data[col];
735
- const valStr = val === void 0 ? "" : typeof val === "string" ? val : String(val);
736
- cellParts.push(`${opColor}${truncate(valStr, width).padEnd(width)}${reset}`);
737
- }
738
- }
739
- console.log(` ${vLine} ${cellParts.join(` ${vLine} `)} ${vLine}`);
740
- }
741
- const bottomParts = [
742
- "\u2500".repeat(colWidths["Op"]),
743
- ...columns.map((col) => "\u2500".repeat(colWidths[col]))
744
- ];
745
- console.log(` ${dim}\u2514\u2500${bottomParts.join("\u2500\u2534\u2500")}\u2500\u2518${reset}`);
746
- console.log();
747
- }
748
- }
749
- if ((!ddl || ddl.length === 0) && (!diff || diff.length === 0)) {
750
- console.log("No changes");
751
- }
752
- trackEvent("CLI: branch diff succeeded", {
753
- sql_mode: Boolean(options.sql),
754
- ddl_count: ddl?.length ?? 0,
755
- data_change_count: diff?.length ?? 0
756
- });
757
- }
758
- } catch (err) {
759
- trackEvent("CLI: branch diff failed", { reason: "api_error" });
760
- console.error("\u2717 Failed:", err instanceof Error ? err.message : err);
761
- process.exit(1);
762
- }
543
+ function diffAction() {
544
+ const red = "\x1B[31m";
545
+ const yellow = "\x1B[33m";
546
+ const reset2 = "\x1B[0m";
547
+ console.error(
548
+ `${red}error:${reset2} \`ardent branch diff\` has been removed.
549
+
550
+ The underlying CDC service (branching-replay-service + StarRocks) was
551
+ deprecated in favour of pgstream. A pgstream-backed diff view is on the
552
+ roadmap but not yet shipped.
553
+
554
+ ${yellow}If you need the current state of a branch:${reset2} \`ardent branch info <name>\`
555
+ `
556
+ );
557
+ process.exit(2);
763
558
  }
764
559
 
765
560
  // src/commands/branch/index.ts
@@ -769,7 +564,7 @@ branchCommand.command("list").description("List your branches").action(listActio
769
564
  branchCommand.command("info [name]").description("Show branch details (defaults to current branch)").action(infoAction);
770
565
  branchCommand.command("delete <name>").description("Delete a branch").action(deleteAction);
771
566
  branchCommand.command("switch <name>").description("Switch to a different branch").action(switchAction);
772
- branchCommand.command("diff").description("Show all changes since branch creation").option("-b, --branch <name>", "Branch name (defaults to current)").option("--sql", "Output as replay SQL").action(diffAction);
567
+ branchCommand.command("diff [name]", { hidden: true }).description("(removed) Show changes on a branch").action(diffAction);
773
568
 
774
569
  // src/commands/connector/index.ts
775
570
  import { Command as Command2 } from "commander";
@@ -807,9 +602,9 @@ function getOnboardingState() {
807
602
  }
808
603
  return { state: "ready", connectorCount, branchCount, currentBranch };
809
604
  }
810
- var dim2 = "\x1B[2m";
811
- var reset2 = "\x1B[0m";
812
- var green2 = "\x1B[32m";
605
+ var dim = "\x1B[2m";
606
+ var reset = "\x1B[0m";
607
+ var green = "\x1B[32m";
813
608
  function showOnboarding() {
814
609
  const { state, connectorCount, branchCount, currentBranch } = getOnboardingState();
815
610
  switch (state) {
@@ -817,37 +612,37 @@ function showOnboarding() {
817
612
  console.log(BANNER);
818
613
  console.log(`To get started, log in with your GitHub account:
819
614
 
820
- ${green2}ardent login${reset2}
615
+ ${green}ardent login${reset}
821
616
 
822
- Run ${dim2}ardent --help${reset2} to see all commands.
617
+ Run ${dim}ardent --help${reset} to see all commands.
823
618
  `);
824
619
  break;
825
620
  case "no_connectors":
826
621
  console.log(`
827
- ${green2}\u2713${reset2} Logged in
622
+ ${green}\u2713${reset} Logged in
828
623
 
829
624
  Next step \u2014 connect your first database:
830
625
 
831
- ${green2}ardent connector create <type> <connection-url>${reset2}
626
+ ${green}ardent connector create <type> <connection-url>${reset}
832
627
 
833
628
  Example:
834
- ${dim2}ardent connector create postgresql postgresql://user:password@host:5432/database${reset2}
629
+ ${dim}ardent connector create postgresql postgresql://user:password@host:5432/database${reset}
835
630
 
836
- Run ${dim2}ardent --help${reset2} to see all commands.
631
+ Run ${dim}ardent --help${reset} to see all commands.
837
632
  `);
838
633
  break;
839
634
  case "no_branches":
840
635
  console.log(`
841
- ${green2}\u2713${reset2} Logged in ${green2}\u2713${reset2} ${connectorCount} connector${connectorCount !== 1 ? "s" : ""}
636
+ ${green}\u2713${reset} Logged in ${green}\u2713${reset} ${connectorCount} connector${connectorCount !== 1 ? "s" : ""}
842
637
 
843
638
  You're all set! Create your first branch:
844
639
 
845
- ${green2}ardent branch create <name>${reset2}
640
+ ${green}ardent branch create <name>${reset}
846
641
 
847
642
  Example:
848
- ${dim2}ardent branch create my-feature${reset2}
643
+ ${dim}ardent branch create my-feature${reset}
849
644
 
850
- Run ${dim2}ardent --help${reset2} to see all commands.
645
+ Run ${dim}ardent --help${reset} to see all commands.
851
646
  `);
852
647
  return true;
853
648
  case "ready":
@@ -862,20 +657,20 @@ function showNextStep() {
862
657
  console.log(`
863
658
  Next step \u2014 connect your first database:
864
659
 
865
- ${green2}ardent connector create <type> <connection-url>${reset2}
660
+ ${green}ardent connector create <type> <connection-url>${reset}
866
661
 
867
662
  Example:
868
- ${dim2}ardent connector create postgresql postgresql://user:password@host:5432/database${reset2}
663
+ ${dim}ardent connector create postgresql postgresql://user:password@host:5432/database${reset}
869
664
  `);
870
665
  break;
871
666
  case "no_branches":
872
667
  console.log(`
873
668
  Next step \u2014 create your first branch:
874
669
 
875
- ${green2}ardent branch create <name>${reset2}
670
+ ${green}ardent branch create <name>${reset}
876
671
 
877
672
  Example:
878
- ${dim2}ardent branch create my-feature${reset2}
673
+ ${dim}ardent branch create my-feature${reset}
879
674
  `);
880
675
  break;
881
676
  case "ready":
@@ -981,11 +776,11 @@ async function createAction2(type, url, options) {
981
776
  );
982
777
  const discoveryWarnings = discoverResult?.source_metadata?.warnings ?? [];
983
778
  if (discoveryWarnings.length > 0) {
984
- const yellow2 = "\x1B[33m";
985
- const reset3 = "\x1B[0m";
779
+ const yellow = "\x1B[33m";
780
+ const reset2 = "\x1B[0m";
986
781
  console.log("");
987
782
  for (const warning of discoveryWarnings) {
988
- console.log(`${yellow2}\u26A0 ${warning}${reset3}`);
783
+ console.log(`${yellow}\u26A0 ${warning}${reset2}`);
989
784
  }
990
785
  console.log("");
991
786
  }
@@ -1080,25 +875,25 @@ async function listAction2() {
1080
875
  return;
1081
876
  }
1082
877
  const currentConnectorId = getConfig("currentConnectorId");
1083
- const green3 = "\x1B[32m";
1084
- const dim3 = "\x1B[2m";
1085
- const yellow2 = "\x1B[33m";
1086
- const reset3 = "\x1B[0m";
878
+ const green2 = "\x1B[32m";
879
+ const dim2 = "\x1B[2m";
880
+ const yellow = "\x1B[33m";
881
+ const reset2 = "\x1B[0m";
1087
882
  console.log("Connectors:\n");
1088
883
  for (const connector of connectors) {
1089
884
  const isCurrent = connector.id === currentConnectorId;
1090
885
  const icon = connector.status === "healthy" ? "\u25CF" : "\u25CB";
1091
886
  const warnings = connector.warnings ?? [];
1092
- const warningSuffix = warnings.length > 0 ? ` ${yellow2}\u26A0 ${warnings.length}${reset3}` : "";
887
+ const warningSuffix = warnings.length > 0 ? ` ${yellow}\u26A0 ${warnings.length}${reset2}` : "";
1093
888
  if (isCurrent) {
1094
- console.log(`${green3}* ${icon} ${connector.name}${reset3}${warningSuffix}`);
1095
- console.log(`${green3} ${connector.service_name}${reset3}`);
889
+ console.log(`${green2}* ${icon} ${connector.name}${reset2}${warningSuffix}`);
890
+ console.log(`${green2} ${connector.service_name}${reset2}`);
1096
891
  } else {
1097
892
  console.log(` ${icon} ${connector.name}${warningSuffix}`);
1098
- console.log(`${dim3} ${connector.service_name}${reset3}`);
893
+ console.log(`${dim2} ${connector.service_name}${reset2}`);
1099
894
  }
1100
895
  for (const warning of warnings) {
1101
- console.log(`${yellow2} \u26A0 ${warning}${reset3}`);
896
+ console.log(`${yellow} \u26A0 ${warning}${reset2}`);
1102
897
  }
1103
898
  console.log();
1104
899
  }
@@ -1505,18 +1300,18 @@ async function listAction4() {
1505
1300
  return;
1506
1301
  }
1507
1302
  const currentProjectId = getConfig("currentProjectId");
1508
- const green3 = "\x1B[32m";
1509
- const dim3 = "\x1B[2m";
1510
- const reset3 = "\x1B[0m";
1303
+ const green2 = "\x1B[32m";
1304
+ const dim2 = "\x1B[2m";
1305
+ const reset2 = "\x1B[0m";
1511
1306
  console.log("Projects:\n");
1512
1307
  for (const project of projects) {
1513
1308
  const isCurrent = project.id === currentProjectId;
1514
1309
  if (isCurrent) {
1515
- console.log(`${green3}* ${project.name}${reset3}`);
1516
- console.log(`${green3} ${project.id}${reset3}`);
1310
+ console.log(`${green2}* ${project.name}${reset2}`);
1311
+ console.log(`${green2} ${project.id}${reset2}`);
1517
1312
  } else {
1518
1313
  console.log(` ${project.name}`);
1519
- console.log(`${dim3} ${project.id}${reset3}`);
1314
+ console.log(`${dim2} ${project.id}${reset2}`);
1520
1315
  }
1521
1316
  console.log();
1522
1317
  }
@@ -1793,11 +1588,11 @@ async function checkForUpdate(currentVersion) {
1793
1588
  }
1794
1589
  }
1795
1590
  function printUpdateNotice(current, latest) {
1796
- const yellow2 = "\x1B[33m";
1797
- const green3 = "\x1B[32m";
1798
- const reset3 = "\x1B[0m";
1591
+ const yellow = "\x1B[33m";
1592
+ const green2 = "\x1B[32m";
1593
+ const reset2 = "\x1B[0m";
1799
1594
  console.error(
1800
- `${yellow2}Update available: ${current} \u2192 ${latest}${reset3} \u2014 run ${green3}npm install -g ardent-cli@latest${reset3}`
1595
+ `${yellow}Update available: ${current} \u2192 ${latest}${reset2} \u2014 run ${green2}npm install -g ardent-cli@latest${reset2}`
1801
1596
  );
1802
1597
  }
1803
1598
 
@@ -1828,7 +1623,6 @@ BRANCHES
1828
1623
  branch info Show branch details (URL, status, etc.)
1829
1624
  branch delete Delete a branch
1830
1625
  branch switch Switch to a different branch
1831
- branch diff Show all changes since branch creation
1832
1626
 
1833
1627
  TEAM
1834
1628
  invite <email> Invite a user to your organization
@@ -1878,9 +1672,6 @@ program.on("command:*", (operands) => {
1878
1672
  `);
1879
1673
  if (unknown === "switch") {
1880
1674
  console.error(` Did you mean: ardent branch switch <name>
1881
- `);
1882
- } else if (unknown === "diff") {
1883
- console.error(` Did you mean: ardent branch diff
1884
1675
  `);
1885
1676
  }
1886
1677
  console.error(`Run ardent --help for available commands.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ardent-cli",
3
- "version": "0.0.15",
3
+ "version": "0.0.16",
4
4
  "description": "Git for Data infrastructure",
5
5
  "type": "module",
6
6
  "bin": {