feat: add sentry sourcemap inject and sentry sourcemap upload commands#547
Merged
feat: add sentry sourcemap inject and sentry sourcemap upload commands#547
sentry sourcemap inject and sentry sourcemap upload commands#547Conversation
…mands Add user-facing CLI commands for sourcemap management: - `sentry sourcemap inject <dir>` — Scans a directory for JS files and their companion .map files, injects Sentry debug IDs for reliable sourcemap resolution. Supports --ext for custom extensions and --dry-run for preview. - `sentry sourcemap upload [org/project/]<dir>` — Uploads sourcemaps to Sentry using the chunk-upload + assemble protocol. Supports --release and --url-prefix flags. Auto-detects org/project from DSN/config or accepts explicit org/project/ prefix. Code organization: - Moved debug ID functions from script/debug-id.ts to src/lib/sourcemap/debug-id.ts (the canonical location). script/debug-id.ts is now a thin re-export. - Added src/lib/sourcemap/inject.ts for directory scanning + injection. - Registered `sourcemap` route in app.ts with `sourcemaps` plural alias. - Generated SKILL.md and reference docs for new commands.
Contributor
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Internal Changes 🔧Coverage
Other
🤖 This preview updates automatically when you update the PR. |
Contributor
|
- Rewrite upload command to take <directory> as a plain positional arg
instead of using parseSlashSeparatedArg (which breaks on paths with
slashes like ./dist). Org/project resolved via auto-detection cascade.
- injectDebugId now returns { debugId, wasInjected } so callers can
distinguish newly injected files from pre-existing ones. This fixes
the inject command's modified/skipped counts always showing 100%/0%.
- Register 'sourcemaps' as a duplicate route (not just a PLURAL_TO_SINGULAR
entry) so 'sentry sourcemaps inject/upload' actually works.
- Regenerated SKILL.md for the updated upload command signature.
Contributor
Codecov Results 📊✅ 126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 1028 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 96.03% 96.06% +0.03%
==========================================
Files 186 192 +6
Lines 25929 26084 +155
Branches 0 0 —
==========================================
+ Hits 24899 25056 +157
- Misses 1030 1028 -2
- Partials 0 0 —Generated by Codecov Action |
- Use path.relative() from the upload directory to construct artifact URLs, preserving subdirectory structure (e.g., static/js/main.js instead of just main.js). Prevents collisions for same-named files in different directories. - Hide the 'sourcemaps' alias route in --help output.
Use path.basename() for sourcemap filename extraction and path.relative() with backslash normalization for URLs. Prevents broken URLs on Windows where path separators are backslashes.
- Dry-run now reads the JS file to check for existing //# debugId= comments, correctly distinguishing 'would inject' from 'already has debug ID' in the modified/skipped counts. - Removed dead 'debugId !== (dry run)' filter in upload command since upload never uses dry-run.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
- Export EXISTING_DEBUGID_RE from debug-id.ts and import in inject.ts instead of maintaining duplicate regex definitions. - Clarify upload command docs: it automatically injects debug IDs into files that don't already have them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Add user-facing CLI commands for sourcemap management, completing the native sourcemap toolchain started in #543.
New Commands
sentry sourcemap inject <dir>.js/.mjs/.cjs) and their companion.mapfiles--extfor custom extensions,--dry-runfor previewnode_modulesand hidden directoriessentry sourcemap upload [org/project/]<dir>--releaseand--url-prefixflagsorg/project/prefix--jsonoutput and human-readable output supportedCode Changes
script/debug-id.ts→src/lib/sourcemap/debug-id.ts(canonical location)script/debug-id.tsbecomes a thin re-export (build scripts still import from here)src/lib/sourcemap/inject.tsfor directory scanning + injectionsourcemaproute inapp.tswithsourcemapsplural aliasUsage Examples
Depends on: #543 (merged)