-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
136 lines (112 loc) · 5.27 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
const core = require('@actions/core');
const github = require('@actions/github');
const { http, https } = require('follow-redirects');
const fs = require('fs');
const path = require('path');
async function main() {
try {
let output_dir = core.getInput('output_dir', { required: false });
let output_file = core.getInput('output_file', { required: false });
let output_format = core.getInput('output_format', { required: false });
let clean_output_dir = core.getInput('clean_output_dir', { required: false });
let only_printable_characters = core.getInput('only_printable_characters', { required: false });
let safe_percent_encoding = core.getInput('safe_percent_encoding', { required: false });
let na_filter = core.getInput('na_filter', { required: false });
let na_values = core.getInput('na_values', { required: false });
let mapping_partition = core.getInput('mapping_partition', { required: false });
let chunksize = core.getInput('chunksize', { required: false });
let number_of_processes = core.getInput('number_of_processes', { required: false });
let logging_level = core.getInput('logging_level', { required: false });
let logging_file = core.getInput('logging_file', { required: false });
if(output_dir)
output_dir='output_dir=' + output_dir;
if(output_file)
output_file='output_file=' + output_file;
if(output_format)
output_format='output_format=' + output_format;
if(clean_output_dir)
clean_output_dir='clean_output_dir=' + clean_output_dir;
if(only_printable_characters)
only_printable_characters='only_printable_characters=' + only_printable_characters;
if(safe_percent_encoding)
safe_percent_encoding='safe_percent_encoding=' + safe_percent_encoding;
if(na_filter)
na_filter='na_filter=' + na_filter;
if(na_values)
na_values='na_values=' + na_values;
if(mapping_partition)
mapping_partition='mapping_partition=' + mapping_partition;
if(chunksize)
chunksize='chunksize=' + chunksize;
if(number_of_processes)
number_of_processes='number_of_processes=' + number_of_processes;
if(logging_level)
logging_level='logging_level=' + logging_level;
if(logging_file)
logging_file='logging_file=' + logging_file;
let changes = [];
let files = getAllFiles('./');
for (let file of files) {
file = file.split('/');
file.splice(0, 6);
changes.push(file.join('/'));
}
core.setOutput('run', false);
if(fs.mkdirSync('./morph-kgc-exec/', { recursive: true })){
let data = '[CONFIGURATION]\n#OUTPUT\n' +
/* output optional parameters */
output_dir + '\n' + output_file + '\n' + output_format + '\n' + clean_output_dir + '\n' + only_printable_characters + '\n' + safe_percent_encoding + '\n\n#INPUT\n' +
/* input parameters */
na_filter + '\n' + na_values + '\n\n#MAPPINGS\n' +
/* mappings parameters */
mapping_partition + '\n\n#MATERIALIZATION\n' +
/* materialization parameters */
chunksize + '\n\n#MULTIPROCESSING\n' +
/* multiprocessing parameters */
number_of_processes + '\n\n#LOGS\n' +
/* logging parameters */
logging_level + '\n' + logging_file;
fs.writeFile('./morph-kgc-exec/config.ini', data, err => {
if (err) {
core.setFailed(error.message);
}
})
}
for (const file of changes) {
let fle = file.split('.');
const file_extension = fle.pop();
if (file_extension == 'ttl' || file_extension == 'nt'){
const mapping_file_extension = fle.pop();
switch (mapping_file_extension) {
case 'rml':
case 'rml':
fle = fle.join('/').split('/').pop();
core.setOutput('run', true);
data = '\n\n[' + "mapping_file_" + fle + ']\nmappings=./' + file;
fs.appendFile('./morph-kgc-exec/config.ini',data,err => {
if (err) {
core.setFailed(error.message);
}
});
break;
}
}
}
}
catch (error){
core.setFailed(error.message);
}
}
function getAllFiles (dirPath, arrayOfFiles) {
let files = fs.readdirSync(dirPath)
arrayOfFiles = arrayOfFiles || []
files.forEach(function(file) {
if (fs.statSync(dirPath + "/" + file).isDirectory()) {
arrayOfFiles = getAllFiles(dirPath + "/" + file, arrayOfFiles)
} else {
arrayOfFiles.push(path.join(__dirname, dirPath, "/", file))
}
})
return arrayOfFiles
}
main();