Commit feb50fe
refactor: migrate to TypeScript with Vitest and modern tooling (#311)
* refactor: migrate to TypeScript with Vitest and modern tooling
BREAKING CHANGE: @actions/github upgraded from v2 to v6
- 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
- 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
- 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.*`
- Enable TypeScript support in @antfu/eslint-config
- Replace Jest globals with Vitest globals (vi instead of jest)
- Add lib/ to ignore patterns
- 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
- 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
* chore: apply AI code review suggestions
- 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)
* refactor: split index.ts into smaller modules
- 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.
* build: rebuild dist after refactoring
* build: update vercel to v50
* fix: improve error handling in vercel deploy and comment functions
- Extract and validate deployment URL from vercel CLI stdout
- Wrap vercelInspect exec in try-catch to prevent action failure
- Expand try-catch scope in comment functions to cover API lookups
- Route stderr to core.warning for better error visibility
* test: add tests for vercel, config, and github-comments modules
- Add vercel.test.ts: URL extraction, inspect regex, alias retry
- Add config.test.ts: alias domain substitution, env export
- Add github-comments.test.ts: comment create/update, error handling
- Total tests: 55 → 100
* fix: port personal account scope error handling from PR #297/#298
- Add core.setSecret for vercel token to prevent log exposure
- Disable telemetry with VERCEL_TELEMETRY_DISABLED env var
- Require both org and project IDs together (v41+ compat)
- Auto-retry deployment on personal account scope error
- Sanitize commit message newlines and quotes in metadata
- Add ignoreReturnCode for proper exit code handling
- Update tests for new behavior (105 total)
* refactor: use DeploymentContext object in vercelDeploy signature
Reduce parameter count from 6 to 2 by passing DeploymentContext
object instead of individual ref, commit, sha, commitOrg, commitRepo
arguments. Aligns with AGENTS.md parameter limit of 5.
* fix: port alias retry without --scope for personal accounts (#310)
Capture stderr in alias exec and retry without --scope when Vercel CLI
rejects personal account scope, matching the deploy retry pattern.
Add tests for alias scope retry, retry failure, and non-scope failures.
* fix: remove declaration maps to fix check-dist CI failure
Source map files (.d.ts.map) contain absolute local paths that differ
between local builds and CI runners, causing check-dist to fail.
Disable declarationMap in tsconfig.json since these files are not
needed for GitHub Action runtime execution.
* chore: apply AI code review suggestions
- Implement exponential backoff in retry function (was constant delay)
- Fix debug log for head_commit to use JSON.stringify
- Change vercelInspect stderr logging from warning to info level
- Fix retry after PERSONAL_ACCOUNT_SCOPE_ERROR to omit --scope
- Bump @types/node from ^20.0.0 to ^24.0.0 to match Node 24 runtime
- Add setSecret to @actions/core mock in index.test.ts
- Fix mock path in config.test.ts from ../package.json to ../../package.json
- Update test expectation to match mocked vercel version (30.0.0)
- Remove pull_request_target from PullRequestPayload (always undefined)
- Add per_page: 100 to comment listing API calls to reduce duplicate risk
- Fix Node version in session-summary.md (20 → 24)
* fix: make vercelScope optional to clean up retry cast in vercelDeploy
Co-authored-by: amondnet <1964421+amondnet@users.noreply.github.com>
Agent-Logs-Url: https://github.com/amondnet/vercel-action/sessions/16d171b4-3be8-43f8-a736-b5f3ff13deba
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: amondnet <1964421+amondnet@users.noreply.github.com>1 parent 1043003 commit feb50fe
File tree
32 files changed
+11071
-34118
lines changed- .please/memory
- dist
- src
- __tests__
32 files changed
+11071
-34118
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments