@scandipwa/magento-scripts 1.16.0 → 2.0.0-alpha.1

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 (225) 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 +98 -83
  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/versions/elasticsearch-6.8.js +23 -0
  36. package/lib/config/services/elasticsearch/versions/index.js +5 -0
  37. package/lib/config/templates/magentorc.template +5 -5
  38. package/lib/config/templates/mariadb.template.cnf +191 -0
  39. package/lib/config/templates/php-fpm.template.conf +3 -3
  40. package/lib/config/templates/php.template.ini +12 -6
  41. package/lib/config/templates/ssl-terminator.template.conf +1 -1
  42. package/lib/config/templates/vscode-launch.template.json +3 -1
  43. package/lib/config/versions/magento-2.3.0.js +10 -5
  44. package/lib/config/versions/magento-2.3.1.js +10 -5
  45. package/lib/config/versions/magento-2.3.2-p1.js +43 -0
  46. package/lib/config/versions/magento-2.3.2-p2.js +10 -5
  47. package/lib/config/versions/magento-2.3.2.js +10 -5
  48. package/lib/config/versions/magento-2.3.3-p1.js +10 -5
  49. package/lib/config/versions/magento-2.3.3.js +10 -5
  50. package/lib/config/versions/magento-2.3.4-p1.js +43 -0
  51. package/lib/config/versions/magento-2.3.4-p2.js +10 -5
  52. package/lib/config/versions/magento-2.3.4.js +10 -5
  53. package/lib/config/versions/magento-2.3.5-p1.js +8 -2
  54. package/lib/config/versions/magento-2.3.5-p2.js +8 -2
  55. package/lib/config/versions/magento-2.3.5.js +8 -2
  56. package/lib/config/versions/magento-2.3.6-p1.js +8 -2
  57. package/lib/config/versions/magento-2.3.6.js +8 -2
  58. package/lib/config/versions/magento-2.3.7-p1.js +8 -2
  59. package/lib/config/versions/magento-2.3.7-p2.js +8 -2
  60. package/lib/config/versions/magento-2.3.7-p3.js +8 -2
  61. package/lib/config/versions/magento-2.3.7.js +8 -2
  62. package/lib/config/versions/magento-2.4.0-p1.js +9 -3
  63. package/lib/config/versions/magento-2.4.0.js +9 -3
  64. package/lib/config/versions/magento-2.4.1-p1.js +6 -5
  65. package/lib/config/versions/magento-2.4.1.js +9 -2
  66. package/lib/config/versions/magento-2.4.2-p1.js +6 -5
  67. package/lib/config/versions/magento-2.4.2-p2.js +6 -6
  68. package/lib/config/versions/magento-2.4.2.js +6 -6
  69. package/lib/config/versions/magento-2.4.3-p1.js +7 -7
  70. package/lib/config/versions/magento-2.4.3-p2.js +7 -7
  71. package/lib/config/versions/magento-2.4.3.js +7 -7
  72. package/lib/config/versions/magento-2.4.4.js +9 -2
  73. package/lib/tasks/cleanup.js +3 -3
  74. package/lib/tasks/composer/index.js +14 -104
  75. package/lib/tasks/database/connect-to-database.js +117 -0
  76. package/lib/tasks/database/create-magento-database.js +18 -0
  77. package/lib/tasks/{mysql → database}/dump-theme-config.js +3 -3
  78. package/lib/tasks/{mysql → database}/fix-db.js +2 -2
  79. package/lib/tasks/{mysql/import-dump-to-mysql.js → database/import-dump-to-database.js} +65 -22
  80. package/lib/tasks/{mysql → database}/import-remote-db/index.js +0 -0
  81. package/lib/tasks/{mysql/import-remote-db/ssh/mysqldump-command.js → database/import-remote-db/ssh/database-dump-command.js} +2 -2
  82. package/lib/tasks/{mysql → database}/import-remote-db/ssh/index.js +0 -0
  83. package/lib/tasks/{mysql → database}/import-remote-db/ssh/readymage.js +4 -4
  84. package/lib/tasks/{mysql → database}/import-remote-db/ssh/regular-server.js +2 -2
  85. package/lib/tasks/{mysql → database}/index.js +2 -2
  86. package/lib/tasks/{mysql → database}/magento-tables.js +0 -0
  87. package/lib/tasks/{mysql → database}/restore-theme-config.js +4 -4
  88. package/lib/tasks/docker/api.d.ts +71 -0
  89. package/lib/tasks/docker/api.js +30 -0
  90. package/lib/tasks/docker/containers/container-api.d.ts +128 -0
  91. package/lib/tasks/docker/containers/container-api.js +153 -0
  92. package/lib/tasks/docker/containers/index.js +19 -0
  93. package/lib/tasks/docker/containers/tasks.js +215 -0
  94. package/lib/tasks/docker/convert-legacy-volumes.js +15 -10
  95. package/lib/tasks/docker/convert-mysql-to-mariadb.js +284 -0
  96. package/lib/tasks/docker/image/image-api.d.ts +34 -0
  97. package/lib/tasks/docker/image/image-api.js +49 -0
  98. package/lib/tasks/docker/image/index.js +5 -0
  99. package/lib/tasks/docker/index.js +1 -13
  100. package/lib/tasks/docker/network/index.js +7 -0
  101. package/lib/tasks/docker/network/network-api.d.ts +103 -0
  102. package/lib/tasks/docker/network/network-api.js +99 -0
  103. package/lib/tasks/docker/{network.js → network/tasks.js} +17 -10
  104. package/lib/tasks/docker/project-image-builder.js +167 -0
  105. package/lib/tasks/docker/volume/index.js +8 -0
  106. package/lib/tasks/docker/{volumes.js → volume/tasks.js} +5 -19
  107. package/lib/tasks/docker/volume/volume-api.d.ts +39 -0
  108. package/lib/tasks/docker/volume/volume-api.js +66 -0
  109. package/lib/tasks/execute/index.js +5 -2
  110. package/lib/tasks/file-system/create-mariadb-config.js +23 -0
  111. package/lib/tasks/file-system/create-nginx-config.js +2 -3
  112. package/lib/tasks/file-system/create-php-config.js +20 -5
  113. package/lib/tasks/file-system/create-php-fpm-config.js +8 -4
  114. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +41 -29
  115. package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -0
  116. package/lib/tasks/file-system/create-phpstorm-config/keys.js +15 -1
  117. package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +4 -1
  118. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-config.js +3 -3
  119. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-interpreters-config.js +81 -0
  120. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/index.js +42 -0
  121. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/php-docker-settings-config.js +9 -0
  122. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/setup-php-docker-container-settings-config.js +66 -0
  123. package/lib/tasks/file-system/create-phpstorm-config/setup-xml-structure.js +11 -9
  124. package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +2 -1
  125. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +15 -30
  126. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +24 -5
  127. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/mess-detector-project-configuration-config.js +50 -0
  128. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-code-sniffer-project-configuration-config.js +50 -0
  129. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-cs-fixer-project-configuration-config.js +50 -0
  130. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +15 -15
  131. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +29 -3
  132. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-stan-project-configuration-config.js.js +50 -0
  133. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +42 -0
  134. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/psalm-project-configuration-config.js.js +50 -0
  135. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/workspace-config.js +0 -2
  136. package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -2
  137. package/lib/tasks/file-system/create-vscode-config.js +57 -42
  138. package/lib/tasks/file-system/index.js +5 -2
  139. package/lib/tasks/import-dump.js +6 -6
  140. package/lib/tasks/link.js +5 -4
  141. package/lib/tasks/magento/install-magento-project.js +31 -63
  142. package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +4 -4
  143. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +7 -3
  144. package/lib/tasks/magento/setup-magento/create-admin.js +5 -6
  145. package/lib/tasks/magento/setup-magento/delete-admin-users.js +2 -2
  146. package/lib/tasks/magento/setup-magento/delete-customers.js +4 -4
  147. package/lib/tasks/magento/setup-magento/delete-orders.js +4 -4
  148. package/lib/tasks/magento/setup-magento/disable-2fa.js +3 -5
  149. package/lib/tasks/magento/setup-magento/disable-maintenance-mode.js +3 -4
  150. package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +2 -2
  151. package/lib/tasks/magento/setup-magento/index.js +3 -3
  152. package/lib/tasks/magento/setup-magento/install-magento.js +47 -40
  153. package/lib/tasks/magento/setup-magento/migrate-database.js +7 -14
  154. package/lib/tasks/magento/setup-magento/set-base-url.js +2 -2
  155. package/lib/tasks/magento/setup-magento/set-deployment-mode.js +4 -4
  156. package/lib/tasks/magento/setup-magento/set-url-rewrite.js +2 -2
  157. package/lib/tasks/magento/setup-magento/varnish-config.js +11 -9
  158. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +128 -3
  159. package/lib/tasks/php/php-container.js +108 -0
  160. package/lib/tasks/php/update-env-php.js +39 -21
  161. package/lib/tasks/php/update-env.php +66 -61
  162. package/lib/tasks/php/working_health_check.php +85 -0
  163. package/lib/tasks/requirements/{composer.js → composer-credentials.js} +3 -1
  164. package/lib/tasks/requirements/docker/index.js +15 -12
  165. package/lib/tasks/requirements/docker/performance.js +54 -0
  166. package/lib/tasks/requirements/docker/version.js +8 -8
  167. package/lib/tasks/requirements/index.js +5 -8
  168. package/lib/tasks/requirements/php-version.js +8 -116
  169. package/lib/tasks/requirements/platform.js +12 -25
  170. package/lib/tasks/start.js +24 -51
  171. package/lib/tasks/status/index.js +8 -12
  172. package/lib/tasks/stop.js +0 -2
  173. package/lib/tasks/theme/install-theme.js +1 -1
  174. package/lib/tasks/theme/link-theme.js +2 -2
  175. package/lib/tasks/theme/symlink-theme.js +2 -3
  176. package/lib/util/config-file-validator.js +27 -13
  177. package/lib/util/config-php-json.js +13 -4
  178. package/lib/util/database.js +7 -7
  179. package/lib/util/dockerfile-builder/build-instructions.js +197 -0
  180. package/lib/util/dockerfile-builder/index.js +276 -0
  181. package/lib/util/dockerfile-builder/types.d.ts +123 -0
  182. package/lib/util/env-php-json.js +10 -6
  183. package/lib/util/exec-async-command.js +3 -9
  184. package/lib/util/macos-version.js +20 -0
  185. package/lib/util/magento-task.js +3 -4
  186. package/lib/util/nginx-logs-parser.js +122 -0
  187. package/lib/util/php-task.js +3 -6
  188. package/lib/util/run-composer.js +6 -14
  189. package/lib/util/run-container-image.js +17 -0
  190. package/lib/util/run-magento.js +6 -14
  191. package/lib/util/run-php.js +6 -17
  192. package/package.json +9 -9
  193. package/typings/context.d.ts +7 -13
  194. package/typings/index.d.ts +67 -85
  195. package/yarn-error.log +9660 -0
  196. package/lib/config/composer.js +0 -11
  197. package/lib/config/php/extensions/libsodium.js +0 -36
  198. package/lib/config/php/releases/php-7.2.js +0 -25
  199. package/lib/config/php/releases/php-7.3.js +0 -25
  200. package/lib/config/php/releases/php-7.4.js +0 -23
  201. package/lib/config/php/releases/php-8.1.js +0 -25
  202. package/lib/config/phpbrew.js +0 -12
  203. package/lib/tasks/composer/install-prestissimo.js +0 -103
  204. package/lib/tasks/docker/containers.js +0 -231
  205. package/lib/tasks/mysql/connect-to-mysql.js +0 -114
  206. package/lib/tasks/mysql/create-magento-database.js +0 -18
  207. package/lib/tasks/php/bundled-extensions.js +0 -27
  208. package/lib/tasks/php/compile-options.js +0 -56
  209. package/lib/tasks/php/compile.js +0 -55
  210. package/lib/tasks/php/configure.js +0 -89
  211. package/lib/tasks/php/extensions/disable.js +0 -49
  212. package/lib/tasks/php/extensions/enable.js +0 -52
  213. package/lib/tasks/php/extensions/index.js +0 -80
  214. package/lib/tasks/php/extensions/install.js +0 -54
  215. package/lib/tasks/php/index.js +0 -79
  216. package/lib/tasks/php/install-sodium.js +0 -93
  217. package/lib/tasks/php/update-phpbrew.js +0 -45
  218. package/lib/tasks/php/validate-php.js +0 -67
  219. package/lib/tasks/php-fpm/get-process-id.js +0 -14
  220. package/lib/tasks/php-fpm/index.js +0 -4
  221. package/lib/tasks/php-fpm/start-php-fpm.js +0 -49
  222. package/lib/tasks/php-fpm/stop-php-fpm.js +0 -48
  223. package/lib/tasks/requirements/phpbrew/index.js +0 -61
  224. package/lib/tasks/requirements/phpbrew/install.js +0 -159
  225. 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,59 @@
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
8
 
9
- module.exports = async ({ configuration, ssl, host }, config) => {
9
+ /**
10
+ *
11
+ * @param {import('../../typings/context').ListrContext} ctx
12
+ * @param {import('../../typings/context').ListrContext['config']['overridenConfiguration']} overridenConfiguration
13
+ * @param {import('../../typings/context').ListrContext['config']['baseConfig']} baseConfig
14
+ * @returns
15
+ */
16
+ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
17
+ const { configuration, ssl, host } = overridenConfiguration;
10
18
  const {
11
19
  nginx,
12
20
  redis,
13
- mysql,
14
21
  elasticsearch,
15
22
  mariadb,
16
23
  varnish
17
24
  } = configuration;
18
25
 
26
+ const php = getPhpConfig(configuration, baseConfig);
19
27
  const {
20
28
  prefix,
21
29
  magentoDir,
30
+ containerMagentoDir,
22
31
  cacheDir
23
- } = config;
32
+ } = baseConfig;
24
33
 
25
- const cpuSupportedFlags = await systeminformation.cpuFlags();
34
+ const cpuSupportedFlags = (await systeminformation.cpuFlags()).split(' ');
26
35
 
27
36
  const network = {
28
37
  name: `${ prefix }_network`
29
38
  };
30
39
 
31
40
  const volumes = {
32
- mysql: {
33
- name: `${ prefix }_mysql-data`
41
+ mariadb: {
42
+ name: `${ prefix }_mariadb-data`
34
43
  },
35
44
  redis: {
36
45
  name: `${ prefix }_redis-data`
37
46
  },
38
47
  elasticsearch: {
39
48
  name: `${ prefix }_elasticsearch-data`
49
+ },
50
+ composer_home: {
51
+ name: 'composer_home-data'
40
52
  }
41
53
  };
42
54
 
43
- const isLinux = os.platform() === 'linux';
44
- const isWsl = await getIsWsl();
45
- const isArm = (await getArch()) === 'arm64';
55
+ const isLinux = ctx.platform === 'linux';
56
+ const { isWsl } = ctx;
46
57
  const isNotNativeLinux = (!isLinux || isWsl);
47
58
 
48
59
  if (!isLinux) {
@@ -50,9 +61,17 @@ module.exports = async ({ configuration, ssl, host }, config) => {
50
61
  * When CMA is running in non-native linux environment,
51
62
  * we need also create named volumes for nginx to avoid performance penalty
52
63
  */
64
+ volumes.php = {
65
+ name: `${ prefix }_project-data`,
66
+ opt: {
67
+ type: 'nfs',
68
+ device: path.join(magentoDir),
69
+ o: 'bind'
70
+ }
71
+ };
53
72
  volumes.nginx = {
54
73
  name: `${ prefix }_nginx-data`,
55
- opts: {
74
+ opt: {
56
75
  type: 'nfs',
57
76
  device: path.join(cacheDir, 'nginx', 'conf.d'),
58
77
  o: 'bind'
@@ -60,7 +79,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
60
79
  };
61
80
  volumes.appPub = {
62
81
  name: `${ prefix }_pub-data`,
63
- opts: {
82
+ opt: {
64
83
  type: 'nfs',
65
84
  device: path.join(magentoDir, 'pub'),
66
85
  o: 'bind'
@@ -68,7 +87,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
68
87
  };
69
88
  volumes.appSetup = {
70
89
  name: `${ prefix }_setup-data`,
71
- opts: {
90
+ opt: {
72
91
  type: 'nfs',
73
92
  device: path.join(magentoDir, 'setup'),
74
93
  o: 'bind'
@@ -76,7 +95,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
76
95
  };
77
96
  volumes.sslTerminator = {
78
97
  name: `${ prefix }_ssl-terminator-data`,
79
- opts: {
98
+ opt: {
80
99
  type: 'nfs',
81
100
  device: path.join(cacheDir, 'ssl-terminator', 'conf.d'),
82
101
  o: 'bind'
@@ -86,7 +105,7 @@ module.exports = async ({ configuration, ssl, host }, config) => {
86
105
  if (varnish.enabled) {
87
106
  volumes.varnish = {
88
107
  name: `${ prefix }_varnish-data`,
89
- opts: {
108
+ opt: {
90
109
  type: 'nfs',
91
110
  device: path.join(cacheDir, 'varnish'),
92
111
  o: 'bind'
@@ -96,7 +115,42 @@ module.exports = async ({ configuration, ssl, host }, config) => {
96
115
  }
97
116
 
98
117
  const getContainers = (ports = {}) => {
118
+ /**
119
+ * @type {Record<string, import('../tasks/docker/containers/container-api').ContainerRunOptions>}
120
+ */
99
121
  const dockerConfig = {
122
+ php: {
123
+ _: 'PHP',
124
+ ports: isNotNativeLinux ? [
125
+ `${ isIpAddress(host) ? host : '127.0.0.1' }:${ ports.fpm }:9000`
126
+ ] : [],
127
+ forwardedPorts: [
128
+ isNotNativeLinux
129
+ ? `127.0.0.1:${ ports.fpm }:9000`
130
+ : `127.0.0.1:${ ports.fpm }`
131
+ ],
132
+ network: isNotNativeLinux ? network.name : 'host',
133
+ mountVolumes: [
134
+ `${ isLinux ? magentoDir : volumes.php.name }:${containerMagentoDir}`,
135
+ `${ volumes.composer_home.name }:/composer/home`,
136
+ `${ php.iniPath }:/usr/local/etc/php/php.ini`,
137
+ `${ php.fpmConfPath }:/usr/local/etc/php-fpm.d/zz-docker.conf`
138
+ ],
139
+ env: {
140
+ COMPOSER_AUTH: process.env.COMPOSER_AUTH || '',
141
+ COMPOSER_HOME: '/composer/home'
142
+ },
143
+ restart: 'on-failure:5',
144
+ image: `local-cma-project:${ prefix }`,
145
+ debugImage: `local-cma-project:${ prefix }.debug`,
146
+ remoteImages: [
147
+ configuration.php.baseImage,
148
+ configuration.php.debugImage
149
+ ],
150
+ name: `${ prefix }_php`,
151
+ connectCommand: ['/bin/sh'],
152
+ user: isLinux ? `${os.userInfo().uid}:${os.userInfo().gid}` : ''
153
+ },
100
154
  sslTerminator: {
101
155
  _: 'SSL Terminator (Nginx)',
102
156
  ports: isNotNativeLinux ? [
@@ -117,13 +171,8 @@ module.exports = async ({ configuration, ssl, host }, config) => {
117
171
  `${ isLinux ? path.join(cacheDir, 'ssl-terminator', 'conf.d') : volumes.sslTerminator.name }:/etc/nginx/conf.d`
118
172
  ],
119
173
  restart: 'on-failure:5',
120
- // TODO: use connect instead
121
174
  network: isNotNativeLinux ? network.name : 'host',
122
- image: `nginx:${ nginx.version }`,
123
- imageDetails: {
124
- name: 'nginx',
125
- tag: nginx.version
126
- },
175
+ image: `${ nginx.version ? `nginx:${ nginx.version }` : nginx.image }`,
127
176
  name: `${ prefix }_ssl-terminator`,
128
177
  command: "nginx -g 'daemon off;'"
129
178
  },
@@ -145,21 +194,17 @@ module.exports = async ({ configuration, ssl, host }, config) => {
145
194
  */
146
195
  mountVolumes: isLinux ? [
147
196
  `${ 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')}`
197
+ `${ path.join(magentoDir, 'pub') }:${path.join(containerMagentoDir, 'pub')}`,
198
+ `${ path.join(magentoDir, 'setup') }:${path.join(containerMagentoDir, 'setup')}`
150
199
  ] : [
151
200
  `${ volumes.nginx.name }:/etc/nginx/conf.d`,
152
- `${ volumes.appPub.name }:${path.join(magentoDir, 'pub')}`,
153
- `${ volumes.appSetup.name }:${path.join(magentoDir, 'setup')}`
201
+ `${ volumes.appPub.name }:${path.join(containerMagentoDir, 'pub')}`,
202
+ `${ volumes.appSetup.name }:${path.join(containerMagentoDir, 'setup')}`
154
203
  ],
155
204
  restart: 'on-failure:5',
156
205
  // TODO: use connect instead
157
206
  network: isNotNativeLinux ? network.name : 'host',
158
- image: `nginx:${ nginx.version }`,
159
- imageDetails: {
160
- name: 'nginx',
161
- tag: nginx.version
162
- },
207
+ image: `${ nginx.version ? `nginx:${ nginx.version }` : nginx.image }`,
163
208
  name: `${ prefix }_nginx`,
164
209
  command: "nginx -g 'daemon off;'"
165
210
  },
@@ -173,56 +218,38 @@ module.exports = async ({ configuration, ssl, host }, config) => {
173
218
  mounts: [`source=${ volumes.redis.name },target=/data`],
174
219
  // TODO: use connect instead
175
220
  network: network.name,
176
- image: `redis:${ redis.version }`,
177
- imageDetails: {
178
- name: 'redis',
179
- tag: redis.version
180
- },
221
+ image: `${ redis.version ? `redis:${ redis.version }` : redis.image }`,
181
222
  name: `${ prefix }_redis`,
182
223
  connectCommand: ['redis-cli']
183
224
  },
184
- mysql: {
185
- _: !isArm ? 'MySQL' : 'MariaDB',
225
+ mariadb: {
226
+ _: 'MariaDB',
186
227
  healthCheck: {
187
228
  cmd: 'mysqladmin ping --silent'
188
229
  },
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`],
230
+ ports: [`127.0.0.1:${ ports.mariadb }:3306`],
231
+ forwardedPorts: [`127.0.0.1:${ ports.mariadb }:3306`],
232
+ mountVolumes: [
233
+ `${ volumes.mariadb.name }:/var/lib/mysql`,
234
+ `${ path.join(baseConfig.cacheDir, 'mariadb.cnf') }:/etc/mysql/my.cnf`
235
+ ],
192
236
  env: {
193
- MYSQL_PORT: 3306,
194
- MYSQL_ROOT_PASSWORD: 'scandipwa',
195
- MYSQL_USER: 'magento',
196
- MYSQL_PASSWORD: 'magento',
197
- MYSQL_DATABASE: 'magento'
237
+ MARIADB_PORT: 3306,
238
+ MARIADB_ROOT_PASSWORD: 'scandipwa',
239
+ MARIADB_USER: 'magento',
240
+ MARIADB_PASSWORD: 'magento',
241
+ MARIADB_DATABASE: 'magento'
198
242
  },
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
243
  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'
244
+ '--log_bin_trust_function_creators=1'
210
245
  ]
211
- .concat(!isArm ? ['--secure-file-priv=NULL'] : [])
212
246
  .join(' '),
213
247
  securityOptions: [
214
248
  'seccomp=unconfined'
215
249
  ],
216
250
  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`
251
+ image: `${ mariadb.version ? `mariadb:${ mariadb.version }` : mariadb.image }`,
252
+ name: `${ prefix }_mariadb`
226
253
  },
227
254
  elasticsearch: {
228
255
  _: 'ElasticSearch',
@@ -232,20 +259,12 @@ module.exports = async ({ configuration, ssl, host }, config) => {
232
259
  ports: [`127.0.0.1:${ ports.elasticsearch }:9200`],
233
260
  forwardedPorts: [`127.0.0.1:${ ports.elasticsearch }:9200`],
234
261
  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"',
262
+ env: deepmerge({
240
263
  // https://www.elastic.co/guide/en/elasticsearch/reference/master/ml-settings.html
241
264
  'xpack.ml.enabled': ['sse4.2', 'sse4_2'].some((sse42Flag) => cpuSupportedFlags.includes(sse42Flag))
242
- },
265
+ }, elasticsearch.env),
243
266
  network: network.name,
244
- image: `elasticsearch:${ elasticsearch.version }`,
245
- imageDetails: {
246
- name: 'elasticsearch',
247
- tag: elasticsearch.version
248
- },
267
+ image: `${ elasticsearch.version ? `elasticsearch:${ elasticsearch.version }` : elasticsearch.image }`,
249
268
  name: `${ prefix }_elasticsearch`
250
269
  }
251
270
  };
@@ -256,14 +275,10 @@ module.exports = async ({ configuration, ssl, host }, config) => {
256
275
  );
257
276
  }
258
277
 
259
- if (varnish.enabled) {
278
+ if (!ctx.debug && varnish.enabled) {
260
279
  dockerConfig.varnish = {
261
280
  _: 'Varnish',
262
- image: `varnish:${ varnish.version }`,
263
- imageDetails: {
264
- name: 'varnish',
265
- tag: varnish.version
266
- },
281
+ image: `${ varnish.version ? `varnish:${ varnish.version }` : varnish.image }`,
267
282
  name: `${ prefix }_varnish`,
268
283
  mountVolumes: [
269
284
  `${ 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
+ };
@@ -0,0 +1,19 @@
1
+ const magento23RequiredPHPExtensions = [
2
+ 'bcmath',
3
+ 'ctype',
4
+ 'curl',
5
+ 'dom',
6
+ 'gd',
7
+ 'hash',
8
+ 'iconv',
9
+ 'intl',
10
+ 'mbstring',
11
+ 'openssl',
12
+ 'pdo_mysql',
13
+ 'simplexml',
14
+ 'soap',
15
+ 'xsl',
16
+ 'zip'
17
+ ];
18
+
19
+ module.exports = magento23RequiredPHPExtensions;