@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
@@ -1,11 +0,0 @@
1
- const path = require('path');
2
-
3
- module.exports = ({ composer }, config) => {
4
- const { cacheDir } = config;
5
-
6
- return {
7
- dirPath: path.join(cacheDir, 'composer'),
8
- binPath: path.join(cacheDir, 'composer', 'composer.phar'),
9
- version: composer.version
10
- };
11
- };
@@ -1,36 +0,0 @@
1
- const path = require('path');
2
- const fs = require('fs');
3
- const pathExists = require('../../../util/path-exists');
4
- const UnknownError = require('../../../errors/unknown-error');
5
- const phpbrewConfig = require('../../phpbrew');
6
-
7
- /**
8
- * @type {import('../../../../typings/index').PHPExtension}
9
- */
10
- module.exports = {
11
- extensionName: 'sodium',
12
- hooks: {
13
- postInstall: async ({ php }) => {
14
- const sodiumDynamicLibraryPath = path.join(
15
- phpbrewConfig.phpPath,
16
- `php-${php.version}`,
17
- 'var',
18
- 'db',
19
- 'libsodium.ini'
20
- );
21
-
22
- if (!await pathExists(sodiumDynamicLibraryPath)) {
23
- throw new UnknownError(`libsodium dynamic library file configuration not found: ${sodiumDynamicLibraryPath}`);
24
- }
25
- const fileContent = await fs.promises.readFile(sodiumDynamicLibraryPath, 'utf-8');
26
-
27
- if (/^extension=libsodium\.so$/.test(fileContent.trim())) {
28
- await fs.promises.writeFile(
29
- sodiumDynamicLibraryPath,
30
- 'extension=sodium.so\n',
31
- 'utf-8'
32
- );
33
- }
34
- }
35
- }
36
- };
@@ -1,25 +0,0 @@
1
- const path = require('path');
2
- const { xdebug } = require('../extensions');
3
-
4
- const php72 = ({ templateDir, additionalExtensions = {} }) => ({
5
- version: '7.2.34',
6
- configTemplate: path.join(templateDir || '', 'php.template.ini'),
7
- extensions: {
8
- gd: {
9
- macosOptions: '--with-zlib-dir=$(brew --prefix zlib) --with-freetype-dir=$(brew --prefix freetype)'
10
- },
11
- intl: {},
12
- zlib: {},
13
- openssl: {},
14
- sockets: {},
15
- SimpleXML: {},
16
- xdebug,
17
- apcu: {},
18
- opcache: {
19
- extensionName: 'Zend OPcache'
20
- },
21
- ...additionalExtensions
22
- }
23
- });
24
-
25
- module.exports = php72;
@@ -1,25 +0,0 @@
1
- const path = require('path');
2
- const { xdebug } = require('../extensions');
3
-
4
- const php73 = ({ templateDir, additionalExtensions = {} }) => ({
5
- version: '7.3.33',
6
- configTemplate: path.join(templateDir || '', 'php.template.ini'),
7
- extensions: {
8
- gd: {
9
- macosOptions: '--with-zlib-dir=$(brew --prefix zlib) --with-freetype-dir=$(brew --prefix freetype)'
10
- },
11
- intl: {},
12
- zlib: {},
13
- openssl: {},
14
- sockets: {},
15
- SimpleXML: {},
16
- xdebug,
17
- apcu: {},
18
- opcache: {
19
- extensionName: 'Zend OPcache'
20
- },
21
- ...additionalExtensions
22
- }
23
- });
24
-
25
- module.exports = php73;
@@ -1,23 +0,0 @@
1
- const path = require('path');
2
- const { xdebug } = require('../extensions');
3
-
4
- const php74 = ({ templateDir, additionalExtensions = {} } = {}) => ({
5
- version: '7.4.30',
6
- configTemplate: path.join(templateDir || '', 'php.template.ini'),
7
- extensions: {
8
- gd: {},
9
- intl: {},
10
- zlib: {},
11
- openssl: {},
12
- sockets: {},
13
- SimpleXML: {},
14
- xdebug,
15
- apcu: {},
16
- opcache: {
17
- extensionName: 'Zend OPcache'
18
- },
19
- ...additionalExtensions
20
- }
21
- });
22
-
23
- module.exports = php74;
@@ -1,25 +0,0 @@
1
- const path = require('path');
2
- const { libsodium, xdebug } = require('../extensions');
3
-
4
- const php81 = ({ templateDir, additionalExtensions = {} } = {}) => ({
5
- version: '8.1.7',
6
- configTemplate: path.join(templateDir || '', 'php.template.ini'),
7
- extensions: {
8
- gd: {},
9
- intl: {},
10
- zlib: {},
11
- openssl: {},
12
- sockets: {},
13
- SimpleXML: {},
14
- libsodium,
15
- fileinfo: {},
16
- xdebug,
17
- apcu: {},
18
- opcache: {
19
- extensionName: 'Zend OPcache'
20
- },
21
- ...additionalExtensions
22
- }
23
- });
24
-
25
- module.exports = php81;
@@ -1,12 +0,0 @@
1
- const os = require('os');
2
- const path = require('path');
3
-
4
- const homePath = process.env.PHPBREW_HOME || path.join(os.homedir(), '.phpbrew');
5
- const phpbrewConfig = {
6
- homePath,
7
- buildPath: path.join(homePath, 'build'),
8
- phpPath: path.join(homePath, 'php'),
9
- bashrcPath: path.join(homePath, 'bashrc')
10
- };
11
-
12
- module.exports = phpbrewConfig;
@@ -1,103 +0,0 @@
1
- const logger = require('@scandipwa/scandipwa-dev-utils/logger');
2
- const os = require('os');
3
- const path = require('path');
4
- const fs = require('fs');
5
- const semver = require('semver');
6
- const { baseConfig } = require('../../config');
7
- const getJsonfileData = require('../../util/get-jsonfile-data');
8
- const pathExists = require('../../util/path-exists');
9
- const runComposerCommand = require('../../util/run-composer');
10
-
11
- const globalComposerJsonPath = path.join(os.homedir(), '.config', 'composer', 'composer.json');
12
- const localComposerJsonPath = path.join(baseConfig.magentoDir, 'composer.json');
13
- const prestissimoPluginName = 'hirak/prestissimo';
14
-
15
- /**
16
- * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
17
- */
18
- const prestissimoInstall = () => ({
19
- title: 'Installing Prestissimo',
20
- task: async (ctx, task) => {
21
- const { magentoVersion, composerVersion } = ctx;
22
-
23
- if (semver.satisfies(composerVersion, '^2')) {
24
- if (await pathExists(globalComposerJsonPath) && semver.satisfies(composerVersion, '^2.2.0')) {
25
- const globalComposerJsonData = await getJsonfileData(globalComposerJsonPath);
26
- const hasPrestissimoInstalled = globalComposerJsonData
27
- && globalComposerJsonData.require
28
- && !!globalComposerJsonData.require[prestissimoPluginName];
29
-
30
- if (await pathExists(localComposerJsonPath)) {
31
- const localComposerJsonData = await getJsonfileData(localComposerJsonPath);
32
-
33
- if (
34
- hasPrestissimoInstalled
35
- && localComposerJsonData
36
- && localComposerJsonData.config
37
- && localComposerJsonData.config['allow-plugins']
38
- && typeof localComposerJsonData.config['allow-plugins'][prestissimoPluginName] !== 'boolean'
39
- ) {
40
- const disableConfirmation = await task.prompt({
41
- type: 'Select',
42
- message: `We noticed that you have Composer ${ctx.composerVersion}, but you have ${logger.style.code(prestissimoPluginName)} installed, which is used only in Composer 1.
43
- Would you like to disable it in your project?`,
44
- choices: [
45
- {
46
- name: 'disable',
47
- message: 'Disable it, thanks'
48
- },
49
- {
50
- name: 'remove',
51
- message: `Remove ${prestissimoPluginName} from your system`
52
- },
53
- {
54
- name: 'skip',
55
- message: 'Skip this step'
56
- }
57
- ]
58
- });
59
-
60
- if (disableConfirmation === 'disable') {
61
- localComposerJsonData.config['allow-plugins'][prestissimoPluginName] = false;
62
- await fs.promises.writeFile(localComposerJsonPath, JSON.stringify(localComposerJsonData, null, 4), 'utf-8');
63
-
64
- return;
65
- }
66
-
67
- if (disableConfirmation === 'remove') {
68
- await runComposerCommand(`global remove ${prestissimoPluginName}`, {
69
- throwNonZeroCode: false,
70
- magentoVersion
71
- });
72
-
73
- return;
74
- }
75
- }
76
- }
77
- }
78
- task.skip();
79
- return;
80
- }
81
- const { code } = await runComposerCommand(`global show ${prestissimoPluginName}`, {
82
- throwNonZeroCode: false,
83
- magentoVersion
84
- });
85
-
86
- if (code === 0) {
87
- task.skip();
88
- return;
89
- }
90
-
91
- await runComposerCommand(`global require ${prestissimoPluginName}`, {
92
- magentoVersion,
93
- callback: (t) => {
94
- task.output = t;
95
- }
96
- });
97
- },
98
- options: {
99
- bottomBar: 10
100
- }
101
- });
102
-
103
- module.exports = prestissimoInstall;
@@ -1,231 +0,0 @@
1
- /* eslint-disable max-len */
2
- const { execAsyncSpawn } = require('../../util/exec-async-command');
3
- const sleep = require('../../util/sleep');
4
- const logger = require('@scandipwa/scandipwa-dev-utils/logger');
5
- const KnownError = require('../../errors/known-error');
6
-
7
- /**
8
- * @param {Object} options
9
- * @param {number[]} [options.ports] Publish or expose port [docs](https://docs.docker.com/engine/reference/commandline/run/#publish-or-expose-port--p---expose)
10
- * @param {number[]} [options.mounts] Add bind mounts or volumes using the --mount flag [docs](https://docs.docker.com/engine/reference/commandline/run/#add-bind-mounts-or-volumes-using-the---mount-flag)
11
- * @param {number[]} [options.mountVolumes] Mount volume [docs](https://docs.docker.com/engine/reference/commandline/run/#mount-volume--v---read-only)
12
- * @param {Record<string, string>} [options.env] Set environment variables [docs](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file)
13
- * @param {string} [options.image]
14
- * @param {string} [options.restart] Restart policies [docs](https://docs.docker.com/engine/reference/commandline/run/#restart-policies---restart)
15
- * @param {string} [options.name] Container name
16
- * @param {string} [options.entrypoint] Container entrypoint
17
- * @param {string} [options.command] Container command
18
- * @param {Record<"cmd" | "interval" | "retries" | "start-period" | "timeout", string>} [options.healthCheck] Container heathcheck properties
19
- * @param {string[]} [options.securityOptions] Security options [docs](https://docs.docker.com/engine/reference/commandline/run/#optional-security-options---security-opt)
20
- * @param {string[]} [options.tmpfs]
21
- */
22
- const run = (options) => {
23
- const {
24
- ports = [],
25
- mounts = [],
26
- mountVolumes = [],
27
- env = {},
28
- image,
29
- restart,
30
- network,
31
- name,
32
- entrypoint,
33
- command = '',
34
- healthCheck,
35
- securityOptions = [],
36
- tmpfs = [],
37
- expose = []
38
- } = options;
39
-
40
- const exposeArg = expose && expose.map((e) => `--expose=${ e }`);
41
- const restartArg = restart && `--restart ${ restart }`;
42
- const networkArg = network && `--network ${ network }`;
43
- const portsArgs = ports.map((port) => `-p ${ port }`).join(' ');
44
- const mountsArgs = mounts.map((mount) => `--mount ${ mount }`).join(' ');
45
- const mountVolumesArgs = mountVolumes.map((mount) => `-v ${mount}`).join(' ');
46
- const envArgs = Object.entries(env).map(([key, value]) => `--env ${ key }=${ value }`).join(' ');
47
- const nameArg = name && `--name ${name}`;
48
- const entrypointArg = entrypoint && `--entrypoint "${entrypoint}"`;
49
- const healthCheckArg = healthCheck && Object.entries(healthCheck).map(([key, value]) => `--health-${key} '${value}'`).join(' ');
50
- const securityArg = securityOptions.length > 0 && securityOptions.map((opt) => `--security-opt ${opt}`).join(' ');
51
- const tmpfsArg = tmpfs.length > 0 && tmpfs.map((t) => `--tmpfs ${t}`).join(' ');
52
-
53
- const dockerCommand = [
54
- 'docker',
55
- 'run',
56
- '-d',
57
- nameArg,
58
- networkArg,
59
- restartArg,
60
- portsArgs,
61
- exposeArg,
62
- mountsArgs,
63
- mountVolumesArgs,
64
- envArgs,
65
- entrypointArg,
66
- healthCheckArg,
67
- securityArg,
68
- tmpfsArg,
69
- image,
70
- command
71
- ].filter(Boolean).join(' ');
72
-
73
- return execAsyncSpawn(dockerCommand);
74
- };
75
-
76
- const stop = async (containers) => {
77
- await execAsyncSpawn(`docker container stop ${containers.join(' ')}`);
78
- await execAsyncSpawn(`docker container rm ${containers.join(' ')}`);
79
- };
80
-
81
- const pull = async (image) => execAsyncSpawn(`docker pull ${image}`);
82
-
83
- /**
84
- * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
85
- */
86
- const pullContainers = () => ({
87
- title: 'Pulling container images',
88
- task: async ({ config: { docker } }, task) => {
89
- const containers = Object.values(docker.getContainers());
90
- const containerFilters = containers
91
- .map((container) => `-f=reference='${container.imageDetails.name}:${container.imageDetails.tag}'`)
92
- .join(' ');
93
- const existingImages = await execAsyncSpawn(`docker images ${containerFilters}`);
94
- const missingContainerImages = containers.filter((container) => !existingImages.split('\n')
95
- .some((line) => line.includes(container.imageDetails.name) && line.includes(container.imageDetails.tag)))
96
- .reduce((acc, val) => acc.concat(acc.some((c) => c.imageDetails.name === val.imageDetails.name && c.imageDetails.tag === val.imageDetails.tag) ? [] : val), []);
97
-
98
- if (missingContainerImages.length === 0) {
99
- task.skip();
100
- return;
101
- }
102
-
103
- return task.newListr(
104
- missingContainerImages.map((container) => ({
105
- title: `Pulling ${ logger.style.file(`${container.imageDetails.name}:${container.imageDetails.tag}`) } image`,
106
- task: () => pull(`${container.imageDetails.name}:${container.imageDetails.tag}`)
107
- })), {
108
- concurrent: true,
109
- exitOnError: true
110
- }
111
- );
112
- }
113
- });
114
-
115
- /**
116
- * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
117
- */
118
- const startContainers = () => ({
119
- title: 'Starting containers',
120
- task: async ({ ports, config: { docker } }, task) => {
121
- const containerList = (await execAsyncSpawn('docker container ls --all --format="{{.Names}}"')).split('\n');
122
-
123
- const missingContainers = Object.values(docker.getContainers(ports)).filter(
124
- ({ name }) => !containerList.includes(name)
125
- );
126
-
127
- if (missingContainers.length === 0) {
128
- task.skip();
129
- return;
130
- }
131
-
132
- // TODO: we might stop containers here ?
133
- await Promise.all(missingContainers.map((container) => run(container).then((out) => {
134
- task.output = `From ${container._}: ${out}`;
135
- })));
136
- },
137
- options: {
138
- bottomBar: 10
139
- }
140
- });
141
-
142
- /**
143
- * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
144
- */
145
- const stopContainers = () => ({
146
- title: 'Stopping Docker containers',
147
- task: async ({ config: { baseConfig: { prefix } } }, task) => {
148
- const containerList = (await execAsyncSpawn('docker container ls --all --format="{{.Names}}"')).split('\n');
149
-
150
- const runningContainers = containerList.filter((containerName) => containerName.startsWith(prefix));
151
-
152
- if (runningContainers.length === 0) {
153
- task.skip();
154
- return;
155
- }
156
-
157
- await stop(runningContainers);
158
- }
159
- });
160
-
161
- const getContainerStatus = async (containerName) => {
162
- try {
163
- return JSON.parse(await execAsyncSpawn(`docker inspect --format='{{json .State}}' ${containerName}`));
164
- } catch {
165
- return null;
166
- }
167
- };
168
-
169
- /**
170
- * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
171
- */
172
- const checkContainersAreRunning = () => ({
173
- title: 'Checking container statuses',
174
- task: async (ctx, task) => {
175
- const { config: { docker }, ports } = ctx;
176
- const containers = Object.values(docker.getContainers(ports));
177
- let tries = 0;
178
- while (tries < 3) {
179
- const containersWithStatus = await Promise.all(
180
- containers.map(async (container) => ({
181
- ...container,
182
- status: await getContainerStatus(container.name)
183
- }))
184
- );
185
-
186
- if (containersWithStatus.some((c) => c.status.Status !== 'running')) {
187
- if (tries === 2) {
188
- throw new KnownError(`${containersWithStatus.filter((c) => c.status.Status !== 'running').map((c) => c._).join(', ')} containers are not running! Please check container logs for more details!`);
189
- } else {
190
- task.output = `${containersWithStatus.filter((c) => c.status.Status !== 'running').map((c) => c._).join(', ')} are not running, waiting if something will change...`;
191
- await sleep(2000);
192
- tries++;
193
- }
194
- } else {
195
- break;
196
- }
197
- }
198
- },
199
- options: {
200
- bottomBar: 10
201
- }
202
- });
203
-
204
- /**
205
- * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
206
- */
207
- const statusContainers = () => ({
208
- task: async (ctx) => {
209
- const { config: { docker }, ports } = ctx;
210
- const containers = Object.values(docker.getContainers(ports));
211
-
212
- ctx.containers = await Promise.all(
213
- containers.map(async (container) => ({
214
- ...container,
215
- status: await getContainerStatus(container.name)
216
- }))
217
- );
218
- },
219
- options: {
220
- bottomBar: 10
221
- }
222
- });
223
-
224
- module.exports = {
225
- startContainers,
226
- stopContainers,
227
- pullContainers,
228
- statusContainers,
229
- checkContainersAreRunning,
230
- getContainerStatus
231
- };
@@ -1,114 +0,0 @@
1
- const mysql = require('mysql2/promise');
2
- const UnknownError = require('../../errors/unknown-error');
3
- const { execAsyncSpawn } = require('../../util/exec-async-command');
4
- const sleep = require('../../util/sleep');
5
- const { createMagentoDatabase } = require('./create-magento-database');
6
-
7
- /**
8
- * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
9
- */
10
- const waitForMySQLInitialization = () => ({
11
- title: 'Waiting for MySQL to initialize',
12
- task: async (ctx, task) => {
13
- const { mysql: { name } } = ctx.config.docker.getContainers();
14
- let mysqlReadyForConnections = false;
15
- while (!mysqlReadyForConnections) {
16
- const mysqlOutput = await execAsyncSpawn(`docker logs ${name}`);
17
- if (mysqlOutput.includes('ready for connections')) {
18
- mysqlReadyForConnections = true;
19
- break;
20
- } else if (mysqlOutput.includes('Initializing database files')) {
21
- task.output = `MySQL is initializing database files!
22
- Please wait, this will take some time and do not restart the MySQL container until initialization is finished!`;
23
-
24
- let mysqlFinishedInitialization = false;
25
- while (!mysqlFinishedInitialization) {
26
- const mysqlOutput = await execAsyncSpawn(`docker logs ${name}`);
27
- if (mysqlOutput.includes('init process done.') && !mysqlFinishedInitialization) {
28
- mysqlFinishedInitialization = true;
29
- break;
30
- }
31
- await sleep(2000);
32
- }
33
- }
34
-
35
- await sleep(2000);
36
- }
37
- },
38
- options: {
39
- bottomBar: 10
40
- }
41
- });
42
-
43
- /**
44
- * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
45
- */
46
- const gettingMySQLConnection = () => ({
47
- title: 'Getting MySQL connection',
48
- task: async (ctx, task) => {
49
- const { config: { docker }, ports } = ctx;
50
- const { mysql: { env } } = docker.getContainers();
51
- let tries = 0;
52
- const maxTries = 20;
53
- const errors = [];
54
- while (tries < maxTries) {
55
- tries++;
56
- try {
57
- const connection = await mysql.createConnection({
58
- host: '127.0.0.1',
59
- port: ports.mysql,
60
- user: env.MYSQL_USER,
61
- password: env.MYSQL_PASSWORD,
62
- database: env.MYSQL_DATABASE
63
- });
64
-
65
- ctx.mysqlConnection = connection;
66
- break;
67
- } catch (e) {
68
- errors.push(e);
69
- }
70
- await sleep(1000);
71
- }
72
-
73
- if (tries === maxTries) {
74
- throw new UnknownError(`Unable to connect to MySQL server. Check your server configuration!\n\n${ errors.join(' ') }`);
75
- }
76
-
77
- task.title = 'MySQL server connected!';
78
- }
79
- });
80
-
81
- /**
82
- * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
83
- */
84
- const terminatingExistingConnection = () => ({
85
- title: 'Terminating existing MySQL connection',
86
- skip: (ctx) => !ctx.mysqlConnection,
87
- task: (ctx) => {
88
- ctx.mysqlConnection.destroy();
89
- }
90
- });
91
-
92
- /**
93
- * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
94
- */
95
- const connectToMySQL = () => ({
96
- title: 'Connecting to MySQL server',
97
- skip: (ctx) => ctx.skipSetup,
98
- task: (ctx, task) => task.newListr([
99
- waitForMySQLInitialization(),
100
- createMagentoDatabase(),
101
- terminatingExistingConnection(),
102
- gettingMySQLConnection()
103
- ], {
104
- concurrent: false,
105
- rendererOptions: {
106
- collapse: true
107
- }
108
- }),
109
- options: {
110
- bottomBar: 10
111
- }
112
- });
113
-
114
- module.exports = connectToMySQL;
@@ -1,18 +0,0 @@
1
- const { execAsyncSpawn } = require('../../util/exec-async-command');
2
-
3
- /**
4
- * Will create database 'magento' in MySQL if it does not exist for some reason
5
- * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
6
- */
7
- const createMagentoDatabase = () => ({
8
- title: 'Creating Magento database in MySQL',
9
- task: async (ctx) => {
10
- const { mysql } = ctx.config.docker.getContainers();
11
-
12
- await execAsyncSpawn(`docker exec ${mysql.name} mysql -umagento -pmagento -h 127.0.0.1 -e "CREATE DATABASE IF NOT EXISTS magento;"`);
13
- }
14
- });
15
-
16
- module.exports = {
17
- createMagentoDatabase
18
- };
@@ -1,27 +0,0 @@
1
- const bundledExtensions = [
2
- 'bz2',
3
- 'bcmath',
4
- 'ctype',
5
- 'curl',
6
- 'intl',
7
- 'dom',
8
- 'filter',
9
- 'hash',
10
- 'sockets',
11
- 'iconv',
12
- 'json',
13
- 'mbstring',
14
- 'openssl',
15
- 'xml',
16
- 'mysql',
17
- 'pdo',
18
- 'soap',
19
- 'xml',
20
- 'zip',
21
- 'fpm',
22
- 'gd'
23
- ];
24
-
25
- module.exports = {
26
- bundledExtensions
27
- };