@scandipwa/magento-scripts 1.16.1 → 2.0.0-alpha.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 (189) hide show
  1. package/lib/commands/cli.js +2 -4
  2. package/lib/commands/execute.js +28 -3
  3. package/lib/commands/start.js +37 -15
  4. package/lib/commands/status.js +2 -0
  5. package/lib/config/docker.js +65 -42
  6. package/lib/config/get-project-configuration.js +3 -1
  7. package/lib/config/index.js +10 -7
  8. package/lib/config/magento/required-php-extensions/index.js +29 -0
  9. package/lib/config/magento/required-php-extensions/magento-2.3.js +19 -0
  10. package/lib/config/magento/required-php-extensions/magento-2.4.js +29 -0
  11. package/lib/config/php/base-repo.js +3 -0
  12. package/lib/config/php/extensions/apcu.js +12 -0
  13. package/lib/config/php/extensions/bcmath.js +7 -0
  14. package/lib/config/php/extensions/curl.js +11 -0
  15. package/lib/config/php/extensions/gd.js +14 -0
  16. package/lib/config/php/extensions/index.js +18 -2
  17. package/lib/config/php/extensions/intl.js +10 -0
  18. package/lib/config/php/extensions/opcache.js +10 -0
  19. package/lib/config/php/extensions/pdo_mysql.js +7 -0
  20. package/lib/config/php/extensions/soap.js +10 -0
  21. package/lib/config/php/extensions/sodium.js +10 -0
  22. package/lib/config/php/extensions/xdebug.js +8 -5
  23. package/lib/config/php/extensions/xsl.js +10 -0
  24. package/lib/config/php/extensions/zip.js +10 -0
  25. package/lib/config/php/{releases → versions}/index.js +0 -0
  26. package/lib/config/php/versions/php-7.2.js +23 -0
  27. package/lib/config/php/versions/php-7.3.js +23 -0
  28. package/lib/config/php/versions/php-7.4.js +23 -0
  29. package/lib/config/php/versions/php-8.1.js +23 -0
  30. package/lib/config/php-config.js +8 -12
  31. package/lib/config/port-config.js +1 -5
  32. package/lib/config/templates/magentorc.template +3 -3
  33. package/lib/config/templates/php-fpm.template.conf +3 -3
  34. package/lib/config/templates/php.template.ini +12 -6
  35. package/lib/config/templates/ssl-terminator.template.conf +1 -1
  36. package/lib/config/templates/vscode-launch.template.json +3 -1
  37. package/lib/config/versions/magento-2.3.0.js +8 -2
  38. package/lib/config/versions/magento-2.3.1.js +8 -2
  39. package/lib/config/versions/magento-2.3.2-p1.js +44 -0
  40. package/lib/config/versions/magento-2.3.2-p2.js +8 -2
  41. package/lib/config/versions/magento-2.3.2.js +8 -2
  42. package/lib/config/versions/magento-2.3.3-p1.js +8 -2
  43. package/lib/config/versions/magento-2.3.3.js +8 -2
  44. package/lib/config/versions/magento-2.3.4-p1.js +44 -0
  45. package/lib/config/versions/magento-2.3.4-p2.js +8 -2
  46. package/lib/config/versions/magento-2.3.4.js +8 -2
  47. package/lib/config/versions/magento-2.3.5-p1.js +8 -2
  48. package/lib/config/versions/magento-2.3.5-p2.js +8 -2
  49. package/lib/config/versions/magento-2.3.5.js +8 -2
  50. package/lib/config/versions/magento-2.3.6-p1.js +8 -2
  51. package/lib/config/versions/magento-2.3.6.js +8 -2
  52. package/lib/config/versions/magento-2.3.7-p1.js +8 -2
  53. package/lib/config/versions/magento-2.3.7-p2.js +8 -2
  54. package/lib/config/versions/magento-2.3.7-p3.js +8 -2
  55. package/lib/config/versions/magento-2.3.7.js +8 -2
  56. package/lib/config/versions/magento-2.4.0-p1.js +9 -3
  57. package/lib/config/versions/magento-2.4.0.js +9 -3
  58. package/lib/config/versions/magento-2.4.1-p1.js +6 -5
  59. package/lib/config/versions/magento-2.4.1.js +9 -2
  60. package/lib/config/versions/magento-2.4.2-p1.js +6 -5
  61. package/lib/config/versions/magento-2.4.2-p2.js +6 -6
  62. package/lib/config/versions/magento-2.4.2.js +6 -6
  63. package/lib/config/versions/magento-2.4.3-p1.js +7 -7
  64. package/lib/config/versions/magento-2.4.3-p2.js +7 -7
  65. package/lib/config/versions/magento-2.4.3.js +7 -7
  66. package/lib/config/versions/magento-2.4.4.js +9 -2
  67. package/lib/tasks/cleanup.js +2 -2
  68. package/lib/tasks/composer/index.js +14 -104
  69. package/lib/tasks/docker/api.d.ts +71 -0
  70. package/lib/tasks/docker/api.js +30 -0
  71. package/lib/tasks/docker/containers/container-api.d.ts +128 -0
  72. package/lib/tasks/docker/containers/container-api.js +153 -0
  73. package/lib/tasks/docker/containers/index.js +19 -0
  74. package/lib/tasks/docker/containers/tasks.js +215 -0
  75. package/lib/tasks/docker/convert-legacy-volumes.js +7 -3
  76. package/lib/tasks/docker/image/image-api.d.ts +34 -0
  77. package/lib/tasks/docker/image/image-api.js +49 -0
  78. package/lib/tasks/docker/image/index.js +5 -0
  79. package/lib/tasks/docker/index.js +1 -13
  80. package/lib/tasks/docker/network/index.js +7 -0
  81. package/lib/tasks/docker/network/network-api.d.ts +103 -0
  82. package/lib/tasks/docker/network/network-api.js +99 -0
  83. package/lib/tasks/docker/{network.js → network/tasks.js} +17 -10
  84. package/lib/tasks/docker/project-image-builder.js +167 -0
  85. package/lib/tasks/docker/volumes.js +1 -1
  86. package/lib/tasks/file-system/create-nginx-config.js +2 -3
  87. package/lib/tasks/file-system/create-php-config.js +20 -5
  88. package/lib/tasks/file-system/create-php-fpm-config.js +8 -4
  89. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +41 -29
  90. package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -0
  91. package/lib/tasks/file-system/create-phpstorm-config/keys.js +15 -1
  92. package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +4 -1
  93. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-config.js +3 -3
  94. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-interpreters-config.js +81 -0
  95. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/index.js +42 -0
  96. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/php-docker-settings-config.js +9 -0
  97. package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/setup-php-docker-container-settings-config.js +66 -0
  98. package/lib/tasks/file-system/create-phpstorm-config/setup-xml-structure.js +11 -9
  99. package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +2 -1
  100. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +15 -30
  101. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +24 -5
  102. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/mess-detector-project-configuration-config.js +50 -0
  103. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-code-sniffer-project-configuration-config.js +50 -0
  104. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-cs-fixer-project-configuration-config.js +50 -0
  105. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +15 -15
  106. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +29 -3
  107. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-stan-project-configuration-config.js.js +50 -0
  108. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +42 -0
  109. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/psalm-project-configuration-config.js.js +50 -0
  110. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/workspace-config.js +0 -2
  111. package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -2
  112. package/lib/tasks/file-system/create-vscode-config.js +57 -42
  113. package/lib/tasks/file-system/index.js +2 -1
  114. package/lib/tasks/link.js +1 -2
  115. package/lib/tasks/magento/install-magento-project.js +31 -63
  116. package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +4 -4
  117. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +6 -2
  118. package/lib/tasks/magento/setup-magento/create-admin.js +5 -6
  119. package/lib/tasks/magento/setup-magento/disable-2fa.js +3 -5
  120. package/lib/tasks/magento/setup-magento/disable-maintenance-mode.js +3 -4
  121. package/lib/tasks/magento/setup-magento/install-magento.js +10 -9
  122. package/lib/tasks/magento/setup-magento/migrate-database.js +7 -8
  123. package/lib/tasks/magento/setup-magento/set-deployment-mode.js +4 -4
  124. package/lib/tasks/magento/setup-magento/varnish-config.js +6 -4
  125. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +128 -3
  126. package/lib/tasks/mysql/connect-to-mysql.js +34 -21
  127. package/lib/tasks/mysql/import-dump-to-mysql.js +46 -3
  128. package/lib/tasks/php/php-container.js +108 -0
  129. package/lib/tasks/php/update-env-php.js +35 -19
  130. package/lib/tasks/php/update-env.php +61 -56
  131. package/lib/tasks/php/working_health_check.php +85 -0
  132. package/lib/tasks/requirements/{composer.js → composer-credentials.js} +3 -1
  133. package/lib/tasks/requirements/docker/index.js +15 -12
  134. package/lib/tasks/requirements/docker/performance.js +54 -0
  135. package/lib/tasks/requirements/docker/version.js +8 -8
  136. package/lib/tasks/requirements/index.js +5 -8
  137. package/lib/tasks/requirements/php-version.js +8 -116
  138. package/lib/tasks/requirements/platform.js +12 -25
  139. package/lib/tasks/start.js +38 -47
  140. package/lib/tasks/status/index.js +4 -10
  141. package/lib/tasks/stop.js +0 -2
  142. package/lib/tasks/theme/install-theme.js +1 -1
  143. package/lib/tasks/theme/symlink-theme.js +2 -3
  144. package/lib/util/config-php-json.js +13 -4
  145. package/lib/util/dockerfile-builder/build-instructions.js +197 -0
  146. package/lib/util/dockerfile-builder/index.js +276 -0
  147. package/lib/util/dockerfile-builder/types.d.ts +123 -0
  148. package/lib/util/env-php-json.js +10 -6
  149. package/lib/util/exec-async-command.js +3 -9
  150. package/lib/util/macos-version.js +20 -0
  151. package/lib/util/magento-task.js +3 -4
  152. package/lib/util/nginx-logs-parser.js +122 -0
  153. package/lib/util/php-task.js +3 -6
  154. package/lib/util/prefix.js +1 -1
  155. package/lib/util/run-composer.js +6 -14
  156. package/lib/util/run-container-image.js +17 -0
  157. package/lib/util/run-magento.js +6 -14
  158. package/lib/util/run-php.js +6 -17
  159. package/package.json +9 -9
  160. package/typings/context.d.ts +3 -9
  161. package/typings/index.d.ts +38 -57
  162. package/lib/config/composer.js +0 -11
  163. package/lib/config/php/extensions/libsodium.js +0 -36
  164. package/lib/config/php/releases/php-7.2.js +0 -25
  165. package/lib/config/php/releases/php-7.3.js +0 -25
  166. package/lib/config/php/releases/php-7.4.js +0 -23
  167. package/lib/config/php/releases/php-8.1.js +0 -25
  168. package/lib/config/phpbrew.js +0 -12
  169. package/lib/tasks/composer/install-prestissimo.js +0 -103
  170. package/lib/tasks/docker/containers.js +0 -231
  171. package/lib/tasks/php/bundled-extensions.js +0 -27
  172. package/lib/tasks/php/compile-options.js +0 -56
  173. package/lib/tasks/php/compile.js +0 -55
  174. package/lib/tasks/php/configure.js +0 -89
  175. package/lib/tasks/php/extensions/disable.js +0 -49
  176. package/lib/tasks/php/extensions/enable.js +0 -52
  177. package/lib/tasks/php/extensions/index.js +0 -80
  178. package/lib/tasks/php/extensions/install.js +0 -54
  179. package/lib/tasks/php/index.js +0 -79
  180. package/lib/tasks/php/install-sodium.js +0 -93
  181. package/lib/tasks/php/update-phpbrew.js +0 -45
  182. package/lib/tasks/php/validate-php.js +0 -67
  183. package/lib/tasks/php-fpm/get-process-id.js +0 -14
  184. package/lib/tasks/php-fpm/index.js +0 -4
  185. package/lib/tasks/php-fpm/start-php-fpm.js +0 -49
  186. package/lib/tasks/php-fpm/stop-php-fpm.js +0 -48
  187. package/lib/tasks/requirements/phpbrew/index.js +0 -61
  188. package/lib/tasks/requirements/phpbrew/install.js +0 -159
  189. package/lib/tasks/requirements/phpbrew/version.js +0 -28
@@ -0,0 +1,50 @@
1
+ const { nameKey, valueKey } = require('../keys');
2
+
3
+ const MESS_DETECTOR_PROJECT_CONFIGURATION_COMPONENT_NAME = 'MessDetectorProjectConfiguration';
4
+
5
+ const selectedConfigurationIdName = 'selectedConfigurationId';
6
+ const value = 'DEFAULT_INTERPRETER';
7
+
8
+ const defaultOption = {
9
+ [nameKey]: selectedConfigurationIdName,
10
+ [valueKey]: value
11
+ };
12
+
13
+ /**
14
+ * @param {Array} workspaceConfigs
15
+ * @returns {Promise<Boolean>}
16
+ */
17
+ const setupMessDetectorProjectConfiguration = async (workspaceConfigs) => {
18
+ let hasChanges = false;
19
+ const messDetectorProjectConfigurationComponent = workspaceConfigs.find(
20
+ (workspaceConfig) => workspaceConfig[nameKey] === MESS_DETECTOR_PROJECT_CONFIGURATION_COMPONENT_NAME
21
+ );
22
+
23
+ if (messDetectorProjectConfigurationComponent) {
24
+ if (messDetectorProjectConfigurationComponent.option && !Array.isArray(messDetectorProjectConfigurationComponent.option)) {
25
+ hasChanges = true;
26
+ messDetectorProjectConfigurationComponent.option = [messDetectorProjectConfigurationComponent.option];
27
+ } else if (!messDetectorProjectConfigurationComponent.option) {
28
+ hasChanges = true;
29
+ messDetectorProjectConfigurationComponent.option = [];
30
+ }
31
+
32
+ if (
33
+ messDetectorProjectConfigurationComponent.option.length > 0
34
+ && !messDetectorProjectConfigurationComponent.option.some((option) => option[nameKey] === selectedConfigurationIdName)
35
+ ) {
36
+ messDetectorProjectConfigurationComponent.option = [defaultOption];
37
+ hasChanges = true;
38
+ }
39
+ } else {
40
+ hasChanges = true;
41
+ workspaceConfigs.push({
42
+ [nameKey]: MESS_DETECTOR_PROJECT_CONFIGURATION_COMPONENT_NAME,
43
+ option: [defaultOption]
44
+ });
45
+ }
46
+
47
+ return hasChanges;
48
+ };
49
+
50
+ module.exports = setupMessDetectorProjectConfiguration;
@@ -0,0 +1,50 @@
1
+ const { nameKey, valueKey } = require('../keys');
2
+
3
+ const PHP_CODE_SNIFFER_PROJECT_CONFIGURATION_COMPONENT_NAME = 'PHPCodeSnifferProjectConfiguration';
4
+
5
+ const selectedConfigurationIdName = 'selectedConfigurationId';
6
+ const value = 'DEFAULT_INTERPRETER';
7
+
8
+ const defaultOption = {
9
+ [nameKey]: selectedConfigurationIdName,
10
+ [valueKey]: value
11
+ };
12
+
13
+ /**
14
+ * @param {Array} workspaceConfigs
15
+ * @returns {Promise<Boolean>}
16
+ */
17
+ const setupPHPCodeSnifferProjectConfiguration = async (workspaceConfigs) => {
18
+ let hasChanges = false;
19
+ const phpCodeSnifferProjectConfigurationComponent = workspaceConfigs.find(
20
+ (workspaceConfig) => workspaceConfig[nameKey] === PHP_CODE_SNIFFER_PROJECT_CONFIGURATION_COMPONENT_NAME
21
+ );
22
+
23
+ if (phpCodeSnifferProjectConfigurationComponent) {
24
+ if (phpCodeSnifferProjectConfigurationComponent.option && !Array.isArray(phpCodeSnifferProjectConfigurationComponent.option)) {
25
+ hasChanges = true;
26
+ phpCodeSnifferProjectConfigurationComponent.option = [phpCodeSnifferProjectConfigurationComponent.option];
27
+ } else if (!phpCodeSnifferProjectConfigurationComponent.option) {
28
+ hasChanges = true;
29
+ phpCodeSnifferProjectConfigurationComponent.option = [];
30
+ }
31
+
32
+ if (
33
+ phpCodeSnifferProjectConfigurationComponent.option.length > 0
34
+ && !phpCodeSnifferProjectConfigurationComponent.option.some((option) => option[nameKey] === selectedConfigurationIdName)
35
+ ) {
36
+ phpCodeSnifferProjectConfigurationComponent.option = [defaultOption];
37
+ hasChanges = true;
38
+ }
39
+ } else {
40
+ hasChanges = true;
41
+ workspaceConfigs.push({
42
+ [nameKey]: PHP_CODE_SNIFFER_PROJECT_CONFIGURATION_COMPONENT_NAME,
43
+ option: [defaultOption]
44
+ });
45
+ }
46
+
47
+ return hasChanges;
48
+ };
49
+
50
+ module.exports = setupPHPCodeSnifferProjectConfiguration;
@@ -0,0 +1,50 @@
1
+ const { nameKey, valueKey } = require('../keys');
2
+
3
+ const PHP_CS_FIXER_PROJECT_CONFIGURATION_COMPONENT_NAME = 'PHPCSFixerProjectConfiguration';
4
+
5
+ const selectedConfigurationIdName = 'selectedConfigurationId';
6
+ const value = 'DEFAULT_INTERPRETER';
7
+
8
+ const defaultOption = {
9
+ [nameKey]: selectedConfigurationIdName,
10
+ [valueKey]: value
11
+ };
12
+
13
+ /**
14
+ * @param {Array} workspaceConfigs
15
+ * @returns {Promise<Boolean>}
16
+ */
17
+ const setupPHPCSFixerProjectConfiguration = async (workspaceConfigs) => {
18
+ let hasChanges = false;
19
+ const phpCSFixeProjectConfigurationComponent = workspaceConfigs.find(
20
+ (workspaceConfig) => workspaceConfig[nameKey] === PHP_CS_FIXER_PROJECT_CONFIGURATION_COMPONENT_NAME
21
+ );
22
+
23
+ if (phpCSFixeProjectConfigurationComponent) {
24
+ if (phpCSFixeProjectConfigurationComponent.option && !Array.isArray(phpCSFixeProjectConfigurationComponent.option)) {
25
+ hasChanges = true;
26
+ phpCSFixeProjectConfigurationComponent.option = [phpCSFixeProjectConfigurationComponent.option];
27
+ } else if (!phpCSFixeProjectConfigurationComponent.option) {
28
+ hasChanges = true;
29
+ phpCSFixeProjectConfigurationComponent.option = [];
30
+ }
31
+
32
+ if (
33
+ phpCSFixeProjectConfigurationComponent.option.length > 0
34
+ && !phpCSFixeProjectConfigurationComponent.option.some((option) => option[nameKey] === selectedConfigurationIdName)
35
+ ) {
36
+ phpCSFixeProjectConfigurationComponent.option = [defaultOption];
37
+ hasChanges = true;
38
+ }
39
+ } else {
40
+ hasChanges = true;
41
+ workspaceConfigs.push({
42
+ [nameKey]: PHP_CS_FIXER_PROJECT_CONFIGURATION_COMPONENT_NAME,
43
+ option: [defaultOption]
44
+ });
45
+ }
46
+
47
+ return hasChanges;
48
+ };
49
+
50
+ module.exports = setupPHPCSFixerProjectConfiguration;
@@ -8,12 +8,13 @@ const portKey = '@_port';
8
8
  const xdebugDebugPortKey = '@_xdebug_debug_port';
9
9
  const ignoreConnectionsThroughUnregisteredServersKey = '@_ignore_connections_through_unregistered_servers';
10
10
 
11
+ const xdebugPort = '9003';
12
+
11
13
  /**
12
14
  * @param {Array} workspaceConfigs
13
- * @param {ReturnType<typeof import('./workspace-config').getWorkspaceConfig>} workspaceConfig
14
15
  * @returns {Promise<Boolean>}
15
16
  */
16
- const setupPHPDebugGeneral = async (workspaceConfigs, workspaceConfig) => {
17
+ const setupPHPDebugGeneral = async (workspaceConfigs) => {
17
18
  let hasChanges = false;
18
19
  const phpDebugGeneralComponent = workspaceConfigs.find(
19
20
  (workspaceConfig) => workspaceConfig[nameKey] === PHP_DEBUG_GENERAL_COMPONENT_NAME
@@ -30,30 +31,29 @@ const setupPHPDebugGeneral = async (workspaceConfigs, workspaceConfig) => {
30
31
 
31
32
  if (!(xdebugDebugPortKey in phpDebugGeneralComponent)) {
32
33
  hasChanges = true;
33
- phpDebugGeneralComponent[xdebugDebugPortKey] = workspaceConfig.v3Port;
34
+ phpDebugGeneralComponent[xdebugDebugPortKey] = xdebugPort;
34
35
  }
35
36
 
36
- const missingXDebugPorts = [workspaceConfig.v3Port, workspaceConfig.v2Port].filter(
37
- (port) => !phpDebugGeneralComponent.xdebug_debug_ports.some((xPort) => xPort[portKey] === port)
38
- );
37
+ if (phpDebugGeneralComponent[xdebugDebugPortKey] !== xdebugPort) {
38
+ hasChanges = true;
39
+ phpDebugGeneralComponent[xdebugDebugPortKey] = xdebugPort;
40
+ }
39
41
 
40
- if (missingXDebugPorts.length > 0) {
42
+ if (!phpDebugGeneralComponent.xdebug_debug_ports.some((xPort) => xPort[portKey] === xdebugPort)) {
41
43
  hasChanges = true;
42
- missingXDebugPorts.forEach((port) => {
43
- phpDebugGeneralComponent.xdebug_debug_ports.push({
44
- [portKey]: port
45
- });
44
+ phpDebugGeneralComponent.xdebug_debug_ports.push({
45
+ [portKey]: xdebugPort
46
46
  });
47
47
  }
48
48
  } else {
49
49
  hasChanges = true;
50
50
  workspaceConfigs.push({
51
51
  [nameKey]: PHP_DEBUG_GENERAL_COMPONENT_NAME,
52
- [xdebugDebugPortKey]: workspaceConfig.v3Port,
52
+ [xdebugDebugPortKey]: xdebugPort,
53
53
  [ignoreConnectionsThroughUnregisteredServersKey]: 'true',
54
- xdebug_debug_ports: [workspaceConfig.v3Port, workspaceConfig.v2Port].map((port) => ({
55
- [portKey]: port
56
- }))
54
+ xdebug_debug_ports: [{
55
+ [portKey]: xdebugPort
56
+ }]
57
57
  });
58
58
  }
59
59
 
@@ -3,13 +3,17 @@ const { nameKey } = require('../keys');
3
3
  const PHP_SERVERS_COMPONENT_NAME = 'PhpServers';
4
4
 
5
5
  const hostKey = '@_host';
6
+ const usePathMappingsKey = '@_use_path_mappings';
7
+ const localRootKey = '@_local-root';
8
+ const remoteRootKey = '@_remote-root';
6
9
 
7
10
  /**
8
11
  * @param {Array} workspaceConfigs
9
12
  * @param {ReturnType<typeof import('./workspace-config').getWorkspaceConfig>} workspaceConfig
13
+ * @param {import('../../../../../typings/context').ListrContext} ctx
10
14
  * @returns {Promise<Boolean>}
11
15
  */
12
- const setupPHPServers = async (workspaceConfigs, workspaceConfig) => {
16
+ const setupPHPServers = async (workspaceConfigs, workspaceConfig, ctx) => {
13
17
  let hasChanges = false;
14
18
  const phpServersComponent = workspaceConfigs.find(
15
19
  (workspaceConfig) => workspaceConfig[nameKey] === PHP_SERVERS_COMPONENT_NAME
@@ -18,7 +22,14 @@ const setupPHPServers = async (workspaceConfigs, workspaceConfig) => {
18
22
  const defaultServerConfig = {
19
23
  [hostKey]: workspaceConfig.debugServerAddress,
20
24
  id: '7e16e907-9ce3-4559-9d26-a30a5650d11f',
21
- [nameKey]: workspaceConfig.serverName
25
+ [nameKey]: workspaceConfig.serverName,
26
+ [usePathMappingsKey]: true,
27
+ path_mappings: {
28
+ mapping: {
29
+ [localRootKey]: '$PROJECT_DIR$',
30
+ [remoteRootKey]: ctx.config.baseConfig.containerMagentoDir
31
+ }
32
+ }
22
33
  };
23
34
 
24
35
  if (phpServersComponent) {
@@ -32,11 +43,26 @@ const setupPHPServers = async (workspaceConfigs, workspaceConfig) => {
32
43
 
33
44
  const serverConfiguration = phpServersComponent.servers.find((server) => server.server[nameKey] === workspaceConfig.serverName);
34
45
 
35
- if (!serverConfiguration) {
46
+ if (!serverConfiguration || !serverConfiguration.server) {
36
47
  hasChanges = true;
37
48
  phpServersComponent.servers.push({
38
49
  server: defaultServerConfig
39
50
  });
51
+ } else if (serverConfiguration.server) {
52
+ if (!serverConfiguration.server[usePathMappingsKey]) {
53
+ hasChanges = true;
54
+ serverConfiguration.server[usePathMappingsKey] = true;
55
+ }
56
+ if (!serverConfiguration.server.path_mappings
57
+ || (
58
+ serverConfiguration.server.path_mappings.mapping
59
+ && serverConfiguration.server.path_mappings.mapping[remoteRootKey] !== defaultServerConfig.path_mappings.mapping[remoteRootKey]
60
+ )
61
+ ) {
62
+ hasChanges = true;
63
+ serverConfiguration.server.path_mappings = serverConfiguration.server.path_mappings || {};
64
+ serverConfiguration.server.path_mappings.mapping = defaultServerConfig.path_mappings.mapping;
65
+ }
40
66
  }
41
67
  } else {
42
68
  hasChanges = true;
@@ -0,0 +1,50 @@
1
+ const { nameKey, valueKey } = require('../keys');
2
+
3
+ const PHP_STAN_PROJECT_CONFIGURATION_COMPONENT_NAME = 'PhpStanProjectConfiguration';
4
+
5
+ const selectedConfigurationIdName = 'selectedConfigurationId';
6
+ const value = 'DEFAULT_INTERPRETER';
7
+
8
+ const defaultOption = {
9
+ [nameKey]: selectedConfigurationIdName,
10
+ [valueKey]: value
11
+ };
12
+
13
+ /**
14
+ * @param {Array} workspaceConfigs
15
+ * @returns {Promise<Boolean>}
16
+ */
17
+ const setupPHPStanProjectConfiguration = async (workspaceConfigs) => {
18
+ let hasChanges = false;
19
+ const phpStanProjectConfigurationComponent = workspaceConfigs.find(
20
+ (workspaceConfig) => workspaceConfig[nameKey] === PHP_STAN_PROJECT_CONFIGURATION_COMPONENT_NAME
21
+ );
22
+
23
+ if (phpStanProjectConfigurationComponent) {
24
+ if (phpStanProjectConfigurationComponent.option && !Array.isArray(phpStanProjectConfigurationComponent.option)) {
25
+ hasChanges = true;
26
+ phpStanProjectConfigurationComponent.option = [phpStanProjectConfigurationComponent.option];
27
+ } else if (!phpStanProjectConfigurationComponent.option) {
28
+ hasChanges = true;
29
+ phpStanProjectConfigurationComponent.option = [];
30
+ }
31
+
32
+ if (
33
+ phpStanProjectConfigurationComponent.option.length > 0
34
+ && !phpStanProjectConfigurationComponent.option.some((option) => option[nameKey] === selectedConfigurationIdName)
35
+ ) {
36
+ phpStanProjectConfigurationComponent.option = [defaultOption];
37
+ hasChanges = true;
38
+ }
39
+ } else {
40
+ hasChanges = true;
41
+ workspaceConfigs.push({
42
+ [nameKey]: PHP_STAN_PROJECT_CONFIGURATION_COMPONENT_NAME,
43
+ option: [defaultOption]
44
+ });
45
+ }
46
+
47
+ return hasChanges;
48
+ };
49
+
50
+ module.exports = setupPHPStanProjectConfiguration;
@@ -0,0 +1,42 @@
1
+ const { nameKey } = require('../keys');
2
+
3
+ const PHP_WORKSPACE_PROJECT_CONFIGURATION_COMPONENT_NAME = 'PhpWorkspaceProjectConfiguration';
4
+
5
+ const interpreterNameKey = '@_interpreter_name';
6
+
7
+ /**
8
+ * @param {Array} workspaceConfigs
9
+ * @param {import('../../../../../typings/context').ListrContext} ctx
10
+ * @returns {Promise<Boolean>}
11
+ */
12
+ const setupPHPWorkspaceProjectConfiguration = async (workspaceConfigs, ctx) => {
13
+ let hasChanges = false;
14
+ const phpWorkspaceProjectConfigurationComponent = workspaceConfigs.find(
15
+ (workspaceConfig) => workspaceConfig[nameKey] === PHP_WORKSPACE_PROJECT_CONFIGURATION_COMPONENT_NAME
16
+ );
17
+ const { php } = ctx.config.docker.getContainers(ctx.ports);
18
+ const currentInterpreterImage = ctx.debug ? php.debugImage : php.image;
19
+
20
+ if (phpWorkspaceProjectConfigurationComponent) {
21
+ if (
22
+ !phpWorkspaceProjectConfigurationComponent[interpreterNameKey]
23
+ || (
24
+ phpWorkspaceProjectConfigurationComponent[interpreterNameKey] !== currentInterpreterImage
25
+ )
26
+ ) {
27
+ hasChanges = true;
28
+ phpWorkspaceProjectConfigurationComponent[interpreterNameKey] = currentInterpreterImage;
29
+ }
30
+ } else {
31
+ hasChanges = true;
32
+ workspaceConfigs.push({
33
+ [nameKey]: PHP_WORKSPACE_PROJECT_CONFIGURATION_COMPONENT_NAME,
34
+ [currentInterpreterImage]: currentInterpreterImage,
35
+ include_path: []
36
+ });
37
+ }
38
+
39
+ return hasChanges;
40
+ };
41
+
42
+ module.exports = setupPHPWorkspaceProjectConfiguration;
@@ -0,0 +1,50 @@
1
+ const { nameKey, valueKey } = require('../keys');
2
+
3
+ const PSALM_PROJECT_CONFIGURATION_COMPONENT_NAME = 'PsalmProjectConfiguration';
4
+
5
+ const selectedConfigurationIdName = 'selectedConfigurationId';
6
+ const value = 'DEFAULT_INTERPRETER';
7
+
8
+ const defaultOption = {
9
+ [nameKey]: selectedConfigurationIdName,
10
+ [valueKey]: value
11
+ };
12
+
13
+ /**
14
+ * @param {Array} workspaceConfigs
15
+ * @returns {Promise<Boolean>}
16
+ */
17
+ const setupPSalmProjectConfiguration = async (workspaceConfigs) => {
18
+ let hasChanges = false;
19
+ const psalmProjectConfigurationComponent = workspaceConfigs.find(
20
+ (workspaceConfig) => workspaceConfig[nameKey] === PSALM_PROJECT_CONFIGURATION_COMPONENT_NAME
21
+ );
22
+
23
+ if (psalmProjectConfigurationComponent) {
24
+ if (psalmProjectConfigurationComponent.option && !Array.isArray(psalmProjectConfigurationComponent.option)) {
25
+ hasChanges = true;
26
+ psalmProjectConfigurationComponent.option = [psalmProjectConfigurationComponent.option];
27
+ } else if (!psalmProjectConfigurationComponent.option) {
28
+ hasChanges = true;
29
+ psalmProjectConfigurationComponent.option = [];
30
+ }
31
+
32
+ if (
33
+ psalmProjectConfigurationComponent.option.length > 0
34
+ && !psalmProjectConfigurationComponent.option.some((option) => option[nameKey] === selectedConfigurationIdName)
35
+ ) {
36
+ psalmProjectConfigurationComponent.option = [defaultOption];
37
+ hasChanges = true;
38
+ }
39
+ } else {
40
+ hasChanges = true;
41
+ workspaceConfigs.push({
42
+ [nameKey]: PSALM_PROJECT_CONFIGURATION_COMPONENT_NAME,
43
+ option: [defaultOption]
44
+ });
45
+ }
46
+
47
+ return hasChanges;
48
+ };
49
+
50
+ module.exports = setupPSalmProjectConfiguration;
@@ -5,8 +5,6 @@ const { baseConfig } = require('../../../../config');
5
5
  * @param {import('../../../../../typings/index').CMAConfiguration} app
6
6
  */
7
7
  const getWorkspaceConfig = (app) => ({
8
- v2Port: '9111',
9
- v3Port: '9003',
10
8
  debugServerAddress: `http://${ app.host }`,
11
9
  serverName: 'create-magento-app',
12
10
  runManagerName: 'create-magento-app',
@@ -19,7 +19,8 @@ const createSSLTerminatorConfig = () => ({
19
19
  overridenConfiguration,
20
20
  baseConfig
21
21
  },
22
- isWsl
22
+ isWsl,
23
+ debug
23
24
  } = ctx;
24
25
 
25
26
  const {
@@ -84,7 +85,8 @@ const createSSLTerminatorConfig = () => ({
84
85
  hostMachine,
85
86
  hostPort,
86
87
  config: overridenConfiguration,
87
- networkToBindTo
88
+ networkToBindTo,
89
+ debug
88
90
  }
89
91
  });
90
92
  } catch (e) {
@@ -1,77 +1,85 @@
1
1
  const path = require('path');
2
- const semver = require('semver');
3
2
  const fs = require('fs');
4
- const os = require('os');
5
3
  const hjson = require('hjson');
6
4
  const pathExists = require('../../util/path-exists');
7
5
  const setConfigFile = require('../../util/set-config');
8
6
  const UnknownError = require('../../errors/unknown-error');
9
7
 
10
- const phpXDebug2port = 9111;
11
- const phpXDebug3port = 9003;
12
8
  const listenForXDebugConfigName = 'Listen for XDebug';
13
9
 
14
- const vscodeLaunchConfigPath = path.join(process.cwd(), '.vscode', 'launch.json');
10
+ const xdebugPort = 9003;
15
11
 
16
- /**
17
- * @param {import('../../../typings/context').ListrContext['config']['php']} php
18
- */
19
- const getCurrentXDebugPort = (php) => (semver.satisfies(php.extensions.xdebug.version, '>=3')
20
- ? phpXDebug3port
21
- : phpXDebug2port);
12
+ const vscodeLaunchConfigPath = path.join(process.cwd(), '.vscode', 'launch.json');
22
13
 
23
14
  /**
24
- * @param {import('../../../typings/context').ListrContext['config']['php']} php
25
- */
26
- const getPHPBinPathWithHomeVariable = (php) => php.binPath.replace(os.homedir(), '$HOME');
27
- /**
28
- * @param {import('../../../typings/context').ListrContext['config']['php']} php
15
+ * @param {import('../../../typings/context').ListrContext} ctx
29
16
  */
30
- const addPHPDebugConfig = (vscodeLaunchConfig, php) => {
17
+ const addPHPDebugConfig = (vscodeLaunchConfig, ctx) => {
31
18
  const phpXDebugConfig = vscodeLaunchConfig.configurations.find(
32
19
  ({ name }) => name === listenForXDebugConfigName
33
20
  );
34
21
 
35
- const phpXDebugPort = getCurrentXDebugPort(php);
36
- const phpBingPath = getPHPBinPathWithHomeVariable(php);
22
+ let hasChanges = false;
23
+
24
+ const newConfiguration = {
25
+ name: listenForXDebugConfigName,
26
+ type: 'php',
27
+ request: 'launch',
28
+ port: xdebugPort,
29
+ pathMappings: {
30
+ // eslint-disable-next-line no-template-curly-in-string
31
+ [ctx.config.baseConfig.containerMagentoDir]: '${workspaceFolder}'
32
+ }
33
+
34
+ };
35
+
36
+ if (phpXDebugConfig && phpXDebugConfig.runtimeExecutable) {
37
+ vscodeLaunchConfig.configurations = vscodeLaunchConfig.configurations.filter(
38
+ ({ name }) => name !== listenForXDebugConfigName
39
+ );
37
40
 
41
+ vscodeLaunchConfig.configurations.push(newConfiguration);
42
+
43
+ return true;
44
+ }
38
45
  if (!phpXDebugConfig) {
39
- vscodeLaunchConfig.configurations.push({
40
- name: listenForXDebugConfigName,
41
- type: 'php',
42
- request: 'launch',
43
- port: phpXDebugPort,
44
- runtimeExecutable: phpBingPath
45
- });
46
+ vscodeLaunchConfig.configurations.push(newConfiguration);
46
47
 
47
48
  return true;
48
49
  }
49
50
 
50
51
  if (
51
- phpXDebugConfig.port !== phpXDebugPort
52
- && phpXDebugConfig.runtimeExecutable !== phpBingPath
53
- ) {
54
- phpXDebugConfig.port = phpXDebugPort;
55
- phpXDebugConfig.runtimeExecutable = phpBingPath;
52
+ !phpXDebugConfig.port
53
+ || phpXDebugConfig.port !== xdebugPort) {
54
+ phpXDebugConfig.port = xdebugPort;
56
55
 
57
- return true;
56
+ hasChanges = true;
57
+ }
58
+
59
+ if (!phpXDebugConfig.pathMappings || !phpXDebugConfig.pathMappings[ctx.config.baseConfig.containerMagentoDir]) {
60
+ phpXDebugConfig.pathMappings = {
61
+ // eslint-disable-next-line no-template-curly-in-string
62
+ [ctx.config.baseConfig.containerMagentoDir]: '${workspaceFolder}'
63
+ };
64
+
65
+ hasChanges = true;
58
66
  }
59
67
 
60
- return false;
68
+ return hasChanges;
61
69
  };
62
70
 
63
71
  /**
64
72
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
65
73
  */
66
- const createPhpFpmConfig = () => ({
74
+ const createVSCodeConfig = () => ({
67
75
  title: 'Setting VSCode config',
68
- task: async ({ config: { php, baseConfig } }, task) => {
76
+ task: async (ctx, task) => {
69
77
  if (await pathExists(vscodeLaunchConfigPath)) {
70
78
  const vscodeLaunchConfig = hjson.parse(await fs.promises.readFile(vscodeLaunchConfigPath, 'utf-8'), {
71
79
  keepWsc: true
72
80
  });
73
81
 
74
- const vscodeConfigEdited = addPHPDebugConfig(vscodeLaunchConfig, php);
82
+ const vscodeConfigEdited = addPHPDebugConfig(vscodeLaunchConfig, ctx);
75
83
 
76
84
  // if vscode config is up-to-date, skip task
77
85
  if (!vscodeConfigEdited) {
@@ -79,7 +87,15 @@ const createPhpFpmConfig = () => ({
79
87
  return;
80
88
  }
81
89
 
82
- await fs.promises.writeFile(vscodeLaunchConfigPath, hjson.stringify(vscodeLaunchConfig));
90
+ const result = hjson.stringify(vscodeLaunchConfig, {
91
+ keepWsc: true,
92
+ bracesSameLine: true,
93
+ separator: true,
94
+ quotes: 'all'
95
+
96
+ });
97
+
98
+ await fs.promises.writeFile(vscodeLaunchConfigPath, result);
83
99
 
84
100
  return;
85
101
  }
@@ -93,14 +109,13 @@ const createPhpFpmConfig = () => ({
93
109
  }
94
110
 
95
111
  try {
96
- const phpXDebugPort = getCurrentXDebugPort(php);
97
- const vscodeLaunchConfigTemplatePath = path.join(baseConfig.templateDir, 'vscode-launch.template.json');
112
+ const vscodeLaunchConfigTemplatePath = path.join(ctx.config.baseConfig.templateDir, 'vscode-launch.template.json');
98
113
  await setConfigFile({
99
114
  template: vscodeLaunchConfigTemplatePath,
100
115
  configPathname: vscodeLaunchConfigPath,
101
116
  templateArgs: {
102
- XDebugPort: phpXDebugPort,
103
- PHPBinPath: getPHPBinPathWithHomeVariable(php)
117
+ XDebugPort: xdebugPort,
118
+ baseConfig: ctx.config.baseConfig
104
119
  }
105
120
  });
106
121
  } catch (e) {
@@ -109,4 +124,4 @@ const createPhpFpmConfig = () => ({
109
124
  }
110
125
  });
111
126
 
112
- module.exports = createPhpFpmConfig;
127
+ module.exports = createVSCodeConfig;
@@ -20,7 +20,8 @@ const prepareFileSystem = () => ({
20
20
  createVSCodeConfig(),
21
21
  createVarnishConfig()
22
22
  ], {
23
- concurrent: true
23
+ concurrent: true,
24
+ exitOnError: false
24
25
  })
25
26
  });
26
27
 
package/lib/tasks/link.js CHANGED
@@ -4,7 +4,6 @@ const getProjectConfiguration = require('../config/get-project-configuration');
4
4
  const retrieveThemeData = require('./theme/retrieve-theme-data');
5
5
  const linkTheme = require('./theme/link-theme');
6
6
  const { startServices } = require('./docker');
7
- const { startPhpFpm } = require('./php-fpm');
8
7
  const checkConfigurationFile = require('../config/check-configuration-file');
9
8
  const { connectToMySQL } = require('./mysql');
10
9
 
@@ -18,7 +17,7 @@ const linkTask = (themePath) => ({
18
17
  getProjectConfiguration(),
19
18
  getCachedPorts(),
20
19
  startServices(),
21
- startPhpFpm(),
20
+ // startPhpFpm(),
22
21
  connectToMySQL(),
23
22
  retrieveThemeData(themePath),
24
23
  linkTheme()