@akal/supaforge 0.0.34 → 0.0.35
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 +28 -12
- package/dist/base-command.d.ts +1 -1
- package/dist/base-command.js +2 -2
- package/dist/{branch-C4ndfoj5.d.ts → branch-BppjQBv_.d.ts} +1 -1
- package/dist/{chunk-PYAGSMFB.js → chunk-44UVQJV2.js} +146 -13
- package/dist/{chunk-OB5GP7UB.js → chunk-4AGJRRBT.js} +376 -32
- package/dist/{chunk-MG3SFV5J.js → chunk-4M6OQLPO.js} +1 -1
- package/dist/{chunk-TPX2MAO4.js → chunk-5Q6LSLA3.js} +53 -4
- package/dist/{chunk-F46FFUKC.js → chunk-7N63OPFN.js} +20 -12
- package/dist/chunk-AGONS5JJ.js +242 -0
- package/dist/{chunk-7DL63NWP.js → chunk-H2D3YSKM.js} +6 -2
- package/dist/{chunk-3WKWPSFN.js → chunk-NEM5AEPQ.js} +171 -21
- package/dist/{chunk-6ERVCWLY.js → chunk-NX2KKUS7.js} +6 -6
- package/dist/{chunk-S5L4A3UR.js → chunk-O5ERC2SE.js} +2 -2
- package/dist/{chunk-ICSCHS72.js → chunk-SM7HP6EP.js} +10 -180
- package/dist/{chunk-N5VNNOA2.js → chunk-T7GMPGUO.js} +578 -16
- package/dist/{chunk-DQJSSTIJ.js → chunk-WNTCZM2J.js} +4 -476
- package/dist/{chunk-5STH2A6K.js → chunk-XLZCX6R2.js} +2 -2
- package/dist/{chunk-EFKQOQGG.js → chunk-YWERIWFD.js} +6 -4
- package/dist/{chunk-V2SBZERO.js → chunk-YZM76W22.js} +3 -3
- package/dist/commands/clone.d.ts +2 -2
- package/dist/commands/clone.js +7 -6
- package/dist/commands/diff.d.ts +24 -22
- package/dist/commands/diff.js +11 -11
- package/dist/commands/hukam.d.ts +2 -3
- package/dist/commands/hukam.js +11 -11
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/mcp.js +8 -8
- package/dist/commands/migrate/baseline.d.ts +1 -1
- package/dist/commands/migrate/baseline.js +3 -3
- package/dist/commands/migrate/create.d.ts +1 -1
- package/dist/commands/migrate/create.js +12 -7
- package/dist/commands/migrate/list.d.ts +1 -1
- package/dist/commands/migrate/list.js +3 -3
- package/dist/commands/migrate/run.d.ts +4 -1
- package/dist/commands/migrate/run.js +7 -6
- package/dist/commands/report.d.ts +1 -1
- package/dist/commands/report.js +2 -2
- package/dist/commands/restore.d.ts +1 -1
- package/dist/commands/restore.js +10 -10
- package/dist/commands/snapshot.d.ts +1 -1
- package/dist/commands/snapshot.js +5 -5
- package/dist/commands/sync.d.ts +2 -3
- package/dist/commands/sync.js +11 -11
- package/dist/{config-CTbeRlJk.d.ts → config-l3ggjw9r.d.ts} +2 -0
- package/dist/index.d.ts +21 -4
- package/dist/index.js +13 -13
- package/package.json +2 -2
- package/dist/chunk-DQQ5E563.js +0 -64
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
pgQuery,
|
|
3
3
|
readLocalMigrations
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-4M6OQLPO.js";
|
|
5
5
|
import {
|
|
6
6
|
MIGRATIONS_SCHEMA,
|
|
7
7
|
MIGRATIONS_TABLE
|
|
@@ -119,4 +119,4 @@ export {
|
|
|
119
119
|
runMigration,
|
|
120
120
|
baselineMigrations
|
|
121
121
|
};
|
|
122
|
-
//# sourceMappingURL=chunk-
|
|
122
|
+
//# sourceMappingURL=chunk-O5ERC2SE.js.map
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
assertPgBinUsable,
|
|
3
|
+
describeMissingPgDump,
|
|
4
|
+
getServerMajorVersion,
|
|
5
|
+
normalizeRoles,
|
|
6
|
+
resolvePgDumpPath
|
|
7
|
+
} from "./chunk-AGONS5JJ.js";
|
|
4
8
|
import {
|
|
5
9
|
Check,
|
|
6
10
|
inRolledBackTransaction,
|
|
7
|
-
newPgClient,
|
|
8
11
|
newPgPool,
|
|
9
12
|
pgClientConfig,
|
|
10
13
|
pgQuery,
|
|
@@ -12,7 +15,7 @@ import {
|
|
|
12
15
|
quoteLiteral,
|
|
13
16
|
quoteName,
|
|
14
17
|
readOrAbsent
|
|
15
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-4M6OQLPO.js";
|
|
16
19
|
import {
|
|
17
20
|
DEFAULT_IGNORE_SCHEMAS,
|
|
18
21
|
MIGRATIONS_SUBDIR,
|
|
@@ -27,175 +30,6 @@ import {
|
|
|
27
30
|
warn
|
|
28
31
|
} from "./chunk-KNXHLVF7.js";
|
|
29
32
|
|
|
30
|
-
// src/pg-tools.ts
|
|
31
|
-
import { execFile } from "child_process";
|
|
32
|
-
import { platform } from "os";
|
|
33
|
-
import { existsSync } from "fs";
|
|
34
|
-
function parsePgDumpVersion(output) {
|
|
35
|
-
const m = output.match(/(\d+)(?:\.\d+)?/);
|
|
36
|
-
return m ? Number(m[1]) : null;
|
|
37
|
-
}
|
|
38
|
-
function parseServerVersion(versionStr) {
|
|
39
|
-
const m = versionStr.match(/^(\d+)/);
|
|
40
|
-
return m ? Number(m[1]) : null;
|
|
41
|
-
}
|
|
42
|
-
async function getLocalPgDumpVersion() {
|
|
43
|
-
return new Promise((resolve2) => {
|
|
44
|
-
execFile("pg_dump", ["--version"], (err, stdout) => {
|
|
45
|
-
if (err) return resolve2(null);
|
|
46
|
-
resolve2(parsePgDumpVersion(stdout));
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
function getPgDumpVersionAt(path) {
|
|
51
|
-
return new Promise((resolve2) => {
|
|
52
|
-
execFile(path, ["--version"], (err, stdout) => {
|
|
53
|
-
if (err) return resolve2(null);
|
|
54
|
-
resolve2(parsePgDumpVersion(stdout));
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
var VERSIONED_PG_DIRS = [
|
|
59
|
-
"/usr/lib/postgresql/{v}/bin",
|
|
60
|
-
// Debian / Ubuntu (PGDG)
|
|
61
|
-
"/opt/homebrew/opt/postgresql@{v}/bin",
|
|
62
|
-
// macOS Homebrew (Apple Silicon)
|
|
63
|
-
"/usr/local/opt/postgresql@{v}/bin",
|
|
64
|
-
// macOS Homebrew (Intel)
|
|
65
|
-
"/usr/pgsql-{v}/bin"
|
|
66
|
-
// RHEL / CentOS (PGDG)
|
|
67
|
-
];
|
|
68
|
-
async function resolvePgDumpPath(serverMajor) {
|
|
69
|
-
const named = process.env.SUPAFORGE_PG_BIN?.trim();
|
|
70
|
-
if (named) {
|
|
71
|
-
if (!existsSync(`${named}/pg_dump`)) {
|
|
72
|
-
throw new Error(`SUPAFORGE_PG_BIN is set to "${named}", which has no pg_dump`);
|
|
73
|
-
}
|
|
74
|
-
const major = await getPgDumpVersionAt(`${named}/pg_dump`);
|
|
75
|
-
if (major !== null && major >= serverMajor) return { path: `${named}/pg_dump`, major };
|
|
76
|
-
}
|
|
77
|
-
const defaultMajor = await getLocalPgDumpVersion();
|
|
78
|
-
if (defaultMajor !== null && defaultMajor >= serverMajor) {
|
|
79
|
-
return { path: "pg_dump", major: defaultMajor };
|
|
80
|
-
}
|
|
81
|
-
for (const v of versionsToCheck(serverMajor)) {
|
|
82
|
-
for (const tmpl of VERSIONED_PG_DIRS) {
|
|
83
|
-
const dir = tmpl.replace("{v}", String(v));
|
|
84
|
-
const candidate = `${dir}/pg_dump`;
|
|
85
|
-
if (!existsSync(candidate)) continue;
|
|
86
|
-
const major = await getPgDumpVersionAt(candidate);
|
|
87
|
-
if (major !== null && major >= serverMajor) {
|
|
88
|
-
return { path: candidate, major };
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
function assertPgBinUsable() {
|
|
95
|
-
const named = process.env.SUPAFORGE_PG_BIN?.trim();
|
|
96
|
-
if (named && !existsSync(`${named}/pg_dump`)) {
|
|
97
|
-
throw new Error(
|
|
98
|
-
`SUPAFORGE_PG_BIN is set to "${named}", which has no pg_dump. Point it at a directory of PostgreSQL client tools, or unset it to use the ones on PATH.`
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
async function describeMissingPgDump(neededMajor) {
|
|
103
|
-
const onPath = await getLocalPgDumpVersion();
|
|
104
|
-
const named = process.env.SUPAFORGE_PG_BIN?.trim();
|
|
105
|
-
const namedMajor = named ? await getPgDumpVersionAt(`${named}/pg_dump`) : null;
|
|
106
|
-
const found = [
|
|
107
|
-
onPath === null ? "none on PATH" : `${onPath} on PATH`,
|
|
108
|
-
...named ? [`${namedMajor ?? "none"} in SUPAFORGE_PG_BIN`] : []
|
|
109
|
-
].join(", ");
|
|
110
|
-
return `no pg_dump ${neededMajor} or newer (found: ${found}); set SUPAFORGE_PG_BIN to a directory of PostgreSQL ${neededMajor}+ client tools`;
|
|
111
|
-
}
|
|
112
|
-
function resolvePgRestorePath(pgDumpPath) {
|
|
113
|
-
if (pgDumpPath === "pg_dump") return "pg_restore";
|
|
114
|
-
return pgDumpPath.replace(/pg_dump$/, "pg_restore");
|
|
115
|
-
}
|
|
116
|
-
function versionsToCheck(required) {
|
|
117
|
-
const versions = [];
|
|
118
|
-
for (let v = required + 3; v >= required; v--) {
|
|
119
|
-
versions.push(v);
|
|
120
|
-
}
|
|
121
|
-
return versions;
|
|
122
|
-
}
|
|
123
|
-
async function getServerMajorVersion(dbUrl) {
|
|
124
|
-
const client = newPgClient(dbUrl);
|
|
125
|
-
try {
|
|
126
|
-
await client.connect();
|
|
127
|
-
const { rows } = await client.query("SHOW server_version");
|
|
128
|
-
const raw = rows[0].server_version;
|
|
129
|
-
const major = parseServerVersion(raw);
|
|
130
|
-
if (!major) throw new Error(`Could not parse server version: ${raw}`);
|
|
131
|
-
return major;
|
|
132
|
-
} finally {
|
|
133
|
-
await client.end();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
async function checkPgDumpCompat(dbUrl) {
|
|
137
|
-
const serverMajor = await getServerMajorVersion(dbUrl);
|
|
138
|
-
const resolved = await resolvePgDumpPath(serverMajor);
|
|
139
|
-
if (resolved) {
|
|
140
|
-
return {
|
|
141
|
-
localMajor: resolved.major,
|
|
142
|
-
serverMajor,
|
|
143
|
-
compatible: true,
|
|
144
|
-
message: "",
|
|
145
|
-
pgDumpPath: resolved.path,
|
|
146
|
-
pgRestorePath: resolvePgRestorePath(resolved.path)
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
const localMajor = await getLocalPgDumpVersion();
|
|
150
|
-
const message = buildInstallMessage(localMajor, serverMajor);
|
|
151
|
-
return {
|
|
152
|
-
localMajor,
|
|
153
|
-
serverMajor,
|
|
154
|
-
compatible: false,
|
|
155
|
-
message,
|
|
156
|
-
pgDumpPath: "pg_dump",
|
|
157
|
-
pgRestorePath: "pg_restore"
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
function buildInstallMessage(localMajor, serverMajor) {
|
|
161
|
-
const header = localMajor === null ? `pg_dump not found. The server is PostgreSQL ${serverMajor} \u2014 install postgresql-client-${serverMajor}:` : `pg_dump version mismatch: local v${localMajor}, server v${serverMajor}. Install postgresql-client-${serverMajor}:`;
|
|
162
|
-
const instructions = getInstallInstructions(serverMajor);
|
|
163
|
-
return `${header}
|
|
164
|
-
|
|
165
|
-
${instructions}`;
|
|
166
|
-
}
|
|
167
|
-
function getInstallInstructions(majorVersion) {
|
|
168
|
-
const os = platform();
|
|
169
|
-
const v = majorVersion;
|
|
170
|
-
switch (os) {
|
|
171
|
-
case "darwin":
|
|
172
|
-
return [
|
|
173
|
-
` brew install postgresql@${v}`,
|
|
174
|
-
` # Then add to PATH:`,
|
|
175
|
-
` export PATH="/opt/homebrew/opt/postgresql@${v}/bin:$PATH"`
|
|
176
|
-
].join("\n");
|
|
177
|
-
case "linux":
|
|
178
|
-
return [
|
|
179
|
-
` # Debian / Ubuntu:`,
|
|
180
|
-
` sudo apt-get install -y postgresql-client-${v}`,
|
|
181
|
-
` # If the package is not found, add the PGDG repository first:`,
|
|
182
|
-
` # https://www.postgresql.org/download/linux/ubuntu/`,
|
|
183
|
-
``,
|
|
184
|
-
` # RHEL / Fedora:`,
|
|
185
|
-
` sudo dnf install -y postgresql${v}`
|
|
186
|
-
].join("\n");
|
|
187
|
-
case "win32":
|
|
188
|
-
return [
|
|
189
|
-
` # Download the installer from:`,
|
|
190
|
-
` # https://www.postgresql.org/download/windows/`,
|
|
191
|
-
` # Or use Chocolatey:`,
|
|
192
|
-
` choco install postgresql${v} --params '/Password:postgres'`
|
|
193
|
-
].join("\n");
|
|
194
|
-
default:
|
|
195
|
-
return ` Download PostgreSQL ${v} client tools from: https://www.postgresql.org/download/`;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
33
|
// src/snapshot.ts
|
|
200
34
|
import { mkdir, writeFile, readFile, readdir, rm } from "fs/promises";
|
|
201
35
|
import { join, resolve } from "path";
|
|
@@ -737,7 +571,7 @@ function shapeOf(value) {
|
|
|
737
571
|
}
|
|
738
572
|
|
|
739
573
|
// src/snapshot.ts
|
|
740
|
-
var
|
|
574
|
+
var execFile = promisify(execFileCb);
|
|
741
575
|
function generateTimestamp() {
|
|
742
576
|
return (/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
|
|
743
577
|
}
|
|
@@ -852,7 +686,7 @@ async function captureSchemaSql(dir, dbUrl, schemas) {
|
|
|
852
686
|
sqlSkipReason: `${await describeMissingPgDump(serverMajor)} \u2014 schema.json was still captured, but restore cannot replay the schema`
|
|
853
687
|
};
|
|
854
688
|
}
|
|
855
|
-
const { stdout } = await
|
|
689
|
+
const { stdout } = await execFile(resolved.path, [
|
|
856
690
|
dbUrl,
|
|
857
691
|
"--schema-only",
|
|
858
692
|
"--no-owner",
|
|
@@ -1328,10 +1162,6 @@ export {
|
|
|
1328
1162
|
readJsonArray,
|
|
1329
1163
|
readJsonObject,
|
|
1330
1164
|
RealtimeCheck,
|
|
1331
|
-
resolvePgDumpPath,
|
|
1332
|
-
describeMissingPgDump,
|
|
1333
|
-
getServerMajorVersion,
|
|
1334
|
-
checkPgDumpCompat,
|
|
1335
1165
|
captureSnapshot,
|
|
1336
1166
|
unrestorableSchema,
|
|
1337
1167
|
formatSnapshotLayers,
|
|
@@ -1341,4 +1171,4 @@ export {
|
|
|
1341
1171
|
DEFAULT_KEEP_COUNT,
|
|
1342
1172
|
pruneSnapshots
|
|
1343
1173
|
};
|
|
1344
|
-
//# sourceMappingURL=chunk-
|
|
1174
|
+
//# sourceMappingURL=chunk-SM7HP6EP.js.map
|