alchemy 0.2.1 → 0.2.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.d.ts +1 -0
- package/lib/alchemy.js +84 -8
- package/lib/apply.d.ts +1 -1
- package/lib/apply.js +13 -10
- package/lib/aws/bucket.d.ts +1 -1
- package/lib/aws/function.d.ts +1 -1
- package/lib/aws/oidc/oidc-provider.d.ts +1 -1
- package/lib/aws/policy-attachment.d.ts +1 -1
- package/lib/aws/policy.d.ts +1 -1
- package/lib/aws/queue.d.ts +1 -1
- package/lib/aws/role.d.ts +1 -1
- package/lib/aws/ses.d.ts +1 -1
- package/lib/aws/table.d.ts +1 -1
- package/lib/cloudflare/bucket.d.ts +1 -1
- package/lib/cloudflare/kv-namespace.d.ts +1 -1
- package/lib/cloudflare/static-site.d.ts +1 -1
- package/lib/cloudflare/worker.d.ts +1 -1
- package/lib/cloudflare/wrangler.json.d.ts +1 -1
- package/lib/cloudflare/zone.d.ts +1 -1
- package/lib/context.d.ts +9 -4
- package/lib/context.js +4 -2
- package/lib/destroy.js +8 -7
- package/lib/docs/document.d.ts +123 -0
- package/lib/docs/document.js +67 -0
- package/lib/docs/index.d.ts +1 -0
- package/lib/docs/index.js +1 -0
- package/lib/esbuild/bundle.d.ts +1 -1
- package/lib/fs/file.d.ts +30 -3
- package/lib/fs/file.js +63 -3
- package/lib/fs/folder.d.ts +3 -3
- package/lib/fs/folder.js +2 -1
- package/lib/github/secret.d.ts +1 -1
- package/lib/resource.d.ts +2 -2
- package/lib/resource.js +4 -0
- package/lib/scope.d.ts +1 -1
- package/lib/scope.js +6 -6
- package/lib/shadcn/component.d.ts +29 -0
- package/lib/shadcn/component.js +31 -0
- package/lib/shadcn/index.d.ts +1 -0
- package/lib/shadcn/index.js +1 -0
- package/lib/state.d.ts +1 -1
- package/lib/state.js +8 -1
- package/lib/stripe/price.d.ts +1 -1
- package/lib/stripe/product.d.ts +1 -1
- package/lib/stripe/webhook.d.ts +1 -1
- package/lib/util/serde.d.ts +3 -1
- package/lib/util/serde.js +6 -4
- package/lib/vite/vite.d.ts +90 -0
- package/lib/vite/vite.js +228 -0
- package/lib/vitepress/dependencies.d.ts +16 -0
- package/lib/vitepress/dependencies.js +35 -0
- package/lib/vitepress/home-page.d.ts +133 -0
- package/lib/vitepress/home-page.js +11 -0
- package/lib/vitepress/index.d.ts +2 -0
- package/lib/vitepress/index.js +2 -0
- package/lib/vitepress/vitepress.d.ts +60 -0
- package/lib/vitepress/vitepress.js +260 -0
- package/package.json +19 -11
- package/src/alchemy.ts +105 -13
- package/src/apply.ts +25 -13
- package/src/context.ts +30 -10
- package/src/destroy.ts +10 -7
- package/src/docs/document.ts +225 -0
- package/src/docs/index.ts +1 -0
- package/src/fs/file.ts +114 -6
- package/src/fs/folder.ts +2 -1
- package/src/resource.ts +7 -2
- package/src/scope.ts +9 -9
- package/src/shadcn/component.ts +80 -0
- package/src/shadcn/index.ts +1 -0
- package/src/state.ts +9 -2
- package/src/util/serde.ts +13 -4
- package/src/vite/vite.ts +406 -0
- package/src/vitepress/dependencies.ts +68 -0
- package/src/vitepress/home-page.ts +166 -0
- package/src/vitepress/index.md +75 -0
- package/src/vitepress/index.ts +2 -0
- package/src/vitepress/vitepress.ts +361 -0
- package/lib/project/vite.d.ts +0 -39
- package/lib/project/vite.js +0 -68
- package/src/project/vite.ts +0 -152
- /package/lib/{project → vite}/index.d.ts +0 -0
- /package/lib/{project → vite}/index.js +0 -0
- /package/src/{project → vite}/index.ts +0 -0
package/lib/vite/vite.js
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { exec } from "child_process";
|
|
2
|
+
import fs from "fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { promisify } from "util";
|
|
5
|
+
import { Resource } from "../resource";
|
|
6
|
+
import { ShadcnComponent } from "../shadcn/component";
|
|
7
|
+
import { rm } from "../util/rm";
|
|
8
|
+
const execAsync = promisify(exec);
|
|
9
|
+
export const ViteProject = Resource("project::ViteProject", {
|
|
10
|
+
alwaysUpdate: true,
|
|
11
|
+
}, async function (id, props) {
|
|
12
|
+
const phase = this.phase;
|
|
13
|
+
if (this.phase === "delete") {
|
|
14
|
+
try {
|
|
15
|
+
if (await fs.exists(props.name)) {
|
|
16
|
+
// TODO: OS agnostic - fs.rm is slow to delete node_modules/
|
|
17
|
+
await execAsync("rm -rf " + props.name);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.error(`Error deleting project ${id}:`, error);
|
|
22
|
+
}
|
|
23
|
+
return this.destroy();
|
|
24
|
+
}
|
|
25
|
+
if (this.phase === "update") {
|
|
26
|
+
if (props.overwrite) {
|
|
27
|
+
await modifyConfig(props);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
console.warn("ViteProject does not support updates - the project must be recreated to change the template");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
await execAsync(`bun create vite ${id} --template ${props.template}`);
|
|
35
|
+
await modifyConfig(props);
|
|
36
|
+
}
|
|
37
|
+
return this(props);
|
|
38
|
+
async function modifyConfig(props) {
|
|
39
|
+
const tailwind = props.tailwind ?? false;
|
|
40
|
+
const tanstack = props.tanstack ?? false;
|
|
41
|
+
const plugins = [
|
|
42
|
+
tailwind && "tailwindcss()",
|
|
43
|
+
tanstack &&
|
|
44
|
+
"TanStackRouterVite({ target: 'react', autoCodeSplitting: true })",
|
|
45
|
+
"react()",
|
|
46
|
+
].filter((s) => typeof s === "string");
|
|
47
|
+
const cwd = path.resolve(process.cwd(), props.name);
|
|
48
|
+
const exec = (command) => execAsync(command, { cwd });
|
|
49
|
+
if (phase === "create" || props.overwrite) {
|
|
50
|
+
await removeUnnecessaryFiles();
|
|
51
|
+
}
|
|
52
|
+
await patchTsConfig();
|
|
53
|
+
if (props.tailwind) {
|
|
54
|
+
await installTailwind();
|
|
55
|
+
}
|
|
56
|
+
if (props.tanstack) {
|
|
57
|
+
await installTanstack();
|
|
58
|
+
}
|
|
59
|
+
if (props.shadcn !== undefined) {
|
|
60
|
+
await installShadcn();
|
|
61
|
+
}
|
|
62
|
+
await build();
|
|
63
|
+
async function build() {
|
|
64
|
+
// tsc -b will fail if we have not invoked tan stacks' code gen
|
|
65
|
+
await execAsync(`bun vite build`, { cwd: props.name });
|
|
66
|
+
}
|
|
67
|
+
async function installTailwind() {
|
|
68
|
+
await exec(`bun add tailwindcss @tailwindcss/vite`);
|
|
69
|
+
await fs.writeFile(path.join(props.name, "vite.config.ts"), `import path from "path";
|
|
70
|
+
import react from "@vitejs/plugin-react";
|
|
71
|
+
import { defineConfig } from "vite";
|
|
72
|
+
${tailwind ? "import tailwindcss from '@tailwindcss/vite';" : ""}
|
|
73
|
+
${tanstack ? 'import { TanStackRouterVite } from "@tanstack/router-plugin/vite";' : ""}
|
|
74
|
+
|
|
75
|
+
// https://vite.dev/config/
|
|
76
|
+
export default defineConfig({
|
|
77
|
+
plugins: [${plugins.join(", ")}],
|
|
78
|
+
resolve: {
|
|
79
|
+
alias: {
|
|
80
|
+
"@": path.resolve(__dirname, "./src"),
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
});`);
|
|
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
|
+
}
|
|
91
|
+
async function installShadcn() {
|
|
92
|
+
await exec("bun add -D @types/node");
|
|
93
|
+
// Build the shadcn init command with all options
|
|
94
|
+
const shadcnOptions = props.shadcn;
|
|
95
|
+
const initCommand = [
|
|
96
|
+
"bunx --bun shadcn@latest init",
|
|
97
|
+
shadcnOptions?.baseColor && `-b ${shadcnOptions.baseColor}`,
|
|
98
|
+
shadcnOptions?.defaults && "-d",
|
|
99
|
+
shadcnOptions?.force && "-f",
|
|
100
|
+
shadcnOptions?.cwd && `-c ${shadcnOptions.cwd}`,
|
|
101
|
+
shadcnOptions?.silent && "-s",
|
|
102
|
+
shadcnOptions?.srcDir && "--src-dir",
|
|
103
|
+
shadcnOptions?.cssVariables === false && "--no-css-variables",
|
|
104
|
+
]
|
|
105
|
+
.filter(Boolean)
|
|
106
|
+
.join(" ");
|
|
107
|
+
await exec(initCommand);
|
|
108
|
+
// Install requested components using the ShadcnComponent resource
|
|
109
|
+
for (const componentName of props.shadcn?.components ?? []) {
|
|
110
|
+
await ShadcnComponent(`shadcn-component-${componentName}`, {
|
|
111
|
+
name: componentName,
|
|
112
|
+
cwd: props.name,
|
|
113
|
+
force: props.shadcn?.force,
|
|
114
|
+
silent: props.shadcn?.silent,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async function installTanstack() {
|
|
119
|
+
await exec(`bun add @tanstack/react-router`);
|
|
120
|
+
await exec(`bun add -D @tanstack/router-plugin @tanstack/react-router-devtools`);
|
|
121
|
+
const src = path.join(props.name, "src");
|
|
122
|
+
const routes = path.join(src, "routes");
|
|
123
|
+
await fs.mkdir(routes, { recursive: true });
|
|
124
|
+
await fs.writeFile(path.join(routes, "__root.tsx"), `import { Link, Outlet, createRootRoute } from "@tanstack/react-router";
|
|
125
|
+
import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
|
|
126
|
+
|
|
127
|
+
export const Route = createRootRoute({
|
|
128
|
+
component: () => (
|
|
129
|
+
<div className="w-full min-h-screen flex flex-col">
|
|
130
|
+
<div className="p-2 flex gap-2">
|
|
131
|
+
<Link to="/" className="[&.active]:font-bold">
|
|
132
|
+
Home
|
|
133
|
+
</Link>{" "}
|
|
134
|
+
<Link to="/about" className="[&.active]:font-bold">
|
|
135
|
+
About
|
|
136
|
+
</Link>
|
|
137
|
+
</div>
|
|
138
|
+
<hr />
|
|
139
|
+
<Outlet />
|
|
140
|
+
<TanStackRouterDevtools />
|
|
141
|
+
</div>
|
|
142
|
+
),
|
|
143
|
+
});
|
|
144
|
+
`);
|
|
145
|
+
await fs.writeFile(path.join(routes, "index.tsx"), `import { createLazyFileRoute } from '@tanstack/react-router'
|
|
146
|
+
|
|
147
|
+
export const Route = createLazyFileRoute('/')({
|
|
148
|
+
component: Index,
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
function Index() {
|
|
152
|
+
return (
|
|
153
|
+
<div className="p-2">
|
|
154
|
+
<h3>Welcome Home!</h3>
|
|
155
|
+
</div>
|
|
156
|
+
)
|
|
157
|
+
}`);
|
|
158
|
+
await fs.writeFile(path.join(routes, "about.tsx"), `import { createLazyFileRoute } from '@tanstack/react-router'
|
|
159
|
+
|
|
160
|
+
export const Route = createLazyFileRoute('/about')({
|
|
161
|
+
component: About,
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
function About() {
|
|
165
|
+
return <div className="p-2">Hello from About!</div>
|
|
166
|
+
}`);
|
|
167
|
+
await fs.writeFile(path.join(src, "main.tsx"), `import { StrictMode } from 'react'
|
|
168
|
+
import ReactDOM from 'react-dom/client'
|
|
169
|
+
import { RouterProvider, createRouter } from '@tanstack/react-router'
|
|
170
|
+
import './index.css'
|
|
171
|
+
|
|
172
|
+
// Import the generated route tree
|
|
173
|
+
import { routeTree } from './routeTree.gen'
|
|
174
|
+
|
|
175
|
+
// Create a new router instance
|
|
176
|
+
const router = createRouter({ routeTree })
|
|
177
|
+
|
|
178
|
+
// Register the router instance for type safety
|
|
179
|
+
declare module '@tanstack/react-router' {
|
|
180
|
+
interface Register {
|
|
181
|
+
router: typeof router
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Render the app
|
|
186
|
+
const rootElement = document.getElementById('root')!
|
|
187
|
+
if (!rootElement.innerHTML) {
|
|
188
|
+
const root = ReactDOM.createRoot(rootElement)
|
|
189
|
+
root.render(
|
|
190
|
+
<StrictMode>
|
|
191
|
+
<RouterProvider router={router} />
|
|
192
|
+
</StrictMode>,
|
|
193
|
+
)
|
|
194
|
+
}`);
|
|
195
|
+
}
|
|
196
|
+
async function removeUnnecessaryFiles() {
|
|
197
|
+
await Promise.all([
|
|
198
|
+
rm(path.join(props.name, "src", "App.tsx")),
|
|
199
|
+
rm(path.join(props.name, "src", "App.css")),
|
|
200
|
+
]);
|
|
201
|
+
}
|
|
202
|
+
async function patchTsConfig() {
|
|
203
|
+
await Promise.all([
|
|
204
|
+
rm(path.join(props.name, "tsconfig.app.json")),
|
|
205
|
+
rm(path.join(props.name, "tsconfig.node.json")),
|
|
206
|
+
fs.writeFile(path.join(props.name, "tsconfig.json"), JSON.stringify({
|
|
207
|
+
extends: props.extends,
|
|
208
|
+
compilerOptions: {
|
|
209
|
+
baseUrl: ".",
|
|
210
|
+
paths: {
|
|
211
|
+
"@/*": ["./src/*"],
|
|
212
|
+
},
|
|
213
|
+
types: ["@cloudflare/workers-types"],
|
|
214
|
+
allowImportingTsExtensions: true,
|
|
215
|
+
jsx: "react-jsx",
|
|
216
|
+
},
|
|
217
|
+
include: [
|
|
218
|
+
"vite/*.ts",
|
|
219
|
+
"src/**/*.ts",
|
|
220
|
+
"src/**/*.tsx",
|
|
221
|
+
"src/env.d.ts",
|
|
222
|
+
],
|
|
223
|
+
references: props.references?.map((path) => ({ path })),
|
|
224
|
+
}, null, 2)),
|
|
225
|
+
]);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Context } from "../context";
|
|
2
|
+
import { Resource } from "../resource";
|
|
3
|
+
export type InstallDependencies = Resource<"project::InstallDependencies">;
|
|
4
|
+
export declare const InstallDependencies: ((this: Context<InstallDependencies>, id: string, { cwd, dependencies, devDependencies, }: {
|
|
5
|
+
cwd: string;
|
|
6
|
+
dependencies?: Record<string, string>;
|
|
7
|
+
devDependencies?: Record<string, string>;
|
|
8
|
+
}) => Promise<InstallDependencies>) | (((this: any, id: string, props?: {
|
|
9
|
+
cwd: string;
|
|
10
|
+
dependencies?: Record<string, string>;
|
|
11
|
+
devDependencies?: Record<string, string>;
|
|
12
|
+
} | undefined) => never) & (new (_: never) => never));
|
|
13
|
+
export declare function fixedDependencies(dependencies?: Record<string, string>): {
|
|
14
|
+
[k: string]: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function installDependencies(cwd: string, dependencies: Record<string, string> | undefined, ...args: string[]): Promise<void>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { exec } from "child_process";
|
|
2
|
+
import { promisify } from "util";
|
|
3
|
+
import { Resource } from "../resource";
|
|
4
|
+
const execAsync = promisify(exec);
|
|
5
|
+
export const InstallDependencies = Resource("project::InstallDependencies", {
|
|
6
|
+
alwaysUpdate: true,
|
|
7
|
+
}, async function (id, { cwd, dependencies, devDependencies, }) {
|
|
8
|
+
if (this.phase === "delete") {
|
|
9
|
+
return this.destroy();
|
|
10
|
+
}
|
|
11
|
+
await installDependencies(cwd, dependencies);
|
|
12
|
+
await installDependencies(cwd, devDependencies, "-D");
|
|
13
|
+
await execAsync("bun install", { cwd });
|
|
14
|
+
return this({});
|
|
15
|
+
});
|
|
16
|
+
function isInstallableVersion(version) {
|
|
17
|
+
// TODO: file:// ?
|
|
18
|
+
return !version.startsWith("workspace:");
|
|
19
|
+
}
|
|
20
|
+
export function fixedDependencies(dependencies) {
|
|
21
|
+
if (!dependencies)
|
|
22
|
+
return {};
|
|
23
|
+
return Object.fromEntries(Object.entries(dependencies).filter(([, value]) => !isInstallableVersion(value)));
|
|
24
|
+
}
|
|
25
|
+
export async function installDependencies(cwd, dependencies, ...args) {
|
|
26
|
+
if (!dependencies)
|
|
27
|
+
return;
|
|
28
|
+
const deps = Object.entries(dependencies)
|
|
29
|
+
.filter(([, value]) => isInstallableVersion(value))
|
|
30
|
+
.map(([pkg, version]) => `${pkg}@${version}`)
|
|
31
|
+
.join(" ");
|
|
32
|
+
const cmd = `bun add ${args.join(" ")} ${deps}`;
|
|
33
|
+
console.log(cmd);
|
|
34
|
+
await execAsync(cmd, { cwd });
|
|
35
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image that can be themed for light/dark mode
|
|
3
|
+
*/
|
|
4
|
+
export interface ThemeableImage {
|
|
5
|
+
/**
|
|
6
|
+
* Image source URL
|
|
7
|
+
*/
|
|
8
|
+
src?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Image alt text
|
|
11
|
+
*/
|
|
12
|
+
alt?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Light theme image URL
|
|
15
|
+
*/
|
|
16
|
+
light?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Dark theme image URL
|
|
19
|
+
*/
|
|
20
|
+
dark?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Hero action button configuration
|
|
24
|
+
*/
|
|
25
|
+
export interface HeroAction {
|
|
26
|
+
/**
|
|
27
|
+
* Color theme of the button
|
|
28
|
+
* @default "brand"
|
|
29
|
+
*/
|
|
30
|
+
theme?: "brand" | "alt";
|
|
31
|
+
/**
|
|
32
|
+
* Label of the button
|
|
33
|
+
*/
|
|
34
|
+
text: string;
|
|
35
|
+
/**
|
|
36
|
+
* Destination link of the button
|
|
37
|
+
*/
|
|
38
|
+
link: string;
|
|
39
|
+
/**
|
|
40
|
+
* Link target attribute
|
|
41
|
+
*/
|
|
42
|
+
target?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Link rel attribute
|
|
45
|
+
*/
|
|
46
|
+
rel?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Hero section configuration
|
|
50
|
+
*/
|
|
51
|
+
export interface Hero {
|
|
52
|
+
/**
|
|
53
|
+
* The string shown top of text. Comes with brand color
|
|
54
|
+
* and expected to be short, such as product name.
|
|
55
|
+
*/
|
|
56
|
+
name?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The main text for the hero section. This will be defined
|
|
59
|
+
* as h1 tag.
|
|
60
|
+
*/
|
|
61
|
+
text: string;
|
|
62
|
+
/**
|
|
63
|
+
* Tagline displayed below text
|
|
64
|
+
*/
|
|
65
|
+
tagline?: string;
|
|
66
|
+
/**
|
|
67
|
+
* The image displayed next to the text and tagline area
|
|
68
|
+
*/
|
|
69
|
+
image?: string | ThemeableImage;
|
|
70
|
+
/**
|
|
71
|
+
* Action buttons to display in home hero section
|
|
72
|
+
*/
|
|
73
|
+
actions?: HeroAction[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Feature item configuration
|
|
77
|
+
*/
|
|
78
|
+
export interface Feature {
|
|
79
|
+
/**
|
|
80
|
+
* Show icon on each feature box
|
|
81
|
+
*/
|
|
82
|
+
icon?: string | ThemeableImage;
|
|
83
|
+
/**
|
|
84
|
+
* Title of the feature
|
|
85
|
+
*/
|
|
86
|
+
title: string;
|
|
87
|
+
/**
|
|
88
|
+
* Details of the feature
|
|
89
|
+
*/
|
|
90
|
+
details: string;
|
|
91
|
+
/**
|
|
92
|
+
* Link when clicked on feature component
|
|
93
|
+
*/
|
|
94
|
+
link?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Link text to be shown inside feature component
|
|
97
|
+
*/
|
|
98
|
+
linkText?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Link rel attribute
|
|
101
|
+
*/
|
|
102
|
+
rel?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Link target attribute
|
|
105
|
+
*/
|
|
106
|
+
target?: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* VitePress home page configuration
|
|
110
|
+
*/
|
|
111
|
+
export interface HomePage {
|
|
112
|
+
/**
|
|
113
|
+
* Use home page layout
|
|
114
|
+
*/
|
|
115
|
+
layout: "home";
|
|
116
|
+
/**
|
|
117
|
+
* Hero section configuration
|
|
118
|
+
*/
|
|
119
|
+
hero?: Hero;
|
|
120
|
+
/**
|
|
121
|
+
* Features section configuration
|
|
122
|
+
*/
|
|
123
|
+
features?: Feature[];
|
|
124
|
+
/**
|
|
125
|
+
* Whether to apply default markdown styles
|
|
126
|
+
* @default true
|
|
127
|
+
*/
|
|
128
|
+
markdownStyles?: boolean;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Parse YAML frontmatter to home page config
|
|
132
|
+
*/
|
|
133
|
+
export declare function parseHomePage(content: string): HomePage;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import yaml from "yaml";
|
|
2
|
+
/**
|
|
3
|
+
* Parse YAML frontmatter to home page config
|
|
4
|
+
*/
|
|
5
|
+
export function parseHomePage(content) {
|
|
6
|
+
const match = content.match(/^---\n([\s\S]*?)\n---/);
|
|
7
|
+
if (!match) {
|
|
8
|
+
throw new Error("Invalid frontmatter format");
|
|
9
|
+
}
|
|
10
|
+
return yaml.parse(match[1]);
|
|
11
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { DefaultTheme, ThemeOptions } from "vitepress";
|
|
2
|
+
import type { Context } from "../context";
|
|
3
|
+
import { Resource } from "../resource";
|
|
4
|
+
import type { HomePage } from "./home-page";
|
|
5
|
+
export interface VitePressProjectProps {
|
|
6
|
+
/**
|
|
7
|
+
* The name/path of the project
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* The title of the documentation site
|
|
12
|
+
*/
|
|
13
|
+
title?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The description of the documentation site
|
|
16
|
+
*/
|
|
17
|
+
description?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether to use TypeScript for config and theme files
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
typescript?: boolean;
|
|
23
|
+
tsconfig?: {
|
|
24
|
+
extends?: string;
|
|
25
|
+
references?: string[];
|
|
26
|
+
compilerOptions?: Record<string, any>;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Force overwrite the project config files during the update phase
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
overwrite?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* The dependencies to install
|
|
35
|
+
*/
|
|
36
|
+
dependencies?: Record<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* The dev dependencies to install
|
|
39
|
+
*/
|
|
40
|
+
devDependencies?: Record<string, string>;
|
|
41
|
+
/**
|
|
42
|
+
* The theme options to use
|
|
43
|
+
*/
|
|
44
|
+
theme?: ThemeOptions;
|
|
45
|
+
/**
|
|
46
|
+
* The theme config to use
|
|
47
|
+
*/
|
|
48
|
+
themeConfig: DefaultTheme.Config;
|
|
49
|
+
/**
|
|
50
|
+
* The home page configuration
|
|
51
|
+
*/
|
|
52
|
+
home: HomePage;
|
|
53
|
+
}
|
|
54
|
+
export interface VitePressProject extends VitePressProjectProps, Resource {
|
|
55
|
+
/**
|
|
56
|
+
* The name/path of the project
|
|
57
|
+
*/
|
|
58
|
+
name: string;
|
|
59
|
+
}
|
|
60
|
+
export declare const VitePressProject: ((this: Context<VitePressProject>, id: string, props: VitePressProjectProps) => Promise<VitePressProject>) | (((this: any, id: string, props?: VitePressProjectProps | undefined) => never) & (new (_: never) => never));
|