From c9a9632ccc07b59d6e219b45750826202eed6412 Mon Sep 17 00:00:00 2001 From: ren Date: Tue, 21 Oct 2025 11:59:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 11 ++++++++--- README.md | 8 ++++---- action.yml | 2 +- package.json | 10 +++++----- index.js => src/index.js | 0 tests/index.test.js | 2 +- 6 files changed, 19 insertions(+), 14 deletions(-) rename index.js => src/index.js (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3616101..34a5476 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,11 +40,17 @@ jobs: pnpm --version echo "✅ 包管理器安装成功" + - name: 准备 | 获取项目依赖哈希 + id: files-hash + uses: ./ + with: + files: '**/pnpm-lock.yaml' + - name: 准备 | 配置依赖缓存 uses: actions/cache@v3 with: path: ~/.pnpm-store - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + key: ${{ runner.os }}-pnpm-store-${{ steps.files-hash.outputs.hash }} restore-keys: | ${{ runner.os }}-pnpm-store- @@ -56,7 +62,7 @@ jobs: - name: 测试 | 执行语法检查 run: | echo "🔍 执行 JavaScript 语法检查..." - node -c index.js + node -c src/index.js echo "✅ 语法检查通过" - name: 测试 | 执行 Lint 检查 @@ -76,4 +82,3 @@ jobs: echo "🧪 执行测试..." pnpm run test echo "✅ 测试通过" - diff --git a/README.md b/README.md index 8a4c0ef..cb4d53a 100644 --- a/README.md +++ b/README.md @@ -72,10 +72,10 @@ jobs: ## 输入参数 -| 输入参数 | 描述 | 必需 | 默认值 | -| ----------------- | ------------------------------------------- | ----- | -------- | -| `files` | 文件路径或 glob 模式(每行一个) | ✅ 是 | - | -| `algorithm` | 哈希算法:`md5`、`sha1`、`sha256`、`sha512` | ❌ 否 | `sha256` | +| 输入参数 | 描述 | 必需 | 默认值 | +| ----------- | ------------------------------------------- | ----- | -------- | +| `files` | 文件路径或 glob 模式(每行一个) | ✅ 是 | - | +| `algorithm` | 哈希算法:`md5`、`sha1`、`sha256`、`sha512` | ❌ 否 | `sha256` | ### 文件模式 diff --git a/action.yml b/action.yml index 1a84f1e..b043015 100644 --- a/action.yml +++ b/action.yml @@ -22,4 +22,4 @@ outputs: runs: using: 'node20' - main: 'index.js' + main: 'src/index.js' diff --git a/package.json b/package.json index edb1ccb..6c238b8 100644 --- a/package.json +++ b/package.json @@ -2,15 +2,15 @@ "name": "files-hash-action", "version": "0.1.1", "description": "A lightweight Gitea Action to calculate hash of multiple files", - "main": "index.js", + "main": "src/index.js", "scripts": { "test": "vitest run", "test:watch": "vitest watch", "test:coverage": "vitest run --coverage", - "lint": "eslint .", - "lint:fix": "eslint . --fix", - "format": "prettier --write .", - "format:check": "prettier --check .", + "lint": "eslint ./src", + "lint:fix": "eslint ./src --fix", + "format": "prettier --write ./src", + "format:check": "prettier --check ./src", "check": "pnpm run lint && pnpm run format:check", "preinstall": "npx only-allow pnpm" }, diff --git a/index.js b/src/index.js similarity index 100% rename from index.js rename to src/index.js diff --git a/tests/index.test.js b/tests/index.test.js index 8a4f337..8743c61 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -10,7 +10,7 @@ import { ErrorType, ActionInputs, ActionOutputs, -} from '../index.js'; +} from '../src/index.js'; import { createTestFile, createTestDir, cleanupTestFiles, cleanupTestDirs } from './utils.js'; describe('测试 FileDiscovery 类', () => {