@donkeylabs/cli 0.1.0 → 0.1.1
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/package.json +1 -1
- package/src/commands/generate.ts +20 -12
- package/src/index.ts +0 -0
- package/templates/starter/package.json +3 -3
- package/templates/sveltekit-app/bun.lock +547 -0
- package/templates/sveltekit-app/donkeylabs.config.ts +1 -0
- package/templates/sveltekit-app/package.json +8 -6
- package/templates/sveltekit-app/scripts/watch-server.ts +55 -0
- package/templates/sveltekit-app/src/lib/api.ts +61 -121
- package/templates/sveltekit-app/src/routes/+page.server.ts +2 -2
- package/templates/sveltekit-app/src/server/index.ts +24 -150
- package/templates/sveltekit-app/src/server/plugins/demo/index.ts +144 -0
- package/templates/sveltekit-app/svelte.config.js +1 -3
- package/templates/sveltekit-app/tsconfig.json +4 -9
- package/templates/sveltekit-app/vite.config.ts +2 -1
package/package.json
CHANGED
package/src/commands/generate.ts
CHANGED
|
@@ -206,17 +206,21 @@ export async function generateCommand(_args: string[]): Promise<void> {
|
|
|
206
206
|
// Check if adapter provides a custom generator
|
|
207
207
|
if (config.adapter) {
|
|
208
208
|
try {
|
|
209
|
-
//
|
|
210
|
-
const
|
|
211
|
-
if (
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
209
|
+
// Resolve the adapter path from the project's node_modules
|
|
210
|
+
const adapterPath = join(process.cwd(), "node_modules", config.adapter, "src/generator/index.ts");
|
|
211
|
+
if (existsSync(adapterPath)) {
|
|
212
|
+
const adapterModule = await import(adapterPath);
|
|
213
|
+
if (adapterModule.generateClient) {
|
|
214
|
+
await adapterModule.generateClient(config, serverRoutes, clientOutput);
|
|
215
|
+
generated.push(`client (${config.adapter})`);
|
|
216
|
+
console.log(pc.green("Generated:"), generated.map(g => pc.dim(g)).join(", "));
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
216
219
|
}
|
|
217
|
-
} catch (e) {
|
|
220
|
+
} catch (e: any) {
|
|
218
221
|
// Adapter doesn't provide generator or import failed, fall back to default
|
|
219
222
|
console.log(pc.dim(`Note: Adapter ${config.adapter} has no custom generator, using default`));
|
|
223
|
+
console.log(pc.dim(`Error: ${e.message}`));
|
|
220
224
|
}
|
|
221
225
|
}
|
|
222
226
|
|
|
@@ -232,10 +236,14 @@ async function generateRegistry(
|
|
|
232
236
|
outPath: string
|
|
233
237
|
) {
|
|
234
238
|
const importLines = plugins
|
|
235
|
-
.map(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
+
.map((p) => {
|
|
240
|
+
// Calculate relative path from outPath to plugin
|
|
241
|
+
const pluginAbsPath = join(process.cwd(), p.path).replace(/\.ts$/, "");
|
|
242
|
+
const relativePath = relative(outPath, pluginAbsPath);
|
|
243
|
+
// Ensure path starts with ./ or ../
|
|
244
|
+
const importPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
245
|
+
return `import { ${p.exportName} } from "${importPath}";`;
|
|
246
|
+
})
|
|
239
247
|
.join("\n");
|
|
240
248
|
|
|
241
249
|
const pluginRegistryEntries = plugins
|
package/src/index.ts
CHANGED
|
File without changes
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
"gen:types": "donkeylabs generate"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@donkeylabs/server": "
|
|
12
|
+
"@donkeylabs/server": "latest",
|
|
13
13
|
"kysely": "^0.27.0",
|
|
14
14
|
"kysely-bun-sqlite": "^0.3.0",
|
|
15
15
|
"zod": "^3.24.0"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@donkeylabs/cli": "
|
|
18
|
+
"@donkeylabs/cli": "latest",
|
|
19
19
|
"@types/bun": "latest"
|
|
20
20
|
}
|
|
21
|
-
}
|
|
21
|
+
}
|