@solid-stack/builder 2.0.1 → 2.0.2

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/bin.js CHANGED
@@ -656,6 +656,52 @@ function rebaseComposePaths(document, composeFilePath, outputProjectDir) {
656
656
  for (const kind of ["configs", "secrets"]) for (const def of Object.values(doc[kind] ?? {})) if (def && typeof def === "object" && typeof def.file === "string") def.file = rebase(def.file, base, out);
657
657
  return doc;
658
658
  }
659
+ function rebaseAppOverridePaths(document, serviceProjectDir, outputProjectDir) {
660
+ const doc = structuredClone(document);
661
+ const base = path.resolve(serviceProjectDir);
662
+ const out = path.resolve(outputProjectDir);
663
+ for (const svc of Object.values(doc.services ?? {})) {
664
+ if (svc.build && typeof svc.build === "object" && !Array.isArray(svc.build)) {
665
+ const build = svc.build;
666
+ if (typeof build.context === "string") {
667
+ build.context = rebase(build.context, base, out);
668
+ }
669
+ }
670
+ if (typeof svc.env_file === "string") {
671
+ svc.env_file = rebase(svc.env_file, base, out);
672
+ } else if (Array.isArray(svc.env_file)) {
673
+ svc.env_file = svc.env_file.map((entry) => {
674
+ if (typeof entry === "string") return rebase(entry, base, out);
675
+ if (entry && typeof entry === "object") {
676
+ const value = entry;
677
+ if (typeof value.path === "string") return { ...value, path: rebase(value.path, base, out) };
678
+ }
679
+ return entry;
680
+ });
681
+ }
682
+ if (Array.isArray(svc.volumes)) {
683
+ svc.volumes = svc.volumes.map((volume) => {
684
+ if (typeof volume === "string") return volumeShort(volume, base, out);
685
+ if (volume && typeof volume === "object") {
686
+ const value = volume;
687
+ if (value.type === "bind" && typeof value.source === "string") {
688
+ return { ...value, source: rebase(value.source, base, out) };
689
+ }
690
+ }
691
+ return volume;
692
+ });
693
+ }
694
+ }
695
+ for (const kind of ["configs", "secrets"]) {
696
+ for (const definition of Object.values(doc[kind] ?? {})) {
697
+ if (definition && typeof definition === "object") {
698
+ const value = definition;
699
+ if (typeof value.file === "string") value.file = rebase(value.file, base, out);
700
+ }
701
+ }
702
+ }
703
+ return doc;
704
+ }
659
705
 
660
706
  // src/core/composition/composeEnvironment.ts
661
707
  function normalizeComposeEnvironment(value, context) {
@@ -779,11 +825,15 @@ function validateDependencyCompose(dependencyKey, dependency, document, context)
779
825
  if (!health || health.disable === true || !health.test || typeof health.test === "string" && !health.test.trim() || Array.isArray(health.test) && (!health.test.length || health.test[0] === "NONE" || health.test.every((v) => typeof v === "string" && !v.trim()))) fail(`services.${owner}.healthcheck`, `endpoint owner requires an enabled, non-empty healthcheck`);
780
826
  }
781
827
  }
782
-
783
- // src/core/composition/validateOverrideCompose.ts
828
+ function canonicalBuildContext(value, baseDir) {
829
+ return canonicalPath(path.resolve(baseDir, value));
830
+ }
831
+ function isSameBuildContext(actual, expected, baseDir) {
832
+ return canonicalBuildContext(actual, baseDir) === canonicalBuildContext(expected, baseDir);
833
+ }
784
834
  function validateAndPrepareAppOverride(document, context) {
785
- const fail = (path19, reason, value) => {
786
- throw new ConfigError({ sourceFile: context.file, configPath: path19, stage: context.stage, composition: "service", ...{} , reason });
835
+ const fail = (path20, reason, value) => {
836
+ throw new ConfigError({ sourceFile: context.file, configPath: path20, stage: context.stage, composition: "service", ...value === void 0 ? {} : { value }, reason });
787
837
  };
788
838
  const keys = Object.keys(document.services ?? {});
789
839
  if (keys.length !== 1 || keys[0] !== "app") fail("services", "override must define exactly one service named app");
@@ -793,10 +843,24 @@ function validateAndPrepareAppOverride(document, context) {
793
843
  const health = app.healthcheck;
794
844
  for (const key of Object.keys(health)) if (!["interval", "timeout", "retries", "start_period", "start_interval"].includes(key)) fail(`services.app.healthcheck.${key}`, "override may set only healthcheck timing fields");
795
845
  }
846
+ if (typeof app.build === "string") {
847
+ fail("services.app.build", "override cannot replace Builder-owned app build context; use object-form build.args for build arguments", app.build);
848
+ }
796
849
  if (app.build && typeof app.build === "object") {
797
- const b = app.build;
798
- for (const k of ["target", "dockerfile"]) if (b[k] !== void 0) fail(`services.app.build.${k}`, "override cannot change Builder-owned build configuration");
799
- if (b.context !== void 0 && b.context !== "." && b.context !== context.expectedBuildContext) fail("services.app.build.context", "override cannot change app build context");
850
+ const build = app.build;
851
+ for (const key of ["target", "dockerfile"]) {
852
+ if (build[key] !== void 0) {
853
+ fail(`services.app.build.${key}`, "override cannot change Builder-owned build configuration");
854
+ }
855
+ }
856
+ if (build.context !== void 0) {
857
+ if (typeof build.context !== "string") {
858
+ fail("services.app.build.context", "override app build context must be a string", build.context);
859
+ }
860
+ if (!isSameBuildContext(build.context, context.expectedBuildContext, context.buildContextBaseDir)) {
861
+ fail("services.app.build.context", "override cannot change app build context", build.context);
862
+ }
863
+ }
800
864
  }
801
865
  const env = normalizeComposeEnvironment(app.environment, "services.app.environment");
802
866
  for (const k of ["EXEC_MODE", "INFRA_MODE"]) if (k in env) fail(`services.app.environment.${k}`, "override cannot set Builder-owned environment");
@@ -1048,9 +1112,24 @@ function compileServiceComposition(stage, projectDir, options = {}) {
1048
1112
  for (const [epName, ep] of Object.entries(depEndpoints[key])) dependency.endpoints[epName] = ep;
1049
1113
  }
1050
1114
  if (effective.overrideCompose) {
1051
- const overridePath = resolveInsideProject(root, effective.overrideCompose, { sourceFile: buildPath, configPath: "override-compose", stage });
1052
- const odoc = rebaseComposePaths(loadComposeDocument(overridePath, { sourceFile: buildPath, configPath: "override-compose", stage, composition: "service" }), overridePath, options.composeOutputDir ?? root);
1053
- const prepared = validateAndPrepareAppOverride(odoc, { file: overridePath, stage, expectedBuildContext: options.meshMode ? path.relative(options.composeOutputDir ?? root, root).replace(/\\/g, "/") || "." : "." });
1115
+ const overridePath = resolveInsideProject(root, effective.overrideCompose, {
1116
+ sourceFile: buildPath,
1117
+ configPath: "override-compose",
1118
+ stage
1119
+ });
1120
+ const loadedOverride = loadComposeDocument(overridePath, {
1121
+ sourceFile: buildPath,
1122
+ configPath: "override-compose",
1123
+ stage,
1124
+ composition: "service"
1125
+ });
1126
+ const overrideDocument = rebaseAppOverridePaths(loadedOverride, root, outputDir);
1127
+ const prepared = validateAndPrepareAppOverride(overrideDocument, {
1128
+ file: overridePath,
1129
+ stage,
1130
+ expectedBuildContext: String(appBuild.context),
1131
+ buildContextBaseDir: outputDir
1132
+ });
1054
1133
  for (const section of ["volumes", "networks", "configs", "secrets"]) if (prepared.resources[section]) mergeDocument(compose, { services: {}, [section]: prepared.resources[section] }, "app override");
1055
1134
  const rawOverrideEnv = normalizeComposeEnvironment(prepared.app.environment, "override-compose.services.app.environment");
1056
1135
  const overrideEnv = options.deferReferenceResolution ? rawOverrideEnv : resolveEnv(rawOverrideEnv, registry, "override-compose.services.app.environment");