Skip to content

[Hackathon] fix(ci): ci connect --dry-run really runs vercel link / vercel git connect (and ci doctor --dry-run calls gh api) #372

Closed

Description

@protonjls

Verified against (commit SHA or released version)

commit 988c0355bb05631e9c6c1785e443937ff2a88c0e (main, v0.14.0)

Discord Username / User ID

1149447580477042769

What does this improvement do?

--dry-run is documented as a no-side-effect preview:

  • global --help: "Skip the network and credentials; emit a canned sample matching the OpenAPI contract."
  • DOCUMENTATION.md (Quick start): "--dry-run is a global flag that emits a canned sample matching the API contract without writes or charges."

Every other command I tried honours that, including the sibling ci init --dry-run ("[dry-run] would write the workflow below — no files changed, no secret set"). setup, auth remove, agent install, doctor, usage and tunnel list honour it too. But ci connect and ci doctor never read --dry-run:

  • ci connect --project <name> --dry-run spawns the real npx --yes vercel@59 link --project <name> --non-interactive and then npx --yes vercel@59 git connect --non-interactive. The command's own help lists what that does: vercel link "writes .vercel/, may add a VERCEL_OIDC_TOKEN line to .env.local, and may update .gitignore". git connect links the GitHub repo to the Vercel project on Vercel's side, so future pushes deploy. After all that, it prints Connected Vercel to this repo., emits JSON "connected": true, exits 0, and shows no [dry-run] banner.
  • ci doctor --dry-run runs a live gh api repos/<repo>/deployments?per_page=100 and reports the real verdict.

So a user or coding agent following the docs' advice to "run any command with --dry-run first" ends up linking a real Vercel project to their repo.

Reproduction. No Vercel or GitHub account is needed: a PATH shim logs what would have been spawned and exits 0.

mkdir -p /tmp/shim
printf '#!/bin/sh\necho "npx $*" >> /tmp/shim.log\nexit 0\n' > /tmp/shim/npx
printf '#!/bin/sh\necho "gh $*" >> /tmp/shim.log\necho "[]"\n' > /tmp/shim/gh
chmod +x /tmp/shim/npx /tmp/shim/gh
cd "$(mktemp -d)" && git init -q
PATH=/tmp/shim:$PATH testsprite ci connect --project my-app --dry-run --output json; echo "exit=$?"
PATH=/tmp/shim:$PATH testsprite ci doctor --repo acme/web --dry-run >/dev/null 2>&1
cat /tmp/shim.log

Actual output:

{
  "platform": "vercel",
  "ran": [
    "npx vercel@59 link --project my-app --non-interactive",
    "npx vercel@59 git connect --non-interactive"
  ],
  "connected": true,
  "alreadyConnected": false,
  "reason": null
}
[info] connected. Linking only affects FUTURE pushes.
...
exit=0
npx --yes vercel@59 link --project my-app --non-interactive
npx --yes vercel@59 git connect --non-interactive
gh api repos/acme/web/deployments?per_page=100

Expected. With --dry-run, neither command spawns a subprocess. ci connect previews the commands it would run, and ci doctor previews the read it would make, each with a [dry-run] line on stderr like ci init --dry-run does.

Details / implementation notes

Root cause. In src/commands/ci.ts, runCiConnect and runCiDoctor never consult opts.dryRun. The flag is resolved (dryRun: g.dryRun ?? false in the common options) and runCiInit honours it in its // --dry-run: preview to stderr, emit the summary, and make no writes / no gh call. branch, but the two commands added alongside it in v0.13.0 skip it.

Proposed change (one file plus its spec):

  • runCiConnect: keep the existing --project name validation (so a bad name still exits 5 under --dry-run). Then, when opts.dryRun is set:
    • read .vercel/project.json the way it already does, to decide whether link would be needed;
    • print [dry-run] would run: npx vercel@59 … for each step;
    • emit the summary with ran: [] and connected: false, spawn nothing, and exit 0.
    • The "not linked and no --project" refusal stays as it is, since it is a local check.
  • runCiDoctor: when opts.dryRun is set, skip gh, print [dry-run] would read: gh api repos/<repo>/deployments?per_page=100, and emit a summary marked as a sample, the same way usage --dry-run labels its canned values. If you'd rather keep ci doctor out of scope, I'll limit the change to ci connect, since that is the one with side effects.
  • Tests in src/commands/ci.spec.ts: inject deps.spawn as a spy and assert it is never called under dryRun: true for connect (linked and unlinked directory) and doctor, plus that a bad --project name still fails with exit 5 under --dry-run. Each test fails on main today.
  • Update the ci connect / ci doctor sections of DOCUMENTATION.md to say what --dry-run previews.

I'd like to work on this once it's triaged.

Confirmations

  • I have searched existing issues and this is not a duplicate.
  • I have provided my Discord identity above for reward coordination.

Activity

  1. protonjls commented on Oct 20, 2026

    @protonjls
    ContributorAuthor

    Closing this myself. v0.15.0 deprecated ci doctor and ci connect, and the CHANGELOG says both are removed in the next release, so a fix here would land in code that is about to be deleted (the same reason #375 and #378 were closed). Until then, ci connect --dry-run on main (d61e6df) still runs npx vercel link / vercel git connect, so --dry-run on that command is a real run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions