From f6bd507d84bccde4dc9724bb1a04b0f8ebd720e7 Mon Sep 17 00:00:00 2001 From: Sitri Kamishirasawa Date: Tue, 29 Oct 2024 06:20:44 +0900 Subject: [PATCH] feat: make minimal for bun script repository template --- Dockerfile | 6 ++---- bun.prod.toml | 2 -- cli.ts | 2 -- docs/README.md | 33 --------------------------------- index.ts | 1 - main.test.ts | 6 ------ package.json | 16 +++++----------- server.ts | 1 - src/index.ts | 3 --- src/main.test.ts | 3 +++ src/main.ts | 12 ++++++++++++ tsconfig.prod.json | 3 --- 12 files changed, 22 insertions(+), 66 deletions(-) delete mode 100644 bun.prod.toml delete mode 100644 cli.ts delete mode 100644 docs/README.md delete mode 100644 index.ts delete mode 100644 main.test.ts delete mode 100644 server.ts delete mode 100644 src/index.ts create mode 100644 src/main.test.ts create mode 100644 src/main.ts delete mode 100644 tsconfig.prod.json diff --git a/Dockerfile b/Dockerfile index 212a0bf..5830fe9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,9 @@ FROM oven/bun:alpine@sha256:3dc101cc42433f8a470da07701441afdb1aab4c6d056a291eb405e348c5a5c37 -COPY tsconfig.prod.json ./ -COPY bun.prod.toml ./bun.toml -COPY server.ts cli.ts ./ +COPY tsconfig.json ./ COPY src/ ./ COPY package.json bun.lockb ./ RUN bun install --production --frozen-lockfile ENTRYPOINT ["bun"] -CMD ["run", "start"] +CMD ["--version"] diff --git a/bun.prod.toml b/bun.prod.toml deleted file mode 100644 index 8374782..0000000 --- a/bun.prod.toml +++ /dev/null @@ -1,2 +0,0 @@ -[test] -coverage = false diff --git a/cli.ts b/cli.ts deleted file mode 100644 index 6f29a9c..0000000 --- a/cli.ts +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env bun -console.log("Hello from cli.ts"); diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index ebb72fc..0000000 --- a/docs/README.md +++ /dev/null @@ -1,33 +0,0 @@ -## indexes - -make static index if you need. - -But IMO, if you feel the document will have been large/huge, then we use anyone document generation tool(e.g. [Docusaurus](https://docusaurus.io/docs)) and that may auto-generate index. -目次が必要になるほどドキュメントが大きくなったら、そもそもドキュメント生成ツールを使うべきフェーズだよね。 - -## entrypoint files implementation - -```mermaid ---- -title: entrypoint files using which Application class ---- -classDiagram -direction LR - -class ApplicationBase { - <> -} -class ApplicationInterface { - <> -} -%% entrypoint --> each application class -cli-ts_file --> ConsoleApplication: use -serve-ts_file --> HttpApplication: use -import_as_module --> Application: import - -%% Application classes extends/implements -ConsoleApplication --|> ApplicationBase -HttpApplication --|> ApplicationBase -Application --|> ApplicationBase -ApplicationBase ..|> ApplicationInterface -``` diff --git a/index.ts b/index.ts deleted file mode 100644 index 3bd16e1..0000000 --- a/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./src"; diff --git a/main.test.ts b/main.test.ts deleted file mode 100644 index f905916..0000000 --- a/main.test.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { expect, test } from "bun:test"; -import { main } from "./"; - -test("main test", () => { - expect(main()).toBeString(); -}); diff --git a/package.json b/package.json index 407858f..524f535 100644 --- a/package.json +++ b/package.json @@ -1,25 +1,19 @@ { + "private": true, "name": "bun", - "module": "index.ts", + "type": "module", "devDependencies": { "@biomejs/biome": "1.9.4", "@tsconfig/bun": "1.0.7", "@tsconfig/strictest": "2.0.5", - "@types/bun": "latest" + "@types/bun": "latest", + "lefthook": "1.8.1" }, "peerDependencies": { - "typescript": "^5.0.0" + "typescript": "5.0.0" }, "scripts": { - "cli": "bun cli.ts", - "start": "bun server.ts", "fmt": "biome check --write --unsafe", "docker:action-lint": "docker run --rm -v $(pwd):/repo --workdir /repo rhysd/actionlint:latest -color" - }, - "bin": "cli.ts", - "private": true, - "type": "module", - "dependencies": { - "lefthook": "^1.8.1" } } diff --git a/server.ts b/server.ts deleted file mode 100644 index 51f75db..0000000 --- a/server.ts +++ /dev/null @@ -1 +0,0 @@ -console.log("Hello from server.ts"); diff --git a/src/index.ts b/src/index.ts deleted file mode 100644 index 11e7c3f..0000000 --- a/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function main(): string { - return "Hello via Bun!"; -} diff --git a/src/main.test.ts b/src/main.test.ts new file mode 100644 index 0000000..bf7c538 --- /dev/null +++ b/src/main.test.ts @@ -0,0 +1,3 @@ +import { test } from "bun:test"; + +test.todo("main test", () => {}); diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..4b39d48 --- /dev/null +++ b/src/main.ts @@ -0,0 +1,12 @@ +function main(): Promise { + return Promise.resolve(); +} + +main() + .then(() => { + process.exit(0); + }) + .catch((error) => { + console.error(error); + process.exit(1); + }); diff --git a/tsconfig.prod.json b/tsconfig.prod.json deleted file mode 100644 index 419faab..0000000 --- a/tsconfig.prod.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["@tsconfig/bun/tsconfig", "@tsconfig/strictest/tsconfig"] -}