@donkeylabs/cli 2.0.15 → 2.0.17

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 (85) hide show
  1. package/package.json +1 -1
  2. package/src/commands/config.ts +610 -0
  3. package/src/commands/deploy-enhanced.ts +354 -0
  4. package/src/commands/deploy.ts +204 -0
  5. package/src/commands/docs.ts +207 -0
  6. package/src/commands/init-enhanced.ts +1994 -0
  7. package/src/deployment/manager.ts +356 -0
  8. package/src/index.ts +58 -19
  9. package/templates/starter/.env.example +0 -44
  10. package/templates/starter/.gitignore.template +0 -4
  11. package/templates/starter/donkeylabs.config.ts +0 -6
  12. package/templates/starter/package.json +0 -21
  13. package/templates/starter/src/index.ts +0 -54
  14. package/templates/starter/src/plugins/stats/index.ts +0 -105
  15. package/templates/starter/src/routes/health/handlers/ping.ts +0 -22
  16. package/templates/starter/src/routes/health/index.ts +0 -19
  17. package/templates/starter/tsconfig.json +0 -27
  18. package/templates/sveltekit-app/.env.example +0 -59
  19. package/templates/sveltekit-app/README.md +0 -103
  20. package/templates/sveltekit-app/bun.lock +0 -683
  21. package/templates/sveltekit-app/donkeylabs.config.ts +0 -12
  22. package/templates/sveltekit-app/package.json +0 -38
  23. package/templates/sveltekit-app/src/app.css +0 -40
  24. package/templates/sveltekit-app/src/app.html +0 -12
  25. package/templates/sveltekit-app/src/hooks.server.ts +0 -4
  26. package/templates/sveltekit-app/src/lib/components/ui/badge/badge.svelte +0 -30
  27. package/templates/sveltekit-app/src/lib/components/ui/badge/index.ts +0 -3
  28. package/templates/sveltekit-app/src/lib/components/ui/button/button.svelte +0 -48
  29. package/templates/sveltekit-app/src/lib/components/ui/button/index.ts +0 -9
  30. package/templates/sveltekit-app/src/lib/components/ui/card/card-content.svelte +0 -18
  31. package/templates/sveltekit-app/src/lib/components/ui/card/card-description.svelte +0 -18
  32. package/templates/sveltekit-app/src/lib/components/ui/card/card-footer.svelte +0 -18
  33. package/templates/sveltekit-app/src/lib/components/ui/card/card-header.svelte +0 -18
  34. package/templates/sveltekit-app/src/lib/components/ui/card/card-title.svelte +0 -18
  35. package/templates/sveltekit-app/src/lib/components/ui/card/card.svelte +0 -21
  36. package/templates/sveltekit-app/src/lib/components/ui/card/index.ts +0 -21
  37. package/templates/sveltekit-app/src/lib/components/ui/index.ts +0 -4
  38. package/templates/sveltekit-app/src/lib/components/ui/input/index.ts +0 -2
  39. package/templates/sveltekit-app/src/lib/components/ui/input/input.svelte +0 -20
  40. package/templates/sveltekit-app/src/lib/permissions.ts +0 -213
  41. package/templates/sveltekit-app/src/lib/utils/index.ts +0 -6
  42. package/templates/sveltekit-app/src/routes/+layout.svelte +0 -8
  43. package/templates/sveltekit-app/src/routes/+page.server.ts +0 -25
  44. package/templates/sveltekit-app/src/routes/+page.svelte +0 -680
  45. package/templates/sveltekit-app/src/routes/workflows/+page.server.ts +0 -23
  46. package/templates/sveltekit-app/src/routes/workflows/+page.svelte +0 -522
  47. package/templates/sveltekit-app/src/server/events.ts +0 -28
  48. package/templates/sveltekit-app/src/server/index.ts +0 -124
  49. package/templates/sveltekit-app/src/server/plugins/auth/auth.test.ts +0 -377
  50. package/templates/sveltekit-app/src/server/plugins/auth/index.ts +0 -815
  51. package/templates/sveltekit-app/src/server/plugins/auth/migrations/001_create_users.ts +0 -25
  52. package/templates/sveltekit-app/src/server/plugins/auth/migrations/002_create_sessions.ts +0 -32
  53. package/templates/sveltekit-app/src/server/plugins/auth/migrations/003_create_refresh_tokens.ts +0 -33
  54. package/templates/sveltekit-app/src/server/plugins/auth/migrations/004_create_passkeys.ts +0 -60
  55. package/templates/sveltekit-app/src/server/plugins/auth/schema.ts +0 -65
  56. package/templates/sveltekit-app/src/server/plugins/demo/index.ts +0 -262
  57. package/templates/sveltekit-app/src/server/plugins/email/email.test.ts +0 -369
  58. package/templates/sveltekit-app/src/server/plugins/email/index.ts +0 -411
  59. package/templates/sveltekit-app/src/server/plugins/email/migrations/001_create_email_tokens.ts +0 -33
  60. package/templates/sveltekit-app/src/server/plugins/email/schema.ts +0 -24
  61. package/templates/sveltekit-app/src/server/plugins/permissions/index.ts +0 -1048
  62. package/templates/sveltekit-app/src/server/plugins/permissions/migrations/001_create_tenants.ts +0 -63
  63. package/templates/sveltekit-app/src/server/plugins/permissions/migrations/002_create_roles.ts +0 -90
  64. package/templates/sveltekit-app/src/server/plugins/permissions/migrations/003_create_resource_grants.ts +0 -50
  65. package/templates/sveltekit-app/src/server/plugins/permissions/permissions.test.ts +0 -566
  66. package/templates/sveltekit-app/src/server/plugins/permissions/schema.ts +0 -67
  67. package/templates/sveltekit-app/src/server/plugins/workflow-demo/index.ts +0 -198
  68. package/templates/sveltekit-app/src/server/routes/auth/auth.schemas.ts +0 -66
  69. package/templates/sveltekit-app/src/server/routes/auth/handlers/login.handler.ts +0 -18
  70. package/templates/sveltekit-app/src/server/routes/auth/handlers/logout.handler.ts +0 -16
  71. package/templates/sveltekit-app/src/server/routes/auth/handlers/me.handler.ts +0 -20
  72. package/templates/sveltekit-app/src/server/routes/auth/handlers/refresh.handler.ts +0 -17
  73. package/templates/sveltekit-app/src/server/routes/auth/handlers/register.handler.ts +0 -19
  74. package/templates/sveltekit-app/src/server/routes/auth/handlers/update-profile.handler.ts +0 -21
  75. package/templates/sveltekit-app/src/server/routes/auth/index.ts +0 -73
  76. package/templates/sveltekit-app/src/server/routes/demo.ts +0 -464
  77. package/templates/sveltekit-app/src/server/routes/example/example.schemas.ts +0 -22
  78. package/templates/sveltekit-app/src/server/routes/example/handlers/greet.handler.ts +0 -21
  79. package/templates/sveltekit-app/src/server/routes/example/index.ts +0 -28
  80. package/templates/sveltekit-app/src/server/routes/permissions/index.ts +0 -248
  81. package/templates/sveltekit-app/src/server/routes/tenants/index.ts +0 -339
  82. package/templates/sveltekit-app/static/robots.txt +0 -3
  83. package/templates/sveltekit-app/svelte.config.ts +0 -17
  84. package/templates/sveltekit-app/tsconfig.json +0 -20
  85. package/templates/sveltekit-app/vite.config.ts +0 -12
@@ -0,0 +1,207 @@
1
+ /**
2
+ * Docs Command
3
+ *
4
+ * Syncs documentation from the installed @donkeylabs/server package
5
+ * to the user's project. This ensures users always have access to
6
+ * the latest documentation for their installed version.
7
+ *
8
+ * Usage:
9
+ * donkeylabs docs # Sync all docs to ./docs/donkeylabs/
10
+ * donkeylabs docs --list # List available docs
11
+ * donkeylabs docs workflows # Sync specific doc
12
+ */
13
+
14
+ import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, statSync } from "fs";
15
+ import { join, dirname } from "path";
16
+ import pc from "picocolors";
17
+
18
+ const DEFAULT_DOCS_DIR = "docs/donkeylabs";
19
+
20
+ interface DocsCommandOptions {
21
+ list?: boolean;
22
+ output?: string;
23
+ }
24
+
25
+ /**
26
+ * Find the docs directory from installed @donkeylabs/server
27
+ */
28
+ function findDocsPath(): string | null {
29
+ // Try common locations
30
+ const possiblePaths = [
31
+ // node_modules (standard install)
32
+ join(process.cwd(), "node_modules", "@donkeylabs", "server", "docs"),
33
+ // bun's .bun cache
34
+ join(process.cwd(), "node_modules", ".bun", "@donkeylabs", "server", "docs"),
35
+ // Workspace/monorepo
36
+ join(process.cwd(), "..", "server", "docs"),
37
+ join(process.cwd(), "..", "..", "packages", "server", "docs"),
38
+ ];
39
+
40
+ for (const path of possiblePaths) {
41
+ if (existsSync(path) && statSync(path).isDirectory()) {
42
+ return path;
43
+ }
44
+ }
45
+
46
+ // Try to resolve from require
47
+ try {
48
+ const serverPkgPath = require.resolve("@donkeylabs/server/package.json", {
49
+ paths: [process.cwd()],
50
+ });
51
+ const serverDir = dirname(serverPkgPath);
52
+ const docsPath = join(serverDir, "docs");
53
+ if (existsSync(docsPath)) {
54
+ return docsPath;
55
+ }
56
+ } catch {
57
+ // Package not found
58
+ }
59
+
60
+ return null;
61
+ }
62
+
63
+ /**
64
+ * Get list of available doc files
65
+ */
66
+ function getAvailableDocs(docsPath: string): string[] {
67
+ return readdirSync(docsPath)
68
+ .filter((f) => f.endsWith(".md"))
69
+ .map((f) => f.replace(".md", ""));
70
+ }
71
+
72
+ /**
73
+ * Sync a single doc file
74
+ */
75
+ function syncDoc(docsPath: string, docName: string, outputDir: string): boolean {
76
+ const sourcePath = join(docsPath, `${docName}.md`);
77
+ if (!existsSync(sourcePath)) {
78
+ return false;
79
+ }
80
+
81
+ const content = readFileSync(sourcePath, "utf-8");
82
+ const outputPath = join(outputDir, `${docName}.md`);
83
+
84
+ // Create output directory if needed
85
+ mkdirSync(dirname(outputPath), { recursive: true });
86
+
87
+ writeFileSync(outputPath, content);
88
+ return true;
89
+ }
90
+
91
+ /**
92
+ * Sync all docs
93
+ */
94
+ function syncAllDocs(docsPath: string, outputDir: string): number {
95
+ const docs = getAvailableDocs(docsPath);
96
+ let synced = 0;
97
+
98
+ for (const doc of docs) {
99
+ if (syncDoc(docsPath, doc, outputDir)) {
100
+ synced++;
101
+ }
102
+ }
103
+
104
+ return synced;
105
+ }
106
+
107
+ /**
108
+ * Get version from installed package
109
+ */
110
+ function getInstalledVersion(): string | null {
111
+ try {
112
+ const pkgPath = require.resolve("@donkeylabs/server/package.json", {
113
+ paths: [process.cwd()],
114
+ });
115
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
116
+ return pkg.version;
117
+ } catch {
118
+ return null;
119
+ }
120
+ }
121
+
122
+ export async function docsCommand(args: string[], options: DocsCommandOptions = {}): Promise<void> {
123
+ const docsPath = findDocsPath();
124
+
125
+ if (!docsPath) {
126
+ console.error(pc.red("Error: Could not find @donkeylabs/server docs."));
127
+ console.log(pc.dim("Make sure @donkeylabs/server is installed in your project."));
128
+ console.log(pc.dim("\nRun: bun add @donkeylabs/server"));
129
+ process.exit(1);
130
+ }
131
+
132
+ const version = getInstalledVersion();
133
+ const availableDocs = getAvailableDocs(docsPath);
134
+
135
+ // List mode
136
+ if (options.list || args[0] === "--list" || args[0] === "-l") {
137
+ console.log(pc.bold("\nAvailable Documentation"));
138
+ console.log(pc.dim(`Version: ${version || "unknown"}\n`));
139
+
140
+ // Group docs by category
141
+ const categories: Record<string, string[]> = {
142
+ "Core Services": ["logger", "cache", "events", "cron", "jobs", "external-jobs", "processes", "workflows", "sse", "rate-limiter", "errors"],
143
+ "API": ["router", "handlers", "middleware"],
144
+ "Server": ["lifecycle-hooks", "services", "core-services"],
145
+ "Infrastructure": ["database", "plugins", "sveltekit-adapter", "api-client"],
146
+ "Testing": ["testing"],
147
+ "Other": [],
148
+ };
149
+
150
+ // Categorize docs
151
+ const categorized = new Set<string>();
152
+ for (const [category, docs] of Object.entries(categories)) {
153
+ const matching = availableDocs.filter((d) => docs.includes(d));
154
+ if (matching.length > 0) {
155
+ console.log(pc.cyan(` ${category}:`));
156
+ for (const doc of matching) {
157
+ console.log(` ${pc.green("•")} ${doc}`);
158
+ categorized.add(doc);
159
+ }
160
+ console.log();
161
+ }
162
+ }
163
+
164
+ // Uncategorized
165
+ const uncategorized = availableDocs.filter((d) => !categorized.has(d));
166
+ if (uncategorized.length > 0) {
167
+ console.log(pc.cyan(" Other:"));
168
+ for (const doc of uncategorized) {
169
+ console.log(` ${pc.green("•")} ${doc}`);
170
+ }
171
+ console.log();
172
+ }
173
+
174
+ console.log(pc.dim(`\nUsage:`));
175
+ console.log(pc.dim(` donkeylabs docs # Sync all docs`));
176
+ console.log(pc.dim(` donkeylabs docs workflows # Sync specific doc`));
177
+ return;
178
+ }
179
+
180
+ const outputDir = options.output || DEFAULT_DOCS_DIR;
181
+ const specificDoc = args[0];
182
+
183
+ // Sync specific doc
184
+ if (specificDoc && specificDoc !== "--list" && specificDoc !== "-l") {
185
+ if (!availableDocs.includes(specificDoc)) {
186
+ console.error(pc.red(`Error: Doc "${specificDoc}" not found.`));
187
+ console.log(pc.dim(`\nAvailable docs: ${availableDocs.join(", ")}`));
188
+ console.log(pc.dim(`\nRun: donkeylabs docs --list`));
189
+ process.exit(1);
190
+ }
191
+
192
+ syncDoc(docsPath, specificDoc, outputDir);
193
+ console.log(pc.green(`✓ Synced ${specificDoc}.md to ${outputDir}/`));
194
+ return;
195
+ }
196
+
197
+ // Sync all docs
198
+ console.log(pc.bold("\nSyncing Documentation"));
199
+ console.log(pc.dim(`Version: ${version || "unknown"}`));
200
+ console.log(pc.dim(`Source: ${docsPath}`));
201
+ console.log(pc.dim(`Target: ${outputDir}/\n`));
202
+
203
+ const synced = syncAllDocs(docsPath, outputDir);
204
+
205
+ console.log(pc.green(`\n✓ Synced ${synced} documentation files to ${outputDir}/`));
206
+ console.log(pc.dim(`\nTip: Add ${outputDir}/ to your .gitignore if you don't want to commit docs.`));
207
+ }