@scandipwa/magento-scripts 2.0.0-alpha.9 → 2.0.0

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 (141) hide show
  1. package/lib/commands/cli.js +18 -1
  2. package/lib/commands/logs.js +28 -2
  3. package/lib/commands/start.js +24 -3
  4. package/lib/commands/status.js +9 -1
  5. package/lib/config/config.js +20 -2
  6. package/lib/config/dependencies-for-platforms.js +1 -1
  7. package/lib/config/docker.js +94 -54
  8. package/lib/config/get-project-configuration.js +5 -0
  9. package/lib/config/index.js +10 -3
  10. package/lib/config/php/versions/php-7.2.js +1 -0
  11. package/lib/config/php/versions/php-7.3.js +1 -0
  12. package/lib/config/php/versions/php-7.4.js +1 -0
  13. package/lib/config/php/versions/php-8.1.js +1 -0
  14. package/lib/config/php-config.js +4 -3
  15. package/lib/config/port-config.js +3 -1
  16. package/lib/config/services/composer/versions/composer-1.js +13 -0
  17. package/lib/config/services/composer/versions/composer-2.js +8 -0
  18. package/lib/config/services/composer/versions/index.js +4 -0
  19. package/lib/config/services/maildev/index.js +7 -0
  20. package/lib/config/services/nginx/versions/index.js +3 -0
  21. package/lib/config/services/nginx/versions/nginx-1.18.js +11 -0
  22. package/lib/config/{ssl-terminator → services/ssl-terminator}/index.js +3 -0
  23. package/lib/config/templates/magentorc.template +12 -5
  24. package/lib/config/templates/nginx.fastcgi_params.template +29 -0
  25. package/lib/config/templates/php-debug.template.ini +31 -0
  26. package/lib/config/templates/php-fpm.template.conf +1 -2
  27. package/lib/config/templates/php.template.ini +5 -201
  28. package/lib/config/templates/ssl-terminator.template.conf +2 -0
  29. package/lib/config/templates/varnish.template.vcl +20 -13
  30. package/lib/config/varnish/varnish-6-0.js +4 -0
  31. package/lib/config/varnish/varnish-6-6.js +4 -0
  32. package/lib/config/varnish/varnish-7-0.js +4 -0
  33. package/lib/config/versions/magento-2.2.10.js +41 -0
  34. package/lib/config/versions/magento-2.3.0.js +8 -10
  35. package/lib/config/versions/magento-2.3.1.js +8 -10
  36. package/lib/config/versions/magento-2.3.2-p1.js +8 -10
  37. package/lib/config/versions/magento-2.3.2-p2.js +8 -10
  38. package/lib/config/versions/magento-2.3.2.js +8 -10
  39. package/lib/config/versions/magento-2.3.3-p1.js +8 -10
  40. package/lib/config/versions/magento-2.3.3.js +8 -10
  41. package/lib/config/versions/magento-2.3.4-p1.js +8 -10
  42. package/lib/config/versions/magento-2.3.4-p2.js +8 -10
  43. package/lib/config/versions/magento-2.3.4.js +8 -10
  44. package/lib/config/versions/magento-2.3.5-p1.js +8 -10
  45. package/lib/config/versions/magento-2.3.5-p2.js +8 -10
  46. package/lib/config/versions/magento-2.3.5.js +8 -10
  47. package/lib/config/versions/magento-2.3.6-p1.js +8 -10
  48. package/lib/config/versions/magento-2.3.6.js +8 -10
  49. package/lib/config/versions/magento-2.3.7-p1.js +8 -10
  50. package/lib/config/versions/magento-2.3.7-p2.js +8 -10
  51. package/lib/config/versions/magento-2.3.7-p3.js +8 -10
  52. package/lib/config/versions/magento-2.3.7-p4.js +8 -10
  53. package/lib/config/versions/magento-2.3.7.js +8 -10
  54. package/lib/config/versions/magento-2.4.0-p1.js +8 -10
  55. package/lib/config/versions/magento-2.4.0.js +8 -10
  56. package/lib/config/versions/magento-2.4.1-p1.js +8 -10
  57. package/lib/config/versions/magento-2.4.1.js +8 -10
  58. package/lib/config/versions/magento-2.4.2-p1.js +8 -10
  59. package/lib/config/versions/magento-2.4.2-p2.js +8 -10
  60. package/lib/config/versions/magento-2.4.2.js +8 -10
  61. package/lib/config/versions/magento-2.4.3-p1.js +8 -10
  62. package/lib/config/versions/magento-2.4.3-p2.js +8 -10
  63. package/lib/config/versions/magento-2.4.3-p3.js +8 -10
  64. package/lib/config/versions/magento-2.4.3.js +8 -10
  65. package/lib/config/versions/magento-2.4.4-p1.js +8 -10
  66. package/lib/config/versions/magento-2.4.4.js +8 -10
  67. package/lib/config/versions/magento-2.4.5.js +8 -10
  68. package/lib/tasks/cli/create-bashrc-config.js +4 -2
  69. package/lib/tasks/composer/local-auth-json.js +1 -1
  70. package/lib/tasks/database/connect-to-database.js +6 -3
  71. package/lib/tasks/database/create-magento-database.js +5 -2
  72. package/lib/tasks/database/create-magento-user.js +50 -0
  73. package/lib/tasks/database/default-magento-database.js +3 -0
  74. package/lib/tasks/database/default-magento-user.js +7 -0
  75. package/lib/tasks/database/import-dump-to-database.js +3 -2
  76. package/lib/tasks/docker/api.d.ts +25 -1
  77. package/lib/tasks/docker/api.js +31 -1
  78. package/lib/tasks/docker/containers/container-api.d.ts +17 -0
  79. package/lib/tasks/docker/containers/container-api.js +64 -9
  80. package/lib/tasks/docker/containers/tasks.js +44 -13
  81. package/lib/tasks/docker/convert-composer-home-to-composer-cache-volume.js +52 -0
  82. package/lib/tasks/docker/convert-mysql-to-mariadb.js +2 -2
  83. package/lib/tasks/docker/image/image-api.d.ts +44 -0
  84. package/lib/tasks/docker/image/image-api.js +30 -2
  85. package/lib/tasks/docker/index.js +6 -1
  86. package/lib/tasks/docker/project-image-builder.js +37 -14
  87. package/lib/tasks/docker/system/index.js +5 -0
  88. package/lib/tasks/docker/system/system-api.d.ts +71 -0
  89. package/lib/tasks/docker/system/system-api.js +29 -0
  90. package/lib/tasks/docker/volume/index.js +2 -1
  91. package/lib/tasks/docker/volume/tasks.js +67 -9
  92. package/lib/tasks/docker/volume/volume-api.d.ts +40 -0
  93. package/lib/tasks/docker/volume/volume-api.js +54 -1
  94. package/lib/tasks/execute.js +5 -2
  95. package/lib/tasks/file-system/create-nginx-config.js +3 -5
  96. package/lib/tasks/file-system/create-php-config.js +2 -23
  97. package/lib/tasks/file-system/create-php-debug-config.js +45 -0
  98. package/lib/tasks/file-system/create-php-fpm-config.js +2 -4
  99. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +13 -3
  100. package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -1
  101. package/lib/tasks/file-system/create-ssl-terminator-config.js +23 -8
  102. package/lib/tasks/file-system/create-varnish-config.js +4 -7
  103. package/lib/tasks/file-system/create-vscode-config.js +2 -1
  104. package/lib/tasks/file-system/index.js +3 -2
  105. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +2 -4
  106. package/lib/tasks/magento/setup-magento/flush-redis-config.js +3 -6
  107. package/lib/tasks/magento/setup-magento/index.js +2 -0
  108. package/lib/tasks/magento/setup-magento/install-magento.js +8 -13
  109. package/lib/tasks/magento/setup-magento/set-base-url.js +2 -1
  110. package/lib/tasks/magento/setup-magento/set-mail-config.js +22 -0
  111. package/lib/tasks/magento/setup-magento/varnish-config.js +4 -9
  112. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +15 -16
  113. package/lib/tasks/php/php-container.js +1 -1
  114. package/lib/tasks/php/update-env-php.js +3 -5
  115. package/lib/tasks/{prefix → project-config}/index.js +6 -6
  116. package/lib/tasks/requirements/composer-credentials.js +7 -3
  117. package/lib/tasks/requirements/docker/context.js +88 -0
  118. package/lib/tasks/requirements/docker/index.js +111 -19
  119. package/lib/tasks/requirements/docker/install.js +21 -7
  120. package/lib/tasks/requirements/docker/permissions.js +2 -11
  121. package/lib/tasks/requirements/docker/running-status.js +94 -24
  122. package/lib/tasks/requirements/docker/version.js +1 -0
  123. package/lib/tasks/requirements/index.js +0 -2
  124. package/lib/tasks/requirements/php-version.js +4 -2
  125. package/lib/tasks/start.js +27 -8
  126. package/lib/tasks/status/index.js +60 -21
  127. package/lib/tasks/stop.js +2 -0
  128. package/lib/tasks/theme/retrieve-theme-data.js +12 -2
  129. package/lib/util/config-file-validator.js +17 -3
  130. package/lib/util/execute-in-container.js +7 -8
  131. package/lib/util/instance-metadata.js +14 -2
  132. package/lib/util/systemctl.js +62 -13
  133. package/package.json +2 -2
  134. package/typings/context.d.ts +11 -0
  135. package/typings/index.d.ts +46 -1
  136. package/lib/tasks/requirements/dependency/arch.js +0 -50
  137. package/lib/tasks/requirements/dependency/centos.js +0 -36
  138. package/lib/tasks/requirements/dependency/fedora.js +0 -36
  139. package/lib/tasks/requirements/dependency/index.js +0 -33
  140. package/lib/tasks/requirements/dependency/mac.js +0 -124
  141. package/lib/tasks/requirements/dependency/ubuntu.js +0 -83
@@ -0,0 +1,45 @@
1
+ const semver = require('semver');
2
+ const UnknownError = require('../../errors/unknown-error');
3
+ const setConfigFile = require('../../util/set-config');
4
+ const { getEnabledExtensionsFromImage } = require('../docker/project-image-builder');
5
+
6
+ /**
7
+ * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
8
+ */
9
+ const createPhpDebugConfig = () => ({
10
+ title: 'Setting PHP XDebug config',
11
+ skip: (ctx) => !ctx.debug,
12
+ task: async (ctx) => {
13
+ const {
14
+ config: {
15
+ php,
16
+ baseConfig
17
+ },
18
+ debug,
19
+ isDockerDesktop
20
+ } = ctx;
21
+ const containers = ctx.config.docker.getContainers(ctx.ports);
22
+ const phpExtensions = await getEnabledExtensionsFromImage(containers.php.debugImage);
23
+ const isXDebug2 = semver.satisfies(phpExtensions.xdebug, '2');
24
+
25
+ const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
26
+
27
+ try {
28
+ await setConfigFile({
29
+ configPathname: php.debugIniPath,
30
+ template: php.debugTemplatePath,
31
+ overwrite: true,
32
+ templateArgs: {
33
+ debug,
34
+ mageRoot: baseConfig.containerMagentoDir,
35
+ isXDebug2,
36
+ hostMachine
37
+ }
38
+ });
39
+ } catch (e) {
40
+ throw new UnknownError(`Unexpected error accrued during xdebug.ini config creation\n\n${e}`);
41
+ }
42
+ }
43
+ });
44
+
45
+ module.exports = createPhpDebugConfig;
@@ -7,10 +7,8 @@ const setConfigFile = require('../../util/set-config');
7
7
  const createPhpFpmConfig = () => ({
8
8
  title: 'Setting php-fpm config',
9
9
  task: async (ctx) => {
10
- const { config: { php } } = ctx;
11
- const isLinux = ctx.platform === 'linux';
12
- const isNativeLinux = isLinux && !ctx.isWsl;
13
- const port = isNativeLinux ? ctx.ports.fpm : 9000;
10
+ const { config: { php }, isDockerDesktop } = ctx;
11
+ const port = !isDockerDesktop ? ctx.ports.fpm : 9000;
14
12
 
15
13
  try {
16
14
  await setConfigFile({
@@ -26,11 +26,21 @@ const mustBeIncludedPaths = [
26
26
  /**
27
27
  * Will retrieve project config file path from module.xml
28
28
  *
29
- * @returns {Promise<String>}
29
+ * @returns {Promise<String | null>}
30
30
  */
31
31
  const getProjectConfigFilePath = async () => {
32
32
  const modulesConfigData = await loadXmlFile(pathToModulesConfig);
33
- return modulesConfigData.project.component.modules.module['@_filepath'].replace('$PROJECT_DIR$', process.cwd());
33
+ const {
34
+ project: {
35
+ component: {
36
+ modules: {
37
+ module
38
+ } = {}
39
+ } = {}
40
+ } = {}
41
+ } = modulesConfigData || {};
42
+ const filePath = module && module['@_filepath'];
43
+ return filePath ? filePath.replace('$PROJECT_DIR$', process.cwd()) : null;
34
44
  };
35
45
 
36
46
  const setupDefaultsForExcludedFoldersConfig = (projectConfigData) => {
@@ -138,7 +148,7 @@ const setupExcludedFoldersConfig = () => ({
138
148
  task: async (ctx, task) => {
139
149
  if (await pathExists(pathToModulesConfig)) {
140
150
  const projectFilePath = await getProjectConfigFilePath();
141
- if (await pathExists(projectFilePath)) {
151
+ if (projectFilePath && await pathExists(projectFilePath)) {
142
152
  const projectConfigData = await loadXmlFile(projectFilePath);
143
153
  setupDefaultsForExcludedFoldersConfig(projectConfigData);
144
154
  const hasChanges = setupExcludedFolders(projectConfigData);
@@ -22,7 +22,8 @@ const createPhpStormConfig = () => ({
22
22
  setupStylelintConfig(),
23
23
  setupESLintConfig()
24
24
  ], {
25
- concurrent: true
25
+ concurrent: true,
26
+ exitOnError: false
26
27
  })
27
28
  });
28
29
 
@@ -1,4 +1,3 @@
1
- const os = require('os');
2
1
  const path = require('path');
3
2
  const fs = require('fs');
4
3
  const setConfigFile = require('../../util/set-config');
@@ -19,8 +18,8 @@ const createSSLTerminatorConfig = () => ({
19
18
  overridenConfiguration,
20
19
  baseConfig
21
20
  },
22
- isWsl,
23
- debug
21
+ debug,
22
+ isDockerDesktop
24
23
  } = ctx;
25
24
 
26
25
  const {
@@ -65,10 +64,8 @@ const createSSLTerminatorConfig = () => ({
65
64
  }
66
65
 
67
66
  const networkToBindTo = isIpAddress(host) ? host : '127.0.0.1';
68
- const isLinux = os.platform() === 'linux';
69
- const isNativeLinux = isLinux && !isWsl;
70
- const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
71
- const hostPort = isNativeLinux ? ports.sslTerminator : 80;
67
+ const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
68
+ const hostPort = !isDockerDesktop ? ports.sslTerminator : 80;
72
69
 
73
70
  try {
74
71
  await setConfigFile({
@@ -90,7 +87,25 @@ const createSSLTerminatorConfig = () => ({
90
87
  }
91
88
  });
92
89
  } catch (e) {
93
- throw new UnknownError(`Unexpected error accrued during ssl terminator config creation\n\n${e}`);
90
+ throw new UnknownError(`Unexpected error appeared during ssl terminator config creation\n\n${e}`);
91
+ }
92
+
93
+ // fixes ngrok error "ngrok.io redirected you too many times"
94
+ try {
95
+ await setConfigFile({
96
+ configPathname: path.join(
97
+ baseConfig.cacheDir,
98
+ 'ssl-terminator',
99
+ 'fastcgi_params'
100
+ ),
101
+ template: path.join(baseConfig.templateDir, 'nginx.fastcgi_params.template'),
102
+ overwrite: true,
103
+ templateArgs: {
104
+ isNgrok: host.endsWith('ngrok.io')
105
+ }
106
+ });
107
+ } catch (e) {
108
+ throw new UnknownError(`Unexpected error appeared during ssl terminator fastcgi_params config creation\n\n${e}`);
94
109
  }
95
110
  }
96
111
  });
@@ -17,8 +17,7 @@ const createVarnishConfig = () => ({
17
17
  cacheDir
18
18
  }
19
19
  },
20
- isWsl,
21
- platform
20
+ isDockerDesktop
22
21
  } = ctx;
23
22
 
24
23
  const {
@@ -27,9 +26,6 @@ const createVarnishConfig = () => ({
27
26
  }
28
27
  } = overridenConfiguration;
29
28
 
30
- const isLinux = platform === 'linux';
31
- const isNativeLinux = isLinux && !isWsl;
32
-
33
29
  try {
34
30
  await setConfigFile({
35
31
  configPathname: path.join(
@@ -40,8 +36,9 @@ const createVarnishConfig = () => ({
40
36
  template: varnish.configTemplate,
41
37
  overwrite: true,
42
38
  templateArgs: {
43
- hostMachine: isNativeLinux ? '127.0.0.1' : 'host.docker.internal',
44
- nginxPort: ports.app
39
+ hostMachine: !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal',
40
+ nginxPort: ports.app,
41
+ healthCheck: varnish.healthCheck
45
42
  }
46
43
  });
47
44
  } catch (e) {
@@ -121,7 +121,8 @@ const createVSCodeConfig = () => ({
121
121
  } catch (e) {
122
122
  throw new UnknownError(`Unexpected error accrued during launch.json config creation!\n\n${e}`);
123
123
  }
124
- }
124
+ },
125
+ exitOnError: false
125
126
  });
126
127
 
127
128
  module.exports = createVSCodeConfig;
@@ -1,6 +1,7 @@
1
1
  const createMariaDBConfig = require('./create-mariadb-config');
2
2
  const createNginxConfig = require('./create-nginx-config');
3
3
  const createPhpConfig = require('./create-php-config');
4
+ const createPhpDebugConfig = require('./create-php-debug-config');
4
5
  const createPhpFpmConfig = require('./create-php-fpm-config');
5
6
  const createPhpStormConfig = require('./create-phpstorm-config');
6
7
  const createSSLTerminatorConfig = require('./create-ssl-terminator-config');
@@ -17,13 +18,13 @@ const prepareFileSystem = () => ({
17
18
  createNginxConfig(),
18
19
  createPhpFpmConfig(),
19
20
  createPhpConfig(),
21
+ createPhpDebugConfig(),
20
22
  createPhpStormConfig(),
21
23
  createVSCodeConfig(),
22
24
  createVarnishConfig(),
23
25
  createMariaDBConfig()
24
26
  ], {
25
- concurrent: true,
26
- exitOnError: false
27
+ concurrent: true
27
28
  })
28
29
  });
29
30
 
@@ -7,10 +7,8 @@ module.exports = () => ({
7
7
  title: 'Configuring Elasticsearch',
8
8
  skip: async (ctx) => !(await isTableExists('magento', 'core_config_data', ctx)),
9
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
+ const { ports, databaseConnection, isDockerDesktop } = ctx;
11
+ const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
14
12
  await updateTableValues('core_config_data', [
15
13
  { path: 'catalog/search/engine', value: 'elasticsearch7' },
16
14
  { path: 'catalog/search/elasticsearch7_server_hostname', value: hostMachine },
@@ -1,18 +1,15 @@
1
1
  const { execAsyncSpawn } = require('../../../util/exec-async-command');
2
- const os = require('os');
3
2
  const UnknownError = require('../../../errors/unknown-error');
4
3
 
5
- const isLinux = os.platform() === 'linux';
6
-
7
4
  /**
8
5
  * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
9
6
  */
10
7
  module.exports = () => ({
11
8
  title: 'Flushing Magento redis cache',
12
- task: async ({ ports, config: { docker } }) => {
9
+ task: async ({ ports, config: { docker }, isDockerDesktop }) => {
13
10
  const { redis: { name } } = docker.getContainers(ports);
14
- const host = isLinux ? 'localhost' : 'host.docker.internal';
15
- const port = isLinux ? '6379' : ports.redis;
11
+ const host = !isDockerDesktop ? 'localhost' : 'host.docker.internal';
12
+ const port = !isDockerDesktop ? '6379' : ports.redis;
16
13
  const result = await execAsyncSpawn(`docker exec ${ name } redis-cli -h ${ host } -p ${ port } -n 0 flushdb`);
17
14
 
18
15
  if (!result.trim().includes('OK')) {
@@ -12,6 +12,7 @@ const magentoTask = require('../../../util/magento-task');
12
12
  const urnHighlighter = require('./urn-highlighter');
13
13
  const adjustFullPageCache = require('./adjust-full-page-cache');
14
14
  const updateEnvPHP = require('../../php/update-env-php');
15
+ const setMailConfig = require('./set-mail-config');
15
16
 
16
17
  /**
17
18
  * @param {Object} [options]
@@ -40,6 +41,7 @@ const setupMagento = (options = {}) => ({
40
41
  task: (ctx, task) => task.newListr([
41
42
  setBaseUrl(),
42
43
  setUrlRewrite(),
44
+ setMailConfig(),
43
45
  increaseAdminSessionLifetime()
44
46
  ], {
45
47
  concurrent: true
@@ -5,6 +5,8 @@ const UnknownError = require('../../../errors/unknown-error');
5
5
  const runMagentoCommand = require('../../../util/run-magento');
6
6
  const envPhpToJson = require('../../../util/env-php-json');
7
7
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
8
+ const { defaultMagentoDatabase } = require('../../database/default-magento-database');
9
+ const defaultMagentoUser = require('../../database/default-magento-user');
8
10
 
9
11
  /**
10
12
  * @param {Object} [param0]
@@ -20,16 +22,14 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
20
22
  const {
21
23
  magentoVersion,
22
24
  config: {
23
- docker,
24
25
  magentoConfiguration
25
26
  },
26
27
  ports,
27
- databaseConnection
28
+ databaseConnection,
29
+ isDockerDesktop
28
30
  } = ctx;
29
31
 
30
- const isLinux = ctx.platform === 'linux';
31
- const isNativeLinux = isLinux && !ctx.isWsl;
32
- const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
32
+ const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
33
33
 
34
34
  const [tableResponse] = await databaseConnection.query(
35
35
  'SELECT * FROM information_schema.tables WHERE table_schema = \'magento\' AND table_name = \'admin_user\' LIMIT 1;'
@@ -73,8 +73,6 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
73
73
  await databaseConnection.query('SET FOREIGN_KEY_CHECKS = 1;');
74
74
  }
75
75
  }
76
-
77
- const { mariadb: { env } } = docker.getContainers(ports);
78
76
  const envPhpData = await envPhpToJson(ctx);
79
77
 
80
78
  const envPhpHaveEncryptionKey = envPhpData && envPhpData.crypt && envPhpData.crypt.key && envPhpData.crypt.key;
@@ -127,9 +125,9 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
127
125
  --cache-backend-redis-port='${ ports.redis }' \
128
126
  --cache-backend-redis-db='0't \
129
127
  --db-host='${ hostMachine }:${ ports.mariadb }' \
130
- --db-name='${ env.MARIADB_DATABASE }' \
131
- --db-user='${ env.MARIADB_USER }' \
132
- --db-password='${ env.MARIADB_PASSWORD }' \
128
+ --db-name='${ defaultMagentoDatabase }' \
129
+ --db-user='${ defaultMagentoUser.user }' \
130
+ --db-password='${ defaultMagentoUser.password }' \
133
131
  --backend-frontname='${ magentoConfiguration.adminuri }' \
134
132
  --no-interaction`;
135
133
 
@@ -143,9 +141,6 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
143
141
  installed = true;
144
142
  } catch (e) {
145
143
  errors.push(e);
146
- if (tries === 2) {
147
- throw e;
148
- }
149
144
  }
150
145
 
151
146
  if (installed) {
@@ -17,7 +17,7 @@ module.exports = () => ({
17
17
  databaseConnection
18
18
  } = ctx;
19
19
  const isNgrok = host.endsWith('ngrok.io');
20
- const enableSecureFrontend = (ctx.config.overridenConfiguration.configuration.varnish.enabled && ssl.enabled) ? '1' : '0';
20
+ const enableSecureFrontend = (isNgrok || ssl.enabled) ? '1' : '0';
21
21
  const location = `${host}${ !isNgrok && ports.sslTerminator !== 80 ? `:${ports.sslTerminator }` : '' }/`;
22
22
  const secureLocation = `${host}/`; // SSL will work only on port 443, so you cannot run multiple projects with SSL at the same time.
23
23
  const httpUrl = `http://${location}`;
@@ -28,6 +28,7 @@ module.exports = () => ({
28
28
  { path: 'web/secure/base_url', value: httpsUrl },
29
29
  { path: 'web/secure/use_in_frontend', value: enableSecureFrontend },
30
30
  { path: 'web/secure/use_in_adminhtml', value: enableSecureFrontend },
31
+ { path: 'web/secure/enable_upgrade_insecure', value: enableSecureFrontend },
31
32
  { path: 'web/cookie/cookie_domain', value: null }
32
33
  ], { databaseConnection, task });
33
34
  }
@@ -0,0 +1,22 @@
1
+ const { updateTableValues } = require('../../../util/database');
2
+
3
+ /**
4
+ * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
+ */
6
+ const setMailConfig = () => ({
7
+ title: 'Setting up mail configuration',
8
+ task: async ({ databaseConnection, ports, isDockerDesktop }, task) => {
9
+ await updateTableValues('core_config_data', [
10
+ {
11
+ path: 'smtp/configuration_option/port',
12
+ value: `${ ports.maildevSMTP }`
13
+ },
14
+ {
15
+ path: 'smtp/configuration_option/host',
16
+ value: isDockerDesktop ? 'host.docker.internal' : 'localhost'
17
+ }
18
+ ], { databaseConnection, task });
19
+ }
20
+ });
21
+
22
+ module.exports = setMailConfig;
@@ -1,6 +1,4 @@
1
- const os = require('os');
2
1
  const { updateTableValues } = require('../../../util/database');
3
- const getIsWsl = require('../../../util/is-wsl');
4
2
 
5
3
  /**
6
4
  * @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
@@ -20,18 +18,15 @@ const varnishConfigSetup = () => ({
20
18
  },
21
19
  databaseConnection,
22
20
  ports,
23
- debug
21
+ debug,
22
+ isDockerDesktop
24
23
  } = ctx;
25
24
 
26
- const isLinux = os.platform() === 'linux';
27
- const isWsl = await getIsWsl();
28
- const isNativeLinux = isLinux && !isWsl;
29
-
30
25
  if (!debug && varnishEnabled) {
31
26
  await updateTableValues('core_config_data', [
32
27
  {
33
28
  path: 'system/full_page_cache/varnish/backend_host',
34
- value: !isNativeLinux ? 'host.docker.internal' : 'localhost'
29
+ value: isDockerDesktop ? 'host.docker.internal' : 'localhost'
35
30
  },
36
31
  {
37
32
  path: 'system/full_page_cache/varnish/backend_port',
@@ -39,7 +34,7 @@ const varnishConfigSetup = () => ({
39
34
  },
40
35
  {
41
36
  path: 'system/full_page_cache/varnish/access_list',
42
- value: !isNativeLinux ? 'host.docker.internal,localhost' : 'localhost'
37
+ value: isDockerDesktop ? 'host.docker.internal,localhost' : 'localhost'
43
38
  },
44
39
  {
45
40
  path: 'system/full_page_cache/caching_application',
@@ -4,9 +4,9 @@ const fs = require('fs');
4
4
  const path = require('path');
5
5
  const { request } = require('smol-request');
6
6
  const KnownError = require('../../../errors/known-error');
7
- const { execAsyncSpawn } = require('../../../util/exec-async-command');
8
7
  const { NginxParser } = require('../../../util/nginx-logs-parser');
9
8
  const sleep = require('../../../util/sleep');
9
+ const { containerApi } = require('../../docker/containers');
10
10
 
11
11
  const pathToWorkingHealthCheckPhp = path.join(__dirname, '..', '..', 'php', 'working_health_check.php');
12
12
  const pathToProjectsHealthCheckPhp = path.join(process.cwd(), 'pub', 'health_check.php');
@@ -17,19 +17,18 @@ const pathToHealthCheckBackupPhp = path.join(process.cwd(), 'pub', 'health_check
17
17
  */
18
18
  const getIsHealthCheckRequestBroken = async (ctx) => {
19
19
  const { nginx } = ctx.config.docker.getContainers(ctx.ports);
20
-
21
- const nginxLogs = await execAsyncSpawn(`docker logs ${nginx.name}`);
22
-
23
- const healthCheckRequests = nginxLogs
24
- .split('\n')
25
- .filter((line) => line.includes('"GET /health_check.php HTTP/1.1"'));
26
-
27
- // eslint-disable-next-line max-len
28
- const parser = new NginxParser('$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"');
29
-
30
- const parsedRequests = healthCheckRequests.map((line) => parser.parseLine(line));
31
-
32
- return parsedRequests.every((parsedRequest) => parsedRequest.status !== '200');
20
+ const parser = new NginxParser(
21
+ '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"'
22
+ );
23
+ const parsedLogs = await containerApi.logs({
24
+ name: nginx.name,
25
+ parser: (line) => parser.parseLine(line)
26
+ });
27
+
28
+ const healthCheckRequests = parsedLogs
29
+ .filter((line) => line.request.includes('/health_check.php'));
30
+
31
+ return healthCheckRequests.every((parsedRequest) => parsedRequest.status !== '200');
33
32
  };
34
33
 
35
34
  /**
@@ -39,12 +38,12 @@ const waitingForVarnish = () => ({
39
38
  title: 'Waiting for Varnish to return code 200',
40
39
  skip: (ctx) => ctx.debug
41
40
  || !ctx.config.overridenConfiguration.configuration.varnish.enabled
42
- || ctx.config.overridenConfiguration.ssl.enabled,
41
+ || ctx.config.overridenConfiguration.ssl.enabled
42
+ || !ctx.config.overridenConfiguration.configuration.varnish.healthCheck,
43
43
  task: async (ctx, task) => {
44
44
  const pureMagentoVersion = ctx.magentoVersion.match(/^([0-9]+\.[0-9]+\.[0-9]+)/)[1];
45
45
 
46
46
  const isMagento23 = semver.satisfies(pureMagentoVersion, '<2.4');
47
-
48
47
  let tries = 0;
49
48
  while (tries < 10) {
50
49
  try {
@@ -29,7 +29,7 @@ const runPHPContainerCommand = async (ctx, command, options = {}) => {
29
29
  },
30
30
  options.useXDebugContainer
31
31
  ? {
32
- image: `${ php.image }.xdebug`
32
+ image: php.debugImage
33
33
  }
34
34
  : {},
35
35
  {
@@ -19,11 +19,10 @@ const updateEnvPHP = () => ({
19
19
  return;
20
20
  }
21
21
 
22
+ const { isDockerDesktop, platform } = ctx;
22
23
  const { php } = ctx.config.docker.getContainers(ctx.ports);
23
24
 
24
- const isLinux = ctx.platform === 'linux';
25
- const isNativeLinux = isLinux && !ctx.isWsl;
26
- const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
25
+ const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
27
26
 
28
27
  const useVarnish = (!ctx.debug && ctx.config.overridenConfiguration.configuration.varnish.enabled) ? '1' : '';
29
28
  const varnishHost = hostMachine;
@@ -53,7 +52,6 @@ const updateEnvPHP = () => ({
53
52
  || persistedQueryConfig.redis.host === hostMachine)
54
53
  ) {
55
54
  SETUP_PQ = '';
56
- return;
57
55
  }
58
56
  }
59
57
  }
@@ -78,7 +76,7 @@ const updateEnvPHP = () => ({
78
76
  image: php.image,
79
77
  detach: false,
80
78
  rm: true,
81
- user: isLinux ? `${os.userInfo().uid}:${os.userInfo().gid}` : ''
79
+ user: platform === 'linux' ? `${os.userInfo().uid}:${os.userInfo().gid}` : ''
82
80
  });
83
81
 
84
82
  task.output = result;
@@ -1,21 +1,21 @@
1
+ const { setProjectConfig } = require('../../config/config');
1
2
  const { setPrefix: setPrefixUtil } = require('../../util/prefix');
2
3
 
3
4
  /**
4
5
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
5
6
  */
6
- const setPrefix = () => ({
7
- // if project is missing prefix, set one
8
- title: 'Settings project prefix',
7
+ const setProjectConfigTask = () => ({
8
+ title: 'Settings project config',
9
9
  task: (ctx) => {
10
10
  const { config: { overridenConfiguration: { prefix } } } = ctx;
11
11
 
12
12
  setPrefixUtil(prefix);
13
+
14
+ setProjectConfig('debug', ctx.debug);
13
15
  },
14
16
  options: {
15
17
  showTimer: false
16
18
  }
17
19
  });
18
20
 
19
- module.exports = {
20
- setPrefix
21
- };
21
+ module.exports = { setProjectConfigTask };
@@ -96,9 +96,9 @@ ${ logger.style.misc('Password') } (${ logger.style.misc('Private key') }):`,
96
96
  };
97
97
 
98
98
  const authJsonContent = JSON.stringify(authContent, null, 4);
99
- const authEnvContent = `export COMPOSER_AUTH='${JSON.stringify(authContent)}'`;
99
+ const authEnvContent = `export COMPOSER_AUTH='${JSON.stringify(authContent, null, 0)}'`;
100
100
 
101
- process.env.COMPOSER_AUTH = authJsonContent;
101
+ process.env.COMPOSER_AUTH = JSON.stringify(JSON.parse(authJsonContent), null, 0);
102
102
 
103
103
  if (configureLocation === 'auth.json') {
104
104
  await fs.promises.writeFile(authJsonPath, authJsonContent, 'utf-8');
@@ -175,7 +175,11 @@ Would you like to load them now?`
175
175
 
176
176
  if (loadCredentialsFrom) {
177
177
  const credentialsLine = lines.find((line) => line.startsWith('export COMPOSER_AUTH='));
178
- process.env.COMPOSER_AUTH = credentialsLine.replace('export COMPOSER_AUTH=', '').replace(/'/ig, '').trim();
178
+ process.env.COMPOSER_AUTH = JSON.stringify(
179
+ JSON.parse(credentialsLine.replace('export COMPOSER_AUTH=', '').replace(/'/ig, '').trim()),
180
+ null,
181
+ 0
182
+ );
179
183
  problems.delete(MISSING_COMPOSER_AUTH_ENV);
180
184
  }
181
185
  }