@codemarc/blt 1.10.2 → 1.10.5
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/README.md +30 -6
- package/dist/commands/init/root.d.ts +10 -0
- package/dist/commands/init/root.d.ts.map +1 -0
- package/dist/commands/init/root.js +34 -0
- package/dist/commands/init/root.js.map +1 -0
- package/dist/commands/init/script.d.ts +37 -1
- package/dist/commands/init/script.d.ts.map +1 -1
- package/dist/commands/init/script.js +142 -78
- package/dist/commands/init/script.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +57 -12
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/show/repo.js +3 -3
- package/dist/commands/show/repo.js.map +1 -1
- package/dist/lib/repositories.d.ts +21 -5
- package/dist/lib/repositories.d.ts.map +1 -1
- package/dist/lib/repositories.js +98 -80
- package/dist/lib/repositories.js.map +1 -1
- package/dist/lib/repositories.manifest.json +54 -0
- package/package.json +7 -6
- package/repositories.json.example +14 -0
- package/dist/commands/db/diff.d.ts +0 -37
- package/dist/commands/db/diff.d.ts.map +0 -1
- package/dist/commands/db/diff.js +0 -123
- package/dist/commands/db/diff.js.map +0 -1
package/README.md
CHANGED
|
@@ -615,22 +615,46 @@ Snapshots default under `data-snapshots/` from the **current working directory**
|
|
|
615
615
|
|
|
616
616
|
## Init Commands
|
|
617
617
|
|
|
618
|
+
### `blt init root`
|
|
619
|
+
|
|
620
|
+
Clone the umbrella repository (`bltcore-com/blt`). Start here on a fresh machine.
|
|
621
|
+
|
|
622
|
+
```bash
|
|
623
|
+
blt init root -s
|
|
624
|
+
cd blt
|
|
625
|
+
blt init -w -s
|
|
626
|
+
./getblt.sh
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
**Options:**
|
|
630
|
+
|
|
631
|
+
- `-d, --directory <name>` — Clone directory name (default: `blt`)
|
|
632
|
+
- `-p, --parent <path>` — Parent directory (default: `.`)
|
|
633
|
+
- `-s, --ssh` — Use SSH URL instead of HTTPS
|
|
634
|
+
- `-g, --gh` — Use GitHub CLI (`gh repo clone`)
|
|
635
|
+
|
|
618
636
|
### `blt init [options]`
|
|
619
637
|
|
|
620
|
-
Create a shell script to
|
|
638
|
+
Create a shell script to fast-forward sync sibling BLT repositories. Run the generated script from the **umbrella repo root** (`bltcore-com/blt`), not from a parent directory.
|
|
621
639
|
|
|
622
640
|
```bash
|
|
623
|
-
blt init
|
|
624
|
-
blt
|
|
641
|
+
blt init root -s
|
|
642
|
+
cd blt
|
|
643
|
+
blt init -w -s
|
|
644
|
+
blt init -b -s # bundle: single-root workspace
|
|
625
645
|
./getblt.sh
|
|
626
646
|
```
|
|
627
647
|
|
|
628
648
|
**Options:**
|
|
629
649
|
|
|
630
|
-
- `-o, --output <path>` — Output path for the script (default:
|
|
650
|
+
- `-o, --output <path>` — Output path for the script (default: `./getblt.sh`)
|
|
631
651
|
- `-s, --ssh` — Use SSH URLs instead of HTTPS
|
|
632
|
-
- `-
|
|
633
|
-
- `-
|
|
652
|
+
- `-g, --gh` — Use GitHub CLI (`gh repo clone`) instead of `git clone`
|
|
653
|
+
- `-w, --workspace` — Generate `blt.code-workspace` (umbrella at `.` plus one folder per sibling repo)
|
|
654
|
+
- `-b, --bundle` — Sync umbrella into `.` when needed; single-root workspace (`blt` → `.`)
|
|
655
|
+
- `-c, --connections` — Add `sqltools.connections` from `.env` (requires `-w` or `-b`)
|
|
656
|
+
|
|
657
|
+
**Repository list:** `repositories.json` in the umbrella repo root (or `BLT_REPOSITORIES_PATH`). Re-run `blt init` after editing it to refresh `getblt.sh`.
|
|
634
658
|
|
|
635
659
|
---
|
|
636
660
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Logger } from "@caporal/core";
|
|
2
|
+
export interface InitRootOptions {
|
|
3
|
+
directory: string;
|
|
4
|
+
parent: string;
|
|
5
|
+
ssh: boolean;
|
|
6
|
+
gh: boolean;
|
|
7
|
+
}
|
|
8
|
+
/** Clone the umbrella BLT repository into parent/directory. */
|
|
9
|
+
export declare function cloneUmbrellaRoot(options: InitRootOptions, logger: Logger): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=root.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../../src/commands/init/root.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAO5C,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,OAAO,CAAC;IACb,EAAE,EAAE,OAAO,CAAC;CACb;AAgBD,+DAA+D;AAC/D,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAkCf"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { ensureGhReady, ghCloneTarget } from "../../lib/github";
|
|
5
|
+
import { getBundleRepository } from "../../lib/repositories";
|
|
6
|
+
function runOrExit(command, args, cwd, logger, label) {
|
|
7
|
+
const result = spawnSync(command, args, { cwd, stdio: "inherit" });
|
|
8
|
+
if (result.status !== 0) {
|
|
9
|
+
logger.error(`${label} failed`);
|
|
10
|
+
process.exit(result.status === null ? 1 : result.status);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Clone the umbrella BLT repository into parent/directory. */
|
|
14
|
+
export async function cloneUmbrellaRoot(options, logger) {
|
|
15
|
+
const parent = resolve(options.parent);
|
|
16
|
+
const target = join(parent, options.directory);
|
|
17
|
+
if (existsSync(target)) {
|
|
18
|
+
logger.error(`Target already exists: ${target}`);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
const bundle = getBundleRepository();
|
|
22
|
+
if (options.gh) {
|
|
23
|
+
ensureGhReady(logger);
|
|
24
|
+
runOrExit("gh", ["repo", "clone", ghCloneTarget(bundle, options.ssh), options.directory], parent, logger, "gh repo clone");
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const url = options.ssh ? bundle.sshUrl : bundle.url;
|
|
28
|
+
runOrExit("git", ["clone", url, options.directory], parent, logger, "git clone");
|
|
29
|
+
}
|
|
30
|
+
logger.info(`Cloned umbrella repo to ${target}`);
|
|
31
|
+
logger.info(`cd ${options.directory}`);
|
|
32
|
+
logger.info("Then run: blt init -w -s # or blt init -b -s");
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=root.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.js","sourceRoot":"","sources":["../../../src/commands/init/root.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAS7D,SAAS,SAAS,CAChB,OAAe,EACf,IAAc,EACd,GAAW,EACX,MAAc,EACd,KAAa;IAEb,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IACnE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC;QAChC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAA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+1,6 @@
|
|
|
1
1
|
import type { Logger } from "@caporal/core";
|
|
2
|
-
|
|
2
|
+
import { type Repository } from "../../lib/repositories";
|
|
3
|
+
export interface InitScriptOptions {
|
|
3
4
|
output: string;
|
|
4
5
|
ssh: boolean;
|
|
5
6
|
gh: boolean;
|
|
@@ -7,6 +8,41 @@ interface InitScriptOptions {
|
|
|
7
8
|
bundleWorkspace: boolean;
|
|
8
9
|
connectionsFromEnv: boolean;
|
|
9
10
|
}
|
|
11
|
+
interface WorkspaceFolder {
|
|
12
|
+
name?: string;
|
|
13
|
+
path: string;
|
|
14
|
+
}
|
|
15
|
+
interface SqlConnection {
|
|
16
|
+
ssh: string;
|
|
17
|
+
previewLimit: number;
|
|
18
|
+
server: string;
|
|
19
|
+
port: number;
|
|
20
|
+
driver: string;
|
|
21
|
+
name: string;
|
|
22
|
+
group: string;
|
|
23
|
+
database: string;
|
|
24
|
+
password: string;
|
|
25
|
+
username: string;
|
|
26
|
+
}
|
|
27
|
+
interface WorkspaceContent {
|
|
28
|
+
folders?: WorkspaceFolder[];
|
|
29
|
+
settings?: {
|
|
30
|
+
"sqltools.connections"?: SqlConnection[];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export declare function connectionFromSupabaseEnv(env: Record<string, string>): SqlConnection | null;
|
|
34
|
+
/** Bash lines to fast-forward sync an existing git checkout. */
|
|
35
|
+
export declare function gitPullFfOnlyLines(label: string, indent?: string): string[];
|
|
36
|
+
/** Bash lines to clone or fast-forward sync the umbrella repo at `.`. */
|
|
37
|
+
export declare function bundleUmbrellaSyncLines(gh: boolean, ssh: boolean): string[];
|
|
38
|
+
/** Bash lines to clone or fast-forward sync one sibling repository. */
|
|
39
|
+
export declare function subRepoSyncLines(repo: Repository, gh: boolean, ssh: boolean): string[];
|
|
40
|
+
/** Workspace folder entries for `-w` / `-b` modes. */
|
|
41
|
+
export declare function workspaceFoldersForInit(workspace: boolean, bundleWorkspace: boolean): WorkspaceFolder[] | undefined;
|
|
42
|
+
/** Build the getblt.sh script body (without writing files). */
|
|
43
|
+
export declare function buildInitScriptLines(options: InitScriptOptions): string[];
|
|
44
|
+
export declare function buildWorkspaceContent(options: InitScriptOptions, baseDir: string, logger: Logger): WorkspaceContent;
|
|
45
|
+
export declare function validateInitOptions(options: InitScriptOptions): string | null;
|
|
10
46
|
/**
|
|
11
47
|
* Generate a shell script that clones or pulls all BLT projects into the current directory
|
|
12
48
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../../src/commands/init/script.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../../src/commands/init/script.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAQ5C,OAAO,EAAwE,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAE/H,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,OAAO,CAAC;IACb,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;IACzB,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAED,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,aAAa;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MA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|
2
2
|
import { dirname, join, resolve } from "node:path";
|
|
3
3
|
import { ensureGhReady, ghInitScriptPreamble, ghRepoCloneCommand, } from "../../lib/github";
|
|
4
|
-
import {
|
|
4
|
+
import { getBundleRepository, getRepositoryManifestSource, getSubRepositories } from "../../lib/repositories";
|
|
5
5
|
function parseEnvFile(envPath) {
|
|
6
6
|
const content = readFileSync(envPath, "utf-8");
|
|
7
7
|
const out = {};
|
|
@@ -26,7 +26,7 @@ function parseEnvFile(envPath) {
|
|
|
26
26
|
}
|
|
27
27
|
return out;
|
|
28
28
|
}
|
|
29
|
-
function connectionFromSupabaseEnv(env) {
|
|
29
|
+
export function connectionFromSupabaseEnv(env) {
|
|
30
30
|
const connectionString = env.SUPABASE_CONNECTION_STRING;
|
|
31
31
|
if (!connectionString?.startsWith("postgresql://"))
|
|
32
32
|
return null;
|
|
@@ -50,69 +50,159 @@ function connectionFromSupabaseEnv(env) {
|
|
|
50
50
|
return null;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
/** Bash lines to fast-forward sync an existing git checkout. */
|
|
54
|
+
export function gitPullFfOnlyLines(label, indent = "") {
|
|
55
|
+
return [
|
|
56
|
+
`${indent}git fetch origin`,
|
|
57
|
+
`${indent}git pull --ff-only || { echo "ERROR: ${label}: fast-forward pull failed; resolve locally and re-run." >&2; exit 1; }`,
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
/** Bash lines to clone or fast-forward sync the umbrella repo at `.`. */
|
|
61
|
+
export function bundleUmbrellaSyncLines(gh, ssh) {
|
|
62
|
+
const bundle = getBundleRepository();
|
|
63
|
+
const bundleUrl = ssh ? bundle.sshUrl : bundle.url;
|
|
64
|
+
const lines = [`if [ -d ".git" ]; then`];
|
|
65
|
+
lines.push(...gitPullFfOnlyLines("umbrella repo", " "));
|
|
66
|
+
lines.push(`else`);
|
|
67
|
+
if (gh) {
|
|
68
|
+
lines.push(` ${ghRepoCloneCommand(bundle, ".", ssh)}`);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
lines.push(` git clone ${bundleUrl} .`);
|
|
72
|
+
}
|
|
73
|
+
lines.push(`fi`);
|
|
74
|
+
return lines;
|
|
75
|
+
}
|
|
76
|
+
/** Bash lines to clone or fast-forward sync one sibling repository. */
|
|
77
|
+
export function subRepoSyncLines(repo, gh, ssh) {
|
|
78
|
+
const lines = [
|
|
79
|
+
`# ${repo.description || repo.name}`,
|
|
80
|
+
`if [ -d "${repo.name}" ]; then`,
|
|
81
|
+
` echo "Pulling ${repo.name}..."`,
|
|
82
|
+
` (`,
|
|
83
|
+
` cd ${repo.name}`,
|
|
84
|
+
...gitPullFfOnlyLines(repo.name, " "),
|
|
85
|
+
` )`,
|
|
86
|
+
`else`,
|
|
87
|
+
` echo "Cloning ${repo.name}..."`,
|
|
88
|
+
];
|
|
89
|
+
if (gh) {
|
|
90
|
+
lines.push(` ${ghRepoCloneCommand(repo, repo.name, ssh)}`);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
const url = ssh ? repo.sshUrl : repo.url;
|
|
94
|
+
lines.push(` git clone ${url} ${repo.name}`);
|
|
95
|
+
}
|
|
96
|
+
lines.push(`fi`, "");
|
|
97
|
+
return lines;
|
|
98
|
+
}
|
|
99
|
+
/** Workspace folder entries for `-w` / `-b` modes. */
|
|
100
|
+
export function workspaceFoldersForInit(workspace, bundleWorkspace) {
|
|
101
|
+
if (bundleWorkspace) {
|
|
102
|
+
return [{ name: getBundleRepository().name, path: "." }];
|
|
103
|
+
}
|
|
104
|
+
if (workspace) {
|
|
105
|
+
const bundle = getBundleRepository();
|
|
106
|
+
return [
|
|
107
|
+
{ name: bundle.name, path: "." },
|
|
108
|
+
...getSubRepositories().map((repo) => ({
|
|
109
|
+
name: repo.name,
|
|
110
|
+
path: repo.name,
|
|
111
|
+
})),
|
|
112
|
+
];
|
|
59
113
|
}
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
/** Build the getblt.sh script body (without writing files). */
|
|
117
|
+
export function buildInitScriptLines(options) {
|
|
60
118
|
const lines = [
|
|
61
119
|
"#!/usr/bin/env bash",
|
|
62
|
-
"# BLT project init script - clones or pulls
|
|
120
|
+
"# BLT project init script - clones or pulls sibling repos into the current directory",
|
|
63
121
|
"# Generated by: blt init",
|
|
122
|
+
"# Run from the umbrella repo root (bltcore-com/blt), after: git clone …/blt.git && cd blt",
|
|
64
123
|
"",
|
|
65
|
-
|
|
124
|
+
"set -e",
|
|
66
125
|
"",
|
|
67
|
-
|
|
126
|
+
'cd "$(dirname "$0")"',
|
|
68
127
|
"",
|
|
69
128
|
];
|
|
70
129
|
if (options.gh) {
|
|
71
130
|
lines.push(...ghInitScriptPreamble());
|
|
72
131
|
}
|
|
73
132
|
if (options.bundleWorkspace) {
|
|
74
|
-
|
|
75
|
-
lines.push(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
lines.push(` git fetch origin`);
|
|
79
|
-
lines.push(` git reset --hard origin/HEAD`);
|
|
80
|
-
lines.push(`else`);
|
|
81
|
-
lines.push(` ${ghRepoCloneCommand(BUNDLE_REPOSITORY, ".", options.ssh)}`);
|
|
82
|
-
lines.push(`fi`);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
const bundleUrl = options.ssh ? BUNDLE_REPOSITORY.sshUrl : BUNDLE_REPOSITORY.url;
|
|
86
|
-
lines.push(`if [ ! -d ".git" ]; then`);
|
|
87
|
-
lines.push(` git init`);
|
|
88
|
-
lines.push(`fi`);
|
|
89
|
-
lines.push(`if ! git remote get-url origin &>/dev/null; then`);
|
|
90
|
-
lines.push(` git remote add origin ${bundleUrl}`);
|
|
91
|
-
lines.push(`fi`);
|
|
92
|
-
lines.push(`git fetch origin`);
|
|
93
|
-
lines.push(`git reset --hard origin/HEAD`);
|
|
94
|
-
}
|
|
133
|
+
const bundle = getBundleRepository();
|
|
134
|
+
lines.push(`# ${bundle.description}`);
|
|
135
|
+
lines.push(`echo "Syncing ${bundle.name} (umbrella)..."`);
|
|
136
|
+
lines.push(...bundleUmbrellaSyncLines(options.gh, options.ssh));
|
|
95
137
|
lines.push("");
|
|
96
138
|
}
|
|
97
|
-
for (const repo of
|
|
98
|
-
lines.push(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
139
|
+
for (const repo of getSubRepositories()) {
|
|
140
|
+
lines.push(...subRepoSyncLines(repo, options.gh, options.ssh));
|
|
141
|
+
}
|
|
142
|
+
lines.push('echo "Done! All projects are up to date."');
|
|
143
|
+
return lines;
|
|
144
|
+
}
|
|
145
|
+
function applyConnectionsFromEnv(workspaceContent, baseDir, logger) {
|
|
146
|
+
const envPath = join(baseDir, ".env");
|
|
147
|
+
if (!existsSync(envPath)) {
|
|
148
|
+
logger.warn(`No .env at ${envPath}; skipping SQLTools connections.`);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const env = parseEnvFile(envPath);
|
|
152
|
+
const connection = connectionFromSupabaseEnv(env);
|
|
153
|
+
if (!connection) {
|
|
154
|
+
logger.warn(`SUPABASE_CONNECTION_STRING missing or invalid in ${envPath}; skipping SQLTools connections.`);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
workspaceContent.settings = {
|
|
158
|
+
...(workspaceContent.settings ?? {}),
|
|
159
|
+
"sqltools.connections": [connection],
|
|
160
|
+
};
|
|
161
|
+
logger.warn("SQLTools connection includes database credentials in blt.code-workspace. " +
|
|
162
|
+
"Do not commit this file if it contains secrets; add blt.code-workspace to .gitignore or use user settings.");
|
|
163
|
+
}
|
|
164
|
+
export function buildWorkspaceContent(options, baseDir, logger) {
|
|
165
|
+
const workspaceContent = {};
|
|
166
|
+
const folders = workspaceFoldersForInit(options.workspace, options.bundleWorkspace);
|
|
167
|
+
if (folders) {
|
|
168
|
+
workspaceContent.folders = folders;
|
|
169
|
+
if (options.bundleWorkspace) {
|
|
170
|
+
workspaceContent.settings = {};
|
|
110
171
|
}
|
|
111
|
-
lines.push(`fi`);
|
|
112
|
-
lines.push("");
|
|
113
172
|
}
|
|
114
|
-
|
|
115
|
-
|
|
173
|
+
if (options.connectionsFromEnv) {
|
|
174
|
+
applyConnectionsFromEnv(workspaceContent, baseDir, logger);
|
|
175
|
+
}
|
|
176
|
+
if (!workspaceContent.folders) {
|
|
177
|
+
workspaceContent.folders = [];
|
|
178
|
+
}
|
|
179
|
+
return workspaceContent;
|
|
180
|
+
}
|
|
181
|
+
export function validateInitOptions(options) {
|
|
182
|
+
if (options.connectionsFromEnv &&
|
|
183
|
+
!options.workspace &&
|
|
184
|
+
!options.bundleWorkspace) {
|
|
185
|
+
return "-c requires -w or -b; SQLTools connections are written to blt.code-workspace";
|
|
186
|
+
}
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Generate a shell script that clones or pulls all BLT projects into the current directory
|
|
191
|
+
*/
|
|
192
|
+
export async function generateInitScript(options, logger) {
|
|
193
|
+
const validationError = validateInitOptions(options);
|
|
194
|
+
if (validationError) {
|
|
195
|
+
logger.error(validationError);
|
|
196
|
+
process.exit(1);
|
|
197
|
+
}
|
|
198
|
+
if (options.gh) {
|
|
199
|
+
ensureGhReady(logger);
|
|
200
|
+
}
|
|
201
|
+
const manifestSource = getRepositoryManifestSource();
|
|
202
|
+
if (manifestSource !== "bundled") {
|
|
203
|
+
logger.info(`Using repository manifest: ${manifestSource}`);
|
|
204
|
+
}
|
|
205
|
+
const script = buildInitScriptLines(options).join("\n");
|
|
116
206
|
try {
|
|
117
207
|
await Bun.write(options.output, script);
|
|
118
208
|
// Make executable on Unix
|
|
@@ -123,37 +213,11 @@ export async function generateInitScript(options, logger) {
|
|
|
123
213
|
// chmod may fail on Windows, ignore
|
|
124
214
|
}
|
|
125
215
|
logger.info(`Created init script: ${options.output}`);
|
|
126
|
-
|
|
216
|
+
logger.info("Re-run blt init after editing repositories.json to refresh getblt.sh");
|
|
217
|
+
if (options.workspace || options.bundleWorkspace) {
|
|
127
218
|
const baseDir = resolve(dirname(options.output));
|
|
128
219
|
const workspacePath = join(baseDir, "blt.code-workspace");
|
|
129
|
-
const workspaceContent =
|
|
130
|
-
if (options.bundleWorkspace) {
|
|
131
|
-
workspaceContent.folders = [{ name: "blt", path: "." }];
|
|
132
|
-
workspaceContent.settings = {};
|
|
133
|
-
}
|
|
134
|
-
else if (options.workspace) {
|
|
135
|
-
workspaceContent.folders = REPOSITORIES.map((repo) => ({
|
|
136
|
-
name: repo.name,
|
|
137
|
-
path: repo.name,
|
|
138
|
-
}));
|
|
139
|
-
}
|
|
140
|
-
if (options.connectionsFromEnv) {
|
|
141
|
-
const envPath = join(baseDir, ".env");
|
|
142
|
-
if (existsSync(envPath)) {
|
|
143
|
-
const env = parseEnvFile(envPath);
|
|
144
|
-
const connection = connectionFromSupabaseEnv(env);
|
|
145
|
-
if (connection) {
|
|
146
|
-
workspaceContent.settings = {
|
|
147
|
-
...(workspaceContent.settings ?? {}),
|
|
148
|
-
"sqltools.connections": [connection],
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
// Ensure we have at least folders so the file is valid
|
|
154
|
-
if (!workspaceContent.folders) {
|
|
155
|
-
workspaceContent.folders = [];
|
|
156
|
-
}
|
|
220
|
+
const workspaceContent = buildWorkspaceContent(options, baseDir, logger);
|
|
157
221
|
await Bun.write(workspacePath, JSON.stringify(workspaceContent, null, "\t") + "\n");
|
|
158
222
|
logger.info(`Created workspace: ${workspacePath}`);
|
|
159
223
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script.js","sourceRoot":"","sources":["../../../src/commands/init/script.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAA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,MAAM,CAAC,IAAI,CAAC,wBAAwB,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QACtD,MAAM,CAAC,IAAI,CACT,sEAAsE,CACvE,CAAC;QAEF,IAAI,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;YACjD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;YACjD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;YAC1D,MAAM,gBAAgB,GAAG,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAEzE,MAAM,GAAG,CAAC,KAAK,CACb,aAAa,EACb,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,IAAI,CACpD,CAAC;YACF,MAAM,CAAC,IAAI,CAAC,sBAAsB,aAAa,EAAE,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,CAAC,KAAK,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAC;QACnD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAI7C;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,OAAO,EAAE,OAAO,QA0GnD"}
|
package/dist/commands/init.js
CHANGED
|
@@ -1,30 +1,75 @@
|
|
|
1
1
|
import { generateInitScript } from "./init/script";
|
|
2
|
+
import { cloneUmbrellaRoot } from "./init/root";
|
|
2
3
|
/**
|
|
3
4
|
* Register init command with the CLI program
|
|
4
5
|
*/
|
|
5
6
|
export default function initCommand(program) {
|
|
7
|
+
const initRootHelpText = `
|
|
8
|
+
Clone the BLT umbrella repository (bltcore-com/blt)
|
|
9
|
+
|
|
10
|
+
Usage:
|
|
11
|
+
blt init root [options]
|
|
12
|
+
|
|
13
|
+
Equivalent to:
|
|
14
|
+
git clone git@github.com:bltcore-com/blt.git blt
|
|
15
|
+
cd blt
|
|
16
|
+
|
|
17
|
+
Then generate getblt.sh from inside the clone:
|
|
18
|
+
blt init -w -s
|
|
19
|
+
|
|
20
|
+
Example:
|
|
21
|
+
blt init root -s
|
|
22
|
+
cd blt
|
|
23
|
+
blt init -w -s
|
|
24
|
+
./getblt.sh
|
|
25
|
+
`;
|
|
26
|
+
program
|
|
27
|
+
.command("init root", "clone umbrella blt repo")
|
|
28
|
+
.help(initRootHelpText)
|
|
29
|
+
.option("-d, --directory <name>", "Directory name for the clone", {
|
|
30
|
+
default: "blt",
|
|
31
|
+
})
|
|
32
|
+
.option("-p, --parent <path>", "Parent directory to clone into", {
|
|
33
|
+
default: ".",
|
|
34
|
+
})
|
|
35
|
+
.option("-s, --ssh", "Use SSH URL instead of HTTPS", { default: false })
|
|
36
|
+
.option("-g, --gh", "Use GitHub CLI (gh repo clone) instead of git clone", {
|
|
37
|
+
default: false,
|
|
38
|
+
})
|
|
39
|
+
.action(async ({ options, logger }) => {
|
|
40
|
+
await cloneUmbrellaRoot({
|
|
41
|
+
directory: options.directory,
|
|
42
|
+
parent: options.parent,
|
|
43
|
+
ssh: options.ssh,
|
|
44
|
+
gh: options.gh,
|
|
45
|
+
}, logger);
|
|
46
|
+
});
|
|
6
47
|
const initHelpText = `
|
|
7
48
|
Initialize a BLT workspace by creating a script to clone/pull all projects
|
|
8
49
|
|
|
9
50
|
Usage:
|
|
10
51
|
blt init [options]
|
|
11
52
|
|
|
12
|
-
Creates a shell script that
|
|
13
|
-
|
|
14
|
-
|
|
53
|
+
Creates a shell script that clones or fast-forward pulls sibling BLT repositories
|
|
54
|
+
(tools, data, pos, …). Run the generated script from the umbrella repo root
|
|
55
|
+
(bltcore-com/blt), not from a parent directory.
|
|
15
56
|
|
|
16
|
-
With -w, also creates blt.code-workspace with
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
57
|
+
With -w, also creates blt.code-workspace with the umbrella at "." plus one folder
|
|
58
|
+
per sibling repo.
|
|
59
|
+
With -b, clones/pulls the umbrella repo (bltcore-com/blt) into "." when needed,
|
|
60
|
+
then sub-repos, and creates blt.code-workspace as a single-root workspace
|
|
61
|
+
(name "blt", path ".").
|
|
62
|
+
With -c, adds sqltools.connections from SUPABASE_* vars in .env (requires -w or -b).
|
|
20
63
|
With -g, use GitHub CLI (gh repo clone) instead of git clone. Requires gh auth login.
|
|
21
64
|
|
|
22
65
|
Example:
|
|
23
|
-
blt init
|
|
24
|
-
blt
|
|
25
|
-
blt init -
|
|
26
|
-
blt init -g
|
|
66
|
+
blt init root -s
|
|
67
|
+
cd blt
|
|
68
|
+
blt init -w -s
|
|
27
69
|
./getblt.sh
|
|
70
|
+
|
|
71
|
+
Repository list: bundled src/lib/repositories.manifest.json, or override with
|
|
72
|
+
./repositories.json in the current directory or BLT_REPOSITORIES_PATH.
|
|
28
73
|
`;
|
|
29
74
|
program
|
|
30
75
|
.command("init", "clone repo script")
|
|
@@ -42,7 +87,7 @@ Example:
|
|
|
42
87
|
.option("-b, --bundle", "Also generate blt.code-workspace as a single-root workspace (blt → .)", {
|
|
43
88
|
default: false,
|
|
44
89
|
})
|
|
45
|
-
.option("-c, --connections", "Add sqltools.connections from .env
|
|
90
|
+
.option("-c, --connections", "Add sqltools.connections from .env (requires -w or -b)", {
|
|
46
91
|
default: false,
|
|
47
92
|
})
|
|
48
93
|
.action(async ({ options, logger }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,OAAgB;IACnD,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;CAkBzB,CAAC;IAED,OAAO;SACL,OAAO,CAAC,WAAW,EAAE,yBAAyB,CAAC;SAC/C,IAAI,CAAC,gBAAgB,CAAC;SACtB,MAAM,CAAC,wBAAwB,EAAE,8BAA8B,EAAE;QACjE,OAAO,EAAE,KAAK;KACd,CAAC;SACD,MAAM,CAAC,qBAAqB,EAAE,gCAAgC,EAAE;QAChE,OAAO,EAAE,GAAG;KACZ,CAAC;SACD,MAAM,CAAC,WAAW,EAAE,8BAA8B,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;SACvE,MAAM,CAAC,UAAU,EAAE,qDAAqD,EAAE;QAC1E,OAAO,EAAE,KAAK;KACd,CAAC;SACD,MAAM,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;QACrC,MAAM,iBAAiB,CACtB;YACC,SAAS,EAAE,OAAO,CAAC,SAAmB;YACtC,MAAM,EAAE,OAAO,CAAC,MAAgB;YAChC,GAAG,EAAE,OAAO,CAAC,GAAc;YAC3B,EAAE,EAAE,OAAO,CAAC,EAAa;SACzB,EACD,MAAM,CACN,CAAC;IACH,CAAC,CAAC,CAAC;IAEJ,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BrB,CAAC;IAED,OAAO;SACL,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC;SACpC,IAAI,CAAC,YAAY,CAAC;SAClB,MAAM,CAAC,qBAAqB,EAAE,4BAA4B,EAAE;QAC5D,OAAO,EAAE,aAAa;KACtB,CAAC;SACD,MAAM,CAAC,WAAW,EAAE,oCAAoC,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;SAC7E,MAAM,CAAC,UAAU,EAAE,qDAAqD,EAAE;QAC1E,OAAO,EAAE,KAAK;KACd,CAAC;SACD,MAAM,CAAC,iBAAiB,EAAE,iEAAiE,EAAE;QAC7F,OAAO,EAAE,KAAK;KACd,CAAC;SACD,MAAM,CAAC,cAAc,EAAE,uEAAuE,EAAE;QAChG,OAAO,EAAE,KAAK;KACd,CAAC;SACD,MAAM,CAAC,mBAAmB,EAAE,wDAAwD,EAAE;QACtF,OAAO,EAAE,KAAK;KACd,CAAC;SACD,MAAM,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE;QACrC,MAAM,kBAAkB,CACvB;YACC,MAAM,EAAE,OAAO,CAAC,MAAgB;YAChC,GAAG,EAAE,OAAO,CAAC,GAAc;YAC3B,EAAE,EAAE,OAAO,CAAC,EAAa;YACzB,SAAS,EAAE,OAAO,CAAC,SAAoB;YACvC,eAAe,EAAE,OAAO,CAAC,MAAiB;YAC1C,kBAAkB,EAAE,OAAO,CAAC,WAAsB;SAClD,EACD,MAAM,CACN,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getRepositories } from "../../lib/repositories";
|
|
2
2
|
/**
|
|
3
3
|
* Render a table row for ASCII table display
|
|
4
4
|
*/
|
|
@@ -19,7 +19,7 @@ export async function showRepo(options, logger) {
|
|
|
19
19
|
console.log("\n📦 Current Repositories\n");
|
|
20
20
|
const headers = ["Name", "Description", options.ssh ? "SSH URL" : "URL"];
|
|
21
21
|
const tableRows = [headers];
|
|
22
|
-
for (const repo of
|
|
22
|
+
for (const repo of getRepositories()) {
|
|
23
23
|
tableRows.push([
|
|
24
24
|
repo.name,
|
|
25
25
|
repo.description || "",
|
|
@@ -36,7 +36,7 @@ export async function showRepo(options, logger) {
|
|
|
36
36
|
}
|
|
37
37
|
console.log("");
|
|
38
38
|
// Print summary
|
|
39
|
-
console.log(`Total repositories: ${
|
|
39
|
+
console.log(`Total repositories: ${getRepositories().length}\n`);
|
|
40
40
|
}
|
|
41
41
|
catch (error) {
|
|
42
42
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo.js","sourceRoot":"","sources":["../../../src/commands/show/repo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"repo.js","sourceRoot":"","sources":["../../../src/commands/show/repo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAMzD;;GAEG;AACH,SAAS,SAAS,CAAC,GAAa,EAAE,SAAmB;IACnD,OAAO,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;AAC9E,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,SAAmB;IACxC,OAAO,KAAK,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;AAClE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAoB,E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;QAEhB,gBAAgB;QAChB,OAAO,CAAC,GAAG,CAAC,uBAAuB,eAAe,EAAE,CAAC,MAAM,IAAI,CAAC,CAAC;IACnE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,CAAC,KAAK,CAAC,mCAAmC,OAAO,EAAE,CAAC,CAAC;QAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -1,14 +1,30 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface RepositoryManifestEntry {
|
|
2
2
|
name: string;
|
|
3
3
|
gh: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface RepositoryManifest {
|
|
7
|
+
umbrella: RepositoryManifestEntry;
|
|
8
|
+
repositories: RepositoryManifestEntry[];
|
|
9
|
+
}
|
|
10
|
+
export interface Repository extends RepositoryManifestEntry {
|
|
4
11
|
url: string;
|
|
5
12
|
sshUrl: string;
|
|
6
|
-
description?: string;
|
|
7
13
|
}
|
|
14
|
+
export declare function parseRepositoryManifest(raw: unknown, source: string): RepositoryManifest;
|
|
15
|
+
/** Clear cached manifest (for tests). */
|
|
16
|
+
export declare function resetRepositoryCache(): void;
|
|
17
|
+
/** Load the active repository manifest (override file or bundled default). */
|
|
18
|
+
export declare function getRepositoryManifest(): RepositoryManifest;
|
|
19
|
+
/** Where the active manifest was loaded from (`bundled`, a path, or `BLT_REPOSITORIES_PATH`). */
|
|
20
|
+
export declare function getRepositoryManifestSource(): string;
|
|
8
21
|
/** Umbrella meta-repo used with `blt init -b` (single-root workspace). */
|
|
9
|
-
export declare
|
|
22
|
+
export declare function getBundleRepository(): Repository;
|
|
10
23
|
/**
|
|
11
|
-
*
|
|
24
|
+
* Sibling repos cloned/pulled by getblt.sh (excludes the umbrella meta-repo).
|
|
25
|
+
* Run getblt.sh from the umbrella checkout root, not from a parent directory.
|
|
12
26
|
*/
|
|
13
|
-
export declare
|
|
27
|
+
export declare function getSubRepositories(): Repository[];
|
|
28
|
+
/** Full working set including the umbrella meta-repo (for display commands). */
|
|
29
|
+
export declare function getRepositories(): Repository[];
|
|
14
30
|
//# sourceMappingURL=repositories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repositories.d.ts","sourceRoot":"","sources":["../../src/lib/repositories.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"repositories.d.ts","sourceRoot":"","sources":["../../src/lib/repositories.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,uBAAuB,CAAC;IAClC,YAAY,EAAE,uBAAuB,EAAE,CAAC;CACzC;AAED,MAAM,WAAW,UAAW,SAAQ,uBAAuB;IACzD,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB;AAQD,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAoBxF;AAaD,yCAAyC;AACzC,wBAAgB,oBAAoB,IAAI,IAAI,CAG3C;AAwBD,8EAA8E;AAC9E,wBAAgB,qBAAqB,IAAI,kBAAkB,CAe1D;AAED,iGAAiG;AACjG,wBAAgB,2BAA2B,IAAI,MAAM,CAGpD;AAED,0EAA0E;AAC1E,wBAAgB,mBAAmB,IAAI,UAAU,CAEhD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,UAAU,EAAE,CAEjD;AAED,gFAAgF;AAChF,wBAAgB,eAAe,IAAI,UAAU,EAAE,CAM9C"}
|
package/dist/lib/repositories.js
CHANGED
|
@@ -1,84 +1,102 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import bundledManifest from "./repositories.manifest.json";
|
|
4
|
+
function isManifestEntry(value) {
|
|
5
|
+
if (!value || typeof value !== "object")
|
|
6
|
+
return false;
|
|
7
|
+
const entry = value;
|
|
8
|
+
return typeof entry.name === "string" && typeof entry.gh === "string";
|
|
9
|
+
}
|
|
10
|
+
export function parseRepositoryManifest(raw, source) {
|
|
11
|
+
if (!raw || typeof raw !== "object") {
|
|
12
|
+
throw new Error(`${source}: expected a JSON object`);
|
|
13
|
+
}
|
|
14
|
+
const manifest = raw;
|
|
15
|
+
if (!isManifestEntry(manifest.umbrella)) {
|
|
16
|
+
throw new Error(`${source}: missing or invalid "umbrella" entry`);
|
|
17
|
+
}
|
|
18
|
+
if (!Array.isArray(manifest.repositories)) {
|
|
19
|
+
throw new Error(`${source}: missing or invalid "repositories" array`);
|
|
20
|
+
}
|
|
21
|
+
for (const [index, entry] of manifest.repositories.entries()) {
|
|
22
|
+
if (!isManifestEntry(entry)) {
|
|
23
|
+
throw new Error(`${source}: invalid repository at index ${index}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
umbrella: manifest.umbrella,
|
|
28
|
+
repositories: manifest.repositories,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function enrichRepo(entry) {
|
|
32
|
+
return {
|
|
33
|
+
...entry,
|
|
34
|
+
url: `https://github.com/${entry.gh}.git`,
|
|
35
|
+
sshUrl: `git@github.com:${entry.gh}.git`,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
let cachedManifest = null;
|
|
39
|
+
let cachedSource = null;
|
|
40
|
+
/** Clear cached manifest (for tests). */
|
|
41
|
+
export function resetRepositoryCache() {
|
|
42
|
+
cachedManifest = null;
|
|
43
|
+
cachedSource = null;
|
|
44
|
+
}
|
|
45
|
+
function loadManifestFile(path) {
|
|
46
|
+
const raw = JSON.parse(readFileSync(path, "utf-8"));
|
|
47
|
+
return parseRepositoryManifest(raw, path);
|
|
48
|
+
}
|
|
49
|
+
function resolveManifestPath() {
|
|
50
|
+
const envPath = process.env.BLT_REPOSITORIES_PATH?.trim();
|
|
51
|
+
if (envPath) {
|
|
52
|
+
if (!existsSync(envPath)) {
|
|
53
|
+
throw new Error(`BLT_REPOSITORIES_PATH does not exist: ${envPath}`);
|
|
54
|
+
}
|
|
55
|
+
return envPath;
|
|
56
|
+
}
|
|
57
|
+
const cwdPath = join(process.cwd(), "repositories.json");
|
|
58
|
+
if (existsSync(cwdPath)) {
|
|
59
|
+
return cwdPath;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
/** Load the active repository manifest (override file or bundled default). */
|
|
64
|
+
export function getRepositoryManifest() {
|
|
65
|
+
if (cachedManifest) {
|
|
66
|
+
return cachedManifest;
|
|
67
|
+
}
|
|
68
|
+
const overridePath = resolveManifestPath();
|
|
69
|
+
if (overridePath) {
|
|
70
|
+
cachedManifest = loadManifestFile(overridePath);
|
|
71
|
+
cachedSource = overridePath;
|
|
72
|
+
return cachedManifest;
|
|
73
|
+
}
|
|
74
|
+
cachedManifest = parseRepositoryManifest(bundledManifest, "bundled manifest");
|
|
75
|
+
cachedSource = "bundled";
|
|
76
|
+
return cachedManifest;
|
|
77
|
+
}
|
|
78
|
+
/** Where the active manifest was loaded from (`bundled`, a path, or `BLT_REPOSITORIES_PATH`). */
|
|
79
|
+
export function getRepositoryManifestSource() {
|
|
80
|
+
getRepositoryManifest();
|
|
81
|
+
return cachedSource ?? "bundled";
|
|
82
|
+
}
|
|
1
83
|
/** Umbrella meta-repo used with `blt init -b` (single-root workspace). */
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
url: "https://github.com/bltcore-com/blt.git",
|
|
6
|
-
sshUrl: "git@github.com:bltcore-com/blt.git",
|
|
7
|
-
description: "BLT umbrella workspace",
|
|
8
|
-
};
|
|
84
|
+
export function getBundleRepository() {
|
|
85
|
+
return enrichRepo(getRepositoryManifest().umbrella);
|
|
86
|
+
}
|
|
9
87
|
/**
|
|
10
|
-
*
|
|
88
|
+
* Sibling repos cloned/pulled by getblt.sh (excludes the umbrella meta-repo).
|
|
89
|
+
* Run getblt.sh from the umbrella checkout root, not from a parent directory.
|
|
11
90
|
*/
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
url: "https://github.com/bltcore-com/tools.git",
|
|
24
|
-
sshUrl: "git@github.com:bltcore-com/tools.git",
|
|
25
|
-
description: "tools repository",
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: "data",
|
|
29
|
-
gh: "bltcore-com/blt-core-data",
|
|
30
|
-
url: "https://github.com/bltcore-com/blt-core-data.git",
|
|
31
|
-
sshUrl: "git@github.com:bltcore-com/blt-core-data.git",
|
|
32
|
-
description: "data schema & sample data",
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: "pos",
|
|
36
|
-
gh: "bltcore-com/blt-core-pos",
|
|
37
|
-
url: "https://github.com/bltcore-com/blt-core-pos.git",
|
|
38
|
-
sshUrl: "git@github.com:bltcore-com/blt-core-pos.git",
|
|
39
|
-
description: "core pos application",
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: "kiosk",
|
|
43
|
-
gh: "bltcore-com/blt-core-kiosk",
|
|
44
|
-
url: "https://github.com/bltcore-com/blt-core-kiosk.git",
|
|
45
|
-
sshUrl: "git@github.com:bltcore-com/blt-core-kiosk.git",
|
|
46
|
-
description: "self-service kiosk application",
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
name: "gateway",
|
|
50
|
-
gh: "bltcore-com/blt-device-gateway",
|
|
51
|
-
url: "https://github.com/bltcore-com/blt-device-gateway.git",
|
|
52
|
-
sshUrl: "git@github.com:bltcore-com/blt-device-gateway.git",
|
|
53
|
-
description: "device manager/gateway",
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: "agents",
|
|
57
|
-
gh: "bltcore-com/blt-core-agents",
|
|
58
|
-
url: "https://github.com/bltcore-com/blt-core-agents.git",
|
|
59
|
-
sshUrl: "git@github.com:bltcore-com/blt-core-agents.git",
|
|
60
|
-
description: "hospitality agents repository",
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
name: "deploy",
|
|
64
|
-
gh: "bltcore-com/deploy",
|
|
65
|
-
url: "https://github.com/bltcore-com/deploy.git",
|
|
66
|
-
sshUrl: "git@github.com:bltcore-com/deploy.git",
|
|
67
|
-
description: "deployment scripts",
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: "customers",
|
|
71
|
-
gh: "bltcore-com/customers",
|
|
72
|
-
url: "https://github.com/bltcore-com/customers.git",
|
|
73
|
-
sshUrl: "git@github.com:bltcore-com/customers.git",
|
|
74
|
-
description: "customer repository",
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
name: "website",
|
|
78
|
-
gh: "bltcore-com/website",
|
|
79
|
-
url: "https://github.com/bltcore-com/website.git",
|
|
80
|
-
sshUrl: "git@github.com:bltcore-com/website.git",
|
|
81
|
-
description: "BLTWAI homepage",
|
|
82
|
-
},
|
|
83
|
-
];
|
|
91
|
+
export function getSubRepositories() {
|
|
92
|
+
return getRepositoryManifest().repositories.map(enrichRepo);
|
|
93
|
+
}
|
|
94
|
+
/** Full working set including the umbrella meta-repo (for display commands). */
|
|
95
|
+
export function getRepositories() {
|
|
96
|
+
const bundle = getBundleRepository();
|
|
97
|
+
return [
|
|
98
|
+
{ ...bundle, description: bundle.description ?? "workspace root" },
|
|
99
|
+
...getSubRepositories(),
|
|
100
|
+
];
|
|
101
|
+
}
|
|
84
102
|
//# sourceMappingURL=repositories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repositories.js","sourceRoot":"","sources":["../../src/lib/repositories.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"repositories.js","sourceRoot":"","sources":["../../src/lib/repositories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAkB3D,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,KAAK,GAAG,KAAgC,CAAC;IAC/C,OAAO,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,EAAE,KAAK,QAAQ,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,GAAY,EAAE,MAAc;IAClE,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,0BAA0B,CAAC,CAAC;IACvD,CAAC;IACD,MAAM,QAAQ,GAAG,GAA8B,CAAC;IAChD,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,uCAAuC,CAAC,CAAC;IACpE,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,2CAA2C,CAAC,CAAC;IACxE,CAAC;IACD,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,QAAQ,CAAC,YAAY,CAAC,OAAO,EAAE,EAAE,CAAC;QAC7D,IAAI,CAAC,eAAe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brella workspace"
|
|
6
|
+
},
|
|
7
|
+
"repositories": [
|
|
8
|
+
{
|
|
9
|
+
"name": "tools",
|
|
10
|
+
"gh": "bltcore-com/tools",
|
|
11
|
+
"description": "tools repository"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "data",
|
|
15
|
+
"gh": "bltcore-com/blt-core-data",
|
|
16
|
+
"description": "data schema & sample data"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "pos",
|
|
20
|
+
"gh": "bltcore-com/blt-core-pos",
|
|
21
|
+
"description": "core pos application"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "kiosk",
|
|
25
|
+
"gh": "bltcore-com/blt-core-kiosk",
|
|
26
|
+
"description": "self-service kiosk application"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "gateway",
|
|
30
|
+
"gh": "bltcore-com/blt-device-gateway",
|
|
31
|
+
"description": "device manager/gateway"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "agents",
|
|
35
|
+
"gh": "bltcore-com/blt-core-agents",
|
|
36
|
+
"description": "hospitality agents repository"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "deploy",
|
|
40
|
+
"gh": "bltcore-com/deploy",
|
|
41
|
+
"description": "deployment scripts"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "customers",
|
|
45
|
+
"gh": "bltcore-com/customers",
|
|
46
|
+
"description": "customer repository"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "website",
|
|
50
|
+
"gh": "bltcore-com/website",
|
|
51
|
+
"description": "BLTWAI homepage"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codemarc/blt",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.5",
|
|
4
4
|
"description": "blt cli",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/blt",
|
|
@@ -10,11 +10,12 @@
|
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"dist",
|
|
13
|
+
"repositories.json.example",
|
|
13
14
|
"README.md",
|
|
14
15
|
"LICENSE"
|
|
15
16
|
],
|
|
16
17
|
"scripts": {
|
|
17
|
-
"build": "bunx --bun tsc && mv dist/blt.js dist/blt && chmod +x dist/blt",
|
|
18
|
+
"build": "bunx --bun tsc && cp src/lib/repositories.manifest.json dist/lib/repositories.manifest.json && mv dist/blt.js dist/blt && chmod +x dist/blt",
|
|
18
19
|
"postbuild": "bun run src/commands/version/update.ts",
|
|
19
20
|
"dev": "bunx --bun tsc --watch",
|
|
20
21
|
"start": "bun run src/blt.ts",
|
|
@@ -48,21 +49,21 @@
|
|
|
48
49
|
},
|
|
49
50
|
"dependencies": {
|
|
50
51
|
"@caporal/core": "^2.0.7",
|
|
51
|
-
"@supabase/supabase-js": "^2.
|
|
52
|
+
"@supabase/supabase-js": "^2.108.2",
|
|
52
53
|
"@toon-format/toon": "2.2.0",
|
|
53
54
|
"build-number-generator": "^3.1.0",
|
|
54
55
|
"debug": "^4.4.3",
|
|
55
56
|
"dotenv": "^17.4.2",
|
|
56
57
|
"dotenv-expand": "^13.0.0",
|
|
57
58
|
"file-type": "^17.1.6",
|
|
58
|
-
"js-yaml": "^4.
|
|
59
|
+
"js-yaml": "^4.2.0",
|
|
59
60
|
"pdf-lib": "^1.17.1",
|
|
60
|
-
"pg": "^8.
|
|
61
|
+
"pg": "^8.22.0"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
64
|
"@types/debug": "^4.1.13",
|
|
64
65
|
"@types/js-yaml": "^4.0.9",
|
|
65
|
-
"@types/node": "^20.19.
|
|
66
|
+
"@types/node": "^20.19.43",
|
|
66
67
|
"@types/pg": "^8.20.0",
|
|
67
68
|
"bun-types": "^1.3.14",
|
|
68
69
|
"typescript": "^5.9.3"
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Logger } from "@caporal/core";
|
|
2
|
-
export type DbDiffOptions = {
|
|
3
|
-
sourceEnv: string;
|
|
4
|
-
targetEnv: string;
|
|
5
|
-
schema: string;
|
|
6
|
-
dir: string;
|
|
7
|
-
cwd?: string;
|
|
8
|
-
};
|
|
9
|
-
export type DiffArtifactKey = "source.sql" | "target.sql" | "rollforward.sql" | "rollback.sql";
|
|
10
|
-
export type DiffManifest = {
|
|
11
|
-
generatedAt: string;
|
|
12
|
-
source: {
|
|
13
|
-
kind: "env" | "file";
|
|
14
|
-
spec: string;
|
|
15
|
-
};
|
|
16
|
-
target: {
|
|
17
|
-
kind: "env" | "file";
|
|
18
|
-
spec: string;
|
|
19
|
-
};
|
|
20
|
-
schema: string;
|
|
21
|
-
dir: string;
|
|
22
|
-
connections: {
|
|
23
|
-
source: string;
|
|
24
|
-
target: string;
|
|
25
|
-
};
|
|
26
|
-
artifacts: Partial<Record<DiffArtifactKey, {
|
|
27
|
-
path: string;
|
|
28
|
-
bytes: number;
|
|
29
|
-
}>>;
|
|
30
|
-
notes: string[];
|
|
31
|
-
};
|
|
32
|
-
export declare function buildDiffPlan(sourceUrl: string, targetUrl: string, schema: string, outDir: string): {
|
|
33
|
-
rollforward: string[];
|
|
34
|
-
rollback: string[];
|
|
35
|
-
};
|
|
36
|
-
export declare function dbDiff(opts: DbDiffOptions, logger: Logger): Promise<void>;
|
|
37
|
-
//# sourceMappingURL=diff.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/commands/db/diff.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAoB5C,MAAM,MAAM,aAAa,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,eAAe,GACxB,YAAY,GACZ,YAAY,GACZ,iBAAiB,GACjB,cAAc,CAAC;AAElB,MAAM,MAAM,YAAY,GAAG;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE;QAAE,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,MAAM,EAAE;QAAE,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;KACf,CAAC;IACF,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAC;IAC7E,KAAK,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAEF,wBAAgB,aAAa,CAC5B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM;;;EAgBd;AA4CD,wBAAsB,MAAM,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgH/E"}
|
package/dist/commands/db/diff.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { writeFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { runCommand } from "../app/shell";
|
|
4
|
-
import { redactedDbUrl } from "../data/helpers";
|
|
5
|
-
import { materializeDumpArtifact, resolveDiffEndpoint, } from "./diff-endpoint";
|
|
6
|
-
import { resolveSchemaUrlsForDiff } from "./schema-loader";
|
|
7
|
-
import { buildSupabaseDiffArgs, ensureOutDir, fileBytes, prependHeader, requireSupabaseCli, resolveOutDir, runSchemaDump, sqlFileHeader, } from "./supabase-schema";
|
|
8
|
-
export function buildDiffPlan(sourceUrl, targetUrl, schema, outDir) {
|
|
9
|
-
return {
|
|
10
|
-
rollforward: buildSupabaseDiffArgs(targetUrl, sourceUrl, schema, join(outDir, "rollforward.sql")),
|
|
11
|
-
rollback: buildSupabaseDiffArgs(sourceUrl, targetUrl, schema, join(outDir, "rollback.sql")),
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function connectionLabel(endpoint) {
|
|
15
|
-
return endpoint.kind === "env"
|
|
16
|
-
? redactedDbUrl(endpoint.dbUrl)
|
|
17
|
-
: endpoint.path;
|
|
18
|
-
}
|
|
19
|
-
function prepareDumpArtifact(endpoint, artifactPath, otherSpec, opts, generatedAt, logger, cwd, side) {
|
|
20
|
-
const header = sqlFileHeader({
|
|
21
|
-
command: "diff",
|
|
22
|
-
kind: "dump",
|
|
23
|
-
env: endpoint.spec,
|
|
24
|
-
otherEnv: otherSpec,
|
|
25
|
-
schema: opts.schema,
|
|
26
|
-
generatedAt,
|
|
27
|
-
});
|
|
28
|
-
if (endpoint.kind === "file") {
|
|
29
|
-
materializeDumpArtifact(endpoint.path, artifactPath, logger);
|
|
30
|
-
prependHeader(artifactPath, header);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
runSchemaDump({
|
|
34
|
-
dbUrl: endpoint.dbUrl,
|
|
35
|
-
schema: opts.schema,
|
|
36
|
-
outputFile: artifactPath,
|
|
37
|
-
header,
|
|
38
|
-
logger,
|
|
39
|
-
cwd,
|
|
40
|
-
label: side === "source" ? "Dumping source schema…" : "Dumping target schema…",
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
export async function dbDiff(opts, logger) {
|
|
44
|
-
const cwd = opts.cwd ?? process.cwd();
|
|
45
|
-
const outDir = resolveOutDir(opts.dir, cwd);
|
|
46
|
-
const generatedAt = new Date().toISOString();
|
|
47
|
-
if (opts.sourceEnv === opts.targetEnv) {
|
|
48
|
-
logger.error("Source and target must differ.");
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
|
-
requireSupabaseCli(logger);
|
|
52
|
-
ensureOutDir(outDir, logger);
|
|
53
|
-
logger.info(`Schema: ${opts.schema}`);
|
|
54
|
-
const source = resolveDiffEndpoint(opts.sourceEnv, logger, cwd);
|
|
55
|
-
const target = resolveDiffEndpoint(opts.targetEnv, logger, cwd);
|
|
56
|
-
const sourceArtifact = join(outDir, "source.sql");
|
|
57
|
-
const targetArtifact = join(outDir, "target.sql");
|
|
58
|
-
prepareDumpArtifact(source, sourceArtifact, opts.targetEnv, opts, generatedAt, logger, cwd, "source");
|
|
59
|
-
prepareDumpArtifact(target, targetArtifact, opts.sourceEnv, opts, generatedAt, logger, cwd, "target");
|
|
60
|
-
const { sourceUrl, targetUrl, cleanup } = resolveSchemaUrlsForDiff({
|
|
61
|
-
source: source.kind === "env"
|
|
62
|
-
? { kind: "env", dbUrl: source.dbUrl }
|
|
63
|
-
: { kind: "file", path: sourceArtifact },
|
|
64
|
-
target: target.kind === "env"
|
|
65
|
-
? { kind: "env", dbUrl: target.dbUrl }
|
|
66
|
-
: { kind: "file", path: targetArtifact },
|
|
67
|
-
logger,
|
|
68
|
-
});
|
|
69
|
-
try {
|
|
70
|
-
const plan = buildDiffPlan(sourceUrl, targetUrl, opts.schema, outDir);
|
|
71
|
-
const diffHeader = (kind) => sqlFileHeader({
|
|
72
|
-
command: "diff",
|
|
73
|
-
kind,
|
|
74
|
-
env: opts.sourceEnv,
|
|
75
|
-
otherEnv: opts.targetEnv,
|
|
76
|
-
schema: opts.schema,
|
|
77
|
-
generatedAt,
|
|
78
|
-
});
|
|
79
|
-
logger.info("Generating roll-forward SQL (target → source)…");
|
|
80
|
-
runCommand("supabase", plan.rollforward, logger, { cwd });
|
|
81
|
-
prependHeader(join(outDir, "rollforward.sql"), diffHeader("rollforward"));
|
|
82
|
-
logger.info("Generating rollback SQL (source → target)…");
|
|
83
|
-
runCommand("supabase", plan.rollback, logger, { cwd });
|
|
84
|
-
prependHeader(join(outDir, "rollback.sql"), diffHeader("rollback"));
|
|
85
|
-
}
|
|
86
|
-
finally {
|
|
87
|
-
cleanup();
|
|
88
|
-
}
|
|
89
|
-
const artifacts = {};
|
|
90
|
-
for (const key of [
|
|
91
|
-
"source.sql",
|
|
92
|
-
"target.sql",
|
|
93
|
-
"rollforward.sql",
|
|
94
|
-
"rollback.sql",
|
|
95
|
-
]) {
|
|
96
|
-
const path = join(outDir, key);
|
|
97
|
-
artifacts[key] = { path, bytes: fileBytes(path) };
|
|
98
|
-
}
|
|
99
|
-
const manifest = {
|
|
100
|
-
generatedAt,
|
|
101
|
-
source: { kind: source.kind, spec: source.spec },
|
|
102
|
-
target: { kind: target.kind, spec: target.spec },
|
|
103
|
-
schema: opts.schema,
|
|
104
|
-
dir: outDir,
|
|
105
|
-
connections: {
|
|
106
|
-
source: connectionLabel(source),
|
|
107
|
-
target: connectionLabel(target),
|
|
108
|
-
},
|
|
109
|
-
artifacts,
|
|
110
|
-
notes: [
|
|
111
|
-
"Review rollforward.sql before applying to the target database.",
|
|
112
|
-
"Rollback SQL may include destructive DDL — review before use.",
|
|
113
|
-
".sql file endpoints skip re-dump; existing files are copied to source.sql / target.sql when needed.",
|
|
114
|
-
"Docker is used to load .sql files for supabase db diff when a side is not a live env URL.",
|
|
115
|
-
"Prefer direct Postgres URLs (port 5432) when pooler URLs cause dump/diff timeouts.",
|
|
116
|
-
],
|
|
117
|
-
};
|
|
118
|
-
const manifestPath = join(outDir, "manifest.json");
|
|
119
|
-
writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
|
|
120
|
-
logger.info(`Wrote ${manifestPath}`);
|
|
121
|
-
logger.info("Done. Review rollforward.sql and rollback.sql before applying.");
|
|
122
|
-
}
|
|
123
|
-
//# sourceMappingURL=diff.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../../../src/commands/db/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EACN,uBAAuB,EACvB,mBAAmB,GAEnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EACN,qBAAqB,EACrB,YAAY,EACZ,SAAS,EACT,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,aAAa,GACb,MAAM,mBAAmB,CAAC;AA8B3B,MAAM,UAAU,aAAa,CAC5B,SAAiB,EACjB,SAAiB,EACjB,MAAc,EACd,MAAc;IAEd,OAAO;QACN,WAAW,EAAE,qBAAqB,CACjC,SAAS,EACT,SAAS,EACT,MAAM,EACN,IAAI,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAC/B;QACD,QAAQ,EAAE,qBAAqB,CAC9B,SAAS,EACT,SAAS,EACT,MAAM,EACN,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,CAC5B;KACD,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CAAC,QAAsB;IAC9C,OAAO,QAAQ,CAAC,IAAI,KAAK,KAAK;QAC7B,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC;QAC/B,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;AAClB,CAAC;AAED,SAAS,mBAAmB,CAC3B,QAAsB,EACtB,YAAoB,EACpB,SAAiB,EACjB,IAAmB,EACnB,WAAmB,EACnB,MAAc,EACd,GAAW,EACX,IAAyB;IAEz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