Commit graph

9 commits

Author SHA1 Message Date
007b09e3be Merge pull request 'Audit: fix auth/config bugs, add issue/pr create, tests and docs' (#2) from audit/fixes-and-hardening into main 2026-07-22 19:35:52 +00:00
Claude
69704cdf9b Audit: fix auth/config bugs, add issue/pr create, tests and docs
Fixes found during a full audit of the CLI:

- auth logout: remote token revocation always failed with 401 because
  Forgejo only accepts Basic auth on the token endpoints. Logout now
  asks for (or accepts) the account password, supports --password,
  --password-file and --local-only, and clearly reports when the token
  is left active.
- Silent password prompt actually echoed the password on a TTY:
  overriding rl.write does not suppress readline echo. Switched to the
  callback readline module and mute _writeToOutput instead (the
  readline/promises interface does not honor that hook).
- Global --config flag was silently ignored: config paths were resolved
  at require time, before the preAction hook set STOKE_CONFIG_FILE.
  Paths are now resolved lazily on every access.
- XDG_CONFIG_HOME handling put the config in $XDG_CONFIG_HOME/.config/stoke;
  per the XDG spec it now resolves to $XDG_CONFIG_HOME/stoke.
- repo create: --auto-init defaulted to true with no way to disable it;
  added --no-auto-init.
- repo import/import-batch: a GitHub token was required even for
  non-GitHub services (e.g. --service git), making those imports fail
  without gh/GITHUB_TOKEN. Tokens are now only auto-resolved for the
  github service; batch imports resolve per entry and memoize.
- Branding leftovers: 'Run: forgejo auth login' hint and
  forgejo-cli/1.0.0 User-Agent now say stoke (UA tracks pkg.version).
- Added request timeouts (30s default, 10m for migrations).
- --limit and --team-id are validated as integers instead of silently
  misbehaving on garbage (NaN made -l show all results).

New commands (per the repo's every-operation-becomes-a-command design):

- stoke issue create (title/body/body-file/assignees)
- stoke pr create (head/base/title/body/body-file)

Tests and metadata:

- New test suite on the built-in node:test runner (25 tests) covering
  config resolution/persistence, the API client with a mocked fetch,
  and end-to-end CLI behavior. npm test previously matched no files.
- package.json: engines >=22.12.0 (required by commander@15 — the
  README claimed Node 18), repository, keywords, author; version 1.1.0.
- README: corrected Node requirement, documented repo rename (was
  missing), issue create, pr create, logout options and revocation
  caveat, --no-auto-init, XDG behavior, import token rules, testing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 19:28:23 +00:00
0a50b40798 Add user and org team commands
New commands, one per Forgejo API call used to set up the heavy-duty
organization membership:

- stoke user list              (GET /api/v1/users/search)
- stoke user show              (GET /api/v1/users/{username})
- stoke org team list          (GET /api/v1/orgs/{org}/teams)
- stoke org team create        (POST /api/v1/orgs/{org}/teams)
- stoke org team member-list   (GET /api/v1/teams/{id}/members)
- stoke org team member-add    (PUT /api/v1/teams/{id}/members/{username})
- stoke org team member-remove (DELETE /api/v1/teams/{id}/members/{username})

All commands documented in the README.
2026-07-22 17:56:14 +00:00
dadfca6093 Add org and repo transfer commands
New commands, one per Forgejo API call used to move the heavy-duty
repositories into the new heavy-duty organization:

- stoke org create   (POST /api/v1/orgs)
- stoke org repos    (GET /api/v1/orgs/{org}/repos)
- stoke org avatar   (POST /api/v1/orgs/{org}/avatar)
- stoke repo transfer (POST /api/v1/repos/{owner}/{repo}/transfer)

All commands documented in the README.
2026-07-22 17:47:48 +00:00
54f80bbbcf docs: explain the stoke name 2026-07-22 16:38:14 +00:00
a661e4f923 chore: update lockfile name to stoke 2026-07-22 15:16:56 +00:00
9e7c204201 chore: rename CLI and project to stoke 2026-07-22 15:16:42 +00:00
25670253ea feat: add repo collaborator command 2026-07-22 15:06:35 +00:00
c981a1258d feat: forgejo-cli with auth, repo, issue, pr and branch commands 2026-07-22 15:03:32 +00:00