@fishawack/lab-env 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitattributes +1 -0
- package/CHANGELOG.md +234 -0
- package/README.md +197 -0
- package/cli.js +71 -0
- package/commands/artisan.js +15 -0
- package/commands/check.js +16 -0
- package/commands/clean.js +16 -0
- package/commands/composer.js +15 -0
- package/commands/connect.js +15 -0
- package/commands/content.js +10 -0
- package/commands/create/cmds/delete.js +27 -0
- package/commands/create/cmds/diagnose.js +77 -0
- package/commands/create/cmds/new.js +48 -0
- package/commands/create/libs/prompts.js +60 -0
- package/commands/create/libs/utilities.js +50 -0
- package/commands/create/libs/vars.js +95 -0
- package/commands/create/services/api.js +3 -0
- package/commands/create/services/bitbucket.js +92 -0
- package/commands/create/services/egnyte.js +31 -0
- package/commands/create/services/git.js +31 -0
- package/commands/create/services/gitlab.js +30 -0
- package/commands/create/services/guide.js +296 -0
- package/commands/create/services/test.js +138 -0
- package/commands/deploy.js +23 -0
- package/commands/docker/build.js +10 -0
- package/commands/docker/config.js +10 -0
- package/commands/docker/down.js +10 -0
- package/commands/docker/mocha.js +10 -0
- package/commands/docker/rebuild.js +10 -0
- package/commands/docker/up.js +15 -0
- package/commands/docker/volumes.js +27 -0
- package/commands/execute.js +21 -0
- package/commands/install.js +15 -0
- package/commands/npm.js +15 -0
- package/commands/nuke.js +17 -0
- package/commands/origin.js +126 -0
- package/commands/php.js +15 -0
- package/commands/production.js +10 -0
- package/commands/regenerate.js +16 -0
- package/commands/reinstall.js +16 -0
- package/commands/run.js +25 -0
- package/commands/setup.js +27 -0
- package/commands/start.js +33 -0
- package/commands/test.js +22 -0
- package/commands/uninstall.js +15 -0
- package/commands/watch.js +20 -0
- package/core/0.0.19/Dockerfile +234 -0
- package/core/0.0.19/docker-compose.yml +27 -0
- package/core/0.0.19/entrypoint.sh +4 -0
- package/globals.js +85 -0
- package/intercept.sh +37 -0
- package/laravel/8/docker-compose.yml +49 -0
- package/laravel/8/nginx/nginx.conf +37 -0
- package/laravel/8/php/custom.conf +7 -0
- package/package.json +33 -0
- package/wordpress/5.7.2/apache/.htaccess +25 -0
- package/wordpress/5.7.2/apache/uploads.ini +6 -0
- package/wordpress/5.7.2/docker-compose.yml +42 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const api = require('./api');
|
|
2
|
+
const { Spinner } = require('../libs/utilities');
|
|
3
|
+
const { apis, headers, misc } = require('../libs/vars');
|
|
4
|
+
const { success } = require('./git');
|
|
5
|
+
|
|
6
|
+
module.exports.check = async () => {
|
|
7
|
+
let spinner = new Spinner(`Communicating with ${misc.bitbucket.workspace} on Bitbucket`);
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
if (await api(headers.bbHeaders).get(apis.bbWorkspaceAPI)) {
|
|
11
|
+
spinner.update(`Successfully communicated with ${misc.bitbucket.workspace} on Bitbucket.`);
|
|
12
|
+
} else {
|
|
13
|
+
throw('');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return true;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
spinner.update(`Failed to communicate with ${misc.bitbucket.workspace} on Bitbucket.`, 'fail');
|
|
19
|
+
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
module.exports.remove = async (slug) => {
|
|
25
|
+
let spinner = new Spinner(`Deleting ${slug} on Bitbucket`);
|
|
26
|
+
|
|
27
|
+
await api(headers.bbHeaders).delete(`${apis.bbWorkspaceAPI}/${slug}`)
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
if (await success(`${apis.bbWorkspaceAPI}/${slug}`, headers.bbHeaders)) {
|
|
31
|
+
spinner.update(`Successfully deleted ${slug} on Bitbucket.`);
|
|
32
|
+
} else {
|
|
33
|
+
throw('');
|
|
34
|
+
}
|
|
35
|
+
} catch (error) {
|
|
36
|
+
spinner.update(`Failed to delete ${slug} on Bitbucket.`, 'fail');
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
module.exports.exists = async (slug) => {
|
|
41
|
+
let spinner = new Spinner(`Ensuring ${slug} does not exist on Bitbucket`);
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
await api(headers.bbHeaders).get(`${apis.bbWorkspaceAPI}/${slug}`);
|
|
45
|
+
|
|
46
|
+
spinner.update(`${slug} exists on Bitbucket`, 'info');
|
|
47
|
+
|
|
48
|
+
return true;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
if (error.response.status === 404) {
|
|
51
|
+
spinner.update(`${slug} does not exist on Bitbucket.`, 'info');
|
|
52
|
+
|
|
53
|
+
return false;
|
|
54
|
+
} else {
|
|
55
|
+
spinner.update(`Error finding ${slug} on Bitbucket`, 'fail');
|
|
56
|
+
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
module.exports.fork = async (slug, template) => {
|
|
63
|
+
const forkData = {
|
|
64
|
+
"name": slug,
|
|
65
|
+
"is_private": true,
|
|
66
|
+
"workspace": {
|
|
67
|
+
"slug": misc.bitbucket.workspace
|
|
68
|
+
},
|
|
69
|
+
"project": {
|
|
70
|
+
"key": template.project || "BES"
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// Execute post request to create new fork on Bitbucket
|
|
75
|
+
let spinner = new Spinner(`Creating ${slug} on Bitbucket`);
|
|
76
|
+
|
|
77
|
+
try {
|
|
78
|
+
await api(headers.bbHeaders).post(`${apis.bbWorkspaceAPI}/${template.name}/forks`, forkData);
|
|
79
|
+
|
|
80
|
+
if (await success(`${apis.bbWorkspaceAPI}/${slug}`, headers.bbHeaders)) {
|
|
81
|
+
spinner.update(`Successfully created ${slug} on Bitbucket.`);
|
|
82
|
+
} else {
|
|
83
|
+
throw('');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return true;
|
|
87
|
+
} catch (error) {
|
|
88
|
+
spinner.update(`Failed to create ${slug} on Bitbucket.`, 'fail');
|
|
89
|
+
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const api = require('./api');
|
|
2
|
+
const { Spinner } = require('../libs/utilities');
|
|
3
|
+
const { ftppass } = require('../libs/vars');
|
|
4
|
+
const { exec } = require("child_process");
|
|
5
|
+
|
|
6
|
+
module.exports.check = async () => {
|
|
7
|
+
let spinner = new Spinner(`Communicating with Egnyte`);
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
if (!await new Promise((resolve, reject) => {
|
|
11
|
+
exec(`curl -I -k --ftp-ssl --ftp-pasv -u "${ftppass['ftp-fishawack.egnyte.com'].username.replace('$', '\\$')}:${ftppass['ftp-fishawack.egnyte.com'].password}" ftp://ftp-fishawack.egnyte.com`, (error, stdout, stderr) => {
|
|
12
|
+
if(error){
|
|
13
|
+
reject(error);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
resolve(stdout.trim());
|
|
18
|
+
});
|
|
19
|
+
})) {
|
|
20
|
+
spinner.update(`Successfully communicated with Egnyte.`);
|
|
21
|
+
} else {
|
|
22
|
+
throw('');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return true;
|
|
26
|
+
} catch (error) {
|
|
27
|
+
spinner.update(`Failed to communicate with Egnyte.`, 'fail');
|
|
28
|
+
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const api = require('./api');
|
|
2
|
+
|
|
3
|
+
// Check api call success status
|
|
4
|
+
module.exports.success = async (url, headers) => {
|
|
5
|
+
let stop;
|
|
6
|
+
let success = false;
|
|
7
|
+
let timeout = setTimeout(() => stop = true, 30000);
|
|
8
|
+
|
|
9
|
+
while(!stop) {
|
|
10
|
+
try {
|
|
11
|
+
await api(headers).get(url);
|
|
12
|
+
success = true;
|
|
13
|
+
|
|
14
|
+
break;
|
|
15
|
+
} catch(error) {
|
|
16
|
+
/*
|
|
17
|
+
404 is expected for delete call,
|
|
18
|
+
will get 403 during deletion process so consider 404 success
|
|
19
|
+
*/
|
|
20
|
+
if (error.response.status === 404){
|
|
21
|
+
success = true;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
clearTimeout(timeout);
|
|
28
|
+
timeout = null;
|
|
29
|
+
|
|
30
|
+
return success;
|
|
31
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const { Spinner } = require('../libs/utilities');
|
|
2
|
+
const { misc } = require('../libs/vars');
|
|
3
|
+
const { exec } = require("child_process");
|
|
4
|
+
|
|
5
|
+
module.exports.check = async () => {
|
|
6
|
+
let spinner = new Spinner(`Communicating with ${misc.gitlab.workspace} on Gitlab (VPN required)`);
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
if (!JSON.parse(await new Promise((resolve, reject) => {
|
|
10
|
+
exec(`curl -H "Content-Type:application/json" http://${misc.gitlab.workspace}/api/v4/users?private_token=${misc.gitlab.token}`, (error, stdout, stderr) => {
|
|
11
|
+
if(error){
|
|
12
|
+
reject(error);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
resolve(stdout.trim());
|
|
17
|
+
});
|
|
18
|
+
})).message) {
|
|
19
|
+
spinner.update(`Successfully communicated with ${misc.gitlab.workspace} on Gitlab.`);
|
|
20
|
+
} else {
|
|
21
|
+
throw('');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return true;
|
|
25
|
+
} catch (error) {
|
|
26
|
+
spinner.update(`Failed to communicate with ${misc.gitlab.workspace} on Gitlab.`, 'fail');
|
|
27
|
+
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
const inquirer = require('inquirer');
|
|
2
|
+
const { homedir } = require('os');
|
|
3
|
+
const { mkdirSync, writeFileSync, readFileSync } = require("fs");
|
|
4
|
+
const { encode } = require('../libs/utilities');
|
|
5
|
+
const { urls, apis, misc: creds, bitbucketApi, headers, ftppass: creds_ftppass } = require('../libs/vars');
|
|
6
|
+
const { execSync } = require('child_process');
|
|
7
|
+
|
|
8
|
+
module.exports.targets = async () => {
|
|
9
|
+
let inputs = await inquirer.prompt([
|
|
10
|
+
{
|
|
11
|
+
type: 'confirm',
|
|
12
|
+
name: 'confirm',
|
|
13
|
+
message: 'Generate targets folder?',
|
|
14
|
+
default: true
|
|
15
|
+
}
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
if(inputs.confirm){
|
|
19
|
+
mkdirSync(`${homedir()}/targets`);
|
|
20
|
+
} else {
|
|
21
|
+
throw('');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports.misc = async () => {
|
|
26
|
+
let inputs = await inquirer.prompt([
|
|
27
|
+
{
|
|
28
|
+
type: 'confirm',
|
|
29
|
+
name: 'confirm',
|
|
30
|
+
message: 'Generate misc.json file?',
|
|
31
|
+
default: true
|
|
32
|
+
}
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
if(inputs.confirm){
|
|
36
|
+
writeFileSync(`${homedir()}/targets/misc.json`, JSON.stringify({bitbucket: {}, gitlab: {}}, null, 4));
|
|
37
|
+
} else {
|
|
38
|
+
throw('');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports.bitbucket = async () => {
|
|
43
|
+
let inputs = await inquirer.prompt([
|
|
44
|
+
{
|
|
45
|
+
type: 'confirm',
|
|
46
|
+
name: 'confirm',
|
|
47
|
+
message: 'Would you like to populate your bitbucket credentials?',
|
|
48
|
+
default: true
|
|
49
|
+
}
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
if(inputs.confirm){
|
|
53
|
+
let inputs = await inquirer.prompt([
|
|
54
|
+
{
|
|
55
|
+
type: 'input',
|
|
56
|
+
name: 'username',
|
|
57
|
+
message: 'What is your bitbucket username? (e.g. mmellor)',
|
|
58
|
+
default: creds.bitbucket && creds.bitbucket.username,
|
|
59
|
+
validate: input => input.trim().length > 0 || 'Username cannot be an empty string'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
type: 'password',
|
|
63
|
+
name: 'password',
|
|
64
|
+
default: creds.bitbucket && creds.bitbucket.password,
|
|
65
|
+
message: 'What is your bitbucket password? (e.g. password1234)',
|
|
66
|
+
validate: input => input.trim().length > 0 || 'Password cannot be an empty string'
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: 'input',
|
|
70
|
+
name: 'workspace',
|
|
71
|
+
message: 'What is your bitbucket workspace?',
|
|
72
|
+
default: 'fishawackdigital'
|
|
73
|
+
}
|
|
74
|
+
]);
|
|
75
|
+
|
|
76
|
+
let file = JSON.parse(readFileSync(`${homedir()}/targets/misc.json`, { encoding: 'utf8' }));
|
|
77
|
+
|
|
78
|
+
creds.bitbucket = file.bitbucket = {...inputs};
|
|
79
|
+
apis.bbWorkspaceAPI = `${bitbucketApi}/${inputs.workspace}`;
|
|
80
|
+
headers.bbHeaders = encode(inputs.username, inputs.password);
|
|
81
|
+
urls.bitbucketSSH = `git@bitbucket.org:${inputs.workspace}`;
|
|
82
|
+
|
|
83
|
+
writeFileSync(`${homedir()}/targets/misc.json`, JSON.stringify(file, null, 4));
|
|
84
|
+
} else {
|
|
85
|
+
throw('');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
module.exports.gitlab = async () => {
|
|
90
|
+
let inputs = await inquirer.prompt([
|
|
91
|
+
{
|
|
92
|
+
type: 'confirm',
|
|
93
|
+
name: 'confirm',
|
|
94
|
+
message: 'Would you like to populate your gitlab credentials?',
|
|
95
|
+
default: true
|
|
96
|
+
}
|
|
97
|
+
]);
|
|
98
|
+
|
|
99
|
+
if(inputs.confirm){
|
|
100
|
+
let inputs = await inquirer.prompt([
|
|
101
|
+
{
|
|
102
|
+
type: 'password',
|
|
103
|
+
name: 'token',
|
|
104
|
+
message: 'What is your gitlab token? (e.g. puhQmpZGooQyLCa5LhTg)',
|
|
105
|
+
default: creds.gitlab && creds.gitlab.token || null,
|
|
106
|
+
validate: input => input.trim().length > 0 || 'Password cannot be an empty string'
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
type: 'input',
|
|
110
|
+
name: 'workspace',
|
|
111
|
+
message: 'What is your gitlab workspace?',
|
|
112
|
+
default: 'diggit01.fw.local'
|
|
113
|
+
}
|
|
114
|
+
]);
|
|
115
|
+
|
|
116
|
+
let file = JSON.parse(readFileSync(`${homedir()}/targets/misc.json`, { encoding: 'utf8' }));
|
|
117
|
+
|
|
118
|
+
creds.gitlab = file.gitlab = {...inputs};
|
|
119
|
+
|
|
120
|
+
writeFileSync(`${homedir()}/targets/misc.json`, JSON.stringify(file, null, 4));
|
|
121
|
+
} else {
|
|
122
|
+
throw('');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
module.exports.ftppass = async () => {
|
|
127
|
+
let inputs = await inquirer.prompt([
|
|
128
|
+
{
|
|
129
|
+
type: 'confirm',
|
|
130
|
+
name: 'confirm',
|
|
131
|
+
message: 'Generate .ftppass file?',
|
|
132
|
+
default: true
|
|
133
|
+
}
|
|
134
|
+
]);
|
|
135
|
+
|
|
136
|
+
if(inputs.confirm){
|
|
137
|
+
writeFileSync(`${homedir()}/targets/.ftppass`, JSON.stringify({}, null, 4));
|
|
138
|
+
} else {
|
|
139
|
+
throw('');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
module.exports.egnyte = async () => {
|
|
144
|
+
let inputs = await inquirer.prompt([
|
|
145
|
+
{
|
|
146
|
+
type: 'confirm',
|
|
147
|
+
name: 'confirm',
|
|
148
|
+
message: 'Would you like to populate your egnyte credentials?',
|
|
149
|
+
default: true
|
|
150
|
+
}
|
|
151
|
+
]);
|
|
152
|
+
|
|
153
|
+
if(inputs.confirm){
|
|
154
|
+
let inputs = await inquirer.prompt([
|
|
155
|
+
{
|
|
156
|
+
type: 'input',
|
|
157
|
+
name: 'username',
|
|
158
|
+
message: 'What is your egnyte username? (e.g. mmellor$fishawack)',
|
|
159
|
+
default: creds_ftppass['ftp-fishawack.egnyte.com'] && creds_ftppass['ftp-fishawack.egnyte.com'].username || null,
|
|
160
|
+
validate: input => input.trim().length > 0 || 'Username cannot be an empty string'
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
type: 'password',
|
|
164
|
+
name: 'password',
|
|
165
|
+
message: 'What is your egnyte password? (e.g. password1234)',
|
|
166
|
+
default: creds_ftppass['ftp-fishawack.egnyte.com'] && creds_ftppass['ftp-fishawack.egnyte.com'].password || null,
|
|
167
|
+
validate: input => input.trim().length > 0 || 'Password cannot be an empty string'
|
|
168
|
+
}
|
|
169
|
+
]);
|
|
170
|
+
|
|
171
|
+
let file = JSON.parse(readFileSync(`${homedir()}/targets/.ftppass`, { encoding: 'utf8' }));
|
|
172
|
+
|
|
173
|
+
creds_ftppass['ftp-fishawack.egnyte.com'] = file['ftp-fishawack.egnyte.com'] = {...inputs};
|
|
174
|
+
|
|
175
|
+
writeFileSync(`${homedir()}/targets/.ftppass`, JSON.stringify(file, null, 4));
|
|
176
|
+
} else {
|
|
177
|
+
throw('');
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
module.exports.preset = async () => {
|
|
182
|
+
let inputs = await inquirer.prompt([
|
|
183
|
+
{
|
|
184
|
+
type: 'list',
|
|
185
|
+
name: 'preset',
|
|
186
|
+
message: 'What type of developer are you?',
|
|
187
|
+
choices: [
|
|
188
|
+
'permanent',
|
|
189
|
+
'freelancer'
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
]);
|
|
193
|
+
|
|
194
|
+
return inputs.preset;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
module.exports.config = async () => {
|
|
198
|
+
let inputs = await inquirer.prompt([
|
|
199
|
+
{
|
|
200
|
+
type: 'confirm',
|
|
201
|
+
name: 'confirm',
|
|
202
|
+
message: 'Generate config file?',
|
|
203
|
+
default: true
|
|
204
|
+
}
|
|
205
|
+
]);
|
|
206
|
+
|
|
207
|
+
if(inputs.confirm){
|
|
208
|
+
writeFileSync(`${homedir()}/.ssh/config`, '');
|
|
209
|
+
} else {
|
|
210
|
+
throw('');
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
module.exports.ignore = async () => {
|
|
215
|
+
let inputs = await inquirer.prompt([
|
|
216
|
+
{
|
|
217
|
+
type: 'confirm',
|
|
218
|
+
name: 'confirm',
|
|
219
|
+
message: 'Would you like to add IgnoreUnknown to your config?',
|
|
220
|
+
default: true
|
|
221
|
+
}
|
|
222
|
+
]);
|
|
223
|
+
|
|
224
|
+
if(inputs.confirm){
|
|
225
|
+
let file = readFileSync(`${homedir()}/.ssh/config`, { encoding: 'utf8' });
|
|
226
|
+
|
|
227
|
+
file = `Host *\n\tIgnoreUnknown AddKeysToAgent,UseKeychain\n\n` + file;
|
|
228
|
+
|
|
229
|
+
writeFileSync(`${homedir()}/.ssh/config`, file);
|
|
230
|
+
} else {
|
|
231
|
+
throw('');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
module.exports.strict = async () => {
|
|
236
|
+
let inputs = await inquirer.prompt([
|
|
237
|
+
{
|
|
238
|
+
type: 'confirm',
|
|
239
|
+
name: 'confirm',
|
|
240
|
+
message: 'Would you like to add StrictHostKeyChecking to your config?',
|
|
241
|
+
default: true
|
|
242
|
+
}
|
|
243
|
+
]);
|
|
244
|
+
|
|
245
|
+
if(inputs.confirm){
|
|
246
|
+
let file = readFileSync(`${homedir()}/.ssh/config`, { encoding: 'utf8' });
|
|
247
|
+
|
|
248
|
+
file = `Host *\n\tStrictHostKeyChecking no\n\n` + file;
|
|
249
|
+
|
|
250
|
+
writeFileSync(`${homedir()}/.ssh/config`, file);
|
|
251
|
+
} else {
|
|
252
|
+
throw('');
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
module.exports.ssh = async () => {
|
|
257
|
+
let inputs = await inquirer.prompt([
|
|
258
|
+
{
|
|
259
|
+
type: 'confirm',
|
|
260
|
+
name: 'confirm',
|
|
261
|
+
message: 'Generate .ssh folder?',
|
|
262
|
+
default: true
|
|
263
|
+
}
|
|
264
|
+
]);
|
|
265
|
+
|
|
266
|
+
if(inputs.confirm){
|
|
267
|
+
mkdirSync(`${homedir()}/.ssh`);
|
|
268
|
+
} else {
|
|
269
|
+
throw('');
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
module.exports.key = async () => {
|
|
274
|
+
let inputs = await inquirer.prompt([
|
|
275
|
+
{
|
|
276
|
+
type: 'confirm',
|
|
277
|
+
name: 'confirm',
|
|
278
|
+
message: 'Generate ssh key?',
|
|
279
|
+
default: true
|
|
280
|
+
}
|
|
281
|
+
]);
|
|
282
|
+
|
|
283
|
+
if(inputs.confirm){
|
|
284
|
+
let inputs = await inquirer.prompt([
|
|
285
|
+
{
|
|
286
|
+
type: 'input',
|
|
287
|
+
name: 'email',
|
|
288
|
+
message: 'What is your fishawack email? (e.g. mike.mellor@fishawack.com)',
|
|
289
|
+
validate: input => input.trim().length > 0 || 'Email cannot be an empty string'
|
|
290
|
+
}
|
|
291
|
+
]);
|
|
292
|
+
execSync(`ssh-keygen -t rsa -C "${inputs.email}"`, {encoding: 'utf8', stdio: 'inherit'});
|
|
293
|
+
} else {
|
|
294
|
+
throw('');
|
|
295
|
+
}
|
|
296
|
+
}
|