Skip to content

Commit c811d43

Browse files
authored
begin migration from wrangler to alchemy (v2) (#445)
1 parent 5e53b08 commit c811d43

33 files changed

Lines changed: 2091 additions & 273 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy Docs
1+
name: Deploy
22

33
on:
44
workflow_dispatch:
@@ -12,18 +12,15 @@ concurrency:
1212
group: ${{ github.workflow }}
1313

1414
jobs:
15-
deploy-docs:
15+
deploy:
1616
runs-on: ubuntu-latest
17-
environment: docs
17+
environment: deploy
1818
steps:
1919
- uses: actions/checkout@v6
2020
- run: "git -c url.https://github.com/.insteadOf=git@github.com: submodule update --init konfik"
2121
- uses: ./konfik/.github/actions/configure_environment
2222
- run: pnpm build
23-
- run: pnpm build
24-
working-directory: docs
25-
- run: pnpm wrangler deploy
26-
working-directory: docs
23+
- run: pnpm exec alchemy deploy --stage prod --yes
2724
env:
2825
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
2926
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.tsbuildinfo
22
.DS_Store
3+
.alchemy
34
.dev.vars
45
.direnv/
56
.env*

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@
2525
[submodule "repos/vitest"]
2626
path = repos/vitest
2727
url = git@github.com:vitest-dev/vitest.git
28+
[submodule "repos/alchemy-effect"]
29+
path = repos/alchemy-effect
30+
url = git@github.com:alchemy-run/alchemy-effect.git

alchemy.run.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import * as Alchemy from "alchemy"
2+
import * as Cloudflare from "alchemy/Cloudflare"
3+
import * as Effect from "effect/Effect"
4+
5+
import { LiminalDocs } from "./docs/alchemy.run.ts"
6+
import { TicTacToe } from "./examples/tictactoe/alchemy.run.ts"
7+
8+
export default Alchemy.Stack(
9+
"liminal",
10+
{
11+
providers: Cloudflare.providers(),
12+
state: Cloudflare.state(),
13+
},
14+
Effect.gen(function* () {
15+
const docs = yield* LiminalDocs
16+
const tictactoe = yield* TicTacToe
17+
18+
return {
19+
docsUrl: docs.url,
20+
docsDomains: docs.domains,
21+
tictactoeUrl: tictactoe.url,
22+
tictactoeDomains: tictactoe.domains,
23+
}
24+
}),
25+
)

docs/alchemy.run.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as Cloudflare from "alchemy/Cloudflare"
2+
3+
export const LiminalDocs = Cloudflare.StaticSite("LiminalDocs", {
4+
name: "liminal-docs",
5+
cwd: "docs",
6+
command: "pnpm build",
7+
outdir: "dist",
8+
main: "docs/main.ts",
9+
compatibility: { date: "2026-04-08" },
10+
observability: { enabled: true },
11+
assetsConfig: { notFoundHandling: "single-page-application" },
12+
domain: ["liminal.actor", "www.liminal.actor"],
13+
})

docs/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from "effect-workerd/asset_forwarding"

docs/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
},
1111
"dependencies": {
1212
"@types/react": "catalog:",
13+
"alchemy": "catalog:",
1314
"effect": "catalog:",
15+
"effect-workerd": "workspace:*",
1416
"liminal": "workspace:*",
1517
"portless": "catalog:",
1618
"react": "catalog:",

docs/wrangler.jsonc

Lines changed: 0 additions & 22 deletions
This file was deleted.

effect-workerd/Binding.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { env } from "cloudflare:workers"
21
import { Context, Layer, Effect, Schema as S, SchemaIssue } from "effect"
32
import * as Spanner from "liminal-util/Spanner"
43

4+
import { Env } from "./Env.ts"
5+
56
const span = Spanner.make(import.meta.url)
67

78
export const layer =
@@ -12,8 +13,9 @@ export const layer =
1213
) =>
1314
(binding: string) =>
1415
Effect.gen(function* () {
15-
const resolved = (env as never)[binding]
16-
if (!resolved) {
16+
const env = yield* Env
17+
const resolved = env[binding]
18+
if (!resolved || typeof resolved !== "object" || resolved === null) {
1719
return yield* Effect.fail(
1820
new S.SchemaError(
1921
new SchemaIssue.Pointer(
@@ -39,7 +41,7 @@ export const layer =
3941
)
4042
}
4143
}
42-
return Layer.mergeAll(Layer.succeed(tag, resolved), derive?.(resolved) ?? Layer.empty)
44+
return Layer.mergeAll(Layer.succeed(tag, resolved as never), derive?.(resolved as never) ?? Layer.empty)
4345
}).pipe(
4446
span("make-binding", {
4547
attributes: { id: tag.key },

effect-workerd/Env.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { Context } from "effect"
2+
3+
export class Env extends Context.Service<Env, Record<string, unknown>>()("effect-workerd/Env") {}

0 commit comments

Comments
 (0)