@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.js
CHANGED
|
@@ -65,8 +65,8 @@ __export(src_exports, {
|
|
|
65
65
|
module.exports = __toCommonJS(src_exports);
|
|
66
66
|
|
|
67
67
|
// src/detection/detect-framework.ts
|
|
68
|
-
var
|
|
69
|
-
var
|
|
68
|
+
var import_platform7 = require("@effect/platform");
|
|
69
|
+
var import_effect9 = require("effect");
|
|
70
70
|
|
|
71
71
|
// src/detection/detect-package-manager.ts
|
|
72
72
|
var import_platform = require("@effect/platform");
|
|
@@ -449,6 +449,16 @@ var nextjs = {
|
|
|
449
449
|
};
|
|
450
450
|
|
|
451
451
|
// src/detection/frameworks/nuxt.ts
|
|
452
|
+
var import_platform5 = require("@effect/platform");
|
|
453
|
+
var import_effect5 = require("effect");
|
|
454
|
+
var isVercelBuildOutputV3 = (content) => {
|
|
455
|
+
try {
|
|
456
|
+
const config = JSON.parse(content);
|
|
457
|
+
return typeof config === "object" && config !== null && "version" in config && typeof config.version === "number" && config.version >= 3;
|
|
458
|
+
} catch {
|
|
459
|
+
return false;
|
|
460
|
+
}
|
|
461
|
+
};
|
|
452
462
|
var nuxt = {
|
|
453
463
|
slug: "nuxt",
|
|
454
464
|
name: "Nuxt",
|
|
@@ -466,6 +476,20 @@ var nuxt = {
|
|
|
466
476
|
populateAssetCache: true,
|
|
467
477
|
routes: [{ source: "/*", destination: ".output/server/index.mjs" }],
|
|
468
478
|
environmentVariables: { NODE_ENV: "production", NITRO_PRESET: "node-server" }
|
|
479
|
+
}),
|
|
480
|
+
refineDefaultConfig: (defaults, projectFolder) => import_effect5.Effect.gen(function* () {
|
|
481
|
+
const fs = yield* import_platform5.FileSystem.FileSystem;
|
|
482
|
+
const buildOutputConfig = yield* fs.readFileString(`${projectFolder}/.vercel/output/config.json`).pipe(import_effect5.Effect.catchAll(() => import_effect5.Effect.succeed(void 0)));
|
|
483
|
+
if (!buildOutputConfig || !isVercelBuildOutputV3(buildOutputConfig)) {
|
|
484
|
+
return defaults;
|
|
485
|
+
}
|
|
486
|
+
return {
|
|
487
|
+
...defaults,
|
|
488
|
+
entrypoint: void 0,
|
|
489
|
+
assetsDir: ".vercel/output/static",
|
|
490
|
+
routes: [],
|
|
491
|
+
environmentVariables: { ...defaults.environmentVariables, NITRO_PRESET: "vercel" }
|
|
492
|
+
};
|
|
469
493
|
})
|
|
470
494
|
};
|
|
471
495
|
|
|
@@ -578,7 +602,7 @@ var FRAMEWORK_DEFINITIONS = [
|
|
|
578
602
|
].sort((a, b) => b.priority - a.priority);
|
|
579
603
|
|
|
580
604
|
// src/detection/generate-config.ts
|
|
581
|
-
var
|
|
605
|
+
var import_effect6 = require("effect");
|
|
582
606
|
|
|
583
607
|
// src/regions.ts
|
|
584
608
|
var REGION_DEFINITIONS = [
|
|
@@ -618,11 +642,11 @@ var getInstallCommand = (pm) => {
|
|
|
618
642
|
return "npm install";
|
|
619
643
|
}
|
|
620
644
|
};
|
|
621
|
-
var generateConfig =
|
|
645
|
+
var generateConfig = import_effect6.Effect.fn("generateConfig")(function* (framework, packageManager, refinedDefaults) {
|
|
622
646
|
const defaults = refinedDefaults ?? framework.getDefaultConfig(packageManager);
|
|
623
647
|
const installCmd = defaults.installCommand ?? getInstallCommand(packageManager);
|
|
624
648
|
const commands = [installCmd, ...defaults.commands];
|
|
625
|
-
yield*
|
|
649
|
+
yield* import_effect6.Effect.logDebug(`Generating config for ${framework.name}`, {
|
|
626
650
|
runtime: defaults.runtime,
|
|
627
651
|
entrypoint: defaults.entrypoint,
|
|
628
652
|
commands
|
|
@@ -668,31 +692,31 @@ var generateConfig = import_effect5.Effect.fn("generateConfig")(function* (frame
|
|
|
668
692
|
});
|
|
669
693
|
|
|
670
694
|
// src/detection/read-dependencies.ts
|
|
671
|
-
var
|
|
672
|
-
var
|
|
695
|
+
var import_platform6 = require("@effect/platform");
|
|
696
|
+
var import_effect8 = require("effect");
|
|
673
697
|
|
|
674
698
|
// src/detection/types.ts
|
|
675
|
-
var
|
|
676
|
-
var ManifestNotFoundError = class extends
|
|
677
|
-
message:
|
|
678
|
-
filePath:
|
|
699
|
+
var import_effect7 = require("effect");
|
|
700
|
+
var ManifestNotFoundError = class extends import_effect7.Schema.TaggedError()("ManifestNotFoundError", {
|
|
701
|
+
message: import_effect7.Schema.String,
|
|
702
|
+
filePath: import_effect7.Schema.String
|
|
679
703
|
}) {
|
|
680
704
|
};
|
|
681
|
-
var ManifestReadError = class extends
|
|
682
|
-
message:
|
|
683
|
-
filePath:
|
|
705
|
+
var ManifestReadError = class extends import_effect7.Schema.TaggedError()("ManifestReadError", {
|
|
706
|
+
message: import_effect7.Schema.String,
|
|
707
|
+
filePath: import_effect7.Schema.String
|
|
684
708
|
}) {
|
|
685
709
|
};
|
|
686
|
-
var ManifestParseError = class extends
|
|
687
|
-
message:
|
|
688
|
-
filePath:
|
|
710
|
+
var ManifestParseError = class extends import_effect7.Schema.TaggedError()("ManifestParseError", {
|
|
711
|
+
message: import_effect7.Schema.String,
|
|
712
|
+
filePath: import_effect7.Schema.String
|
|
689
713
|
}) {
|
|
690
714
|
};
|
|
691
|
-
var FrameworkNotDetectedError = class extends
|
|
715
|
+
var FrameworkNotDetectedError = class extends import_effect7.Schema.TaggedError()(
|
|
692
716
|
"FrameworkNotDetectedError",
|
|
693
717
|
{
|
|
694
|
-
message:
|
|
695
|
-
directory:
|
|
718
|
+
message: import_effect7.Schema.String,
|
|
719
|
+
directory: import_effect7.Schema.String
|
|
696
720
|
}
|
|
697
721
|
) {
|
|
698
722
|
};
|
|
@@ -702,25 +726,25 @@ var MANIFEST_CONFIG = {
|
|
|
702
726
|
node: { file: "package.json", depKeys: ["dependencies", "devDependencies"] },
|
|
703
727
|
php: { file: "composer.json", depKeys: ["require", "require-dev"] }
|
|
704
728
|
};
|
|
705
|
-
var readManifest =
|
|
706
|
-
const fs = yield*
|
|
707
|
-
const exists = yield* fs.exists(filePath).pipe(
|
|
729
|
+
var readManifest = import_effect8.Effect.fn("readManifest")(function* (filePath) {
|
|
730
|
+
const fs = yield* import_platform6.FileSystem.FileSystem;
|
|
731
|
+
const exists = yield* fs.exists(filePath).pipe(import_effect8.Effect.catchAll(() => import_effect8.Effect.succeed(false)));
|
|
708
732
|
if (!exists) {
|
|
709
|
-
return yield*
|
|
733
|
+
return yield* import_effect8.Effect.fail(new ManifestNotFoundError({ message: "Manifest not found", filePath }));
|
|
710
734
|
}
|
|
711
|
-
const content = yield* fs.readFileString(filePath).pipe(
|
|
712
|
-
const parsed = yield*
|
|
735
|
+
const content = yield* fs.readFileString(filePath).pipe(import_effect8.Effect.mapError(() => new ManifestReadError({ message: "Failed to read manifest", filePath })));
|
|
736
|
+
const parsed = yield* import_effect8.Effect.try({
|
|
713
737
|
try: () => JSON.parse(content),
|
|
714
738
|
catch: () => new ManifestParseError({ message: "Failed to parse manifest JSON", filePath })
|
|
715
739
|
});
|
|
716
740
|
return parsed;
|
|
717
741
|
});
|
|
718
|
-
var readDependencies =
|
|
719
|
-
const pathService = yield*
|
|
742
|
+
var readDependencies = import_effect8.Effect.fn("readDependencies")(function* (projectFolder, language) {
|
|
743
|
+
const pathService = yield* import_platform6.Path.Path;
|
|
720
744
|
const config = MANIFEST_CONFIG[language];
|
|
721
745
|
const filePath = pathService.join(projectFolder, config.file);
|
|
722
746
|
const manifest = yield* readManifest(filePath).pipe(
|
|
723
|
-
|
|
747
|
+
import_effect8.Effect.catchTag("ManifestNotFoundError", () => import_effect8.Effect.succeed(null))
|
|
724
748
|
);
|
|
725
749
|
if (!manifest) {
|
|
726
750
|
return /* @__PURE__ */ new Set();
|
|
@@ -738,9 +762,9 @@ var readDependencies = import_effect7.Effect.fn("readDependencies")(function* (p
|
|
|
738
762
|
});
|
|
739
763
|
|
|
740
764
|
// src/detection/detect-framework.ts
|
|
741
|
-
var matchesDetectionItem =
|
|
742
|
-
const fs = yield*
|
|
743
|
-
const pathService = yield*
|
|
765
|
+
var matchesDetectionItem = import_effect9.Effect.fn("matchesDetectionItem")(function* (item, projectFolder, framework, cachedReadDeps) {
|
|
766
|
+
const fs = yield* import_platform7.FileSystem.FileSystem;
|
|
767
|
+
const pathService = yield* import_platform7.Path.Path;
|
|
744
768
|
if (item.matchPackage != null) {
|
|
745
769
|
const deps = yield* cachedReadDeps(`${projectFolder}\0${framework.language}`);
|
|
746
770
|
if (!deps.has(item.matchPackage)) {
|
|
@@ -749,12 +773,12 @@ var matchesDetectionItem = import_effect8.Effect.fn("matchesDetectionItem")(func
|
|
|
749
773
|
}
|
|
750
774
|
if (item.path != null) {
|
|
751
775
|
const filePath = pathService.join(projectFolder, item.path);
|
|
752
|
-
const exists = yield* fs.exists(filePath).pipe(
|
|
776
|
+
const exists = yield* fs.exists(filePath).pipe(import_effect9.Effect.catchAll(() => import_effect9.Effect.succeed(false)));
|
|
753
777
|
if (!exists) {
|
|
754
778
|
return false;
|
|
755
779
|
}
|
|
756
780
|
if (item.matchContent != null) {
|
|
757
|
-
const content = yield* fs.readFileString(filePath).pipe(
|
|
781
|
+
const content = yield* fs.readFileString(filePath).pipe(import_effect9.Effect.catchAll(() => import_effect9.Effect.succeed("")));
|
|
758
782
|
let regexMatch = false;
|
|
759
783
|
try {
|
|
760
784
|
regexMatch = new RegExp(item.matchContent).test(content);
|
|
@@ -767,7 +791,7 @@ var matchesDetectionItem = import_effect8.Effect.fn("matchesDetectionItem")(func
|
|
|
767
791
|
}
|
|
768
792
|
return true;
|
|
769
793
|
});
|
|
770
|
-
var matchesFramework =
|
|
794
|
+
var matchesFramework = import_effect9.Effect.fn("matchesFramework")(function* (framework, projectFolder, cachedReadDeps) {
|
|
771
795
|
for (const detector of framework.detectors) {
|
|
772
796
|
const matches = yield* matchesDetectionItem(detector, projectFolder, framework, cachedReadDeps);
|
|
773
797
|
if (!matches) {
|
|
@@ -776,9 +800,9 @@ var matchesFramework = import_effect8.Effect.fn("matchesFramework")(function* (f
|
|
|
776
800
|
}
|
|
777
801
|
return true;
|
|
778
802
|
});
|
|
779
|
-
var detectFramework =
|
|
780
|
-
yield*
|
|
781
|
-
const cachedReadDeps = yield*
|
|
803
|
+
var detectFramework = import_effect9.Effect.fn("detectFramework")(function* (projectFolder) {
|
|
804
|
+
yield* import_effect9.Effect.logDebug(`Detecting framework in ${projectFolder}`);
|
|
805
|
+
const cachedReadDeps = yield* import_effect9.Effect.cachedFunction((key) => {
|
|
782
806
|
const sepIndex = key.lastIndexOf("\0");
|
|
783
807
|
const folder = key.slice(0, sepIndex);
|
|
784
808
|
const language = key.slice(sepIndex + 1);
|
|
@@ -787,7 +811,7 @@ var detectFramework = import_effect8.Effect.fn("detectFramework")(function* (pro
|
|
|
787
811
|
for (const framework of FRAMEWORK_DEFINITIONS) {
|
|
788
812
|
const matches = yield* matchesFramework(framework, projectFolder, cachedReadDeps);
|
|
789
813
|
if (matches) {
|
|
790
|
-
yield*
|
|
814
|
+
yield* import_effect9.Effect.log(`Detected framework: ${framework.name}`, { slug: framework.slug });
|
|
791
815
|
const detectedPackageManager = yield* detectPackageManager(projectFolder);
|
|
792
816
|
const packageManager = framework.language === "php" ? "composer" : detectedPackageManager;
|
|
793
817
|
const defaults = framework.getDefaultConfig(packageManager);
|
|
@@ -796,7 +820,7 @@ var detectFramework = import_effect8.Effect.fn("detectFramework")(function* (pro
|
|
|
796
820
|
return { framework, packageManager, config };
|
|
797
821
|
}
|
|
798
822
|
}
|
|
799
|
-
return yield*
|
|
823
|
+
return yield* import_effect9.Effect.fail(
|
|
800
824
|
new FrameworkNotDetectedError({
|
|
801
825
|
message: `No framework detected in project directory`,
|
|
802
826
|
directory: projectFolder
|
|
@@ -805,9 +829,9 @@ var detectFramework = import_effect8.Effect.fn("detectFramework")(function* (pro
|
|
|
805
829
|
});
|
|
806
830
|
|
|
807
831
|
// src/detection/merge-config.ts
|
|
808
|
-
var
|
|
809
|
-
var mergeWithFrameworkDefaults =
|
|
810
|
-
yield*
|
|
832
|
+
var import_effect10 = require("effect");
|
|
833
|
+
var mergeWithFrameworkDefaults = import_effect10.Effect.fn("mergeWithFrameworkDefaults")(function* (userConfig, frameworkConfig) {
|
|
834
|
+
yield* import_effect10.Effect.logDebug("Merging user config with framework defaults");
|
|
811
835
|
const merged = {
|
|
812
836
|
regions: userConfig.regions,
|
|
813
837
|
commands: userConfig.commands.length > 0 ? userConfig.commands : frameworkConfig.commands,
|
|
@@ -828,41 +852,41 @@ var mergeWithFrameworkDefaults = import_effect9.Effect.fn("mergeWithFrameworkDef
|
|
|
828
852
|
});
|
|
829
853
|
|
|
830
854
|
// src/errors.ts
|
|
831
|
-
var
|
|
832
|
-
var ConfigFileNotFoundError = class extends
|
|
833
|
-
message:
|
|
834
|
-
filePath:
|
|
855
|
+
var import_effect11 = require("effect");
|
|
856
|
+
var ConfigFileNotFoundError = class extends import_effect11.Schema.TaggedError()("ConfigFileNotFoundError", {
|
|
857
|
+
message: import_effect11.Schema.String,
|
|
858
|
+
filePath: import_effect11.Schema.String
|
|
835
859
|
}) {
|
|
836
860
|
};
|
|
837
|
-
var ConfigFileEmptyError = class extends
|
|
838
|
-
message:
|
|
839
|
-
filePath:
|
|
861
|
+
var ConfigFileEmptyError = class extends import_effect11.Schema.TaggedError()("ConfigFileEmptyError", {
|
|
862
|
+
message: import_effect11.Schema.String,
|
|
863
|
+
filePath: import_effect11.Schema.String
|
|
840
864
|
}) {
|
|
841
865
|
};
|
|
842
|
-
var ConfigFileParseError = class extends
|
|
843
|
-
message:
|
|
844
|
-
filePath:
|
|
845
|
-
cause:
|
|
866
|
+
var ConfigFileParseError = class extends import_effect11.Schema.TaggedError()("ConfigFileParseError", {
|
|
867
|
+
message: import_effect11.Schema.String,
|
|
868
|
+
filePath: import_effect11.Schema.String,
|
|
869
|
+
cause: import_effect11.Schema.optional(import_effect11.Schema.String)
|
|
846
870
|
}) {
|
|
847
871
|
};
|
|
848
|
-
var ConfigVersionError = class extends
|
|
849
|
-
message:
|
|
850
|
-
filePath:
|
|
851
|
-
version:
|
|
872
|
+
var ConfigVersionError = class extends import_effect11.Schema.TaggedError()("ConfigVersionError", {
|
|
873
|
+
message: import_effect11.Schema.String,
|
|
874
|
+
filePath: import_effect11.Schema.String,
|
|
875
|
+
version: import_effect11.Schema.optional(import_effect11.Schema.Number)
|
|
852
876
|
}) {
|
|
853
877
|
};
|
|
854
|
-
var ConfigSchemaValidationError = class extends
|
|
878
|
+
var ConfigSchemaValidationError = class extends import_effect11.Schema.TaggedError()(
|
|
855
879
|
"ConfigSchemaValidationError",
|
|
856
880
|
{
|
|
857
|
-
message:
|
|
858
|
-
filePath:
|
|
859
|
-
validationErrors:
|
|
881
|
+
message: import_effect11.Schema.String,
|
|
882
|
+
filePath: import_effect11.Schema.String,
|
|
883
|
+
validationErrors: import_effect11.Schema.Array(import_effect11.Schema.String)
|
|
860
884
|
}
|
|
861
885
|
) {
|
|
862
886
|
};
|
|
863
|
-
var FunctionConfigError = class extends
|
|
864
|
-
message:
|
|
865
|
-
functionPath:
|
|
887
|
+
var FunctionConfigError = class extends import_effect11.Schema.TaggedError()("FunctionConfigError", {
|
|
888
|
+
message: import_effect11.Schema.String,
|
|
889
|
+
functionPath: import_effect11.Schema.String
|
|
866
890
|
}) {
|
|
867
891
|
};
|
|
868
892
|
|
|
@@ -882,11 +906,11 @@ var DEFAULT_FUNCTION_DURATION_SECONDS = 30;
|
|
|
882
906
|
var MAX_FUNCTION_DURATION_SECONDS = 28800;
|
|
883
907
|
|
|
884
908
|
// src/parse-config.ts
|
|
885
|
-
var
|
|
909
|
+
var import_effect16 = require("effect");
|
|
886
910
|
|
|
887
911
|
// src/services/raw-config-reader.ts
|
|
888
|
-
var
|
|
889
|
-
var
|
|
912
|
+
var import_platform8 = require("@effect/platform");
|
|
913
|
+
var import_effect12 = require("effect");
|
|
890
914
|
var import_yaml = require("yaml");
|
|
891
915
|
var ALLOWED_CONFIG_NAMES = [
|
|
892
916
|
"gigadrive.yaml",
|
|
@@ -895,34 +919,34 @@ var ALLOWED_CONFIG_NAMES = [
|
|
|
895
919
|
"nebula.yml",
|
|
896
920
|
"nebula.json"
|
|
897
921
|
];
|
|
898
|
-
var RawConfigReader = class extends
|
|
899
|
-
effect:
|
|
900
|
-
const fs = yield*
|
|
901
|
-
const pathService = yield*
|
|
902
|
-
const findConfig =
|
|
922
|
+
var RawConfigReader = class extends import_effect12.Effect.Service()("RawConfigReader", {
|
|
923
|
+
effect: import_effect12.Effect.gen(function* () {
|
|
924
|
+
const fs = yield* import_platform8.FileSystem.FileSystem;
|
|
925
|
+
const pathService = yield* import_platform8.Path.Path;
|
|
926
|
+
const findConfig = import_effect12.Effect.fn("RawConfigReader.findConfig")(function* (projectFolder) {
|
|
903
927
|
for (const name of ALLOWED_CONFIG_NAMES) {
|
|
904
928
|
const filePath = pathService.join(projectFolder, name);
|
|
905
|
-
const exists = yield* fs.exists(filePath).pipe(
|
|
929
|
+
const exists = yield* fs.exists(filePath).pipe(import_effect12.Effect.catchAll(() => import_effect12.Effect.succeed(false)));
|
|
906
930
|
if (exists) {
|
|
907
931
|
return filePath;
|
|
908
932
|
}
|
|
909
933
|
}
|
|
910
934
|
return null;
|
|
911
935
|
});
|
|
912
|
-
const readRawConfig =
|
|
913
|
-
const exists = yield* fs.exists(filePath).pipe(
|
|
936
|
+
const readRawConfig = import_effect12.Effect.fn("RawConfigReader.readRawConfig")(function* (filePath, options) {
|
|
937
|
+
const exists = yield* fs.exists(filePath).pipe(import_effect12.Effect.catchAll(() => import_effect12.Effect.succeed(false)));
|
|
914
938
|
if (!exists) {
|
|
915
|
-
return yield*
|
|
939
|
+
return yield* import_effect12.Effect.fail(
|
|
916
940
|
new ConfigFileNotFoundError({ message: `Config file not found at ${filePath}`, filePath })
|
|
917
941
|
);
|
|
918
942
|
}
|
|
919
943
|
const fileContents = yield* fs.readFileString(filePath).pipe(
|
|
920
|
-
|
|
944
|
+
import_effect12.Effect.mapError(
|
|
921
945
|
() => new ConfigFileParseError({ message: `Failed to read config file at ${filePath}`, filePath })
|
|
922
946
|
)
|
|
923
947
|
);
|
|
924
948
|
if (fileContents.length === 0) {
|
|
925
|
-
return yield*
|
|
949
|
+
return yield* import_effect12.Effect.fail(
|
|
926
950
|
new ConfigFileEmptyError({ message: `Config file is empty at ${filePath}`, filePath })
|
|
927
951
|
);
|
|
928
952
|
}
|
|
@@ -937,7 +961,7 @@ var RawConfigReader = class extends import_effect11.Effect.Service()("RawConfigR
|
|
|
937
961
|
parsed = (0, import_yaml.parse)(fileContents);
|
|
938
962
|
}
|
|
939
963
|
} catch (error) {
|
|
940
|
-
return yield*
|
|
964
|
+
return yield* import_effect12.Effect.fail(
|
|
941
965
|
new ConfigFileParseError({
|
|
942
966
|
message: `Failed to parse config file at ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
943
967
|
filePath,
|
|
@@ -946,21 +970,21 @@ var RawConfigReader = class extends import_effect11.Effect.Service()("RawConfigR
|
|
|
946
970
|
);
|
|
947
971
|
}
|
|
948
972
|
if (parsed == null) {
|
|
949
|
-
return yield*
|
|
973
|
+
return yield* import_effect12.Effect.fail(
|
|
950
974
|
new ConfigFileParseError({ message: `Config file could not be parsed at ${filePath}`, filePath })
|
|
951
975
|
);
|
|
952
976
|
}
|
|
953
977
|
if (!options?.disableVersionCheck && typeof parsed.version !== "number") {
|
|
954
|
-
return yield*
|
|
978
|
+
return yield* import_effect12.Effect.fail(
|
|
955
979
|
new ConfigVersionError({ message: `Config file is missing version at ${filePath}`, filePath })
|
|
956
980
|
);
|
|
957
981
|
}
|
|
958
982
|
return parsed;
|
|
959
983
|
});
|
|
960
984
|
const readConfigFile = (configFilePath) => readRawConfig(configFilePath, { disableVersionCheck: true }).pipe(
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
985
|
+
import_effect12.Effect.map((parsed) => parsed),
|
|
986
|
+
import_effect12.Effect.catchTag("ConfigFileNotFoundError", () => import_effect12.Effect.succeed(null)),
|
|
987
|
+
import_effect12.Effect.withSpan("RawConfigReader.readConfigFile")
|
|
964
988
|
);
|
|
965
989
|
return { findConfig, readRawConfig, readConfigFile };
|
|
966
990
|
})
|
|
@@ -970,17 +994,17 @@ var RawConfigReader = class extends import_effect11.Effect.Service()("RawConfigR
|
|
|
970
994
|
// src/services/schema-validator.ts
|
|
971
995
|
var import_ajv = __toESM(require("ajv"));
|
|
972
996
|
var import_ajv_formats = __toESM(require("ajv-formats"));
|
|
973
|
-
var
|
|
974
|
-
var SchemaValidator = class extends
|
|
975
|
-
effect:
|
|
997
|
+
var import_effect13 = require("effect");
|
|
998
|
+
var SchemaValidator = class extends import_effect13.Effect.Service()("SchemaValidator", {
|
|
999
|
+
effect: import_effect13.Effect.gen(function* () {
|
|
976
1000
|
const ajv = new import_ajv.default();
|
|
977
1001
|
(0, import_ajv_formats.default)(ajv);
|
|
978
|
-
const validate =
|
|
1002
|
+
const validate = import_effect13.Effect.fn("SchemaValidator.validate")(function* (config, schema, filePath) {
|
|
979
1003
|
const compiledValidate = ajv.compile(schema);
|
|
980
1004
|
const valid = compiledValidate(config);
|
|
981
1005
|
if (!valid) {
|
|
982
1006
|
const errors = compiledValidate.errors?.map((e) => `${e.instancePath || "/"} ${e.message ?? ""}`.trim()) ?? [];
|
|
983
|
-
return yield*
|
|
1007
|
+
return yield* import_effect13.Effect.fail(
|
|
984
1008
|
new ConfigSchemaValidationError({
|
|
985
1009
|
message: `Config file at ${filePath} is invalid: ${ajv.errorsText(compiledValidate.errors)}`,
|
|
986
1010
|
filePath,
|
|
@@ -995,9 +1019,9 @@ var SchemaValidator = class extends import_effect12.Effect.Service()("SchemaVali
|
|
|
995
1019
|
};
|
|
996
1020
|
|
|
997
1021
|
// src/services/v4-config-parser.ts
|
|
998
|
-
var
|
|
1022
|
+
var import_platform9 = require("@effect/platform");
|
|
999
1023
|
var import_build_utils = require("@gigadrive/build-utils");
|
|
1000
|
-
var
|
|
1024
|
+
var import_effect14 = require("effect");
|
|
1001
1025
|
var import_minimatch = require("minimatch");
|
|
1002
1026
|
var import_safe_regex2 = __toESM(require("safe-regex2"));
|
|
1003
1027
|
var MAX_ASSET_DEPTH = 100;
|
|
@@ -1068,7 +1092,7 @@ var mapRoute = (route, entrypoints) => ({
|
|
|
1068
1092
|
negativeRequirements: route.missing,
|
|
1069
1093
|
status: route.statusCode
|
|
1070
1094
|
});
|
|
1071
|
-
var parseEntrypoints =
|
|
1095
|
+
var parseEntrypoints = import_effect14.Effect.fn("parseEntrypoints")(function* (config, projectFolder) {
|
|
1072
1096
|
const entrypoints = [];
|
|
1073
1097
|
if (config.functions == null) return entrypoints;
|
|
1074
1098
|
for (const [fnPath, func] of Object.entries(config.functions)) {
|
|
@@ -1078,7 +1102,7 @@ var parseEntrypoints = import_effect13.Effect.fn("parseEntrypoints")(function* (
|
|
|
1078
1102
|
functionPath: fnPath
|
|
1079
1103
|
});
|
|
1080
1104
|
}
|
|
1081
|
-
const matchedFiles = yield*
|
|
1105
|
+
const matchedFiles = yield* import_effect14.Effect.tryPromise({
|
|
1082
1106
|
try: () => (0, import_build_utils.getFilesForPattern)(fnPath, projectFolder, func.excludeFiles),
|
|
1083
1107
|
catch: (error) => new FunctionConfigError({
|
|
1084
1108
|
message: `Failed to resolve files for function pattern '${fnPath}': ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1114,14 +1138,14 @@ var parseEntrypoints = import_effect13.Effect.fn("parseEntrypoints")(function* (
|
|
|
1114
1138
|
}
|
|
1115
1139
|
return entrypoints;
|
|
1116
1140
|
});
|
|
1117
|
-
var collectAssets =
|
|
1141
|
+
var collectAssets = import_effect14.Effect.fn("collectAssets")(function* (config, projectFolder) {
|
|
1118
1142
|
if (config.assets == null) return [];
|
|
1119
|
-
const fs = yield*
|
|
1120
|
-
const pathService = yield*
|
|
1143
|
+
const fs = yield* import_platform9.FileSystem.FileSystem;
|
|
1144
|
+
const pathService = yield* import_platform9.Path.Path;
|
|
1121
1145
|
const assetsPath = pathService.join(projectFolder, config.assets);
|
|
1122
|
-
const assetsExist = yield* fs.exists(assetsPath).pipe(
|
|
1146
|
+
const assetsExist = yield* fs.exists(assetsPath).pipe(import_effect14.Effect.catchAll(() => import_effect14.Effect.succeed(false)));
|
|
1123
1147
|
if (!assetsExist) return [];
|
|
1124
|
-
const stat = yield* fs.stat(assetsPath).pipe(
|
|
1148
|
+
const stat = yield* fs.stat(assetsPath).pipe(import_effect14.Effect.catchAll(() => import_effect14.Effect.succeed(null)));
|
|
1125
1149
|
if (!stat || stat.type !== "Directory") return [];
|
|
1126
1150
|
const allFiles = yield* collectFilesRecursively(assetsPath);
|
|
1127
1151
|
const assets = [];
|
|
@@ -1132,18 +1156,18 @@ var collectAssets = import_effect13.Effect.fn("collectAssets")(function* (config
|
|
|
1132
1156
|
}
|
|
1133
1157
|
return assets;
|
|
1134
1158
|
});
|
|
1135
|
-
var collectFilesRecursively =
|
|
1159
|
+
var collectFilesRecursively = import_effect14.Effect.fn("collectFilesRecursively")(
|
|
1136
1160
|
function* (basePath, relativePath = "", depth = 0) {
|
|
1137
1161
|
if (depth > MAX_ASSET_DEPTH) return [];
|
|
1138
|
-
const fs = yield*
|
|
1139
|
-
const pathSvc = yield*
|
|
1162
|
+
const fs = yield* import_platform9.FileSystem.FileSystem;
|
|
1163
|
+
const pathSvc = yield* import_platform9.Path.Path;
|
|
1140
1164
|
const currentPath = relativePath ? pathSvc.join(basePath, relativePath) : basePath;
|
|
1141
|
-
const entries = yield* fs.readDirectory(currentPath).pipe(
|
|
1165
|
+
const entries = yield* fs.readDirectory(currentPath).pipe(import_effect14.Effect.catchAll(() => import_effect14.Effect.succeed([])));
|
|
1142
1166
|
const result = [];
|
|
1143
1167
|
for (const name of entries) {
|
|
1144
1168
|
const fullPath = pathSvc.join(currentPath, name);
|
|
1145
1169
|
const entryRelative = relativePath ? pathSvc.join(relativePath, name) : name;
|
|
1146
|
-
const stat = yield* fs.stat(fullPath).pipe(
|
|
1170
|
+
const stat = yield* fs.stat(fullPath).pipe(import_effect14.Effect.catchAll(() => import_effect14.Effect.succeed(null)));
|
|
1147
1171
|
if (!stat) continue;
|
|
1148
1172
|
if (stat.type === "Directory") {
|
|
1149
1173
|
const nested = yield* collectFilesRecursively(basePath, entryRelative, depth + 1);
|
|
@@ -1155,16 +1179,16 @@ var collectFilesRecursively = import_effect13.Effect.fn("collectFilesRecursively
|
|
|
1155
1179
|
return result;
|
|
1156
1180
|
}
|
|
1157
1181
|
);
|
|
1158
|
-
var V4ConfigParser = class extends
|
|
1182
|
+
var V4ConfigParser = class extends import_effect14.Effect.Service()("V4ConfigParser", {
|
|
1159
1183
|
accessors: true,
|
|
1160
|
-
effect:
|
|
1184
|
+
effect: import_effect14.Effect.succeed({
|
|
1161
1185
|
/**
|
|
1162
1186
|
* Parses a ConfigV4 into a NormalizedConfig.
|
|
1163
1187
|
*
|
|
1164
1188
|
* @param config - The raw V4 config object
|
|
1165
1189
|
* @param projectFolder - Absolute path to the project root
|
|
1166
1190
|
*/
|
|
1167
|
-
parse:
|
|
1191
|
+
parse: import_effect14.Effect.fn("V4ConfigParser.parse")(function* (config, projectFolder) {
|
|
1168
1192
|
const entrypoints = yield* parseEntrypoints(config, projectFolder);
|
|
1169
1193
|
const assets = yield* collectAssets(config, projectFolder);
|
|
1170
1194
|
return {
|
|
@@ -1188,10 +1212,10 @@ var V4ConfigParser = class extends import_effect13.Effect.Service()("V4ConfigPar
|
|
|
1188
1212
|
};
|
|
1189
1213
|
|
|
1190
1214
|
// src/services/vercel-build-output-parser.ts
|
|
1191
|
-
var
|
|
1215
|
+
var import_platform10 = require("@effect/platform");
|
|
1192
1216
|
var import_build_utils2 = require("@gigadrive/build-utils");
|
|
1193
1217
|
var import_commons = require("@gigadrive/commons");
|
|
1194
|
-
var
|
|
1218
|
+
var import_effect15 = require("effect");
|
|
1195
1219
|
|
|
1196
1220
|
// src/build-output-v3/determine-repo-root.ts
|
|
1197
1221
|
var import_path = __toESM(require("path"));
|
|
@@ -1287,11 +1311,11 @@ var translateVercelRuntime = (runtime) => {
|
|
|
1287
1311
|
var CONFIG_PATH = ".vercel/output/config.json";
|
|
1288
1312
|
var FUNCTIONS_FOLDER = ".vercel/output/functions";
|
|
1289
1313
|
var FUNCTION_CONFIGS_PATTERN = `${FUNCTIONS_FOLDER}/**/*.func/.vc-config.json`;
|
|
1290
|
-
var VercelBuildOutputParser = class extends
|
|
1291
|
-
effect:
|
|
1314
|
+
var VercelBuildOutputParser = class extends import_effect15.Effect.Service()("VercelBuildOutputParser", {
|
|
1315
|
+
effect: import_effect15.Effect.gen(function* () {
|
|
1292
1316
|
const rawConfigReader = yield* RawConfigReader;
|
|
1293
|
-
const pathService = yield*
|
|
1294
|
-
const parse =
|
|
1317
|
+
const pathService = yield* import_platform10.Path.Path;
|
|
1318
|
+
const parse = import_effect15.Effect.fn("VercelBuildOutputParser.parse")(function* (parseResult, projectFolder) {
|
|
1295
1319
|
const config = yield* rawConfigReader.readConfigFile(pathService.join(projectFolder, CONFIG_PATH));
|
|
1296
1320
|
if (!config || typeof config.version !== "number" || config.version < 3) {
|
|
1297
1321
|
return parseResult;
|
|
@@ -1302,8 +1326,8 @@ var VercelBuildOutputParser = class extends import_effect14.Effect.Service()("Ve
|
|
|
1302
1326
|
merged.regions = [...new Set(merged.regions)];
|
|
1303
1327
|
return merged;
|
|
1304
1328
|
});
|
|
1305
|
-
const loadFunctions =
|
|
1306
|
-
const functionConfigs = yield*
|
|
1329
|
+
const loadFunctions = import_effect15.Effect.fn("VercelBuildOutputParser.loadFunctions")(function* (config, parseResult, projectFolder) {
|
|
1330
|
+
const functionConfigs = yield* import_effect15.Effect.tryPromise({
|
|
1307
1331
|
try: () => (0, import_build_utils2.getFilesForPattern)(FUNCTION_CONFIGS_PATTERN, projectFolder),
|
|
1308
1332
|
catch: (error) => new ConfigFileParseError({
|
|
1309
1333
|
message: `Failed to scan for function configs: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1759,7 +1783,7 @@ var schema_default = {
|
|
|
1759
1783
|
};
|
|
1760
1784
|
|
|
1761
1785
|
// src/parse-config.ts
|
|
1762
|
-
var parseConfigRaw =
|
|
1786
|
+
var parseConfigRaw = import_effect16.Effect.fn("parseConfigRaw")(function* (filePath, projectFolder) {
|
|
1763
1787
|
const rawReader = yield* RawConfigReader;
|
|
1764
1788
|
const validator = yield* SchemaValidator;
|
|
1765
1789
|
const v4Parser = yield* V4ConfigParser;
|
|
@@ -1770,7 +1794,7 @@ var parseConfigRaw = import_effect15.Effect.fn("parseConfigRaw")(function* (file
|
|
|
1770
1794
|
};
|
|
1771
1795
|
const schema = schemaMap[version];
|
|
1772
1796
|
if (!schema) {
|
|
1773
|
-
return yield*
|
|
1797
|
+
return yield* import_effect16.Effect.fail(
|
|
1774
1798
|
new ConfigVersionError({
|
|
1775
1799
|
message: `Config file at ${filePath} has an unsupported version: ${version}`,
|
|
1776
1800
|
filePath,
|
|
@@ -1781,11 +1805,11 @@ var parseConfigRaw = import_effect15.Effect.fn("parseConfigRaw")(function* (file
|
|
|
1781
1805
|
yield* validator.validate(parsed, schema, filePath);
|
|
1782
1806
|
return yield* v4Parser.parse(parsed, projectFolder);
|
|
1783
1807
|
});
|
|
1784
|
-
var parseConfig =
|
|
1808
|
+
var parseConfig = import_effect16.Effect.fn("parseConfig")(function* (filePath, projectFolder) {
|
|
1785
1809
|
const parseResult = yield* parseConfigRaw(filePath, projectFolder);
|
|
1786
1810
|
return yield* postProcessConfig(parseResult, projectFolder);
|
|
1787
1811
|
});
|
|
1788
|
-
var postProcessConfig =
|
|
1812
|
+
var postProcessConfig = import_effect16.Effect.fn("postProcessConfig")(function* (config, projectFolder) {
|
|
1789
1813
|
const vercelParser = yield* VercelBuildOutputParser;
|
|
1790
1814
|
let result = yield* vercelParser.parse(config, projectFolder);
|
|
1791
1815
|
if (result.entrypoints.length === 0 && (result.assets?.paths?.length || 0) === 0 && result.routes.length === 0) {
|
|
@@ -1813,9 +1837,9 @@ var RUNTIME_DEFINITIONS = [
|
|
|
1813
1837
|
var AVAILABLE_RUNTIMES = [...RUNTIME_DEFINITIONS];
|
|
1814
1838
|
|
|
1815
1839
|
// src/services/index.ts
|
|
1816
|
-
var
|
|
1817
|
-
var BaseLayers =
|
|
1818
|
-
var NetworkConfigLive = VercelBuildOutputParser.Default.pipe(
|
|
1840
|
+
var import_effect17 = require("effect");
|
|
1841
|
+
var BaseLayers = import_effect17.Layer.mergeAll(RawConfigReader.Default, SchemaValidator.Default, V4ConfigParser.Default);
|
|
1842
|
+
var NetworkConfigLive = VercelBuildOutputParser.Default.pipe(import_effect17.Layer.provideMerge(BaseLayers));
|
|
1819
1843
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1820
1844
|
0 && (module.exports = {
|
|
1821
1845
|
ALLOWED_CONFIG_NAMES,
|