-
Notifications
You must be signed in to change notification settings - Fork 4
Initial sourcemaps: upload from target dir #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
LGTM - I think this is a good start for source maps.. |
Nice work @waltjones on getting initial patch out the door. Since it's WIP I won't add myself to the review yet. But initial questions looking at the patch,
|
@mrunalk Node 8 just means that it uses no Node features added in Node 9+. It does not mean that it isn't compatible with those versions. (It is compatible with later versions.) Since this runs on the user's installed Node, it makes sense to be inclusive as reasonably possible. The travis YML was included, but there is nothing in the code or any other files tying this to travis. Once a CI is decided, we can just update to use that CI. (BTW, I have no concerns with Github Actions CI.) |
7d9d553
to
7acafa5
Compare
7acafa5
to
35ec481
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - but did you intend on checking in the build folder?
@vselvarajijay Yes, those are actually test fixtures. Much easier to see that in tree view. Much harder in PR view. => https://github.com/rollbar/rollbar-cli/tree/wj-initial-sourcemaps/test/fixtures/builds |
}) | ||
.option('D', { | ||
alias: 'dry-run', | ||
describe: 'Scan and validate source maps without uploading', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the option of dry run.
const path = require('path'); | ||
const BasicSourceMapConsumer = require('source-map/lib/source-map-consumer').BasicSourceMapConsumer; | ||
|
||
class Scanner { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this scanner work if sourcemap and sources are in a totally different directory? I see only one targetPath.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It uses sourceMappingURL to determine the source map location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can there be a case when sourceMappingURL is not there?
src/sourcemaps/scanner.js
Outdated
mappings[m.generatedLine] = true; | ||
}); | ||
|
||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we are always returning true suggesting maps are always valid. I am guessing there will also be a case when map is invalid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, the only non-true result of this method is if BasicSourceMapConsumer
throws. At some point, it would make sense to use the iteration of consumer to do more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've refactored the validate method to make it more apparent that we're catching and reporting errors from BasicSourceMapConsumer
. (The errors no longer bubble up to the outer catch.) Also, validate() now returns an errors array that is empty on success.
file.mapPathName = mapPath; | ||
file.sourceMappingURL = true; | ||
} else { | ||
output.warn('', 'map not found'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming control will reach here when map path is not in the minified file. In that case we would have to manually find the sourcemap in the directory right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant here is that if we don't find map path do we want to prompt the user to enter the path manually but probably that won't be intuitive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@waltjones, did you test if this works for TypeScript and Babel sourcemaps? If not it will be good to add tests for those as well.
const path = require('path'); | ||
const BasicSourceMapConsumer = require('source-map/lib/source-map-consumer').BasicSourceMapConsumer; | ||
|
||
class Scanner { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can there be a case when sourceMappingURL 23D3 is not there?
file.mapPathName = mapPath; | ||
file.sourceMappingURL = true; | ||
} else { | ||
output.warn('', 'map not found'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant here is that if we don't find map path do we want to prompt the user to enter the path manually but probably that won't be intuitive.
await this.scanFiles(); | ||
} | ||
|
||
async scanFiles() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this mainly scanning for minified files and then extracting map path from those min files? If yes then can you rename this to something like scanMinifiedFiles()?
quiet: argv['quiet'] | ||
}); | ||
|
||
const scanner = new Scanner({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this scanner adapt to dsym or other symbol files in future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would assume not since the source-map
npm package is the standard package for Javascript source maps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. So looks like we will have to implement separate scanner for scanning dsym files.
|
||
await scanner.scan(); | ||
|
||
const uploader = new Uploader({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this uploader adapt to dsym or other symbol files in future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose it depends on how different Rollbar's API is for dsym, and how different the data structures are. It's not something I've evaluated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. I was just asking so that in near future if we end up adding dsym or proguard symbol upload functionality we shouldn't have to do majore rewrite of the CLI.
@mrunalk The existing test fixtures are TypeScript (Angular build) and ES6 (React build) original sources. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Nice work @waltjones.
quiet: argv['quiet'] | ||
}); | ||
|
||
const scanner = new Scanner({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. So looks like we will have to implement separate scanner for scanning dsym files.
|
||
await scanner.scan(); | ||
|
||
const uploader = new Uploader({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. I was just asking so that in near future if we end up adding dsym or proguard symbol upload functionality we shouldn't have to do majore rewrite of the CLI.
Description of the change
Initial implementation to:
Reviewers: test/fixtures/ contains a lot of files that dominate the diff. However, changes are cleanly separated by commit. If it's hard to navigate the overall PR, go to the specific commit.
Styleguide:
Test/Evaluation:
When published to npm, install globally using
npm install -g rollbar-cli
For now, clone repo and run
npm link
. The rollbar command will be globally available.Known Issues:
ch72220: Upload fails due to filename parsing bug. Including original sources can cause the entire upload request to fail due to an API bug.
ch72221: Original sources option disabled. The spec doesn't provide an option to send original sources, and doing so without a way to turn it off causes several issues that would render the CLI unusable by many users.
Command line spec has been updated to match Mrunal spec. https://rollbar.quip.com/amFQAoKENQ81/Design-of-rollbar-cliWIP
rollbar-cli upload-sourcemaps --help
(source map options)Tasks:
Coverage report
Fixtures
The tests use the build output from typical React and Angular projects.
Examples
React
rollbar-cli upload-sourcemaps dist -access-token 638d... --url-prefix 'http://localhost:3000/' --code-version react16
Angular 8
rollbar-cli upload-sourcemaps dist/my-app --access-token 638d... --url-prefix 'http://localhost:3000/' --code-version angular8v1 -s
Angular 9
rollbar-cli upload-sourcemaps dist/angular9 --access-token 638d... --url-prefix 'http://localhost:3000/' --code-version angular9v1 -s
Type of change
Development
Code review