-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
145 lines (131 loc) · 3.71 KB
/
cli.js
File metadata and controls
145 lines (131 loc) · 3.71 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
138
139
140
141
142
143
144
145
#!/usr/bin/env node
'use strict'
const chalk = require('chalk')
const meow = require('meow')
const WebSSL = require('./openssl')
// prettier-ignore
const cli = meow(
`
${chalk.blue('Usage')}
$ webssl [flags] <out_dir>
${chalk.blue('Arguments')}
<out_dir> Where to save all files (default: ${chalk.yellow('/Current/Folder')})*
Path can be absolute (starting with a slash) or relative. Relative path
will be resolved with the folder you are executing this script from.
${chalk.blue('Options')}
--filename, -f The name of the file which gets generated (default: ${chalk.yellow('ssl')})
--addToKeychain, -a Add your generated key file to Keychain (default: ${chalk.yellow('false')})
--removeOld, -r Remove your old key from Keychain (default: ${chalk.yellow('false')})
--keychain, -k Select a keychain (default: ${chalk.yellow('login')})
--config, -c Path to config file or false to disable (default: ${chalk.yellow('./')})
--dns DNS entries split by a comma. (default: ${chalk.yellow('null')})
--commonName, -CN OpenSSL \`commonName\` subject entry${chalk.red('*')}
--countryName, -C OpenSSL \`countryName\` subject entry${chalk.red('*')}
--stateOrProvinceName, -ST OpenSSL \`stateOrProvinceName\` subject entry${chalk.red('*')}
--localityName, -L OpenSSL \`localityName\` subject entry${chalk.red('*')}
--organizationName, -O OpenSSL \`organizationName\` subject entry${chalk.red('*')}
--organizationalUnit, -OU OpenSSL \`organizationalUnit\` subject entry
--emailAddress OpenSSL \`emailAddress\` subject entry
${chalk.blue('Examples')}
$ webssl \\
--addToKeychain \\
--keychain development \\
--dns some.net,test.de \\
--commonName Test \\
/Users/Hi/Downloads
${chalk.red('*')} this is required unless you do not have it in a config file
`,
{
flags: {
filename: {
type: 'string',
default: "ssl",
alias: 'f',
},
config: {
type: 'string',
alias: 'c',
},
dns: {
type: 'string',
},
addToKeychain: {
type: 'boolean',
alias: 'a',
default: false
},
removeOld: {
type: 'boolean',
alias: 'r',
default: false
},
keychain: {
type: 'string',
alias: 'k',
default: 'login'
},
commonName: {
type: 'string',
alias: 'CN',
},
countryName: {
type: 'string',
alias: 'C',
},
stateOrProvinceName: {
type: 'string',
alias: 'ST',
},
localityName: {
type: 'string',
alias: 'L',
},
organizationName: {
type: 'string',
alias: 'O',
},
organizationalUnit: {
type: 'string',
alias: 'OU',
},
emailAddress: {
type: 'string',
},
},
}
)
const {
filename,
addToKeychain,
removeOld,
keychain,
commonName,
countryName,
stateOrProvinceName,
localityName,
organizationName,
organizationalUnit,
emailAddress,
} = cli.flags
const dns = cli.flags.dns ? cli.flags.dns.split(',') : undefined
const config = cli.flags.config === 'false' ? false : cli.flags.config
const options = {
filename,
addToKeychain,
removeOld,
keychain,
config,
dns,
openssl: {
commonName,
countryName,
stateOrProvinceName,
localityName,
organizationName,
organizationalUnit,
emailAddress,
},
}
options.outDir = cli.input[0] || process.cwd()
const webssl = new WebSSL(options)
webssl.generate()