@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
@@ -1751,7 +1751,9 @@ function resolveProfile(opts) {
1751
1751
  function buildInvocation(args, opts) {
1752
1752
  const base = opts.env ?? process.env;
1753
1753
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
1754
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
1754
+ const env = { ...base };
1755
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
1756
+ delete env.DATABRICKS_WORKSPACE_ID;
1755
1757
  const profile = resolveProfile(opts);
1756
1758
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
1757
1759
  return { argv, env, profile };
@@ -2498,8 +2500,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
2498
2500
  var cached;
2499
2501
  function substrateSelfVersion() {
2500
2502
  if (cached !== void 0) return cached;
2501
- if ("0.2.40".length > 0) {
2502
- cached = "0.2.40";
2503
+ if ("0.2.42".length > 0) {
2504
+ cached = "0.2.42";
2503
2505
  return cached;
2504
2506
  }
2505
2507
  cached = "unknown";
@@ -12282,12 +12284,27 @@ function runTestsE2eBlock() {
12282
12284
  ' export VITE_PROXY_TARGET="http://127.0.0.1:${E2E_BACKEND_PORT}"',
12283
12285
  ' echo "Local E2E free-port: backend :$E2E_BACKEND_PORT / client :$E2E_CLIENT_PORT"',
12284
12286
  "fi",
12287
+ // Stale-server hygiene (issue #197): CI=1 on the Playwright invocations below
12288
+ // forces EVERY config vintage's reuseExistingServer guard OFF (old `!CI` and
12289
+ // new `!!BASE_URL` alike), so the verify never reuses a stale server bound to
12290
+ // an unmigrated branch (the false-500 misdiagnosis). A lingering uvicorn/vite
12291
+ // on the conventional default ports still serves STALE schema to anything
12292
+ // that reaches it, so clear it (TERM, not KILL) before the boot - never when
12293
+ // the caller pre-set the ports (the deploy gate owns that server; BASE_URL).
12294
+ 'if [ -z "${BASE_URL:-}" ] && command -v lsof >/dev/null 2>&1; then',
12295
+ ' for p in "${E2E_BACKEND_PORT:-8000}" "${E2E_CLIENT_PORT:-5173}"; do',
12296
+ ' if lsof -iTCP:"$p" -sTCP:LISTEN -n -P >/dev/null 2>&1; then',
12297
+ ' echo "Local E2E: clearing a stale listener on :$p before the webServer boot"',
12298
+ ' lsof -ti tcp:"$p" 2>/dev/null | xargs kill 2>/dev/null || true',
12299
+ " fi",
12300
+ " done",
12301
+ "fi",
12285
12302
  'if [ -f "$REPO_ROOT/playwright.config.ts" ] || [ -f "$REPO_ROOT/playwright.config.js" ]; then',
12286
12303
  ' echo "Running Playwright E2E tests..."',
12287
12304
  ' if [ -f "$REPO_ROOT/package.json" ] && command -v npm >/dev/null 2>&1; then',
12288
- ' (cd "$REPO_ROOT" && npm run test:e2e)',
12305
+ ' (cd "$REPO_ROOT" && CI=1 npm run test:e2e)',
12289
12306
  " else",
12290
- ' (cd "$REPO_ROOT" && npx --yes playwright test)',
12307
+ ' (cd "$REPO_ROOT" && CI=1 npx --yes playwright test)',
12291
12308
  " fi",
12292
12309
  // Python E2E: pytest-playwright + the shipped tests/e2e/conftest.py
12293
12310
  // (live_server). Gated on the conftest + pyproject so it only fires for a
@@ -12326,7 +12343,8 @@ function runTestsE2eBlock() {
12326
12343
  'if [ -f "$REPO_ROOT/client/playwright.config.ts" ] || [ -f "$REPO_ROOT/client/playwright.config.js" ] || [ -f "$REPO_ROOT/client/playwright.config.mjs" ]; then',
12327
12344
  ' echo "Running client Playwright E2E tests..."',
12328
12345
  ' (cd "$REPO_ROOT/client" && npx --yes playwright install chromium)',
12329
- ' (cd "$REPO_ROOT/client" && npx --yes playwright test --pass-with-no-tests)',
12346
+ // CI=1: no server reuse on any config vintage (see the stale-server note above).
12347
+ ' (cd "$REPO_ROOT/client" && CI=1 npx --yes playwright test --pass-with-no-tests)',
12330
12348
  "fi",
12331
12349
  ""
12332
12350
  ].join("\n");
@@ -12931,6 +12949,39 @@ async function syncCiSecrets(args) {
12931
12949
  init_esm_shims();
12932
12950
  import * as fs17 from "fs";
12933
12951
  import * as path16 from "path";
12952
+ import { execFileSync as execFileSync6 } from "child_process";
12953
+ function isGitTracked(projectDir, rel) {
12954
+ try {
12955
+ execFileSync6("git", ["ls-files", "--error-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
12956
+ return true;
12957
+ } catch {
12958
+ return false;
12959
+ }
12960
+ }
12961
+ function ensureWorkflowStateUntracked(projectDir) {
12962
+ const rel = ".lakebase/workflow-state.json";
12963
+ try {
12964
+ if (isGitTracked(projectDir, rel)) {
12965
+ execFileSync6("git", ["rm", "--cached", "--quiet", "--ignore-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
12966
+ }
12967
+ } catch {
12968
+ }
12969
+ try {
12970
+ const gitignore = path16.join(projectDir, ".gitignore");
12971
+ const existing = fs17.existsSync(gitignore) ? fs17.readFileSync(gitignore, "utf8") : "";
12972
+ if (!existing.split("\n").some((l) => l.trim() === rel)) {
12973
+ const sep4 = existing === "" || existing.endsWith("\n") ? "" : "\n";
12974
+ fs17.appendFileSync(
12975
+ gitignore,
12976
+ `${sep4}# Runtime SCM claim state (per working tree): a branch checkout must never restore
12977
+ # a stale committed claim over the live one (issue #203 / Finding 28).
12978
+ ${rel}
12979
+ `
12980
+ );
12981
+ }
12982
+ } catch {
12983
+ }
12984
+ }
12934
12985
  var SCM_STATES = [
12935
12986
  "scaffold-complete",
12936
12987
  "feature-claimed",
@@ -12983,6 +13034,7 @@ function writeWorkflowState(projectDir, state) {
12983
13034
  throw new Error(`Refusing to write invalid SCM state:
12984
13035
  ${summary}`);
12985
13036
  }
13037
+ ensureWorkflowStateUntracked(projectDir);
12986
13038
  const dir = path16.join(projectDir, ".lakebase");
12987
13039
  fs17.mkdirSync(dir, { recursive: true });
12988
13040
  const target = stateFilePath(projectDir);
@@ -16239,7 +16291,6 @@ function parentForTopology(t, defaultLeaf) {
16239
16291
  // scripts/lakebase/scm-doctor.ts
16240
16292
  init_esm_shims();
16241
16293
  import * as fs29 from "fs";
16242
- import { execFileSync as execFileSync6 } from "child_process";
16243
16294
  import * as path29 from "path";
16244
16295
  var FEATURE_PREFIX = "feature/";
16245
16296
  var TIER_LEAFS2 = DEFAULT_PROTECTED_TIER_NAMES;
@@ -16257,14 +16308,6 @@ function readEnv(projectDir) {
16257
16308
  function leafOf2(b) {
16258
16309
  return b.name.split("/").pop() ?? b.name;
16259
16310
  }
16260
- function isGitTracked(projectDir, rel) {
16261
- try {
16262
- execFileSync6("git", ["ls-files", "--error-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
16263
- return true;
16264
- } catch {
16265
- return false;
16266
- }
16267
- }
16268
16311
  function worstOf(a, b) {
16269
16312
  const order = ["ok", "warn", "fail"];
16270
16313
  return order[Math.max(order.indexOf(a), order.indexOf(b))];
@@ -17725,6 +17768,7 @@ export {
17725
17768
  installPlaywright,
17726
17769
  isAllSchemas,
17727
17770
  isForeignFeatureClaim,
17771
+ isGitTracked,
17728
17772
  isLongRunningTierBranch,
17729
17773
  isLtsJavaVersion,
17730
17774
  isPrereleaseBootVersion,
@@ -77700,7 +77700,9 @@ function resolveProfile(opts) {
77700
77700
  function buildInvocation(args, opts) {
77701
77701
  const base = opts.env ?? process.env;
77702
77702
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
77703
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
77703
+ const env = { ...base };
77704
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
77705
+ delete env.DATABRICKS_WORKSPACE_ID;
77704
77706
  const profile = resolveProfile(opts);
77705
77707
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
77706
77708
  return { argv, env, profile };
@@ -79270,8 +79272,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79270
79272
  var cached;
79271
79273
  function substrateSelfVersion() {
79272
79274
  if (cached !== void 0) return cached;
79273
- if ("0.2.40".length > 0) {
79274
- cached = "0.2.40";
79275
+ if ("0.2.42".length > 0) {
79276
+ cached = "0.2.42";
79275
79277
  return cached;
79276
79278
  }
79277
79279
  cached = "unknown";
@@ -179,7 +179,9 @@ function resolveProfile(opts) {
179
179
  function buildInvocation(args, opts) {
180
180
  const base = opts.env ?? process.env;
181
181
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
182
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
182
+ const env = { ...base };
183
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
184
+ delete env.DATABRICKS_WORKSPACE_ID;
183
185
  const profile = resolveProfile(opts);
184
186
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
185
187
  return { argv, env, profile };
@@ -373,8 +375,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
373
375
  var cached;
374
376
  function substrateSelfVersion() {
375
377
  if (cached !== void 0) return cached;
376
- if ("0.2.40".length > 0) {
377
- cached = "0.2.40";
378
+ if ("0.2.42".length > 0) {
379
+ cached = "0.2.42";
378
380
  return cached;
379
381
  }
380
382
  cached = "unknown";
@@ -77700,7 +77700,9 @@ function resolveProfile(opts) {
77700
77700
  function buildInvocation(args, opts) {
77701
77701
  const base = opts.env ?? process.env;
77702
77702
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
77703
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
77703
+ const env = { ...base };
77704
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
77705
+ delete env.DATABRICKS_WORKSPACE_ID;
77704
77706
  const profile = resolveProfile(opts);
77705
77707
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
77706
77708
  return { argv, env, profile };
@@ -79270,8 +79272,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79270
79272
  var cached;
79271
79273
  function substrateSelfVersion() {
79272
79274
  if (cached !== void 0) return cached;
79273
- if ("0.2.40".length > 0) {
79274
- cached = "0.2.40";
79275
+ if ("0.2.42".length > 0) {
79276
+ cached = "0.2.42";
79275
79277
  return cached;
79276
79278
  }
79277
79279
  cached = "unknown";
@@ -179,7 +179,9 @@ function resolveProfile(opts) {
179
179
  function buildInvocation(args, opts) {
180
180
  const base = opts.env ?? process.env;
181
181
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
182
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
182
+ const env = { ...base };
183
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
184
+ delete env.DATABRICKS_WORKSPACE_ID;
183
185
  const profile = resolveProfile(opts);
184
186
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
185
187
  return { argv, env, profile };
@@ -373,8 +375,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
373
375
  var cached;
374
376
  function substrateSelfVersion() {
375
377
  if (cached !== void 0) return cached;
376
- if ("0.2.40".length > 0) {
377
- cached = "0.2.40";
378
+ if ("0.2.42".length > 0) {
379
+ cached = "0.2.42";
378
380
  return cached;
379
381
  }
380
382
  cached = "unknown";
@@ -77695,7 +77695,9 @@ function resolveProfile(opts) {
77695
77695
  function buildInvocation(args, opts) {
77696
77696
  const base = opts.env ?? process.env;
77697
77697
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
77698
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
77698
+ const env = { ...base };
77699
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
77700
+ delete env.DATABRICKS_WORKSPACE_ID;
77699
77701
  const profile = resolveProfile(opts);
77700
77702
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
77701
77703
  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";
@@ -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";
@@ -77700,7 +77700,9 @@ function resolveProfile(opts) {
77700
77700
  function buildInvocation(args, opts) {
77701
77701
  const base = opts.env ?? process.env;
77702
77702
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
77703
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
77703
+ const env = { ...base };
77704
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
77705
+ delete env.DATABRICKS_WORKSPACE_ID;
77704
77706
  const profile = resolveProfile(opts);
77705
77707
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
77706
77708
  return { argv, env, profile };
@@ -79304,8 +79306,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79304
79306
  var cached;
79305
79307
  function substrateSelfVersion() {
79306
79308
  if (cached !== void 0) return cached;
79307
- if ("0.2.40".length > 0) {
79308
- cached = "0.2.40";
79309
+ if ("0.2.42".length > 0) {
79310
+ cached = "0.2.42";
79309
79311
  return cached;
79310
79312
  }
79311
79313
  cached = "unknown";
@@ -179,7 +179,9 @@ function resolveProfile(opts) {
179
179
  function buildInvocation(args, opts) {
180
180
  const base = opts.env ?? process.env;
181
181
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
182
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
182
+ const env = { ...base };
183
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
184
+ delete env.DATABRICKS_WORKSPACE_ID;
183
185
  const profile = resolveProfile(opts);
184
186
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
185
187
  return { argv, env, profile };
@@ -407,8 +409,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
407
409
  var cached;
408
410
  function substrateSelfVersion() {
409
411
  if (cached !== void 0) return cached;
410
- if ("0.2.40".length > 0) {
411
- cached = "0.2.40";
412
+ if ("0.2.42".length > 0) {
413
+ cached = "0.2.42";
412
414
  return cached;
413
415
  }
414
416
  cached = "unknown";
@@ -77755,7 +77755,9 @@ function resolveProfile(opts) {
77755
77755
  function buildInvocation(args, opts) {
77756
77756
  const base = opts.env ?? process.env;
77757
77757
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
77758
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
77758
+ const env = { ...base };
77759
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
77760
+ delete env.DATABRICKS_WORKSPACE_ID;
77759
77761
  const profile = resolveProfile(opts);
77760
77762
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
77761
77763
  return { argv, env, profile };
@@ -78140,6 +78142,39 @@ async function deletePairedBranch(args) {
78140
78142
  init_cjs_shims();
78141
78143
  var fs6 = __toESM(require("fs"), 1);
78142
78144
  var path4 = __toESM(require("path"), 1);
78145
+ var import_node_child_process4 = require("child_process");
78146
+ function isGitTracked(projectDir, rel) {
78147
+ try {
78148
+ (0, import_node_child_process4.execFileSync)("git", ["ls-files", "--error-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
78149
+ return true;
78150
+ } catch {
78151
+ return false;
78152
+ }
78153
+ }
78154
+ function ensureWorkflowStateUntracked(projectDir) {
78155
+ const rel = ".lakebase/workflow-state.json";
78156
+ try {
78157
+ if (isGitTracked(projectDir, rel)) {
78158
+ (0, import_node_child_process4.execFileSync)("git", ["rm", "--cached", "--quiet", "--ignore-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
78159
+ }
78160
+ } catch {
78161
+ }
78162
+ try {
78163
+ const gitignore = path4.join(projectDir, ".gitignore");
78164
+ const existing = fs6.existsSync(gitignore) ? fs6.readFileSync(gitignore, "utf8") : "";
78165
+ if (!existing.split("\n").some((l) => l.trim() === rel)) {
78166
+ const sep = existing === "" || existing.endsWith("\n") ? "" : "\n";
78167
+ fs6.appendFileSync(
78168
+ gitignore,
78169
+ `${sep}# Runtime SCM claim state (per working tree): a branch checkout must never restore
78170
+ # a stale committed claim over the live one (issue #203 / Finding 28).
78171
+ ${rel}
78172
+ `
78173
+ );
78174
+ }
78175
+ } catch {
78176
+ }
78177
+ }
78143
78178
  var SCM_STATES = [
78144
78179
  "scaffold-complete",
78145
78180
  "feature-claimed",
@@ -78186,6 +78221,7 @@ function writeWorkflowState(projectDir, state) {
78186
78221
  throw new Error(`Refusing to write invalid SCM state:
78187
78222
  ${summary}`);
78188
78223
  }
78224
+ ensureWorkflowStateUntracked(projectDir);
78189
78225
  const dir = path4.join(projectDir, ".lakebase");
78190
78226
  fs6.mkdirSync(dir, { recursive: true });
78191
78227
  const target = stateFilePath(projectDir);
@@ -226,7 +226,9 @@ function resolveProfile(opts) {
226
226
  function buildInvocation(args, opts) {
227
227
  const base = opts.env ?? process.env;
228
228
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
229
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
229
+ const env = { ...base };
230
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
231
+ delete env.DATABRICKS_WORKSPACE_ID;
230
232
  const profile = resolveProfile(opts);
231
233
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
232
234
  return { argv, env, profile };
@@ -545,6 +547,39 @@ async function deletePairedBranch(args) {
545
547
  // scripts/lakebase/scm-workflow-state.ts
546
548
  import * as fs5 from "fs";
547
549
  import * as path4 from "path";
550
+ import { execFileSync as execFileSync4 } from "child_process";
551
+ function isGitTracked(projectDir, rel) {
552
+ try {
553
+ execFileSync4("git", ["ls-files", "--error-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
554
+ return true;
555
+ } catch {
556
+ return false;
557
+ }
558
+ }
559
+ function ensureWorkflowStateUntracked(projectDir) {
560
+ const rel = ".lakebase/workflow-state.json";
561
+ try {
562
+ if (isGitTracked(projectDir, rel)) {
563
+ execFileSync4("git", ["rm", "--cached", "--quiet", "--ignore-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
564
+ }
565
+ } catch {
566
+ }
567
+ try {
568
+ const gitignore = path4.join(projectDir, ".gitignore");
569
+ const existing = fs5.existsSync(gitignore) ? fs5.readFileSync(gitignore, "utf8") : "";
570
+ if (!existing.split("\n").some((l) => l.trim() === rel)) {
571
+ const sep = existing === "" || existing.endsWith("\n") ? "" : "\n";
572
+ fs5.appendFileSync(
573
+ gitignore,
574
+ `${sep}# Runtime SCM claim state (per working tree): a branch checkout must never restore
575
+ # a stale committed claim over the live one (issue #203 / Finding 28).
576
+ ${rel}
577
+ `
578
+ );
579
+ }
580
+ } catch {
581
+ }
582
+ }
548
583
  var SCM_STATES = [
549
584
  "scaffold-complete",
550
585
  "feature-claimed",
@@ -591,6 +626,7 @@ function writeWorkflowState(projectDir, state) {
591
626
  throw new Error(`Refusing to write invalid SCM state:
592
627
  ${summary}`);
593
628
  }
629
+ ensureWorkflowStateUntracked(projectDir);
594
630
  const dir = path4.join(projectDir, ".lakebase");
595
631
  fs5.mkdirSync(dir, { recursive: true });
596
632
  const target = stateFilePath(projectDir);
@@ -258,7 +258,9 @@ function resolveProfile(opts) {
258
258
  function buildInvocation(args, opts) {
259
259
  const base = opts.env ?? process.env;
260
260
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
261
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
261
+ const env = { ...base };
262
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
263
+ delete env.DATABRICKS_WORKSPACE_ID;
262
264
  const profile = resolveProfile(opts);
263
265
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
264
266
  return { argv, env, profile };
@@ -445,6 +447,39 @@ function dbcli(args, host) {
445
447
  // scripts/lakebase/scm-workflow-state.ts
446
448
  var fs3 = __toESM(require("fs"), 1);
447
449
  var path2 = __toESM(require("path"), 1);
450
+ var import_node_child_process3 = require("child_process");
451
+ function isGitTracked(projectDir, rel) {
452
+ try {
453
+ (0, import_node_child_process3.execFileSync)("git", ["ls-files", "--error-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
454
+ return true;
455
+ } catch {
456
+ return false;
457
+ }
458
+ }
459
+ function ensureWorkflowStateUntracked(projectDir) {
460
+ const rel = ".lakebase/workflow-state.json";
461
+ try {
462
+ if (isGitTracked(projectDir, rel)) {
463
+ (0, import_node_child_process3.execFileSync)("git", ["rm", "--cached", "--quiet", "--ignore-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
464
+ }
465
+ } catch {
466
+ }
467
+ try {
468
+ const gitignore = path2.join(projectDir, ".gitignore");
469
+ const existing = fs3.existsSync(gitignore) ? fs3.readFileSync(gitignore, "utf8") : "";
470
+ if (!existing.split("\n").some((l) => l.trim() === rel)) {
471
+ const sep = existing === "" || existing.endsWith("\n") ? "" : "\n";
472
+ fs3.appendFileSync(
473
+ gitignore,
474
+ `${sep}# Runtime SCM claim state (per working tree): a branch checkout must never restore
475
+ # a stale committed claim over the live one (issue #203 / Finding 28).
476
+ ${rel}
477
+ `
478
+ );
479
+ }
480
+ } catch {
481
+ }
482
+ }
448
483
  var SCM_STATES = [
449
484
  "scaffold-complete",
450
485
  "feature-claimed",
@@ -491,6 +526,7 @@ function writeWorkflowState(projectDir, state) {
491
526
  throw new Error(`Refusing to write invalid SCM state:
492
527
  ${summary}`);
493
528
  }
529
+ ensureWorkflowStateUntracked(projectDir);
494
530
  const dir = path2.join(projectDir, ".lakebase");
495
531
  fs3.mkdirSync(dir, { recursive: true });
496
532
  const target = stateFilePath(projectDir);
@@ -219,7 +219,9 @@ function resolveProfile(opts) {
219
219
  function buildInvocation(args, opts) {
220
220
  const base = opts.env ?? process.env;
221
221
  const trimmedHost = effectiveHost(opts)?.replace(/\/+$/, "");
222
- const env = trimmedHost ? { ...base, DATABRICKS_HOST: trimmedHost } : base;
222
+ const env = { ...base };
223
+ if (trimmedHost) env.DATABRICKS_HOST = trimmedHost;
224
+ delete env.DATABRICKS_WORKSPACE_ID;
223
225
  const profile = resolveProfile(opts);
224
226
  const argv = profile && !opts.noProfile && !args.includes("--profile") ? [...args, "--profile", profile] : args;
225
227
  return { argv, env, profile };
@@ -406,6 +408,39 @@ function dbcli(args, host) {
406
408
  // scripts/lakebase/scm-workflow-state.ts
407
409
  import * as fs3 from "fs";
408
410
  import * as path2 from "path";
411
+ import { execFileSync as execFileSync3 } from "child_process";
412
+ function isGitTracked(projectDir, rel) {
413
+ try {
414
+ execFileSync3("git", ["ls-files", "--error-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
415
+ return true;
416
+ } catch {
417
+ return false;
418
+ }
419
+ }
420
+ function ensureWorkflowStateUntracked(projectDir) {
421
+ const rel = ".lakebase/workflow-state.json";
422
+ try {
423
+ if (isGitTracked(projectDir, rel)) {
424
+ execFileSync3("git", ["rm", "--cached", "--quiet", "--ignore-unmatch", "--", rel], { cwd: projectDir, stdio: "ignore" });
425
+ }
426
+ } catch {
427
+ }
428
+ try {
429
+ const gitignore = path2.join(projectDir, ".gitignore");
430
+ const existing = fs3.existsSync(gitignore) ? fs3.readFileSync(gitignore, "utf8") : "";
431
+ if (!existing.split("\n").some((l) => l.trim() === rel)) {
432
+ const sep = existing === "" || existing.endsWith("\n") ? "" : "\n";
433
+ fs3.appendFileSync(
434
+ gitignore,
435
+ `${sep}# Runtime SCM claim state (per working tree): a branch checkout must never restore
436
+ # a stale committed claim over the live one (issue #203 / Finding 28).
437
+ ${rel}
438
+ `
439
+ );
440
+ }
441
+ } catch {
442
+ }
443
+ }
409
444
  var SCM_STATES = [
410
445
  "scaffold-complete",
411
446
  "feature-claimed",
@@ -452,6 +487,7 @@ function writeWorkflowState(projectDir, state) {
452
487
  throw new Error(`Refusing to write invalid SCM state:
453
488
  ${summary}`);
454
489
  }
490
+ ensureWorkflowStateUntracked(projectDir);
455
491
  const dir = path2.join(projectDir, ".lakebase");
456
492
  fs3.mkdirSync(dir, { recursive: true });
457
493
  const target = stateFilePath(projectDir);