Skip to content

feat: add TypeScript support and testing setup#275

Open
amondnet wants to merge 3 commits intomasterfrom
typescript
Open

feat: add TypeScript support and testing setup#275
amondnet wants to merge 3 commits intomasterfrom
typescript

Conversation

@amondnet
Copy link
Owner

No description provided.

@github-actions
Copy link

github-actions bot commented Jul 15, 2025

Deploy preview for team-scope-test ready!

✅ Preview
https://team-scope-test-rj70s56yz-dietfriends.vercel.app

Built with commit a47c99d.
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.

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 primarily focuses on modernizing the project's development stack by migrating the codebase to TypeScript and overhauling the testing infrastructure. It introduces robust static type checking, switches to Vitest for a faster and more integrated testing experience, and refines the build process to accommodate these changes.

Highlights

  • TypeScript Migration: The core index.js file has been renamed to src/index.ts and fully converted to TypeScript, including extensive type annotations for functions and variables. This introduces static type checking across the main application logic.
  • ESLint Configuration Update: ESLint has been reconfigured to support TypeScript, integrating @typescript-eslint plugins and parser. This ensures consistent code style and catches potential issues in the new TypeScript codebase, with adjusted import rules to handle .ts and .tsx extensions.
  • Testing Framework Switch: The project's testing framework has been migrated from Jest to Vitest. This includes the removal of old Jest test files, the addition of new Vitest configuration (vitest.config.ts), and a new test directory structure (test/index.test.ts), aiming for a faster and more integrated testing experience.
  • Build Process Refinement: The package.json scripts have been updated to incorporate TypeScript compilation (tsc) as a build step. The ncc build process now targets the compiled TypeScript output, including minification for optimized distribution.
  • Dependency Updates: Various @actions dependencies, axios, common-tags, and @octokit/webhooks have been updated to their latest versions. Correspondingly, Jest-related development dependencies have been replaced with TypeScript and Vitest-related ones.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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 Jul 15, 2025

Deploy preview for zeit-now-deployment-action-example-static ready!

✅ Preview
https://zeit-now-deployment-action-example-static-k7zvvt8mu.vercel.app
https://staging.static.vercel-action.amond.dev
https://pr-275.static.vercel-action.amond.dev

Built with commit 2ac98d7.
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

The pull request introduces TypeScript support and sets up a testing environment using Vitest. The changes include updates to ESLint configuration, package.json scripts, and the main action file. The code improvements include adding type annotations, improving error handling, and enhancing code readability. The review identified opportunities to improve type safety, simplify logic, and enhance error handling.

.eslintrc.json Outdated
"sourceType": "module"
},
"ignorePatterns": ["example/*"]
"ignorePatterns": ["example/*", "dist/*", "test/*"],
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Consider adding **/*.test.ts and **/*.test.tsx to the ignore patterns to prevent linting test files, as these often have different requirements than source files.

Comment on lines +19 to +20
"start": "node ./dist/src/index.js",
"package": "npm run build && ncc build dist/src/index.js -o dist --minify --no-cache --no-source-map-register",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The package script includes a build step, but it's not immediately clear what ncc does. Consider adding a comment to explain its purpose (e.g., 'Bundle the project with ncc').

src/index.ts Outdated
const args: string[] = [];

for (const match of s.matchAll(/'([^']*)'|"([^"]*)"|[^\s]+/gm)) {
const matches = Array.from(s.matchAll(/'([^']*)'|"([^"]*)"|[^\s]+/gm));
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

It's generally a good practice to avoid unused variables. Although the linter is disabled for myError, it might be better to remove it if it's truly not needed, or use it for logging purposes.


if (githubComment && githubToken) {
if (githubComment && githubToken && deploymentUrl && deploymentName) {
if (context.issue.number) {
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The condition githubComment && githubToken && deploymentUrl && deploymentName checks if deploymentUrl and deploymentName are truthy. However, it's possible for deploymentName to be an empty string, which is still truthy but might not be the desired behavior. Consider checking if deploymentName is a non-empty string.

amondnet added 2 commits July 15, 2025 14:06
- Introduced TypeScript configuration files (tsconfig.json, tsconfig.build.json)
- Added Vitest configuration for testing (vitest.config.ts)
- Created initial test file (index.test.ts) with a basic test case
- Updated package.json scripts for TypeScript build and testing
- Refactored ESLint configuration to support TypeScript
- Implemented main action logic in TypeScript (index.ts)
- Introduced TypeScript configuration files (tsconfig.json, tsconfig.build.json)
- Added Vitest configuration for testing (vitest.config.ts)
- Created initial test file (index.test.ts) with a basic test case
- Updated package.json scripts for TypeScript build and testing
- Refactored ESLint configuration to support TypeScript
- Implemented main action logic in TypeScript (index.ts)
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
3 Security Hotspots

See analysis details on SonarQube Cloud

@github-actions
Copy link

github-actions bot commented Jul 15, 2025

Deploy preview for express-basic-auth ready!

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

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

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
7 Security Hotspots

See analysis details on SonarQube Cloud

@claude
Copy link

claude bot commented Aug 28, 2025

Code Review: TypeScript Support and Testing Setup

I've thoroughly reviewed PR #275 which adds TypeScript support and modernizes the development setup. Here's my comprehensive feedback:

Positive Changes

Build System & Tooling

  • Modern package manager: Migration to pnpm with proper lockfile and version pinning (10.15.0) is excellent
  • Updated dependencies: All GitHub Actions updated to v4, Node.js to v20 - good security practice
  • ESLint modernization: Switch to @antfu/eslint-config with flat config is a solid choice
  • Enhanced CI/CD: New comprehensive CI workflow with separate jobs for linting, testing, building, and commit validation

Code Quality Improvements

  • Consistent formatting: Removal of quotes around YAML values improves consistency
  • Better variable naming: _myError and _myOutput prefixes for unused variables follows convention
  • Improved regex: /-{2,}/g is more precise than /--+/g in slugify function
  • Error handling: Better fork deletion handling with fallback to base repository info

⚠️ Issues & Concerns

Critical Issues

  1. Missing TypeScript Implementation: The PR title promises TypeScript support, but no TypeScript files, configuration, or dependencies were added

  2. Node Version Mismatch: .nvmrc specifies Node v20, but package.json engine requires Node 22.x, and CI uses mixed versions

  3. Deprecated GitHub API Usage: Line 96 uses deprecated github.GitHub() - should use github.getOctokit()

Security & Best Practices

  1. Regex Vulnerability: Line 138 parseArgs function uses \S+ pattern that could be exploited with very long strings

  2. Missing Input Validation: No validation of vercel-token format or alias-domains format

  3. Insufficient Test Coverage: Only placeholder test exists, no tests for critical functions

📋 Recommendations

High Priority

  1. Fix title accuracy - either implement TypeScript or rename PR
  2. Standardize Node version to v20 across all configurations
  3. Update deprecated GitHub API usage
  4. Add proper tests for core functionality

Medium Priority

  1. Add input validation for critical inputs
  2. Use .nvmrc in GitHub Actions workflows
  3. Improve error handling in deployment functions

🎯 Final Verdict

While this PR makes valuable infrastructure improvements, it has a misleading title and missing core functionality. The modernization is excellent, but critical issues prevent approval.

Recommendation: Fix Node version consistency and GitHub API deprecation before merging.

Overall quality: Good foundation, needs refinement ⭐⭐⭐☆☆

@claude
Copy link

claude bot commented Aug 28, 2025

Code Review - PR #275: TypeScript Support and Testing Setup

After reviewing this PR, I have identified several important issues and observations:

🚨 Critical Issues

  1. Incomplete TypeScript Migration

    • The PR claims to add TypeScript support but the current state shows only JavaScript files
    • TypeScript source files (src/index.ts, test/index.test.ts) and config files (tsconfig.json, vitest.config.ts) referenced in the diff are missing from the current branch
    • This suggests an incomplete or failed migration
  2. Package.json Script Inconsistencies

    • Scripts still reference JavaScript files (index.js) but the migration should use TypeScript entry points
    • Missing TypeScript build scripts in package.json
    • The package script still points to index.js instead of built output from TypeScript

🔍 Code Quality Issues

  1. ESLint Configuration Problems

    • Missing TypeScript parser configuration in eslint.config.mjs
    • Configuration shows type: lib but should be configured for TypeScript if migrating
    • Unused imports rule configured for TypeScript but no TypeScript files present
  2. Testing Setup Issues

    • Test file is essentially empty (only a placeholder test)
    • No meaningful test coverage for the core deployment functionality
    • Missing tests for critical functions like vercelDeploy, aliasDomainsToDeployment, etc.
  3. Dependencies Management

    • Switched from npm to pnpm but some workflows still have mixed usage
    • Missing TypeScript-related dependencies in package.json if this is truly a TypeScript migration
    • Package.json shows Jest for testing but diff mentions Vitest

🔒 Security Concerns

  1. Input Validation

    • parseArgs function in index.js:138 uses regex for parsing but could be vulnerable to ReDoS
    • No validation on user inputs like vercel-args which gets passed to shell commands
    • Shell command injection potential in vercelDeploy function
  2. Secret Handling

    • Korean comment on line 425 should be in English for consistency
    • Vercel token passed as CLI argument which may appear in process lists

Performance Considerations

  1. Async Operations
    • Good use of Promise.all() in aliasDomainsToDeployment for parallel execution
    • Retry mechanism is well-implemented with exponential backoff
    • However, no timeout handling for long-running Vercel CLI operations

🧪 Test Coverage

  1. Insufficient Testing
    • Only a placeholder test exists
    • No tests for core functionality like deployment, aliasing, or comment creation
    • No error handling tests
    • CI workflow includes testing but tests do not validate actual functionality

📋 GitHub Actions Workflow Issues

  1. CI Configuration Problems
    • Mixed Node.js versions (20 vs 22.x) across different jobs
    • Inconsistent pnpm versions in workflows
    • commitlint job references branches that may not exist

Positive Changes

  • Good migration to pnpm for better performance
  • Proper CI/CD setup with multiple validation steps
  • Updated GitHub Actions to latest versions
  • Improved ESLint configuration with modern rules
  • Better workflow organization with separate jobs

🎯 Recommendations

  1. Complete the TypeScript migration - Add missing TS files and proper build setup
  2. Add comprehensive tests - Cover all major functions and error scenarios
  3. Fix package.json scripts - Align with TypeScript build process
  4. Improve input validation - Sanitize all user inputs before shell execution
  5. Standardize Node.js versions - Use consistent version across all workflows
  6. Add timeout handling - For long-running CLI operations
  7. Remove non-English comments - Keep codebase in English
  8. Add TypeScript dependencies - If completing the migration

🚧 Blocking Issues

This PR appears to be in an incomplete state and should not be merged until:

  • TypeScript migration is completed with proper source files
  • Build process is fixed to work with TypeScript
  • Meaningful tests are added

The changes show promise but need significant work to be production-ready.

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.

1 participant