forked from ioBroker/ioBroker.repositories
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.js
58 lines (57 loc) · 2.52 KB
/
tasks.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
48
49
50
51
52
53
54
55
56
57
58
const axios = require('axios');
// check if all adapters in stable have the version attribute
// and published attribute
if (process.argv.includes('--init')) {
const scripts = require('./lib/scripts');
scripts.init().catch(e => console.error(e));
} else if (process.argv.includes('--stable')) {
const build = require('./lib/build');
const tools = require('./lib/tools');
tools.getRepositoryFile(`https://raw.githubusercontent.com/${tools.appName}/${tools.appName}.repositories/master/sources-dist-stable.json`, (err, data) => {
if (err) {
console.error(err);
if (!data) {
process.exit(1);
}
}
build.getStats((err, stats) => {
if (stats) {
for (const adapter in stats) {
if (stats.hasOwnProperty(adapter) && data[adapter]) {
data[adapter].stat = stats[adapter];
}
}
}
build.processRepository(data, ['--file', '/var/www/download/sources-dist-latest.json'], () => {});
});
});
} else if (process.argv.includes('--latest')) {
const build = require('./lib/build');
const tools = require('./lib/tools');
axios(`https://raw.githubusercontent.com/${tools.appName}/${tools.appName}.repositories/master/sources-dist-stable.json`)
.then(response => {
const latest = response.data;
tools.getRepositoryFile(`https://raw.githubusercontent.com/${tools.appName}/${tools.appName}.repositories/master/sources-dist.json`, latest, (err, data) => {
if (err) {
console.error(err);
!data && process.exit(1);
}
build.getStats((err, stats) => {
if (stats) {
Object.keys(stats).forEach(adapter => {
if (data[adapter]) {
data[adapter].stat = stats[adapter];
}
});
}
build.processRepository(data, ['--file', '/var/www/download/sources-dist.json', '--shields', '/var/www/download/img'], () => {});
});
});
});
} else if (process.argv.includes('--sort')) {
const scripts = require('./lib/scripts');
scripts.sort().catch(e => console.error(e));
} else if (process.argv.includes('--nodates')) {
const scripts = require('./lib/scripts');
scripts.nodates().catch(e => console.error(e));
}