Auto-merge for PR #861 via VersionBot

727 sentry improvements
This commit is contained in:
resin-io-versionbot[bot] 2018-04-17 14:46:13 +00:00 committed by GitHub
commit 2e1ab22173
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 54 additions and 30 deletions

View File

@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
This project adheres to [Semantic Versioning](http://semver.org/).
## v7.3.3 - 2018-04-17
* Don't report lots of user input errors #861 [Tim Perry]
* Include Sentry breadcrumbs for context in error reports #861 [Tim Perry]
* Update to Sentry 2.x #861 [Tim Perry]
## v7.3.2 - 2018-04-16
* Update Dockerode to fix local push issue in standalone builds #862 [Tim Perry]

View File

@ -52,7 +52,7 @@ exports.create =
# https://github.com/resin-io/resin-cli/issues/30
resin.models.application.has(params.name).then (hasApplication) ->
if hasApplication
throw new Error('You already have an application with that name!')
patterns.exitWithExpectedError('You already have an application with that name!')
.then ->
return options.type or patterns.selectDeviceType()

View File

@ -92,7 +92,7 @@ exports.login =
resin.auth.whoami()
.then (username) ->
if !username
patterns.expectedError('Token authentication failed')
patterns.exitWithExpectedError('Token authentication failed')
else if options.credentials
return patterns.authenticate(options)
else if options.web

View File

@ -95,6 +95,7 @@ module.exports =
# compositions with many services trigger misleading warnings
require('events').defaultMaxListeners = 1000
{ exitWithExpectedError } = require('../utils/patterns')
helpers = require('../utils/helpers')
Logger = require('../utils/logger')
@ -111,7 +112,7 @@ module.exports =
{ application, arch, deviceType } = options
if (not (arch? and deviceType?) and not application?) or (application? and (arch? or deviceType?))
throw new Error('You must specify either an application or an arch/deviceType pair to build for')
exitWithExpectedError('You must specify either an application or an arch/deviceType pair to build for')
if arch? and deviceType?
[ undefined, arch, deviceType ]

View File

@ -277,10 +277,12 @@ exports.generate =
form = require('resin-cli-form')
deviceConfig = require('resin-device-config')
prettyjson = require('prettyjson')
{ generateDeviceConfig, generateApplicationConfig } = require('../utils/config')
{ exitWithExpectedError } = require('../utils/patterns')
if not options.device? and not options.application?
throw new Error '''
exitWithExpectedError '''
You have to pass either a device or an application.
See the help page for examples:

View File

@ -53,17 +53,19 @@ exports.list =
resin = require('resin-sdk-preconfigured')
visuals = require('resin-cli-visuals')
{ exitWithExpectedError } = require('../utils/patterns')
Promise.try ->
if options.application?
return resin.models.environmentVariables.getAllByApplication(options.application)
else if options.device?
return resin.models.environmentVariables.device.getAll(options.device)
else
throw new Error('You must specify an application or device')
exitWithExpectedError('You must specify an application or device')
.tap (environmentVariables) ->
if _.isEmpty(environmentVariables)
throw new Error('No environment variables found')
exitWithExpectedError('No environment variables found')
if not options.verbose
isSystemVariable = resin.models.environmentVariables.isSystemVariable
environmentVariables = _.reject(environmentVariables, isSystemVariable)
@ -141,6 +143,8 @@ exports.add =
Promise = require('bluebird')
resin = require('resin-sdk-preconfigured')
{ exitWithExpectedError } = require('../utils/patterns')
Promise.try ->
if not params.value?
params.value = process.env[params.key]
@ -155,7 +159,7 @@ exports.add =
else if options.device?
resin.models.environmentVariables.device.create(options.device, params.key, params.value)
else
throw new Error('You must specify an application or device')
exitWithExpectedError('You must specify an application or device')
.nodeify(done)
exports.rename =

View File

@ -18,6 +18,7 @@ _ = require('lodash')
capitano = require('capitano')
columnify = require('columnify')
messages = require('../utils/messages')
{ exitWithExpectedError } = require('../utils/patterns')
parse = (object) ->
return _.fromPairs _.map object, (item) ->
@ -78,7 +79,7 @@ command = (params, options, done) ->
return done(error) if error?
if not command? or command.isWildcard()
return done(new Error("Command not found: #{params.command}"))
exitWithExpectedError("Command not found: #{params.command}")
console.log("Usage: #{command.signature}")

View File

@ -4,6 +4,7 @@ form = require('resin-cli-form')
chalk = require('chalk')
dockerUtils = require('../../utils/docker')
{ exitWithExpectedError } = require('../../utils/patterns')
exports.dockerPort = dockerPort = 2375
exports.dockerTimeout = dockerTimeout = 2000
@ -23,7 +24,7 @@ exports.selectContainerFromDevice = Promise.method (deviceIp, filterSupervisor =
filterOutSupervisorContainer(container)
.then (containers) ->
if _.isEmpty(containers)
throw new Error("No containers found in #{deviceIp}")
exitWithExpectedError("No containers found in #{deviceIp}")
return form.ask
message: 'Select a container'

View File

@ -64,6 +64,7 @@ module.exports =
{ SpinnerPromise } = require('resin-cli-visuals')
{ dockerPort, dockerTimeout } = require('./common')
dockerUtils = require('../../utils/docker')
{ exitWithExpectedError } = require('../../utils/patterns')
if options.timeout?
options.timeout *= 1000
@ -81,7 +82,7 @@ module.exports =
.catchReturn(false)
.tap (devices) ->
if _.isEmpty(devices)
throw new Error('Could not find any resinOS devices in the local network')
exitWithExpectedError('Could not find any resinOS devices in the local network')
.map ({ host, address }) ->
docker = dockerUtils.createClient(host: address, port: dockerPort, timeout: dockerTimeout)
Promise.props

View File

@ -67,10 +67,12 @@ module.exports =
Promise = require 'bluebird'
_ = require('lodash')
{ forms } = require('resin-sync')
{ selectContainerFromDevice, getSubShellCommand } = require('./common')
{ exitWithExpectedError } = require('../../utils/patterns')
if (options.host is true and options.container?)
throw new Error('Please pass either --host or --container option')
exitWithExpectedError('Please pass either --host or --container option')
if not options.port?
options.port = 22222

View File

@ -45,9 +45,11 @@ exports.set =
_ = require('lodash')
resin = require('resin-sdk-preconfigured')
{ exitWithExpectedError } = require('../utils/patterns')
Promise.try ->
if _.isEmpty(params.note)
throw new Error('Missing note content')
exitWithExpectedError('Missing note content')
resin.models.device.note(options.device, params.note)
.nodeify(done)

View File

@ -244,7 +244,7 @@ exports.configure =
options.application
params.uuid
]).length != 1
patterns.expectedError '''
patterns.exitWithExpectedError '''
To configure an image, you must provide exactly one of:
* A device, with --device <uuid>

View File

@ -40,7 +40,7 @@ getApplicationsWithSuccessfulBuilds = (deviceType) ->
selectApplication = (deviceType) ->
visuals = require('resin-cli-visuals')
form = require('resin-cli-form')
{ expectedError } = require('../utils/patterns')
{ exitWithExpectedError } = require('../utils/patterns')
applicationInfoSpinner = new visuals.Spinner('Downloading list of applications and releases.')
applicationInfoSpinner.start()
@ -49,7 +49,7 @@ selectApplication = (deviceType) ->
.then (applications) ->
applicationInfoSpinner.stop()
if applications.length == 0
expectedError("You have no apps with successful releases for a '#{deviceType}' device type.")
exitWithExpectedError("You have no apps with successful releases for a '#{deviceType}' device type.")
form.ask
message: 'Select an application'
type: 'list'
@ -59,10 +59,10 @@ selectApplication = (deviceType) ->
selectApplicationCommit = (releases) ->
form = require('resin-cli-form')
{ expectedError } = require('../utils/patterns')
{ exitWithExpectedError } = require('../utils/patterns')
if releases.length == 0
expectedError('This application has no successful releases.')
exitWithExpectedError('This application has no successful releases.')
DEFAULT_CHOICE = { 'name': LATEST, 'value': LATEST }
choices = [ DEFAULT_CHOICE ].concat releases.map (release) ->
name: "#{release.end_timestamp} - #{release.commit}"
@ -152,7 +152,7 @@ module.exports =
preload = require('resin-preload')
visuals = require('resin-cli-visuals')
nodeCleanup = require('node-cleanup')
{ expectedError } = require('../utils/patterns')
{ exitWithExpectedError } = require('../utils/patterns')
progressBars = {}
@ -184,7 +184,7 @@ module.exports =
options.dontCheckDeviceType = options['dont-check-device-type']
delete options['dont-check-device-type']
if options.dontCheckDeviceType and not options.appId
expectedError('You need to specify an app id if you disable the device type check.')
exitWithExpectedError('You need to specify an app id if you disable the device type check.')
# Get a configured dockerode instance
dockerUtils.getDocker(options)
@ -240,7 +240,7 @@ module.exports =
release = _.find preloader.application.owns__release, (release) ->
release.commit.startsWith(options.commit)
if not release
expectedError('There is no release matching this commit')
exitWithExpectedError('There is no release matching this commit')
return release.commit
selectApplicationCommit(preloader.application.owns__release)
.then (commit) ->
@ -254,7 +254,7 @@ module.exports =
.then ->
# All options are ready: preload the image.
preloader.preload()
.catch(resin.errors.ResinError, expectedError)
.catch(resin.errors.ResinError, exitWithExpectedError)
.then(resolve)
.catch(reject)
.then(done)

View File

@ -108,7 +108,7 @@ module.exports =
console.info("Connecting to: #{uuid}")
resin.models.device.get(uuid)
.then (device) ->
throw new Error('Device is not online') if not device.is_online
patterns.exitWithExpectedError('Device is not online') if not device.is_online
Promise.props
username: resin.auth.whoami()

View File

@ -17,7 +17,8 @@ limitations under the License.
Raven = require('raven')
Raven.disableConsoleAlerts()
Raven.config require('./config').sentryDsn,
captureUnhandledRejections: true
captureUnhandledRejections: true,
autoBreadcrumbs: true,
release: require('../package.json').version
.install (logged, error) ->
console.error(error)
@ -76,6 +77,7 @@ actions = require('./actions')
errors = require('./errors')
events = require('./events')
update = require('./utils/update')
{ exitWithExpectedError } = require('./utils/patterns')
# Assign bluebird as the global promise library
# stream-to-promise will produce native promises if not
@ -86,13 +88,13 @@ require('any-promise/register/bluebird')
capitano.permission 'user', (done) ->
resin.auth.isLoggedIn().then (isLoggedIn) ->
if not isLoggedIn
throw new Error '''
exitWithExpectedError('''
You have to log in to continue
Run the following command to go through the login wizard:
$ resin login
'''
''')
.nodeify(done)
capitano.command

View File

@ -174,5 +174,6 @@ exports.createClient = createClient = do ->
return new Docker(opts)
ensureDockerSeemsAccessible = (docker) ->
{ exitWithExpectedError } = require('./patterns')
docker.ping().catch ->
throw new Error('Docker seems to be unavailable. Is it installed and running?')
exitWithExpectedError('Docker seems to be unavailable. Is it installed and running?')

View File

@ -250,7 +250,7 @@ export function printErrorMessage(message: string) {
console.error(chalk.red(`\n${messages.getHelp}\n`));
}
export function expectedError(message: string | Error) {
export function exitWithExpectedError(message: string | Error) {
if (message instanceof Error) {
({ message } = message);
}

View File

@ -1,6 +1,6 @@
{
"name": "resin-cli",
"version": "7.3.2",
"version": "7.3.3",
"description": "The official resin.io CLI tool",
"main": "./build/actions/index.js",
"homepage": "https://github.com/resin-io/resin-cli",
@ -21,7 +21,8 @@
"pkg": {
"scripts": [
"node_modules/resin-sync/build/capitano/*.js",
"node_modules/resin-sync/build/sync/*.js"
"node_modules/resin-sync/build/sync/*.js",
"node_modules/raven/lib/instrumentation/*.js"
],
"assets": [
"build/auth/pages/*.ejs",
@ -126,7 +127,7 @@
"president": "^2.0.1",
"prettyjson": "^1.1.3",
"progress-stream": "^2.0.0",
"raven": "^1.2.0",
"raven": "^2.5.0",
"reconfix": "^0.0.3",
"request": "^2.81.0",
"resin-bundle-resolve": "^0.5.3",