create-prisma-php-app 4.4.3 → 4.4.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.
@@ -3,6 +3,7 @@ import {
3
3
  responseInterceptor,
4
4
  } from "http-proxy-middleware";
5
5
  import { writeFileSync, existsSync, mkdirSync } from "fs";
6
+ import { networkInterfaces } from "os";
6
7
  import browserSync, { BrowserSyncInstance } from "browser-sync";
7
8
  import prismaPhpConfigJson from "../prisma-php.json";
8
9
  import { generateFileListJson } from "./files-list.js";
@@ -23,6 +24,18 @@ const bs: BrowserSyncInstance = browserSync.create();
23
24
 
24
25
  const PUBLIC_IGNORE_DIRS = [""];
25
26
 
27
+ function getExternalIP(): string | null {
28
+ const nets = networkInterfaces();
29
+ for (const name of Object.keys(nets)) {
30
+ for (const net of nets[name]!) {
31
+ if (net.family === "IPv4" && !net.internal) {
32
+ return net.address;
33
+ }
34
+ }
35
+ }
36
+ return null;
37
+ }
38
+
26
39
  const pipeline = new DebouncedWorker(
27
40
  async () => {
28
41
  await generateFileListJson();
@@ -117,6 +130,7 @@ createSrcWatcher(viteFlagFile, {
117
130
  bs.init(
118
131
  {
119
132
  proxy: "http://localhost:3000",
133
+ online: true,
120
134
  middleware: [
121
135
  (_req, res, next) => {
122
136
  res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
@@ -217,9 +231,13 @@ bs.init(
217
231
  return;
218
232
  }
219
233
 
234
+ const bsPort = bsInstance.getOption("port");
220
235
  const urls = bsInstance.getOption("urls");
221
- const localUrl = urls.get("local");
222
- const externalUrl = urls.get("external");
236
+ const localUrl = urls.get("local") || `http://localhost:${bsPort}`;
237
+ const externalIP = getExternalIP();
238
+ const externalUrl =
239
+ urls.get("external") ||
240
+ (externalIP ? `http://${externalIP}:${bsPort}` : null);
223
241
  const uiUrl = urls.get("ui");
224
242
  const uiExtUrl = urls.get("ui-external");
225
243
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "4.4.3",
3
+ "version": "4.4.4",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",