feat: migrate to TypeScript, pnpm, and @octokit/rest#3
Open
GabrielHogan wants to merge 7 commits into
Open
Conversation
octokit.paginate silently returned an empty array when called with the endpoint method form (octokit.rest.issues.listForRepo), causing alias labels to be deleted without re-labeling issues that had them. Switching to the route string form produces the correct results.
Replaces package-lock.json with pnpm-lock.yaml and updated CI workflows to be compatible with pnpm.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The following PR and most of this code was written with the use of Generative AI. While I tested this extensively in the command line, AI models can produce incomplete, misleading, or erroneous information. I also did not test the JS tools beyond a basic implementation. I also did not test the enterprise functionality as I didn't have ready access to a self-hosted Github enterprise install. Github actions were also not tested.
My hope is that this was a good use of AI and the output is well-formed. It does pass all tests. Some further work is likely necessary, including bringing dependencies to their latest versions. I would love further input or guidance.
Thanks!
Gabe
Summary
This PR addresses #1 (Migrate to pnpm) and #2 (Migrate to TypeScript), and fixes a critical bug in alias label handling that manifests in EndBug/label-sync#302.
Closes #1
Closes #2
Closes EndBug/label-sync#302
Changes
TypeScript port (closes #2)
All source files have been rewritten in TypeScript:
lib/*.js+bin/github-label-sync.js→src/*.tsGitHubLabel,ConfiguredLabel,SyncOptions,LabelDiff, etc.)tsupproduces dual ESM + CJS bundles (dist/esm/anddist/cjs/)src/index.ctsshim provides propermodule.exports = githubLabelSyncCJS compatibilitypackage.jsonexportsmap for correct ESM/CJS resolution in all environmentspnpm migration (closes #1)
package-lock.jsonremoved,pnpm-lock.yaml+pnpm-workspace.yamladdedpnpm/action-setup@v6@octokit/restmigrationReplaced the deprecated
octonodepackage with the official@octokit/restv22:gotandnode.extendremoved as direct dependencies (tsup bundles@octokit/restandgot)Bug fix:
getLabeledIssuessilent empty array (related to EndBug/label-sync#302)octokit.paginatesilently returns an empty array when called with the endpoint method form (octokit.rest.issues.listForRepo). This caused alias labels to be deleted without re-labeling any issues that had them — the core failure mode reported in label-sync#302.Using the route string form produces the correct paginated results.
Dependency updates
js-yamlcommanderoctonodenode.extend@octokit/restTest modernization
vi.mock@vitest/coverage-v8Lint modernization
.eslintrc(ESLint v7) →eslint.config.js(ESLint v9 flat config +typescript-eslint)CI workflow updates
actions/checkoutv5/v4 → v6actions/setup-nodev4/v6 → v6 with Node.js 24.xpnpm/action-setup@v6added to all jobspnpm buildbefore publishREADME
--endpointCLI flag for GitHub Enterpriselabels.jsonlink (file no longer exists)Test plan
pnpm install --frozen-lockfilepnpm typecheck— passes with no errorspnpm lint— passespnpm test:coverage— all tests pass with ≥90% coveragepnpm build— producesdist/esm/anddist/cjs/artifactspnpm test:smoke— verifies CJSrequire, ESMimport, and CLI--helpall work correctly