From 52f93f8f12bb1d466144c937ecc20dedbbc2219c Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Tue, 10 Jul 2018 19:45:48 +0200 Subject: [PATCH 1/2] Add --generate-device-api-key parameter to config generate Change-Type: minor --- doc/cli.markdown | 5 +++++ lib/actions/config.coffee | 8 +++++++- lib/utils/config.ts | 14 +++++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/doc/cli.markdown b/doc/cli.markdown index 141d4da0..1ae752f3 100644 --- a/doc/cli.markdown +++ b/doc/cli.markdown @@ -1136,6 +1136,7 @@ that will be asked for the relevant device type. Examples: $ resin config generate --device 7cf02a6 + $ resin config generate --device 7cf02a6 --generate-device-api-key $ resin config generate --device 7cf02a6 --device-api-key $ resin config generate --device 7cf02a6 --output config.json $ resin config generate --app MyApp @@ -1156,6 +1157,10 @@ device uuid custom device key - note that this is only supported on ResinOS 2.0.3+ +#### --generate-device-api-key + +generate a fresh device key for the device + #### --output, -o <output> output diff --git a/lib/actions/config.coffee b/lib/actions/config.coffee index 1c71680f..608e4c96 100644 --- a/lib/actions/config.coffee +++ b/lib/actions/config.coffee @@ -230,6 +230,7 @@ exports.generate = Examples: $ resin config generate --device 7cf02a6 + $ resin config generate --device 7cf02a6 --generate-device-api-key $ resin config generate --device 7cf02a6 --device-api-key $ resin config generate --device 7cf02a6 --output config.json $ resin config generate --app MyApp @@ -240,6 +241,11 @@ exports.generate = commandOptions.optionalApplication commandOptions.optionalDevice commandOptions.optionalDeviceApiKey + { + signature: 'generate-device-api-key' + description: 'generate a fresh device key for the device' + boolean: true + } { signature: 'output' description: 'output' @@ -303,7 +309,7 @@ exports.generate = form.run(formOptions, override: options) .then (answers) -> if resource.uuid? - generateDeviceConfig(resource, options.deviceApiKey, answers) + generateDeviceConfig(resource, options.deviceApiKey || options['generate-device-api-key'], answers) else generateApplicationConfig(resource, answers) .then (config) -> diff --git a/lib/utils/config.ts b/lib/utils/config.ts index 9926e38a..fac78b08 100644 --- a/lib/utils/config.ts +++ b/lib/utils/config.ts @@ -75,7 +75,7 @@ export function generateApplicationConfig( export function generateDeviceConfig( device: ResinSdk.Device & { application_name: string }, - deviceApiKey: string | null, + deviceApiKey: string | true | null, options: {}, ) { return resin.models.application @@ -111,9 +111,17 @@ function addApplicationKey(config: any, applicationNameOrId: string | number) { }); } -function addDeviceKey(config: any, uuid: string, customDeviceApiKey: string) { +function addDeviceKey( + config: any, + uuid: string, + customDeviceApiKey: string | true, +) { return Promise.try(() => { - return customDeviceApiKey || resin.models.device.generateDeviceKey(uuid); + if (customDeviceApiKey === true) { + return resin.models.device.generateDeviceKey(uuid); + } else { + return customDeviceApiKey; + } }).tap(deviceApiKey => { config.deviceApiKey = deviceApiKey; }); From ce3e04bfe80b8031de6f03978e79b8ab498fc48c Mon Sep 17 00:00:00 2001 From: "resin-io-versionbot[bot]" Date: Wed, 11 Jul 2018 04:21:42 +0000 Subject: [PATCH 2/2] v7.7.0 --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f711339..09459bf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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/). +## v7.7.0 - 2018-07-11 + +* Add --generate-device-api-key parameter to config generate #921 [Tim Perry] + ## v7.6.2 - 2018-06-28 * Make local commands more resilient to unnamed containers #910 [Tim Perry] diff --git a/package.json b/package.json index 0a31f9c1..17b3403e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "resin-cli", - "version": "7.6.2", + "version": "7.7.0", "description": "The official resin.io CLI tool", "main": "./build/actions/index.js", "homepage": "https://github.com/resin-io/resin-cli",