Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.

Commit 95c0c25

Browse files
Updated Command class for error handling, removed ts-ignore
1 parent c17f196 commit 95c0c25

File tree

14 files changed

+29
-45
lines changed

14 files changed

+29
-45
lines changed

src/commands/auth/login.ts

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default class Login extends Command {
1717
}),
1818
};
1919

20-
async run() {
20+
async execute() {
2121
const { flags: userFlags } = this.parse(Login);
2222

2323
if (userFlags.interactive) {
@@ -37,24 +37,16 @@ export default class Login extends Command {
3737
]);
3838
const { login, password } = prompt;
3939
// in this case we the REST call to api was sent, so token was returned to overwrite .codestore/credentials file.
40-
try {
41-
await this.codestore.login(login, password);
42-
this.log(blue('You have been successfully authenticated to code.store.'));
43-
} catch (e) {
44-
this.error(e);
45-
}
40+
await this.codestore.login(login, password);
41+
this.log(blue('You have been successfully authenticated to code.store.'));
4642
} else {
4743
this.warn('Login using web');
48-
4944
ux.action.start(blue('Starting login process'));
5045

51-
try {
52-
await this.codestore.loginWeb();
53-
ux.action.stop(blue('Done'));
54-
this.log(blue('You have been successfully authenticated to code.store.'));
55-
} catch (e) {
56-
this.error(e);
57-
}
46+
await this.codestore.loginWeb();
47+
48+
ux.action.stop(blue('Done'));
49+
this.log(blue('You have been successfully authenticated to code.store.'));
5850
}
5951
}
6052
}

src/commands/auth/logout.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,10 @@ export default class Logout extends Command {
66

77
static aliases = [Aliases.LOGOUT];
88

9-
async run() {
9+
async execute() {
1010
const ora = require('ora');
1111
const spinner = ora().start('Logging out');
12-
try {
13-
await this.codestore.logout();
14-
spinner.succeed('Your have been successfully logged out.');
15-
} catch (e) {
16-
this.error(e.message);
17-
}
12+
await this.codestore.logout();
13+
spinner.succeed('Your have been successfully logged out.');
1814
}
1915
}

src/commands/auth/whoami.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@ export default class Whoami extends Command {
77

88
static aliases = [Aliases.WHOAMI];
99

10-
async run() {
11-
try {
12-
const user: IUser = await this.codestore.getMe();
13-
this.log(user.email);
14-
} catch (e) {
15-
this.error(e.message);
16-
}
10+
async execute() {
11+
const user: IUser = await this.codestore.getMe();
12+
this.log(user.email);
1713
}
1814
}

src/commands/context/clear.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Command } from '../../lib/command';
66
export default class Clear extends Command {
77
static description = 'Clear all contexts';
88

9-
async run() {
9+
async execute() {
1010
const data = [
1111
{ context_type: 'Project ID', value: bold.cyan('prj-d28f33cf') },
1212
{ context_type: 'Service ID', value: bold.cyan('srv-2b00042f') }];

src/commands/context/list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default class List extends Command {
88

99
static aliases = [Aliases.CONTEXT_LS];
1010

11-
async run() {
11+
async execute() {
1212
const data = [
1313
{ context_type: 'Project ID', value: bold.cyan('prj-d28f33cf') },
1414
{ context_type: 'Service ID', value: bold.cyan('srv-2b00042f') }];

src/commands/context/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class Project extends Command {
1919
},
2020
];
2121

22-
async run() {
22+
async execute() {
2323
const { flags: userFlags, args } = this.parse(Project);
2424

2525
if (userFlags.clear) {

src/commands/context/service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class Service extends Command {
1919
},
2020
];
2121

22-
async run() {
22+
async execute() {
2323
const { flags: userFlags, args } = this.parse(Service);
2424

2525
if (userFlags.clear) {

src/commands/project/create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export default class Create extends Command {
1818
}),
1919
};
2020

21-
async run() {
21+
async execute() {
2222
const { flags: userFlags } = this.parse(Create);
2323
let { name, identifier, description } = userFlags;
2424

src/commands/project/list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default class List extends Command {
1111
...ux.table.flags(),
1212
};
1313

14-
async run() {
14+
async execute() {
1515
const { flags: userflags } = this.parse(List);
1616

1717
// this.warn(`You haven't created any projects yet. You can create them using ${italic('$ cs project:add')}.`);

src/commands/service/list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default class List extends Command {
2020
}),
2121
};
2222

23-
async run() {
23+
async execute() {
2424
const { flags: userFlags } = this.parse(List);
2525

2626
if (userFlags.all && userFlags['project-id']) {

0 commit comments

Comments
 (0)