Skip to content

refactor: migrate to TypeScript with Vitest and modern tooling #291

@amondnet

Description

@amondnet

Summary

Migrate the vercel-action codebase from JavaScript to TypeScript with modern tooling:

  • TypeScript: Convert index.js to src/index.ts + src/utils.ts with strict mode
  • Vitest: Replace Jest with Vitest for faster, ESM-native testing
  • @antfu/eslint-config: Update for TypeScript support (already installed)
  • @actions/github v6: Upgrade from deprecated v2 API (github.GitHub → getOctokit)

Motivation

  • Type safety for better maintainability
  • Modern testing framework with better DX
  • Fix deprecated GitHub API usage
  • Comprehensive test coverage (target: 80%+)

Tasks

Phase 1: Setup Infrastructure

  • T001 [P] Create tsconfig.json with strict settings
  • T002 [P] Update package.json (add TypeScript, Vitest; remove Jest)
  • T003 [P] Update eslint.config.mjs for TypeScript + Vitest globals
  • T004 [P] Create vitest.config.ts

Phase 2: TypeScript Migration

  • T005 Create src/utils.ts with pure utility functions (depends on T001-T004)
  • T006 Create src/tests/utils.test.ts with unit tests (depends on T005)
  • T007 Create src/index.ts with main action logic (depends on T005)
  • T008 Upgrade @actions/github to v6 and update API calls (depends on T007)
  • T009 Create src/tests/index.test.ts (depends on T007, T008)

Phase 3: Cleanup & Verification

  • T010 Delete old files (index.js, index.test.js, jest.config.js, now.js) (depends on T007, T009)
  • T011 Build and verify dist/index.js (depends on T010)
  • T012 Run all quality checks (lint, typecheck, test) (depends on T011)

Dependencies & Execution Order

Parallel Group 1 (independent setup):

  • T001, T002, T003, T004

Sequential (depends on setup):

  • T005 → T006 → T007 → T008 → T009 → T010 → T011 → T012

Technical Notes

@actions/github API Migration

// Old (deprecated)
const octokit = new github.GitHub(token)
octokit.repos.listCommentsForCommit(...)

// New
const octokit = github.getOctokit(token)
octokit.rest.repos.listCommentsForCommit(...)

File Structure

src/
├── index.ts           # Main action entry (~350 LOC)
├── utils.ts           # Pure utility functions (~150 LOC)
└── __tests__/
    ├── index.test.ts  # Integration tests
    └── utils.test.ts  # Unit tests

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions