forked from rolodato/gitlab-letsencrypt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathargs.js
executable file
·46 lines (45 loc) · 2.18 KB
/
args.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
'use strict';
const yargs = require('yargs');
module.exports = yargs
.strict()
.help()
.option('domain', {
describe: 'Domain(s) that the cert will be issued for (separated by spaces)',
type: 'array',
demandOption: true
}).option('email', {
describe: 'Email address for your Let\'s Encrypt account',
type: 'string',
demandOption: true
}).option('repository', {
describe: 'GitLab pages repository identifier',
type: 'string',
demandOption: true
}).option('token', {
describe: 'GitLab personal access token (https://gitlab.com/profile/personal_access_tokens)',
type: 'string',
demandOption: true
}).option('jekyll', {
describe: 'Upload challenge files with a Jekyll-compatible YAML front matter (see https://jekyllrb.com/docs/frontmatter)',
type: 'boolean',
default: false
}).option('path', {
describe: 'Absolute path in your repository where challenge files will be uploaded. Your .gitlab-ci.yml file must be configured to serve the contents of this directory under http://YOUR_SITE/.well-known/acme-challenge',
type: 'string',
default: '/public/.well-known/acme-challenge'
}).option('staging', {
describe: 'Use Let\'s Encrypt\'s staging environment (does not issue real certificates - use only for testing)',
type: 'boolean',
default: false
}).example('$0 --domain example.com www.example.com --email [email protected] --repository foo/example.gitlab.io --token abc123', 'Simple build where all files are served from public/ inside your repository')
.example('$0 --jekyll --path / --domain example.com --email [email protected] --repository foo/example.gitlab.io --token abc123', 'Jekyll website that serves all valid files in your repository\'s root directory')
.wrap(yargs.terminalWidth())
.check(argv => {
const empty = Object.keys(argv).filter(key => key !== '_' && argv[key].length == 0);
if (empty.length > 0) {
console.error(`Missing required arguments: ${empty.join(', ')}`);
process.exit(1);
} else {
return true;
}
}).argv;