kavoru 0.9.0 → 0.9.3
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 +102 -100
- package/package.json +2 -2
- package/src/args.ts +144 -143
- package/src/features.ts +138 -29
- package/src/index.ts +11 -1
- package/src/module-cli.ts +73 -16
- package/src/prompts.ts +187 -193
package/README.md
CHANGED
|
@@ -1,100 +1,102 @@
|
|
|
1
|
-
# kavoru (CLI)
|
|
2
|
-
|
|
3
|
-
Scaffold a new [Kavoru](https://
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
After publishing to npm:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
bunx kavoru@latest my-api
|
|
11
|
-
cd my-api
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
Always use `@latest` so you get the newest published CLI. Equivalent to `bunx --bun kavoru@latest`.
|
|
16
|
-
|
|
17
|
-
**
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
| `-
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
| `--
|
|
39
|
-
| `--
|
|
40
|
-
| `--
|
|
41
|
-
| `--
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
56
|
-
| `
|
|
57
|
-
| `
|
|
58
|
-
| `
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
#
|
|
94
|
-
bun
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
1
|
+
# kavoru (CLI)
|
|
2
|
+
|
|
3
|
+
Scaffold a new [Kavoru](https://kavoru.com) backend — ElysiaJS, Bun, TypeScript, Prisma, and the full production starter stack.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
After publishing to npm:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bunx kavoru@latest my-api
|
|
11
|
+
cd my-api
|
|
12
|
+
docker compose up --build
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Always use `@latest` so you get the newest published CLI. Equivalent to `bunx --bun kavoru@latest`.
|
|
16
|
+
|
|
17
|
+
Every scaffold includes **Docker Compose** (`docker-compose.yaml` + `docker/app/`). Infra services (Postgres, Kafka, Redis, OTEL, Spotlight) are added when you select those features — the app service is always present.
|
|
18
|
+
|
|
19
|
+
**Stale CLI after a new publish?** Bun caches `bunx` installs under `%TEMP%\bunx-*-kavoru@latest` and does not auto-refresh. Clear the cache, then run `@latest` again:
|
|
20
|
+
|
|
21
|
+
```powershell
|
|
22
|
+
Remove-Item -Recurse -Force "$env:TEMP\bunx-*-kavoru*"
|
|
23
|
+
bunx kavoru@latest my-api
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
rm -rf "${TMPDIR:-/tmp}"/bunx-*-kavoru*
|
|
28
|
+
bunx kavoru@latest my-api
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Options
|
|
32
|
+
|
|
33
|
+
| Flag | Description |
|
|
34
|
+
| ------------------- | -------------------------------------------------------- |
|
|
35
|
+
| `-h, --help` | Show help |
|
|
36
|
+
| `-V, --version` | Show CLI version |
|
|
37
|
+
| `-f, --force` | Scaffold into a non-empty directory |
|
|
38
|
+
| `--no-install` | Skip `bun install` |
|
|
39
|
+
| `--repo owner/name` | Override template repo (default: `mertthesamael/Kavoru`) |
|
|
40
|
+
| `--branch name` | Template branch (default: `master`) |
|
|
41
|
+
| `--minimal` | Core only — health, OpenAPI, response envelope |
|
|
42
|
+
| `--features list` | Comma-separated features to include |
|
|
43
|
+
| `--no-features list`| Comma-separated features to exclude (default: all on) |
|
|
44
|
+
|
|
45
|
+
### Optional features
|
|
46
|
+
|
|
47
|
+
During setup you can pick which integrations to scaffold. **Docker Compose is always included** (app image + compose file). Core is always included: health routes, OpenAPI at `/help`, CORS, and the JSON response envelope.
|
|
48
|
+
|
|
49
|
+
| ID | Feature |
|
|
50
|
+
| ----------- | ---------------------- |
|
|
51
|
+
| `auth` | JWT authentication |
|
|
52
|
+
| `postgres` | PostgreSQL + Prisma (includes Docker Postgres) |
|
|
53
|
+
| `otel` | OpenTelemetry |
|
|
54
|
+
| `sentry` | Sentry + Spotlight |
|
|
55
|
+
| `kafka` | Kafka producer/consumer|
|
|
56
|
+
| `redis` | Redis cache + CRUD API |
|
|
57
|
+
| `websocket` | WebSocket realtime |
|
|
58
|
+
| `resend` | Resend email |
|
|
59
|
+
| `cron` | Cron jobs |
|
|
60
|
+
| `cli` | Project CLI (`kavoru module`, bin, root shims) |
|
|
61
|
+
|
|
62
|
+
Interactive mode (TTY) shows a checkbox menu (↑↓ move, Space toggle, Enter confirm). Non-interactive runs use the full stack unless you pass flags.
|
|
63
|
+
|
|
64
|
+
### Examples
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Interactive (prompts for project name + feature toggles)
|
|
68
|
+
bunx kavoru@latest
|
|
69
|
+
|
|
70
|
+
# Current directory
|
|
71
|
+
bunx kavoru@latest .
|
|
72
|
+
|
|
73
|
+
# Minimal API skeleton
|
|
74
|
+
bunx kavoru@latest my-api --minimal
|
|
75
|
+
|
|
76
|
+
# Pick specific features
|
|
77
|
+
bunx kavoru@latest my-api --features auth,postgres,otel,sentry
|
|
78
|
+
|
|
79
|
+
# Full stack minus Kafka and Resend
|
|
80
|
+
bunx kavoru@latest my-api --no-features kafka,resend
|
|
81
|
+
|
|
82
|
+
# Custom template fork (local dev)
|
|
83
|
+
bunx kavoru@latest demo --repo your-user/Kavoru --no-install
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Development
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
cd elysia-template-initializer
|
|
90
|
+
bun install
|
|
91
|
+
bun test
|
|
92
|
+
|
|
93
|
+
# Run locally without publishing
|
|
94
|
+
bun run src/index.ts my-test-app
|
|
95
|
+
# or
|
|
96
|
+
bun link
|
|
97
|
+
bunx kavoru@latest my-test-app
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kavoru",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"description": "Scaffold a new Kavoru (Elysia + Bun) backend from the official template",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"type": "git",
|
|
29
29
|
"url": "git+https://github.com/mertthesamael/kavoru-cli.git"
|
|
30
30
|
},
|
|
31
|
-
"homepage": "https://
|
|
31
|
+
"homepage": "https://kavoru.com",
|
|
32
32
|
"bugs": {
|
|
33
33
|
"url": "https://github.com/mertthesamael/Kavoru/issues"
|
|
34
34
|
},
|
package/src/args.ts
CHANGED
|
@@ -1,143 +1,144 @@
|
|
|
1
|
-
import { PACKAGE_VERSION } from "./constants";
|
|
2
|
-
|
|
3
|
-
export type CliOptions = {
|
|
4
|
-
targetDir: string | undefined;
|
|
5
|
-
help: boolean;
|
|
6
|
-
version: boolean;
|
|
7
|
-
install: boolean;
|
|
8
|
-
force: boolean;
|
|
9
|
-
repo: string;
|
|
10
|
-
branch: string;
|
|
11
|
-
minimal: boolean;
|
|
12
|
-
features: string | undefined;
|
|
13
|
-
noFeatures: string[];
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const HELP = `\
|
|
17
|
-
Usage: kavoru [options] [directory]
|
|
18
|
-
kavoru module <module-name> [options]
|
|
19
|
-
|
|
20
|
-
Create a new project from the Kavoru Elysia + Bun template.
|
|
21
|
-
|
|
22
|
-
Commands:
|
|
23
|
-
module <name> Generate src/modules/<name> (routes, service, types)
|
|
24
|
-
|
|
25
|
-
Arguments:
|
|
26
|
-
directory Project folder (use "." for current directory)
|
|
27
|
-
|
|
28
|
-
Options:
|
|
29
|
-
-h, --help Show help
|
|
30
|
-
-V, --version Show version
|
|
31
|
-
-f, --force Overwrite / use a non-empty target directory
|
|
32
|
-
--no-install Skip "bun install" after scaffolding
|
|
33
|
-
--repo <owner/name> GitHub template repo (default: mertthesamael/Kavoru)
|
|
34
|
-
--branch <name> Template branch (default: master)
|
|
35
|
-
--minimal Core only (health, OpenAPI, response envelope)
|
|
36
|
-
--features <list> Comma-separated features to include (default: all)
|
|
37
|
-
--no-features <list> Comma-separated features to exclude
|
|
38
|
-
|
|
39
|
-
Features:
|
|
40
|
-
auth, postgres, otel, sentry, kafka, websocket, resend, cron,
|
|
41
|
-
(prisma is accepted as an alias for postgres; kavoru-cli for cli)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
bunx kavoru@latest my-api
|
|
46
|
-
bunx kavoru@latest my-api --
|
|
47
|
-
bunx kavoru@latest my-api --
|
|
48
|
-
bunx kavoru@latest
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
case "
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
case "
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
case "
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
1
|
+
import { PACKAGE_VERSION } from "./constants";
|
|
2
|
+
|
|
3
|
+
export type CliOptions = {
|
|
4
|
+
targetDir: string | undefined;
|
|
5
|
+
help: boolean;
|
|
6
|
+
version: boolean;
|
|
7
|
+
install: boolean;
|
|
8
|
+
force: boolean;
|
|
9
|
+
repo: string;
|
|
10
|
+
branch: string;
|
|
11
|
+
minimal: boolean;
|
|
12
|
+
features: string | undefined;
|
|
13
|
+
noFeatures: string[];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const HELP = `\
|
|
17
|
+
Usage: kavoru [options] [directory]
|
|
18
|
+
kavoru module <module-name> [options]
|
|
19
|
+
|
|
20
|
+
Create a new project from the Kavoru Elysia + Bun template.
|
|
21
|
+
|
|
22
|
+
Commands:
|
|
23
|
+
module <name> Generate src/modules/<name> (routes, service, types)
|
|
24
|
+
|
|
25
|
+
Arguments:
|
|
26
|
+
directory Project folder (use "." for current directory)
|
|
27
|
+
|
|
28
|
+
Options:
|
|
29
|
+
-h, --help Show help
|
|
30
|
+
-V, --version Show version
|
|
31
|
+
-f, --force Overwrite / use a non-empty target directory
|
|
32
|
+
--no-install Skip "bun install" after scaffolding
|
|
33
|
+
--repo <owner/name> GitHub template repo (default: mertthesamael/Kavoru)
|
|
34
|
+
--branch <name> Template branch (default: master)
|
|
35
|
+
--minimal Core only (health, OpenAPI, response envelope)
|
|
36
|
+
--features <list> Comma-separated features to include (default: all)
|
|
37
|
+
--no-features <list> Comma-separated features to exclude
|
|
38
|
+
|
|
39
|
+
Features:
|
|
40
|
+
auth, postgres, otel, sentry, kafka, redis, websocket, resend, cron, cli
|
|
41
|
+
(prisma is accepted as an alias for postgres; kavoru-cli for cli)
|
|
42
|
+
Docker Compose is always included — not a toggle.
|
|
43
|
+
|
|
44
|
+
Examples:
|
|
45
|
+
bunx kavoru@latest my-api
|
|
46
|
+
bunx kavoru@latest my-api --minimal
|
|
47
|
+
bunx kavoru@latest my-api --features auth,postgres,otel
|
|
48
|
+
bunx kavoru@latest my-api --no-features kafka,resend
|
|
49
|
+
bunx kavoru@latest module users
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
export function parseArgs(argv: string[]): CliOptions {
|
|
53
|
+
const options: CliOptions = {
|
|
54
|
+
targetDir: undefined,
|
|
55
|
+
help: false,
|
|
56
|
+
version: false,
|
|
57
|
+
install: true,
|
|
58
|
+
force: false,
|
|
59
|
+
repo: "mertthesamael/Kavoru",
|
|
60
|
+
branch: "master",
|
|
61
|
+
minimal: false,
|
|
62
|
+
features: undefined,
|
|
63
|
+
noFeatures: [],
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const positional: string[] = [];
|
|
67
|
+
|
|
68
|
+
for (let i = 0; i < argv.length; i++) {
|
|
69
|
+
const arg = argv[i];
|
|
70
|
+
if (!arg) continue;
|
|
71
|
+
|
|
72
|
+
switch (arg) {
|
|
73
|
+
case "-h":
|
|
74
|
+
case "--help":
|
|
75
|
+
options.help = true;
|
|
76
|
+
break;
|
|
77
|
+
case "-V":
|
|
78
|
+
case "--version":
|
|
79
|
+
options.version = true;
|
|
80
|
+
break;
|
|
81
|
+
case "-f":
|
|
82
|
+
case "--force":
|
|
83
|
+
options.force = true;
|
|
84
|
+
break;
|
|
85
|
+
case "--no-install":
|
|
86
|
+
options.install = false;
|
|
87
|
+
break;
|
|
88
|
+
case "--minimal":
|
|
89
|
+
options.minimal = true;
|
|
90
|
+
break;
|
|
91
|
+
case "--features": {
|
|
92
|
+
const value = argv[++i];
|
|
93
|
+
if (!value) throw new Error("--features requires a comma-separated list.");
|
|
94
|
+
options.features = value;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
case "--no-features": {
|
|
98
|
+
const value = argv[++i];
|
|
99
|
+
if (!value) {
|
|
100
|
+
throw new Error("--no-features requires a comma-separated list.");
|
|
101
|
+
}
|
|
102
|
+
options.noFeatures.push(
|
|
103
|
+
...value.split(",").map((part) => part.trim()).filter(Boolean),
|
|
104
|
+
);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case "--repo": {
|
|
108
|
+
const value = argv[++i];
|
|
109
|
+
if (!value) throw new Error("--repo requires a value (owner/name).");
|
|
110
|
+
options.repo = value;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
case "--branch": {
|
|
114
|
+
const value = argv[++i];
|
|
115
|
+
if (!value) throw new Error("--branch requires a value.");
|
|
116
|
+
options.branch = value;
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
default:
|
|
120
|
+
if (arg.startsWith("-")) {
|
|
121
|
+
throw new Error(`Unknown option: ${arg}`);
|
|
122
|
+
}
|
|
123
|
+
positional.push(arg);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (positional[0]) {
|
|
128
|
+
options.targetDir = positional[0];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (options.minimal && options.features) {
|
|
132
|
+
throw new Error("Use either --minimal or --features, not both.");
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return options;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function printHelp(): void {
|
|
139
|
+
console.log(HELP.trim());
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function printVersion(): void {
|
|
143
|
+
console.log(PACKAGE_VERSION);
|
|
144
|
+
}
|