create-prisma-php-app 4.1.0-alpha.11 → 4.1.0-alpha.12

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.
@@ -1,9 +1,9 @@
1
1
  import { createProxyMiddleware } from "http-proxy-middleware";
2
- import { writeFileSync } from "fs";
2
+ import { writeFileSync, existsSync, mkdirSync } from "fs";
3
3
  import browserSync, { BrowserSyncInstance } from "browser-sync";
4
4
  import prismaPhpConfigJson from "../prisma-php.json";
5
5
  import { generateFileListJson } from "./files-list.js";
6
- import { join } from "path";
6
+ import { join, dirname } from "path";
7
7
  import { getFileMeta, PUBLIC_DIR, SRC_DIR } from "./utils.js";
8
8
  import { updateAllClassLogs } from "./class-log.js";
9
9
  import {
@@ -39,6 +39,10 @@ const pipeline = new DebouncedWorker(
39
39
  }
40
40
  await checkComponentImports(file, fileImports);
41
41
  }
42
+
43
+ if (bs.active) {
44
+ bs.reload();
45
+ }
42
46
  },
43
47
  350,
44
48
  "bs-pipeline"
@@ -46,7 +50,10 @@ const pipeline = new DebouncedWorker(
46
50
 
47
51
  const publicPipeline = new DebouncedWorker(
48
52
  async () => {
49
- console.log("Public directory changed");
53
+ console.log("Public directory changed, reloading browser...");
54
+ if (bs.active) {
55
+ bs.reload();
56
+ }
50
57
  },
51
58
  350,
52
59
  "bs-public-pipeline"
@@ -68,6 +75,27 @@ createSrcWatcher(join(PUBLIC_DIR, "**", "*"), {
68
75
  interval: 1000,
69
76
  });
70
77
 
78
+ const viteFlagFile = join(__dirname, "..", ".pp", ".vite-build-complete");
79
+ mkdirSync(dirname(viteFlagFile), { recursive: true });
80
+ writeFileSync(viteFlagFile, "");
81
+
82
+ if (!existsSync(viteFlagFile)) {
83
+ writeFileSync(viteFlagFile, "0");
84
+ }
85
+
86
+ createSrcWatcher(viteFlagFile, {
87
+ onEvent: (ev) => {
88
+ if (ev === "change" && bs.active) {
89
+ console.log("→ Vite build complete, reloading browser...");
90
+ bs.reload();
91
+ }
92
+ },
93
+ awaitWriteFinish: { stabilityThreshold: 100, pollInterval: 50 },
94
+ logPrefix: "watch-vite",
95
+ usePolling: true,
96
+ interval: 500,
97
+ });
98
+
71
99
  bs.init(
72
100
  {
73
101
  proxy: "http://localhost:3000",
@@ -85,15 +113,10 @@ bs.init(
85
113
  }),
86
114
  ],
87
115
 
88
- files: [`${SRC_DIR}/**/*.*`, `${PUBLIC_DIR}/**/*.*`],
89
116
  notify: false,
90
117
  open: false,
91
118
  ghostMode: false,
92
119
  codeSync: true,
93
- watchOptions: {
94
- usePolling: true,
95
- interval: 1000,
96
- },
97
120
  },
98
121
  (err, bsInstance) => {
99
122
  if (err) {
@@ -1,6 +1,7 @@
1
- import { defineConfig } from "vite";
1
+ import { defineConfig, Plugin } from "vite";
2
2
  import path from "path";
3
3
  import fg from "fast-glob";
4
+ import { writeFileSync } from "fs";
4
5
 
5
6
  const entries = Object.fromEntries(
6
7
  fg.sync("ts/**/*.ts", { ignore: ["**/*.test.ts"] }).map((f) => {
@@ -9,6 +10,17 @@ const entries = Object.fromEntries(
9
10
  })
10
11
  );
11
12
 
13
+ function browserSyncNotify(): Plugin {
14
+ const flagFile = path.resolve(__dirname, ".pp", ".vite-build-complete");
15
+
16
+ return {
17
+ name: "browsersync-notify",
18
+ writeBundle() {
19
+ writeFileSync(flagFile, Date.now().toString());
20
+ },
21
+ };
22
+ }
23
+
12
24
  export default defineConfig({
13
25
  publicDir: false,
14
26
  build: {
@@ -28,6 +40,7 @@ export default defineConfig({
28
40
  },
29
41
  },
30
42
  },
43
+ plugins: [browserSyncNotify()],
31
44
  esbuild: { legalComments: "none" },
32
45
  define: { "process.env.NODE_ENV": '"production"' },
33
46
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-prisma-php-app",
3
- "version": "4.1.0-alpha.11",
3
+ "version": "4.1.0-alpha.12",
4
4
  "description": "Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",