alchemy 0.10.1 → 0.10.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/lib/alchemy.js +4 -1
- package/lib/cloudflare/api.js +1 -1
- package/lib/cloudflare/assets.js +2 -2
- package/lib/cloudflare/bound.d.ts +1 -1
- package/lib/cloudflare/d1-database.d.ts +28 -1
- package/lib/cloudflare/d1-database.js +39 -1
- package/lib/cloudflare/d1-migrations.d.ts +46 -0
- package/lib/cloudflare/d1-migrations.js +82 -0
- package/lib/cloudflare/worker.js +2 -2
- package/lib/cloudflare/wrangler.json.js +1 -1
- package/lib/internal/docs/providers.d.ts +2 -2
- package/lib/internal/docs/providers.js +5 -4
- package/lib/test/bun.js +1 -1
- package/lib/test/prune.d.ts +13 -0
- package/lib/test/prune.js +130 -0
- package/lib/util/content-type.js +1 -1
- package/lib/util/rm.js +1 -1
- package/lib/web/astro.js +6 -3
- package/lib/web/shadcn-component.js +2 -2
- package/lib/web/shadcn.d.ts +1 -1
- package/lib/web/shadcn.js +3 -2
- package/lib/web/tailwind.js +3 -2
- package/lib/web/vite.js +5 -3
- package/lib/web/vitepress/config.js +1 -1
- package/lib/web/vitepress/custom-theme.js +2 -2
- package/lib/web/vitepress/home-page.d.ts +1 -1
- package/lib/web/vitepress/home-page.js +1 -1
- package/lib/web/vitepress/vitepress.js +7 -4
- package/package.json +1 -1
- package/src/alchemy.ts +4 -1
- package/src/cloudflare/api.ts +1 -1
- package/src/cloudflare/assets.ts +2 -2
- package/src/cloudflare/bound.ts +3 -1
- package/src/cloudflare/d1-database.ts +65 -1
- package/src/cloudflare/d1-migrations.ts +137 -0
- package/src/cloudflare/worker.ts +2 -2
- package/src/cloudflare/wrangler.json.ts +1 -1
- package/src/internal/docs/providers.ts +5 -4
- package/src/test/bun.ts +1 -1
- package/src/test/prune.ts +165 -0
- package/src/util/content-type.ts +1 -1
- package/src/util/rm.ts +1 -1
- package/src/web/astro.ts +15 -17
- package/src/web/shadcn-component.ts +6 -6
- package/src/web/shadcn.ts +9 -8
- package/src/web/tailwind.ts +5 -4
- package/src/web/vite.ts +14 -12
- package/src/web/vitepress/config.ts +1 -1
- package/src/web/vitepress/custom-theme.ts +9 -9
- package/src/web/vitepress/home-page.ts +21 -17
- package/src/web/vitepress/vitepress.ts +7 -9
package/src/web/tailwind.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { exec } from "child_process";
|
|
2
|
-
import path from "path";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import { promisify } from "util";
|
|
4
4
|
import type { Context } from "../context";
|
|
5
|
-
import { Folder
|
|
5
|
+
import { Folder } from "../fs/folder";
|
|
6
|
+
import { StaticTextFile } from "../fs/static-text-file";
|
|
6
7
|
import { Resource } from "../resource";
|
|
7
8
|
|
|
8
9
|
const execAsync = promisify(exec);
|
|
@@ -81,7 +82,7 @@ export const TailwindConfig = Resource(
|
|
|
81
82
|
async function (
|
|
82
83
|
this: Context<TailwindConfig>,
|
|
83
84
|
id: string,
|
|
84
|
-
props: TailwindConfigProps
|
|
85
|
+
props: TailwindConfigProps
|
|
85
86
|
): Promise<TailwindConfig> {
|
|
86
87
|
if (this.phase === "delete") {
|
|
87
88
|
// Nothing to clean up specifically for Tailwind
|
|
@@ -163,5 +164,5 @@ export const TailwindConfig = Resource(
|
|
|
163
164
|
// Create CSS file with Tailwind directives
|
|
164
165
|
await StaticTextFile(cssPath, tailwindDirectives);
|
|
165
166
|
}
|
|
166
|
-
}
|
|
167
|
+
}
|
|
167
168
|
);
|
package/src/web/vite.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { exec } from "child_process";
|
|
2
|
-
import path from "path";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import { promisify } from "util";
|
|
4
4
|
import type { Context } from "../context";
|
|
5
|
-
import { Folder
|
|
5
|
+
import { Folder } from "../fs/folder";
|
|
6
|
+
import { StaticJsonFile } from "../fs/static-json-file";
|
|
7
|
+
import { StaticTypeScriptFile } from "../fs/static-typescript-file";
|
|
6
8
|
import { Resource } from "../resource";
|
|
7
9
|
import { rm } from "../util/rm";
|
|
8
10
|
import { ShadcnComponent } from "./shadcn-component";
|
|
@@ -136,7 +138,7 @@ export const ViteProject = Resource(
|
|
|
136
138
|
async function (
|
|
137
139
|
this: Context<ViteProject>,
|
|
138
140
|
id: string,
|
|
139
|
-
props: ViteProjectProps
|
|
141
|
+
props: ViteProjectProps
|
|
140
142
|
): Promise<ViteProject> {
|
|
141
143
|
const phase = this.phase;
|
|
142
144
|
if (this.phase === "delete") {
|
|
@@ -155,7 +157,7 @@ export const ViteProject = Resource(
|
|
|
155
157
|
await modifyConfig(props);
|
|
156
158
|
} else {
|
|
157
159
|
console.warn(
|
|
158
|
-
"ViteProject does not support updates - the project must be recreated to change the template"
|
|
160
|
+
"ViteProject does not support updates - the project must be recreated to change the template"
|
|
159
161
|
);
|
|
160
162
|
}
|
|
161
163
|
} else {
|
|
@@ -220,7 +222,7 @@ export const ViteProject = Resource(
|
|
|
220
222
|
|
|
221
223
|
await StaticTypeScriptFile(
|
|
222
224
|
path.join(props.name, "vite.config.ts"),
|
|
223
|
-
`import path from "path";
|
|
225
|
+
`import path from "node:path";
|
|
224
226
|
import react from "@vitejs/plugin-react";
|
|
225
227
|
import { defineConfig } from "vite";
|
|
226
228
|
${tailwind ? "import tailwindcss from '@tailwindcss/vite';" : ""}
|
|
@@ -234,7 +236,7 @@ export default defineConfig({
|
|
|
234
236
|
"@": path.resolve(__dirname, "./src"),
|
|
235
237
|
},
|
|
236
238
|
},
|
|
237
|
-
})
|
|
239
|
+
});`
|
|
238
240
|
);
|
|
239
241
|
}
|
|
240
242
|
|
|
@@ -272,7 +274,7 @@ export default defineConfig({
|
|
|
272
274
|
async function installTanstack() {
|
|
273
275
|
await exec(`bun add @tanstack/react-router`);
|
|
274
276
|
await exec(
|
|
275
|
-
`bun add -D @tanstack/router-plugin @tanstack/react-router-devtools
|
|
277
|
+
`bun add -D @tanstack/router-plugin @tanstack/react-router-devtools`
|
|
276
278
|
);
|
|
277
279
|
|
|
278
280
|
const src = path.join(props.name, "src");
|
|
@@ -306,7 +308,7 @@ export const Route = createRootRoute({
|
|
|
306
308
|
</div>
|
|
307
309
|
),
|
|
308
310
|
});
|
|
309
|
-
|
|
311
|
+
`
|
|
310
312
|
);
|
|
311
313
|
|
|
312
314
|
// Create index route file
|
|
@@ -324,7 +326,7 @@ function Index() {
|
|
|
324
326
|
<h3>Welcome Home!</h3>
|
|
325
327
|
</div>
|
|
326
328
|
)
|
|
327
|
-
}
|
|
329
|
+
}`
|
|
328
330
|
);
|
|
329
331
|
|
|
330
332
|
// Create about route file
|
|
@@ -338,7 +340,7 @@ export const Route = createLazyFileRoute('/about')({
|
|
|
338
340
|
|
|
339
341
|
function About() {
|
|
340
342
|
return <div className="p-2">Hello from About!</div>
|
|
341
|
-
}
|
|
343
|
+
}`
|
|
342
344
|
);
|
|
343
345
|
|
|
344
346
|
// Create main.tsx
|
|
@@ -371,7 +373,7 @@ if (!rootElement.innerHTML) {
|
|
|
371
373
|
<RouterProvider router={router} />
|
|
372
374
|
</StrictMode>,
|
|
373
375
|
)
|
|
374
|
-
}
|
|
376
|
+
}`
|
|
375
377
|
);
|
|
376
378
|
}
|
|
377
379
|
|
|
@@ -400,5 +402,5 @@ if (!rootElement.innerHTML) {
|
|
|
400
402
|
});
|
|
401
403
|
}
|
|
402
404
|
}
|
|
403
|
-
}
|
|
405
|
+
}
|
|
404
406
|
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type } from "arktype";
|
|
2
|
-
import path from "path";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import type { ModelConfig } from "../../ai/client";
|
|
4
4
|
import { CSSFile } from "../../ai/css-file";
|
|
5
5
|
import { Data } from "../../ai/data";
|
|
@@ -7,7 +7,7 @@ import { TypeScriptFile } from "../../ai/typescript-file";
|
|
|
7
7
|
import { VueFile } from "../../ai/vue-file";
|
|
8
8
|
import { alchemy } from "../../alchemy";
|
|
9
9
|
import type { Context } from "../../context";
|
|
10
|
-
import { Folder } from "../../fs";
|
|
10
|
+
import { Folder } from "../../fs/folder";
|
|
11
11
|
import { Resource } from "../../resource";
|
|
12
12
|
import type { Secret } from "../../secret";
|
|
13
13
|
|
|
@@ -208,7 +208,7 @@ export const CustomTheme = Resource(
|
|
|
208
208
|
async function (
|
|
209
209
|
this: Context<CustomTheme>,
|
|
210
210
|
id: string,
|
|
211
|
-
props: CustomThemeProps
|
|
211
|
+
props: CustomThemeProps
|
|
212
212
|
): Promise<CustomTheme> {
|
|
213
213
|
// Handle deletion
|
|
214
214
|
if (this.phase === "delete") {
|
|
@@ -325,13 +325,13 @@ Break down the layout into logical components like NavBar, Sidebar, Footer, etc.
|
|
|
325
325
|
schema: type({
|
|
326
326
|
components: type({
|
|
327
327
|
name: type("string").describe(
|
|
328
|
-
"Component name as used in the import statement (e.g., NavBar, Footer)"
|
|
328
|
+
"Component name as used in the import statement (e.g., NavBar, Footer)"
|
|
329
329
|
),
|
|
330
330
|
path: type("string").describe(
|
|
331
|
-
"Import path as written in the import statement (e.g., './components/NavBar.vue')"
|
|
331
|
+
"Import path as written in the import statement (e.g., './components/NavBar.vue')"
|
|
332
332
|
),
|
|
333
333
|
purpose: type("string").describe(
|
|
334
|
-
"A clear description of the component's purpose, functionality, and responsibilities in the layout"
|
|
334
|
+
"A clear description of the component's purpose, functionality, and responsibilities in the layout"
|
|
335
335
|
),
|
|
336
336
|
}).array(),
|
|
337
337
|
}),
|
|
@@ -406,7 +406,7 @@ Make sure it integrates well with the overall layout and theme style.`,
|
|
|
406
406
|
model: props.model,
|
|
407
407
|
temperature: props.temperature,
|
|
408
408
|
});
|
|
409
|
-
})
|
|
409
|
+
})
|
|
410
410
|
);
|
|
411
411
|
|
|
412
412
|
// Generate user-specified components if provided
|
|
@@ -444,7 +444,7 @@ You are writing a Vue component for a VitePress theme.`,
|
|
|
444
444
|
model: props.model,
|
|
445
445
|
temperature: props.temperature,
|
|
446
446
|
});
|
|
447
|
-
})
|
|
447
|
+
})
|
|
448
448
|
);
|
|
449
449
|
|
|
450
450
|
// Generate styles file
|
|
@@ -510,5 +510,5 @@ You are writing CSS styles for a VitePress theme.`,
|
|
|
510
510
|
createdAt: this.output?.createdAt || now,
|
|
511
511
|
updatedAt: now,
|
|
512
512
|
});
|
|
513
|
-
}
|
|
513
|
+
}
|
|
514
514
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import yaml from "yaml";
|
|
2
2
|
import { Document } from "../../ai/document";
|
|
3
3
|
import { alchemy } from "../../alchemy";
|
|
4
|
-
import { StaticTextFile } from "../../fs";
|
|
4
|
+
import { StaticTextFile } from "../../fs/static-text-file";
|
|
5
5
|
import type { Secret } from "../../secret";
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -291,7 +291,7 @@ export function parseHomePage(content: string): HomePageConfig {
|
|
|
291
291
|
*/
|
|
292
292
|
export async function HomePage(
|
|
293
293
|
id: string,
|
|
294
|
-
props: HomePageProps
|
|
294
|
+
props: HomePageProps
|
|
295
295
|
): Promise<HomePage> {
|
|
296
296
|
// Build the system prompt with optional extension
|
|
297
297
|
const systemPrompt = `
|
|
@@ -323,18 +323,18 @@ ${props.system || ""}
|
|
|
323
323
|
? JSON.stringify(props.features, null, 2)
|
|
324
324
|
: "";
|
|
325
325
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
326
|
+
if (props.prompt) {
|
|
327
|
+
return Document(id, {
|
|
328
|
+
title: props.title,
|
|
329
|
+
path: props.outFile,
|
|
330
|
+
baseURL: props.baseURL,
|
|
331
|
+
apiKey: props.apiKey,
|
|
332
|
+
model: props.model ?? {
|
|
333
|
+
id: "claude-3-7-sonnet-latest",
|
|
334
|
+
provider: "anthropic",
|
|
335
|
+
},
|
|
336
|
+
temperature: props.temperature ?? 0.7,
|
|
337
|
+
prompt: await alchemy`
|
|
338
338
|
${systemPrompt}
|
|
339
339
|
|
|
340
340
|
Create a VitePress homepage based on the following description:
|
|
@@ -360,9 +360,12 @@ ${props.system || ""}
|
|
|
360
360
|
|
|
361
361
|
The output should be a complete index.md file with proper YAML frontmatter and markdown content.
|
|
362
362
|
`,
|
|
363
|
-
|
|
363
|
+
});
|
|
364
364
|
} else {
|
|
365
|
-
return StaticTextFile(
|
|
365
|
+
return StaticTextFile(
|
|
366
|
+
id,
|
|
367
|
+
props.outFile,
|
|
368
|
+
`---
|
|
366
369
|
${yaml.stringify({
|
|
367
370
|
layout: "home",
|
|
368
371
|
name: props.title,
|
|
@@ -370,6 +373,7 @@ ${yaml.stringify({
|
|
|
370
373
|
features: props.features,
|
|
371
374
|
})}
|
|
372
375
|
---
|
|
373
|
-
`
|
|
376
|
+
`
|
|
377
|
+
);
|
|
374
378
|
}
|
|
375
379
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { exec } from "child_process";
|
|
2
|
-
import fs from "fs/promises";
|
|
3
|
-
import path from "path";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
4
|
import { promisify } from "util";
|
|
5
5
|
import type { Context } from "../../context";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
StaticTypeScriptFile,
|
|
11
|
-
} from "../../fs";
|
|
6
|
+
import { Folder } from "../../fs/folder";
|
|
7
|
+
import { StaticJsonFile } from "../../fs/static-json-file";
|
|
8
|
+
import { StaticTextFile } from "../../fs/static-text-file";
|
|
9
|
+
import { StaticTypeScriptFile } from "../../fs/static-typescript-file";
|
|
12
10
|
import { Resource } from "../../resource";
|
|
13
11
|
import { InstallDependencies, fixedDependencies } from "./dependencies";
|
|
14
12
|
|
|
@@ -188,7 +186,7 @@ export const VitepressProject = Resource(
|
|
|
188
186
|
// `import alchemy from "alchemy";
|
|
189
187
|
// import { Folder } from "alchemy/fs";
|
|
190
188
|
// import { Document } from "alchemy/docs";
|
|
191
|
-
// import path from "path";
|
|
189
|
+
// import path from "node:path";
|
|
192
190
|
|
|
193
191
|
// const app = await alchemy("alchemy.run", {
|
|
194
192
|
// stage: "prod",
|