@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
package/lib/tasks/link.js CHANGED
@@ -4,22 +4,23 @@ const getProjectConfiguration = require('../config/get-project-configuration');
4
4
  const retrieveThemeData = require('./theme/retrieve-theme-data');
5
5
  const linkTheme = require('./theme/link-theme');
6
6
  const { startServices } = require('./docker');
7
- const { startPhpFpm } = require('./php-fpm');
8
7
  const checkConfigurationFile = require('../config/check-configuration-file');
9
- const { connectToMySQL } = require('./mysql');
8
+ const { connectToDatabase } = require('./database');
9
+ const { checkRequirements } = require('./requirements');
10
10
 
11
11
  /**
12
12
  * @type {(theme: string) => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
13
13
  */
14
14
  const linkTask = (themePath) => ({
15
15
  task: (ctx, task) => task.newListr([
16
+ checkRequirements(),
16
17
  getMagentoVersionConfig(),
17
18
  checkConfigurationFile(),
18
19
  getProjectConfiguration(),
19
20
  getCachedPorts(),
20
21
  startServices(),
21
- startPhpFpm(),
22
- connectToMySQL(),
22
+ // startPhpFpm(),
23
+ connectToDatabase(),
23
24
  retrieveThemeData(themePath),
24
25
  linkTheme()
25
26
  ])
@@ -4,7 +4,6 @@ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
4
4
  const semver = require('semver');
5
5
  const pathExists = require('../../util/path-exists');
6
6
  const getJsonfileData = require('../../util/get-jsonfile-data');
7
- const KnownError = require('../../errors/known-error');
8
7
 
9
8
  const vendorPath = path.join(process.cwd(), 'vendor');
10
9
  const composerJsonPath = path.join(process.cwd(), 'composer.json');
@@ -86,29 +85,80 @@ const enableMagentoComposerPlugins = () => ({
86
85
  } = composerJsonData;
87
86
  const allowPluginsKeys = Object.keys(allowPlugins);
88
87
 
88
+ const missingPluginsFromAllowPlugins = composerPlugins.filter((plugin) => {
89
+ const [pluginVendor, pluginName] = plugin.split('/');
90
+ return !allowPluginsKeys.some((allowedPlugin) => {
91
+ const [allowedPluginVendor, allowedPluginName] = allowedPlugin.split('/');
92
+ if (allowedPluginVendor === pluginVendor) {
93
+ if (allowedPluginName === '*') {
94
+ return true;
95
+ }
96
+
97
+ return allowedPluginName === pluginName;
98
+ }
99
+
100
+ return false;
101
+ });
102
+ });
103
+
89
104
  if (
90
105
  allowPluginsKeys.length === 0
91
- || composerPlugins.some((p) => !allowPluginsKeys.includes(p))
106
+ || missingPluginsFromAllowPlugins.length > 0
92
107
  ) {
93
- const missingPlugins = composerPlugins.filter((p) => !allowPluginsKeys.includes(p));
108
+ const missingVendors = missingPluginsFromAllowPlugins.reduce((acc, val) => {
109
+ const [pluginVendor] = val.split('/');
110
+
111
+ if (acc.length === 0) {
112
+ return [pluginVendor];
113
+ }
114
+
115
+ if (!acc.includes(pluginVendor)) {
116
+ return [...acc, pluginVendor];
117
+ }
118
+
119
+ return acc;
120
+ }, []);
121
+
122
+ const pluginOptions = [
123
+ {
124
+ name: 'all-individual',
125
+ message: 'Enable all individually'
126
+ },
127
+ {
128
+ name: 'manual',
129
+ message: 'Configure manually'
130
+ },
131
+ {
132
+ name: 'skip',
133
+ message: 'Skip this step'
134
+ }
135
+ ];
136
+
137
+ if (missingVendors.length === 1) {
138
+ pluginOptions.unshift({
139
+ name: 'all',
140
+ message: `Enable all (${logger.style.code(`"${missingVendors[0]}/*"`)})`
141
+ });
142
+ }
143
+
94
144
  const answerForEnablingPlugins = await task.prompt({
95
145
  type: 'Select',
96
146
  message: `Composer 2.2 requires manually allowing composer-plugins to run.
97
147
  Magento requires the following plugins to correctly operate:
98
148
 
99
- ${missingPlugins.map((p) => logger.style.code(p)).join('\n')}
149
+ ${missingPluginsFromAllowPlugins.map((p) => logger.style.code(p)).join('\n')}
100
150
 
101
151
  Do you want to enable them all or disable some of them?`,
102
- choices: ['Enable all', 'Configure manually', 'Skip this step']
152
+ choices: pluginOptions
103
153
  });
104
154
 
105
155
  switch (answerForEnablingPlugins.toLowerCase()) {
106
- case 'enable all': {
156
+ case 'all': {
107
157
  composerJsonData.config = {
108
158
  ...(composerJsonData.config || {}),
109
159
  'allow-plugins': {
110
160
  ...allowPlugins,
111
- ...missingPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
161
+ [`${missingVendors[0]}/*`]: true
112
162
  }
113
163
  };
114
164
 
@@ -117,36 +167,41 @@ Do you want to enable them all or disable some of them?`,
117
167
  });
118
168
  break;
119
169
  }
120
- case 'configure manually': {
170
+ case 'all-individual': {
171
+ composerJsonData.config = {
172
+ ...(composerJsonData.config || {}),
173
+ 'allow-plugins': {
174
+ ...allowPlugins,
175
+ ...missingPluginsFromAllowPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
176
+ }
177
+ };
178
+
179
+ await fs.promises.writeFile(composerJsonPath, JSON.stringify(composerJsonData, null, 4), {
180
+ encoding: 'utf-8'
181
+ });
182
+ break;
183
+ }
184
+ case 'manual': {
121
185
  const userEnabledPlugins = await task.prompt({
122
186
  type: 'MultiSelect',
123
187
  message: 'Please pick plugins you want to enable!',
124
- choices: missingPlugins.map((p) => ({ name: p }))
188
+ choices: missingPluginsFromAllowPlugins.map((p) => ({ name: p }))
125
189
  });
126
190
 
127
- const userConfirmation = await task.prompt({
128
- type: 'Confirm',
129
- message: `Please confirm enabling of the following plugins:\n\n${userEnabledPlugins.map((p) => logger.style.code(p)).join('\n')}\n`
130
- });
191
+ const disabledPlugins = composerPlugins.filter((p) => !userEnabledPlugins.includes(p));
131
192
 
132
- if (userConfirmation) {
133
- const disabledPlugins = composerPlugins.filter((p) => !userEnabledPlugins.includes(p));
134
-
135
- composerJsonData.config = {
136
- ...(composerJsonData.config || {}),
137
- 'allow-plugins': {
138
- ...allowPlugins,
139
- ...disabledPlugins.reduce((acc, val) => ({ ...acc, [val]: false }), {}),
140
- ...userEnabledPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
141
- }
142
- };
193
+ composerJsonData.config = {
194
+ ...(composerJsonData.config || {}),
195
+ 'allow-plugins': {
196
+ ...allowPlugins,
197
+ ...disabledPlugins.reduce((acc, val) => ({ ...acc, [val]: false }), {}),
198
+ ...userEnabledPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
199
+ }
200
+ };
143
201
 
144
- await fs.promises.writeFile(composerJsonPath, JSON.stringify(composerJsonData, null, 4), {
145
- encoding: 'utf-8'
146
- });
147
- } else {
148
- throw new KnownError('Please confirm your choice or choose other option.');
149
- }
202
+ await fs.promises.writeFile(composerJsonPath, JSON.stringify(composerJsonData, null, 4), {
203
+ encoding: 'utf-8'
204
+ });
150
205
 
151
206
  break;
152
207
  }
@@ -1,32 +1,27 @@
1
1
  const path = require('path');
2
2
  const fs = require('fs');
3
- const os = require('os');
3
+ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
4
4
  const runComposerCommand = require('../../util/run-composer');
5
5
  const matchFilesystem = require('../../util/match-filesystem');
6
- const moveFile = require('../../util/move-file');
7
6
  const pathExists = require('../../util/path-exists');
8
7
  const getJsonFileData = require('../../util/get-jsonfile-data');
9
- const rmdirSafe = require('../../util/rmdir-safe');
10
8
  const KnownError = require('../../errors/known-error');
11
9
  const UnknownError = require('../../errors/unknown-error');
12
- const logger = require('@scandipwa/scandipwa-dev-utils/logger');
10
+ const { runPHPContainerCommand } = require('../php/php-container');
13
11
 
14
12
  const magentoProductEnterpriseEdition = 'magento/product-enterprise-edition';
15
13
  const magentoProductCommunityEdition = 'magento/product-community-edition';
16
14
 
17
15
  /**
18
- * Adjust composer.json file configuration for magento
16
+ * @param {import('../../../typings/context').ListrContext} ctx
17
+ * @param {import('listr2').ListrTaskWrapper<import('../../../typings/context').ListrContext>} task
19
18
  */
20
- const adjustComposerJson = async ({
21
- baseConfig,
19
+ const adjustComposerJson = async (ctx, task, {
22
20
  magentoEdition,
23
21
  magentoProductSelectedEdition,
24
- magentoVersion,
25
- magentoPackageVersion,
26
- task,
27
- verbose
22
+ magentoPackageVersion
28
23
  }) => {
29
- const composerData = await getJsonFileData(path.join(baseConfig.magentoDir, 'composer.json'));
24
+ const composerData = await getJsonFileData(path.join(ctx.config.baseConfig.magentoDir, 'composer.json'));
30
25
 
31
26
  // fix composer magento repository
32
27
  if (composerData && (!composerData.repositories
@@ -37,9 +32,8 @@ const adjustComposerJson = async ({
37
32
  && !Object.values(composerData.repositories).some((repo) => repo.type === 'composer' && repo.url.includes('repo.magento.com')))
38
33
  )) {
39
34
  task.output = 'No Magento repository is set in composer.json! Setting up...';
40
- await runComposerCommand('config repo.0 composer https://repo.magento.com', {
41
- magentoVersion,
42
- callback: !verbose ? undefined : (t) => {
35
+ await runComposerCommand(ctx, 'config repo.0 composer https://repo.magento.com', {
36
+ callback: !ctx.verbose ? undefined : (t) => {
43
37
  task.output = t;
44
38
  }
45
39
  });
@@ -48,10 +42,9 @@ const adjustComposerJson = async ({
48
42
  // if composer-root-update-plugin is not installed in composer, install it.
49
43
  if (composerData && !composerData.require['magento/composer-root-update-plugin']) {
50
44
  task.output = 'Installing magento/composer-root-update-plugin!';
51
- await runComposerCommand('require magento/composer-root-update-plugin:^1',
45
+ await runComposerCommand(ctx, 'require magento/composer-root-update-plugin:^1',
52
46
  {
53
- magentoVersion,
54
- callback: !verbose ? undefined : (t) => {
47
+ callback: !ctx.verbose ? undefined : (t) => {
55
48
  task.output = t;
56
49
  }
57
50
  });
@@ -62,7 +55,8 @@ const adjustComposerJson = async ({
62
55
  && composerData.require[magentoProductCommunityEdition]
63
56
  && composerData.require[magentoProductEnterpriseEdition]
64
57
  ) {
65
- throw new KnownError('Somehow, both Magento editions are installed!\nPlease choose only one edition an modify your composer.json manually!');
58
+ throw new KnownError(`Somehow, both Magento editions are installed!
59
+ Please choose only one edition an modify your composer.json manually!`);
66
60
  }
67
61
 
68
62
  const oppositeEdition = [magentoProductCommunityEdition, magentoProductEnterpriseEdition]
@@ -76,13 +70,11 @@ Change magento edition in config file or manually reinstall correct magento edit
76
70
  }
77
71
 
78
72
  // if magento package is not installed in composer, require it.
79
-
80
73
  if (composerData && !composerData.require[magentoProductSelectedEdition]) {
81
74
  task.output = `Installing ${magentoProductSelectedEdition}=${magentoPackageVersion}!`;
82
- await runComposerCommand(`require ${magentoProductSelectedEdition}:${magentoPackageVersion}`,
75
+ await runComposerCommand(ctx, `require ${magentoProductSelectedEdition}:${magentoPackageVersion}`,
83
76
  {
84
- magentoVersion,
85
- callback: !verbose ? undefined : (t) => {
77
+ callback: !ctx.verbose ? undefined : (t) => {
86
78
  task.output = t;
87
79
  }
88
80
  });
@@ -90,16 +82,14 @@ Change magento edition in config file or manually reinstall correct magento edit
90
82
  };
91
83
 
92
84
  /**
93
- * Create Magento Project
85
+ * @param {import('../../../typings/context').ListrContext} ctx
86
+ * @param {import('listr2').ListrTaskWrapper<import('../../../typings/context').ListrContext>} task
94
87
  */
95
- const createMagentoProject = async ({
88
+ const createMagentoProject = async (ctx, task, {
96
89
  magentoProject,
97
- magentoPackageVersion,
98
- magentoVersion,
99
- task,
100
- verbose
90
+ magentoPackageVersion
101
91
  }) => {
102
- const tempDir = path.join(os.tmpdir(), `magento-tmpdir-${Date.now()}`);
92
+ const tempDir = `/tmp/magento-tmpdir-${Date.now()}`;
103
93
  const installCommand = [
104
94
  'create-project',
105
95
  `--repository=https://repo.magento.com/ ${magentoProject}=${magentoPackageVersion}`,
@@ -107,22 +97,9 @@ const createMagentoProject = async ({
107
97
  `"${tempDir}"`
108
98
  ];
109
99
 
110
- await runComposerCommand(
111
- installCommand.join(' '),
112
- {
113
- magentoVersion,
114
- callback: !verbose ? undefined : (t) => {
115
- task.output = t;
116
- }
117
- }
118
- );
119
-
120
- await moveFile({
121
- from: path.join(tempDir, 'composer.json'),
122
- to: path.join(process.cwd(), 'composer.json')
123
- });
124
-
125
- await rmdirSafe(tempDir);
100
+ await runPHPContainerCommand(ctx, `bash -c 'mkdir ${tempDir} && \
101
+ composer ${installCommand.join(' ')} && \
102
+ mv ${tempDir}/composer.json ${ctx.config.baseConfig.containerMagentoDir}/composer.json'`);
126
103
  };
127
104
 
128
105
  /**
@@ -131,7 +108,7 @@ const createMagentoProject = async ({
131
108
  const installMagentoProject = () => ({
132
109
  title: 'Installing Magento Project',
133
110
  task: async (ctx, task) => {
134
- const { magentoVersion, config: { baseConfig, overridenConfiguration }, verbose } = ctx;
111
+ const { config: { baseConfig, overridenConfiguration } } = ctx;
135
112
  const {
136
113
  magento: { edition: magentoEdition },
137
114
  magentoVersion: magentoPackageVersion
@@ -141,15 +118,10 @@ const installMagentoProject = () => ({
141
118
  const magentoProject = `magento/project-${magentoEdition}-edition`;
142
119
 
143
120
  if (await pathExists(path.join(baseConfig.magentoDir, 'composer.json'))) {
144
- await adjustComposerJson({
145
- baseConfig,
146
- isEnterprise,
121
+ await adjustComposerJson(ctx, task, {
147
122
  magentoEdition,
148
123
  magentoPackageVersion,
149
- magentoProductSelectedEdition,
150
- magentoVersion,
151
- task,
152
- verbose
124
+ magentoProductSelectedEdition
153
125
  });
154
126
  }
155
127
 
@@ -173,12 +145,9 @@ const installMagentoProject = () => ({
173
145
  task.output = 'Creating Magento project';
174
146
 
175
147
  if (!await pathExists(path.join(process.cwd(), 'composer.json'))) {
176
- await createMagentoProject({
148
+ await createMagentoProject(ctx, task, {
177
149
  magentoProject,
178
- magentoPackageVersion,
179
- magentoVersion,
180
- task,
181
- verbose
150
+ magentoPackageVersion
182
151
  });
183
152
  }
184
153
 
@@ -187,18 +156,18 @@ const installMagentoProject = () => ({
187
156
  recursive: true
188
157
  });
189
158
  }
159
+
190
160
  try {
191
- await runComposerCommand('install',
161
+ await runComposerCommand(ctx, 'install',
192
162
  {
193
- magentoVersion,
194
- callback: !verbose ? undefined : (t) => {
163
+ callback: !ctx.verbose ? undefined : (t) => {
195
164
  task.output = t;
196
165
  }
197
166
  });
198
167
  } catch (e) {
199
168
  if (e.message.includes('man-in-the-middle attack')) {
200
169
  throw new KnownError(`Probably you haven't setup pubkeys in composer.
201
- Please run ${logger.style.command('composer diagnose')} in cli to get mode.\n\n${e}`);
170
+ Please run ${logger.style.command('composer diagnose')} in cli to get mode.\n\n${e}`);
202
171
  }
203
172
 
204
173
  throw new UnknownError(`Unexpected error during composer install.\n\n${e}`);
@@ -6,15 +6,15 @@ const magentoTask = require('../../../util/magento-task');
6
6
  */
7
7
  const disableFullPageCache = () => ({
8
8
  title: 'Adjusting full_page cache setting',
9
- task: async ({ magentoVersion, config }, task) => {
10
- const { cache_types } = await envPhpToJson(process.cwd(), { magentoVersion });
9
+ task: async (ctx, task) => {
10
+ const { cache_types } = await envPhpToJson(ctx);
11
11
  if (cache_types && typeof cache_types.full_page === 'number') {
12
- if (cache_types.full_page !== 0 && !config.overridenConfiguration.configuration.varnish.enabled) {
12
+ if (cache_types.full_page !== 0 && !ctx.config.overridenConfiguration.configuration.varnish.enabled) {
13
13
  task.title = 'Disabling full_page cache in Magento';
14
14
  return task.newListr(magentoTask('cache:disable full_page'));
15
15
  }
16
16
 
17
- if (config.overridenConfiguration.configuration.varnish.enabled && cache_types.full_page !== 1) {
17
+ if (ctx.config.overridenConfiguration.configuration.varnish.enabled && cache_types.full_page !== 1) {
18
18
  task.title = 'Enabling full_page cache in Magento (Varnish is enabled)';
19
19
  return task.newListr(magentoTask('cache:enable full_page'));
20
20
  }
@@ -6,11 +6,15 @@ const { updateTableValues, isTableExists } = require('../../../util/database');
6
6
  module.exports = () => ({
7
7
  title: 'Configuring Elasticsearch',
8
8
  skip: async (ctx) => !(await isTableExists('magento', 'core_config_data', ctx)),
9
- task: async ({ ports, mysqlConnection }, task) => {
9
+ task: async (ctx, task) => {
10
+ const { ports, databaseConnection } = ctx;
11
+ const isLinux = ctx.platform === 'linux';
12
+ const isNativeLinux = isLinux && !ctx.isWsl;
13
+ const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
10
14
  await updateTableValues('core_config_data', [
11
15
  { path: 'catalog/search/engine', value: 'elasticsearch7' },
12
- { path: 'catalog/search/elasticsearch7_server_hostname', value: '127.0.0.1' },
16
+ { path: 'catalog/search/elasticsearch7_server_hostname', value: hostMachine },
13
17
  { path: 'catalog/search/elasticsearch7_server_port', value: `${ports.elasticsearch}` }
14
- ], { mysqlConnection, task });
18
+ ], { databaseConnection, task });
15
19
  }
16
20
  });
@@ -5,8 +5,9 @@ const runMagentoCommand = require('../../../util/run-magento');
5
5
  */
6
6
  module.exports = () => ({
7
7
  title: 'Creating admin user',
8
- task: async ({ magentoVersion, mysqlConnection, config: { magentoConfiguration } }, task) => {
9
- const [[{ userCount }]] = await mysqlConnection.query(`
8
+ task: async (ctx, task) => {
9
+ const { config: { magentoConfiguration } } = ctx;
10
+ const [[{ userCount }]] = await ctx.databaseConnection.query(`
10
11
  SELECT count(*) AS userCount
11
12
  FROM admin_user
12
13
  WHERE username = ?;
@@ -17,13 +18,11 @@ module.exports = () => ({
17
18
  return;
18
19
  }
19
20
 
20
- await runMagentoCommand(`admin:user:create \
21
+ await runMagentoCommand(ctx, `admin:user:create \
21
22
  --admin-firstname='${ magentoConfiguration.first_name }' \
22
23
  --admin-lastname='${ magentoConfiguration.last_name }' \
23
24
  --admin-email='${ magentoConfiguration.email }' \
24
25
  --admin-user='${ magentoConfiguration.user }' \
25
- --admin-password='${ magentoConfiguration.password }'`, {
26
- magentoVersion
27
- });
26
+ --admin-password='${ magentoConfiguration.password }'`);
28
27
  }
29
28
  });
@@ -7,8 +7,8 @@ const deleteAdminUsers = () => ({
7
7
  title: 'Deleting old admin users',
8
8
  skip: async (ctx) => !(await isTableExists('magento', 'admin_user', ctx)),
9
9
  task: async (ctx) => {
10
- const { mysqlConnection } = ctx;
11
- await mysqlConnection.query(`
10
+ const { databaseConnection } = ctx;
11
+ await databaseConnection.query(`
12
12
  TRUNCATE TABLE admin_user;
13
13
  `);
14
14
  }
@@ -1,4 +1,4 @@
1
- const { customerTables } = require('../../mysql/magento-tables');
1
+ const { customerTables } = require('../../database/magento-tables');
2
2
 
3
3
  /**
4
4
  * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
@@ -6,19 +6,19 @@ const { customerTables } = require('../../mysql/magento-tables');
6
6
  const deleteCustomers = () => ({
7
7
  title: 'Deleting customers',
8
8
  task: async (ctx, task) => {
9
- const { mysqlConnection, withCustomersData } = ctx;
9
+ const { databaseConnection, withCustomersData } = ctx;
10
10
 
11
11
  if (withCustomersData) {
12
12
  task.skip();
13
13
  return;
14
14
  }
15
15
 
16
- const [rows] = await mysqlConnection.query('select TABLE_NAME from information_schema.TABLES;');
16
+ const [rows] = await databaseConnection.query('select TABLE_NAME from information_schema.TABLES;');
17
17
 
18
18
  await Promise.all(
19
19
  customerTables
20
20
  .filter((tableName) => rows.some((row) => row.TABLE_NAME === tableName))
21
- .map((tableName) => mysqlConnection.query(`TRUNCATE TABLE \`${ tableName }\`;`))
21
+ .map((tableName) => databaseConnection.query(`TRUNCATE TABLE \`${ tableName }\`;`))
22
22
  );
23
23
  }
24
24
  });
@@ -1,4 +1,4 @@
1
- const { orderTables } = require('../../mysql/magento-tables');
1
+ const { orderTables } = require('../../database/magento-tables');
2
2
 
3
3
  /**
4
4
  * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
@@ -6,19 +6,19 @@ const { orderTables } = require('../../mysql/magento-tables');
6
6
  const deleteOrders = () => ({
7
7
  title: 'Deleting orders',
8
8
  task: async (ctx, task) => {
9
- const { mysqlConnection, withCustomersData } = ctx;
9
+ const { databaseConnection, withCustomersData } = ctx;
10
10
 
11
11
  if (withCustomersData) {
12
12
  task.skip();
13
13
  return;
14
14
  }
15
15
 
16
- const [rows] = await mysqlConnection.query('select TABLE_NAME from information_schema.TABLES;');
16
+ const [rows] = await databaseConnection.query('select TABLE_NAME from information_schema.TABLES;');
17
17
 
18
18
  await Promise.all(
19
19
  orderTables
20
20
  .filter((tableName) => rows.some((row) => row.TABLE_NAME === tableName))
21
- .map((tableName) => mysqlConnection.query(`TRUNCATE TABLE \`${ tableName }\`;`))
21
+ .map((tableName) => databaseConnection.query(`TRUNCATE TABLE \`${ tableName }\`;`))
22
22
  );
23
23
  }
24
24
  });
@@ -6,13 +6,11 @@ const runMagentoCommand = require('../../../util/run-magento');
6
6
  */
7
7
  module.exports = () => ({
8
8
  title: 'Disabling 2fa for admin',
9
- task: async ({ magentoVersion }, task) => {
10
- const { modules } = await configPhpToJson(process.cwd(), { magentoVersion });
9
+ task: async (ctx, task) => {
10
+ const { modules } = await configPhpToJson(ctx);
11
11
 
12
12
  if (modules.Magento_TwoFactorAuth !== undefined && modules.Magento_TwoFactorAuth !== 0) {
13
- await runMagentoCommand('module:disable Magento_TwoFactorAuth', {
14
- magentoVersion
15
- });
13
+ await runMagentoCommand(ctx, 'module:disable Magento_TwoFactorAuth');
16
14
 
17
15
  return;
18
16
  }
@@ -5,9 +5,8 @@ const runMagentoCommand = require('../../../util/run-magento');
5
5
  */
6
6
  const disableMaintenanceMode = () => ({
7
7
  title: 'Disabling maintenance mode',
8
- task: async ({ magentoVersion }, task) => {
9
- const { result } = await runMagentoCommand('maintenance:status', {
10
- magentoVersion,
8
+ task: async (ctx, task) => {
9
+ const { result } = await runMagentoCommand(ctx, 'maintenance:status', {
11
10
  throwNonZeroCode: false
12
11
  });
13
12
 
@@ -16,7 +15,7 @@ const disableMaintenanceMode = () => ({
16
15
  return;
17
16
  }
18
17
 
19
- await runMagentoCommand('maintenance:disable', { magentoVersion });
18
+ await runMagentoCommand(ctx, 'maintenance:disable');
20
19
  }
21
20
  });
22
21
 
@@ -5,7 +5,7 @@ const { updateTableValues } = require('../../../util/database');
5
5
  */
6
6
  const increaseAdminSessionLifetime = () => ({
7
7
  title: 'Increase admin session lifetime to 1 month',
8
- task: async ({ mysqlConnection }, task) => updateTableValues('core_config_data', [
8
+ task: async ({ databaseConnection }, task) => updateTableValues('core_config_data', [
9
9
  {
10
10
  path: 'admin/security/session_lifetime',
11
11
  value: '2800000'
@@ -15,7 +15,7 @@ const increaseAdminSessionLifetime = () => ({
15
15
  value: null
16
16
  }
17
17
  ], {
18
- mysqlConnection,
18
+ databaseConnection,
19
19
  task
20
20
  })
21
21
 
@@ -11,6 +11,7 @@ const increaseAdminSessionLifetime = require('./increase-admin-session-lifetime'
11
11
  const magentoTask = require('../../../util/magento-task');
12
12
  const urnHighlighter = require('./urn-highlighter');
13
13
  const adjustFullPageCache = require('./adjust-full-page-cache');
14
+ const updateEnvPHP = require('../../php/update-env-php');
14
15
 
15
16
  /**
16
17
  * @param {Object} [options]
@@ -32,6 +33,7 @@ const setupMagento = (options = {}) => ({
32
33
  return task.newListr([
33
34
  flushRedisConfig(),
34
35
  waitingForRedis(),
36
+ updateEnvPHP(),
35
37
  migrateDatabase(),
36
38
  {
37
39
  title: 'Configuring Magento settings',