This repository has been archived by the owner on Jun 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 111
/
settings.js
47 lines (40 loc) · 1.24 KB
/
settings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import expiry from 'expiry-js';
import { intersection } from 'lodash';
import { resolve } from 'path';
import { arch, platform } from 'os';
function generateUrls({ version, plugin }) {
return [
plugin,
`https://artifacts.elastic.co/downloads/kibana-plugins/${plugin}/${plugin}-${version}.zip`
];
}
export function parseMilliseconds(val) {
let result;
try {
const timeVal = expiry(val);
result = timeVal.asMilliseconds();
} catch (ex) {
result = 0;
}
return result;
}
export function parse(command, options, kbnPackage) {
const settings = {
timeout: options.timeout || 0,
quiet: options.quiet || false,
silent: options.silent || false,
config: options.config || '',
plugin: command,
version: kbnPackage.version,
pluginDir: options.pluginDir || ''
};
settings.urls = generateUrls(settings);
settings.workingPath = resolve(settings.pluginDir, '.plugin.installing');
settings.tempArchiveFile = resolve(settings.workingPath, 'archive.part');
settings.tempPackageFile = resolve(settings.workingPath, 'package.json');
settings.setPlugin = function (plugin) {
settings.plugin = plugin;
settings.pluginPath = resolve(settings.pluginDir, settings.plugin.name);
};
return settings;
}