@fishawack/lab-env 1.18.1 → 2.0.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,10 @@
1
1
  ## Changelog
2
2
 
3
+ ### 2.0.0 (2022-04-05)
4
+ * [Feature] Craftcms now an option in `fw new` command
5
+ * [Change] Wordpress repos now works differently and will flag unsupported unless they change their folder structure - see [migration guide](https://demo.fishawack.solutions/Lab/Doc/#lab-env-migrating-200)
6
+ * [Docs] Wordpress migration guide
7
+
3
8
  ### 1.18.1 (2022-03-30)
4
9
  * [Bug] Craftcms now correctly calls reinstall and deploy commands
5
10
 
package/README.md CHANGED
@@ -195,3 +195,300 @@ Or you can target specific node_modules and hand pick which ones to remove. For
195
195
  ```bash
196
196
  docker volume rm boilerplate_node_modules
197
197
  ```
198
+
199
+ ## Migrating
200
+
201
+ ### 2.0.0
202
+
203
+ Wordpress repo's are now structured slightly differently to better match laravel, drupal and craftcms setups. Follow these steps to upgrade a wordpress build and get lab-env working again.
204
+
205
+ #### Reset repository
206
+
207
+ Before starting this migration ensure all code is committed so you don't run the risk of losing anything afterwhich run one of the following.
208
+
209
+ ```bash
210
+ fw nuke
211
+
212
+ # or
213
+
214
+ Remove / Re-clone repository
215
+ ```
216
+
217
+ #### wp-content
218
+
219
+ Move the plugins, themes and uploads folder a new wp-content folder at the root of the project.
220
+
221
+ ```bash
222
+ # Old way
223
+ ./themes
224
+ ./plugins
225
+ ./uploads
226
+
227
+ # New way
228
+ ./wp-content/themes
229
+ ./wp-content/plugins
230
+ ./wp-content/uploads
231
+ ```
232
+
233
+ #### .env.example
234
+
235
+ Replace the contents of the .env.example with the following.
236
+
237
+ ```bash
238
+ # Old way
239
+ DB_DATABASE=wordpress
240
+ DB_USERNAME=wordpress
241
+ DB_PASSWORD=password
242
+ JWT_SECRET=
243
+
244
+ # New way
245
+ DEBUG=true
246
+
247
+ DB_DATABASE=wordpress
248
+ DB_USERNAME=wordpress
249
+ DB_PASSWORD=password
250
+ DB_HOST=mysql
251
+ DB_CHARSET=utf8
252
+ DB_COLLATE=
253
+
254
+ TABLE_PREFIX=wp_
255
+
256
+ AUTH_KEY=5c94a709b751faeed445f29b92f8513b8bce1652
257
+ SECURE_AUTH=09e370e7bfc34b17fc96d80cda1a281427053afd
258
+ LOGGED_IN=405de7e577398c86b6975fc4a8bba1df179666dd
259
+ NONCE_KEY=10c232cb86bb257af4c0434a7e3b9f993f18ba11
260
+ AUTH_SALT=07a08cb5a6c3318633c505fcf1ffffa4d01ab375
261
+ SECURE_AUTH=df11e32128f8d5403a7c681d0e5cc4145be2b2ab
262
+ LOGGED_IN=a99860e8150b15e11caada875f56421165659a7d
263
+ NONCE_SALT=51c6eba59477027e612fc13e38a53acaa2b73d92
264
+
265
+ CONFIG_EXTRA="
266
+ define( 'WP_HOME', 'http://localhost:3000' );
267
+ define( 'WP_SITEURL', 'http://localhost:3000' );
268
+ "
269
+ ```
270
+
271
+ #### .gitignore
272
+
273
+ There's a new more complex gitignore now that takes into account the wordpress files that are reverse mounted back to the host machine.
274
+
275
+ ```bash
276
+ # Old way
277
+ # These are some examples of commonly ignored file patterns.
278
+ # You should customize this list as applicable to your project.
279
+ # Learn more about .gitignore:
280
+ # https://www.atlassian.com/git/tutorials/saving-changes/gitignore
281
+
282
+ # Node artifact files
283
+ node_modules/
284
+ dist/
285
+
286
+ # Compiled Java class files
287
+ *.class
288
+
289
+ # Compiled Python bytecode
290
+ *.py[cod]
291
+
292
+ # Log files
293
+ *.log
294
+
295
+ # Package files
296
+ *.jar
297
+
298
+ # Maven
299
+ target/
300
+ dist/
301
+
302
+ # JetBrains IDE
303
+ .idea/
304
+
305
+ # Unit test reports
306
+ TEST*.xml
307
+
308
+ # Generated by MacOS
309
+ .DS_Store
310
+
311
+ # Generated by Windows
312
+ Thumbs.db
313
+
314
+ # Applications
315
+ *.app
316
+ *.exe
317
+ *.war
318
+
319
+ # Large media files
320
+ *.mp4
321
+ *.tiff
322
+ *.avi
323
+ *.flv
324
+ *.mov
325
+ *.wmv
326
+ .env
327
+
328
+
329
+ .tmp/
330
+ generated/
331
+ _Zips/
332
+ _Pdfs/
333
+ coverage/
334
+ **/generated/**/*
335
+ _Build/**/pulled/**/*
336
+ _Output
337
+ _Login
338
+ _Packages
339
+ _Build/content
340
+ _Build/media/content
341
+ _App
342
+ _Electron
343
+ _Node/stats
344
+ ssh-*
345
+ .ftppass
346
+ id_rsa
347
+ misc.json
348
+ .cache/
349
+ themes/twenty*
350
+ themes/thirty*
351
+ themes/*/css
352
+ themes/*/js
353
+ plugins/akismet
354
+ plugins/hello.php
355
+ uploads
356
+
357
+ # New way
358
+ # These are some examples of commonly ignored file patterns.
359
+ # You should customize this list as applicable to your project.
360
+ # Learn more about .gitignore:
361
+ # https://www.atlassian.com/git/tutorials/saving-changes/gitignore
362
+
363
+ # Node artifact files
364
+ node_modules/
365
+ dist/
366
+
367
+ # Compiled Java class files
368
+ *.class
369
+
370
+ # Compiled Python bytecode
371
+ *.py[cod]
372
+
373
+ # Log files
374
+ *.log
375
+
376
+ # Package files
377
+ *.jar
378
+
379
+ # Maven
380
+ target/
381
+ dist/
382
+
383
+ # JetBrains IDE
384
+ .idea/
385
+
386
+ # Unit test reports
387
+ TEST*.xml
388
+
389
+ # Generated by Windows
390
+ Thumbs.db
391
+
392
+ # Applications
393
+ *.app
394
+ *.exe
395
+ *.war
396
+
397
+ # Large media files
398
+ *.mp4
399
+ *.tiff
400
+ *.avi
401
+ *.flv
402
+ *.mov
403
+ *.wmv
404
+ .env
405
+
406
+ .tmp/
407
+ generated/
408
+ _Zips/
409
+ _Pdfs/
410
+ coverage/
411
+ **/generated/**/*
412
+ _Build/**/pulled/**/*
413
+ _Output
414
+ _Login
415
+ _Packages
416
+ _Build/content
417
+ _Build/media/content
418
+ _App
419
+ _Electron
420
+ _Node/stats
421
+ ssh-*
422
+ .ftppass
423
+ id_rsa
424
+ misc.json
425
+ .cache/
426
+
427
+ # Wordpress docker image files
428
+ .htaccess
429
+ license.txt
430
+ readme.html
431
+ index.php
432
+ xmlrpc.php
433
+ wp-*
434
+ !wp-content**/*
435
+ wp-content/index.php
436
+ wp-content/plugins/index.php
437
+ wp-content/themes/index.php
438
+ wp-content/themes/twenty*
439
+ wp-content/themes/thirty*
440
+ wp-content/themes/fishawack/css
441
+ wp-content/themes/fishawack/js
442
+ wp-content/plugins/akismet
443
+ wp-content/plugins/hello.php
444
+ wp-content/uploads
445
+
446
+ # Generated by MacOS
447
+ .DS_Store
448
+ ```
449
+
450
+ #### Default theme location
451
+
452
+ The default root attribute needs updating to take into account the new folder structure.
453
+
454
+ ```json
455
+ // Old way
456
+ "attributes": {
457
+ "root": "themes/fishawack",
458
+ }
459
+
460
+ // New way
461
+ "attributes": {
462
+ "root": "wp-content/themes/fishawack",
463
+ }
464
+ ```
465
+
466
+ #### Deploy files
467
+
468
+ The deploy paths also need updating to take into account the new folder structure.
469
+
470
+ ```json
471
+ // Old way
472
+ "paths": [
473
+ {
474
+ "src": "plugins",
475
+ "dest": "wp-content/plugins"
476
+ },
477
+ {
478
+ "src": "themes",
479
+ "dest": "wp-content/themes"
480
+ }
481
+ ]
482
+
483
+ // New way
484
+ "paths": [
485
+ {
486
+ "src": "wp-content/plugins",
487
+ "dest": "wp-content/plugins"
488
+ },
489
+ {
490
+ "src": "wp-content/themes",
491
+ "dest": "wp-content/themes"
492
+ }
493
+ ]
494
+ ```
package/cli.js CHANGED
@@ -45,6 +45,10 @@ if(!_.services && !(args[0] === 'origin' || args[0] === '--version')) return;
45
45
  commands.push('drush');
46
46
  }
47
47
 
48
+ if(_.platform === "wordpress"){
49
+ commands.push('wp');
50
+ }
51
+
48
52
  if(_.platform === "laravel" || _.platform === "drupal" || _.platform === "craftcms"){
49
53
  commands.push('composer', 'php');
50
54
  }
@@ -66,6 +66,10 @@ module.exports.templates = [
66
66
  "name": "boilerplate-drupal",
67
67
  "type": "boilerplate"
68
68
  },
69
+ {
70
+ "name": "boilerplate-craftcms",
71
+ "type": "boilerplate"
72
+ },
69
73
  {
70
74
  "name": "sprinkle-base",
71
75
  "type": "framework",
package/commands/wp.js ADDED
@@ -0,0 +1,15 @@
1
+ const _ = require('../globals.js');
2
+
3
+ const execSync = require('child_process').execSync;
4
+
5
+ module.exports = [
6
+ ['wp [command...]', 'wordpress'],
7
+ 'run wp-cli command',
8
+ yargs => {
9
+ yargs.positional('command', {
10
+ describe: 'command to run',
11
+ default: ''
12
+ });
13
+ },
14
+ argv => _.up(() => execSync(`${_.docker} ${_.exec} wordpress bash -lc "wp ${argv.command.join(' ')} --allow-root"`, _.opts))
15
+ ];
package/globals.js CHANGED
@@ -3,6 +3,7 @@ const path = require('path');
3
3
  const { lstatSync, readdirSync, copyFileSync, existsSync } = require('fs');
4
4
  const semver = require('semver');
5
5
  const getPort = require('get-port');
6
+ const utilities = require('./commands/create/libs/utilities');
6
7
 
7
8
  process.env.DIRNAME = __dirname;
8
9
 
@@ -31,7 +32,7 @@ try{ pkg = require(path.join(process.cwd(), 'package.json')); } catch(e){}
31
32
 
32
33
  try{ composer = require(path.join(process.cwd(), 'composer.json')); } catch(e){}
33
34
 
34
- try{ wordpress = existsSync(path.join(process.cwd(), 'themes/')); } catch(e){}
35
+ try{ wordpress = existsSync(path.join(process.cwd(), 'wp-content/')); } catch(e){}
35
36
 
36
37
  if(composer && composer.require && composer.require['laravel/framework']){
37
38
  platform = 'laravel';
@@ -42,6 +43,14 @@ if(composer && composer.require && composer.require['laravel/framework']){
42
43
  } else if(wordpress) {
43
44
  platform = 'wordpress';
44
45
  } else {
46
+ // Check for old wordpress repo stucture and show warning
47
+ try{
48
+ if(existsSync(path.join(process.cwd(), 'themes/'))){
49
+ console.log(`This wordpress repo needs migrating to the new repo structure: \n${utilities.colorize(`https://demo.fishawack.solutions/Lab/Doc/#lab-env-migrating-200`, 'title')}`)
50
+ process.exit(1);
51
+ }
52
+ } catch(e){}
53
+
45
54
  platform = 'core';
46
55
  }
47
56
 
package/intercept.sh CHANGED
@@ -20,6 +20,10 @@ craft(){
20
20
  command lab-env craft "$@"
21
21
  }
22
22
 
23
+ wp(){
24
+ command lab-env wp "$@"
25
+ }
26
+
23
27
  php(){
24
28
  command lab-env php "$@"
25
29
  }
@@ -41,6 +45,7 @@ export -f composer;
41
45
  export -f drush;
42
46
  export -f artisan;
43
47
  export -f craft;
48
+ export -f wp;
44
49
  export -f php;
45
50
  export -f chown;
46
51
  export -f chmod;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishawack/lab-env",
3
- "version": "1.18.1",
3
+ "version": "2.0.0",
4
4
  "description": "Docker manager for FW",
5
5
  "main": "cli.js",
6
6
  "scripts": {
@@ -13,22 +13,32 @@ services:
13
13
  volumes:
14
14
  - mysql:/var/lib/mysql
15
15
  wordpress:
16
- image: wordpress:5.7.2
16
+ build:
17
+ context: ./wordpress/
18
+ dockerfile: Dockerfile
19
+ image: lab-env/wordpress/5.7.2/wordpress:0.0.1
17
20
  networks:
18
21
  - default
19
22
  environment:
20
- WORDPRESS_DB_HOST: mysql
23
+ WORDPRESS_DB_NAME: ${DB_DATABASE}
21
24
  WORDPRESS_DB_USER: ${DB_USERNAME}
22
25
  WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
23
- WORDPRESS_DB_NAME: ${DB_DATABASE}
24
- WORDPRESS_CONFIG_EXTRA: |
25
- define('JWT_AUTH_SECRET_KEY', '${JWT_SECRET}');
26
- define('JWT_AUTH_CORS_ENABLE',true);
27
- define('WP_DEBUG',true);
26
+ WORDPRESS_DB_HOST: ${DB_HOST}
27
+ WORDPRESS_DB_CHARSET: ${DB_CHARSET}
28
+ WORDPRESS_DB_COLLATE: ${DB_COLLATE}
29
+ WORDPRESS_AUTH_KEY: ${AUTH_KEY}
30
+ WORDPRESS_SECURE_AUTH: ${SECURE_AUTH}
31
+ WORDPRESS_LOGGED_IN: ${LOGGED_IN}
32
+ WORDPRESS_NONCE_KEY: ${NONCE_KEY}
33
+ WORDPRESS_AUTH_SALT: ${AUTH_SALT}
34
+ WORDPRESS_SECURE_AUTH: ${SECURE_AUTH}
35
+ WORDPRESS_LOGGED_IN: ${LOGGED_IN}
36
+ WORDPRESS_NONCE_SALT: ${NONCE_SALT}
37
+ WORDPRESS_TABLE_PREFIX: ${TABLE_PREFIX}
38
+ WORDPRESS_DEBUG: ${DEBUG}
39
+ WORDPRESS_CONFIG_EXTRA: ${CONFIG_EXTRA}
28
40
  volumes:
29
- - $CWD/themes:/var/www/html/wp-content/themes
30
- - $CWD/plugins:/var/www/html/wp-content/plugins
31
- - $CWD/uploads:/var/www/html/wp-content/uploads
41
+ - $CWD/:/var/www/html
32
42
  - ./apache/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
33
43
  - ./apache/.htaccess:/var/www/html/.htaccess
34
44
  ports:
@@ -0,0 +1,16 @@
1
+ FROM wordpress:5.7.2
2
+
3
+ MAINTAINER Mike Mellor
4
+
5
+ # Install mysql client
6
+ RUN apt-get update && \
7
+ apt-get install -y mariadb-client
8
+
9
+ # Install wordpress cli
10
+ RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
11
+ chmod +x wp-cli.phar && \
12
+ mv wp-cli.phar /usr/local/bin/wp
13
+
14
+ # Cleanup apt-get install folders
15
+ RUN apt-get clean && \
16
+ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*