gencow 0.1.270 → 0.1.272
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/lib/canonical-drizzle-generator.config.mjs +7 -1
- package/lib/cli-command-runner.mjs +5 -3
- package/lib/cloud-targets.mjs +22 -2
- package/lib/db-command.mjs +12 -15
- package/lib/db-push-command.mjs +6 -0
- package/lib/deploy-app-target.mjs +8 -2
- package/lib/deploy-runtime.mjs +9 -5
- package/lib/dev-local-command.mjs +7 -2
- package/lib/drizzle-generate.mjs +138 -38
- package/lib/env-command.mjs +36 -5
- package/lib/files-command.mjs +10 -2
- package/lib/jobs-command.mjs +5 -1
- package/lib/migration-schema-load-failure.mjs +53 -22
- package/lib/static-command.mjs +12 -2
- package/package.json +4 -4
- package/runtime/server.mjs +17 -17
|
@@ -1,31 +1,62 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
|
|
1
|
+
// Classifies a generator failure by its PHASE, not by its message text.
|
|
2
|
+
//
|
|
3
|
+
// The real drizzle-kit 1.0.0-rc.4 prints only `Error <message>` on stderr when the schema
|
|
4
|
+
// fails to load: no error class, no stack. Message text therefore cannot identify the phase.
|
|
5
|
+
// Instead the Gencow-owned generator config (canonical-drizzle-generator.config.mjs) writes
|
|
6
|
+
// the `config_loaded` marker to a CLI-provided path once it has been evaluated. A failure is a
|
|
7
|
+
// schema-load failure only when all of these hold (see drizzle-generate.mjs):
|
|
8
|
+
// 1. the config was evaluated (the marker exists with the exact contract content),
|
|
9
|
+
// 2. the generator exited non-zero and was spawned successfully,
|
|
10
|
+
// 3. the migrations directory is unchanged (drizzle-kit wrote nothing), and
|
|
11
|
+
// 4. the first non-empty stderr line is drizzle-kit's `Error ` wrapper.
|
|
12
|
+
// A config-stage failure (no marker), a snapshot error (no `Error ` wrapper), a spawn failure,
|
|
13
|
+
// and a success with no changes all stay unclassified.
|
|
12
14
|
|
|
13
15
|
export const SCHEMA_LOAD_FAILED_REASON_CODE = "schema_load_failed";
|
|
14
16
|
|
|
15
|
-
//
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
// Env var the CLI sets to a temp file path. Shared by the CLI and the generator config.
|
|
18
|
+
export const GENERATOR_PHASE_MARKER_ENV = "GENCOW_DRIZZLE_PHASE_MARKER";
|
|
19
|
+
export const CONFIG_LOADED_PHASE_MARKER = "config_loaded";
|
|
20
|
+
|
|
21
|
+
const DRIZZLE_ERROR_WRAPPER = "Error ";
|
|
22
|
+
// drizzle-kit prints the schema file location on its own line: `<path>/gencow/schema.ts:1:17`.
|
|
23
|
+
// Only the project's canonical schema file is reported; the absolute prefix is never kept.
|
|
24
|
+
const SCHEMA_LOCATION_PATTERN = /gencow[\\/]schema\.ts:(\d{1,6}):(\d{1,6})\b/u;
|
|
25
|
+
const MAX_CAUSE_LENGTH = 200;
|
|
26
|
+
|
|
27
|
+
// Returns { reasonCode, cause, location } for a phase-proven schema-load failure, otherwise null.
|
|
28
|
+
// `rawStderr` is the unsanitized stderr; `sanitize` is the CLI's output redaction function.
|
|
29
|
+
export function classifySchemaLoadFailure({ configLoaded, migrationsUnchanged, rawStderr, sanitize }) {
|
|
30
|
+
if (configLoaded !== true || migrationsUnchanged !== true) return null;
|
|
31
|
+
const raw = String(rawStderr ?? "");
|
|
32
|
+
const firstLine = raw.split(/\r?\n/u).find((line) => line.trim() !== "") ?? "";
|
|
33
|
+
if (!firstLine.startsWith(DRIZZLE_ERROR_WRAPPER)) return null;
|
|
34
|
+
|
|
35
|
+
const rawCause = firstLine.slice(DRIZZLE_ERROR_WRAPPER.length);
|
|
36
|
+
const cause = toSafeCause(sanitize(rawCause));
|
|
37
|
+
const locationMatch = SCHEMA_LOCATION_PATTERN.exec(raw);
|
|
38
|
+
const location = locationMatch
|
|
39
|
+
? Object.freeze({
|
|
40
|
+
sourceFile: "[project]/gencow/schema.ts",
|
|
41
|
+
line: Number(locationMatch[1]),
|
|
42
|
+
column: Number(locationMatch[2]),
|
|
43
|
+
})
|
|
44
|
+
: null;
|
|
45
|
+
return Object.freeze({ reasonCode: SCHEMA_LOAD_FAILED_REASON_CODE, cause, location });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function toSafeCause(sanitizedMessage) {
|
|
49
|
+
const singleLine = String(sanitizedMessage ?? "")
|
|
50
|
+
.replace(/[\u0000-\u001f\u007f]+/gu, " ")
|
|
51
|
+
.replace(/\s+/gu, " ")
|
|
52
|
+
.trim();
|
|
53
|
+
if (!singleLine) return null;
|
|
54
|
+
return singleLine.length > MAX_CAUSE_LENGTH ? `${singleLine.slice(0, MAX_CAUSE_LENGTH - 3)}...` : singleLine;
|
|
21
55
|
}
|
|
22
56
|
|
|
23
57
|
// The raw generator text is never printed; only these fixed sentences reach the user.
|
|
24
58
|
export const SCHEMA_LOAD_FAILURE_CLI_MESSAGE =
|
|
25
|
-
"Migration generation stopped: drizzle-kit failed while
|
|
26
|
-
|
|
27
|
-
export const SCHEMA_LOAD_FAILURE_CAUSE_HINT =
|
|
28
|
-
"Possible cause (not confirmed): a table callback (the third argument of pgTable) returns an entry that is not an index, policy, or constraint. If a policy helper returns an array, spread it into the returned array with `...`. The tooling or environment may also be the cause.";
|
|
59
|
+
"Migration generation stopped: drizzle-kit failed while loading or evaluating your schema (gencow/schema.ts), so no migration file was generated.";
|
|
29
60
|
|
|
30
61
|
export const SCHEMA_LOAD_FAILURE_CLI_ACTION =
|
|
31
|
-
"Retryable:
|
|
62
|
+
"Retryable: yes, after gencow/schema.ts is fixed — then run `npx gencow@latest db:generate` to confirm migrations generate.";
|
package/lib/static-command.mjs
CHANGED
|
@@ -84,16 +84,19 @@ export function readStaticProjectContext(options = {}) {
|
|
|
84
84
|
}
|
|
85
85
|
const gencowJsonPath = resolveProjectMetadataPath(projectRoot, resolvePathImpl);
|
|
86
86
|
let appId = explicitAppId;
|
|
87
|
+
let projectAppId = null;
|
|
87
88
|
let prodAppId = null;
|
|
88
89
|
|
|
89
90
|
if (existsSyncImpl(gencowJsonPath)) {
|
|
90
91
|
const gencowJson = JSON.parse(readFileSyncImpl(gencowJsonPath, "utf8"));
|
|
92
|
+
projectAppId = gencowJson.appId || gencowJson.appName || null;
|
|
91
93
|
if (!appId) appId = gencowJson.appId || gencowJson.appName;
|
|
92
94
|
prodAppId = gencowJson.prodApp || null;
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
return {
|
|
96
98
|
appId,
|
|
99
|
+
projectAppId,
|
|
97
100
|
displayName: readProjectDisplayNameImpl({
|
|
98
101
|
cwd: projectRoot,
|
|
99
102
|
existsSyncImpl,
|
|
@@ -220,6 +223,7 @@ export function createStaticCommand(options = {}) {
|
|
|
220
223
|
displayName: initialDisplayName,
|
|
221
224
|
gencowJsonPath,
|
|
222
225
|
prodAppId,
|
|
226
|
+
projectAppId,
|
|
223
227
|
projectRoot,
|
|
224
228
|
} = readStaticProjectContextImpl({
|
|
225
229
|
cwd: cwdImpl(),
|
|
@@ -299,9 +303,15 @@ export function createStaticCommand(options = {}) {
|
|
|
299
303
|
selectedClient && artifactPreflight.targetDir && !isAbsolute(artifactPreflight.targetDir)
|
|
300
304
|
? resolvePathImpl(frontendRoot, artifactPreflight.targetDir)
|
|
301
305
|
: artifactPreflight.targetDir;
|
|
302
|
-
if (parsed.isProd &&
|
|
306
|
+
if (parsed.isProd && parsed.appId) {
|
|
303
307
|
// An explicit --app must be this project's prod app; it is never silently replaced by the default.
|
|
304
|
-
|
|
308
|
+
// A project with no prod app yet still rejects its own dev app; any other explicit id keeps legacy acceptance.
|
|
309
|
+
const prodTarget = resolveProdAppTarget({
|
|
310
|
+
explicitAppId: parsed.appId,
|
|
311
|
+
prodApp: prodAppId,
|
|
312
|
+
projectAppId,
|
|
313
|
+
acceptExplicitWithoutProdApp: true,
|
|
314
|
+
});
|
|
305
315
|
if (!prodTarget.appId) {
|
|
306
316
|
errorImpl(
|
|
307
317
|
cloudTargetRejectionMessage(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gencow",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.272",
|
|
4
4
|
"description": "Gencow — AI Backend Engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"better-auth": "1.7.11",
|
|
42
42
|
"postgres": "^3.4.9",
|
|
43
43
|
"@gencow/client": "0.2.8",
|
|
44
|
-
"@gencow/server": "0.1.3",
|
|
45
44
|
"@gencow/core": "0.1.47",
|
|
46
|
-
"@gencow/
|
|
47
|
-
"@gencow/shared": "0.0.0"
|
|
45
|
+
"@gencow/server": "0.1.3",
|
|
46
|
+
"@gencow/shared": "0.0.0",
|
|
47
|
+
"@gencow/react": "0.2.8"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "node scripts/bundle-core.mjs && node scripts/bundle-shared.mjs && node scripts/bundle-server.mjs",
|