@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.cjs
CHANGED
|
@@ -4279,9 +4279,7 @@ function resolveKoraVersion() {
|
|
|
4279
4279
|
if ((0, import_node_fs2.existsSync)(pkgPath)) {
|
|
4280
4280
|
const pkg = JSON.parse((0, import_node_fs2.readFileSync)(pkgPath, "utf-8"));
|
|
4281
4281
|
if (pkg.name === "@korajs/cli") {
|
|
4282
|
-
|
|
4283
|
-
const parts = pkg.version.split(".");
|
|
4284
|
-
return `^${parts[0]}.${parts[1]}.0`;
|
|
4282
|
+
return deriveKoraTemplateVersion(pkg.version);
|
|
4285
4283
|
}
|
|
4286
4284
|
}
|
|
4287
4285
|
dir = (0, import_node_path10.dirname)(dir);
|
|
@@ -4291,6 +4289,12 @@ function resolveKoraVersion() {
|
|
|
4291
4289
|
return "latest";
|
|
4292
4290
|
}
|
|
4293
4291
|
}
|
|
4292
|
+
function deriveKoraTemplateVersion(version) {
|
|
4293
|
+
if (version === "0.0.0") return "latest";
|
|
4294
|
+
if (version.includes("-")) return version;
|
|
4295
|
+
const parts = version.split(".");
|
|
4296
|
+
return `^${parts[0]}.${parts[1]}.0`;
|
|
4297
|
+
}
|
|
4294
4298
|
|
|
4295
4299
|
// src/commands/deploy/deploy-command.ts
|
|
4296
4300
|
var import_node_fs4 = require("fs");
|
|
@@ -6520,6 +6524,7 @@ var import_node_child_process10 = require("child_process");
|
|
|
6520
6524
|
var ProcessManager = class {
|
|
6521
6525
|
processes = /* @__PURE__ */ new Map();
|
|
6522
6526
|
spawn(config) {
|
|
6527
|
+
this.processes.get(config.label)?.child.kill("SIGTERM");
|
|
6523
6528
|
const options = {
|
|
6524
6529
|
cwd: config.cwd,
|
|
6525
6530
|
env: { ...process.env, ...config.env },
|
|
@@ -6563,6 +6568,20 @@ var ProcessManager = class {
|
|
|
6563
6568
|
hasRunning() {
|
|
6564
6569
|
return this.processes.size > 0;
|
|
6565
6570
|
}
|
|
6571
|
+
async restart(config) {
|
|
6572
|
+
await this.stop(config.label);
|
|
6573
|
+
this.spawn(config);
|
|
6574
|
+
}
|
|
6575
|
+
async stop(label) {
|
|
6576
|
+
const running = this.processes.get(label);
|
|
6577
|
+
if (!running) return;
|
|
6578
|
+
running.child.kill("SIGTERM");
|
|
6579
|
+
await Promise.race([running.exitPromise, delay(5e3)]);
|
|
6580
|
+
const remaining = this.processes.get(label);
|
|
6581
|
+
if (!remaining) return;
|
|
6582
|
+
remaining.child.kill("SIGKILL");
|
|
6583
|
+
await remaining.exitPromise;
|
|
6584
|
+
}
|
|
6566
6585
|
async shutdownAll() {
|
|
6567
6586
|
const running = Array.from(this.processes.values());
|
|
6568
6587
|
if (running.length === 0) return;
|
|
@@ -6607,6 +6626,7 @@ var import_node_child_process11 = require("child_process");
|
|
|
6607
6626
|
var import_node_fs5 = require("fs");
|
|
6608
6627
|
var import_node_path22 = require("path");
|
|
6609
6628
|
init_fs_helpers();
|
|
6629
|
+
init_schema_loader();
|
|
6610
6630
|
var SchemaWatcher = class {
|
|
6611
6631
|
constructor(config) {
|
|
6612
6632
|
this.config = config;
|
|
@@ -6616,6 +6636,7 @@ var SchemaWatcher = class {
|
|
|
6616
6636
|
debounceMs;
|
|
6617
6637
|
watcher = null;
|
|
6618
6638
|
debounceTimer = null;
|
|
6639
|
+
schemaVersion = null;
|
|
6619
6640
|
start() {
|
|
6620
6641
|
if (this.watcher) return;
|
|
6621
6642
|
this.watcher = (0, import_node_fs5.watch)(this.config.schemaPath, () => {
|
|
@@ -6624,6 +6645,9 @@ var SchemaWatcher = class {
|
|
|
6624
6645
|
this.watcher.on("error", (error) => {
|
|
6625
6646
|
this.config.onError?.(toError(error));
|
|
6626
6647
|
});
|
|
6648
|
+
void this.refreshSchemaVersion().catch((error) => {
|
|
6649
|
+
this.config.onError?.(toError(error));
|
|
6650
|
+
});
|
|
6627
6651
|
}
|
|
6628
6652
|
stop() {
|
|
6629
6653
|
if (this.debounceTimer) {
|
|
@@ -6647,6 +6671,15 @@ var SchemaWatcher = class {
|
|
|
6647
6671
|
const args = hasTsx ? ["--import", "tsx", koraBinJs, "generate", "types", "--schema", this.config.schemaPath] : [koraBinJs, "generate", "types", "--schema", this.config.schemaPath];
|
|
6648
6672
|
await spawnCommand(command, args, this.config.projectRoot);
|
|
6649
6673
|
this.config.onRegenerate?.();
|
|
6674
|
+
await this.refreshSchemaVersion();
|
|
6675
|
+
}
|
|
6676
|
+
async refreshSchemaVersion() {
|
|
6677
|
+
const schema = await loadSchemaDefinition(this.config.schemaPath, this.config.projectRoot);
|
|
6678
|
+
const previous = this.schemaVersion;
|
|
6679
|
+
this.schemaVersion = schema.version;
|
|
6680
|
+
if (previous !== null && previous !== schema.version) {
|
|
6681
|
+
this.config.onSchemaVersionChange?.({ previous, next: schema.version });
|
|
6682
|
+
}
|
|
6650
6683
|
}
|
|
6651
6684
|
scheduleRegeneration() {
|
|
6652
6685
|
if (this.debounceTimer) {
|
|
@@ -6833,7 +6866,9 @@ var devCommand = (0, import_citty6.defineCommand)({
|
|
|
6833
6866
|
logger.step(" Schema watcher disabled (schema.ts not found)");
|
|
6834
6867
|
}
|
|
6835
6868
|
logger.blank();
|
|
6836
|
-
logger.step(
|
|
6869
|
+
logger.step(
|
|
6870
|
+
" Kora DevTools overlay: Ctrl+Shift+K (Cmd+Shift+K on macOS) when devtools is enabled"
|
|
6871
|
+
);
|
|
6837
6872
|
processManager.spawn({
|
|
6838
6873
|
label: "vite",
|
|
6839
6874
|
command: process.execPath,
|
|
@@ -6844,33 +6879,31 @@ var devCommand = (0, import_citty6.defineCommand)({
|
|
|
6844
6879
|
},
|
|
6845
6880
|
onExit: onManagedProcessExit
|
|
6846
6881
|
});
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
onExit: onManagedProcessExit
|
|
6873
|
-
});
|
|
6882
|
+
const syncProcessConfig = shouldStartSync && hasTsx && syncServerFile ? {
|
|
6883
|
+
label: "sync",
|
|
6884
|
+
command: process.execPath,
|
|
6885
|
+
args: ["--import", "tsx", syncServerFile],
|
|
6886
|
+
cwd: projectRoot,
|
|
6887
|
+
env: {
|
|
6888
|
+
PORT: String(syncPort),
|
|
6889
|
+
KORA_SYNC_PORT: String(syncPort)
|
|
6890
|
+
},
|
|
6891
|
+
onExit: onManagedProcessExit
|
|
6892
|
+
} : shouldStartSync && syncServerFile === null && managedSyncStore !== null ? {
|
|
6893
|
+
label: "sync",
|
|
6894
|
+
command: process.execPath,
|
|
6895
|
+
args: ["--input-type=module", "--eval", MANAGED_SYNC_BOOTSTRAP_SCRIPT],
|
|
6896
|
+
cwd: projectRoot,
|
|
6897
|
+
env: {
|
|
6898
|
+
KORA_DEV_SYNC_CONFIG: JSON.stringify({
|
|
6899
|
+
port: Number(syncPort),
|
|
6900
|
+
store: managedSyncStore
|
|
6901
|
+
})
|
|
6902
|
+
},
|
|
6903
|
+
onExit: onManagedProcessExit
|
|
6904
|
+
} : null;
|
|
6905
|
+
if (syncProcessConfig) {
|
|
6906
|
+
processManager.spawn(syncProcessConfig);
|
|
6874
6907
|
}
|
|
6875
6908
|
if (watchEnabled && schemaPath) {
|
|
6876
6909
|
schemaWatcher = new SchemaWatcher({
|
|
@@ -6880,6 +6913,16 @@ var devCommand = (0, import_citty6.defineCommand)({
|
|
|
6880
6913
|
onRegenerate: () => {
|
|
6881
6914
|
logger.success("Regenerated types from schema changes");
|
|
6882
6915
|
},
|
|
6916
|
+
onSchemaVersionChange: ({ previous, next }) => {
|
|
6917
|
+
if (!syncProcessConfig) {
|
|
6918
|
+
logger.warn(
|
|
6919
|
+
`Schema version changed from ${previous} to ${next}; restart your sync server before clients can sync.`
|
|
6920
|
+
);
|
|
6921
|
+
return;
|
|
6922
|
+
}
|
|
6923
|
+
logger.warn(`Schema version changed from ${previous} to ${next}; restarting sync server.`);
|
|
6924
|
+
void processManager.restart(syncProcessConfig);
|
|
6925
|
+
},
|
|
6883
6926
|
onError: (error) => {
|
|
6884
6927
|
logger.error(`Schema watcher error: ${error.message}`);
|
|
6885
6928
|
}
|