@donkeylabs/cli 0.1.0

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.
Files changed (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +141 -0
  3. package/package.json +51 -0
  4. package/src/commands/generate.ts +585 -0
  5. package/src/commands/init.ts +201 -0
  6. package/src/commands/interactive.ts +223 -0
  7. package/src/commands/plugin.ts +205 -0
  8. package/src/index.ts +108 -0
  9. package/templates/starter/.env.example +3 -0
  10. package/templates/starter/.gitignore.template +4 -0
  11. package/templates/starter/CLAUDE.md +144 -0
  12. package/templates/starter/donkeylabs.config.ts +6 -0
  13. package/templates/starter/package.json +21 -0
  14. package/templates/starter/src/client.test.ts +7 -0
  15. package/templates/starter/src/db.ts +9 -0
  16. package/templates/starter/src/index.ts +48 -0
  17. package/templates/starter/src/plugins/stats/index.ts +105 -0
  18. package/templates/starter/src/routes/health/index.ts +5 -0
  19. package/templates/starter/src/routes/health/ping/index.ts +13 -0
  20. package/templates/starter/src/routes/health/ping/models/model.ts +23 -0
  21. package/templates/starter/src/routes/health/ping/schema.ts +14 -0
  22. package/templates/starter/src/routes/health/ping/tests/integ.test.ts +20 -0
  23. package/templates/starter/src/routes/health/ping/tests/unit.test.ts +21 -0
  24. package/templates/starter/src/test-ctx.ts +24 -0
  25. package/templates/starter/tsconfig.json +27 -0
  26. package/templates/sveltekit-app/.env.example +3 -0
  27. package/templates/sveltekit-app/README.md +103 -0
  28. package/templates/sveltekit-app/donkeylabs.config.ts +10 -0
  29. package/templates/sveltekit-app/package.json +36 -0
  30. package/templates/sveltekit-app/src/app.css +40 -0
  31. package/templates/sveltekit-app/src/app.html +12 -0
  32. package/templates/sveltekit-app/src/hooks.server.ts +4 -0
  33. package/templates/sveltekit-app/src/lib/api.ts +134 -0
  34. package/templates/sveltekit-app/src/lib/components/ui/badge/badge.svelte +30 -0
  35. package/templates/sveltekit-app/src/lib/components/ui/badge/index.ts +3 -0
  36. package/templates/sveltekit-app/src/lib/components/ui/button/button.svelte +48 -0
  37. package/templates/sveltekit-app/src/lib/components/ui/button/index.ts +9 -0
  38. package/templates/sveltekit-app/src/lib/components/ui/card/card-content.svelte +18 -0
  39. package/templates/sveltekit-app/src/lib/components/ui/card/card-description.svelte +18 -0
  40. package/templates/sveltekit-app/src/lib/components/ui/card/card-footer.svelte +18 -0
  41. package/templates/sveltekit-app/src/lib/components/ui/card/card-header.svelte +18 -0
  42. package/templates/sveltekit-app/src/lib/components/ui/card/card-title.svelte +18 -0
  43. package/templates/sveltekit-app/src/lib/components/ui/card/card.svelte +21 -0
  44. package/templates/sveltekit-app/src/lib/components/ui/card/index.ts +21 -0
  45. package/templates/sveltekit-app/src/lib/components/ui/index.ts +4 -0
  46. package/templates/sveltekit-app/src/lib/components/ui/input/index.ts +2 -0
  47. package/templates/sveltekit-app/src/lib/components/ui/input/input.svelte +20 -0
  48. package/templates/sveltekit-app/src/lib/utils/index.ts +6 -0
  49. package/templates/sveltekit-app/src/routes/+layout.svelte +8 -0
  50. package/templates/sveltekit-app/src/routes/+page.server.ts +25 -0
  51. package/templates/sveltekit-app/src/routes/+page.svelte +401 -0
  52. package/templates/sveltekit-app/src/server/index.ts +263 -0
  53. package/templates/sveltekit-app/static/robots.txt +3 -0
  54. package/templates/sveltekit-app/svelte.config.js +18 -0
  55. package/templates/sveltekit-app/tsconfig.json +25 -0
  56. package/templates/sveltekit-app/vite.config.ts +7 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 DonkeyLabs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,141 @@
1
+ # @donkeylabs/cli
2
+
3
+ CLI tool for `@donkeylabs/server` - project scaffolding and code generation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add -D @donkeylabs/cli
9
+ ```
10
+
11
+ Or install globally:
12
+
13
+ ```bash
14
+ bun add -g @donkeylabs/cli
15
+ ```
16
+
17
+ ## Commands
18
+
19
+ ### Interactive Mode
20
+
21
+ Run without arguments for an interactive menu:
22
+
23
+ ```bash
24
+ donkeylabs
25
+ ```
26
+
27
+ ### Initialize Project
28
+
29
+ Create a new project:
30
+
31
+ ```bash
32
+ # Interactive project setup
33
+ donkeylabs init
34
+
35
+ # Server-only project
36
+ donkeylabs init --type server
37
+
38
+ # SvelteKit + adapter project
39
+ donkeylabs init --type sveltekit
40
+
41
+ # Initialize in specific directory
42
+ donkeylabs init my-project
43
+ ```
44
+
45
+ ### Generate Types
46
+
47
+ Generate TypeScript types from your plugins and routes:
48
+
49
+ ```bash
50
+ donkeylabs generate
51
+ # or
52
+ donkeylabs gen
53
+ ```
54
+
55
+ This generates:
56
+ - `registry.d.ts` - Plugin registry types
57
+ - `context.d.ts` - App context with merged schemas
58
+ - `routes.ts` - Route input/output types
59
+ - `client.ts` - API client (or adapter-specific client)
60
+
61
+ ### Plugin Management
62
+
63
+ Create and manage plugins:
64
+
65
+ ```bash
66
+ # Create a new plugin (interactive)
67
+ donkeylabs plugin create
68
+
69
+ # Create a named plugin
70
+ donkeylabs plugin create auth
71
+
72
+ # List plugins
73
+ donkeylabs plugin list
74
+ ```
75
+
76
+ ## Configuration
77
+
78
+ Create a `donkeylabs.config.ts` in your project root:
79
+
80
+ ```typescript
81
+ import { defineConfig } from "@donkeylabs/server";
82
+
83
+ export default defineConfig({
84
+ // Glob patterns for plugin files
85
+ plugins: ["./src/plugins/**/index.ts"],
86
+
87
+ // Generated types output directory
88
+ outDir: ".@donkeylabs/server",
89
+
90
+ // Server entry file (for route extraction)
91
+ entry: "./src/index.ts",
92
+
93
+ // Optional: Client generation
94
+ client: {
95
+ output: "./src/client/api.ts",
96
+ },
97
+
98
+ // Optional: Adapter for framework-specific generation
99
+ adapter: "@donkeylabs/adapter-sveltekit",
100
+ });
101
+ ```
102
+
103
+ ## Context-Aware Menus
104
+
105
+ The interactive mode is context-aware:
106
+
107
+ **From project root:**
108
+ - Create New Plugin
109
+ - Initialize New Project
110
+ - Generate Types
111
+ - Generate Registry
112
+ - Generate Server Context
113
+
114
+ **From inside a plugin directory (`src/plugins/<name>/`):**
115
+ - Generate Schema Types
116
+ - Create Migration
117
+ - Back to Global Menu
118
+
119
+ ## Templates
120
+
121
+ The CLI includes starter templates:
122
+
123
+ - `templates/starter` - Basic server project
124
+ - `templates/sveltekit-app` - Full SvelteKit + adapter project
125
+
126
+ ## Usage with package.json
127
+
128
+ Add scripts to your `package.json`:
129
+
130
+ ```json
131
+ {
132
+ "scripts": {
133
+ "gen:types": "donkeylabs generate",
134
+ "new:plugin": "donkeylabs plugin create"
135
+ }
136
+ }
137
+ ```
138
+
139
+ ## License
140
+
141
+ MIT
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@donkeylabs/cli",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "CLI for @donkeylabs/server - project scaffolding and code generation",
6
+ "main": "./src/index.ts",
7
+ "types": "./src/index.ts",
8
+ "bin": {
9
+ "donkeylabs": "./src/index.ts"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "types": "./src/index.ts",
14
+ "import": "./src/index.ts"
15
+ }
16
+ },
17
+ "files": [
18
+ "src",
19
+ "templates",
20
+ "LICENSE",
21
+ "README.md"
22
+ ],
23
+ "scripts": {
24
+ "typecheck": "bun --bun tsc --noEmit"
25
+ },
26
+ "dependencies": {
27
+ "picocolors": "^1.1.1",
28
+ "prompts": "^2.4.2"
29
+ },
30
+ "devDependencies": {
31
+ "@types/bun": "latest",
32
+ "@types/prompts": "^2.4.9"
33
+ },
34
+ "peerDependencies": {
35
+ "@donkeylabs/server": "*"
36
+ },
37
+ "keywords": [
38
+ "cli",
39
+ "donkeylabs",
40
+ "scaffolding",
41
+ "code-generation",
42
+ "bun",
43
+ "typescript"
44
+ ],
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "https://github.com/donkeylabs/server",
48
+ "directory": "packages/cli"
49
+ },
50
+ "license": "MIT"
51
+ }