@scandipwa/magento-scripts 1.14.1-alpha.9 → 1.15.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.
- package/lib/commands/cli.js +9 -4
- package/lib/commands/logs.js +1 -0
- package/lib/commands/start.js +18 -5
- package/lib/config/cma-config.js +16 -0
- package/lib/config/dependencies-for-platforms.js +15 -3
- package/lib/config/docker.js +4 -3
- package/lib/config/get-port-config.js +2 -1
- package/lib/config/index.js +2 -1
- package/lib/config/php/extensions/libsodium.js +2 -1
- package/lib/config/scandipwa-versions.js +2 -1
- package/lib/config/system-config.js +34 -5
- package/lib/config/templates/magentorc.template +2 -0
- package/lib/config/templates/varnish.template.vcl +9 -4
- package/lib/config/xml-parser.js +63 -0
- package/lib/errors/known-error.js +15 -0
- package/lib/errors/unknown-error.js +15 -0
- package/lib/tasks/cli/create-bashrc-config.js +2 -1
- package/lib/tasks/composer/index.js +5 -3
- package/lib/tasks/composer/local-auth-json.js +8 -4
- package/lib/tasks/docker/network.js +2 -1
- package/lib/tasks/execute/index.js +2 -3
- package/lib/tasks/file-system/create-nginx-config.js +2 -1
- package/lib/tasks/file-system/create-php-config.js +2 -1
- package/lib/tasks/file-system/create-php-fpm-config.js +2 -1
- package/lib/tasks/file-system/create-phpstorm-config/database-config.js +249 -0
- package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +85 -0
- package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +154 -0
- package/lib/tasks/file-system/create-phpstorm-config/index.js +27 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +26 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/config.js +54 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +28 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +42 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/eslint-inspection-config.js +37 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/index.js +80 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +26 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +142 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/paths.js +20 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-fixer-validation-inspection-config.js +60 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +116 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/stylelint-inspection-config.js +37 -0
- package/lib/tasks/file-system/create-phpstorm-config/keys.js +14 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +67 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +54 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +66 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +58 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +59 -0
- package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +77 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +97 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/format-setting-config.js +57 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +66 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +64 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +57 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +49 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +64 -0
- package/lib/tasks/file-system/create-phpstorm-config/xml-utils.js +5 -0
- package/lib/tasks/file-system/create-ssl-terminator-config.js +5 -3
- package/lib/tasks/file-system/create-varnish-config.js +2 -23
- package/lib/tasks/file-system/create-vscode-config.js +3 -2
- package/lib/tasks/file-system/index.js +1 -1
- package/lib/tasks/magento/enable-magento-composer-plugins.js +3 -2
- package/lib/tasks/magento/install-magento.js +7 -5
- package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +26 -0
- package/lib/tasks/magento/setup-magento/delete-admin-users.js +1 -1
- package/lib/tasks/magento/setup-magento/delete-customers.js +7 -4
- package/lib/tasks/magento/setup-magento/delete-orders.js +6 -4
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +2 -1
- package/lib/tasks/magento/setup-magento/index.js +3 -1
- package/lib/tasks/magento/setup-magento/install-magento.js +2 -1
- package/lib/tasks/magento/setup-magento/set-base-url.js +7 -2
- package/lib/tasks/magento/setup-magento/upgrade-magento.js +11 -1
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +41 -0
- package/lib/tasks/mysql/connect-to-mysql.js +2 -1
- package/lib/tasks/mysql/import-dump-to-mysql.js +13 -2
- package/lib/tasks/mysql/import-remote-db/index.js +2 -1
- package/lib/tasks/mysql/import-remote-db/ssh/index.js +2 -1
- package/lib/tasks/mysql/import-remote-db/ssh/regular-server.js +2 -1
- package/lib/tasks/php/bundled-extensions.js +28 -0
- package/lib/tasks/php/compile-options.js +27 -54
- package/lib/tasks/php/compile.js +6 -4
- package/lib/tasks/php/configure.js +7 -66
- package/lib/tasks/php/extensions/disable.js +2 -1
- package/lib/tasks/php/extensions/enable.js +2 -1
- package/lib/tasks/php/extensions/index.js +74 -0
- package/lib/tasks/php/extensions/install.js +3 -3
- package/lib/tasks/php/index.js +7 -6
- package/lib/tasks/php/install-sodium.js +93 -0
- package/lib/tasks/php/update-phpbrew.js +7 -3
- package/lib/tasks/php/validate-php.js +67 -0
- package/lib/tasks/php-fpm/start-php-fpm.js +4 -2
- package/lib/tasks/requirements/composer.js +59 -5
- package/lib/tasks/requirements/dependency/arch.js +2 -1
- package/lib/tasks/requirements/dependency/centos.js +2 -1
- package/lib/tasks/requirements/dependency/fedora.js +2 -1
- package/lib/tasks/requirements/dependency/mac.js +18 -3
- package/lib/tasks/requirements/docker/index.js +94 -40
- package/lib/tasks/requirements/docker/install-on-mac.js +29 -0
- package/lib/tasks/requirements/docker/install.js +2 -1
- package/lib/tasks/requirements/docker/running-status.js +32 -31
- package/lib/tasks/requirements/docker/version.js +2 -1
- package/lib/tasks/requirements/index.js +3 -0
- package/lib/tasks/requirements/node-version.js +2 -1
- package/lib/tasks/requirements/php-version.js +26 -24
- package/lib/tasks/requirements/phpbrew/index.js +2 -1
- package/lib/tasks/requirements/phpbrew/install.js +14 -2
- package/lib/tasks/requirements/phpbrew/version.js +2 -1
- package/lib/tasks/requirements/platform.js +5 -3
- package/lib/tasks/requirements/rosetta.js +32 -0
- package/lib/tasks/start.js +10 -2
- package/lib/tasks/theme/build-theme.js +2 -1
- package/lib/tasks/theme/install-theme.js +2 -1
- package/lib/tasks/theme/link-theme.js +2 -2
- package/lib/tasks/theme/retrieve-theme-data.js +2 -1
- package/lib/tasks/theme/setup-persisted-query.js +2 -1
- package/lib/tasks/theme/setup-themes.js +10 -3
- package/lib/tasks/theme/symlink-theme.js +8 -1
- package/lib/util/CSA-theme.js +4 -0
- package/lib/util/analytics.js +317 -0
- package/lib/util/arch.js +1 -1
- package/lib/util/config-file-validator.js +2 -1
- package/lib/util/config-php-json.js +3 -2
- package/lib/util/env-php-json.js +3 -2
- package/lib/util/exec-async-command.d.ts +2 -0
- package/lib/util/exec-async-command.js +31 -15
- package/lib/util/exec-async.js +9 -0
- package/lib/util/get-brew-bin-path.js +64 -0
- package/lib/util/get-installed-magento-version.js +3 -2
- package/lib/util/get-jsonfile-data.js +2 -1
- package/lib/util/install-dependencies-task.js +15 -5
- package/lib/util/instance-metadata.js +9 -2
- package/lib/util/ip.js +47 -1
- package/lib/util/magento-task.js +20 -9
- package/lib/util/php-task.js +7 -7
- package/lib/util/request.js +0 -0
- package/lib/util/resolve-configuration-with-overrides.js +2 -1
- package/lib/util/run-composer.js +5 -3
- package/lib/util/run-magento.js +3 -2
- package/lib/util/run-php.js +7 -2
- package/lib/util/wait-for-it.js +3 -2
- package/package.json +5 -3
- package/typings/context.d.ts +4 -0
- package/typings/phpstorm.d.ts +33 -0
- package/lib/tasks/file-system/create-php-storm-config.js +0 -82
- package/lib/tasks/magento/setup-magento/disable-full-page-cache.js +0 -20
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const {
|
|
2
|
+
classes: {
|
|
3
|
+
ESLINT_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 setupESLintInspection = async (inspectionToolsData) => {
|
|
17
|
+
let hasChanges = false;
|
|
18
|
+
const eslintConfig = inspectionToolsData.find(
|
|
19
|
+
(inspectionToolData) => inspectionToolData[classKey] === ESLINT_INSPECTION
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
if (eslintConfig) {
|
|
23
|
+
hasChanges = setupDefaultProperties(eslintConfig);
|
|
24
|
+
} else {
|
|
25
|
+
hasChanges = true;
|
|
26
|
+
inspectionToolsData.push({
|
|
27
|
+
[classKey]: ESLINT_INSPECTION,
|
|
28
|
+
'@_enabled': 'true',
|
|
29
|
+
'@_level': 'ERROR',
|
|
30
|
+
'@_enabled_by_default': 'true'
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return hasChanges;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
module.exports = setupESLintInspection;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const { loadXmlFile, buildXmlFile } = require('../../../../config/xml-parser');
|
|
2
|
+
const pathExists = require('../../../../util/path-exists');
|
|
3
|
+
const {
|
|
4
|
+
nameKey,
|
|
5
|
+
valueKey,
|
|
6
|
+
classKey
|
|
7
|
+
} = require('../keys');
|
|
8
|
+
const setupESLintInspection = require('./eslint-inspection-config');
|
|
9
|
+
const setupMessDetectorValidationInspection = require('./mess-detector-validation-inspection-config');
|
|
10
|
+
const setupPhpCSFixerValidationInspection = require('./php-cs-fixer-validation-inspection-config');
|
|
11
|
+
const setupPhpCSValidationInspection = require('./php-cs-validation-inspection-config');
|
|
12
|
+
const setupStyleLintInspection = require('./stylelint-inspection-config');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @type {() => import('listr2').ListrTask<import('../../../../../typings/context').ListrContext>}
|
|
16
|
+
*/
|
|
17
|
+
const setupInspectionToolsConfig = () => ({
|
|
18
|
+
title: 'Set up inspection tools configuration',
|
|
19
|
+
task: async (ctx, task) => {
|
|
20
|
+
const {
|
|
21
|
+
config: {
|
|
22
|
+
phpStorm
|
|
23
|
+
}
|
|
24
|
+
} = ctx;
|
|
25
|
+
|
|
26
|
+
if (await pathExists(phpStorm.inspectionTools.path)) {
|
|
27
|
+
const inspectionToolsData = await loadXmlFile(phpStorm.inspectionTools.path);
|
|
28
|
+
const inspectionTools = inspectionToolsData.component.profile.inspection_tool;
|
|
29
|
+
const hasChanges = await Promise.all([
|
|
30
|
+
setupPhpCSFixerValidationInspection(inspectionTools),
|
|
31
|
+
setupPhpCSValidationInspection(inspectionTools),
|
|
32
|
+
setupStyleLintInspection(inspectionTools),
|
|
33
|
+
setupMessDetectorValidationInspection(inspectionTools)
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
if (hasChanges.includes(true)) {
|
|
37
|
+
await buildXmlFile(phpStorm.inspectionTools.path, inspectionToolsData);
|
|
38
|
+
} else {
|
|
39
|
+
task.skip();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const inspectionToolsData = {
|
|
46
|
+
component: {
|
|
47
|
+
[nameKey]: 'InspectionProjectProfileManager',
|
|
48
|
+
profile: {
|
|
49
|
+
'@_version': '1.0',
|
|
50
|
+
option: {
|
|
51
|
+
[nameKey]: 'myName',
|
|
52
|
+
[valueKey]: 'Project Default'
|
|
53
|
+
},
|
|
54
|
+
inspection_tool: [
|
|
55
|
+
{
|
|
56
|
+
[classKey]: 'PhpStanGlobal',
|
|
57
|
+
'@_enabled': 'true',
|
|
58
|
+
'@_level': 'ERROR',
|
|
59
|
+
'@_enabled_by_default': 'true'
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const inspectionTools = inspectionToolsData.component.profile.inspection_tool;
|
|
66
|
+
|
|
67
|
+
await Promise.all([
|
|
68
|
+
setupPhpCSFixerValidationInspection(inspectionTools),
|
|
69
|
+
setupPhpCSValidationInspection(inspectionTools),
|
|
70
|
+
setupStyleLintInspection(inspectionTools),
|
|
71
|
+
setupMessDetectorValidationInspection(inspectionTools),
|
|
72
|
+
setupStyleLintInspection(inspectionTools),
|
|
73
|
+
setupESLintInspection(inspectionTools)
|
|
74
|
+
]);
|
|
75
|
+
|
|
76
|
+
await buildXmlFile(phpStorm.inspectionTools.path, inspectionToolsData);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
module.exports = setupInspectionToolsConfig;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const { nameKey, valueKey } = require('../keys');
|
|
2
|
+
const {
|
|
3
|
+
options: {
|
|
4
|
+
CODING_STANDARD_OPTION_NAME,
|
|
5
|
+
MAGENTO2_CODING_STANDARD_OPTION_VALUE
|
|
6
|
+
}
|
|
7
|
+
} = require('./config');
|
|
8
|
+
|
|
9
|
+
const setupMagento2CodingStandardOption = async (config) => {
|
|
10
|
+
let hasChanges = false;
|
|
11
|
+
const codingStandardOption = config.option.find(
|
|
12
|
+
(option) => option[nameKey] === CODING_STANDARD_OPTION_NAME
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
if (!codingStandardOption) {
|
|
16
|
+
hasChanges = true;
|
|
17
|
+
config.option.push({
|
|
18
|
+
[nameKey]: CODING_STANDARD_OPTION_NAME,
|
|
19
|
+
[valueKey]: MAGENTO2_CODING_STANDARD_OPTION_VALUE
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return hasChanges;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
module.exports = setupMagento2CodingStandardOption;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
const { phpMDRuleSetFormattedPath } = require('./paths');
|
|
2
|
+
const {
|
|
3
|
+
classes: {
|
|
4
|
+
MESS_DETECTOR_VALIDATION_INSPECTION
|
|
5
|
+
},
|
|
6
|
+
options: {
|
|
7
|
+
CODESIZE_OPTION_NAME,
|
|
8
|
+
CONTROVERSIAL_OPTION_NAME,
|
|
9
|
+
DESIGN_OPTION_NAME,
|
|
10
|
+
UNUSED_CODE_OPTION_NAME,
|
|
11
|
+
NAMING_OPTION_NAME,
|
|
12
|
+
CUSTOM_RULESETS_OPTION_NAME,
|
|
13
|
+
PHP_MD_RULESET_OPTION_VALUE
|
|
14
|
+
}
|
|
15
|
+
} = require('./config');
|
|
16
|
+
const {
|
|
17
|
+
classKey,
|
|
18
|
+
nameKey,
|
|
19
|
+
valueKey
|
|
20
|
+
} = require('../keys');
|
|
21
|
+
const setupDefaultProperties = require('./default-properties-config');
|
|
22
|
+
|
|
23
|
+
const messDetectorBooleanOptionNames = [
|
|
24
|
+
CODESIZE_OPTION_NAME,
|
|
25
|
+
CONTROVERSIAL_OPTION_NAME,
|
|
26
|
+
DESIGN_OPTION_NAME,
|
|
27
|
+
UNUSED_CODE_OPTION_NAME,
|
|
28
|
+
NAMING_OPTION_NAME
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const messDetectorDefaultRuleSetsListContent = {
|
|
32
|
+
RulesetDescriptor: {
|
|
33
|
+
option: [
|
|
34
|
+
{
|
|
35
|
+
[nameKey]: 'name',
|
|
36
|
+
[valueKey]: PHP_MD_RULESET_OPTION_VALUE
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
[nameKey]: 'path',
|
|
40
|
+
[valueKey]: phpMDRuleSetFormattedPath
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const messDetectorDefaultOptions = [
|
|
47
|
+
...messDetectorBooleanOptionNames.map((optionName) => ({
|
|
48
|
+
[nameKey]: optionName,
|
|
49
|
+
[valueKey]: 'true'
|
|
50
|
+
})),
|
|
51
|
+
{
|
|
52
|
+
[nameKey]: CUSTOM_RULESETS_OPTION_NAME,
|
|
53
|
+
list: messDetectorDefaultRuleSetsListContent
|
|
54
|
+
}
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {Array} inspectionToolsData
|
|
59
|
+
* @returns {Promise<Boolean>}
|
|
60
|
+
*/
|
|
61
|
+
const setupMessDetectorValidationInspection = async (inspectionToolsData) => {
|
|
62
|
+
let hasChanges = false;
|
|
63
|
+
const messDetectorConfig = inspectionToolsData.find((inspectionToolData) => inspectionToolData[classKey] === MESS_DETECTOR_VALIDATION_INSPECTION);
|
|
64
|
+
if (messDetectorConfig) {
|
|
65
|
+
const hasChangesInProperties = setupDefaultProperties(messDetectorConfig, {
|
|
66
|
+
enabled: 'true',
|
|
67
|
+
enabled_by_default: 'true',
|
|
68
|
+
level: 'WEAK WARNING'
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (hasChangesInProperties) {
|
|
72
|
+
hasChanges = true;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (messDetectorConfig.option) {
|
|
76
|
+
messDetectorBooleanOptionNames.forEach((optionName) => {
|
|
77
|
+
const booleanOption = messDetectorConfig.option.find(
|
|
78
|
+
(o) => o[nameKey] === optionName
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
if (!booleanOption) {
|
|
82
|
+
hasChanges = true;
|
|
83
|
+
messDetectorConfig.option.push({
|
|
84
|
+
[nameKey]: optionName,
|
|
85
|
+
[valueKey]: 'true'
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const customRulesetsOption = messDetectorConfig.option.find(
|
|
91
|
+
(o) => o[nameKey] === CUSTOM_RULESETS_OPTION_NAME
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
if (customRulesetsOption) {
|
|
95
|
+
if (!customRulesetsOption.list) {
|
|
96
|
+
hasChanges = true;
|
|
97
|
+
customRulesetsOption.list = [];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (customRulesetsOption.list && !Array.isArray(customRulesetsOption.list)) {
|
|
101
|
+
hasChanges = true;
|
|
102
|
+
customRulesetsOption.list = [customRulesetsOption.list];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const correctRulesetsExists = customRulesetsOption.list.some(
|
|
106
|
+
(r) => r.RulesetDescriptor.option.some(
|
|
107
|
+
(o) => o[nameKey] === 'path' && o[valueKey] === phpMDRuleSetFormattedPath
|
|
108
|
+
)
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
if (!correctRulesetsExists) {
|
|
112
|
+
hasChanges = true;
|
|
113
|
+
customRulesetsOption.list.push(
|
|
114
|
+
messDetectorDefaultRuleSetsListContent
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
hasChanges = true;
|
|
119
|
+
messDetectorConfig.option.push({
|
|
120
|
+
[nameKey]: CUSTOM_RULESETS_OPTION_NAME,
|
|
121
|
+
list: messDetectorDefaultRuleSetsListContent
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
hasChanges = true;
|
|
126
|
+
messDetectorConfig.option = messDetectorDefaultOptions;
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
hasChanges = true;
|
|
130
|
+
inspectionToolsData.push({
|
|
131
|
+
[classKey]: MESS_DETECTOR_VALIDATION_INSPECTION,
|
|
132
|
+
'@_enabled': 'true',
|
|
133
|
+
'@_level': 'WEAK WARNING',
|
|
134
|
+
'@_enabled_by_default': 'true',
|
|
135
|
+
option: messDetectorDefaultOptions
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return hasChanges;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
module.exports = setupMessDetectorValidationInspection;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { formatPathForPHPStormConfig } = require('../xml-utils');
|
|
3
|
+
|
|
4
|
+
const phpCompatibilityPath = path.join(process.cwd(), 'vendor', 'phpcompatibility', 'php-compatibility', 'PHPCompatibility');
|
|
5
|
+
const phpCompatibilityRuleSetPath = path.join(phpCompatibilityPath, 'ruleset.xml');
|
|
6
|
+
const phpCompatibilityFormattedPath = formatPathForPHPStormConfig(phpCompatibilityPath);
|
|
7
|
+
const phpCSConfigurationPath = path.join(process.cwd(), '.php_cs.dist');
|
|
8
|
+
const phpCSConfigFormattedPath = formatPathForPHPStormConfig(phpCSConfigurationPath);
|
|
9
|
+
const phpMDRuleSetPath = path.join(process.cwd(), 'dev', 'tests', 'static', 'testsuite', 'Magento', 'Test', 'Php', '_files', 'phpmd', 'ruleset.xml');
|
|
10
|
+
const phpMDRuleSetFormattedPath = formatPathForPHPStormConfig(phpMDRuleSetPath);
|
|
11
|
+
|
|
12
|
+
module.exports = {
|
|
13
|
+
phpCompatibilityPath,
|
|
14
|
+
phpCompatibilityRuleSetPath,
|
|
15
|
+
phpCompatibilityFormattedPath,
|
|
16
|
+
phpCSConfigurationPath,
|
|
17
|
+
phpCSConfigFormattedPath,
|
|
18
|
+
phpMDRuleSetPath,
|
|
19
|
+
phpMDRuleSetFormattedPath
|
|
20
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const {
|
|
2
|
+
classes: {
|
|
3
|
+
PHP_CS_FIXER_VALIDATION_INSPECTION
|
|
4
|
+
}
|
|
5
|
+
} = require('./config');
|
|
6
|
+
const { classKey } = require('../keys');
|
|
7
|
+
const setupCodingStandardOption = require('./coding-standard-config');
|
|
8
|
+
const setupCustomRuleSetPathOption = require('./custom-ruleset-path-config');
|
|
9
|
+
const setupDefaultProperties = require('./default-properties-config');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {Array} inspectionToolsData
|
|
13
|
+
* @returns {Promise<Boolean>}
|
|
14
|
+
*/
|
|
15
|
+
const setupPhpCSFixerValidationInspection = async (inspectionToolsData) => {
|
|
16
|
+
let hasChanges = false;
|
|
17
|
+
const phpCSFixerConfig = inspectionToolsData.find(
|
|
18
|
+
(inspectionToolData) => inspectionToolData[classKey] === PHP_CS_FIXER_VALIDATION_INSPECTION
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
if (phpCSFixerConfig) {
|
|
22
|
+
const hasChangesInProperties = setupDefaultProperties(phpCSFixerConfig);
|
|
23
|
+
if (hasChangesInProperties) {
|
|
24
|
+
hasChanges = true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (phpCSFixerConfig.option) {
|
|
28
|
+
const hasCodingStandardChanges = await setupCodingStandardOption(phpCSFixerConfig);
|
|
29
|
+
if (hasCodingStandardChanges) {
|
|
30
|
+
hasChanges = true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const hasCustomRuleSetChanges = await setupCustomRuleSetPathOption(phpCSFixerConfig);
|
|
34
|
+
if (hasCustomRuleSetChanges) {
|
|
35
|
+
hasChanges = true;
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
hasChanges = true;
|
|
39
|
+
phpCSFixerConfig.option = [];
|
|
40
|
+
await setupCodingStandardOption(phpCSFixerConfig);
|
|
41
|
+
await setupCustomRuleSetPathOption(phpCSFixerConfig);
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
hasChanges = true;
|
|
45
|
+
const phpCSFixerConfig = {
|
|
46
|
+
[classKey]: PHP_CS_FIXER_VALIDATION_INSPECTION,
|
|
47
|
+
option: []
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
setupDefaultProperties(phpCSFixerConfig);
|
|
51
|
+
await setupCodingStandardOption(phpCSFixerConfig);
|
|
52
|
+
await setupCustomRuleSetPathOption(phpCSFixerConfig);
|
|
53
|
+
|
|
54
|
+
inspectionToolsData.push(phpCSFixerConfig);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return hasChanges;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
module.exports = setupPhpCSFixerValidationInspection;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
const {
|
|
2
|
+
classes: {
|
|
3
|
+
PHP_CS_VALIDATION_INSPECTION
|
|
4
|
+
},
|
|
5
|
+
options: {
|
|
6
|
+
CODING_STANDARD_OPTION_NAME,
|
|
7
|
+
MAGENTO2_CODING_STANDARD_OPTION_VALUE,
|
|
8
|
+
EXTENSIONS_OPTION_NAME,
|
|
9
|
+
WARNING_HIGHLIGHT_LEVEL_NAME_OPTION_NAME,
|
|
10
|
+
WARNING_HIGHLIGHT_LEVEL_NAME_OPTION_VALUE,
|
|
11
|
+
SHOW_SNIFF_NAMES_OPTION_NAME
|
|
12
|
+
}
|
|
13
|
+
} = require('./config');
|
|
14
|
+
const {
|
|
15
|
+
classKey,
|
|
16
|
+
nameKey,
|
|
17
|
+
valueKey
|
|
18
|
+
} = require('../keys');
|
|
19
|
+
const setupDefaultProperties = require('./default-properties-config');
|
|
20
|
+
const setupMagento2CodingStandardOption = require('./magento-coding-standard-config');
|
|
21
|
+
|
|
22
|
+
const phpCSConfigDefaultOptions = [
|
|
23
|
+
{
|
|
24
|
+
[nameKey]: CODING_STANDARD_OPTION_NAME,
|
|
25
|
+
[valueKey]: MAGENTO2_CODING_STANDARD_OPTION_VALUE
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
[nameKey]: WARNING_HIGHLIGHT_LEVEL_NAME_OPTION_NAME,
|
|
29
|
+
[valueKey]: WARNING_HIGHLIGHT_LEVEL_NAME_OPTION_VALUE
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
[nameKey]: SHOW_SNIFF_NAMES_OPTION_NAME,
|
|
33
|
+
[valueKey]: 'true'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
[nameKey]: EXTENSIONS_OPTION_NAME,
|
|
37
|
+
[valueKey]: 'php'
|
|
38
|
+
}
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const setupPhpCSValidationInspection = async (inspectionToolsData) => {
|
|
42
|
+
let hasChanges = false;
|
|
43
|
+
const phpCSConfig = inspectionToolsData.find(
|
|
44
|
+
(inspectionToolData) => inspectionToolData[classKey] === PHP_CS_VALIDATION_INSPECTION
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
if (phpCSConfig) {
|
|
48
|
+
const hasChangesInProperties = setupDefaultProperties(phpCSConfig);
|
|
49
|
+
if (hasChangesInProperties) {
|
|
50
|
+
hasChanges = true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (phpCSConfig.option) {
|
|
54
|
+
const hasCodingStandardChanges = await setupMagento2CodingStandardOption(phpCSConfig);
|
|
55
|
+
if (hasCodingStandardChanges) {
|
|
56
|
+
hasChanges = true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const warningHighlightLevelNameOption = phpCSConfig.option.find(
|
|
60
|
+
(option) => option[nameKey] === WARNING_HIGHLIGHT_LEVEL_NAME_OPTION_NAME
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (!warningHighlightLevelNameOption) {
|
|
64
|
+
hasChanges = true;
|
|
65
|
+
phpCSConfig.option.push({
|
|
66
|
+
[nameKey]: WARNING_HIGHLIGHT_LEVEL_NAME_OPTION_NAME,
|
|
67
|
+
[valueKey]: WARNING_HIGHLIGHT_LEVEL_NAME_OPTION_VALUE
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const showSniffNamesOption = phpCSConfig.option.find(
|
|
72
|
+
(option) => option[nameKey] === SHOW_SNIFF_NAMES_OPTION_NAME
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
if (!showSniffNamesOption) {
|
|
76
|
+
hasChanges = true;
|
|
77
|
+
phpCSConfig.option.push({
|
|
78
|
+
[nameKey]: SHOW_SNIFF_NAMES_OPTION_NAME,
|
|
79
|
+
[valueKey]: 'true'
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// we want php code sniffer to lint only php files
|
|
84
|
+
// for other files (js, css, scss) we have separate linter setups
|
|
85
|
+
const extensionsOption = phpCSConfig.option.find(
|
|
86
|
+
(option) => option[nameKey] === EXTENSIONS_OPTION_NAME
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
if (!extensionsOption) {
|
|
90
|
+
hasChanges = true;
|
|
91
|
+
phpCSConfig.option.push({
|
|
92
|
+
[nameKey]: EXTENSIONS_OPTION_NAME,
|
|
93
|
+
[valueKey]: 'php'
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
hasChanges = true;
|
|
98
|
+
phpCSConfig.option = phpCSConfigDefaultOptions;
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
hasChanges = true;
|
|
102
|
+
|
|
103
|
+
const phpCSConfig = {
|
|
104
|
+
[classKey]: PHP_CS_VALIDATION_INSPECTION,
|
|
105
|
+
option: phpCSConfigDefaultOptions
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
setupDefaultProperties(phpCSConfig);
|
|
109
|
+
|
|
110
|
+
inspectionToolsData.push(phpCSConfig);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return hasChanges;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
module.exports = setupPhpCSValidationInspection;
|
|
@@ -0,0 +1,37 @@
|
|
|
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;
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
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;
|
|
@@ -0,0 +1,54 @@
|
|
|
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) {
|
|
38
|
+
hasChanges = true;
|
|
39
|
+
messDetectorComponent.phpmd_settings.push(defaultMessDetectorSetting);
|
|
40
|
+
}
|
|
41
|
+
} else if (isPhpMDBinPathExists) {
|
|
42
|
+
hasChanges = true;
|
|
43
|
+
phpConfigs.push({
|
|
44
|
+
[nameKey]: 'MessDetector',
|
|
45
|
+
phpmd_settings: [
|
|
46
|
+
defaultMessDetectorSetting
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return hasChanges;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
module.exports = setupMessDetector;
|