@databricks-solutions/lakebase-scm-utils 0.2.40 → 0.2.42

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 (74) hide show
  1. package/dist/scripts/github/index.cjs +3 -1
  2. package/dist/scripts/github/index.js +3 -1
  3. package/dist/scripts/github/pr.cli.cjs +3 -1
  4. package/dist/scripts/github/pr.cli.js +3 -1
  5. package/dist/scripts/index.cjs +66 -21
  6. package/dist/scripts/index.d.cts +1 -1
  7. package/dist/scripts/index.d.ts +1 -1
  8. package/dist/scripts/index.js +59 -15
  9. package/dist/scripts/lakebase/branch.cli.cjs +3 -1
  10. package/dist/scripts/lakebase/branch.cli.js +3 -1
  11. package/dist/scripts/lakebase/ci-app-endpoint.cli.cjs +3 -1
  12. package/dist/scripts/lakebase/ci-app-endpoint.cli.js +3 -1
  13. package/dist/scripts/lakebase/ci-resolve-branch.cli.cjs +5 -3
  14. package/dist/scripts/lakebase/ci-resolve-branch.cli.js +5 -3
  15. package/dist/scripts/lakebase/collapse-heads.cli.cjs +5 -3
  16. package/dist/scripts/lakebase/collapse-heads.cli.js +5 -3
  17. package/dist/scripts/lakebase/cut-backup.cli.cjs +3 -1
  18. package/dist/scripts/lakebase/cut-backup.cli.js +3 -1
  19. package/dist/scripts/lakebase/cut-tier.cli.cjs +3 -1
  20. package/dist/scripts/lakebase/cut-tier.cli.js +3 -1
  21. package/dist/scripts/lakebase/detect-language.cli.cjs +5 -3
  22. package/dist/scripts/lakebase/detect-language.cli.js +5 -3
  23. package/dist/scripts/lakebase/doctor.cli.cjs +5 -3
  24. package/dist/scripts/lakebase/doctor.cli.js +5 -3
  25. package/dist/scripts/lakebase/get-connection.cli.cjs +5 -3
  26. package/dist/scripts/lakebase/get-connection.cli.js +5 -3
  27. package/dist/scripts/lakebase/index.cjs +66 -21
  28. package/dist/scripts/lakebase/index.d.cts +5 -1
  29. package/dist/scripts/lakebase/index.d.ts +5 -1
  30. package/dist/scripts/lakebase/index.js +59 -15
  31. package/dist/scripts/lakebase/infra-runner.cli.cjs +5 -3
  32. package/dist/scripts/lakebase/infra-runner.cli.js +5 -3
  33. package/dist/scripts/lakebase/new-migration.cli.cjs +5 -3
  34. package/dist/scripts/lakebase/new-migration.cli.js +5 -3
  35. package/dist/scripts/lakebase/schema-diff.cli.cjs +5 -3
  36. package/dist/scripts/lakebase/schema-diff.cli.js +5 -3
  37. package/dist/scripts/lakebase/schema-migrate.cli.cjs +5 -3
  38. package/dist/scripts/lakebase/schema-migrate.cli.js +5 -3
  39. package/dist/scripts/lakebase/scm-abandon-feature.cli.cjs +37 -1
  40. package/dist/scripts/lakebase/scm-abandon-feature.cli.js +37 -1
  41. package/dist/scripts/lakebase/scm-adopt-state.cli.cjs +37 -1
  42. package/dist/scripts/lakebase/scm-adopt-state.cli.js +37 -1
  43. package/dist/scripts/lakebase/scm-claim-feature.cli.cjs +45 -9
  44. package/dist/scripts/lakebase/scm-claim-feature.cli.js +39 -3
  45. package/dist/scripts/lakebase/scm-cleanup.cli.cjs +3 -1
  46. package/dist/scripts/lakebase/scm-cleanup.cli.js +3 -1
  47. package/dist/scripts/lakebase/scm-doctor.cli.cjs +56 -29
  48. package/dist/scripts/lakebase/scm-doctor.cli.js +50 -23
  49. package/dist/scripts/lakebase/scm-feature-branch.cli.cjs +1 -0
  50. package/dist/scripts/lakebase/scm-feature-branch.cli.js +1 -0
  51. package/dist/scripts/lakebase/scm-merge.cli.cjs +45 -9
  52. package/dist/scripts/lakebase/scm-merge.cli.js +39 -3
  53. package/dist/scripts/lakebase/scm-prepare-pr.cli.cjs +34 -0
  54. package/dist/scripts/lakebase/scm-prepare-pr.cli.js +34 -0
  55. package/dist/scripts/lakebase/scm-reconcile-tier.cli.cjs +6 -3
  56. package/dist/scripts/lakebase/scm-reconcile-tier.cli.js +6 -3
  57. package/dist/scripts/lakebase/scm-recover-orphans.cli.cjs +37 -1
  58. package/dist/scripts/lakebase/scm-recover-orphans.cli.js +37 -1
  59. package/dist/scripts/lakebase/scm-state.cli.cjs +5 -4
  60. package/dist/scripts/lakebase/scm-state.cli.js +4 -3
  61. package/dist/scripts/lakebase/scm-wait-ci.cli.cjs +34 -0
  62. package/dist/scripts/lakebase/scm-wait-ci.cli.js +34 -0
  63. package/dist/scripts/util/index.cjs +5 -3
  64. package/dist/scripts/util/index.js +5 -3
  65. package/package.json +1 -1
  66. package/scripts/lakebase/databricks-cli.ts +7 -1
  67. package/scripts/lakebase/enable-e2e.ts +19 -3
  68. package/scripts/lakebase/scm-doctor.ts +1 -12
  69. package/scripts/lakebase/scm-workflow-state.ts +49 -0
  70. package/templates/project/common/.github/workflows/merge.yml +14 -5
  71. package/templates/project/common/.github/workflows/pr.yml +14 -5
  72. package/templates/project/common/.gitignore.base +8 -0
  73. package/templates/project/common/scripts/lk +66 -33
  74. package/templates/project/common/scripts/run-tests.sh +18 -1
@@ -85758,7 +85758,9 @@ function resolveProfile(opts) {
85758
85758
  function buildInvocation(args, opts) {
85759
85759
  const base = opts.env ?? process.env;
85760
85760
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
85761
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
85761
+ const env = { ...base };
85762
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
85763
+ delete env.DATABRICKS_WORKSPACE_ID;
85762
85764
  const profile = resolveProfile(opts);
85763
85765
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
85764
85766
  return { argv, env, profile };
@@ -86257,6 +86259,39 @@ async function resolveGitBase(parentBranch, cwd) {
86257
86259
  init_cjs_shims();
86258
86260
  var fs3 = __toESM(require("fs"), 1);
86259
86261
  var path2 = __toESM(require("path"), 1);
86262
+ var import_node_child_process4 = require("child_process");
86263
+ function isGitTracked(projectDir, rel) {
86264
+ try {
86265
+ (0, import_node_child_process4.execFileSync)("git", ["ls-files", "--error-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
86266
+ return true;
86267
+ } catch {
86268
+ return false;
86269
+ }
86270
+ }
86271
+ function ensureWorkflowStateUntracked(projectDir) {
86272
+ const rel = ".lakebase/workflow-state.json";
86273
+ try {
86274
+ if (isGitTracked(projectDir, rel)) {
86275
+ (0, import_node_child_process4.execFileSync)("git", ["rm", "--cached", "--quiet", "--ignore-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
86276
+ }
86277
+ } catch {
86278
+ }
86279
+ try {
86280
+ const gitignore = path2.join(projectDir, ".gitignore");
86281
+ const existing = fs3.existsSync(gitignore) ? fs3.readFileSync(gitignore, "utf8") : "";
86282
+ if (!existing.split("\n").some((l) => l.trim() === rel)) {
86283
+ const sep2 = existing === "" || existing.endsWith("\n") ? "" : "\n";
86284
+ fs3.appendFileSync(
86285
+ gitignore,
86286
+ `${sep2}# Runtime SCM claim state (per working tree): a branch checkout must never restore
86287
+ # a stale committed claim over the live one (issue #203 / Finding 28).
86288
+ ${rel}
86289
+ `
86290
+ );
86291
+ }
86292
+ } catch {
86293
+ }
86294
+ }
86260
86295
  var SCM_STATES = [
86261
86296
  "scaffold-complete",
86262
86297
  "feature-claimed",
@@ -86303,6 +86338,7 @@ function writeWorkflowState(projectDir, state) {
86303
86338
  throw new Error(`Refusing to write invalid SCM state:
86304
86339
  ${summary}`);
86305
86340
  }
86341
+ ensureWorkflowStateUntracked(projectDir);
86306
86342
  const dir = path2.join(projectDir, ".lakebase");
86307
86343
  fs3.mkdirSync(dir, { recursive: true });
86308
86344
  const target = stateFilePath(projectDir);
@@ -88153,8 +88189,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
88153
88189
  var cached;
88154
88190
  function substrateSelfVersion() {
88155
88191
  if (cached !== void 0) return cached;
88156
- if ("0.2.40".length > 0) {
88157
- cached = "0.2.40";
88192
+ if ("0.2.42".length > 0) {
88193
+ cached = "0.2.42";
88158
88194
  return cached;
88159
88195
  }
88160
88196
  cached = "unknown";
@@ -88264,7 +88300,7 @@ var path5 = __toESM(require("path"), 1);
88264
88300
 
88265
88301
  // scripts/lakebase/schema-migrate-runners/alembic.ts
88266
88302
  init_cjs_shims();
88267
- var import_node_child_process4 = require("child_process");
88303
+ var import_node_child_process5 = require("child_process");
88268
88304
  var fs6 = __toESM(require("fs"), 1);
88269
88305
  var path4 = __toESM(require("path"), 1);
88270
88306
  function resolveAlembicBin(projectDir) {
@@ -88286,7 +88322,7 @@ function spawnAlembic(projectDir, args, dsn) {
88286
88322
  const env = { ...process.env };
88287
88323
  env.PYTHONPATH = [projectDir, process.env.PYTHONPATH].filter(Boolean).join(path4.delimiter);
88288
88324
  if (dsn) env.DATABASE_URL = dsn;
88289
- const child = (0, import_node_child_process4.spawn)(bin, args, {
88325
+ const child = (0, import_node_child_process5.spawn)(bin, args, {
88290
88326
  cwd: projectDir,
88291
88327
  env,
88292
88328
  stdio: ["ignore", "pipe", "pipe"]
@@ -88648,7 +88684,7 @@ var path7 = __toESM(require("path"), 1);
88648
88684
 
88649
88685
  // scripts/lakebase/schema-migrate-runners/flyway.ts
88650
88686
  init_cjs_shims();
88651
- var import_node_child_process5 = require("child_process");
88687
+ var import_node_child_process6 = require("child_process");
88652
88688
  var path6 = __toESM(require("path"), 1);
88653
88689
  function dsnToFlywayEnv(dsn) {
88654
88690
  const u = new URL(dsn);
@@ -88664,7 +88700,7 @@ function migrationsLocation(projectDir) {
88664
88700
  function runFlyway(ctx, args) {
88665
88701
  const { url, user, password } = dsnToFlywayEnv(ctx.dsn);
88666
88702
  return new Promise((resolve2, reject) => {
88667
- const child = (0, import_node_child_process5.spawn)(
88703
+ const child = (0, import_node_child_process6.spawn)(
88668
88704
  "flyway",
88669
88705
  ["-outputType=json", `-locations=${migrationsLocation(ctx.projectDir)}`, ...args],
88670
88706
  {
@@ -88901,7 +88937,7 @@ var path9 = __toESM(require("path"), 1);
88901
88937
 
88902
88938
  // scripts/lakebase/schema-migrate-runners/knex.ts
88903
88939
  init_cjs_shims();
88904
- var import_node_child_process6 = require("child_process");
88940
+ var import_node_child_process7 = require("child_process");
88905
88941
  var fs9 = __toESM(require("fs"), 1);
88906
88942
  var path8 = __toESM(require("path"), 1);
88907
88943
  var KNEXFILE_VARIANTS = ["knexfile.js", "knexfile.ts", "knexfile.mjs", "knexfile.cjs"];
@@ -88923,7 +88959,7 @@ function spawnKnex(projectDir, args, dsn) {
88923
88959
  );
88924
88960
  return;
88925
88961
  }
88926
- const child = (0, import_node_child_process6.spawn)("npx", ["--no-install", "knex", "--knexfile", knexfile, ...args], {
88962
+ const child = (0, import_node_child_process7.spawn)("npx", ["--no-install", "knex", "--knexfile", knexfile, ...args], {
88927
88963
  cwd: projectDir,
88928
88964
  env: dsn ? { ...process.env, DATABASE_URL: dsn } : { ...process.env },
88929
88965
  stdio: ["ignore", "pipe", "pipe"]
@@ -8280,7 +8280,9 @@ function resolveProfile(opts) {
8280
8280
  function buildInvocation(args, opts) {
8281
8281
  const base = opts.env ?? process.env;
8282
8282
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
8283
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
8283
+ const env = { ...base };
8284
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
8285
+ delete env.DATABRICKS_WORKSPACE_ID;
8284
8286
  const profile = resolveProfile(opts);
8285
8287
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
8286
8288
  return { argv, env, profile };
@@ -8779,6 +8781,39 @@ async function resolveGitBase(parentBranch, cwd) {
8779
8781
  init_esm_shims();
8780
8782
  import * as fs3 from "fs";
8781
8783
  import * as path3 from "path";
8784
+ import { execFileSync as execFileSync4 } from "child_process";
8785
+ function isGitTracked(projectDir, rel) {
8786
+ try {
8787
+ execFileSync4("git", ["ls-files", "--error-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
8788
+ return true;
8789
+ } catch {
8790
+ return false;
8791
+ }
8792
+ }
8793
+ function ensureWorkflowStateUntracked(projectDir) {
8794
+ const rel = ".lakebase/workflow-state.json";
8795
+ try {
8796
+ if (isGitTracked(projectDir, rel)) {
8797
+ execFileSync4("git", ["rm", "--cached", "--quiet", "--ignore-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
8798
+ }
8799
+ } catch {
8800
+ }
8801
+ try {
8802
+ const gitignore = path3.join(projectDir, ".gitignore");
8803
+ const existing = fs3.existsSync(gitignore) ? fs3.readFileSync(gitignore, "utf8") : "";
8804
+ if (!existing.split("\n").some((l) => l.trim() === rel)) {
8805
+ const sep2 = existing === "" || existing.endsWith("\n") ? "" : "\n";
8806
+ fs3.appendFileSync(
8807
+ gitignore,
8808
+ `${sep2}# Runtime SCM claim state (per working tree): a branch checkout must never restore
8809
+ # a stale committed claim over the live one (issue #203 / Finding 28).
8810
+ ${rel}
8811
+ `
8812
+ );
8813
+ }
8814
+ } catch {
8815
+ }
8816
+ }
8782
8817
  var SCM_STATES = [
8783
8818
  "scaffold-complete",
8784
8819
  "feature-claimed",
@@ -8825,6 +8860,7 @@ function writeWorkflowState(projectDir, state) {
8825
8860
  throw new Error(`Refusing to write invalid SCM state:
8826
8861
  ${summary}`);
8827
8862
  }
8863
+ ensureWorkflowStateUntracked(projectDir);
8828
8864
  const dir = path3.join(projectDir, ".lakebase");
8829
8865
  fs3.mkdirSync(dir, { recursive: true });
8830
8866
  const target = stateFilePath(projectDir);
@@ -9306,8 +9342,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
9306
9342
  var cached;
9307
9343
  function substrateSelfVersion() {
9308
9344
  if (cached !== void 0) return cached;
9309
- if ("0.2.40".length > 0) {
9310
- cached = "0.2.40";
9345
+ if ("0.2.42".length > 0) {
9346
+ cached = "0.2.42";
9311
9347
  return cached;
9312
9348
  }
9313
9349
  cached = "unknown";
@@ -8436,6 +8436,39 @@ var RUNTIME_ARTIFACT_IGNORE = [
8436
8436
  init_cjs_shims();
8437
8437
  var fs3 = __toESM(require("fs"), 1);
8438
8438
  var path2 = __toESM(require("path"), 1);
8439
+ var import_node_child_process4 = require("child_process");
8440
+ function isGitTracked(projectDir, rel) {
8441
+ try {
8442
+ (0, import_node_child_process4.execFileSync)("git", ["ls-files", "--error-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
8443
+ return true;
8444
+ } catch {
8445
+ return false;
8446
+ }
8447
+ }
8448
+ function ensureWorkflowStateUntracked(projectDir) {
8449
+ const rel = ".lakebase/workflow-state.json";
8450
+ try {
8451
+ if (isGitTracked(projectDir, rel)) {
8452
+ (0, import_node_child_process4.execFileSync)("git", ["rm", "--cached", "--quiet", "--ignore-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
8453
+ }
8454
+ } catch {
8455
+ }
8456
+ try {
8457
+ const gitignore = path2.join(projectDir, ".gitignore");
8458
+ const existing = fs3.existsSync(gitignore) ? fs3.readFileSync(gitignore, "utf8") : "";
8459
+ if (!existing.split("\n").some((l) => l.trim() === rel)) {
8460
+ const sep2 = existing === "" || existing.endsWith("\n") ? "" : "\n";
8461
+ fs3.appendFileSync(
8462
+ gitignore,
8463
+ `${sep2}# Runtime SCM claim state (per working tree): a branch checkout must never restore
8464
+ # a stale committed claim over the live one (issue #203 / Finding 28).
8465
+ ${rel}
8466
+ `
8467
+ );
8468
+ }
8469
+ } catch {
8470
+ }
8471
+ }
8439
8472
  var SCM_STATES = [
8440
8473
  "scaffold-complete",
8441
8474
  "feature-claimed",
@@ -8482,6 +8515,7 @@ function writeWorkflowState(projectDir, state) {
8482
8515
  throw new Error(`Refusing to write invalid SCM state:
8483
8516
  ${summary}`);
8484
8517
  }
8518
+ ensureWorkflowStateUntracked(projectDir);
8485
8519
  const dir = path2.join(projectDir, ".lakebase");
8486
8520
  fs3.mkdirSync(dir, { recursive: true });
8487
8521
  const target = stateFilePath(projectDir);
@@ -8424,6 +8424,39 @@ var RUNTIME_ARTIFACT_IGNORE = [
8424
8424
  init_esm_shims();
8425
8425
  import * as fs3 from "fs";
8426
8426
  import * as path3 from "path";
8427
+ import { execFileSync as execFileSync4 } from "child_process";
8428
+ function isGitTracked(projectDir, rel) {
8429
+ try {
8430
+ execFileSync4("git", ["ls-files", "--error-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
8431
+ return true;
8432
+ } catch {
8433
+ return false;
8434
+ }
8435
+ }
8436
+ function ensureWorkflowStateUntracked(projectDir) {
8437
+ const rel = ".lakebase/workflow-state.json";
8438
+ try {
8439
+ if (isGitTracked(projectDir, rel)) {
8440
+ execFileSync4("git", ["rm", "--cached", "--quiet", "--ignore-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
8441
+ }
8442
+ } catch {
8443
+ }
8444
+ try {
8445
+ const gitignore = path3.join(projectDir, ".gitignore");
8446
+ const existing = fs3.existsSync(gitignore) ? fs3.readFileSync(gitignore, "utf8") : "";
8447
+ if (!existing.split("\n").some((l) => l.trim() === rel)) {
8448
+ const sep2 = existing === "" || existing.endsWith("\n") ? "" : "\n";
8449
+ fs3.appendFileSync(
8450
+ gitignore,
8451
+ `${sep2}# Runtime SCM claim state (per working tree): a branch checkout must never restore
8452
+ # a stale committed claim over the live one (issue #203 / Finding 28).
8453
+ ${rel}
8454
+ `
8455
+ );
8456
+ }
8457
+ } catch {
8458
+ }
8459
+ }
8427
8460
  var SCM_STATES = [
8428
8461
  "scaffold-complete",
8429
8462
  "feature-claimed",
@@ -8470,6 +8503,7 @@ function writeWorkflowState(projectDir, state) {
8470
8503
  throw new Error(`Refusing to write invalid SCM state:
8471
8504
  ${summary}`);
8472
8505
  }
8506
+ ensureWorkflowStateUntracked(projectDir);
8473
8507
  const dir = path3.join(projectDir, ".lakebase");
8474
8508
  fs3.mkdirSync(dir, { recursive: true });
8475
8509
  const target = stateFilePath(projectDir);
@@ -77698,7 +77698,9 @@ function resolveProfile(opts) {
77698
77698
  function buildInvocation(args, opts) {
77699
77699
  const base = opts.env ?? process.env;
77700
77700
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
77701
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
77701
+ const env = { ...base };
77702
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
77703
+ delete env.DATABRICKS_WORKSPACE_ID;
77702
77704
  const profile = resolveProfile(opts);
77703
77705
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
77704
77706
  return { argv, env, profile };
@@ -79268,8 +79270,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79268
79270
  var cached;
79269
79271
  function substrateSelfVersion() {
79270
79272
  if (cached !== void 0) return cached;
79271
- if ("0.2.40".length > 0) {
79272
- cached = "0.2.40";
79273
+ if ("0.2.42".length > 0) {
79274
+ cached = "0.2.42";
79273
79275
  return cached;
79274
79276
  }
79275
79277
  cached = "unknown";
@@ -80591,6 +80593,7 @@ async function reconcileTierBranch(args, deps = {}) {
80591
80593
  init_cjs_shims();
80592
80594
  var fs12 = __toESM(require("fs"), 1);
80593
80595
  var path11 = __toESM(require("path"), 1);
80596
+ var import_node_child_process6 = require("child_process");
80594
80597
  var SCM_STATES = [
80595
80598
  "scaffold-complete",
80596
80599
  "feature-claimed",
@@ -175,7 +175,9 @@ function resolveProfile(opts) {
175
175
  function buildInvocation(args, opts) {
176
176
  const base = opts.env ?? process.env;
177
177
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
178
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
178
+ const env = { ...base };
179
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
180
+ delete env.DATABRICKS_WORKSPACE_ID;
179
181
  const profile = resolveProfile(opts);
180
182
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
181
183
  return { argv, env, profile };
@@ -369,8 +371,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
369
371
  var cached;
370
372
  function substrateSelfVersion() {
371
373
  if (cached !== void 0) return cached;
372
- if ("0.2.40".length > 0) {
373
- cached = "0.2.40";
374
+ if ("0.2.42".length > 0) {
375
+ cached = "0.2.42";
374
376
  return cached;
375
377
  }
376
378
  cached = "unknown";
@@ -1682,6 +1684,7 @@ async function reconcileTierBranch(args, deps = {}) {
1682
1684
  // scripts/lakebase/scm-workflow-state.ts
1683
1685
  import * as fs11 from "fs";
1684
1686
  import * as path11 from "path";
1687
+ import { execFileSync as execFileSync3 } from "child_process";
1685
1688
  var SCM_STATES = [
1686
1689
  "scaffold-complete",
1687
1690
  "feature-claimed",
@@ -77816,7 +77816,9 @@ function resolveProfile(opts) {
77816
77816
  function buildInvocation(args, opts) {
77817
77817
  const base = opts.env ?? process.env;
77818
77818
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
77819
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
77819
+ const env = { ...base };
77820
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
77821
+ delete env.DATABRICKS_WORKSPACE_ID;
77820
77822
  const profile = resolveProfile(opts);
77821
77823
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
77822
77824
  return { argv, env, profile };
@@ -78759,6 +78761,39 @@ init_cjs_shims();
78759
78761
  init_cjs_shims();
78760
78762
  var fs6 = __toESM(require("fs"), 1);
78761
78763
  var path4 = __toESM(require("path"), 1);
78764
+ var import_node_child_process4 = require("child_process");
78765
+ function isGitTracked(projectDir, rel) {
78766
+ try {
78767
+ (0, import_node_child_process4.execFileSync)("git", ["ls-files", "--error-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
78768
+ return true;
78769
+ } catch {
78770
+ return false;
78771
+ }
78772
+ }
78773
+ function ensureWorkflowStateUntracked(projectDir) {
78774
+ const rel = ".lakebase/workflow-state.json";
78775
+ try {
78776
+ if (isGitTracked(projectDir, rel)) {
78777
+ (0, import_node_child_process4.execFileSync)("git", ["rm", "--cached", "--quiet", "--ignore-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
78778
+ }
78779
+ } catch {
78780
+ }
78781
+ try {
78782
+ const gitignore = path4.join(projectDir, ".gitignore");
78783
+ const existing = fs6.existsSync(gitignore) ? fs6.readFileSync(gitignore, "utf8") : "";
78784
+ if (!existing.split("\n").some((l) => l.trim() === rel)) {
78785
+ const sep = existing === "" || existing.endsWith("\n") ? "" : "\n";
78786
+ fs6.appendFileSync(
78787
+ gitignore,
78788
+ `${sep}# Runtime SCM claim state (per working tree): a branch checkout must never restore
78789
+ # a stale committed claim over the live one (issue #203 / Finding 28).
78790
+ ${rel}
78791
+ `
78792
+ );
78793
+ }
78794
+ } catch {
78795
+ }
78796
+ }
78762
78797
  var SCM_STATES = [
78763
78798
  "scaffold-complete",
78764
78799
  "feature-claimed",
@@ -78805,6 +78840,7 @@ function writeWorkflowState(projectDir, state) {
78805
78840
  throw new Error(`Refusing to write invalid SCM state:
78806
78841
  ${summary}`);
78807
78842
  }
78843
+ ensureWorkflowStateUntracked(projectDir);
78808
78844
  const dir = path4.join(projectDir, ".lakebase");
78809
78845
  fs6.mkdirSync(dir, { recursive: true });
78810
78846
  const target = stateFilePath(projectDir);
@@ -288,7 +288,9 @@ function resolveProfile(opts) {
288
288
  function buildInvocation(args, opts) {
289
289
  const base = opts.env ?? process.env;
290
290
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
291
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
291
+ const env = { ...base };
292
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
293
+ delete env.DATABRICKS_WORKSPACE_ID;
292
294
  const profile = resolveProfile(opts);
293
295
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
294
296
  return { argv, env, profile };
@@ -1159,6 +1161,39 @@ async function listLocalBranches(args) {
1159
1161
  // scripts/lakebase/scm-workflow-state.ts
1160
1162
  import * as fs5 from "fs";
1161
1163
  import * as path4 from "path";
1164
+ import { execFileSync as execFileSync4 } from "child_process";
1165
+ function isGitTracked(projectDir, rel) {
1166
+ try {
1167
+ execFileSync4("git", ["ls-files", "--error-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
1168
+ return true;
1169
+ } catch {
1170
+ return false;
1171
+ }
1172
+ }
1173
+ function ensureWorkflowStateUntracked(projectDir) {
1174
+ const rel = ".lakebase/workflow-state.json";
1175
+ try {
1176
+ if (isGitTracked(projectDir, rel)) {
1177
+ execFileSync4("git", ["rm", "--cached", "--quiet", "--ignore-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
1178
+ }
1179
+ } catch {
1180
+ }
1181
+ try {
1182
+ const gitignore = path4.join(projectDir, ".gitignore");
1183
+ const existing = fs5.existsSync(gitignore) ? fs5.readFileSync(gitignore, "utf8") : "";
1184
+ if (!existing.split("\n").some((l) => l.trim() === rel)) {
1185
+ const sep = existing === "" || existing.endsWith("\n") ? "" : "\n";
1186
+ fs5.appendFileSync(
1187
+ gitignore,
1188
+ `${sep}# Runtime SCM claim state (per working tree): a branch checkout must never restore
1189
+ # a stale committed claim over the live one (issue #203 / Finding 28).
1190
+ ${rel}
1191
+ `
1192
+ );
1193
+ }
1194
+ } catch {
1195
+ }
1196
+ }
1162
1197
  var SCM_STATES = [
1163
1198
  "scaffold-complete",
1164
1199
  "feature-claimed",
@@ -1205,6 +1240,7 @@ function writeWorkflowState(projectDir, state) {
1205
1240
  throw new Error(`Refusing to write invalid SCM state:
1206
1241
  ${summary}`);
1207
1242
  }
1243
+ ensureWorkflowStateUntracked(projectDir);
1208
1244
  const dir = path4.join(projectDir, ".lakebase");
1209
1245
  fs5.mkdirSync(dir, { recursive: true });
1210
1246
  const target = stateFilePath(projectDir);
@@ -77545,6 +77545,7 @@ function isCliEntry(importMetaUrl2) {
77545
77545
  init_cjs_shims();
77546
77546
  var fs = __toESM(require("fs"), 1);
77547
77547
  var path = __toESM(require("path"), 1);
77548
+ var import_node_child_process = require("child_process");
77548
77549
  var SCM_STATES = [
77549
77550
  "scaffold-complete",
77550
77551
  "feature-claimed",
@@ -77821,21 +77822,21 @@ var KIT_REGISTRIES = {
77821
77822
  init_cjs_shims();
77822
77823
  var fs6 = __toESM(require("fs"), 1);
77823
77824
  var path4 = __toESM(require("path"), 1);
77824
- var import_node_child_process3 = require("child_process");
77825
+ var import_node_child_process4 = require("child_process");
77825
77826
 
77826
77827
  // scripts/lakebase/branch-create.ts
77827
77828
  init_cjs_shims();
77828
77829
 
77829
77830
  // scripts/lakebase/databricks-cli.ts
77830
77831
  init_cjs_shims();
77831
- var import_node_child_process2 = require("child_process");
77832
+ var import_node_child_process3 = require("child_process");
77832
77833
  var import_node_util = require("util");
77833
77834
  var import_node_path = require("path");
77834
77835
 
77835
77836
  // scripts/lakebase/databricks-profile.ts
77836
77837
  init_cjs_shims();
77837
77838
  var fs2 = __toESM(require("fs"), 1);
77838
- var import_node_child_process = require("child_process");
77839
+ var import_node_child_process2 = require("child_process");
77839
77840
 
77840
77841
  // scripts/util/exec.ts
77841
77842
  init_cjs_shims();
@@ -77847,7 +77848,7 @@ var fs3 = __toESM(require("fs"), 1);
77847
77848
  var path2 = __toESM(require("path"), 1);
77848
77849
 
77849
77850
  // scripts/lakebase/databricks-cli.ts
77850
- var execFileP = (0, import_node_util.promisify)(import_node_child_process2.execFile);
77851
+ var execFileP = (0, import_node_util.promisify)(import_node_child_process3.execFile);
77851
77852
 
77852
77853
  // scripts/util/poll-until.ts
77853
77854
  init_cjs_shims();
@@ -27,6 +27,7 @@ function isCliEntry(importMetaUrl) {
27
27
  // scripts/lakebase/scm-workflow-state.ts
28
28
  import * as fs from "fs";
29
29
  import * as path from "path";
30
+ import { execFileSync } from "child_process";
30
31
  var SCM_STATES = [
31
32
  "scaffold-complete",
32
33
  "feature-claimed",
@@ -297,16 +298,16 @@ var KIT_REGISTRIES = {
297
298
  // scripts/lakebase/paired-branch.ts
298
299
  import * as fs5 from "fs";
299
300
  import * as path4 from "path";
300
- import { execFileSync as execFileSync3 } from "child_process";
301
+ import { execFileSync as execFileSync4 } from "child_process";
301
302
 
302
303
  // scripts/lakebase/databricks-cli.ts
303
- import { execFile, execFileSync as execFileSync2 } from "child_process";
304
+ import { execFile, execFileSync as execFileSync3 } from "child_process";
304
305
  import { promisify } from "util";
305
306
  import { join as join3 } from "path";
306
307
 
307
308
  // scripts/lakebase/databricks-profile.ts
308
309
  import * as fs2 from "fs";
309
- import { execFileSync } from "child_process";
310
+ import { execFileSync as execFileSync2 } from "child_process";
310
311
 
311
312
  // scripts/util/exec.ts
312
313
  import * as cp from "child_process";
@@ -8351,6 +8351,39 @@ async function pollUntil(args) {
8351
8351
  init_cjs_shims();
8352
8352
  var fs3 = __toESM(require("fs"), 1);
8353
8353
  var path2 = __toESM(require("path"), 1);
8354
+ var import_node_child_process4 = require("child_process");
8355
+ function isGitTracked(projectDir, rel) {
8356
+ try {
8357
+ (0, import_node_child_process4.execFileSync)("git", ["ls-files", "--error-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
8358
+ return true;
8359
+ } catch {
8360
+ return false;
8361
+ }
8362
+ }
8363
+ function ensureWorkflowStateUntracked(projectDir) {
8364
+ const rel = ".lakebase/workflow-state.json";
8365
+ try {
8366
+ if (isGitTracked(projectDir, rel)) {
8367
+ (0, import_node_child_process4.execFileSync)("git", ["rm", "--cached", "--quiet", "--ignore-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
8368
+ }
8369
+ } catch {
8370
+ }
8371
+ try {
8372
+ const gitignore = path2.join(projectDir, ".gitignore");
8373
+ const existing = fs3.existsSync(gitignore) ? fs3.readFileSync(gitignore, "utf8") : "";
8374
+ if (!existing.split("\n").some((l) => l.trim() === rel)) {
8375
+ const sep2 = existing === "" || existing.endsWith("\n") ? "" : "\n";
8376
+ fs3.appendFileSync(
8377
+ gitignore,
8378
+ `${sep2}# Runtime SCM claim state (per working tree): a branch checkout must never restore
8379
+ # a stale committed claim over the live one (issue #203 / Finding 28).
8380
+ ${rel}
8381
+ `
8382
+ );
8383
+ }
8384
+ } catch {
8385
+ }
8386
+ }
8354
8387
  var SCM_STATES = [
8355
8388
  "scaffold-complete",
8356
8389
  "feature-claimed",
@@ -8397,6 +8430,7 @@ function writeWorkflowState(projectDir, state) {
8397
8430
  throw new Error(`Refusing to write invalid SCM state:
8398
8431
  ${summary}`);
8399
8432
  }
8433
+ ensureWorkflowStateUntracked(projectDir);
8400
8434
  const dir = path2.join(projectDir, ".lakebase");
8401
8435
  fs3.mkdirSync(dir, { recursive: true });
8402
8436
  const target = stateFilePath(projectDir);
@@ -8339,6 +8339,39 @@ async function pollUntil(args) {
8339
8339
  init_esm_shims();
8340
8340
  import * as fs3 from "fs";
8341
8341
  import * as path3 from "path";
8342
+ import { execFileSync as execFileSync4 } from "child_process";
8343
+ function isGitTracked(projectDir, rel) {
8344
+ try {
8345
+ execFileSync4("git", ["ls-files", "--error-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
8346
+ return true;
8347
+ } catch {
8348
+ return false;
8349
+ }
8350
+ }
8351
+ function ensureWorkflowStateUntracked(projectDir) {
8352
+ const rel = ".lakebase/workflow-state.json";
8353
+ try {
8354
+ if (isGitTracked(projectDir, rel)) {
8355
+ execFileSync4("git", ["rm", "--cached", "--quiet", "--ignore-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
8356
+ }
8357
+ } catch {
8358
+ }
8359
+ try {
8360
+ const gitignore = path3.join(projectDir, ".gitignore");
8361
+ const existing = fs3.existsSync(gitignore) ? fs3.readFileSync(gitignore, "utf8") : "";
8362
+ if (!existing.split("\n").some((l) => l.trim() === rel)) {
8363
+ const sep2 = existing === "" || existing.endsWith("\n") ? "" : "\n";
8364
+ fs3.appendFileSync(
8365
+ gitignore,
8366
+ `${sep2}# Runtime SCM claim state (per working tree): a branch checkout must never restore
8367
+ # a stale committed claim over the live one (issue #203 / Finding 28).
8368
+ ${rel}
8369
+ `
8370
+ );
8371
+ }
8372
+ } catch {
8373
+ }
8374
+ }
8342
8375
  var SCM_STATES = [
8343
8376
  "scaffold-complete",
8344
8377
  "feature-claimed",
@@ -8385,6 +8418,7 @@ function writeWorkflowState(projectDir, state) {
8385
8418
  throw new Error(`Refusing to write invalid SCM state:
8386
8419
  ${summary}`);
8387
8420
  }
8421
+ ensureWorkflowStateUntracked(projectDir);
8388
8422
  const dir = path3.join(projectDir, ".lakebase");
8389
8423
  fs3.mkdirSync(dir, { recursive: true });
8390
8424
  const target = stateFilePath(projectDir);
@@ -1659,8 +1659,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
1659
1659
  var cached;
1660
1660
  function substrateSelfVersion() {
1661
1661
  if (cached !== void 0) return cached;
1662
- if ("0.2.40".length > 0) {
1663
- cached = "0.2.40";
1662
+ if ("0.2.42".length > 0) {
1663
+ cached = "0.2.42";
1664
1664
  return cached;
1665
1665
  }
1666
1666
  cached = "unknown";
@@ -1895,7 +1895,9 @@ function resolveProfile(opts) {
1895
1895
  function buildInvocation(args, opts) {
1896
1896
  const base = opts.env ?? process.env;
1897
1897
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
1898
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
1898
+ const env = { ...base };
1899
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
1900
+ delete env.DATABRICKS_WORKSPACE_ID;
1899
1901
  const profile = resolveProfile(opts);
1900
1902
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
1901
1903
  return { argv, env, profile };