@gigadrive/network-config 3.3.0 → 3.3.1
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 +146 -122
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +101 -77
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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 FileSystem7, Path as Path5 } from "@effect/platform";
|
|
3
|
+
import { Effect as Effect9 } from "effect";
|
|
4
4
|
|
|
5
5
|
// src/detection/detect-package-manager.ts
|
|
6
6
|
import { FileSystem, Path } from "@effect/platform";
|
|
@@ -383,6 +383,16 @@ var nextjs = {
|
|
|
383
383
|
};
|
|
384
384
|
|
|
385
385
|
// src/detection/frameworks/nuxt.ts
|
|
386
|
+
import { FileSystem as FileSystem5 } from "@effect/platform";
|
|
387
|
+
import { Effect as Effect5 } from "effect";
|
|
388
|
+
var isVercelBuildOutputV3 = (content) => {
|
|
389
|
+
try {
|
|
390
|
+
const config = JSON.parse(content);
|
|
391
|
+
return typeof config === "object" && config !== null && "version" in config && typeof config.version === "number" && config.version >= 3;
|
|
392
|
+
} catch {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
};
|
|
386
396
|
var nuxt = {
|
|
387
397
|
slug: "nuxt",
|
|
388
398
|
name: "Nuxt",
|
|
@@ -400,6 +410,20 @@ var nuxt = {
|
|
|
400
410
|
populateAssetCache: true,
|
|
401
411
|
routes: [{ source: "/*", destination: ".output/server/index.mjs" }],
|
|
402
412
|
environmentVariables: { NODE_ENV: "production", NITRO_PRESET: "node-server" }
|
|
413
|
+
}),
|
|
414
|
+
refineDefaultConfig: (defaults, projectFolder) => Effect5.gen(function* () {
|
|
415
|
+
const fs = yield* FileSystem5.FileSystem;
|
|
416
|
+
const buildOutputConfig = yield* fs.readFileString(`${projectFolder}/.vercel/output/config.json`).pipe(Effect5.catchAll(() => Effect5.succeed(void 0)));
|
|
417
|
+
if (!buildOutputConfig || !isVercelBuildOutputV3(buildOutputConfig)) {
|
|
418
|
+
return defaults;
|
|
419
|
+
}
|
|
420
|
+
return {
|
|
421
|
+
...defaults,
|
|
422
|
+
entrypoint: void 0,
|
|
423
|
+
assetsDir: ".vercel/output/static",
|
|
424
|
+
routes: [],
|
|
425
|
+
environmentVariables: { ...defaults.environmentVariables, NITRO_PRESET: "vercel" }
|
|
426
|
+
};
|
|
403
427
|
})
|
|
404
428
|
};
|
|
405
429
|
|
|
@@ -512,7 +536,7 @@ var FRAMEWORK_DEFINITIONS = [
|
|
|
512
536
|
].sort((a, b) => b.priority - a.priority);
|
|
513
537
|
|
|
514
538
|
// src/detection/generate-config.ts
|
|
515
|
-
import { Effect as
|
|
539
|
+
import { Effect as Effect6 } from "effect";
|
|
516
540
|
|
|
517
541
|
// src/regions.ts
|
|
518
542
|
var REGION_DEFINITIONS = [
|
|
@@ -552,11 +576,11 @@ var getInstallCommand = (pm) => {
|
|
|
552
576
|
return "npm install";
|
|
553
577
|
}
|
|
554
578
|
};
|
|
555
|
-
var generateConfig =
|
|
579
|
+
var generateConfig = Effect6.fn("generateConfig")(function* (framework, packageManager, refinedDefaults) {
|
|
556
580
|
const defaults = refinedDefaults ?? framework.getDefaultConfig(packageManager);
|
|
557
581
|
const installCmd = defaults.installCommand ?? getInstallCommand(packageManager);
|
|
558
582
|
const commands = [installCmd, ...defaults.commands];
|
|
559
|
-
yield*
|
|
583
|
+
yield* Effect6.logDebug(`Generating config for ${framework.name}`, {
|
|
560
584
|
runtime: defaults.runtime,
|
|
561
585
|
entrypoint: defaults.entrypoint,
|
|
562
586
|
commands
|
|
@@ -602,8 +626,8 @@ var generateConfig = Effect5.fn("generateConfig")(function* (framework, packageM
|
|
|
602
626
|
});
|
|
603
627
|
|
|
604
628
|
// src/detection/read-dependencies.ts
|
|
605
|
-
import { FileSystem as
|
|
606
|
-
import { Effect as
|
|
629
|
+
import { FileSystem as FileSystem6, Path as Path4 } from "@effect/platform";
|
|
630
|
+
import { Effect as Effect8 } from "effect";
|
|
607
631
|
|
|
608
632
|
// src/detection/types.ts
|
|
609
633
|
import { Schema } from "effect";
|
|
@@ -636,25 +660,25 @@ var MANIFEST_CONFIG = {
|
|
|
636
660
|
node: { file: "package.json", depKeys: ["dependencies", "devDependencies"] },
|
|
637
661
|
php: { file: "composer.json", depKeys: ["require", "require-dev"] }
|
|
638
662
|
};
|
|
639
|
-
var readManifest =
|
|
640
|
-
const fs = yield*
|
|
641
|
-
const exists = yield* fs.exists(filePath).pipe(
|
|
663
|
+
var readManifest = Effect8.fn("readManifest")(function* (filePath) {
|
|
664
|
+
const fs = yield* FileSystem6.FileSystem;
|
|
665
|
+
const exists = yield* fs.exists(filePath).pipe(Effect8.catchAll(() => Effect8.succeed(false)));
|
|
642
666
|
if (!exists) {
|
|
643
|
-
return yield*
|
|
667
|
+
return yield* Effect8.fail(new ManifestNotFoundError({ message: "Manifest not found", filePath }));
|
|
644
668
|
}
|
|
645
|
-
const content = yield* fs.readFileString(filePath).pipe(
|
|
646
|
-
const parsed = yield*
|
|
669
|
+
const content = yield* fs.readFileString(filePath).pipe(Effect8.mapError(() => new ManifestReadError({ message: "Failed to read manifest", filePath })));
|
|
670
|
+
const parsed = yield* Effect8.try({
|
|
647
671
|
try: () => JSON.parse(content),
|
|
648
672
|
catch: () => new ManifestParseError({ message: "Failed to parse manifest JSON", filePath })
|
|
649
673
|
});
|
|
650
674
|
return parsed;
|
|
651
675
|
});
|
|
652
|
-
var readDependencies =
|
|
676
|
+
var readDependencies = Effect8.fn("readDependencies")(function* (projectFolder, language) {
|
|
653
677
|
const pathService = yield* Path4.Path;
|
|
654
678
|
const config = MANIFEST_CONFIG[language];
|
|
655
679
|
const filePath = pathService.join(projectFolder, config.file);
|
|
656
680
|
const manifest = yield* readManifest(filePath).pipe(
|
|
657
|
-
|
|
681
|
+
Effect8.catchTag("ManifestNotFoundError", () => Effect8.succeed(null))
|
|
658
682
|
);
|
|
659
683
|
if (!manifest) {
|
|
660
684
|
return /* @__PURE__ */ new Set();
|
|
@@ -672,8 +696,8 @@ var readDependencies = Effect7.fn("readDependencies")(function* (projectFolder,
|
|
|
672
696
|
});
|
|
673
697
|
|
|
674
698
|
// src/detection/detect-framework.ts
|
|
675
|
-
var matchesDetectionItem =
|
|
676
|
-
const fs = yield*
|
|
699
|
+
var matchesDetectionItem = Effect9.fn("matchesDetectionItem")(function* (item, projectFolder, framework, cachedReadDeps) {
|
|
700
|
+
const fs = yield* FileSystem7.FileSystem;
|
|
677
701
|
const pathService = yield* Path5.Path;
|
|
678
702
|
if (item.matchPackage != null) {
|
|
679
703
|
const deps = yield* cachedReadDeps(`${projectFolder}\0${framework.language}`);
|
|
@@ -683,12 +707,12 @@ var matchesDetectionItem = Effect8.fn("matchesDetectionItem")(function* (item, p
|
|
|
683
707
|
}
|
|
684
708
|
if (item.path != null) {
|
|
685
709
|
const filePath = pathService.join(projectFolder, item.path);
|
|
686
|
-
const exists = yield* fs.exists(filePath).pipe(
|
|
710
|
+
const exists = yield* fs.exists(filePath).pipe(Effect9.catchAll(() => Effect9.succeed(false)));
|
|
687
711
|
if (!exists) {
|
|
688
712
|
return false;
|
|
689
713
|
}
|
|
690
714
|
if (item.matchContent != null) {
|
|
691
|
-
const content = yield* fs.readFileString(filePath).pipe(
|
|
715
|
+
const content = yield* fs.readFileString(filePath).pipe(Effect9.catchAll(() => Effect9.succeed("")));
|
|
692
716
|
let regexMatch = false;
|
|
693
717
|
try {
|
|
694
718
|
regexMatch = new RegExp(item.matchContent).test(content);
|
|
@@ -701,7 +725,7 @@ var matchesDetectionItem = Effect8.fn("matchesDetectionItem")(function* (item, p
|
|
|
701
725
|
}
|
|
702
726
|
return true;
|
|
703
727
|
});
|
|
704
|
-
var matchesFramework =
|
|
728
|
+
var matchesFramework = Effect9.fn("matchesFramework")(function* (framework, projectFolder, cachedReadDeps) {
|
|
705
729
|
for (const detector of framework.detectors) {
|
|
706
730
|
const matches = yield* matchesDetectionItem(detector, projectFolder, framework, cachedReadDeps);
|
|
707
731
|
if (!matches) {
|
|
@@ -710,9 +734,9 @@ var matchesFramework = Effect8.fn("matchesFramework")(function* (framework, proj
|
|
|
710
734
|
}
|
|
711
735
|
return true;
|
|
712
736
|
});
|
|
713
|
-
var detectFramework =
|
|
714
|
-
yield*
|
|
715
|
-
const cachedReadDeps = yield*
|
|
737
|
+
var detectFramework = Effect9.fn("detectFramework")(function* (projectFolder) {
|
|
738
|
+
yield* Effect9.logDebug(`Detecting framework in ${projectFolder}`);
|
|
739
|
+
const cachedReadDeps = yield* Effect9.cachedFunction((key) => {
|
|
716
740
|
const sepIndex = key.lastIndexOf("\0");
|
|
717
741
|
const folder = key.slice(0, sepIndex);
|
|
718
742
|
const language = key.slice(sepIndex + 1);
|
|
@@ -721,7 +745,7 @@ var detectFramework = Effect8.fn("detectFramework")(function* (projectFolder) {
|
|
|
721
745
|
for (const framework of FRAMEWORK_DEFINITIONS) {
|
|
722
746
|
const matches = yield* matchesFramework(framework, projectFolder, cachedReadDeps);
|
|
723
747
|
if (matches) {
|
|
724
|
-
yield*
|
|
748
|
+
yield* Effect9.log(`Detected framework: ${framework.name}`, { slug: framework.slug });
|
|
725
749
|
const detectedPackageManager = yield* detectPackageManager(projectFolder);
|
|
726
750
|
const packageManager = framework.language === "php" ? "composer" : detectedPackageManager;
|
|
727
751
|
const defaults = framework.getDefaultConfig(packageManager);
|
|
@@ -730,7 +754,7 @@ var detectFramework = Effect8.fn("detectFramework")(function* (projectFolder) {
|
|
|
730
754
|
return { framework, packageManager, config };
|
|
731
755
|
}
|
|
732
756
|
}
|
|
733
|
-
return yield*
|
|
757
|
+
return yield* Effect9.fail(
|
|
734
758
|
new FrameworkNotDetectedError({
|
|
735
759
|
message: `No framework detected in project directory`,
|
|
736
760
|
directory: projectFolder
|
|
@@ -739,9 +763,9 @@ var detectFramework = Effect8.fn("detectFramework")(function* (projectFolder) {
|
|
|
739
763
|
});
|
|
740
764
|
|
|
741
765
|
// src/detection/merge-config.ts
|
|
742
|
-
import { Effect as
|
|
743
|
-
var mergeWithFrameworkDefaults =
|
|
744
|
-
yield*
|
|
766
|
+
import { Effect as Effect10 } from "effect";
|
|
767
|
+
var mergeWithFrameworkDefaults = Effect10.fn("mergeWithFrameworkDefaults")(function* (userConfig, frameworkConfig) {
|
|
768
|
+
yield* Effect10.logDebug("Merging user config with framework defaults");
|
|
745
769
|
const merged = {
|
|
746
770
|
regions: userConfig.regions,
|
|
747
771
|
commands: userConfig.commands.length > 0 ? userConfig.commands : frameworkConfig.commands,
|
|
@@ -816,11 +840,11 @@ var DEFAULT_FUNCTION_DURATION_SECONDS = 30;
|
|
|
816
840
|
var MAX_FUNCTION_DURATION_SECONDS = 28800;
|
|
817
841
|
|
|
818
842
|
// src/parse-config.ts
|
|
819
|
-
import { Effect as
|
|
843
|
+
import { Effect as Effect15 } from "effect";
|
|
820
844
|
|
|
821
845
|
// src/services/raw-config-reader.ts
|
|
822
|
-
import { FileSystem as
|
|
823
|
-
import { Effect as
|
|
846
|
+
import { FileSystem as FileSystem8, Path as Path6 } from "@effect/platform";
|
|
847
|
+
import { Effect as Effect11 } from "effect";
|
|
824
848
|
import { parse as parseYaml } from "yaml";
|
|
825
849
|
var ALLOWED_CONFIG_NAMES = [
|
|
826
850
|
"gigadrive.yaml",
|
|
@@ -829,34 +853,34 @@ var ALLOWED_CONFIG_NAMES = [
|
|
|
829
853
|
"nebula.yml",
|
|
830
854
|
"nebula.json"
|
|
831
855
|
];
|
|
832
|
-
var RawConfigReader = class extends
|
|
833
|
-
effect:
|
|
834
|
-
const fs = yield*
|
|
856
|
+
var RawConfigReader = class extends Effect11.Service()("RawConfigReader", {
|
|
857
|
+
effect: Effect11.gen(function* () {
|
|
858
|
+
const fs = yield* FileSystem8.FileSystem;
|
|
835
859
|
const pathService = yield* Path6.Path;
|
|
836
|
-
const findConfig =
|
|
860
|
+
const findConfig = Effect11.fn("RawConfigReader.findConfig")(function* (projectFolder) {
|
|
837
861
|
for (const name of ALLOWED_CONFIG_NAMES) {
|
|
838
862
|
const filePath = pathService.join(projectFolder, name);
|
|
839
|
-
const exists = yield* fs.exists(filePath).pipe(
|
|
863
|
+
const exists = yield* fs.exists(filePath).pipe(Effect11.catchAll(() => Effect11.succeed(false)));
|
|
840
864
|
if (exists) {
|
|
841
865
|
return filePath;
|
|
842
866
|
}
|
|
843
867
|
}
|
|
844
868
|
return null;
|
|
845
869
|
});
|
|
846
|
-
const readRawConfig =
|
|
847
|
-
const exists = yield* fs.exists(filePath).pipe(
|
|
870
|
+
const readRawConfig = Effect11.fn("RawConfigReader.readRawConfig")(function* (filePath, options) {
|
|
871
|
+
const exists = yield* fs.exists(filePath).pipe(Effect11.catchAll(() => Effect11.succeed(false)));
|
|
848
872
|
if (!exists) {
|
|
849
|
-
return yield*
|
|
873
|
+
return yield* Effect11.fail(
|
|
850
874
|
new ConfigFileNotFoundError({ message: `Config file not found at ${filePath}`, filePath })
|
|
851
875
|
);
|
|
852
876
|
}
|
|
853
877
|
const fileContents = yield* fs.readFileString(filePath).pipe(
|
|
854
|
-
|
|
878
|
+
Effect11.mapError(
|
|
855
879
|
() => new ConfigFileParseError({ message: `Failed to read config file at ${filePath}`, filePath })
|
|
856
880
|
)
|
|
857
881
|
);
|
|
858
882
|
if (fileContents.length === 0) {
|
|
859
|
-
return yield*
|
|
883
|
+
return yield* Effect11.fail(
|
|
860
884
|
new ConfigFileEmptyError({ message: `Config file is empty at ${filePath}`, filePath })
|
|
861
885
|
);
|
|
862
886
|
}
|
|
@@ -871,7 +895,7 @@ var RawConfigReader = class extends Effect10.Service()("RawConfigReader", {
|
|
|
871
895
|
parsed = parseYaml(fileContents);
|
|
872
896
|
}
|
|
873
897
|
} catch (error) {
|
|
874
|
-
return yield*
|
|
898
|
+
return yield* Effect11.fail(
|
|
875
899
|
new ConfigFileParseError({
|
|
876
900
|
message: `Failed to parse config file at ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
877
901
|
filePath,
|
|
@@ -880,21 +904,21 @@ var RawConfigReader = class extends Effect10.Service()("RawConfigReader", {
|
|
|
880
904
|
);
|
|
881
905
|
}
|
|
882
906
|
if (parsed == null) {
|
|
883
|
-
return yield*
|
|
907
|
+
return yield* Effect11.fail(
|
|
884
908
|
new ConfigFileParseError({ message: `Config file could not be parsed at ${filePath}`, filePath })
|
|
885
909
|
);
|
|
886
910
|
}
|
|
887
911
|
if (!options?.disableVersionCheck && typeof parsed.version !== "number") {
|
|
888
|
-
return yield*
|
|
912
|
+
return yield* Effect11.fail(
|
|
889
913
|
new ConfigVersionError({ message: `Config file is missing version at ${filePath}`, filePath })
|
|
890
914
|
);
|
|
891
915
|
}
|
|
892
916
|
return parsed;
|
|
893
917
|
});
|
|
894
918
|
const readConfigFile = (configFilePath) => readRawConfig(configFilePath, { disableVersionCheck: true }).pipe(
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
919
|
+
Effect11.map((parsed) => parsed),
|
|
920
|
+
Effect11.catchTag("ConfigFileNotFoundError", () => Effect11.succeed(null)),
|
|
921
|
+
Effect11.withSpan("RawConfigReader.readConfigFile")
|
|
898
922
|
);
|
|
899
923
|
return { findConfig, readRawConfig, readConfigFile };
|
|
900
924
|
})
|
|
@@ -904,17 +928,17 @@ var RawConfigReader = class extends Effect10.Service()("RawConfigReader", {
|
|
|
904
928
|
// src/services/schema-validator.ts
|
|
905
929
|
import Ajv from "ajv";
|
|
906
930
|
import addFormats from "ajv-formats";
|
|
907
|
-
import { Effect as
|
|
908
|
-
var SchemaValidator = class extends
|
|
909
|
-
effect:
|
|
931
|
+
import { Effect as Effect12 } from "effect";
|
|
932
|
+
var SchemaValidator = class extends Effect12.Service()("SchemaValidator", {
|
|
933
|
+
effect: Effect12.gen(function* () {
|
|
910
934
|
const ajv = new Ajv();
|
|
911
935
|
addFormats(ajv);
|
|
912
|
-
const validate =
|
|
936
|
+
const validate = Effect12.fn("SchemaValidator.validate")(function* (config, schema, filePath) {
|
|
913
937
|
const compiledValidate = ajv.compile(schema);
|
|
914
938
|
const valid = compiledValidate(config);
|
|
915
939
|
if (!valid) {
|
|
916
940
|
const errors = compiledValidate.errors?.map((e) => `${e.instancePath || "/"} ${e.message ?? ""}`.trim()) ?? [];
|
|
917
|
-
return yield*
|
|
941
|
+
return yield* Effect12.fail(
|
|
918
942
|
new ConfigSchemaValidationError({
|
|
919
943
|
message: `Config file at ${filePath} is invalid: ${ajv.errorsText(compiledValidate.errors)}`,
|
|
920
944
|
filePath,
|
|
@@ -929,9 +953,9 @@ var SchemaValidator = class extends Effect11.Service()("SchemaValidator", {
|
|
|
929
953
|
};
|
|
930
954
|
|
|
931
955
|
// src/services/v4-config-parser.ts
|
|
932
|
-
import { FileSystem as
|
|
956
|
+
import { FileSystem as FileSystem9, Path as Path7 } from "@effect/platform";
|
|
933
957
|
import { getFilesForPattern } from "@gigadrive/build-utils";
|
|
934
|
-
import { Effect as
|
|
958
|
+
import { Effect as Effect13 } from "effect";
|
|
935
959
|
import { minimatch } from "minimatch";
|
|
936
960
|
import safeRegex from "safe-regex2";
|
|
937
961
|
var MAX_ASSET_DEPTH = 100;
|
|
@@ -1002,7 +1026,7 @@ var mapRoute = (route, entrypoints) => ({
|
|
|
1002
1026
|
negativeRequirements: route.missing,
|
|
1003
1027
|
status: route.statusCode
|
|
1004
1028
|
});
|
|
1005
|
-
var parseEntrypoints =
|
|
1029
|
+
var parseEntrypoints = Effect13.fn("parseEntrypoints")(function* (config, projectFolder) {
|
|
1006
1030
|
const entrypoints = [];
|
|
1007
1031
|
if (config.functions == null) return entrypoints;
|
|
1008
1032
|
for (const [fnPath, func] of Object.entries(config.functions)) {
|
|
@@ -1012,7 +1036,7 @@ var parseEntrypoints = Effect12.fn("parseEntrypoints")(function* (config, projec
|
|
|
1012
1036
|
functionPath: fnPath
|
|
1013
1037
|
});
|
|
1014
1038
|
}
|
|
1015
|
-
const matchedFiles = yield*
|
|
1039
|
+
const matchedFiles = yield* Effect13.tryPromise({
|
|
1016
1040
|
try: () => getFilesForPattern(fnPath, projectFolder, func.excludeFiles),
|
|
1017
1041
|
catch: (error) => new FunctionConfigError({
|
|
1018
1042
|
message: `Failed to resolve files for function pattern '${fnPath}': ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1048,14 +1072,14 @@ var parseEntrypoints = Effect12.fn("parseEntrypoints")(function* (config, projec
|
|
|
1048
1072
|
}
|
|
1049
1073
|
return entrypoints;
|
|
1050
1074
|
});
|
|
1051
|
-
var collectAssets =
|
|
1075
|
+
var collectAssets = Effect13.fn("collectAssets")(function* (config, projectFolder) {
|
|
1052
1076
|
if (config.assets == null) return [];
|
|
1053
|
-
const fs = yield*
|
|
1077
|
+
const fs = yield* FileSystem9.FileSystem;
|
|
1054
1078
|
const pathService = yield* Path7.Path;
|
|
1055
1079
|
const assetsPath = pathService.join(projectFolder, config.assets);
|
|
1056
|
-
const assetsExist = yield* fs.exists(assetsPath).pipe(
|
|
1080
|
+
const assetsExist = yield* fs.exists(assetsPath).pipe(Effect13.catchAll(() => Effect13.succeed(false)));
|
|
1057
1081
|
if (!assetsExist) return [];
|
|
1058
|
-
const stat = yield* fs.stat(assetsPath).pipe(
|
|
1082
|
+
const stat = yield* fs.stat(assetsPath).pipe(Effect13.catchAll(() => Effect13.succeed(null)));
|
|
1059
1083
|
if (!stat || stat.type !== "Directory") return [];
|
|
1060
1084
|
const allFiles = yield* collectFilesRecursively(assetsPath);
|
|
1061
1085
|
const assets = [];
|
|
@@ -1066,18 +1090,18 @@ var collectAssets = Effect12.fn("collectAssets")(function* (config, projectFolde
|
|
|
1066
1090
|
}
|
|
1067
1091
|
return assets;
|
|
1068
1092
|
});
|
|
1069
|
-
var collectFilesRecursively =
|
|
1093
|
+
var collectFilesRecursively = Effect13.fn("collectFilesRecursively")(
|
|
1070
1094
|
function* (basePath, relativePath = "", depth = 0) {
|
|
1071
1095
|
if (depth > MAX_ASSET_DEPTH) return [];
|
|
1072
|
-
const fs = yield*
|
|
1096
|
+
const fs = yield* FileSystem9.FileSystem;
|
|
1073
1097
|
const pathSvc = yield* Path7.Path;
|
|
1074
1098
|
const currentPath = relativePath ? pathSvc.join(basePath, relativePath) : basePath;
|
|
1075
|
-
const entries = yield* fs.readDirectory(currentPath).pipe(
|
|
1099
|
+
const entries = yield* fs.readDirectory(currentPath).pipe(Effect13.catchAll(() => Effect13.succeed([])));
|
|
1076
1100
|
const result = [];
|
|
1077
1101
|
for (const name of entries) {
|
|
1078
1102
|
const fullPath = pathSvc.join(currentPath, name);
|
|
1079
1103
|
const entryRelative = relativePath ? pathSvc.join(relativePath, name) : name;
|
|
1080
|
-
const stat = yield* fs.stat(fullPath).pipe(
|
|
1104
|
+
const stat = yield* fs.stat(fullPath).pipe(Effect13.catchAll(() => Effect13.succeed(null)));
|
|
1081
1105
|
if (!stat) continue;
|
|
1082
1106
|
if (stat.type === "Directory") {
|
|
1083
1107
|
const nested = yield* collectFilesRecursively(basePath, entryRelative, depth + 1);
|
|
@@ -1089,16 +1113,16 @@ var collectFilesRecursively = Effect12.fn("collectFilesRecursively")(
|
|
|
1089
1113
|
return result;
|
|
1090
1114
|
}
|
|
1091
1115
|
);
|
|
1092
|
-
var V4ConfigParser = class extends
|
|
1116
|
+
var V4ConfigParser = class extends Effect13.Service()("V4ConfigParser", {
|
|
1093
1117
|
accessors: true,
|
|
1094
|
-
effect:
|
|
1118
|
+
effect: Effect13.succeed({
|
|
1095
1119
|
/**
|
|
1096
1120
|
* Parses a ConfigV4 into a NormalizedConfig.
|
|
1097
1121
|
*
|
|
1098
1122
|
* @param config - The raw V4 config object
|
|
1099
1123
|
* @param projectFolder - Absolute path to the project root
|
|
1100
1124
|
*/
|
|
1101
|
-
parse:
|
|
1125
|
+
parse: Effect13.fn("V4ConfigParser.parse")(function* (config, projectFolder) {
|
|
1102
1126
|
const entrypoints = yield* parseEntrypoints(config, projectFolder);
|
|
1103
1127
|
const assets = yield* collectAssets(config, projectFolder);
|
|
1104
1128
|
return {
|
|
@@ -1125,7 +1149,7 @@ var V4ConfigParser = class extends Effect12.Service()("V4ConfigParser", {
|
|
|
1125
1149
|
import { Path as Path8 } from "@effect/platform";
|
|
1126
1150
|
import { getFilesForPattern as getFilesForPattern2 } from "@gigadrive/build-utils";
|
|
1127
1151
|
import { deepMerge } from "@gigadrive/commons";
|
|
1128
|
-
import { Effect as
|
|
1152
|
+
import { Effect as Effect14 } from "effect";
|
|
1129
1153
|
|
|
1130
1154
|
// src/build-output-v3/determine-repo-root.ts
|
|
1131
1155
|
import path from "path";
|
|
@@ -1221,11 +1245,11 @@ var translateVercelRuntime = (runtime) => {
|
|
|
1221
1245
|
var CONFIG_PATH = ".vercel/output/config.json";
|
|
1222
1246
|
var FUNCTIONS_FOLDER = ".vercel/output/functions";
|
|
1223
1247
|
var FUNCTION_CONFIGS_PATTERN = `${FUNCTIONS_FOLDER}/**/*.func/.vc-config.json`;
|
|
1224
|
-
var VercelBuildOutputParser = class extends
|
|
1225
|
-
effect:
|
|
1248
|
+
var VercelBuildOutputParser = class extends Effect14.Service()("VercelBuildOutputParser", {
|
|
1249
|
+
effect: Effect14.gen(function* () {
|
|
1226
1250
|
const rawConfigReader = yield* RawConfigReader;
|
|
1227
1251
|
const pathService = yield* Path8.Path;
|
|
1228
|
-
const parse =
|
|
1252
|
+
const parse = Effect14.fn("VercelBuildOutputParser.parse")(function* (parseResult, projectFolder) {
|
|
1229
1253
|
const config = yield* rawConfigReader.readConfigFile(pathService.join(projectFolder, CONFIG_PATH));
|
|
1230
1254
|
if (!config || typeof config.version !== "number" || config.version < 3) {
|
|
1231
1255
|
return parseResult;
|
|
@@ -1236,8 +1260,8 @@ var VercelBuildOutputParser = class extends Effect13.Service()("VercelBuildOutpu
|
|
|
1236
1260
|
merged.regions = [...new Set(merged.regions)];
|
|
1237
1261
|
return merged;
|
|
1238
1262
|
});
|
|
1239
|
-
const loadFunctions =
|
|
1240
|
-
const functionConfigs = yield*
|
|
1263
|
+
const loadFunctions = Effect14.fn("VercelBuildOutputParser.loadFunctions")(function* (config, parseResult, projectFolder) {
|
|
1264
|
+
const functionConfigs = yield* Effect14.tryPromise({
|
|
1241
1265
|
try: () => getFilesForPattern2(FUNCTION_CONFIGS_PATTERN, projectFolder),
|
|
1242
1266
|
catch: (error) => new ConfigFileParseError({
|
|
1243
1267
|
message: `Failed to scan for function configs: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1693,7 +1717,7 @@ var schema_default = {
|
|
|
1693
1717
|
};
|
|
1694
1718
|
|
|
1695
1719
|
// src/parse-config.ts
|
|
1696
|
-
var parseConfigRaw =
|
|
1720
|
+
var parseConfigRaw = Effect15.fn("parseConfigRaw")(function* (filePath, projectFolder) {
|
|
1697
1721
|
const rawReader = yield* RawConfigReader;
|
|
1698
1722
|
const validator = yield* SchemaValidator;
|
|
1699
1723
|
const v4Parser = yield* V4ConfigParser;
|
|
@@ -1704,7 +1728,7 @@ var parseConfigRaw = Effect14.fn("parseConfigRaw")(function* (filePath, projectF
|
|
|
1704
1728
|
};
|
|
1705
1729
|
const schema = schemaMap[version];
|
|
1706
1730
|
if (!schema) {
|
|
1707
|
-
return yield*
|
|
1731
|
+
return yield* Effect15.fail(
|
|
1708
1732
|
new ConfigVersionError({
|
|
1709
1733
|
message: `Config file at ${filePath} has an unsupported version: ${version}`,
|
|
1710
1734
|
filePath,
|
|
@@ -1715,11 +1739,11 @@ var parseConfigRaw = Effect14.fn("parseConfigRaw")(function* (filePath, projectF
|
|
|
1715
1739
|
yield* validator.validate(parsed, schema, filePath);
|
|
1716
1740
|
return yield* v4Parser.parse(parsed, projectFolder);
|
|
1717
1741
|
});
|
|
1718
|
-
var parseConfig =
|
|
1742
|
+
var parseConfig = Effect15.fn("parseConfig")(function* (filePath, projectFolder) {
|
|
1719
1743
|
const parseResult = yield* parseConfigRaw(filePath, projectFolder);
|
|
1720
1744
|
return yield* postProcessConfig(parseResult, projectFolder);
|
|
1721
1745
|
});
|
|
1722
|
-
var postProcessConfig =
|
|
1746
|
+
var postProcessConfig = Effect15.fn("postProcessConfig")(function* (config, projectFolder) {
|
|
1723
1747
|
const vercelParser = yield* VercelBuildOutputParser;
|
|
1724
1748
|
let result = yield* vercelParser.parse(config, projectFolder);
|
|
1725
1749
|
if (result.entrypoints.length === 0 && (result.assets?.paths?.length || 0) === 0 && result.routes.length === 0) {
|