balm-core 6.0.0-alpha.6 → 6.0.0-alpha.7
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/CHANGELOG.md +9 -0
- package/dist/index.cjs +58 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +56 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# balm-core
|
|
2
2
|
|
|
3
|
+
## 6.0.0-alpha.7
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4f5a612: Add LAN host exposure, real network IP logging, and `--host` / `--port` CLI options for the dev server
|
|
8
|
+
- Support `server.host: true` (binds `0.0.0.0`), string hosts (`0.0.0.0` / `::` / custom IP), `false`, and `HOST` env fallback in `ServerTask`
|
|
9
|
+
- Print resolved `Local` and non-internal IPv4 `Network` URLs via `os.networkInterfaces()` instead of hardcoded `127.0.0.1`
|
|
10
|
+
- Add `--host [host]` (including `--no-host`) and `--port <port>` options to the `balm` CLI
|
|
11
|
+
|
|
3
12
|
## 6.0.0-alpha.6
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -67,6 +67,7 @@ __export(index_exports, {
|
|
|
67
67
|
deepMerge: () => deepMerge,
|
|
68
68
|
default: () => index_default,
|
|
69
69
|
file: () => file,
|
|
70
|
+
getNetworkAddresses: () => getNetworkAddresses,
|
|
70
71
|
getWorkspaces: () => getWorkspaces,
|
|
71
72
|
globalResolve: () => globalResolve,
|
|
72
73
|
globalWorkspace: () => globalWorkspace,
|
|
@@ -81,6 +82,7 @@ __export(index_exports, {
|
|
|
81
82
|
logger: () => logger,
|
|
82
83
|
resolveConfig: () => resolveConfig,
|
|
83
84
|
resolveDefaultEntry: () => resolveDefaultEntry,
|
|
85
|
+
resolveServerHost: () => resolveServerHost,
|
|
84
86
|
rewriteCssAssetUrls: () => rewriteCssAssetUrls,
|
|
85
87
|
rewriteHtmlAssetPaths: () => rewriteHtmlAssetPaths,
|
|
86
88
|
runEsbuild: () => runEsbuild,
|
|
@@ -2426,6 +2428,7 @@ var FtpTask = class extends BaseTask {
|
|
|
2426
2428
|
// src/tasks/server.ts
|
|
2427
2429
|
var import_node_http = __toESM(require("http"), 1);
|
|
2428
2430
|
var import_node_fs8 = __toESM(require("fs"), 1);
|
|
2431
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
2429
2432
|
var import_node_path24 = __toESM(require("path"), 1);
|
|
2430
2433
|
var import_connect = __toESM(require("connect"), 1);
|
|
2431
2434
|
var import_serve_static = __toESM(require("serve-static"), 1);
|
|
@@ -2722,6 +2725,33 @@ function createDevServerApp(config) {
|
|
|
2722
2725
|
app.use((0, import_serve_static.default)(config.workspace));
|
|
2723
2726
|
return app;
|
|
2724
2727
|
}
|
|
2728
|
+
function getNetworkAddresses() {
|
|
2729
|
+
const addresses = [];
|
|
2730
|
+
const interfaces = import_node_os.default.networkInterfaces();
|
|
2731
|
+
for (const entries of Object.values(interfaces)) {
|
|
2732
|
+
for (const net of entries || []) {
|
|
2733
|
+
if (net.family === "IPv4" && !net.internal) {
|
|
2734
|
+
addresses.push(net.address);
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
}
|
|
2738
|
+
return addresses;
|
|
2739
|
+
}
|
|
2740
|
+
function resolveServerHost(rawHost, envHost = process.env.HOST) {
|
|
2741
|
+
let host = "localhost";
|
|
2742
|
+
if (rawHost === true) {
|
|
2743
|
+
host = "0.0.0.0";
|
|
2744
|
+
} else if (typeof rawHost === "string" && rawHost.trim()) {
|
|
2745
|
+
host = rawHost.trim();
|
|
2746
|
+
} else if (rawHost !== false && typeof envHost === "string" && envHost.trim()) {
|
|
2747
|
+
const trimmed = envHost.trim();
|
|
2748
|
+
host = trimmed === "true" ? "0.0.0.0" : trimmed;
|
|
2749
|
+
}
|
|
2750
|
+
return {
|
|
2751
|
+
host,
|
|
2752
|
+
isWildcard: host === "0.0.0.0" || host === "::"
|
|
2753
|
+
};
|
|
2754
|
+
}
|
|
2725
2755
|
var ServerTask = class extends BaseTask {
|
|
2726
2756
|
watcher = null;
|
|
2727
2757
|
wsServer = null;
|
|
@@ -2743,8 +2773,8 @@ var ServerTask = class extends BaseTask {
|
|
|
2743
2773
|
return;
|
|
2744
2774
|
}
|
|
2745
2775
|
const app = createDevServerApp(config);
|
|
2746
|
-
const port = config.server.port
|
|
2747
|
-
const host = config.server.host
|
|
2776
|
+
const port = config.server.port ?? 3e3;
|
|
2777
|
+
const { host, isWildcard } = resolveServerHost(config.server.host);
|
|
2748
2778
|
const server = import_node_http.default.createServer(app);
|
|
2749
2779
|
this.wsServer = new import_ws.WebSocketServer({ server, path: "/__balm_ws" });
|
|
2750
2780
|
this.wsServer.on("connection", (socket) => {
|
|
@@ -2757,10 +2787,32 @@ var ServerTask = class extends BaseTask {
|
|
|
2757
2787
|
this.watcher.start();
|
|
2758
2788
|
return new Promise((resolve) => {
|
|
2759
2789
|
server.listen(port, host, () => {
|
|
2790
|
+
const address = server.address();
|
|
2791
|
+
const activePort = address && typeof address === "object" ? address.port : port;
|
|
2792
|
+
const localHost = isWildcard ? "localhost" : host;
|
|
2760
2793
|
console.log("");
|
|
2761
2794
|
logger.success("server", import_picocolors4.default.bold("BalmJS Dev Server is ready!"));
|
|
2762
|
-
console.log(
|
|
2763
|
-
|
|
2795
|
+
console.log(
|
|
2796
|
+
` ${import_picocolors4.default.green("\u279C")} ${import_picocolors4.default.bold("Local:")} ${import_picocolors4.default.cyan(`http://${localHost}:${activePort}/`)}`
|
|
2797
|
+
);
|
|
2798
|
+
if (isWildcard) {
|
|
2799
|
+
const networkIps = getNetworkAddresses();
|
|
2800
|
+
if (networkIps.length > 0) {
|
|
2801
|
+
for (const ip of networkIps) {
|
|
2802
|
+
console.log(
|
|
2803
|
+
` ${import_picocolors4.default.green("\u279C")} ${import_picocolors4.default.bold("Network:")} ${import_picocolors4.default.cyan(`http://${ip}:${activePort}/`)}`
|
|
2804
|
+
);
|
|
2805
|
+
}
|
|
2806
|
+
} else {
|
|
2807
|
+
console.log(
|
|
2808
|
+
` ${import_picocolors4.default.green("\u279C")} ${import_picocolors4.default.bold("Network:")} ${import_picocolors4.default.cyan(`http://127.0.0.1:${activePort}/`)}`
|
|
2809
|
+
);
|
|
2810
|
+
}
|
|
2811
|
+
} else if (host === "localhost" || host === "127.0.0.1" || host === "::1") {
|
|
2812
|
+
console.log(
|
|
2813
|
+
` ${import_picocolors4.default.dim("\u279C Network: use --host or server.host = true to expose")}`
|
|
2814
|
+
);
|
|
2815
|
+
}
|
|
2764
2816
|
console.log("");
|
|
2765
2817
|
if (config.env.isTest) {
|
|
2766
2818
|
this.watcher?.stop();
|
|
@@ -3143,6 +3195,7 @@ var index_default = balm;
|
|
|
3143
3195
|
createHistoryFallbackMiddleware,
|
|
3144
3196
|
deepMerge,
|
|
3145
3197
|
file,
|
|
3198
|
+
getNetworkAddresses,
|
|
3146
3199
|
getWorkspaces,
|
|
3147
3200
|
globalResolve,
|
|
3148
3201
|
globalWorkspace,
|
|
@@ -3157,6 +3210,7 @@ var index_default = balm;
|
|
|
3157
3210
|
logger,
|
|
3158
3211
|
resolveConfig,
|
|
3159
3212
|
resolveDefaultEntry,
|
|
3213
|
+
resolveServerHost,
|
|
3160
3214
|
rewriteCssAssetUrls,
|
|
3161
3215
|
rewriteHtmlAssetPaths,
|
|
3162
3216
|
runEsbuild,
|