feat: migrate scrapegraph-js from github pin to npm v2.1.0#17
feat: migrate scrapegraph-js from github pin to npm v2.1.0#17Vikrant-Khedkar wants to merge 3 commits intomainfrom
Conversation
Switches dependency from a broken github commit (no dist, wrong base URL) to the published npm package which ships with dist and uses the correct v2-api.scrapegraphai.com endpoint. Updates Api* type names to match the renamed exports in v2.1.0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Extract shared buildBaseFormat helper (src/lib/formats.ts) to dedup format-building logic previously duplicated across crawl/monitor/scrape. Uses exhaustive switch — no `as FormatConfig` cast needed. - Replace pervasive `params as Record<string, unknown>` mut-cast pattern with conditional spreads and properly-typed requests. - Add parseJsonArg / parseIntArg helpers (src/lib/parse.ts) so invalid --schema / --headers / --num-results / --max-pages etc. produce friendly CLI errors instead of raw SyntaxError or silent NaN. - Fix cast-then-validate ordering for --service in history.ts. - Type log.error as `: never` so control-flow narrowing works after it. No behavioural change to the golden path; tsc and biome clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Test results — commit
|
| # | Command | Result |
|---|---|---|
| 1 | validate |
200 {status: ok} |
| 2 | credits |
balance + job quotas returned |
| 3 | scrape -f markdown,html |
both payloads returned |
| 4 | scrape -f links |
leaf FormatConfig variant (no extras) |
| 5 | scrape -f summary |
leaf variant |
| 6 | scrape -f json -p … --schema … |
structured JSON |
| 7 | scrape --html-mode reader |
mode propagated (history confirms "mode":"reader") |
| 8 | extract --schema … |
typed JSON back |
| 9 | search --num-results 2 --country us |
results returned |
| 10 | search --time-range past_week |
filter applied (history confirms "timeRange":"past_week") |
| 11 | history scrape |
service filter works |
| 12 | crawl --max-pages 2 --max-depth 1 |
completed; params echoed back correctly |
Error paths (all new friendly messages)
| # | Input | Output |
|---|---|---|
| 13 | search --num-results abc |
--num-results: expected a number, got "abc" |
| 14 | extract --schema "not json" |
--schema: invalid JSON (JSON Parse error: …) |
| 15 | crawl --max-pages xyz |
--max-pages: expected a number, got "xyz" |
| 16 | crawl --include-patterns 'not-valid-json' |
--include-patterns: invalid JSON (…) |
| 17 | scrape -f bogusformat |
Unknown format: bogusformat. Valid: … |
| 18 | scrape -f json (no --prompt) |
--prompt is required when format includes json |
| 19 | monitor update (no --id) |
--id is required for update |
| 20 | monitor bogus |
Unknown action: bogus. Valid: … |
Not exercised
monitor create/pause/resume/delete/get/activity — free plan has monitor.limit = 1 so no live monitor was created. The code typechecks cleanly and all error branches (missing --url, missing --id, unknown action) pass.
Build
tsc --noEmit— zero errorsbiome check— clean
No longer needed — scrapegraph-js is now on npm and ships with dist/. The workaround was added in 82b8137 for the old github commit pin. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fixing it I thought it was breaking before also , |
|
I Fixed the CI/CD please check now @VinciGit00 |
Re-test results — all green ✅Re-ran the full test plan on
Credits delta: 407 → 397 (10 credits consumed across the run), confirming each request was actually billed server-side (not cached / stubbed). The type rename surface ( LGTM from my side. 🚀 |
Summary
ScrapeGraphAI/scrapegraph-js#096c110) with published npm package^2.1.0dist/and used the wrong base URL (api.scrapegraphai.com/api/v2→ 403), making the CLI broken out-of-the-boxApi*type imports to match renamed exports in v2.1.0 (ApiScrapeRequest→ScrapeRequest,ApiHistoryEntry→HistoryEntry, etc.)Test plan
credits— 200, correct balance returnedvalidate—{"status":"ok"}scrape— markdown returned for example.comsearch— results returnedextract— structured JSON returnedhistory— full history returnedtsc --noEmit— zero errors🤖 Generated with Claude Code