alchemy 0.2.2 → 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 +1 -1
- 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 +1 -1
- 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 +16 -9
- 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/state.ts +9 -2
- package/src/util/serde.ts +13 -4
- 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 -90
- package/lib/project/vite.js +0 -228
- package/src/project/vite.ts +0 -406
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import yaml from "yaml";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Image that can be themed for light/dark mode
|
|
5
|
+
*/
|
|
6
|
+
export interface ThemeableImage {
|
|
7
|
+
/**
|
|
8
|
+
* Image source URL
|
|
9
|
+
*/
|
|
10
|
+
src?: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Image alt text
|
|
14
|
+
*/
|
|
15
|
+
alt?: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Light theme image URL
|
|
19
|
+
*/
|
|
20
|
+
light?: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Dark theme image URL
|
|
24
|
+
*/
|
|
25
|
+
dark?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Hero action button configuration
|
|
30
|
+
*/
|
|
31
|
+
export interface HeroAction {
|
|
32
|
+
/**
|
|
33
|
+
* Color theme of the button
|
|
34
|
+
* @default "brand"
|
|
35
|
+
*/
|
|
36
|
+
theme?: "brand" | "alt";
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Label of the button
|
|
40
|
+
*/
|
|
41
|
+
text: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Destination link of the button
|
|
45
|
+
*/
|
|
46
|
+
link: string;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Link target attribute
|
|
50
|
+
*/
|
|
51
|
+
target?: string;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Link rel attribute
|
|
55
|
+
*/
|
|
56
|
+
rel?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Hero section configuration
|
|
61
|
+
*/
|
|
62
|
+
export interface Hero {
|
|
63
|
+
/**
|
|
64
|
+
* The string shown top of text. Comes with brand color
|
|
65
|
+
* and expected to be short, such as product name.
|
|
66
|
+
*/
|
|
67
|
+
name?: string;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The main text for the hero section. This will be defined
|
|
71
|
+
* as h1 tag.
|
|
72
|
+
*/
|
|
73
|
+
text: string;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Tagline displayed below text
|
|
77
|
+
*/
|
|
78
|
+
tagline?: string;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The image displayed next to the text and tagline area
|
|
82
|
+
*/
|
|
83
|
+
image?: string | ThemeableImage;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Action buttons to display in home hero section
|
|
87
|
+
*/
|
|
88
|
+
actions?: HeroAction[];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Feature item configuration
|
|
93
|
+
*/
|
|
94
|
+
export interface Feature {
|
|
95
|
+
/**
|
|
96
|
+
* Show icon on each feature box
|
|
97
|
+
*/
|
|
98
|
+
icon?: string | ThemeableImage;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Title of the feature
|
|
102
|
+
*/
|
|
103
|
+
title: string;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Details of the feature
|
|
107
|
+
*/
|
|
108
|
+
details: string;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Link when clicked on feature component
|
|
112
|
+
*/
|
|
113
|
+
link?: string;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Link text to be shown inside feature component
|
|
117
|
+
*/
|
|
118
|
+
linkText?: string;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Link rel attribute
|
|
122
|
+
*/
|
|
123
|
+
rel?: string;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Link target attribute
|
|
127
|
+
*/
|
|
128
|
+
target?: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* VitePress home page configuration
|
|
133
|
+
*/
|
|
134
|
+
export interface HomePage {
|
|
135
|
+
/**
|
|
136
|
+
* Use home page layout
|
|
137
|
+
*/
|
|
138
|
+
layout: "home";
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Hero section configuration
|
|
142
|
+
*/
|
|
143
|
+
hero?: Hero;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Features section configuration
|
|
147
|
+
*/
|
|
148
|
+
features?: Feature[];
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Whether to apply default markdown styles
|
|
152
|
+
* @default true
|
|
153
|
+
*/
|
|
154
|
+
markdownStyles?: boolean;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Parse YAML frontmatter to home page config
|
|
159
|
+
*/
|
|
160
|
+
export function parseHomePage(content: string): HomePage {
|
|
161
|
+
const match = content.match(/^---\n([\s\S]*?)\n---/);
|
|
162
|
+
if (!match) {
|
|
163
|
+
throw new Error("Invalid frontmatter format");
|
|
164
|
+
}
|
|
165
|
+
return yaml.parse(match[1]) as HomePage;
|
|
166
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Docs Index
|
|
2
|
+
|
|
3
|
+
```ts twoslash
|
|
4
|
+
// @noErrors
|
|
5
|
+
import path from "path";
|
|
6
|
+
|
|
7
|
+
import alchemy, { Resource, Context } from "alchemy";
|
|
8
|
+
|
|
9
|
+
import { Zone } from "alchemy/cloudflare";
|
|
10
|
+
|
|
11
|
+
type alchemy = any;
|
|
12
|
+
|
|
13
|
+
await using app = alchemy("github:alchemy", {
|
|
14
|
+
// ^?
|
|
15
|
+
stage: "prod",
|
|
16
|
+
phase: process.argv.includes("--destroy") ? "destroy" : "up",
|
|
17
|
+
// pass the password in (you can get it from anywhere, e.g. stdin)
|
|
18
|
+
password: process.env.SECRET_PASSPHRASE,
|
|
19
|
+
quiet: process.argv.includes("--verbose") ? false : true,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export interface Product {}
|
|
23
|
+
|
|
24
|
+
export const Product = Resource(
|
|
25
|
+
"stripe::Product",
|
|
26
|
+
async function (
|
|
27
|
+
this: Context<any>,
|
|
28
|
+
id: string,
|
|
29
|
+
props: any,
|
|
30
|
+
): Promise<Product> {
|
|
31
|
+
this.
|
|
32
|
+
// ^|
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```ts twoslash
|
|
38
|
+
// @noErrors
|
|
39
|
+
// @esModuleInterop
|
|
40
|
+
import express from "express"
|
|
41
|
+
const app = {
|
|
42
|
+
get(path: string, fn: (req: any, res: { send(): void }))
|
|
43
|
+
}
|
|
44
|
+
app.get("/", function (req, res) {
|
|
45
|
+
res.sen
|
|
46
|
+
// ^|
|
|
47
|
+
})
|
|
48
|
+
app.listen(3000)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```ts twoslash
|
|
52
|
+
// @module: esnext
|
|
53
|
+
// @filename: maths.ts
|
|
54
|
+
export function absolute(num: number) {
|
|
55
|
+
if (num < 0) return num * -1;
|
|
56
|
+
return num;
|
|
57
|
+
}
|
|
58
|
+
// @filename: index.ts
|
|
59
|
+
import { absolute } from "./maths";
|
|
60
|
+
const value = absolute(-1);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```ts twoslash
|
|
64
|
+
// @module: esnext
|
|
65
|
+
// @filename: maths.ts
|
|
66
|
+
export function absolute(num: number) {
|
|
67
|
+
if (num < 0) return num * -1;
|
|
68
|
+
return num;
|
|
69
|
+
}
|
|
70
|
+
// @filename: index.ts
|
|
71
|
+
// ---cut---
|
|
72
|
+
import { absolute } from "./maths";
|
|
73
|
+
const value = absolute(-1);
|
|
74
|
+
// ^?
|
|
75
|
+
```
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { exec } from "child_process";
|
|
2
|
+
import fs from "fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { promisify } from "util";
|
|
5
|
+
import type { DefaultTheme, ThemeOptions } from "vitepress";
|
|
6
|
+
import yaml from "yaml";
|
|
7
|
+
import type { Context } from "../context";
|
|
8
|
+
import { Folder, JsonFile, TextFile, TypeScriptFile } from "../fs";
|
|
9
|
+
import { Resource } from "../resource";
|
|
10
|
+
import { InstallDependencies, fixedDependencies } from "./dependencies";
|
|
11
|
+
import type { HomePage } from "./home-page";
|
|
12
|
+
|
|
13
|
+
const execAsync = promisify(exec);
|
|
14
|
+
|
|
15
|
+
export interface VitePressProjectProps {
|
|
16
|
+
/**
|
|
17
|
+
* The name/path of the project
|
|
18
|
+
*/
|
|
19
|
+
name: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The title of the documentation site
|
|
23
|
+
*/
|
|
24
|
+
title?: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The description of the documentation site
|
|
28
|
+
*/
|
|
29
|
+
description?: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Whether to use TypeScript for config and theme files
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
typescript?: boolean;
|
|
36
|
+
|
|
37
|
+
tsconfig?: {
|
|
38
|
+
extends?: string;
|
|
39
|
+
references?: string[];
|
|
40
|
+
compilerOptions?: Record<string, any>;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Force overwrite the project config files during the update phase
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
overwrite?: boolean;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The dependencies to install
|
|
51
|
+
*/
|
|
52
|
+
dependencies?: Record<string, string>;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The dev dependencies to install
|
|
56
|
+
*/
|
|
57
|
+
devDependencies?: Record<string, string>;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The theme options to use
|
|
61
|
+
*/
|
|
62
|
+
theme?: ThemeOptions;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The theme config to use
|
|
66
|
+
*/
|
|
67
|
+
themeConfig: DefaultTheme.Config;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* The home page configuration
|
|
71
|
+
*/
|
|
72
|
+
home: HomePage;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface VitePressProject extends VitePressProjectProps, Resource {
|
|
76
|
+
/**
|
|
77
|
+
* The name/path of the project
|
|
78
|
+
*/
|
|
79
|
+
name: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export const VitePressProject = Resource(
|
|
83
|
+
"project::VitePressProject",
|
|
84
|
+
{
|
|
85
|
+
alwaysUpdate: true,
|
|
86
|
+
},
|
|
87
|
+
async function (
|
|
88
|
+
this: Context<VitePressProject>,
|
|
89
|
+
id: string,
|
|
90
|
+
props: VitePressProjectProps,
|
|
91
|
+
): Promise<VitePressProject> {
|
|
92
|
+
if (this.phase === "delete") {
|
|
93
|
+
try {
|
|
94
|
+
if (await fs.exists(props.name)) {
|
|
95
|
+
// Delete the entire project directory
|
|
96
|
+
await execAsync(`rm -rf ${props.name}`);
|
|
97
|
+
}
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error(`Error deleting VitePress project ${id}:`, error);
|
|
100
|
+
}
|
|
101
|
+
return this.destroy();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const cwd = (await Folder(props.name)).path;
|
|
105
|
+
|
|
106
|
+
// Initialize package.json
|
|
107
|
+
await JsonFile(path.join(cwd, "package.json"), {
|
|
108
|
+
name: props.name,
|
|
109
|
+
scripts: {
|
|
110
|
+
"docs:gen": "bun alchemy.run.ts",
|
|
111
|
+
"docs:dev": "vitepress dev",
|
|
112
|
+
"docs:build": "vitepress build",
|
|
113
|
+
"docs:preview": "vitepress preview",
|
|
114
|
+
},
|
|
115
|
+
dependencies: fixedDependencies(props.dependencies || {}),
|
|
116
|
+
devDependencies: fixedDependencies(props.devDependencies || {}),
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
await InstallDependencies("dependencies", {
|
|
120
|
+
cwd,
|
|
121
|
+
dependencies: props.dependencies,
|
|
122
|
+
devDependencies: {
|
|
123
|
+
vue: "latest",
|
|
124
|
+
vitepress: "latest",
|
|
125
|
+
"@shikijs/vitepress-twoslash": "latest",
|
|
126
|
+
"markdown-it-footnote": "latest",
|
|
127
|
+
...props.devDependencies,
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
// Create .vitepress directory and config
|
|
131
|
+
await Folder(path.join(cwd, ".vitepress"));
|
|
132
|
+
await Folder(path.join(cwd, ".vitepress", "theme"));
|
|
133
|
+
|
|
134
|
+
await Promise.all([
|
|
135
|
+
TextFile(path.join(cwd, ".gitignore"), `.vitepress/cache\n`),
|
|
136
|
+
JsonFile(path.join(cwd, "tsconfig.json"), {
|
|
137
|
+
extends: props.tsconfig?.extends,
|
|
138
|
+
references: props.tsconfig?.references?.map((path) => ({ path })),
|
|
139
|
+
compilerOptions: props.tsconfig?.compilerOptions,
|
|
140
|
+
}),
|
|
141
|
+
TextFile(
|
|
142
|
+
path.join(cwd, "index.md"),
|
|
143
|
+
`---\n${yaml.stringify(props.home)}---\n`,
|
|
144
|
+
),
|
|
145
|
+
TypeScriptFile(
|
|
146
|
+
path.join(cwd, "alchemy.run.ts"),
|
|
147
|
+
`import alchemy from "alchemy";
|
|
148
|
+
import { Folder } from "alchemy/fs";
|
|
149
|
+
import { Document } from "alchemy/docs";
|
|
150
|
+
import path from "path";
|
|
151
|
+
|
|
152
|
+
await using _ = alchemy("alchemy.run", {
|
|
153
|
+
stage: "prod",
|
|
154
|
+
phase: process.argv.includes("--destroy") ? "destroy" : "up",
|
|
155
|
+
password: process.env.SECRET_PASSPHRASE,
|
|
156
|
+
quiet: !process.argv.includes("--verbose"),
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const docs = await Folder(path.join("alchemy.run", "docs"));
|
|
160
|
+
|
|
161
|
+
await Document("home.md", {
|
|
162
|
+
path: path.join(docs.path, "home.md"),
|
|
163
|
+
prompt: await alchemy\`Generate a landing page.\`,
|
|
164
|
+
});
|
|
165
|
+
`,
|
|
166
|
+
),
|
|
167
|
+
TypeScriptFile(
|
|
168
|
+
path.join(cwd, ".vitepress", "theme", "index.ts"),
|
|
169
|
+
`import TwoslashFloatingVue from "@shikijs/vitepress-twoslash/client";
|
|
170
|
+
import "@shikijs/vitepress-twoslash/style.css";
|
|
171
|
+
import type { Theme as ThemeConfig } from "vitepress";
|
|
172
|
+
import Theme from "vitepress/theme-without-fonts";
|
|
173
|
+
import "./style.css";
|
|
174
|
+
|
|
175
|
+
export default {
|
|
176
|
+
extends: Theme,
|
|
177
|
+
enhanceApp(ctx) {
|
|
178
|
+
ctx.app.use(TwoslashFloatingVue);
|
|
179
|
+
},
|
|
180
|
+
} satisfies ThemeConfig;
|
|
181
|
+
`,
|
|
182
|
+
),
|
|
183
|
+
TextFile(
|
|
184
|
+
path.join(cwd, ".vitepress", "theme", "style.css"),
|
|
185
|
+
`/**
|
|
186
|
+
* Customize default theme styling by overriding CSS variables:
|
|
187
|
+
* https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Colors
|
|
192
|
+
*
|
|
193
|
+
* Each colors have exact same color scale system with 3 levels of solid
|
|
194
|
+
* colors with different brightness, and 1 soft color.
|
|
195
|
+
*
|
|
196
|
+
* - \`XXX-1\`: The most solid color used mainly for colored text. It must
|
|
197
|
+
* satisfy the contrast ratio against when used on top of \`XXX-soft\`.
|
|
198
|
+
*
|
|
199
|
+
* - \`XXX-2\`: The color used mainly for hover state of the button.
|
|
200
|
+
*
|
|
201
|
+
* - \`XXX-3\`: The color for solid background, such as bg color of the button.
|
|
202
|
+
* It must satisfy the contrast ratio with pure white (#ffffff) text on
|
|
203
|
+
* top of it.
|
|
204
|
+
*
|
|
205
|
+
* - \`XXX-soft\`: The color used for subtle background such as custom container
|
|
206
|
+
* or badges. It must satisfy the contrast ratio when putting \`XXX-1\` colors
|
|
207
|
+
* on top of it.
|
|
208
|
+
*
|
|
209
|
+
* The soft color must be semi transparent alpha channel. This is crucial
|
|
210
|
+
* because it allows adding multiple "soft" colors on top of each other
|
|
211
|
+
* to create a accent, such as when having inline code block inside
|
|
212
|
+
* custom containers.
|
|
213
|
+
*
|
|
214
|
+
* - \`default\`: The color used purely for subtle indication without any
|
|
215
|
+
* special meanings attached to it such as bg color for menu hover state.
|
|
216
|
+
*
|
|
217
|
+
* - \`brand\`: Used for primary brand colors, such as link text, button with
|
|
218
|
+
* brand theme, etc.
|
|
219
|
+
*
|
|
220
|
+
* - \`tip\`: Used to indicate useful information. The default theme uses the
|
|
221
|
+
* brand color for this by default.
|
|
222
|
+
*
|
|
223
|
+
* - \`warning\`: Used to indicate warning to the users. Used in custom
|
|
224
|
+
* container, badges, etc.
|
|
225
|
+
*
|
|
226
|
+
* - \`danger\`: Used to show error, or dangerous message to the users. Used
|
|
227
|
+
* in custom container, badges, etc.
|
|
228
|
+
* -------------------------------------------------------------------------- */
|
|
229
|
+
|
|
230
|
+
:root {
|
|
231
|
+
--vp-c-default-1: var(--vp-c-gray-1);
|
|
232
|
+
--vp-c-default-2: var(--vp-c-gray-2);
|
|
233
|
+
--vp-c-default-3: var(--vp-c-gray-3);
|
|
234
|
+
--vp-c-default-soft: var(--vp-c-gray-soft);
|
|
235
|
+
|
|
236
|
+
--vp-c-brand-1: var(--vp-c-indigo-1);
|
|
237
|
+
--vp-c-brand-2: var(--vp-c-indigo-2);
|
|
238
|
+
--vp-c-brand-3: var(--vp-c-indigo-3);
|
|
239
|
+
--vp-c-brand-soft: var(--vp-c-indigo-soft);
|
|
240
|
+
|
|
241
|
+
--vp-c-tip-1: var(--vp-c-brand-1);
|
|
242
|
+
--vp-c-tip-2: var(--vp-c-brand-2);
|
|
243
|
+
--vp-c-tip-3: var(--vp-c-brand-3);
|
|
244
|
+
--vp-c-tip-soft: var(--vp-c-brand-soft);
|
|
245
|
+
|
|
246
|
+
--vp-c-warning-1: var(--vp-c-yellow-1);
|
|
247
|
+
--vp-c-warning-2: var(--vp-c-yellow-2);
|
|
248
|
+
--vp-c-warning-3: var(--vp-c-yellow-3);
|
|
249
|
+
--vp-c-warning-soft: var(--vp-c-yellow-soft);
|
|
250
|
+
|
|
251
|
+
--vp-c-danger-1: var(--vp-c-red-1);
|
|
252
|
+
--vp-c-danger-2: var(--vp-c-red-2);
|
|
253
|
+
--vp-c-danger-3: var(--vp-c-red-3);
|
|
254
|
+
--vp-c-danger-soft: var(--vp-c-red-soft);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Component: Button
|
|
259
|
+
* -------------------------------------------------------------------------- */
|
|
260
|
+
|
|
261
|
+
:root {
|
|
262
|
+
--vp-button-brand-border: transparent;
|
|
263
|
+
--vp-button-brand-text: var(--vp-c-white);
|
|
264
|
+
--vp-button-brand-bg: var(--vp-c-brand-3);
|
|
265
|
+
--vp-button-brand-hover-border: transparent;
|
|
266
|
+
--vp-button-brand-hover-text: var(--vp-c-white);
|
|
267
|
+
--vp-button-brand-hover-bg: var(--vp-c-brand-2);
|
|
268
|
+
--vp-button-brand-active-border: transparent;
|
|
269
|
+
--vp-button-brand-active-text: var(--vp-c-white);
|
|
270
|
+
--vp-button-brand-active-bg: var(--vp-c-brand-1);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Component: Home
|
|
275
|
+
* -------------------------------------------------------------------------- */
|
|
276
|
+
|
|
277
|
+
:root {
|
|
278
|
+
--vp-home-hero-name-color: transparent;
|
|
279
|
+
--vp-home-hero-name-background: -webkit-linear-gradient(
|
|
280
|
+
120deg,
|
|
281
|
+
#bd34fe 30%,
|
|
282
|
+
#41d1ff
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
--vp-home-hero-image-background-image: linear-gradient(
|
|
286
|
+
-45deg,
|
|
287
|
+
#bd34fe 50%,
|
|
288
|
+
#47caff 50%
|
|
289
|
+
);
|
|
290
|
+
--vp-home-hero-image-filter: blur(44px);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
@media (min-width: 640px) {
|
|
294
|
+
:root {
|
|
295
|
+
--vp-home-hero-image-filter: blur(56px);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
@media (min-width: 960px) {
|
|
300
|
+
:root {
|
|
301
|
+
--vp-home-hero-image-filter: blur(68px);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Component: Custom Block
|
|
307
|
+
* -------------------------------------------------------------------------- */
|
|
308
|
+
|
|
309
|
+
:root {
|
|
310
|
+
--vp-custom-block-tip-border: transparent;
|
|
311
|
+
--vp-custom-block-tip-text: var(--vp-c-text-1);
|
|
312
|
+
--vp-custom-block-tip-bg: var(--vp-c-brand-soft);
|
|
313
|
+
--vp-custom-block-tip-code-bg: var(--vp-c-brand-soft);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Component: Algolia
|
|
318
|
+
* -------------------------------------------------------------------------- */
|
|
319
|
+
|
|
320
|
+
.DocSearch {
|
|
321
|
+
--docsearch-primary-color: var(--vp-c-brand-1) !important;
|
|
322
|
+
}
|
|
323
|
+
`,
|
|
324
|
+
),
|
|
325
|
+
TypeScriptFile(
|
|
326
|
+
path.join(cwd, ".vitepress", "config.mts"),
|
|
327
|
+
`import { transformerTwoslash } from "@shikijs/vitepress-twoslash";
|
|
328
|
+
import footnotePlugin from "markdown-it-footnote";
|
|
329
|
+
import { defineConfig } from "vitepress";
|
|
330
|
+
|
|
331
|
+
// https://vitepress.dev/reference/site-config
|
|
332
|
+
export default defineConfig({
|
|
333
|
+
title: ${JSON.stringify(props.title || "Alchemy")},
|
|
334
|
+
description: ${JSON.stringify(props.description || "Alchemy Docs")},
|
|
335
|
+
markdown: {
|
|
336
|
+
// @ts-ignore
|
|
337
|
+
codeTransformers: [transformerTwoslash()],
|
|
338
|
+
theme: ${JSON.stringify(
|
|
339
|
+
props.theme ?? {
|
|
340
|
+
light: "light-plus",
|
|
341
|
+
dark: "dark-plus",
|
|
342
|
+
},
|
|
343
|
+
)},
|
|
344
|
+
config: (md) => md.use(footnotePlugin),
|
|
345
|
+
},
|
|
346
|
+
// https://vitepress.dev/reference/default-theme-config
|
|
347
|
+
themeConfig: ${JSON.stringify({
|
|
348
|
+
...props.themeConfig,
|
|
349
|
+
search: props.themeConfig.search ?? { provider: "local" },
|
|
350
|
+
nav: props.themeConfig.nav ?? [{ text: "Home", link: "/" }],
|
|
351
|
+
sidebar: props.themeConfig.sidebar ?? [],
|
|
352
|
+
socialLinks: props.themeConfig.socialLinks ?? [],
|
|
353
|
+
})}
|
|
354
|
+
});
|
|
355
|
+
`,
|
|
356
|
+
),
|
|
357
|
+
]);
|
|
358
|
+
|
|
359
|
+
return this(props);
|
|
360
|
+
},
|
|
361
|
+
);
|
package/lib/project/vite.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { Context } from "../context";
|
|
2
|
-
import { Resource } from "../resource";
|
|
3
|
-
type ViteTemplate = "vanilla" | "vanilla-ts" | "vue" | "vue-ts" | "react" | "react-ts" | "react-swc" | "react-swc-ts" | "preact" | "preact-ts" | "lit" | "lit-ts" | "svelte" | "svelte-ts" | "solid" | "solid-ts" | "qwik" | "qwik-ts";
|
|
4
|
-
export interface ViteProjectProps {
|
|
5
|
-
/**
|
|
6
|
-
* The name/path of the project
|
|
7
|
-
*/
|
|
8
|
-
name: string;
|
|
9
|
-
/**
|
|
10
|
-
* The Vite template to use
|
|
11
|
-
*/
|
|
12
|
-
template: ViteTemplate;
|
|
13
|
-
/**
|
|
14
|
-
* The extends to add to the tsconfig.json file
|
|
15
|
-
*/
|
|
16
|
-
extends?: string;
|
|
17
|
-
/**
|
|
18
|
-
* The references to add to the tsconfig.json file
|
|
19
|
-
*/
|
|
20
|
-
references?: string[];
|
|
21
|
-
/**
|
|
22
|
-
* Add Tailwind CSS to the project
|
|
23
|
-
* @default false
|
|
24
|
-
*/
|
|
25
|
-
tailwind?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Add Tanstack Router to the project
|
|
28
|
-
* @default false
|
|
29
|
-
*/
|
|
30
|
-
tanstack?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Add Shadcn UI to the project
|
|
33
|
-
* @default false
|
|
34
|
-
*/
|
|
35
|
-
shadcn?: {
|
|
36
|
-
/**
|
|
37
|
-
* The base color to use
|
|
38
|
-
* @default "neutral"
|
|
39
|
-
*/
|
|
40
|
-
baseColor?: "neutral" | "gray" | "zinc" | "stone" | "slate";
|
|
41
|
-
/**
|
|
42
|
-
* Use default configuration
|
|
43
|
-
* @default false
|
|
44
|
-
*/
|
|
45
|
-
defaults?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* Force overwrite of existing configuration
|
|
48
|
-
* @default false
|
|
49
|
-
*/
|
|
50
|
-
force?: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* The working directory
|
|
53
|
-
* @default current directory
|
|
54
|
-
*/
|
|
55
|
-
cwd?: string;
|
|
56
|
-
/**
|
|
57
|
-
* Mute output
|
|
58
|
-
* @default false
|
|
59
|
-
*/
|
|
60
|
-
silent?: boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Use the src directory when creating a new project
|
|
63
|
-
* @default false
|
|
64
|
-
*/
|
|
65
|
-
srcDir?: boolean;
|
|
66
|
-
/**
|
|
67
|
-
* Use css variables for theming
|
|
68
|
-
* @default true
|
|
69
|
-
*/
|
|
70
|
-
cssVariables?: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* The components to add
|
|
73
|
-
*/
|
|
74
|
-
components?: string[];
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* Force overwrite the project config files during the update phase
|
|
78
|
-
*
|
|
79
|
-
* @default false
|
|
80
|
-
*/
|
|
81
|
-
overwrite?: boolean;
|
|
82
|
-
}
|
|
83
|
-
export interface ViteProject extends ViteProjectProps, Resource {
|
|
84
|
-
/**
|
|
85
|
-
* The name/path of the project
|
|
86
|
-
*/
|
|
87
|
-
name: string;
|
|
88
|
-
}
|
|
89
|
-
export declare const ViteProject: ((this: Context<ViteProject>, id: string, props: ViteProjectProps) => Promise<ViteProject>) | (((this: any, id: string, props: ViteProjectProps) => never) & (new (_: never) => never));
|
|
90
|
-
export {};
|