@scandipwa/magento-scripts 1.13.5-alpha.1 → 1.14.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/lib/config/templates/php-fpm.template.conf +1 -0
  2. package/lib/config/versions/magento-2.3.0.js +3 -1
  3. package/lib/config/versions/magento-2.3.1.js +3 -1
  4. package/lib/config/versions/magento-2.3.2-p2.js +3 -1
  5. package/lib/config/versions/magento-2.3.2.js +3 -1
  6. package/lib/config/versions/magento-2.3.3-p1.js +3 -1
  7. package/lib/config/versions/magento-2.3.3.js +3 -1
  8. package/lib/config/versions/magento-2.3.4-p2.js +3 -1
  9. package/lib/config/versions/magento-2.3.4.js +3 -1
  10. package/lib/config/versions/magento-2.3.5-p1.js +3 -1
  11. package/lib/config/versions/magento-2.3.5-p2.js +3 -1
  12. package/lib/config/versions/magento-2.3.5.js +3 -1
  13. package/lib/config/versions/magento-2.3.6-p1.js +3 -1
  14. package/lib/config/versions/magento-2.3.6.js +3 -1
  15. package/lib/config/versions/magento-2.3.7-p2.js +47 -0
  16. package/lib/config/versions/magento-2.3.7-p3.js +47 -0
  17. package/lib/config/versions/magento-2.4.3-p2.js +51 -0
  18. package/lib/config/versions/magento-2.4.4.js +51 -0
  19. package/lib/config/xml-parser.js +61 -0
  20. package/lib/tasks/composer/index.js +1 -1
  21. package/lib/tasks/file-system/create-phpstorm-config/database-config.js +248 -0
  22. package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +83 -0
  23. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +154 -0
  24. package/lib/tasks/file-system/create-phpstorm-config/index.js +27 -0
  25. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +29 -0
  26. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/config.js +54 -0
  27. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +31 -0
  28. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +42 -0
  29. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/eslint-inspection-config.js +37 -0
  30. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/index.js +80 -0
  31. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +29 -0
  32. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +145 -0
  33. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/paths.js +20 -0
  34. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-fixer-validation-inspection-config.js +60 -0
  35. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +119 -0
  36. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/stylelint-inspection-config.js +37 -0
  37. package/lib/tasks/file-system/create-phpstorm-config/keys.js +14 -0
  38. package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +67 -0
  39. package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +57 -0
  40. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +76 -0
  41. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +63 -0
  42. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +69 -0
  43. package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +77 -0
  44. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +98 -0
  45. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/format-setting-config.js +57 -0
  46. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +66 -0
  47. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +64 -0
  48. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +60 -0
  49. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +51 -0
  50. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +74 -0
  51. package/lib/tasks/file-system/create-phpstorm-config/xml-utils.js +5 -0
  52. package/lib/tasks/file-system/index.js +1 -1
  53. package/lib/tasks/php/compile-options.js +2 -1
  54. package/lib/tasks/php/compile.js +1 -1
  55. package/lib/tasks/requirements/composer.js +211 -19
  56. package/lib/tasks/requirements/index.js +1 -2
  57. package/lib/tasks/start.js +6 -2
  58. package/lib/util/instance-metadata.js +7 -1
  59. package/package.json +13 -2
  60. package/readme.md +54 -124
  61. package/typings/context.d.ts +2 -0
  62. package/typings/phpstorm.d.ts +33 -0
  63. package/lib/tasks/file-system/create-php-storm-config.js +0 -82
@@ -0,0 +1,69 @@
1
+ const {
2
+ nameKey,
3
+ valueKey
4
+ } = require('../keys');
5
+
6
+ const PHP_PROJECT_SHARED_CONFIGURATION_COMPONENT_NAME = 'PhpProjectSharedConfiguration';
7
+
8
+ const SUGGESTED_CHANGE_DEFAULT_LANGUAGE_LEVEL_OPTION_NAME = 'suggestChangeDefaultLanguageLevel';
9
+
10
+ const phpLanguageLevelKey = '@_php_language_level';
11
+
12
+ /**
13
+ * @param {Array} phpConfigs
14
+ * @param {String} currentPhpLanguageLevel
15
+ * @returns {Promise<Boolean>}
16
+ */
17
+ const setupPHPProjectSharedConfiguration = async (phpConfigs, currentPhpLanguageLevel) => {
18
+ let hasChanges = false;
19
+ const phpProjectSharedConfigurationComponent = phpConfigs.find(
20
+ (phpConfig) => phpConfig[nameKey] === PHP_PROJECT_SHARED_CONFIGURATION_COMPONENT_NAME
21
+ );
22
+
23
+ const defaultSuggestChangeDefaultLanguageLevelOption = {
24
+ [nameKey]: SUGGESTED_CHANGE_DEFAULT_LANGUAGE_LEVEL_OPTION_NAME,
25
+ [valueKey]: currentPhpLanguageLevel
26
+ };
27
+
28
+ if (phpProjectSharedConfigurationComponent) {
29
+ if (phpProjectSharedConfigurationComponent.option && !Array.isArray(phpProjectSharedConfigurationComponent.option)) {
30
+ hasChanges = true;
31
+ phpProjectSharedConfigurationComponent.option = [phpProjectSharedConfigurationComponent.option];
32
+ } else if (!phpProjectSharedConfigurationComponent.option) {
33
+ hasChanges = true;
34
+ phpProjectSharedConfigurationComponent.option = [];
35
+ }
36
+
37
+ if (phpProjectSharedConfigurationComponent[phpLanguageLevelKey] !== currentPhpLanguageLevel) {
38
+ hasChanges = true;
39
+ phpProjectSharedConfigurationComponent[phpLanguageLevelKey] = currentPhpLanguageLevel;
40
+ }
41
+
42
+ const suggestedChangeDefaultLanguageLevelOption = phpProjectSharedConfigurationComponent.option.find(
43
+ (phpProjectSharedConfigOption) => phpProjectSharedConfigOption[nameKey] === SUGGESTED_CHANGE_DEFAULT_LANGUAGE_LEVEL_OPTION_NAME
44
+ );
45
+
46
+ if (suggestedChangeDefaultLanguageLevelOption) {
47
+ if (suggestedChangeDefaultLanguageLevelOption[valueKey] !== 'false') {
48
+ hasChanges = true;
49
+ suggestedChangeDefaultLanguageLevelOption[valueKey] = 'false';
50
+ }
51
+ } else {
52
+ hasChanges = true;
53
+ phpProjectSharedConfigurationComponent.option.push(defaultSuggestChangeDefaultLanguageLevelOption);
54
+ }
55
+ } else {
56
+ hasChanges = true;
57
+ phpConfigs.push({
58
+ [nameKey]: PHP_PROJECT_SHARED_CONFIGURATION_COMPONENT_NAME,
59
+ [phpLanguageLevelKey]: currentPhpLanguageLevel,
60
+ option: [
61
+ defaultSuggestChangeDefaultLanguageLevelOption
62
+ ]
63
+ });
64
+ }
65
+
66
+ return hasChanges;
67
+ };
68
+
69
+ module.exports = setupPHPProjectSharedConfiguration;
@@ -0,0 +1,77 @@
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+ const { loadXmlFile, buildXmlFile } = require('../../../config/xml-parser');
4
+ const pathExists = require('../../../util/path-exists');
5
+ const { valueKey, nameKey } = require('./keys');
6
+
7
+ const STYLELINT_CONFIGURATION_COMPONENT_NAME = 'StylelintConfiguration';
8
+
9
+ const pathToStylelintConfig = path.join(process.cwd(), '.idea', 'stylesheetLinters', 'stylelint.xml');
10
+ const pathToStylelintConfigDir = path.parse(pathToStylelintConfig).dir;
11
+
12
+ const DEFAULT_STYLE_PATTERN = '{**/*,*}.{css,scss}';
13
+
14
+ const defaultESLintComponentConfiguration = {
15
+ [nameKey]: STYLELINT_CONFIGURATION_COMPONENT_NAME,
16
+ 'file-patterns': {
17
+ [valueKey]: DEFAULT_STYLE_PATTERN
18
+ }
19
+ };
20
+
21
+ /**
22
+ * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
23
+ */
24
+ const setupStylelintConfig = () => ({
25
+ title: 'Set up Stylelint configuration',
26
+ task: async (ctx, task) => {
27
+ if (await pathExists(pathToStylelintConfig)) {
28
+ let hasChanges = false;
29
+ const styleLintConfigurationData = await loadXmlFile(pathToStylelintConfig);
30
+
31
+ if (styleLintConfigurationData.project.component && !Array.isArray(styleLintConfigurationData.project.component)) {
32
+ hasChanges = true;
33
+ styleLintConfigurationData.project.component = [styleLintConfigurationData.project.component];
34
+ }
35
+
36
+ const styleLintConfigurationComponent = styleLintConfigurationData.project.component.find(
37
+ (component) => component[nameKey] === STYLELINT_CONFIGURATION_COMPONENT_NAME
38
+ );
39
+
40
+ if (!styleLintConfigurationComponent) {
41
+ hasChanges = true;
42
+ styleLintConfigurationData.project.component.push(defaultESLintComponentConfiguration);
43
+ }
44
+
45
+ if (hasChanges) {
46
+ await buildXmlFile(pathToStylelintConfig, styleLintConfigurationData);
47
+ } else {
48
+ task.skip();
49
+ }
50
+
51
+ return;
52
+ }
53
+
54
+ if (!await pathExists(pathToStylelintConfigDir)) {
55
+ await fs.promises.mkdir(pathToStylelintConfigDir, {
56
+ recursive: true
57
+ });
58
+ }
59
+
60
+ const styleLintConfigurationData = {
61
+ '?xml': {
62
+ '@_version': '1.0',
63
+ '@_encoding': 'UTF-8'
64
+ },
65
+ project: {
66
+ '@_version': '4',
67
+ component: [
68
+ defaultESLintComponentConfiguration
69
+ ]
70
+ }
71
+ };
72
+
73
+ await buildXmlFile(pathToStylelintConfig, styleLintConfigurationData);
74
+ }
75
+ });
76
+
77
+ module.exports = setupStylelintConfig;
@@ -0,0 +1,98 @@
1
+ const path = require('path');
2
+ const { baseConfig } = require('../../../../config');
3
+ const pathExists = require('../../../../util/path-exists');
4
+ const { nameKey } = require('../keys');
5
+ const { formatPathForPHPStormConfig } = require('../xml-utils');
6
+
7
+ const COMPOSER_SETTINGS_COMPONENT_NAME = 'ComposerSettings';
8
+
9
+ const pharPathKey = '@_pharPath';
10
+ const doNotAskKey = '@_doNotAsk';
11
+ const synchronizationStateKey = '@_synchronizationState';
12
+
13
+ const composerJsonPath = path.join(process.cwd(), 'composer.json');
14
+ const composerJsonFormattedPath = formatPathForPHPStormConfig(composerJsonPath);
15
+ const composerPharPath = path.join(baseConfig.cacheDir, 'composer', 'composer.phar');
16
+ const composerPharFormattedPath = formatPathForPHPStormConfig(composerPharPath);
17
+
18
+ const defaultComposerSettingsProperties = {
19
+ [doNotAskKey]: 'true',
20
+ [synchronizationStateKey]: 'SYNCHRONIZE'
21
+ };
22
+
23
+ // TODO Ideally, we want to setup interpreter for compose.phar
24
+
25
+ // It should look like this:
26
+ // <component name="ComposerSettings" synchronizationState="DONT_SYNCHRONIZE">
27
+ // <pharConfigPath>$PROJECT_DIR$/composer.json</pharConfigPath>
28
+ // <execution>
29
+ // <phar
30
+ // pharPath="$PROJECT_DIR$/node_modules/.create-magento-app-cache/composer/composer.phar"
31
+ // interpreterId="f19b09e2-16e7-491f-9056-3299df58e578"
32
+ // />
33
+ // </execution>
34
+ // </component>
35
+
36
+ /**
37
+ * @param {Array} workspaceConfigs
38
+ * @returns {Promise<Boolean>}
39
+ */
40
+ const setupComposerSettings = async (workspaceConfigs) => {
41
+ let hasChanges = false;
42
+ const composerSettingsComponent = workspaceConfigs.find(
43
+ (workspaceConfig) => workspaceConfig[nameKey] === COMPOSER_SETTINGS_COMPONENT_NAME
44
+ );
45
+
46
+ const isComposerJsonExists = await pathExists(composerJsonPath);
47
+ const isComposerPharExists = await pathExists(composerPharPath);
48
+
49
+ if (composerSettingsComponent) {
50
+ if (
51
+ 'pharConfigPath' in composerSettingsComponent
52
+ && isComposerJsonExists
53
+ && composerSettingsComponent.pharConfigPath !== composerJsonFormattedPath
54
+ ) {
55
+ hasChanges = true;
56
+ composerSettingsComponent.pharConfigPath = composerJsonFormattedPath;
57
+ }
58
+
59
+ const pharConfig = composerSettingsComponent.execution && composerSettingsComponent.execution.phar;
60
+
61
+ if (pharConfig && isComposerPharExists && pharConfig[pharPathKey] !== composerPharFormattedPath) {
62
+ hasChanges = true;
63
+ pharConfig[pharPathKey] = composerPharFormattedPath;
64
+ } else if (!pharConfig && isComposerPharExists) {
65
+ hasChanges = true;
66
+ composerSettingsComponent.execution = composerSettingsComponent.execution || {};
67
+ composerSettingsComponent.execution.phar = {
68
+ [pharPathKey]: composerPharFormattedPath
69
+ };
70
+ }
71
+
72
+ const composerSettingsMissingProperties = Object.entries(defaultComposerSettingsProperties)
73
+ .filter(([key]) => !(key in composerSettingsComponent));
74
+
75
+ if (composerSettingsMissingProperties.length > 0) {
76
+ hasChanges = true;
77
+ composerSettingsMissingProperties.forEach(([key, value]) => {
78
+ composerSettingsComponent[key] = value;
79
+ });
80
+ }
81
+ } else {
82
+ hasChanges = true;
83
+ workspaceConfigs.push({
84
+ [nameKey]: COMPOSER_SETTINGS_COMPONENT_NAME,
85
+ ...defaultComposerSettingsProperties,
86
+ pharConfigPath: composerJsonFormattedPath,
87
+ execution: {
88
+ phar: {
89
+ [pharPathKey]: composerPharFormattedPath
90
+ }
91
+ }
92
+ });
93
+ }
94
+
95
+ return hasChanges;
96
+ };
97
+
98
+ module.exports = setupComposerSettings;
@@ -0,0 +1,57 @@
1
+ const {
2
+ nameKey,
3
+ valueKey
4
+ } = require('../keys');
5
+
6
+ const FORMAT_ON_SAVE_OPTIONS_COMPONENT_NAME = 'FormatOnSaveOptions';
7
+
8
+ const MY_FORMAT_ONLY_CHANGED_LINES_OPTION_NAME = 'myFormatOnlyChangedLines';
9
+ const MY_RUN_ON_SAVE_OPTION_NAME = 'myRunOnSave';
10
+
11
+ /**
12
+ * @param {Array} workspaceConfigs
13
+ * @returns {Promise<Boolean>}
14
+ */
15
+ const setupFormatOnSave = async (workspaceConfigs) => {
16
+ let hasChanges = false;
17
+ const formatOnSaveOptionsComponent = workspaceConfigs.find(
18
+ (workspaceConfig) => workspaceConfig[nameKey] === FORMAT_ON_SAVE_OPTIONS_COMPONENT_NAME
19
+ );
20
+
21
+ if (formatOnSaveOptionsComponent) {
22
+ if (formatOnSaveOptionsComponent.option && !Array.isArray(formatOnSaveOptionsComponent.option)) {
23
+ hasChanges = true;
24
+ formatOnSaveOptionsComponent.option = [formatOnSaveOptionsComponent.option];
25
+ } else if (!formatOnSaveOptionsComponent.option) {
26
+ hasChanges = true;
27
+ formatOnSaveOptionsComponent.option = [];
28
+ }
29
+
30
+ const missingOptions = [MY_FORMAT_ONLY_CHANGED_LINES_OPTION_NAME, MY_RUN_ON_SAVE_OPTION_NAME].filter(
31
+ (optionName) => !formatOnSaveOptionsComponent.option.some((option) => option[nameKey] === optionName)
32
+ );
33
+
34
+ if (missingOptions.length > 0) {
35
+ hasChanges = true;
36
+ missingOptions.forEach((missingOption) => {
37
+ formatOnSaveOptionsComponent.option.push({
38
+ [nameKey]: missingOption,
39
+ [valueKey]: 'true'
40
+ });
41
+ });
42
+ }
43
+ } else {
44
+ hasChanges = true;
45
+ workspaceConfigs.push({
46
+ [nameKey]: FORMAT_ON_SAVE_OPTIONS_COMPONENT_NAME,
47
+ option: [MY_FORMAT_ONLY_CHANGED_LINES_OPTION_NAME, MY_RUN_ON_SAVE_OPTION_NAME].map((option) => ({
48
+ [nameKey]: option,
49
+ [valueKey]: 'true'
50
+ }))
51
+ });
52
+ }
53
+
54
+ return hasChanges;
55
+ };
56
+
57
+ module.exports = setupFormatOnSave;
@@ -0,0 +1,66 @@
1
+ const { loadXmlFile, buildXmlFile } = require('../../../../config/xml-parser');
2
+ const pathExists = require('../../../../util/path-exists');
3
+ const setupComposerSettings = require('./composer-settings-config');
4
+ const setupFormatOnSave = require('./format-setting-config');
5
+ const setupPHPDebugGeneral = require('./php-debug-general-config');
6
+ const setupPHPServers = require('./php-server-config');
7
+ const setupPropertiesComponent = require('./properties-component-config');
8
+ const setupRunManager = require('./run-manager-config');
9
+
10
+ /**
11
+ * @type {() => import('listr2').ListrTask<import('../../../../../typings/context').ListrContext>}
12
+ */
13
+ const setupWorkspaceConfig = () => ({
14
+ title: 'Set up Workspace configuration',
15
+ task: async (ctx, task) => {
16
+ const {
17
+ config: {
18
+ phpStorm
19
+ }
20
+ } = ctx;
21
+
22
+ if (await pathExists(phpStorm.xdebug.path)) {
23
+ const workspaceConfiguration = await loadXmlFile(phpStorm.xdebug.path);
24
+ const workspaceConfigs = workspaceConfiguration.project.component;
25
+ const hasChanges = await Promise.all([
26
+ setupPHPDebugGeneral(workspaceConfigs, phpStorm),
27
+ setupPHPServers(workspaceConfigs, phpStorm),
28
+ setupRunManager(workspaceConfigs, phpStorm),
29
+ setupPropertiesComponent(workspaceConfigs)
30
+ ]);
31
+
32
+ if (hasChanges.includes(true)) {
33
+ await buildXmlFile(phpStorm.php.path, workspaceConfiguration);
34
+ } else {
35
+ task.skip();
36
+ }
37
+
38
+ return;
39
+ }
40
+
41
+ const workspaceConfiguration = {
42
+ '?xml': {
43
+ '@_version': '1.0',
44
+ '@_encoding': 'UTF-8'
45
+ },
46
+ project: {
47
+ '@_version': '4',
48
+ component: []
49
+ }
50
+ };
51
+ const workspaceConfigs = workspaceConfiguration.project.component;
52
+
53
+ await Promise.all([
54
+ setupPHPDebugGeneral(workspaceConfigs, phpStorm),
55
+ setupPHPServers(workspaceConfigs, phpStorm),
56
+ setupRunManager(workspaceConfigs, phpStorm),
57
+ setupPropertiesComponent(workspaceConfigs),
58
+ setupComposerSettings(workspaceConfigs),
59
+ setupFormatOnSave(workspaceConfigs)
60
+ ]);
61
+
62
+ await buildXmlFile(phpStorm.xdebug.path, workspaceConfiguration);
63
+ }
64
+ });
65
+
66
+ module.exports = setupWorkspaceConfig;
@@ -0,0 +1,64 @@
1
+ const {
2
+ nameKey
3
+ } = require('../keys');
4
+
5
+ const PHP_DEBUG_GENERAL_COMPONENT_NAME = 'PhpDebugGeneral';
6
+
7
+ const portKey = '@_port';
8
+ const xdebugDebugPortKey = '@_xdebug_debug_port';
9
+ const ignoreConnectionsThroughUnregisteredServersKey = '@_ignore_connections_through_unregistered_servers';
10
+
11
+ /**
12
+ * @param {Array} workspaceConfigs
13
+ * @param {import('../../../../../typings/phpstorm').PHPStormConfig} phpStormConfiguration
14
+ * @returns {Promise<Boolean>}
15
+ */
16
+ const setupPHPDebugGeneral = async (workspaceConfigs, phpStormConfiguration) => {
17
+ const { xdebug } = phpStormConfiguration;
18
+ let hasChanges = false;
19
+ const phpDebugGeneralComponent = workspaceConfigs.find(
20
+ (workspaceConfig) => workspaceConfig[nameKey] === PHP_DEBUG_GENERAL_COMPONENT_NAME
21
+ );
22
+
23
+ if (phpDebugGeneralComponent) {
24
+ if (phpDebugGeneralComponent.xdebug_debug_ports && !Array.isArray(phpDebugGeneralComponent.xdebug_debug_ports)) {
25
+ hasChanges = true;
26
+ phpDebugGeneralComponent.xdebug_debug_ports = [phpDebugGeneralComponent.xdebug_debug_ports];
27
+ } else if (!phpDebugGeneralComponent.xdebug_debug_ports) {
28
+ hasChanges = true;
29
+ phpDebugGeneralComponent.xdebug_debug_ports = [];
30
+ }
31
+
32
+ if (!(xdebugDebugPortKey in phpDebugGeneralComponent)) {
33
+ hasChanges = true;
34
+ phpDebugGeneralComponent[xdebugDebugPortKey] = xdebug.v3Port;
35
+ }
36
+
37
+ const missingXDebugPorts = [xdebug.v3Port, xdebug.v2Port].filter(
38
+ (port) => !phpDebugGeneralComponent.xdebug_debug_ports.some((xPort) => xPort[portKey] === port)
39
+ );
40
+
41
+ if (missingXDebugPorts.length > 0) {
42
+ hasChanges = true;
43
+ missingXDebugPorts.forEach((port) => {
44
+ phpDebugGeneralComponent.xdebug_debug_ports.push({
45
+ [portKey]: port
46
+ });
47
+ });
48
+ }
49
+ } else {
50
+ hasChanges = true;
51
+ workspaceConfigs.push({
52
+ [nameKey]: PHP_DEBUG_GENERAL_COMPONENT_NAME,
53
+ [xdebugDebugPortKey]: xdebug.v3Port,
54
+ [ignoreConnectionsThroughUnregisteredServersKey]: 'true',
55
+ xdebug_debug_ports: [xdebug.v3Port, xdebug.v2Port].map((port) => ({
56
+ [portKey]: port
57
+ }))
58
+ });
59
+ }
60
+
61
+ return hasChanges;
62
+ };
63
+
64
+ module.exports = setupPHPDebugGeneral;
@@ -0,0 +1,60 @@
1
+ const { nameKey } = require('../keys');
2
+
3
+ const PHP_SERVERS_COMPONENT_NAME = 'PhpServers';
4
+
5
+ const hostKey = '@_host';
6
+
7
+ /**
8
+ * @param {Array} workspaceConfigs
9
+ * @param {import('../../../../../typings/phpstorm').PHPStormConfig} phpStormConfiguration
10
+ * @returns {Promise<Boolean>}
11
+ */
12
+ const setupPHPServers = async (workspaceConfigs, phpStormConfiguration) => {
13
+ const { xdebug } = phpStormConfiguration;
14
+ let hasChanges = false;
15
+ const phpServersComponent = workspaceConfigs.find(
16
+ (workspaceConfig) => workspaceConfig[nameKey] === PHP_SERVERS_COMPONENT_NAME
17
+ );
18
+
19
+ const defaultServerConfig = {
20
+ [hostKey]: xdebug.debugServerAddress,
21
+ id: '7e16e907-9ce3-4559-9d26-a30a5650d11f',
22
+ [nameKey]: xdebug.serverName
23
+ };
24
+
25
+ if (phpServersComponent) {
26
+ if (phpServersComponent.servers && !Array.isArray(phpServersComponent.servers)) {
27
+ hasChanges = true;
28
+ phpServersComponent.servers = [phpServersComponent.servers];
29
+ } else if (!phpServersComponent.servers) {
30
+ hasChanges = true;
31
+ phpServersComponent.servers = [];
32
+ }
33
+
34
+ const serverConfiguration = phpServersComponent.servers.find((server) => server.server[nameKey] === xdebug.serverName);
35
+
36
+ if (serverConfiguration && serverConfiguration.server[hostKey] !== xdebug.debugServerAddress) {
37
+ hasChanges = true;
38
+ serverConfiguration.server[hostKey] = xdebug.debugServerAddress;
39
+ } else if (!serverConfiguration) {
40
+ hasChanges = true;
41
+ phpServersComponent.servers.push({
42
+ server: defaultServerConfig
43
+ });
44
+ }
45
+ } else {
46
+ hasChanges = true;
47
+ workspaceConfigs.push({
48
+ [nameKey]: PHP_SERVERS_COMPONENT_NAME,
49
+ servers: [
50
+ {
51
+ server: defaultServerConfig
52
+ }
53
+ ]
54
+ });
55
+ }
56
+
57
+ return hasChanges;
58
+ };
59
+
60
+ module.exports = setupPHPServers;
@@ -0,0 +1,51 @@
1
+ const path = require('path');
2
+ // const { baseConfig } = require('../../../../config');
3
+ const { getCSAThemes } = require('../../../../util/CSA-theme');
4
+ const pathExists = require('../../../../util/path-exists');
5
+ const { nameKey } = require('../keys');
6
+ // const { formatPathForPHPStormConfig } = require('../xml-utils');
7
+
8
+ const PROPERTIES_COMPONENT_NAME = 'PropertiesComponent';
9
+
10
+ const defaultProperties = {
11
+ keyToString: {
12
+ 'RunOnceActivity.OpenProjectViewOnStart': 'true',
13
+ 'RunOnceActivity.ShowReadmeOnStart': 'true'
14
+ }
15
+ };
16
+
17
+ /**
18
+ * @param {Array} workspaceConfigs
19
+ * @returns {Promise<Boolean>}
20
+ */
21
+ const setupPropertiesComponent = async (workspaceConfigs) => {
22
+ let hasChanges = false;
23
+ const propertiesComponent = workspaceConfigs.find(
24
+ (workspaceConfig) => workspaceConfig[nameKey] === PROPERTIES_COMPONENT_NAME
25
+ );
26
+
27
+ if (propertiesComponent) {
28
+ // check later
29
+ } else {
30
+ hasChanges = true;
31
+ const themes = await getCSAThemes();
32
+ if (themes.length > 0) {
33
+ const theme = themes[0];
34
+ const themeESLintPath = path.join(process.cwd(), theme.themePath, 'node_modules', 'eslint');
35
+ if (await pathExists(themeESLintPath)) {
36
+ defaultProperties.keyToString['node.js.selected.package.eslint'] = themeESLintPath;
37
+ defaultProperties.keyToString['js.linters.configure.manually.selectedeslint'] = 'true';
38
+ defaultProperties.keyToString['node.js.detected.package.eslint'] = 'true';
39
+ defaultProperties.keyToString['settings.editor.selected.configurable'] = 'settings.javascript.linters.eslint';
40
+ }
41
+ }
42
+ workspaceConfigs.push({
43
+ [nameKey]: PROPERTIES_COMPONENT_NAME,
44
+ '#text': JSON.stringify(defaultProperties)
45
+ });
46
+ }
47
+
48
+ return hasChanges;
49
+ };
50
+
51
+ module.exports = setupPropertiesComponent;
@@ -0,0 +1,74 @@
1
+ const { nameKey } = require('../keys');
2
+
3
+ const RUN_MANAGER_COMPONENT_NAME = 'RunManager';
4
+
5
+ const PHP_REMOTE_DEBUG_RUN_CONFIGURATION_TYPE = 'PhpRemoteDebugRunConfigurationType';
6
+
7
+ const serverNameKey = '@_server_name';
8
+ const sessionIdKey = '@_session_id';
9
+
10
+ /**
11
+ * @param {Array} workspaceConfigs
12
+ * @param {import('../../../../../typings/phpstorm').PHPStormConfig} phpStormConfiguration
13
+ * @returns {Promise<Boolean>}
14
+ */
15
+ const setupRunManager = async (workspaceConfigs, phpStormConfiguration) => {
16
+ const { xdebug } = phpStormConfiguration;
17
+ let hasChanges = false;
18
+ const runManagerComponent = workspaceConfigs.find(
19
+ (workspaceConfig) => workspaceConfig[nameKey] === RUN_MANAGER_COMPONENT_NAME
20
+ );
21
+
22
+ const defaultRunManagerConfiguration = {
23
+ [nameKey]: xdebug.runManagerName,
24
+ '@_type': PHP_REMOTE_DEBUG_RUN_CONFIGURATION_TYPE,
25
+ '@_factoryName': 'PHP Remote Debug',
26
+ '@_filter_connections': 'FILTER',
27
+ [serverNameKey]: xdebug.serverName,
28
+ [sessionIdKey]: xdebug.sessionId,
29
+ method: {
30
+ '@_v': '2'
31
+ }
32
+ };
33
+
34
+ if (runManagerComponent) {
35
+ if (runManagerComponent.configuration && !Array.isArray(runManagerComponent.configuration)) {
36
+ hasChanges = true;
37
+ runManagerComponent.configuration = [runManagerComponent.configuration];
38
+ } else if (!runManagerComponent.configuration) {
39
+ hasChanges = true;
40
+ runManagerComponent.configuration = [];
41
+ }
42
+
43
+ const phpRemoteDebugRunConfiguration = runManagerComponent.configuration.find(
44
+ (configuration) => configuration['@_type'] === PHP_REMOTE_DEBUG_RUN_CONFIGURATION_TYPE && configuration[nameKey] === xdebug.runManagerName
45
+ );
46
+
47
+ if (phpRemoteDebugRunConfiguration) {
48
+ if (phpRemoteDebugRunConfiguration[serverNameKey] !== xdebug.serverName) {
49
+ hasChanges = true;
50
+ phpRemoteDebugRunConfiguration[serverNameKey] = xdebug.serverName;
51
+ }
52
+
53
+ if (phpRemoteDebugRunConfiguration[sessionIdKey] !== xdebug.sessionId) {
54
+ hasChanges = true;
55
+ phpRemoteDebugRunConfiguration[sessionIdKey] = xdebug.sessionId;
56
+ }
57
+ } else {
58
+ hasChanges = true;
59
+ runManagerComponent.configuration.push(defaultRunManagerConfiguration);
60
+ }
61
+ } else {
62
+ hasChanges = true;
63
+ workspaceConfigs.push({
64
+ [nameKey]: RUN_MANAGER_COMPONENT_NAME,
65
+ configuration: [
66
+ defaultRunManagerConfiguration
67
+ ]
68
+ });
69
+ }
70
+
71
+ return hasChanges;
72
+ };
73
+
74
+ module.exports = setupRunManager;
@@ -0,0 +1,5 @@
1
+ const formatPathForPHPStormConfig = (p) => p.replace(process.cwd(), '$PROJECT_DIR$');
2
+
3
+ module.exports = {
4
+ formatPathForPHPStormConfig
5
+ };
@@ -1,7 +1,7 @@
1
1
  const createNginxConfig = require('./create-nginx-config');
2
2
  const createPhpConfig = require('./create-php-config');
3
3
  const createPhpFpmConfig = require('./create-php-fpm-config');
4
- const createPhpStormConfig = require('./create-php-storm-config');
4
+ const createPhpStormConfig = require('./create-phpstorm-config');
5
5
  const createVSCodeConfig = require('./create-vscode-config');
6
6
 
7
7
  /**
@@ -74,7 +74,8 @@ const compileOptions = {
74
74
  CPATH: '$CPATH:$(brew --prefix openssl@1.1)/include',
75
75
  CXX: 'g++ -DTRUE=1 -DFALSE=0',
76
76
  CC: 'gcc -DTRUE=1 -DFALSE=0',
77
- LDFLAGS: '$(brew --prefix openssl@1.1)/lib/libssl.dylib $(brew --prefix openssl@1.1)/lib/libcrypto.dylib'
77
+ LDFLAGS: '$(brew --prefix openssl@1.1)/lib/libssl.dylib $(brew --prefix openssl@1.1)/lib/libcrypto.dylib',
78
+ CFLAGS: '-Wno-implicit-function-declaration' // https://github.com/phpbrew/phpbrew/issues/1222
78
79
  }
79
80
  }
80
81
  };
@@ -16,7 +16,7 @@ const compile = () => ({
16
16
  platformCompileOptions.extraOptions.push('--with-libdir=lib64');
17
17
  }
18
18
  }
19
- const commandEnv = Object.entries(platformCompileOptions.env || {}).map(([key, value]) => `${key}="${value}"`).join(' && ');
19
+ const commandEnv = Object.entries(platformCompileOptions.env || {}).map(([key, value]) => `export ${key}="${value}"`).join(' && ');
20
20
  const phpCompileCommand = `${commandEnv ? `${commandEnv} && ` : ''} \
21
21
  phpbrew install -j ${platformCompileOptions.cpuCount} ${php.version} ${platformCompileOptions.variants.join(' ')} \
22
22
  -- ${platformCompileOptions.extraOptions.join(' ')}`;