Skip to content

Rename to gswap, add gh bootstrap and update checking, release v1.0.0 - #1

Open
ImadRashid wants to merge 2 commits into
mainfrom
release/v1.0.0
Open

Rename to gswap, add gh bootstrap and update checking, release v1.0.0#1
ImadRashid wants to merge 2 commits into
mainfrom
release/v1.0.0

Conversation

@ImadRashid

Copy link
Copy Markdown
Owner

Summary

  • Renames the package, binary, data directory (~/.gswap) and env vars (GSWAP_*) from ghswap, since that npm name is owned by an unrelated project. Done now while nothing is published and the change is free.
  • Adds 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/.ps1 shim is printed for the user to run. Never a postinstall hook. add offers it inline when it finds no gh.
  • Adds a daily update check plus 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=1 opts in. The notice goes to stderr and is skipped under --json, CI and non-TTY use. upgrade detects npm/pnpm/bun/volta/yarn/brew and defers to the right one.
  • Fixes credentialHelpers() reading --global only. Helpers are usually set 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.
  • Smaller fixes: addedVia mislabelled PAT fallbacks as browser; removed --login, which was documented and recommended but never read; run() now survives Node refusing to spawn .cmd shims; the version is read from package.json instead of duplicated in cli.js; corrected a stale README troubleshooting entry and a message that blamed the network for a 404.
  • Adds CI across ubuntu/macOS/Windows on Node 18 and 22 — every real bug in this project so far has been platform-specific. Adds an auto-publish workflow gated on the version not already being on npm, so ordinary merges to main are a no-op rather than a red build.

Publishing v1.0.0 needs an NPM_TOKEN repository secret before this merges.

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.
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