forked from cnumr/GreenIT-Analysis-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgreenit
More file actions
137 lines (135 loc) · 4.87 KB
/
greenit
File metadata and controls
137 lines (135 loc) · 4.87 KB
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
137
#!/usr/bin/env node
'use strict';
const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');
const sizes = require('./src/conf/sizes.js');
const analyse_core = require('./src/commands/analyse.js').analyse_core;
yargs(hideBin(process.argv))
.command(
'analyse [url_input_file] [report_output_file]',
'Run the analysis',
(yargs) => {
yargs
.positional('url_input_file', {
describe: 'YAML file path listing all URL',
default: 'url.yaml',
})
.positional('report_output_file', {
describe: 'Report output file path',
default: 'results.xlsx',
})
.option('grafana_link', {
description: 'Grafana link to display in HTML report when using influxdbhtml format',
type: 'string',
default: '',
})
.option('device', {
alias: 'd',
description: 'Hardware to simulate',
choices: Object.keys(sizes),
default: 'desktop',
})
.option('format', {
alias: 'f',
type: 'string',
description: 'Report format : Possible choices : xlsx (excel), html, influxdb',
})
.option('headers', {
alias: 'h',
type: 'string',
description: 'Headers HTTP to configure to analyze url',
})
.option('headless', {
type: 'boolean',
description: 'Option to enable or disable web browser headless mode',
default: true,
})
.option('influxdb_bucket', {
type: 'string',
})
.option('influxdb_hostname', {
type: 'string',
})
.option('influxdb_org', {
type: 'string',
})
.option('influxdb_token', {
type: 'string',
})
.option('language', {
type: 'string',
description: 'Report language : Possible choices: fr, en',
choices: ['fr', 'en'],
default: 'fr',
})
.option('login', {
type: 'string',
alias: 'l',
description: 'Path to YAML file with login informations',
})
.option('max_tab', {
type: 'number',
description: 'Number of concurrent analysis',
default: 40,
})
.option('mobile', {
type: 'boolean',
description: 'Connection type : mobile or wired',
default: false,
})
.option('proxy', {
alias: 'p',
type: 'string',
description: 'Path to YAML file with proxy configuration to apply in Chromium',
})
.option('retry', {
alias: 'r',
type: 'number',
description: 'Number of retry when an analysis of a URL fail',
default: 2,
})
.option('timeout', {
alias: 't',
type: 'number',
description: 'Timeout for an analysis of a URL in ms',
default: 180000,
})
.option('worst_pages', {
type: 'number',
description: 'Number of displayed worst pages',
default: 5,
})
.option('worst_rules', {
type: 'number',
description: 'Number of displayed worst rules',
default: 5,
});
},
(argv) => {
analyse_core(argv);
}
)
.command(
'parseSitemap <sitemap_url> [yaml_output_file]',
'Parse sitemap to a YAML file',
(yargs) => {
yargs
.positional('sitemap_url', {
describe: 'URL to the sitemap.xml file',
})
.positional('yaml_output_file', {
describe: 'Output file path',
default: 'url.yaml',
});
},
(argv) => {
require('./src/commands/sitemapParser.js')(argv);
}
)
.option('ci', {
type: 'boolean',
description: 'Disable progress bar to work with GitLab CI',
})
.strict()
.demandCommand()
.help().argv;