@solid-stack/builder 1.1.3 → 1.1.4
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 +53 -25
- package/dist/bin.js.map +1 -1
- package/dist/core/buildSchema.d.ts +8 -0
- package/dist/core/buildSchema.d.ts.map +1 -1
- package/dist/core/compileEnvironment.d.ts.map +1 -1
- package/dist/core/mesh/checkers/checkMeshJson.d.ts.map +1 -1
- package/dist/core/mesh/compileMeshEnvironment.d.ts.map +1 -1
- package/dist/index.js +55 -26
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/extractBuildDeps.d.ts.map +1 -1
- package/package.json +1 -1
- package/schemas/build-schema.json +7 -0
|
@@ -12,12 +12,15 @@ export declare const buildPolicyConfigSchema: z.ZodObject<{
|
|
|
12
12
|
export declare const buildDependencySchema: z.ZodObject<{
|
|
13
13
|
path: z.ZodString;
|
|
14
14
|
service: z.ZodOptional<z.ZodString>;
|
|
15
|
+
port: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
15
16
|
}, "strict", z.ZodTypeAny, {
|
|
16
17
|
path: string;
|
|
17
18
|
service?: string | undefined;
|
|
19
|
+
port?: string | number | undefined;
|
|
18
20
|
}, {
|
|
19
21
|
path: string;
|
|
20
22
|
service?: string | undefined;
|
|
23
|
+
port?: string | number | undefined;
|
|
21
24
|
}>;
|
|
22
25
|
export declare const buildOverrideSchema: z.ZodObject<{
|
|
23
26
|
path: z.ZodString;
|
|
@@ -62,12 +65,15 @@ export declare const buildJsonSchema: z.ZodObject<{
|
|
|
62
65
|
dependencies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
63
66
|
path: z.ZodString;
|
|
64
67
|
service: z.ZodOptional<z.ZodString>;
|
|
68
|
+
port: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
|
|
65
69
|
}, "strict", z.ZodTypeAny, {
|
|
66
70
|
path: string;
|
|
67
71
|
service?: string | undefined;
|
|
72
|
+
port?: string | number | undefined;
|
|
68
73
|
}, {
|
|
69
74
|
path: string;
|
|
70
75
|
service?: string | undefined;
|
|
76
|
+
port?: string | number | undefined;
|
|
71
77
|
}>>>;
|
|
72
78
|
envOverrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
73
79
|
overrides: z.ZodOptional<z.ZodRecord<z.ZodEnum<["dev", "prod", "test", "e2e"]>, z.ZodObject<{
|
|
@@ -102,6 +108,7 @@ export declare const buildJsonSchema: z.ZodObject<{
|
|
|
102
108
|
dependencies?: Record<string, {
|
|
103
109
|
path: string;
|
|
104
110
|
service?: string | undefined;
|
|
111
|
+
port?: string | number | undefined;
|
|
105
112
|
}> | undefined;
|
|
106
113
|
envOverrides?: Record<string, string> | undefined;
|
|
107
114
|
overrides?: Partial<Record<"dev" | "e2e" | "prod" | "test", {
|
|
@@ -128,6 +135,7 @@ export declare const buildJsonSchema: z.ZodObject<{
|
|
|
128
135
|
dependencies?: Record<string, {
|
|
129
136
|
path: string;
|
|
130
137
|
service?: string | undefined;
|
|
138
|
+
port?: string | number | undefined;
|
|
131
139
|
}> | undefined;
|
|
132
140
|
envOverrides?: Record<string, string> | undefined;
|
|
133
141
|
overrides?: Partial<Record<"dev" | "e2e" | "prod" | "test", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildSchema.d.ts","sourceRoot":"","sources":["../../src/core/buildSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,uBAAuB;;;;;;;;;EAYgC,CAAC;AAErE,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"buildSchema.d.ts","sourceRoot":"","sources":["../../src/core/buildSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,uBAAuB;;;;;;;;;EAYgC,CAAC;AAErE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;EAea,CAAC;AAEhD,eAAO,MAAM,mBAAmB;;;;;;EAOiB,CAAC;AAElD,eAAO,MAAM,iBAAiB;;;;;;EAUS,CAAC;AAExC,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6CyC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileEnvironment.d.ts","sourceRoot":"","sources":["../../src/core/compileEnvironment.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAarD,eAAO,MAAM,kBAAkB,gBAChB,WAAW,eACZ,MAAM,YACT;IAAE,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAAE,KACjD,
|
|
1
|
+
{"version":3,"file":"compileEnvironment.d.ts","sourceRoot":"","sources":["../../src/core/compileEnvironment.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAarD,eAAO,MAAM,kBAAkB,gBAChB,WAAW,eACZ,MAAM,YACT;IAAE,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAAE,KACjD,MA4TF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkMeshJson.d.ts","sourceRoot":"","sources":["../../../../src/core/mesh/checkers/checkMeshJson.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"checkMeshJson.d.ts","sourceRoot":"","sources":["../../../../src/core/mesh/checkers/checkMeshJson.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAwEpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compileMeshEnvironment.d.ts","sourceRoot":"","sources":["../../../src/core/mesh/compileMeshEnvironment.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,kBAAkB;IACjC,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACzC,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACvC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,KAAK,GAAG,MAAM,EACpB,UAAU,GAAE,MAAsB,EAClC,OAAO,GAAE,kBAAuB,GAC/B,iBAAiB,
|
|
1
|
+
{"version":3,"file":"compileMeshEnvironment.d.ts","sourceRoot":"","sources":["../../../src/core/mesh/compileMeshEnvironment.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,kBAAkB;IACjC,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACzC,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACvC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAED,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,KAAK,GAAG,MAAM,EACpB,UAAU,GAAE,MAAsB,EAClC,OAAO,GAAE,kBAAuB,GAC/B,iBAAiB,CAm0BnB"}
|
package/dist/index.js
CHANGED
|
@@ -535,20 +535,6 @@ function checkMeshJson(mesh) {
|
|
|
535
535
|
}
|
|
536
536
|
const services = result.data.services;
|
|
537
537
|
const serviceKeys = new Set(Object.keys(services));
|
|
538
|
-
const seenPorts = /* @__PURE__ */ new Map();
|
|
539
|
-
for (const [serviceName, serviceConfig] of Object.entries(services)) {
|
|
540
|
-
if (serviceConfig.port) {
|
|
541
|
-
const portNum = Number(serviceConfig.port);
|
|
542
|
-
if (!isNaN(portNum)) {
|
|
543
|
-
if (seenPorts.has(portNum)) {
|
|
544
|
-
throw new ScriptError(
|
|
545
|
-
`Host port collision in mesh.json: Port ${portNum} is declared by both "${seenPorts.get(portNum)}" and "${serviceName}".`
|
|
546
|
-
);
|
|
547
|
-
}
|
|
548
|
-
seenPorts.set(portNum, serviceName);
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
538
|
const graph = /* @__PURE__ */ new Map();
|
|
553
539
|
for (const sName of serviceKeys) {
|
|
554
540
|
graph.set(sName, /* @__PURE__ */ new Set());
|
|
@@ -862,7 +848,8 @@ var extractBuildDeps = (buildJson, projectDir = process.cwd()) => {
|
|
|
862
848
|
z.string(),
|
|
863
849
|
z.object({
|
|
864
850
|
path: z.string(),
|
|
865
|
-
service: z.string().optional()
|
|
851
|
+
service: z.string().optional(),
|
|
852
|
+
port: z.union([z.number(), z.string()]).optional()
|
|
866
853
|
})
|
|
867
854
|
)
|
|
868
855
|
});
|
|
@@ -879,7 +866,8 @@ var extractBuildDeps = (buildJson, projectDir = process.cwd()) => {
|
|
|
879
866
|
return {
|
|
880
867
|
path: path13.resolve(projectDir, service.path),
|
|
881
868
|
name,
|
|
882
|
-
serviceName: service.service
|
|
869
|
+
serviceName: service.service,
|
|
870
|
+
port: service.port
|
|
883
871
|
};
|
|
884
872
|
}
|
|
885
873
|
);
|
|
@@ -1152,24 +1140,44 @@ function compileMeshEnvironment(mode, rawMeshDir = process.cwd(), options = {})
|
|
|
1152
1140
|
const globalDepAliasToProvider = /* @__PURE__ */ new Map();
|
|
1153
1141
|
const INTERNAL_PORT = 3e3;
|
|
1154
1142
|
const serviceUrls = /* @__PURE__ */ new Map();
|
|
1143
|
+
const allocatedPorts = /* @__PURE__ */ new Map();
|
|
1144
|
+
function claimPort(portVal, ownerDesc) {
|
|
1145
|
+
if (!portVal) return;
|
|
1146
|
+
const portStr = String(portVal);
|
|
1147
|
+
const hostPort = portStr.includes(":") ? portStr.split(":")[0] : portStr;
|
|
1148
|
+
if (!hostPort) return;
|
|
1149
|
+
if (allocatedPorts.has(hostPort)) {
|
|
1150
|
+
throw new ScriptError(
|
|
1151
|
+
`\u274C Port Collision Detected: Host port ${hostPort} is requested by both [${allocatedPorts.get(hostPort)}] and [${ownerDesc}].`
|
|
1152
|
+
);
|
|
1153
|
+
}
|
|
1154
|
+
allocatedPorts.set(hostPort, ownerDesc);
|
|
1155
|
+
}
|
|
1155
1156
|
for (const [serviceName, serviceConfig] of Object.entries(mesh.services)) {
|
|
1156
1157
|
const serviceDir = path13.resolve(meshDir, serviceConfig.path);
|
|
1157
1158
|
const serviceBuildJson = getBuildJson(serviceDir);
|
|
1159
|
+
const serviceDeps = extractBuildDeps(serviceBuildJson, serviceDir);
|
|
1158
1160
|
let publicPort = null;
|
|
1159
1161
|
if (serviceConfig.port !== void 0 && serviceConfig.port !== null && serviceConfig.port !== "") {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
publicPort = p;
|
|
1163
|
-
}
|
|
1162
|
+
publicPort = serviceConfig.port;
|
|
1163
|
+
claimPort(publicPort, `mesh service "${serviceName}"`);
|
|
1164
1164
|
} else if (serviceConfig.preservePort && serviceBuildJson.port) {
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1165
|
+
publicPort = serviceBuildJson.port;
|
|
1166
|
+
claimPort(publicPort, `mesh service "${serviceName}" (via preservePort)`);
|
|
1167
|
+
}
|
|
1168
|
+
const provideMap = {
|
|
1169
|
+
...serviceConfig.replaceMocks || {},
|
|
1170
|
+
...serviceConfig.provideDependency || {}
|
|
1171
|
+
};
|
|
1172
|
+
for (const dep of serviceDeps) {
|
|
1173
|
+
if (!provideMap[dep.name] && !(mesh.dependencies && mesh.dependencies[dep.name]) && dep.port) {
|
|
1174
|
+
claimPort(dep.port, `local dependency "${dep.name}" of service "${serviceName}"`);
|
|
1168
1175
|
}
|
|
1169
1176
|
}
|
|
1177
|
+
const hostPort = publicPort ? String(publicPort).includes(":") ? String(publicPort).split(":")[0] : String(publicPort) : null;
|
|
1170
1178
|
serviceUrls.set(serviceName, {
|
|
1171
1179
|
networkUrl: `http://${serviceName}:${INTERNAL_PORT}`,
|
|
1172
|
-
publicUrl:
|
|
1180
|
+
publicUrl: hostPort ? `http://localhost:${hostPort}` : null
|
|
1173
1181
|
});
|
|
1174
1182
|
}
|
|
1175
1183
|
function escapeRegExp(string) {
|
|
@@ -1453,6 +1461,10 @@ function compileMeshEnvironment(mode, rawMeshDir = process.cwd(), options = {})
|
|
|
1453
1461
|
delete resolvedMock.container_name;
|
|
1454
1462
|
normalizeDependsOn(resolvedMock);
|
|
1455
1463
|
applyInternalMockDependsOnMapping(resolvedMock, sidecarMapping);
|
|
1464
|
+
if (dep.port) {
|
|
1465
|
+
const portMapping = String(dep.port).includes(":") ? String(dep.port) : `${dep.port}:3000`;
|
|
1466
|
+
resolvedMock.ports = [...resolvedMock.ports || [], portMapping];
|
|
1467
|
+
}
|
|
1456
1468
|
resolvedMock.networks = {
|
|
1457
1469
|
[`${serviceName}_net`]: {
|
|
1458
1470
|
aliases: [depKey, namespacedDepKey]
|
|
@@ -2718,9 +2730,11 @@ ${explanation}`);
|
|
|
2718
2730
|
urlRegistry.set(buildJson.name, urlRegistry.get("app"));
|
|
2719
2731
|
}
|
|
2720
2732
|
for (const dep of dependencies) {
|
|
2733
|
+
const depPortStr = dep.port ? String(dep.port) : null;
|
|
2734
|
+
const depHostPort = depPortStr ? depPortStr.includes(":") ? depPortStr.split(":")[0] : depPortStr : null;
|
|
2721
2735
|
urlRegistry.set(dep.name, {
|
|
2722
2736
|
networkUrl: `http://${dep.name}:${INTERNAL_PORT}`,
|
|
2723
|
-
publicUrl: null
|
|
2737
|
+
publicUrl: depHostPort ? `http://localhost:${depHostPort}` : null
|
|
2724
2738
|
});
|
|
2725
2739
|
}
|
|
2726
2740
|
const interpolateEnv = (val, context) => {
|
|
@@ -2794,6 +2808,20 @@ ${explanation}`);
|
|
|
2794
2808
|
yml.services.tester.environment[k] = interpolateEnv(v, "Tester EnvOverrides");
|
|
2795
2809
|
}
|
|
2796
2810
|
}
|
|
2811
|
+
if (yml.services) {
|
|
2812
|
+
for (const dep of dependencies) {
|
|
2813
|
+
if (dep.port) {
|
|
2814
|
+
let targetSvc = dep.serviceName && yml.services[dep.serviceName] ? dep.serviceName : dep.name;
|
|
2815
|
+
if (!yml.services[targetSvc]) {
|
|
2816
|
+
targetSvc = Object.keys(yml.services).find((k) => k !== "app" && k !== "tester") || targetSvc;
|
|
2817
|
+
}
|
|
2818
|
+
if (yml.services[targetSvc]) {
|
|
2819
|
+
const portMapping = String(dep.port).includes(":") ? String(dep.port) : `${dep.port}:3000`;
|
|
2820
|
+
yml.services[targetSvc].ports = [...yml.services[targetSvc].ports || [], portMapping];
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2797
2825
|
attachName(yml, projectName);
|
|
2798
2826
|
const finalYamlConfig = stringify(yml);
|
|
2799
2827
|
return finalYamlConfig;
|
|
@@ -3612,7 +3640,8 @@ var buildPolicyConfigSchema = z.object({
|
|
|
3612
3640
|
}).strict().describe("Policy configurations for infra/contract verification");
|
|
3613
3641
|
var buildDependencySchema = z.object({
|
|
3614
3642
|
path: z.string({ required_error: 'Dependency "path" is required' }).describe("Relative path to mock Docker Compose file"),
|
|
3615
|
-
service: z.string().optional().describe("Target service name in the mock compose file")
|
|
3643
|
+
service: z.string().optional().describe("Target service name in the mock compose file"),
|
|
3644
|
+
port: z.union([z.number(), z.string()]).optional().describe("Host port to map to this dependency locally")
|
|
3616
3645
|
}).strict().describe("Service dependency specification");
|
|
3617
3646
|
var buildOverrideSchema = z.object({
|
|
3618
3647
|
path: z.string({ required_error: 'Override "path" is required' }).describe("Relative path to the environment stage override file")
|