@sdt-tools/cli 0.2.5 → 0.3.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/index.js CHANGED
@@ -678,11 +678,14 @@ function splitStatements(sql) {
678
678
  function publishCommand() {
679
679
  const cmd = new Command5("publish");
680
680
  cmd.description(
681
- "Compare a .sdtpac to a live Snowflake target and apply (or dry-run) the migration."
681
+ "Compare a .sdtpac (the desired state) to a live Snowflake target and apply (or dry-run) the migration. Shared form with `ddt publish`: `--source <desired> --connection <live-target>`."
682
+ ).option(
683
+ "--source <path>",
684
+ "Path to the desired-state .sdtpac (canonical name; the same flag `ddt publish` uses). Required for a normal publish; omit only with --restore-from-snapshot."
682
685
  ).option(
683
686
  "--pac <path>",
684
- "Path to a built .sdtpac. Required for a normal publish; omit only with --restore-from-snapshot."
685
- ).requiredOption("-c, --connection <profile>", "Connection profile name").option(
687
+ "Back-compat alias for --source (the desired-state .sdtpac). Prefer --source for cross-platform parity with `ddt publish`."
688
+ ).requiredOption("-c, --connection <profile>", "Connection profile name (the live target).").option(
686
689
  "--restore-from-snapshot <batchId>",
687
690
  "Recovery mode: skip the compare step and emit ALTER TABLE \u2026 SWAP WITH against the snapshot batch <batchId> from the registry. Dry-run by default; pass --apply --yes to execute. This is the command printed by TRUST.4's post-deploy-smoke + TRUST.8's restore-hint when a deploy fails \u2014 they tell the operator to run `sdt publish --restore-from-snapshot <id>`."
688
691
  ).option(
@@ -769,12 +772,15 @@ function publishCommand() {
769
772
  await runRestoreFromSnapshot(opts);
770
773
  return;
771
774
  }
772
- if (!opts.pac) {
773
- logger.error("--pac <path> is required (unless --restore-from-snapshot is given).");
775
+ const pacRef = opts.source ?? opts.pac;
776
+ if (!pacRef) {
777
+ logger.error(
778
+ "--source <path> (or its alias --pac) is required (unless --restore-from-snapshot is given)."
779
+ );
774
780
  process.exitCode = 1;
775
781
  return;
776
782
  }
777
- const pacPath = path4.resolve(String(opts.pac));
783
+ const pacPath = path4.resolve(String(pacRef));
778
784
  const pac10 = await readPac(pacPath);
779
785
  const freshnessMode = opts.freshness ?? "warn";
780
786
  if (freshnessMode !== "skip") {
@@ -1712,6 +1718,11 @@ function connectionCommand() {
1712
1718
  await upsertProfile(profile);
1713
1719
  logger.success(`Saved profile "${profile.name}".`);
1714
1720
  });
1721
+ cmd.command("get <name>").description("Print a profile (secrets are redacted).").action(async (name) => {
1722
+ const profile = await getProfile5(String(name));
1723
+ const redacted = { ...profile, auth: redactAuth(profile.auth) };
1724
+ logger.info(JSON.stringify(redacted, null, 2));
1725
+ });
1715
1726
  cmd.command("remove").description("Remove a connection profile.").argument("<name>").action(async (name) => {
1716
1727
  const ok = await removeProfile(String(name));
1717
1728
  if (ok) logger.success(`Removed profile "${name}".`);
@@ -1729,6 +1740,24 @@ function connectionCommand() {
1729
1740
  });
1730
1741
  return cmd;
1731
1742
  }
1743
+ function redactAuth(auth) {
1744
+ const isPlaceholder = (v) => v.startsWith("env:") || v.startsWith("keyring:");
1745
+ switch (auth.method) {
1746
+ case "PASSWORD":
1747
+ case "MFA":
1748
+ return auth.password && !isPlaceholder(auth.password) ? { ...auth, password: "<redacted>" } : auth;
1749
+ case "OAUTH":
1750
+ return auth.token && !isPlaceholder(auth.token) ? { ...auth, token: "<redacted>" } : auth;
1751
+ case "KEY_PAIR":
1752
+ return auth.privateKeyPassphrase && !isPlaceholder(auth.privateKeyPassphrase) ? { ...auth, privateKeyPassphrase: "<redacted>" } : auth;
1753
+ case "EXTERNAL_BROWSER":
1754
+ return auth;
1755
+ default: {
1756
+ const _exhaustive = auth;
1757
+ return _exhaustive;
1758
+ }
1759
+ }
1760
+ }
1732
1761
 
1733
1762
  // src/commands/scaffold.ts
1734
1763
  import { Command as Command9 } from "commander";