rollbar-cli
Advanced tools
Comparing version 0.1.0 to 0.2.0
{ | ||
"name": "rollbar-cli", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"license": "MIT", | ||
@@ -9,6 +9,7 @@ "bin": { | ||
"scripts": { | ||
"lint": "./node_modules/.bin/eslint . --ext .js", | ||
"lint": "eslint . --ext .js", | ||
"test": "nyc --reporter=html --reporter=text mocha './test/{,!(fixtures)/**/}*test.js'" | ||
}, | ||
"dependencies": { | ||
"adm-zip": "^0.5.2", | ||
"axios": "^0.19.2", | ||
@@ -27,3 +28,18 @@ "chalk": "^4.1.0", | ||
"sinon": "^9.0.3" | ||
} | ||
}, | ||
"description": "![build](https://github.com/rollbar/rollbar-cli/workflows/Node.js%20CI/badge.svg)", | ||
"main": "index.js", | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/rollbar/rollbar-cli.git" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"bugs": { | ||
"url": "https://github.com/rollbar/rollbar-cli/issues" | ||
}, | ||
"homepage": "https://github.com/rollbar/rollbar-cli#readme" | ||
} |
# rollbar-cli | ||
![build](https://github.com/rollbar/rollbar-cli/workflows/Node.js%20CI/badge.svg) | ||
The Rollbar CLI provides easy command line access to Rollbar's API features, | ||
starting with source map uploads and notifying deploys. | ||
![build](https://github.com/rollbar/rollbar-cli/workflows/Node.js%20CI/badge.svg) | ||
## Install | ||
``` | ||
npm install -g rollbar-cli | ||
``` | ||
## Usage and Reference | ||
@@ -28,9 +34,36 @@ Currently upload-sourcemaps and notify-deploy commands are supported. | ||
[string] [required] | ||
--next Next version. Zip all the source map files and upload as one | ||
file [boolean] | ||
-D, --dry-run Scan and validate source maps without uploading [boolean] | ||
``` | ||
Some of these options are required and must be specified for a successful upload. | ||
`path`: Absolute or relative path to build directory. This directory should contain .js | ||
files with `sourceMappingURL` directives included. The current version of the CLI | ||
supports detecting files with `sourceMappingURL` directives and uploading related | ||
map files within a directory. | ||
`--access-token`: The Rollbar API `post_server_item` token. | ||
`--url-prefix`: The base portion of the URL to be concatenated with the js filenames | ||
discovered while scanning `path`. The Rollbar backend uses this to match stack frame locations | ||
and it must exactly match the URLs in the error stack frames. See `minified_url` at | ||
[Source Maps](https://docs.rollbar.com/docs/source-maps) for more information. | ||
`--code-version`: The code version string must match the string passed in the Rollbar | ||
error payload, which is usually set in the config options for Rollbar.js. | ||
See [Source Maps](https://docs.rollbar.com/docs/source-maps) for more information. | ||
`--next`: This is an optional parameter triggering next version. When specified, all source map files | ||
are compressed and uploaded as one zip file directly. | ||
Example: | ||
``` | ||
rollbar-cli upload-sourcemaps ./dist -access-token 638d... --url-prefix 'http://example.com/' --code-version 123.456 | ||
rollbar-cli upload-sourcemaps ./dist --access-token 638d... --url-prefix 'http://example.com/' --code-version 123.456 | ||
``` | ||
or | ||
``` | ||
rollbar-cli upload-sourcemaps ./dist --access-token 638d... --url-prefix 'http://example.com/' --code-version 123.456 --next | ||
``` | ||
@@ -37,0 +70,0 @@ ### notify-deploy |
@@ -39,2 +39,10 @@ 'use strict'; | ||
async sigendURLsourcemaps(request) { | ||
const resp = await this.axios.post( | ||
'/signed_url/sourcemap_bundle', { version: request.version , prefix_url: request.baseUrl} | ||
); | ||
return this.processSignedURLResponse(resp); | ||
} | ||
async sourcemaps(request) { | ||
@@ -74,2 +82,7 @@ output.verbose('', 'minified_url: ' + request.minified_url); | ||
processSignedURLResponse(resp) { | ||
output.verbose('', 'response:', resp.data, resp.status, resp.statusText); | ||
return resp.data; | ||
} | ||
processResponse(resp) { | ||
@@ -76,0 +89,0 @@ output.verbose('', 'response:', resp.data, resp.status, resp.statusText); |
@@ -5,2 +5,4 @@ 'use strict'; | ||
const Uploader = require('./uploader'); | ||
const SignedUrlUploader = require('./signed-url-uploader'); | ||
const Requester = require('./requester'); | ||
const Output = require('../common/output.js'); | ||
@@ -32,2 +34,8 @@ | ||
}) | ||
.option('next', { | ||
describe: 'Next version. Zip all the source map files and upload as one file', | ||
requiresArg: false, | ||
type: 'boolean', | ||
demandOption: false | ||
}) | ||
.option('D', { | ||
@@ -55,11 +63,28 @@ alias: 'dry-run', | ||
const uploader = new Uploader({ | ||
accessToken: argv['access-token'], | ||
baseUrl: argv['url-prefix'], | ||
codeVersion: argv['code-version'] | ||
}) | ||
if (argv['next']) { | ||
const requester = new Requester({ | ||
accessToken: argv['access-token'], | ||
baseUrl: argv['url-prefix'], | ||
codeVersion: argv['code-version'], | ||
dryRun: argv['dry-run'] | ||
}); | ||
uploader.mapFiles(scanner.files); | ||
await requester.requestSignedUrl(); | ||
const signedUrlUploader = new SignedUrlUploader(requester); | ||
if (requester.data && requester.data['err'] === 0) { | ||
requester.setProjectID(); | ||
requester.createManifestData(); | ||
await signedUrlUploader.upload(argv['dry-run'], scanner.files, requester.data['result']['signed_url']); | ||
} | ||
} else { | ||
const uploader = new Uploader({ | ||
accessToken: argv['access-token'], | ||
baseUrl: argv['url-prefix'], | ||
codeVersion: argv['code-version'] | ||
}); | ||
await uploader.upload(argv['dry-run']); | ||
uploader.mapFiles(scanner.files); | ||
await uploader.upload(argv['dry-run']); | ||
} | ||
} |
@@ -46,2 +46,4 @@ 'use strict'; | ||
file.sourceMappingURL = true; | ||
file.mappedFile = path.join(this.targetPath, mapPath); | ||
} else { | ||
@@ -48,0 +50,0 @@ output.warn('', 'map not found'); |
@@ -38,2 +38,37 @@ /* globals describe */ | ||
it('should send well formed request for signed URL', async function() { | ||
const rollbarAPI = this.test.rollbarAPI; | ||
const stub = this.test.stub; | ||
stub.resolves({ | ||
status: 200, | ||
statusText: 'Success', | ||
data: { err: 0, result: { uuid: 'd4c7acef55bf4c9ea95e4fe9428a8287'}} | ||
}); | ||
const request = { | ||
version: '123', | ||
prefix_url: 'https://example.com/', | ||
source_map: '{ \ | ||
"version" : 3, \ | ||
"file": "out.js", \ | ||
"sourceRoot": "", \ | ||
"sources": ["foo.js", "bar.js"], \ | ||
"sourcesContent": [null, null], \ | ||
"names": ["src", "maps", "are", "fun"], \ | ||
"mappings": "A,AAAB;;ABCDE;" \ | ||
}', | ||
sources: [] | ||
}; | ||
const response = await rollbarAPI.sigendURLsourcemaps(request); | ||
expect(response).to.be.not.null; | ||
expect(stub.calledOnce).to.be.true; | ||
const body = stub.getCall(0).args; | ||
expect(body[0]).to.equal('/signed_url/sourcemap_bundle'); | ||
expect(body[1]).to.be.a('Object'); | ||
}); | ||
it('should send well formed request', async function() { | ||
@@ -40,0 +75,0 @@ const rollbarAPI = this.test.rollbarAPI; |
@@ -31,2 +31,16 @@ /* globals describe */ | ||
}); | ||
it('uploads react project via signed URL', function() { | ||
this.timeout(5000); | ||
const stdout = execSync('./bin/rollbar upload-sourcemaps ./test/fixtures/builds/react16/build --access-token 1234 --url-prefix "http://localhost:3000/" --code-version react16 -D --signed-url'); | ||
const lines = stdout.toString().split('\n'); | ||
expect(lines.length).to.equal(14); | ||
for(let i; i < lines.length; i+=2) { | ||
expect(lines[i]).to.have.string('[Found ]'); | ||
} | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
12699517
78
165737
1
1
141
1
7
12
+ Addedadm-zip@^0.5.2
+ Addedadm-zip@0.5.16(transitive)