forked from ioBroker/ioBroker.repositories
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.js
More file actions
70 lines (69 loc) · 2.76 KB
/
Copy pathtasks.js
File metadata and controls
70 lines (69 loc) · 2.76 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
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 (Object.prototype.hasOwnProperty.call(stats, 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));
}