@databricks-solutions/lakebase-scm-utils 0.3.0 → 0.3.1

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 (36) hide show
  1. package/README.md +10 -4
  2. package/dist/scripts/index.cjs +2313 -2256
  3. package/dist/scripts/index.js +371 -314
  4. package/dist/scripts/lakebase/ci-resolve-branch.cli.cjs +2 -2
  5. package/dist/scripts/lakebase/ci-resolve-branch.cli.js +2 -2
  6. package/dist/scripts/lakebase/collapse-heads.cli.cjs +2 -2
  7. package/dist/scripts/lakebase/collapse-heads.cli.js +2 -2
  8. package/dist/scripts/lakebase/detect-language.cli.cjs +2 -2
  9. package/dist/scripts/lakebase/detect-language.cli.js +2 -2
  10. package/dist/scripts/lakebase/doctor.cli.cjs +2 -2
  11. package/dist/scripts/lakebase/doctor.cli.js +2 -2
  12. package/dist/scripts/lakebase/get-connection.cli.cjs +2 -2
  13. package/dist/scripts/lakebase/get-connection.cli.js +2 -2
  14. package/dist/scripts/lakebase/index.cjs +2310 -2217
  15. package/dist/scripts/lakebase/index.js +365 -272
  16. package/dist/scripts/lakebase/infra-runner.cli.cjs +2 -2
  17. package/dist/scripts/lakebase/infra-runner.cli.js +2 -2
  18. package/dist/scripts/lakebase/new-migration.cli.cjs +2 -2
  19. package/dist/scripts/lakebase/new-migration.cli.js +2 -2
  20. package/dist/scripts/lakebase/schema-diff.cli.cjs +2 -2
  21. package/dist/scripts/lakebase/schema-diff.cli.js +2 -2
  22. package/dist/scripts/lakebase/schema-migrate.cli.cjs +2 -2
  23. package/dist/scripts/lakebase/schema-migrate.cli.js +2 -2
  24. package/dist/scripts/lakebase/scm-claim-feature.cli.cjs +2 -2
  25. package/dist/scripts/lakebase/scm-claim-feature.cli.js +2 -2
  26. package/dist/scripts/lakebase/scm-doctor.cli.cjs +2 -2
  27. package/dist/scripts/lakebase/scm-doctor.cli.js +2 -2
  28. package/dist/scripts/lakebase/scm-merge.cli.cjs +2 -2
  29. package/dist/scripts/lakebase/scm-merge.cli.js +2 -2
  30. package/dist/scripts/lakebase/scm-reconcile-tier.cli.cjs +2 -2
  31. package/dist/scripts/lakebase/scm-reconcile-tier.cli.js +2 -2
  32. package/dist/scripts/util/index.cjs +2 -2
  33. package/dist/scripts/util/index.js +2 -2
  34. package/package.json +1 -1
  35. package/scripts/lakebase/client-lockfile.ts +102 -0
  36. package/scripts/lakebase/create-project.ts +19 -0
@@ -79290,8 +79290,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79290
79290
  var cached;
79291
79291
  function substrateSelfVersion() {
79292
79292
  if (cached !== void 0) return cached;
79293
- if ("0.3.0".length > 0) {
79294
- cached = "0.3.0";
79293
+ if ("0.3.1".length > 0) {
79294
+ cached = "0.3.1";
79295
79295
  return cached;
79296
79296
  }
79297
79297
  cached = "unknown";
@@ -393,8 +393,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
393
393
  var cached;
394
394
  function substrateSelfVersion() {
395
395
  if (cached !== void 0) return cached;
396
- if ("0.3.0".length > 0) {
397
- cached = "0.3.0";
396
+ if ("0.3.1".length > 0) {
397
+ cached = "0.3.1";
398
398
  return cached;
399
399
  }
400
400
  cached = "unknown";
@@ -79290,8 +79290,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79290
79290
  var cached;
79291
79291
  function substrateSelfVersion() {
79292
79292
  if (cached !== void 0) return cached;
79293
- if ("0.3.0".length > 0) {
79294
- cached = "0.3.0";
79293
+ if ("0.3.1".length > 0) {
79294
+ cached = "0.3.1";
79295
79295
  return cached;
79296
79296
  }
79297
79297
  cached = "unknown";
@@ -393,8 +393,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
393
393
  var cached;
394
394
  function substrateSelfVersion() {
395
395
  if (cached !== void 0) return cached;
396
- if ("0.3.0".length > 0) {
397
- cached = "0.3.0";
396
+ if ("0.3.1".length > 0) {
397
+ cached = "0.3.1";
398
398
  return cached;
399
399
  }
400
400
  cached = "unknown";
@@ -79288,8 +79288,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79288
79288
  var cached;
79289
79289
  function substrateSelfVersion() {
79290
79290
  if (cached !== void 0) return cached;
79291
- if ("0.3.0".length > 0) {
79292
- cached = "0.3.0";
79291
+ if ("0.3.1".length > 0) {
79292
+ cached = "0.3.1";
79293
79293
  return cached;
79294
79294
  }
79295
79295
  cached = "unknown";
@@ -389,8 +389,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
389
389
  var cached;
390
390
  function substrateSelfVersion() {
391
391
  if (cached !== void 0) return cached;
392
- if ("0.3.0".length > 0) {
393
- cached = "0.3.0";
392
+ if ("0.3.1".length > 0) {
393
+ cached = "0.3.1";
394
394
  return cached;
395
395
  }
396
396
  cached = "unknown";
@@ -79324,8 +79324,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79324
79324
  var cached;
79325
79325
  function substrateSelfVersion() {
79326
79326
  if (cached !== void 0) return cached;
79327
- if ("0.3.0".length > 0) {
79328
- cached = "0.3.0";
79327
+ if ("0.3.1".length > 0) {
79328
+ cached = "0.3.1";
79329
79329
  return cached;
79330
79330
  }
79331
79331
  cached = "unknown";
@@ -427,8 +427,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
427
427
  var cached;
428
428
  function substrateSelfVersion() {
429
429
  if (cached !== void 0) return cached;
430
- if ("0.3.0".length > 0) {
431
- cached = "0.3.0";
430
+ if ("0.3.1".length > 0) {
431
+ cached = "0.3.1";
432
432
  return cached;
433
433
  }
434
434
  cached = "unknown";
@@ -79783,8 +79783,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79783
79783
  var cached;
79784
79784
  function substrateSelfVersion() {
79785
79785
  if (cached !== void 0) return cached;
79786
- if ("0.3.0".length > 0) {
79787
- cached = "0.3.0";
79786
+ if ("0.3.1".length > 0) {
79787
+ cached = "0.3.1";
79788
79788
  return cached;
79789
79789
  }
79790
79790
  cached = "unknown";
@@ -864,8 +864,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
864
864
  var cached;
865
865
  function substrateSelfVersion() {
866
866
  if (cached !== void 0) return cached;
867
- if ("0.3.0".length > 0) {
868
- cached = "0.3.0";
867
+ if ("0.3.1".length > 0) {
868
+ cached = "0.3.1";
869
869
  return cached;
870
870
  }
871
871
  cached = "unknown";
@@ -88240,8 +88240,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
88240
88240
  var cached;
88241
88241
  function substrateSelfVersion() {
88242
88242
  if (cached !== void 0) return cached;
88243
- if ("0.3.0".length > 0) {
88244
- cached = "0.3.0";
88243
+ if ("0.3.1".length > 0) {
88244
+ cached = "0.3.1";
88245
88245
  return cached;
88246
88246
  }
88247
88247
  cached = "unknown";
@@ -9393,8 +9393,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
9393
9393
  var cached;
9394
9394
  function substrateSelfVersion() {
9395
9395
  if (cached !== void 0) return cached;
9396
- if ("0.3.0".length > 0) {
9397
- cached = "0.3.0";
9396
+ if ("0.3.1".length > 0) {
9397
+ cached = "0.3.1";
9398
9398
  return cached;
9399
9399
  }
9400
9400
  cached = "unknown";
@@ -88825,8 +88825,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
88825
88825
  var cached;
88826
88826
  function substrateSelfVersion() {
88827
88827
  if (cached !== void 0) return cached;
88828
- if ("0.3.0".length > 0) {
88829
- cached = "0.3.0";
88828
+ if ("0.3.1".length > 0) {
88829
+ cached = "0.3.1";
88830
88830
  return cached;
88831
88831
  }
88832
88832
  cached = "unknown";
@@ -9978,8 +9978,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
9978
9978
  var cached;
9979
9979
  function substrateSelfVersion() {
9980
9980
  if (cached !== void 0) return cached;
9981
- if ("0.3.0".length > 0) {
9982
- cached = "0.3.0";
9981
+ if ("0.3.1".length > 0) {
9982
+ cached = "0.3.1";
9983
9983
  return cached;
9984
9984
  }
9985
9985
  cached = "unknown";
@@ -79288,8 +79288,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
79288
79288
  var cached;
79289
79289
  function substrateSelfVersion() {
79290
79290
  if (cached !== void 0) return cached;
79291
- if ("0.3.0".length > 0) {
79292
- cached = "0.3.0";
79291
+ if ("0.3.1".length > 0) {
79292
+ cached = "0.3.1";
79293
79293
  return cached;
79294
79294
  }
79295
79295
  cached = "unknown";
@@ -389,8 +389,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
389
389
  var cached;
390
390
  function substrateSelfVersion() {
391
391
  if (cached !== void 0) return cached;
392
- if ("0.3.0".length > 0) {
393
- cached = "0.3.0";
392
+ if ("0.3.1".length > 0) {
393
+ cached = "0.3.1";
394
394
  return cached;
395
395
  }
396
396
  cached = "unknown";
@@ -1667,8 +1667,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
1667
1667
  var cached;
1668
1668
  function substrateSelfVersion() {
1669
1669
  if (cached !== void 0) return cached;
1670
- if ("0.3.0".length > 0) {
1671
- cached = "0.3.0";
1670
+ if ("0.3.1".length > 0) {
1671
+ cached = "0.3.1";
1672
1672
  return cached;
1673
1673
  }
1674
1674
  cached = "unknown";
@@ -1630,8 +1630,8 @@ var PKG_NAME = "@databricks-solutions/lakebase-scm-utils";
1630
1630
  var cached;
1631
1631
  function substrateSelfVersion() {
1632
1632
  if (cached !== void 0) return cached;
1633
- if ("0.3.0".length > 0) {
1634
- cached = "0.3.0";
1633
+ if ("0.3.1".length > 0) {
1634
+ cached = "0.3.1";
1635
1635
  return cached;
1636
1636
  }
1637
1637
  cached = "unknown";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@databricks-solutions/lakebase-scm-utils",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Lakebase SCM + substrate engine: database branching, paired-branch SCM workflows, connection/credential minting, schema migration, project scaffold + deploy primitives, and the git/github utility layer. Extracted from consort for portable, standalone consumption by lakebase-scm-extension and the SFTDD orchestration.",
5
5
  "type": "module",
6
6
  "private": false,
@@ -0,0 +1,102 @@
1
+ // Generate + normalize the client's package-lock.json at scaffold time, so a
2
+ // scaffolded UI project ships a COMMITTED lockfile that resolves from the
3
+ // public npm registry.
4
+ //
5
+ // WHY: createProject writes the client template + wires Playwright but never
6
+ // runs `npm install` in client/, so no package-lock.json exists at the initial
7
+ // commit. The user had to generate it by hand (README: `cd client && npm
8
+ // install`), and when they did it on the Databricks network the lock pinned
9
+ // npm-proxy.cloud.databricks.com in its `resolved` URLs — which hangs a cold
10
+ // install off-network (the lockfile-registry-guard hazard: the proxy host
11
+ // resolves but never accepts a TCP connection off the Databricks network).
12
+ //
13
+ // WHAT: `npm install --package-lock-only` resolves the dep tree and writes
14
+ // client/package-lock.json WITHOUT installing node_modules (fast, no tarball
15
+ // downloads), then we host-swap any Databricks-proxy `resolved` host to
16
+ // registry.npmjs.org (integrity hashes are unchanged — the proxy is a
17
+ // passthrough mirror of the same tarballs). The scaffold's `git add -A` initial
18
+ // commit then picks the normalized lock up for free.
19
+ //
20
+ // Non-fatal: a resolve failure (offline, registry down) is a warning, not a
21
+ // create abort — the user can still `cd client && npm install` as before.
22
+
23
+ import * as fs from "node:fs";
24
+ import * as path from "node:path";
25
+ import { exec } from "../util/exec.js";
26
+ import { withProxyEnv } from "../util/proxy-env.js";
27
+
28
+ /** The Databricks npm proxy host a cold off-network install hangs on. */
29
+ const PROXY_HOST = "npm-proxy.cloud.databricks.com";
30
+ /** The public registry every tracked lockfile must resolve from. */
31
+ const PUBLIC_HOST = "registry.npmjs.org";
32
+
33
+ export interface EnsureClientLockfileArgs {
34
+ /** The project root (the client dir lives at <projectDir>/<clientDir>). */
35
+ projectDir: string;
36
+ /** The client dir name under projectDir. Default "client". */
37
+ clientDir?: string;
38
+ }
39
+
40
+ export interface EnsureClientLockfileResult {
41
+ /** True when a package-lock.json exists in the client dir after this ran. */
42
+ generated: boolean;
43
+ /** Count of proxy-host `resolved` URLs rewritten to the public registry. */
44
+ swaps: number;
45
+ /** Why it did not run / generate (no client package.json, exec error). */
46
+ reason?: string;
47
+ }
48
+
49
+ /**
50
+ * Host-swap any Databricks-proxy `resolved` URL to the public registry. A pure
51
+ * string substitution — integrity hashes are left untouched because the proxy
52
+ * is a passthrough mirror of the same tarballs. Returns the rewritten text and
53
+ * the number of swaps.
54
+ */
55
+ export function normalizeLockfileRegistry(lockText: string): { text: string; swaps: number } {
56
+ let swaps = 0;
57
+ const text = lockText.replace(new RegExp(PROXY_HOST.replace(/\./g, "\\."), "g"), () => {
58
+ swaps++;
59
+ return PUBLIC_HOST;
60
+ });
61
+ return { text, swaps };
62
+ }
63
+
64
+ /**
65
+ * For a UI project, generate client/package-lock.json (lock only, no install)
66
+ * and normalize its registry host. Idempotent, non-fatal: callers push the
67
+ * reason onto their warnings and continue.
68
+ */
69
+ export async function ensureClientLockfile(
70
+ args: EnsureClientLockfileArgs,
71
+ ): Promise<EnsureClientLockfileResult> {
72
+ const clientDir = path.join(args.projectDir, args.clientDir ?? "client");
73
+ const pkg = path.join(clientDir, "package.json");
74
+ if (!fs.existsSync(pkg)) {
75
+ return { generated: false, swaps: 0, reason: "no client package.json" };
76
+ }
77
+ const lockPath = path.join(clientDir, "package-lock.json");
78
+ try {
79
+ // --package-lock-only resolves the dep tree + writes the lock, skipping
80
+ // node_modules (no tarball downloads), so the scaffold stays fast.
81
+ await exec("npm install --package-lock-only", {
82
+ cwd: clientDir,
83
+ env: withProxyEnv(),
84
+ timeout: 180_000,
85
+ });
86
+ } catch (err) {
87
+ const msg = err instanceof Error ? err.message : String(err);
88
+ return { generated: fs.existsSync(lockPath), swaps: 0, reason: `npm resolve failed: ${msg}` };
89
+ }
90
+ if (!fs.existsSync(lockPath)) {
91
+ return { generated: false, swaps: 0, reason: "npm wrote no package-lock.json" };
92
+ }
93
+ // Normalize proxy -> public registry so a cold off-network install never hangs.
94
+ try {
95
+ const { text, swaps } = normalizeLockfileRegistry(fs.readFileSync(lockPath, "utf8"));
96
+ if (swaps > 0) fs.writeFileSync(lockPath, text);
97
+ return { generated: true, swaps };
98
+ } catch (err) {
99
+ const msg = err instanceof Error ? err.message : String(err);
100
+ return { generated: true, swaps: 0, reason: `lock normalize failed: ${msg}` };
101
+ }
102
+ }
@@ -28,6 +28,7 @@ import { scaffoldAll, substrateVersion } from "./scaffold.js";
28
28
  import type { ClientFramework } from "./scaffold-language.js";
29
29
  import { createLongRunningBranch } from "./long-running-branch.js";
30
30
  import { enableE2eForProject } from "./enable-e2e.js";
31
+ import { ensureClientLockfile } from "./client-lockfile.js";
31
32
  import { enableInfraForProject } from "./enable-infra.js";
32
33
  import { setupRunner } from "./runner-setup.js";
33
34
  import { syncCiSecrets, missingCiSecrets } from "../util/ci-secrets.js";
@@ -587,6 +588,24 @@ export async function createProject(
587
588
  dotnet: `.NET/ASP.NET Core (${input.migrationTool === "flyway" ? "Flyway" : "EF Core"})`,
588
589
  };
589
590
  const langLabel = langLabels[language] ?? language;
591
+
592
+ // ── Step 7f: client lockfile (UI projects) ───────────────────
593
+ // Generate + registry-normalize client/package-lock.json BEFORE the commit so
594
+ // `git add -A` tracks it. Without this the scaffold ships no client lock, and
595
+ // the user's hand-generated one (made on the Databricks network) pins the npm
596
+ // proxy and hangs a cold off-network install. Non-fatal: warn + continue.
597
+ if (clientFramework !== "none") {
598
+ report("Generating client package-lock.json (registry-normalized)...");
599
+ const lock = await ensureClientLockfile({ projectDir });
600
+ if (lock.generated) {
601
+ report(` wrote client/package-lock.json${lock.swaps > 0 ? ` (normalized ${lock.swaps} proxy URL(s) to the public registry)` : ""}`);
602
+ } else {
603
+ const m = `Could not generate client/package-lock.json (${lock.reason ?? "unknown"}). Generate it with: (cd client && npm install) — the lock is committed on first push.`;
604
+ warnings.push(m);
605
+ report(`WARNING: ${m}`);
606
+ }
607
+ }
608
+
590
609
  report("Creating initial commit...");
591
610
  await commitAndPush({
592
611
  projectDir,