Skip to content

Commit bf85c1a

Browse files
committed
refactor: migrate to TypeScript with Vitest and modern tooling
BREAKING CHANGE: @actions/github upgraded from v2 to v6 ## Changes ### TypeScript Migration - Convert index.js to src/index.ts with strict TypeScript mode - Extract pure utility functions to src/utils.ts for testability - Add tsconfig.json with strict compiler options ### Testing Framework - Replace Jest with Vitest for faster, ESM-native testing - Add comprehensive unit tests for utility functions (43 tests) - Add integration tests for GitHub Action structure (12 tests) - Target: 80%+ code coverage ### @actions/github v6 Upgrade - Migrate from deprecated `new github.GitHub(token)` to `github.getOctokit(token)` - Update all API calls from `octokit.repos.*` to `octokit.rest.repos.*` - Update all API calls from `octokit.issues.*` to `octokit.rest.issues.*` - Update all API calls from `octokit.git.*` to `octokit.rest.git.*` ### ESLint Configuration - Enable TypeScript support in @antfu/eslint-config - Replace Jest globals with Vitest globals (vi instead of jest) - Add lib/ to ignore patterns ### Build System - Update ncc build to compile TypeScript directly - Add source maps and licenses to dist output - Add typecheck script for standalone type checking - Update all npm scripts for TypeScript workflow ### Files Deleted - index.js (migrated to src/index.ts) - index.test.js (migrated to src/__tests__/*.test.ts) - jest.config.js (replaced by vitest.config.ts) - now.js (unused legacy file) Closes #291
1 parent 436e9eb commit bf85c1a

23 files changed

Lines changed: 7156 additions & 33418 deletions

.github/workflows/claude-code-review.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,40 @@ name: Basic PR Review with Claude
33
on:
44
pull_request:
55
types: [opened, synchronize, reopened, ready_for_review]
6-
6+
77
# Manual trigger for testing
88
workflow_dispatch:
99

1010
jobs:
1111
claude-review:
1212
name: Claude Code Review
1313
runs-on: ubuntu-latest
14-
14+
1515
# Skip draft PRs unless manually triggered
1616
if: github.event.pull_request.draft == false || github.event_name == 'workflow_dispatch'
17-
17+
1818
permissions:
1919
contents: read
2020
pull-requests: write
2121
id-token: write
22-
22+
2323
steps:
2424
- name: Checkout code
2525
uses: actions/checkout@v4
2626
with:
2727
fetch-depth: 0
28-
28+
2929
- name: Run Claude Code Review
3030
uses: amondnet/claude-code-review@main
3131
with:
3232
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
33-
review_type: 'comprehensive'
33+
review_type: comprehensive
3434
progress_tracking: true
3535
severity_labels: true
3636
max_review_comments: 30
3737
exclude_paths: 'node_modules,dist,build,.git,*.lock'
3838
github_token: ${{ secrets.GITHUB_TOKEN }}
39-
39+
4040
- name: Review Complete Notification
4141
if: always()
4242
run: |

.please/memory/session-summary.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Session Summary: TypeScript and Vitest Migration
2+
3+
## Feature Description
4+
Migrate vercel-action from JavaScript to TypeScript with modern tooling:
5+
1. Convert index.js to TypeScript (src/index.ts)
6+
2. Replace Jest with Vitest for testing
7+
3. Update @antfu/eslint-config for TypeScript support
8+
9+
## Requirements Summary
10+
- TypeScript source files in `src/` directory
11+
- Strict TypeScript mode enabled
12+
- Delete deprecated `now.js` file
13+
- Maintain backward compatibility with action inputs/outputs
14+
- Keep dist/index.js as bundled output
15+
16+
## Constraints
17+
- GitHub Action must remain functional
18+
- Node 20 runtime requirement
19+
- ncc bundling for dist/
20+
21+
## Current Phase: Codebase Exploration
22+
23+
## Key Decisions
24+
- [x] Source directory: `src/`
25+
- [x] TypeScript strict mode: enabled
26+
- [x] Delete now.js: yes
27+
28+
## Files to Modify
29+
- index.js → src/index.ts
30+
- index.test.js → src/index.test.ts
31+
- package.json (scripts, dependencies)
32+
- eslint.config.mjs (TypeScript support)
33+
- jest.config.js → vitest.config.ts
34+
- action.yml (verify dist path)
35+
- tsconfig.json (new)
36+
37+
## Progress
38+
- [x] Phase 1: Discovery - Complete
39+
- [ ] Phase 2: Codebase Exploration - In Progress

.please/memory/tasklist.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"session_id": "20251212-typescript-vitest-migration",
3+
"feature_name": "TypeScript and Vitest Migration",
4+
"created_at": "2025-12-12T00:00:00Z",
5+
"updated_at": "2025-12-12T00:00:00Z",
6+
"status": "in_progress",
7+
"current_phase": 6,
8+
"issue_number": 291,
9+
"branch": "291-refactor-migrate-to-typescript-with-vitest-and-modern-tooling",
10+
"phases": [
11+
{ "number": 1, "name": "Discovery", "status": "completed", "started_at": "2025-12-12T00:00:00Z", "completed_at": "2025-12-12T00:01:00Z" },
12+
{ "number": 2, "name": "Codebase Exploration", "status": "completed", "started_at": "2025-12-12T00:01:00Z", "completed_at": "2025-12-12T00:02:00Z" },
13+
{ "number": 3, "name": "Clarifying Questions", "status": "completed", "completed_at": "2025-12-12T00:03:00Z" },
14+
{ "number": 4, "name": "Architecture Design", "status": "completed", "completed_at": "2025-12-12T00:04:00Z" },
15+
{ "number": 5, "name": "GitHub Issue & PR", "status": "completed", "completed_at": "2025-12-12T00:05:00Z" },
16+
{ "number": 6, "name": "Implementation", "status": "completed", "completed_at": "2025-12-12T00:22:00Z" },
17+
{ "number": 7, "name": "Quality Review", "status": "in_progress", "started_at": "2025-12-12T00:22:00Z" },
18+
{ "number": 8, "name": "PR Finalization", "status": "pending" }
19+
],
20+
"tasks": [
21+
{ "id": "T001", "title": "Create tsconfig.json with strict settings", "phase": 6, "status": "pending", "parallel": true, "dependencies": [] },
22+
{ "id": "T002", "title": "Update package.json (add TypeScript, Vitest; remove Jest)", "phase": 6, "status": "pending", "parallel": true, "dependencies": [] },
23+
{ "id": "T003", "title": "Update eslint.config.mjs for TypeScript + Vitest globals", "phase": 6, "status": "pending", "parallel": true, "dependencies": [] },
24+
{ "id": "T004", "title": "Create vitest.config.ts", "phase": 6, "status": "pending", "parallel": true, "dependencies": [] },
25+
{ "id": "T005", "title": "Create src/utils.ts with pure utility functions", "phase": 6, "status": "pending", "parallel": false, "dependencies": ["T001", "T002", "T003", "T004"] },
26+
{ "id": "T006", "title": "Create src/__tests__/utils.test.ts with unit tests", "phase": 6, "status": "pending", "parallel": false, "dependencies": ["T005"] },
27+
{ "id": "T007", "title": "Create src/index.ts with main action logic", "phase": 6, "status": "pending", "parallel": false, "dependencies": ["T005"] },
28+
{ "id": "T008", "title": "Upgrade @actions/github to v6 and update API calls", "phase": 6, "status": "pending", "parallel": false, "dependencies": ["T007"] },
29+
{ "id": "T009", "title": "Create src/__tests__/index.test.ts", "phase": 6, "status": "pending", "parallel": false, "dependencies": ["T007", "T008"] },
30+
{ "id": "T010", "title": "Delete old files (index.js, index.test.js, jest.config.js, now.js)", "phase": 6, "status": "pending", "parallel": false, "dependencies": ["T007", "T009"] },
31+
{ "id": "T011", "title": "Build and verify dist/index.js", "phase": 6, "status": "pending", "parallel": false, "dependencies": ["T010"] },
32+
{ "id": "T012", "title": "Run all quality checks (lint, typecheck, test)", "phase": 6, "status": "pending", "parallel": false, "dependencies": ["T011"] }
33+
],
34+
"decisions": {
35+
"source_directory": "src/",
36+
"keep_now_js": false,
37+
"typescript_strict": true,
38+
"modularize": false,
39+
"add_comprehensive_tests": true,
40+
"upgrade_github_api": true,
41+
"split_utils": true
42+
}
43+
}

dist/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

dist/index.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)