Skip to content

Convert to TypeScript#58

Merged
hawkeyexl merged 3 commits intomainfrom
typescript
Feb 27, 2026
Merged

Convert to TypeScript#58
hawkeyexl merged 3 commits intomainfrom
typescript

Conversation

@hawkeyexl
Copy link
Contributor

@hawkeyexl hawkeyexl commented Feb 27, 2026

Add a TypeScript configuration and an esbuild script for building the project. Exclude intermediate build outputs from version control. Update package.json to reflect the new build process and dependencies. Remove legacy JavaScript code.

Summary by CodeRabbit

  • New Features

    • Added TypeScript type checking capability
  • Chores

    • Updated GitHub Actions dependencies to latest major versions
    • Migrated build system to esbuild
    • Changed application entry point to dist/index.js
    • Added TypeScript configuration for modern compilation targets

Copilot AI review requested due to automatic review settings February 27, 2026 19:10
@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

Warning

Rate limit exceeded

@hawkeyexl has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 7 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between a2a4f5c and 6f7beb8.

⛔ Files ignored due to path filters (3)
  • dist/index.js is excluded by !**/dist/**
  • dist/index.js.map is excluded by !**/dist/**, !**/*.map
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • .gitignore
  • esbuild.config.mjs
  • package.json
  • src/index.ts
  • tsconfig.json
  • utils.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch typescript

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hawkeyexl
Copy link
Contributor Author

@CodeRabbit review

@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

Pull request overview

This PR migrates the GitHub Action codebase from legacy JavaScript to TypeScript, introducing a TypeScript build/typecheck workflow and updating dependencies to support the new build pipeline.

Changes:

  • Added tsconfig.json and an esbuild build script to bundle src/index.ts into dist/index.js.
  • Converted the action entrypoint to TypeScript and removed the legacy utils.js.
  • Updated npm dependencies/devDependencies and ignored intermediate TypeScript build output.

Reviewed changes

Copilot reviewed 4 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
utils.js Removes legacy JS utilities (now unused after TS conversion).
tsconfig.json Adds strict TypeScript configuration for src/ with build/ output.
src/index.ts Converts action implementation to TypeScript and updates runtime behavior accordingly.
package.json Switches build script to esbuild, adds typecheck script, updates dependencies.
package-lock.json Locks updated dependency graph for the new toolchain and action libraries.
esbuild.config.mjs Adds bundling configuration to produce dist/index.js for the action runtime.
.gitignore Ignores intermediate build/ TypeScript output.
Comments suppressed due to low confidence (5)

src/index.ts:88

  • process.env.RUNNER_TEMP || "" can cause outputPath to resolve relative to the current working directory when RUNNER_TEMP is unset, which can write the results file into an unexpected location (and may later fail when trying to read it back). Prefer failing fast with a clear error when RUNNER_TEMP is missing, or falling back to os.tmpdir() explicitly.
    src/index.ts:104
  • compiledCommand is built as a single string with unquoted user-provided paths (e.g. config, input, outputPath). If any of these contain spaces, @actions/exec will split them into multiple arguments and Doc Detective will receive corrupted flags. Consider calling exec("npx", [dd, ...args]) (or at least quoting/escaping) so paths are passed as discrete args.
    src/index.ts:145
  • The working_directory input is passed as cwd to Doc Detective, but the subsequent git change detection uses execSync("git status") without setting cwd (or process.chdir). If working_directory is not . this will check the wrong directory/repo (and can incorrectly skip/trigger PR creation). Run these git commands with the same cwd as the Doc Detective invocation.
    src/index.ts:266
  • createPullRequest() runs all git commands (rev-parse, checkout, add, commit, push) without specifying cwd, so it will operate on whatever the process working directory is rather than the working_directory input used earlier. This can break PR creation for workflows that run Doc Detective in a subdirectory. Pass cwd into exec/execSync (or process.chdir) consistently.
    src/index.ts:317
  • In the error handler for adding labels/assignees/reviewers, non-403 errors are logged but not propagated. That means API failures (e.g. invalid labels/reviewers) will silently succeed and the workflow will continue as if the PR was fully configured. Consider rethrowing the error (or at least failing the action) for unexpected statuses so misconfiguration is surfaced.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/index.ts (1)

287-289: ⚠️ Potential issue | 🟡 Minor

Missing filter for empty labels, assignees, and reviewers.

Unlike createIssue (lines 198-199), this function doesn't filter out empty strings after splitting. If inputs are empty or have trailing commas, this could send invalid values to the GitHub API.

🐛 Suggested fix
     core.info(`Adding labels.`);
     await octokit.request(
       "POST /repos/{owner}/{repo}/issues/{issue_number}/labels",
       {
         owner: github.context.repo.owner,
         repo: github.context.repo.repo,
         issue_number: pr.data.number,
-        labels: labels.split(","),
+        labels: labels.split(",").map((s) => s.trim()).filter(Boolean),
       }
     );
     core.info(`Adding assignees.`);
     await octokit.request(
       "POST /repos/{owner}/{repo}/issues/{issue_number}/assignees",
       {
         owner: github.context.repo.owner,
         repo: github.context.repo.repo,
         issue_number: pr.data.number,
-        assignees: assignees.split(","),
+        assignees: assignees.split(",").map((s) => s.trim()).filter(Boolean),
       }
     );
     core.info(`Adding reviewers.`);
     await octokit.request(
       "POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers",
       {
         owner: github.context.repo.owner,
         repo: github.context.repo.repo,
         pull_number: pr.data.number,
-        reviewers: reviewers.split(","),
+        reviewers: reviewers.split(",").map((s) => s.trim()).filter(Boolean),
       }
     );
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/index.ts` around lines 287 - 289, The PR creation path currently does
labels: labels.split(",") without removing empty strings; mirror the createIssue
fix by splitting then filtering out falsy/empty entries for labels, assignees
and reviewers before sending to the GitHub API (i.e., replace labels.split(",")
with a split+filter sequence and apply the same to assignees and reviewers
variables), ensuring the properties passed are arrays with no empty-string
items.
🧹 Nitpick comments (2)
tsconfig.json (1)

7-10: Declaration options are unused with --noEmit typecheck.

The declaration and declarationMap options won't produce any output since package.json runs tsc --noEmit. If you don't need declaration files, you can remove these options to simplify the config. If you do need them for consumers, consider adding a separate script.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tsconfig.json` around lines 7 - 10, The tsconfig includes "declaration" and
"declarationMap" which are unused because your package.json runs "tsc --noEmit";
either remove "declaration" and "declarationMap" from tsconfig to simplify
config, or keep them but add a separate build script (e.g., a new npm script
that runs tsc without --noEmit to emit declaration files) and document that
script; update any README or package scripts accordingly so consumers get .d.ts
when needed.
esbuild.config.mjs (1)

3-12: Consider adding error handling for build failures.

The build script doesn't handle errors, which could result in silent failures. While esbuild will throw on critical errors, adding explicit error handling improves debugging.

♻️ Suggested improvement
 import { build } from "esbuild";
 
-await build({
-  entryPoints: ["src/index.ts"],
-  bundle: true,
-  platform: "node",
-  target: "node20",
-  format: "cjs",
-  outfile: "dist/index.js",
-  sourcemap: true,
-  minify: false,
-});
+try {
+  await build({
+    entryPoints: ["src/index.ts"],
+    bundle: true,
+    platform: "node",
+    target: "node20",
+    format: "cjs",
+    outfile: "dist/index.js",
+    sourcemap: true,
+    minify: false,
+  });
+  console.log("Build completed successfully");
+} catch (error) {
+  console.error("Build failed:", error);
+  process.exit(1);
+}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@esbuild.config.mjs` around lines 3 - 12, The esbuild call (await
build({...})) lacks error handling; wrap the await build(...) invocation in a
try/catch block (or append a .catch handler) to catch thrown errors, log the
full error via console.error (or your app logger) and exit non‑zero (e.g.,
process.exit(1)) so build failures aren’t silent; update the code around the
build(...) call to use try { await build(...) } catch (err) {
console.error("Build failed:", err); process.exit(1); }.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/index.ts`:
- Around line 85-88: The outputPath resolution uses an empty string fallback for
RUNNER_TEMP which can resolve to the CWD; update the outputPath assignment (the
const outputPath variable using path.resolve) to use a safe fallback like
os.tmpdir() when process.env.RUNNER_TEMP is undefined or empty (import os via
require('os') or import { tmpdir } from 'os'), e.g. use process.env.RUNNER_TEMP
|| os.tmpdir() in the path.resolve call so the file is placed in the system temp
directory instead of the working directory.

---

Outside diff comments:
In `@src/index.ts`:
- Around line 287-289: The PR creation path currently does labels:
labels.split(",") without removing empty strings; mirror the createIssue fix by
splitting then filtering out falsy/empty entries for labels, assignees and
reviewers before sending to the GitHub API (i.e., replace labels.split(",") with
a split+filter sequence and apply the same to assignees and reviewers
variables), ensuring the properties passed are arrays with no empty-string
items.

---

Nitpick comments:
In `@esbuild.config.mjs`:
- Around line 3-12: The esbuild call (await build({...})) lacks error handling;
wrap the await build(...) invocation in a try/catch block (or append a .catch
handler) to catch thrown errors, log the full error via console.error (or your
app logger) and exit non‑zero (e.g., process.exit(1)) so build failures aren’t
silent; update the code around the build(...) call to use try { await build(...)
} catch (err) { console.error("Build failed:", err); process.exit(1); }.

In `@tsconfig.json`:
- Around line 7-10: The tsconfig includes "declaration" and "declarationMap"
which are unused because your package.json runs "tsc --noEmit"; either remove
"declaration" and "declarationMap" from tsconfig to simplify config, or keep
them but add a separate build script (e.g., a new npm script that runs tsc
without --noEmit to emit declaration files) and document that script; update any
README or package scripts accordingly so consumers get .d.ts when needed.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a2a4f5c and b2557f5.

⛔ Files ignored due to path filters (3)
  • dist/index.js is excluded by !**/dist/**
  • dist/index.js.map is excluded by !**/dist/**, !**/*.map
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • .gitignore
  • esbuild.config.mjs
  • package.json
  • src/index.ts
  • tsconfig.json
  • utils.js
💤 Files with no reviewable changes (1)
  • utils.js

- Use os.tmpdir() fallback instead of empty string for RUNNER_TEMP
- Add .trim().filter(Boolean) for labels/assignees/reviewers in createPullRequest
- Remove unused declaration/declarationMap from tsconfig (tsc runs with --noEmit)
- Add error handling to esbuild config

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@hawkeyexl
Copy link
Contributor Author

@CodeRabbit review

@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@hawkeyexl hawkeyexl merged commit 504c9f4 into main Feb 27, 2026
8 checks passed
@promptless
Copy link

promptless bot commented Feb 27, 2026

📝 Documentation updates detected!

New suggestion: Update github-action docs to reflect TypeScript migration


Tip: Request one-off documentation tasks in the Dashboard under New Task 🚀

@hawkeyexl hawkeyexl deleted the typescript branch February 27, 2026 20:51
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.

2 participants