@scandipwa/magento-scripts 2.0.0-alpha.9 → 2.0.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 (183) 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 +19 -1
  5. package/lib/config/config.js +20 -2
  6. package/lib/config/dependencies-for-platforms.js +1 -113
  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/magento/required-php-extensions/index.js +1 -1
  11. package/lib/config/php-config.js +4 -3
  12. package/lib/config/port-config.js +3 -1
  13. package/lib/config/services/composer/versions/composer-1.js +13 -0
  14. package/lib/config/services/composer/versions/composer-2.js +8 -0
  15. package/lib/config/services/composer/versions/index.js +4 -0
  16. package/lib/config/services/elasticsearch/versions/elasticsearch-7.10.js +11 -0
  17. package/lib/config/services/elasticsearch/versions/elasticsearch-7.12.js +11 -0
  18. package/lib/config/services/elasticsearch/versions/elasticsearch-7.16.js +11 -0
  19. package/lib/config/services/elasticsearch/versions/elasticsearch-7.17.js +11 -0
  20. package/lib/config/services/elasticsearch/versions/elasticsearch-7.6.js +11 -0
  21. package/lib/config/services/elasticsearch/versions/elasticsearch-7.7.js +11 -0
  22. package/lib/config/services/elasticsearch/versions/elasticsearch-7.9.js +11 -0
  23. package/lib/config/services/elasticsearch/versions/index.js +15 -1
  24. package/lib/config/services/maildev/index.js +7 -0
  25. package/lib/config/services/mariadb/versions/index.js +5 -0
  26. package/lib/config/services/mariadb/versions/mariadb-10.2.js +8 -0
  27. package/lib/config/services/mariadb/versions/mariadb-10.3.js +8 -0
  28. package/lib/config/services/mariadb/versions/mariadb-10.4.js +8 -0
  29. package/lib/config/services/nginx/versions/index.js +3 -0
  30. package/lib/config/services/nginx/versions/nginx-1.18.js +11 -0
  31. package/lib/config/{php → services/php}/base-repo.js +0 -0
  32. package/lib/config/{php → services/php}/extensions/apcu.js +0 -0
  33. package/lib/config/{php → services/php}/extensions/bcmath.js +0 -0
  34. package/lib/config/{php → services/php}/extensions/curl.js +0 -0
  35. package/lib/config/{php → services/php}/extensions/gd.js +0 -0
  36. package/lib/config/{php → services/php}/extensions/index.js +0 -0
  37. package/lib/config/{php → services/php}/extensions/intl.js +0 -0
  38. package/lib/config/{php → services/php}/extensions/opcache.js +0 -0
  39. package/lib/config/{php → services/php}/extensions/pdo_mysql.js +0 -0
  40. package/lib/config/{php → services/php}/extensions/soap.js +0 -0
  41. package/lib/config/{php → services/php}/extensions/sodium.js +0 -0
  42. package/lib/config/{php → services/php}/extensions/xdebug.js +0 -0
  43. package/lib/config/{php → services/php}/extensions/xsl.js +0 -0
  44. package/lib/config/{php → services/php}/extensions/zip.js +0 -0
  45. package/lib/config/{php → services/php}/versions/index.js +0 -0
  46. package/lib/config/{php → services/php}/versions/php-7.2.js +1 -0
  47. package/lib/config/{php → services/php}/versions/php-7.3.js +1 -0
  48. package/lib/config/{php → services/php}/versions/php-7.4.js +1 -0
  49. package/lib/config/{php → services/php}/versions/php-8.1.js +1 -0
  50. package/lib/config/services/redis/index.js +5 -0
  51. package/lib/config/services/redis/redis-5.0.js +8 -0
  52. package/lib/config/services/redis/redis-6.0.js +8 -0
  53. package/lib/config/services/redis/redis-6.2.js +8 -0
  54. package/lib/config/{ssl-terminator → services/ssl-terminator}/index.js +3 -0
  55. package/lib/config/services/varnish/index.js +5 -0
  56. package/lib/config/{varnish → services/varnish}/varnish-6-0.js +5 -3
  57. package/lib/config/{varnish → services/varnish}/varnish-6-6.js +5 -3
  58. package/lib/config/{varnish → services/varnish}/varnish-7-0.js +5 -3
  59. package/lib/config/templates/magentorc.template +12 -5
  60. package/lib/config/templates/nginx.fastcgi_params.template +29 -0
  61. package/lib/config/templates/nginx.template.conf +1 -1
  62. package/lib/config/templates/php-debug.template.ini +31 -0
  63. package/lib/config/templates/php-fpm.template.conf +1 -2
  64. package/lib/config/templates/php.template.ini +5 -201
  65. package/lib/config/templates/ssl-terminator.template.conf +2 -0
  66. package/lib/config/templates/varnish.template.vcl +20 -13
  67. package/lib/config/versions/magento-2.2.10.js +39 -0
  68. package/lib/config/versions/magento-2.3.0.js +15 -19
  69. package/lib/config/versions/magento-2.3.1.js +15 -19
  70. package/lib/config/versions/magento-2.3.2-p1.js +15 -19
  71. package/lib/config/versions/magento-2.3.2-p2.js +15 -19
  72. package/lib/config/versions/magento-2.3.2.js +15 -19
  73. package/lib/config/versions/magento-2.3.3-p1.js +15 -19
  74. package/lib/config/versions/magento-2.3.3.js +15 -19
  75. package/lib/config/versions/magento-2.3.4-p1.js +15 -19
  76. package/lib/config/versions/magento-2.3.4-p2.js +15 -19
  77. package/lib/config/versions/magento-2.3.4.js +15 -19
  78. package/lib/config/versions/magento-2.3.5-p1.js +17 -22
  79. package/lib/config/versions/magento-2.3.5-p2.js +17 -22
  80. package/lib/config/versions/magento-2.3.5.js +17 -22
  81. package/lib/config/versions/magento-2.3.6-p1.js +17 -22
  82. package/lib/config/versions/magento-2.3.6.js +17 -22
  83. package/lib/config/versions/magento-2.3.7-p1.js +17 -22
  84. package/lib/config/versions/magento-2.3.7-p2.js +17 -22
  85. package/lib/config/versions/magento-2.3.7-p3.js +17 -22
  86. package/lib/config/versions/magento-2.3.7-p4.js +17 -22
  87. package/lib/config/versions/magento-2.3.7.js +17 -22
  88. package/lib/config/versions/magento-2.4.0-p1.js +17 -22
  89. package/lib/config/versions/magento-2.4.0.js +17 -22
  90. package/lib/config/versions/magento-2.4.1-p1.js +18 -23
  91. package/lib/config/versions/magento-2.4.1.js +18 -23
  92. package/lib/config/versions/magento-2.4.2-p1.js +18 -23
  93. package/lib/config/versions/magento-2.4.2-p2.js +18 -23
  94. package/lib/config/versions/magento-2.4.2.js +18 -23
  95. package/lib/config/versions/magento-2.4.3-p1.js +18 -23
  96. package/lib/config/versions/magento-2.4.3-p2.js +18 -23
  97. package/lib/config/versions/magento-2.4.3-p3.js +18 -23
  98. package/lib/config/versions/magento-2.4.3.js +18 -23
  99. package/lib/config/versions/magento-2.4.4-p1.js +18 -23
  100. package/lib/config/versions/magento-2.4.4-p2.js +41 -0
  101. package/lib/config/versions/magento-2.4.4.js +18 -23
  102. package/lib/config/versions/magento-2.4.5-p1.js +41 -0
  103. package/lib/config/versions/magento-2.4.5.js +18 -23
  104. package/lib/tasks/cli/create-bashrc-config.js +4 -2
  105. package/lib/tasks/composer/local-auth-json.js +1 -1
  106. package/lib/tasks/database/connect-to-database.js +6 -3
  107. package/lib/tasks/database/create-magento-database.js +5 -2
  108. package/lib/tasks/database/create-magento-user.js +50 -0
  109. package/lib/tasks/database/default-magento-database.js +3 -0
  110. package/lib/tasks/database/default-magento-user.js +7 -0
  111. package/lib/tasks/database/import-dump-to-database.js +3 -2
  112. package/lib/tasks/docker/api.d.ts +25 -1
  113. package/lib/tasks/docker/api.js +31 -1
  114. package/lib/tasks/docker/containers/container-api.d.ts +17 -0
  115. package/lib/tasks/docker/containers/container-api.js +64 -9
  116. package/lib/tasks/docker/containers/tasks.js +44 -13
  117. package/lib/tasks/docker/convert-composer-home-to-composer-cache-volume.js +52 -0
  118. package/lib/tasks/docker/convert-mysql-to-mariadb.js +2 -2
  119. package/lib/tasks/docker/image/image-api.d.ts +44 -0
  120. package/lib/tasks/docker/image/image-api.js +30 -2
  121. package/lib/tasks/docker/index.js +6 -1
  122. package/lib/tasks/docker/network/tasks.js +19 -14
  123. package/lib/tasks/docker/project-image-builder.js +39 -14
  124. package/lib/tasks/docker/system/index.js +5 -0
  125. package/lib/tasks/docker/system/system-api.d.ts +71 -0
  126. package/lib/tasks/docker/system/system-api.js +35 -0
  127. package/lib/tasks/docker/volume/index.js +2 -1
  128. package/lib/tasks/docker/volume/tasks.js +67 -9
  129. package/lib/tasks/docker/volume/volume-api.d.ts +40 -0
  130. package/lib/tasks/docker/volume/volume-api.js +55 -2
  131. package/lib/tasks/execute.js +5 -2
  132. package/lib/tasks/file-system/create-nginx-config.js +3 -5
  133. package/lib/tasks/file-system/create-php-config.js +2 -23
  134. package/lib/tasks/file-system/create-php-debug-config.js +45 -0
  135. package/lib/tasks/file-system/create-php-fpm-config.js +2 -4
  136. package/lib/tasks/file-system/create-phpstorm-config/database-config.js +24 -5
  137. package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +25 -13
  138. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +13 -3
  139. package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -1
  140. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +18 -7
  141. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/paths.js +4 -0
  142. package/lib/tasks/file-system/create-ssl-terminator-config.js +23 -8
  143. package/lib/tasks/file-system/create-varnish-config.js +4 -7
  144. package/lib/tasks/file-system/create-vscode-config.js +2 -1
  145. package/lib/tasks/file-system/index.js +3 -2
  146. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +2 -4
  147. package/lib/tasks/magento/setup-magento/flush-redis-config.js +3 -6
  148. package/lib/tasks/magento/setup-magento/index.js +2 -0
  149. package/lib/tasks/magento/setup-magento/install-magento.js +8 -13
  150. package/lib/tasks/magento/setup-magento/set-base-url.js +2 -1
  151. package/lib/tasks/magento/setup-magento/set-mail-config.js +22 -0
  152. package/lib/tasks/magento/setup-magento/varnish-config.js +4 -9
  153. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +15 -16
  154. package/lib/tasks/php/php-container.js +1 -1
  155. package/lib/tasks/php/update-env-php.js +4 -6
  156. package/lib/tasks/{prefix → project-config}/index.js +6 -6
  157. package/lib/tasks/requirements/composer-credentials.js +7 -3
  158. package/lib/tasks/requirements/docker/context.js +88 -0
  159. package/lib/tasks/requirements/docker/index.js +111 -19
  160. package/lib/tasks/requirements/docker/install.js +21 -7
  161. package/lib/tasks/requirements/docker/permissions.js +2 -11
  162. package/lib/tasks/requirements/docker/running-status.js +94 -24
  163. package/lib/tasks/requirements/docker/version.js +1 -0
  164. package/lib/tasks/requirements/index.js +0 -2
  165. package/lib/tasks/requirements/php-version.js +4 -2
  166. package/lib/tasks/start.js +27 -8
  167. package/lib/tasks/status/index.js +86 -21
  168. package/lib/tasks/stop.js +2 -0
  169. package/lib/tasks/theme/retrieve-theme-data.js +12 -2
  170. package/lib/util/config-file-validator.js +17 -3
  171. package/lib/util/connection-string.js +62 -0
  172. package/lib/util/execute-in-container.js +7 -8
  173. package/lib/util/instance-metadata.js +14 -2
  174. package/lib/util/systemctl.js +62 -13
  175. package/package.json +2 -2
  176. package/typings/context.d.ts +11 -0
  177. package/typings/index.d.ts +46 -1
  178. package/lib/tasks/requirements/dependency/arch.js +0 -50
  179. package/lib/tasks/requirements/dependency/centos.js +0 -36
  180. package/lib/tasks/requirements/dependency/fedora.js +0 -36
  181. package/lib/tasks/requirements/dependency/index.js +0 -33
  182. package/lib/tasks/requirements/dependency/mac.js +0 -124
  183. package/lib/tasks/requirements/dependency/ubuntu.js +0 -83
@@ -1,7 +1,5 @@
1
- const semver = require('semver');
2
1
  const UnknownError = require('../../errors/unknown-error');
3
2
  const setConfigFile = require('../../util/set-config');
4
- const { getEnabledExtensionsFromImage } = require('../docker/project-image-builder');
5
3
 
6
4
  /**
7
5
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
@@ -9,32 +7,13 @@ const { getEnabledExtensionsFromImage } = require('../docker/project-image-build
9
7
  const createPhpConfig = () => ({
10
8
  title: 'Setting PHP config',
11
9
  task: async (ctx) => {
12
- const {
13
- config: {
14
- php,
15
- baseConfig
16
- },
17
- debug
18
- } = ctx;
19
- const containers = ctx.config.docker.getContainers(ctx.ports);
20
- const phpExtensions = await getEnabledExtensionsFromImage(containers.php.debugImage);
21
- const isXDebug2 = semver.satisfies(phpExtensions.xdebug, '2');
22
-
23
- const isLinux = ctx.platform === 'linux';
24
- const isNativeLinux = isLinux && !ctx.isWsl;
25
- const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
10
+ const { config: { php } } = ctx;
26
11
 
27
12
  try {
28
13
  await setConfigFile({
29
14
  configPathname: php.iniPath,
30
15
  template: php.iniTemplatePath,
31
- overwrite: true,
32
- templateArgs: {
33
- debug,
34
- mageRoot: baseConfig.containerMagentoDir,
35
- isXDebug2,
36
- hostMachine
37
- }
16
+ overwrite: true
38
17
  });
39
18
  } catch (e) {
40
19
  throw new UnknownError(`Unexpected error accrued during php.ini config creation\n\n${e}`);
@@ -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({
@@ -3,6 +3,7 @@ const path = require('path');
3
3
  const { baseConfig } = require('../../../config');
4
4
  const { loadXmlFile, buildXmlFile } = require('../../../config/xml-parser');
5
5
  const UnknownError = require('../../../errors/unknown-error');
6
+ const { connectionStringParser, connectionStringBuilder } = require('../../../util/connection-string');
6
7
  const pathExists = require('../../../util/path-exists');
7
8
  const setConfigFile = require('../../../util/set-config');
8
9
 
@@ -40,7 +41,7 @@ const getToDataSource = (data, defaultData) => {
40
41
 
41
42
  return data.project.component['data-source'];
42
43
  };
43
-
44
+ // const mariadbVersion = await ctx.databaseConnection.query('SHOW VARIABLES LIKE "%version%";');
44
45
  /**
45
46
  * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
46
47
  */
@@ -153,8 +154,6 @@ const setupDataSourceLocalConfig = () => ({
153
154
  */
154
155
  const setupDataSourceConfig = () => ({
155
156
  task: async (ctx, task) => {
156
- const jdbcUrl = `jdbc:mysql://localhost:${ctx.ports.mysql}/magento`;
157
-
158
157
  if (await pathExists(databaseConfiguration.dataSources.path)) {
159
158
  let hasChanges = false;
160
159
  const dataSourcesData = await loadXmlFile(databaseConfiguration.dataSources.path);
@@ -176,6 +175,26 @@ const setupDataSourceConfig = () => ({
176
175
  }
177
176
  );
178
177
 
178
+ if (dataSource['jdbc-url']) {
179
+ const parsedJDBC = dataSource['jdbc-url'].match(/jdbc:(\S+)/i);
180
+ if (parsedJDBC && parsedJDBC.length > 0) {
181
+ const url = parsedJDBC[1];
182
+ const parsedJDBCUrl = connectionStringParser(url);
183
+
184
+ if (/\S+:undefined/.test(parsedJDBCUrl.host)) {
185
+ hasChanges = true;
186
+ parsedJDBCUrl.host = parsedJDBCUrl.host.split(':').shift();
187
+ }
188
+
189
+ if (parsedJDBCUrl.port !== `${ctx.ports.mariadb}`) {
190
+ hasChanges = true;
191
+ parsedJDBCUrl.port = `${ctx.ports.mariadb}`;
192
+
193
+ dataSource['jdbc-url'] = `jdbc:${connectionStringBuilder(parsedJDBCUrl)}`;
194
+ }
195
+ }
196
+ }
197
+
179
198
  if (dataSource['@_uuid'] === undefined) {
180
199
  hasChanges = true;
181
200
  dataSource['@_uuid'] = 'a2eadb3c-6fc9-4d85-b5f4-d8114906ce2f';
@@ -186,7 +205,7 @@ const setupDataSourceConfig = () => ({
186
205
  'driver-ref': 'mysql.8',
187
206
  synchronize: true,
188
207
  'jdbc-driver': 'com.mysql.cj.jdbc.Driver',
189
- 'jdbc-url': jdbcUrl,
208
+ 'jdbc-url': `jdbc:mysql://localhost:${ctx.ports.mariadb}/magento`,
190
209
  'working-dir': '$ProjectFileDir$',
191
210
  '@_source': 'LOCAL'
192
211
  };
@@ -222,7 +241,7 @@ const setupDataSourceConfig = () => ({
222
241
  overwrite: true,
223
242
  templateArgs: {
224
243
  databaseConfiguration,
225
- jdbcUrl
244
+ jdbcUrl: `jdbc:mysql://localhost:${ctx.ports.mariadb}/magento`
226
245
  }
227
246
  });
228
247
  } catch (e) {
@@ -17,6 +17,17 @@ const defaultESLintComponentConfiguration = {
17
17
  }
18
18
  };
19
19
 
20
+ const esLintDefaultConfigurationData = {
21
+ '?xml': {
22
+ '@_version': '1.0',
23
+ '@_encoding': 'UTF-8'
24
+ },
25
+ project: {
26
+ '@_version': '4',
27
+ component: defaultESLintComponentConfiguration
28
+ }
29
+ };
30
+
20
31
  const setupESlintConfig = async (esLintConfigurationData) => {
21
32
  let hasChanges = false;
22
33
  const themes = await getCSAThemes();
@@ -56,6 +67,18 @@ const setupESLintConfigTask = () => ({
56
67
  let hasChanges = false;
57
68
  const esLintConfigurationData = await loadXmlFile(pathToESLintConfig);
58
69
 
70
+ if (!esLintConfigurationData.project) {
71
+ esLintConfigurationData.project = {
72
+ ...esLintDefaultConfigurationData.project
73
+ };
74
+ }
75
+
76
+ if (!esLintConfigurationData['?xml']) {
77
+ esLintConfigurationData['?xml'] = {
78
+ ...esLintDefaultConfigurationData['?xml']
79
+ };
80
+ }
81
+
59
82
  if (esLintConfigurationData.project.component && !Array.isArray(esLintConfigurationData.project.component)) {
60
83
  hasChanges = true;
61
84
  esLintConfigurationData.project.component = [esLintConfigurationData.project.component];
@@ -84,20 +107,9 @@ const setupESLintConfigTask = () => ({
84
107
  return;
85
108
  }
86
109
 
87
- const esLintConfigurationData = {
88
- '?xml': {
89
- '@_version': '1.0',
90
- '@_encoding': 'UTF-8'
91
- },
92
- project: {
93
- '@_version': '4',
94
- component: defaultESLintComponentConfiguration
95
- }
96
- };
97
-
98
- await setupESlintConfig(esLintConfigurationData);
110
+ await setupESlintConfig(esLintDefaultConfigurationData);
99
111
 
100
- await buildXmlFile(pathToESLintConfig, esLintConfigurationData);
112
+ await buildXmlFile(pathToESLintConfig, esLintDefaultConfigurationData);
101
113
  }
102
114
  });
103
115
 
@@ -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,5 +1,7 @@
1
1
  const pathExists = require('../../../../util/path-exists');
2
- const { phpCSConfigurationPath, phpCSConfigFormattedPath } = require('./paths');
2
+ const {
3
+ phpCSConfigurationPath, phpCSConfigFormattedPath, phpCSFixerConfigurationPath, phpCSFixerConfigurationFormattedPath
4
+ } = require('./paths');
3
5
  const { nameKey, valueKey } = require('../keys');
4
6
  const {
5
7
  options: {
@@ -13,13 +15,22 @@ const setupCustomRuleSetPathOption = async (config) => {
13
15
  (option) => option[nameKey] === CUSTOM_RULE_SET_PATH_OPTION_NAME
14
16
  );
15
17
  const phpCSConfigExists = await pathExists(phpCSConfigurationPath);
18
+ const phpCSFixerConfigPathExists = await pathExists(phpCSFixerConfigurationPath);
16
19
 
17
- if (!customRuleSetPathOption && phpCSConfigExists) {
18
- hasChanges = true;
19
- config.option.push({
20
- [nameKey]: CUSTOM_RULE_SET_PATH_OPTION_NAME,
21
- [valueKey]: phpCSConfigFormattedPath
22
- });
20
+ if (!customRuleSetPathOption) {
21
+ if (phpCSConfigExists) {
22
+ hasChanges = true;
23
+ config.option.push({
24
+ [nameKey]: CUSTOM_RULE_SET_PATH_OPTION_NAME,
25
+ [valueKey]: phpCSConfigFormattedPath
26
+ });
27
+ } else if (phpCSFixerConfigPathExists) {
28
+ hasChanges = true;
29
+ config.option.push({
30
+ [nameKey]: CUSTOM_RULE_SET_PATH_OPTION_NAME,
31
+ [valueKey]: phpCSFixerConfigurationFormattedPath
32
+ });
33
+ }
23
34
  }
24
35
 
25
36
  return hasChanges;
@@ -6,6 +6,8 @@ const phpCompatibilityRuleSetPath = path.join(phpCompatibilityPath, 'ruleset.xml
6
6
  const phpCompatibilityFormattedPath = formatPathForPHPStormConfig(phpCompatibilityPath);
7
7
  const phpCSConfigurationPath = path.join(process.cwd(), '.php_cs.dist');
8
8
  const phpCSConfigFormattedPath = formatPathForPHPStormConfig(phpCSConfigurationPath);
9
+ const phpCSFixerConfigurationPath = path.join(process.cwd(), '.php-cs-fixer.dist.php');
10
+ const phpCSFixerConfigurationFormattedPath = formatPathForPHPStormConfig(phpCSFixerConfigurationPath);
9
11
  const phpMDRuleSetPath = path.join(process.cwd(), 'dev', 'tests', 'static', 'testsuite', 'Magento', 'Test', 'Php', '_files', 'phpmd', 'ruleset.xml');
10
12
  const phpMDRuleSetFormattedPath = formatPathForPHPStormConfig(phpMDRuleSetPath);
11
13
 
@@ -15,6 +17,8 @@ module.exports = {
15
17
  phpCompatibilityFormattedPath,
16
18
  phpCSConfigurationPath,
17
19
  phpCSConfigFormattedPath,
20
+ phpCSFixerConfigurationPath,
21
+ phpCSFixerConfigurationFormattedPath,
18
22
  phpMDRuleSetPath,
19
23
  phpMDRuleSetFormattedPath
20
24
  };
@@ -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',