feat: 优化项目结构
All checks were successful
CI / 测试 (push) Successful in 20s

This commit is contained in:
ren
2025-10-21 11:59:50 +08:00
parent 4174e14517
commit c9a9632ccc
6 changed files with 19 additions and 14 deletions

View File

@@ -40,11 +40,17 @@ jobs:
pnpm --version pnpm --version
echo "✅ 包管理器安装成功" echo "✅ 包管理器安装成功"
- name: 准备 | 获取项目依赖哈希
id: files-hash
uses: ./
with:
files: '**/pnpm-lock.yaml'
- name: 准备 | 配置依赖缓存 - name: 准备 | 配置依赖缓存
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: ~/.pnpm-store path: ~/.pnpm-store
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} key: ${{ runner.os }}-pnpm-store-${{ steps.files-hash.outputs.hash }}
restore-keys: | restore-keys: |
${{ runner.os }}-pnpm-store- ${{ runner.os }}-pnpm-store-
@@ -56,7 +62,7 @@ jobs:
- name: 测试 | 执行语法检查 - name: 测试 | 执行语法检查
run: | run: |
echo "🔍 执行 JavaScript 语法检查..." echo "🔍 执行 JavaScript 语法检查..."
node -c index.js node -c src/index.js
echo "✅ 语法检查通过" echo "✅ 语法检查通过"
- name: 测试 | 执行 Lint 检查 - name: 测试 | 执行 Lint 检查
@@ -76,4 +82,3 @@ jobs:
echo "🧪 执行测试..." echo "🧪 执行测试..."
pnpm run test pnpm run test
echo "✅ 测试通过" echo "✅ 测试通过"

View File

@@ -72,10 +72,10 @@ jobs:
## 输入参数 ## 输入参数
| 输入参数 | 描述 | 必需 | 默认值 | | 输入参数 | 描述 | 必需 | 默认值 |
| ----------------- | ------------------------------------------- | ----- | -------- | | ----------- | ------------------------------------------- | ----- | -------- |
| `files` | 文件路径或 glob 模式(每行一个) | ✅ 是 | - | | `files` | 文件路径或 glob 模式(每行一个) | ✅ 是 | - |
| `algorithm` | 哈希算法:`md5``sha1``sha256``sha512` | ❌ 否 | `sha256` | | `algorithm` | 哈希算法:`md5``sha1``sha256``sha512` | ❌ 否 | `sha256` |
### 文件模式 ### 文件模式

View File

@@ -22,4 +22,4 @@ outputs:
runs: runs:
using: 'node20' using: 'node20'
main: 'index.js' main: 'src/index.js'

View File

@@ -2,15 +2,15 @@
"name": "files-hash-action", "name": "files-hash-action",
"version": "0.1.1", "version": "0.1.1",
"description": "A lightweight Gitea Action to calculate hash of multiple files", "description": "A lightweight Gitea Action to calculate hash of multiple files",
"main": "index.js", "main": "src/index.js",
"scripts": { "scripts": {
"test": "vitest run", "test": "vitest run",
"test:watch": "vitest watch", "test:watch": "vitest watch",
"test:coverage": "vitest run --coverage", "test:coverage": "vitest run --coverage",
"lint": "eslint .", "lint": "eslint ./src",
"lint:fix": "eslint . --fix", "lint:fix": "eslint ./src --fix",
"format": "prettier --write .", "format": "prettier --write ./src",
"format:check": "prettier --check .", "format:check": "prettier --check ./src",
"check": "pnpm run lint && pnpm run format:check", "check": "pnpm run lint && pnpm run format:check",
"preinstall": "npx only-allow pnpm" "preinstall": "npx only-allow pnpm"
}, },

View File

@@ -10,7 +10,7 @@ import {
ErrorType, ErrorType,
ActionInputs, ActionInputs,
ActionOutputs, ActionOutputs,
} from '../index.js'; } from '../src/index.js';
import { createTestFile, createTestDir, cleanupTestFiles, cleanupTestDirs } from './utils.js'; import { createTestFile, createTestDir, cleanupTestFiles, cleanupTestDirs } from './utils.js';
describe('测试 FileDiscovery 类', () => { describe('测试 FileDiscovery 类', () => {