Skip to content

Commit 0efcc64

Browse files
committed
Fast login switch enhancement and account command added
1 parent b8897c8 commit 0efcc64

File tree

4 files changed

+24
-33
lines changed

4 files changed

+24
-33
lines changed

bin/dropstack

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ process.on('SIGINT', () => {
1818

1919
program
2020
.version(`${pkg.name} v${pkg.version}`)
21-
.command('login <url>', 'Log-in to URL given deployment environment. (default http://api.cloud.dropstack.run)')
21+
.command('login <url>', 'Log-in to URL given deployment environment. (default https://api.cloud.dropstack.run)')
2222
.command('logout', 'Log-out from current deployment environment.')
23-
.command('deploy [folder]', 'Deploy to current deployment environment.')
24-
.command('list', 'List', 'List your active deployment from current environment.')
25-
.command('remove [name]', 'Remove deployment from current environment.')
26-
.command('ssl [name]', 'Manage SSL for deployments')
27-
.command('alias [name]', 'Manage alias for deployments')
28-
.command('logs [name]', 'Show libe StdOut/StdErr logs')
29-
.command('metric [name]', 'Show metrics for deployments')
30-
.command('scale [name]', 'Scale instances for deployments')
23+
.command('account', 'Show account informations.')
24+
.command('deploy [folder]', 'Deploy to current deployment environment.').alias('add')
25+
.command('list', 'List your active deployment from current environment.').alias('ls')
26+
.command('remove [name]', 'Remove deployment from current environment.').alias('rm')
27+
.command('ssl [name]', 'Manage SSL for deployments.')
28+
.command('alias [name]', 'Manage domain for deployments.')
29+
.command('logs [name]', 'Show StdOut/StdErr logs for deployment.').alias('log')
30+
.command('metric [name]', 'Show metrics for deployments.')
31+
.command('scale [name]', 'Scale instances for deployments.')
3132
.parse(process.argv);

bin/dropstack-list

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ function list(){
2020
.then(response => response.json()))
2121
.then(data => Boolean(data.message) ? Promise.reject(new Error(data.message)) : data)
2222
.then(data => {
23-
console.log(`${chalk.bold(pad(7, 'TYPE', ' '))} | ${chalk.bold(pad(5, 'COUNT', ' '))} | ${chalk.bold(pad(9, 'ID/NAME', ' '))} | ${chalk.bold(pad(45, 'URL', ' '))}`);
23+
console.log(`${chalk.bold(pad(7, 'TYPE', ' '))} | ${chalk.bold(pad(5, 'NUM #', ' '))} | ${chalk.bold(pad(9, 'ID/NAME', ' '))} | ${chalk.bold(pad(45, 'URL', ' '))}`);
2424
return data;
2525
})
2626
.then(data => (data || []).map(x => `${chalk.gray(pad(7, x.serviceType.toUpperCase(), ' '))} | ${chalk.gray(pad(5, x.serviceInstances, ' '))} | ${chalk.green(pad(9, x.serviceName, ' '))} | ${chalk.bold(pad(45, `https://${x.serviceUrl || '-'}`, ' '))}`))
2727
.then(data => {
2828
if(data.length > 0) return data.map(x => console.log(x));
29-
console.log('Nothing deployed');
29+
console.log(chalk.gray('\nNothing deployed'));
3030
})
3131
.catch(err => {
3232
if(err.message === 'Sign in failed. Use `dropstack login` to log in with your credentials.'){

bin/dropstack-login

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,27 @@ const configuration = require('../lib/settings')();
1111

1212
program
1313
.arguments('<url>')
14-
.option('-r, --reset', 'Request password reset')
15-
.option('-t, --token', 'Display current JSON Web Token')
16-
.action(url => account(Object.assign({url: url}, program)))
14+
.action(url => login(Object.assign({url: url, program})))
1715
.parse(process.argv);
1816

19-
if(!program.args.length) account(program.opts());
17+
if(!program.args.length) login(program.opts());
2018

21-
function account({url, token, reset}) {
19+
function login({url}) {
2220
if(url && !urlRegex({exact: true}).test(url)) {
23-
console.log(chalk.red('Invalid DROPSTACK URL. Must be the format http(s)://host.domain.com.'));
21+
console.log(chalk.red('Invalid Dropstack-Server-URL. Must be the format http(s)://host.domain.com.'));
2422
return process.exit(1);
2523
}
2624

27-
configuration
28-
.load({url, reset})
29-
.then(settings => configuration.save(settings))
25+
configuration.removeGlobalFile()
26+
.then(() => configuration.load({url}))
3027
.then(settings => {
3128
console.log(chalk.green(`Account information for ${chalk.green.underline(settings.username || '-')} on ${chalk.green.underline(settings.url || '-')}`));
32-
if(!(settings.token && settings.username)) console.log(chalk.yellow(`Enter your email and password to log in or sign up for free!\n`));
29+
console.log(chalk.yellow(`Enter your email and password to log in or sign up for free!\n`));
3330
return settings;
3431
})
35-
.then(settings => reset ? credentials.reset(settings).then(data => Promise.reject(data)) : Promise.resolve(settings))
36-
.then(settings => !settings.token ? credentials.inputEmail(settings.username).then(data => Object.assign(settings, data)) : Promise.resolve(settings))
37-
.then(settings => !settings.token ? credentials.inputPassword(settings.password).then(data => Object.assign(settings, data)) : Promise.resolve(settings))
38-
.then(settings => !settings.token ? credentials.login(settings).catch(() => credentials.signup(settings)).then(data => Object.assign(settings, data)) : Promise.resolve(settings))
32+
.then(settings => credentials.inputEmail(settings.username).then(data => Object.assign(settings, data)))
33+
.then(settings => credentials.inputPassword(settings.password).then(data => Object.assign(settings, data)))
34+
.then(settings => credentials.login(settings).catch(() => credentials.signup(settings)).then(data => Object.assign(settings, data)))
3935
.then(settings => {
4036
if(!settings.token) return Promise.reject(new Error('Sign in failed. Use `dropstack login` to log in with your credentials.'));
4137
if(settings.message) return Promise.reject(new Error(settings.message));
@@ -51,17 +47,11 @@ function account({url, token, reset}) {
5147
.then(data => Boolean(data.message) ? Promise.reject(new Error(data.message)) : data)
5248
.then(data => {
5349
let message = `${chalk.green(`User ${chalk.bold(data.id)} logged in successful!\n\n`)}`;
54-
message += `• ${chalk.gray(`Server-Version: ${data.version}`)}`;
55-
if(token) message = `${chalk.gray(`JWT: ${data.token}`)}`;
50+
message += `• ${chalk.gray(`Server Version: ${chalk.white(data.version)}`)}`;
5651
console.log(boxen(message, {padding: 1, borderColor: 'gray', margin: 1}));
57-
5852
process.exit(0);
5953
})
6054
.catch(err => {
61-
if(err.message === '"We\'ve just sent you an email to reset your password"') {
62-
console.log(chalk.red(err.message));
63-
return process.exit(0);
64-
}
6555
if(err.message === 'canceled') {
6656
console.log(chalk.yellow('aborted'));
6757
return process.exit(0);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dropstack-cli",
3-
"version": "2.3.14",
3+
"version": "2.4.0",
44
"description": "A CLI to simplify continuous deployments into hybrid clouds.",
55
"author": "Mike Bild <mike@codecommission.com>",
66
"homepage": "https://github.com/codecommission/dropstack-cli#readme",

0 commit comments

Comments
 (0)