@gigadrive/network-config 4.3.5 → 4.3.7
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/dist/index.js +254 -173
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +216 -135
- package/dist/index.mjs.map +1 -1
- package/dist/nextjs-adapter.js +35 -0
- package/dist/nextjs-adapter.js.map +1 -1
- package/dist/nextjs-adapter.mjs +35 -0
- package/dist/nextjs-adapter.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/detection/detect-framework.ts
|
|
2
|
-
import { FileSystem as
|
|
3
|
-
import { Effect as
|
|
2
|
+
import { FileSystem as FileSystem8, Path as Path6 } from "@effect/platform";
|
|
3
|
+
import { Effect as Effect10 } from "effect";
|
|
4
4
|
|
|
5
5
|
// src/detection/detect-package-manager.ts
|
|
6
6
|
import { FileSystem, Path } from "@effect/platform";
|
|
@@ -49,6 +49,83 @@ var astro = {
|
|
|
49
49
|
})
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
// src/detection/frameworks/resolve-node-entrypoint.ts
|
|
53
|
+
import { FileSystem as FileSystem2, Path as Path2 } from "@effect/platform";
|
|
54
|
+
import { Effect as Effect2 } from "effect";
|
|
55
|
+
var SCRIPT_RUNNERS = /* @__PURE__ */ new Set(["node", "bun", "tsx", "ts-node"]);
|
|
56
|
+
var COMMON_ENTRYPOINT_CANDIDATES = [
|
|
57
|
+
"index.js",
|
|
58
|
+
"src/index.js",
|
|
59
|
+
"index.ts",
|
|
60
|
+
"src/index.ts",
|
|
61
|
+
"app.js",
|
|
62
|
+
"src/app.js",
|
|
63
|
+
"server.js",
|
|
64
|
+
"src/server.js",
|
|
65
|
+
"app.ts",
|
|
66
|
+
"src/app.ts",
|
|
67
|
+
"server.ts",
|
|
68
|
+
"src/server.ts"
|
|
69
|
+
];
|
|
70
|
+
var isRecord = (value) => typeof value === "object" && value !== null;
|
|
71
|
+
var parsePackageJson = (content) => {
|
|
72
|
+
try {
|
|
73
|
+
const parsed = JSON.parse(content);
|
|
74
|
+
if (!isRecord(parsed)) return void 0;
|
|
75
|
+
return parsed;
|
|
76
|
+
} catch {
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var normalizeEntrypointPath = (entrypoint) => {
|
|
81
|
+
const normalized = entrypoint.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
82
|
+
if (!normalized || normalized === "." || normalized.startsWith("/") || normalized.includes(":") || normalized.split("/").some((segment) => segment === "..")) {
|
|
83
|
+
return void 0;
|
|
84
|
+
}
|
|
85
|
+
return normalized;
|
|
86
|
+
};
|
|
87
|
+
var parseStartScript = (script) => {
|
|
88
|
+
const tokens = script.trim().split(/\s+/);
|
|
89
|
+
if (tokens.length < 2 || !SCRIPT_RUNNERS.has(tokens[0])) return void 0;
|
|
90
|
+
let index = 1;
|
|
91
|
+
if (tokens[0] === "bun" && tokens[index] === "run") index++;
|
|
92
|
+
while (index < tokens.length && tokens[index].startsWith("-")) index++;
|
|
93
|
+
return tokens[index];
|
|
94
|
+
};
|
|
95
|
+
var applyEntrypoint = (defaults, entrypoint) => ({
|
|
96
|
+
...defaults,
|
|
97
|
+
entrypoint,
|
|
98
|
+
routes: defaults.routes.map(
|
|
99
|
+
(route) => route.destination === defaults.entrypoint ? { ...route, destination: entrypoint } : route
|
|
100
|
+
)
|
|
101
|
+
});
|
|
102
|
+
var resolveNodeServerEntrypoint = (defaults, projectFolder) => Effect2.gen(function* () {
|
|
103
|
+
const fs = yield* FileSystem2.FileSystem;
|
|
104
|
+
const pathService = yield* Path2.Path;
|
|
105
|
+
const isFile = (relativePath) => fs.stat(pathService.join(projectFolder, relativePath)).pipe(
|
|
106
|
+
Effect2.map((info) => info.type === "File"),
|
|
107
|
+
Effect2.catchAll(() => Effect2.succeed(false))
|
|
108
|
+
);
|
|
109
|
+
const content = yield* fs.readFileString(pathService.join(projectFolder, "package.json")).pipe(Effect2.catchAll(() => Effect2.succeed(void 0)));
|
|
110
|
+
const manifest = content ? parsePackageJson(content) : void 0;
|
|
111
|
+
const startScript = typeof manifest?.scripts?.start === "string" ? manifest.scripts.start : void 0;
|
|
112
|
+
const candidates = [
|
|
113
|
+
typeof manifest?.main === "string" ? manifest.main : void 0,
|
|
114
|
+
startScript ? parseStartScript(startScript) : void 0,
|
|
115
|
+
defaults.entrypoint,
|
|
116
|
+
...COMMON_ENTRYPOINT_CANDIDATES
|
|
117
|
+
];
|
|
118
|
+
for (const candidate of candidates) {
|
|
119
|
+
if (!candidate) continue;
|
|
120
|
+
const normalized = normalizeEntrypointPath(candidate);
|
|
121
|
+
if (!normalized) continue;
|
|
122
|
+
if (yield* isFile(normalized)) {
|
|
123
|
+
return applyEntrypoint(defaults, normalized);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return defaults;
|
|
127
|
+
});
|
|
128
|
+
|
|
52
129
|
// src/detection/frameworks/elysia.ts
|
|
53
130
|
var elysia = {
|
|
54
131
|
slug: "elysia",
|
|
@@ -65,7 +142,8 @@ var elysia = {
|
|
|
65
142
|
entrypoint: "src/index.ts",
|
|
66
143
|
routes: [{ source: "/*", destination: "src/index.ts" }],
|
|
67
144
|
environmentVariables: { NODE_ENV: "production" }
|
|
68
|
-
})
|
|
145
|
+
}),
|
|
146
|
+
refineDefaultConfig: resolveNodeServerEntrypoint
|
|
69
147
|
};
|
|
70
148
|
|
|
71
149
|
// src/detection/frameworks/express.ts
|
|
@@ -84,7 +162,8 @@ var express = {
|
|
|
84
162
|
entrypoint: "index.js",
|
|
85
163
|
routes: [{ source: "/*", destination: "index.js" }],
|
|
86
164
|
environmentVariables: { NODE_ENV: "production" }
|
|
87
|
-
})
|
|
165
|
+
}),
|
|
166
|
+
refineDefaultConfig: resolveNodeServerEntrypoint
|
|
88
167
|
};
|
|
89
168
|
|
|
90
169
|
// src/detection/frameworks/fastify.ts
|
|
@@ -103,7 +182,8 @@ var fastify = {
|
|
|
103
182
|
entrypoint: "src/index.ts",
|
|
104
183
|
routes: [{ source: "/*", destination: "src/index.ts" }],
|
|
105
184
|
environmentVariables: { NODE_ENV: "production" }
|
|
106
|
-
})
|
|
185
|
+
}),
|
|
186
|
+
refineDefaultConfig: resolveNodeServerEntrypoint
|
|
107
187
|
};
|
|
108
188
|
|
|
109
189
|
// src/detection/frameworks/hono.ts
|
|
@@ -122,7 +202,8 @@ var hono = {
|
|
|
122
202
|
entrypoint: "src/index.ts",
|
|
123
203
|
routes: [{ source: "/*", destination: "src/index.ts" }],
|
|
124
204
|
environmentVariables: { NODE_ENV: "production" }
|
|
125
|
-
})
|
|
205
|
+
}),
|
|
206
|
+
refineDefaultConfig: resolveNodeServerEntrypoint
|
|
126
207
|
};
|
|
127
208
|
|
|
128
209
|
// src/detection/frameworks/laravel.ts
|
|
@@ -157,13 +238,13 @@ var laravel = {
|
|
|
157
238
|
};
|
|
158
239
|
|
|
159
240
|
// src/detection/frameworks/nestjs.ts
|
|
160
|
-
import { FileSystem as
|
|
161
|
-
import { Effect as
|
|
162
|
-
var
|
|
241
|
+
import { FileSystem as FileSystem3 } from "@effect/platform";
|
|
242
|
+
import { Effect as Effect3 } from "effect";
|
|
243
|
+
var isRecord2 = (value) => typeof value === "object" && value !== null;
|
|
163
244
|
var parseNestCliJson = (content) => {
|
|
164
245
|
try {
|
|
165
246
|
const parsed = JSON.parse(content);
|
|
166
|
-
if (!
|
|
247
|
+
if (!isRecord2(parsed)) return void 0;
|
|
167
248
|
return parsed;
|
|
168
249
|
} catch {
|
|
169
250
|
return void 0;
|
|
@@ -209,9 +290,9 @@ var nestjs = {
|
|
|
209
290
|
detectors: [{ matchPackage: "@nestjs/core" }],
|
|
210
291
|
priority: 90,
|
|
211
292
|
getDefaultConfig: () => createNestConfig("dist"),
|
|
212
|
-
refineDefaultConfig: (defaults, projectFolder) =>
|
|
213
|
-
const fs = yield*
|
|
214
|
-
const content = yield* fs.readFileString(`${projectFolder}/nest-cli.json`).pipe(
|
|
293
|
+
refineDefaultConfig: (defaults, projectFolder) => Effect3.gen(function* () {
|
|
294
|
+
const fs = yield* FileSystem3.FileSystem;
|
|
295
|
+
const content = yield* fs.readFileString(`${projectFolder}/nest-cli.json`).pipe(Effect3.catchAll(() => Effect3.succeed(void 0)));
|
|
215
296
|
if (!content) return defaults;
|
|
216
297
|
const nestConfig = parseNestCliJson(content);
|
|
217
298
|
const outputPath = nestConfig ? getProjectOutputPath(nestConfig) : void 0;
|
|
@@ -220,28 +301,28 @@ var nestjs = {
|
|
|
220
301
|
};
|
|
221
302
|
|
|
222
303
|
// src/detection/frameworks/nextjs.ts
|
|
223
|
-
import { FileSystem as
|
|
224
|
-
import { Effect as
|
|
304
|
+
import { FileSystem as FileSystem5, Path as Path4 } from "@effect/platform";
|
|
305
|
+
import { Effect as Effect5 } from "effect";
|
|
225
306
|
|
|
226
307
|
// src/build-output-v3/get-default-path-map.ts
|
|
227
|
-
import { FileSystem as
|
|
228
|
-
import { Effect as
|
|
229
|
-
var getDefaultPathMap =
|
|
230
|
-
const fs = yield*
|
|
231
|
-
const pathService = yield*
|
|
308
|
+
import { FileSystem as FileSystem4, Path as Path3 } from "@effect/platform";
|
|
309
|
+
import { Effect as Effect4 } from "effect";
|
|
310
|
+
var getDefaultPathMap = Effect4.fn("getDefaultPathMap")(function* (directory) {
|
|
311
|
+
const fs = yield* FileSystem4.FileSystem;
|
|
312
|
+
const pathService = yield* Path3.Path;
|
|
232
313
|
const result = {};
|
|
233
|
-
const exists = yield* fs.exists(directory).pipe(
|
|
314
|
+
const exists = yield* fs.exists(directory).pipe(Effect4.catchAll(() => Effect4.succeed(false)));
|
|
234
315
|
if (!exists) {
|
|
235
316
|
return result;
|
|
236
317
|
}
|
|
237
318
|
const MAX_DEPTH = 100;
|
|
238
|
-
const processDirectory = (currentPath, basePath = "", depth = 0) =>
|
|
319
|
+
const processDirectory = (currentPath, basePath = "", depth = 0) => Effect4.gen(function* () {
|
|
239
320
|
if (depth > MAX_DEPTH) return;
|
|
240
|
-
const entries = yield* fs.readDirectory(currentPath).pipe(
|
|
321
|
+
const entries = yield* fs.readDirectory(currentPath).pipe(Effect4.catchAll(() => Effect4.succeed([])));
|
|
241
322
|
for (const name of entries) {
|
|
242
323
|
const fullPath = pathService.join(currentPath, name);
|
|
243
324
|
const relativePath = basePath ? pathService.join(basePath, name) : name;
|
|
244
|
-
const stat = yield* fs.stat(fullPath).pipe(
|
|
325
|
+
const stat = yield* fs.stat(fullPath).pipe(Effect4.catchAll(() => Effect4.succeed(null)));
|
|
245
326
|
if (!stat) continue;
|
|
246
327
|
if (stat.type === "Directory") {
|
|
247
328
|
yield* processDirectory(fullPath, relativePath, depth + 1);
|
|
@@ -255,27 +336,27 @@ var getDefaultPathMap = Effect3.fn("getDefaultPathMap")(function* (directory) {
|
|
|
255
336
|
});
|
|
256
337
|
|
|
257
338
|
// src/nextjs-manifest.ts
|
|
258
|
-
var
|
|
339
|
+
var isRecord3 = (value) => typeof value === "object" && value !== null;
|
|
259
340
|
var isPortableRelativePath = (value, allowCurrentDirectory = false) => {
|
|
260
341
|
if (typeof value !== "string") return false;
|
|
261
342
|
const normalized = value.replaceAll("\\", "/").replace(/^\.\//, "").replace(/\/+$/, "");
|
|
262
343
|
return (allowCurrentDirectory || normalized !== "" && normalized !== ".") && !normalized.startsWith("/") && !/^[A-Za-z]:/.test(normalized) && !normalized.includes(":") && !normalized.split("/").some((segment) => segment === "..");
|
|
263
344
|
};
|
|
264
|
-
var isStringRecord = (value) =>
|
|
345
|
+
var isStringRecord = (value) => isRecord3(value) && Object.values(value).every((item) => typeof item === "string");
|
|
265
346
|
var isJsonValue = (value) => {
|
|
266
347
|
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
267
348
|
if (typeof value === "number") return Number.isFinite(value);
|
|
268
349
|
if (Array.isArray(value)) return value.every(isJsonValue);
|
|
269
|
-
return
|
|
350
|
+
return isRecord3(value) && Object.values(value).every(isJsonValue);
|
|
270
351
|
};
|
|
271
|
-
var isPrerenderOutput = (value) =>
|
|
272
|
-
var isStaticAssetPrefix = (value) =>
|
|
273
|
-
var isServerDescriptor = (value) =>
|
|
274
|
-
var isImagePolicy = (value) =>
|
|
352
|
+
var isPrerenderOutput = (value) => isRecord3(value) && value.type === "PRERENDER" && typeof value.id === "string" && typeof value.pathname === "string" && typeof value.parentOutputId === "string" && typeof value.groupId === "number" && isRecord3(value.config) && (value.fallback === void 0 || isRecord3(value.fallback) && (value.fallback.filePath === void 0 || isPortableRelativePath(value.fallback.filePath)));
|
|
353
|
+
var isStaticAssetPrefix = (value) => isRecord3(value) && isPortableRelativePath(value.sourceDir) && isPortableRelativePath(value.urlPrefix) && typeof value.immutable === "boolean";
|
|
354
|
+
var isServerDescriptor = (value) => isRecord3(value) && (value.maxDuration === void 0 || typeof value.maxDuration === "number") && (value.preferredRegion === void 0 || typeof value.preferredRegion === "string" || Array.isArray(value.preferredRegion) && value.preferredRegion.every((region) => typeof region === "string")) && (value.env === void 0 || isStringRecord(value.env));
|
|
355
|
+
var isImagePolicy = (value) => isRecord3(value) && Array.isArray(value.localPatterns) && Array.isArray(value.remotePatterns) && value.remotePatterns.every((pattern) => isRecord3(pattern) && typeof pattern.hostname === "string") && Array.isArray(value.widths) && value.widths.every((item) => typeof item === "number" && Number.isInteger(item) && item > 0) && Array.isArray(value.heights) && value.heights.every((item) => typeof item === "number" && Number.isInteger(item) && item > 0) && Array.isArray(value.qualities) && value.qualities.every((item) => typeof item === "number" && item >= 1 && item <= 100) && Array.isArray(value.formats) && value.formats.every((item) => ["image/avif", "image/webp", "image/jpeg", "image/png"].includes(String(item))) && typeof value.minimumCacheTTL === "number" && typeof value.dangerouslyAllowSVG === "boolean" && typeof value.contentSecurityPolicy === "string" && (value.contentDispositionType === "inline" || value.contentDispositionType === "attachment") && typeof value.maximumRedirects === "number" && typeof value.maximumResponseBody === "number" && isRecord3(value.variants);
|
|
275
356
|
var parseGigadriveNextBuildManifest = (content) => {
|
|
276
357
|
try {
|
|
277
358
|
const value = JSON.parse(content);
|
|
278
|
-
if (!
|
|
359
|
+
if (!isRecord3(value)) return void 0;
|
|
279
360
|
if (value.version === 1) {
|
|
280
361
|
if (value.output !== "standalone" && value.output !== "export" || !isPortableRelativePath(value.distDir) || !isPortableRelativePath(value.repoRootToProject, true) || typeof value.nextVersion !== "string" || typeof value.buildId !== "string") {
|
|
281
362
|
return void 0;
|
|
@@ -290,7 +371,7 @@ var parseGigadriveNextBuildManifest = (content) => {
|
|
|
290
371
|
return value;
|
|
291
372
|
}
|
|
292
373
|
if (value.mode === "standalone-v2") {
|
|
293
|
-
if (!isServerDescriptor(value.server) || !
|
|
374
|
+
if (!isServerDescriptor(value.server) || !isRecord3(value.config) || typeof value.config.basePath !== "string" || typeof value.config.trailingSlash !== "boolean" || typeof value.config.cacheComponents !== "boolean" || value.config.images !== void 0 && !isImagePolicy(value.config.images) || !isRecord3(value.routing) || !isJsonValue(value.routing) || !isRecord3(value.outputs) || !Array.isArray(value.outputs.prerenders) || !value.outputs.prerenders.every(isPrerenderOutput) || !Array.isArray(value.outputs.staticAssets) || !value.outputs.staticAssets.every(isStaticAssetPrefix)) {
|
|
294
375
|
return void 0;
|
|
295
376
|
}
|
|
296
377
|
return value;
|
|
@@ -329,22 +410,22 @@ var AVAILABLE_REGIONS = [...REGION_DEFINITIONS];
|
|
|
329
410
|
var toPortablePath = (value) => value.replaceAll("\\", "/");
|
|
330
411
|
var MAXIMUM_ENTRY_PAGE_PATHS = 50;
|
|
331
412
|
var STANDALONE_SERVER_MEMORY_MB = 1024;
|
|
332
|
-
var resolveStandaloneServer =
|
|
333
|
-
const fs = yield*
|
|
334
|
-
const pathService = yield*
|
|
413
|
+
var resolveStandaloneServer = Effect5.fn("nextjs.resolveStandaloneServer")(function* (projectFolder, distDir, repoRootToProject) {
|
|
414
|
+
const fs = yield* FileSystem5.FileSystem;
|
|
415
|
+
const pathService = yield* Path4.Path;
|
|
335
416
|
const standaloneRoot = pathService.join(projectFolder, distDir, "standalone");
|
|
336
417
|
const monorepoServer = pathService.join(standaloneRoot, repoRootToProject, "server.js");
|
|
337
418
|
const rootServer = pathService.join(standaloneRoot, "server.js");
|
|
338
|
-
const monorepoServerExists = yield* fs.exists(monorepoServer).pipe(
|
|
419
|
+
const monorepoServerExists = yield* fs.exists(monorepoServer).pipe(Effect5.catchAll(() => Effect5.succeed(false)));
|
|
339
420
|
const serverPath = monorepoServerExists ? monorepoServer : rootServer;
|
|
340
|
-
const serverExists = yield* fs.exists(serverPath).pipe(
|
|
421
|
+
const serverExists = yield* fs.exists(serverPath).pipe(Effect5.catchAll(() => Effect5.succeed(false)));
|
|
341
422
|
if (!serverExists) return void 0;
|
|
342
423
|
const serverDirectory = pathService.dirname(serverPath);
|
|
343
424
|
const entrypoint = toPortablePath(pathService.relative(standaloneRoot, serverPath));
|
|
344
425
|
return { standaloneRoot, serverDirectory, entrypoint };
|
|
345
426
|
});
|
|
346
|
-
var buildStandalonePublicAssets =
|
|
347
|
-
const pathService = yield*
|
|
427
|
+
var buildStandalonePublicAssets = Effect5.fn("nextjs.buildStandalonePublicAssets")(function* (projectFolder, standaloneRoot, serverDirectory) {
|
|
428
|
+
const pathService = yield* Path4.Path;
|
|
348
429
|
const publicFiles = yield* getDefaultPathMap(pathService.join(projectFolder, "public"));
|
|
349
430
|
const assetPaths = [];
|
|
350
431
|
const assetOverrides = {};
|
|
@@ -360,8 +441,8 @@ var buildStandalonePublicAssets = Effect4.fn("nextjs.buildStandalonePublicAssets
|
|
|
360
441
|
}
|
|
361
442
|
return { assetPaths, assetOverrides, filePathMap };
|
|
362
443
|
});
|
|
363
|
-
var createStaticExportConfig =
|
|
364
|
-
const pathService = yield*
|
|
444
|
+
var createStaticExportConfig = Effect5.fn("nextjs.createStaticExportConfig")(function* (defaults, projectFolder) {
|
|
445
|
+
const pathService = yield* Path4.Path;
|
|
365
446
|
const outputDirectory = pathService.join(projectFolder, "out");
|
|
366
447
|
const files = yield* getDefaultPathMap(outputDirectory);
|
|
367
448
|
const assetPaths = [];
|
|
@@ -384,8 +465,8 @@ var createStaticExportConfig = Effect4.fn("nextjs.createStaticExportConfig")(fun
|
|
|
384
465
|
package: void 0
|
|
385
466
|
};
|
|
386
467
|
});
|
|
387
|
-
var createStandaloneConfig =
|
|
388
|
-
const pathService = yield*
|
|
468
|
+
var createStandaloneConfig = Effect5.fn("nextjs.createStandaloneConfig")(function* (defaults, projectFolder, manifest) {
|
|
469
|
+
const pathService = yield* Path4.Path;
|
|
389
470
|
const resolved = yield* resolveStandaloneServer(projectFolder, manifest.distDir, manifest.repoRootToProject);
|
|
390
471
|
if (!resolved) return defaults;
|
|
391
472
|
const { standaloneRoot, serverDirectory, entrypoint } = resolved;
|
|
@@ -418,7 +499,7 @@ var createStandaloneConfig = Effect4.fn("nextjs.createStandaloneConfig")(functio
|
|
|
418
499
|
}
|
|
419
500
|
};
|
|
420
501
|
});
|
|
421
|
-
var createStandaloneV2Config =
|
|
502
|
+
var createStandaloneV2Config = Effect5.fn("nextjs.createStandaloneV2Config")(function* (defaults, projectFolder, manifest) {
|
|
422
503
|
const resolved = yield* resolveStandaloneServer(projectFolder, manifest.distDir, manifest.repoRootToProject);
|
|
423
504
|
if (!resolved) return defaults;
|
|
424
505
|
const { standaloneRoot, serverDirectory, entrypoint } = resolved;
|
|
@@ -519,9 +600,9 @@ var nextjs = {
|
|
|
519
600
|
routes: [{ source: "/*", destination: ".next/standalone/server.js" }],
|
|
520
601
|
environmentVariables: { NODE_ENV: "production" }
|
|
521
602
|
}),
|
|
522
|
-
refineDefaultConfig: (defaults, projectFolder) =>
|
|
523
|
-
const fs = yield*
|
|
524
|
-
const manifestContent = yield* fs.readFileString(`${projectFolder}/.gigadrive/nextjs.json`).pipe(
|
|
603
|
+
refineDefaultConfig: (defaults, projectFolder) => Effect5.gen(function* () {
|
|
604
|
+
const fs = yield* FileSystem5.FileSystem;
|
|
605
|
+
const manifestContent = yield* fs.readFileString(`${projectFolder}/.gigadrive/nextjs.json`).pipe(Effect5.catchAll(() => Effect5.succeed(void 0)));
|
|
525
606
|
const manifest = manifestContent ? parseGigadriveNextBuildManifest(manifestContent) : void 0;
|
|
526
607
|
if (!manifest) return defaults;
|
|
527
608
|
if (manifest.version === 2) {
|
|
@@ -532,8 +613,8 @@ var nextjs = {
|
|
|
532
613
|
};
|
|
533
614
|
|
|
534
615
|
// src/detection/frameworks/nuxt.ts
|
|
535
|
-
import { FileSystem as
|
|
536
|
-
import { Effect as
|
|
616
|
+
import { FileSystem as FileSystem6 } from "@effect/platform";
|
|
617
|
+
import { Effect as Effect6 } from "effect";
|
|
537
618
|
var isVercelBuildOutputV3 = (content) => {
|
|
538
619
|
try {
|
|
539
620
|
const config = JSON.parse(content);
|
|
@@ -560,9 +641,9 @@ var nuxt = {
|
|
|
560
641
|
routes: [{ source: "/*", destination: ".output/server/index.mjs" }],
|
|
561
642
|
environmentVariables: { NODE_ENV: "production", NITRO_PRESET: "node-server" }
|
|
562
643
|
}),
|
|
563
|
-
refineDefaultConfig: (defaults, projectFolder) =>
|
|
564
|
-
const fs = yield*
|
|
565
|
-
const buildOutputConfig = yield* fs.readFileString(`${projectFolder}/.vercel/output/config.json`).pipe(
|
|
644
|
+
refineDefaultConfig: (defaults, projectFolder) => Effect6.gen(function* () {
|
|
645
|
+
const fs = yield* FileSystem6.FileSystem;
|
|
646
|
+
const buildOutputConfig = yield* fs.readFileString(`${projectFolder}/.vercel/output/config.json`).pipe(Effect6.catchAll(() => Effect6.succeed(void 0)));
|
|
566
647
|
if (!buildOutputConfig || !isVercelBuildOutputV3(buildOutputConfig)) {
|
|
567
648
|
return defaults;
|
|
568
649
|
}
|
|
@@ -685,7 +766,7 @@ var FRAMEWORK_DEFINITIONS = [
|
|
|
685
766
|
].sort((a, b) => b.priority - a.priority);
|
|
686
767
|
|
|
687
768
|
// src/detection/generate-config.ts
|
|
688
|
-
import { Effect as
|
|
769
|
+
import { Effect as Effect7 } from "effect";
|
|
689
770
|
var getInstallCommand = (pm) => {
|
|
690
771
|
switch (pm) {
|
|
691
772
|
case "bun":
|
|
@@ -701,11 +782,11 @@ var getInstallCommand = (pm) => {
|
|
|
701
782
|
return "npm install";
|
|
702
783
|
}
|
|
703
784
|
};
|
|
704
|
-
var generateConfig =
|
|
785
|
+
var generateConfig = Effect7.fn("generateConfig")(function* (framework, packageManager, refinedDefaults) {
|
|
705
786
|
const defaults = refinedDefaults ?? framework.getDefaultConfig(packageManager);
|
|
706
787
|
const installCmd = defaults.installCommand ?? getInstallCommand(packageManager);
|
|
707
788
|
const commands = [installCmd, ...defaults.commands];
|
|
708
|
-
yield*
|
|
789
|
+
yield* Effect7.logDebug(`Generating config for ${framework.name}`, {
|
|
709
790
|
runtime: defaults.runtime,
|
|
710
791
|
entrypoint: defaults.entrypoint,
|
|
711
792
|
commands
|
|
@@ -753,8 +834,8 @@ var generateConfig = Effect6.fn("generateConfig")(function* (framework, packageM
|
|
|
753
834
|
});
|
|
754
835
|
|
|
755
836
|
// src/detection/read-dependencies.ts
|
|
756
|
-
import { FileSystem as
|
|
757
|
-
import { Effect as
|
|
837
|
+
import { FileSystem as FileSystem7, Path as Path5 } from "@effect/platform";
|
|
838
|
+
import { Effect as Effect9 } from "effect";
|
|
758
839
|
|
|
759
840
|
// src/detection/types.ts
|
|
760
841
|
import { Schema } from "effect";
|
|
@@ -787,25 +868,25 @@ var MANIFEST_CONFIG = {
|
|
|
787
868
|
node: { file: "package.json", depKeys: ["dependencies", "devDependencies"] },
|
|
788
869
|
php: { file: "composer.json", depKeys: ["require", "require-dev"] }
|
|
789
870
|
};
|
|
790
|
-
var readManifest =
|
|
791
|
-
const fs = yield*
|
|
792
|
-
const exists = yield* fs.exists(filePath).pipe(
|
|
871
|
+
var readManifest = Effect9.fn("readManifest")(function* (filePath) {
|
|
872
|
+
const fs = yield* FileSystem7.FileSystem;
|
|
873
|
+
const exists = yield* fs.exists(filePath).pipe(Effect9.catchAll(() => Effect9.succeed(false)));
|
|
793
874
|
if (!exists) {
|
|
794
|
-
return yield*
|
|
875
|
+
return yield* Effect9.fail(new ManifestNotFoundError({ message: "Manifest not found", filePath }));
|
|
795
876
|
}
|
|
796
|
-
const content = yield* fs.readFileString(filePath).pipe(
|
|
797
|
-
const parsed = yield*
|
|
877
|
+
const content = yield* fs.readFileString(filePath).pipe(Effect9.mapError(() => new ManifestReadError({ message: "Failed to read manifest", filePath })));
|
|
878
|
+
const parsed = yield* Effect9.try({
|
|
798
879
|
try: () => JSON.parse(content),
|
|
799
880
|
catch: () => new ManifestParseError({ message: "Failed to parse manifest JSON", filePath })
|
|
800
881
|
});
|
|
801
882
|
return parsed;
|
|
802
883
|
});
|
|
803
|
-
var readDependencies =
|
|
804
|
-
const pathService = yield*
|
|
884
|
+
var readDependencies = Effect9.fn("readDependencies")(function* (projectFolder, language) {
|
|
885
|
+
const pathService = yield* Path5.Path;
|
|
805
886
|
const config = MANIFEST_CONFIG[language];
|
|
806
887
|
const filePath = pathService.join(projectFolder, config.file);
|
|
807
888
|
const manifest = yield* readManifest(filePath).pipe(
|
|
808
|
-
|
|
889
|
+
Effect9.catchTag("ManifestNotFoundError", () => Effect9.succeed(null))
|
|
809
890
|
);
|
|
810
891
|
if (!manifest) {
|
|
811
892
|
return /* @__PURE__ */ new Set();
|
|
@@ -823,9 +904,9 @@ var readDependencies = Effect8.fn("readDependencies")(function* (projectFolder,
|
|
|
823
904
|
});
|
|
824
905
|
|
|
825
906
|
// src/detection/detect-framework.ts
|
|
826
|
-
var matchesDetectionItem =
|
|
827
|
-
const fs = yield*
|
|
828
|
-
const pathService = yield*
|
|
907
|
+
var matchesDetectionItem = Effect10.fn("matchesDetectionItem")(function* (item, projectFolder, framework, cachedReadDeps) {
|
|
908
|
+
const fs = yield* FileSystem8.FileSystem;
|
|
909
|
+
const pathService = yield* Path6.Path;
|
|
829
910
|
if (item.matchPackage != null) {
|
|
830
911
|
const deps = yield* cachedReadDeps(`${projectFolder}\0${framework.language}`);
|
|
831
912
|
if (!deps.has(item.matchPackage)) {
|
|
@@ -834,12 +915,12 @@ var matchesDetectionItem = Effect9.fn("matchesDetectionItem")(function* (item, p
|
|
|
834
915
|
}
|
|
835
916
|
if (item.path != null) {
|
|
836
917
|
const filePath = pathService.join(projectFolder, item.path);
|
|
837
|
-
const exists = yield* fs.exists(filePath).pipe(
|
|
918
|
+
const exists = yield* fs.exists(filePath).pipe(Effect10.catchAll(() => Effect10.succeed(false)));
|
|
838
919
|
if (!exists) {
|
|
839
920
|
return false;
|
|
840
921
|
}
|
|
841
922
|
if (item.matchContent != null) {
|
|
842
|
-
const content = yield* fs.readFileString(filePath).pipe(
|
|
923
|
+
const content = yield* fs.readFileString(filePath).pipe(Effect10.catchAll(() => Effect10.succeed("")));
|
|
843
924
|
let regexMatch = false;
|
|
844
925
|
try {
|
|
845
926
|
regexMatch = new RegExp(item.matchContent).test(content);
|
|
@@ -852,7 +933,7 @@ var matchesDetectionItem = Effect9.fn("matchesDetectionItem")(function* (item, p
|
|
|
852
933
|
}
|
|
853
934
|
return true;
|
|
854
935
|
});
|
|
855
|
-
var matchesFramework =
|
|
936
|
+
var matchesFramework = Effect10.fn("matchesFramework")(function* (framework, projectFolder, cachedReadDeps) {
|
|
856
937
|
for (const detector of framework.detectors) {
|
|
857
938
|
const matches = yield* matchesDetectionItem(detector, projectFolder, framework, cachedReadDeps);
|
|
858
939
|
if (!matches) {
|
|
@@ -861,9 +942,9 @@ var matchesFramework = Effect9.fn("matchesFramework")(function* (framework, proj
|
|
|
861
942
|
}
|
|
862
943
|
return true;
|
|
863
944
|
});
|
|
864
|
-
var detectFramework =
|
|
865
|
-
yield*
|
|
866
|
-
const cachedReadDeps = yield*
|
|
945
|
+
var detectFramework = Effect10.fn("detectFramework")(function* (projectFolder) {
|
|
946
|
+
yield* Effect10.logDebug(`Detecting framework in ${projectFolder}`);
|
|
947
|
+
const cachedReadDeps = yield* Effect10.cachedFunction((key) => {
|
|
867
948
|
const sepIndex = key.lastIndexOf("\0");
|
|
868
949
|
const folder = key.slice(0, sepIndex);
|
|
869
950
|
const language = key.slice(sepIndex + 1);
|
|
@@ -872,7 +953,7 @@ var detectFramework = Effect9.fn("detectFramework")(function* (projectFolder) {
|
|
|
872
953
|
for (const framework of FRAMEWORK_DEFINITIONS) {
|
|
873
954
|
const matches = yield* matchesFramework(framework, projectFolder, cachedReadDeps);
|
|
874
955
|
if (matches) {
|
|
875
|
-
yield*
|
|
956
|
+
yield* Effect10.log(`Detected framework: ${framework.name}`, { slug: framework.slug });
|
|
876
957
|
const detectedPackageManager = yield* detectPackageManager(projectFolder);
|
|
877
958
|
const packageManager = framework.language === "php" ? "composer" : detectedPackageManager;
|
|
878
959
|
const defaults = framework.getDefaultConfig(packageManager);
|
|
@@ -881,7 +962,7 @@ var detectFramework = Effect9.fn("detectFramework")(function* (projectFolder) {
|
|
|
881
962
|
return { framework, packageManager, config };
|
|
882
963
|
}
|
|
883
964
|
}
|
|
884
|
-
return yield*
|
|
965
|
+
return yield* Effect10.fail(
|
|
885
966
|
new FrameworkNotDetectedError({
|
|
886
967
|
message: `No framework detected in project directory`,
|
|
887
968
|
directory: projectFolder
|
|
@@ -890,9 +971,9 @@ var detectFramework = Effect9.fn("detectFramework")(function* (projectFolder) {
|
|
|
890
971
|
});
|
|
891
972
|
|
|
892
973
|
// src/detection/merge-config.ts
|
|
893
|
-
import { Effect as
|
|
894
|
-
var mergeWithFrameworkDefaults =
|
|
895
|
-
yield*
|
|
974
|
+
import { Effect as Effect11 } from "effect";
|
|
975
|
+
var mergeWithFrameworkDefaults = Effect11.fn("mergeWithFrameworkDefaults")(function* (userConfig, frameworkConfig) {
|
|
976
|
+
yield* Effect11.logDebug("Merging user config with framework defaults");
|
|
896
977
|
const merged = {
|
|
897
978
|
regions: userConfig.regions,
|
|
898
979
|
commands: userConfig.commands.length > 0 ? userConfig.commands : frameworkConfig.commands,
|
|
@@ -967,11 +1048,11 @@ var DEFAULT_FUNCTION_DURATION_SECONDS = 30;
|
|
|
967
1048
|
var MAX_FUNCTION_DURATION_SECONDS = 28800;
|
|
968
1049
|
|
|
969
1050
|
// src/parse-config.ts
|
|
970
|
-
import { Effect as
|
|
1051
|
+
import { Effect as Effect16 } from "effect";
|
|
971
1052
|
|
|
972
1053
|
// src/services/raw-config-reader.ts
|
|
973
|
-
import { FileSystem as
|
|
974
|
-
import { Effect as
|
|
1054
|
+
import { FileSystem as FileSystem9, Path as Path7 } from "@effect/platform";
|
|
1055
|
+
import { Effect as Effect12 } from "effect";
|
|
975
1056
|
import { parse as parseYaml } from "yaml";
|
|
976
1057
|
var ALLOWED_CONFIG_NAMES = [
|
|
977
1058
|
"gigadrive.yaml",
|
|
@@ -980,34 +1061,34 @@ var ALLOWED_CONFIG_NAMES = [
|
|
|
980
1061
|
"nebula.yml",
|
|
981
1062
|
"nebula.json"
|
|
982
1063
|
];
|
|
983
|
-
var RawConfigReader = class extends
|
|
984
|
-
effect:
|
|
985
|
-
const fs = yield*
|
|
986
|
-
const pathService = yield*
|
|
987
|
-
const findConfig =
|
|
1064
|
+
var RawConfigReader = class extends Effect12.Service()("RawConfigReader", {
|
|
1065
|
+
effect: Effect12.gen(function* () {
|
|
1066
|
+
const fs = yield* FileSystem9.FileSystem;
|
|
1067
|
+
const pathService = yield* Path7.Path;
|
|
1068
|
+
const findConfig = Effect12.fn("RawConfigReader.findConfig")(function* (projectFolder) {
|
|
988
1069
|
for (const name of ALLOWED_CONFIG_NAMES) {
|
|
989
1070
|
const filePath = pathService.join(projectFolder, name);
|
|
990
|
-
const exists = yield* fs.exists(filePath).pipe(
|
|
1071
|
+
const exists = yield* fs.exists(filePath).pipe(Effect12.catchAll(() => Effect12.succeed(false)));
|
|
991
1072
|
if (exists) {
|
|
992
1073
|
return filePath;
|
|
993
1074
|
}
|
|
994
1075
|
}
|
|
995
1076
|
return null;
|
|
996
1077
|
});
|
|
997
|
-
const readRawConfig =
|
|
998
|
-
const exists = yield* fs.exists(filePath).pipe(
|
|
1078
|
+
const readRawConfig = Effect12.fn("RawConfigReader.readRawConfig")(function* (filePath, options) {
|
|
1079
|
+
const exists = yield* fs.exists(filePath).pipe(Effect12.catchAll(() => Effect12.succeed(false)));
|
|
999
1080
|
if (!exists) {
|
|
1000
|
-
return yield*
|
|
1081
|
+
return yield* Effect12.fail(
|
|
1001
1082
|
new ConfigFileNotFoundError({ message: `Config file not found at ${filePath}`, filePath })
|
|
1002
1083
|
);
|
|
1003
1084
|
}
|
|
1004
1085
|
const fileContents = yield* fs.readFileString(filePath).pipe(
|
|
1005
|
-
|
|
1086
|
+
Effect12.mapError(
|
|
1006
1087
|
() => new ConfigFileParseError({ message: `Failed to read config file at ${filePath}`, filePath })
|
|
1007
1088
|
)
|
|
1008
1089
|
);
|
|
1009
1090
|
if (fileContents.length === 0) {
|
|
1010
|
-
return yield*
|
|
1091
|
+
return yield* Effect12.fail(
|
|
1011
1092
|
new ConfigFileEmptyError({ message: `Config file is empty at ${filePath}`, filePath })
|
|
1012
1093
|
);
|
|
1013
1094
|
}
|
|
@@ -1022,7 +1103,7 @@ var RawConfigReader = class extends Effect11.Service()("RawConfigReader", {
|
|
|
1022
1103
|
parsed = parseYaml(fileContents);
|
|
1023
1104
|
}
|
|
1024
1105
|
} catch (error) {
|
|
1025
|
-
return yield*
|
|
1106
|
+
return yield* Effect12.fail(
|
|
1026
1107
|
new ConfigFileParseError({
|
|
1027
1108
|
message: `Failed to parse config file at ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
1028
1109
|
filePath,
|
|
@@ -1031,21 +1112,21 @@ var RawConfigReader = class extends Effect11.Service()("RawConfigReader", {
|
|
|
1031
1112
|
);
|
|
1032
1113
|
}
|
|
1033
1114
|
if (parsed == null) {
|
|
1034
|
-
return yield*
|
|
1115
|
+
return yield* Effect12.fail(
|
|
1035
1116
|
new ConfigFileParseError({ message: `Config file could not be parsed at ${filePath}`, filePath })
|
|
1036
1117
|
);
|
|
1037
1118
|
}
|
|
1038
1119
|
if (!options?.disableVersionCheck && typeof parsed.version !== "number") {
|
|
1039
|
-
return yield*
|
|
1120
|
+
return yield* Effect12.fail(
|
|
1040
1121
|
new ConfigVersionError({ message: `Config file is missing version at ${filePath}`, filePath })
|
|
1041
1122
|
);
|
|
1042
1123
|
}
|
|
1043
1124
|
return parsed;
|
|
1044
1125
|
});
|
|
1045
1126
|
const readConfigFile = (configFilePath) => readRawConfig(configFilePath, { disableVersionCheck: true }).pipe(
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1127
|
+
Effect12.map((parsed) => parsed),
|
|
1128
|
+
Effect12.catchTag("ConfigFileNotFoundError", () => Effect12.succeed(null)),
|
|
1129
|
+
Effect12.withSpan("RawConfigReader.readConfigFile")
|
|
1049
1130
|
);
|
|
1050
1131
|
return { findConfig, readRawConfig, readConfigFile };
|
|
1051
1132
|
})
|
|
@@ -1055,17 +1136,17 @@ var RawConfigReader = class extends Effect11.Service()("RawConfigReader", {
|
|
|
1055
1136
|
// src/services/schema-validator.ts
|
|
1056
1137
|
import Ajv from "ajv";
|
|
1057
1138
|
import addFormats from "ajv-formats";
|
|
1058
|
-
import { Effect as
|
|
1059
|
-
var SchemaValidator = class extends
|
|
1060
|
-
effect:
|
|
1139
|
+
import { Effect as Effect13 } from "effect";
|
|
1140
|
+
var SchemaValidator = class extends Effect13.Service()("SchemaValidator", {
|
|
1141
|
+
effect: Effect13.gen(function* () {
|
|
1061
1142
|
const ajv = new Ajv();
|
|
1062
1143
|
addFormats(ajv);
|
|
1063
|
-
const validate =
|
|
1144
|
+
const validate = Effect13.fn("SchemaValidator.validate")(function* (config, schema, filePath) {
|
|
1064
1145
|
const compiledValidate = ajv.compile(schema);
|
|
1065
1146
|
const valid = compiledValidate(config);
|
|
1066
1147
|
if (!valid) {
|
|
1067
1148
|
const errors = compiledValidate.errors?.map((e) => `${e.instancePath || "/"} ${e.message ?? ""}`.trim()) ?? [];
|
|
1068
|
-
return yield*
|
|
1149
|
+
return yield* Effect13.fail(
|
|
1069
1150
|
new ConfigSchemaValidationError({
|
|
1070
1151
|
message: `Config file at ${filePath} is invalid: ${ajv.errorsText(compiledValidate.errors)}`,
|
|
1071
1152
|
filePath,
|
|
@@ -1080,9 +1161,9 @@ var SchemaValidator = class extends Effect12.Service()("SchemaValidator", {
|
|
|
1080
1161
|
};
|
|
1081
1162
|
|
|
1082
1163
|
// src/services/v4-config-parser.ts
|
|
1083
|
-
import { FileSystem as
|
|
1164
|
+
import { FileSystem as FileSystem10, Path as Path8 } from "@effect/platform";
|
|
1084
1165
|
import { getFilesForPattern } from "@gigadrive/build-utils";
|
|
1085
|
-
import { Effect as
|
|
1166
|
+
import { Effect as Effect14 } from "effect";
|
|
1086
1167
|
import { minimatch } from "minimatch";
|
|
1087
1168
|
import safeRegex from "safe-regex2";
|
|
1088
1169
|
var MAX_ASSET_DEPTH = 100;
|
|
@@ -1171,7 +1252,7 @@ var mapRoute = (route, entrypoints) => ({
|
|
|
1171
1252
|
negativeRequirements: route.missing,
|
|
1172
1253
|
status: route.statusCode
|
|
1173
1254
|
});
|
|
1174
|
-
var parseEntrypoints =
|
|
1255
|
+
var parseEntrypoints = Effect14.fn("parseEntrypoints")(function* (config, projectFolder) {
|
|
1175
1256
|
const entrypoints = [];
|
|
1176
1257
|
if (config.functions == null) return entrypoints;
|
|
1177
1258
|
for (const [fnPath, func] of Object.entries(config.functions)) {
|
|
@@ -1181,7 +1262,7 @@ var parseEntrypoints = Effect13.fn("parseEntrypoints")(function* (config, projec
|
|
|
1181
1262
|
functionPath: fnPath
|
|
1182
1263
|
});
|
|
1183
1264
|
}
|
|
1184
|
-
const matchedFiles = yield*
|
|
1265
|
+
const matchedFiles = yield* Effect14.tryPromise({
|
|
1185
1266
|
try: () => getFilesForPattern(fnPath, projectFolder, func.excludeFiles),
|
|
1186
1267
|
catch: (error) => new FunctionConfigError({
|
|
1187
1268
|
message: `Failed to resolve files for function pattern '${fnPath}': ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1217,14 +1298,14 @@ var parseEntrypoints = Effect13.fn("parseEntrypoints")(function* (config, projec
|
|
|
1217
1298
|
}
|
|
1218
1299
|
return entrypoints;
|
|
1219
1300
|
});
|
|
1220
|
-
var collectAssets =
|
|
1301
|
+
var collectAssets = Effect14.fn("collectAssets")(function* (config, projectFolder) {
|
|
1221
1302
|
if (config.assets == null) return [];
|
|
1222
|
-
const fs = yield*
|
|
1223
|
-
const pathService = yield*
|
|
1303
|
+
const fs = yield* FileSystem10.FileSystem;
|
|
1304
|
+
const pathService = yield* Path8.Path;
|
|
1224
1305
|
const assetsPath = pathService.join(projectFolder, config.assets);
|
|
1225
|
-
const assetsExist = yield* fs.exists(assetsPath).pipe(
|
|
1306
|
+
const assetsExist = yield* fs.exists(assetsPath).pipe(Effect14.catchAll(() => Effect14.succeed(false)));
|
|
1226
1307
|
if (!assetsExist) return [];
|
|
1227
|
-
const stat = yield* fs.stat(assetsPath).pipe(
|
|
1308
|
+
const stat = yield* fs.stat(assetsPath).pipe(Effect14.catchAll(() => Effect14.succeed(null)));
|
|
1228
1309
|
if (!stat || stat.type !== "Directory") return [];
|
|
1229
1310
|
const allFiles = yield* collectFilesRecursively(assetsPath);
|
|
1230
1311
|
const assets = [];
|
|
@@ -1235,18 +1316,18 @@ var collectAssets = Effect13.fn("collectAssets")(function* (config, projectFolde
|
|
|
1235
1316
|
}
|
|
1236
1317
|
return assets;
|
|
1237
1318
|
});
|
|
1238
|
-
var collectFilesRecursively =
|
|
1319
|
+
var collectFilesRecursively = Effect14.fn("collectFilesRecursively")(
|
|
1239
1320
|
function* (basePath, relativePath = "", depth = 0) {
|
|
1240
1321
|
if (depth > MAX_ASSET_DEPTH) return [];
|
|
1241
|
-
const fs = yield*
|
|
1242
|
-
const pathSvc = yield*
|
|
1322
|
+
const fs = yield* FileSystem10.FileSystem;
|
|
1323
|
+
const pathSvc = yield* Path8.Path;
|
|
1243
1324
|
const currentPath = relativePath ? pathSvc.join(basePath, relativePath) : basePath;
|
|
1244
|
-
const entries = yield* fs.readDirectory(currentPath).pipe(
|
|
1325
|
+
const entries = yield* fs.readDirectory(currentPath).pipe(Effect14.catchAll(() => Effect14.succeed([])));
|
|
1245
1326
|
const result = [];
|
|
1246
1327
|
for (const name of entries) {
|
|
1247
1328
|
const fullPath = pathSvc.join(currentPath, name);
|
|
1248
1329
|
const entryRelative = relativePath ? pathSvc.join(relativePath, name) : name;
|
|
1249
|
-
const stat = yield* fs.stat(fullPath).pipe(
|
|
1330
|
+
const stat = yield* fs.stat(fullPath).pipe(Effect14.catchAll(() => Effect14.succeed(null)));
|
|
1250
1331
|
if (!stat) continue;
|
|
1251
1332
|
if (stat.type === "Directory") {
|
|
1252
1333
|
const nested = yield* collectFilesRecursively(basePath, entryRelative, depth + 1);
|
|
@@ -1258,16 +1339,16 @@ var collectFilesRecursively = Effect13.fn("collectFilesRecursively")(
|
|
|
1258
1339
|
return result;
|
|
1259
1340
|
}
|
|
1260
1341
|
);
|
|
1261
|
-
var V4ConfigParser = class extends
|
|
1342
|
+
var V4ConfigParser = class extends Effect14.Service()("V4ConfigParser", {
|
|
1262
1343
|
accessors: true,
|
|
1263
|
-
effect:
|
|
1344
|
+
effect: Effect14.succeed({
|
|
1264
1345
|
/**
|
|
1265
1346
|
* Parses a ConfigV4 into a NormalizedConfig.
|
|
1266
1347
|
*
|
|
1267
1348
|
* @param config - The raw V4 config object
|
|
1268
1349
|
* @param projectFolder - Absolute path to the project root
|
|
1269
1350
|
*/
|
|
1270
|
-
parse:
|
|
1351
|
+
parse: Effect14.fn("V4ConfigParser.parse")(function* (config, projectFolder) {
|
|
1271
1352
|
const entrypoints = yield* parseEntrypoints(config, projectFolder);
|
|
1272
1353
|
const assets = yield* collectAssets(config, projectFolder);
|
|
1273
1354
|
return {
|
|
@@ -1292,10 +1373,10 @@ var V4ConfigParser = class extends Effect13.Service()("V4ConfigParser", {
|
|
|
1292
1373
|
};
|
|
1293
1374
|
|
|
1294
1375
|
// src/services/vercel-build-output-parser.ts
|
|
1295
|
-
import { Path as
|
|
1376
|
+
import { Path as Path9 } from "@effect/platform";
|
|
1296
1377
|
import { getFilesForPattern as getFilesForPattern2 } from "@gigadrive/build-utils";
|
|
1297
1378
|
import { deepMerge } from "@gigadrive/commons";
|
|
1298
|
-
import { Effect as
|
|
1379
|
+
import { Effect as Effect15 } from "effect";
|
|
1299
1380
|
|
|
1300
1381
|
// src/build-output-v3/determine-repo-root.ts
|
|
1301
1382
|
import path from "path";
|
|
@@ -1391,11 +1472,11 @@ var translateVercelRuntime = (runtime) => {
|
|
|
1391
1472
|
var CONFIG_PATH = ".vercel/output/config.json";
|
|
1392
1473
|
var FUNCTIONS_FOLDER = ".vercel/output/functions";
|
|
1393
1474
|
var FUNCTION_CONFIGS_PATTERN = `${FUNCTIONS_FOLDER}/**/*.func/.vc-config.json`;
|
|
1394
|
-
var VercelBuildOutputParser = class extends
|
|
1395
|
-
effect:
|
|
1475
|
+
var VercelBuildOutputParser = class extends Effect15.Service()("VercelBuildOutputParser", {
|
|
1476
|
+
effect: Effect15.gen(function* () {
|
|
1396
1477
|
const rawConfigReader = yield* RawConfigReader;
|
|
1397
|
-
const pathService = yield*
|
|
1398
|
-
const parse =
|
|
1478
|
+
const pathService = yield* Path9.Path;
|
|
1479
|
+
const parse = Effect15.fn("VercelBuildOutputParser.parse")(function* (parseResult, projectFolder) {
|
|
1399
1480
|
const config = yield* rawConfigReader.readConfigFile(pathService.join(projectFolder, CONFIG_PATH));
|
|
1400
1481
|
if (!config || typeof config.version !== "number" || config.version < 3) {
|
|
1401
1482
|
return parseResult;
|
|
@@ -1407,8 +1488,8 @@ var VercelBuildOutputParser = class extends Effect14.Service()("VercelBuildOutpu
|
|
|
1407
1488
|
merged.regions = [...new Set(merged.regions)];
|
|
1408
1489
|
return merged;
|
|
1409
1490
|
});
|
|
1410
|
-
const loadFunctions =
|
|
1411
|
-
const functionConfigs = yield*
|
|
1491
|
+
const loadFunctions = Effect15.fn("VercelBuildOutputParser.loadFunctions")(function* (config, parseResult, projectFolder) {
|
|
1492
|
+
const functionConfigs = yield* Effect15.tryPromise({
|
|
1412
1493
|
try: () => getFilesForPattern2(FUNCTION_CONFIGS_PATTERN, projectFolder),
|
|
1413
1494
|
catch: (error) => new ConfigFileParseError({
|
|
1414
1495
|
message: `Failed to scan for function configs: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1973,7 +2054,7 @@ var schema_default = {
|
|
|
1973
2054
|
};
|
|
1974
2055
|
|
|
1975
2056
|
// src/parse-config.ts
|
|
1976
|
-
var parseConfigRaw =
|
|
2057
|
+
var parseConfigRaw = Effect16.fn("parseConfigRaw")(function* (filePath, projectFolder) {
|
|
1977
2058
|
const rawReader = yield* RawConfigReader;
|
|
1978
2059
|
const validator = yield* SchemaValidator;
|
|
1979
2060
|
const v4Parser = yield* V4ConfigParser;
|
|
@@ -1984,7 +2065,7 @@ var parseConfigRaw = Effect15.fn("parseConfigRaw")(function* (filePath, projectF
|
|
|
1984
2065
|
};
|
|
1985
2066
|
const schema = schemaMap[version];
|
|
1986
2067
|
if (!schema) {
|
|
1987
|
-
return yield*
|
|
2068
|
+
return yield* Effect16.fail(
|
|
1988
2069
|
new ConfigVersionError({
|
|
1989
2070
|
message: `Config file at ${filePath} has an unsupported version: ${version}`,
|
|
1990
2071
|
filePath,
|
|
@@ -1995,11 +2076,11 @@ var parseConfigRaw = Effect15.fn("parseConfigRaw")(function* (filePath, projectF
|
|
|
1995
2076
|
yield* validator.validate(parsed, schema, filePath);
|
|
1996
2077
|
return yield* v4Parser.parse(parsed, projectFolder);
|
|
1997
2078
|
});
|
|
1998
|
-
var parseConfig =
|
|
2079
|
+
var parseConfig = Effect16.fn("parseConfig")(function* (filePath, projectFolder) {
|
|
1999
2080
|
const parseResult = yield* parseConfigRaw(filePath, projectFolder);
|
|
2000
2081
|
return yield* postProcessConfig(parseResult, projectFolder);
|
|
2001
2082
|
});
|
|
2002
|
-
var postProcessConfig =
|
|
2083
|
+
var postProcessConfig = Effect16.fn("postProcessConfig")(function* (config, projectFolder) {
|
|
2003
2084
|
const vercelParser = yield* VercelBuildOutputParser;
|
|
2004
2085
|
let result = yield* vercelParser.parse(config, projectFolder);
|
|
2005
2086
|
if (result.entrypoints.length === 0 && (result.assets?.paths?.length || 0) === 0 && result.routes.length === 0) {
|