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.
Files changed (74) hide show
  1. package/lib/alchemy.d.ts +1 -0
  2. package/lib/alchemy.js +84 -8
  3. package/lib/apply.d.ts +1 -1
  4. package/lib/apply.js +13 -10
  5. package/lib/aws/bucket.d.ts +1 -1
  6. package/lib/aws/function.d.ts +1 -1
  7. package/lib/aws/oidc/oidc-provider.d.ts +1 -1
  8. package/lib/aws/policy-attachment.d.ts +1 -1
  9. package/lib/aws/policy.d.ts +1 -1
  10. package/lib/aws/queue.d.ts +1 -1
  11. package/lib/aws/role.d.ts +1 -1
  12. package/lib/aws/ses.d.ts +1 -1
  13. package/lib/aws/table.d.ts +1 -1
  14. package/lib/cloudflare/bucket.d.ts +1 -1
  15. package/lib/cloudflare/kv-namespace.d.ts +1 -1
  16. package/lib/cloudflare/static-site.d.ts +1 -1
  17. package/lib/cloudflare/worker.d.ts +1 -1
  18. package/lib/cloudflare/wrangler.json.d.ts +1 -1
  19. package/lib/cloudflare/zone.d.ts +1 -1
  20. package/lib/context.d.ts +9 -4
  21. package/lib/context.js +4 -2
  22. package/lib/destroy.js +8 -7
  23. package/lib/docs/document.d.ts +123 -0
  24. package/lib/docs/document.js +67 -0
  25. package/lib/docs/index.d.ts +1 -0
  26. package/lib/docs/index.js +1 -0
  27. package/lib/esbuild/bundle.d.ts +1 -1
  28. package/lib/fs/file.d.ts +30 -3
  29. package/lib/fs/file.js +63 -3
  30. package/lib/fs/folder.d.ts +3 -3
  31. package/lib/fs/folder.js +2 -1
  32. package/lib/github/secret.d.ts +1 -1
  33. package/lib/resource.d.ts +2 -2
  34. package/lib/resource.js +4 -0
  35. package/lib/scope.d.ts +1 -1
  36. package/lib/scope.js +6 -6
  37. package/lib/shadcn/component.d.ts +1 -1
  38. package/lib/state.d.ts +1 -1
  39. package/lib/state.js +8 -1
  40. package/lib/stripe/price.d.ts +1 -1
  41. package/lib/stripe/product.d.ts +1 -1
  42. package/lib/stripe/webhook.d.ts +1 -1
  43. package/lib/util/serde.d.ts +3 -1
  44. package/lib/util/serde.js +6 -4
  45. package/lib/vite/vite.d.ts +1 -1
  46. package/lib/vitepress/dependencies.d.ts +16 -0
  47. package/lib/vitepress/dependencies.js +35 -0
  48. package/lib/vitepress/home-page.d.ts +133 -0
  49. package/lib/vitepress/home-page.js +11 -0
  50. package/lib/vitepress/index.d.ts +2 -0
  51. package/lib/vitepress/index.js +2 -0
  52. package/lib/vitepress/vitepress.d.ts +60 -0
  53. package/lib/vitepress/vitepress.js +260 -0
  54. package/package.json +16 -9
  55. package/src/alchemy.ts +105 -13
  56. package/src/apply.ts +25 -13
  57. package/src/context.ts +30 -10
  58. package/src/destroy.ts +10 -7
  59. package/src/docs/document.ts +225 -0
  60. package/src/docs/index.ts +1 -0
  61. package/src/fs/file.ts +114 -6
  62. package/src/fs/folder.ts +2 -1
  63. package/src/resource.ts +7 -2
  64. package/src/scope.ts +9 -9
  65. package/src/state.ts +9 -2
  66. package/src/util/serde.ts +13 -4
  67. package/src/vitepress/dependencies.ts +68 -0
  68. package/src/vitepress/home-page.ts +166 -0
  69. package/src/vitepress/index.md +75 -0
  70. package/src/vitepress/index.ts +2 -0
  71. package/src/vitepress/vitepress.ts +361 -0
  72. package/lib/project/vite.d.ts +0 -90
  73. package/lib/project/vite.js +0 -228
  74. package/src/project/vite.ts +0 -406
package/lib/fs/file.d.ts CHANGED
@@ -1,13 +1,40 @@
1
1
  import type { Context } from "../context";
2
2
  import { Resource } from "../resource";
3
+ declare module "../alchemy" {
4
+ interface Alchemy {
5
+ file(path: string): Promise<FileRef>;
6
+ files(paths: string[]): Promise<FileCollection>;
7
+ files(path: string, ...paths: string[]): Promise<FileCollection>;
8
+ }
9
+ }
10
+ export type FileRef = {
11
+ kind: "fs::FileRef";
12
+ path: string;
13
+ };
14
+ export declare function isFileRef(value: unknown): value is FileRef;
15
+ export type FileCollection = {
16
+ type: "fs::FileCollection";
17
+ files: {
18
+ [relativePath: string]: string;
19
+ };
20
+ };
21
+ export declare function isFileCollection(value: unknown): value is FileCollection;
3
22
  export interface File extends Resource<"fs::File"> {
4
23
  path: string;
5
24
  content: string;
6
25
  }
7
- export declare const File: ((this: Context<File>, id: string, { path: filePath, content, }: {
26
+ export declare const File: ((this: Context<File>, id: string, props: {
8
27
  path: string;
9
28
  content: string;
10
- }) => Promise<File>) | (((this: any, id: string, props: {
29
+ }) => Promise<File>) | (((this: any, id: string, props?: {
11
30
  path: string;
12
31
  content: string;
13
- }) => never) & (new (_: never) => never));
32
+ } | undefined) => never) & (new (_: never) => never));
33
+ export type JsonFile = File;
34
+ export declare function JsonFile(id: string, content: any): Promise<JsonFile>;
35
+ export type TextFile = File;
36
+ export declare function TextFile(id: string, content: string): Promise<TextFile>;
37
+ export type YamlFile = File;
38
+ export declare function YamlFile(id: string, content: any): Promise<YamlFile>;
39
+ export type TypeScriptFile = File;
40
+ export declare function TypeScriptFile(id: string, content: string): Promise<TypeScriptFile>;
package/lib/fs/file.js CHANGED
@@ -2,7 +2,35 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { Resource } from "../resource";
4
4
  import { ignore } from "../util/ignore";
5
- export const File = Resource("fs::File", async function (id, { path: filePath, content, }) {
5
+ import { alchemy } from "../alchemy";
6
+ export function isFileRef(value) {
7
+ return (typeof value === "object" &&
8
+ value !== null &&
9
+ "kind" in value &&
10
+ value.kind === "fs::FileRef");
11
+ }
12
+ export function isFileCollection(value) {
13
+ return (typeof value === "object" &&
14
+ value !== null &&
15
+ "type" in value &&
16
+ value.type === "fs::FileCollection");
17
+ }
18
+ alchemy.file = async (path) => ({
19
+ kind: "fs::FileRef",
20
+ path,
21
+ });
22
+ alchemy.files = async (...args) => {
23
+ const paths = typeof args[0] === "string" ? args : args[0];
24
+ return {
25
+ type: "fs::FileCollection",
26
+ files: Object.fromEntries(await Promise.all(paths.map(async (path) => [
27
+ path,
28
+ await fs.promises.readFile(path, "utf-8"),
29
+ ]))),
30
+ };
31
+ };
32
+ export const File = Resource("fs::File", async function (id, props) {
33
+ const filePath = props?.path ?? id;
6
34
  if (this.phase === "delete") {
7
35
  await ignore("ENOENT", async () => fs.promises.unlink(filePath));
8
36
  return this.destroy();
@@ -11,10 +39,42 @@ export const File = Resource("fs::File", async function (id, { path: filePath, c
11
39
  await fs.promises.mkdir(path.dirname(filePath), {
12
40
  recursive: true,
13
41
  });
14
- await fs.promises.writeFile(filePath, content);
42
+ await fs.promises.writeFile(filePath, props.content);
15
43
  }
16
44
  return this({
17
45
  path: filePath,
18
- content,
46
+ content: props.content,
19
47
  });
20
48
  });
49
+ export function JsonFile(id, content) {
50
+ return File(id, {
51
+ path: id,
52
+ content: JSON.stringify(content, null, 2),
53
+ });
54
+ }
55
+ export function TextFile(id, content) {
56
+ return File(id, {
57
+ path: id,
58
+ content,
59
+ });
60
+ }
61
+ export async function YamlFile(id, content) {
62
+ const yaml = await import("yaml");
63
+ return File(id, {
64
+ path: id,
65
+ content: yaml.stringify(content),
66
+ });
67
+ }
68
+ export async function TypeScriptFile(id, content) {
69
+ const prettier = await import("prettier");
70
+ return File(id, {
71
+ path: id,
72
+ content: await prettier.format(content, {
73
+ parser: "typescript",
74
+ editor: {
75
+ tabWidth: 2,
76
+ indentWidth: 2,
77
+ },
78
+ }),
79
+ });
80
+ }
@@ -3,8 +3,8 @@ import { Resource } from "../resource";
3
3
  export interface Folder extends Resource<"fs::Folder"> {
4
4
  path: string;
5
5
  }
6
- export declare const Folder: ((this: Context<Folder>, id: string, { path: dirPath }: {
6
+ export declare const Folder: ((this: Context<Folder>, id: string, props?: {
7
7
  path: string;
8
- }) => Promise<Folder>) | (((this: any, id: string, props: {
8
+ }) => Promise<Folder>) | (((this: any, id: string, props?: {
9
9
  path: string;
10
- }) => never) & (new (_: never) => never));
10
+ } | undefined) => never) & (new (_: never) => never));
package/lib/fs/folder.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import fs from "node:fs";
2
2
  import { Resource } from "../resource";
3
3
  import { ignore } from "../util/ignore";
4
- export const Folder = Resource("fs::Folder", async function (id, { path: dirPath }) {
4
+ export const Folder = Resource("fs::Folder", async function (id, props) {
5
+ const dirPath = props?.path ?? id;
5
6
  if (this.phase === "delete") {
6
7
  // we just do a best effort attempt
7
8
  await ignore(["ENOENT", "ENOTEMPTY"], async () => fs.promises.rmdir(dirPath));
@@ -42,4 +42,4 @@ export interface GitHubSecretOutput extends Resource<"github::Secret">, Omit<Git
42
42
  /**
43
43
  * Resource for managing GitHub repository secrets
44
44
  */
45
- export declare const GitHubSecret: ((this: Context<GitHubSecretOutput>, id: string, props: GitHubSecretProps) => Promise<GitHubSecretOutput>) | (((this: any, id: string, props: GitHubSecretProps) => never) & (new (_: never) => never));
45
+ export declare const GitHubSecret: ((this: Context<GitHubSecretOutput>, id: string, props: GitHubSecretProps) => Promise<GitHubSecretOutput>) | (((this: any, id: string, props?: GitHubSecretProps | undefined) => never) & (new (_: never) => never));
package/lib/resource.d.ts CHANGED
@@ -36,8 +36,8 @@ export interface Resource<Kind extends ResourceKind = ResourceKind, ID extends R
36
36
  type IsClass = {
37
37
  new (_: never): never;
38
38
  };
39
- type ResourceLifecycleHandler = (this: Context<any>, id: string, props: any) => Promise<Resource<string>>;
40
- type Handler<F extends (...args: any[]) => any> = F | (((this: any, id: string, props: Parameters<F>[1]) => never) & IsClass);
39
+ type ResourceLifecycleHandler = (this: Context<any, any>, id: string, props: any) => Promise<Resource<string>>;
40
+ type Handler<F extends (...args: any[]) => any> = F | (((this: any, id: string, props?: Parameters<F>[1]) => never) & IsClass);
41
41
  export declare function Resource<const Type extends string, F extends ResourceLifecycleHandler>(type: Type, fn: F): Handler<F>;
42
42
  export declare function Resource<const Type extends string, F extends ResourceLifecycleHandler>(type: Type, options: Partial<ProviderOptions>, fn: F): Handler<F>;
43
43
  export {};
package/lib/resource.js CHANGED
@@ -8,6 +8,10 @@ export function Resource(type, ...args) {
8
8
  const [options, handler] = args.length === 2 ? args : [undefined, args[0]];
9
9
  const provider = ((resourceID, props) => {
10
10
  const scope = _Scope.current;
11
+ if (resourceID.includes(":")) {
12
+ // we want to use : as an internal separator for resources
13
+ throw new Error(`ID cannot include colons: ${resourceID}`);
14
+ }
11
15
  if (scope.resources.has(resourceID)) {
12
16
  // TODO(sam): do we want to throw?
13
17
  // it's kind of awesome that you can re-create a resource and call apply
package/lib/scope.d.ts CHANGED
@@ -31,9 +31,9 @@ export declare class Scope {
31
31
  init(): Promise<void>;
32
32
  deinit(): Promise<void>;
33
33
  fqn(resourceID: ResourceID): string;
34
- finalize(): Promise<void>;
35
34
  run<T>(fn: (scope: Scope) => Promise<T>): Promise<T>;
36
35
  [Symbol.asyncDispose](): Promise<void>;
36
+ finalize(): Promise<void>;
37
37
  /**
38
38
  * Returns a string representation of the scope.
39
39
  */
package/lib/scope.js CHANGED
@@ -68,6 +68,12 @@ export class Scope {
68
68
  fqn(resourceID) {
69
69
  return [...this.chain, resourceID].join("/");
70
70
  }
71
+ async run(fn) {
72
+ return scopeStorage.run(this, () => fn(this));
73
+ }
74
+ [Symbol.asyncDispose]() {
75
+ return this.finalize();
76
+ }
71
77
  async finalize() {
72
78
  if (!this.isErrored) {
73
79
  // TODO: need to detect if it is in error
@@ -84,12 +90,6 @@ export class Scope {
84
90
  console.warn("Scope is in error, skipping finalize");
85
91
  }
86
92
  }
87
- async run(fn) {
88
- return scopeStorage.run(this, () => fn(this));
89
- }
90
- [Symbol.asyncDispose]() {
91
- return this.finalize();
92
- }
93
93
  /**
94
94
  * Returns a string representation of the scope.
95
95
  */
@@ -26,4 +26,4 @@ export interface ShadcnComponent extends ShadcnComponentProps, Resource {
26
26
  */
27
27
  name: string;
28
28
  }
29
- export declare const ShadcnComponent: ((this: Context<ShadcnComponent>, id: string, props: ShadcnComponentProps) => Promise<ShadcnComponent>) | (((this: any, id: string, props: ShadcnComponentProps) => never) & (new (_: never) => never));
29
+ export declare const ShadcnComponent: ((this: Context<ShadcnComponent>, id: string, props: ShadcnComponentProps) => Promise<ShadcnComponent>) | (((this: any, id: string, props?: ShadcnComponentProps | undefined) => never) & (new (_: never) => never));
package/lib/state.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Resource, ResourceProps } from "./resource";
2
2
  import type { Scope } from "./scope";
3
- export interface State<Kind extends string = string, Props extends ResourceProps = ResourceProps, Out extends Resource = Resource> {
3
+ export interface State<Kind extends string = string, Props extends ResourceProps | undefined = ResourceProps | undefined, Out extends Resource = Resource> {
4
4
  status: `creating` | `created` | `updating` | `updated` | `deleting` | `deleted`;
5
5
  kind: Kind;
6
6
  id: string;
package/lib/state.js CHANGED
@@ -27,7 +27,8 @@ export class FileSystemStateStore {
27
27
  });
28
28
  return files
29
29
  .filter((dirent) => dirent.isFile() && dirent.name.endsWith(".json"))
30
- .map((dirent) => dirent.name.replace(/\.json$/, ""));
30
+ .map((dirent) => dirent.name.replace(/\.json$/, ""))
31
+ .map((key) => key.replaceAll(":", "/"));
31
32
  }
32
33
  catch (error) {
33
34
  if (error.code === "ENOENT") {
@@ -72,6 +73,12 @@ export class FileSystemStateStore {
72
73
  }))).flat());
73
74
  }
74
75
  async getPath(key) {
76
+ if (key.includes(":")) {
77
+ throw new Error(`ID cannot include colons: ${key}`);
78
+ }
79
+ if (key.includes("/")) {
80
+ key = key.replaceAll("/", ":");
81
+ }
75
82
  const file = path.join(this.dir, `${key}.json`);
76
83
  const dir = path.dirname(file);
77
84
  await fs.promises.mkdir(dir, { recursive: true });
@@ -104,5 +104,5 @@ export interface Price extends Resource<"stripe::Price">, PriceProps {
104
104
  */
105
105
  lookupKey?: string;
106
106
  }
107
- export declare const Price: ((this: Context<Price>, id: string, props: PriceProps) => Promise<Price>) | (((this: any, id: string, props: PriceProps) => never) & (new (_: never) => never));
107
+ export declare const Price: ((this: Context<Price>, id: string, props: PriceProps) => Promise<Price>) | (((this: any, id: string, props?: PriceProps | undefined) => never) & (new (_: never) => never));
108
108
  export {};
@@ -81,5 +81,5 @@ export interface Product extends Resource<"stripe::Product">, ProductProps {
81
81
  width: number;
82
82
  };
83
83
  }
84
- export declare const Product: ((this: Context<Product>, id: string, props: ProductProps) => Promise<Product>) | (((this: any, id: string, props: ProductProps) => never) & (new (_: never) => never));
84
+ export declare const Product: ((this: Context<Product>, id: string, props: ProductProps) => Promise<Product>) | (((this: any, id: string, props?: ProductProps | undefined) => never) & (new (_: never) => never));
85
85
  export {};
@@ -68,4 +68,4 @@ export interface WebhookEndpoint extends Resource<"stripe::WebhookEndpoint">, We
68
68
  */
69
69
  status: string;
70
70
  }
71
- export declare const WebhookEndpoint: ((this: Context<WebhookEndpoint>, id: string, props: WebhookEndpointProps) => Promise<WebhookEndpoint>) | (((this: any, id: string, props: WebhookEndpointProps) => never) & (new (_: never) => never));
71
+ export declare const WebhookEndpoint: ((this: Context<WebhookEndpoint>, id: string, props: WebhookEndpointProps) => Promise<WebhookEndpoint>) | (((this: any, id: string, props?: WebhookEndpointProps | undefined) => never) & (new (_: never) => never));
@@ -1,3 +1,5 @@
1
1
  import { Scope } from "../scope";
2
- export declare function serialize(scope: Scope, value: any): Promise<any>;
2
+ export declare function serialize(scope: Scope, value: any, options?: {
3
+ encrypt?: boolean;
4
+ }): Promise<any>;
3
5
  export declare function deserialize(scope: Scope, value: any): Promise<any>;
package/lib/util/serde.js CHANGED
@@ -1,16 +1,18 @@
1
1
  import { Scope } from "../scope";
2
2
  import { Secret } from "../secret";
3
3
  import { decryptWithKey, encryptWithKey } from "./encrypt";
4
- export async function serialize(scope, value) {
4
+ export async function serialize(scope, value, options) {
5
5
  if (Array.isArray(value)) {
6
- return Promise.all(value.map((value) => serialize(scope, value)));
6
+ return Promise.all(value.map((value) => serialize(scope, value, options)));
7
7
  }
8
8
  else if (value instanceof Secret) {
9
9
  if (!scope.password) {
10
10
  throw new Error("Cannot serialize secret without password");
11
11
  }
12
12
  return {
13
- "@secret": await encryptWithKey(value.unencrypted, scope.password),
13
+ "@secret": options?.encrypt !== false
14
+ ? await encryptWithKey(value.unencrypted, scope.password)
15
+ : value.unencrypted,
14
16
  };
15
17
  }
16
18
  else if (value instanceof Scope) {
@@ -19,7 +21,7 @@ export async function serialize(scope, value) {
19
21
  else if (value && typeof value === "object") {
20
22
  return Object.fromEntries(await Promise.all(Object.entries(value).map(async ([key, value]) => [
21
23
  key,
22
- await serialize(scope, value),
24
+ await serialize(scope, value, options),
23
25
  ])));
24
26
  }
25
27
  return value;
@@ -86,5 +86,5 @@ export interface ViteProject extends ViteProjectProps, Resource {
86
86
  */
87
87
  name: string;
88
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));
89
+ export declare const ViteProject: ((this: Context<ViteProject>, id: string, props: ViteProjectProps) => Promise<ViteProject>) | (((this: any, id: string, props?: ViteProjectProps | undefined) => never) & (new (_: never) => never));
90
90
  export {};
@@ -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,2 @@
1
+ export * from "./home-page";
2
+ export * from "./vitepress";
@@ -0,0 +1,2 @@
1
+ export * from "./home-page";
2
+ export * from "./vitepress";
@@ -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));