@solid-stack/builder 1.1.1 → 1.1.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 +51 -42
- package/dist/bin.js.map +1 -1
- package/dist/core/buildSchema.d.ts +3 -0
- package/dist/core/buildSchema.d.ts.map +1 -1
- package/dist/core/compileEnvironment.d.ts.map +1 -1
- package/dist/index.js +52 -42
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/schemas/build-schema.json +7 -0
package/dist/bin.js
CHANGED
|
@@ -2688,49 +2688,49 @@ ${explanation}`);
|
|
|
2688
2688
|
if (environment === "e2e") {
|
|
2689
2689
|
makeE2eDependOnApp(yml);
|
|
2690
2690
|
}
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2691
|
+
const INTERNAL_PORT = 3e3;
|
|
2692
|
+
const urlRegistry = /* @__PURE__ */ new Map();
|
|
2693
|
+
const appPublicPort = buildJson.port ? Number(buildJson.port) : null;
|
|
2694
|
+
urlRegistry.set("app", {
|
|
2695
|
+
networkUrl: `http://app:${INTERNAL_PORT}`,
|
|
2696
|
+
publicUrl: appPublicPort ? `http://localhost:${appPublicPort}` : null
|
|
2697
|
+
});
|
|
2698
|
+
if (buildJson.name && buildJson.name !== "app") {
|
|
2699
|
+
urlRegistry.set(buildJson.name, urlRegistry.get("app"));
|
|
2700
|
+
}
|
|
2701
|
+
for (const dep of dependencies) {
|
|
2702
|
+
urlRegistry.set(dep.name, {
|
|
2703
|
+
networkUrl: `http://${dep.name}:${INTERNAL_PORT}`,
|
|
2704
|
+
publicUrl: null
|
|
2698
2705
|
});
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
for (const
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
let output = val;
|
|
2710
|
-
for (const [sName, urls] of urlRegistry.entries()) {
|
|
2711
|
-
const escaped = sName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2706
|
+
}
|
|
2707
|
+
const interpolateEnv = (val, context) => {
|
|
2708
|
+
let output = val;
|
|
2709
|
+
for (const [sName, urls] of urlRegistry.entries()) {
|
|
2710
|
+
const escaped = sName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2711
|
+
output = output.replace(
|
|
2712
|
+
new RegExp(`\\$\\{${escaped}\\.network_url\\}`, "g"),
|
|
2713
|
+
urls.networkUrl
|
|
2714
|
+
);
|
|
2715
|
+
if (urls.publicUrl) {
|
|
2712
2716
|
output = output.replace(
|
|
2713
|
-
new RegExp(`\\$\\{${escaped}\\.
|
|
2714
|
-
urls.
|
|
2715
|
-
);
|
|
2716
|
-
if (urls.publicUrl) {
|
|
2717
|
-
output = output.replace(
|
|
2718
|
-
new RegExp(`\\$\\{${escaped}\\.public_url\\}`, "g"),
|
|
2719
|
-
urls.publicUrl
|
|
2720
|
-
);
|
|
2721
|
-
}
|
|
2722
|
-
}
|
|
2723
|
-
const unresolvedMatch = output.match(/\$\{([^}]+?)\.(network_url|public_url)\}/);
|
|
2724
|
-
if (unresolvedMatch) {
|
|
2725
|
-
throw new ScriptError(
|
|
2726
|
-
`[Local E2E Tester] Unresolved template variable: ${unresolvedMatch[0]}. Check build.json dependencies.`
|
|
2717
|
+
new RegExp(`\\$\\{${escaped}\\.public_url\\}`, "g"),
|
|
2718
|
+
urls.publicUrl
|
|
2727
2719
|
);
|
|
2728
2720
|
}
|
|
2729
|
-
|
|
2730
|
-
};
|
|
2731
|
-
if (
|
|
2721
|
+
}
|
|
2722
|
+
const unresolvedMatch = output.match(/\$\{([^}]+?)\.(network_url|public_url)\}/);
|
|
2723
|
+
if (unresolvedMatch) {
|
|
2724
|
+
throw new ScriptError(
|
|
2725
|
+
`[${context}] Unresolved template variable: ${unresolvedMatch[0]}. Check build.json dependencies.`
|
|
2726
|
+
);
|
|
2727
|
+
}
|
|
2728
|
+
return output;
|
|
2729
|
+
};
|
|
2730
|
+
const normalizeEnvironment = (serviceConfig) => {
|
|
2731
|
+
if (Array.isArray(serviceConfig.environment)) {
|
|
2732
2732
|
const envObj = {};
|
|
2733
|
-
for (const item of
|
|
2733
|
+
for (const item of serviceConfig.environment) {
|
|
2734
2734
|
if (typeof item === "string") {
|
|
2735
2735
|
const eqIdx = item.indexOf("=");
|
|
2736
2736
|
if (eqIdx !== -1) {
|
|
@@ -2740,12 +2740,21 @@ ${explanation}`);
|
|
|
2740
2740
|
}
|
|
2741
2741
|
}
|
|
2742
2742
|
}
|
|
2743
|
-
|
|
2744
|
-
} else if (!
|
|
2745
|
-
|
|
2743
|
+
serviceConfig.environment = envObj;
|
|
2744
|
+
} else if (!serviceConfig.environment || typeof serviceConfig.environment !== "object") {
|
|
2745
|
+
serviceConfig.environment = {};
|
|
2746
2746
|
}
|
|
2747
|
+
};
|
|
2748
|
+
if (buildJson.envOverrides && yml.services && yml.services.app) {
|
|
2749
|
+
normalizeEnvironment(yml.services.app);
|
|
2750
|
+
for (const [k, v] of Object.entries(buildJson.envOverrides)) {
|
|
2751
|
+
yml.services.app.environment[k] = interpolateEnv(v, "App EnvOverrides");
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
if (buildJson.tester?.envOverrides && yml.services && yml.services.tester) {
|
|
2755
|
+
normalizeEnvironment(yml.services.tester);
|
|
2747
2756
|
for (const [k, v] of Object.entries(buildJson.tester.envOverrides)) {
|
|
2748
|
-
yml.services.tester.environment[k] = interpolateEnv(v);
|
|
2757
|
+
yml.services.tester.environment[k] = interpolateEnv(v, "Tester EnvOverrides");
|
|
2749
2758
|
}
|
|
2750
2759
|
}
|
|
2751
2760
|
attachName(yml, projectName);
|