Total Complexity | 5 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import execa from 'execa' |
||
3 | |||
4 | class Expose extends Tool { |
||
5 | alias = 'expose' |
||
6 | name = 'Beyondcode Expose' |
||
7 | |||
8 | /** |
||
9 | * Install the app. |
||
10 | */ |
||
11 | install = async (): Promise<boolean> => { |
||
12 | if (await this.isInstalled()) { |
||
13 | console.log(`${this.name} already is installed. Execute it by running ${this.alias}`) |
||
14 | return false |
||
15 | } |
||
16 | |||
17 | console.log(`Installing ${this.name} using Composer...`) |
||
18 | |||
19 | await execa('composer', ['global', 'require', 'beyondcode/expose']) |
||
20 | |||
21 | console.log(`Successfully installed ${this.name}`) |
||
22 | |||
23 | return true |
||
24 | } |
||
25 | |||
26 | |||
27 | /** |
||
28 | * Uninstall the app. |
||
29 | */ |
||
30 | uninstall = async (): Promise<boolean> => { |
||
31 | if (!(await this.isInstalled())) { |
||
32 | console.log(`${this.name} is not installed`) |
||
33 | } |
||
34 | |||
35 | console.log(`Uninstalling ${this.name} using Composer...`) |
||
36 | |||
37 | await execa('composer', ['global', 'remove', 'beyondcode/expose']) |
||
38 | |||
39 | console.log(`Successfully uninstalled ${this.name}`) |
||
40 | |||
41 | return true |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Check if the app is already installed.. |
||
46 | */ |
||
47 | isInstalled = async (): Promise<boolean> => { |
||
48 | const {stdout} = await execa('composer', ['global', 'show', '-i']) |
||
49 | return stdout.includes('beyondcode/expose') |
||
50 | } |
||
53 | export default Expose |