Skip to content

Commit d21285a

Browse files
committed
feat(ci): add simple workflow
1 parent 03ef3c8 commit d21285a

14 files changed

Lines changed: 203 additions & 131 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: test_and_deploy_docs
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
test_and_deploy:
8+
name: test_and_deploy
9+
permissions:
10+
pages: write
11+
id-token: write
12+
environment:
13+
name: github-pages
14+
url: ${{ steps.deployment.outputs.page_url }}
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: oven-sh/setup-bun@v2
19+
- name: Install Dependencies
20+
run: bun install
21+
- name: Build
22+
run: bun run build
23+
- name: Upload static files as artifact
24+
uses: actions/upload-pages-artifact@v3
25+
with:
26+
path: apps/docs/build/
27+
- name: Deploy to GitHub Pages
28+
id: deployment
29+
uses: actions/deploy-pages@v4

apps/docs/app/index.ts

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { WaveKitResponse } from "@wavekit/kit";
2+
import { wave } from "@wavekit/wave";
13
import type { BunRequest } from "bun";
4+
import dedent from "dedent";
5+
import { createHighlighter } from "shiki";
26
import { Layout } from "../src/components/layout";
3-
import { wave } from "@wavekit/wave";
4-
import { WaveKitResponse } from "@wavekit/kit";
5-
import dedent from 'dedent'
6-
import { createHighlighter } from "shiki"
77

88
const waveKitServerCode = dedent`
99
// src/index.ts
@@ -13,7 +13,7 @@ const waveKitServerCode = dedent`
1313
console.log("Serving on http://localhost:3000")
1414
Bun.serve({ port: 3000, routes })
1515
})
16-
`
16+
`;
1717

1818
const waveKitAppCode = dedent`
1919
// app/index.ts
@@ -30,38 +30,47 @@ const waveKitAppCode = dedent`
3030
})
3131
)
3232
}
33-
`
33+
`;
3434

3535
export async function GET(req: BunRequest) {
3636
const highlighter = await createHighlighter({
3737
themes: ["github-dark"],
3838
langs: ["typescript"],
39-
})
39+
});
4040
return WaveKitResponse.html(
4141
Layout(
42-
wave
43-
.div({ style: "margin-top: 6rem;" }, (div) => {
44-
div
45-
.h1("The minimalist Bun web framework.")
46-
.p("WaveKit is a tiny framework built on top of Bun HTTP.")
47-
.h2("Features")
48-
.ul((ul) => {
49-
ul
50-
.li("Next.js style routing")
51-
.li("Zero extra dependencies")
52-
.li("Lightweight templating engine")
53-
.li("Works flawlessly with HTMX and Alpine.js")
54-
})
55-
.div({ style: "margin-top: 6rem;" }, (div) => {
56-
div
57-
.h2("Getting started")
58-
.p("The kit is a web server library. Use it like:")
59-
.h3("Install")
60-
.code("bun add @wavekit/wave @wavekit/kit")
61-
.h3("Usage")
62-
.div(highlighter.codeToHtml(waveKitServerCode, { lang: "typescript", theme: "github-dark" }))
63-
.div(highlighter.codeToHtml(waveKitAppCode, { lang: "typescript", theme: "github-dark" }))
64-
})
65-
}))
66-
)
42+
wave.div({ style: "margin-top: 6rem;" }, (div) => {
43+
div
44+
.h1("The minimalist Bun web framework.")
45+
.p("WaveKit is a tiny framework built on top of Bun HTTP.")
46+
.h2("Features")
47+
.ul((ul) => {
48+
ul.li("Next.js style routing")
49+
.li("Zero extra dependencies")
50+
.li("Lightweight templating engine")
51+
.li("Works flawlessly with HTMX and Alpine.js");
52+
})
53+
.div({ style: "margin-top: 6rem;" }, (div) => {
54+
div
55+
.h2("Getting started")
56+
.p("The kit is a web server library. Use it like:")
57+
.h3("Install")
58+
.code("bun add @wavekit/wave @wavekit/kit")
59+
.h3("Usage")
60+
.div(
61+
highlighter.codeToHtml(waveKitServerCode, {
62+
lang: "typescript",
63+
theme: "github-dark",
64+
}),
65+
)
66+
.div(
67+
highlighter.codeToHtml(waveKitAppCode, {
68+
lang: "typescript",
69+
theme: "github-dark",
70+
}),
71+
);
72+
});
73+
}),
74+
),
75+
);
6776
}

apps/docs/src/components/footer.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { wave } from "@wavekit/wave";
22

33
export function Footer() {
4-
const year = new Date().getFullYear();
5-
return wave.footer({ style: "margin-top:6rem;" }, `Copyright © ${year} WaveKit. All rights reserved.`)
6-
}
4+
const year = new Date().getFullYear();
5+
return wave.footer(
6+
{ style: "margin-top:6rem;" },
7+
`Copyright © ${year} WaveKit. All rights reserved.`,
8+
);
9+
}

apps/docs/src/components/layout.ts

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
1-
import { wave, type Child } from "@wavekit/wave"
2-
import { Navbar } from "./navbar"
3-
import { Footer } from "./footer"
1+
import { type Child, wave } from "@wavekit/wave";
2+
import { Footer } from "./footer";
3+
import { Navbar } from "./navbar";
44

5-
export function Layout (slot: Child) {
6-
return wave.html({ lang: "en" }, (html) => {
7-
html
8-
.head((head) => {
9-
head
10-
.meta({ charset: "UTF-8" })
11-
.meta({ name: "viewport", content: "width=device-width, initial-scale=1.0" })
12-
.title("Wavekit")
13-
.link({ rel: "stylesheet", href: "https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css" })
14-
})
15-
.body((body) => {
16-
body.main({ class: "container" }, [
17-
Navbar(),
18-
slot.toString(),
19-
Footer(),
20-
])
21-
})
22-
})
5+
export function Layout(slot: Child) {
6+
return wave.html({ lang: "en" }, (html) => {
7+
html
8+
.head((head) => {
9+
head
10+
.meta({ charset: "UTF-8" })
11+
.meta({
12+
name: "viewport",
13+
content: "width=device-width, initial-scale=1.0",
14+
})
15+
.title("Wavekit")
16+
.link({
17+
rel: "stylesheet",
18+
href: "https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css",
19+
});
20+
})
21+
.body((body) => {
22+
body.main({ class: "container" }, [
23+
Navbar(),
24+
slot.toString(),
25+
Footer(),
26+
]);
27+
});
28+
});
2329
}

apps/docs/src/components/navbar.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
import { wave } from "@wavekit/wave"
1+
import { wave } from "@wavekit/wave";
22

3-
const Logo = wave
4-
.li(
5-
(li) => li.a({ href: "/" }, "WaveKit")
6-
)
3+
const Logo = wave.li((li) => li.a({ href: "/" }, "WaveKit"));
74

8-
const NavItem = ({ href, label }: { href: string, label: string }) => {
9-
return wave
10-
.li(
11-
(li) => li.a({ href, target: "_blank", rel: "noopener noreferrer" }, label)
12-
)
13-
}
5+
const NavItem = ({ href, label }: { href: string; label: string }) => {
6+
return wave.li((li) =>
7+
li.a({ href, target: "_blank", rel: "noopener noreferrer" }, label),
8+
);
9+
};
1410

15-
export const Navbar = () => wave
16-
.nav((nav) => {
17-
nav
18-
.ul([Logo])
19-
.ul([NavItem({ href: "https://github.com/getgrinta/wavekit", label: "GitHub" })])
20-
})
11+
export const Navbar = () =>
12+
wave.nav((nav) => {
13+
nav
14+
.ul([Logo])
15+
.ul([
16+
NavItem({
17+
href: "https://github.com/getgrinta/wavekit",
18+
label: "GitHub",
19+
}),
20+
]);
21+
});

apps/docs/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { ssgRender } from "@wavekit/kit"
1+
import { ssgRender } from "@wavekit/kit";
22

3-
ssgRender()
3+
ssgRender();

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "wavekit",
33
"private": true,
44
"scripts": {
5+
"build": "bun --filter \"*\" build",
56
"lint": "bunx --bun biome check .",
67
"format": "bunx --bun biome check --write --unsafe ."
78
},

packages/kit/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export { createWaveKit, ssgRender } from './server'
2-
export { WaveKitResponse } from './response'
1+
export { createWaveKit, ssgRender } from "./server";
2+
export { WaveKitResponse } from "./response";

packages/kit/src/response.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import type { Attributes, HTMLElementProxy } from "@wavekit/wave";
22

33
export class WaveKitResponse extends Response {
4-
static html(content: HTMLElementProxy<Attributes> | string) {
5-
return new WaveKitResponse(content.toString(), { headers: { "Content-Type": "text/html" } })
6-
}
4+
static html(content: HTMLElementProxy<Attributes> | string) {
5+
return new WaveKitResponse(content.toString(), {
6+
headers: { "Content-Type": "text/html" },
7+
});
8+
}
79
}

packages/kit/src/server.spec.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { it, expect } from "bun:test"
2-
import { buildRoutes, createWaveKit } from "./server"
3-
import path from "node:path"
1+
import { expect, it } from "bun:test";
2+
import path from "node:path";
3+
import { buildRoutes, createWaveKit } from "./server";
44

5-
const TEST_DIR = path.join(process.cwd(), "test", "app")
5+
const TEST_DIR = path.join(process.cwd(), "test", "app");
66

77
const FAKE_ROUTES = {
8-
"/": path.join(TEST_DIR, "test.ts"),
9-
}
8+
"/": path.join(TEST_DIR, "test.ts"),
9+
};
1010

1111
it("should prepare routes", async () => {
12-
const routes = await buildRoutes({ routes: FAKE_ROUTES })
13-
expect(routes["/"]).toHaveProperty("GET")
14-
})
12+
const routes = await buildRoutes({ routes: FAKE_ROUTES });
13+
expect(routes["/"]).toHaveProperty("GET");
14+
});
1515

1616
it("should create wavekit config", async () => {
17-
const routes = await createWaveKit({ routesDir: TEST_DIR })
18-
expect(routes["/test"]).toHaveProperty("GET")
19-
})
17+
const routes = await createWaveKit({ routesDir: TEST_DIR });
18+
expect(routes["/test"]).toHaveProperty("GET");
19+
});

0 commit comments

Comments
 (0)