Files
hello-world/readme.md

52 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

项目:用于在 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`