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

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 (234) hide show
  1. package/exec.js +71 -0
  2. package/index.js +1 -1
  3. package/lib/commands/cli.js +4 -6
  4. package/lib/commands/execute.js +3 -33
  5. package/lib/commands/import-db.js +1 -1
  6. package/lib/commands/logs.js +1 -1
  7. package/lib/commands/start.js +38 -20
  8. package/lib/commands/status.js +2 -0
  9. package/lib/config/docker.js +103 -85
  10. package/lib/config/get-project-configuration.js +3 -1
  11. package/lib/config/index.js +10 -7
  12. package/lib/config/magento/required-php-extensions/index.js +29 -0
  13. package/lib/config/magento/required-php-extensions/magento-2.3.js +19 -0
  14. package/lib/config/magento/required-php-extensions/magento-2.4.js +29 -0
  15. package/lib/config/php/base-repo.js +3 -0
  16. package/lib/config/php/extensions/apcu.js +12 -0
  17. package/lib/config/php/extensions/bcmath.js +7 -0
  18. package/lib/config/php/extensions/curl.js +11 -0
  19. package/lib/config/php/extensions/gd.js +14 -0
  20. package/lib/config/php/extensions/index.js +18 -2
  21. package/lib/config/php/extensions/intl.js +10 -0
  22. package/lib/config/php/extensions/opcache.js +10 -0
  23. package/lib/config/php/extensions/pdo_mysql.js +7 -0
  24. package/lib/config/php/extensions/soap.js +10 -0
  25. package/lib/config/php/extensions/sodium.js +10 -0
  26. package/lib/config/php/extensions/xdebug.js +8 -5
  27. package/lib/config/php/extensions/xsl.js +10 -0
  28. package/lib/config/php/extensions/zip.js +10 -0
  29. package/lib/config/php/{releases → versions}/index.js +0 -0
  30. package/lib/config/php/versions/php-7.2.js +23 -0
  31. package/lib/config/php/versions/php-7.3.js +23 -0
  32. package/lib/config/php/versions/php-7.4.js +23 -0
  33. package/lib/config/php/versions/php-8.1.js +23 -0
  34. package/lib/config/php-config.js +8 -12
  35. package/lib/config/port-config.js +2 -6
  36. package/lib/config/services/elasticsearch/base-repo.js +3 -0
  37. package/lib/config/services/elasticsearch/default-es-env.js +6 -0
  38. package/lib/config/services/elasticsearch/versions/elasticsearch-6.8.js +19 -0
  39. package/lib/config/services/elasticsearch/versions/index.js +5 -0
  40. package/lib/config/templates/magentorc.template +6 -6
  41. package/lib/config/templates/mariadb.template.cnf +191 -0
  42. package/lib/config/templates/php-fpm.template.conf +3 -3
  43. package/lib/config/templates/php.template.ini +12 -6
  44. package/lib/config/templates/ssl-terminator.template.conf +9 -4
  45. package/lib/config/templates/vscode-launch.template.json +3 -1
  46. package/lib/config/versions/magento-2.3.0.js +10 -5
  47. package/lib/config/versions/magento-2.3.1.js +10 -5
  48. package/lib/config/versions/magento-2.3.2-p1.js +43 -0
  49. package/lib/config/versions/magento-2.3.2-p2.js +10 -5
  50. package/lib/config/versions/magento-2.3.2.js +10 -5
  51. package/lib/config/versions/magento-2.3.3-p1.js +10 -5
  52. package/lib/config/versions/magento-2.3.3.js +10 -5
  53. package/lib/config/versions/magento-2.3.4-p1.js +43 -0
  54. package/lib/config/versions/magento-2.3.4-p2.js +10 -5
  55. package/lib/config/versions/magento-2.3.4.js +10 -5
  56. package/lib/config/versions/magento-2.3.5-p1.js +8 -2
  57. package/lib/config/versions/magento-2.3.5-p2.js +8 -2
  58. package/lib/config/versions/magento-2.3.5.js +8 -2
  59. package/lib/config/versions/magento-2.3.6-p1.js +8 -2
  60. package/lib/config/versions/magento-2.3.6.js +8 -2
  61. package/lib/config/versions/magento-2.3.7-p1.js +8 -2
  62. package/lib/config/versions/magento-2.3.7-p2.js +8 -2
  63. package/lib/config/versions/magento-2.3.7-p3.js +8 -2
  64. package/lib/config/versions/magento-2.3.7-p4.js +44 -0
  65. package/lib/config/versions/magento-2.3.7.js +8 -2
  66. package/lib/config/versions/magento-2.4.0-p1.js +9 -3
  67. package/lib/config/versions/magento-2.4.0.js +9 -3
  68. package/lib/config/versions/magento-2.4.1-p1.js +6 -5
  69. package/lib/config/versions/magento-2.4.1.js +9 -2
  70. package/lib/config/versions/magento-2.4.2-p1.js +6 -5
  71. package/lib/config/versions/magento-2.4.2-p2.js +6 -6
  72. package/lib/config/versions/magento-2.4.2.js +6 -6
  73. package/lib/config/versions/magento-2.4.3-p1.js +7 -7
  74. package/lib/config/versions/magento-2.4.3-p2.js +7 -7
  75. package/lib/config/versions/magento-2.4.3-p3.js +46 -0
  76. package/lib/config/versions/magento-2.4.3.js +7 -7
  77. package/lib/config/versions/magento-2.4.4-p1.js +46 -0
  78. package/lib/config/versions/magento-2.4.4.js +9 -2
  79. package/lib/config/versions/magento-2.4.5.js +46 -0
  80. package/lib/tasks/cleanup.js +3 -3
  81. package/lib/tasks/composer/index.js +14 -104
  82. package/lib/tasks/database/connect-to-database.js +117 -0
  83. package/lib/tasks/database/create-magento-database.js +18 -0
  84. package/lib/tasks/{mysql → database}/dump-theme-config.js +3 -3
  85. package/lib/tasks/{mysql → database}/fix-db.js +2 -2
  86. package/lib/tasks/{mysql/import-dump-to-mysql.js → database/import-dump-to-database.js} +65 -22
  87. package/lib/tasks/{mysql → database}/import-remote-db/index.js +0 -0
  88. package/lib/tasks/{mysql/import-remote-db/ssh/mysqldump-command.js → database/import-remote-db/ssh/database-dump-command.js} +2 -2
  89. package/lib/tasks/{mysql → database}/import-remote-db/ssh/index.js +0 -0
  90. package/lib/tasks/{mysql → database}/import-remote-db/ssh/readymage.js +4 -4
  91. package/lib/tasks/{mysql → database}/import-remote-db/ssh/regular-server.js +2 -2
  92. package/lib/tasks/{mysql → database}/index.js +2 -2
  93. package/lib/tasks/{mysql → database}/magento-tables.js +0 -0
  94. package/lib/tasks/{mysql → database}/restore-theme-config.js +4 -4
  95. package/lib/tasks/docker/api.d.ts +71 -0
  96. package/lib/tasks/docker/api.js +30 -0
  97. package/lib/tasks/docker/containers/container-api.d.ts +132 -0
  98. package/lib/tasks/docker/containers/container-api.js +163 -0
  99. package/lib/tasks/docker/containers/index.js +19 -0
  100. package/lib/tasks/docker/containers/tasks.js +215 -0
  101. package/lib/tasks/docker/convert-legacy-volumes.js +15 -10
  102. package/lib/tasks/docker/convert-mysql-to-mariadb.js +284 -0
  103. package/lib/tasks/docker/image/image-api.d.ts +34 -0
  104. package/lib/tasks/docker/image/image-api.js +49 -0
  105. package/lib/tasks/docker/image/index.js +5 -0
  106. package/lib/tasks/docker/index.js +1 -13
  107. package/lib/tasks/docker/network/index.js +7 -0
  108. package/lib/tasks/docker/network/network-api.d.ts +103 -0
  109. package/lib/tasks/docker/network/network-api.js +99 -0
  110. package/lib/tasks/docker/{network.js → network/tasks.js} +17 -10
  111. package/lib/tasks/docker/project-image-builder.js +167 -0
  112. package/lib/tasks/docker/volume/index.js +8 -0
  113. package/lib/tasks/docker/{volumes.js → volume/tasks.js} +5 -19
  114. package/lib/tasks/docker/volume/volume-api.d.ts +39 -0
  115. package/lib/tasks/docker/volume/volume-api.js +66 -0
  116. package/lib/tasks/execute.js +97 -0
  117. package/lib/tasks/file-system/create-mariadb-config.js +23 -0
  118. package/lib/tasks/file-system/create-nginx-config.js +2 -3
  119. package/lib/tasks/file-system/create-php-config.js +20 -5
  120. package/lib/tasks/file-system/create-php-fpm-config.js +8 -4
  121. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +41 -29
  122. package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -0
  123. package/lib/tasks/file-system/create-phpstorm-config/keys.js +15 -1
  124. package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +4 -1
  125. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-config.js +3 -3
  126. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-interpreters-config.js +81 -0
  127. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/index.js +42 -0
  128. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/php-docker-settings-config.js +9 -0
  129. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/setup-php-docker-container-settings-config.js +66 -0
  130. package/lib/tasks/file-system/create-phpstorm-config/setup-xml-structure.js +11 -9
  131. package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +2 -1
  132. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +15 -30
  133. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +24 -5
  134. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/mess-detector-project-configuration-config.js +50 -0
  135. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-code-sniffer-project-configuration-config.js +50 -0
  136. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-cs-fixer-project-configuration-config.js +50 -0
  137. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +15 -15
  138. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +29 -3
  139. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-stan-project-configuration-config.js.js +50 -0
  140. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +42 -0
  141. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/psalm-project-configuration-config.js.js +50 -0
  142. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/workspace-config.js +0 -2
  143. package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -2
  144. package/lib/tasks/file-system/create-vscode-config.js +57 -42
  145. package/lib/tasks/file-system/index.js +5 -2
  146. package/lib/tasks/import-dump.js +6 -6
  147. package/lib/tasks/link.js +5 -4
  148. package/lib/tasks/magento/enable-magento-composer-plugins.js +85 -30
  149. package/lib/tasks/magento/install-magento-project.js +32 -63
  150. package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +4 -4
  151. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +7 -3
  152. package/lib/tasks/magento/setup-magento/create-admin.js +5 -6
  153. package/lib/tasks/magento/setup-magento/delete-admin-users.js +2 -2
  154. package/lib/tasks/magento/setup-magento/delete-customers.js +4 -4
  155. package/lib/tasks/magento/setup-magento/delete-orders.js +4 -4
  156. package/lib/tasks/magento/setup-magento/disable-2fa.js +3 -5
  157. package/lib/tasks/magento/setup-magento/disable-maintenance-mode.js +3 -4
  158. package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +2 -2
  159. package/lib/tasks/magento/setup-magento/index.js +2 -0
  160. package/lib/tasks/magento/setup-magento/install-magento.js +21 -20
  161. package/lib/tasks/magento/setup-magento/migrate-database.js +7 -14
  162. package/lib/tasks/magento/setup-magento/set-base-url.js +3 -3
  163. package/lib/tasks/magento/setup-magento/set-deployment-mode.js +4 -4
  164. package/lib/tasks/magento/setup-magento/set-url-rewrite.js +2 -2
  165. package/lib/tasks/magento/setup-magento/varnish-config.js +10 -8
  166. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +130 -3
  167. package/lib/tasks/php/php-container.js +112 -0
  168. package/lib/tasks/php/update-env-php.js +39 -21
  169. package/lib/tasks/php/update-env.php +66 -61
  170. package/lib/tasks/php/working_health_check.php +85 -0
  171. package/lib/tasks/requirements/{composer.js → composer-credentials.js} +3 -1
  172. package/lib/tasks/requirements/docker/index.js +18 -13
  173. package/lib/tasks/requirements/docker/performance.js +54 -0
  174. package/lib/tasks/requirements/docker/version.js +8 -8
  175. package/lib/tasks/requirements/index.js +5 -8
  176. package/lib/tasks/requirements/php-version.js +8 -116
  177. package/lib/tasks/requirements/platform.js +12 -25
  178. package/lib/tasks/start.js +21 -50
  179. package/lib/tasks/status/index.js +8 -12
  180. package/lib/tasks/stop.js +0 -2
  181. package/lib/tasks/theme/install-theme.js +1 -1
  182. package/lib/tasks/theme/link-theme.js +2 -2
  183. package/lib/tasks/theme/symlink-theme.js +2 -3
  184. package/lib/util/config-file-validator.js +27 -13
  185. package/lib/util/config-php-json.js +13 -4
  186. package/lib/util/database.js +7 -7
  187. package/lib/util/dockerfile-builder/build-instructions.js +197 -0
  188. package/lib/util/dockerfile-builder/index.js +276 -0
  189. package/lib/util/dockerfile-builder/types.d.ts +123 -0
  190. package/lib/util/env-php-json.js +10 -6
  191. package/lib/util/exec-async-command.js +3 -9
  192. package/lib/util/execute-in-container.js +63 -0
  193. package/lib/util/macos-version.js +20 -0
  194. package/lib/util/magento-task.js +3 -4
  195. package/lib/util/nginx-logs-parser.js +122 -0
  196. package/lib/util/php-task.js +3 -6
  197. package/lib/util/run-composer.js +6 -14
  198. package/lib/util/run-container-image.js +17 -0
  199. package/lib/util/run-magento.js +6 -14
  200. package/lib/util/run-php.js +6 -17
  201. package/package.json +11 -10
  202. package/typings/context.d.ts +7 -13
  203. package/typings/index.d.ts +67 -85
  204. package/lib/config/composer.js +0 -11
  205. package/lib/config/php/extensions/libsodium.js +0 -36
  206. package/lib/config/php/releases/php-7.2.js +0 -25
  207. package/lib/config/php/releases/php-7.3.js +0 -25
  208. package/lib/config/php/releases/php-7.4.js +0 -23
  209. package/lib/config/php/releases/php-8.1.js +0 -25
  210. package/lib/config/phpbrew.js +0 -12
  211. package/lib/tasks/composer/install-prestissimo.js +0 -103
  212. package/lib/tasks/docker/containers.js +0 -231
  213. package/lib/tasks/execute/index.js +0 -23
  214. package/lib/tasks/mysql/connect-to-mysql.js +0 -114
  215. package/lib/tasks/mysql/create-magento-database.js +0 -18
  216. package/lib/tasks/php/bundled-extensions.js +0 -27
  217. package/lib/tasks/php/compile-options.js +0 -56
  218. package/lib/tasks/php/compile.js +0 -55
  219. package/lib/tasks/php/configure.js +0 -89
  220. package/lib/tasks/php/extensions/disable.js +0 -49
  221. package/lib/tasks/php/extensions/enable.js +0 -52
  222. package/lib/tasks/php/extensions/index.js +0 -80
  223. package/lib/tasks/php/extensions/install.js +0 -54
  224. package/lib/tasks/php/index.js +0 -79
  225. package/lib/tasks/php/install-sodium.js +0 -93
  226. package/lib/tasks/php/update-phpbrew.js +0 -45
  227. package/lib/tasks/php/validate-php.js +0 -67
  228. package/lib/tasks/php-fpm/get-process-id.js +0 -14
  229. package/lib/tasks/php-fpm/index.js +0 -4
  230. package/lib/tasks/php-fpm/start-php-fpm.js +0 -49
  231. package/lib/tasks/php-fpm/stop-php-fpm.js +0 -48
  232. package/lib/tasks/requirements/phpbrew/index.js +0 -61
  233. package/lib/tasks/requirements/phpbrew/install.js +0 -159
  234. package/lib/tasks/requirements/phpbrew/version.js +0 -28
@@ -1,132 +1,24 @@
1
- const logger = require('@scandipwa/scandipwa-dev-utils/logger');
2
- const fs = require('fs');
3
- const path = require('path');
4
- const semver = require('semver');
5
- const phpbrewConfig = require('../../config/phpbrew');
6
- const KnownError = require('../../errors/known-error');
7
1
  const UnknownError = require('../../errors/unknown-error');
8
- const { execAsyncSpawn } = require('../../util/exec-async-command');
9
- const { getBrewCommandSync } = require('../../util/get-brew-bin-path');
10
- const pathExists = require('../../util/path-exists');
11
- const compileOptions = require('../php/compile-options');
12
-
13
- const latestStablePHP74 = '7.4.27';
14
- const phpbrewPHPName = `php-${latestStablePHP74}-phpbrew`;
15
-
16
- /**
17
- * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
18
- */
19
- const installPHPForPHPBrew = () => ({
20
- title: `Installing PHP ${latestStablePHP74} for PHPBrew...`,
21
- task: async (ctx, task) => {
22
- const compileOptionsForPhp = {
23
- linux: {
24
- ...compileOptions.linux,
25
- variants: [
26
- '+default'
27
- ],
28
- extraOptions: []
29
- },
30
- darwin: {
31
- ...compileOptions.darwin,
32
- variants: [
33
- '+default',
34
- `+openssl=$(${getBrewCommandSync({ native: false })} --prefix openssl@1.1)`
35
- ],
36
- extraOptions: []
37
- }
38
- };
39
- const platformCompileOptions = compileOptionsForPhp[process.platform];
40
-
41
- if (!await pathExists(path.join(phpbrewConfig.phpPath, `${phpbrewPHPName}`, 'bin'))) {
42
- const commandEnv = Object.entries(platformCompileOptions.env || {}).map(([key, value]) => `${key}="${value}"`).join(' ');
43
- // eslint-disable-next-line max-len
44
- const compileCommand = ` ${commandEnv ? `${commandEnv} && ` : ''}phpbrew install -j ${platformCompileOptions.cpuCount} ${latestStablePHP74} as ${phpbrewPHPName} ${platformCompileOptions.variants.join(' ')}`;
45
-
46
- try {
47
- await execAsyncSpawn(
48
- compileCommand,
49
- {
50
- callback: (t) => {
51
- task.output = t;
52
- },
53
- useRosetta2: true
54
- }
55
- );
56
- } catch (e) {
57
- throw new KnownError(
58
- `Failed to compile the required by PHPBrew PHP version.
59
- Tried compiling the PHP version ${ latestStablePHP74 }.
60
- Use your favorite search engine to resolve the issue.
61
- See error details in the output below.\n\n${e}`
62
- );
63
- }
64
- }
65
-
66
- try {
67
- const phpbrewInitFileContent = `# DO NOT EDIT THIS FILE
68
-
69
- export PHPBREW_ROOT=${phpbrewConfig.homePath}
70
- export PHPBREW_HOME=${phpbrewConfig.homePath}
71
- export PHPBREW_PHP=${phpbrewPHPName}
72
- export PHPBREW_PATH=${phpbrewConfig.homePath}/php/${phpbrewPHPName}/bin
73
- # Run this command to configure your shell:
74
- # eval "$(phpbrew env)"\n`;
75
-
76
- await fs.promises.writeFile(
77
- path.join(phpbrewConfig.homePath, 'init'),
78
- phpbrewInitFileContent,
79
- {
80
- encoding: 'utf-8'
81
- }
82
- );
83
- } catch (e) {
84
- throw new UnknownError(`Something went wrong when trying to switch PHP to ${phpbrewPHPName}!\n\n${e}`);
85
- }
86
-
87
- throw new KnownError(`You will need to restart your terminal and run ${logger.style.command('start')} again.
88
-
89
- You can use keyboard shortcut ${logger.style.command('CTRL+D')} to close terminal.`);
90
- },
91
- options: {
92
- bottomBar: 10
93
- }
94
- });
2
+ const { runContainerImage } = require('../../util/run-container-image');
95
3
 
96
4
  /**
97
5
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
98
6
  */
99
7
  const checkPHPVersion = () => ({
100
- title: 'Checking system PHP version',
8
+ title: 'Checking container PHP version',
101
9
  task: async (ctx, task) => {
102
- const phpVersionResponse = await execAsyncSpawn('php --version');
10
+ const { php } = ctx.config.docker.getContainers(ctx.ports);
11
+ const phpVersionResponse = await runContainerImage(php.image, 'php --version');
103
12
 
104
13
  const phpVersionResponseResult = phpVersionResponse.match(/PHP\s(\d+\.\d+\.\d+)/i);
105
14
 
106
15
  if (phpVersionResponseResult && phpVersionResponseResult.length > 0) {
107
16
  const phpVersion = phpVersionResponseResult[1];
108
17
 
109
- if (semver.satisfies(phpVersion, '>=8.1.x')) {
110
- const userConfirmation = await task.prompt({
111
- type: 'Confirm',
112
- message: `You have PHP ${phpVersion} installed in the system.
113
- PHPBrew can work with this version but it will have a lot of warning.
114
- To fix that we will build special PHP version that will be used by PHPBrew, please confirm this action.`
115
- });
116
-
117
- if (userConfirmation) {
118
- return task.newListr(
119
- installPHPForPHPBrew,
120
- {
121
- rendererOptions: {
122
- collapse: false
123
- }
124
- }
125
- );
126
- }
127
- }
128
-
129
- task.title = `Using PHP version ${phpVersion} in system`;
18
+ ctx.phpVersion = phpVersion;
19
+ task.title = `Using PHP version ${phpVersion} in container`;
20
+ } else {
21
+ throw new UnknownError(`Cannot retrieve PHP Version!\n\n${phpVersionResponse}`);
130
22
  }
131
23
  }
132
24
  });
@@ -1,12 +1,12 @@
1
1
  const os = require('os');
2
- const macosVersion = require('macos-version');
2
+ const semver = require('semver');
3
3
  const systeminformation = require('systeminformation');
4
4
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
5
5
  const { platforms, darwinMinimalVersion } = require('../../config');
6
- const dependencyCheck = require('./dependency');
7
6
  const { getArch } = require('../../util/arch');
8
7
  const getIsWsl = require('../../util/is-wsl');
9
8
  const KnownError = require('../../errors/known-error');
9
+ const { getMacOSVersion } = require('../../util/macos-version');
10
10
 
11
11
  /**
12
12
  * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
@@ -16,6 +16,15 @@ const checkPlatform = () => ({
16
16
  task: async (ctx, task) => {
17
17
  const currentPlatform = os.platform();
18
18
 
19
+ ctx.arch = await getArch();
20
+
21
+ ctx.isArm = ctx.arch === 'arm64';
22
+ ctx.isWsl = await getIsWsl();
23
+
24
+ ctx.platform = currentPlatform;
25
+ ctx.platformVersion = currentPlatform !== 'darwin' ? os.release() : await getMacOSVersion();
26
+ ctx.isArmMac = ctx.isArm && ctx.platform === 'darwin';
27
+
19
28
  if (!platforms.includes(currentPlatform)) {
20
29
  throw new KnownError(
21
30
  `Your current OS platform is ${ logger.style.misc(currentPlatform) }.
@@ -23,38 +32,16 @@ const checkPlatform = () => ({
23
32
  );
24
33
  }
25
34
 
26
- if (macosVersion.isMacOS && !macosVersion.isGreaterThanOrEqualTo(darwinMinimalVersion)) {
35
+ if (currentPlatform === 'darwin' && !semver.gt(ctx.platformVersion, semver.coerce(darwinMinimalVersion).version)) {
27
36
  throw new KnownError(
28
37
  'Please update your system!',
29
38
  `MacOS bellow version ${ logger.style.misc(darwinMinimalVersion) } is not supported.`
30
39
  );
31
40
  }
32
41
 
33
- ctx.arch = await getArch();
34
-
35
- ctx.isArm = ctx.arch === 'arm64';
36
- ctx.isWsl = await getIsWsl();
37
-
38
- ctx.platform = currentPlatform;
39
- ctx.platformVersion = currentPlatform !== 'darwin' ? os.release() : macosVersion();
40
- ctx.isArmMac = ctx.isArm && ctx.platform === 'darwin';
41
-
42
42
  const { manufacturer, brand, cores } = await systeminformation.cpu();
43
43
 
44
44
  task.title = `Running on ${currentPlatform} ${ctx.platformVersion} (${manufacturer} ${brand} ${cores} threads)`;
45
-
46
- const installDependenciesTask = await dependencyCheck();
47
-
48
- if (installDependenciesTask) {
49
- return task.newListr(
50
- installDependenciesTask,
51
- {
52
- rendererOptions: {
53
- showTimer: false
54
- }
55
- }
56
- );
57
- }
58
45
  }
59
46
  });
60
47
 
@@ -3,23 +3,17 @@ const openBrowser = require('../util/open-browser');
3
3
  const getMagentoVersionConfig = require('../config/get-magento-version-config');
4
4
  const { saveConfiguration } = require('../config/save-config');
5
5
  const { getAvailablePorts, getCachedPorts } = require('../config/get-port-config');
6
- const { installComposer, installPrestissimo } = require('./composer');
6
+ const { getComposerVersionTask } = require('./composer');
7
7
  const { startServices } = require('./docker');
8
- const { installPhp, configurePhp } = require('./php');
9
8
  const { checkRequirements } = require('./requirements');
10
9
  const { createCacheFolder } = require('./cache');
11
- const { startPhpFpm, stopPhpFpm } = require('./php-fpm');
12
10
  const { prepareFileSystem } = require('./file-system');
13
11
  const { installMagentoProject, setupMagento } = require('./magento');
14
- const { pullContainers, stopContainers } = require('./docker/containers');
12
+ const { pullImages, stopContainers } = require('./docker/containers');
13
+ const dockerNetwork = require('./docker/network');
15
14
  const { setPrefix } = require('./prefix');
16
- const {
17
- connectToMySQL,
18
- importDumpToMySQL,
19
- fixDB,
20
- restoreThemeConfig,
21
- dumpThemeConfig
22
- } = require('./mysql');
15
+ const { connectToDatabase } = require('./database');
16
+ const { buildProjectImage, buildDebugProjectImage } = require('./docker/project-image-builder');
23
17
  const getProjectConfiguration = require('../config/get-project-configuration');
24
18
  const { getSystemConfigTask } = require('../config/system-config');
25
19
  const setupThemes = require('./theme/setup-themes');
@@ -30,9 +24,10 @@ const enableMagentoComposerPlugins = require('./magento/enable-magento-composer-
30
24
  const getIsWsl = require('../util/is-wsl');
31
25
  const checkForXDGOpen = require('../util/xdg-open-exists');
32
26
  const { getInstanceMetadata, constants: { WEB_LOCATION_TITLE } } = require('../util/instance-metadata');
33
- const validatePHPInstallation = require('./php/validate-php');
34
- const installSodiumExtension = require('./php/install-sodium');
35
27
  const waitingForVarnish = require('./magento/setup-magento/waiting-for-varnish');
28
+ const checkPHPVersion = require('./requirements/php-version');
29
+ const volumes = require('./docker/volume/tasks');
30
+ const convertMySQLDatabaseToMariaDB = require('./docker/convert-mysql-to-mariadb');
36
31
 
37
32
  /**
38
33
  * @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
@@ -63,15 +58,8 @@ const retrieveProjectConfiguration = () => ({
63
58
  const stopProject = () => ({
64
59
  title: 'Stopping project',
65
60
  task: (ctx, task) => task.newListr([
66
- stopContainers(),
67
- stopPhpFpm()
68
- ], {
69
- concurrent: true,
70
- rendererOptions: {
71
- collapse: true,
72
- showTimer: false
73
- }
74
- }),
61
+ stopContainers()
62
+ ]),
75
63
  options: {
76
64
  showTimer: false
77
65
  }
@@ -104,26 +92,25 @@ const retrieveFreshProjectConfiguration = () => ({
104
92
  const configureProject = () => ({
105
93
  title: 'Configuring project',
106
94
  task: (ctx, task) => task.newListr([
107
- installPhp(),
108
- installComposer(),
95
+ convertMySQLDatabaseToMariaDB(),
96
+ pullImages(),
97
+ dockerNetwork.tasks.createNetwork(),
98
+ volumes.createVolumes(),
109
99
  {
110
100
  task: (ctx, task) => task.newListr([
111
- prepareFileSystem(),
112
- pullContainers()
101
+ buildProjectImage(),
102
+ buildDebugProjectImage()
113
103
  ], {
114
- concurrent: true,
115
- exitOnError: true
104
+ concurrent: true
116
105
  })
117
106
  },
118
- installSodiumExtension(),
119
- configurePhp(),
120
- validatePHPInstallation(),
121
- installPrestissimo(),
107
+ checkPHPVersion(),
108
+ getComposerVersionTask(),
109
+ prepareFileSystem(),
122
110
  installMagentoProject(),
123
111
  enableMagentoComposerPlugins(),
124
- startPhpFpm(),
125
112
  startServices(),
126
- connectToMySQL()
113
+ connectToDatabase()
127
114
  ])
128
115
  });
129
116
 
@@ -134,22 +121,6 @@ const finishProjectConfiguration = () => ({
134
121
  title: 'Finishing project configuration',
135
122
  skip: ({ skipSetup }) => skipSetup,
136
123
  task: (ctx, task) => task.newListr([
137
- {
138
- skip: (ctx) => !ctx.importDb,
139
- task: (ctx, task) => {
140
- task.title = 'Importing database dump';
141
- return task.newListr([
142
- dumpThemeConfig(),
143
- importDumpToMySQL(),
144
- fixDB(),
145
- restoreThemeConfig(),
146
- setupMagento()
147
- ], {
148
- concurrent: false,
149
- exitOnError: true
150
- });
151
- }
152
- },
153
124
  setupThemes(),
154
125
  waitingForVarnish()
155
126
  ], {
@@ -25,19 +25,16 @@ const parsePort = (port) => {
25
25
  const prettyStatus = async (ctx) => {
26
26
  const {
27
27
  config: {
28
- baseConfig,
29
- php,
30
- composer
28
+ baseConfig
31
29
  },
32
30
  magentoVersion,
33
31
  dockerVersion,
34
- PHPBrewVersion,
35
32
  platform,
36
33
  platformVersion,
37
34
  containers
38
35
  } = ctx;
39
36
  const projectCreatedAt = getProjectCreatedAt();
40
- const composerVersion = await getComposerVersion({ composer, php });
37
+ const composerVersion = await getComposerVersion(ctx);
41
38
 
42
39
  const prefix = getPrefix();
43
40
 
@@ -48,7 +45,7 @@ const prettyStatus = async (ctx) => {
48
45
  block
49
46
  .addHeader(`magento-scripts version: ${ logger.style.link(packageVersion) }`)
50
47
  .addEmptyLine()
51
- .addLine(`Project: ${logger.style.file(baseConfig.prefix)} ${prefix === folderName ? '(without prefix)' : '(with prefix)'}`)
48
+ .addLine(`Project: ${logger.style.file(baseConfig.prefix)} ${prefix === folderName ? '(without prefix)' : '(with prefix)'} (with php container)`)
52
49
  .addLine(`Project location: ${logger.style.link(process.cwd())}`);
53
50
 
54
51
  if (projectCreatedAt) {
@@ -57,12 +54,9 @@ const prettyStatus = async (ctx) => {
57
54
 
58
55
  block
59
56
  .addLine(`Magento 2 version: ${logger.style.file(magentoVersion)}`)
60
- .addLine(`PHP version: ${logger.style.file(php.version)}`)
61
- .addLine(`PHP location: ${logger.style.link(php.binPath)}`)
57
+ .addLine(`PHP version: ${logger.style.file(ctx.phpVersion)}`)
62
58
  .addLine(`Composer version: ${logger.style.file(composerVersion)}`)
63
- .addLine(`Composer location: ${logger.style.link(path.relative(process.cwd(), composer.binPath))}`)
64
59
  .addLine(`Docker version: ${logger.style.file(dockerVersion)}`)
65
- .addLine(`PHPBrew version: ${logger.style.file(PHPBrewVersion)}`)
66
60
  .addLine(`Platform: ${logger.style.code(platform)}`)
67
61
  .addLine(`Platform version: ${logger.style.file(platformVersion)}`)
68
62
  .addLine(`Platform architecture: ${logger.style.file(getArchSync())}`)
@@ -79,8 +73,10 @@ const prettyStatus = async (ctx) => {
79
73
 
80
74
  if (container.status && container.status.Health) {
81
75
  containerStatus = `✓ ${ logger.style.file(container.status.Health.Status) } and ${ logger.style.file('running') }`;
82
- } else {
76
+ } else if (container.status) {
83
77
  containerStatus = logger.style.file(container.status.Status);
78
+ } else {
79
+ containerStatus = '✖ Not running';
84
80
  }
85
81
 
86
82
  block
@@ -89,7 +85,7 @@ const prettyStatus = async (ctx) => {
89
85
  .addLine(`Image: ${logger.style.file(container.image)}`)
90
86
  .addLine(`Network: ${logger.style.link(container.network)}`);
91
87
 
92
- if (container.forwardedPorts && container.forwardedPorts.length > 0) {
88
+ if (!containerStatus.includes('Not running') && container.forwardedPorts && container.forwardedPorts.length > 0) {
93
89
  block.addLine('Port forwarding:');
94
90
  container.forwardedPorts.forEach((port) => {
95
91
  const { host, hostPort, containerPort } = parsePort(port);
package/lib/tasks/stop.js CHANGED
@@ -1,6 +1,5 @@
1
1
  const { stopServices } = require('./docker');
2
2
  const getMagentoVersionConfig = require('../config/get-magento-version-config');
3
- const { stopPhpFpm } = require('./php-fpm');
4
3
  const getProjectConfiguration = require('../config/get-project-configuration');
5
4
  const checkConfigurationFile = require('../config/check-configuration-file');
6
5
 
@@ -13,7 +12,6 @@ const stop = () => ({
13
12
  getMagentoVersionConfig(),
14
13
  checkConfigurationFile(),
15
14
  getProjectConfiguration(),
16
- stopPhpFpm(),
17
15
  stopServices()
18
16
  ], {
19
17
  concurrent: false,
@@ -18,7 +18,7 @@ const installTheme = (theme) => ({
18
18
  }
19
19
 
20
20
  try {
21
- await runComposerCommand(`require ${theme.composerData.name}`, {
21
+ await runComposerCommand(ctx, `require ${theme.composerData.name}`, {
22
22
  magentoVersion,
23
23
  callback: !verbose ? undefined : (t) => {
24
24
  task.output = t;
@@ -18,7 +18,7 @@ const linkTheme = () => ({
18
18
  absoluteThemePath,
19
19
  themePath,
20
20
  composerData,
21
- mysqlConnection
21
+ databaseConnection
22
22
  } = ctx;
23
23
  const {
24
24
  magento: { edition: magentoEdition },
@@ -27,7 +27,7 @@ const linkTheme = () => ({
27
27
 
28
28
  const isEnterprise = magentoEdition === 'enterprise';
29
29
  const isPageBuilderInstalled = isEnterprise && semver.satisfies(semver.coerce(magentoVersion), '^2.4');
30
- const [queryResult] = await mysqlConnection.query(`
30
+ const [queryResult] = await databaseConnection.query(`
31
31
  SELECT value AS isPagebuilderEnabled
32
32
  FROM core_config_data
33
33
  WHERE path = 'cms/pagebuilder/enabled'
@@ -9,7 +9,7 @@ const runComposerCommand = require('../../util/run-composer');
9
9
  const symlinkTheme = (theme) => ({
10
10
  title: 'Setting symbolic link for theme in composer.json',
11
11
  task: async (ctx, task) => {
12
- const { magentoVersion, verbose = false } = ctx;
12
+ const { verbose = false } = ctx;
13
13
  const composerJsonData = await getJsonfileData(path.join(process.cwd(), 'composer.json'));
14
14
 
15
15
  if (!composerJsonData.repositories) {
@@ -27,8 +27,7 @@ const symlinkTheme = (theme) => ({
27
27
  }
28
28
 
29
29
  try {
30
- await runComposerCommand(`config repo.scandipwa path ${theme.absoluteThemePath}`, {
31
- magentoVersion,
30
+ await runComposerCommand(ctx, `config repo.scandipwa path ${theme.absoluteThemePath}`, {
32
31
  callback: !verbose ? undefined : (t) => {
33
32
  task.output = t;
34
33
  }
@@ -46,10 +46,16 @@ const sslSchema = Joi.object({
46
46
  ssl_certificate_key: Joi.string().required()
47
47
  });
48
48
 
49
+ /**
50
+ * @type {Joi.ObjectSchema<import('../../typings/index').PHPExtensions>}
51
+ */
49
52
  const phpExtensionConfiguration = Joi.object()
50
53
  .pattern(
51
54
  Joi.string(),
52
55
  Joi.object({
56
+ alternativeName: Joi.array().items(Joi.string()).optional(),
57
+ command: Joi.func().optional(),
58
+ dependencies: Joi.array().items(Joi.string()).optional(),
53
59
  version: Joi.string().optional()
54
60
  })
55
61
  .unknown()
@@ -59,38 +65,47 @@ const phpExtensionConfiguration = Joi.object()
59
65
  * @type {Joi.ObjectSchema<import('../../typings').PHPConfiguration>}
60
66
  */
61
67
  const phpConfigurationSchema = Joi.object({
62
- version: Joi.string().optional().custom(versionValidator),
68
+ baseImage: Joi.string().optional(),
69
+ debugImage: Joi.string().optional(),
70
+ fpmConfigTemplate: Joi.string().optional(),
63
71
  configTemplate: Joi.string().optional().custom(fileExistsValidator),
64
- extensions: phpExtensionConfiguration.optional(),
65
- disabledExtensions: Joi.array().items(Joi.string())
72
+ extensions: phpExtensionConfiguration.optional()
66
73
  });
67
74
 
68
75
  /**
69
76
  * @type {Joi.ObjectSchema<import('../../typings').NginxConfiguration>}
70
77
  */
71
78
  const nginxConfigurationSchema = Joi.object({
72
- version: Joi.string().optional(),
79
+ image: Joi.string().optional(),
73
80
  configTemplate: Joi.string().optional().custom(fileExistsValidator)
74
81
  });
75
82
 
76
83
  /**
77
- * @type {Joi.ObjectSchema<import('../../typings').NginxConfiguration>}
84
+ * @type {Joi.ObjectSchema<import('../../typings').VarnishConfiguration>}
78
85
  */
79
86
  const varnishConfigurationSchema = Joi.object({
80
87
  enabled: Joi.boolean().optional(),
81
- version: Joi.string().optional(),
88
+ image: Joi.string().optional(),
82
89
  configTemplate: Joi.string().optional().custom(fileExistsValidator)
83
90
  });
84
91
 
85
92
  /**
86
- * @type {Joi.ObjectSchema<import('../../typings').ServiceWithVersion>}
93
+ * @type {Joi.ObjectSchema<import('../../typings').ServiceWithImage>}
87
94
  */
88
95
  const serviceConfigurationSchema = Joi.object({
89
- version: Joi.string().optional()
96
+ image: Joi.string().optional()
97
+ });
98
+
99
+ /**
100
+ * @type {Joi.ObjectSchema<import('../../typings').ElasticSearchConfiguration>}
101
+ */
102
+ const elasticsearchConfigurationSchema = Joi.object({
103
+ image: Joi.string().optional(),
104
+ env: Joi.object().optional()
90
105
  });
91
106
 
92
107
  /**
93
- * @type {Joi.ObjectSchema<import('../../typings').CMAConfiguration['configuration']['composer']>}
108
+ * @type {Joi.ObjectSchema<import('../../typings').ComposerConfiguration>}
94
109
  */
95
110
  const composerConfigurationSchema = Joi.object({
96
111
  version: Joi.string().optional().custom((value) => {
@@ -108,8 +123,8 @@ const composerConfigurationSchema = Joi.object({
108
123
  const configurationSchema = Joi.object({
109
124
  php: phpConfigurationSchema.optional(),
110
125
  nginx: nginxConfigurationSchema.optional(),
111
- mysql: serviceConfigurationSchema.optional(),
112
- elasticsearch: serviceConfigurationSchema.optional(),
126
+ mariadb: serviceConfigurationSchema.optional(),
127
+ elasticsearch: elasticsearchConfigurationSchema.optional(),
113
128
  redis: serviceConfigurationSchema.optional(),
114
129
  composer: composerConfigurationSchema.optional(),
115
130
  varnish: varnishConfigurationSchema.optional(),
@@ -124,8 +139,7 @@ const configFileSchema = Joi.object({
124
139
  host: Joi.string().optional(),
125
140
  ssl: sslSchema.optional(),
126
141
  prefix: Joi.bool().optional(),
127
- configuration: configurationSchema.required(),
128
- useNonOverlappingPorts: Joi.bool().forbidden()
142
+ configuration: configurationSchema.required()
129
143
  });
130
144
 
131
145
  /**
@@ -1,10 +1,19 @@
1
1
  const path = require('path');
2
2
  const UnknownError = require('../errors/unknown-error');
3
- const runPhpCode = require('./run-php');
3
+ const { runPHPContainerCommand } = require('../tasks/php/php-container');
4
+ const pathExists = require('./path-exists');
4
5
 
5
- const configPhpToJson = async (projectPath = process.cwd(), { magentoVersion }) => {
6
- const { code, result } = await runPhpCode(`-r "echo json_encode(require '${path.join(projectPath, 'app', 'etc', 'config.php')}');"`, {
7
- magentoVersion
6
+ /**
7
+ * @param {import('../../typings/context').ListrContext} ctx
8
+ */
9
+ const configPhpToJson = async (ctx) => {
10
+ const configPhpOnSystemPath = path.join(ctx.config.baseConfig.magentoDir, 'app', 'etc', 'config.php');
11
+ const configPhpInContainerPath = path.join(ctx.config.baseConfig.containerMagentoDir, 'app', 'etc', 'config.php');
12
+ if (!await pathExists(configPhpOnSystemPath)) {
13
+ return null;
14
+ }
15
+ const { code, result } = await runPHPContainerCommand(ctx, `php -r "echo json_encode(require '${configPhpInContainerPath}');"`, {
16
+ withCode: true
8
17
  });
9
18
 
10
19
  if (code !== 0) {
@@ -4,8 +4,8 @@
4
4
  * @param {{path: string, value: string}[]} values
5
5
  * @param {import('../../typings/context').ListrContext} param1
6
6
  */
7
- const updateTableValues = async (table, values, { mysqlConnection, task }) => {
8
- const [rows] = await mysqlConnection.query(`
7
+ const updateTableValues = async (table, values, { databaseConnection, task }) => {
8
+ const [rows] = await databaseConnection.query(`
9
9
  SELECT * FROM ${table}
10
10
  WHERE ${values.map((p) => `path = '${p.path}'`).join(' OR ')};
11
11
  `);
@@ -13,7 +13,7 @@ const updateTableValues = async (table, values, { mysqlConnection, task }) => {
13
13
  if (rows.filter(Boolean).length !== values.length) {
14
14
  const lostConfigs = values.filter((p) => !rows.some((row) => row.path === p.path));
15
15
  for (const config of lostConfigs) {
16
- await mysqlConnection.query(`
16
+ await databaseConnection.query(`
17
17
  INSERT INTO ${table}
18
18
  (scope, path, value)
19
19
  VALUES ('default', ?, ?);
@@ -22,7 +22,7 @@ const updateTableValues = async (table, values, { mysqlConnection, task }) => {
22
22
 
23
23
  const configsToUpdate = values.filter((p) => rows.some((row) => row.path === p.path));
24
24
  for (const config of configsToUpdate) {
25
- await mysqlConnection.query(`
25
+ await databaseConnection.query(`
26
26
  UPDATE ${table}
27
27
  SET value = ?
28
28
  WHERE path = ?;
@@ -50,7 +50,7 @@ const updateTableValues = async (table, values, { mysqlConnection, task }) => {
50
50
  });
51
51
 
52
52
  for (const config of configsToUpdate) {
53
- await mysqlConnection.query(`
53
+ await databaseConnection.query(`
54
54
  UPDATE ${table}
55
55
  SET value = ?
56
56
  WHERE path = ?;
@@ -63,11 +63,11 @@ const updateTableValues = async (table, values, { mysqlConnection, task }) => {
63
63
  * @param {String} tableName
64
64
  * @param {import('../../typings/context').ListrContext} param2
65
65
  */
66
- const isTableExists = async (database, tableName, { mysqlConnection }) => {
66
+ const isTableExists = async (database, tableName, { databaseConnection }) => {
67
67
  /**
68
68
  * @type {{ tableCount: number }[][]}
69
69
  */
70
- const [[{ tableCount }]] = await mysqlConnection.query(`
70
+ const [[{ tableCount }]] = await databaseConnection.query(`
71
71
  SELECT count(*) as tableCount
72
72
  FROM information_schema.TABLES
73
73
  WHERE (TABLE_SCHEMA = ?) AND (TABLE_NAME = ?);