@fishawack/lab-env 4.30.0 → 4.31.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## Changelog
2
2
 
3
+ ### 4.31.0 (2024-07-12)
4
+ * [Feature] added legacy flag for diagnosis to skip unneccessary steps
5
+ * [Feature] added -y and -p flags to diag to skip prompts
6
+ * [Bug] static sites now return a 404 when assets not found and redirect to index
7
+ * [Bug] remove obsolete version from compose files
8
+
3
9
  ### 4.30.0 (2024-07-05)
4
10
  * [Feature] added new clients
5
11
 
@@ -13,65 +13,94 @@ const { Spinner } = require('../libs/utilities');
13
13
  module.exports = [
14
14
  ['diagnose', 'diag'],
15
15
  'Check if environment is setup correctly',
16
- yargs => {},
16
+ yargs => {
17
+ yargs.option('confirm', {
18
+ alias: 'y',
19
+ describe: 'Accept all prompts automatically',
20
+ type: 'boolean'
21
+ });
22
+
23
+ yargs.option('preset', {
24
+ alias: 'p',
25
+ describe: 'Define the user preset to use'
26
+ });
27
+
28
+ yargs.option('legacy', {
29
+ alias: 'l',
30
+ describe: 'Run the legacy diagnosis steps. When omitted it will be default true for permanent users and false for everyone else',
31
+ type: "boolean"
32
+ });
33
+ },
17
34
  async argv => {
18
35
  try{
19
- let preset = await guide.preset();
36
+ let preset = await guide.preset(argv);
37
+
38
+ if(argv.l == null && preset === "permanent"){
39
+ argv.legacy = argv.l = true;
40
+ }
20
41
 
21
- while(!await test.gitconfig()){
22
- await guide.gitconfig();
23
- };
24
-
42
+ if(argv.legacy){
43
+ while(!await test.gitconfig()){
44
+ await guide.gitconfig(argv);
45
+ };
46
+ }
47
+
25
48
  while(!await test.ssh()){
26
- await guide.ssh();
49
+ await guide.ssh(argv);
27
50
  };
28
51
 
29
52
  while(!await test.key()){
30
- await guide.key();
53
+ await guide.key(argv);
31
54
  }
32
55
 
33
56
  while(!await test.config()){
34
- await guide.config();
57
+ await guide.config(argv);
35
58
  };
36
59
 
37
60
  while(!await test.ignore()){
38
- await guide.ignore();
61
+ await guide.ignore(argv);
39
62
  };
40
63
 
41
64
  while(!await test.strict()){
42
- await guide.strict();
65
+ await guide.strict(argv);
43
66
  };
44
67
 
45
68
  if(preset === "permanent" || preset === "freelancer"){
46
69
  while(!await test.targets()){
47
- await guide.targets();
70
+ await guide.targets(argv);
48
71
  }
49
72
 
50
- while(!await test.ftppass()){
51
- await guide.ftppass();
73
+ if(argv.legacy){
74
+ while(!await test.ftppass()){
75
+ await guide.ftppass(argv);
76
+ }
52
77
  }
53
78
 
54
79
  while(!await test.egnyte() || !await egnyte.check()){
55
- await guide.egnyte();
80
+ await guide.egnyte(argv);
56
81
  };
57
82
 
58
- while(!await test.watertight()){
59
- await guide.watertight();
83
+ if(argv.legacy){
84
+ while(!await test.watertight()){
85
+ await guide.watertight(argv);
86
+ }
60
87
  }
61
88
  }
62
89
 
63
90
  if(preset === "permanent"){
64
91
  while(!await test.misc()){
65
- await guide.misc();
92
+ await guide.misc(argv);
66
93
  };
67
94
 
68
95
  while(!await test.bitbucket() || !await bitbucket.check()){
69
- await guide.bitbucket();
96
+ await guide.bitbucket(argv);
70
97
  }
71
98
 
72
- if(!await guide.gitlabSkip()) {
73
- while(!await test.gitlab() || !await gitlab.check()){
74
- await guide.gitlab();
99
+ if(argv.legacy){
100
+ if(!await guide.gitlabSkip(argv)) {
101
+ while(!await test.gitlab() || !await gitlab.check()){
102
+ await guide.gitlab(argv);
103
+ }
75
104
  }
76
105
  }
77
106
 
@@ -58,6 +58,13 @@ module.exports.headers = {
58
58
  bbHeaders: encode(misc.bitbucket.username, misc.bitbucket.password)
59
59
  };
60
60
 
61
+ // User presets
62
+ module.exports.presets = [
63
+ 'permanent',
64
+ 'freelancer',
65
+ 'external'
66
+ ];
67
+
61
68
  module.exports.templates = [
62
69
  {
63
70
  "name": "boilerplate",
@@ -32,7 +32,7 @@ module.exports.createCloudFrontDistribution = async (name, account, tags = [], F
32
32
  Items: [
33
33
  {
34
34
  ErrorCachingMinTTL: 0,
35
- ErrorCode: 403,
35
+ ErrorCode: 404,
36
36
  ResponseCode: 200,
37
37
  ResponsePagePath: '/index.html'
38
38
  }
@@ -65,8 +65,14 @@ module.exports.setS3BucketPolicy = async (bucket, account, OAI) => {
65
65
  "Principal": {
66
66
  "AWS": `arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ${OAI}`
67
67
  },
68
- "Action": "s3:GetObject",
69
- "Resource": `arn:aws:s3:::${bucket}/*`
68
+ "Action": [
69
+ "s3:GetObject",
70
+ "s3:ListBucket"
71
+ ],
72
+ "Resource": [
73
+ `arn:aws:s3:::${bucket}`,
74
+ `arn:aws:s3:::${bucket}/*`
75
+ ]
70
76
  }
71
77
  ]
72
78
  })
@@ -2,11 +2,11 @@ const inquirer = require('inquirer');
2
2
  const { homedir } = require('os');
3
3
  const { mkdirSync, writeFileSync, readFileSync } = require("fs");
4
4
  const { encode } = require('../libs/utilities');
5
- const { urls, apis, misc: creds_misc, bitbucketApi, headers, ftppass: creds_ftppass, creds } = require('../libs/vars');
5
+ const { urls, apis, misc: creds_misc, bitbucketApi, headers, ftppass: creds_ftppass, creds, presets } = require('../libs/vars');
6
6
  const { execSync } = require('child_process');
7
7
 
8
- module.exports.targets = async () => {
9
- let inputs = await inquirer.prompt([
8
+ module.exports.targets = async ({ confirm }) => {
9
+ let inputs = confirm ? { confirm } : await inquirer.prompt([
10
10
  {
11
11
  type: 'confirm',
12
12
  name: 'confirm',
@@ -22,8 +22,8 @@ module.exports.targets = async () => {
22
22
  }
23
23
  }
24
24
 
25
- module.exports.misc = async () => {
26
- let inputs = await inquirer.prompt([
25
+ module.exports.misc = async ({ confirm }) => {
26
+ let inputs = confirm ? { confirm } : await inquirer.prompt([
27
27
  {
28
28
  type: 'confirm',
29
29
  name: 'confirm',
@@ -39,8 +39,8 @@ module.exports.misc = async () => {
39
39
  }
40
40
  }
41
41
 
42
- module.exports.bitbucket = async () => {
43
- let inputs = await inquirer.prompt([
42
+ module.exports.bitbucket = async ({ confirm }) => {
43
+ let inputs = confirm ? { confirm } : await inquirer.prompt([
44
44
  {
45
45
  type: 'confirm',
46
46
  name: 'confirm',
@@ -86,8 +86,8 @@ module.exports.bitbucket = async () => {
86
86
  }
87
87
  }
88
88
 
89
- module.exports.gitlab = async () => {
90
- let inputs = await inquirer.prompt([
89
+ module.exports.gitlab = async ({ confirm }) => {
90
+ let inputs = confirm ? { confirm } : await inquirer.prompt([
91
91
  {
92
92
  type: 'confirm',
93
93
  name: 'confirm',
@@ -123,8 +123,8 @@ module.exports.gitlab = async () => {
123
123
  }
124
124
  }
125
125
 
126
- module.exports.ftppass = async () => {
127
- let inputs = await inquirer.prompt([
126
+ module.exports.ftppass = async ({ confirm }) => {
127
+ let inputs = confirm ? { confirm } : await inquirer.prompt([
128
128
  {
129
129
  type: 'confirm',
130
130
  name: 'confirm',
@@ -140,8 +140,8 @@ module.exports.ftppass = async () => {
140
140
  }
141
141
  }
142
142
 
143
- module.exports.egnyte = async () => {
144
- let inputs = await inquirer.prompt([
143
+ module.exports.egnyte = async ({ confirm }) => {
144
+ let inputs = confirm ? { confirm } : await inquirer.prompt([
145
145
  {
146
146
  type: 'confirm',
147
147
  name: 'confirm',
@@ -186,25 +186,21 @@ module.exports.egnyte = async () => {
186
186
  }
187
187
  }
188
188
 
189
- module.exports.preset = async () => {
190
- let inputs = await inquirer.prompt([
189
+ module.exports.preset = async ({ preset }) => {
190
+ let inputs = preset ? { preset } : await inquirer.prompt([
191
191
  {
192
192
  type: 'list',
193
193
  name: 'preset',
194
194
  message: 'What type of developer are you?',
195
- choices: [
196
- 'permanent',
197
- 'freelancer',
198
- 'external'
199
- ]
195
+ choices: presets
200
196
  }
201
197
  ]);
202
198
 
203
199
  return inputs.preset;
204
200
  }
205
201
 
206
- module.exports.gitlabSkip = async () => {
207
- let inputs = await inquirer.prompt([
202
+ module.exports.gitlabSkip = async ({ confirm }) => {
203
+ let inputs = confirm ? { confirm } : await inquirer.prompt([
208
204
  {
209
205
  type: 'confirm',
210
206
  name: 'confirm',
@@ -216,8 +212,8 @@ module.exports.gitlabSkip = async () => {
216
212
  return !inputs.confirm;
217
213
  }
218
214
 
219
- module.exports.config = async () => {
220
- let inputs = await inquirer.prompt([
215
+ module.exports.config = async ({ confirm }) => {
216
+ let inputs = confirm ? { confirm } : await inquirer.prompt([
221
217
  {
222
218
  type: 'confirm',
223
219
  name: 'confirm',
@@ -233,8 +229,8 @@ module.exports.config = async () => {
233
229
  }
234
230
  }
235
231
 
236
- module.exports.ignore = async () => {
237
- let inputs = await inquirer.prompt([
232
+ module.exports.ignore = async ({ confirm }) => {
233
+ let inputs = confirm ? { confirm } : await inquirer.prompt([
238
234
  {
239
235
  type: 'confirm',
240
236
  name: 'confirm',
@@ -254,8 +250,8 @@ module.exports.ignore = async () => {
254
250
  }
255
251
  }
256
252
 
257
- module.exports.strict = async () => {
258
- let inputs = await inquirer.prompt([
253
+ module.exports.strict = async ({ confirm }) => {
254
+ let inputs = confirm ? { confirm } : await inquirer.prompt([
259
255
  {
260
256
  type: 'confirm',
261
257
  name: 'confirm',
@@ -275,8 +271,8 @@ module.exports.strict = async () => {
275
271
  }
276
272
  }
277
273
 
278
- module.exports.ssh = async () => {
279
- let inputs = await inquirer.prompt([
274
+ module.exports.ssh = async ({ confirm }) => {
275
+ let inputs = confirm ? { confirm } : await inquirer.prompt([
280
276
  {
281
277
  type: 'confirm',
282
278
  name: 'confirm',
@@ -292,8 +288,8 @@ module.exports.ssh = async () => {
292
288
  }
293
289
  }
294
290
 
295
- module.exports.key = async () => {
296
- let inputs = await inquirer.prompt([
291
+ module.exports.key = async ({ confirm }) => {
292
+ let inputs = confirm ? { confirm } : await inquirer.prompt([
297
293
  {
298
294
  type: 'confirm',
299
295
  name: 'confirm',
@@ -317,8 +313,8 @@ module.exports.key = async () => {
317
313
  }
318
314
  }
319
315
 
320
- module.exports.watertight = async () => {
321
- let inputs = await inquirer.prompt([
316
+ module.exports.watertight = async ({ confirm }) => {
317
+ let inputs = confirm ? { confirm } : await inquirer.prompt([
322
318
  {
323
319
  type: 'confirm',
324
320
  name: 'confirm',
@@ -333,8 +329,8 @@ module.exports.watertight = async () => {
333
329
  }
334
330
  }
335
331
 
336
- module.exports.gitconfig = async () => {
337
- let inputs = await inquirer.prompt([
332
+ module.exports.gitconfig = async ({ confirm }) => {
333
+ let inputs = confirm ? { confirm } : await inquirer.prompt([
338
334
  {
339
335
  type: 'confirm',
340
336
  name: 'confirm',
@@ -1,4 +1,3 @@
1
- version: "3.8"
2
1
  services:
3
2
  core:
4
3
  platform: linux/amd64
@@ -1,4 +1,3 @@
1
- version: "3.8"
2
1
  services:
3
2
  core:
4
3
  build:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishawack/lab-env",
3
- "version": "4.30.0",
3
+ "version": "4.31.0",
4
4
  "description": "Docker manager for FW",
5
5
  "main": "cli.js",
6
6
  "scripts": {