-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (44 loc) · 1.11 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
'use strict';
const arvish = require('arvish');
const dateFormat = require('date-format');
let q = arvish.input;
const s = q.split(':');
if (s.length > 1) {
q = 'g:'+s[0];
if (s[1]) {
q = q+' AND '+'a:'+s[1];
}
if (s.length > 2 && s[2]) {
q = q+' AND '+'v:'+s[2];
}
}
arvish.fetch('http://search.maven.org/solrsearch/select', {
query: {
q,
start: 0,
rows: 20
}
}).then(data => {
const items = data.response.docs
.map(x => {
const v = x.v?x.v:x.latestVersion;
const mvn = `<dependency>\n <groupId>${x.g}</groupId>\n <artifactId>${x.a}</artifactId>\n <version>${v}</version>\n</dependency>`;
const gradle = `compile '${x.g}:${x.a}:${v}'`;
return {
title: `${x.g}:${x.a}:${v}`,
subtitle: `updated at ${dateFormat('yyyy-dd-MM', new Date(x.timestamp))}`,
arg: mvn,
mods: {
cmd: {
arg: mvn,
subtitle: `copy maven dependency to clipboard`
},
alt: {
arg: gradle,
subtitle: `copy gradle dependency to clipboard`
}
}
};
});
arvish.output(items);
});