gencow 0.1.271 → 0.1.273
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 +22 -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-codegen-failure.mjs +11 -0
- package/lib/deploy-runtime.mjs +9 -5
- package/lib/dev-local-command.mjs +7 -2
- package/lib/drizzle-generate.mjs +138 -38
- 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/tooling.mjs +109 -65
- package/scripts/codegen-named-import-check.ts +131 -63
- package/scripts/tooling-codegen-runtime.ts +11 -10
|
@@ -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.273",
|
|
4
4
|
"description": "Gencow — AI Backend Engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"ai": "^6.0.314",
|
|
41
41
|
"better-auth": "1.7.11",
|
|
42
42
|
"postgres": "^3.4.9",
|
|
43
|
-
"@gencow/
|
|
44
|
-
"@gencow/core": "0.1.47",
|
|
43
|
+
"@gencow/react": "0.2.8",
|
|
45
44
|
"@gencow/server": "0.1.3",
|
|
45
|
+
"@gencow/client": "0.2.8",
|
|
46
46
|
"@gencow/shared": "0.0.0",
|
|
47
|
-
"@gencow/
|
|
47
|
+
"@gencow/core": "0.1.47"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "node scripts/bundle-core.mjs && node scripts/bundle-shared.mjs && node scripts/bundle-server.mjs",
|
package/runtime/tooling.mjs
CHANGED
|
@@ -6777,12 +6777,14 @@ function shouldTriggerCodegenFromPath(path, backendRoot = "gencow") {
|
|
|
6777
6777
|
}
|
|
6778
6778
|
|
|
6779
6779
|
// scripts/codegen-named-import-check.ts
|
|
6780
|
+
import { statSync as statSync3 } from "node:fs";
|
|
6780
6781
|
import { createRequire } from "node:module";
|
|
6781
|
-
import { join as join6, relative as relative4, resolve as resolve10, sep as sep2 } from "node:path";
|
|
6782
|
+
import { dirname as dirname4, join as join6, relative as relative4, resolve as resolve10, sep as sep2 } from "node:path";
|
|
6782
6783
|
var SCRIPT_FILE = /\.(?:[cm]?[jt]sx?)$/u;
|
|
6783
6784
|
var TYPESCRIPT_FILE = /\.(?:[cm]?tsx?)$/u;
|
|
6784
6785
|
var RELATIVE_SPECIFIER = /^\.{1,2}\//u;
|
|
6785
6786
|
var DECLARATION_FILE = /\.d\.[cm]?ts$/u;
|
|
6787
|
+
var FALLBACK_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs", ".json", ".css"];
|
|
6786
6788
|
function loadProjectTypeScript(projectRoot) {
|
|
6787
6789
|
try {
|
|
6788
6790
|
const requireFromProject = createRequire(join6(projectRoot, "package.json"));
|
|
@@ -6792,17 +6794,31 @@ function loadProjectTypeScript(projectRoot) {
|
|
|
6792
6794
|
return null;
|
|
6793
6795
|
}
|
|
6794
6796
|
}
|
|
6797
|
+
function isFile(path) {
|
|
6798
|
+
try {
|
|
6799
|
+
return statSync3(path).isFile();
|
|
6800
|
+
} catch {
|
|
6801
|
+
return false;
|
|
6802
|
+
}
|
|
6803
|
+
}
|
|
6804
|
+
function existsOnDisk(fromFile, specifier) {
|
|
6805
|
+
const base = resolve10(dirname4(fromFile), specifier);
|
|
6806
|
+
if (isFile(base)) return true;
|
|
6807
|
+
return FALLBACK_EXTENSIONS.some((ext) => isFile(`${base}${ext}`) || isFile(join6(base, `index${ext}`)));
|
|
6808
|
+
}
|
|
6795
6809
|
function resolveRelativeModule(ctx, fromFile, specifier) {
|
|
6796
|
-
if (!RELATIVE_SPECIFIER.test(specifier)) return
|
|
6810
|
+
if (!RELATIVE_SPECIFIER.test(specifier)) return { status: "skipped" };
|
|
6797
6811
|
const resolved = ctx.ts.resolveModuleName(
|
|
6798
6812
|
specifier,
|
|
6799
6813
|
fromFile,
|
|
6800
6814
|
ctx.compilerOptions,
|
|
6801
6815
|
ctx.ts.sys
|
|
6802
6816
|
).resolvedModule;
|
|
6803
|
-
if (
|
|
6804
|
-
|
|
6805
|
-
|
|
6817
|
+
if (resolved && !resolved.isExternalLibraryImport) {
|
|
6818
|
+
if (DECLARATION_FILE.test(resolved.resolvedFileName)) return { status: "skipped" };
|
|
6819
|
+
return { status: "resolved", file: resolved.resolvedFileName };
|
|
6820
|
+
}
|
|
6821
|
+
return existsOnDisk(fromFile, specifier) ? { status: "skipped" } : { status: "unresolved" };
|
|
6806
6822
|
}
|
|
6807
6823
|
function parseSource(ctx, file2) {
|
|
6808
6824
|
const text = ctx.ts.sys.readFile(file2);
|
|
@@ -6840,8 +6856,8 @@ function collectExportNames(ctx, file2) {
|
|
|
6840
6856
|
if (ts.isExportDeclaration(statement)) {
|
|
6841
6857
|
const clause = statement.exportClause;
|
|
6842
6858
|
if (!clause) {
|
|
6843
|
-
const
|
|
6844
|
-
const inner =
|
|
6859
|
+
const resolution = resolveRelativeModule(ctx, file2, statement.moduleSpecifier.text);
|
|
6860
|
+
const inner = resolution.status === "resolved" ? exportNamesOf(ctx, resolution.file) : null;
|
|
6845
6861
|
if (!inner) return null;
|
|
6846
6862
|
for (const name2 of inner) if (name2 !== "default") names.add(name2);
|
|
6847
6863
|
} else if (ts.isNamespaceExport(clause)) {
|
|
@@ -6867,40 +6883,65 @@ function collectExportNames(ctx, file2) {
|
|
|
6867
6883
|
}
|
|
6868
6884
|
return names;
|
|
6869
6885
|
}
|
|
6870
|
-
function
|
|
6886
|
+
function valueReferenceOf(ts, statement) {
|
|
6887
|
+
if (ts.isImportDeclaration(statement)) {
|
|
6888
|
+
const clause = statement.importClause;
|
|
6889
|
+
if (!clause) return { specifier: statement.moduleSpecifier, elements: [] };
|
|
6890
|
+
if (clause.isTypeOnly) return null;
|
|
6891
|
+
const bindings = clause.namedBindings;
|
|
6892
|
+
if (bindings && ts.isNamedImports(bindings)) {
|
|
6893
|
+
const elements = bindings.elements.filter((element) => !element.isTypeOnly);
|
|
6894
|
+
if (!clause.name && bindings.elements.length > 0 && elements.length === 0) return null;
|
|
6895
|
+
return { specifier: statement.moduleSpecifier, elements };
|
|
6896
|
+
}
|
|
6897
|
+
return { specifier: statement.moduleSpecifier, elements: [] };
|
|
6898
|
+
}
|
|
6899
|
+
if (ts.isExportDeclaration(statement) && statement.moduleSpecifier && !statement.isTypeOnly) {
|
|
6900
|
+
const clause = statement.exportClause;
|
|
6901
|
+
if (clause && ts.isNamedExports(clause)) {
|
|
6902
|
+
const elements = clause.elements.filter((element) => !element.isTypeOnly);
|
|
6903
|
+
if (clause.elements.length > 0 && elements.length === 0) return null;
|
|
6904
|
+
return { specifier: statement.moduleSpecifier, elements };
|
|
6905
|
+
}
|
|
6906
|
+
return { specifier: statement.moduleSpecifier, elements: [] };
|
|
6907
|
+
}
|
|
6908
|
+
return null;
|
|
6909
|
+
}
|
|
6910
|
+
function positionOf(sourceFile, node2) {
|
|
6911
|
+
const position = sourceFile.getLineAndCharacterOfPosition(node2.getStart(sourceFile));
|
|
6912
|
+
return { line: position.line + 1, column: position.character };
|
|
6913
|
+
}
|
|
6914
|
+
function importResolutionIssuesIn(ctx, file2) {
|
|
6871
6915
|
const { ts } = ctx;
|
|
6872
6916
|
const sourceFile = parseSource(ctx, file2);
|
|
6873
6917
|
if (!sourceFile) return [];
|
|
6874
|
-
const
|
|
6918
|
+
const issues = [];
|
|
6875
6919
|
for (const statement of sourceFile.statements) {
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6886
|
-
specifiers = statement.exportClause.elements;
|
|
6887
|
-
specifier = statement.moduleSpecifier.text;
|
|
6888
|
-
}
|
|
6889
|
-
if (!specifier) continue;
|
|
6890
|
-
const target = resolveRelativeModule(ctx, file2, specifier);
|
|
6891
|
-
if (!target) continue;
|
|
6892
|
-
const exported = exportNamesOf(ctx, target);
|
|
6920
|
+
const reference = valueReferenceOf(ts, statement);
|
|
6921
|
+
if (!reference) continue;
|
|
6922
|
+
const specifier = reference.specifier.text;
|
|
6923
|
+
const resolution = resolveRelativeModule(ctx, file2, specifier);
|
|
6924
|
+
if (resolution.status === "unresolved") {
|
|
6925
|
+
issues.push({ kind: "unresolvedModule", file: file2, ...positionOf(sourceFile, reference.specifier), specifier });
|
|
6926
|
+
continue;
|
|
6927
|
+
}
|
|
6928
|
+
if (resolution.status !== "resolved") continue;
|
|
6929
|
+
const exported = exportNamesOf(ctx, resolution.file);
|
|
6893
6930
|
if (!exported) continue;
|
|
6894
|
-
for (const element of
|
|
6895
|
-
if (element.isTypeOnly) continue;
|
|
6931
|
+
for (const element of reference.elements) {
|
|
6896
6932
|
const nameNode = element.propertyName ?? element.name;
|
|
6897
6933
|
const name2 = nameNode.text;
|
|
6898
6934
|
if (exported.has(name2)) continue;
|
|
6899
|
-
|
|
6900
|
-
|
|
6935
|
+
issues.push({
|
|
6936
|
+
kind: "missingExport",
|
|
6937
|
+
file: file2,
|
|
6938
|
+
...positionOf(sourceFile, nameNode),
|
|
6939
|
+
name: name2,
|
|
6940
|
+
target: resolution.file
|
|
6941
|
+
});
|
|
6901
6942
|
}
|
|
6902
6943
|
}
|
|
6903
|
-
return
|
|
6944
|
+
return issues;
|
|
6904
6945
|
}
|
|
6905
6946
|
function isProjectSource(file2, projectRoot) {
|
|
6906
6947
|
return file2.startsWith(`${projectRoot}${sep2}`) && !file2.split(sep2).includes("node_modules") && SCRIPT_FILE.test(file2);
|
|
@@ -6908,7 +6949,7 @@ function isProjectSource(file2, projectRoot) {
|
|
|
6908
6949
|
function hasProjectTypeScript(projectRootInput) {
|
|
6909
6950
|
return loadProjectTypeScript(resolve10(projectRootInput)) !== null;
|
|
6910
6951
|
}
|
|
6911
|
-
function
|
|
6952
|
+
function findImportResolutionIssues(inputFiles, projectRootInput) {
|
|
6912
6953
|
const projectRoot = resolve10(projectRootInput);
|
|
6913
6954
|
const ts = loadProjectTypeScript(projectRoot);
|
|
6914
6955
|
if (!ts) return [];
|
|
@@ -6923,17 +6964,20 @@ function findMissingNamedImports(inputFiles, projectRootInput) {
|
|
|
6923
6964
|
exportCache: /* @__PURE__ */ new Map()
|
|
6924
6965
|
};
|
|
6925
6966
|
try {
|
|
6926
|
-
const
|
|
6967
|
+
const issues = [];
|
|
6927
6968
|
for (const file2 of inputFiles) {
|
|
6928
|
-
if (isProjectSource(file2, projectRoot))
|
|
6969
|
+
if (isProjectSource(file2, projectRoot)) issues.push(...importResolutionIssuesIn(ctx, file2));
|
|
6929
6970
|
}
|
|
6930
|
-
return
|
|
6971
|
+
return issues;
|
|
6931
6972
|
} catch {
|
|
6932
6973
|
return [];
|
|
6933
6974
|
}
|
|
6934
6975
|
}
|
|
6935
|
-
function
|
|
6936
|
-
return
|
|
6976
|
+
function formatImportResolutionIssues(issues, projectRoot) {
|
|
6977
|
+
return issues.map((item) => {
|
|
6978
|
+
if (item.kind === "unresolvedModule") {
|
|
6979
|
+
return `${item.file}:${item.line}:${item.column}: ERROR: Could not resolve "${item.specifier}"`;
|
|
6980
|
+
}
|
|
6937
6981
|
const target = relative4(resolve10(projectRoot), item.target).split(sep2).join("/");
|
|
6938
6982
|
return `${item.file}:${item.line}:${item.column}: ERROR: No matching export in "${target}" for import "${item.name}"`;
|
|
6939
6983
|
});
|
|
@@ -7069,7 +7113,7 @@ async function transpileTypescriptForNodeDefault(entryPath, context) {
|
|
|
7069
7113
|
}
|
|
7070
7114
|
};
|
|
7071
7115
|
}
|
|
7072
|
-
var
|
|
7116
|
+
var IMPORT_RESOLUTION_DIAGNOSTIC = /No matching export in "|Could not resolve "/u;
|
|
7073
7117
|
var NAMED_IMPORT_CHECK_SKIPPED_MESSAGE = "Warning: codegen skipped the named-import check because this project has no typescript package. Install typescript in the project (for example: npm install -D typescript) and rerun codegen.";
|
|
7074
7118
|
function defaultWarn(message) {
|
|
7075
7119
|
process.stderr.write(`${message}
|
|
@@ -7098,15 +7142,15 @@ async function assertNamedImportsResolve(input2) {
|
|
|
7098
7142
|
inputFiles = bundledInputFiles(await build({ ...esbuildEntryOptions(input2.appEntryAbs), write: false }));
|
|
7099
7143
|
} catch (error62) {
|
|
7100
7144
|
const details = error62 instanceof Error ? error62.message : String(error62);
|
|
7101
|
-
if (input2.runtime === "bun" && !
|
|
7145
|
+
if (input2.runtime === "bun" && !IMPORT_RESOLUTION_DIAGNOSTIC.test(details)) return;
|
|
7102
7146
|
throw namedImportLoadFailure(input2.appEntryAbs, input2.runtime, [`Transpile error: ${details}`]);
|
|
7103
7147
|
}
|
|
7104
7148
|
}
|
|
7105
|
-
const
|
|
7106
|
-
if (
|
|
7149
|
+
const issues = findImportResolutionIssues(inputFiles, input2.projectRoot);
|
|
7150
|
+
if (issues.length > 0) {
|
|
7107
7151
|
throw namedImportLoadFailure(input2.appEntryAbs, input2.runtime, [
|
|
7108
|
-
`Transpile error: Build failed with ${
|
|
7109
|
-
...
|
|
7152
|
+
`Transpile error: Build failed with ${issues.length} error${issues.length === 1 ? "" : "s"}:`,
|
|
7153
|
+
...formatImportResolutionIssues(issues, input2.projectRoot)
|
|
7110
7154
|
]);
|
|
7111
7155
|
}
|
|
7112
7156
|
}
|
|
@@ -7223,10 +7267,10 @@ async function runCodegen2(input2) {
|
|
|
7223
7267
|
|
|
7224
7268
|
// ../shared/src/analyzer/consumers/doctor/run-app-doctor.ts
|
|
7225
7269
|
import { existsSync as existsSync10, mkdirSync as mkdirSync3, readFileSync as readFileSync9, renameSync, rmSync as rmSync2, writeFileSync as writeFileSync4 } from "fs";
|
|
7226
|
-
import { dirname as
|
|
7270
|
+
import { dirname as dirname10, resolve as resolve16 } from "path";
|
|
7227
7271
|
|
|
7228
7272
|
// ../shared/src/analyzer/shared/deprecated-api-fix-plugin.ts
|
|
7229
|
-
import { dirname as
|
|
7273
|
+
import { dirname as dirname5, relative as relative5 } from "path";
|
|
7230
7274
|
var DEPRECATED_CORE_IMPORTS = {
|
|
7231
7275
|
query: {
|
|
7232
7276
|
code: "DOC_DEPRECATED_QUERY_API",
|
|
@@ -7279,7 +7323,7 @@ function stripExtension(pathValue) {
|
|
|
7279
7323
|
return pathValue.replace(/\.[^.\/]+$/, "");
|
|
7280
7324
|
}
|
|
7281
7325
|
function toImportSpecifier2(fromFile, targetFile) {
|
|
7282
|
-
const fromDir =
|
|
7326
|
+
const fromDir = dirname5(fromFile);
|
|
7283
7327
|
const rel = relative5(fromDir, stripExtension(targetFile)).replace(/\\/g, "/");
|
|
7284
7328
|
if (!rel || rel === ".") return "./ai";
|
|
7285
7329
|
return rel.startsWith(".") ? rel : `./${rel}`;
|
|
@@ -7418,17 +7462,17 @@ function createDeprecatedApiFixPlugin() {
|
|
|
7418
7462
|
import { readFileSync as readFileSync8 } from "fs";
|
|
7419
7463
|
|
|
7420
7464
|
// ../shared/src/analyzer/adapters/app-schema-graph.ts
|
|
7421
|
-
import { basename, dirname as
|
|
7465
|
+
import { basename, dirname as dirname7, join as join9, resolve as resolve13 } from "path";
|
|
7422
7466
|
import { existsSync as existsSync7, readFileSync as readFileSync5 } from "fs";
|
|
7423
7467
|
|
|
7424
7468
|
// ../shared/src/analyzer/internal/source-files.ts
|
|
7425
|
-
import { existsSync as existsSync6, readdirSync as readdirSync2, readFileSync as readFileSync4, statSync as
|
|
7426
|
-
import { dirname as
|
|
7469
|
+
import { existsSync as existsSync6, readdirSync as readdirSync2, readFileSync as readFileSync4, statSync as statSync4 } from "fs";
|
|
7470
|
+
import { dirname as dirname6, join as join8, relative as relative6, resolve as resolve12 } from "path";
|
|
7427
7471
|
var SOURCE_FILE_EXTENSIONS2 = [".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"];
|
|
7428
7472
|
function findSourceFiles(dir) {
|
|
7429
7473
|
if (!existsSync6(dir)) return [];
|
|
7430
7474
|
try {
|
|
7431
|
-
if (
|
|
7475
|
+
if (statSync4(dir).isFile()) {
|
|
7432
7476
|
return /\.(?:[cm]?[jt]sx?)$/.test(dir) ? [dir] : [];
|
|
7433
7477
|
}
|
|
7434
7478
|
} catch {
|
|
@@ -7487,7 +7531,7 @@ function findStaticRelativeImports(filePath) {
|
|
|
7487
7531
|
}
|
|
7488
7532
|
function resolveRelativeModule2(fromPath, specifier) {
|
|
7489
7533
|
if (!specifier.startsWith(".")) return null;
|
|
7490
|
-
const base = resolve12(
|
|
7534
|
+
const base = resolve12(dirname6(fromPath), specifier);
|
|
7491
7535
|
return resolveSourceFileCandidate(base);
|
|
7492
7536
|
}
|
|
7493
7537
|
function toProjectPath(projectRootAbs, absPath) {
|
|
@@ -7573,7 +7617,7 @@ function parseJsoncObject(filePath) {
|
|
|
7573
7617
|
}
|
|
7574
7618
|
function resolveTsConfigExtendsPath(configFile, extendsValue) {
|
|
7575
7619
|
if (!extendsValue.startsWith(".") && !extendsValue.startsWith("/")) return null;
|
|
7576
|
-
const configDir =
|
|
7620
|
+
const configDir = dirname6(configFile);
|
|
7577
7621
|
const rawPath = extendsValue.startsWith("/") ? extendsValue : resolve12(configDir, extendsValue);
|
|
7578
7622
|
const candidates = rawPath.endsWith(".json") ? [rawPath] : [rawPath, `${rawPath}.json`, join8(rawPath, "tsconfig.json")];
|
|
7579
7623
|
return candidates.find((candidate) => existsSync6(candidate)) ?? null;
|
|
@@ -7627,7 +7671,7 @@ function findNearestProjectConfigFiles(startDir) {
|
|
|
7627
7671
|
}
|
|
7628
7672
|
} catch {
|
|
7629
7673
|
}
|
|
7630
|
-
const parentDir =
|
|
7674
|
+
const parentDir = dirname6(currentDir);
|
|
7631
7675
|
if (parentDir === currentDir) break;
|
|
7632
7676
|
currentDir = parentDir;
|
|
7633
7677
|
}
|
|
@@ -7648,9 +7692,9 @@ function substituteTsconfigPathTarget(target, wildcardValue) {
|
|
|
7648
7692
|
return target.replace("*", wildcardValue);
|
|
7649
7693
|
}
|
|
7650
7694
|
function resolveTsconfigAliasImportFile(importerFile, specifier) {
|
|
7651
|
-
for (const configFile of findNearestProjectConfigFiles(
|
|
7695
|
+
for (const configFile of findNearestProjectConfigFiles(dirname6(importerFile))) {
|
|
7652
7696
|
const compilerOptions = loadTsConfigCompilerOptions(configFile);
|
|
7653
|
-
const configDir =
|
|
7697
|
+
const configDir = dirname6(configFile);
|
|
7654
7698
|
const baseDir = compilerOptions.baseUrl ? resolve12(configDir, compilerOptions.baseUrl) : configDir;
|
|
7655
7699
|
for (const [pattern, targets] of Object.entries(compilerOptions.paths ?? {})) {
|
|
7656
7700
|
const wildcardValue = matchTsconfigPathPattern(specifier, pattern);
|
|
@@ -7702,7 +7746,7 @@ function collectReachableSourceFiles(entryPoint) {
|
|
|
7702
7746
|
}
|
|
7703
7747
|
function resolveSourceEntrypoint(basePath) {
|
|
7704
7748
|
try {
|
|
7705
|
-
if (existsSync6(basePath) &&
|
|
7749
|
+
if (existsSync6(basePath) && statSync4(basePath).isFile() && /\.(?:[cm]?[jt]sx?)$/.test(basePath)) {
|
|
7706
7750
|
return basePath;
|
|
7707
7751
|
}
|
|
7708
7752
|
} catch {
|
|
@@ -7846,9 +7890,9 @@ function resolveSchemaAuthGeneratedTarget(schemaAuthPathAbs, source) {
|
|
|
7846
7890
|
/(?:export|import)\s+[^;\n]*\bfrom\s+["']([^"']*schema-auth\.gen(?:\.[cm]?[jt]sx?)?)["']/m
|
|
7847
7891
|
);
|
|
7848
7892
|
if (!match) {
|
|
7849
|
-
return resolve13(
|
|
7893
|
+
return resolve13(dirname7(schemaAuthPathAbs), "./generated/schema-auth.gen.ts");
|
|
7850
7894
|
}
|
|
7851
|
-
return resolve13(
|
|
7895
|
+
return resolve13(dirname7(schemaAuthPathAbs), match[1]);
|
|
7852
7896
|
}
|
|
7853
7897
|
function classifySchemaSourceKind(pathValue) {
|
|
7854
7898
|
const normalized = pathValue.replace(/\\/g, "/");
|
|
@@ -7884,14 +7928,14 @@ function dedupeOwners(owners) {
|
|
|
7884
7928
|
}
|
|
7885
7929
|
|
|
7886
7930
|
// ../shared/src/analyzer/adapters/app-project.ts
|
|
7887
|
-
import { existsSync as existsSync8, statSync as
|
|
7888
|
-
import { dirname as
|
|
7931
|
+
import { existsSync as existsSync8, statSync as statSync5 } from "fs";
|
|
7932
|
+
import { dirname as dirname8, isAbsolute as isAbsolute3, resolve as resolve14 } from "path";
|
|
7889
7933
|
function resolveAppProject(input2) {
|
|
7890
7934
|
const projectRootAbs = resolve14(input2.projectRoot);
|
|
7891
7935
|
const rootDir = input2.rootDir ?? input2.functionsDir ?? "gencow";
|
|
7892
7936
|
const functionsDirAbs = isAbsolute3(rootDir) ? rootDir : resolve14(projectRootAbs, rootDir);
|
|
7893
7937
|
const entryPointAbs = resolveSourceEntrypoint(functionsDirAbs);
|
|
7894
|
-
const sourceBaseAbs = isExistingDirectory(functionsDirAbs) ? functionsDirAbs :
|
|
7938
|
+
const sourceBaseAbs = isExistingDirectory(functionsDirAbs) ? functionsDirAbs : dirname8(entryPointAbs);
|
|
7895
7939
|
const sourceFilesAbs = existsSync8(entryPointAbs) ? collectReachableSourceFiles(entryPointAbs) : isExistingDirectory(functionsDirAbs) ? findSourceFiles(functionsDirAbs) : [];
|
|
7896
7940
|
const serverCodegenDirAbs = resolveServerCodegenDirAbs(
|
|
7897
7941
|
projectRootAbs,
|
|
@@ -7920,7 +7964,7 @@ function resolveAppProject(input2) {
|
|
|
7920
7964
|
}
|
|
7921
7965
|
function isExistingDirectory(pathValue) {
|
|
7922
7966
|
try {
|
|
7923
|
-
return
|
|
7967
|
+
return statSync5(pathValue).isDirectory();
|
|
7924
7968
|
} catch {
|
|
7925
7969
|
return false;
|
|
7926
7970
|
}
|
|
@@ -8402,7 +8446,7 @@ function createSourcePatternsPlugin() {
|
|
|
8402
8446
|
|
|
8403
8447
|
// ../shared/src/analyzer/consumers/auditor/source-auditor.ts
|
|
8404
8448
|
import { existsSync as existsSync9 } from "fs";
|
|
8405
|
-
import { basename as basename3, dirname as
|
|
8449
|
+
import { basename as basename3, dirname as dirname9, extname, resolve as resolve15 } from "path";
|
|
8406
8450
|
|
|
8407
8451
|
// ../shared/src/analyzer/consumers/auditor/source-auditor-shared.ts
|
|
8408
8452
|
import { readFileSync as readFileSync7 } from "fs";
|
|
@@ -8580,7 +8624,7 @@ function describeAnalyzerFunctionsLabel(entryPoint) {
|
|
|
8580
8624
|
const normalized = entryPoint.replace(/\\/g, "/");
|
|
8581
8625
|
const fileName = normalized.split("/").pop() ?? normalized;
|
|
8582
8626
|
if (/^index\.[cm]?[jt]sx?$/.test(fileName)) {
|
|
8583
|
-
return `${basename3(
|
|
8627
|
+
return `${basename3(dirname9(normalized))}/`;
|
|
8584
8628
|
}
|
|
8585
8629
|
return extname(fileName) ? fileName : `${fileName}/`;
|
|
8586
8630
|
}
|
|
@@ -9525,7 +9569,7 @@ function validateNonOverlappingReplaceEdits(source, edits) {
|
|
|
9525
9569
|
}
|
|
9526
9570
|
}
|
|
9527
9571
|
function ensureParentDir(pathValue) {
|
|
9528
|
-
mkdirSync3(
|
|
9572
|
+
mkdirSync3(dirname10(pathValue), { recursive: true });
|
|
9529
9573
|
}
|
|
9530
9574
|
function formatPatchTimestamp(now = /* @__PURE__ */ new Date()) {
|
|
9531
9575
|
return now.toISOString();
|