alchemy 0.2.5 → 0.3.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/README.md +3 -3
- package/lib/ai/approve.d.ts +99 -0
- package/lib/ai/approve.js +76 -0
- package/lib/ai/astro-file.d.ts +137 -0
- package/lib/ai/astro-file.js +156 -0
- package/lib/ai/client.d.ts +7 -8
- package/lib/ai/client.js +48 -19
- package/lib/ai/css-file.d.ts +131 -0
- package/lib/ai/css-file.js +141 -0
- package/lib/ai/data.d.ts +51 -6
- package/lib/ai/data.js +58 -12
- package/lib/ai/document.d.ts +108 -24
- package/lib/ai/document.js +166 -52
- package/lib/ai/html-file.d.ts +128 -0
- package/lib/ai/html-file.js +138 -0
- package/lib/ai/index.d.ts +9 -0
- package/lib/ai/index.js +9 -0
- package/lib/ai/json-file.d.ts +160 -0
- package/lib/ai/json-file.js +187 -0
- package/lib/ai/review.d.ts +122 -0
- package/lib/ai/review.js +101 -0
- package/lib/ai/typescript-file.d.ts +139 -0
- package/lib/ai/typescript-file.js +145 -0
- package/lib/ai/vue-file.d.ts +126 -0
- package/lib/ai/vue-file.js +136 -0
- package/lib/ai/yaml-file.d.ts +169 -0
- package/lib/ai/yaml-file.js +200 -0
- package/lib/alchemy.js +17 -2
- package/lib/apply.js +1 -1
- package/lib/cloudflare/dns.d.ts +88 -0
- package/lib/cloudflare/dns.js +192 -0
- package/lib/cloudflare/generate-asset-manifest.js +1 -1
- package/lib/cloudflare/index.d.ts +2 -1
- package/lib/cloudflare/index.js +2 -1
- package/lib/cloudflare/r2-rest-state-store.d.ts +125 -0
- package/lib/cloudflare/r2-rest-state-store.js +254 -0
- package/lib/cloudflare/response.d.ts +12 -0
- package/lib/cloudflare/response.js +0 -0
- package/lib/cloudflare/static-site-router.js +16 -7
- package/lib/cloudflare/static-site.js +3 -0
- package/lib/cloudflare/upload-asset-manifest.js +4 -2
- package/lib/cloudflare/zone.d.ts +18 -0
- package/lib/cloudflare/zone.js +17 -4
- package/lib/dns/godaddy.d.ts +7 -0
- package/lib/dns/godaddy.js +21 -0
- package/lib/dns/import-dns.d.ts +82 -0
- package/lib/dns/import-dns.js +114 -0
- package/lib/dns/index.d.ts +2 -0
- package/lib/dns/index.js +2 -0
- package/lib/dns/record.d.ts +88 -0
- package/lib/dns/record.js +13 -0
- package/lib/fs/copy-file.d.ts +54 -0
- package/lib/fs/copy-file.js +63 -0
- package/lib/fs/file-system-state-store.d.ts +17 -0
- package/lib/fs/file-system-state-store.js +87 -0
- package/lib/fs/file.d.ts +13 -0
- package/lib/fs/file.js +24 -5
- package/lib/fs/folder.d.ts +10 -0
- package/lib/fs/folder.js +2 -2
- package/lib/fs/index.d.ts +10 -4
- package/lib/fs/index.js +10 -4
- package/lib/fs/static-astro-file.d.ts +34 -0
- package/lib/fs/static-astro-file.js +39 -0
- package/lib/fs/static-css-file.d.ts +24 -0
- package/lib/fs/static-css-file.js +29 -0
- package/lib/fs/static-html-file.d.ts +31 -0
- package/lib/fs/static-html-file.js +36 -0
- package/lib/fs/{json-file.d.ts → static-json-file.d.ts} +3 -3
- package/lib/fs/static-json-file.js +15 -0
- package/lib/fs/{text-file.d.ts → static-text-file.d.ts} +2 -2
- package/lib/fs/static-text-file.js +8 -0
- package/lib/fs/{typescript-file.d.ts → static-typescript-file.d.ts} +3 -3
- package/lib/fs/{typescript-file.js → static-typescript-file.js} +3 -2
- package/lib/fs/static-vue-file.d.ts +28 -0
- package/lib/fs/static-vue-file.js +33 -0
- package/lib/fs/static-yaml-file.d.ts +22 -0
- package/lib/fs/{yaml-file.js → static-yaml-file.js} +3 -2
- package/lib/internal/getting-started.d.ts +21 -0
- package/lib/internal/getting-started.js +87 -0
- package/lib/internal/index.d.ts +3 -0
- package/lib/internal/index.js +3 -0
- package/lib/internal/providers.d.ts +27 -0
- package/lib/internal/providers.js +172 -0
- package/lib/internal/tutorial.d.ts +104 -0
- package/lib/internal/tutorial.js +251 -0
- package/lib/resource.js +8 -1
- package/lib/scope.d.ts +1 -1
- package/lib/scope.js +4 -2
- package/lib/state.d.ts +1 -16
- package/lib/state.js +0 -87
- package/lib/test/bun.d.ts +11 -0
- package/lib/test/bun.js +36 -8
- package/lib/web/astro.d.ts +147 -0
- package/lib/web/astro.js +414 -0
- package/lib/{shadcn/component.js → web/shadcn-component.js} +2 -9
- package/lib/web/shadcn.d.ts +97 -0
- package/lib/web/shadcn.js +99 -0
- package/lib/web/tailwind.d.ts +64 -0
- package/lib/web/tailwind.js +97 -0
- package/lib/{vite → web}/vite.d.ts +5 -0
- package/lib/{vite → web}/vite.js +44 -44
- package/lib/web/vitepress/config.d.ts +10 -0
- package/lib/web/vitepress/config.js +31 -0
- package/lib/web/vitepress/custom-theme.d.ts +173 -0
- package/lib/web/vitepress/custom-theme.js +336 -0
- package/lib/{vitepress → web/vitepress}/dependencies.d.ts +2 -2
- package/lib/{vitepress → web/vitepress}/dependencies.js +1 -1
- package/lib/web/vitepress/home-page.d.ts +246 -0
- package/lib/web/vitepress/home-page.js +147 -0
- package/lib/{vitepress → web/vitepress}/index.d.ts +2 -0
- package/lib/{vitepress → web/vitepress}/index.js +2 -0
- package/lib/{vitepress → web/vitepress}/vitepress.d.ts +15 -12
- package/lib/{vitepress → web/vitepress}/vitepress.js +26 -44
- package/package.json +6 -2
- package/src/ai/approve.ts +163 -0
- package/src/ai/astro-file.ts +269 -0
- package/src/ai/client.ts +60 -21
- package/src/ai/css-file.ts +247 -0
- package/src/ai/data.ts +81 -19
- package/src/ai/document.ts +240 -62
- package/src/ai/html-file.ts +244 -0
- package/src/ai/index.ts +9 -0
- package/src/ai/json-file.ts +325 -0
- package/src/ai/review.ts +213 -0
- package/src/ai/typescript-file.ts +259 -0
- package/src/ai/vue-file.ts +242 -0
- package/src/ai/yaml-file.ts +328 -0
- package/src/alchemy.ts +18 -7
- package/src/apply.ts +8 -9
- package/src/cloudflare/dns.ts +344 -0
- package/src/cloudflare/generate-asset-manifest.ts +4 -4
- package/src/cloudflare/index.ts +2 -1
- package/src/cloudflare/r2-rest-state-store.ts +353 -0
- package/src/cloudflare/response.ts +9 -0
- package/src/cloudflare/static-site-router.ts +18 -8
- package/src/cloudflare/static-site.ts +11 -7
- package/src/cloudflare/upload-asset-manifest.ts +6 -4
- package/src/cloudflare/worker.ts +44 -43
- package/src/cloudflare/zone.ts +39 -23
- package/src/dns/godaddy.ts +29 -0
- package/src/dns/import-dns.ts +213 -0
- package/src/dns/index.ts +2 -0
- package/src/dns/record.ts +121 -0
- package/src/fs/copy-file.ts +115 -0
- package/src/fs/file-system-state-store.ts +109 -0
- package/src/fs/file.ts +35 -9
- package/src/fs/folder.ts +14 -2
- package/src/fs/index.ts +10 -4
- package/src/fs/static-astro-file.ts +45 -0
- package/src/fs/static-css-file.ts +35 -0
- package/src/fs/static-html-file.ts +42 -0
- package/src/fs/static-json-file.ts +34 -0
- package/src/fs/{text-file.ts → static-text-file.ts} +9 -3
- package/src/fs/{typescript-file.ts → static-typescript-file.ts} +7 -6
- package/src/fs/static-vue-file.ts +39 -0
- package/src/fs/static-yaml-file.ts +33 -0
- package/src/internal/getting-started.ts +115 -0
- package/src/internal/index.ts +3 -0
- package/src/internal/providers.ts +241 -0
- package/src/internal/tutorial.ts +392 -0
- package/src/resource.ts +10 -1
- package/src/scope.ts +5 -6
- package/src/state.ts +1 -111
- package/src/test/bun.ts +60 -10
- package/src/web/astro.ts +644 -0
- package/src/{shadcn/component.ts → web/shadcn-component.ts} +5 -13
- package/src/web/shadcn.ts +219 -0
- package/src/web/tailwind.ts +167 -0
- package/src/{vite → web}/vite.ts +54 -56
- package/src/web/vitepress/config.ts +48 -0
- package/src/web/vitepress/custom-theme.ts +514 -0
- package/src/{vitepress → web/vitepress}/dependencies.ts +2 -2
- package/src/web/vitepress/home-page.ts +375 -0
- package/src/{vitepress → web/vitepress}/index.ts +2 -0
- package/src/{vitepress → web/vitepress}/vitepress.ts +62 -72
- package/lib/cloudflare/state.d.ts +0 -82
- package/lib/cloudflare/state.js +0 -108
- package/lib/fs/json-file.js +0 -7
- package/lib/fs/text-file.js +0 -7
- package/lib/fs/yaml-file.d.ts +0 -19
- package/lib/internal/docs.d.ts +0 -5
- package/lib/internal/docs.js +0 -287
- package/lib/shadcn/index.d.ts +0 -1
- package/lib/shadcn/index.js +0 -1
- package/lib/vite/index.d.ts +0 -1
- package/lib/vite/index.js +0 -1
- package/lib/vitepress/home-page.d.ts +0 -133
- package/lib/vitepress/home-page.js +0 -11
- package/src/cloudflare/state.ts +0 -138
- package/src/fs/json-file.ts +0 -23
- package/src/fs/yaml-file.ts +0 -26
- package/src/internal/docs.ts +0 -338
- package/src/shadcn/index.ts +0 -1
- package/src/vite/index.ts +0 -1
- package/src/vitepress/home-page.ts +0 -166
- /package/lib/{shadcn/component.d.ts → web/shadcn-component.d.ts} +0 -0
- /package/src/{vitepress → web/vitepress}/index.md +0 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { Document } from "../../ai/document";
|
|
2
|
+
import { StaticTextFile } from "../../fs";
|
|
3
|
+
import type { Secret } from "../../secret";
|
|
4
|
+
/**
|
|
5
|
+
* Image that can be themed for light/dark mode
|
|
6
|
+
*/
|
|
7
|
+
export interface ThemeableImage {
|
|
8
|
+
/**
|
|
9
|
+
* Image source URL
|
|
10
|
+
*/
|
|
11
|
+
src?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Image alt text
|
|
14
|
+
*/
|
|
15
|
+
alt?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Light theme image URL
|
|
18
|
+
*/
|
|
19
|
+
light?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Dark theme image URL
|
|
22
|
+
*/
|
|
23
|
+
dark?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Hero action button configuration
|
|
27
|
+
*/
|
|
28
|
+
export interface HeroAction {
|
|
29
|
+
/**
|
|
30
|
+
* Color theme of the button
|
|
31
|
+
* @default "brand"
|
|
32
|
+
*/
|
|
33
|
+
theme?: "brand" | "alt";
|
|
34
|
+
/**
|
|
35
|
+
* Label of the button
|
|
36
|
+
*/
|
|
37
|
+
text: string;
|
|
38
|
+
/**
|
|
39
|
+
* Destination link of the button
|
|
40
|
+
*/
|
|
41
|
+
link: string;
|
|
42
|
+
/**
|
|
43
|
+
* Link target attribute
|
|
44
|
+
*/
|
|
45
|
+
target?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Link rel attribute
|
|
48
|
+
*/
|
|
49
|
+
rel?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Hero section configuration
|
|
53
|
+
*/
|
|
54
|
+
export interface Hero {
|
|
55
|
+
/**
|
|
56
|
+
* The string shown top of text. Comes with brand color
|
|
57
|
+
* and expected to be short, such as product name.
|
|
58
|
+
*/
|
|
59
|
+
name?: string;
|
|
60
|
+
/**
|
|
61
|
+
* The main text for the hero section. This will be defined
|
|
62
|
+
* as h1 tag.
|
|
63
|
+
*/
|
|
64
|
+
text: string;
|
|
65
|
+
/**
|
|
66
|
+
* Tagline displayed below text
|
|
67
|
+
*/
|
|
68
|
+
tagline?: string;
|
|
69
|
+
/**
|
|
70
|
+
* The image displayed next to the text and tagline area
|
|
71
|
+
*/
|
|
72
|
+
image?: string | ThemeableImage;
|
|
73
|
+
/**
|
|
74
|
+
* Action buttons to display in home hero section
|
|
75
|
+
*/
|
|
76
|
+
actions?: HeroAction[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Feature item configuration
|
|
80
|
+
*/
|
|
81
|
+
export interface Feature {
|
|
82
|
+
/**
|
|
83
|
+
* Show icon on each feature box
|
|
84
|
+
*/
|
|
85
|
+
icon?: string | ThemeableImage;
|
|
86
|
+
/**
|
|
87
|
+
* Title of the feature
|
|
88
|
+
*/
|
|
89
|
+
title: string;
|
|
90
|
+
/**
|
|
91
|
+
* Details of the feature
|
|
92
|
+
*/
|
|
93
|
+
details: string;
|
|
94
|
+
/**
|
|
95
|
+
* Link when clicked on feature component
|
|
96
|
+
*/
|
|
97
|
+
link?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Link text to be shown inside feature component
|
|
100
|
+
*/
|
|
101
|
+
linkText?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Link rel attribute
|
|
104
|
+
*/
|
|
105
|
+
rel?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Link target attribute
|
|
108
|
+
*/
|
|
109
|
+
target?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* VitePress home page configuration
|
|
113
|
+
*/
|
|
114
|
+
export interface HomePageConfig {
|
|
115
|
+
/**
|
|
116
|
+
* Use home page layout
|
|
117
|
+
*/
|
|
118
|
+
layout: "home";
|
|
119
|
+
/**
|
|
120
|
+
* Hero section configuration
|
|
121
|
+
*/
|
|
122
|
+
hero?: Hero;
|
|
123
|
+
/**
|
|
124
|
+
* Features section configuration
|
|
125
|
+
*/
|
|
126
|
+
features?: Feature[];
|
|
127
|
+
/**
|
|
128
|
+
* Whether to apply default markdown styles
|
|
129
|
+
* @default true
|
|
130
|
+
*/
|
|
131
|
+
markdownStyles?: boolean;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Properties for creating or updating a VitePress HomePage
|
|
135
|
+
*/
|
|
136
|
+
export interface HomePageProps {
|
|
137
|
+
/**
|
|
138
|
+
* Output directory for the home page markdown file
|
|
139
|
+
*/
|
|
140
|
+
outFile: string;
|
|
141
|
+
/**
|
|
142
|
+
* Title of the home page document
|
|
143
|
+
*/
|
|
144
|
+
title: string;
|
|
145
|
+
/**
|
|
146
|
+
* Hero section configuration
|
|
147
|
+
*/
|
|
148
|
+
hero?: Hero;
|
|
149
|
+
/**
|
|
150
|
+
* Features section configuration
|
|
151
|
+
*/
|
|
152
|
+
features?: Feature[];
|
|
153
|
+
/**
|
|
154
|
+
* User prompt describing the design of the home page
|
|
155
|
+
*/
|
|
156
|
+
prompt?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Optional extension to the built-in system prompt
|
|
159
|
+
*/
|
|
160
|
+
system?: string;
|
|
161
|
+
/**
|
|
162
|
+
* Base URL for the OpenAI API
|
|
163
|
+
* @default 'https://api.openai.com/v1'
|
|
164
|
+
*/
|
|
165
|
+
baseURL?: string;
|
|
166
|
+
/**
|
|
167
|
+
* OpenAI API key to use for generating content
|
|
168
|
+
* If not provided, will use OPENAI_API_KEY environment variable
|
|
169
|
+
*/
|
|
170
|
+
apiKey?: Secret;
|
|
171
|
+
/**
|
|
172
|
+
* Model configuration for the AI generator
|
|
173
|
+
*/
|
|
174
|
+
model?: import("../../ai/client").ModelConfig;
|
|
175
|
+
/**
|
|
176
|
+
* Temperature for controlling randomness in generation
|
|
177
|
+
* @default 0.7
|
|
178
|
+
*/
|
|
179
|
+
temperature?: number;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Output type for the HomePage resource
|
|
183
|
+
*/
|
|
184
|
+
export type HomePage = StaticTextFile | Document;
|
|
185
|
+
/**
|
|
186
|
+
* Parse YAML frontmatter to home page config
|
|
187
|
+
*/
|
|
188
|
+
export declare function parseHomePage(content: string): HomePageConfig;
|
|
189
|
+
/**
|
|
190
|
+
* Resource for generating a VitePress homepage using AI.
|
|
191
|
+
* Creates an index.md file with the appropriate frontmatter and content
|
|
192
|
+
* based on the provided prompt and configuration.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* // Create a basic home page with just a prompt
|
|
196
|
+
* const homePage = await HomePage("docs-home", {
|
|
197
|
+
* outDir: "./docs",
|
|
198
|
+
* title: "My Project Documentation",
|
|
199
|
+
* prompt: "Create a welcoming homepage for a JavaScript utility library with modern design"
|
|
200
|
+
* });
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* // Create a home page with hero and features configuration
|
|
204
|
+
* const detailedHome = await HomePage("product-home", {
|
|
205
|
+
* outDir: "./website",
|
|
206
|
+
* title: "Product Landing Page",
|
|
207
|
+
* prompt: "Create an engaging product page for our cloud database service",
|
|
208
|
+
* hero: {
|
|
209
|
+
* name: "CloudDB",
|
|
210
|
+
* text: "The database built for the cloud era",
|
|
211
|
+
* tagline: "Scalable, reliable, and developer-friendly",
|
|
212
|
+
* image: "/images/cloud-db-logo.png",
|
|
213
|
+
* actions: [
|
|
214
|
+
* { text: "Get Started", link: "/guide/", theme: "brand" },
|
|
215
|
+
* { text: "View on GitHub", link: "https://github.com/org/cloud-db" }
|
|
216
|
+
* ]
|
|
217
|
+
* },
|
|
218
|
+
* features: [
|
|
219
|
+
* {
|
|
220
|
+
* icon: "🚀",
|
|
221
|
+
* title: "Lightning Fast",
|
|
222
|
+
* details: "Optimized for performance at any scale"
|
|
223
|
+
* },
|
|
224
|
+
* {
|
|
225
|
+
* icon: "🔒",
|
|
226
|
+
* title: "Secure by Default",
|
|
227
|
+
* details: "Enterprise-grade security built in"
|
|
228
|
+
* }
|
|
229
|
+
* ]
|
|
230
|
+
* });
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* // Create a home page with custom model settings
|
|
234
|
+
* const customHome = await HomePage("docs-home", {
|
|
235
|
+
* outDir: "./docs",
|
|
236
|
+
* title: "API Documentation",
|
|
237
|
+
* prompt: "Create a technical homepage for our REST API documentation",
|
|
238
|
+
* model: {
|
|
239
|
+
* id: "gpt-4o",
|
|
240
|
+
* provider: "openai"
|
|
241
|
+
* },
|
|
242
|
+
* temperature: 0.3,
|
|
243
|
+
* systemPromptExtension: "Make sure to use technical terminology appropriate for developers."
|
|
244
|
+
* });
|
|
245
|
+
*/
|
|
246
|
+
export declare function HomePage(id: string, props: HomePageProps): Promise<HomePage>;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import yaml from "yaml";
|
|
2
|
+
import { Document } from "../../ai/document";
|
|
3
|
+
import { alchemy } from "../../alchemy";
|
|
4
|
+
import { StaticTextFile } from "../../fs";
|
|
5
|
+
/**
|
|
6
|
+
* Parse YAML frontmatter to home page config
|
|
7
|
+
*/
|
|
8
|
+
export function parseHomePage(content) {
|
|
9
|
+
const match = content.match(/^---\n([\s\S]*?)\n---/);
|
|
10
|
+
if (!match) {
|
|
11
|
+
throw new Error("Invalid frontmatter format");
|
|
12
|
+
}
|
|
13
|
+
return yaml.parse(match[1]);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resource for generating a VitePress homepage using AI.
|
|
17
|
+
* Creates an index.md file with the appropriate frontmatter and content
|
|
18
|
+
* based on the provided prompt and configuration.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Create a basic home page with just a prompt
|
|
22
|
+
* const homePage = await HomePage("docs-home", {
|
|
23
|
+
* outDir: "./docs",
|
|
24
|
+
* title: "My Project Documentation",
|
|
25
|
+
* prompt: "Create a welcoming homepage for a JavaScript utility library with modern design"
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Create a home page with hero and features configuration
|
|
30
|
+
* const detailedHome = await HomePage("product-home", {
|
|
31
|
+
* outDir: "./website",
|
|
32
|
+
* title: "Product Landing Page",
|
|
33
|
+
* prompt: "Create an engaging product page for our cloud database service",
|
|
34
|
+
* hero: {
|
|
35
|
+
* name: "CloudDB",
|
|
36
|
+
* text: "The database built for the cloud era",
|
|
37
|
+
* tagline: "Scalable, reliable, and developer-friendly",
|
|
38
|
+
* image: "/images/cloud-db-logo.png",
|
|
39
|
+
* actions: [
|
|
40
|
+
* { text: "Get Started", link: "/guide/", theme: "brand" },
|
|
41
|
+
* { text: "View on GitHub", link: "https://github.com/org/cloud-db" }
|
|
42
|
+
* ]
|
|
43
|
+
* },
|
|
44
|
+
* features: [
|
|
45
|
+
* {
|
|
46
|
+
* icon: "🚀",
|
|
47
|
+
* title: "Lightning Fast",
|
|
48
|
+
* details: "Optimized for performance at any scale"
|
|
49
|
+
* },
|
|
50
|
+
* {
|
|
51
|
+
* icon: "🔒",
|
|
52
|
+
* title: "Secure by Default",
|
|
53
|
+
* details: "Enterprise-grade security built in"
|
|
54
|
+
* }
|
|
55
|
+
* ]
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // Create a home page with custom model settings
|
|
60
|
+
* const customHome = await HomePage("docs-home", {
|
|
61
|
+
* outDir: "./docs",
|
|
62
|
+
* title: "API Documentation",
|
|
63
|
+
* prompt: "Create a technical homepage for our REST API documentation",
|
|
64
|
+
* model: {
|
|
65
|
+
* id: "gpt-4o",
|
|
66
|
+
* provider: "openai"
|
|
67
|
+
* },
|
|
68
|
+
* temperature: 0.3,
|
|
69
|
+
* systemPromptExtension: "Make sure to use technical terminology appropriate for developers."
|
|
70
|
+
* });
|
|
71
|
+
*/
|
|
72
|
+
export async function HomePage(id, props) {
|
|
73
|
+
// Build the system prompt with optional extension
|
|
74
|
+
const systemPrompt = `
|
|
75
|
+
You are creating a VitePress homepage (index.md file).
|
|
76
|
+
|
|
77
|
+
VitePress uses YAML frontmatter to configure the homepage.
|
|
78
|
+
The homepage must have "layout: home" in its frontmatter.
|
|
79
|
+
|
|
80
|
+
The homepage can include:
|
|
81
|
+
- A hero section with name, text, tagline, image, and action buttons
|
|
82
|
+
- A features section with multiple feature items (title, icon, details)
|
|
83
|
+
- Additional markdown content below the frontmatter
|
|
84
|
+
|
|
85
|
+
Follow these guidelines:
|
|
86
|
+
1. Start with YAML frontmatter (--- at beginning and end)
|
|
87
|
+
2. Include "layout: home" in the frontmatter
|
|
88
|
+
3. Use the provided hero and features configuration if supplied
|
|
89
|
+
4. Add any additional sections or content based on the user's prompt
|
|
90
|
+
5. Create visually appealing, well-structured content
|
|
91
|
+
6. Ensure all links are properly formatted
|
|
92
|
+
7. Use appropriate markdown formatting for headings, lists, etc.
|
|
93
|
+
|
|
94
|
+
${props.system || ""}
|
|
95
|
+
`;
|
|
96
|
+
// Convert hero and features to YAML strings if provided
|
|
97
|
+
const heroYaml = props.hero ? JSON.stringify(props.hero, null, 2) : "";
|
|
98
|
+
const featuresYaml = props.features
|
|
99
|
+
? JSON.stringify(props.features, null, 2)
|
|
100
|
+
: "";
|
|
101
|
+
if (props.prompt) {
|
|
102
|
+
return Document(id, {
|
|
103
|
+
title: props.title,
|
|
104
|
+
path: props.outFile,
|
|
105
|
+
baseURL: props.baseURL,
|
|
106
|
+
apiKey: props.apiKey,
|
|
107
|
+
model: props.model ?? {
|
|
108
|
+
id: "claude-3-7-sonnet-latest",
|
|
109
|
+
provider: "anthropic",
|
|
110
|
+
},
|
|
111
|
+
temperature: props.temperature ?? 0.7,
|
|
112
|
+
prompt: await alchemy `
|
|
113
|
+
${systemPrompt}
|
|
114
|
+
|
|
115
|
+
Create a VitePress homepage based on the following description:
|
|
116
|
+
${props.prompt}
|
|
117
|
+
|
|
118
|
+
${props.hero
|
|
119
|
+
? `Use this hero section configuration:
|
|
120
|
+
\`\`\`json
|
|
121
|
+
${heroYaml}
|
|
122
|
+
\`\`\``
|
|
123
|
+
: ""}
|
|
124
|
+
|
|
125
|
+
${props.features
|
|
126
|
+
? `Use these features:
|
|
127
|
+
\`\`\`json
|
|
128
|
+
${featuresYaml}
|
|
129
|
+
\`\`\``
|
|
130
|
+
: ""}
|
|
131
|
+
|
|
132
|
+
The output should be a complete index.md file with proper YAML frontmatter and markdown content.
|
|
133
|
+
`,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
return StaticTextFile(id, props.outFile, `---
|
|
138
|
+
${yaml.stringify({
|
|
139
|
+
layout: "home",
|
|
140
|
+
name: props.title,
|
|
141
|
+
hero: props.hero,
|
|
142
|
+
features: props.features,
|
|
143
|
+
})}
|
|
144
|
+
---
|
|
145
|
+
`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
import { Resource } from "../resource";
|
|
4
|
-
import type { HomePage } from "./home-page";
|
|
1
|
+
import type { Context } from "../../context";
|
|
2
|
+
import { Resource } from "../../resource";
|
|
5
3
|
export interface VitePressProjectProps {
|
|
6
4
|
/**
|
|
7
5
|
* The name/path of the project
|
|
@@ -20,6 +18,13 @@ export interface VitePressProjectProps {
|
|
|
20
18
|
* @default true
|
|
21
19
|
*/
|
|
22
20
|
typescript?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The scripts to add to the project
|
|
23
|
+
*/
|
|
24
|
+
scripts?: Record<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* The tsconfig to use
|
|
27
|
+
*/
|
|
23
28
|
tsconfig?: {
|
|
24
29
|
extends?: string;
|
|
25
30
|
references?: string[];
|
|
@@ -41,22 +46,16 @@ export interface VitePressProjectProps {
|
|
|
41
46
|
/**
|
|
42
47
|
* The theme options to use
|
|
43
48
|
*/
|
|
44
|
-
theme?: ThemeOptions;
|
|
45
49
|
/**
|
|
46
50
|
* The theme config to use
|
|
47
51
|
*/
|
|
48
|
-
themeConfig: DefaultTheme.Config;
|
|
49
|
-
/**
|
|
50
|
-
* The home page configuration
|
|
51
|
-
*/
|
|
52
|
-
home: HomePage;
|
|
53
52
|
/**
|
|
54
53
|
* Whether to delete the project folder during the delete phase
|
|
55
54
|
* @default true
|
|
56
55
|
*/
|
|
57
56
|
delete?: boolean;
|
|
58
57
|
/**
|
|
59
|
-
* The directory to
|
|
58
|
+
* The directory to initialize the project in.
|
|
60
59
|
*
|
|
61
60
|
* @default {@link name}
|
|
62
61
|
*/
|
|
@@ -67,5 +66,9 @@ export interface VitePressProject extends VitePressProjectProps, Resource {
|
|
|
67
66
|
* The name/path of the project
|
|
68
67
|
*/
|
|
69
68
|
name: string;
|
|
69
|
+
/**
|
|
70
|
+
* The directory of the project
|
|
71
|
+
*/
|
|
72
|
+
dir: string;
|
|
70
73
|
}
|
|
71
|
-
export declare const
|
|
74
|
+
export declare const VitepressProject: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<VitePressProject>, id: string, props: VitePressProjectProps) => Promise<VitePressProject>);
|
|
@@ -2,12 +2,11 @@ import { exec } from "child_process";
|
|
|
2
2
|
import fs from "fs/promises";
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { promisify } from "util";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import { Resource } from "../resource";
|
|
5
|
+
import { Folder, StaticJsonFile, StaticTextFile, StaticTypeScriptFile, } from "../../fs";
|
|
6
|
+
import { Resource } from "../../resource";
|
|
8
7
|
import { InstallDependencies, fixedDependencies } from "./dependencies";
|
|
9
8
|
const execAsync = promisify(exec);
|
|
10
|
-
export const
|
|
9
|
+
export const VitepressProject = Resource("project::VitepressProject", {
|
|
11
10
|
alwaysUpdate: true,
|
|
12
11
|
}, async function (id, props) {
|
|
13
12
|
const dir = props.dir ?? props.name;
|
|
@@ -25,18 +24,19 @@ export const VitePressProject = Resource("project::VitePressProject", {
|
|
|
25
24
|
}
|
|
26
25
|
return this.destroy();
|
|
27
26
|
}
|
|
28
|
-
const cwd = (await Folder("dir", {
|
|
27
|
+
const cwd = path.relative(process.cwd(), (await Folder("dir", {
|
|
29
28
|
path: dir,
|
|
30
29
|
delete: props.delete,
|
|
31
|
-
})).path;
|
|
30
|
+
})).path);
|
|
32
31
|
// Initialize package.json
|
|
33
|
-
await
|
|
32
|
+
await StaticJsonFile(path.join(cwd, "package.json"), {
|
|
34
33
|
name: props.name,
|
|
35
34
|
scripts: {
|
|
36
35
|
"docs:gen": "bun alchemy.run.ts",
|
|
37
36
|
"docs:dev": "vitepress dev",
|
|
38
37
|
"docs:build": "vitepress build",
|
|
39
38
|
"docs:preview": "vitepress preview",
|
|
39
|
+
...props.scripts,
|
|
40
40
|
},
|
|
41
41
|
dependencies: fixedDependencies(props.dependencies || {}),
|
|
42
42
|
devDependencies: fixedDependencies(props.devDependencies || {}),
|
|
@@ -56,13 +56,19 @@ export const VitePressProject = Resource("project::VitePressProject", {
|
|
|
56
56
|
await Folder(path.join(cwd, ".vitepress"));
|
|
57
57
|
await Folder(path.join(cwd, ".vitepress", "theme"));
|
|
58
58
|
await Promise.all([
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
59
|
+
StaticTextFile(path.join(cwd, ".gitignore"), `.vitepress/cache\n`),
|
|
60
|
+
// StaticJsonFile(path.join(cwd, "tsconfig.json"), {
|
|
61
|
+
// extends: props.tsconfig?.extends,
|
|
62
|
+
// references: props.tsconfig?.references?.map((path) => ({ path })),
|
|
63
|
+
// compilerOptions: props.tsconfig?.compilerOptions ?? {
|
|
64
|
+
// target: "ES2020",
|
|
65
|
+
// module: "ESNext",
|
|
66
|
+
// moduleResolution: "Node",
|
|
67
|
+
// allowJs: true,
|
|
68
|
+
// skipLibCheck: true,
|
|
69
|
+
// forceConsistentCasingInFileNames: true,
|
|
70
|
+
// },
|
|
71
|
+
// }),
|
|
66
72
|
// TypeScriptFile(
|
|
67
73
|
// path.join(cwd, "alchemy.run.ts"),
|
|
68
74
|
// `import alchemy from "alchemy";
|
|
@@ -82,7 +88,7 @@ export const VitePressProject = Resource("project::VitePressProject", {
|
|
|
82
88
|
// });
|
|
83
89
|
// `,
|
|
84
90
|
// ),
|
|
85
|
-
|
|
91
|
+
StaticTypeScriptFile(path.join(cwd, ".vitepress", "theme", "index.ts"), `import TwoslashFloatingVue from "@shikijs/vitepress-twoslash/client";
|
|
86
92
|
import "@shikijs/vitepress-twoslash/style.css";
|
|
87
93
|
import type { Theme as ThemeConfig } from "vitepress";
|
|
88
94
|
import Theme from "vitepress/theme-without-fonts";
|
|
@@ -95,7 +101,7 @@ export default {
|
|
|
95
101
|
},
|
|
96
102
|
} satisfies ThemeConfig;
|
|
97
103
|
`),
|
|
98
|
-
|
|
104
|
+
StaticTextFile(path.join(cwd, ".vitepress", "theme", "style.css"), `/**
|
|
99
105
|
* Customize default theme styling by overriding CSS variables:
|
|
100
106
|
* https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css
|
|
101
107
|
*/
|
|
@@ -233,34 +239,10 @@ export default {
|
|
|
233
239
|
.DocSearch {
|
|
234
240
|
--docsearch-primary-color: var(--vp-c-brand-1) !important;
|
|
235
241
|
}
|
|
236
|
-
`),
|
|
237
|
-
TypeScriptFile(path.join(cwd, ".vitepress", "config.mts"), `import { transformerTwoslash } from "@shikijs/vitepress-twoslash";
|
|
238
|
-
import footnotePlugin from "markdown-it-footnote";
|
|
239
|
-
import { defineConfig } from "vitepress";
|
|
240
|
-
|
|
241
|
-
// https://vitepress.dev/reference/site-config
|
|
242
|
-
export default defineConfig({
|
|
243
|
-
title: ${JSON.stringify(props.title || "Alchemy")},
|
|
244
|
-
description: ${JSON.stringify(props.description || "Alchemy Docs")},
|
|
245
|
-
markdown: {
|
|
246
|
-
// @ts-ignore
|
|
247
|
-
codeTransformers: [transformerTwoslash()],
|
|
248
|
-
theme: ${JSON.stringify(props.theme ?? {
|
|
249
|
-
light: "light-plus",
|
|
250
|
-
dark: "dark-plus",
|
|
251
|
-
})},
|
|
252
|
-
config: (md) => md.use(footnotePlugin),
|
|
253
|
-
},
|
|
254
|
-
// https://vitepress.dev/reference/default-theme-config
|
|
255
|
-
themeConfig: ${JSON.stringify({
|
|
256
|
-
...props.themeConfig,
|
|
257
|
-
search: props.themeConfig.search ?? { provider: "local" },
|
|
258
|
-
nav: props.themeConfig.nav ?? [{ text: "Home", link: "/" }],
|
|
259
|
-
sidebar: props.themeConfig.sidebar ?? [],
|
|
260
|
-
socialLinks: props.themeConfig.socialLinks ?? [],
|
|
261
|
-
})}
|
|
262
|
-
});
|
|
263
242
|
`),
|
|
264
243
|
]);
|
|
265
|
-
return this(
|
|
244
|
+
return this({
|
|
245
|
+
...props,
|
|
246
|
+
dir,
|
|
247
|
+
});
|
|
266
248
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alchemy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"module": "./lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,13 +14,17 @@
|
|
|
14
14
|
"./aws": "./lib/aws/index.js",
|
|
15
15
|
"./aws/oidc": "./lib/aws/oidc/index.js",
|
|
16
16
|
"./cloudflare": "./lib/cloudflare/index.js",
|
|
17
|
+
"./dns": "./lib/dns/index.js",
|
|
17
18
|
"./esbuild": "./lib/esbuild/index.js",
|
|
18
19
|
"./fs": "./lib/fs/index.js",
|
|
19
20
|
"./github": "./lib/github/index.js",
|
|
20
21
|
"./shadcn": "./lib/shadcn/index.js",
|
|
21
22
|
"./stripe": "./lib/stripe/index.js",
|
|
22
23
|
"./test/bun": "./lib/test/bun.js",
|
|
23
|
-
"./
|
|
24
|
+
"./web/astro": "./lib/web/astro/index.js",
|
|
25
|
+
"./web/tailwind": "./lib/web/tailwind/index.js",
|
|
26
|
+
"./web/vite": "./lib/web/vite/index.js",
|
|
27
|
+
"./web/vitepress": "./lib/web/vitepress/index.js"
|
|
24
28
|
},
|
|
25
29
|
"peerDependencies": {
|
|
26
30
|
"@ai-sdk/openai": "^1.1.9",
|