koguma 2.3.4 → 2.3.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/cli/dev-sync.ts +18 -1
- package/package.json +1 -1
- package/src/admin/_bundle.ts +1 -1
- package/src/vite.js +7 -17
- package/src/vite.ts +15 -32
package/cli/dev-sync.ts
CHANGED
|
@@ -37,7 +37,22 @@ import {
|
|
|
37
37
|
writeContentDir,
|
|
38
38
|
type ContentTypeInfo
|
|
39
39
|
} from './content.ts';
|
|
40
|
-
import { CONTENT_DIR, SITE_CONFIG_FILE } from './constants.ts';
|
|
40
|
+
import { CONTENT_DIR, SITE_CONFIG_FILE, KOGUMA_DIR } from './constants.ts';
|
|
41
|
+
|
|
42
|
+
// ── HMR signal ─────────────────────────────────────────────────────
|
|
43
|
+
// Writes a timestamp to .koguma/dbhash after each successful sync.
|
|
44
|
+
// The kogumaHMR Vite plugin watches this file and triggers a full
|
|
45
|
+
// browser reload — much cleaner than watching the SQLite WAL files.
|
|
46
|
+
|
|
47
|
+
function touchDbHash(root: string): void {
|
|
48
|
+
try {
|
|
49
|
+
const dir = resolve(root, KOGUMA_DIR);
|
|
50
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
51
|
+
writeFileSync(resolve(dir, 'dbhash'), String(Date.now()));
|
|
52
|
+
} catch {
|
|
53
|
+
// non-critical — worst case Vite won't auto-reload
|
|
54
|
+
}
|
|
55
|
+
}
|
|
41
56
|
|
|
42
57
|
// ── Constants ──────────────────────────────────────────────────────
|
|
43
58
|
|
|
@@ -153,6 +168,7 @@ function startFileWatcher(opts: FileWatcherOptions): { stop: () => void } {
|
|
|
153
168
|
...(publishAt !== undefined ? { publish_at: publishAt } : {})
|
|
154
169
|
});
|
|
155
170
|
markRecentWrite(entryId);
|
|
171
|
+
touchDbHash(root);
|
|
156
172
|
|
|
157
173
|
ok(
|
|
158
174
|
`${ANSI.DIM}sync:${ANSI.RESET} ${contentTypeId}/${parts.slice(1).join('/')} → D1`
|
|
@@ -396,6 +412,7 @@ function startSyncServer(opts: SyncServerOptions): {
|
|
|
396
412
|
|
|
397
413
|
if (count > 0) {
|
|
398
414
|
markRecentWrite(entryId);
|
|
415
|
+
touchDbHash(root);
|
|
399
416
|
ok(
|
|
400
417
|
`${ANSI.DIM}sync:${ANSI.RESET} D1 → ${payload.contentType}/${slug || 'index'}`
|
|
401
418
|
);
|