alchemy 0.2.5 → 0.3.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.
- package/README.md +3 -3
- package/lib/ai/astro-file.d.ts +137 -0
- package/lib/ai/astro-file.js +173 -0
- package/lib/ai/client.d.ts +2 -10
- package/lib/ai/client.js +8 -24
- package/lib/ai/css-file.d.ts +131 -0
- package/lib/ai/css-file.js +158 -0
- package/lib/ai/data.d.ts +45 -5
- package/lib/ai/data.js +45 -10
- package/lib/ai/document.d.ts +44 -20
- package/lib/ai/document.js +95 -28
- package/lib/ai/html-file.d.ts +128 -0
- package/lib/ai/html-file.js +155 -0
- package/lib/ai/index.d.ts +7 -0
- package/lib/ai/index.js +7 -0
- package/lib/ai/json-file.d.ts +160 -0
- package/lib/ai/json-file.js +208 -0
- package/lib/ai/typescript-file.d.ts +140 -0
- package/lib/ai/typescript-file.js +176 -0
- package/lib/ai/vue-file.d.ts +126 -0
- package/lib/ai/vue-file.js +153 -0
- package/lib/ai/yaml-file.d.ts +169 -0
- package/lib/ai/yaml-file.js +236 -0
- package/lib/cloudflare/dns.d.ts +88 -0
- package/lib/cloudflare/dns.js +192 -0
- 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/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/file-system-state-store.d.ts +17 -0
- package/lib/fs/file-system-state-store.js +87 -0
- package/lib/fs/folder.d.ts +10 -0
- package/lib/fs/folder.js +2 -2
- package/lib/fs/index.d.ts +4 -4
- package/lib/fs/index.js +4 -4
- package/lib/fs/{json-file.d.ts → static-json-file.d.ts} +2 -2
- package/lib/fs/static-json-file.js +14 -0
- package/lib/fs/{text-file.d.ts → static-text-file.d.ts} +2 -2
- package/lib/fs/{text-file.js → static-text-file.js} +1 -1
- package/lib/fs/{typescript-file.d.ts → static-typescript-file.d.ts} +2 -2
- package/lib/fs/{typescript-file.js → static-typescript-file.js} +1 -1
- package/lib/fs/{yaml-file.d.ts → static-yaml-file.d.ts} +2 -2
- package/lib/fs/{yaml-file.js → static-yaml-file.js} +1 -1
- package/lib/internal/getting-started.d.ts +10 -0
- package/lib/internal/getting-started.js +94 -0
- package/lib/internal/project.d.ts +13 -0
- package/lib/internal/project.js +101 -0
- package/lib/internal/providers.d.ts +23 -0
- package/lib/internal/providers.js +148 -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/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 +244 -0
- package/lib/web/vitepress/home-page.js +134 -0
- package/lib/{vitepress → web/vitepress}/index.d.ts +1 -0
- package/lib/{vitepress → web/vitepress}/index.js +1 -0
- package/lib/{vitepress → web/vitepress}/vitepress.d.ts +10 -8
- package/lib/{vitepress → web/vitepress}/vitepress.js +11 -12
- package/package.json +6 -2
- package/src/ai/astro-file.ts +288 -0
- package/src/ai/client.ts +8 -28
- package/src/ai/css-file.ts +266 -0
- package/src/ai/data.ts +53 -16
- package/src/ai/document.ts +130 -33
- package/src/ai/html-file.ts +263 -0
- package/src/ai/index.ts +7 -0
- package/src/ai/json-file.ts +349 -0
- package/src/ai/typescript-file.ts +293 -0
- package/src/ai/vue-file.ts +261 -0
- package/src/ai/yaml-file.ts +368 -0
- package/src/apply.ts +0 -1
- package/src/cloudflare/dns.ts +344 -0
- 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/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/file-system-state-store.ts +109 -0
- package/src/fs/folder.ts +14 -2
- package/src/fs/index.ts +4 -4
- package/src/fs/{json-file.ts → static-json-file.ts} +13 -3
- package/src/fs/{text-file.ts → static-text-file.ts} +5 -2
- package/src/fs/{typescript-file.ts → static-typescript-file.ts} +3 -3
- package/src/fs/{yaml-file.ts → static-yaml-file.ts} +5 -2
- package/src/internal/getting-started.ts +107 -0
- package/src/internal/project.ts +119 -0
- package/src/internal/providers.ts +209 -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/custom-theme.ts +514 -0
- package/src/{vitepress → web/vitepress}/dependencies.ts +2 -2
- package/src/web/vitepress/home-page.ts +363 -0
- package/src/{vitepress → web/vitepress}/index.ts +1 -0
- package/src/{vitepress → web/vitepress}/vitepress.ts +34 -27
- 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/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/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,97 @@
|
|
|
1
|
+
import { exec } from "child_process";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { promisify } from "util";
|
|
4
|
+
import { Folder, StaticTextFile } from "../fs";
|
|
5
|
+
import { Resource } from "../resource";
|
|
6
|
+
const execAsync = promisify(exec);
|
|
7
|
+
/**
|
|
8
|
+
* Installs and configures Tailwind CSS for a project
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* // Install Tailwind for a Vite project
|
|
12
|
+
* const tailwind = await TailwindConfig("vite-tailwind", {
|
|
13
|
+
* cwd: "my-vite-app",
|
|
14
|
+
* framework: "vite"
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Install Tailwind for an Astro project
|
|
19
|
+
* const tailwind = await TailwindConfig("astro-tailwind", {
|
|
20
|
+
* cwd: "my-astro-app",
|
|
21
|
+
* framework: "astro"
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Install Tailwind as standalone with a custom CSS path
|
|
26
|
+
* const tailwind = await TailwindConfig("custom-tailwind", {
|
|
27
|
+
* cwd: "my-project",
|
|
28
|
+
* cssPath: "src/css/main.css",
|
|
29
|
+
* additionalPackages: ["@tailwindcss/typography", "@tailwindcss/forms"]
|
|
30
|
+
* });
|
|
31
|
+
*/
|
|
32
|
+
export const TailwindConfig = Resource("config::TailwindConfig", async function (id, props) {
|
|
33
|
+
if (this.phase === "delete") {
|
|
34
|
+
// Nothing to clean up specifically for Tailwind
|
|
35
|
+
return this.destroy();
|
|
36
|
+
}
|
|
37
|
+
const framework = props.framework || "standalone";
|
|
38
|
+
// Setup execAsync with the correct cwd
|
|
39
|
+
const exec = (command) => execAsync(command, { cwd: props.cwd });
|
|
40
|
+
// Install Tailwind and framework-specific dependencies
|
|
41
|
+
await installTailwindDependencies(framework);
|
|
42
|
+
// Create CSS file with Tailwind directives
|
|
43
|
+
await createTailwindCssFile();
|
|
44
|
+
return this({
|
|
45
|
+
...props,
|
|
46
|
+
framework: framework,
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Install Tailwind and framework-specific dependencies
|
|
50
|
+
*/
|
|
51
|
+
async function installTailwindDependencies(framework) {
|
|
52
|
+
const basePackages = ["tailwindcss", "postcss", "autoprefixer"];
|
|
53
|
+
// Add framework-specific packages
|
|
54
|
+
const frameworkPackages = getFrameworkPackages(framework);
|
|
55
|
+
// Add custom additional packages
|
|
56
|
+
const additionalPackages = props.additionalPackages || [];
|
|
57
|
+
// Combine all packages
|
|
58
|
+
const allPackages = [
|
|
59
|
+
...basePackages,
|
|
60
|
+
...frameworkPackages,
|
|
61
|
+
...additionalPackages,
|
|
62
|
+
];
|
|
63
|
+
// Install all packages
|
|
64
|
+
await exec(`bun add -D ${allPackages.join(" ")}`);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get framework-specific packages for Tailwind
|
|
68
|
+
*/
|
|
69
|
+
function getFrameworkPackages(framework) {
|
|
70
|
+
switch (framework) {
|
|
71
|
+
case "vite":
|
|
72
|
+
return ["@tailwindcss/vite"];
|
|
73
|
+
case "astro":
|
|
74
|
+
return ["@astrojs/tailwind"];
|
|
75
|
+
case "next":
|
|
76
|
+
return [];
|
|
77
|
+
case "standalone":
|
|
78
|
+
default:
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Create or update CSS file with Tailwind directives
|
|
84
|
+
*/
|
|
85
|
+
async function createTailwindCssFile() {
|
|
86
|
+
const tailwindDirectives = `@import 'tailwindcss';`;
|
|
87
|
+
// Determine CSS file path
|
|
88
|
+
const cssPath = props.cssPath || path.join(props.cwd, "src", "styles", "global.css");
|
|
89
|
+
// Create directory structure if needed
|
|
90
|
+
const cssDir = path.dirname(cssPath);
|
|
91
|
+
await Folder(path.join(id, "css-dir"), {
|
|
92
|
+
path: cssDir,
|
|
93
|
+
});
|
|
94
|
+
// Create CSS file with Tailwind directives
|
|
95
|
+
await StaticTextFile(cssPath, tailwindDirectives);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
@@ -79,6 +79,11 @@ export interface ViteProjectProps {
|
|
|
79
79
|
* @default false
|
|
80
80
|
*/
|
|
81
81
|
overwrite?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Whether to delete the project folder during the delete phase
|
|
84
|
+
* @default true
|
|
85
|
+
*/
|
|
86
|
+
delete?: boolean;
|
|
82
87
|
}
|
|
83
88
|
export interface ViteProject extends ViteProjectProps, Resource {
|
|
84
89
|
/**
|
package/lib/{vite → web}/vite.js
RENAMED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { exec } from "child_process";
|
|
2
|
-
import fs from "fs/promises";
|
|
3
2
|
import path from "path";
|
|
4
3
|
import { promisify } from "util";
|
|
4
|
+
import { Folder, StaticJsonFile, StaticTypeScriptFile } from "../fs";
|
|
5
5
|
import { Resource } from "../resource";
|
|
6
|
-
import { ShadcnComponent } from "../shadcn/component";
|
|
7
6
|
import { rm } from "../util/rm";
|
|
7
|
+
import { ShadcnComponent } from "./shadcn-component";
|
|
8
|
+
import { TailwindConfig } from "./tailwind";
|
|
8
9
|
const execAsync = promisify(exec);
|
|
9
10
|
export const ViteProject = Resource("project::ViteProject", {
|
|
10
11
|
alwaysUpdate: true,
|
|
@@ -12,9 +13,8 @@ export const ViteProject = Resource("project::ViteProject", {
|
|
|
12
13
|
const phase = this.phase;
|
|
13
14
|
if (this.phase === "delete") {
|
|
14
15
|
try {
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
await execAsync("rm -rf " + props.name);
|
|
16
|
+
if (props.delete !== false) {
|
|
17
|
+
await execAsync(`rm -rf ${props.name}`);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
catch (error) {
|
|
@@ -45,6 +45,11 @@ export const ViteProject = Resource("project::ViteProject", {
|
|
|
45
45
|
"react()",
|
|
46
46
|
].filter((s) => typeof s === "string");
|
|
47
47
|
const cwd = path.resolve(process.cwd(), props.name);
|
|
48
|
+
// Create folder for project
|
|
49
|
+
await Folder("project-dir", {
|
|
50
|
+
path: props.name,
|
|
51
|
+
delete: props.delete,
|
|
52
|
+
});
|
|
48
53
|
const exec = (command) => execAsync(command, { cwd });
|
|
49
54
|
if (phase === "create" || props.overwrite) {
|
|
50
55
|
await removeUnnecessaryFiles();
|
|
@@ -65,8 +70,11 @@ export const ViteProject = Resource("project::ViteProject", {
|
|
|
65
70
|
await execAsync(`bun vite build`, { cwd: props.name });
|
|
66
71
|
}
|
|
67
72
|
async function installTailwind() {
|
|
68
|
-
await
|
|
69
|
-
|
|
73
|
+
await TailwindConfig(`${id}-tailwind`, {
|
|
74
|
+
cwd: props.name,
|
|
75
|
+
framework: "vite",
|
|
76
|
+
});
|
|
77
|
+
await StaticTypeScriptFile(path.join(props.name, "vite.config.ts"), `import path from "path";
|
|
70
78
|
import react from "@vitejs/plugin-react";
|
|
71
79
|
import { defineConfig } from "vite";
|
|
72
80
|
${tailwind ? "import tailwindcss from '@tailwindcss/vite';" : ""}
|
|
@@ -81,12 +89,6 @@ export default defineConfig({
|
|
|
81
89
|
},
|
|
82
90
|
},
|
|
83
91
|
});`);
|
|
84
|
-
// Add Tailwind CSS import to index.css
|
|
85
|
-
const indexCssPath = path.join(props.name, "src", "index.css");
|
|
86
|
-
const currentCss = await fs.readFile(indexCssPath, "utf-8");
|
|
87
|
-
if (!currentCss.includes('@import "tailwindcss";')) {
|
|
88
|
-
await fs.writeFile(indexCssPath, '@import "tailwindcss";\n\n' + currentCss);
|
|
89
|
-
}
|
|
90
92
|
}
|
|
91
93
|
async function installShadcn() {
|
|
92
94
|
await exec("bun add -D @types/node");
|
|
@@ -120,8 +122,12 @@ export default defineConfig({
|
|
|
120
122
|
await exec(`bun add -D @tanstack/router-plugin @tanstack/react-router-devtools`);
|
|
121
123
|
const src = path.join(props.name, "src");
|
|
122
124
|
const routes = path.join(src, "routes");
|
|
123
|
-
|
|
124
|
-
await
|
|
125
|
+
// Create routes directory
|
|
126
|
+
await Folder("routes-dir", {
|
|
127
|
+
path: routes,
|
|
128
|
+
});
|
|
129
|
+
// Create root route file
|
|
130
|
+
await StaticTypeScriptFile(path.join(routes, "__root.tsx"), `import { Link, Outlet, createRootRoute } from "@tanstack/react-router";
|
|
125
131
|
import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
|
|
126
132
|
|
|
127
133
|
export const Route = createRootRoute({
|
|
@@ -142,7 +148,8 @@ export const Route = createRootRoute({
|
|
|
142
148
|
),
|
|
143
149
|
});
|
|
144
150
|
`);
|
|
145
|
-
|
|
151
|
+
// Create index route file
|
|
152
|
+
await StaticTypeScriptFile(path.join(routes, "index.tsx"), `import { createLazyFileRoute } from '@tanstack/react-router'
|
|
146
153
|
|
|
147
154
|
export const Route = createLazyFileRoute('/')({
|
|
148
155
|
component: Index,
|
|
@@ -155,7 +162,8 @@ function Index() {
|
|
|
155
162
|
</div>
|
|
156
163
|
)
|
|
157
164
|
}`);
|
|
158
|
-
|
|
165
|
+
// Create about route file
|
|
166
|
+
await StaticTypeScriptFile(path.join(routes, "about.tsx"), `import { createLazyFileRoute } from '@tanstack/react-router'
|
|
159
167
|
|
|
160
168
|
export const Route = createLazyFileRoute('/about')({
|
|
161
169
|
component: About,
|
|
@@ -164,7 +172,8 @@ export const Route = createLazyFileRoute('/about')({
|
|
|
164
172
|
function About() {
|
|
165
173
|
return <div className="p-2">Hello from About!</div>
|
|
166
174
|
}`);
|
|
167
|
-
|
|
175
|
+
// Create main.tsx
|
|
176
|
+
await StaticTypeScriptFile(path.join(src, "main.tsx"), `import { StrictMode } from 'react'
|
|
168
177
|
import ReactDOM from 'react-dom/client'
|
|
169
178
|
import { RouterProvider, createRouter } from '@tanstack/react-router'
|
|
170
179
|
import './index.css'
|
|
@@ -194,35 +203,26 @@ if (!rootElement.innerHTML) {
|
|
|
194
203
|
}`);
|
|
195
204
|
}
|
|
196
205
|
async function removeUnnecessaryFiles() {
|
|
197
|
-
await
|
|
198
|
-
|
|
199
|
-
rm(path.join(props.name, "src", "App.css")),
|
|
200
|
-
]);
|
|
206
|
+
await rm(path.join(props.name, "src", "App.tsx"));
|
|
207
|
+
await rm(path.join(props.name, "src", "App.css"));
|
|
201
208
|
}
|
|
202
209
|
async function patchTsConfig() {
|
|
203
|
-
await
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
"@/*": ["./src/*"],
|
|
212
|
-
},
|
|
213
|
-
types: ["@cloudflare/workers-types"],
|
|
214
|
-
allowImportingTsExtensions: true,
|
|
215
|
-
jsx: "react-jsx",
|
|
210
|
+
await rm(path.join(props.name, "tsconfig.app.json"));
|
|
211
|
+
await rm(path.join(props.name, "tsconfig.node.json"));
|
|
212
|
+
await StaticJsonFile(path.join(props.name, "tsconfig.json"), {
|
|
213
|
+
extends: props.extends,
|
|
214
|
+
compilerOptions: {
|
|
215
|
+
baseUrl: ".",
|
|
216
|
+
paths: {
|
|
217
|
+
"@/*": ["./src/*"],
|
|
216
218
|
},
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}, null, 2)),
|
|
225
|
-
]);
|
|
219
|
+
types: ["@cloudflare/workers-types"],
|
|
220
|
+
allowImportingTsExtensions: true,
|
|
221
|
+
jsx: "react-jsx",
|
|
222
|
+
},
|
|
223
|
+
include: ["vite/*.ts", "src/**/*.ts", "src/**/*.tsx", "src/env.d.ts"],
|
|
224
|
+
references: props.references?.map((path) => ({ path })),
|
|
225
|
+
});
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
});
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import type { ModelConfig } from "../../ai/client";
|
|
2
|
+
import type { Context } from "../../context";
|
|
3
|
+
import { Resource } from "../../resource";
|
|
4
|
+
import type { Secret } from "../../secret";
|
|
5
|
+
/**
|
|
6
|
+
* Theme component props for customizing the layout
|
|
7
|
+
*/
|
|
8
|
+
export interface ThemeComponentProps {
|
|
9
|
+
/**
|
|
10
|
+
* Name of the component
|
|
11
|
+
*/
|
|
12
|
+
name: string;
|
|
13
|
+
/**
|
|
14
|
+
* Description of what the component does
|
|
15
|
+
*/
|
|
16
|
+
description: string;
|
|
17
|
+
/**
|
|
18
|
+
* Features or functionality to include in the component
|
|
19
|
+
*/
|
|
20
|
+
features?: string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Properties for creating or updating a VitePress custom theme
|
|
24
|
+
*/
|
|
25
|
+
export interface CustomThemeProps {
|
|
26
|
+
/**
|
|
27
|
+
* Output directory for the theme files
|
|
28
|
+
*/
|
|
29
|
+
outDir: string;
|
|
30
|
+
/**
|
|
31
|
+
* Title of the theme
|
|
32
|
+
*/
|
|
33
|
+
title: string;
|
|
34
|
+
/**
|
|
35
|
+
* Description of the theme
|
|
36
|
+
*/
|
|
37
|
+
description: string;
|
|
38
|
+
/**
|
|
39
|
+
* Components to include in the theme
|
|
40
|
+
*/
|
|
41
|
+
components?: ThemeComponentProps[];
|
|
42
|
+
/**
|
|
43
|
+
* Whether to include dark mode support
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
darkMode?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Custom CSS variables for theming
|
|
49
|
+
*/
|
|
50
|
+
customCssVars?: Record<string, string>;
|
|
51
|
+
/**
|
|
52
|
+
* Custom plugins to add to the theme
|
|
53
|
+
*/
|
|
54
|
+
plugins?: string[];
|
|
55
|
+
/**
|
|
56
|
+
* User prompt describing the design of the theme
|
|
57
|
+
*/
|
|
58
|
+
prompt: string;
|
|
59
|
+
/**
|
|
60
|
+
* Optional extension to the built-in system prompt
|
|
61
|
+
*/
|
|
62
|
+
systemPromptExtension?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Base URL for the OpenAI API
|
|
65
|
+
* @default 'https://api.openai.com/v1'
|
|
66
|
+
*/
|
|
67
|
+
baseURL?: string;
|
|
68
|
+
/**
|
|
69
|
+
* OpenAI API key to use for generating content
|
|
70
|
+
* If not provided, will use OPENAI_API_KEY environment variable
|
|
71
|
+
*/
|
|
72
|
+
apiKey?: Secret;
|
|
73
|
+
/**
|
|
74
|
+
* Model configuration for the AI generator
|
|
75
|
+
*/
|
|
76
|
+
model?: ModelConfig;
|
|
77
|
+
/**
|
|
78
|
+
* Temperature for controlling randomness in generation
|
|
79
|
+
* @default 0.7
|
|
80
|
+
*/
|
|
81
|
+
temperature?: number;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A generated file in the custom theme
|
|
85
|
+
*/
|
|
86
|
+
export interface ThemeFile {
|
|
87
|
+
/**
|
|
88
|
+
* Path to the file
|
|
89
|
+
*/
|
|
90
|
+
path: string;
|
|
91
|
+
/**
|
|
92
|
+
* Content of the file
|
|
93
|
+
*/
|
|
94
|
+
content: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Output for the VitePress custom theme resource
|
|
98
|
+
*/
|
|
99
|
+
export interface CustomTheme extends CustomThemeProps, Resource<"vitepress::CustomTheme"> {
|
|
100
|
+
/**
|
|
101
|
+
* Path to the generated theme directory
|
|
102
|
+
*/
|
|
103
|
+
themePath: string;
|
|
104
|
+
/**
|
|
105
|
+
* List of generated files
|
|
106
|
+
*/
|
|
107
|
+
files: ThemeFile[];
|
|
108
|
+
/**
|
|
109
|
+
* Time at which the theme was created
|
|
110
|
+
*/
|
|
111
|
+
createdAt: number;
|
|
112
|
+
/**
|
|
113
|
+
* Time at which the theme was last updated
|
|
114
|
+
*/
|
|
115
|
+
updatedAt: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Resource for generating a custom VitePress theme using AI.
|
|
119
|
+
*
|
|
120
|
+
* Generates the necessary theme files including:
|
|
121
|
+
* - Theme entry file (index.ts)
|
|
122
|
+
* - Layout component (Layout.vue)
|
|
123
|
+
* - Additional components based on configuration
|
|
124
|
+
* - Style sheets and utilities
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* // Create a basic custom theme
|
|
128
|
+
* const theme = await CustomTheme("docs-theme", {
|
|
129
|
+
* outDir: "./.vitepress/theme",
|
|
130
|
+
* title: "My Custom Theme",
|
|
131
|
+
* description: "A clean, minimal theme for documentation",
|
|
132
|
+
* prompt: "Create a clean documentation theme with a sidebar and search"
|
|
133
|
+
* });
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* // Create a theme with specific components
|
|
137
|
+
* const complexTheme = await CustomTheme("blog-theme", {
|
|
138
|
+
* outDir: "./.vitepress/theme",
|
|
139
|
+
* title: "Blog Theme",
|
|
140
|
+
* description: "A theme for technical blogs",
|
|
141
|
+
* components: [
|
|
142
|
+
* {
|
|
143
|
+
* name: "PostList",
|
|
144
|
+
* description: "Component that displays a list of blog posts with pagination",
|
|
145
|
+
* features: ["thumbnail images", "post dates", "categories", "excerpts"]
|
|
146
|
+
* },
|
|
147
|
+
* {
|
|
148
|
+
* name: "TableOfContents",
|
|
149
|
+
* description: "Component that displays the current page's table of contents",
|
|
150
|
+
* features: ["sticky positioning", "active link highlighting"]
|
|
151
|
+
* }
|
|
152
|
+
* ],
|
|
153
|
+
* darkMode: true,
|
|
154
|
+
* prompt: "Create a modern blog theme with post listings and detailed article pages"
|
|
155
|
+
* });
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* // Create a theme with custom CSS variables
|
|
159
|
+
* const brandedTheme = await CustomTheme("branded-theme", {
|
|
160
|
+
* outDir: "./.vitepress/theme",
|
|
161
|
+
* title: "Branded Docs",
|
|
162
|
+
* description: "A themed documentation site with custom branding",
|
|
163
|
+
* customCssVars: {
|
|
164
|
+
* "--vp-c-brand": "#3a70b0",
|
|
165
|
+
* "--vp-c-brand-light": "#5785bc",
|
|
166
|
+
* "--vp-c-brand-lighter": "#79a1ce",
|
|
167
|
+
* "--vp-c-brand-dark": "#2c5989",
|
|
168
|
+
* "--vp-c-brand-darker": "#1e3d5c"
|
|
169
|
+
* },
|
|
170
|
+
* prompt: "Create a documentation theme with custom branding and color scheme"
|
|
171
|
+
* });
|
|
172
|
+
*/
|
|
173
|
+
export declare const CustomTheme: (((this: any, id: string, props?: {}) => never) & (new (_: never) => never)) | ((this: Context<CustomTheme>, id: string, props: CustomThemeProps) => Promise<CustomTheme>);
|