Skip to content

Commit a697302

Browse files
authored
feat: add custom builder, pass 1 (#49)
1 parent 01fb5c1 commit a697302

34 files changed

+1347
-990
lines changed

.github/tools/fill_github_scopes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
// Imports
22
import type { rw } from "@libs/typing/types"
3-
import { parse, stringify } from "@std/yaml"
43
import { expandGlob } from "@std/fs"
54
import { Logger } from "@libs/logger"
65
import { command } from "@libs/run/command"
6+
import * as YAML from "@std/yaml"
77
const log = new Logger()
88

99
/*** Fill GitHub files with current existing scopes. */
1010
if (import.meta.main) {
11-
const scopes = [...await Array.fromAsync(Deno.readDir("@mizu"))].map(({ name }) => name)
11+
const scopes = [...await Array.fromAsync(Deno.readDir("@mizu"))].map(({ name }) => name).filter((name) => !["coverage"].includes(name))
1212
scopes.push("www", "repo")
1313
for await (const { path, name } of expandGlob(".github/ISSUE_TEMPLATE/*.yml")) {
1414
if (name === "config.yml") {
1515
continue
1616
}
17-
const parsed = parse(await Deno.readTextFile(path)) as rw
17+
const parsed = YAML.parse(await Deno.readTextFile(path)) as rw
1818
parsed.body.find((filed: rw) => filed.id === "scope").attributes.options = scopes
19-
await Deno.writeTextFile(path, stringify(parsed))
19+
await Deno.writeTextFile(path, YAML.stringify(parsed))
2020
await command("deno", ["fmt", path], { stdout: null, stderr: null })
2121
log.with({ path }).ok("done")
2222
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Imports
2+
import * as JSONC from "@std/jsonc"
3+
import * as core from "@actions/core"
4+
5+
// Parse deno.jsonc and print deno deploy flags
6+
// deno-lint-ignore no-explicit-any
7+
const config = JSONC.parse(await Deno.readTextFile("./deno.jsonc")) as any
8+
core.setOutput("project", config.deploy.project)
9+
core.setOutput("entrypoint", config.deploy.entrypoint)
10+
core.setOutput("include", config.deploy.include.join(","))
11+
core.setOutput("exclude", config.deploy.exclude.join(","))
12+
core.setOutput("import_map", ".imports_map.json")
13+
14+
await Deno.writeTextFile(".imports_map.json", JSON.stringify({ imports: config.imports }, null, 2))

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,37 @@ jobs:
4646
if: matrix.runtime == 'bun'
4747
- run: deno task test:${{ matrix.runtime }}
4848

49+
preview:
50+
name: Deploy
51+
runs-on: ubuntu-latest
52+
needs:
53+
- lint
54+
- test
55+
permissions:
56+
id-token: write
57+
contents: read
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: denoland/setup-deno@v2
61+
- name: Run deno task deploy:setup-github-actions
62+
run: deno task deploy:setup-github-actions
63+
id: setup_github_actions
64+
- uses: denoland/deployctl@v1
65+
with:
66+
project: ${{ steps.setup_github_actions.outputs.project }}
67+
entrypoint: ${{ steps.setup_github_actions.outputs.entrypoint }}
68+
import-map: ${{ steps.setup_github_actions.outputs.import_map }}
69+
include: ${{ steps.setup_github_actions.outputs.include }}
70+
exclude: ${{ steps.setup_github_actions.outputs.exclude }}
71+
4972
publish:
5073
name: Publish
5174
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
5275
runs-on: ubuntu-latest
5376
needs:
5477
- lint
5578
- test
79+
- preview
5680
permissions:
5781
id-token: write
5882
contents: read

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.cache
2-
.pages
32
.vercel
3+
.imports_map.json
44
coverage
55
node_modules
6+
www/.pages

@mizu/bind/boolean.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* See {@link https://html.spec.whatwg.org/#attributes-3 | HTML attributes reference}.
55
*/
6-
export function boolean(tagname: string, attribute: string) {
6+
export function boolean(tagname: string, attribute: string): boolean {
77
if (/^autofocus|inert|itemscope$/.test(attribute)) {
88
return true
99
}

@mizu/code/mod_test.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
<test name="[*code] with `.trim` modifier changes whitespaces handling">
3737
<script>
3838
context.value = [
39-
"",
40-
" function foo() {",
41-
" return 'bar'",
42-
" }",
43-
" ",
44-
].join("\n")
39+
"",
40+
" function foo() {",
41+
" return 'bar'",
42+
" }",
43+
" ",
44+
].join("\n")
4545
</script>
4646
<render>
4747
<pre>

@mizu/event/keyboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* @author Simon Lecoq (lowlighter)
3131
* @license MIT
3232
*/
33-
export function keyboard(keys: string) {
33+
export function keyboard(keys: string): (event: KeyboardEvent) => boolean {
3434
const combinations = keys.split(",").map((combination) => combination.split("+").map((key) => key.trim().toLowerCase()))
3535
return function (event: KeyboardEvent) {
3636
if (!/^key(?:down|press|up)$/.test(event.type)) {

0 commit comments

Comments
 (0)