Skip to content

Conversation

@amondnet
Copy link
Owner

Summary

This PR completes the migration of vercel-action 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 (55 tests)
  • @actions/github v6: Upgrade from deprecated v2 API (github.GitHubgetOctokit)

Changes

TypeScript Migration

  • ✅ Convert index.js to src/index.ts (~350 LOC)
  • ✅ Extract pure utilities to src/utils.ts (~140 LOC)
  • ✅ Add strict TypeScript configuration
  • ✅ Add proper type definitions for payloads and interfaces

Testing Framework

  • ✅ Replace Jest with Vitest
  • ✅ Add 43 unit tests for utility functions
  • ✅ Add 12 integration tests for action structure
  • ✅ All 55 tests passing

@actions/github v6 Upgrade

  • ✅ Migrate new github.GitHub(token)github.getOctokit(token)
  • ✅ Update octokit.repos.*octokit.rest.repos.*
  • ✅ Update octokit.issues.*octokit.rest.issues.*
  • ✅ Update octokit.git.*octokit.rest.git.*

ESLint Configuration

  • ✅ Enable TypeScript support
  • ✅ Replace Jest globals with Vitest globals

Files Changed

Action Files
Created src/index.ts, src/utils.ts, src/__tests__/*.ts, tsconfig.json, vitest.config.ts
Updated package.json, eslint.config.mjs, dist/index.js
Deleted index.js, index.test.js, jest.config.js, now.js

Test Plan

  • pnpm lint - ESLint passes
  • pnpm typecheck - TypeScript strict mode passes
  • pnpm build - ncc bundles successfully
  • pnpm test - All 55 tests pass
  • Manual test with example project

Breaking Changes

⚠️ BREAKING: @actions/github upgraded from v2 to v6. This is an internal change and should not affect action users, but the API calls now use octokit.rest.* namespace.

Closes #291

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
Copilot AI review requested due to automatic review settings December 12, 2025 09:25
@amondnet amondnet linked an issue Dec 12, 2025 that may be closed by this pull request
12 tasks
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @amondnet, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request represents a significant modernization effort for the vercel-action project. By migrating to TypeScript, adopting Vitest for testing, and upgrading core GitHub Action dependencies, the project benefits from improved code quality, better developer experience, and a more robust testing infrastructure. These changes lay a solid foundation for future development and maintenance, ensuring the action remains efficient and reliable.

Highlights

  • TypeScript Migration: The entire vercel-action project has been migrated from JavaScript to TypeScript, enhancing type safety and maintainability. This involved converting index.js to src/index.ts and extracting utilities into src/utils.ts, along with strict TypeScript configuration.
  • Testing Framework Update: Jest has been replaced with Vitest for unit and integration testing. This change leverages Vitest's faster, ESM-native testing capabilities, with 55 tests now implemented and passing.
  • @actions/github v6 Upgrade: The @actions/github dependency has been upgraded from v2 to v6, modernizing the GitHub API interactions. This includes migrating from new github.GitHub(token) to github.getOctokit(token) and updating API calls to use the octokit.rest.* namespace.
  • Tooling Modernization: ESLint configuration has been updated to support TypeScript and integrate Vitest globals, ensuring consistent code quality across the new codebase. Old JavaScript files and configurations (like jest.config.js and now.js) have been removed.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/claude-code-review.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

github-actions bot commented Dec 12, 2025

Deploy preview for express-basic-auth ready!

✅ Preview
https://express-basic-auth-hejt13iew-minsu-lees-projects-b1e388b7.vercel.app

Built with commit 405f136.
This pull request is being automatically deployed with vercel-action

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This is an excellent and comprehensive pull request that successfully migrates the project from JavaScript to TypeScript. The adoption of modern tooling like Vitest, the upgrade of @actions/github, and the move to a src directory structure with strict TypeScript are all significant improvements for the project's maintainability and reliability. The code is well-structured, with utility functions cleanly extracted into src/utils.ts. I have a couple of minor suggestions to further improve type consistency and code clarity, but overall, this is a very strong contribution.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

- Move PullRequestPayload and ReleasePayload interfaces to top of file
- Use PullRequestPayload type instead of inline type assertion
- Simplify parseArgs regex match logic (remove redundant fallback)
- Extract types to src/types.ts
- Extract config and initialization to src/config.ts
- Extract Vercel functions to src/vercel.ts
- Extract GitHub comment functions to src/github-comments.ts
- Refactor run() into smaller focused functions (< 50 LOC each)
- Add try-catch around execSync for git log with descriptive error
- Add error handling for GitHub API calls
- Make alias failures explicit with warning messages
- Extract magic numbers to named constants (RETRY_DELAY_MS, ALIAS_RETRY_COUNT)
- Use buildCommentPrefix() consistently in both comment functions

All files now under 300 LOC limit, all functions under 50 LOC limit.
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 6, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
3 Security Hotspots

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: migrate to TypeScript with Vitest and modern tooling

2 participants