Update readme.md to include project overview, setup instructions, directory structure, and usage with Docker for Node + TypeScript project.
Some checks failed
ci / build-test-pack (push) Has been cancelled

This commit is contained in:
2025-08-10 01:43:28 +08:00
parent 34637ef77a
commit 26a36b197e
13 changed files with 220 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
项目:用于在 Gitea 中测试 Node + TypeScript 项目的构建与打包(含 OOP 示例、CI、Docker
### 快速开始
1) 安装 Node 20建议使用 nvm
```bash
nvm use || nvm install
```
2) 安装依赖并运行测试、构建与打包
```bash
npm i
npm test
npm run build
npm pack
```
生成的 npm 包形如:`hello-world-0.1.0.tgz`
### 目录结构
- `src/`TypeScript 源码OOP 风格示例位于 `src/core/Greeter.ts`
- `tests/`Vitest 单元测试
- `.gitea/workflows/ci.yml`Gitea Actions 工作流(安装、测试、构建、打包、上传构件)
- `Dockerfile`:容器内构建与打包
### 本地使用Docker
```bash
docker build -t node-oop-ci .
docker run --rm node-oop-ci
```
镜像在构建阶段会运行 `npm run build && npm pack`,启动时会执行编译产物 `dist/index.js`
### 在 Gitea 上运行
将仓库推送到 Gitea确保实例启用了 Actions并且 Runner 提供了 `ubuntu-latest` 或兼容标签。
工作流位于 `.gitea/workflows/ci.yml`,包含以下阶段:
- Checkout 代码
- 安装 Node 20 与依赖
- 运行测试Vitest
- 构建TypeScript 到 `dist/`
- 打包(`npm pack`
- 上传构件(若实例提供 `actions/upload-artifact` 镜像)
如你的 Runner 标签不同,可调整 `runs-on`