Auto-merge for PR #854 via VersionBot

Add 'api-key generate' command
This commit is contained in:
resin-io-versionbot[bot] 2018-04-12 10:24:39 +00:00 committed by GitHub
commit b7214a306c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 76 additions and 10 deletions

View File

@ -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.3.0 - 2018-04-12
* Add 'api-key generate' command #854 [Tim Perry]
## v7.2.4 - 2018-04-10
* Explicitly depend on tar-stream #852 [Tim Perry]

View File

@ -63,6 +63,10 @@ environment variable (in the same standard URL format).\
`,
categories: [
{
title: 'Api keys',
files: [ 'build/actions/api-key.js' ],
},
{
title: 'Application',
files: [ 'build/actions/app.js' ]

View File

@ -62,6 +62,10 @@ environment variable (in the same standard URL format).
# Table of contents
- Api keys
- [api-key generate <name>](#api-key-generate-name-)
- Application
- [app create <name>](#app-create-name-)
@ -180,6 +184,20 @@ environment variable (in the same standard URL format).
- [util available-drives](#util-available-drives)
# Api keys
## api-key generate <name>
This command generates a new API key for the current user, with the given
name. The key will be logged to the console.
This key can be used to log into the CLI using 'resin login --token <key>',
or to authenticate requests to the API with an 'Authorization: Bearer <key>' header.
Examples:
$ resin api-key generate "Jenkins Key"
# Application
## app create &#60;name&#62;

36
lib/actions/api-key.ts Normal file
View File

@ -0,0 +1,36 @@
import { CommandDefinition } from 'capitano';
import { stripIndent } from 'common-tags';
export const generate: CommandDefinition<{
name: string;
}> = {
signature: 'api-key generate <name>',
description: 'Generate a new API key with the given name',
help: stripIndent`
This command generates a new API key for the current user, with the given
name. The key will be logged to the console.
This key can be used to log into the CLI using 'resin login --token <key>',
or to authenticate requests to the API with an 'Authorization: Bearer <key>' header.
Examples:
$ resin api-key generate "Jenkins Key"
`,
async action(params, _options, done) {
const resin = (await import('resin-sdk')).fromSharedOptions();
resin.models.apiKey
.create(params.name)
.then(key => {
console.log(stripIndent`
Registered api key '${params.name}':
${key}
This key will not be shown again, so please save it now.
`);
})
.finally(done);
},
};

View File

@ -16,9 +16,10 @@ limitations under the License.
module.exports =
wizard: require('./wizard')
apiKey: require('./api-key')
app: require('./app')
info: require('./info')
auth: require('./auth')
info: require('./info')
device: require('./device')
env: require('./environment-variables')
keys: require('./keys')

View File

@ -114,11 +114,8 @@ capitano.command(actions.help.help)
# ---------- Wizard Module ----------
capitano.command(actions.wizard.wizard)
# ---------- Auth Module ----------
capitano.command(actions.auth.login)
capitano.command(actions.auth.logout)
capitano.command(actions.auth.signup)
capitano.command(actions.auth.whoami)
# ---------- Api key module ----------
capitano.command(actions.apiKey.generate)
# ---------- App Module ----------
capitano.command(actions.app.create)
@ -127,6 +124,12 @@ capitano.command(actions.app.remove)
capitano.command(actions.app.restart)
capitano.command(actions.app.info)
# ---------- Auth Module ----------
capitano.command(actions.auth.login)
capitano.command(actions.auth.logout)
capitano.command(actions.auth.signup)
capitano.command(actions.auth.whoami)
# ---------- Device Module ----------
capitano.command(actions.device.list)
capitano.command(actions.device.supported)

View File

@ -1,6 +1,6 @@
{
"name": "resin-cli",
"version": "7.2.4",
"version": "7.3.0",
"description": "The official resin.io CLI tool",
"main": "./build/actions/index.js",
"homepage": "https://github.com/resin-io/resin-cli",
@ -57,6 +57,7 @@
"devDependencies": {
"@types/archiver": "^2.0.1",
"@types/bluebird": "^3.5.19",
"@types/common-tags": "^1.4.0",
"@types/es6-promise": "0.0.32",
"@types/fs-extra": "^5.0.0",
"@types/is-root": "^1.0.0",
@ -85,7 +86,6 @@
},
"dependencies": {
"@resin.io/valid-email": "^0.1.0",
"@types/stream-to-promise": "^2.2.0",
"ansi-escapes": "^2.0.0",
"any-promise": "^1.3.0",
"archiver": "^2.1.0",
@ -97,6 +97,7 @@
"cli-truncate": "^1.1.0",
"coffeescript": "^1.12.6",
"columnify": "^1.5.2",
"common-tags": "^1.7.2",
"denymount": "^2.2.0",
"docker-progress": "^3.0.1",
"docker-qemu-transpose": "^0.5.1",
@ -143,7 +144,7 @@
"resin-multibuild": "^0.5.1",
"resin-preload": "^6.2.0",
"resin-release": "^1.2.0",
"resin-sdk": "9.0.0-beta16",
"resin-sdk": "9.0.0-beta17",
"resin-sdk-preconfigured": "^6.9.0",
"resin-settings-client": "^3.6.1",
"resin-stream-logger": "^0.1.0",
@ -152,7 +153,6 @@
"rindle": "^1.0.0",
"semver": "^5.3.0",
"split": "^1.0.1",
"stream-to-promise": "^2.2.0",
"string-width": "^2.1.1",
"strip-ansi-stream": "^1.0.0",
"tar-stream": "^1.5.5",