@korajs/cli 0.1.0 → 0.1.2
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/README.md +77 -0
- package/dist/bin.cjs +24 -7
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +1 -1
- package/dist/{chunk-REOTYAM6.js → chunk-2YBUSQ7D.js} +23 -6
- package/dist/chunk-2YBUSQ7D.js.map +1 -0
- package/dist/create.cjs +22 -5
- package/dist/create.cjs.map +1 -1
- package/dist/create.js +1 -1
- package/package.json +6 -2
- package/dist/chunk-REOTYAM6.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# @korajs/cli
|
|
2
|
+
|
|
3
|
+
CLI tooling for Kora.js. Scaffold new apps, run the development server, manage schema migrations, and generate TypeScript types.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add -g @korajs/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or use directly with `npx`:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx create-kora-app my-app
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Commands
|
|
18
|
+
|
|
19
|
+
### create-kora-app
|
|
20
|
+
|
|
21
|
+
Scaffold a new Kora.js project:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx create-kora-app my-app
|
|
25
|
+
|
|
26
|
+
# Interactive prompts:
|
|
27
|
+
# Select a template: React (basic) | React (with sync)
|
|
28
|
+
# Package manager: pnpm | npm | yarn | bun
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### kora dev
|
|
32
|
+
|
|
33
|
+
Start the development environment:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
kora dev
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
This runs:
|
|
40
|
+
- Vite dev server for your application
|
|
41
|
+
- Kora sync server (if configured)
|
|
42
|
+
- Schema file watcher with auto type generation
|
|
43
|
+
- Embedded DevTools (toggle with `Ctrl+Shift+K`)
|
|
44
|
+
|
|
45
|
+
### kora migrate
|
|
46
|
+
|
|
47
|
+
Detect schema changes and generate migrations:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
kora migrate
|
|
51
|
+
# Detects changes, generates migration file, prompts to apply
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### kora generate types
|
|
55
|
+
|
|
56
|
+
Generate TypeScript types from your schema:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
kora generate types
|
|
60
|
+
# Output: kora/generated/types.ts
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Quick Start
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npx create-kora-app my-app
|
|
67
|
+
cd my-app
|
|
68
|
+
pnpm dev
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
You'll have a working offline-first app in under 2 minutes.
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
|
|
75
|
+
MIT
|
|
76
|
+
|
|
77
|
+
See the [full documentation](https://github.com/ehoneahobed/kora) for guides, API reference, and examples.
|
package/dist/bin.cjs
CHANGED
|
@@ -27,7 +27,7 @@ var import_citty5 = require("citty");
|
|
|
27
27
|
|
|
28
28
|
// src/commands/create/create-command.ts
|
|
29
29
|
var import_node_child_process2 = require("child_process");
|
|
30
|
-
var
|
|
30
|
+
var import_node_fs2 = require("fs");
|
|
31
31
|
var import_node_path3 = require("path");
|
|
32
32
|
var import_node_url2 = require("url");
|
|
33
33
|
var import_citty = require("citty");
|
|
@@ -305,6 +305,7 @@ function createReadline(options) {
|
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
// src/commands/create/template-engine.ts
|
|
308
|
+
var import_node_fs = require("fs");
|
|
308
309
|
var import_promises2 = require("fs/promises");
|
|
309
310
|
var import_node_path2 = require("path");
|
|
310
311
|
var import_node_url = require("url");
|
|
@@ -316,8 +317,15 @@ function substituteVariables(template, context) {
|
|
|
316
317
|
});
|
|
317
318
|
}
|
|
318
319
|
function getTemplatePath(templateName) {
|
|
320
|
+
let dir = (0, import_node_path2.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
321
|
+
for (let i = 0; i < 5; i++) {
|
|
322
|
+
if ((0, import_node_fs.existsSync)((0, import_node_path2.resolve)(dir, "templates"))) {
|
|
323
|
+
return (0, import_node_path2.resolve)(dir, "templates", templateName);
|
|
324
|
+
}
|
|
325
|
+
dir = (0, import_node_path2.dirname)(dir);
|
|
326
|
+
}
|
|
319
327
|
const currentDir = (0, import_node_path2.dirname)((0, import_node_url.fileURLToPath)(import_meta.url));
|
|
320
|
-
return (0, import_node_path2.resolve)(currentDir, "..", "
|
|
328
|
+
return (0, import_node_path2.resolve)(currentDir, "..", "templates", templateName);
|
|
321
329
|
}
|
|
322
330
|
async function scaffoldTemplate(templateName, targetDir, context) {
|
|
323
331
|
const templateDir = getTemplatePath(templateName);
|
|
@@ -441,9 +449,18 @@ function isValidPackageManager(value) {
|
|
|
441
449
|
}
|
|
442
450
|
function resolveKoraVersion() {
|
|
443
451
|
try {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
452
|
+
let dir = (0, import_node_path3.dirname)((0, import_node_url2.fileURLToPath)(import_meta2.url));
|
|
453
|
+
for (let i = 0; i < 5; i++) {
|
|
454
|
+
const pkgPath = (0, import_node_path3.resolve)(dir, "package.json");
|
|
455
|
+
if ((0, import_node_fs2.existsSync)(pkgPath)) {
|
|
456
|
+
const pkg = JSON.parse((0, import_node_fs2.readFileSync)(pkgPath, "utf-8"));
|
|
457
|
+
if (pkg.name === "@korajs/cli") {
|
|
458
|
+
return pkg.version === "0.0.0" ? "latest" : `^${pkg.version}`;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
dir = (0, import_node_path3.dirname)(dir);
|
|
462
|
+
}
|
|
463
|
+
return "latest";
|
|
447
464
|
} catch {
|
|
448
465
|
return "latest";
|
|
449
466
|
}
|
|
@@ -638,7 +655,7 @@ function delay(ms) {
|
|
|
638
655
|
|
|
639
656
|
// src/commands/dev/schema-watcher.ts
|
|
640
657
|
var import_node_child_process5 = require("child_process");
|
|
641
|
-
var
|
|
658
|
+
var import_node_fs3 = require("fs");
|
|
642
659
|
var SchemaWatcher = class {
|
|
643
660
|
constructor(config) {
|
|
644
661
|
this.config = config;
|
|
@@ -650,7 +667,7 @@ var SchemaWatcher = class {
|
|
|
650
667
|
debounceTimer = null;
|
|
651
668
|
start() {
|
|
652
669
|
if (this.watcher) return;
|
|
653
|
-
this.watcher = (0,
|
|
670
|
+
this.watcher = (0, import_node_fs3.watch)(this.config.schemaPath, () => {
|
|
654
671
|
this.scheduleRegeneration();
|
|
655
672
|
});
|
|
656
673
|
this.watcher.on("error", (error) => {
|