Passed
Push — main ( de7f7b...33397e )
by Bjarn
02:52 queued 01:28
created

src/services/elasticsearch.ts   A

Complexity

Total Complexity 2
Complexity/F 1

Size

Lines of Code 36
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 31
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 2
mnd 0
bc 0
fnc 2
bpm 0
cpm 1
noi 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A Elasticsearch.install 0 6 1
A Elasticsearch.configure 0 6 1
1
import {writeFileSync} from 'fs'
2
import nginxElasticsearchConf from '../templates/nginx/elasticsearch'
3
import {client} from '../utils/os'
4
import {getConfig, jaleNginxAppsPath} from '../utils/jale'
5
import Nginx from './nginx'
6
import Service from './service'
7
8
class Elasticsearch extends Service {
9
    requireRoot = false
10
    service = 'elasticsearch'
11
12
    // TODO: These paths should be using the Client class. Otherwise they won't work cross platform.
13
    configPath = '/usr/local/etc/elasticsearch/elasticsearch.yml'
14
    dataPath = 'path.data'
15
    dataRootPath = '/usr/local/var'
16
    nginxConfigPath = `${jaleNginxAppsPath}/elasticsearch.conf`
17
18
    install = async (): Promise<boolean> => {
19
        await client().packageManager.install('homebrew/cask-versions/adoptopenjdk8', true)
20
        await client().packageManager.install('libyaml', false)
21
        await client().packageManager.install(this.service, false)
22
23
        return true
24
    }
25
26
    configure = async (): Promise<boolean> => {
27
        const config = await getConfig()
28
        await writeFileSync(this.nginxConfigPath, nginxElasticsearchConf(config.tld))
29
        await (new Nginx).restart()
30
31
        return true
32
    }
33
34
}
35
36
export default Elasticsearch