-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
78 lines (65 loc) · 2.32 KB
/
index.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
Import tsv file into Neo4J
---
Import UTF8 tsv data into neo4j.
Schema
languages: en,fr comma separated
all other fields will be stored as well.
Note that if a slug field is present.
task=
*/
var fs = require('fs'),
settings = require('./settings'),
options = require('minimist')(process.argv.slice(2));
async = require('async'),
_ = require('lodash'),
clc = require('cli-color'),
tasks = require('require-all')({
dirname: __dirname + '/tasks',
filter : /(.*).js$/
}),
availableTasks = _.assign({
demo: [],
syncone: [
tasks.eibio.getPerson,
tasks.eibio.cleanMedia,
tasks.histograph.getMediaByEibio,
tasks.eibio.assignMedia,
tasks.eibio.assignHistographLink
],
sync: [
tasks.eibio.getPeople,
tasks.eibio.cleanMedia,
tasks.histograph.getMediaByEibio,
tasks.eibio.assignMedia,
tasks.eibio.assignHistographLink
],
}, settings.availableTasks || {});
console.log(clc.whiteBright( "\n\n +-+-+-+-+-+ +-+-+"));
console.log(clc.whiteBright( " |E|I|B|I|O|-|H|G| "));
console.log(clc.whiteBright( " +-+-+-+-+-+ +-+-+ \n\n"));
if(!availableTasks[options.task]) {
console.log(clc.blackBright(' task', clc.whiteBright(options.task || 'null'), clc.redBright('not found'), 'please specify a valid', clc.whiteBright('--task'),'param'));
console.log(clc.blackBright(' available tasks: '), _.keys(availableTasks));
console.log("\n\n");
return;
}
// the waterfall specified for the task
async.waterfall([
// send initial options
function init(callback) {
callback(null, options);
},
tasks.helpers.tick.start
].concat(_.map(availableTasks[options.task], function (d){
if(typeof d == 'function')
return d;
return _.get(tasks, d.replace('tasks.', ''))
})).concat([tasks.helpers.tick.end]), function (err) {
if(err) {
console.warn(err);
console.log(clc.blackBright('\n task'), clc.whiteBright(options.task), clc.redBright('exit with error'));
} else
console.log(clc.blackBright('\n task'), clc.whiteBright(options.task), clc.cyanBright('completed'));
console.log("\n\n")
});