Skip to content

Commit 06ff6e2

Browse files
committed
Signup and cleanup up
1 parent 9536f0c commit 06ff6e2

21 files changed

+1340
-668
lines changed

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"bracketSpacing": false,
33
"eslintIntegration": true,
44
"singleQuote": true,
5-
"printWidth": 120
5+
"printWidth": 180
66
}

bin/dropstack

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,30 @@ process.on('SIGINT', () => {
2323

2424
program
2525
.version(`${pkg.name} v${pkg.version}`)
26-
.command('login <url>', 'Log-in or switch to deployment environment. (default https://api.cloud.dropstack.run)')
26+
.command('login <url>', 'Log in or switch to deployment environment. (default https://api.cloud.dropstack.run)')
27+
.command('signup <url>', 'Sign up to deployment environment. (default https://api.cloud.dropstack.run)')
2728
.command('logout', 'Log-out from deployment environment.')
28-
.command('inspect [name]', 'Show instance informations.').alias('info')
29-
.command('account', 'Show account informations.').alias('infos')
30-
.command('activities', 'Show account activities.').alias('activity')
31-
.command('deploy [folder]', 'Deploy to environment.').alias('add')
32-
.command('list', 'List your active environment deployments.').alias('ls')
33-
.command('remove [name]', 'Remove deployment from environment.').alias('rm')
29+
.command('inspect [name]', 'Show instance informations.')
30+
.alias('info')
31+
.command('account', 'Show account informations.')
32+
.alias('infos')
33+
.command('activities', 'Show account activities.')
34+
.alias('activity')
35+
.command('deploy [folder]', 'Deploy to environment.')
36+
.alias('add')
37+
.command('list', 'List your active environment deployments.')
38+
.alias('ls')
39+
.command('remove [name]', 'Remove deployment from environment.')
40+
.alias('rm')
3441
.command('ssl [name]', 'Manage SSL for deployments.')
35-
.command('domain [name]', 'Manage domain for deployments.').alias('alias')
36-
.command('logs [name]', 'Show StdOut/StdErr logs for deployment.').alias('log')
37-
.command('metric [name]', 'Show metrics for deployments.').alias('metrics')
42+
.command('domain [name]', 'Manage domain for deployments.')
43+
.alias('alias')
44+
.command('logs [name]', 'Show StdOut/StdErr logs for deployment.')
45+
.alias('log')
46+
.command('metric [name]', 'Show metrics for deployments.')
47+
.alias('metrics')
3848
.command('scale [name]', 'Scale instances for deployments.')
39-
.command('mapping [name]', 'Manage route mappings for deployment.').alias('map').alias('mappings')
49+
.command('mapping [name]', 'Manage route mappings for deployment.')
50+
.alias('map')
51+
.alias('mappings')
4052
.parse(process.argv);

bin/dropstack-account

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,16 @@ function account({reset, token}) {
2222
configuration
2323
.load()
2424
.then(settings => {
25-
console.log(
26-
chalk.green(
27-
`Account information for ${chalk.green.underline(settings.username || '-')} on ${chalk.green.underline(
28-
settings.url || '-'
29-
)}`
30-
)
31-
);
25+
console.log(chalk.green(`Account information for ${chalk.green.underline(settings.username || '-')} on ${chalk.green.underline(settings.url || '-')}`));
3226
if (!(settings.token && settings.username)) return Promise.reject(new Error('Sign in failed'));
3327
return settings;
3428
})
35-
.then(
36-
settings => (reset ? credentials.reset(settings).then(data => Promise.reject(data)) : Promise.resolve(settings))
37-
)
29+
.then(settings => (reset ? credentials.reset(settings).then(data => Promise.reject(data)) : Promise.resolve(settings)))
3830
.then(settings => {
3931
return fetch(`${settings.url}/auth/account`, {
4032
headers: {Authorization: `Bearer ${settings.token}`, timeout: 10}
4133
})
42-
.then(
43-
response =>
44-
response.status >= 400 ? Promise.reject(new Error(`Response error: ${response.statusText}`)) : response
45-
)
34+
.then(response => (response.status >= 400 ? Promise.reject(new Error(`Response error: ${response.statusText}`)) : response))
4635
.then(response =>
4736
response.json().then(data =>
4837
Object.assign({}, data, {
@@ -58,12 +47,7 @@ function account({reset, token}) {
5847
message += `${chalk.gray(`${pad(15, 'Server Version', ' ')}: ${chalk.white(data.version)}`)}\n`;
5948
message += `${chalk.gray(`${pad(15, 'Client Version', ' ')}: ${chalk.white(appPackage.version)}`)}\n`;
6049
message += `${chalk.gray(`${pad(15, 'Server URL', ' ')}: ${chalk.white(data.url)}`)}`;
61-
if (data.signedUpAt)
62-
message += `\n${chalk.gray(`${pad(15, 'Signed up', ' ')}: ${chalk.white(new Date(data.signedUpAt))}`)}`;
63-
if (data.metadata && data.metadata.plan)
64-
message += `\n${chalk.gray(
65-
`${pad(15, 'Plan (beta)', ' ')}: ${chalk.white((data.metadata && data.metadata.plan) || '-')}`
66-
)}`;
50+
if (data.signedUpAt) message += `\n${chalk.gray(`${pad(15, 'Signed up', ' ')}: ${chalk.white(new Date(data.signedUpAt))}`)}`;
6751
if (token) message += `\n${chalk.gray(`${pad(15, 'JSON Web Token', ' ')}: ${chalk.white(data.token)}`)}`;
6852
console.log(boxen(message, {padding: 1, borderColor: 'gray', margin: 1}));
6953

@@ -76,28 +60,22 @@ function account({reset, token}) {
7660
}
7761

7862
if (err.message === 'canceled') {
79-
console.log(chalk.yellow('\nAborted operation.'));
63+
console.log(chalk.yellow('\nOperation aborted.'));
8064
return process.exit(0);
8165
}
8266

8367
if (err.message === 'Sign in failed') {
84-
console.error(
85-
chalk.red(`\nCredentials not found. Use ${chalk.bold('dropstack login <url>')} to verifiy your credentials.`)
86-
);
68+
console.error(chalk.red(`\nCredentials not found. Use ${chalk.bold('dropstack login <url>')} to verifiy your credentials.`));
8769
process.exit(1);
8870
}
8971

9072
if (err.message === 'Unauthorized') {
91-
console.error(
92-
chalk.red(`\nUnauthorized. Use ${chalk.bold('dropstack login <url>')} to verifiy your credentials.`)
93-
);
73+
console.error(chalk.red(`\nUnauthorized. Use ${chalk.bold('dropstack login <url>')} to verifiy your credentials.`));
9474
process.exit(1);
9575
}
9676

9777
if (err.message === 'Not found') {
98-
console.error(
99-
chalk.red(`\nServer communication error occurred! Retry later please.\nError: ${chalk.gray(err.message)}`)
100-
);
78+
console.error(chalk.red(`\nServer communication error occurred! Retry later please.\nError: ${chalk.gray(err.message)}`));
10179
process.exit(1);
10280
}
10381

bin/dropstack-activities

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,11 @@ function activities({raw}) {
1818
.load()
1919
.then(settings => {
2020
if (!raw) {
21-
console.log(
22-
`Activities for ${chalk.green.underline(settings.username || '-')} on ${chalk.green.underline(
23-
settings.url || '-'
24-
)}`
25-
);
21+
console.log(`Activities for ${chalk.green.underline(settings.username || '-')} on ${chalk.green.underline(settings.url || '-')}`);
2622
}
2723
return settings;
2824
})
29-
.then(
30-
settings =>
31-
Boolean(!(settings.token && settings.username)) ? Promise.reject(new Error('Sign in failed')) : settings
32-
)
25+
.then(settings => (Boolean(!(settings.token && settings.username)) ? Promise.reject(new Error('Sign in failed')) : settings))
3326
.then(settings => {
3427
process.stderr.write('\x1B[?25l'); //hide terminal cursor
3528
const es = new EventSource(`${settings.url}/activities/live`, {
@@ -58,9 +51,9 @@ function activities({raw}) {
5851
if (!logEntry.timestamp) return;
5952
console.log(
6053
chalk.gray(
61-
`${chalk.yellow(logEntry.timestamp)} | ${chalk.white(logEntry.id)} | ${chalk.white(
62-
logEntry.topic
63-
)} | ${chalk.white(logEntry.activity)} | ${chalk.white(logEntry.state)}`
54+
`${chalk.yellow(logEntry.timestamp)} | ${chalk.white(logEntry.id)} | ${chalk.white(logEntry.topic)} | ${chalk.white(logEntry.activity)} | ${chalk.white(
55+
logEntry.state
56+
)}`
6457
)
6558
);
6659
} catch (e) {}
@@ -70,50 +63,32 @@ function activities({raw}) {
7063
process.stderr.write('\x1B[?25h'); //show terminal cursor
7164

7265
if (err.message === 'canceled') {
73-
console.log(chalk.yellow('\nAborted operation.'));
66+
console.log(chalk.yellow('\nOperation aborted.'));
7467
return process.exit(0);
7568
}
7669

7770
if (err.message === 'Error fetching service') {
78-
console.error(
79-
chalk.red(
80-
`\nService not found. Wrong account? Use ${chalk.bold(
81-
'dropstack login <url>'
82-
)} to verifiy your credentials.`
83-
)
84-
);
71+
console.error(chalk.red(`\nService not found. Wrong account? Use ${chalk.bold('dropstack login <url>')} to verifiy your credentials.`));
8572
process.exit(1);
8673
}
8774

8875
if (err.message === 'Sign in failed') {
89-
console.error(
90-
chalk.red(`\nCredentials not found. Use ${chalk.bold('dropstack login <url>')} to verifiy your credentials.`)
91-
);
76+
console.error(chalk.red(`\nCredentials not found. Use ${chalk.bold('dropstack login <url>')} to verifiy your credentials.`));
9277
process.exit(1);
9378
}
9479

9580
if (err.message === 'Unauthorized') {
96-
console.error(
97-
chalk.red(`\nUnauthorized. Use ${chalk.bold('dropstack login <url>')} to verifiy your credentials.`)
98-
);
81+
console.error(chalk.red(`\nUnauthorized. Use ${chalk.bold('dropstack login <url>')} to verifiy your credentials.`));
9982
process.exit(1);
10083
}
10184

10285
if (err.message === 'Service not found') {
103-
console.error(
104-
chalk.red(
105-
`\nService not found. Wrong account? Use ${chalk.bold(
106-
'dropstack login <url>'
107-
)} to verifiy your credentials.`
108-
)
109-
);
86+
console.error(chalk.red(`\nService not found. Wrong account? Use ${chalk.bold('dropstack login <url>')} to verifiy your credentials.`));
11087
process.exit(1);
11188
}
11289

11390
if (err.message === 'Not found') {
114-
console.error(
115-
chalk.red(`\nServer communication error occurred! Retry later please.\nError: ${chalk.gray(err.message)}`)
116-
);
91+
console.error(chalk.red(`\nServer communication error occurred! Retry later please.\nError: ${chalk.gray(err.message)}`));
11792
process.exit(1);
11893
}
11994

0 commit comments

Comments
 (0)