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

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 (124) hide show
  1. package/index.js +13 -0
  2. package/lib/commands/cli.js +28 -1
  3. package/lib/commands/execute.js +2 -1
  4. package/lib/config/docker.js +85 -12
  5. package/lib/config/get-port-config.js +7 -2
  6. package/lib/config/port-config.js +3 -1
  7. package/lib/config/scandipwa-versions.js +2 -1
  8. package/lib/config/ssl-terminator/index.js +10 -0
  9. package/lib/config/templates/magentorc.template +3 -5
  10. package/lib/config/templates/nginx.template.conf +0 -14
  11. package/lib/config/templates/php.template.ini +6 -4
  12. package/lib/config/templates/ssl-terminator.template.conf +27 -0
  13. package/lib/config/templates/varnish.template.vcl +250 -0
  14. package/lib/config/varnish/varnish-6-0.js +11 -0
  15. package/lib/config/varnish/varnish-6-6.js +11 -0
  16. package/lib/config/varnish/varnish-7-0.js +11 -0
  17. package/lib/config/versions/magento-2.3.0.js +9 -1
  18. package/lib/config/versions/magento-2.3.1.js +9 -1
  19. package/lib/config/versions/magento-2.3.2-p2.js +9 -1
  20. package/lib/config/versions/magento-2.3.2.js +9 -1
  21. package/lib/config/versions/magento-2.3.3-p1.js +9 -1
  22. package/lib/config/versions/magento-2.3.3.js +9 -1
  23. package/lib/config/versions/magento-2.3.4-p2.js +9 -1
  24. package/lib/config/versions/magento-2.3.4.js +9 -1
  25. package/lib/config/versions/magento-2.3.5-p1.js +9 -1
  26. package/lib/config/versions/magento-2.3.5-p2.js +9 -1
  27. package/lib/config/versions/magento-2.3.5.js +9 -1
  28. package/lib/config/versions/magento-2.3.6-p1.js +9 -1
  29. package/lib/config/versions/magento-2.3.6.js +9 -1
  30. package/lib/config/versions/magento-2.3.7-p1.js +9 -1
  31. package/lib/config/versions/magento-2.3.7-p2.js +9 -1
  32. package/lib/config/versions/magento-2.3.7-p3.js +9 -1
  33. package/lib/config/versions/magento-2.3.7.js +9 -1
  34. package/lib/config/versions/magento-2.4.0-p1.js +9 -1
  35. package/lib/config/versions/magento-2.4.0.js +9 -1
  36. package/lib/config/versions/magento-2.4.1-p1.js +9 -1
  37. package/lib/config/versions/magento-2.4.1.js +9 -1
  38. package/lib/config/versions/magento-2.4.2-p1.js +9 -1
  39. package/lib/config/versions/magento-2.4.2-p2.js +9 -1
  40. package/lib/config/versions/magento-2.4.2.js +9 -1
  41. package/lib/config/versions/magento-2.4.3-p1.js +9 -1
  42. package/lib/config/versions/magento-2.4.3-p2.js +9 -1
  43. package/lib/config/versions/magento-2.4.3.js +9 -1
  44. package/lib/config/versions/magento-2.4.4.js +9 -1
  45. package/lib/tasks/cli/create-bashrc-config.js +5 -2
  46. package/lib/tasks/docker/containers.js +13 -8
  47. package/lib/tasks/docker/volumes.js +4 -4
  48. package/lib/tasks/file-system/create-nginx-config.js +7 -39
  49. package/lib/tasks/file-system/create-php-storm-config.js +82 -0
  50. package/lib/tasks/file-system/create-ssl-terminator-config.js +94 -0
  51. package/lib/tasks/file-system/create-varnish-config.js +74 -0
  52. package/lib/tasks/file-system/index.js +6 -2
  53. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +1 -1
  54. package/lib/tasks/magento/setup-magento/disable-2fa.js +4 -12
  55. package/lib/tasks/magento/setup-magento/disable-full-page-cache.js +20 -0
  56. package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +14 -16
  57. package/lib/tasks/magento/setup-magento/migrate-database.js +24 -11
  58. package/lib/tasks/magento/setup-magento/set-base-url.js +7 -2
  59. package/lib/tasks/magento/setup-magento/upgrade-magento.js +17 -3
  60. package/lib/tasks/magento/setup-magento/varnish-config.js +69 -0
  61. package/lib/tasks/mysql/fix-db.js +2 -2
  62. package/lib/tasks/php/index.js +1 -1
  63. package/lib/tasks/php/update-env-php.js +16 -1
  64. package/lib/tasks/php/update-env.php +56 -12
  65. package/lib/tasks/requirements/docker/index.js +2 -0
  66. package/lib/tasks/requirements/docker/install.js +11 -11
  67. package/lib/tasks/requirements/docker/running-status.js +137 -0
  68. package/lib/tasks/requirements/docker/version.js +2 -0
  69. package/lib/tasks/requirements/index.js +5 -5
  70. package/lib/tasks/requirements/php-version.js +3 -1
  71. package/lib/tasks/start.js +3 -8
  72. package/lib/tasks/status/index.js +25 -9
  73. package/lib/tasks/theme/build-theme.js +26 -8
  74. package/lib/tasks/theme/install-theme.js +16 -4
  75. package/lib/tasks/theme/link-theme.js +2 -2
  76. package/lib/tasks/theme/setup-persisted-query.js +3 -3
  77. package/lib/tasks/theme/setup-themes.js +3 -2
  78. package/lib/tasks/theme/symlink-theme.js +18 -3
  79. package/lib/util/config-file-validator.js +12 -1
  80. package/lib/util/config-php-json.js +19 -0
  81. package/lib/util/instance-metadata.js +2 -2
  82. package/lib/util/is-running-root.js +3 -0
  83. package/lib/util/match-filesystem.js +2 -1
  84. package/lib/util/php-task.js +6 -2
  85. package/lib/util/run-php.js +7 -1
  86. package/lib/util/systemctl.js +46 -0
  87. package/package.json +2 -3
  88. package/typings/context.d.ts +5 -3
  89. package/typings/index.d.ts +32 -1
  90. package/lib/config/xml-parser.js +0 -61
  91. package/lib/tasks/file-system/create-phpstorm-config/database-config.js +0 -248
  92. package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +0 -83
  93. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +0 -154
  94. package/lib/tasks/file-system/create-phpstorm-config/index.js +0 -27
  95. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +0 -29
  96. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/config.js +0 -54
  97. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +0 -31
  98. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +0 -42
  99. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/eslint-inspection-config.js +0 -37
  100. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/index.js +0 -80
  101. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +0 -29
  102. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +0 -145
  103. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/paths.js +0 -20
  104. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-fixer-validation-inspection-config.js +0 -60
  105. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +0 -119
  106. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/stylelint-inspection-config.js +0 -37
  107. package/lib/tasks/file-system/create-phpstorm-config/keys.js +0 -14
  108. package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +0 -67
  109. package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +0 -57
  110. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +0 -76
  111. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +0 -63
  112. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +0 -69
  113. package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +0 -77
  114. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +0 -98
  115. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/format-setting-config.js +0 -57
  116. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +0 -66
  117. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +0 -64
  118. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +0 -60
  119. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +0 -51
  120. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +0 -74
  121. package/lib/tasks/file-system/create-phpstorm-config/xml-utils.js +0 -5
  122. package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -27
  123. package/lib/tasks/magento/setup-magento/disable-page-cache.js +0 -11
  124. package/typings/phpstorm.d.ts +0 -33
@@ -1,37 +0,0 @@
1
- const {
2
- classes: {
3
- STYLELINT_INSPECTION
4
- }
5
- } = require('./config');
6
- const { classKey } = require('../keys');
7
- const setupDefaultProperties = require('./default-properties-config');
8
-
9
- /**
10
- * Set up Styelint configuration
11
- *
12
- * *function is async so it will be properly handled in Promise.all*
13
- * @param {Array} inspectionToolsData
14
- * @returns {Promise<Boolean>}
15
- */
16
- const setupStyleLintInspection = async (inspectionToolsData) => {
17
- let hasChanges = false;
18
- const stylelintConfig = inspectionToolsData.find(
19
- (inspectionToolData) => inspectionToolData[classKey] === STYLELINT_INSPECTION
20
- );
21
-
22
- if (stylelintConfig) {
23
- hasChanges = setupDefaultProperties(stylelintConfig);
24
- } else {
25
- hasChanges = true;
26
- inspectionToolsData.push({
27
- [classKey]: STYLELINT_INSPECTION,
28
- '@_enabled': 'true',
29
- '@_level': 'ERROR',
30
- '@_enabled_by_default': 'true'
31
- });
32
- }
33
-
34
- return hasChanges;
35
- };
36
-
37
- module.exports = setupStyleLintInspection;
@@ -1,14 +0,0 @@
1
- // xml property key names
2
- const classKey = '@_class';
3
- const nameKey = '@_name';
4
- const valueKey = '@_value';
5
- const toolPathKey = '@_tool_path';
6
- const standardsKey = '@_standards';
7
-
8
- module.exports = {
9
- classKey,
10
- nameKey,
11
- valueKey,
12
- toolPathKey,
13
- standardsKey
14
- };
@@ -1,67 +0,0 @@
1
- const { loadXmlFile, buildXmlFile } = require('../../../../config/xml-parser');
2
- const pathExists = require('../../../../util/path-exists');
3
- const setupMessDetector = require('./mess-detector-config');
4
- const setupPHPCodeSniffer = require('./php-code-sniffer-config');
5
- const setupPHPCSFixer = require('./php-cs-fixer-config');
6
- const setupPHPProjectSharedConfiguration = require('./php-project-shared-configuration-config');
7
-
8
- /**
9
- * @type {() => import('listr2').ListrTask<import('../../../../../typings/context').ListrContext>}
10
- */
11
- const setupPhpConfig = () => ({
12
- title: 'Set up PHP configuration',
13
- task: async (ctx, task) => {
14
- const {
15
- config: {
16
- phpStorm,
17
- phpStorm: {
18
- php: {
19
- phpLanguageLevel
20
- }
21
- }
22
- }
23
- } = ctx;
24
-
25
- if (await pathExists(phpStorm.php.path)) {
26
- const phpConfigContent = await loadXmlFile(phpStorm.php.path);
27
- const phpConfigs = phpConfigContent.project.component;
28
- const hasChanges = await Promise.all([
29
- setupMessDetector(phpConfigs),
30
- setupPHPCodeSniffer(phpConfigs),
31
- setupPHPCSFixer(phpConfigs),
32
- setupPHPProjectSharedConfiguration(phpConfigs, phpLanguageLevel)
33
- ]);
34
-
35
- if (hasChanges.includes(true)) {
36
- await buildXmlFile(phpStorm.php.path, phpConfigContent);
37
- } else {
38
- task.skip();
39
- }
40
-
41
- return;
42
- }
43
-
44
- const phpConfigContent = {
45
- '?xml': {
46
- '@_version': '1.0',
47
- '@_encoding': 'UTF-8'
48
- },
49
- project: {
50
- '@_version': '4',
51
- component: []
52
- }
53
- };
54
- const phpConfigs = phpConfigContent.project.component;
55
-
56
- await Promise.all([
57
- setupMessDetector(phpConfigs),
58
- setupPHPCodeSniffer(phpConfigs),
59
- setupPHPCSFixer(phpConfigs),
60
- setupPHPProjectSharedConfiguration(phpConfigs, phpLanguageLevel)
61
- ]);
62
-
63
- await buildXmlFile(phpStorm.php.path, phpConfigContent);
64
- }
65
- });
66
-
67
- module.exports = setupPhpConfig;
@@ -1,57 +0,0 @@
1
- const path = require('path');
2
- const pathExists = require('../../../../util/path-exists');
3
- const { nameKey, toolPathKey } = require('../keys');
4
- const { formatPathForPHPStormConfig } = require('../xml-utils');
5
-
6
- const phpMDBinaryPath = path.join(process.cwd(), 'vendor', 'bin', 'phpmd');
7
- const phpMDBinaryFormattedPath = formatPathForPHPStormConfig(phpMDBinaryPath);
8
-
9
- const defaultMessDetectorSetting = {
10
- MessDetectorConfiguration: {
11
- [toolPathKey]: phpMDBinaryFormattedPath
12
- }
13
- };
14
-
15
- /**
16
- * @param {Array} phpConfigs
17
- * @returns {Promise<Boolean>}
18
- */
19
- const setupMessDetector = async (phpConfigs) => {
20
- let hasChanges = false;
21
- const messDetectorComponent = phpConfigs.find(
22
- (phpConfig) => phpConfig[nameKey] === 'MessDetector'
23
- );
24
-
25
- const isPhpMDBinPathExists = await pathExists(phpMDBinaryPath);
26
-
27
- if (messDetectorComponent && isPhpMDBinPathExists) {
28
- if (!Array.isArray(messDetectorComponent.phpmd_settings)) {
29
- hasChanges = true;
30
- messDetectorComponent.phpmd_settings = [messDetectorComponent.phpmd_settings];
31
- }
32
-
33
- const messDetectorConfiguration = messDetectorComponent.phpmd_settings.find(
34
- (phpmdSetting) => phpmdSetting.MessDetectorConfiguration
35
- );
36
-
37
- if (messDetectorConfiguration && messDetectorConfiguration[toolPathKey] !== phpMDBinaryFormattedPath) {
38
- hasChanges = true;
39
- messDetectorConfiguration[toolPathKey] = phpMDBinaryFormattedPath;
40
- } else if (!messDetectorConfiguration) {
41
- hasChanges = true;
42
- messDetectorComponent.phpmd_settings.push(defaultMessDetectorSetting);
43
- }
44
- } else if (isPhpMDBinPathExists) {
45
- hasChanges = true;
46
- phpConfigs.push({
47
- [nameKey]: 'MessDetector',
48
- phpmd_settings: [
49
- defaultMessDetectorSetting
50
- ]
51
- });
52
- }
53
-
54
- return hasChanges;
55
- };
56
-
57
- module.exports = setupMessDetector;
@@ -1,76 +0,0 @@
1
- const path = require('path');
2
- const pathExists = require('../../../../util/path-exists');
3
- const { nameKey, toolPathKey, standardsKey } = require('../keys');
4
- const { formatPathForPHPStormConfig } = require('../xml-utils');
5
-
6
- const PHP_CODE_SNIFFER_COMPONENT_NAME = 'PhpCodeSniffer';
7
-
8
- const beautifierPathKey = '@_beautifier_path';
9
-
10
- const phpCodeSnifferStandards = 'MySource;PEAR;PHPCompatibility;PSR1;PSR12;PSR2;Squiz;Zend';
11
- const phpCodeSnifferBinaryPath = path.join(process.cwd(), 'vendor', 'bin', 'phpcs');
12
- const phpCodeSnifferBinaryFormattedPath = formatPathForPHPStormConfig(phpCodeSnifferBinaryPath);
13
-
14
- const phpCodeSnifferBeautifierBinaryPath = path.join(process.cwd(), 'vendor', 'bin', 'phpcbf');
15
- const phpCodeSnifferBeautifierBinaryFormattedPath = formatPathForPHPStormConfig(phpCodeSnifferBeautifierBinaryPath);
16
-
17
- const defaultPHPCSSetting = {
18
- PhpCSConfiguration: {
19
- [toolPathKey]: phpCodeSnifferBinaryFormattedPath,
20
- [standardsKey]: phpCodeSnifferStandards,
21
- [beautifierPathKey]: phpCodeSnifferBeautifierBinaryFormattedPath
22
- }
23
- };
24
-
25
- /**
26
- * @param {Array} phpConfigs
27
- * @returns {Promise<Boolean>}
28
- */
29
- const setupPHPCodeSniffer = async (phpConfigs) => {
30
- let hasChanges = false;
31
- const phpCodeSnifferComponent = phpConfigs.find(
32
- (phpConfig) => phpConfig[nameKey] === PHP_CODE_SNIFFER_COMPONENT_NAME
33
- );
34
-
35
- const isPhpCodeSnifferBinPathExists = await pathExists(phpCodeSnifferBinaryPath);
36
- const isPhpCodeSnifferBeautifierBinPathExists = await pathExists(phpCodeSnifferBeautifierBinaryPath);
37
- const isAllPHPCSBinsExists = isPhpCodeSnifferBinPathExists && isPhpCodeSnifferBeautifierBinPathExists;
38
-
39
- if (phpCodeSnifferComponent && isAllPHPCSBinsExists) {
40
- if (!Array.isArray(phpCodeSnifferComponent.phpcs_settings)) {
41
- hasChanges = true;
42
- phpCodeSnifferComponent.phpcs_settings = [phpCodeSnifferComponent.phpcs_settings];
43
- }
44
-
45
- const phpCodeSnifferConfiguration = phpCodeSnifferComponent.phpcs_settings.find(
46
- (phpcsSetting) => phpcsSetting.PhpCSConfiguration
47
- );
48
-
49
- if (phpCodeSnifferConfiguration) {
50
- if (phpCodeSnifferConfiguration[toolPathKey] !== phpCodeSnifferBinaryFormattedPath) {
51
- hasChanges = true;
52
- phpCodeSnifferConfiguration[toolPathKey] = phpCodeSnifferBinaryFormattedPath;
53
- }
54
-
55
- if (phpCodeSnifferConfiguration[beautifierPathKey] !== phpCodeSnifferBeautifierBinaryFormattedPath) {
56
- hasChanges = true;
57
- phpCodeSnifferConfiguration[beautifierPathKey] = phpCodeSnifferBeautifierBinaryFormattedPath;
58
- }
59
- } else {
60
- hasChanges = true;
61
- phpCodeSnifferComponent.phpcs_settings.push(defaultPHPCSSetting);
62
- }
63
- } else if (isAllPHPCSBinsExists) {
64
- hasChanges = true;
65
- phpConfigs.push({
66
- [nameKey]: PHP_CODE_SNIFFER_COMPONENT_NAME,
67
- phpcs_settings: [
68
- defaultPHPCSSetting
69
- ]
70
- });
71
- }
72
-
73
- return hasChanges;
74
- };
75
-
76
- module.exports = setupPHPCodeSniffer;
@@ -1,63 +0,0 @@
1
- const path = require('path');
2
- const pathExists = require('../../../../util/path-exists');
3
- const { nameKey, toolPathKey, standardsKey } = require('../keys');
4
- const { formatPathForPHPStormConfig } = require('../xml-utils');
5
-
6
- const PHP_CS_FIXER_COMPONENT_NAME = 'PhpCSFixer';
7
-
8
- const phpCSFixerStandards = 'PSR1;PSR2;Symfony;DoctrineAnnotation;PHP70Migration;PHP71Migration';
9
- const phpCSFixerBinaryPath = path.join(process.cwd(), 'vendor', 'bin', 'php-cs-fixer');
10
- const phpCSFixerBinaryFormattedPath = formatPathForPHPStormConfig(phpCSFixerBinaryPath);
11
-
12
- const defaultPHPCSFixerSettings = {
13
- PhpCSFixerConfiguration: {
14
- [toolPathKey]: phpCSFixerBinaryFormattedPath,
15
- [standardsKey]: phpCSFixerStandards
16
- }
17
- };
18
-
19
- /**
20
- * @param {Array} phpConfigs
21
- * @returns {Promise<Boolean>}
22
- */
23
- const setupPHPCSFixer = async (phpConfigs) => {
24
- let hasChanges = false;
25
- const phpCSFixerComponent = phpConfigs.find(
26
- (phpConfig) => phpConfig[nameKey] === PHP_CS_FIXER_COMPONENT_NAME
27
- );
28
-
29
- const isPhpCSFixerBinPathExists = await pathExists(phpCSFixerBinaryPath);
30
-
31
- if (phpCSFixerComponent && isPhpCSFixerBinPathExists) {
32
- if (!Array.isArray(phpCSFixerComponent.phpcsfixer_settings)) {
33
- hasChanges = true;
34
- phpCSFixerComponent.phpcsfixer_settings = [phpCSFixerComponent.phpcsfixer_settings];
35
- }
36
-
37
- const phpCSFixerConfiguration = phpCSFixerComponent.phpcsfixer_settings.find(
38
- (phpcsfixerSetting) => phpcsfixerSetting.PhpCSFixerConfiguration
39
- );
40
-
41
- if (phpCSFixerConfiguration) {
42
- if (phpCSFixerConfiguration[toolPathKey] !== phpCSFixerBinaryFormattedPath) {
43
- hasChanges = true;
44
- phpCSFixerConfiguration[toolPathKey] = phpCSFixerBinaryFormattedPath;
45
- }
46
- } else {
47
- hasChanges = true;
48
- phpCSFixerComponent.phpcsfixer_settings.push(defaultPHPCSFixerSettings);
49
- }
50
- } else if (isPhpCSFixerBinPathExists) {
51
- hasChanges = true;
52
- phpConfigs.push({
53
- [nameKey]: PHP_CS_FIXER_COMPONENT_NAME,
54
- phpcsfixer_settings: [
55
- defaultPHPCSFixerSettings
56
- ]
57
- });
58
- }
59
-
60
- return hasChanges;
61
- };
62
-
63
- module.exports = setupPHPCSFixer;
@@ -1,69 +0,0 @@
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;
@@ -1,77 +0,0 @@
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;
@@ -1,98 +0,0 @@
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;
@@ -1,57 +0,0 @@
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;