-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-jira-miner-in-order.js
92 lines (83 loc) · 2.97 KB
/
run-jira-miner-in-order.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
/**
* Created by austin on 16/03/2017.
* node version 6.9.5
*/// jscs:ignore
'use strict';
var prompt = require('prompt');
var exec = require('child_process').exec;
var child;
//validation for prompt see https://www.npmjs.com/package/prompt
var schema = {
properties: {
username: {
description: 'Enter your Jira Username',
pattern: /^[a-zA-Z0-9._-]+$/,
message: 'Username must be characters, numbers, dots, underscores and dashes',
required: true,
},
password: {
description: 'Enter your Jira password',
pattern: /^[a-zA-Z0-9]+$/,
hidden: true,
message: 'Invalid characters in password',
replace: '*',
required: true,
},
url: {
description: 'Enter Jira URL e.g. "issues.jboss.org"',
pattern: /^[a-zA-Z0-9._-]+$/,
message: 'url must be a valid',
required: true,
},
project: {
description: 'Enter the project name e.g. "RHMAP or RAINCATCH"',
pattern: /^[a-zA-Z0-9._-]+$/,
message: 'Must be a valid project',
required: true,
},
format: {
description: 'Enter format either json or csv ,enter for default tsv',
pattern: /^[a-z]+$/,
required: false,
},
},
};
// Start the prompt
prompt.start();
// Get three properties from the user: username , password and url and project
console.log('Enter username, password and url e.g. "issues.jboss.org"');
prompt.get(schema, function (err, result) {
//prompt.get(['username', 'password', 'url', 'project'], function (err, result) {
// Log the results.
console.log('Command-line input received:');
console.log(' username: ' + result.username);
console.log(' password: ********');
console.log(' url: https://' + result.url);
console.log(' project: ' + result.project);
// execute jira-miner target to point at the source
child = exec('jira-miner target https://' + result.url + ' --user ' + result.username + ' --password ' + result.password,{maxBuffer: 1024 * 20000}, function(error, stdout, stderr){
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
} else {
// pull data from the target with populate, to populate local loki db
child = exec('jira-miner populate "project in (' + result.project + ')"',{maxBuffer: 1024 * 9000}, function (error, stdout, stderr){
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
} else {
// use jira-miner query to access a local search file
child = exec('jira-miner query search --key=RAINCATCH-623 --' + result.format,{maxBuffer: 1024 * 9000}, function (error, stdout, stderr){
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
}
});
}
});
});