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,22 +1,22 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
|
|
3
|
-
import type { Auth, AuthToken } from
|
|
3
|
+
import type { Auth, AuthToken } from "./auth.gen";
|
|
4
4
|
import type {
|
|
5
5
|
BodySerializer,
|
|
6
6
|
QuerySerializer,
|
|
7
7
|
QuerySerializerOptions,
|
|
8
|
-
} from
|
|
8
|
+
} from "./bodySerializer.gen";
|
|
9
9
|
|
|
10
10
|
export type HttpMethod =
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
11
|
+
| "connect"
|
|
12
|
+
| "delete"
|
|
13
|
+
| "get"
|
|
14
|
+
| "head"
|
|
15
|
+
| "options"
|
|
16
|
+
| "patch"
|
|
17
|
+
| "post"
|
|
18
|
+
| "put"
|
|
19
|
+
| "trace";
|
|
20
20
|
|
|
21
21
|
export type Client<
|
|
22
22
|
RequestFn = never,
|
|
@@ -56,7 +56,7 @@ export interface Config {
|
|
|
56
56
|
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
|
57
57
|
*/
|
|
58
58
|
headers?:
|
|
59
|
-
| RequestInit[
|
|
59
|
+
| RequestInit["headers"]
|
|
60
60
|
| Record<
|
|
61
61
|
string,
|
|
62
62
|
| string
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
2
|
|
|
3
|
-
import type { BodySerializer, QuerySerializer } from
|
|
3
|
+
import type { BodySerializer, QuerySerializer } from "./bodySerializer.gen";
|
|
4
4
|
import {
|
|
5
5
|
type ArraySeparatorStyle,
|
|
6
6
|
serializeArrayParam,
|
|
7
7
|
serializeObjectParam,
|
|
8
8
|
serializePrimitiveParam,
|
|
9
|
-
} from
|
|
9
|
+
} from "./pathSerializer.gen";
|
|
10
10
|
|
|
11
11
|
export interface PathSerializer {
|
|
12
12
|
path: Record<string, unknown>;
|
|
@@ -22,19 +22,19 @@ export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|
|
22
22
|
for (const match of matches) {
|
|
23
23
|
let explode = false;
|
|
24
24
|
let name = match.substring(1, match.length - 1);
|
|
25
|
-
let style: ArraySeparatorStyle =
|
|
25
|
+
let style: ArraySeparatorStyle = "simple";
|
|
26
26
|
|
|
27
|
-
if (name.endsWith(
|
|
27
|
+
if (name.endsWith("*")) {
|
|
28
28
|
explode = true;
|
|
29
29
|
name = name.substring(0, name.length - 1);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
if (name.startsWith(
|
|
32
|
+
if (name.startsWith(".")) {
|
|
33
33
|
name = name.substring(1);
|
|
34
|
-
style =
|
|
35
|
-
} else if (name.startsWith(
|
|
34
|
+
style = "label";
|
|
35
|
+
} else if (name.startsWith(";")) {
|
|
36
36
|
name = name.substring(1);
|
|
37
|
-
style =
|
|
37
|
+
style = "matrix";
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const value = path[name];
|
|
@@ -51,7 +51,7 @@ export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|
|
51
51
|
continue;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
if (typeof value ===
|
|
54
|
+
if (typeof value === "object") {
|
|
55
55
|
url = url.replace(
|
|
56
56
|
match,
|
|
57
57
|
serializeObjectParam({
|
|
@@ -65,7 +65,7 @@ export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|
|
65
65
|
continue;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
if (style ===
|
|
68
|
+
if (style === "matrix") {
|
|
69
69
|
url = url.replace(
|
|
70
70
|
match,
|
|
71
71
|
`;${serializePrimitiveParam({
|
|
@@ -77,7 +77,7 @@ export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
const replaceValue = encodeURIComponent(
|
|
80
|
-
style ===
|
|
80
|
+
style === "label" ? `.${value as string}` : (value as string),
|
|
81
81
|
);
|
|
82
82
|
url = url.replace(match, replaceValue);
|
|
83
83
|
}
|
|
@@ -98,13 +98,13 @@ export const getUrl = ({
|
|
|
98
98
|
querySerializer: QuerySerializer;
|
|
99
99
|
url: string;
|
|
100
100
|
}) => {
|
|
101
|
-
const pathUrl = _url.startsWith(
|
|
102
|
-
let url = (baseUrl ??
|
|
101
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
102
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
103
103
|
if (path) {
|
|
104
104
|
url = defaultPathSerializer({ path, url });
|
|
105
105
|
}
|
|
106
|
-
let search = query ? querySerializer(query) :
|
|
107
|
-
if (search.startsWith(
|
|
106
|
+
let search = query ? querySerializer(query) : "";
|
|
107
|
+
if (search.startsWith("?")) {
|
|
108
108
|
search = search.substring(1);
|
|
109
109
|
}
|
|
110
110
|
if (search) {
|
|
@@ -122,15 +122,15 @@ export function getValidRequestBody(options: {
|
|
|
122
122
|
const isSerializedBody = hasBody && options.bodySerializer;
|
|
123
123
|
|
|
124
124
|
if (isSerializedBody) {
|
|
125
|
-
if (
|
|
125
|
+
if ("serializedBody" in options) {
|
|
126
126
|
const hasSerializedBody =
|
|
127
|
-
options.serializedBody !== undefined && options.serializedBody !==
|
|
127
|
+
options.serializedBody !== undefined && options.serializedBody !== "";
|
|
128
128
|
|
|
129
129
|
return hasSerializedBody ? options.serializedBody : null;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
// not all clients implement a serializedBody property (i.e. client-axios)
|
|
133
|
-
return options.body !==
|
|
133
|
+
return options.body !== "" ? options.body : null;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
// plain/text body
|
|
@@ -25,18 +25,20 @@ export function camelToSnakeObjectDeep<T extends object | undefined>(
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// Helper to check if a character is uppercase
|
|
28
|
-
type IsUpper<C extends string> =
|
|
29
|
-
|
|
30
|
-
?
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
type IsUpper<C extends string> =
|
|
29
|
+
C extends Uppercase<C>
|
|
30
|
+
? C extends Lowercase<C>
|
|
31
|
+
? false // Not a letter
|
|
32
|
+
: true // Uppercase letter
|
|
33
|
+
: false;
|
|
33
34
|
|
|
34
35
|
// Helper to check if a character is lowercase
|
|
35
|
-
type IsLower<C extends string> =
|
|
36
|
-
|
|
37
|
-
?
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
type IsLower<C extends string> =
|
|
37
|
+
C extends Lowercase<C>
|
|
38
|
+
? C extends Uppercase<C>
|
|
39
|
+
? false // Not a letter
|
|
40
|
+
: true // Lowercase letter
|
|
41
|
+
: false;
|
|
40
42
|
|
|
41
43
|
// Convert a camelCase string to snake_case at the type level
|
|
42
44
|
type CamelToSnakeString<
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import fsp from "node:fs/promises";
|
|
3
|
+
import path from "pathe";
|
|
4
|
+
import { exists } from "./exists.ts";
|
|
5
|
+
|
|
6
|
+
export async function findWorkspaceRoot(
|
|
7
|
+
directory: string = process.cwd(),
|
|
8
|
+
): Promise<string> {
|
|
9
|
+
const checks = await Promise.all(
|
|
10
|
+
Object.entries(predicates).map(async ([file, predicate]) => {
|
|
11
|
+
return await check(path.join(directory, file), predicate);
|
|
12
|
+
}),
|
|
13
|
+
);
|
|
14
|
+
if (checks.includes(true)) {
|
|
15
|
+
return directory;
|
|
16
|
+
}
|
|
17
|
+
const parent = path.resolve(directory, "..");
|
|
18
|
+
if (parent === directory) {
|
|
19
|
+
// Bail if we've reached the filesystem root to avoid infinite recursion
|
|
20
|
+
return directory;
|
|
21
|
+
}
|
|
22
|
+
return await findWorkspaceRoot(parent);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function findWorkspaceRootSync(
|
|
26
|
+
directory: string = process.cwd(),
|
|
27
|
+
): string {
|
|
28
|
+
for (const [file, predicate] of Object.entries(predicates)) {
|
|
29
|
+
const filePath = path.join(directory, file);
|
|
30
|
+
if (checkSync(filePath, predicate)) {
|
|
31
|
+
return directory;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const parent = path.resolve(directory, "..");
|
|
35
|
+
if (parent === directory) {
|
|
36
|
+
// Bail if we've reached the filesystem root to avoid infinite recursion
|
|
37
|
+
return directory;
|
|
38
|
+
}
|
|
39
|
+
return findWorkspaceRootSync(parent);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function check(filePath: string, predicate: Predicate) {
|
|
43
|
+
if (!(await exists(filePath))) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (typeof predicate === "function") {
|
|
48
|
+
try {
|
|
49
|
+
const value = await fsp.readFile(filePath, "utf-8");
|
|
50
|
+
const json = JSON.parse(value);
|
|
51
|
+
return predicate(json);
|
|
52
|
+
} catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function checkSync(filePath: string, predicate: Predicate) {
|
|
61
|
+
if (!fs.existsSync(filePath)) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (typeof predicate === "function") {
|
|
66
|
+
try {
|
|
67
|
+
const value = fs.readFileSync(filePath, "utf-8");
|
|
68
|
+
const json = JSON.parse(value);
|
|
69
|
+
return predicate(json);
|
|
70
|
+
} catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
return predicate;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
type Predicate = true | ((value: Record<string, unknown>) => boolean);
|
|
79
|
+
|
|
80
|
+
const predicates: Record<string, Predicate> = {
|
|
81
|
+
// bun
|
|
82
|
+
"bun.lock": true,
|
|
83
|
+
"bun.lockb": true,
|
|
84
|
+
|
|
85
|
+
// git
|
|
86
|
+
".git": true,
|
|
87
|
+
|
|
88
|
+
// lerna
|
|
89
|
+
"lerna.json": true,
|
|
90
|
+
|
|
91
|
+
// npm
|
|
92
|
+
"package.json": (value) => "workspaces" in value,
|
|
93
|
+
"package-lock.json": true,
|
|
94
|
+
|
|
95
|
+
// nx
|
|
96
|
+
"nx.json": true,
|
|
97
|
+
|
|
98
|
+
// pnpm
|
|
99
|
+
"pnpm-lock.yaml": true,
|
|
100
|
+
"pnpm-workspace.yaml": true,
|
|
101
|
+
"pnpm-workspace.yml": true,
|
|
102
|
+
|
|
103
|
+
// rush
|
|
104
|
+
"rush.json": true,
|
|
105
|
+
|
|
106
|
+
// turbo
|
|
107
|
+
// (a monorepo can contain more than one turbo.json, but unless it's the root, it must contain the `extends` property)
|
|
108
|
+
"turbo.json": (value) => !("extends" in value),
|
|
109
|
+
|
|
110
|
+
// yarn
|
|
111
|
+
"yarn.lock": true,
|
|
112
|
+
};
|
|
@@ -158,11 +158,7 @@ export async function idempotentSpawn({
|
|
|
158
158
|
// Follow a file from persisted offset and mirror to a sink (stdout/stderr)
|
|
159
159
|
async function followFilePersisted(
|
|
160
160
|
logPath: string,
|
|
161
|
-
{
|
|
162
|
-
write,
|
|
163
|
-
chunkSize = 64 * 1024,
|
|
164
|
-
tickMs = 100,
|
|
165
|
-
}: {
|
|
161
|
+
{ write, chunkSize = 64 * 1024, tickMs = 100 }: {
|
|
166
162
|
stateKey: string;
|
|
167
163
|
write: (buf: Buffer) => boolean;
|
|
168
164
|
chunkSize?: number;
|
package/src/util/peer.ts
CHANGED
|
@@ -11,7 +11,9 @@ export class PeerDependencyError extends Error {
|
|
|
11
11
|
}) {
|
|
12
12
|
super(
|
|
13
13
|
[
|
|
14
|
-
`Missing peer ${input.missing.length} ${
|
|
14
|
+
`Missing peer ${input.missing.length} ${
|
|
15
|
+
input.missing.length === 1 ? "dependency" : "dependencies"
|
|
16
|
+
}${input.feature ? ` for ${input.feature}` : ""}:`,
|
|
15
17
|
...input.missing.map((dep) => `- "${dep}"`),
|
|
16
18
|
"",
|
|
17
19
|
"Please install with:",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import alchemy from
|
|
2
|
-
import { defineConfig } from
|
|
1
|
+
import alchemy from "alchemy/cloudflare/astro";
|
|
2
|
+
import { defineConfig } from "astro/config";
|
|
3
3
|
|
|
4
4
|
// https://astro.build/config
|
|
5
5
|
export default defineConfig({
|
|
6
|
-
output:
|
|
6
|
+
output: "server",
|
|
7
7
|
adapter: alchemy(),
|
|
8
8
|
});
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import type { APIRoute } from
|
|
1
|
+
import type { APIRoute } from "astro";
|
|
2
2
|
|
|
3
3
|
export const GET: APIRoute = async ({ request }) => {
|
|
4
4
|
// Access Cloudflare runtime context
|
|
5
5
|
const runtime = request.cf;
|
|
6
|
-
|
|
7
|
-
return new Response(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
|
|
7
|
+
return new Response(
|
|
8
|
+
JSON.stringify({
|
|
9
|
+
message: "Hello from Astro API on Cloudflare!",
|
|
10
|
+
timestamp: new Date().toISOString(),
|
|
11
|
+
colo: runtime?.colo || "unknown",
|
|
12
|
+
country: runtime?.country || "unknown",
|
|
13
|
+
city: runtime?.city || "unknown",
|
|
14
|
+
}),
|
|
15
|
+
{
|
|
16
|
+
status: 200,
|
|
17
|
+
headers: {
|
|
18
|
+
"Content-Type": "application/json",
|
|
19
|
+
},
|
|
17
20
|
},
|
|
18
|
-
|
|
21
|
+
);
|
|
19
22
|
};
|
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
import js from
|
|
2
|
-
import reactHooks from
|
|
3
|
-
import reactRefresh from
|
|
4
|
-
import tseslint from
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import reactHooks from "eslint-plugin-react-hooks";
|
|
3
|
+
import reactRefresh from "eslint-plugin-react-refresh";
|
|
4
|
+
import tseslint from "typescript-eslint";
|
|
5
5
|
|
|
6
6
|
export default tseslint.config(
|
|
7
|
-
{ ignores: [
|
|
7
|
+
{ ignores: ["dist"] },
|
|
8
8
|
{
|
|
9
9
|
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
|
10
|
-
files: [
|
|
10
|
+
files: ["**/*.{ts,tsx}"],
|
|
11
11
|
languageOptions: {
|
|
12
12
|
ecmaVersion: 2020,
|
|
13
13
|
},
|
|
14
14
|
plugins: {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
"react-hooks": reactHooks,
|
|
16
|
+
"react-refresh": reactRefresh,
|
|
17
17
|
},
|
|
18
18
|
rules: {
|
|
19
19
|
...reactHooks.configs.recommended.rules,
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
"react-refresh/only-export-components": [
|
|
21
|
+
"warn",
|
|
22
22
|
{ allowConstantExport: true },
|
|
23
23
|
],
|
|
24
24
|
},
|
|
25
25
|
},
|
|
26
|
-
)
|
|
27
|
-
|
|
26
|
+
);
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Hono } from
|
|
1
|
+
import { Hono } from "hono";
|
|
2
2
|
|
|
3
|
-
const app = new Hono<{ Bindings: Env }>()
|
|
3
|
+
const app = new Hono<{ Bindings: Env }>();
|
|
4
4
|
|
|
5
|
-
app.get(
|
|
6
|
-
return c.text(
|
|
7
|
-
})
|
|
5
|
+
app.get("/", (c) => {
|
|
6
|
+
return c.text("Hello Hono!");
|
|
7
|
+
});
|
|
8
8
|
|
|
9
|
-
app.get(
|
|
10
|
-
const key =
|
|
11
|
-
const value = `world@${Date.now()}
|
|
12
|
-
await c.env.KV.put(key, value)
|
|
13
|
-
const got = await c.env.KV.get(key)
|
|
14
|
-
return c.json({ key, value: got })
|
|
15
|
-
})
|
|
9
|
+
app.get("/kv", async (c) => {
|
|
10
|
+
const key = "hello";
|
|
11
|
+
const value = `world@${Date.now()}`;
|
|
12
|
+
await c.env.KV.put(key, value);
|
|
13
|
+
const got = await c.env.KV.get(key);
|
|
14
|
+
return c.json({ key, value: got });
|
|
15
|
+
});
|
|
16
16
|
|
|
17
|
-
export default app
|
|
17
|
+
export default app;
|
|
@@ -10,10 +10,10 @@ export async function GET(request: NextRequest) {
|
|
|
10
10
|
|
|
11
11
|
export async function POST(request: NextRequest) {
|
|
12
12
|
const body = await request.json();
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
return Response.json({
|
|
15
15
|
message: "POST received",
|
|
16
16
|
data: body,
|
|
17
17
|
timestamp: new Date().toISOString(),
|
|
18
18
|
});
|
|
19
|
-
}
|
|
19
|
+
}
|
|
@@ -4,15 +4,12 @@ export default function Home() {
|
|
|
4
4
|
<h1>Welcome to Next.js on Cloudflare Workers!</h1>
|
|
5
5
|
<p>
|
|
6
6
|
This is a Next.js application deployed to Cloudflare Workers using{" "}
|
|
7
|
-
<a
|
|
8
|
-
href="https://alchemy.run"
|
|
9
|
-
target="_blank"
|
|
10
|
-
rel="noopener noreferrer"
|
|
11
|
-
>
|
|
7
|
+
<a href="https://alchemy.run" target="_blank" rel="noopener noreferrer">
|
|
12
8
|
Alchemy
|
|
13
|
-
</a
|
|
9
|
+
</a>
|
|
10
|
+
.
|
|
14
11
|
</p>
|
|
15
|
-
|
|
12
|
+
|
|
16
13
|
<section>
|
|
17
14
|
<h2>Features</h2>
|
|
18
15
|
<ul>
|
|
@@ -27,23 +24,25 @@ export default function Home() {
|
|
|
27
24
|
|
|
28
25
|
<section>
|
|
29
26
|
<h2>Get Started</h2>
|
|
30
|
-
<p>
|
|
27
|
+
<p>
|
|
28
|
+
Edit <code>src/app/page.tsx</code> and save to see your changes.
|
|
29
|
+
</p>
|
|
31
30
|
</section>
|
|
32
31
|
|
|
33
32
|
<footer>
|
|
34
33
|
<p>
|
|
35
34
|
Learn more:{" "}
|
|
36
|
-
<a
|
|
37
|
-
href="https://nextjs.org/docs"
|
|
38
|
-
target="_blank"
|
|
35
|
+
<a
|
|
36
|
+
href="https://nextjs.org/docs"
|
|
37
|
+
target="_blank"
|
|
39
38
|
rel="noopener noreferrer"
|
|
40
39
|
>
|
|
41
40
|
Next.js Docs
|
|
42
41
|
</a>{" "}
|
|
43
42
|
|{" "}
|
|
44
|
-
<a
|
|
45
|
-
href="https://alchemy.run"
|
|
46
|
-
target="_blank"
|
|
43
|
+
<a
|
|
44
|
+
href="https://alchemy.run"
|
|
45
|
+
target="_blank"
|
|
47
46
|
rel="noopener noreferrer"
|
|
48
47
|
>
|
|
49
48
|
Alchemy Docs
|
|
@@ -52,4 +51,4 @@ export default function Home() {
|
|
|
52
51
|
</footer>
|
|
53
52
|
</main>
|
|
54
53
|
);
|
|
55
|
-
}
|
|
54
|
+
}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
import type { website } from "./alchemy.run.ts";
|
|
5
5
|
|
|
6
6
|
declare global {
|
|
7
|
-
|
|
7
|
+
type CloudflareEnv = typeof website.Env;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
declare module "cloudflare:workers" {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
namespace Cloudflare {
|
|
12
|
+
export interface Env extends CloudflareEnv {}
|
|
13
|
+
}
|
|
14
14
|
}
|
|
@@ -8,7 +8,7 @@ export default async function handleRequest(
|
|
|
8
8
|
responseStatusCode: number,
|
|
9
9
|
responseHeaders: Headers,
|
|
10
10
|
routerContext: EntryContext,
|
|
11
|
-
_loadContext: AppLoadContext
|
|
11
|
+
_loadContext: AppLoadContext,
|
|
12
12
|
) {
|
|
13
13
|
let shellRendered = false;
|
|
14
14
|
const userAgent = request.headers.get("user-agent");
|
|
@@ -25,7 +25,7 @@ export default async function handleRequest(
|
|
|
25
25
|
console.error(error);
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
|
-
}
|
|
28
|
+
},
|
|
29
29
|
);
|
|
30
30
|
shellRendered = true;
|
|
31
31
|
|
|
@@ -11,7 +11,7 @@ declare module "react-router" {
|
|
|
11
11
|
|
|
12
12
|
const requestHandler = createRequestHandler(
|
|
13
13
|
() => import("virtual:react-router/server-build"),
|
|
14
|
-
import.meta.env.MODE
|
|
14
|
+
import.meta.env.MODE,
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
export default {
|
|
@@ -20,4 +20,4 @@ export default {
|
|
|
20
20
|
cloudflare: { env, ctx },
|
|
21
21
|
});
|
|
22
22
|
},
|
|
23
|
-
}
|
|
23
|
+
};
|