@akal/supaforge 0.0.32 → 0.0.34
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/LICENSE +21 -0
- package/README.md +66 -11
- package/dist/base-command.js +4 -3
- package/dist/{chunk-DMIWAJRB.js → chunk-3WKWPSFN.js} +6 -6
- package/dist/{chunk-GZREXCQZ.js → chunk-5STH2A6K.js} +17 -10
- package/dist/{chunk-6LJERPUN.js → chunk-6ERVCWLY.js} +20 -12
- package/dist/{chunk-GEHPTPNZ.js → chunk-7DL63NWP.js} +3 -3
- package/dist/{chunk-UWAVXC57.js → chunk-DQJSSTIJ.js} +39 -15
- package/dist/{chunk-ORQJVE57.js → chunk-EFKQOQGG.js} +15 -16
- package/dist/{chunk-7NAZGZPV.js → chunk-F46FFUKC.js} +16 -17
- package/dist/chunk-GQPGH6YR.js +50 -0
- package/dist/{chunk-6Q7MHFBM.js → chunk-HNJ6BNNZ.js} +2 -2
- package/dist/{chunk-MIRLB5JM.js → chunk-ICSCHS72.js} +66 -14
- package/dist/{chunk-6WAMNZLO.js → chunk-KNXHLVF7.js} +126 -4
- package/dist/{chunk-SQPCWGQO.js → chunk-MG3SFV5J.js} +22 -121
- package/dist/{chunk-BUOWHE36.js → chunk-N5VNNOA2.js} +37 -52
- package/dist/{chunk-3HGAV5CC.js → chunk-OB5GP7UB.js} +19 -16
- package/dist/{chunk-4IVN7QVY.js → chunk-PYAGSMFB.js} +23 -15
- package/dist/{chunk-SC2XHGIS.js → chunk-S5L4A3UR.js} +3 -3
- package/dist/{chunk-2SELREHW.js → chunk-TPX2MAO4.js} +7 -9
- package/dist/{chunk-NTUASFQ3.js → chunk-V2SBZERO.js} +4 -4
- package/dist/{chunk-G2DIPIYU.js → chunk-WK5YTINL.js} +29 -2
- package/dist/{chunk-BLKJWDTL.js → chunk-ZI435CAU.js} +2 -2
- package/dist/commands/clone.js +11 -11
- package/dist/commands/diff.d.ts +13 -1
- package/dist/commands/diff.js +19 -16
- package/dist/commands/hukam.js +15 -14
- package/dist/commands/init.js +5 -1
- package/dist/commands/mcp.d.ts +1 -0
- package/dist/commands/mcp.js +26 -10
- package/dist/commands/migrate/baseline.js +5 -4
- package/dist/commands/migrate/create.js +8 -7
- package/dist/commands/migrate/list.js +6 -5
- package/dist/commands/migrate/run.js +8 -7
- package/dist/commands/report.js +5 -4
- package/dist/commands/restore.js +13 -12
- package/dist/commands/snapshot.d.ts +7 -0
- package/dist/commands/snapshot.js +36 -8
- package/dist/commands/sync.js +15 -14
- package/dist/index.js +14 -14
- package/package.json +10 -8
- package/bin/dev.js +0 -10
- package/dist/base-command.js.map +0 -1
- package/dist/chunk-2SELREHW.js.map +0 -1
- package/dist/chunk-3HGAV5CC.js.map +0 -1
- package/dist/chunk-4IVN7QVY.js.map +0 -1
- package/dist/chunk-6LJERPUN.js.map +0 -1
- package/dist/chunk-6Q7MHFBM.js.map +0 -1
- package/dist/chunk-6WAMNZLO.js.map +0 -1
- package/dist/chunk-7NAZGZPV.js.map +0 -1
- package/dist/chunk-BLKJWDTL.js.map +0 -1
- package/dist/chunk-BUOWHE36.js.map +0 -1
- package/dist/chunk-DMIWAJRB.js.map +0 -1
- package/dist/chunk-DQQ5E563.js.map +0 -1
- package/dist/chunk-G2DIPIYU.js.map +0 -1
- package/dist/chunk-GEHPTPNZ.js.map +0 -1
- package/dist/chunk-GZREXCQZ.js.map +0 -1
- package/dist/chunk-MIRLB5JM.js.map +0 -1
- package/dist/chunk-NTUASFQ3.js.map +0 -1
- package/dist/chunk-ORQJVE57.js.map +0 -1
- package/dist/chunk-SC2XHGIS.js.map +0 -1
- package/dist/chunk-SQPCWGQO.js.map +0 -1
- package/dist/chunk-UWAVXC57.js.map +0 -1
- package/dist/commands/clone.js.map +0 -1
- package/dist/commands/diff.js.map +0 -1
- package/dist/commands/help.js.map +0 -1
- package/dist/commands/hukam.js.map +0 -1
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/mcp.js.map +0 -1
- package/dist/commands/migrate/baseline.js.map +0 -1
- package/dist/commands/migrate/create.js.map +0 -1
- package/dist/commands/migrate/list.js.map +0 -1
- package/dist/commands/migrate/run.js.map +0 -1
- package/dist/commands/report.js.map +0 -1
- package/dist/commands/restore.js.map +0 -1
- package/dist/commands/snapshot.js.map +0 -1
- package/dist/commands/sync.js.map +0 -1
- package/dist/help.js.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
// src/utils/sql-split.ts
|
|
2
|
+
var ROUTINE_HEAD = /^CREATE\s+(?:OR\s+REPLACE\s+)?(?:FUNCTION|PROCEDURE)\b/i;
|
|
3
|
+
function withoutLeadingComments(text) {
|
|
4
|
+
let rest = text.trimStart();
|
|
5
|
+
for (; ; ) {
|
|
6
|
+
if (rest.startsWith("--")) {
|
|
7
|
+
const newline = rest.indexOf("\n");
|
|
8
|
+
rest = newline === -1 ? "" : rest.slice(newline + 1).trimStart();
|
|
9
|
+
} else if (rest.startsWith("/*")) {
|
|
10
|
+
const close = rest.indexOf("*/");
|
|
11
|
+
rest = close === -1 ? "" : rest.slice(close + 2).trimStart();
|
|
12
|
+
} else {
|
|
13
|
+
return rest;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
2
17
|
var DOLLAR_TAG = /^\$(?:[A-Za-z_][A-Za-z0-9_]*)?\$/;
|
|
3
18
|
function splitSqlStatements(sql) {
|
|
4
19
|
const statements = [];
|
|
5
20
|
let start = 0;
|
|
6
21
|
let i = 0;
|
|
7
22
|
let blockDepth = 0;
|
|
23
|
+
let beginDepth = 0;
|
|
8
24
|
const push = (end) => {
|
|
9
25
|
const piece = sql.slice(start, end).trim();
|
|
10
26
|
if (piece.length > 0) statements.push(piece);
|
|
@@ -61,7 +77,18 @@ function splitSqlStatements(sql) {
|
|
|
61
77
|
i++;
|
|
62
78
|
continue;
|
|
63
79
|
}
|
|
64
|
-
if (ch
|
|
80
|
+
if (/[A-Za-z_]/.test(ch)) {
|
|
81
|
+
const word = /^[A-Za-z_][A-Za-z0-9_]*/.exec(sql.slice(i, i + 64))[0];
|
|
82
|
+
const upper = word.toUpperCase();
|
|
83
|
+
if ((upper === "BEGIN" || upper === "CASE") && ROUTINE_HEAD.test(withoutLeadingComments(sql.slice(start, i)))) {
|
|
84
|
+
beginDepth++;
|
|
85
|
+
} else if (upper === "END" && beginDepth > 0) {
|
|
86
|
+
beginDepth--;
|
|
87
|
+
}
|
|
88
|
+
i += word.length;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (ch === ";" && beginDepth === 0) {
|
|
65
92
|
push(i);
|
|
66
93
|
i++;
|
|
67
94
|
start = i;
|
|
@@ -91,4 +118,4 @@ export {
|
|
|
91
118
|
stripPsqlMetaCommands,
|
|
92
119
|
isPsqlMetaCommand
|
|
93
120
|
};
|
|
94
|
-
//# sourceMappingURL=chunk-
|
|
121
|
+
//# sourceMappingURL=chunk-WK5YTINL.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
CLONE_SKIP_FLAGS,
|
|
3
3
|
cmd,
|
|
4
4
|
dim
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-KNXHLVF7.js";
|
|
6
6
|
|
|
7
7
|
// src/tips.ts
|
|
8
8
|
function applyTip(sourceIsClone, driftedChecks) {
|
|
@@ -150,4 +150,4 @@ function renderTip(ctx) {
|
|
|
150
150
|
export {
|
|
151
151
|
renderTip
|
|
152
152
|
};
|
|
153
|
-
//# sourceMappingURL=chunk-
|
|
153
|
+
//# sourceMappingURL=chunk-ZI435CAU.js.map
|
package/dist/commands/clone.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
renderTip
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-ZI435CAU.js";
|
|
4
4
|
import {
|
|
5
5
|
BaseCommand
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-5STH2A6K.js";
|
|
7
7
|
import {
|
|
8
8
|
addBranchToManifest,
|
|
9
9
|
cloneRemoteToLocal,
|
|
@@ -11,22 +11,21 @@ import {
|
|
|
11
11
|
listBranches,
|
|
12
12
|
reconcileClones,
|
|
13
13
|
replaceDbName
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-EFKQOQGG.js";
|
|
15
15
|
import {
|
|
16
16
|
captureSnapshot,
|
|
17
17
|
checkPgDumpCompat,
|
|
18
18
|
formatSnapshotLayers
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-ICSCHS72.js";
|
|
20
20
|
import "../chunk-DQQ5E563.js";
|
|
21
21
|
import {
|
|
22
22
|
DEFAULT_LOCAL_PORT,
|
|
23
23
|
LOCAL_PG_PASSWORD,
|
|
24
24
|
LOCAL_PG_USER,
|
|
25
|
-
|
|
26
|
-
pgClientConfig,
|
|
27
|
-
redactUrls,
|
|
25
|
+
newPgClient,
|
|
28
26
|
startLocalPg
|
|
29
|
-
} from "../chunk-
|
|
27
|
+
} from "../chunk-MG3SFV5J.js";
|
|
28
|
+
import "../chunk-GQPGH6YR.js";
|
|
30
29
|
import {
|
|
31
30
|
CLONE_EXTRA_EXCLUDE_SCHEMAS,
|
|
32
31
|
CLONE_SKIP_FLAGS,
|
|
@@ -36,16 +35,17 @@ import {
|
|
|
36
35
|
bold,
|
|
37
36
|
cmd,
|
|
38
37
|
dim,
|
|
38
|
+
errMsg,
|
|
39
39
|
loadConfig,
|
|
40
40
|
ok,
|
|
41
|
+
redactUrls,
|
|
41
42
|
warn
|
|
42
|
-
} from "../chunk-
|
|
43
|
+
} from "../chunk-KNXHLVF7.js";
|
|
43
44
|
|
|
44
45
|
// src/commands/clone.ts
|
|
45
46
|
import { writeFile, mkdir } from "fs/promises";
|
|
46
47
|
import { resolve } from "path";
|
|
47
48
|
import { Flags } from "@oclif/core";
|
|
48
|
-
import pg from "pg";
|
|
49
49
|
var CLONE_EXCLUDE_SCHEMAS = [.../* @__PURE__ */ new Set([
|
|
50
50
|
...DEFAULT_IGNORE_SCHEMAS,
|
|
51
51
|
...CLONE_EXTRA_EXCLUDE_SCHEMAS
|
|
@@ -211,7 +211,7 @@ var Clone = class _Clone extends BaseCommand {
|
|
|
211
211
|
});
|
|
212
212
|
pre.addCheck("Target database", async () => {
|
|
213
213
|
try {
|
|
214
|
-
const client =
|
|
214
|
+
const client = newPgClient(localBaseUrl);
|
|
215
215
|
await client.connect();
|
|
216
216
|
const { rows } = await client.query(
|
|
217
217
|
"SELECT 1 FROM pg_database WHERE datname = $1",
|
package/dist/commands/diff.d.ts
CHANGED
|
@@ -3,6 +3,18 @@ import { BaseCommand } from '../base-command.js';
|
|
|
3
3
|
import '@oclif/core';
|
|
4
4
|
import '../config-CTbeRlJk.js';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* What to do after a rolled-back apply.
|
|
8
|
+
*
|
|
9
|
+
* Usually: apply the fixes that work without the one that failed. Not when
|
|
10
|
+
* the failure is replacing a view or type something else depends on — the
|
|
11
|
+
* others may be what depends on it, and applying them alone leaves the two
|
|
12
|
+
* out of step — so that one is named to fix or leave out instead.
|
|
13
|
+
*/
|
|
14
|
+
declare function rollbackHint(errors: ReadonlyArray<{
|
|
15
|
+
issueId: string;
|
|
16
|
+
error: string;
|
|
17
|
+
}>): string;
|
|
6
18
|
/** Which apply-only flags this invocation will silently ignore. */
|
|
7
19
|
declare function inertApplyFlags(flags: Record<string, unknown>): ReadonlyArray<{
|
|
8
20
|
flag: string;
|
|
@@ -78,4 +90,4 @@ declare class Diff extends BaseCommand {
|
|
|
78
90
|
private preflightBothDatabases;
|
|
79
91
|
}
|
|
80
92
|
|
|
81
|
-
export { Diff as default, inertApplyFlags };
|
|
93
|
+
export { Diff as default, inertApplyFlags, rollbackHint };
|
package/dist/commands/diff.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Diff,
|
|
3
|
-
inertApplyFlags
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-
|
|
3
|
+
inertApplyFlags,
|
|
4
|
+
rollbackHint
|
|
5
|
+
} from "../chunk-PYAGSMFB.js";
|
|
6
|
+
import "../chunk-HNJ6BNNZ.js";
|
|
7
|
+
import "../chunk-7DL63NWP.js";
|
|
8
|
+
import "../chunk-OB5GP7UB.js";
|
|
9
|
+
import "../chunk-3WKWPSFN.js";
|
|
10
|
+
import "../chunk-DQJSSTIJ.js";
|
|
11
|
+
import "../chunk-N5VNNOA2.js";
|
|
12
|
+
import "../chunk-WK5YTINL.js";
|
|
13
|
+
import "../chunk-ZI435CAU.js";
|
|
14
|
+
import "../chunk-5STH2A6K.js";
|
|
15
|
+
import "../chunk-EFKQOQGG.js";
|
|
16
|
+
import "../chunk-ICSCHS72.js";
|
|
16
17
|
import "../chunk-DQQ5E563.js";
|
|
17
|
-
import "../chunk-
|
|
18
|
-
import "../chunk-
|
|
18
|
+
import "../chunk-MG3SFV5J.js";
|
|
19
|
+
import "../chunk-GQPGH6YR.js";
|
|
20
|
+
import "../chunk-KNXHLVF7.js";
|
|
19
21
|
export {
|
|
20
22
|
Diff as default,
|
|
21
|
-
inertApplyFlags
|
|
23
|
+
inertApplyFlags,
|
|
24
|
+
rollbackHint
|
|
22
25
|
};
|
|
23
26
|
//# sourceMappingURL=diff.js.map
|
package/dist/commands/hukam.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
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-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-PYAGSMFB.js";
|
|
4
|
+
import "../chunk-HNJ6BNNZ.js";
|
|
5
|
+
import "../chunk-7DL63NWP.js";
|
|
6
|
+
import "../chunk-OB5GP7UB.js";
|
|
7
|
+
import "../chunk-3WKWPSFN.js";
|
|
8
|
+
import "../chunk-DQJSSTIJ.js";
|
|
9
|
+
import "../chunk-N5VNNOA2.js";
|
|
10
|
+
import "../chunk-WK5YTINL.js";
|
|
11
|
+
import "../chunk-ZI435CAU.js";
|
|
12
|
+
import "../chunk-5STH2A6K.js";
|
|
13
|
+
import "../chunk-EFKQOQGG.js";
|
|
14
|
+
import "../chunk-ICSCHS72.js";
|
|
15
15
|
import "../chunk-DQQ5E563.js";
|
|
16
|
-
import "../chunk-
|
|
17
|
-
import "../chunk-
|
|
16
|
+
import "../chunk-MG3SFV5J.js";
|
|
17
|
+
import "../chunk-GQPGH6YR.js";
|
|
18
|
+
import "../chunk-KNXHLVF7.js";
|
|
18
19
|
|
|
19
20
|
// src/commands/hukam.ts
|
|
20
21
|
var Hukam = class extends Diff {
|
package/dist/commands/init.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
installProcessGuard
|
|
3
|
+
} from "../chunk-GQPGH6YR.js";
|
|
1
4
|
import {
|
|
2
5
|
INIT_HINTS,
|
|
3
6
|
SUPAFORGE_DIR,
|
|
@@ -12,7 +15,7 @@ import {
|
|
|
12
15
|
validateConfig,
|
|
13
16
|
validateSingleEnvConfig,
|
|
14
17
|
warn
|
|
15
|
-
} from "../chunk-
|
|
18
|
+
} from "../chunk-KNXHLVF7.js";
|
|
16
19
|
|
|
17
20
|
// src/commands/init.ts
|
|
18
21
|
import { Command, Flags } from "@oclif/core";
|
|
@@ -248,6 +251,7 @@ var Init = class _Init extends Command {
|
|
|
248
251
|
})
|
|
249
252
|
};
|
|
250
253
|
async run() {
|
|
254
|
+
installProcessGuard(this.argv);
|
|
251
255
|
const { flags } = await this.parse(_Init);
|
|
252
256
|
const configPath = resolve(process.cwd(), CONFIG_FILENAME);
|
|
253
257
|
if (!flags.force) {
|
package/dist/commands/mcp.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ declare class Mcp extends Command {
|
|
|
5
5
|
static description: string;
|
|
6
6
|
static examples: string[];
|
|
7
7
|
static flags: {
|
|
8
|
+
project: _oclif_core_interfaces.OptionFlag<string | undefined, _oclif_core_interfaces.CustomOptions>;
|
|
8
9
|
'allow-config-path': _oclif_core_interfaces.BooleanFlag<boolean>;
|
|
9
10
|
};
|
|
10
11
|
run(): Promise<void>;
|
package/dist/commands/mcp.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createServer
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-6ERVCWLY.js";
|
|
4
|
+
import "../chunk-V2SBZERO.js";
|
|
5
|
+
import "../chunk-OB5GP7UB.js";
|
|
6
|
+
import "../chunk-DQJSSTIJ.js";
|
|
7
|
+
import "../chunk-N5VNNOA2.js";
|
|
8
|
+
import "../chunk-WK5YTINL.js";
|
|
9
|
+
import "../chunk-ICSCHS72.js";
|
|
10
10
|
import "../chunk-DQQ5E563.js";
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import
|
|
11
|
+
import "../chunk-MG3SFV5J.js";
|
|
12
|
+
import {
|
|
13
|
+
installProcessGuard,
|
|
14
|
+
keepRunningOnStrayErrors
|
|
15
|
+
} from "../chunk-GQPGH6YR.js";
|
|
16
|
+
import "../chunk-KNXHLVF7.js";
|
|
13
17
|
|
|
14
18
|
// src/commands/mcp.ts
|
|
19
|
+
import { existsSync, statSync } from "fs";
|
|
20
|
+
import { resolve } from "path";
|
|
15
21
|
import { Command, Flags } from "@oclif/core";
|
|
16
22
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
17
23
|
var Mcp = class _Mcp extends Command {
|
|
@@ -19,17 +25,27 @@ var Mcp = class _Mcp extends Command {
|
|
|
19
25
|
static examples = [
|
|
20
26
|
"<%= config.bin %> mcp",
|
|
21
27
|
"<%= config.bin %> mcp --allow-config-path",
|
|
28
|
+
"<%= config.bin %> mcp --project ~/code/my-app",
|
|
22
29
|
'# Claude Desktop / Cursor config:\n# { "mcpServers": { "supaforge": { "command": "supaforge", "args": ["mcp"] } } }'
|
|
23
30
|
];
|
|
24
31
|
static flags = {
|
|
32
|
+
project: Flags.string({
|
|
33
|
+
description: "The project directory, holding supaforge.config.json. Defaults to the directory the server starts in \u2014 which an AI client may not let you choose, so name it here."
|
|
34
|
+
}),
|
|
25
35
|
"allow-config-path": Flags.boolean({
|
|
26
36
|
description: "Let a client choose which supaforge.config.json to load. Off by default: a tool call, or a prompt injected into one, could otherwise point the server at any config on disk \u2014 including one holding production credentials \u2014 bypassing the one it was started with.",
|
|
27
37
|
default: false
|
|
28
38
|
})
|
|
29
39
|
};
|
|
30
40
|
async run() {
|
|
41
|
+
keepRunningOnStrayErrors();
|
|
42
|
+
installProcessGuard(this.argv);
|
|
31
43
|
const { flags } = await this.parse(_Mcp);
|
|
32
|
-
const
|
|
44
|
+
const project = resolve(flags.project ?? process.cwd());
|
|
45
|
+
if (!existsSync(project) || !statSync(project).isDirectory()) {
|
|
46
|
+
this.error(`--project: ${project} is not a directory`);
|
|
47
|
+
}
|
|
48
|
+
const server = createServer(project, {
|
|
33
49
|
allowConfigPath: flags["allow-config-path"]
|
|
34
50
|
});
|
|
35
51
|
const transport = new StdioServerTransport();
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
baselineMigrations
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-S5L4A3UR.js";
|
|
4
4
|
import {
|
|
5
5
|
BaseCommand
|
|
6
|
-
} from "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
6
|
+
} from "../../chunk-5STH2A6K.js";
|
|
7
|
+
import "../../chunk-MG3SFV5J.js";
|
|
8
|
+
import "../../chunk-GQPGH6YR.js";
|
|
8
9
|
import {
|
|
9
10
|
bold,
|
|
10
11
|
dim,
|
|
11
12
|
ok
|
|
12
|
-
} from "../../chunk-
|
|
13
|
+
} from "../../chunk-KNXHLVF7.js";
|
|
13
14
|
|
|
14
15
|
// src/commands/migrate/baseline.ts
|
|
15
16
|
import { Flags } from "@oclif/core";
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
truncateSql
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-TPX2MAO4.js";
|
|
4
|
+
import "../../chunk-S5L4A3UR.js";
|
|
5
5
|
import {
|
|
6
6
|
isDestructiveSql,
|
|
7
7
|
runDbDiff
|
|
8
|
-
} from "../../chunk-
|
|
8
|
+
} from "../../chunk-N5VNNOA2.js";
|
|
9
9
|
import {
|
|
10
10
|
splitSqlStatements
|
|
11
|
-
} from "../../chunk-
|
|
11
|
+
} from "../../chunk-WK5YTINL.js";
|
|
12
12
|
import {
|
|
13
13
|
BaseCommand
|
|
14
|
-
} from "../../chunk-
|
|
14
|
+
} from "../../chunk-5STH2A6K.js";
|
|
15
15
|
import {
|
|
16
16
|
slugify
|
|
17
17
|
} from "../../chunk-DQQ5E563.js";
|
|
18
|
-
import "../../chunk-
|
|
18
|
+
import "../../chunk-MG3SFV5J.js";
|
|
19
|
+
import "../../chunk-GQPGH6YR.js";
|
|
19
20
|
import {
|
|
20
21
|
DEFAULT_IGNORE_SCHEMAS,
|
|
21
22
|
bold,
|
|
@@ -23,7 +24,7 @@ import {
|
|
|
23
24
|
dim,
|
|
24
25
|
ok,
|
|
25
26
|
warn
|
|
26
|
-
} from "../../chunk-
|
|
27
|
+
} from "../../chunk-KNXHLVF7.js";
|
|
27
28
|
|
|
28
29
|
// src/commands/migrate/create.ts
|
|
29
30
|
import { writeFile, mkdir } from "fs/promises";
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getAppliedVersions
|
|
3
|
-
} from "../../chunk-
|
|
3
|
+
} from "../../chunk-S5L4A3UR.js";
|
|
4
4
|
import {
|
|
5
5
|
BaseCommand
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-5STH2A6K.js";
|
|
7
7
|
import {
|
|
8
|
-
errMsg,
|
|
9
8
|
pgQuery,
|
|
10
9
|
readLocalMigrations
|
|
11
|
-
} from "../../chunk-
|
|
10
|
+
} from "../../chunk-MG3SFV5J.js";
|
|
11
|
+
import "../../chunk-GQPGH6YR.js";
|
|
12
12
|
import {
|
|
13
13
|
bold,
|
|
14
14
|
dim,
|
|
15
|
+
errMsg,
|
|
15
16
|
ok,
|
|
16
17
|
warn
|
|
17
|
-
} from "../../chunk-
|
|
18
|
+
} from "../../chunk-KNXHLVF7.js";
|
|
18
19
|
|
|
19
20
|
// src/commands/migrate/list.ts
|
|
20
21
|
import { Flags } from "@oclif/core";
|
|
@@ -2,14 +2,15 @@ import {
|
|
|
2
2
|
MigrateRun,
|
|
3
3
|
findDestructiveStatements,
|
|
4
4
|
truncateSql
|
|
5
|
-
} from "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
5
|
+
} from "../../chunk-TPX2MAO4.js";
|
|
6
|
+
import "../../chunk-S5L4A3UR.js";
|
|
7
|
+
import "../../chunk-N5VNNOA2.js";
|
|
8
|
+
import "../../chunk-WK5YTINL.js";
|
|
9
|
+
import "../../chunk-5STH2A6K.js";
|
|
10
10
|
import "../../chunk-DQQ5E563.js";
|
|
11
|
-
import "../../chunk-
|
|
12
|
-
import "../../chunk-
|
|
11
|
+
import "../../chunk-MG3SFV5J.js";
|
|
12
|
+
import "../../chunk-GQPGH6YR.js";
|
|
13
|
+
import "../../chunk-KNXHLVF7.js";
|
|
13
14
|
export {
|
|
14
15
|
MigrateRun as default,
|
|
15
16
|
findDestructiveStatements,
|
package/dist/commands/report.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
sanitizeForReport
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-HNJ6BNNZ.js";
|
|
4
4
|
import {
|
|
5
5
|
BaseCommand,
|
|
6
6
|
readRunLog,
|
|
7
7
|
runLogPath
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import "../chunk-
|
|
8
|
+
} from "../chunk-5STH2A6K.js";
|
|
9
|
+
import "../chunk-MG3SFV5J.js";
|
|
10
|
+
import "../chunk-GQPGH6YR.js";
|
|
10
11
|
import {
|
|
11
12
|
bold,
|
|
12
13
|
cmd,
|
|
13
14
|
dim,
|
|
14
15
|
ok,
|
|
15
16
|
warn
|
|
16
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-KNXHLVF7.js";
|
|
17
18
|
|
|
18
19
|
// src/commands/report.ts
|
|
19
20
|
import { Flags } from "@oclif/core";
|
package/dist/commands/restore.js
CHANGED
|
@@ -5,29 +5,30 @@ import {
|
|
|
5
5
|
restoreFromMigrations,
|
|
6
6
|
restoreFromSnapshot,
|
|
7
7
|
summarizeStatement
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
8
|
+
} from "../chunk-F46FFUKC.js";
|
|
9
|
+
import "../chunk-V2SBZERO.js";
|
|
10
|
+
import "../chunk-S5L4A3UR.js";
|
|
11
|
+
import "../chunk-3WKWPSFN.js";
|
|
12
|
+
import "../chunk-DQJSSTIJ.js";
|
|
13
|
+
import "../chunk-N5VNNOA2.js";
|
|
14
|
+
import "../chunk-WK5YTINL.js";
|
|
15
15
|
import {
|
|
16
16
|
renderTip
|
|
17
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-ZI435CAU.js";
|
|
18
18
|
import {
|
|
19
19
|
BaseCommand
|
|
20
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-5STH2A6K.js";
|
|
21
21
|
import {
|
|
22
22
|
findLatestSnapshot,
|
|
23
23
|
listSnapshots
|
|
24
|
-
} from "../chunk-
|
|
24
|
+
} from "../chunk-ICSCHS72.js";
|
|
25
25
|
import "../chunk-DQQ5E563.js";
|
|
26
|
-
import "../chunk-
|
|
26
|
+
import "../chunk-MG3SFV5J.js";
|
|
27
|
+
import "../chunk-GQPGH6YR.js";
|
|
27
28
|
import {
|
|
28
29
|
cmd,
|
|
29
30
|
warn
|
|
30
|
-
} from "../chunk-
|
|
31
|
+
} from "../chunk-KNXHLVF7.js";
|
|
31
32
|
|
|
32
33
|
// src/commands/restore.ts
|
|
33
34
|
import { Flags } from "@oclif/core";
|
|
@@ -24,9 +24,16 @@ declare class Snapshot extends BaseCommand {
|
|
|
24
24
|
keep: _oclif_core_interfaces.OptionFlag<number, _oclif_core_interfaces.CustomOptions>;
|
|
25
25
|
apply: _oclif_core_interfaces.BooleanFlag<boolean>;
|
|
26
26
|
json: _oclif_core_interfaces.BooleanFlag<boolean>;
|
|
27
|
+
'allow-schema-json-only': _oclif_core_interfaces.BooleanFlag<boolean>;
|
|
27
28
|
output: _oclif_core_interfaces.OptionFlag<string | undefined, _oclif_core_interfaces.CustomOptions>;
|
|
28
29
|
};
|
|
29
30
|
run(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* A snapshot without schema.sql cannot restore its schema, and the time to
|
|
33
|
+
* find that out is not during a restore. It is kept — it can still be
|
|
34
|
+
* diffed — but the command fails unless that was asked for.
|
|
35
|
+
*/
|
|
36
|
+
private failIfUnrestorable;
|
|
30
37
|
private logSnapshotResult;
|
|
31
38
|
}
|
|
32
39
|
|
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
backup,
|
|
3
3
|
listMigrationFiles
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-V2SBZERO.js";
|
|
5
|
+
import "../chunk-WK5YTINL.js";
|
|
6
6
|
import {
|
|
7
7
|
renderTip
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-ZI435CAU.js";
|
|
9
9
|
import {
|
|
10
10
|
BaseCommand
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-5STH2A6K.js";
|
|
12
12
|
import {
|
|
13
13
|
DEFAULT_KEEP_COUNT,
|
|
14
14
|
captureSnapshot,
|
|
15
15
|
formatSnapshotLayers,
|
|
16
16
|
listSnapshots,
|
|
17
|
-
pruneSnapshots
|
|
18
|
-
|
|
17
|
+
pruneSnapshots,
|
|
18
|
+
unrestorableSchema
|
|
19
|
+
} from "../chunk-ICSCHS72.js";
|
|
19
20
|
import "../chunk-DQQ5E563.js";
|
|
20
|
-
import "../chunk-
|
|
21
|
+
import "../chunk-MG3SFV5J.js";
|
|
22
|
+
import "../chunk-GQPGH6YR.js";
|
|
21
23
|
import {
|
|
22
24
|
bold,
|
|
23
25
|
cmd,
|
|
24
26
|
dim,
|
|
25
27
|
ok,
|
|
26
28
|
warn
|
|
27
|
-
} from "../chunk-
|
|
29
|
+
} from "../chunk-KNXHLVF7.js";
|
|
28
30
|
|
|
29
31
|
// src/commands/snapshot.ts
|
|
30
32
|
import { Flags } from "@oclif/core";
|
|
@@ -84,6 +86,10 @@ var Snapshot = class _Snapshot extends BaseCommand {
|
|
|
84
86
|
default: false
|
|
85
87
|
}),
|
|
86
88
|
json: Flags.boolean({ description: "Output results as JSON" }),
|
|
89
|
+
"allow-schema-json-only": Flags.boolean({
|
|
90
|
+
description: "Succeed even when no pg_dump could write schema.sql: the snapshot can still be diffed, but restore cannot recreate its schema. Without this, such a snapshot is kept and the command exits 1.",
|
|
91
|
+
default: false
|
|
92
|
+
}),
|
|
87
93
|
output: Flags.string({
|
|
88
94
|
char: "o",
|
|
89
95
|
description: "Custom output directory for snapshot files (timestamp subfolder is created inside)"
|
|
@@ -194,6 +200,7 @@ Capturing snapshot of "${envName}" with migration...
|
|
|
194
200
|
migration: result.migration,
|
|
195
201
|
migrationFile: result.migrationFile
|
|
196
202
|
});
|
|
203
|
+
this.failIfUnrestorable(result.snapshot.manifest, result.snapshot.dir, flags["allow-schema-json-only"]);
|
|
197
204
|
return;
|
|
198
205
|
}
|
|
199
206
|
this.logSnapshotResult(result.snapshot.manifest);
|
|
@@ -211,6 +218,7 @@ Capturing snapshot of "${envName}" with migration...
|
|
|
211
218
|
} else {
|
|
212
219
|
this.log(` ${dim("Migration:")} none (no changes detected)`);
|
|
213
220
|
}
|
|
221
|
+
this.failIfUnrestorable(result.snapshot.manifest, result.snapshot.dir, flags["allow-schema-json-only"]);
|
|
214
222
|
this.log(`
|
|
215
223
|
${ok("Snapshot + migration complete.")}
|
|
216
224
|
`);
|
|
@@ -223,11 +231,13 @@ Capturing snapshot of "${envName}"...
|
|
|
223
231
|
const snapshot = await captureSnapshot({ envName, env, config, outputDir: flags.output });
|
|
224
232
|
if (flags.json) {
|
|
225
233
|
this.json(snapshot.manifest);
|
|
234
|
+
this.failIfUnrestorable(snapshot.manifest, snapshot.dir, flags["allow-schema-json-only"]);
|
|
226
235
|
return;
|
|
227
236
|
}
|
|
228
237
|
this.logSnapshotResult(snapshot.manifest);
|
|
229
238
|
this.log(`
|
|
230
239
|
${dim("Snapshot saved to:")} ${snapshot.dir}`);
|
|
240
|
+
this.failIfUnrestorable(snapshot.manifest, snapshot.dir, flags["allow-schema-json-only"]);
|
|
231
241
|
const existing = await listMigrationFiles();
|
|
232
242
|
if (existing.length > 0) {
|
|
233
243
|
this.log(` \u2192 Run with ${cmd("--migration")} to also generate an incremental diff.`);
|
|
@@ -237,6 +247,24 @@ Capturing snapshot of "${envName}"...
|
|
|
237
247
|
this.log("");
|
|
238
248
|
this.log(renderTip({ command: "snapshot", snapshotMigration: false, snapshotList: false }));
|
|
239
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* A snapshot without schema.sql cannot restore its schema, and the time to
|
|
252
|
+
* find that out is not during a restore. It is kept — it can still be
|
|
253
|
+
* diffed — but the command fails unless that was asked for.
|
|
254
|
+
*/
|
|
255
|
+
failIfUnrestorable(manifest, dir, allowed) {
|
|
256
|
+
const reason = unrestorableSchema(manifest);
|
|
257
|
+
if (!reason) return;
|
|
258
|
+
if (allowed) {
|
|
259
|
+
this.warn(`This snapshot cannot restore the schema: ${reason}`);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
this.error(
|
|
263
|
+
`This snapshot cannot restore the schema: ${reason}.
|
|
264
|
+
It was kept at ${dir}, and can still be diffed. Install PostgreSQL client tools at least as new as the server (or set SUPAFORGE_PG_BIN to them) and snapshot again, or pass --allow-schema-json-only to accept a snapshot whose schema cannot be restored.`,
|
|
265
|
+
{ exit: 1 }
|
|
266
|
+
);
|
|
267
|
+
}
|
|
240
268
|
logSnapshotResult(manifest) {
|
|
241
269
|
for (const line of formatSnapshotLayers(manifest)) {
|
|
242
270
|
this.log(` ${line}`);
|