@akal/supaforge 0.0.34 → 0.0.36
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 +32 -13
- package/dist/base-command.d.ts +1 -1
- package/dist/base-command.js +4 -4
- package/dist/{branch-C4ndfoj5.d.ts → branch-BppjQBv_.d.ts} +1 -1
- package/dist/{chunk-ICSCHS72.js → chunk-5UHIWFQG.js} +76 -186
- package/dist/{chunk-S5L4A3UR.js → chunk-AL6INEFX.js} +3 -3
- package/dist/{chunk-OB5GP7UB.js → chunk-CAQ3QQFP.js} +437 -45
- package/dist/{chunk-TPX2MAO4.js → chunk-CCB7ARZU.js} +54 -5
- package/dist/{chunk-V2SBZERO.js → chunk-EWNZIRCD.js} +4 -4
- package/dist/{chunk-EFKQOQGG.js → chunk-FD2JKEJA.js} +7 -5
- package/dist/{chunk-3WKWPSFN.js → chunk-GGZ7YWBZ.js} +191 -32
- package/dist/{chunk-F46FFUKC.js → chunk-JX5L253P.js} +56 -18
- package/dist/{chunk-GQPGH6YR.js → chunk-KHXEES2M.js} +2 -2
- package/dist/{chunk-MG3SFV5J.js → chunk-KT7NMELZ.js} +77 -7
- package/dist/{chunk-PYAGSMFB.js → chunk-M2564IGT.js} +159 -19
- package/dist/{chunk-7DL63NWP.js → chunk-MRXIE55Y.js} +7 -3
- package/dist/{chunk-6ERVCWLY.js → chunk-MZPWRWBL.js} +7 -7
- package/dist/{chunk-5STH2A6K.js → chunk-OXS42LJH.js} +4 -4
- package/dist/{chunk-HNJ6BNNZ.js → chunk-Q43MN6NE.js} +2 -2
- package/dist/{chunk-ZI435CAU.js → chunk-RQCXGO37.js} +2 -2
- package/dist/{chunk-KNXHLVF7.js → chunk-SQ52YBKK.js} +3 -2
- package/dist/{chunk-N5VNNOA2.js → chunk-YUJ2MHLM.js} +1236 -22
- package/dist/chunk-Z2YUOA4W.js +242 -0
- package/dist/commands/clone.d.ts +2 -2
- package/dist/commands/clone.js +10 -9
- package/dist/commands/diff.d.ts +25 -22
- package/dist/commands/diff.js +14 -15
- package/dist/commands/hukam.d.ts +2 -3
- package/dist/commands/hukam.js +14 -15
- package/dist/commands/init.d.ts +1 -1
- package/dist/commands/init.js +2 -2
- package/dist/commands/mcp.js +9 -10
- package/dist/commands/migrate/baseline.d.ts +1 -1
- package/dist/commands/migrate/baseline.js +5 -5
- package/dist/commands/migrate/create.d.ts +1 -1
- package/dist/commands/migrate/create.js +27 -13
- package/dist/commands/migrate/list.d.ts +1 -1
- package/dist/commands/migrate/list.js +5 -5
- package/dist/commands/migrate/run.d.ts +4 -1
- package/dist/commands/migrate/run.js +9 -8
- package/dist/commands/report.d.ts +1 -1
- package/dist/commands/report.js +5 -5
- package/dist/commands/restore.d.ts +1 -1
- package/dist/commands/restore.js +14 -13
- package/dist/commands/snapshot.d.ts +1 -1
- package/dist/commands/snapshot.js +8 -8
- package/dist/commands/sync.d.ts +2 -3
- package/dist/commands/sync.js +14 -15
- package/dist/{config-CTbeRlJk.d.ts → config-l3ggjw9r.d.ts} +2 -0
- package/dist/index.d.ts +38 -4
- package/dist/index.js +13 -14
- package/package.json +2 -2
- package/dist/chunk-DQJSSTIJ.js +0 -940
- package/dist/chunk-DQQ5E563.js +0 -64
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import {
|
|
2
|
+
newPgClient
|
|
3
|
+
} from "./chunk-KT7NMELZ.js";
|
|
4
|
+
|
|
5
|
+
// src/utils/strings.ts
|
|
6
|
+
var MAX_SLUG_LENGTH = 60;
|
|
7
|
+
function slugify(name, separator = "_") {
|
|
8
|
+
const pattern = new RegExp(`[^a-z0-9]+`, "g");
|
|
9
|
+
const edgePattern = new RegExp(`^${escapeRegex(separator)}|${escapeRegex(separator)}$`, "g");
|
|
10
|
+
return name.toLowerCase().replace(pattern, separator).replace(edgePattern, "").slice(0, MAX_SLUG_LENGTH);
|
|
11
|
+
}
|
|
12
|
+
function escapeRegex(s) {
|
|
13
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
14
|
+
}
|
|
15
|
+
function parseFlagList(values) {
|
|
16
|
+
if (!Array.isArray(values)) return [];
|
|
17
|
+
return values.flatMap((v) => String(v).split(",")).map((v) => v.trim()).filter((v) => v.length > 0);
|
|
18
|
+
}
|
|
19
|
+
function globToRegExp(pattern) {
|
|
20
|
+
let out = "^";
|
|
21
|
+
for (const ch of pattern) {
|
|
22
|
+
if (ch === "*") out += ".*";
|
|
23
|
+
else if (ch === "?") out += ".";
|
|
24
|
+
else out += escapeRegex(ch);
|
|
25
|
+
}
|
|
26
|
+
return new RegExp(out + "$");
|
|
27
|
+
}
|
|
28
|
+
function matchesGlob(value, pattern) {
|
|
29
|
+
return globToRegExp(pattern.toLowerCase()).test(value.toLowerCase());
|
|
30
|
+
}
|
|
31
|
+
function normalizeRoles(roles) {
|
|
32
|
+
const arr = Array.isArray(roles) ? roles : [roles];
|
|
33
|
+
return [...new Set(
|
|
34
|
+
arr.flatMap((r) => /^\{.*\}$/s.test(r) ? arrayLiteralElements(r) : [r]).map((r) => r.trim()).filter(Boolean)
|
|
35
|
+
)].sort();
|
|
36
|
+
}
|
|
37
|
+
function arrayLiteralElements(literal) {
|
|
38
|
+
const inner = literal.slice(1, -1);
|
|
39
|
+
const out = [];
|
|
40
|
+
let i = 0;
|
|
41
|
+
while (i < inner.length) {
|
|
42
|
+
let value = "";
|
|
43
|
+
if (inner[i] === '"') {
|
|
44
|
+
for (i++; i < inner.length && inner[i] !== '"'; i++) {
|
|
45
|
+
if (inner[i] === "\\") i++;
|
|
46
|
+
value += inner[i];
|
|
47
|
+
}
|
|
48
|
+
i++;
|
|
49
|
+
} else {
|
|
50
|
+
const end = inner.indexOf(",", i);
|
|
51
|
+
value = inner.slice(i, end === -1 ? inner.length : end);
|
|
52
|
+
i = end === -1 ? inner.length : end;
|
|
53
|
+
}
|
|
54
|
+
out.push(value);
|
|
55
|
+
if (inner[i] === ",") i++;
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// src/pg-tools.ts
|
|
61
|
+
import { execFile } from "child_process";
|
|
62
|
+
import { platform } from "os";
|
|
63
|
+
import { existsSync } from "fs";
|
|
64
|
+
function parsePgDumpVersion(output) {
|
|
65
|
+
const m = output.match(/(\d+)(?:\.\d+)?/);
|
|
66
|
+
return m ? Number(m[1]) : null;
|
|
67
|
+
}
|
|
68
|
+
function parseServerVersion(versionStr) {
|
|
69
|
+
const m = versionStr.match(/^(\d+)/);
|
|
70
|
+
return m ? Number(m[1]) : null;
|
|
71
|
+
}
|
|
72
|
+
async function getLocalPgDumpVersion() {
|
|
73
|
+
return new Promise((resolve) => {
|
|
74
|
+
execFile("pg_dump", ["--version"], (err, stdout) => {
|
|
75
|
+
if (err) return resolve(null);
|
|
76
|
+
resolve(parsePgDumpVersion(stdout));
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function getPgDumpVersionAt(path) {
|
|
81
|
+
return new Promise((resolve) => {
|
|
82
|
+
execFile(path, ["--version"], (err, stdout) => {
|
|
83
|
+
if (err) return resolve(null);
|
|
84
|
+
resolve(parsePgDumpVersion(stdout));
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
var VERSIONED_PG_DIRS = [
|
|
89
|
+
"/usr/lib/postgresql/{v}/bin",
|
|
90
|
+
// Debian / Ubuntu (PGDG)
|
|
91
|
+
"/opt/homebrew/opt/postgresql@{v}/bin",
|
|
92
|
+
// macOS Homebrew (Apple Silicon)
|
|
93
|
+
"/usr/local/opt/postgresql@{v}/bin",
|
|
94
|
+
// macOS Homebrew (Intel)
|
|
95
|
+
"/usr/pgsql-{v}/bin"
|
|
96
|
+
// RHEL / CentOS (PGDG)
|
|
97
|
+
];
|
|
98
|
+
async function resolvePgDumpPath(serverMajor) {
|
|
99
|
+
const named = process.env.SUPAFORGE_PG_BIN?.trim();
|
|
100
|
+
if (named) {
|
|
101
|
+
if (!existsSync(`${named}/pg_dump`)) {
|
|
102
|
+
throw new Error(`SUPAFORGE_PG_BIN is set to "${named}", which has no pg_dump`);
|
|
103
|
+
}
|
|
104
|
+
const major = await getPgDumpVersionAt(`${named}/pg_dump`);
|
|
105
|
+
if (major !== null && major >= serverMajor) return { path: `${named}/pg_dump`, major };
|
|
106
|
+
}
|
|
107
|
+
const defaultMajor = await getLocalPgDumpVersion();
|
|
108
|
+
if (defaultMajor !== null && defaultMajor >= serverMajor) {
|
|
109
|
+
return { path: "pg_dump", major: defaultMajor };
|
|
110
|
+
}
|
|
111
|
+
for (const v of versionsToCheck(serverMajor)) {
|
|
112
|
+
for (const tmpl of VERSIONED_PG_DIRS) {
|
|
113
|
+
const dir = tmpl.replace("{v}", String(v));
|
|
114
|
+
const candidate = `${dir}/pg_dump`;
|
|
115
|
+
if (!existsSync(candidate)) continue;
|
|
116
|
+
const major = await getPgDumpVersionAt(candidate);
|
|
117
|
+
if (major !== null && major >= serverMajor) {
|
|
118
|
+
return { path: candidate, major };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
function assertPgBinUsable() {
|
|
125
|
+
const named = process.env.SUPAFORGE_PG_BIN?.trim();
|
|
126
|
+
if (named && !existsSync(`${named}/pg_dump`)) {
|
|
127
|
+
throw new Error(
|
|
128
|
+
`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.`
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async function describeMissingPgDump(neededMajor) {
|
|
133
|
+
const onPath = await getLocalPgDumpVersion();
|
|
134
|
+
const named = process.env.SUPAFORGE_PG_BIN?.trim();
|
|
135
|
+
const namedMajor = named ? await getPgDumpVersionAt(`${named}/pg_dump`) : null;
|
|
136
|
+
const found = [
|
|
137
|
+
onPath === null ? "none on PATH" : `${onPath} on PATH`,
|
|
138
|
+
...named ? [`${namedMajor ?? "none"} in SUPAFORGE_PG_BIN`] : []
|
|
139
|
+
].join(", ");
|
|
140
|
+
return `no pg_dump ${neededMajor} or newer (found: ${found}); set SUPAFORGE_PG_BIN to a directory of PostgreSQL ${neededMajor}+ client tools`;
|
|
141
|
+
}
|
|
142
|
+
function resolvePgRestorePath(pgDumpPath) {
|
|
143
|
+
if (pgDumpPath === "pg_dump") return "pg_restore";
|
|
144
|
+
return pgDumpPath.replace(/pg_dump$/, "pg_restore");
|
|
145
|
+
}
|
|
146
|
+
function versionsToCheck(required) {
|
|
147
|
+
const versions = [];
|
|
148
|
+
for (let v = required + 3; v >= required; v--) {
|
|
149
|
+
versions.push(v);
|
|
150
|
+
}
|
|
151
|
+
return versions;
|
|
152
|
+
}
|
|
153
|
+
async function getServerMajorVersion(dbUrl) {
|
|
154
|
+
const client = newPgClient(dbUrl);
|
|
155
|
+
try {
|
|
156
|
+
await client.connect();
|
|
157
|
+
const { rows } = await client.query("SHOW server_version");
|
|
158
|
+
const raw = rows[0].server_version;
|
|
159
|
+
const major = parseServerVersion(raw);
|
|
160
|
+
if (!major) throw new Error(`Could not parse server version: ${raw}`);
|
|
161
|
+
return major;
|
|
162
|
+
} finally {
|
|
163
|
+
await client.end();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async function checkPgDumpCompat(dbUrl) {
|
|
167
|
+
const serverMajor = await getServerMajorVersion(dbUrl);
|
|
168
|
+
const resolved = await resolvePgDumpPath(serverMajor);
|
|
169
|
+
if (resolved) {
|
|
170
|
+
return {
|
|
171
|
+
localMajor: resolved.major,
|
|
172
|
+
serverMajor,
|
|
173
|
+
compatible: true,
|
|
174
|
+
message: "",
|
|
175
|
+
pgDumpPath: resolved.path,
|
|
176
|
+
pgRestorePath: resolvePgRestorePath(resolved.path)
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const localMajor = await getLocalPgDumpVersion();
|
|
180
|
+
const message = buildInstallMessage(localMajor, serverMajor);
|
|
181
|
+
return {
|
|
182
|
+
localMajor,
|
|
183
|
+
serverMajor,
|
|
184
|
+
compatible: false,
|
|
185
|
+
message,
|
|
186
|
+
pgDumpPath: "pg_dump",
|
|
187
|
+
pgRestorePath: "pg_restore"
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
function buildInstallMessage(localMajor, serverMajor) {
|
|
191
|
+
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}:`;
|
|
192
|
+
const instructions = getInstallInstructions(serverMajor);
|
|
193
|
+
return `${header}
|
|
194
|
+
|
|
195
|
+
${instructions}`;
|
|
196
|
+
}
|
|
197
|
+
function getInstallInstructions(majorVersion) {
|
|
198
|
+
const os = platform();
|
|
199
|
+
const v = majorVersion;
|
|
200
|
+
switch (os) {
|
|
201
|
+
case "darwin":
|
|
202
|
+
return [
|
|
203
|
+
` brew install postgresql@${v}`,
|
|
204
|
+
` # Then add to PATH:`,
|
|
205
|
+
` export PATH="/opt/homebrew/opt/postgresql@${v}/bin:$PATH"`
|
|
206
|
+
].join("\n");
|
|
207
|
+
case "linux":
|
|
208
|
+
return [
|
|
209
|
+
` # Debian / Ubuntu:`,
|
|
210
|
+
` sudo apt-get install -y postgresql-client-${v}`,
|
|
211
|
+
` # If the package is not found, add the PGDG repository first:`,
|
|
212
|
+
` # https://www.postgresql.org/download/linux/ubuntu/`,
|
|
213
|
+
``,
|
|
214
|
+
` # RHEL / Fedora:`,
|
|
215
|
+
` sudo dnf install -y postgresql${v}`
|
|
216
|
+
].join("\n");
|
|
217
|
+
case "win32":
|
|
218
|
+
return [
|
|
219
|
+
` # Download the installer from:`,
|
|
220
|
+
` # https://www.postgresql.org/download/windows/`,
|
|
221
|
+
` # Or use Chocolatey:`,
|
|
222
|
+
` choco install postgresql${v} --params '/Password:postgres'`
|
|
223
|
+
].join("\n");
|
|
224
|
+
default:
|
|
225
|
+
return ` Download PostgreSQL ${v} client tools from: https://www.postgresql.org/download/`;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export {
|
|
230
|
+
slugify,
|
|
231
|
+
escapeRegex,
|
|
232
|
+
parseFlagList,
|
|
233
|
+
globToRegExp,
|
|
234
|
+
matchesGlob,
|
|
235
|
+
normalizeRoles,
|
|
236
|
+
resolvePgDumpPath,
|
|
237
|
+
assertPgBinUsable,
|
|
238
|
+
describeMissingPgDump,
|
|
239
|
+
getServerMajorVersion,
|
|
240
|
+
checkPgDumpCompat
|
|
241
|
+
};
|
|
242
|
+
//# sourceMappingURL=chunk-Z2YUOA4W.js.map
|
package/dist/commands/clone.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _oclif_core_interfaces from '@oclif/core/interfaces';
|
|
2
2
|
import { BaseCommand } from '../base-command.js';
|
|
3
|
-
import { R as RestoreFailure } from '../branch-
|
|
4
|
-
import { S as SupaForgeConfig } from '../config-
|
|
3
|
+
import { R as RestoreFailure } from '../branch-BppjQBv_.js';
|
|
4
|
+
import { S as SupaForgeConfig } from '../config-l3ggjw9r.js';
|
|
5
5
|
import '@oclif/core';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/commands/clone.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
renderTip
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-RQCXGO37.js";
|
|
4
4
|
import {
|
|
5
5
|
BaseCommand
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-OXS42LJH.js";
|
|
7
7
|
import {
|
|
8
8
|
addBranchToManifest,
|
|
9
9
|
cloneRemoteToLocal,
|
|
@@ -11,21 +11,22 @@ import {
|
|
|
11
11
|
listBranches,
|
|
12
12
|
reconcileClones,
|
|
13
13
|
replaceDbName
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-FD2JKEJA.js";
|
|
15
15
|
import {
|
|
16
16
|
captureSnapshot,
|
|
17
|
-
checkPgDumpCompat,
|
|
18
17
|
formatSnapshotLayers
|
|
19
|
-
} from "../chunk-
|
|
20
|
-
import
|
|
18
|
+
} from "../chunk-5UHIWFQG.js";
|
|
19
|
+
import {
|
|
20
|
+
checkPgDumpCompat
|
|
21
|
+
} from "../chunk-Z2YUOA4W.js";
|
|
21
22
|
import {
|
|
22
23
|
DEFAULT_LOCAL_PORT,
|
|
23
24
|
LOCAL_PG_PASSWORD,
|
|
24
25
|
LOCAL_PG_USER,
|
|
25
26
|
newPgClient,
|
|
26
27
|
startLocalPg
|
|
27
|
-
} from "../chunk-
|
|
28
|
-
import "../chunk-
|
|
28
|
+
} from "../chunk-KT7NMELZ.js";
|
|
29
|
+
import "../chunk-KHXEES2M.js";
|
|
29
30
|
import {
|
|
30
31
|
CLONE_EXTRA_EXCLUDE_SCHEMAS,
|
|
31
32
|
CLONE_SKIP_FLAGS,
|
|
@@ -40,7 +41,7 @@ import {
|
|
|
40
41
|
ok,
|
|
41
42
|
redactUrls,
|
|
42
43
|
warn
|
|
43
|
-
} from "../chunk-
|
|
44
|
+
} from "../chunk-SQ52YBKK.js";
|
|
44
45
|
|
|
45
46
|
// src/commands/clone.ts
|
|
46
47
|
import { writeFile, mkdir } from "fs/promises";
|
package/dist/commands/diff.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Interfaces } from '@oclif/core';
|
|
2
2
|
import { BaseCommand } from '../base-command.js';
|
|
3
|
-
import '
|
|
4
|
-
import '../config-CTbeRlJk.js';
|
|
3
|
+
import '../config-l3ggjw9r.js';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* What to do after a rolled-back apply.
|
|
@@ -42,25 +41,27 @@ declare class Diff extends BaseCommand {
|
|
|
42
41
|
description: string;
|
|
43
42
|
}[];
|
|
44
43
|
static flags: {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
'
|
|
51
|
-
'
|
|
52
|
-
|
|
53
|
-
'
|
|
54
|
-
|
|
55
|
-
'
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
'
|
|
44
|
+
'source-dir': Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
45
|
+
check: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
46
|
+
skip: Interfaces.OptionFlag<string[] | undefined, Interfaces.CustomOptions>;
|
|
47
|
+
detail: Interfaces.BooleanFlag<boolean>;
|
|
48
|
+
apply: Interfaces.BooleanFlag<boolean>;
|
|
49
|
+
'allow-destructive': Interfaces.BooleanFlag<boolean>;
|
|
50
|
+
'dry-run': Interfaces.BooleanFlag<boolean>;
|
|
51
|
+
'no-snapshot': Interfaces.BooleanFlag<boolean>;
|
|
52
|
+
'no-transaction': Interfaces.BooleanFlag<boolean>;
|
|
53
|
+
only: Interfaces.OptionFlag<string[] | undefined, Interfaces.CustomOptions>;
|
|
54
|
+
'include-files': Interfaces.BooleanFlag<boolean>;
|
|
55
|
+
tables: Interfaces.OptionFlag<string[] | undefined, Interfaces.CustomOptions>;
|
|
56
|
+
'exclude-tables': Interfaces.OptionFlag<string[] | undefined, Interfaces.CustomOptions>;
|
|
57
|
+
json: Interfaces.BooleanFlag<boolean>;
|
|
58
|
+
source: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
59
|
+
target: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
60
|
+
ci: Interfaces.BooleanFlag<boolean>;
|
|
61
|
+
prove: Interfaces.BooleanFlag<boolean>;
|
|
62
|
+
'apply-posture': Interfaces.BooleanFlag<boolean>;
|
|
63
|
+
'fail-on': Interfaces.OptionFlag<string, Interfaces.CustomOptions>;
|
|
64
|
+
'fail-on-posture': Interfaces.BooleanFlag<boolean>;
|
|
64
65
|
};
|
|
65
66
|
/**
|
|
66
67
|
* Report what `--apply` did, or — under `--dry-run` — what it would do.
|
|
@@ -72,6 +73,8 @@ declare class Diff extends BaseCommand {
|
|
|
72
73
|
*/
|
|
73
74
|
private renderApplyResult;
|
|
74
75
|
run(): Promise<void>;
|
|
76
|
+
/** The comparison itself, between the config's source and target. */
|
|
77
|
+
private compare;
|
|
75
78
|
/**
|
|
76
79
|
* Stop before applying anything: the proof could not run, or ran and found
|
|
77
80
|
* the migration would not reproduce the source. Under --json the reason is
|
package/dist/commands/diff.js
CHANGED
|
@@ -2,22 +2,21 @@ import {
|
|
|
2
2
|
Diff,
|
|
3
3
|
inertApplyFlags,
|
|
4
4
|
rollbackHint
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-N5VNNOA2.js";
|
|
5
|
+
} from "../chunk-M2564IGT.js";
|
|
6
|
+
import "../chunk-Q43MN6NE.js";
|
|
7
|
+
import "../chunk-MRXIE55Y.js";
|
|
8
|
+
import "../chunk-CAQ3QQFP.js";
|
|
9
|
+
import "../chunk-GGZ7YWBZ.js";
|
|
10
|
+
import "../chunk-YUJ2MHLM.js";
|
|
12
11
|
import "../chunk-WK5YTINL.js";
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-
|
|
16
|
-
import "../chunk-
|
|
17
|
-
import "../chunk-
|
|
18
|
-
import "../chunk-
|
|
19
|
-
import "../chunk-
|
|
20
|
-
import "../chunk-
|
|
12
|
+
import "../chunk-RQCXGO37.js";
|
|
13
|
+
import "../chunk-OXS42LJH.js";
|
|
14
|
+
import "../chunk-FD2JKEJA.js";
|
|
15
|
+
import "../chunk-5UHIWFQG.js";
|
|
16
|
+
import "../chunk-Z2YUOA4W.js";
|
|
17
|
+
import "../chunk-KT7NMELZ.js";
|
|
18
|
+
import "../chunk-KHXEES2M.js";
|
|
19
|
+
import "../chunk-SQ52YBKK.js";
|
|
21
20
|
export {
|
|
22
21
|
Diff as default,
|
|
23
22
|
inertApplyFlags,
|
package/dist/commands/hukam.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import Diff from './diff.js';
|
|
2
|
-
import '@oclif/core/interfaces';
|
|
3
|
-
import '../base-command.js';
|
|
4
2
|
import '@oclif/core';
|
|
5
|
-
import '../
|
|
3
|
+
import '../base-command.js';
|
|
4
|
+
import '../config-l3ggjw9r.js';
|
|
6
5
|
|
|
7
6
|
declare class Hukam extends Diff {
|
|
8
7
|
static hidden: boolean;
|
package/dist/commands/hukam.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Diff
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-N5VNNOA2.js";
|
|
3
|
+
} from "../chunk-M2564IGT.js";
|
|
4
|
+
import "../chunk-Q43MN6NE.js";
|
|
5
|
+
import "../chunk-MRXIE55Y.js";
|
|
6
|
+
import "../chunk-CAQ3QQFP.js";
|
|
7
|
+
import "../chunk-GGZ7YWBZ.js";
|
|
8
|
+
import "../chunk-YUJ2MHLM.js";
|
|
10
9
|
import "../chunk-WK5YTINL.js";
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-
|
|
16
|
-
import "../chunk-
|
|
17
|
-
import "../chunk-
|
|
18
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-RQCXGO37.js";
|
|
11
|
+
import "../chunk-OXS42LJH.js";
|
|
12
|
+
import "../chunk-FD2JKEJA.js";
|
|
13
|
+
import "../chunk-5UHIWFQG.js";
|
|
14
|
+
import "../chunk-Z2YUOA4W.js";
|
|
15
|
+
import "../chunk-KT7NMELZ.js";
|
|
16
|
+
import "../chunk-KHXEES2M.js";
|
|
17
|
+
import "../chunk-SQ52YBKK.js";
|
|
19
18
|
|
|
20
19
|
// src/commands/hukam.ts
|
|
21
20
|
var Hukam = class extends Diff {
|
package/dist/commands/init.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _oclif_core_interfaces from '@oclif/core/interfaces';
|
|
2
2
|
import { Command } from '@oclif/core';
|
|
3
|
-
import { S as SupaForgeConfig } from '../config-
|
|
3
|
+
import { S as SupaForgeConfig } from '../config-l3ggjw9r.js';
|
|
4
4
|
|
|
5
5
|
type AskFn = ((question: string) => Promise<string>) & {
|
|
6
6
|
close: () => void;
|
package/dist/commands/init.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
installProcessGuard
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-KHXEES2M.js";
|
|
4
4
|
import {
|
|
5
5
|
INIT_HINTS,
|
|
6
6
|
SUPAFORGE_DIR,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
validateConfig,
|
|
16
16
|
validateSingleEnvConfig,
|
|
17
17
|
warn
|
|
18
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-SQ52YBKK.js";
|
|
19
19
|
|
|
20
20
|
// src/commands/init.ts
|
|
21
21
|
import { Command, Flags } from "@oclif/core";
|
package/dist/commands/mcp.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createServer
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-N5VNNOA2.js";
|
|
3
|
+
} from "../chunk-MZPWRWBL.js";
|
|
4
|
+
import "../chunk-EWNZIRCD.js";
|
|
5
|
+
import "../chunk-CAQ3QQFP.js";
|
|
6
|
+
import "../chunk-YUJ2MHLM.js";
|
|
8
7
|
import "../chunk-WK5YTINL.js";
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-5UHIWFQG.js";
|
|
9
|
+
import "../chunk-Z2YUOA4W.js";
|
|
10
|
+
import "../chunk-KT7NMELZ.js";
|
|
12
11
|
import {
|
|
13
12
|
installProcessGuard,
|
|
14
13
|
keepRunningOnStrayErrors
|
|
15
|
-
} from "../chunk-
|
|
16
|
-
import "../chunk-
|
|
14
|
+
} from "../chunk-KHXEES2M.js";
|
|
15
|
+
import "../chunk-SQ52YBKK.js";
|
|
17
16
|
|
|
18
17
|
// src/commands/mcp.ts
|
|
19
18
|
import { existsSync, statSync } from "fs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _oclif_core_interfaces from '@oclif/core/interfaces';
|
|
2
2
|
import { BaseCommand } from '../../base-command.js';
|
|
3
3
|
import '@oclif/core';
|
|
4
|
-
import '../../config-
|
|
4
|
+
import '../../config-l3ggjw9r.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Mark all local migration files as applied without executing them.
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
baselineMigrations
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-AL6INEFX.js";
|
|
4
4
|
import {
|
|
5
5
|
BaseCommand
|
|
6
|
-
} from "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
6
|
+
} from "../../chunk-OXS42LJH.js";
|
|
7
|
+
import "../../chunk-KT7NMELZ.js";
|
|
8
|
+
import "../../chunk-KHXEES2M.js";
|
|
9
9
|
import {
|
|
10
10
|
bold,
|
|
11
11
|
dim,
|
|
12
12
|
ok
|
|
13
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-SQ52YBKK.js";
|
|
14
14
|
|
|
15
15
|
// src/commands/migrate/baseline.ts
|
|
16
16
|
import { Flags } from "@oclif/core";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _oclif_core_interfaces from '@oclif/core/interfaces';
|
|
2
2
|
import { BaseCommand } from '../../base-command.js';
|
|
3
3
|
import '@oclif/core';
|
|
4
|
-
import '../../config-
|
|
4
|
+
import '../../config-l3ggjw9r.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Shared string manipulation utilities.
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
targetFingerprint,
|
|
3
|
+
truncateSql,
|
|
4
|
+
writtenAgainstLine
|
|
5
|
+
} from "../../chunk-CCB7ARZU.js";
|
|
6
|
+
import "../../chunk-AL6INEFX.js";
|
|
7
|
+
import "../../chunk-GGZ7YWBZ.js";
|
|
5
8
|
import {
|
|
9
|
+
RolesCheck,
|
|
6
10
|
isDestructiveSql,
|
|
7
11
|
runDbDiff
|
|
8
|
-
} from "../../chunk-
|
|
12
|
+
} from "../../chunk-YUJ2MHLM.js";
|
|
9
13
|
import {
|
|
10
14
|
splitSqlStatements
|
|
11
15
|
} from "../../chunk-WK5YTINL.js";
|
|
12
16
|
import {
|
|
13
17
|
BaseCommand
|
|
14
|
-
} from "../../chunk-
|
|
18
|
+
} from "../../chunk-OXS42LJH.js";
|
|
15
19
|
import {
|
|
16
20
|
slugify
|
|
17
|
-
} from "../../chunk-
|
|
18
|
-
import
|
|
19
|
-
|
|
21
|
+
} from "../../chunk-Z2YUOA4W.js";
|
|
22
|
+
import {
|
|
23
|
+
pgQuery
|
|
24
|
+
} from "../../chunk-KT7NMELZ.js";
|
|
25
|
+
import "../../chunk-KHXEES2M.js";
|
|
20
26
|
import {
|
|
21
27
|
DEFAULT_IGNORE_SCHEMAS,
|
|
22
28
|
bold,
|
|
@@ -24,7 +30,7 @@ import {
|
|
|
24
30
|
dim,
|
|
25
31
|
ok,
|
|
26
32
|
warn
|
|
27
|
-
} from "../../chunk-
|
|
33
|
+
} from "../../chunk-SQ52YBKK.js";
|
|
28
34
|
|
|
29
35
|
// src/commands/migrate/create.ts
|
|
30
36
|
import { writeFile, mkdir } from "fs/promises";
|
|
@@ -64,7 +70,12 @@ var MigrateCreate = class _MigrateCreate extends BaseCommand {
|
|
|
64
70
|
include: "both",
|
|
65
71
|
ignoreSchemas
|
|
66
72
|
});
|
|
67
|
-
|
|
73
|
+
const grants = (await new RolesCheck(pgQuery, { explicit: true }).scan({
|
|
74
|
+
source: sourceEnv,
|
|
75
|
+
target: targetEnv,
|
|
76
|
+
config
|
|
77
|
+
})).filter((i) => i.id.startsWith("roles-grant-") && i.sql?.up);
|
|
78
|
+
if (!result.up.trim() && grants.length === 0) {
|
|
68
79
|
this.log(`${ok("No schema drift detected.")} Nothing to write. \u2713`);
|
|
69
80
|
return;
|
|
70
81
|
}
|
|
@@ -72,21 +83,24 @@ var MigrateCreate = class _MigrateCreate extends BaseCommand {
|
|
|
72
83
|
const slug = slugify(flags.name);
|
|
73
84
|
const filename = `${timestamp}_${slug}.sql`;
|
|
74
85
|
const destructive = splitSqlStatements(result.up).filter(isDestructiveSql);
|
|
86
|
+
const digest = await targetFingerprint(targetEnv.dbUrl, ignoreSchemas).catch(() => void 0);
|
|
75
87
|
const lines = [
|
|
76
88
|
`-- Migration: ${flags.name}`,
|
|
77
89
|
`-- Generated by supaforge migrate create`,
|
|
78
90
|
`-- Source: ${config.source} \u2192 Target: ${config.target}`,
|
|
91
|
+
...digest ? [writtenAgainstLine(config.target, digest)] : [],
|
|
79
92
|
...destructive.length > 0 ? [`-- WARNING: ${destructive.length} destructive statement(s) \u2014 drops or deletes data. Review before running.`] : [],
|
|
80
93
|
"",
|
|
81
|
-
result.up
|
|
94
|
+
result.up,
|
|
95
|
+
...grants.length > 0 ? ["", "-- Grants", ...grants.map((i) => i.sql.up)] : []
|
|
82
96
|
];
|
|
83
|
-
if (result.down.trim()) {
|
|
97
|
+
if (result.down.trim() || grants.length > 0) {
|
|
84
98
|
lines.push(
|
|
85
99
|
"",
|
|
86
100
|
"-- ==================== DOWN ====================",
|
|
87
101
|
"-- To revert this migration, run the SQL below manually:",
|
|
88
102
|
"--",
|
|
89
|
-
...result.down.split("\n").map((l) => `-- ${l}`)
|
|
103
|
+
...[...grants.map((i) => i.sql?.down ?? "").filter(Boolean).reverse(), result.down].join("\n").split("\n").map((l) => `-- ${l}`)
|
|
90
104
|
);
|
|
91
105
|
}
|
|
92
106
|
const content = lines.join("\n") + "\n";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _oclif_core_interfaces from '@oclif/core/interfaces';
|
|
2
2
|
import { BaseCommand } from '../../base-command.js';
|
|
3
3
|
import '@oclif/core';
|
|
4
|
-
import '../../config-
|
|
4
|
+
import '../../config-l3ggjw9r.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* List local migration files and their applied status.
|