create-caspian-app 0.1.2 → 0.1.3
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/settings/bs-config.ts +19 -2
- package/package.json +1 -1
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { componentMap } from "./component-map.js";
|
|
13
13
|
import { createServer } from "net";
|
|
14
14
|
import chalk from "chalk";
|
|
15
|
+
import { networkInterfaces } from "os";
|
|
15
16
|
|
|
16
17
|
const { __dirname } = getFileMeta();
|
|
17
18
|
const bs: BrowserSyncInstance = browserSync.create();
|
|
@@ -35,6 +36,18 @@ function getAvailablePort(startPort: number): Promise<number> {
|
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
38
|
|
|
39
|
+
function getExternalIP(): string | null {
|
|
40
|
+
const nets = networkInterfaces();
|
|
41
|
+
for (const name of Object.keys(nets)) {
|
|
42
|
+
for (const net of nets[name]!) {
|
|
43
|
+
if (net.family === "IPv4" && !net.internal) {
|
|
44
|
+
return net.address;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
38
51
|
const pipeline = new DebouncedWorker(
|
|
39
52
|
async () => {
|
|
40
53
|
const changedFile = lastChangedFile;
|
|
@@ -199,6 +212,7 @@ const publicPipeline = new DebouncedWorker(
|
|
|
199
212
|
{
|
|
200
213
|
proxy: `http://localhost:${pythonPort}`,
|
|
201
214
|
port: bsPort,
|
|
215
|
+
online: true,
|
|
202
216
|
middleware: [
|
|
203
217
|
(_req, res, next) => {
|
|
204
218
|
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
|
|
@@ -220,8 +234,11 @@ const publicPipeline = new DebouncedWorker(
|
|
|
220
234
|
}
|
|
221
235
|
|
|
222
236
|
const urls = bsInstance.getOption("urls");
|
|
223
|
-
const localUrl = urls.get("local")
|
|
224
|
-
const
|
|
237
|
+
const localUrl = urls.get("local") || `http://localhost:${bsPort}`;
|
|
238
|
+
const externalIP = getExternalIP();
|
|
239
|
+
const externalUrl =
|
|
240
|
+
urls.get("external") ||
|
|
241
|
+
(externalIP ? `http://${externalIP}:${bsPort}` : null);
|
|
225
242
|
const uiUrl = urls.get("ui");
|
|
226
243
|
const uiExtUrl = urls.get("ui-external");
|
|
227
244
|
|