@solid-stack/builder 1.1.3 → 1.1.5
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/README.md +12 -0
- package/dist/bin.js +83 -30
- package/dist/bin.js.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 +1 -0
- 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 +4 -2
- 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/core/runners/runDev.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +85 -31
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +4 -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/README.md
CHANGED
|
@@ -46,6 +46,16 @@ builder service up dev
|
|
|
46
46
|
- Merges `docker-compose.base.yml`, `docker-compose.dev.yml`, `.env.dev`, and any overrides defined in `build.json`
|
|
47
47
|
- Mounts source code with hot-reloading enabled
|
|
48
48
|
|
|
49
|
+
#### Full Development Mode (`builder service up dev --full`)
|
|
50
|
+
|
|
51
|
+
Spins up the development environment with hot-reloading while connecting to all declared mock dependencies and setting `INFRA_MODE=integrated`:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
builder service up dev --full
|
|
55
|
+
# Or alias:
|
|
56
|
+
builder service up dev --integrated
|
|
57
|
+
```
|
|
58
|
+
|
|
49
59
|
### 2. Production Mode (`builder service up prod`)
|
|
50
60
|
|
|
51
61
|
Spins up the production runtime with integrated local mocks:
|
|
@@ -97,6 +107,8 @@ builder service up test-e2e
|
|
|
97
107
|
| `-C, --project-dir <path>` | Specify target service directory (defaults to current working directory) |
|
|
98
108
|
| `--unit` | For `test`, run only unit test stage |
|
|
99
109
|
| `--e2e` | For `test`, run only e2e test stage |
|
|
110
|
+
| `--full` | For `dev`, spin up with mock dependencies and `INFRA_MODE=integrated` |
|
|
111
|
+
| `--integrated` | Alias for `--full` |
|
|
100
112
|
|
|
101
113
|
---
|
|
102
114
|
|
package/dist/bin.js
CHANGED
|
@@ -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());
|
|
@@ -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) {
|
|
@@ -1445,6 +1453,10 @@ function compileMeshEnvironment(mode, rawMeshDir = process.cwd(), options = {})
|
|
|
1445
1453
|
delete resolvedMock.container_name;
|
|
1446
1454
|
normalizeDependsOn(resolvedMock);
|
|
1447
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
|
+
}
|
|
1448
1460
|
resolvedMock.networks = {
|
|
1449
1461
|
[`${serviceName}_net`]: {
|
|
1450
1462
|
aliases: [depKey, namespacedDepKey]
|
|
@@ -2601,6 +2613,12 @@ var compileEnvironment = (environment, projectDir = process.cwd(), options = {})
|
|
|
2601
2613
|
composeFlags.push("-f", overrides.dev.path);
|
|
2602
2614
|
filesUsed.push(overrides.dev.path);
|
|
2603
2615
|
}
|
|
2616
|
+
if (options.full && dependencies.length > 0) {
|
|
2617
|
+
for (const dep of dependencies) {
|
|
2618
|
+
composeFlags.push("-f", dep.path);
|
|
2619
|
+
filesUsed.push(dep.path);
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2604
2622
|
composeFlags.push("-f", standalonePath);
|
|
2605
2623
|
filesUsed.push(standalonePath);
|
|
2606
2624
|
break;
|
|
@@ -2692,7 +2710,7 @@ ${explanation}`);
|
|
|
2692
2710
|
}
|
|
2693
2711
|
const mergedYamlConfig = result.stdout;
|
|
2694
2712
|
const yml = parse(mergedYamlConfig);
|
|
2695
|
-
if (environment === "prod" || environment === "e2e") {
|
|
2713
|
+
if (environment === "prod" || environment === "e2e" || environment === "dev" && options.full) {
|
|
2696
2714
|
renameServicesWithDependencies(yml, dependencies);
|
|
2697
2715
|
addDependenciesToAppService(yml, dependencies);
|
|
2698
2716
|
}
|
|
@@ -2710,9 +2728,11 @@ ${explanation}`);
|
|
|
2710
2728
|
urlRegistry.set(buildJson.name, urlRegistry.get("app"));
|
|
2711
2729
|
}
|
|
2712
2730
|
for (const dep of dependencies) {
|
|
2731
|
+
const depPortStr = dep.port ? String(dep.port) : null;
|
|
2732
|
+
const depHostPort = depPortStr ? depPortStr.includes(":") ? depPortStr.split(":")[0] : depPortStr : null;
|
|
2713
2733
|
urlRegistry.set(dep.name, {
|
|
2714
2734
|
networkUrl: `http://${dep.name}:${INTERNAL_PORT}`,
|
|
2715
|
-
publicUrl: null
|
|
2735
|
+
publicUrl: depHostPort ? `http://localhost:${depHostPort}` : null
|
|
2716
2736
|
});
|
|
2717
2737
|
}
|
|
2718
2738
|
const interpolateEnv = (val, context) => {
|
|
@@ -2786,6 +2806,24 @@ ${explanation}`);
|
|
|
2786
2806
|
yml.services.tester.environment[k] = interpolateEnv(v, "Tester EnvOverrides");
|
|
2787
2807
|
}
|
|
2788
2808
|
}
|
|
2809
|
+
if (yml.services) {
|
|
2810
|
+
for (const dep of dependencies) {
|
|
2811
|
+
if (dep.port) {
|
|
2812
|
+
let targetSvc = dep.serviceName && yml.services[dep.serviceName] ? dep.serviceName : dep.name;
|
|
2813
|
+
if (!yml.services[targetSvc]) {
|
|
2814
|
+
targetSvc = Object.keys(yml.services).find((k) => k !== "app" && k !== "tester") || targetSvc;
|
|
2815
|
+
}
|
|
2816
|
+
if (yml.services[targetSvc]) {
|
|
2817
|
+
const portMapping = String(dep.port).includes(":") ? String(dep.port) : `${dep.port}:3000`;
|
|
2818
|
+
yml.services[targetSvc].ports = [...yml.services[targetSvc].ports || [], portMapping];
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
if (environment === "dev" && options.full && yml.services?.app) {
|
|
2824
|
+
normalizeEnvironment(yml.services.app);
|
|
2825
|
+
yml.services.app.environment.INFRA_MODE = "integrated";
|
|
2826
|
+
}
|
|
2789
2827
|
attachName(yml, projectName);
|
|
2790
2828
|
const finalYamlConfig = stringify(yml);
|
|
2791
2829
|
return finalYamlConfig;
|
|
@@ -3356,9 +3394,14 @@ Examples:
|
|
|
3356
3394
|
);
|
|
3357
3395
|
};
|
|
3358
3396
|
var runDev = async (options) => {
|
|
3359
|
-
console.log(
|
|
3397
|
+
console.log(
|
|
3398
|
+
pc22.cyan(
|
|
3399
|
+
options.full ? `\u{1F680} Starting DEV environment (full / integrated)...` : `\u{1F680} Starting DEV environment...`
|
|
3400
|
+
)
|
|
3401
|
+
);
|
|
3360
3402
|
const finalYamlConfig = compileEnvironment("dev", options.projectDir, {
|
|
3361
|
-
silenceWarnings: options.silenceWarnings
|
|
3403
|
+
silenceWarnings: options.silenceWarnings,
|
|
3404
|
+
full: options.full
|
|
3362
3405
|
});
|
|
3363
3406
|
const parsed = parse(finalYamlConfig);
|
|
3364
3407
|
const projectName = parsed?.name || "dev";
|
|
@@ -3446,12 +3489,14 @@ var runProd = async (options) => {
|
|
|
3446
3489
|
async function handleServiceUp(rawStage, options = {}) {
|
|
3447
3490
|
const projectDir = resolveProjectDir(options.projectDir);
|
|
3448
3491
|
const stage = (rawStage || "dev").toLowerCase();
|
|
3492
|
+
const isFull = Boolean(options.full || options.integrated);
|
|
3449
3493
|
const runOptions = {
|
|
3450
3494
|
projectDir,
|
|
3451
3495
|
debug: Boolean(options.debug),
|
|
3452
3496
|
detach: Boolean(options.detach),
|
|
3453
3497
|
dryRun: Boolean(options.dryRun),
|
|
3454
|
-
silenceWarnings: Boolean(options.silenceWarnings)
|
|
3498
|
+
silenceWarnings: Boolean(options.silenceWarnings),
|
|
3499
|
+
full: isFull
|
|
3455
3500
|
};
|
|
3456
3501
|
if (stage === "dev") {
|
|
3457
3502
|
return await runDev(runOptions);
|
|
@@ -3486,6 +3531,12 @@ var registerUpCommand = (cmd) => {
|
|
|
3486
3531
|
).option(
|
|
3487
3532
|
"--silence-warnings",
|
|
3488
3533
|
"Silence non-critical warnings like URL templating hints"
|
|
3534
|
+
).option(
|
|
3535
|
+
"--full",
|
|
3536
|
+
"Run dev environment with mock dependencies and integrated infra mode"
|
|
3537
|
+
).option(
|
|
3538
|
+
"--integrated",
|
|
3539
|
+
"Alias for --full"
|
|
3489
3540
|
).option(
|
|
3490
3541
|
"-C, --project-dir <dir>",
|
|
3491
3542
|
"Service project directory (defaults to cwd)"
|
|
@@ -3494,6 +3545,7 @@ var registerUpCommand = (cmd) => {
|
|
|
3494
3545
|
`
|
|
3495
3546
|
Examples:
|
|
3496
3547
|
$ builder service up dev
|
|
3548
|
+
$ builder service up dev --full
|
|
3497
3549
|
$ builder service up prod
|
|
3498
3550
|
$ builder service up test
|
|
3499
3551
|
$ builder service up test-unit
|
|
@@ -3506,7 +3558,8 @@ Examples:
|
|
|
3506
3558
|
detach: options.detach,
|
|
3507
3559
|
dryRun: options.dryRun,
|
|
3508
3560
|
skipChecks: options.skipChecks,
|
|
3509
|
-
silenceWarnings: options.silenceWarnings
|
|
3561
|
+
silenceWarnings: options.silenceWarnings,
|
|
3562
|
+
full: Boolean(options.full || options.integrated)
|
|
3510
3563
|
});
|
|
3511
3564
|
if (exitCode !== 0) {
|
|
3512
3565
|
process.exit(exitCode);
|