feat: dogfood published @gitpulse/cli; add Vercel config; package README#35
feat: dogfood published @gitpulse/cli; add Vercel config; package README#35
Conversation
… README Three small follow-ups now that 0.1.2 is on npm: - self-deploy.yml: rewritten to *call* publish-pages.yaml@v0 with the published cli (was running the local workspace inline). Every push to main now exercises the exact path external consumers hit — npx @gitpulse/cli@0 analyze + build → upload Pages artifact → deploy. - vercel.json: build config so a Vercel project connected to this repo picks up the published-cli build hook out of the box. installCommand is a no-op since the cli is fetched via npx; framework: null because the cli wraps Next.js internally and Vercel just sees the static output. - cli/package.json: prepack script copies README.md + LICENSE from repo root into cli/ before npm pack, so the published package on npm has a README (it didn't on 0.1.2 — the files entry referenced paths that don't exist in cli/, so npm pack silently shipped without them). - .gitignore: ignore the prepack-generated cli/README.md and cli/LICENSE copies — never commit them, the originals live at root. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The npm pack --dry-run during local verification left a tarball in cli/ that got swept up by git add -A. Removing it and adding *.tgz to .gitignore so this doesn't happen again.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds platform auto-detection for repository and site URL (Vercel, Netlify, Cloudflare Pages); refactors self-deploy workflow to call a reusable publish workflow; introduces an explicit Vercel prebuilt-deploy workflow; updates CLI/site base-path logic, docs, and a CLI prepack script for packaging. ChangesPlatform Environment Auto-Detection & Deployment
CLI Package Distribution
Sequence Diagram(s)sequenceDiagram
autonumber
participant GH as GitHub Actions
participant PublishWF as publish-pages reusable workflow
participant CLI as `@gitpulse/cli`
participant Vercel as Vercel (Platform)
GH->>PublishWF: call publish-pages (ai inputs, OPENAI_API_KEY)
PublishWF->>CLI: run analyze/build (uses env detection)
CLI->>PublishWF: emits static output (.gitpulse/out)
PublishWF->>Vercel: (optional) stage prebuilt output / trigger deploy
Vercel->>GH: deployment status (via API / env)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
| Filename | Overview |
|---|---|
| cli/src/config.ts | Adds platform auto-detection for GITHUB_REPOSITORY and site URL (Vercel/Netlify/CF Pages); dead autoSiteUrl function left over from refactor; misleading error message on format validation. |
| .github/workflows/deploy-vercel.yml | New CI workflow that runs analyze+build in GitHub Actions and ships prebuilt output to Vercel via --prebuilt; well-structured with correct env mapping and concurrency config. |
| .github/workflows/self-deploy.yml | Simplified to delegate to the published reusable workflow znat/gitpulse/.github/workflows/publish-pages.yaml@v0; permissions correctly elevated to pages:write + id-token:write for the inner deploy. |
| cli/package.json | Adds portable Node.js prepack script to copy README.md and LICENSE from repo root before npm pack; previously flagged cp-based approach replaced with cross-platform Node one-liner. |
| site/src/lib/seo.ts | Adds detectDeployedUrl() mirroring config.ts logic; getBaseUrl() now resolves Vercel/Netlify/CF Pages URLs automatically before falling back to GitHub Pages derivation. |
| site/next.config.js | Detects PaaS root-deploy environments (Vercel/Netlify/CF Pages) to default basePath to '' instead of /, avoiding double-path issues on those platforms. |
| cli/src/cli.ts | Minor help text update for GITPULSE_SITE_URL to reflect auto-detection on Vercel, Netlify, and Cloudflare Pages. |
| README.md | Expanded Vercel section with CI-build path docs, updated Netlify/Cloudflare sections to reflect auto-detection, and config table updates. |
| .gitignore | Adds ignores for prepack-generated cli/README.md and cli/LICENSE, plus *.tgz for dry-run artifacts. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Push to main] --> B[self-deploy.yml]
A --> C[deploy-vercel.yml]
B --> D["znat/gitpulse/.github/workflows/\npublish-pages.yaml@v0\n(published reusable workflow)"]
D --> E["npx @gitpulse/cli@0 analyze\n+ build"]
E --> F[GitHub Pages]
C --> G["npx @gitpulse/cli@0 analyze\n(GITPULSE_SITE_URL from vars.VERCEL_SITE_URL)"]
G --> H["npx @gitpulse/cli@0 build\n(GITPULSE_BASE_PATH=none)"]
H --> I["Stage → .vercel/output/static\n+ config.json version:3"]
I --> J["vercel deploy --prebuilt --prod"]
J --> K[Vercel CDN]
subgraph "config.ts: resolveSiteUrl()"
L{GITPULSE_SITE_URL set?} -->|yes| M[Use explicit URL]
L -->|no| N{Platform detected?}
N -->|Vercel| O[VERCEL_PROJECT_PRODUCTION_URL / VERCEL_URL]
N -->|Netlify| P[URL / DEPLOY_PRIME_URL]
N -->|CF Pages| Q[CF_PAGES_URL]
N -->|none| R{BASE_PATH non-auto?}
R -->|yes| S[throw — require explicit URL]
R -->|no| T[GitHub Pages fallback]
end
Reviews (7): Last reviewed commit: "fix: apply CodeRabbit auto-fixes" | Re-trigger Greptile
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cli/package.json`:
- Line 39: The prepack script in package.json uses the Unix-only "cp -f
../README.md ../LICENSE ." which fails on Windows; replace it with a
cross-platform approach by either adding a devDependency such as "shx" or "cpx"
and updating the "prepack" script to use that (e.g., "shx cp -f ../README.md
../LICENSE .") or implement a small Node script (e.g., scripts/prepack.js) that
copies the files and change "prepack" to "node scripts/prepack.js"; ensure you
update package.json to include the chosen devDependency and the new script
entry.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: c013d29c-5e7e-4406-bb03-e902c3d14b8f
📒 Files selected for processing (4)
.github/workflows/self-deploy.yml.gitignorecli/package.jsonvercel.json
GITPULSE_SITE_URL is what the analyzer uses for state restore and what the site uses for canonical/SEO URLs. Setting it manually after every fresh Vercel/Netlify deploy is friction we don't need — the platforms already expose their URL via build-time env vars. Detection priority (in both cli/src/config.ts and site/src/lib/seo.ts): 1. Explicit GITPULSE_SITE_URL (override) 2. Vercel: VERCEL_PROJECT_PRODUCTION_URL (prod) / VERCEL_URL (preview) 3. Netlify: URL / DEPLOY_PRIME_URL / DEPLOY_URL 4. Cloudflare Pages: CF_PAGES_URL 5. GH Pages: https://<owner>.github.io/<repo>/ Updates: - cli/src/config.ts: autoSiteUrl() detects platforms before falling back. - site/src/lib/seo.ts: getBaseUrl() same priority order. - cli/src/cli.ts --help: docs reflect auto-detection. - README: Vercel / Netlify / Cloudflare deploy guides drop the GITPULSE_SITE_URL row from required vars (auto-detected); Configuration table notes the auto-detection sources. Net effect: zero env-var setup for the URL on Vercel/Netlify/CF Pages. Custom domains still set GITPULSE_SITE_URL explicitly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cli/src/config.ts`:
- Line 46: The explicit GITPULSE_SITE_URL value is used as-is for siteUrl which
causes inconsistent shapes (trailing slash or not) versus
autoSiteUrl(repoFullName); update the siteUrl assignment so when
env.GITPULSE_SITE_URL is present you normalize it to the same shape as
autoSiteUrl by trimming any trailing slash (or otherwise ensuring a consistent
canonical form) before assigning to siteUrl; change the expression that
currently reads siteUrl: env.GITPULSE_SITE_URL || autoSiteUrl(env, repoFullName)
to call a small normalization helper (or inline trim logic) that processes
env.GITPULSE_SITE_URL so both explicit and auto-detected URLs match.
In `@README.md`:
- Line 174: The README's config table entry for GITPULSE_SITE_URL is missing the
Netlify fallback env var DEPLOY_URL; update the GITPULSE_SITE_URL description to
include DEPLOY_URL alongside URL and DEPLOY_PRIME_URL so the documented fallback
list matches the platform behavior and code.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 737cb35d-9a9d-456c-a4bc-a933054ca2d9
📒 Files selected for processing (4)
README.mdcli/src/cli.tscli/src/config.tssite/src/lib/seo.ts
…e URL, complete Netlify list Three review-driven fixes: - cli/package.json: replace 'cp -f' (Unix-only) with a Node one-liner for prepack so npm pack works on Windows too. Verified locally; produces the same tarball contents. - cli/src/config.ts: normalize explicit GITPULSE_SITE_URL to always have a trailing slash, matching the auto-detected shape. Prevents path-join inconsistencies in site-fetcher (was passing through raw input, which let 'https://host' vs 'https://host/' diverge). - README.md: add DEPLOY_URL to the Netlify auto-detection list in the Configuration table — it's the third fallback in the actual detection logic but was missing from the docs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Treats gitpulse-on-Vercel like a consumer would using --prebuilt: CI runs
analyze + build with @gitpulse/cli@0, then ships .gitpulse/out to Vercel
via 'vercel deploy --prebuilt'. Vercel runs no build, sees no LLM keys,
needs no env vars maintained on its side.
Runs alongside self-deploy.yml (Pages) — both deploy gitpulse on every
push to main, decoupled.
Architecture:
- Resolves the production URL via Vercel's /v9/projects API (prefers
custom domains, falls back to <project>.vercel.app).
- Pins GITPULSE_SITE_URL to that URL for both analyze (state restore)
and build (canonical <meta> tags).
- Stages .vercel/output/{static,config.json} per Vercel's Build Output
API v3 format, then 'vercel deploy --prebuilt --prod'.
vercel.json deleted: the previous on-Vercel-build config is obsolete
under this pattern. Vercel never sees a build now.
cli/src/config.ts: auto-detects GITHUB_REPOSITORY from VERCEL_GIT_REPO_*
or Netlify's REPOSITORY_URL when GITHUB_REPOSITORY isn't set explicitly.
This also helps consumers running the on-Vercel-build pattern (option A)
since they no longer need to set it manually.
site/next.config.js: detects PaaS deployment context (VERCEL / NETLIFY /
CF_PAGES env vars) and forces basePath to '' regardless of
GITHUB_REPOSITORY. Means consumers on those platforms don't need to set
GITPULSE_BASE_PATH=none anymore.
README: documents both Vercel patterns side-by-side. Option A (Vercel
builds) is simplest for consumers; option 4 (CI builds, Vercel hosts) is
what gitpulse itself uses and explains the workflow inline.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
README.md (1)
65-90:⚠️ Potential issue | 🟠 Major | ⚡ Quick winThe Vercel "simplest" recipe doesn't match what
gitpulse buildproduces.
gitpulse buildwrites the exported site to.gitpulse/out; it does not produce a repo-localnext buildartifact. As written, this section either fails on repos withoutnextor points Vercel at the wrong directory. Please document the actual Vercel build command/output directory for this flow instead of telling consumers to appendnext build.Suggested fix
-// package.json -{ - "scripts": { - "build": "gitpulse analyze && gitpulse build && next build" - }, - "devDependencies": { - "@gitpulse/cli": "^0" - } -} +Build Command: npx -y `@gitpulse/cli`@0 analyze && npx -y `@gitpulse/cli`@0 build +Output Directory: .gitpulse/out +Framework Preset: Other / no preset-For Vercel's auto-detection to find `next build` output, make sure the framework preset is "Next.js" and the build output is `out` (or however your `next.config.js` is configured). +Because the CLI already produces static output, point Vercel at `.gitpulse/out` directly instead of running a consumer-side `next build`.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@README.md` around lines 65 - 90, The README's Vercel recipe is incorrect: gitpulse build exports the site to .gitpulse/out (not the Next.js build output), so update the instructions to use the gitpulse commands and point Vercel's Output Directory to .gitpulse/out; specifically change the example package.json script to run "gitpulse analyze && gitpulse build" (omit next build unless your repo actually uses Next directly) and instruct users to set Vercel's Build Command to run those gitpulse commands and the Output Directory to ".gitpulse/out" (reference: gitpulse build, gitpulse analyze, .gitpulse/out, next build).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cli/src/config.ts`:
- Around line 25-34: The guard around repoFullName (value from
env.GITHUB_REPOSITORY or detectRepoFullName(env)) accepts malformed values like
"owner-only"; add validation that repoFullName matches the "<owner>/<repo>"
pattern (e.g. non-empty owner, a slash, non-empty repo, no extra slashes) and if
it fails throw the existing Error instead of continuing; implement this check
right after computing repoFullName (before using it to build URLs) and reference
repoFullName and detectRepoFullName when locating the change.
- Around line 53-58: Replace the current inline siteUrl resolution with a small
resolver (e.g. resolveSiteUrl) that first returns
normalizeSiteUrl(env.GITPULSE_SITE_URL) when present, then returns any detected
deployed URL (normalized) from auto/detection logic, and only if neither exists
allow the GitHub Pages fallback; if GITPULSE_BASE_PATH is set and !== 'auto'
(i.e. non-default or "none"), throw an error requiring an explicit
GITPULSE_SITE_URL. Wire resolveSiteUrl to the siteUrl field (instead of the
current normalizeSiteUrl(...) ?? autoSiteUrl(...)) and reference repoFullName
when constructing the Pages fallback.
---
Outside diff comments:
In `@README.md`:
- Around line 65-90: The README's Vercel recipe is incorrect: gitpulse build
exports the site to .gitpulse/out (not the Next.js build output), so update the
instructions to use the gitpulse commands and point Vercel's Output Directory to
.gitpulse/out; specifically change the example package.json script to run
"gitpulse analyze && gitpulse build" (omit next build unless your repo actually
uses Next directly) and instruct users to set Vercel's Build Command to run
those gitpulse commands and the Output Directory to ".gitpulse/out" (reference:
gitpulse build, gitpulse analyze, .gitpulse/out, next build).
🪄 Autofix (Beta)
✅ Autofix completed
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 4d2d6ca7-2abe-4c78-8ecb-1f970bb77e76
📒 Files selected for processing (4)
.github/workflows/deploy-vercel.ymlREADME.mdcli/src/config.tssite/next.config.js
…API call Vercel's production alias is stable per project — the 12-line curl + jq dance to fetch it on every workflow run was strictly more complex than the value it provided. Replaced with a single VERCEL_SITE_URL repo variable (vars, not secrets — the URL is public). Trade: one more thing for maintainers to set up once, vs zero API calls on every deploy. Net code reduction: ~30 lines across the workflow file and README example. If you later need a dynamic / multi-domain setup, the original API+jq approach is in the git history. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/deploy-vercel.yml:
- Around line 57-60: Add a pre-step that fails fast if the VERCEL_SITE_URL repo
variable is unset: before any steps that use GITPULSE_SITE_URL (the env var
populated from vars.VERCEL_SITE_URL) in the analyze/build jobs, insert a small
check step that exits non‑zero when ${{ vars.VERCEL_SITE_URL }} is empty and
prints a clear error; ensure the check runs in the same job(s) that reference
GITPULSE_SITE_URL (e.g., analyze and build) so the workflow stops immediately
rather than proceeding with a missing URL.
In `@README.md`:
- Line 165: Docs claim GITPULSE_SITE_URL is auto-detected from URL /
DEPLOY_PRIME_URL / DEPLOY_URL, but the CLI currently only reads process.env.URL;
either update the README text (lines referenced) to state that the CLI detects
Netlify from process.env.URL only, or modify the CLI detection logic in the
config module to add fallbacks for process.env.DEPLOY_PRIME_URL and
process.env.DEPLOY_URL (so GITPULSE_SITE_URL resolution matches the docs);
ensure whichever approach you pick keeps the GITPULSE_SITE_URL wording
consistent and mention the exact env variables (URL, DEPLOY_PRIME_URL,
DEPLOY_URL) in the README.
🪄 Autofix (Beta)
❌ Autofix failed (check again to retry)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: d290d1d2-9233-49ae-bb63-5ff7d20ef584
📒 Files selected for processing (2)
.github/workflows/deploy-vercel.ymlREADME.md
| # Hardcoded production URL (repo variable). Vercel's prod alias | ||
| # is stable per project — no need to query the API on every run. | ||
| GITPULSE_SITE_URL: ${{ vars.VERCEL_SITE_URL }} | ||
| OPENAI_API_KEY: ${{ secrets.MINIMAX_API_KEY }} |
There was a problem hiding this comment.
Fail fast when VERCEL_SITE_URL is missing.
At Line 59 and Line 69, ${{ vars.VERCEL_SITE_URL }} is used directly, but there’s no guard if it’s unset. That can silently point analyze/build at the wrong URL fallback. Add an explicit validation step before analyze/build.
Suggested patch
- uses: actions/setup-node@v6
with:
node-version: 22
+
+ - name: Validate required repo variable
+ run: |
+ set -euo pipefail
+ if [ -z "${{ vars.VERCEL_SITE_URL }}" ]; then
+ echo "Missing required repo variable: VERCEL_SITE_URL"
+ echo "Set it in Settings → Secrets and variables → Actions → Variables."
+ exit 1
+ fiAlso applies to: 68-69
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.github/workflows/deploy-vercel.yml around lines 57 - 60, Add a pre-step
that fails fast if the VERCEL_SITE_URL repo variable is unset: before any steps
that use GITPULSE_SITE_URL (the env var populated from vars.VERCEL_SITE_URL) in
the analyze/build jobs, insert a small check step that exits non‑zero when ${{
vars.VERCEL_SITE_URL }} is empty and prints a clear error; ensure the check runs
in the same job(s) that reference GITPULSE_SITE_URL (e.g., analyze and build) so
the workflow stops immediately rather than proceeding with a missing URL.
…rom required steps The 'vercel link' step was just a way to extract orgId + projectId. Since the dashboard exposes both directly (Project → Settings → General → Project ID, and Team Settings → General → Team ID), most users don't need to install the CLI locally at all. Updated both the workflow header comment and the README's option-4 setup checklist. Kept 'vercel link' as an alternative for anyone who already lives in the CLI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Fixes Applied SuccessfullyFixed 1 file(s) based on 2 unresolved review comments. Files modified:
Commit: The changes have been pushed to the Time taken: |
Fixed 1 file(s) based on 2 unresolved review comments. Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. ⛔ CodeRabbit does not have permission to push changes to this repository. Please ensure CodeRabbit has Contents: Read and write permission. |
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. ⛔ CodeRabbit does not have permission to push changes to this repository. Please ensure CodeRabbit has Contents: Read and write permission. |
Three small follow-ups now that `@gitpulse/cli@0.1.2` is live on npm.
self-deploy.yml: switch to the public consumer path
Rewritten to call the published reusable workflow (`znat/gitpulse/.github/workflows/publish-pages.yaml@v0`) with the published `@gitpulse/cli` — instead of running the local workspace inline. Every push to `main` now exercises the exact path external consumers hit:
```yaml
jobs:
publish:
uses: znat/gitpulse/.github/workflows/publish-pages.yaml@v0
with:
ai-protocol: openai
ai-base-url: https://api.minimax.io/v1
ai-model: MiniMax-M2.7
secrets:
OPENAI_API_KEY: ${{ secrets.MINIMAX_API_KEY }}
```
Bleeding-edge testing of un-released cli changes happens via PR CI (`yarn workspace @gitpulse/cli build`) and `yarn workspace @gitpulse/cli analyze` during dev.
vercel.json
Drop-in build config so connecting the repo to Vercel picks up the published-cli build hook out of the box:
```json
{
"buildCommand": "npx -y @gitpulse/cli@0 analyze && npx -y @gitpulse/cli@0 build",
"outputDirectory": ".gitpulse/out",
"installCommand": "echo Skipping install — using published @gitpulse/cli@0",
"framework": null
}
```
`framework: null` because the cli wraps Next.js internally — Vercel just sees the static output. `installCommand` is a no-op since the cli is fetched via `npx`.
cli/package.json prepack: ship README + LICENSE on npm
`@gitpulse/cli@0.1.2` shipped without a README — the `files` array in `cli/package.json` referenced `README.md` and `LICENSE` paths that don't exist in `cli/` (originals are at repo root). Added a `prepack` script that copies them before `npm pack` runs:
```json
"prepack": "cp -f ../README.md ../LICENSE ."
```
Verified via `npm pack --dry-run` — README (10.3kB) + LICENSE (34.5kB) now in the tarball.
`.gitignore`: ignore the prepack-generated `cli/README.md` and `cli/LICENSE` copies + `*.tgz` so dry-run artifacts don't get committed.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation