-
-
Notifications
You must be signed in to change notification settings - Fork 110
refactor: migrate to TypeScript with Vitest and modern tooling #292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
refactor: migrate to TypeScript with Vitest and modern tooling #292
Conversation
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
Summary of ChangesHello @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 Highlights
Ignored Files
Using Gemini Code AssistThe 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
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 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
|
|
Deploy preview for express-basic-auth ready! ✅ Preview Built with commit 405f136. |
There was a problem hiding this 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.
There was a problem hiding this 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.
|


Summary
This PR completes the migration of vercel-action from JavaScript to TypeScript with modern tooling:
index.jstosrc/index.ts+src/utils.tswith strict modegithub.GitHub→getOctokit)Changes
TypeScript Migration
Testing Framework
@actions/github v6 Upgrade
new github.GitHub(token)→github.getOctokit(token)octokit.repos.*→octokit.rest.repos.*octokit.issues.*→octokit.rest.issues.*octokit.git.*→octokit.rest.git.*ESLint Configuration
Files Changed
src/index.ts,src/utils.ts,src/__tests__/*.ts,tsconfig.json,vitest.config.tspackage.json,eslint.config.mjs,dist/index.jsindex.js,index.test.js,jest.config.js,now.jsTest Plan
pnpm lint- ESLint passespnpm typecheck- TypeScript strict mode passespnpm build- ncc bundles successfullypnpm test- All 55 tests passBreaking Changes
@actions/githubupgraded from v2 to v6. This is an internal change and should not affect action users, but the API calls now useoctokit.rest.*namespace.Closes #291