@solid-stack/builder 1.1.2 → 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 +229 -153
- package/dist/bin.js.map +1 -1
- package/dist/commands/mesh/commands/up/command.d.ts.map +1 -1
- package/dist/commands/service/commands/up/command.d.ts.map +1 -1
- package/dist/commands/service/commands/up/handler.d.ts.map +1 -1
- package/dist/core/RunOptions.d.ts +3 -2
- package/dist/core/RunOptions.d.ts.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 +3 -1
- package/dist/core/compileEnvironment.d.ts.map +1 -1
- package/dist/core/mesh/MeshRunOptions.d.ts +1 -0
- package/dist/core/mesh/MeshRunOptions.d.ts.map +1 -1
- package/dist/core/mesh/checkers/checkMeshJson.d.ts.map +1 -1
- package/dist/core/mesh/compileMeshEnvironment.d.ts +1 -0
- package/dist/core/mesh/compileMeshEnvironment.d.ts.map +1 -1
- package/dist/core/mesh/runners/runMeshDev.d.ts.map +1 -1
- package/dist/core/mesh/runners/runMeshProd.d.ts.map +1 -1
- package/dist/core/mesh/runners/runMeshTest.d.ts.map +1 -1
- package/dist/core/mesh/runners/runMeshTestE2e.d.ts.map +1 -1
- package/dist/core/runners/runDev.d.ts.map +1 -1
- package/dist/core/runners/runProd.d.ts.map +1 -1
- package/dist/core/runners/runTestE2e.d.ts.map +1 -1
- package/dist/core/runners/runTestUnit.d.ts.map +1 -1
- package/dist/index.js +231 -154
- package/dist/index.js.map +1 -1
- package/dist/templates/docker/docker-compose.e2e.yml +2 -2
- package/dist/types/index.d.ts +3 -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
- package/templates/docker/docker-compose.e2e.yml +2 -2
package/dist/bin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
import
|
|
3
|
+
import pc22 from 'picocolors';
|
|
4
4
|
import fs, { existsSync, readFileSync, unlinkSync, mkdirSync, writeFileSync, statSync } from 'fs';
|
|
5
5
|
import path13 from 'path';
|
|
6
6
|
import { spawnSync, spawn } from 'child_process';
|
|
@@ -151,7 +151,7 @@ function runStep(executable, args, projectDir, ctx) {
|
|
|
151
151
|
if (stderr) process.stderr.write(stderr);
|
|
152
152
|
if (result.error || result.status !== 0) {
|
|
153
153
|
console.error("\n" + "=".repeat(60));
|
|
154
|
-
console.error(
|
|
154
|
+
console.error(pc22.red(`\u{1F6A8} INFRASTRUCTURE CHECK FAILED \u{1F6A8}`));
|
|
155
155
|
console.error("=".repeat(60));
|
|
156
156
|
console.error(`Failed Step : ${ctx.stepName}`);
|
|
157
157
|
if (ctx.targetFile) {
|
|
@@ -189,12 +189,12 @@ function checkDockerfile(buildJson, projectDir) {
|
|
|
189
189
|
);
|
|
190
190
|
}
|
|
191
191
|
console.log(
|
|
192
|
-
|
|
192
|
+
pc22.yellow(`\u26A0\uFE0F No ${dockerfileRel} found in project directory. Skipping Dockerfile checks.`)
|
|
193
193
|
);
|
|
194
194
|
return;
|
|
195
195
|
}
|
|
196
196
|
const content = readFileSync(dockerfilePath, "utf-8");
|
|
197
|
-
console.log(
|
|
197
|
+
console.log(pc22.cyan(`
|
|
198
198
|
\u{1F50D} Linting Dockerfile (${dockerfileRel})...`));
|
|
199
199
|
runStep(
|
|
200
200
|
"docker",
|
|
@@ -217,7 +217,7 @@ function checkDockerfileContract(buildJson, projectDir) {
|
|
|
217
217
|
if (!existsSync(dockerfilePath) || !existsSync(policyDir)) {
|
|
218
218
|
return;
|
|
219
219
|
}
|
|
220
|
-
console.log(
|
|
220
|
+
console.log(pc22.cyan(`
|
|
221
221
|
\u{1F50D} Validating Dockerfile Contract (${policyRel})...`));
|
|
222
222
|
runStep(
|
|
223
223
|
"docker",
|
|
@@ -285,7 +285,7 @@ function checkYamlFiles(buildJson, projectDir) {
|
|
|
285
285
|
return;
|
|
286
286
|
}
|
|
287
287
|
console.log(
|
|
288
|
-
|
|
288
|
+
pc22.cyan(
|
|
289
289
|
`
|
|
290
290
|
\u{1F50D} Validating Declared YAML Files (${declaredFiles.length} file${declaredFiles.length === 1 ? "" : "s"})...`
|
|
291
291
|
)
|
|
@@ -342,7 +342,7 @@ function checkComposeContract(buildJson, projectDir) {
|
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
344
|
const relativePaths = existingFiles.map((f) => f.relativePath);
|
|
345
|
-
console.log(
|
|
345
|
+
console.log(pc22.cyan(`
|
|
346
346
|
\u{1F50D} Validating Compose Contract (${policyRel})...`));
|
|
347
347
|
runStep(
|
|
348
348
|
"docker",
|
|
@@ -378,7 +378,7 @@ function checkInfra(projectDir = process.cwd()) {
|
|
|
378
378
|
checkDockerfileContract(buildJson, absProjectDir);
|
|
379
379
|
checkYamlFiles(buildJson, absProjectDir);
|
|
380
380
|
checkComposeContract(buildJson, absProjectDir);
|
|
381
|
-
console.log(
|
|
381
|
+
console.log(pc22.green("\n\u2705 All infrastructure and contract checks passed.\n"));
|
|
382
382
|
}
|
|
383
383
|
function checkDependencies() {
|
|
384
384
|
const composeCheck = spawnSync(
|
|
@@ -420,7 +420,7 @@ function checkDependencies() {
|
|
|
420
420
|
const count = (networkCheck.stdout || "").trim().split("\n").filter(Boolean).length;
|
|
421
421
|
if (count > 25) {
|
|
422
422
|
console.warn(
|
|
423
|
-
|
|
423
|
+
pc22.yellow(
|
|
424
424
|
`
|
|
425
425
|
\u26A0\uFE0F High Docker Network Count Warning: Detected ${count} networks. Docker's default address pool can become exhausted, resulting in "could not find an available, non-overlapping IPv4 address pool" errors.
|
|
426
426
|
To resolve, run "builder prune" or "docker network prune -f", or configure default-address-pools in /etc/docker/daemon.json.
|
|
@@ -527,20 +527,6 @@ function checkMeshJson(mesh) {
|
|
|
527
527
|
}
|
|
528
528
|
const services = result.data.services;
|
|
529
529
|
const serviceKeys = new Set(Object.keys(services));
|
|
530
|
-
const seenPorts = /* @__PURE__ */ new Map();
|
|
531
|
-
for (const [serviceName, serviceConfig] of Object.entries(services)) {
|
|
532
|
-
if (serviceConfig.port) {
|
|
533
|
-
const portNum = Number(serviceConfig.port);
|
|
534
|
-
if (!isNaN(portNum)) {
|
|
535
|
-
if (seenPorts.has(portNum)) {
|
|
536
|
-
throw new ScriptError(
|
|
537
|
-
`Host port collision in mesh.json: Port ${portNum} is declared by both "${seenPorts.get(portNum)}" and "${serviceName}".`
|
|
538
|
-
);
|
|
539
|
-
}
|
|
540
|
-
seenPorts.set(portNum, serviceName);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
530
|
const graph = /* @__PURE__ */ new Map();
|
|
545
531
|
for (const sName of serviceKeys) {
|
|
546
532
|
graph.set(sName, /* @__PURE__ */ new Set());
|
|
@@ -621,8 +607,8 @@ function checkMeshServices(mesh, meshDir = process.cwd()) {
|
|
|
621
607
|
const absMeshDir = resolveProjectDir(meshDir);
|
|
622
608
|
const serviceNames = Object.keys(mesh.services);
|
|
623
609
|
console.log(
|
|
624
|
-
|
|
625
|
-
|
|
610
|
+
pc22.bold(
|
|
611
|
+
pc22.cyan(
|
|
626
612
|
`
|
|
627
613
|
\u{1F50D} Checking Mesh Services (${serviceNames.length} service${serviceNames.length === 1 ? "" : "s"})...`
|
|
628
614
|
)
|
|
@@ -656,7 +642,7 @@ function checkMeshServices(mesh, meshDir = process.cwd()) {
|
|
|
656
642
|
);
|
|
657
643
|
}
|
|
658
644
|
console.log(
|
|
659
|
-
|
|
645
|
+
pc22.bold(pc22.blue(`
|
|
660
646
|
--- Validating Infrastructure for [${serviceName}] ---`))
|
|
661
647
|
);
|
|
662
648
|
checkInfra(serviceDir);
|
|
@@ -690,7 +676,7 @@ function checkMeshTester(mesh, meshDir = process.cwd(), options = {}) {
|
|
|
690
676
|
);
|
|
691
677
|
}
|
|
692
678
|
console.log(
|
|
693
|
-
|
|
679
|
+
pc22.bold(pc22.cyan(`
|
|
694
680
|
\u{1F50D} Checking E2E Tester (${testerConfig.path})...`))
|
|
695
681
|
);
|
|
696
682
|
const composeRel = testerConfig.compose || "docker-compose.yml";
|
|
@@ -720,7 +706,7 @@ function checkMeshTester(mesh, meshDir = process.cwd(), options = {}) {
|
|
|
720
706
|
);
|
|
721
707
|
}
|
|
722
708
|
const dockerfileContent = readFileSync(dockerfilePath, "utf-8");
|
|
723
|
-
console.log(
|
|
709
|
+
console.log(pc22.cyan(`
|
|
724
710
|
\u{1F50D} Linting E2E Tester Dockerfile (${dockerfileRel})...`));
|
|
725
711
|
runStep(
|
|
726
712
|
"docker",
|
|
@@ -736,7 +722,7 @@ function checkMeshTester(mesh, meshDir = process.cwd(), options = {}) {
|
|
|
736
722
|
const dockerfilePolicyDir = path13.resolve(absTesterDir, dockerfilePolicyRel);
|
|
737
723
|
if (existsSync(dockerfilePolicyDir)) {
|
|
738
724
|
console.log(
|
|
739
|
-
|
|
725
|
+
pc22.cyan(
|
|
740
726
|
`
|
|
741
727
|
\u{1F50D} Validating Tester Dockerfile Contract (${dockerfilePolicyRel})...`
|
|
742
728
|
)
|
|
@@ -766,7 +752,7 @@ function checkMeshTester(mesh, meshDir = process.cwd(), options = {}) {
|
|
|
766
752
|
const composePolicyDir = path13.resolve(absTesterDir, composePolicyRel);
|
|
767
753
|
if (existsSync(composePolicyDir)) {
|
|
768
754
|
console.log(
|
|
769
|
-
|
|
755
|
+
pc22.cyan(`
|
|
770
756
|
\u{1F50D} Validating Tester Compose Contract (${composePolicyRel})...`)
|
|
771
757
|
);
|
|
772
758
|
runStep(
|
|
@@ -791,7 +777,7 @@ function checkMeshTester(mesh, meshDir = process.cwd(), options = {}) {
|
|
|
791
777
|
{ stepName: "E2E Tester Compose Contract", targetFile: composeRel }
|
|
792
778
|
);
|
|
793
779
|
}
|
|
794
|
-
console.log(
|
|
780
|
+
console.log(pc22.green(`\u2705 E2E tester configuration and contracts verified.
|
|
795
781
|
`));
|
|
796
782
|
}
|
|
797
783
|
|
|
@@ -802,8 +788,8 @@ function checkMesh(meshDir = process.cwd(), options = {}) {
|
|
|
802
788
|
checkMeshServices(mesh, absMeshDir);
|
|
803
789
|
checkMeshTester(mesh, absMeshDir, { required: Boolean(options.requireTester) });
|
|
804
790
|
console.log(
|
|
805
|
-
|
|
806
|
-
|
|
791
|
+
pc22.bold(
|
|
792
|
+
pc22.green("\n\u{1F389} All mesh infrastructure, services, and contract checks passed!\n")
|
|
807
793
|
)
|
|
808
794
|
);
|
|
809
795
|
}
|
|
@@ -854,7 +840,8 @@ var extractBuildDeps = (buildJson, projectDir = process.cwd()) => {
|
|
|
854
840
|
z.string(),
|
|
855
841
|
z.object({
|
|
856
842
|
path: z.string(),
|
|
857
|
-
service: z.string().optional()
|
|
843
|
+
service: z.string().optional(),
|
|
844
|
+
port: z.union([z.number(), z.string()]).optional()
|
|
858
845
|
})
|
|
859
846
|
)
|
|
860
847
|
});
|
|
@@ -871,7 +858,8 @@ var extractBuildDeps = (buildJson, projectDir = process.cwd()) => {
|
|
|
871
858
|
return {
|
|
872
859
|
path: path13.resolve(projectDir, service.path),
|
|
873
860
|
name,
|
|
874
|
-
serviceName: service.service
|
|
861
|
+
serviceName: service.service,
|
|
862
|
+
port: service.port
|
|
875
863
|
};
|
|
876
864
|
}
|
|
877
865
|
);
|
|
@@ -1144,24 +1132,44 @@ function compileMeshEnvironment(mode, rawMeshDir = process.cwd(), options = {})
|
|
|
1144
1132
|
const globalDepAliasToProvider = /* @__PURE__ */ new Map();
|
|
1145
1133
|
const INTERNAL_PORT = 3e3;
|
|
1146
1134
|
const serviceUrls = /* @__PURE__ */ new Map();
|
|
1135
|
+
const allocatedPorts = /* @__PURE__ */ new Map();
|
|
1136
|
+
function claimPort(portVal, ownerDesc) {
|
|
1137
|
+
if (!portVal) return;
|
|
1138
|
+
const portStr = String(portVal);
|
|
1139
|
+
const hostPort = portStr.includes(":") ? portStr.split(":")[0] : portStr;
|
|
1140
|
+
if (!hostPort) return;
|
|
1141
|
+
if (allocatedPorts.has(hostPort)) {
|
|
1142
|
+
throw new ScriptError(
|
|
1143
|
+
`\u274C Port Collision Detected: Host port ${hostPort} is requested by both [${allocatedPorts.get(hostPort)}] and [${ownerDesc}].`
|
|
1144
|
+
);
|
|
1145
|
+
}
|
|
1146
|
+
allocatedPorts.set(hostPort, ownerDesc);
|
|
1147
|
+
}
|
|
1147
1148
|
for (const [serviceName, serviceConfig] of Object.entries(mesh.services)) {
|
|
1148
1149
|
const serviceDir = path13.resolve(meshDir, serviceConfig.path);
|
|
1149
1150
|
const serviceBuildJson = getBuildJson(serviceDir);
|
|
1151
|
+
const serviceDeps = extractBuildDeps(serviceBuildJson, serviceDir);
|
|
1150
1152
|
let publicPort = null;
|
|
1151
1153
|
if (serviceConfig.port !== void 0 && serviceConfig.port !== null && serviceConfig.port !== "") {
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
publicPort = p;
|
|
1155
|
-
}
|
|
1154
|
+
publicPort = serviceConfig.port;
|
|
1155
|
+
claimPort(publicPort, `mesh service "${serviceName}"`);
|
|
1156
1156
|
} else if (serviceConfig.preservePort && serviceBuildJson.port) {
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1157
|
+
publicPort = serviceBuildJson.port;
|
|
1158
|
+
claimPort(publicPort, `mesh service "${serviceName}" (via preservePort)`);
|
|
1159
|
+
}
|
|
1160
|
+
const provideMap = {
|
|
1161
|
+
...serviceConfig.replaceMocks || {},
|
|
1162
|
+
...serviceConfig.provideDependency || {}
|
|
1163
|
+
};
|
|
1164
|
+
for (const dep of serviceDeps) {
|
|
1165
|
+
if (!provideMap[dep.name] && !(mesh.dependencies && mesh.dependencies[dep.name]) && dep.port) {
|
|
1166
|
+
claimPort(dep.port, `local dependency "${dep.name}" of service "${serviceName}"`);
|
|
1160
1167
|
}
|
|
1161
1168
|
}
|
|
1169
|
+
const hostPort = publicPort ? String(publicPort).includes(":") ? String(publicPort).split(":")[0] : String(publicPort) : null;
|
|
1162
1170
|
serviceUrls.set(serviceName, {
|
|
1163
1171
|
networkUrl: `http://${serviceName}:${INTERNAL_PORT}`,
|
|
1164
|
-
publicUrl:
|
|
1172
|
+
publicUrl: hostPort ? `http://localhost:${hostPort}` : null
|
|
1165
1173
|
});
|
|
1166
1174
|
}
|
|
1167
1175
|
function escapeRegExp(string) {
|
|
@@ -1171,6 +1179,13 @@ function compileMeshEnvironment(mode, rawMeshDir = process.cwd(), options = {})
|
|
|
1171
1179
|
if (typeof value !== "string") {
|
|
1172
1180
|
return value;
|
|
1173
1181
|
}
|
|
1182
|
+
if (!options.silenceWarnings && context.includes("Tester") && value.includes(".network_url")) {
|
|
1183
|
+
console.warn(
|
|
1184
|
+
pc22.yellow(`
|
|
1185
|
+
\u26A0\uFE0F WARNING: You are passing a '.network_url' template to the E2E tester ("${value}"). Since the tester runs in 'network_mode: host', it cannot resolve internal Docker DNS. Use '.public_url' instead. (Mute with --silence-warnings)
|
|
1186
|
+
`)
|
|
1187
|
+
);
|
|
1188
|
+
}
|
|
1174
1189
|
let interpolated = value;
|
|
1175
1190
|
for (const [sName, urls] of serviceUrls.entries()) {
|
|
1176
1191
|
interpolated = interpolated.replace(
|
|
@@ -1438,6 +1453,10 @@ function compileMeshEnvironment(mode, rawMeshDir = process.cwd(), options = {})
|
|
|
1438
1453
|
delete resolvedMock.container_name;
|
|
1439
1454
|
normalizeDependsOn(resolvedMock);
|
|
1440
1455
|
applyInternalMockDependsOnMapping(resolvedMock, sidecarMapping);
|
|
1456
|
+
if (dep.port) {
|
|
1457
|
+
const portMapping = String(dep.port).includes(":") ? String(dep.port) : `${dep.port}:3000`;
|
|
1458
|
+
resolvedMock.ports = [...resolvedMock.ports || [], portMapping];
|
|
1459
|
+
}
|
|
1441
1460
|
resolvedMock.networks = {
|
|
1442
1461
|
[`${serviceName}_net`]: {
|
|
1443
1462
|
aliases: [depKey, namespacedDepKey]
|
|
@@ -1501,11 +1520,8 @@ function compileMeshEnvironment(mode, rawMeshDir = process.cwd(), options = {})
|
|
|
1501
1520
|
);
|
|
1502
1521
|
delete resolvedTester.container_name;
|
|
1503
1522
|
normalizeDependsOn(resolvedTester);
|
|
1504
|
-
resolvedTester.
|
|
1505
|
-
|
|
1506
|
-
aliases: [tKey, ...tKey === firstKey ? ["tester"] : []]
|
|
1507
|
-
}
|
|
1508
|
-
};
|
|
1523
|
+
resolvedTester.network_mode = "host";
|
|
1524
|
+
delete resolvedTester.networks;
|
|
1509
1525
|
if (tKey === firstKey) {
|
|
1510
1526
|
resolvedTester.depends_on = resolvedTester.depends_on || {};
|
|
1511
1527
|
for (const sName of Object.keys(mesh.services)) {
|
|
@@ -1833,12 +1849,12 @@ async function teardownCompose(yamlConfig, projectDir, options = {}) {
|
|
|
1833
1849
|
if (result.error) {
|
|
1834
1850
|
if (!silent) {
|
|
1835
1851
|
console.error(
|
|
1836
|
-
|
|
1852
|
+
pc22.red(`Failed to run docker compose down: ${result.error.message}`)
|
|
1837
1853
|
);
|
|
1838
1854
|
}
|
|
1839
1855
|
} else if (result.status !== 0 && !silent) {
|
|
1840
1856
|
console.error(
|
|
1841
|
-
|
|
1857
|
+
pc22.red(
|
|
1842
1858
|
`Docker compose down exited with non-zero status code: ${result.status}`
|
|
1843
1859
|
)
|
|
1844
1860
|
);
|
|
@@ -1981,7 +1997,7 @@ async function handleMeshDown(rawStage = "dev", options = {}) {
|
|
|
1981
1997
|
);
|
|
1982
1998
|
}
|
|
1983
1999
|
console.log(
|
|
1984
|
-
|
|
2000
|
+
pc22.cyan(`
|
|
1985
2001
|
\u{1F9F9} Stopping and tearing down global mesh environment [${stage}]...`)
|
|
1986
2002
|
);
|
|
1987
2003
|
if (options.debug) {
|
|
@@ -1990,7 +2006,7 @@ async function handleMeshDown(rawStage = "dev", options = {}) {
|
|
|
1990
2006
|
const includeTester = stage === "test" || stage === "test-e2e";
|
|
1991
2007
|
const { yaml } = compileMeshEnvironment(mode, meshDir, { includeTester });
|
|
1992
2008
|
console.log(
|
|
1993
|
-
|
|
2009
|
+
pc22.yellow("\nFinal merged Mesh YAML configuration:\n"),
|
|
1994
2010
|
redactYamlSecrets(yaml)
|
|
1995
2011
|
);
|
|
1996
2012
|
} catch {
|
|
@@ -2010,7 +2026,7 @@ async function handleMeshDown(rawStage = "dev", options = {}) {
|
|
|
2010
2026
|
}
|
|
2011
2027
|
clearRunState(meshDir);
|
|
2012
2028
|
console.log(
|
|
2013
|
-
|
|
2029
|
+
pc22.green(`\u2705 Global mesh environment [${stage}] stopped and removed.
|
|
2014
2030
|
`)
|
|
2015
2031
|
);
|
|
2016
2032
|
return 0;
|
|
@@ -2093,7 +2109,7 @@ async function checkHostPortCollisions(ports) {
|
|
|
2093
2109
|
const inUse = await isPortInUse(port);
|
|
2094
2110
|
if (inUse) {
|
|
2095
2111
|
console.warn(
|
|
2096
|
-
|
|
2112
|
+
pc22.yellow(
|
|
2097
2113
|
`
|
|
2098
2114
|
\u26A0\uFE0F Host Port Conflict Warning: Port ${port} is already in use on the host (e.g. by another running stage or process). Docker Compose may fail to bind to this port.
|
|
2099
2115
|
`
|
|
@@ -2159,22 +2175,24 @@ async function runCompose(args, yamlConfig, projectDir, options = {}) {
|
|
|
2159
2175
|
// src/core/mesh/runners/runMeshDev.ts
|
|
2160
2176
|
async function runMeshDev(options = {}) {
|
|
2161
2177
|
const meshDir = resolveProjectDir(options.projectDir);
|
|
2162
|
-
console.log(
|
|
2178
|
+
console.log(pc22.cyan(`
|
|
2163
2179
|
\u{1F680} Starting Global DEV Mesh Environment...`));
|
|
2164
2180
|
if (!options.skipChecks) {
|
|
2165
2181
|
checkMesh(meshDir, { requireTester: false });
|
|
2166
2182
|
}
|
|
2167
|
-
const { yaml } = compileMeshEnvironment("dev", meshDir
|
|
2183
|
+
const { yaml } = compileMeshEnvironment("dev", meshDir, {
|
|
2184
|
+
silenceWarnings: options.silenceWarnings
|
|
2185
|
+
});
|
|
2168
2186
|
const parsed = parse(yaml);
|
|
2169
2187
|
const projectName = parsed?.name || "mesh-dev";
|
|
2170
2188
|
if (options.debug) {
|
|
2171
2189
|
console.log(
|
|
2172
|
-
|
|
2190
|
+
pc22.yellow("\nFinal merged Mesh Dev YAML configuration:\n"),
|
|
2173
2191
|
redactYamlSecrets(yaml)
|
|
2174
2192
|
);
|
|
2175
2193
|
}
|
|
2176
2194
|
if (options.dryRun) {
|
|
2177
|
-
console.log(
|
|
2195
|
+
console.log(pc22.green("Dry run complete. Compose was not started."));
|
|
2178
2196
|
return 0;
|
|
2179
2197
|
}
|
|
2180
2198
|
const hostPorts = extractHostPorts(yaml);
|
|
@@ -2203,22 +2221,24 @@ async function runMeshDev(options = {}) {
|
|
|
2203
2221
|
}
|
|
2204
2222
|
async function runMeshProd(options = {}) {
|
|
2205
2223
|
const meshDir = resolveProjectDir(options.projectDir);
|
|
2206
|
-
console.log(
|
|
2224
|
+
console.log(pc22.cyan(`
|
|
2207
2225
|
\u{1F3ED} Starting Global PROD Mesh Environment...`));
|
|
2208
2226
|
if (!options.skipChecks) {
|
|
2209
2227
|
checkMesh(meshDir, { requireTester: false });
|
|
2210
2228
|
}
|
|
2211
|
-
const { yaml } = compileMeshEnvironment("prod", meshDir
|
|
2229
|
+
const { yaml } = compileMeshEnvironment("prod", meshDir, {
|
|
2230
|
+
silenceWarnings: options.silenceWarnings
|
|
2231
|
+
});
|
|
2212
2232
|
const parsed = parse(yaml);
|
|
2213
2233
|
const projectName = parsed?.name || "mesh-prod";
|
|
2214
2234
|
if (options.debug) {
|
|
2215
2235
|
console.log(
|
|
2216
|
-
|
|
2236
|
+
pc22.yellow("\nFinal merged Mesh Prod YAML configuration:\n"),
|
|
2217
2237
|
redactYamlSecrets(yaml)
|
|
2218
2238
|
);
|
|
2219
2239
|
}
|
|
2220
2240
|
if (options.dryRun) {
|
|
2221
|
-
console.log(
|
|
2241
|
+
console.log(pc22.green("Dry run complete. Compose was not started."));
|
|
2222
2242
|
return 0;
|
|
2223
2243
|
}
|
|
2224
2244
|
const hostPorts = extractHostPorts(yaml);
|
|
@@ -2546,7 +2566,7 @@ function getDockerComposeTemplate(filename) {
|
|
|
2546
2566
|
}
|
|
2547
2567
|
|
|
2548
2568
|
// src/core/compileEnvironment.ts
|
|
2549
|
-
var compileEnvironment = (environment, projectDir = process.cwd()) => {
|
|
2569
|
+
var compileEnvironment = (environment, projectDir = process.cwd(), options = {}) => {
|
|
2550
2570
|
const absProjectDir = resolveProjectDir(projectDir);
|
|
2551
2571
|
const buildJson = getBuildJson(absProjectDir);
|
|
2552
2572
|
const overrides = extractOverrides(buildJson, absProjectDir);
|
|
@@ -2629,6 +2649,7 @@ var compileEnvironment = (environment, projectDir = process.cwd()) => {
|
|
|
2629
2649
|
case "e2e": {
|
|
2630
2650
|
const prodPath = getDockerComposeTemplate("docker-compose.prod.yml");
|
|
2631
2651
|
const e2ePath = getDockerComposeTemplate("docker-compose.e2e.yml");
|
|
2652
|
+
const standalonePath = getDockerComposeTemplate("docker-compose.standalone.yml");
|
|
2632
2653
|
composeFlags.push("-f", prodPath);
|
|
2633
2654
|
filesUsed.push(prodPath);
|
|
2634
2655
|
if (overrides.prod) {
|
|
@@ -2641,6 +2662,8 @@ var compileEnvironment = (environment, projectDir = process.cwd()) => {
|
|
|
2641
2662
|
filesUsed.push(dep.path);
|
|
2642
2663
|
}
|
|
2643
2664
|
}
|
|
2665
|
+
composeFlags.push("-f", standalonePath);
|
|
2666
|
+
filesUsed.push(standalonePath);
|
|
2644
2667
|
composeFlags.push("-f", e2ePath);
|
|
2645
2668
|
filesUsed.push(e2ePath);
|
|
2646
2669
|
if (overrides.e2e) {
|
|
@@ -2699,12 +2722,21 @@ ${explanation}`);
|
|
|
2699
2722
|
urlRegistry.set(buildJson.name, urlRegistry.get("app"));
|
|
2700
2723
|
}
|
|
2701
2724
|
for (const dep of dependencies) {
|
|
2725
|
+
const depPortStr = dep.port ? String(dep.port) : null;
|
|
2726
|
+
const depHostPort = depPortStr ? depPortStr.includes(":") ? depPortStr.split(":")[0] : depPortStr : null;
|
|
2702
2727
|
urlRegistry.set(dep.name, {
|
|
2703
2728
|
networkUrl: `http://${dep.name}:${INTERNAL_PORT}`,
|
|
2704
|
-
publicUrl: null
|
|
2729
|
+
publicUrl: depHostPort ? `http://localhost:${depHostPort}` : null
|
|
2705
2730
|
});
|
|
2706
2731
|
}
|
|
2707
2732
|
const interpolateEnv = (val, context) => {
|
|
2733
|
+
if (!options.silenceWarnings && context.includes("Tester") && val.includes(".network_url")) {
|
|
2734
|
+
console.warn(
|
|
2735
|
+
pc22.yellow(`
|
|
2736
|
+
\u26A0\uFE0F WARNING: You are passing a '.network_url' template to the E2E tester ("${val}"). Since the tester runs in 'network_mode: host', it cannot resolve internal Docker DNS. Use '.public_url' instead. (Mute with --silence-warnings)
|
|
2737
|
+
`)
|
|
2738
|
+
);
|
|
2739
|
+
}
|
|
2708
2740
|
let output = val;
|
|
2709
2741
|
for (const [sName, urls] of urlRegistry.entries()) {
|
|
2710
2742
|
const escaped = sName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -2721,9 +2753,20 @@ ${explanation}`);
|
|
|
2721
2753
|
}
|
|
2722
2754
|
const unresolvedMatch = output.match(/\$\{([^}]+?)\.(network_url|public_url)\}/);
|
|
2723
2755
|
if (unresolvedMatch) {
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2756
|
+
const variable = unresolvedMatch[0];
|
|
2757
|
+
const targetService = unresolvedMatch[1];
|
|
2758
|
+
const type = unresolvedMatch[2];
|
|
2759
|
+
if (!urlRegistry.has(targetService)) {
|
|
2760
|
+
throw new ScriptError(
|
|
2761
|
+
`[${context}] Unresolved template variable: ${variable}. Check build.json dependencies.`
|
|
2762
|
+
);
|
|
2763
|
+
} else if (type === "public_url") {
|
|
2764
|
+
throw new ScriptError(
|
|
2765
|
+
`[${context}] Unresolved template variable: ${variable}. Service "${targetService}" does not expose a public port (missing 'port' explicitly defined in build.json).`
|
|
2766
|
+
);
|
|
2767
|
+
} else {
|
|
2768
|
+
throw new ScriptError(`[${context}] Unresolved template variable: ${variable}.`);
|
|
2769
|
+
}
|
|
2727
2770
|
}
|
|
2728
2771
|
return output;
|
|
2729
2772
|
};
|
|
@@ -2757,6 +2800,20 @@ ${explanation}`);
|
|
|
2757
2800
|
yml.services.tester.environment[k] = interpolateEnv(v, "Tester EnvOverrides");
|
|
2758
2801
|
}
|
|
2759
2802
|
}
|
|
2803
|
+
if (yml.services) {
|
|
2804
|
+
for (const dep of dependencies) {
|
|
2805
|
+
if (dep.port) {
|
|
2806
|
+
let targetSvc = dep.serviceName && yml.services[dep.serviceName] ? dep.serviceName : dep.name;
|
|
2807
|
+
if (!yml.services[targetSvc]) {
|
|
2808
|
+
targetSvc = Object.keys(yml.services).find((k) => k !== "app" && k !== "tester") || targetSvc;
|
|
2809
|
+
}
|
|
2810
|
+
if (yml.services[targetSvc]) {
|
|
2811
|
+
const portMapping = String(dep.port).includes(":") ? String(dep.port) : `${dep.port}:3000`;
|
|
2812
|
+
yml.services[targetSvc].ports = [...yml.services[targetSvc].ports || [], portMapping];
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2760
2817
|
attachName(yml, projectName);
|
|
2761
2818
|
const finalYamlConfig = stringify(yml);
|
|
2762
2819
|
return finalYamlConfig;
|
|
@@ -2765,23 +2822,25 @@ ${explanation}`);
|
|
|
2765
2822
|
// src/core/runners/runTestUnit.ts
|
|
2766
2823
|
var runTestUnit = async (options) => {
|
|
2767
2824
|
if (!options.skipBanner) {
|
|
2768
|
-
console.log(
|
|
2825
|
+
console.log(pc22.bold(pc22.blue(`
|
|
2769
2826
|
========================================`)));
|
|
2770
|
-
console.log(
|
|
2771
|
-
console.log(
|
|
2827
|
+
console.log(pc22.bold(pc22.blue(`\u{1F9EA} STAGE: UNIT & ISOLATED TESTS`)));
|
|
2828
|
+
console.log(pc22.bold(pc22.blue(`========================================
|
|
2772
2829
|
`)));
|
|
2773
2830
|
}
|
|
2774
|
-
const finalYamlConfig = compileEnvironment("test", options.projectDir
|
|
2831
|
+
const finalYamlConfig = compileEnvironment("test", options.projectDir, {
|
|
2832
|
+
silenceWarnings: options.silenceWarnings
|
|
2833
|
+
});
|
|
2775
2834
|
const parsed = parse(finalYamlConfig);
|
|
2776
2835
|
const projectName = parsed?.name || "test";
|
|
2777
2836
|
if (options.debug) {
|
|
2778
2837
|
console.log(
|
|
2779
|
-
|
|
2838
|
+
pc22.yellow("Final merged YAML configuration:\n"),
|
|
2780
2839
|
redactYamlSecrets(finalYamlConfig)
|
|
2781
2840
|
);
|
|
2782
2841
|
}
|
|
2783
2842
|
if (options.dryRun) {
|
|
2784
|
-
console.log(
|
|
2843
|
+
console.log(pc22.green("[DRY-RUN] Unit tests simulated. Compose was not started."));
|
|
2785
2844
|
return 0;
|
|
2786
2845
|
}
|
|
2787
2846
|
await teardownCompose(finalYamlConfig, options.projectDir, {
|
|
@@ -2806,11 +2865,11 @@ var runTestUnit = async (options) => {
|
|
|
2806
2865
|
clearRunState(options.projectDir);
|
|
2807
2866
|
}
|
|
2808
2867
|
if (status === 0) {
|
|
2809
|
-
console.log(
|
|
2868
|
+
console.log(pc22.bold(pc22.green(`
|
|
2810
2869
|
\u2705 Unit tests passed successfully.
|
|
2811
2870
|
`)));
|
|
2812
2871
|
} else {
|
|
2813
|
-
console.error(
|
|
2872
|
+
console.error(pc22.red(`
|
|
2814
2873
|
\u274C Unit tests failed with exit code ${status}.
|
|
2815
2874
|
`));
|
|
2816
2875
|
}
|
|
@@ -2818,23 +2877,25 @@ var runTestUnit = async (options) => {
|
|
|
2818
2877
|
};
|
|
2819
2878
|
var runTestE2e = async (options) => {
|
|
2820
2879
|
if (!options.skipBanner) {
|
|
2821
|
-
console.log(
|
|
2880
|
+
console.log(pc22.bold(pc22.blue(`
|
|
2822
2881
|
========================================`)));
|
|
2823
|
-
console.log(
|
|
2824
|
-
console.log(
|
|
2882
|
+
console.log(pc22.bold(pc22.blue(`\u{1F6A6} STAGE: INTEGRATED E2E TESTS`)));
|
|
2883
|
+
console.log(pc22.bold(pc22.blue(`========================================
|
|
2825
2884
|
`)));
|
|
2826
2885
|
}
|
|
2827
|
-
const finalYamlConfig = compileEnvironment("e2e", options.projectDir
|
|
2886
|
+
const finalYamlConfig = compileEnvironment("e2e", options.projectDir, {
|
|
2887
|
+
silenceWarnings: options.silenceWarnings
|
|
2888
|
+
});
|
|
2828
2889
|
const parsed = parse(finalYamlConfig);
|
|
2829
2890
|
const projectName = parsed?.name || "e2e";
|
|
2830
2891
|
if (options.debug) {
|
|
2831
2892
|
console.log(
|
|
2832
|
-
|
|
2893
|
+
pc22.yellow("Final merged YAML configuration:\n"),
|
|
2833
2894
|
redactYamlSecrets(finalYamlConfig)
|
|
2834
2895
|
);
|
|
2835
2896
|
}
|
|
2836
2897
|
if (options.dryRun) {
|
|
2837
|
-
console.log(
|
|
2898
|
+
console.log(pc22.green("[DRY-RUN] E2E tests simulated. Compose was not started."));
|
|
2838
2899
|
return 0;
|
|
2839
2900
|
}
|
|
2840
2901
|
await teardownCompose(finalYamlConfig, options.projectDir, {
|
|
@@ -2865,11 +2926,11 @@ var runTestE2e = async (options) => {
|
|
|
2865
2926
|
clearRunState(options.projectDir);
|
|
2866
2927
|
}
|
|
2867
2928
|
if (status === 0) {
|
|
2868
|
-
console.log(
|
|
2929
|
+
console.log(pc22.bold(pc22.green(`
|
|
2869
2930
|
\u2705 E2E tests passed successfully.
|
|
2870
2931
|
`)));
|
|
2871
2932
|
} else {
|
|
2872
|
-
console.error(
|
|
2933
|
+
console.error(pc22.red(`
|
|
2873
2934
|
\u274C E2E tests failed with exit code ${status}.
|
|
2874
2935
|
`));
|
|
2875
2936
|
}
|
|
@@ -2878,15 +2939,15 @@ var runTestE2e = async (options) => {
|
|
|
2878
2939
|
|
|
2879
2940
|
// src/core/runners/runTest.ts
|
|
2880
2941
|
var runTest = async (options) => {
|
|
2881
|
-
console.log(
|
|
2942
|
+
console.log(pc22.bold(pc22.blue(`
|
|
2882
2943
|
========================================`)));
|
|
2883
|
-
console.log(
|
|
2884
|
-
console.log(
|
|
2944
|
+
console.log(pc22.bold(pc22.blue(`\u{1F9EA} [1/2] STAGE: UNIT & ISOLATED TESTS`)));
|
|
2945
|
+
console.log(pc22.bold(pc22.blue(`========================================
|
|
2885
2946
|
`)));
|
|
2886
2947
|
const unitStatus = await runTestUnit({ ...options, skipBanner: true });
|
|
2887
2948
|
if (unitStatus !== 0) {
|
|
2888
2949
|
console.error(
|
|
2889
|
-
|
|
2950
|
+
pc22.red(
|
|
2890
2951
|
`
|
|
2891
2952
|
\u274C [1/2] Unit tests failed with exit code ${unitStatus}. Aborting E2E tests.
|
|
2892
2953
|
`
|
|
@@ -2895,29 +2956,29 @@ var runTest = async (options) => {
|
|
|
2895
2956
|
return unitStatus;
|
|
2896
2957
|
}
|
|
2897
2958
|
console.log(
|
|
2898
|
-
|
|
2959
|
+
pc22.bold(pc22.green(`
|
|
2899
2960
|
\u2705 [1/2] Unit tests passed successfully.
|
|
2900
2961
|
`))
|
|
2901
2962
|
);
|
|
2902
|
-
console.log(
|
|
2903
|
-
console.log(
|
|
2904
|
-
console.log(
|
|
2963
|
+
console.log(pc22.bold(pc22.blue(`========================================`)));
|
|
2964
|
+
console.log(pc22.bold(pc22.blue(`\u{1F6A6} [2/2] STAGE: INTEGRATED E2E TESTS`)));
|
|
2965
|
+
console.log(pc22.bold(pc22.blue(`========================================
|
|
2905
2966
|
`)));
|
|
2906
2967
|
const e2eStatus = await runTestE2e({ ...options, skipBanner: true });
|
|
2907
2968
|
if (e2eStatus !== 0) {
|
|
2908
2969
|
console.error(
|
|
2909
|
-
|
|
2970
|
+
pc22.red(`
|
|
2910
2971
|
\u274C [2/2] E2E tests failed with exit code ${e2eStatus}.
|
|
2911
2972
|
`)
|
|
2912
2973
|
);
|
|
2913
2974
|
return e2eStatus;
|
|
2914
2975
|
}
|
|
2915
|
-
console.log(
|
|
2976
|
+
console.log(pc22.bold(pc22.green(`
|
|
2916
2977
|
\u2705 [2/2] E2E tests passed successfully.
|
|
2917
2978
|
`)));
|
|
2918
2979
|
console.log(
|
|
2919
|
-
|
|
2920
|
-
|
|
2980
|
+
pc22.bold(
|
|
2981
|
+
pc22.green(`\u{1F389} All test stages (unit + e2e) completed successfully!
|
|
2921
2982
|
`)
|
|
2922
2983
|
)
|
|
2923
2984
|
);
|
|
@@ -2925,16 +2986,17 @@ var runTest = async (options) => {
|
|
|
2925
2986
|
};
|
|
2926
2987
|
async function runMeshTestE2e(options = {}) {
|
|
2927
2988
|
const meshDir = resolveProjectDir(options.projectDir);
|
|
2928
|
-
console.log(
|
|
2989
|
+
console.log(pc22.bold(pc22.blue(`
|
|
2929
2990
|
========================================`)));
|
|
2930
|
-
console.log(
|
|
2931
|
-
console.log(
|
|
2991
|
+
console.log(pc22.bold(pc22.blue(`\u{1F6A6} [MESH] STAGE: GLOBAL INTEGRATED E2E TESTS`)));
|
|
2992
|
+
console.log(pc22.bold(pc22.blue(`========================================
|
|
2932
2993
|
`)));
|
|
2933
2994
|
if (!options.skipChecks) {
|
|
2934
2995
|
checkMesh(meshDir, { requireTester: true });
|
|
2935
2996
|
}
|
|
2936
2997
|
const { yaml, testerServiceName } = compileMeshEnvironment("prod", meshDir, {
|
|
2937
|
-
includeTester: true
|
|
2998
|
+
includeTester: true,
|
|
2999
|
+
silenceWarnings: options.silenceWarnings
|
|
2938
3000
|
});
|
|
2939
3001
|
if (!testerServiceName) {
|
|
2940
3002
|
throw new ScriptError(
|
|
@@ -2943,12 +3005,12 @@ async function runMeshTestE2e(options = {}) {
|
|
|
2943
3005
|
}
|
|
2944
3006
|
if (options.debug) {
|
|
2945
3007
|
console.log(
|
|
2946
|
-
|
|
3008
|
+
pc22.yellow("\nFinal merged Mesh E2E YAML configuration:\n"),
|
|
2947
3009
|
redactYamlSecrets(yaml)
|
|
2948
3010
|
);
|
|
2949
3011
|
}
|
|
2950
3012
|
if (options.dryRun) {
|
|
2951
|
-
console.log(
|
|
3013
|
+
console.log(pc22.green("[DRY-RUN] Global E2E test simulated. Compose was not started."));
|
|
2952
3014
|
return 0;
|
|
2953
3015
|
}
|
|
2954
3016
|
const parsed = parse(yaml);
|
|
@@ -2974,16 +3036,16 @@ async function runMeshTestE2e(options = {}) {
|
|
|
2974
3036
|
{ removeVolumes: true }
|
|
2975
3037
|
);
|
|
2976
3038
|
} finally {
|
|
2977
|
-
console.log(
|
|
3039
|
+
console.log(pc22.cyan("\n\u{1F9F9} Cleaning up global mesh containers and volumes..."));
|
|
2978
3040
|
await teardownCompose(yaml, meshDir, { removeVolumes: true });
|
|
2979
3041
|
clearRunState(meshDir);
|
|
2980
3042
|
}
|
|
2981
3043
|
if (status === 0) {
|
|
2982
|
-
console.log(
|
|
3044
|
+
console.log(pc22.bold(pc22.green(`
|
|
2983
3045
|
\u2705 Global E2E tests passed successfully.
|
|
2984
3046
|
`)));
|
|
2985
3047
|
} else {
|
|
2986
|
-
console.error(
|
|
3048
|
+
console.error(pc22.red(`
|
|
2987
3049
|
\u274C Global E2E tests failed with exit code ${status}.
|
|
2988
3050
|
`));
|
|
2989
3051
|
}
|
|
@@ -2993,44 +3055,45 @@ async function runMeshTestE2e(options = {}) {
|
|
|
2993
3055
|
// src/core/mesh/runners/runMeshTest.ts
|
|
2994
3056
|
async function runMeshTest(options = {}) {
|
|
2995
3057
|
const meshDir = resolveProjectDir(options.projectDir);
|
|
2996
|
-
console.log(
|
|
3058
|
+
console.log(pc22.bold(pc22.blue(`
|
|
2997
3059
|
========================================`)));
|
|
2998
|
-
console.log(
|
|
2999
|
-
console.log(
|
|
3060
|
+
console.log(pc22.bold(pc22.blue(`\u{1F9EA} GLOBAL MESH TEST PIPELINE`)));
|
|
3061
|
+
console.log(pc22.bold(pc22.blue(`========================================
|
|
3000
3062
|
`)));
|
|
3001
3063
|
if (!options.skipChecks) {
|
|
3002
3064
|
checkMesh(meshDir, { requireTester: true });
|
|
3003
3065
|
}
|
|
3004
3066
|
const mesh = getMeshJson(meshDir);
|
|
3005
|
-
console.log(
|
|
3067
|
+
console.log(pc22.bold(pc22.blue(`
|
|
3006
3068
|
========================================`)));
|
|
3007
3069
|
console.log(
|
|
3008
|
-
|
|
3009
|
-
|
|
3070
|
+
pc22.bold(
|
|
3071
|
+
pc22.blue(`\u{1F9EA} [1/2] STAGE: LOCAL SUBMODULE TEST SUITES (Unit & Isolated E2E)`)
|
|
3010
3072
|
)
|
|
3011
3073
|
);
|
|
3012
|
-
console.log(
|
|
3074
|
+
console.log(pc22.bold(pc22.blue(`========================================
|
|
3013
3075
|
`)));
|
|
3014
3076
|
for (const [serviceName, serviceConfig] of Object.entries(mesh.services)) {
|
|
3015
3077
|
const serviceDir = path13.resolve(meshDir, serviceConfig.path);
|
|
3016
3078
|
console.log(
|
|
3017
|
-
|
|
3079
|
+
pc22.bold(pc22.cyan(`
|
|
3018
3080
|
-> Running full test suite for [${serviceName}] in isolation...`))
|
|
3019
3081
|
);
|
|
3020
3082
|
if (options.dryRun) {
|
|
3021
3083
|
console.log(
|
|
3022
|
-
|
|
3084
|
+
pc22.green(`[DRY-RUN] Full isolated tests for ${serviceName} simulated.`)
|
|
3023
3085
|
);
|
|
3024
3086
|
continue;
|
|
3025
3087
|
}
|
|
3026
3088
|
const serviceStatus = await runTest({
|
|
3027
3089
|
projectDir: serviceDir,
|
|
3028
3090
|
debug: Boolean(options.debug),
|
|
3029
|
-
detach: Boolean(options.detach)
|
|
3091
|
+
detach: Boolean(options.detach),
|
|
3092
|
+
silenceWarnings: options.silenceWarnings
|
|
3030
3093
|
});
|
|
3031
3094
|
if (serviceStatus !== 0) {
|
|
3032
3095
|
console.error(
|
|
3033
|
-
|
|
3096
|
+
pc22.red(
|
|
3034
3097
|
`
|
|
3035
3098
|
\u274C Isolated tests failed for service [${serviceName}] with exit code ${serviceStatus}. Aborting global E2E tests.
|
|
3036
3099
|
`
|
|
@@ -3039,27 +3102,27 @@ async function runMeshTest(options = {}) {
|
|
|
3039
3102
|
return serviceStatus;
|
|
3040
3103
|
}
|
|
3041
3104
|
console.log(
|
|
3042
|
-
|
|
3105
|
+
pc22.bold(pc22.green(`
|
|
3043
3106
|
\u2705 Isolated tests passed for service: [${serviceName}]
|
|
3044
3107
|
`))
|
|
3045
3108
|
);
|
|
3046
3109
|
}
|
|
3047
|
-
console.log(
|
|
3110
|
+
console.log(pc22.bold(pc22.blue(`
|
|
3048
3111
|
========================================`)));
|
|
3049
3112
|
console.log(
|
|
3050
|
-
|
|
3051
|
-
|
|
3113
|
+
pc22.bold(
|
|
3114
|
+
pc22.blue(`\u{1F6A6} [2/2] STAGE: INTEGRATED PRODUCTION MESH & GLOBAL E2E ASSERTIONS`)
|
|
3052
3115
|
)
|
|
3053
3116
|
);
|
|
3054
|
-
console.log(
|
|
3117
|
+
console.log(pc22.bold(pc22.blue(`========================================
|
|
3055
3118
|
`)));
|
|
3056
3119
|
const e2eStatus = await runMeshTestE2e({ ...options, skipChecks: true });
|
|
3057
3120
|
if (e2eStatus !== 0) {
|
|
3058
3121
|
return e2eStatus;
|
|
3059
3122
|
}
|
|
3060
3123
|
console.log(
|
|
3061
|
-
|
|
3062
|
-
|
|
3124
|
+
pc22.bold(
|
|
3125
|
+
pc22.green(`\u{1F389} Entire global mesh test pipeline (unit, local e2e, and global e2e) completed successfully!
|
|
3063
3126
|
`)
|
|
3064
3127
|
)
|
|
3065
3128
|
);
|
|
@@ -3067,10 +3130,10 @@ async function runMeshTest(options = {}) {
|
|
|
3067
3130
|
}
|
|
3068
3131
|
async function runMeshTestUnit(options = {}) {
|
|
3069
3132
|
const meshDir = resolveProjectDir(options.projectDir);
|
|
3070
|
-
console.log(
|
|
3133
|
+
console.log(pc22.bold(pc22.blue(`
|
|
3071
3134
|
========================================`)));
|
|
3072
|
-
console.log(
|
|
3073
|
-
console.log(
|
|
3135
|
+
console.log(pc22.bold(pc22.blue(`\u{1F9EA} [MESH] STAGE: ISOLATED UNIT TESTS`)));
|
|
3136
|
+
console.log(pc22.bold(pc22.blue(`========================================
|
|
3074
3137
|
`)));
|
|
3075
3138
|
if (!options.skipChecks) {
|
|
3076
3139
|
checkMesh(meshDir, { requireTester: false });
|
|
@@ -3079,11 +3142,11 @@ async function runMeshTestUnit(options = {}) {
|
|
|
3079
3142
|
for (const [serviceName, serviceConfig] of Object.entries(mesh.services)) {
|
|
3080
3143
|
const serviceDir = path13.resolve(meshDir, serviceConfig.path);
|
|
3081
3144
|
console.log(
|
|
3082
|
-
|
|
3145
|
+
pc22.cyan(`
|
|
3083
3146
|
-> Running isolated unit tests for service: [${serviceName}]...`)
|
|
3084
3147
|
);
|
|
3085
3148
|
if (options.dryRun) {
|
|
3086
|
-
console.log(
|
|
3149
|
+
console.log(pc22.green(`[DRY-RUN] Unit tests for ${serviceName} simulated.`));
|
|
3087
3150
|
continue;
|
|
3088
3151
|
}
|
|
3089
3152
|
const unitStatus = await runTestUnit({
|
|
@@ -3094,20 +3157,20 @@ async function runMeshTestUnit(options = {}) {
|
|
|
3094
3157
|
});
|
|
3095
3158
|
if (unitStatus !== 0) {
|
|
3096
3159
|
console.error(
|
|
3097
|
-
|
|
3160
|
+
pc22.red(`
|
|
3098
3161
|
\u274C Unit tests failed for service [${serviceName}] with exit code ${unitStatus}.
|
|
3099
3162
|
`)
|
|
3100
3163
|
);
|
|
3101
3164
|
return unitStatus;
|
|
3102
3165
|
}
|
|
3103
3166
|
console.log(
|
|
3104
|
-
|
|
3167
|
+
pc22.bold(pc22.green(`
|
|
3105
3168
|
\u2705 Isolated unit tests passed for service: [${serviceName}]
|
|
3106
3169
|
`))
|
|
3107
3170
|
);
|
|
3108
3171
|
}
|
|
3109
3172
|
console.log(
|
|
3110
|
-
|
|
3173
|
+
pc22.bold(pc22.green(`\u{1F389} All mesh service unit tests completed successfully!
|
|
3111
3174
|
`))
|
|
3112
3175
|
);
|
|
3113
3176
|
return 0;
|
|
@@ -3149,6 +3212,9 @@ var registerMeshUpCommand = (cmd) => {
|
|
|
3149
3212
|
).option(
|
|
3150
3213
|
"--skip-checks",
|
|
3151
3214
|
"Skip hadolint and conftest pre-flight checks"
|
|
3215
|
+
).option(
|
|
3216
|
+
"--silence-warnings",
|
|
3217
|
+
"Silence non-critical warnings like URL templating hints"
|
|
3152
3218
|
).option(
|
|
3153
3219
|
"-C, --project-dir <dir>",
|
|
3154
3220
|
"Mesh project directory containing mesh.json (defaults to cwd)"
|
|
@@ -3168,7 +3234,8 @@ Examples:
|
|
|
3168
3234
|
debug: options.debug,
|
|
3169
3235
|
detach: options.detach,
|
|
3170
3236
|
dryRun: options.dryRun,
|
|
3171
|
-
skipChecks: options.skipChecks
|
|
3237
|
+
skipChecks: options.skipChecks,
|
|
3238
|
+
silenceWarnings: options.silenceWarnings
|
|
3172
3239
|
});
|
|
3173
3240
|
if (exitCode !== 0) {
|
|
3174
3241
|
process.exit(exitCode);
|
|
@@ -3188,7 +3255,7 @@ var registerMeshCommand = (program) => {
|
|
|
3188
3255
|
registerMeshCheckCommand(meshCmd);
|
|
3189
3256
|
};
|
|
3190
3257
|
async function handlePrune(options = {}) {
|
|
3191
|
-
console.log(
|
|
3258
|
+
console.log(pc22.cyan("\n\u{1F9F9} Pruning stopped Compose containers and unused networks..."));
|
|
3192
3259
|
const rmContainers = spawnSync("docker", ["container", "prune", "-f"], {
|
|
3193
3260
|
stdio: "inherit",
|
|
3194
3261
|
encoding: "utf-8"
|
|
@@ -3208,13 +3275,13 @@ async function handlePrune(options = {}) {
|
|
|
3208
3275
|
});
|
|
3209
3276
|
}
|
|
3210
3277
|
if (options.volumes) {
|
|
3211
|
-
console.log(
|
|
3278
|
+
console.log(pc22.cyan("\u{1F9F9} Pruning dangling volumes..."));
|
|
3212
3279
|
spawnSync("docker", ["volume", "prune", "-f"], {
|
|
3213
3280
|
stdio: "inherit",
|
|
3214
3281
|
encoding: "utf-8"
|
|
3215
3282
|
});
|
|
3216
3283
|
}
|
|
3217
|
-
console.log(
|
|
3284
|
+
console.log(pc22.green("\u2705 Docker environment pruned successfully.\n"));
|
|
3218
3285
|
return 0;
|
|
3219
3286
|
}
|
|
3220
3287
|
|
|
@@ -3248,7 +3315,7 @@ async function handleServiceDown(rawStage = "dev", options = {}) {
|
|
|
3248
3315
|
);
|
|
3249
3316
|
}
|
|
3250
3317
|
console.log(
|
|
3251
|
-
|
|
3318
|
+
pc22.cyan(`
|
|
3252
3319
|
\u{1F9F9} Stopping and tearing down service environment [${stage}]...`)
|
|
3253
3320
|
);
|
|
3254
3321
|
if (options.debug) {
|
|
@@ -3259,7 +3326,7 @@ async function handleServiceDown(rawStage = "dev", options = {}) {
|
|
|
3259
3326
|
else if (stage === "test-e2e") env = "e2e";
|
|
3260
3327
|
const finalYamlConfig = compileEnvironment(env, projectDir);
|
|
3261
3328
|
console.log(
|
|
3262
|
-
|
|
3329
|
+
pc22.yellow("Final merged YAML configuration:\n"),
|
|
3263
3330
|
redactYamlSecrets(finalYamlConfig)
|
|
3264
3331
|
);
|
|
3265
3332
|
} catch {
|
|
@@ -3279,7 +3346,7 @@ async function handleServiceDown(rawStage = "dev", options = {}) {
|
|
|
3279
3346
|
}
|
|
3280
3347
|
clearRunState(projectDir);
|
|
3281
3348
|
console.log(
|
|
3282
|
-
|
|
3349
|
+
pc22.green(`\u2705 Service environment [${stage}] stopped and removed.
|
|
3283
3350
|
`)
|
|
3284
3351
|
);
|
|
3285
3352
|
return 0;
|
|
@@ -3317,18 +3384,20 @@ Examples:
|
|
|
3317
3384
|
);
|
|
3318
3385
|
};
|
|
3319
3386
|
var runDev = async (options) => {
|
|
3320
|
-
console.log(
|
|
3321
|
-
const finalYamlConfig = compileEnvironment("dev", options.projectDir
|
|
3387
|
+
console.log(pc22.cyan(`\u{1F680} Starting DEV environment...`));
|
|
3388
|
+
const finalYamlConfig = compileEnvironment("dev", options.projectDir, {
|
|
3389
|
+
silenceWarnings: options.silenceWarnings
|
|
3390
|
+
});
|
|
3322
3391
|
const parsed = parse(finalYamlConfig);
|
|
3323
3392
|
const projectName = parsed?.name || "dev";
|
|
3324
3393
|
if (options.debug) {
|
|
3325
3394
|
console.log(
|
|
3326
|
-
|
|
3395
|
+
pc22.yellow("Final merged YAML configuration:\n"),
|
|
3327
3396
|
redactYamlSecrets(finalYamlConfig)
|
|
3328
3397
|
);
|
|
3329
3398
|
}
|
|
3330
3399
|
if (options.dryRun) {
|
|
3331
|
-
console.log(
|
|
3400
|
+
console.log(pc22.green("Dry run complete. Compose was not started."));
|
|
3332
3401
|
return 0;
|
|
3333
3402
|
}
|
|
3334
3403
|
const hostPorts = extractHostPorts(finalYamlConfig);
|
|
@@ -3358,18 +3427,20 @@ var runDev = async (options) => {
|
|
|
3358
3427
|
return status;
|
|
3359
3428
|
};
|
|
3360
3429
|
var runProd = async (options) => {
|
|
3361
|
-
console.log(
|
|
3362
|
-
const finalYamlConfig = compileEnvironment("prod", options.projectDir
|
|
3430
|
+
console.log(pc22.cyan(`\u{1F3ED} Starting PROD environment...`));
|
|
3431
|
+
const finalYamlConfig = compileEnvironment("prod", options.projectDir, {
|
|
3432
|
+
silenceWarnings: options.silenceWarnings
|
|
3433
|
+
});
|
|
3363
3434
|
const parsed = parse(finalYamlConfig);
|
|
3364
3435
|
const projectName = parsed?.name || "prod";
|
|
3365
3436
|
if (options.debug) {
|
|
3366
3437
|
console.log(
|
|
3367
|
-
|
|
3438
|
+
pc22.yellow("Final merged YAML configuration:\n"),
|
|
3368
3439
|
redactYamlSecrets(finalYamlConfig)
|
|
3369
3440
|
);
|
|
3370
3441
|
}
|
|
3371
3442
|
if (options.dryRun) {
|
|
3372
|
-
console.log(
|
|
3443
|
+
console.log(pc22.green("Dry run complete. Compose was not started."));
|
|
3373
3444
|
return 0;
|
|
3374
3445
|
}
|
|
3375
3446
|
const hostPorts = extractHostPorts(finalYamlConfig);
|
|
@@ -3407,7 +3478,8 @@ async function handleServiceUp(rawStage, options = {}) {
|
|
|
3407
3478
|
projectDir,
|
|
3408
3479
|
debug: Boolean(options.debug),
|
|
3409
3480
|
detach: Boolean(options.detach),
|
|
3410
|
-
dryRun: Boolean(options.dryRun)
|
|
3481
|
+
dryRun: Boolean(options.dryRun),
|
|
3482
|
+
silenceWarnings: Boolean(options.silenceWarnings)
|
|
3411
3483
|
};
|
|
3412
3484
|
if (stage === "dev") {
|
|
3413
3485
|
return await runDev(runOptions);
|
|
@@ -3439,6 +3511,9 @@ var registerUpCommand = (cmd) => {
|
|
|
3439
3511
|
).option(
|
|
3440
3512
|
"--skip-checks",
|
|
3441
3513
|
"Skip hadolint and conftest pre-flight checks"
|
|
3514
|
+
).option(
|
|
3515
|
+
"--silence-warnings",
|
|
3516
|
+
"Silence non-critical warnings like URL templating hints"
|
|
3442
3517
|
).option(
|
|
3443
3518
|
"-C, --project-dir <dir>",
|
|
3444
3519
|
"Service project directory (defaults to cwd)"
|
|
@@ -3458,7 +3533,8 @@ Examples:
|
|
|
3458
3533
|
debug: options.debug,
|
|
3459
3534
|
detach: options.detach,
|
|
3460
3535
|
dryRun: options.dryRun,
|
|
3461
|
-
skipChecks: options.skipChecks
|
|
3536
|
+
skipChecks: options.skipChecks,
|
|
3537
|
+
silenceWarnings: options.silenceWarnings
|
|
3462
3538
|
});
|
|
3463
3539
|
if (exitCode !== 0) {
|
|
3464
3540
|
process.exit(exitCode);
|
|
@@ -3511,10 +3587,10 @@ async function runCli(argv = process.argv) {
|
|
|
3511
3587
|
(arg) => arg === "-h" || arg === "--help" || arg === "-V" || arg === "--version"
|
|
3512
3588
|
);
|
|
3513
3589
|
if (!isHelpOrVersion && argv.length > 2) {
|
|
3514
|
-
console.log(
|
|
3590
|
+
console.log(pc22.dim(`builder v${version}`));
|
|
3515
3591
|
}
|
|
3516
3592
|
if (argv.length <= 2) {
|
|
3517
|
-
console.log(
|
|
3593
|
+
console.log(pc22.dim(`builder v${version}
|
|
3518
3594
|
`));
|
|
3519
3595
|
cli.outputHelp();
|
|
3520
3596
|
return;
|
|
@@ -3537,20 +3613,20 @@ async function runCli(argv = process.argv) {
|
|
|
3537
3613
|
if (err instanceof ScriptError) {
|
|
3538
3614
|
exitCode = err.exitCode;
|
|
3539
3615
|
const formatted = err.message.startsWith("\u274C") ? err.message : `\u274C ${err.message}`;
|
|
3540
|
-
console.error(
|
|
3616
|
+
console.error(pc22.red(`
|
|
3541
3617
|
${formatted}
|
|
3542
3618
|
`));
|
|
3543
3619
|
if (isVerbose && err.stack) {
|
|
3544
|
-
console.error(
|
|
3620
|
+
console.error(pc22.dim(err.stack));
|
|
3545
3621
|
}
|
|
3546
3622
|
} else {
|
|
3547
3623
|
const message = errorMessage(err);
|
|
3548
3624
|
const formatted = message.startsWith("\u274C") ? message : `\u274C Error: ${message}`;
|
|
3549
|
-
console.error(
|
|
3625
|
+
console.error(pc22.red(`
|
|
3550
3626
|
${formatted}
|
|
3551
3627
|
`));
|
|
3552
3628
|
if (isVerbose && err instanceof Error && err.stack) {
|
|
3553
|
-
console.error(
|
|
3629
|
+
console.error(pc22.dim(err.stack));
|
|
3554
3630
|
}
|
|
3555
3631
|
}
|
|
3556
3632
|
if (process.env.VITEST) {
|