alchemy 0.75.0 → 0.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/alchemy.js +302 -287
- package/bin/commands/util.ts +8 -4
- package/bin/services/execute-alchemy.ts +4 -2
- package/bin/services/github-workflow.ts +2 -3
- package/bin/services/package-manager.ts +1 -5
- package/lib/alchemy.d.ts +1 -1
- package/lib/alchemy.d.ts.map +1 -1
- package/lib/alchemy.js +1 -1
- package/lib/alchemy.js.map +1 -1
- package/lib/apply.js +10 -0
- package/lib/apply.js.map +1 -1
- package/lib/aws/control/types.d.ts.map +1 -1
- package/lib/aws/control/types.js.map +1 -1
- package/lib/clickhouse/api/sdk.gen.d.ts.map +1 -1
- package/lib/clickhouse/api/sdk.gen.js.map +1 -1
- package/lib/cloudflare/account-api-token.d.ts.map +1 -1
- package/lib/cloudflare/account-api-token.js.map +1 -1
- package/lib/cloudflare/bound.d.ts.map +1 -1
- package/lib/cloudflare/bucket.d.ts +1 -1
- package/lib/cloudflare/bucket.d.ts.map +1 -1
- package/lib/cloudflare/bucket.js +1 -1
- package/lib/cloudflare/bucket.js.map +1 -1
- package/lib/cloudflare/cloudflare-env-proxy.d.ts.map +1 -1
- package/lib/cloudflare/cloudflare-env-proxy.js +3 -3
- package/lib/cloudflare/cloudflare-env-proxy.js.map +1 -1
- package/lib/cloudflare/compatibility-date.gen.d.ts +1 -1
- package/lib/cloudflare/compatibility-date.gen.js +1 -1
- package/lib/cloudflare/d1-database.d.ts.map +1 -1
- package/lib/cloudflare/d1-database.js +0 -4
- package/lib/cloudflare/d1-database.js.map +1 -1
- package/lib/cloudflare/dns-records.js.map +1 -1
- package/lib/cloudflare/hyperdrive.d.ts +0 -1
- package/lib/cloudflare/hyperdrive.d.ts.map +1 -1
- package/lib/cloudflare/hyperdrive.js.map +1 -1
- package/lib/cloudflare/miniflare/delete.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/delete.js +3 -0
- package/lib/cloudflare/miniflare/delete.js.map +1 -1
- package/lib/cloudflare/miniflare/paths.d.ts +0 -1
- package/lib/cloudflare/miniflare/paths.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/paths.js +4 -17
- package/lib/cloudflare/miniflare/paths.js.map +1 -1
- package/lib/cloudflare/nuxt/plugin.d.ts.map +1 -1
- package/lib/cloudflare/nuxt/plugin.js +2 -2
- package/lib/cloudflare/nuxt/plugin.js.map +1 -1
- package/lib/cloudflare/queue-consumer.d.ts.map +1 -1
- package/lib/cloudflare/queue-consumer.js +0 -2
- package/lib/cloudflare/queue-consumer.js.map +1 -1
- package/lib/cloudflare/react-router/plugin.d.ts.map +1 -1
- package/lib/cloudflare/react-router/plugin.js +0 -1
- package/lib/cloudflare/react-router/plugin.js.map +1 -1
- package/lib/cloudflare/vite/plugin.d.ts.map +1 -1
- package/lib/cloudflare/vite/plugin.js +3 -3
- package/lib/cloudflare/vite/plugin.js.map +1 -1
- package/lib/cloudflare/website.d.ts.map +1 -1
- package/lib/cloudflare/website.js +0 -4
- package/lib/cloudflare/website.js.map +1 -1
- package/lib/cloudflare/worker-assets.d.ts +1 -1
- package/lib/cloudflare/worker-assets.d.ts.map +1 -1
- package/lib/cloudflare/worker-assets.js +1 -1
- package/lib/cloudflare/worker-assets.js.map +1 -1
- package/lib/cloudflare/worker-metadata.d.ts.map +1 -1
- package/lib/cloudflare/worker-metadata.js.map +1 -1
- package/lib/cloudflare/worker-tail.d.ts.map +1 -1
- package/lib/cloudflare/worker-tail.js.map +1 -1
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +3 -1
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/cloudflare/wrangler.json.js +0 -1
- package/lib/cloudflare/wrangler.json.js.map +1 -1
- package/lib/cloudflare/zone.d.ts +1 -1
- package/lib/cloudflare/zone.d.ts.map +1 -1
- package/lib/cloudflare/zone.js +3 -28
- package/lib/cloudflare/zone.js.map +1 -1
- package/lib/coinbase/evm-account.d.ts.map +1 -1
- package/lib/coinbase/evm-account.js.map +1 -1
- package/lib/coinbase/evm-smart-account.d.ts.map +1 -1
- package/lib/coinbase/evm-smart-account.js.map +1 -1
- package/lib/docker/api.d.ts.map +1 -1
- package/lib/docker/api.js.map +1 -1
- package/lib/github/secret.d.ts.map +1 -1
- package/lib/github/secret.js.map +1 -1
- package/lib/neon/api/sdk.gen.d.ts.map +1 -1
- package/lib/neon/api/sdk.gen.js.map +1 -1
- package/lib/os/exec.d.ts.map +1 -1
- package/lib/os/exec.js.map +1 -1
- package/lib/planetscale/api/sdk.gen.d.ts.map +1 -1
- package/lib/planetscale/api/sdk.gen.js.map +1 -1
- package/lib/prisma-postgres/api/sdk.gen.d.ts.map +1 -1
- package/lib/prisma-postgres/api/sdk.gen.js.map +1 -1
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +2 -2
- package/lib/scope.js.map +1 -1
- package/lib/sentry/client-key.js +1 -1
- package/lib/sentry/client-key.js.map +1 -1
- package/lib/test/bun.d.ts.map +1 -1
- package/lib/test/bun.js.map +1 -1
- package/lib/test/vitest.d.ts.map +1 -1
- package/lib/test/vitest.js.map +1 -1
- package/lib/util/api/client/client.gen.d.ts +1 -1
- package/lib/util/api/client/client.gen.js +45 -45
- package/lib/util/api/client/types.gen.d.ts +22 -22
- package/lib/util/api/client/utils.gen.d.ts +3 -3
- package/lib/util/api/client/utils.gen.d.ts.map +1 -1
- package/lib/util/api/client/utils.gen.js +34 -34
- package/lib/util/api/client/utils.gen.js.map +1 -1
- package/lib/util/api/core/auth.gen.d.ts +3 -3
- package/lib/util/api/core/auth.gen.js +3 -3
- package/lib/util/api/core/bodySerializer.gen.d.ts +1 -1
- package/lib/util/api/core/bodySerializer.gen.js +3 -3
- package/lib/util/api/core/params.gen.d.ts +3 -3
- package/lib/util/api/core/params.gen.js +7 -7
- package/lib/util/api/core/pathSerializer.gen.d.ts +3 -3
- package/lib/util/api/core/pathSerializer.gen.js +36 -36
- package/lib/util/api/core/serverSentEvents.gen.d.ts +3 -3
- package/lib/util/api/core/serverSentEvents.gen.js +18 -18
- package/lib/util/api/core/types.gen.d.ts +4 -4
- package/lib/util/api/core/utils.gen.d.ts +1 -1
- package/lib/util/api/core/utils.gen.js +17 -17
- package/lib/util/camel-to-snake.d.ts.map +1 -1
- package/lib/util/find-workspace-root.d.ts +3 -0
- package/lib/util/find-workspace-root.d.ts.map +1 -0
- package/lib/util/find-workspace-root.js +94 -0
- package/lib/util/find-workspace-root.js.map +1 -0
- package/lib/util/idempotent-spawn.d.ts.map +1 -1
- package/lib/util/idempotent-spawn.js +1 -1
- package/lib/util/idempotent-spawn.js.map +1 -1
- package/lib/util/peer.d.ts.map +1 -1
- package/lib/util/peer.js.map +1 -1
- package/package.json +1 -1
- package/src/alchemy.ts +4 -3
- package/src/apply.ts +16 -1
- package/src/aws/control/types.ts +87107 -85281
- package/src/clickhouse/api/sdk.gen.ts +1 -3
- package/src/cloudflare/account-api-token.ts +3 -1
- package/src/cloudflare/bound.ts +64 -65
- package/src/cloudflare/bucket.ts +4 -7
- package/src/cloudflare/cloudflare-env-proxy.ts +2 -4
- package/src/cloudflare/compatibility-date.gen.ts +1 -1
- package/src/cloudflare/d1-database.ts +0 -9
- package/src/cloudflare/dns-records.ts +3 -1
- package/src/cloudflare/hyperdrive.ts +0 -1
- package/src/cloudflare/miniflare/delete.ts +3 -0
- package/src/cloudflare/miniflare/paths.ts +4 -25
- package/src/cloudflare/nuxt/plugin.ts +1 -4
- package/src/cloudflare/queue-consumer.ts +0 -2
- package/src/cloudflare/react-router/plugin.ts +0 -1
- package/src/cloudflare/vite/plugin.ts +1 -3
- package/src/cloudflare/website.ts +0 -5
- package/src/cloudflare/worker-assets.ts +1 -6
- package/src/cloudflare/worker-metadata.ts +5 -3
- package/src/cloudflare/worker-tail.ts +3 -1
- package/src/cloudflare/worker.ts +3 -1
- package/src/cloudflare/wrangler.json.ts +0 -1
- package/src/cloudflare/zone.ts +6 -38
- package/src/coinbase/evm-account.ts +3 -1
- package/src/coinbase/evm-smart-account.ts +3 -1
- package/src/docker/api.ts +3 -1
- package/src/github/secret.ts +5 -1
- package/src/neon/api/sdk.gen.ts +1 -3
- package/src/os/exec.ts +3 -1
- package/src/planetscale/api/sdk.gen.ts +1 -3
- package/src/prisma-postgres/api/sdk.gen.ts +1 -3
- package/src/scope.ts +2 -2
- package/src/sentry/client-key.ts +1 -5
- package/src/test/bun.ts +3 -1
- package/src/test/vitest.ts +3 -1
- package/src/util/api/client/client.gen.ts +49 -49
- package/src/util/api/client/types.gen.ts +43 -43
- package/src/util/api/client/utils.gen.ts +47 -42
- package/src/util/api/core/auth.gen.ts +6 -6
- package/src/util/api/core/bodySerializer.gen.ts +4 -4
- package/src/util/api/core/params.gen.ts +10 -10
- package/src/util/api/core/pathSerializer.gen.ts +39 -39
- package/src/util/api/core/serverSentEvents.gen.ts +22 -22
- package/src/util/api/core/types.gen.ts +12 -12
- package/src/util/api/core/utils.gen.ts +18 -18
- package/src/util/camel-to-snake.ts +12 -10
- package/src/util/find-workspace-root.ts +112 -0
- package/src/util/idempotent-spawn.ts +1 -5
- package/src/util/peer.ts +3 -1
- package/templates/astro/astro.config.mjs +3 -3
- package/templates/astro/src/pages/api/hello.ts +16 -13
- package/templates/bun-spa/bun-env.d.ts +0 -1
- package/templates/bun-spa/eslint.config.js +11 -12
- package/templates/bun-spa/src/App.tsx +0 -1
- package/templates/bun-spa/src/frontend.tsx +0 -1
- package/templates/hono/src/index.ts +13 -13
- package/templates/nextjs/alchemy.run.ts +1 -1
- package/templates/nextjs/eslint.config.mjs +1 -1
- package/templates/nextjs/next-env.d.ts +1 -1
- package/templates/nextjs/next.config.ts +1 -1
- package/templates/nextjs/open-next.config.ts +1 -1
- package/templates/nextjs/src/app/api/hello/route.ts +2 -2
- package/templates/nextjs/src/app/layout.tsx +1 -1
- package/templates/nextjs/src/app/page.tsx +14 -15
- package/templates/nextjs/types/env.d.ts +4 -4
- package/templates/nuxt/server/middleware/auth.ts +1 -1
- package/templates/nuxt/server/middleware/hello.ts +2 -2
- package/templates/react-router/app/entry.server.tsx +2 -2
- package/templates/react-router/vite.config.ts +1 -1
- package/templates/react-router/workers/app.ts +2 -2
- package/templates/rwsdk/alchemy.run.ts +6 -3
- package/templates/sveltekit/src/app.d.ts +7 -7
- package/templates/sveltekit/svelte.config.js +4 -4
- package/templates/sveltekit/vite.config.ts +3 -3
- package/templates/tanstack-start/src/components/Header.tsx +2 -2
- package/templates/tanstack-start/src/router.tsx +4 -4
- package/templates/tanstack-start/src/routes/__root.tsx +10 -10
- package/templates/tanstack-start/src/routes/api.demo-names.ts +6 -6
- package/templates/tanstack-start/src/routes/demo.start.api-request.tsx +11 -11
- package/templates/tanstack-start/src/routes/demo.start.server-funcs.tsx +30 -30
- package/templates/tanstack-start/src/routes/index.tsx +5 -5
- package/templates/tanstack-start/vite.config.ts +9 -9
- package/templates/typescript/src/worker.ts +5 -1
- package/templates/vite/eslint.config.js +12 -12
- package/templates/vite/src/App.tsx +7 -7
- package/templates/vite/src/main.tsx +6 -6
- package/templates/vite/src/worker.ts +11 -12
- package/templates/vite/vite.config.ts +2 -2
- package/workers/tunnel-proxy.js +1 -1
- package/bin/services/find-workspace-root.ts +0 -48
- package/lib/cloudflare/miniflare/symlink-miniflare-state.d.ts +0 -2
- package/lib/cloudflare/miniflare/symlink-miniflare-state.d.ts.map +0 -1
- package/lib/cloudflare/miniflare/symlink-miniflare-state.js +0 -18
- package/lib/cloudflare/miniflare/symlink-miniflare-state.js.map +0 -1
- package/src/cloudflare/miniflare/symlink-miniflare-state.ts +0 -18
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import alchemy from "alchemy";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
D1Database,
|
|
4
|
+
DurableObjectNamespace,
|
|
5
|
+
Redwood,
|
|
6
|
+
} from "alchemy/cloudflare";
|
|
3
7
|
|
|
4
8
|
const app = await alchemy("{projectName}");
|
|
5
|
-
|
|
9
|
+
|
|
6
10
|
const database = await D1Database("database", {
|
|
7
11
|
migrationsDir: "migrations",
|
|
8
12
|
});
|
|
@@ -22,4 +26,3 @@ console.log({
|
|
|
22
26
|
});
|
|
23
27
|
|
|
24
28
|
await app.finalize();
|
|
25
|
-
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// See https://svelte.dev/docs/kit/types#app.d.ts
|
|
2
2
|
// for information about these interfaces
|
|
3
3
|
declare global {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
namespace App {
|
|
5
|
+
// interface Error {}
|
|
6
|
+
// interface Locals {}
|
|
7
|
+
// interface PageData {}
|
|
8
|
+
// interface PageState {}
|
|
9
|
+
// interface Platform {}
|
|
10
|
+
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { vitePreprocess } from
|
|
2
|
-
import alchemy from
|
|
1
|
+
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
|
|
2
|
+
import alchemy from "alchemy/cloudflare/sveltekit";
|
|
3
3
|
|
|
4
4
|
/** @type {import('@sveltejs/kit').Config} */
|
|
5
5
|
const config = {
|
|
6
6
|
preprocess: vitePreprocess(),
|
|
7
7
|
kit: {
|
|
8
|
-
adapter: alchemy()
|
|
9
|
-
}
|
|
8
|
+
adapter: alchemy(),
|
|
9
|
+
},
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export default config;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { sveltekit } from
|
|
2
|
-
import { defineConfig } from
|
|
1
|
+
import { sveltekit } from "@sveltejs/kit/vite";
|
|
2
|
+
import { defineConfig } from "vite";
|
|
3
3
|
|
|
4
4
|
export default defineConfig({
|
|
5
|
-
|
|
5
|
+
plugins: [sveltekit()],
|
|
6
6
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createRouter } from
|
|
1
|
+
import { createRouter } from "@tanstack/react-router";
|
|
2
2
|
|
|
3
3
|
// Import the generated route tree
|
|
4
|
-
import { routeTree } from
|
|
4
|
+
import { routeTree } from "./routeTree.gen";
|
|
5
5
|
|
|
6
6
|
// Create a new router instance
|
|
7
7
|
export const getRouter = () => {
|
|
@@ -9,5 +9,5 @@ export const getRouter = () => {
|
|
|
9
9
|
routeTree,
|
|
10
10
|
scrollRestoration: true,
|
|
11
11
|
defaultPreloadStaleTime: 0,
|
|
12
|
-
})
|
|
13
|
-
}
|
|
12
|
+
});
|
|
13
|
+
};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { HeadContent, Scripts, createRootRoute } from
|
|
1
|
+
import { HeadContent, Scripts, createRootRoute } from "@tanstack/react-router";
|
|
2
2
|
|
|
3
|
-
import Header from
|
|
3
|
+
import Header from "../components/Header";
|
|
4
4
|
|
|
5
|
-
import appCss from
|
|
5
|
+
import appCss from "../styles.css?url";
|
|
6
6
|
|
|
7
7
|
export const Route = createRootRoute({
|
|
8
8
|
head: () => ({
|
|
9
9
|
meta: [
|
|
10
10
|
{
|
|
11
|
-
charSet:
|
|
11
|
+
charSet: "utf-8",
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
|
-
name:
|
|
15
|
-
content:
|
|
14
|
+
name: "viewport",
|
|
15
|
+
content: "width=device-width, initial-scale=1",
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
|
-
title:
|
|
18
|
+
title: "TanStack Start Starter",
|
|
19
19
|
},
|
|
20
20
|
],
|
|
21
21
|
links: [
|
|
22
22
|
{
|
|
23
|
-
rel:
|
|
23
|
+
rel: "stylesheet",
|
|
24
24
|
href: appCss,
|
|
25
25
|
},
|
|
26
26
|
],
|
|
27
27
|
}),
|
|
28
28
|
|
|
29
29
|
shellComponent: RootDocument,
|
|
30
|
-
})
|
|
30
|
+
});
|
|
31
31
|
|
|
32
32
|
function RootDocument({ children }: { children: React.ReactNode }) {
|
|
33
33
|
return (
|
|
@@ -41,5 +41,5 @@ function RootDocument({ children }: { children: React.ReactNode }) {
|
|
|
41
41
|
<Scripts />
|
|
42
42
|
</body>
|
|
43
43
|
</html>
|
|
44
|
-
)
|
|
44
|
+
);
|
|
45
45
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { createFileRoute } from
|
|
1
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
2
2
|
|
|
3
|
-
export const Route = createFileRoute(
|
|
3
|
+
export const Route = createFileRoute("/api/demo-names")({
|
|
4
4
|
server: {
|
|
5
5
|
handlers: {
|
|
6
6
|
GET: () => {
|
|
7
|
-
return new Response(JSON.stringify([
|
|
7
|
+
return new Response(JSON.stringify(["Alice", "Bob", "Charlie"]), {
|
|
8
8
|
headers: {
|
|
9
|
-
|
|
9
|
+
"Content-Type": "application/json",
|
|
10
10
|
},
|
|
11
|
-
})
|
|
11
|
+
});
|
|
12
12
|
},
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
|
-
})
|
|
15
|
+
});
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { useEffect, useState } from
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
2
|
|
|
3
|
-
import { createFileRoute } from
|
|
3
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
4
4
|
|
|
5
5
|
function getNames() {
|
|
6
|
-
return fetch(
|
|
6
|
+
return fetch("/api/demo-names").then((res) => res.json());
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const Route = createFileRoute(
|
|
9
|
+
export const Route = createFileRoute("/demo/start/api-request")({
|
|
10
10
|
component: Home,
|
|
11
|
-
})
|
|
11
|
+
});
|
|
12
12
|
|
|
13
13
|
function Home() {
|
|
14
|
-
const [names, setNames] = useState<Array<string>>([])
|
|
14
|
+
const [names, setNames] = useState<Array<string>>([]);
|
|
15
15
|
|
|
16
16
|
useEffect(() => {
|
|
17
|
-
getNames().then(setNames)
|
|
18
|
-
}, [])
|
|
17
|
+
getNames().then(setNames);
|
|
18
|
+
}, []);
|
|
19
19
|
|
|
20
20
|
return (
|
|
21
21
|
<div
|
|
22
22
|
className="flex items-center justify-center min-h-screen p-4 text-white"
|
|
23
23
|
style={{
|
|
24
|
-
backgroundColor:
|
|
24
|
+
backgroundColor: "#000",
|
|
25
25
|
backgroundImage:
|
|
26
|
-
|
|
26
|
+
"radial-gradient(ellipse 60% 60% at 0% 100%, #444 0%, #222 60%, #000 100%)",
|
|
27
27
|
}}
|
|
28
28
|
>
|
|
29
29
|
<div className="w-full max-w-2xl p-8 rounded-xl backdrop-blur-md bg-black/50 shadow-xl border-8 border-black/10">
|
|
@@ -40,5 +40,5 @@ function Home() {
|
|
|
40
40
|
</ul>
|
|
41
41
|
</div>
|
|
42
42
|
</div>
|
|
43
|
-
)
|
|
43
|
+
);
|
|
44
44
|
}
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import { useCallback, useState } from
|
|
3
|
-
import { createFileRoute, useRouter } from
|
|
4
|
-
import { createServerFn } from
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
import { createFileRoute, useRouter } from "@tanstack/react-router";
|
|
4
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
5
5
|
|
|
6
|
-
const filePath =
|
|
6
|
+
const filePath = "todos.json";
|
|
7
7
|
|
|
8
8
|
async function readTodos() {
|
|
9
9
|
return JSON.parse(
|
|
10
|
-
await fs.promises.readFile(filePath,
|
|
10
|
+
await fs.promises.readFile(filePath, "utf-8").catch(() =>
|
|
11
11
|
JSON.stringify(
|
|
12
12
|
[
|
|
13
|
-
{ id: 1, name:
|
|
14
|
-
{ id: 2, name:
|
|
13
|
+
{ id: 1, name: "Get groceries" },
|
|
14
|
+
{ id: 2, name: "Buy a new phone" },
|
|
15
15
|
],
|
|
16
16
|
null,
|
|
17
17
|
2,
|
|
18
18
|
),
|
|
19
19
|
),
|
|
20
|
-
)
|
|
20
|
+
);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const getTodos = createServerFn({
|
|
24
|
-
method:
|
|
25
|
-
}).handler(async () => await readTodos())
|
|
24
|
+
method: "GET",
|
|
25
|
+
}).handler(async () => await readTodos());
|
|
26
26
|
|
|
27
|
-
const addTodo = createServerFn({ method:
|
|
27
|
+
const addTodo = createServerFn({ method: "POST" })
|
|
28
28
|
.inputValidator((d: string) => d)
|
|
29
29
|
.handler(async ({ data }) => {
|
|
30
|
-
const todos = await readTodos()
|
|
31
|
-
todos.push({ id: todos.length + 1, name: data })
|
|
32
|
-
await fs.promises.writeFile(filePath, JSON.stringify(todos, null, 2))
|
|
33
|
-
return todos
|
|
34
|
-
})
|
|
30
|
+
const todos = await readTodos();
|
|
31
|
+
todos.push({ id: todos.length + 1, name: data });
|
|
32
|
+
await fs.promises.writeFile(filePath, JSON.stringify(todos, null, 2));
|
|
33
|
+
return todos;
|
|
34
|
+
});
|
|
35
35
|
|
|
36
|
-
export const Route = createFileRoute(
|
|
36
|
+
export const Route = createFileRoute("/demo/start/server-funcs")({
|
|
37
37
|
component: Home,
|
|
38
38
|
loader: async () => await getTodos(),
|
|
39
|
-
})
|
|
39
|
+
});
|
|
40
40
|
|
|
41
41
|
function Home() {
|
|
42
|
-
const router = useRouter()
|
|
43
|
-
let todos = Route.useLoaderData()
|
|
42
|
+
const router = useRouter();
|
|
43
|
+
let todos = Route.useLoaderData();
|
|
44
44
|
|
|
45
|
-
const [todo, setTodo] = useState(
|
|
45
|
+
const [todo, setTodo] = useState("");
|
|
46
46
|
|
|
47
47
|
const submitTodo = useCallback(async () => {
|
|
48
|
-
todos = await addTodo({ data: todo })
|
|
49
|
-
setTodo(
|
|
50
|
-
router.invalidate()
|
|
51
|
-
}, [addTodo, todo])
|
|
48
|
+
todos = await addTodo({ data: todo });
|
|
49
|
+
setTodo("");
|
|
50
|
+
router.invalidate();
|
|
51
|
+
}, [addTodo, todo]);
|
|
52
52
|
|
|
53
53
|
return (
|
|
54
54
|
<div
|
|
55
55
|
className="flex items-center justify-center min-h-screen bg-gradient-to-br from-zinc-800 to-black p-4 text-white"
|
|
56
56
|
style={{
|
|
57
57
|
backgroundImage:
|
|
58
|
-
|
|
58
|
+
"radial-gradient(50% 50% at 20% 60%, #23272a 0%, #18181b 50%, #000000 100%)",
|
|
59
59
|
}}
|
|
60
60
|
>
|
|
61
61
|
<div className="w-full max-w-2xl p-8 rounded-xl backdrop-blur-md bg-black/50 shadow-xl border-8 border-black/10">
|
|
@@ -76,8 +76,8 @@ function Home() {
|
|
|
76
76
|
value={todo}
|
|
77
77
|
onChange={(e) => setTodo(e.target.value)}
|
|
78
78
|
onKeyDown={(e) => {
|
|
79
|
-
if (e.key ===
|
|
80
|
-
submitTodo()
|
|
79
|
+
if (e.key === "Enter") {
|
|
80
|
+
submitTodo();
|
|
81
81
|
}
|
|
82
82
|
}}
|
|
83
83
|
placeholder="Enter a new todo..."
|
|
@@ -93,5 +93,5 @@ function Home() {
|
|
|
93
93
|
</div>
|
|
94
94
|
</div>
|
|
95
95
|
</div>
|
|
96
|
-
)
|
|
96
|
+
);
|
|
97
97
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createFileRoute } from
|
|
2
|
-
import logo from
|
|
1
|
+
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
+
import logo from "../logo.svg";
|
|
3
3
|
|
|
4
|
-
export const Route = createFileRoute(
|
|
4
|
+
export const Route = createFileRoute("/")({
|
|
5
5
|
component: App,
|
|
6
|
-
})
|
|
6
|
+
});
|
|
7
7
|
|
|
8
8
|
function App() {
|
|
9
9
|
return (
|
|
@@ -35,5 +35,5 @@ function App() {
|
|
|
35
35
|
</a>
|
|
36
36
|
</header>
|
|
37
37
|
</div>
|
|
38
|
-
)
|
|
38
|
+
);
|
|
39
39
|
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import tailwindcss from
|
|
2
|
-
import { tanstackStart } from
|
|
3
|
-
import viteReact from
|
|
4
|
-
import alchemy from
|
|
5
|
-
import { defineConfig, type PluginOption } from
|
|
6
|
-
import viteTsConfigPaths from
|
|
1
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
2
|
+
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
|
|
3
|
+
import viteReact from "@vitejs/plugin-react";
|
|
4
|
+
import alchemy from "alchemy/cloudflare/tanstack-start";
|
|
5
|
+
import { defineConfig, type PluginOption } from "vite";
|
|
6
|
+
import viteTsConfigPaths from "vite-tsconfig-paths";
|
|
7
7
|
|
|
8
8
|
const config = defineConfig({
|
|
9
9
|
plugins: [
|
|
10
10
|
// this is the plugin that enables path aliases
|
|
11
11
|
viteTsConfigPaths({
|
|
12
|
-
projects: [
|
|
12
|
+
projects: ["./tsconfig.json"],
|
|
13
13
|
}),
|
|
14
14
|
tailwindcss(),
|
|
15
15
|
alchemy() as PluginOption,
|
|
16
16
|
tanstackStart(),
|
|
17
17
|
viteReact(),
|
|
18
18
|
],
|
|
19
|
-
})
|
|
19
|
+
});
|
|
20
20
|
|
|
21
|
-
export default config
|
|
21
|
+
export default config;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { worker } from "../alchemy.run.ts";
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
|
-
async fetch(
|
|
4
|
+
async fetch(
|
|
5
|
+
request: Request,
|
|
6
|
+
env: typeof worker.Env,
|
|
7
|
+
ctx: ExecutionContext,
|
|
8
|
+
): Promise<Response> {
|
|
5
9
|
return new Response("Hello World from my-alchemy-app!");
|
|
6
10
|
},
|
|
7
11
|
};
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import js from
|
|
2
|
-
import globals from
|
|
3
|
-
import reactHooks from
|
|
4
|
-
import reactRefresh from
|
|
5
|
-
import tseslint from
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import reactHooks from "eslint-plugin-react-hooks";
|
|
4
|
+
import reactRefresh from "eslint-plugin-react-refresh";
|
|
5
|
+
import tseslint from "typescript-eslint";
|
|
6
6
|
|
|
7
7
|
export default tseslint.config(
|
|
8
|
-
{ ignores: [
|
|
8
|
+
{ ignores: ["dist"] },
|
|
9
9
|
{
|
|
10
10
|
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
|
11
|
-
files: [
|
|
11
|
+
files: ["**/*.{ts,tsx}"],
|
|
12
12
|
languageOptions: {
|
|
13
13
|
ecmaVersion: 2020,
|
|
14
14
|
globals: globals.browser,
|
|
15
15
|
},
|
|
16
16
|
plugins: {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
"react-hooks": reactHooks,
|
|
18
|
+
"react-refresh": reactRefresh,
|
|
19
19
|
},
|
|
20
20
|
rules: {
|
|
21
21
|
...reactHooks.configs.recommended.rules,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
"react-refresh/only-export-components": [
|
|
23
|
+
"warn",
|
|
24
24
|
{ allowConstantExport: true },
|
|
25
25
|
],
|
|
26
26
|
},
|
|
27
27
|
},
|
|
28
|
-
)
|
|
28
|
+
);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useState } from
|
|
2
|
-
import reactLogo from
|
|
3
|
-
import viteLogo from
|
|
4
|
-
import
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import reactLogo from "./assets/react.svg";
|
|
3
|
+
import viteLogo from "/vite.svg";
|
|
4
|
+
import "./App.css";
|
|
5
5
|
|
|
6
6
|
function App() {
|
|
7
|
-
const [count, setCount] = useState(0)
|
|
7
|
+
const [count, setCount] = useState(0);
|
|
8
8
|
|
|
9
9
|
return (
|
|
10
10
|
<>
|
|
@@ -29,7 +29,7 @@ function App() {
|
|
|
29
29
|
Click on the Vite and React logos to learn more
|
|
30
30
|
</p>
|
|
31
31
|
</>
|
|
32
|
-
)
|
|
32
|
+
);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export default App
|
|
35
|
+
export default App;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { StrictMode } from
|
|
2
|
-
import { createRoot } from
|
|
3
|
-
import
|
|
4
|
-
import App from
|
|
1
|
+
import { StrictMode } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import "./index.css";
|
|
4
|
+
import App from "./App.tsx";
|
|
5
5
|
|
|
6
|
-
createRoot(document.getElementById(
|
|
6
|
+
createRoot(document.getElementById("root")!).render(
|
|
7
7
|
<StrictMode>
|
|
8
8
|
<App />
|
|
9
9
|
</StrictMode>,
|
|
10
|
-
)
|
|
10
|
+
);
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
fetch(request) {
|
|
3
|
+
const url = new URL(request.url);
|
|
4
|
+
|
|
5
|
+
if (url.pathname.startsWith("/api/")) {
|
|
6
|
+
return Response.json({
|
|
7
|
+
name: "Cloudflare",
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
return new Response(null, { status: 404 });
|
|
11
|
+
},
|
|
12
|
+
} satisfies ExportedHandler<Env>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import react from
|
|
1
|
+
import react from "@vitejs/plugin-react";
|
|
2
2
|
import alchemy from "alchemy/cloudflare/vite";
|
|
3
|
-
import { defineConfig } from
|
|
3
|
+
import { defineConfig } from "vite";
|
|
4
4
|
|
|
5
5
|
// https://vite.dev/config/
|
|
6
6
|
export default defineConfig({
|
package/workers/tunnel-proxy.js
CHANGED
|
@@ -34,7 +34,7 @@ var h={async fetch(e,r){let n=new URL(e.url);n.host=r.TUNNEL_HOST;let l=new Head
|
|
|
34
34
|
Alchemy</a>.</p>
|
|
35
35
|
</div>
|
|
36
36
|
<div class="bg-slate-200 px-5 py-3 flex flex-col w-full max-w-lg">
|
|
37
|
-
<p class="text-sm text-slate-500">Alchemy 0.
|
|
37
|
+
<p class="text-sm text-slate-500">Alchemy 0.76.0</p>
|
|
38
38
|
</div>
|
|
39
39
|
</div>
|
|
40
40
|
</body>
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import path from "pathe";
|
|
3
|
-
|
|
4
|
-
export async function findWorkspaceRoot(dir: string = process.cwd()) {
|
|
5
|
-
if ((await fs.stat(dir)).isDirectory()) {
|
|
6
|
-
if (await exists(dir, ".git")) {
|
|
7
|
-
// the root of the git repo is usually the workspace root and we should always stop here
|
|
8
|
-
return dir;
|
|
9
|
-
} else if ((await read(dir, "package.json"))?.workspaces) {
|
|
10
|
-
// package.json with workspaces (bun, npm, etc.)
|
|
11
|
-
return dir;
|
|
12
|
-
} else if (await anyExists(dir, ...rootFiles)) {
|
|
13
|
-
return dir;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return findWorkspaceRoot(path.resolve(dir, ".."));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const read = (...p: string[]): Promise<any> =>
|
|
20
|
-
fs
|
|
21
|
-
.readFile(path.join(...p), "utf8")
|
|
22
|
-
.then(JSON.parse)
|
|
23
|
-
.catch(() => undefined);
|
|
24
|
-
|
|
25
|
-
const exists = (...p: string[]) =>
|
|
26
|
-
fs
|
|
27
|
-
.access(path.join(...p))
|
|
28
|
-
.then(() => true)
|
|
29
|
-
.catch(() => false);
|
|
30
|
-
|
|
31
|
-
const anyExists = (base: string, ...files: string[]) =>
|
|
32
|
-
Promise.all(files.map((file) => exists(base, file))).then((results) =>
|
|
33
|
-
results.some(Boolean),
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const rootFiles = [
|
|
37
|
-
// pnpm
|
|
38
|
-
"pnpm-workspace.yaml",
|
|
39
|
-
"pnpm-workspace.yml",
|
|
40
|
-
// lerna
|
|
41
|
-
"lerna.json",
|
|
42
|
-
// nx
|
|
43
|
-
"nx.json",
|
|
44
|
-
// turbo
|
|
45
|
-
// "turbo.json",
|
|
46
|
-
// rush
|
|
47
|
-
"rush.json",
|
|
48
|
-
];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"symlink-miniflare-state.d.ts","sourceRoot":"","sources":["../../../src/cloudflare/miniflare/symlink-miniflare-state.ts"],"names":[],"mappings":"AAIA,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,iBAavE"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import path from "pathe";
|
|
3
|
-
import { getDefaultPersistPath } from "./paths.js";
|
|
4
|
-
export async function writeMiniflareSymlink(rootDir, cwd) {
|
|
5
|
-
const target = path.resolve(getDefaultPersistPath(cwd));
|
|
6
|
-
await fs.mkdir(target, { recursive: true });
|
|
7
|
-
if (cwd === rootDir) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const persistPath = path.resolve(cwd, getDefaultPersistPath(rootDir));
|
|
11
|
-
await fs.mkdir(path.dirname(persistPath), { recursive: true });
|
|
12
|
-
await fs.symlink(target, persistPath).catch((e) => {
|
|
13
|
-
if (e.code !== "EEXIST") {
|
|
14
|
-
throw e;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=symlink-miniflare-state.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"symlink-miniflare-state.js","sourceRoot":"","sources":["../../../src/cloudflare/miniflare/symlink-miniflare-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,OAAO,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAAe,EAAE,GAAW;IACtE,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC;IACxD,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;QACpB,OAAO;IACT,CAAC;IACD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC;IACtE,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,MAAM,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QAChD,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACxB,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import path from "pathe";
|
|
3
|
-
import { getDefaultPersistPath } from "./paths.ts";
|
|
4
|
-
|
|
5
|
-
export async function writeMiniflareSymlink(rootDir: string, cwd: string) {
|
|
6
|
-
const target = path.resolve(getDefaultPersistPath(cwd));
|
|
7
|
-
await fs.mkdir(target, { recursive: true });
|
|
8
|
-
if (cwd === rootDir) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
const persistPath = path.resolve(cwd, getDefaultPersistPath(rootDir));
|
|
12
|
-
await fs.mkdir(path.dirname(persistPath), { recursive: true });
|
|
13
|
-
await fs.symlink(target, persistPath).catch((e) => {
|
|
14
|
-
if (e.code !== "EEXIST") {
|
|
15
|
-
throw e;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}
|