alchemy 0.2.2 → 0.2.4
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/ai/ark.d.ts +11 -0
- package/lib/ai/ark.js +86 -0
- package/lib/ai/client.d.ts +51 -0
- package/lib/ai/client.js +29 -0
- package/lib/ai/document.d.ts +97 -0
- package/lib/ai/document.js +82 -0
- package/lib/ai/index.d.ts +2 -0
- package/lib/ai/index.js +2 -0
- package/lib/ai/object.d.ts +101 -0
- package/lib/ai/object.js +70 -0
- package/lib/alchemy.d.ts +84 -2
- package/lib/alchemy.js +114 -10
- package/lib/apply.d.ts +1 -1
- package/lib/apply.js +13 -10
- package/lib/aws/bucket.d.ts +87 -1
- package/lib/aws/bucket.js +48 -1
- package/lib/aws/function.d.ts +186 -1
- package/lib/aws/function.js +62 -8
- package/lib/aws/oidc/github-oidc-provider.d.ts +81 -0
- package/lib/aws/oidc/github-oidc-provider.js +68 -0
- package/lib/aws/oidc/oidc-provider.d.ts +14 -6
- package/lib/aws/oidc/oidc-provider.js +26 -5
- package/lib/aws/policy-attachment.d.ts +44 -1
- package/lib/aws/policy-attachment.js +31 -0
- package/lib/aws/policy.d.ts +160 -1
- package/lib/aws/policy.js +78 -0
- package/lib/aws/queue.d.ts +83 -1
- package/lib/aws/queue.js +39 -0
- package/lib/aws/role.d.ts +162 -1
- package/lib/aws/role.js +114 -0
- package/lib/aws/ses.d.ts +57 -2
- package/lib/aws/ses.js +42 -1
- package/lib/aws/table.d.ts +96 -1
- package/lib/aws/table.js +36 -0
- package/lib/cloudflare/asset-manifest.js +0 -1
- package/lib/cloudflare/bound.js +0 -1
- package/lib/cloudflare/bucket.d.ts +37 -1
- package/lib/cloudflare/bucket.js +36 -0
- package/lib/cloudflare/durable-object-namespace.d.ts +25 -0
- package/lib/cloudflare/durable-object-namespace.js +22 -0
- package/lib/cloudflare/kv-namespace.d.ts +37 -1
- package/lib/cloudflare/kv-namespace.js +36 -0
- package/lib/cloudflare/static-site.d.ts +53 -1
- package/lib/cloudflare/static-site.js +53 -1
- package/lib/cloudflare/worker-metadata.js +0 -1
- package/lib/cloudflare/worker.d.ts +64 -1
- package/lib/cloudflare/worker.js +63 -0
- package/lib/cloudflare/wrangler.json.d.ts +1 -1
- package/lib/cloudflare/zone-settings.js +0 -1
- package/lib/cloudflare/zone.d.ts +56 -1
- package/lib/cloudflare/zone.js +55 -0
- package/lib/context.d.ts +9 -4
- package/lib/context.js +4 -2
- package/lib/destroy.js +9 -8
- package/lib/esbuild/bundle.d.ts +43 -4
- package/lib/esbuild/bundle.js +16 -0
- package/lib/fs/file-collection.d.ts +16 -0
- package/lib/fs/file-collection.js +6 -0
- package/lib/fs/file-ref.d.ts +14 -0
- package/lib/fs/file-ref.js +6 -0
- package/lib/fs/file.d.ts +78 -5
- package/lib/fs/file.js +39 -3
- package/lib/fs/folder.d.ts +37 -5
- package/lib/fs/folder.js +28 -3
- package/lib/fs/index.d.ts +6 -0
- package/lib/fs/index.js +6 -0
- package/lib/fs/json-file.d.ts +16 -0
- package/lib/fs/json-file.js +7 -0
- package/lib/fs/text-file.d.ts +12 -0
- package/lib/fs/text-file.js +7 -0
- package/lib/fs/typescript-file.d.ts +19 -0
- package/lib/fs/typescript-file.js +14 -0
- package/lib/fs/yaml-file.d.ts +19 -0
- package/lib/fs/yaml-file.js +8 -0
- package/lib/github/secret.d.ts +63 -2
- package/lib/github/secret.js +61 -1
- package/lib/internal/docs.d.ts +5 -0
- package/lib/internal/docs.js +324 -0
- 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/secret.d.ts +67 -0
- package/lib/secret.js +67 -0
- 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 +51 -1
- package/lib/stripe/price.js +50 -0
- package/lib/stripe/product.d.ts +39 -1
- package/lib/stripe/product.js +38 -0
- package/lib/stripe/webhook.d.ts +46 -1
- package/lib/stripe/webhook.js +45 -0
- package/lib/test/bun.d.ts +64 -0
- package/lib/test/bun.js +35 -3
- package/lib/util/serde.d.ts +3 -1
- package/lib/util/serde.js +20 -4
- package/lib/vite/vite.d.ts +1 -1
- package/lib/vitepress/dependencies.d.ts +12 -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 +71 -0
- package/lib/vitepress/vitepress.js +266 -0
- package/package.json +22 -10
- package/src/ai/ark.ts +118 -0
- package/src/ai/client.ts +78 -0
- package/src/ai/document.ts +160 -0
- package/src/ai/index.ts +2 -0
- package/src/ai/object.ts +149 -0
- package/src/alchemy.ts +192 -17
- package/src/apply.ts +25 -13
- package/src/aws/bucket.ts +111 -7
- package/src/aws/function.ts +231 -10
- package/src/aws/oidc/github-oidc-provider.ts +83 -0
- package/src/aws/oidc/oidc-provider.ts +39 -7
- package/src/aws/policy-attachment.ts +44 -1
- package/src/aws/policy.ts +177 -2
- package/src/aws/queue.ts +89 -0
- package/src/aws/role.ts +174 -2
- package/src/aws/ses.ts +56 -1
- package/src/aws/table.ts +103 -0
- package/src/cloudflare/bucket.ts +36 -0
- package/src/cloudflare/durable-object-namespace.ts +25 -0
- package/src/cloudflare/kv-namespace.ts +36 -0
- package/src/cloudflare/static-site.ts +53 -1
- package/src/cloudflare/worker.ts +63 -0
- package/src/cloudflare/zone.ts +55 -0
- package/src/context.ts +30 -10
- package/src/destroy.ts +11 -8
- package/src/esbuild/bundle.ts +53 -3
- package/src/fs/file-collection.ts +24 -0
- package/src/fs/file-ref.ts +22 -0
- package/src/fs/file.ts +107 -6
- package/src/fs/folder.ts +45 -5
- package/src/fs/index.ts +6 -0
- package/src/fs/json-file.ts +23 -0
- package/src/fs/text-file.ts +19 -0
- package/src/fs/typescript-file.ts +36 -0
- package/src/fs/yaml-file.ts +26 -0
- package/src/github/secret.ts +65 -2
- package/src/internal/docs.ts +369 -0
- package/src/resource.ts +7 -2
- package/src/scope.ts +9 -9
- package/src/secret.ts +67 -0
- package/src/state.ts +9 -2
- package/src/stripe/price.ts +50 -0
- package/src/stripe/product.ts +38 -0
- package/src/stripe/webhook.ts +45 -0
- package/src/test/bun.ts +83 -3
- package/src/util/serde.ts +30 -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 +382 -0
- package/lib/project/vite.d.ts +0 -90
- package/lib/project/vite.js +0 -228
- package/src/project/vite.ts +0 -406
package/src/project/vite.ts
DELETED
|
@@ -1,406 +0,0 @@
|
|
|
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 { Context } from "../context";
|
|
6
|
-
import { Resource } from "../resource";
|
|
7
|
-
import { ShadcnComponent } from "../shadcn/component";
|
|
8
|
-
import { rm } from "../util/rm";
|
|
9
|
-
|
|
10
|
-
const execAsync = promisify(exec);
|
|
11
|
-
|
|
12
|
-
type ViteTemplate =
|
|
13
|
-
| "vanilla"
|
|
14
|
-
| "vanilla-ts"
|
|
15
|
-
| "vue"
|
|
16
|
-
| "vue-ts"
|
|
17
|
-
| "react"
|
|
18
|
-
| "react-ts"
|
|
19
|
-
| "react-swc"
|
|
20
|
-
| "react-swc-ts"
|
|
21
|
-
| "preact"
|
|
22
|
-
| "preact-ts"
|
|
23
|
-
| "lit"
|
|
24
|
-
| "lit-ts"
|
|
25
|
-
| "svelte"
|
|
26
|
-
| "svelte-ts"
|
|
27
|
-
| "solid"
|
|
28
|
-
| "solid-ts"
|
|
29
|
-
| "qwik"
|
|
30
|
-
| "qwik-ts";
|
|
31
|
-
|
|
32
|
-
export interface ViteProjectProps {
|
|
33
|
-
/**
|
|
34
|
-
* The name/path of the project
|
|
35
|
-
*/
|
|
36
|
-
name: string;
|
|
37
|
-
/**
|
|
38
|
-
* The Vite template to use
|
|
39
|
-
*/
|
|
40
|
-
template: ViteTemplate;
|
|
41
|
-
/**
|
|
42
|
-
* The extends to add to the tsconfig.json file
|
|
43
|
-
*/
|
|
44
|
-
extends?: string;
|
|
45
|
-
/**
|
|
46
|
-
* The references to add to the tsconfig.json file
|
|
47
|
-
*/
|
|
48
|
-
references?: string[];
|
|
49
|
-
/**
|
|
50
|
-
* Add Tailwind CSS to the project
|
|
51
|
-
* @default false
|
|
52
|
-
*/
|
|
53
|
-
tailwind?: boolean;
|
|
54
|
-
/**
|
|
55
|
-
* Add Tanstack Router to the project
|
|
56
|
-
* @default false
|
|
57
|
-
*/
|
|
58
|
-
tanstack?: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Add Shadcn UI to the project
|
|
61
|
-
* @default false
|
|
62
|
-
*/
|
|
63
|
-
shadcn?: {
|
|
64
|
-
/**
|
|
65
|
-
* The base color to use
|
|
66
|
-
* @default "neutral"
|
|
67
|
-
*/
|
|
68
|
-
baseColor?: "neutral" | "gray" | "zinc" | "stone" | "slate";
|
|
69
|
-
/**
|
|
70
|
-
* Use default configuration
|
|
71
|
-
* @default false
|
|
72
|
-
*/
|
|
73
|
-
defaults?: boolean;
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Force overwrite of existing configuration
|
|
77
|
-
* @default false
|
|
78
|
-
*/
|
|
79
|
-
force?: boolean;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The working directory
|
|
83
|
-
* @default current directory
|
|
84
|
-
*/
|
|
85
|
-
cwd?: string;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Mute output
|
|
89
|
-
* @default false
|
|
90
|
-
*/
|
|
91
|
-
silent?: boolean;
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Use the src directory when creating a new project
|
|
95
|
-
* @default false
|
|
96
|
-
*/
|
|
97
|
-
srcDir?: boolean;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Use css variables for theming
|
|
101
|
-
* @default true
|
|
102
|
-
*/
|
|
103
|
-
cssVariables?: boolean;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* The components to add
|
|
107
|
-
*/
|
|
108
|
-
components?: string[];
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* Force overwrite the project config files during the update phase
|
|
112
|
-
*
|
|
113
|
-
* @default false
|
|
114
|
-
*/
|
|
115
|
-
overwrite?: boolean;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export interface ViteProject extends ViteProjectProps, Resource {
|
|
119
|
-
/**
|
|
120
|
-
* The name/path of the project
|
|
121
|
-
*/
|
|
122
|
-
name: string;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export const ViteProject = Resource(
|
|
126
|
-
"project::ViteProject",
|
|
127
|
-
{
|
|
128
|
-
alwaysUpdate: true,
|
|
129
|
-
},
|
|
130
|
-
async function (
|
|
131
|
-
this: Context<ViteProject>,
|
|
132
|
-
id: string,
|
|
133
|
-
props: ViteProjectProps,
|
|
134
|
-
): Promise<ViteProject> {
|
|
135
|
-
const phase = this.phase;
|
|
136
|
-
if (this.phase === "delete") {
|
|
137
|
-
try {
|
|
138
|
-
if (await fs.exists(props.name)) {
|
|
139
|
-
// TODO: OS agnostic - fs.rm is slow to delete node_modules/
|
|
140
|
-
await execAsync("rm -rf " + props.name);
|
|
141
|
-
}
|
|
142
|
-
} catch (error) {
|
|
143
|
-
console.error(`Error deleting project ${id}:`, error);
|
|
144
|
-
}
|
|
145
|
-
return this.destroy();
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (this.phase === "update") {
|
|
149
|
-
if (props.overwrite) {
|
|
150
|
-
await modifyConfig(props);
|
|
151
|
-
} else {
|
|
152
|
-
console.warn(
|
|
153
|
-
"ViteProject does not support updates - the project must be recreated to change the template",
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
} else {
|
|
157
|
-
await execAsync(`bun create vite ${id} --template ${props.template}`);
|
|
158
|
-
|
|
159
|
-
await modifyConfig(props);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return this(props);
|
|
163
|
-
|
|
164
|
-
async function modifyConfig(props: ViteProjectProps) {
|
|
165
|
-
const tailwind = props.tailwind ?? false;
|
|
166
|
-
const tanstack = props.tanstack ?? false;
|
|
167
|
-
|
|
168
|
-
const plugins = [
|
|
169
|
-
tailwind && "tailwindcss()",
|
|
170
|
-
tanstack &&
|
|
171
|
-
"TanStackRouterVite({ target: 'react', autoCodeSplitting: true })",
|
|
172
|
-
"react()",
|
|
173
|
-
].filter((s) => typeof s === "string");
|
|
174
|
-
|
|
175
|
-
const cwd = path.resolve(process.cwd(), props.name);
|
|
176
|
-
|
|
177
|
-
const exec = (command: string) => execAsync(command, { cwd });
|
|
178
|
-
|
|
179
|
-
if (phase === "create" || props.overwrite) {
|
|
180
|
-
await removeUnnecessaryFiles();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
await patchTsConfig();
|
|
184
|
-
|
|
185
|
-
if (props.tailwind) {
|
|
186
|
-
await installTailwind();
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
if (props.tanstack) {
|
|
190
|
-
await installTanstack();
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (props.shadcn !== undefined) {
|
|
194
|
-
await installShadcn();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
await build();
|
|
198
|
-
|
|
199
|
-
async function build() {
|
|
200
|
-
// tsc -b will fail if we have not invoked tan stacks' code gen
|
|
201
|
-
await execAsync(`bun vite build`, { cwd: props.name });
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
async function installTailwind() {
|
|
205
|
-
await exec(`bun add tailwindcss @tailwindcss/vite`);
|
|
206
|
-
|
|
207
|
-
await fs.writeFile(
|
|
208
|
-
path.join(props.name, "vite.config.ts"),
|
|
209
|
-
`import path from "path";
|
|
210
|
-
import react from "@vitejs/plugin-react";
|
|
211
|
-
import { defineConfig } from "vite";
|
|
212
|
-
${tailwind ? "import tailwindcss from '@tailwindcss/vite';" : ""}
|
|
213
|
-
${tanstack ? 'import { TanStackRouterVite } from "@tanstack/router-plugin/vite";' : ""}
|
|
214
|
-
|
|
215
|
-
// https://vite.dev/config/
|
|
216
|
-
export default defineConfig({
|
|
217
|
-
plugins: [${plugins.join(", ")}],
|
|
218
|
-
resolve: {
|
|
219
|
-
alias: {
|
|
220
|
-
"@": path.resolve(__dirname, "./src"),
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
});`,
|
|
224
|
-
);
|
|
225
|
-
|
|
226
|
-
// Add Tailwind CSS import to index.css
|
|
227
|
-
const indexCssPath = path.join(props.name, "src", "index.css");
|
|
228
|
-
const currentCss = await fs.readFile(indexCssPath, "utf-8");
|
|
229
|
-
if (!currentCss.includes('@import "tailwindcss";')) {
|
|
230
|
-
await fs.writeFile(
|
|
231
|
-
indexCssPath,
|
|
232
|
-
'@import "tailwindcss";\n\n' + currentCss,
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
async function installShadcn() {
|
|
238
|
-
await exec("bun add -D @types/node");
|
|
239
|
-
|
|
240
|
-
// Build the shadcn init command with all options
|
|
241
|
-
const shadcnOptions = props.shadcn;
|
|
242
|
-
const initCommand = [
|
|
243
|
-
"bunx --bun shadcn@latest init",
|
|
244
|
-
shadcnOptions?.baseColor && `-b ${shadcnOptions.baseColor}`,
|
|
245
|
-
shadcnOptions?.defaults && "-d",
|
|
246
|
-
shadcnOptions?.force && "-f",
|
|
247
|
-
shadcnOptions?.cwd && `-c ${shadcnOptions.cwd}`,
|
|
248
|
-
shadcnOptions?.silent && "-s",
|
|
249
|
-
shadcnOptions?.srcDir && "--src-dir",
|
|
250
|
-
shadcnOptions?.cssVariables === false && "--no-css-variables",
|
|
251
|
-
]
|
|
252
|
-
.filter(Boolean)
|
|
253
|
-
.join(" ");
|
|
254
|
-
|
|
255
|
-
await exec(initCommand);
|
|
256
|
-
|
|
257
|
-
// Install requested components using the ShadcnComponent resource
|
|
258
|
-
for (const componentName of props.shadcn?.components ?? []) {
|
|
259
|
-
await ShadcnComponent(`shadcn-component-${componentName}`, {
|
|
260
|
-
name: componentName,
|
|
261
|
-
cwd: props.name,
|
|
262
|
-
force: props.shadcn?.force,
|
|
263
|
-
silent: props.shadcn?.silent,
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
async function installTanstack() {
|
|
269
|
-
await exec(`bun add @tanstack/react-router`);
|
|
270
|
-
await exec(
|
|
271
|
-
`bun add -D @tanstack/router-plugin @tanstack/react-router-devtools`,
|
|
272
|
-
);
|
|
273
|
-
|
|
274
|
-
const src = path.join(props.name, "src");
|
|
275
|
-
const routes = path.join(src, "routes");
|
|
276
|
-
await fs.mkdir(routes, { recursive: true });
|
|
277
|
-
await fs.writeFile(
|
|
278
|
-
path.join(routes, "__root.tsx"),
|
|
279
|
-
`import { Link, Outlet, createRootRoute } from "@tanstack/react-router";
|
|
280
|
-
import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
|
|
281
|
-
|
|
282
|
-
export const Route = createRootRoute({
|
|
283
|
-
component: () => (
|
|
284
|
-
<div className="w-full min-h-screen flex flex-col">
|
|
285
|
-
<div className="p-2 flex gap-2">
|
|
286
|
-
<Link to="/" className="[&.active]:font-bold">
|
|
287
|
-
Home
|
|
288
|
-
</Link>{" "}
|
|
289
|
-
<Link to="/about" className="[&.active]:font-bold">
|
|
290
|
-
About
|
|
291
|
-
</Link>
|
|
292
|
-
</div>
|
|
293
|
-
<hr />
|
|
294
|
-
<Outlet />
|
|
295
|
-
<TanStackRouterDevtools />
|
|
296
|
-
</div>
|
|
297
|
-
),
|
|
298
|
-
});
|
|
299
|
-
`,
|
|
300
|
-
);
|
|
301
|
-
|
|
302
|
-
await fs.writeFile(
|
|
303
|
-
path.join(routes, "index.tsx"),
|
|
304
|
-
`import { createLazyFileRoute } from '@tanstack/react-router'
|
|
305
|
-
|
|
306
|
-
export const Route = createLazyFileRoute('/')({
|
|
307
|
-
component: Index,
|
|
308
|
-
})
|
|
309
|
-
|
|
310
|
-
function Index() {
|
|
311
|
-
return (
|
|
312
|
-
<div className="p-2">
|
|
313
|
-
<h3>Welcome Home!</h3>
|
|
314
|
-
</div>
|
|
315
|
-
)
|
|
316
|
-
}`,
|
|
317
|
-
);
|
|
318
|
-
|
|
319
|
-
await fs.writeFile(
|
|
320
|
-
path.join(routes, "about.tsx"),
|
|
321
|
-
`import { createLazyFileRoute } from '@tanstack/react-router'
|
|
322
|
-
|
|
323
|
-
export const Route = createLazyFileRoute('/about')({
|
|
324
|
-
component: About,
|
|
325
|
-
})
|
|
326
|
-
|
|
327
|
-
function About() {
|
|
328
|
-
return <div className="p-2">Hello from About!</div>
|
|
329
|
-
}`,
|
|
330
|
-
);
|
|
331
|
-
|
|
332
|
-
await fs.writeFile(
|
|
333
|
-
path.join(src, "main.tsx"),
|
|
334
|
-
`import { StrictMode } from 'react'
|
|
335
|
-
import ReactDOM from 'react-dom/client'
|
|
336
|
-
import { RouterProvider, createRouter } from '@tanstack/react-router'
|
|
337
|
-
import './index.css'
|
|
338
|
-
|
|
339
|
-
// Import the generated route tree
|
|
340
|
-
import { routeTree } from './routeTree.gen'
|
|
341
|
-
|
|
342
|
-
// Create a new router instance
|
|
343
|
-
const router = createRouter({ routeTree })
|
|
344
|
-
|
|
345
|
-
// Register the router instance for type safety
|
|
346
|
-
declare module '@tanstack/react-router' {
|
|
347
|
-
interface Register {
|
|
348
|
-
router: typeof router
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// Render the app
|
|
353
|
-
const rootElement = document.getElementById('root')!
|
|
354
|
-
if (!rootElement.innerHTML) {
|
|
355
|
-
const root = ReactDOM.createRoot(rootElement)
|
|
356
|
-
root.render(
|
|
357
|
-
<StrictMode>
|
|
358
|
-
<RouterProvider router={router} />
|
|
359
|
-
</StrictMode>,
|
|
360
|
-
)
|
|
361
|
-
}`,
|
|
362
|
-
);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
async function removeUnnecessaryFiles() {
|
|
366
|
-
await Promise.all([
|
|
367
|
-
rm(path.join(props.name, "src", "App.tsx")),
|
|
368
|
-
rm(path.join(props.name, "src", "App.css")),
|
|
369
|
-
]);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
async function patchTsConfig() {
|
|
373
|
-
await Promise.all([
|
|
374
|
-
rm(path.join(props.name, "tsconfig.app.json")),
|
|
375
|
-
rm(path.join(props.name, "tsconfig.node.json")),
|
|
376
|
-
fs.writeFile(
|
|
377
|
-
path.join(props.name, "tsconfig.json"),
|
|
378
|
-
JSON.stringify(
|
|
379
|
-
{
|
|
380
|
-
extends: props.extends,
|
|
381
|
-
compilerOptions: {
|
|
382
|
-
baseUrl: ".",
|
|
383
|
-
paths: {
|
|
384
|
-
"@/*": ["./src/*"],
|
|
385
|
-
},
|
|
386
|
-
types: ["@cloudflare/workers-types"],
|
|
387
|
-
allowImportingTsExtensions: true,
|
|
388
|
-
jsx: "react-jsx",
|
|
389
|
-
},
|
|
390
|
-
include: [
|
|
391
|
-
"vite/*.ts",
|
|
392
|
-
"src/**/*.ts",
|
|
393
|
-
"src/**/*.tsx",
|
|
394
|
-
"src/env.d.ts",
|
|
395
|
-
],
|
|
396
|
-
references: props.references?.map((path) => ({ path })),
|
|
397
|
-
},
|
|
398
|
-
null,
|
|
399
|
-
2,
|
|
400
|
-
),
|
|
401
|
-
),
|
|
402
|
-
]);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
);
|