@scandipwa/magento-scripts 1.16.1 → 2.0.0-alpha.2

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.
Files changed (226) hide show
  1. package/lib/commands/cli.js +4 -6
  2. package/lib/commands/execute.js +29 -4
  3. package/lib/commands/import-db.js +1 -1
  4. package/lib/commands/logs.js +1 -1
  5. package/lib/commands/start.js +38 -20
  6. package/lib/commands/status.js +2 -0
  7. package/lib/config/docker.js +102 -84
  8. package/lib/config/get-project-configuration.js +3 -1
  9. package/lib/config/index.js +10 -7
  10. package/lib/config/magento/required-php-extensions/index.js +29 -0
  11. package/lib/config/magento/required-php-extensions/magento-2.3.js +19 -0
  12. package/lib/config/magento/required-php-extensions/magento-2.4.js +29 -0
  13. package/lib/config/php/base-repo.js +3 -0
  14. package/lib/config/php/extensions/apcu.js +12 -0
  15. package/lib/config/php/extensions/bcmath.js +7 -0
  16. package/lib/config/php/extensions/curl.js +11 -0
  17. package/lib/config/php/extensions/gd.js +14 -0
  18. package/lib/config/php/extensions/index.js +18 -2
  19. package/lib/config/php/extensions/intl.js +10 -0
  20. package/lib/config/php/extensions/opcache.js +10 -0
  21. package/lib/config/php/extensions/pdo_mysql.js +7 -0
  22. package/lib/config/php/extensions/soap.js +10 -0
  23. package/lib/config/php/extensions/sodium.js +10 -0
  24. package/lib/config/php/extensions/xdebug.js +8 -5
  25. package/lib/config/php/extensions/xsl.js +10 -0
  26. package/lib/config/php/extensions/zip.js +10 -0
  27. package/lib/config/php/{releases → versions}/index.js +0 -0
  28. package/lib/config/php/versions/php-7.2.js +23 -0
  29. package/lib/config/php/versions/php-7.3.js +23 -0
  30. package/lib/config/php/versions/php-7.4.js +23 -0
  31. package/lib/config/php/versions/php-8.1.js +23 -0
  32. package/lib/config/php-config.js +8 -12
  33. package/lib/config/port-config.js +2 -6
  34. package/lib/config/services/elasticsearch/base-repo.js +3 -0
  35. package/lib/config/services/elasticsearch/default-es-env.js +6 -0
  36. package/lib/config/services/elasticsearch/versions/elasticsearch-6.8.js +19 -0
  37. package/lib/config/services/elasticsearch/versions/index.js +5 -0
  38. package/lib/config/templates/magentorc.template +5 -5
  39. package/lib/config/templates/mariadb.template.cnf +191 -0
  40. package/lib/config/templates/php-fpm.template.conf +3 -3
  41. package/lib/config/templates/php.template.ini +12 -6
  42. package/lib/config/templates/ssl-terminator.template.conf +1 -1
  43. package/lib/config/templates/vscode-launch.template.json +3 -1
  44. package/lib/config/versions/magento-2.3.0.js +10 -5
  45. package/lib/config/versions/magento-2.3.1.js +10 -5
  46. package/lib/config/versions/magento-2.3.2-p1.js +43 -0
  47. package/lib/config/versions/magento-2.3.2-p2.js +10 -5
  48. package/lib/config/versions/magento-2.3.2.js +10 -5
  49. package/lib/config/versions/magento-2.3.3-p1.js +10 -5
  50. package/lib/config/versions/magento-2.3.3.js +10 -5
  51. package/lib/config/versions/magento-2.3.4-p1.js +43 -0
  52. package/lib/config/versions/magento-2.3.4-p2.js +10 -5
  53. package/lib/config/versions/magento-2.3.4.js +10 -5
  54. package/lib/config/versions/magento-2.3.5-p1.js +8 -2
  55. package/lib/config/versions/magento-2.3.5-p2.js +8 -2
  56. package/lib/config/versions/magento-2.3.5.js +8 -2
  57. package/lib/config/versions/magento-2.3.6-p1.js +8 -2
  58. package/lib/config/versions/magento-2.3.6.js +8 -2
  59. package/lib/config/versions/magento-2.3.7-p1.js +8 -2
  60. package/lib/config/versions/magento-2.3.7-p2.js +8 -2
  61. package/lib/config/versions/magento-2.3.7-p3.js +8 -2
  62. package/lib/config/versions/magento-2.3.7.js +8 -2
  63. package/lib/config/versions/magento-2.4.0-p1.js +9 -3
  64. package/lib/config/versions/magento-2.4.0.js +9 -3
  65. package/lib/config/versions/magento-2.4.1-p1.js +6 -5
  66. package/lib/config/versions/magento-2.4.1.js +9 -2
  67. package/lib/config/versions/magento-2.4.2-p1.js +6 -5
  68. package/lib/config/versions/magento-2.4.2-p2.js +6 -6
  69. package/lib/config/versions/magento-2.4.2.js +6 -6
  70. package/lib/config/versions/magento-2.4.3-p1.js +7 -7
  71. package/lib/config/versions/magento-2.4.3-p2.js +7 -7
  72. package/lib/config/versions/magento-2.4.3.js +7 -7
  73. package/lib/config/versions/magento-2.4.4.js +9 -2
  74. package/lib/tasks/cleanup.js +3 -3
  75. package/lib/tasks/composer/index.js +14 -104
  76. package/lib/tasks/database/connect-to-database.js +117 -0
  77. package/lib/tasks/database/create-magento-database.js +18 -0
  78. package/lib/tasks/{mysql → database}/dump-theme-config.js +3 -3
  79. package/lib/tasks/{mysql → database}/fix-db.js +2 -2
  80. package/lib/tasks/{mysql/import-dump-to-mysql.js → database/import-dump-to-database.js} +65 -22
  81. package/lib/tasks/{mysql → database}/import-remote-db/index.js +0 -0
  82. package/lib/tasks/{mysql/import-remote-db/ssh/mysqldump-command.js → database/import-remote-db/ssh/database-dump-command.js} +2 -2
  83. package/lib/tasks/{mysql → database}/import-remote-db/ssh/index.js +0 -0
  84. package/lib/tasks/{mysql → database}/import-remote-db/ssh/readymage.js +4 -4
  85. package/lib/tasks/{mysql → database}/import-remote-db/ssh/regular-server.js +2 -2
  86. package/lib/tasks/{mysql → database}/index.js +2 -2
  87. package/lib/tasks/{mysql → database}/magento-tables.js +0 -0
  88. package/lib/tasks/{mysql → database}/restore-theme-config.js +4 -4
  89. package/lib/tasks/docker/api.d.ts +71 -0
  90. package/lib/tasks/docker/api.js +30 -0
  91. package/lib/tasks/docker/containers/container-api.d.ts +128 -0
  92. package/lib/tasks/docker/containers/container-api.js +153 -0
  93. package/lib/tasks/docker/containers/index.js +19 -0
  94. package/lib/tasks/docker/containers/tasks.js +215 -0
  95. package/lib/tasks/docker/convert-legacy-volumes.js +15 -10
  96. package/lib/tasks/docker/convert-mysql-to-mariadb.js +284 -0
  97. package/lib/tasks/docker/image/image-api.d.ts +34 -0
  98. package/lib/tasks/docker/image/image-api.js +49 -0
  99. package/lib/tasks/docker/image/index.js +5 -0
  100. package/lib/tasks/docker/index.js +1 -13
  101. package/lib/tasks/docker/network/index.js +7 -0
  102. package/lib/tasks/docker/network/network-api.d.ts +103 -0
  103. package/lib/tasks/docker/network/network-api.js +99 -0
  104. package/lib/tasks/docker/{network.js → network/tasks.js} +17 -10
  105. package/lib/tasks/docker/project-image-builder.js +167 -0
  106. package/lib/tasks/docker/volume/index.js +8 -0
  107. package/lib/tasks/docker/{volumes.js → volume/tasks.js} +5 -19
  108. package/lib/tasks/docker/volume/volume-api.d.ts +39 -0
  109. package/lib/tasks/docker/volume/volume-api.js +66 -0
  110. package/lib/tasks/execute/index.js +5 -2
  111. package/lib/tasks/file-system/create-mariadb-config.js +23 -0
  112. package/lib/tasks/file-system/create-nginx-config.js +2 -3
  113. package/lib/tasks/file-system/create-php-config.js +20 -5
  114. package/lib/tasks/file-system/create-php-fpm-config.js +8 -4
  115. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +41 -29
  116. package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -0
  117. package/lib/tasks/file-system/create-phpstorm-config/keys.js +15 -1
  118. package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +4 -1
  119. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-config.js +3 -3
  120. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-interpreters-config.js +81 -0
  121. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/index.js +42 -0
  122. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/php-docker-settings-config.js +9 -0
  123. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/setup-php-docker-container-settings-config.js +66 -0
  124. package/lib/tasks/file-system/create-phpstorm-config/setup-xml-structure.js +11 -9
  125. package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +2 -1
  126. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +15 -30
  127. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +24 -5
  128. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/mess-detector-project-configuration-config.js +50 -0
  129. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-code-sniffer-project-configuration-config.js +50 -0
  130. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-cs-fixer-project-configuration-config.js +50 -0
  131. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +15 -15
  132. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +29 -3
  133. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-stan-project-configuration-config.js.js +50 -0
  134. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +42 -0
  135. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/psalm-project-configuration-config.js.js +50 -0
  136. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/workspace-config.js +0 -2
  137. package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -2
  138. package/lib/tasks/file-system/create-vscode-config.js +57 -42
  139. package/lib/tasks/file-system/index.js +5 -2
  140. package/lib/tasks/import-dump.js +6 -6
  141. package/lib/tasks/link.js +5 -4
  142. package/lib/tasks/magento/install-magento-project.js +31 -63
  143. package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +4 -4
  144. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +7 -3
  145. package/lib/tasks/magento/setup-magento/create-admin.js +5 -6
  146. package/lib/tasks/magento/setup-magento/delete-admin-users.js +2 -2
  147. package/lib/tasks/magento/setup-magento/delete-customers.js +4 -4
  148. package/lib/tasks/magento/setup-magento/delete-orders.js +4 -4
  149. package/lib/tasks/magento/setup-magento/disable-2fa.js +3 -5
  150. package/lib/tasks/magento/setup-magento/disable-maintenance-mode.js +3 -4
  151. package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +2 -2
  152. package/lib/tasks/magento/setup-magento/index.js +2 -0
  153. package/lib/tasks/magento/setup-magento/install-magento.js +21 -20
  154. package/lib/tasks/magento/setup-magento/migrate-database.js +7 -14
  155. package/lib/tasks/magento/setup-magento/set-base-url.js +2 -2
  156. package/lib/tasks/magento/setup-magento/set-deployment-mode.js +4 -4
  157. package/lib/tasks/magento/setup-magento/set-url-rewrite.js +2 -2
  158. package/lib/tasks/magento/setup-magento/varnish-config.js +10 -8
  159. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +128 -3
  160. package/lib/tasks/php/php-container.js +108 -0
  161. package/lib/tasks/php/update-env-php.js +39 -21
  162. package/lib/tasks/php/update-env.php +66 -61
  163. package/lib/tasks/php/working_health_check.php +85 -0
  164. package/lib/tasks/requirements/{composer.js → composer-credentials.js} +3 -1
  165. package/lib/tasks/requirements/docker/index.js +15 -12
  166. package/lib/tasks/requirements/docker/performance.js +54 -0
  167. package/lib/tasks/requirements/docker/version.js +8 -8
  168. package/lib/tasks/requirements/index.js +5 -8
  169. package/lib/tasks/requirements/php-version.js +8 -116
  170. package/lib/tasks/requirements/platform.js +12 -25
  171. package/lib/tasks/start.js +21 -50
  172. package/lib/tasks/status/index.js +8 -12
  173. package/lib/tasks/stop.js +0 -2
  174. package/lib/tasks/theme/install-theme.js +1 -1
  175. package/lib/tasks/theme/link-theme.js +2 -2
  176. package/lib/tasks/theme/symlink-theme.js +2 -3
  177. package/lib/util/config-file-validator.js +27 -13
  178. package/lib/util/config-php-json.js +13 -4
  179. package/lib/util/database.js +7 -7
  180. package/lib/util/dockerfile-builder/build-instructions.js +197 -0
  181. package/lib/util/dockerfile-builder/index.js +276 -0
  182. package/lib/util/dockerfile-builder/types.d.ts +123 -0
  183. package/lib/util/env-php-json.js +10 -6
  184. package/lib/util/exec-async-command.js +3 -9
  185. package/lib/util/macos-version.js +20 -0
  186. package/lib/util/magento-task.js +3 -4
  187. package/lib/util/nginx-logs-parser.js +122 -0
  188. package/lib/util/php-task.js +3 -6
  189. package/lib/util/run-composer.js +6 -14
  190. package/lib/util/run-container-image.js +17 -0
  191. package/lib/util/run-magento.js +6 -14
  192. package/lib/util/run-php.js +6 -17
  193. package/package.json +9 -9
  194. package/typings/context.d.ts +7 -13
  195. package/typings/index.d.ts +67 -85
  196. package/yarn-error.log +9660 -0
  197. package/lib/config/composer.js +0 -11
  198. package/lib/config/php/extensions/libsodium.js +0 -36
  199. package/lib/config/php/releases/php-7.2.js +0 -25
  200. package/lib/config/php/releases/php-7.3.js +0 -25
  201. package/lib/config/php/releases/php-7.4.js +0 -23
  202. package/lib/config/php/releases/php-8.1.js +0 -25
  203. package/lib/config/phpbrew.js +0 -12
  204. package/lib/tasks/composer/install-prestissimo.js +0 -103
  205. package/lib/tasks/docker/containers.js +0 -231
  206. package/lib/tasks/mysql/connect-to-mysql.js +0 -114
  207. package/lib/tasks/mysql/create-magento-database.js +0 -18
  208. package/lib/tasks/php/bundled-extensions.js +0 -27
  209. package/lib/tasks/php/compile-options.js +0 -56
  210. package/lib/tasks/php/compile.js +0 -55
  211. package/lib/tasks/php/configure.js +0 -89
  212. package/lib/tasks/php/extensions/disable.js +0 -49
  213. package/lib/tasks/php/extensions/enable.js +0 -52
  214. package/lib/tasks/php/extensions/index.js +0 -80
  215. package/lib/tasks/php/extensions/install.js +0 -54
  216. package/lib/tasks/php/index.js +0 -79
  217. package/lib/tasks/php/install-sodium.js +0 -93
  218. package/lib/tasks/php/update-phpbrew.js +0 -45
  219. package/lib/tasks/php/validate-php.js +0 -67
  220. package/lib/tasks/php-fpm/get-process-id.js +0 -14
  221. package/lib/tasks/php-fpm/index.js +0 -4
  222. package/lib/tasks/php-fpm/start-php-fpm.js +0 -49
  223. package/lib/tasks/php-fpm/stop-php-fpm.js +0 -48
  224. package/lib/tasks/requirements/phpbrew/index.js +0 -61
  225. package/lib/tasks/requirements/phpbrew/install.js +0 -159
  226. package/lib/tasks/requirements/phpbrew/version.js +0 -28
@@ -5,9 +5,9 @@ const getMagentoVersionConfig = require('../config/get-magento-version-config');
5
5
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
6
6
  const getProjectConfiguration = require('../config/get-project-configuration');
7
7
  const checkConfigurationFile = require('../config/check-configuration-file');
8
- const { installComposer, installPrestissimo } = require('../tasks/composer');
8
+ // const { installComposer, installPrestissimo } = require('../tasks/composer');
9
9
  const ConsoleBlock = require('../util/console-block');
10
- const checkComposerCredentials = require('../tasks/requirements/composer');
10
+ const { checkComposerCredentials } = require('../tasks/requirements/composer-credentials');
11
11
 
12
12
  /**
13
13
  * @param {import('yargs')} yargs
@@ -18,8 +18,6 @@ module.exports = (yargs) => {
18
18
  getMagentoVersionConfig(),
19
19
  checkConfigurationFile(),
20
20
  getProjectConfiguration(),
21
- installComposer(),
22
- installPrestissimo(),
23
21
  createBashrcConfigFile(),
24
22
  checkComposerCredentials()
25
23
  ], {
@@ -63,8 +61,8 @@ module.exports = (yargs) => {
63
61
  .addEmptyLine();
64
62
 
65
63
  block
66
- .addLine(`Connect to MySQL server: ${logger.style.command('mysql')}`)
67
- .addLine(`Connect to MySQL server as root: ${logger.style.command('mysqlroot')}`)
64
+ .addLine(`Connect to MariaDB server: ${logger.style.command('mariadb')}`)
65
+ .addLine(`Connect to MariaDB server as root: ${logger.style.command('mariadbroot')}`)
68
66
  .addEmptyLine();
69
67
 
70
68
  block.log();
@@ -1,6 +1,11 @@
1
1
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
2
- const { docker } = require('../config');
2
+ const { Listr } = require('listr2');
3
+ const checkConfigurationFile = require('../config/check-configuration-file');
4
+ const getProjectConfiguration = require('../config/get-project-configuration');
3
5
  const executeInContainer = require('../tasks/execute');
6
+ const getMagentoVersionConfig = require('../config/get-magento-version-config');
7
+ const { checkRequirements } = require('../tasks/requirements');
8
+ const { getCachedPorts } = require('../config/get-port-config');
4
9
 
5
10
  /**
6
11
  * @param {import('yargs')} yargs
@@ -13,7 +18,7 @@ module.exports = (yargs) => {
13
18
  yargs.usage(`Usage: npm run exec <container name> [commands...]
14
19
 
15
20
  Available containers:
16
- - mysql
21
+ - mariadb
17
22
  - nginx
18
23
  - redis
19
24
  - elasticsearch
@@ -21,7 +26,27 @@ Available containers:
21
26
  - sslTerminator`);
22
27
  },
23
28
  async (argv) => {
24
- const containers = (await docker).getContainers();
29
+ const tasks = new Listr([
30
+ checkRequirements(),
31
+ getMagentoVersionConfig(),
32
+ checkConfigurationFile(),
33
+ getProjectConfiguration(),
34
+ getCachedPorts()
35
+ ], {
36
+ concurrent: false,
37
+ exitOnError: true,
38
+ ctx: { throwMagentoVersionMissing: true },
39
+ rendererOptions: { collapse: false, clearOutput: true }
40
+ });
41
+
42
+ let ctx;
43
+ try {
44
+ ctx = await tasks.run();
45
+ } catch (e) {
46
+ logger.error(e.message || e);
47
+ process.exit(1);
48
+ }
49
+ const containers = ctx.config.docker.getContainers(ctx.ports);
25
50
  const services = Object.keys(containers);
26
51
 
27
52
  if (services.includes(argv.containername) || services.some((service) => service.includes(argv.containername))) {
@@ -40,7 +65,7 @@ Available containers:
40
65
  }
41
66
  }
42
67
 
43
- logger.logN(`Executing container ${logger.style.misc(container._)}`);
68
+ logger.logN(`Executing container ${logger.style.misc(container._)} (command: ${logger.style.command(argv.commands[0])})`);
44
69
  await executeInContainer({
45
70
  containerName: container.name,
46
71
  commands: argv.commands
@@ -8,7 +8,7 @@ const importDump = require('../tasks/import-dump');
8
8
  module.exports = (yargs) => {
9
9
  yargs.command(
10
10
  'import-db [importDb]',
11
- 'Import database dump to MySQL',
11
+ 'Import database dump to MariaDB',
12
12
  (yargs) => {
13
13
  yargs.option('remote-db', {
14
14
  alias: 'r',
@@ -14,7 +14,7 @@ module.exports = (yargs) => {
14
14
 
15
15
  Available scopes:
16
16
  - magento
17
- - mysql
17
+ - mariadb
18
18
  - redis
19
19
  - nginx
20
20
  - elasticsearch
@@ -17,6 +17,26 @@ const cmaGaTrackingId = 'UA-127741417-7';
17
17
 
18
18
  googleAnalytics.setGaTrackingId(cmaGaTrackingId);
19
19
 
20
+ const reportErrors = async (errors) => {
21
+ for (const error of errors) {
22
+ const path = (error.path && ` Error path: ${error.path} `) || '';
23
+ if (error instanceof UnknownError || error instanceof KnownError) {
24
+ logger.error(error.message);
25
+ if (error instanceof UnknownError) {
26
+ await googleAnalytics.trackError(`Unknown Error:${path}${error.stack}`);
27
+ } else {
28
+ await googleAnalytics.trackError(`Known Error:${path}${error.message}`);
29
+ }
30
+ } else if (error instanceof Error) {
31
+ logger.error(error.message);
32
+ await googleAnalytics.trackError(`Regular Error:${path}${error.message}`);
33
+ } else {
34
+ logger.error(error);
35
+ await googleAnalytics.trackError(`Non Error:${path}${error}`); // track non-errors throws
36
+ }
37
+ }
38
+ };
39
+
20
40
  /**
21
41
  * @param {import('yargs')} yargs
22
42
  */
@@ -49,10 +69,6 @@ module.exports = (yargs) => {
49
69
  type: 'boolean',
50
70
  default: false
51
71
  })
52
- .option('import-db', {
53
- describe: 'Import database dump to MySQL',
54
- type: 'string'
55
- })
56
72
  .option('edition', {
57
73
  alias: 'e',
58
74
  describe: 'Magento Edition to install',
@@ -80,7 +96,8 @@ module.exports = (yargs) => {
80
96
  rendererOptions: {
81
97
  showErrorMessage: false,
82
98
  showTimer: true
83
- }
99
+ },
100
+ collectErrors: 'minimal'
84
101
  }
85
102
  );
86
103
  const timeStamp = Date.now();
@@ -148,11 +165,18 @@ module.exports = (yargs) => {
148
165
  block.log();
149
166
 
150
167
  logger.note(
151
- `MySQL credentials, containers status and project information available in ${logger.style.code('npm run status')} command.
168
+ `MariaDB credentials, containers status and project information available in ${logger.style.code('npm run status')} command.
152
169
  To access Magento CLI, Composer and PHP for this project use ${logger.style.code('npm run cli')} command.`
153
170
  );
154
171
  logger.log('');
155
172
 
173
+ if (!analytics && tasks.err && tasks.err.length > 0) {
174
+ logger.warn('You have disabled analytics, but we\'ve encountered errors during startup!');
175
+ for (const err of tasks.err) {
176
+ logger.error(`${err.path}\n${err.message}\n\n${err.stack}`);
177
+ }
178
+ }
179
+
156
180
  if (!analytics) {
157
181
  process.exit(0);
158
182
  }
@@ -178,22 +202,16 @@ module.exports = (yargs) => {
178
202
  await googleAnalytics.trackError(e.message || e);
179
203
  }
180
204
 
181
- process.exit(0);
182
- } catch (e) {
183
- if (e instanceof UnknownError || e instanceof KnownError) {
184
- logger.error(e.message);
185
- if (e instanceof UnknownError) {
186
- await googleAnalytics.trackError(`Unknown Error: ${e.stack}`);
187
- } else {
188
- await googleAnalytics.trackError(`Known Error: ${e.message}`);
205
+ if (tasks.err && tasks.err.length > 0) {
206
+ for (const err of tasks.err) {
207
+ console.log(err);
189
208
  }
190
- } else if (e instanceof Error) {
191
- logger.error(e.message);
192
- await googleAnalytics.trackError(`Regular Error: ${e.message}`);
193
- } else {
194
- logger.error(e);
195
- await googleAnalytics.trackError(`Non Error: ${e}`); // track non-errors throws
209
+ await reportErrors(tasks.err);
196
210
  }
211
+
212
+ process.exit(0);
213
+ } catch (e) {
214
+ await reportErrors([e]);
197
215
  process.exit(1);
198
216
  }
199
217
  }
@@ -8,6 +8,7 @@ const { checkRequirements } = require('../tasks/requirements');
8
8
  const { statusContainers } = require('../tasks/docker/containers');
9
9
  const getProjectConfiguration = require('../config/get-project-configuration');
10
10
  const checkConfigurationFile = require('../config/check-configuration-file');
11
+ const checkPHPVersion = require('../tasks/requirements/php-version');
11
12
 
12
13
  /**
13
14
  * @param {import('yargs')} yargs
@@ -20,6 +21,7 @@ module.exports = (yargs) => {
20
21
  checkConfigurationFile(),
21
22
  getProjectConfiguration(),
22
23
  getCachedPorts(),
24
+ checkPHPVersion(),
23
25
  statusContainers()
24
26
  ], {
25
27
  concurrent: false,
@@ -1,48 +1,60 @@
1
1
  const os = require('os');
2
2
  const path = require('path');
3
- const { getArch } = require('../util/arch');
4
- const getIsWsl = require('../util/is-wsl');
3
+ const getPhpConfig = require('./php-config');
5
4
  const { isIpAddress } = require('../util/ip');
6
5
 
7
6
  const systeminformation = require('systeminformation');
7
+ const { deepmerge } = require('../util/deepmerge');
8
+ const defaultEsEnv = require('./services/elasticsearch/default-es-env');
8
9
 
9
- module.exports = async ({ configuration, ssl, host }, config) => {
10
+ /**
11
+ *
12
+ * @param {import('../../typings/context').ListrContext} ctx
13
+ * @param {import('../../typings/context').ListrContext['config']['overridenConfiguration']} overridenConfiguration
14
+ * @param {import('../../typings/context').ListrContext['config']['baseConfig']} baseConfig
15
+ * @returns
16
+ */
17
+ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
18
+ const { configuration, ssl, host } = overridenConfiguration;
10
19
  const {
11
20
  nginx,
12
21
  redis,
13
- mysql,
14
22
  elasticsearch,
15
23
  mariadb,
16
24
  varnish
17
25
  } = configuration;
18
26
 
27
+ const php = getPhpConfig(configuration, baseConfig);
19
28
  const {
20
29
  prefix,
21
30
  magentoDir,
31
+ containerMagentoDir,
22
32
  cacheDir
23
- } = config;
33
+ } = baseConfig;
24
34
 
25
- const cpuSupportedFlags = await systeminformation.cpuFlags();
35
+ const cpuSupportedFlags = (await systeminformation.cpuFlags()).split(' ');
26
36
 
27
37
  const network = {
28
38
  name: `${ prefix }_network`
29
39
  };
30
40
 
31
41
  const volumes = {
32
- mysql: {
33
- name: `${ prefix }_mysql-data`
42
+ mariadb: {
43
+ name: `${ prefix }_mariadb-data`
34
44
  },
35
45
  redis: {
36
46
  name: `${ prefix }_redis-data`
37
47
  },
38
48
  elasticsearch: {
39
49
  name: `${ prefix }_elasticsearch-data`
50
+ },
51
+ composer_home: {
52
+ name: 'composer_home-data'
40
53
  }
41
54
  };
42
55
 
43
- const isLinux = os.platform() === 'linux';
44
- const isWsl = await getIsWsl();
45
- const isArm = (await getArch()) === 'arm64';
56
+ const isLinux = ctx.platform === 'linux';
57
+ const { isWsl } = ctx;
46
58
  const isNotNativeLinux = (!isLinux || isWsl);
47
59
 
48
60
  if (!isLinux) {
@@ -50,9 +62,17 @@ module.exports = async ({ configuration, ssl, host }, config) => {
50
62
  * When CMA is running in non-native linux environment,
51
63
  * we need also create named volumes for nginx to avoid performance penalty
52
64
  */
65
+ volumes.php = {
66
+ name: `${ prefix }_project-data`,
67
+ opt: {
68
+ type: 'nfs',
69
+ device: path.join(magentoDir),
70
+ o: 'bind'
71
+ }
72
+ };
53
73
  volumes.nginx = {
54
74
  name: `${ prefix }_nginx-data`,
55
- opts: {
75
+ opt: {
56
76
  type: 'nfs',
57
77
  device: path.join(cacheDir, 'nginx', 'conf.d'),
58
78
  o: 'bind'
@@ -60,7 +80,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
60
80
  };
61
81
  volumes.appPub = {
62
82
  name: `${ prefix }_pub-data`,
63
- opts: {
83
+ opt: {
64
84
  type: 'nfs',
65
85
  device: path.join(magentoDir, 'pub'),
66
86
  o: 'bind'
@@ -68,7 +88,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
68
88
  };
69
89
  volumes.appSetup = {
70
90
  name: `${ prefix }_setup-data`,
71
- opts: {
91
+ opt: {
72
92
  type: 'nfs',
73
93
  device: path.join(magentoDir, 'setup'),
74
94
  o: 'bind'
@@ -76,7 +96,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
76
96
  };
77
97
  volumes.sslTerminator = {
78
98
  name: `${ prefix }_ssl-terminator-data`,
79
- opts: {
99
+ opt: {
80
100
  type: 'nfs',
81
101
  device: path.join(cacheDir, 'ssl-terminator', 'conf.d'),
82
102
  o: 'bind'
@@ -86,7 +106,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
86
106
  if (varnish.enabled) {
87
107
  volumes.varnish = {
88
108
  name: `${ prefix }_varnish-data`,
89
- opts: {
109
+ opt: {
90
110
  type: 'nfs',
91
111
  device: path.join(cacheDir, 'varnish'),
92
112
  o: 'bind'
@@ -96,7 +116,42 @@ module.exports = async ({ configuration, ssl, host }, config) => {
96
116
  }
97
117
 
98
118
  const getContainers = (ports = {}) => {
119
+ /**
120
+ * @type {Record<string, import('../tasks/docker/containers/container-api').ContainerRunOptions>}
121
+ */
99
122
  const dockerConfig = {
123
+ php: {
124
+ _: 'PHP',
125
+ ports: isNotNativeLinux ? [
126
+ `${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.fpm }:9000`
127
+ ] : [],
128
+ forwardedPorts: [
129
+ isNotNativeLinux
130
+ ? `127.0.0.1:${ ports.fpm }:9000`
131
+ : `127.0.0.1:${ ports.fpm }`
132
+ ],
133
+ network: isNotNativeLinux ? network.name : 'host',
134
+ mountVolumes: [
135
+ `${ isLinux ? magentoDir : volumes.php.name }:${containerMagentoDir}`,
136
+ `${ volumes.composer_home.name }:/composer/home`,
137
+ `${ php.iniPath }:/usr/local/etc/php/php.ini`,
138
+ `${ php.fpmConfPath }:/usr/local/etc/php-fpm.d/zz-docker.conf`
139
+ ],
140
+ env: {
141
+ COMPOSER_AUTH: process.env.COMPOSER_AUTH || '',
142
+ COMPOSER_HOME: '/composer/home'
143
+ },
144
+ restart: 'on-failure:5',
145
+ image: `local-cma-project:${ prefix }`,
146
+ debugImage: `local-cma-project:${ prefix }.debug`,
147
+ remoteImages: [
148
+ configuration.php.baseImage,
149
+ configuration.php.debugImage
150
+ ],
151
+ name: `${ prefix }_php`,
152
+ connectCommand: ['/bin/sh'],
153
+ user: isLinux ? `${os.userInfo().uid}:${os.userInfo().gid}` : ''
154
+ },
100
155
  sslTerminator: {
101
156
  _: 'SSL Terminator (Nginx)',
102
157
  ports: isNotNativeLinux ? [
@@ -117,13 +172,8 @@ module.exports = async ({ configuration, ssl, host }, config) => {
117
172
  `${ isLinux ? path.join(cacheDir, 'ssl-terminator', 'conf.d') : volumes.sslTerminator.name }:/etc/nginx/conf.d`
118
173
  ],
119
174
  restart: 'on-failure:5',
120
- // TODO: use connect instead
121
175
  network: isNotNativeLinux ? network.name : 'host',
122
- image: `nginx:${ nginx.version }`,
123
- imageDetails: {
124
- name: 'nginx',
125
- tag: nginx.version
126
- },
176
+ image: `${ nginx.version ? `nginx:${ nginx.version }` : nginx.image }`,
127
177
  name: `${ prefix }_ssl-terminator`,
128
178
  command: "nginx -g 'daemon off;'"
129
179
  },
@@ -145,21 +195,17 @@ module.exports = async ({ configuration, ssl, host }, config) => {
145
195
  */
146
196
  mountVolumes: isLinux ? [
147
197
  `${ cacheDir }/nginx/conf.d:/etc/nginx/conf.d`,
148
- `${ path.join(magentoDir, 'pub') }:${path.join(magentoDir, 'pub')}`,
149
- `${ path.join(magentoDir, 'setup') }:${path.join(magentoDir, 'setup')}`
198
+ `${ path.join(magentoDir, 'pub') }:${path.join(containerMagentoDir, 'pub')}`,
199
+ `${ path.join(magentoDir, 'setup') }:${path.join(containerMagentoDir, 'setup')}`
150
200
  ] : [
151
201
  `${ volumes.nginx.name }:/etc/nginx/conf.d`,
152
- `${ volumes.appPub.name }:${path.join(magentoDir, 'pub')}`,
153
- `${ volumes.appSetup.name }:${path.join(magentoDir, 'setup')}`
202
+ `${ volumes.appPub.name }:${path.join(containerMagentoDir, 'pub')}`,
203
+ `${ volumes.appSetup.name }:${path.join(containerMagentoDir, 'setup')}`
154
204
  ],
155
205
  restart: 'on-failure:5',
156
206
  // TODO: use connect instead
157
207
  network: isNotNativeLinux ? network.name : 'host',
158
- image: `nginx:${ nginx.version }`,
159
- imageDetails: {
160
- name: 'nginx',
161
- tag: nginx.version
162
- },
208
+ image: `${ nginx.version ? `nginx:${ nginx.version }` : nginx.image }`,
163
209
  name: `${ prefix }_nginx`,
164
210
  command: "nginx -g 'daemon off;'"
165
211
  },
@@ -173,56 +219,38 @@ module.exports = async ({ configuration, ssl, host }, config) => {
173
219
  mounts: [`source=${ volumes.redis.name },target=/data`],
174
220
  // TODO: use connect instead
175
221
  network: network.name,
176
- image: `redis:${ redis.version }`,
177
- imageDetails: {
178
- name: 'redis',
179
- tag: redis.version
180
- },
222
+ image: `${ redis.version ? `redis:${ redis.version }` : redis.image }`,
181
223
  name: `${ prefix }_redis`,
182
224
  connectCommand: ['redis-cli']
183
225
  },
184
- mysql: {
185
- _: !isArm ? 'MySQL' : 'MariaDB',
226
+ mariadb: {
227
+ _: 'MariaDB',
186
228
  healthCheck: {
187
229
  cmd: 'mysqladmin ping --silent'
188
230
  },
189
- ports: [`127.0.0.1:${ ports.mysql }:3306`],
190
- forwardedPorts: [`127.0.0.1:${ ports.mysql }:3306`],
191
- mounts: [`source=${ volumes.mysql.name },target=/var/lib/mysql`],
231
+ ports: [`127.0.0.1:${ ports.mariadb }:3306`],
232
+ forwardedPorts: [`127.0.0.1:${ ports.mariadb }:3306`],
233
+ mountVolumes: [
234
+ `${ volumes.mariadb.name }:/var/lib/mysql`,
235
+ `${ path.join(baseConfig.cacheDir, 'mariadb.cnf') }:/etc/mysql/my.cnf`
236
+ ],
192
237
  env: {
193
- MYSQL_PORT: 3306,
194
- MYSQL_ROOT_PASSWORD: 'scandipwa',
195
- MYSQL_USER: 'magento',
196
- MYSQL_PASSWORD: 'magento',
197
- MYSQL_DATABASE: 'magento'
238
+ MARIADB_PORT: 3306,
239
+ MARIADB_ROOT_PASSWORD: 'scandipwa',
240
+ MARIADB_USER: 'magento',
241
+ MARIADB_PASSWORD: 'magento',
242
+ MARIADB_DATABASE: 'magento'
198
243
  },
199
- /**
200
- * When database dump contains functions, MySQL can throw and error "access denied for those functions"
201
- * so to overcome this issue, we need to enable trust option for these functions to avoid errors during migrations.
202
- *
203
- * Documentation reference: https://dev.mysql.com/doc/refman/5.7/en/stored-programs-logging.html
204
- */
205
244
  command: [
206
- '--log_bin_trust_function_creators=1',
207
- '--default-authentication-plugin=mysql_native_password',
208
- '--max_allowed_packet=1GB',
209
- '--bind-address=0.0.0.0'
245
+ '--log_bin_trust_function_creators=1'
210
246
  ]
211
- .concat(!isArm ? ['--secure-file-priv=NULL'] : [])
212
247
  .join(' '),
213
248
  securityOptions: [
214
249
  'seccomp=unconfined'
215
250
  ],
216
251
  network: network.name,
217
- image: !isArm ? `mysql:${ mysql.version }` : `mariadb:${ mariadb.version }`,
218
- imageDetails: !isArm ? {
219
- name: 'mysql',
220
- tag: mysql.version
221
- } : {
222
- name: 'mariadb',
223
- tag: mariadb.version
224
- },
225
- name: !isArm ? `${ prefix }_mysql` : `${ prefix }_mariadb`
252
+ image: `${ mariadb.version ? `mariadb:${ mariadb.version }` : mariadb.image }`,
253
+ name: `${ prefix }_mariadb`
226
254
  },
227
255
  elasticsearch: {
228
256
  _: 'ElasticSearch',
@@ -232,20 +260,14 @@ module.exports = async ({ configuration, ssl, host }, config) => {
232
260
  ports: [`127.0.0.1:${ ports.elasticsearch }:9200`],
233
261
  forwardedPorts: [`127.0.0.1:${ ports.elasticsearch }:9200`],
234
262
  mounts: [`source=${ volumes.elasticsearch.name },target=/usr/share/elasticsearch/data`],
235
- env: {
236
- 'bootstrap.memory_lock': true,
237
- 'xpack.security.enabled': false,
238
- 'discovery.type': 'single-node',
239
- ES_JAVA_OPTS: '"-Xms512m -Xmx512m"',
263
+ env: deepmerge(
264
+ {
240
265
  // https://www.elastic.co/guide/en/elasticsearch/reference/master/ml-settings.html
241
- 'xpack.ml.enabled': ['sse4.2', 'sse4_2'].some((sse42Flag) => cpuSupportedFlags.includes(sse42Flag))
242
- },
266
+ 'xpack.ml.enabled': ['sse4.2', 'sse4_2'].some((sse42Flag) => cpuSupportedFlags.includes(sse42Flag))
267
+ }, elasticsearch.env || defaultEsEnv
268
+ ),
243
269
  network: network.name,
244
- image: `elasticsearch:${ elasticsearch.version }`,
245
- imageDetails: {
246
- name: 'elasticsearch',
247
- tag: elasticsearch.version
248
- },
270
+ image: `${ elasticsearch.version ? `elasticsearch:${ elasticsearch.version }` : elasticsearch.image }`,
249
271
  name: `${ prefix }_elasticsearch`
250
272
  }
251
273
  };
@@ -256,14 +278,10 @@ module.exports = async ({ configuration, ssl, host }, config) => {
256
278
  );
257
279
  }
258
280
 
259
- if (varnish.enabled) {
281
+ if (!ctx.debug && varnish.enabled) {
260
282
  dockerConfig.varnish = {
261
283
  _: 'Varnish',
262
- image: `varnish:${ varnish.version }`,
263
- imageDetails: {
264
- name: 'varnish',
265
- tag: varnish.version
266
- },
284
+ image: `${ varnish.version ? `varnish:${ varnish.version }` : varnish.image }`,
267
285
  name: `${ prefix }_varnish`,
268
286
  mountVolumes: [
269
287
  `${ isLinux ? path.join(cacheDir, 'varnish') : volumes.varnish.name }:/etc/varnish`
@@ -8,7 +8,9 @@ const getProjectConfiguration = () => ({
8
8
  task: async (ctx) => {
9
9
  const { magentoVersion } = ctx;
10
10
 
11
- ctx.config = await getConfigFromMagentoVersion(magentoVersion, process.cwd());
11
+ ctx.config = await getConfigFromMagentoVersion(ctx, {
12
+ magentoVersion
13
+ });
12
14
  }
13
15
  });
14
16
 
@@ -5,7 +5,6 @@ const {
5
5
  defaultConfiguration
6
6
  } = require('./versions');
7
7
  const getPhpConfig = require('./php-config');
8
- const getComposerConfig = require('./composer');
9
8
  const { getMagentoConfig } = require('./magento-config');
10
9
  const resolveConfigurationWithOverrides = require('../util/resolve-configuration-with-overrides');
11
10
  const { getPrefix, folderName } = require('../util/prefix');
@@ -15,11 +14,12 @@ const platforms = ['linux', 'darwin'];
15
14
  const darwinMinimalVersion = '10.5';
16
15
 
17
16
  /**
18
- * @returns {{prefix: string,magentoDir: string,templateDir: string,cacheDir: string}}
17
+ * @returns {import('../../typings/context').ListrContext['config']['baseConfig']}
19
18
  */
20
19
  const getBaseConfig = (projectPath = process.cwd(), prefix = folderName) => ({
21
20
  prefix: getPrefix(prefix),
22
21
  magentoDir: projectPath,
22
+ containerMagentoDir: projectPath,
23
23
  templateDir: path.join(__dirname, 'templates'),
24
24
  cacheDir: path.join(projectPath, 'node_modules', '.create-magento-app-cache')
25
25
  });
@@ -27,14 +27,19 @@ const getBaseConfig = (projectPath = process.cwd(), prefix = folderName) => ({
27
27
  const baseConfig = getBaseConfig();
28
28
 
29
29
  const magento = {
30
- binPath: path.join(baseConfig.magentoDir, 'bin', 'magento')
30
+ binPath: path.join(baseConfig.magentoDir, 'bin', 'magento'),
31
+ containerBinPath: path.join(baseConfig.containerMagentoDir, 'bin', 'magento')
31
32
  };
32
33
 
33
34
  module.exports = {
34
35
  /**
35
36
  * @param {string} magentoVersion
36
37
  */
37
- async getConfigFromMagentoVersion(magentoVersion, projectPath = process.cwd(), prefix = folderName) {
38
+ async getConfigFromMagentoVersion(ctx, {
39
+ magentoVersion,
40
+ projectPath = process.cwd(),
41
+ prefix = folderName
42
+ }) {
38
43
  const newBaseConfig = getBaseConfig(projectPath, prefix);
39
44
  const configurations = getConfigurations(newBaseConfig);
40
45
  if (!configurations[magentoVersion]) {
@@ -52,8 +57,7 @@ module.exports = {
52
57
 
53
58
  return {
54
59
  php: getPhpConfig(overridenConfiguration.configuration, newBaseConfig),
55
- docker: await getDockerConfig(overridenConfiguration, newBaseConfig),
56
- composer: getComposerConfig(overridenConfiguration.configuration, newBaseConfig),
60
+ docker: await getDockerConfig(ctx, overridenConfiguration, newBaseConfig),
57
61
  magentoConfiguration: getMagentoConfig(overridenConfiguration.magento),
58
62
  baseConfig: newBaseConfig,
59
63
  overridenConfiguration,
@@ -65,7 +69,6 @@ module.exports = {
65
69
  getBaseConfig,
66
70
  magento,
67
71
  platforms,
68
- docker: getDockerConfig(defaultConfiguration, baseConfig),
69
72
  darwinMinimalVersion,
70
73
  defaultConfiguration
71
74
  };
@@ -0,0 +1,29 @@
1
+ const magento23RequiredPHPExtensions = require('./magento-2.3');
2
+ const magento24RequiredPHPExtensions = require('./magento-2.4');
3
+
4
+ const { phpExtensionInstallationInstructions } = require('../../php/extensions');
5
+
6
+ /**
7
+ * @param {string[]} requiredPHPExtensions
8
+ * @returns {Record<string, import('../../../../typings/index').PHPExtensionInstallationInstruction>}
9
+ */
10
+ const mapMagentoRequiredExtensionsToInstructions = (requiredPHPExtensions) => requiredPHPExtensions.map((extensionName) => {
11
+ if (phpExtensionInstallationInstructions[extensionName]) {
12
+ return phpExtensionInstallationInstructions[extensionName];
13
+ }
14
+
15
+ for (const [extensionName, extensionData] of Object.entries(phpExtensionInstallationInstructions)) {
16
+ if (extensionData.alternativeName && extensionData.alternativeName.includes(extensionName)) {
17
+ return extensionData;
18
+ }
19
+ }
20
+
21
+ return {
22
+ name: extensionName
23
+ };
24
+ }).reduce((acc, val) => ({ ...acc, [val.name]: val }), {});
25
+
26
+ module.exports = {
27
+ magento23PHPExtensionList: mapMagentoRequiredExtensionsToInstructions(magento23RequiredPHPExtensions),
28
+ magento24PHPExtensionList: mapMagentoRequiredExtensionsToInstructions(magento24RequiredPHPExtensions)
29
+ };