@korajs/cli 1.0.0-beta.7 → 1.0.0-beta.9
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/bin.cjs +74 -31
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +67 -29
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-ZTVVAYHJ.js → chunk-Z7GCXMGW.js} +8 -4
- package/dist/chunk-Z7GCXMGW.js.map +1 -0
- package/dist/create.cjs +7 -3
- package/dist/create.cjs.map +1 -1
- package/dist/create.js +1 -1
- package/package.json +8 -8
- package/templates/react-basic/src/main.tsx +1 -1
- package/templates/react-basic/src/vite-env.d.ts +1 -0
- package/templates/react-sync/server.ts +4 -1
- package/templates/react-sync/src/main.tsx +1 -1
- package/templates/react-sync/src/vite-env.d.ts +1 -0
- package/templates/react-sync/vite.config.ts +1 -1
- package/templates/react-tailwind/src/main.tsx +1 -1
- package/templates/react-tailwind/src/vite-env.d.ts +1 -0
- package/templates/react-tailwind-sync/server.ts +4 -1
- package/templates/react-tailwind-sync/src/main.tsx +1 -1
- package/templates/react-tailwind-sync/src/vite-env.d.ts +1 -0
- package/templates/react-tailwind-sync/vite.config.ts +1 -1
- package/templates/svelte-basic/src/main.ts +1 -1
- package/templates/svelte-sync/server.ts +4 -1
- package/templates/svelte-sync/src/main.ts +1 -1
- package/templates/svelte-sync/src/vite-env.d.ts +1 -0
- package/templates/svelte-sync/vite.config.ts +1 -1
- package/templates/svelte-tailwind/src/main.ts +1 -1
- package/templates/svelte-tailwind-sync/server.ts +4 -1
- package/templates/svelte-tailwind-sync/src/main.ts +1 -1
- package/templates/svelte-tailwind-sync/src/vite-env.d.ts +1 -0
- package/templates/svelte-tailwind-sync/vite.config.ts +1 -1
- package/templates/tauri-react/server.ts +4 -1
- package/templates/tauri-react/src/AppShell.tsx +1 -1
- package/templates/tauri-react/src/vite-env.d.ts +1 -0
- package/templates/vue-basic/src/main.ts +1 -1
- package/templates/vue-sync/server.ts +4 -1
- package/templates/vue-sync/src/main.ts +1 -1
- package/templates/vue-sync/src/vite-env.d.ts +1 -0
- package/templates/vue-sync/vite.config.ts +1 -1
- package/templates/vue-tailwind/src/main.ts +1 -1
- package/templates/vue-tailwind-sync/server.ts +4 -1
- package/templates/vue-tailwind-sync/src/main.ts +1 -1
- package/templates/vue-tailwind-sync/src/vite-env.d.ts +1 -0
- package/templates/vue-tailwind-sync/vite.config.ts +1 -1
- package/dist/chunk-ZTVVAYHJ.js.map +0 -1
package/dist/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
createCommand
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-Z7GCXMGW.js";
|
|
5
5
|
import {
|
|
6
6
|
agentsCommand,
|
|
7
7
|
deployCommand,
|
|
@@ -373,6 +373,7 @@ import { spawn as spawnChild } from "child_process";
|
|
|
373
373
|
var ProcessManager = class {
|
|
374
374
|
processes = /* @__PURE__ */ new Map();
|
|
375
375
|
spawn(config) {
|
|
376
|
+
this.processes.get(config.label)?.child.kill("SIGTERM");
|
|
376
377
|
const options = {
|
|
377
378
|
cwd: config.cwd,
|
|
378
379
|
env: { ...process.env, ...config.env },
|
|
@@ -416,6 +417,20 @@ var ProcessManager = class {
|
|
|
416
417
|
hasRunning() {
|
|
417
418
|
return this.processes.size > 0;
|
|
418
419
|
}
|
|
420
|
+
async restart(config) {
|
|
421
|
+
await this.stop(config.label);
|
|
422
|
+
this.spawn(config);
|
|
423
|
+
}
|
|
424
|
+
async stop(label) {
|
|
425
|
+
const running = this.processes.get(label);
|
|
426
|
+
if (!running) return;
|
|
427
|
+
running.child.kill("SIGTERM");
|
|
428
|
+
await Promise.race([running.exitPromise, delay(5e3)]);
|
|
429
|
+
const remaining = this.processes.get(label);
|
|
430
|
+
if (!remaining) return;
|
|
431
|
+
remaining.child.kill("SIGKILL");
|
|
432
|
+
await remaining.exitPromise;
|
|
433
|
+
}
|
|
419
434
|
async shutdownAll() {
|
|
420
435
|
const running = Array.from(this.processes.values());
|
|
421
436
|
if (running.length === 0) return;
|
|
@@ -468,6 +483,7 @@ var SchemaWatcher = class {
|
|
|
468
483
|
debounceMs;
|
|
469
484
|
watcher = null;
|
|
470
485
|
debounceTimer = null;
|
|
486
|
+
schemaVersion = null;
|
|
471
487
|
start() {
|
|
472
488
|
if (this.watcher) return;
|
|
473
489
|
this.watcher = watch(this.config.schemaPath, () => {
|
|
@@ -476,6 +492,9 @@ var SchemaWatcher = class {
|
|
|
476
492
|
this.watcher.on("error", (error) => {
|
|
477
493
|
this.config.onError?.(toError(error));
|
|
478
494
|
});
|
|
495
|
+
void this.refreshSchemaVersion().catch((error) => {
|
|
496
|
+
this.config.onError?.(toError(error));
|
|
497
|
+
});
|
|
479
498
|
}
|
|
480
499
|
stop() {
|
|
481
500
|
if (this.debounceTimer) {
|
|
@@ -499,6 +518,15 @@ var SchemaWatcher = class {
|
|
|
499
518
|
const args = hasTsx ? ["--import", "tsx", koraBinJs, "generate", "types", "--schema", this.config.schemaPath] : [koraBinJs, "generate", "types", "--schema", this.config.schemaPath];
|
|
500
519
|
await spawnCommand(command, args, this.config.projectRoot);
|
|
501
520
|
this.config.onRegenerate?.();
|
|
521
|
+
await this.refreshSchemaVersion();
|
|
522
|
+
}
|
|
523
|
+
async refreshSchemaVersion() {
|
|
524
|
+
const schema = await loadSchemaDefinition(this.config.schemaPath, this.config.projectRoot);
|
|
525
|
+
const previous = this.schemaVersion;
|
|
526
|
+
this.schemaVersion = schema.version;
|
|
527
|
+
if (previous !== null && previous !== schema.version) {
|
|
528
|
+
this.config.onSchemaVersionChange?.({ previous, next: schema.version });
|
|
529
|
+
}
|
|
502
530
|
}
|
|
503
531
|
scheduleRegeneration() {
|
|
504
532
|
if (this.debounceTimer) {
|
|
@@ -685,7 +713,9 @@ var devCommand = defineCommand3({
|
|
|
685
713
|
logger.step(" Schema watcher disabled (schema.ts not found)");
|
|
686
714
|
}
|
|
687
715
|
logger.blank();
|
|
688
|
-
logger.step(
|
|
716
|
+
logger.step(
|
|
717
|
+
" Kora DevTools overlay: Ctrl+Shift+K (Cmd+Shift+K on macOS) when devtools is enabled"
|
|
718
|
+
);
|
|
689
719
|
processManager.spawn({
|
|
690
720
|
label: "vite",
|
|
691
721
|
command: process.execPath,
|
|
@@ -696,33 +726,31 @@ var devCommand = defineCommand3({
|
|
|
696
726
|
},
|
|
697
727
|
onExit: onManagedProcessExit
|
|
698
728
|
});
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
onExit: onManagedProcessExit
|
|
725
|
-
});
|
|
729
|
+
const syncProcessConfig = shouldStartSync && hasTsx && syncServerFile ? {
|
|
730
|
+
label: "sync",
|
|
731
|
+
command: process.execPath,
|
|
732
|
+
args: ["--import", "tsx", syncServerFile],
|
|
733
|
+
cwd: projectRoot,
|
|
734
|
+
env: {
|
|
735
|
+
PORT: String(syncPort),
|
|
736
|
+
KORA_SYNC_PORT: String(syncPort)
|
|
737
|
+
},
|
|
738
|
+
onExit: onManagedProcessExit
|
|
739
|
+
} : shouldStartSync && syncServerFile === null && managedSyncStore !== null ? {
|
|
740
|
+
label: "sync",
|
|
741
|
+
command: process.execPath,
|
|
742
|
+
args: ["--input-type=module", "--eval", MANAGED_SYNC_BOOTSTRAP_SCRIPT],
|
|
743
|
+
cwd: projectRoot,
|
|
744
|
+
env: {
|
|
745
|
+
KORA_DEV_SYNC_CONFIG: JSON.stringify({
|
|
746
|
+
port: Number(syncPort),
|
|
747
|
+
store: managedSyncStore
|
|
748
|
+
})
|
|
749
|
+
},
|
|
750
|
+
onExit: onManagedProcessExit
|
|
751
|
+
} : null;
|
|
752
|
+
if (syncProcessConfig) {
|
|
753
|
+
processManager.spawn(syncProcessConfig);
|
|
726
754
|
}
|
|
727
755
|
if (watchEnabled && schemaPath) {
|
|
728
756
|
schemaWatcher = new SchemaWatcher({
|
|
@@ -732,6 +760,16 @@ var devCommand = defineCommand3({
|
|
|
732
760
|
onRegenerate: () => {
|
|
733
761
|
logger.success("Regenerated types from schema changes");
|
|
734
762
|
},
|
|
763
|
+
onSchemaVersionChange: ({ previous, next }) => {
|
|
764
|
+
if (!syncProcessConfig) {
|
|
765
|
+
logger.warn(
|
|
766
|
+
`Schema version changed from ${previous} to ${next}; restart your sync server before clients can sync.`
|
|
767
|
+
);
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
logger.warn(`Schema version changed from ${previous} to ${next}; restarting sync server.`);
|
|
771
|
+
void processManager.restart(syncProcessConfig);
|
|
772
|
+
},
|
|
735
773
|
onError: (error) => {
|
|
736
774
|
logger.error(`Schema watcher error: ${error.message}`);
|
|
737
775
|
}
|