From 3d6bfb380c853e41b7b617dbefa28ab3cb623513 Mon Sep 17 00:00:00 2001 From: uki00a Date: Sun, 8 Dec 2024 23:55:11 +0900 Subject: [PATCH 1/2] ci: remove `tools/make_mod.ts` --- .github/workflows/build.yml | 5 -- tools/make_mod.ts | 93 ------------------------------------- 2 files changed, 98 deletions(-) delete mode 100755 tools/make_mod.ts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8fccb440..e0cc4518 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,11 +35,6 @@ jobs: ~/.deno ~/.cache/deno key: ${{ runner.os }}-deno-${{ hashFiles('deps/**', '.denov', 'deno.lock') }} - - name: Check mod.ts - run: | - deno task make_mod - git diff --exit-code - deno check mod.ts - name: Set up Redis ${{ matrix.redis }} uses: shogo82148/actions-setup-redis@v1 with: diff --git a/tools/make_mod.ts b/tools/make_mod.ts deleted file mode 100755 index a1ea52d5..00000000 --- a/tools/make_mod.ts +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env deno run --allow-read --allow-write --allow-run - -import { readAll, readerFromStreamReader } from "../deps/std/io.ts"; - -const encoder = new TextEncoder(); -const decoder = new TextDecoder(); - -interface Node { - kind: string; - name: string; - declarationKind: "export" | "private"; -} - -interface Doc { - nodes: Array; -} - -async function doc(fileName: string): Promise { - const deno = new Deno.Command(Deno.execPath(), { - args: ["doc", "--json", fileName], - }); - const { stdout } = await deno.output(); - return JSON.parse(decoder.decode(stdout)); -} - -async function fmt(content: string): Promise { - const deno = new Deno.Command(Deno.execPath(), { - args: ["fmt", "-"], - stdin: "piped", - stdout: "piped", - }).spawn(); - const stdin = deno.stdin.getWriter(); - await stdin.ready; - await stdin.write(encoder.encode(content)); - await stdin.ready; - await stdin.close(); - await deno.status; - const stdout = await readAll(readerFromStreamReader(deno.stdout.getReader())); - const formattedContent = decoder.decode(stdout); - return formattedContent; -} - -function collectSourceFilesInRootDir(): Array { - return [...Deno.readDirSync(".")].filter((f) => { - const name = f.name; - if (!name || name === "mod.ts") return false; - return name.endsWith(".ts") && !name.endsWith("_test.ts") && - !name.endsWith(".d.ts"); - }).map((f) => f.name); -} - -const files = [...collectSourceFilesInRootDir(), "protocol/shared/types.ts"] - .sort(); -let content = `// Generated by tools/make_mod.ts. Don't edit.\n`; - -// Expose public variables from protocol/shared/types.ts -{ - const fileName = "protocol/shared/types.ts"; - const variables = (await doc(fileName)).nodes.filter((node) => { - return node.kind === "variable"; - }).map((node) => node.name); - content += `export { ${variables.join(",")} } from "./${fileName}";\n`; -} - -// Expose public functions from redis.ts. -{ - const fileName = "redis.ts"; - const functions = (await doc(fileName)).nodes.filter((node) => { - return node.kind === "function"; - }).map((node) => node.name); - content += `export { ${functions.join(",")} } from "./${fileName}";\n`; -} - -// Expose public classes from errors.ts -{ - const fileName = "errors.ts"; - const classes = (await doc(fileName)).nodes.filter((node) => { - return node.kind === "class"; - }).map((node) => node.name); - content += `export { ${classes.join(",")} } from "./${fileName}";\n`; -} - -// Expose types from *.ts. -for (const f of files) { - const types = (await doc(f)).nodes.filter((node) => { - return (node.kind === "interface" || node.kind === "typeAlias") && - node.declarationKind !== "private"; - }).map((node) => node.name); - if (types.length > 0) { - content += `export type { ${types.join(",")} } from "./${f}"\n`; - } -} -Deno.writeFileSync("mod.ts", encoder.encode(await fmt(content))); From 6a43df6b42b595701bdcd934f134b77c5525a6d0 Mon Sep 17 00:00:00 2001 From: uki00a Date: Sun, 8 Dec 2024 23:55:48 +0900 Subject: [PATCH 2/2] remove make_mod task --- deno.json | 1 - 1 file changed, 1 deletion(-) diff --git a/deno.json b/deno.json index 20f6be2e..b34120ef 100644 --- a/deno.json +++ b/deno.json @@ -38,7 +38,6 @@ "test": "DENO_FUTURE=1 deno test --allow-net --allow-read=tests --allow-write=tests/tmp --allow-run=redis-server,redis-cli --allow-env=REDIS_VERSION --coverage=coverage --trace-leaks --frozen-lockfile", "test:doc": "deno check --doc-only --import-map=import_map.test.json README.md experimental/cluster/README.md", "coverage": "deno coverage ./coverage --lcov --output=coverage/lcov.info", - "make_mod": "deno run --allow-read --allow-write --allow-run=deno --check tools/make_mod.ts", "bench:deno-redis": "DENO_NO_PACKAGE_JSON=1 deno run --unstable --allow-net=127.0.0.1:6379 --allow-read --allow-env --allow-write=tmp --import-map=benchmark/import_map.json benchmark/deno-redis.ts", "bench:ioredis": "node benchmark/ioredis.js" }