-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·47 lines (34 loc) · 1.06 KB
/
cli.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
#!/usr/bin/env node
// Modified version of https://github.com/AliasIO/wappalyzer/blob/master/src/drivers/npm/cli.js
const { AppAnalytics, PuppeteerCluster } = require('./index');
const args = process.argv.slice(2);
const url = args.shift() || '';
if (!url) {
process.stderr.write('No URL specified\n');
process.exit(1);
}
const options = {};
let arg;
do {
arg = args.shift();
const matches = /--([^=]+)=(.+)/.exec(arg);
if (matches) {
const key = matches[1].replace(/-\w/g, _matches => _matches[1].toUpperCase());
const value = matches[2];
options[key] = value;
}
} while (arg);
const appAnalytics = new AppAnalytics();
const wappalyzer = new PuppeteerCluster(appAnalytics, options);
appAnalytics
.loadAppsjson()
.then(() => wappalyzer.startCluster())
.then(() => wappalyzer.analyze(url))
.then(json => {
process.stdout.write(`${JSON.stringify(json)}\n`);
})
.then(() => wappalyzer.closeCluster())
.catch(error => {
process.stderr.write(`${error}\n`);
process.exit(1);
});