Rename to gswap, add gh bootstrap and update checking, release v1.0.0 - #1
Open
ImadRashid wants to merge 2 commits into
Open
Rename to gswap, add gh bootstrap and update checking, release v1.0.0#1ImadRashid wants to merge 2 commits into
ImadRashid wants to merge 2 commits into
Conversation
The npm name "ghswap" is owned by an unrelated project, so the package, binary, data directory (~/.gswap) and environment variables (GSWAP_*) are all renamed while nothing is published yet and the change is still free. New: - `gswap install-gh` installs the GitHub CLI via whichever package manager the machine has. It only auto-runs installers that need no elevation and are real executables; anything requiring sudo/admin, or shipped as a .cmd/.ps1 shim, is printed for the user to run. Never a postinstall hook, so a global install can't escalate privileges or reach the network on its own. `add` offers it inline when it finds no gh. - A daily update check with `gswap upgrade`. It notifies rather than self-updating: this tool holds GitHub tokens, and new code shouldn't start running against them unannounced. GSWAP_AUTO_UPDATE=1 opts in. The check writes to stderr and is skipped under --json, CI and non-TTY use so it can't leak into piped output or slow a script down. The upgrade command detects npm/pnpm/bun/volta/yarn/brew and defers to the right one. Fixes: - credentialHelpers() read --global only, but helpers are usually configured at system scope: Git for Windows writes credential.helper=manager into C:\Program Files\Git\etc\gitconfig, and Xcode's gitconfig sets osxkeychain the same way. Reading only --global reported "no helper", so `use` silently skipped storing the credential and left the user pushing as the previous account. Now reads merged scope, which is what git itself consults. - addedVia recorded 'browser' for tokens pasted through the no-gh fallback. - Removed --login, which was documented and recommended but never read. - run() now survives Node refusing to spawn .cmd shims instead of throwing. - The version is read from package.json rather than duplicated in cli.js. - Corrected a README troubleshooting entry that predated reading tokens via `gh auth token`, and a message that blamed the network for a 404. CI runs the tests on ubuntu, macOS and Windows; this project's real bugs have all been platform-specific. Publishing is gated on the version not already being on npm, so ordinary merges to main are a no-op rather than a red build.
`node --test test/*.test.js` relies on the shell expanding the glob. PowerShell doesn't do that for external commands, so on Windows Node received the literal string and exited 1. Node 22 hid the problem by globbing internally; Node 18 did not, which is what CI caught. Bare `node --test` discovers test/ on its own and behaves the same on every platform and both Node versions. Also bumps actions/checkout and actions/setup-node to v7; v4 targets the now-deprecated Node 20 runtime and the runners were force-upgrading them.
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.
Summary
~/.gswap) and env vars (GSWAP_*) fromghswap, since that npm name is owned by an unrelated project. Done now while nothing is published and the change is free.gswap install-gh, which installs the GitHub CLI via whichever package manager the machine has. Auto-runs only installers needing no elevation that are real executables; anything requiring sudo/admin or shipped as a.cmd/.ps1shim is printed for the user to run. Never a postinstall hook.addoffers it inline when it finds no gh.gswap upgrade. It notifies rather than self-updating — this tool holds GitHub tokens, so new code shouldn't start running against them unannounced.GSWAP_AUTO_UPDATE=1opts in. The notice goes to stderr and is skipped under--json, CI and non-TTY use.upgradedetects npm/pnpm/bun/volta/yarn/brew and defers to the right one.credentialHelpers()reading--globalonly. Helpers are usually set at system scope — Git for Windows writescredential.helper=managerintoC:\Program Files\Git\etc\gitconfig, and Xcode's gitconfig setsosxkeychainthe same way. Reading only--globalreported "no helper", sousesilently skipped storing the credential and left the user pushing as the previous account.addedViamislabelled PAT fallbacks asbrowser; removed--login, which was documented and recommended but never read;run()now survives Node refusing to spawn.cmdshims; the version is read frompackage.jsoninstead of duplicated incli.js; corrected a stale README troubleshooting entry and a message that blamed the network for a 404.mainare a no-op rather than a red build.Publishing
v1.0.0needs anNPM_TOKENrepository secret before this merges.