Skip to content

Commit

Permalink
Auto-merge for PR #774 via VersionBot
Browse files Browse the repository at this point in the history
Fix uuid params being parsed a numbers
  • Loading branch information
resin-io-versionbot[bot] committed Feb 3, 2018
2 parents 74538bb + 0e9b8e4 commit b960655
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ 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/).

## v6.12.8 - 2018-02-03

* Fix uuid params being parsed a numbers #774 [Thodoris Greasidis]

## v6.12.7 - 2018-01-30

* Add 'or mounted resinOS image' #767 [MoranF]
Expand Down
2 changes: 2 additions & 0 deletions lib/actions/config.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ limitations under the License.
###

commandOptions = require('./command-options')
{ normalizeUuidProp } = require('../utils/normalization')

exports.read =
signature: 'config read'
Expand Down Expand Up @@ -269,6 +270,7 @@ exports.generate =
]
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(options, 'device')
Promise = require('bluebird')
writeFileAsync = Promise.promisify(require('fs').writeFile)
resin = require('resin-sdk-preconfigured')
Expand Down
12 changes: 12 additions & 0 deletions lib/actions/device.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.

commandOptions = require('./command-options')
_ = require('lodash')
{ normalizeUuidProp } = require('../utils/normalization')

exports.list =
signature: 'devices'
Expand Down Expand Up @@ -77,6 +78,7 @@ exports.info =
permission: 'user'
primary: true
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk-preconfigured')
visuals = require('resin-cli-visuals')

Expand Down Expand Up @@ -185,6 +187,7 @@ exports.remove =
options: [ commandOptions.yes ]
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk-preconfigured')
patterns = require('../utils/patterns')

Expand All @@ -206,6 +209,7 @@ exports.identify =
'''
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk-preconfigured')
resin.models.device.identify(params.uuid).nodeify(done)

Expand All @@ -222,6 +226,7 @@ exports.reboot =
options: [ commandOptions.forceUpdateLock ]
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk-preconfigured')
resin.models.device.reboot(params.uuid, options).nodeify(done)

Expand All @@ -238,6 +243,7 @@ exports.shutdown =
options: [ commandOptions.forceUpdateLock ]
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk-preconfigured')
resin.models.device.shutdown(params.uuid, options).nodeify(done)

Expand All @@ -253,6 +259,7 @@ exports.enableDeviceUrl =
'''
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk-preconfigured')
resin.models.device.enableDeviceUrl(params.uuid).nodeify(done)

Expand All @@ -268,6 +275,7 @@ exports.disableDeviceUrl =
'''
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk-preconfigured')
resin.models.device.disableDeviceUrl(params.uuid).nodeify(done)

Expand All @@ -283,6 +291,7 @@ exports.getDeviceUrl =
'''
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk-preconfigured')
resin.models.device.getDeviceUrl(params.uuid).then (url) ->
console.log(url)
Expand All @@ -300,6 +309,7 @@ exports.hasDeviceUrl =
'''
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk-preconfigured')
resin.models.device.hasDeviceUrl(params.uuid).then (hasDeviceUrl) ->
console.log(hasDeviceUrl)
Expand All @@ -320,6 +330,7 @@ exports.rename =
'''
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(params)
Promise = require('bluebird')
resin = require('resin-sdk-preconfigured')
form = require('resin-cli-form')
Expand Down Expand Up @@ -350,6 +361,7 @@ exports.move =
permission: 'user'
options: [ commandOptions.optionalApplication ]
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk-preconfigured')
patterns = require('../utils/patterns')

Expand Down
3 changes: 3 additions & 0 deletions lib/actions/environment-variables.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ limitations under the License.
###

commandOptions = require('./command-options')
{ normalizeUuidProp } = require('../utils/normalization')

exports.list =
signature: 'envs'
Expand Down Expand Up @@ -46,6 +47,7 @@ exports.list =
]
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(options, 'device')
Promise = require('bluebird')
_ = require('lodash')
resin = require('resin-sdk-preconfigured')
Expand Down Expand Up @@ -135,6 +137,7 @@ exports.add =
]
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(options, 'device')
Promise = require('bluebird')
resin = require('resin-sdk-preconfigured')

Expand Down
3 changes: 3 additions & 0 deletions lib/actions/logs.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
###

{ normalizeUuidProp } = require('../utils/normalization')

module.exports =
signature: 'logs <uuid>'
description: 'show device logs'
Expand Down Expand Up @@ -44,6 +46,7 @@ module.exports =
permission: 'user'
primary: true
action: (params, options, done) ->
normalizeUuidProp(params)
resin = require('resin-sdk-preconfigured')
moment = require('moment')

Expand Down
3 changes: 3 additions & 0 deletions lib/actions/notes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
###

{ normalizeUuidProp } = require('../utils/normalization')

exports.set =
signature: 'note <|note>'
description: 'set a device note'
Expand All @@ -38,6 +40,7 @@ exports.set =
]
permission: 'user'
action: (params, options, done) ->
normalizeUuidProp(options, 'device')
Promise = require('bluebird')
_ = require('lodash')
resin = require('resin-sdk-preconfigured')
Expand Down
3 changes: 3 additions & 0 deletions lib/actions/os.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.

commandOptions = require('./command-options')
_ = require('lodash')
{ normalizeUuidProp } = require('../utils/normalization')

formatVersion = (v, isRecommended) ->
result = "v#{v}"
Expand Down Expand Up @@ -227,6 +228,8 @@ exports.configure =
}
]
action: (params, options, done) ->
normalizeUuidProp(params)
normalizeUuidProp(options, 'device')
fs = require('fs')
Promise = require('bluebird')
readFileAsync = Promise.promisify(fs.readFile)
Expand Down
2 changes: 2 additions & 0 deletions lib/actions/ssh.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ limitations under the License.
###

commandOptions = require('./command-options')
{ normalizeUuidProp } = require('../utils/normalization')

module.exports =
signature: 'ssh [uuid]'
Expand Down Expand Up @@ -54,6 +55,7 @@ module.exports =
Only makes sense if you've configured proxy globally."
]
action: (params, options, done) ->
normalizeUuidProp(params)
child_process = require('child_process')
Promise = require('bluebird')
resin = require('resin-sdk-preconfigured')
Expand Down
26 changes: 26 additions & 0 deletions lib/utils/normalization.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright 2016-2018 Resin.io
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import _ = require('lodash');

export function normalizeUuidProp(
params: { [key: string]: any },
propName = 'uuid',
) {
if (_.isNumber(params[propName])) {
params[propName] = _.toString(params[propName]);
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "resin-cli",
"version": "6.12.7",
"version": "6.12.8",
"description": "The official resin.io CLI tool",
"main": "./build/actions/index.js",
"homepage": "https://github.com/resin-io/resin-cli",
Expand Down

0 comments on commit b960655

Please sign in to comment.