@scandipwa/magento-scripts 1.16.1 → 2.0.0-alpha.2
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 +4 -6
- package/lib/commands/execute.js +29 -4
- package/lib/commands/import-db.js +1 -1
- package/lib/commands/logs.js +1 -1
- package/lib/commands/start.js +38 -20
- package/lib/commands/status.js +2 -0
- package/lib/config/docker.js +102 -84
- package/lib/config/get-project-configuration.js +3 -1
- package/lib/config/index.js +10 -7
- package/lib/config/magento/required-php-extensions/index.js +29 -0
- package/lib/config/magento/required-php-extensions/magento-2.3.js +19 -0
- package/lib/config/magento/required-php-extensions/magento-2.4.js +29 -0
- package/lib/config/php/base-repo.js +3 -0
- package/lib/config/php/extensions/apcu.js +12 -0
- package/lib/config/php/extensions/bcmath.js +7 -0
- package/lib/config/php/extensions/curl.js +11 -0
- package/lib/config/php/extensions/gd.js +14 -0
- package/lib/config/php/extensions/index.js +18 -2
- package/lib/config/php/extensions/intl.js +10 -0
- package/lib/config/php/extensions/opcache.js +10 -0
- package/lib/config/php/extensions/pdo_mysql.js +7 -0
- package/lib/config/php/extensions/soap.js +10 -0
- package/lib/config/php/extensions/sodium.js +10 -0
- package/lib/config/php/extensions/xdebug.js +8 -5
- package/lib/config/php/extensions/xsl.js +10 -0
- package/lib/config/php/extensions/zip.js +10 -0
- package/lib/config/php/{releases → versions}/index.js +0 -0
- package/lib/config/php/versions/php-7.2.js +23 -0
- package/lib/config/php/versions/php-7.3.js +23 -0
- package/lib/config/php/versions/php-7.4.js +23 -0
- package/lib/config/php/versions/php-8.1.js +23 -0
- package/lib/config/php-config.js +8 -12
- package/lib/config/port-config.js +2 -6
- package/lib/config/services/elasticsearch/base-repo.js +3 -0
- package/lib/config/services/elasticsearch/default-es-env.js +6 -0
- package/lib/config/services/elasticsearch/versions/elasticsearch-6.8.js +19 -0
- package/lib/config/services/elasticsearch/versions/index.js +5 -0
- package/lib/config/templates/magentorc.template +5 -5
- package/lib/config/templates/mariadb.template.cnf +191 -0
- package/lib/config/templates/php-fpm.template.conf +3 -3
- package/lib/config/templates/php.template.ini +12 -6
- package/lib/config/templates/ssl-terminator.template.conf +1 -1
- package/lib/config/templates/vscode-launch.template.json +3 -1
- package/lib/config/versions/magento-2.3.0.js +10 -5
- package/lib/config/versions/magento-2.3.1.js +10 -5
- package/lib/config/versions/magento-2.3.2-p1.js +43 -0
- package/lib/config/versions/magento-2.3.2-p2.js +10 -5
- package/lib/config/versions/magento-2.3.2.js +10 -5
- package/lib/config/versions/magento-2.3.3-p1.js +10 -5
- package/lib/config/versions/magento-2.3.3.js +10 -5
- package/lib/config/versions/magento-2.3.4-p1.js +43 -0
- package/lib/config/versions/magento-2.3.4-p2.js +10 -5
- package/lib/config/versions/magento-2.3.4.js +10 -5
- package/lib/config/versions/magento-2.3.5-p1.js +8 -2
- package/lib/config/versions/magento-2.3.5-p2.js +8 -2
- package/lib/config/versions/magento-2.3.5.js +8 -2
- package/lib/config/versions/magento-2.3.6-p1.js +8 -2
- package/lib/config/versions/magento-2.3.6.js +8 -2
- package/lib/config/versions/magento-2.3.7-p1.js +8 -2
- package/lib/config/versions/magento-2.3.7-p2.js +8 -2
- package/lib/config/versions/magento-2.3.7-p3.js +8 -2
- package/lib/config/versions/magento-2.3.7.js +8 -2
- package/lib/config/versions/magento-2.4.0-p1.js +9 -3
- package/lib/config/versions/magento-2.4.0.js +9 -3
- package/lib/config/versions/magento-2.4.1-p1.js +6 -5
- package/lib/config/versions/magento-2.4.1.js +9 -2
- package/lib/config/versions/magento-2.4.2-p1.js +6 -5
- package/lib/config/versions/magento-2.4.2-p2.js +6 -6
- package/lib/config/versions/magento-2.4.2.js +6 -6
- package/lib/config/versions/magento-2.4.3-p1.js +7 -7
- package/lib/config/versions/magento-2.4.3-p2.js +7 -7
- package/lib/config/versions/magento-2.4.3.js +7 -7
- package/lib/config/versions/magento-2.4.4.js +9 -2
- package/lib/tasks/cleanup.js +3 -3
- package/lib/tasks/composer/index.js +14 -104
- package/lib/tasks/database/connect-to-database.js +117 -0
- package/lib/tasks/database/create-magento-database.js +18 -0
- package/lib/tasks/{mysql → database}/dump-theme-config.js +3 -3
- package/lib/tasks/{mysql → database}/fix-db.js +2 -2
- package/lib/tasks/{mysql/import-dump-to-mysql.js → database/import-dump-to-database.js} +65 -22
- package/lib/tasks/{mysql → database}/import-remote-db/index.js +0 -0
- package/lib/tasks/{mysql/import-remote-db/ssh/mysqldump-command.js → database/import-remote-db/ssh/database-dump-command.js} +2 -2
- package/lib/tasks/{mysql → database}/import-remote-db/ssh/index.js +0 -0
- package/lib/tasks/{mysql → database}/import-remote-db/ssh/readymage.js +4 -4
- package/lib/tasks/{mysql → database}/import-remote-db/ssh/regular-server.js +2 -2
- package/lib/tasks/{mysql → database}/index.js +2 -2
- package/lib/tasks/{mysql → database}/magento-tables.js +0 -0
- package/lib/tasks/{mysql → database}/restore-theme-config.js +4 -4
- package/lib/tasks/docker/api.d.ts +71 -0
- package/lib/tasks/docker/api.js +30 -0
- package/lib/tasks/docker/containers/container-api.d.ts +128 -0
- package/lib/tasks/docker/containers/container-api.js +153 -0
- package/lib/tasks/docker/containers/index.js +19 -0
- package/lib/tasks/docker/containers/tasks.js +215 -0
- package/lib/tasks/docker/convert-legacy-volumes.js +15 -10
- package/lib/tasks/docker/convert-mysql-to-mariadb.js +284 -0
- package/lib/tasks/docker/image/image-api.d.ts +34 -0
- package/lib/tasks/docker/image/image-api.js +49 -0
- package/lib/tasks/docker/image/index.js +5 -0
- package/lib/tasks/docker/index.js +1 -13
- package/lib/tasks/docker/network/index.js +7 -0
- package/lib/tasks/docker/network/network-api.d.ts +103 -0
- package/lib/tasks/docker/network/network-api.js +99 -0
- package/lib/tasks/docker/{network.js → network/tasks.js} +17 -10
- package/lib/tasks/docker/project-image-builder.js +167 -0
- package/lib/tasks/docker/volume/index.js +8 -0
- package/lib/tasks/docker/{volumes.js → volume/tasks.js} +5 -19
- package/lib/tasks/docker/volume/volume-api.d.ts +39 -0
- package/lib/tasks/docker/volume/volume-api.js +66 -0
- package/lib/tasks/execute/index.js +5 -2
- package/lib/tasks/file-system/create-mariadb-config.js +23 -0
- package/lib/tasks/file-system/create-nginx-config.js +2 -3
- package/lib/tasks/file-system/create-php-config.js +20 -5
- package/lib/tasks/file-system/create-php-fpm-config.js +8 -4
- package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +41 -29
- package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -0
- package/lib/tasks/file-system/create-phpstorm-config/keys.js +15 -1
- package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +4 -1
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-config.js +3 -3
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-interpreters-config.js +81 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/index.js +42 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/php-docker-settings-config.js +9 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/setup-php-docker-container-settings-config.js +66 -0
- package/lib/tasks/file-system/create-phpstorm-config/setup-xml-structure.js +11 -9
- package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +2 -1
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +15 -30
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +24 -5
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/mess-detector-project-configuration-config.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-code-sniffer-project-configuration-config.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-cs-fixer-project-configuration-config.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +15 -15
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +29 -3
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-stan-project-configuration-config.js.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +42 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/psalm-project-configuration-config.js.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/workspace-config.js +0 -2
- package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -2
- package/lib/tasks/file-system/create-vscode-config.js +57 -42
- package/lib/tasks/file-system/index.js +5 -2
- package/lib/tasks/import-dump.js +6 -6
- package/lib/tasks/link.js +5 -4
- package/lib/tasks/magento/install-magento-project.js +31 -63
- package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +4 -4
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +7 -3
- package/lib/tasks/magento/setup-magento/create-admin.js +5 -6
- package/lib/tasks/magento/setup-magento/delete-admin-users.js +2 -2
- package/lib/tasks/magento/setup-magento/delete-customers.js +4 -4
- package/lib/tasks/magento/setup-magento/delete-orders.js +4 -4
- package/lib/tasks/magento/setup-magento/disable-2fa.js +3 -5
- package/lib/tasks/magento/setup-magento/disable-maintenance-mode.js +3 -4
- package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +2 -2
- package/lib/tasks/magento/setup-magento/index.js +2 -0
- package/lib/tasks/magento/setup-magento/install-magento.js +21 -20
- package/lib/tasks/magento/setup-magento/migrate-database.js +7 -14
- package/lib/tasks/magento/setup-magento/set-base-url.js +2 -2
- package/lib/tasks/magento/setup-magento/set-deployment-mode.js +4 -4
- package/lib/tasks/magento/setup-magento/set-url-rewrite.js +2 -2
- package/lib/tasks/magento/setup-magento/varnish-config.js +10 -8
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +128 -3
- package/lib/tasks/php/php-container.js +108 -0
- package/lib/tasks/php/update-env-php.js +39 -21
- package/lib/tasks/php/update-env.php +66 -61
- package/lib/tasks/php/working_health_check.php +85 -0
- package/lib/tasks/requirements/{composer.js → composer-credentials.js} +3 -1
- package/lib/tasks/requirements/docker/index.js +15 -12
- package/lib/tasks/requirements/docker/performance.js +54 -0
- package/lib/tasks/requirements/docker/version.js +8 -8
- package/lib/tasks/requirements/index.js +5 -8
- package/lib/tasks/requirements/php-version.js +8 -116
- package/lib/tasks/requirements/platform.js +12 -25
- package/lib/tasks/start.js +21 -50
- package/lib/tasks/status/index.js +8 -12
- package/lib/tasks/stop.js +0 -2
- package/lib/tasks/theme/install-theme.js +1 -1
- package/lib/tasks/theme/link-theme.js +2 -2
- package/lib/tasks/theme/symlink-theme.js +2 -3
- package/lib/util/config-file-validator.js +27 -13
- package/lib/util/config-php-json.js +13 -4
- package/lib/util/database.js +7 -7
- package/lib/util/dockerfile-builder/build-instructions.js +197 -0
- package/lib/util/dockerfile-builder/index.js +276 -0
- package/lib/util/dockerfile-builder/types.d.ts +123 -0
- package/lib/util/env-php-json.js +10 -6
- package/lib/util/exec-async-command.js +3 -9
- package/lib/util/macos-version.js +20 -0
- package/lib/util/magento-task.js +3 -4
- package/lib/util/nginx-logs-parser.js +122 -0
- package/lib/util/php-task.js +3 -6
- package/lib/util/run-composer.js +6 -14
- package/lib/util/run-container-image.js +17 -0
- package/lib/util/run-magento.js +6 -14
- package/lib/util/run-php.js +6 -17
- package/package.json +9 -9
- package/typings/context.d.ts +7 -13
- package/typings/index.d.ts +67 -85
- package/yarn-error.log +9660 -0
- package/lib/config/composer.js +0 -11
- package/lib/config/php/extensions/libsodium.js +0 -36
- package/lib/config/php/releases/php-7.2.js +0 -25
- package/lib/config/php/releases/php-7.3.js +0 -25
- package/lib/config/php/releases/php-7.4.js +0 -23
- package/lib/config/php/releases/php-8.1.js +0 -25
- package/lib/config/phpbrew.js +0 -12
- package/lib/tasks/composer/install-prestissimo.js +0 -103
- package/lib/tasks/docker/containers.js +0 -231
- package/lib/tasks/mysql/connect-to-mysql.js +0 -114
- package/lib/tasks/mysql/create-magento-database.js +0 -18
- package/lib/tasks/php/bundled-extensions.js +0 -27
- package/lib/tasks/php/compile-options.js +0 -56
- package/lib/tasks/php/compile.js +0 -55
- package/lib/tasks/php/configure.js +0 -89
- package/lib/tasks/php/extensions/disable.js +0 -49
- package/lib/tasks/php/extensions/enable.js +0 -52
- package/lib/tasks/php/extensions/index.js +0 -80
- package/lib/tasks/php/extensions/install.js +0 -54
- package/lib/tasks/php/index.js +0 -79
- package/lib/tasks/php/install-sodium.js +0 -93
- package/lib/tasks/php/update-phpbrew.js +0 -45
- package/lib/tasks/php/validate-php.js +0 -67
- package/lib/tasks/php-fpm/get-process-id.js +0 -14
- package/lib/tasks/php-fpm/index.js +0 -4
- package/lib/tasks/php-fpm/start-php-fpm.js +0 -49
- package/lib/tasks/php-fpm/stop-php-fpm.js +0 -48
- package/lib/tasks/requirements/phpbrew/index.js +0 -61
- package/lib/tasks/requirements/phpbrew/install.js +0 -159
- package/lib/tasks/requirements/phpbrew/version.js +0 -28
|
@@ -5,6 +5,7 @@ const setupMessDetector = require('./mess-detector-config');
|
|
|
5
5
|
const setupPHPCodeSniffer = require('./php-code-sniffer-config');
|
|
6
6
|
const { getPhpConfig } = require('./php-config');
|
|
7
7
|
const setupPHPCSFixer = require('./php-cs-fixer-config');
|
|
8
|
+
const setupPHPInterpreters = require('./php-interpreters-config');
|
|
8
9
|
const setupPHPProjectSharedConfiguration = require('./php-project-shared-configuration-config');
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -13,7 +14,7 @@ const setupPHPProjectSharedConfiguration = require('./php-project-shared-configu
|
|
|
13
14
|
const setupPhpConfig = () => ({
|
|
14
15
|
title: 'Set up PHP configuration',
|
|
15
16
|
task: async (ctx, task) => {
|
|
16
|
-
const phpConfig = getPhpConfig(ctx
|
|
17
|
+
const phpConfig = getPhpConfig(ctx);
|
|
17
18
|
|
|
18
19
|
if (await pathExists(phpConfig.path)) {
|
|
19
20
|
const phpConfigContent = setupXMLStructure(await loadXmlFile(phpConfig.path));
|
|
@@ -22,6 +23,7 @@ const setupPhpConfig = () => ({
|
|
|
22
23
|
setupMessDetector(phpConfigs),
|
|
23
24
|
setupPHPCodeSniffer(phpConfigs),
|
|
24
25
|
setupPHPCSFixer(phpConfigs),
|
|
26
|
+
setupPHPInterpreters(phpConfigs, ctx),
|
|
25
27
|
setupPHPProjectSharedConfiguration(phpConfigs, phpConfig.phpLanguageLevel)
|
|
26
28
|
]);
|
|
27
29
|
|
|
@@ -41,6 +43,7 @@ const setupPhpConfig = () => ({
|
|
|
41
43
|
setupMessDetector(phpConfigs),
|
|
42
44
|
setupPHPCodeSniffer(phpConfigs),
|
|
43
45
|
setupPHPCSFixer(phpConfigs),
|
|
46
|
+
setupPHPInterpreters(phpConfigs, ctx),
|
|
44
47
|
setupPHPProjectSharedConfiguration(phpConfigs, phpConfig.phpLanguageLevel)
|
|
45
48
|
]);
|
|
46
49
|
|
|
@@ -2,10 +2,10 @@ const path = require('path');
|
|
|
2
2
|
const { baseConfig } = require('../../../../config');
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @param {import('../../../../../typings/
|
|
5
|
+
* @param {import('../../../../../typings/context').ListrContext} ctx
|
|
6
6
|
*/
|
|
7
|
-
const getPhpConfig = (
|
|
8
|
-
const [majorPHPVersion, minorPHPVersion] =
|
|
7
|
+
const getPhpConfig = (ctx) => {
|
|
8
|
+
const [majorPHPVersion, minorPHPVersion] = ctx.phpVersion.split('.');
|
|
9
9
|
const phpLanguageLevel = `${ majorPHPVersion }.${ minorPHPVersion }`;
|
|
10
10
|
|
|
11
11
|
return {
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const { nameKey, propertyKey } = require('../keys');
|
|
2
|
+
|
|
3
|
+
const PHP_INTERPRETERS_COMPONENT_NAME = 'PhpInterpreters';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {Array} phpConfigs
|
|
7
|
+
* @param {import('../../../../../typings/context').ListrContext} ctx
|
|
8
|
+
* @returns {Promise<Boolean>}
|
|
9
|
+
*/
|
|
10
|
+
const setupPHPInterpreters = async (phpConfigs, ctx) => {
|
|
11
|
+
let hasChanges = false;
|
|
12
|
+
const phpInterpretersComponent = phpConfigs.find(
|
|
13
|
+
(phpConfig) => phpConfig[nameKey] === PHP_INTERPRETERS_COMPONENT_NAME
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const { php } = ctx.config.docker.getContainers(ctx.ports);
|
|
17
|
+
const currentInterpreterImage = ctx.debug ? php.debugImage : php.image;
|
|
18
|
+
|
|
19
|
+
const defaultPhpInterpreterConfiguration = {
|
|
20
|
+
[nameKey]: currentInterpreterImage,
|
|
21
|
+
[propertyKey('id')]: '2fbe75d5-bc8f-4adb-8e62-ddb0ccee6428',
|
|
22
|
+
[propertyKey('home')]: 'docker://DATA',
|
|
23
|
+
[propertyKey('debugger_id')]: 'php.debugger.XDebug',
|
|
24
|
+
remote_data: {
|
|
25
|
+
[propertyKey('INTERPRETER_PATH')]: 'php',
|
|
26
|
+
[propertyKey('HELPERS_PATH')]: '/opt/.phpstorm_helpers',
|
|
27
|
+
[propertyKey('VALID')]: 'true',
|
|
28
|
+
[propertyKey('RUN_AS_ROOT_VIA_SUDO')]: 'false',
|
|
29
|
+
[propertyKey('DOCKER_ACCOUNT_NAME')]: 'Docker',
|
|
30
|
+
[propertyKey('DOCKER_IMAGE_NAME')]: currentInterpreterImage,
|
|
31
|
+
[propertyKey('DOCKER_REMOTE_PROJECT_PATH')]: ctx.config.baseConfig.containerMagentoDir
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
if (phpInterpretersComponent) {
|
|
36
|
+
if (!phpInterpretersComponent.interpreters) {
|
|
37
|
+
hasChanges = true;
|
|
38
|
+
phpInterpretersComponent.interpreters = {};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!Array.isArray(phpInterpretersComponent.interpreters.interpreter)) {
|
|
42
|
+
hasChanges = true;
|
|
43
|
+
phpInterpretersComponent.interpreters.interpreter = [phpInterpretersComponent.interpreters.interpreter];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const phpInterpreterConfiguration = phpInterpretersComponent.interpreters.interpreter.find(
|
|
47
|
+
(interpreter) => interpreter[nameKey] === php.image || interpreter[nameKey] === php.debugImage
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
if (!phpInterpreterConfiguration) {
|
|
51
|
+
hasChanges = true;
|
|
52
|
+
phpInterpretersComponent.interpreters.interpreter.push(defaultPhpInterpreterConfiguration);
|
|
53
|
+
} else {
|
|
54
|
+
if (phpInterpreterConfiguration[nameKey] !== currentInterpreterImage) {
|
|
55
|
+
hasChanges = true;
|
|
56
|
+
phpInterpreterConfiguration[nameKey] = currentInterpreterImage;
|
|
57
|
+
}
|
|
58
|
+
if (phpInterpreterConfiguration.remote_data[propertyKey('DOCKER_IMAGE_NAME')] !== currentInterpreterImage) {
|
|
59
|
+
hasChanges = true;
|
|
60
|
+
phpInterpreterConfiguration.remote_data[propertyKey('DOCKER_IMAGE_NAME')] = currentInterpreterImage;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (phpInterpreterConfiguration.remote_data[propertyKey('DOCKER_REMOTE_PROJECT_PATH')] !== ctx.config.baseConfig.containerMagentoDir) {
|
|
64
|
+
hasChanges = true;
|
|
65
|
+
phpInterpreterConfiguration.remote_data[propertyKey('DOCKER_REMOTE_PROJECT_PATH')] = ctx.config.baseConfig.containerMagentoDir;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
hasChanges = true;
|
|
70
|
+
phpConfigs.push({
|
|
71
|
+
[nameKey]: PHP_INTERPRETERS_COMPONENT_NAME,
|
|
72
|
+
interpreters: {
|
|
73
|
+
interpreter: defaultPhpInterpreterConfiguration
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return hasChanges;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
module.exports = setupPHPInterpreters;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const { loadXmlFile, buildXmlFile } = require('../../../../config/xml-parser');
|
|
2
|
+
const pathExists = require('../../../../util/path-exists');
|
|
3
|
+
const { setupXMLStructure } = require('../setup-xml-structure');
|
|
4
|
+
const { getPhpDockerSettingsConfig } = require('./php-docker-settings-config');
|
|
5
|
+
const setupPHPDockerContainerSettingsConfig = require('./setup-php-docker-container-settings-config');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @type {() => import('listr2').ListrTask<import('../../../../../typings/context').ListrContext>}
|
|
9
|
+
*/
|
|
10
|
+
const setupPhpDockerSettingsConfig = () => ({
|
|
11
|
+
title: 'Set up PHP Docker Settings configuration',
|
|
12
|
+
task: async (ctx, task) => {
|
|
13
|
+
const phpDockerSettingsConfig = getPhpDockerSettingsConfig();
|
|
14
|
+
|
|
15
|
+
if (await pathExists(phpDockerSettingsConfig.path)) {
|
|
16
|
+
const phpDockerSettingsConfigContent = setupXMLStructure(await loadXmlFile(phpDockerSettingsConfig.path));
|
|
17
|
+
const phpDockerSettingsConfigs = phpDockerSettingsConfigContent.project.component;
|
|
18
|
+
const hasChanges = await Promise.all([
|
|
19
|
+
setupPHPDockerContainerSettingsConfig(phpDockerSettingsConfigs, ctx)
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
if (hasChanges.includes(true)) {
|
|
23
|
+
await buildXmlFile(phpDockerSettingsConfig.path, phpDockerSettingsConfigContent);
|
|
24
|
+
} else {
|
|
25
|
+
task.skip();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const phpDockerSettingsConfigContent = setupXMLStructure({});
|
|
32
|
+
const phpDockerSettingsConfigs = phpDockerSettingsConfigContent.project.component;
|
|
33
|
+
|
|
34
|
+
await Promise.all([
|
|
35
|
+
setupPHPDockerContainerSettingsConfig(phpDockerSettingsConfigs, ctx)
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
await buildXmlFile(phpDockerSettingsConfig.path, phpDockerSettingsConfigContent);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
module.exports = setupPhpDockerSettingsConfig;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
const { propertyKey } = require('../keys');
|
|
2
|
+
|
|
3
|
+
const PHP_DOCKER_CONTAINER_SETTINGS_COMPONENT_NAME = 'PhpDockerContainerSettings';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @param {Array} phpDockerSettingsConfigs
|
|
7
|
+
* @param {import('../../../../../typings/context').ListrContext} ctx
|
|
8
|
+
* @returns {Promise<Boolean>}
|
|
9
|
+
*/
|
|
10
|
+
const setupPHPDockerContainerSettingsConfig = async (phpDockerSettingsConfigs, ctx) => {
|
|
11
|
+
let hasChanges = false;
|
|
12
|
+
const phpDockerContainerSettingsComponent = phpDockerSettingsConfigs.find(
|
|
13
|
+
(phpDockerSettingsConfig) => phpDockerSettingsConfig[propertyKey('name')] === PHP_DOCKER_CONTAINER_SETTINGS_COMPONENT_NAME
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const defaultList = {
|
|
17
|
+
map: {
|
|
18
|
+
entry: {
|
|
19
|
+
[propertyKey('key')]: '2fbe75d5-bc8f-4adb-8e62-ddb0ccee6428',
|
|
20
|
+
value: {
|
|
21
|
+
DockerContainerSettings: {
|
|
22
|
+
option: [
|
|
23
|
+
{
|
|
24
|
+
[propertyKey('name')]: 'runCliOptions',
|
|
25
|
+
[propertyKey('value')]: ''
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
[propertyKey('name')]: 'version',
|
|
29
|
+
[propertyKey('value')]: '1'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
[propertyKey('name')]: 'volumeBindings',
|
|
33
|
+
list: {
|
|
34
|
+
DockerVolumeBindingImpl: {
|
|
35
|
+
option: [
|
|
36
|
+
{
|
|
37
|
+
[propertyKey('name')]: 'containerPath',
|
|
38
|
+
[propertyKey('value')]: ctx.config.baseConfig.containerMagentoDir
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
[propertyKey('name')]: 'hostPath',
|
|
42
|
+
[propertyKey('value')]: '$PROJECT_DIR$'
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
if (!phpDockerContainerSettingsComponent) {
|
|
56
|
+
hasChanges = true;
|
|
57
|
+
phpDockerSettingsConfigs.push({
|
|
58
|
+
[propertyKey('name')]: PHP_DOCKER_CONTAINER_SETTINGS_COMPONENT_NAME,
|
|
59
|
+
list: defaultList
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return hasChanges;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
module.exports = setupPHPDockerContainerSettingsConfig;
|
|
@@ -1,29 +1,31 @@
|
|
|
1
|
-
const
|
|
1
|
+
const { propertyKey } = require('./keys');
|
|
2
|
+
|
|
3
|
+
const xmlConfiguration = () => ({
|
|
2
4
|
'?xml': {
|
|
3
|
-
'
|
|
4
|
-
'
|
|
5
|
+
[propertyKey('version')]: '1.0',
|
|
6
|
+
[propertyKey('encoding')]: 'UTF-8'
|
|
5
7
|
},
|
|
6
8
|
project: {
|
|
7
|
-
'
|
|
9
|
+
[propertyKey('version')]: '4',
|
|
8
10
|
component: []
|
|
9
11
|
}
|
|
10
|
-
};
|
|
12
|
+
});
|
|
11
13
|
|
|
12
14
|
const setupXMLStructure = (data) => {
|
|
13
15
|
if (!data) {
|
|
14
|
-
data = xmlConfiguration;
|
|
16
|
+
data = xmlConfiguration();
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
if (data['?xml'] === undefined) {
|
|
18
|
-
data['?xml'] = xmlConfiguration['?xml'];
|
|
20
|
+
data['?xml'] = xmlConfiguration()['?xml'];
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
if (data.project === undefined) {
|
|
22
|
-
data.project = xmlConfiguration.project;
|
|
24
|
+
data.project = xmlConfiguration().project;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
if (data.project.component === undefined) {
|
|
26
|
-
data.project.component =
|
|
28
|
+
data.project.component = [];
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
if (!Array.isArray(data.project.component) && Boolean(data.project.component)) {
|
|
@@ -3,6 +3,7 @@ const fs = require('fs');
|
|
|
3
3
|
const { loadXmlFile, buildXmlFile } = require('../../../config/xml-parser');
|
|
4
4
|
const pathExists = require('../../../util/path-exists');
|
|
5
5
|
const { valueKey, nameKey } = require('./keys');
|
|
6
|
+
const { setupXMLStructure } = require('./setup-xml-structure');
|
|
6
7
|
|
|
7
8
|
const STYLELINT_CONFIGURATION_COMPONENT_NAME = 'StylelintConfiguration';
|
|
8
9
|
|
|
@@ -26,7 +27,7 @@ const setupStylelintConfig = () => ({
|
|
|
26
27
|
task: async (ctx, task) => {
|
|
27
28
|
if (await pathExists(pathToStylelintConfig)) {
|
|
28
29
|
let hasChanges = false;
|
|
29
|
-
const styleLintConfigurationData = await loadXmlFile(pathToStylelintConfig);
|
|
30
|
+
const styleLintConfigurationData = setupXMLStructure(await loadXmlFile(pathToStylelintConfig));
|
|
30
31
|
|
|
31
32
|
if (styleLintConfigurationData.project.component && !Array.isArray(styleLintConfigurationData.project.component)) {
|
|
32
33
|
hasChanges = true;
|
package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js
CHANGED
|
@@ -1,50 +1,39 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const { baseConfig } = require('../../../../config');
|
|
3
2
|
const pathExists = require('../../../../util/path-exists');
|
|
4
3
|
const { nameKey } = require('../keys');
|
|
5
4
|
const { formatPathForPHPStormConfig } = require('../xml-utils');
|
|
6
5
|
|
|
7
6
|
const COMPOSER_SETTINGS_COMPONENT_NAME = 'ComposerSettings';
|
|
8
7
|
|
|
9
|
-
const
|
|
8
|
+
const composerKey = '@_composer';
|
|
10
9
|
const doNotAskKey = '@_doNotAsk';
|
|
11
10
|
const synchronizationStateKey = '@_synchronizationState';
|
|
12
11
|
|
|
13
12
|
const composerJsonPath = path.join(process.cwd(), 'composer.json');
|
|
14
13
|
const composerJsonFormattedPath = formatPathForPHPStormConfig(composerJsonPath);
|
|
15
|
-
const composerPharPath = path.join(baseConfig.cacheDir, 'composer', 'composer.phar');
|
|
16
|
-
const composerPharFormattedPath = formatPathForPHPStormConfig(composerPharPath);
|
|
17
14
|
|
|
18
15
|
const defaultComposerSettingsProperties = {
|
|
19
16
|
[doNotAskKey]: 'true',
|
|
20
17
|
[synchronizationStateKey]: 'SYNCHRONIZE'
|
|
21
18
|
};
|
|
22
19
|
|
|
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
20
|
/**
|
|
37
21
|
* @param {Array} workspaceConfigs
|
|
22
|
+
* @param {import('../../../../../typings/context').ListrContext} ctx
|
|
38
23
|
* @returns {Promise<Boolean>}
|
|
39
24
|
*/
|
|
40
|
-
const setupComposerSettings = async (workspaceConfigs) => {
|
|
25
|
+
const setupComposerSettings = async (workspaceConfigs, ctx) => {
|
|
41
26
|
let hasChanges = false;
|
|
42
27
|
const composerSettingsComponent = workspaceConfigs.find(
|
|
43
28
|
(workspaceConfig) => workspaceConfig[nameKey] === COMPOSER_SETTINGS_COMPONENT_NAME
|
|
44
29
|
);
|
|
45
30
|
|
|
46
31
|
const isComposerJsonExists = await pathExists(composerJsonPath);
|
|
47
|
-
const
|
|
32
|
+
const { php } = ctx.config.docker.getContainers(ctx.ports);
|
|
33
|
+
const defaultInterpreterConfig = {
|
|
34
|
+
[nameKey]: ctx.debug ? php.debugImage : php.image,
|
|
35
|
+
[composerKey]: 'composer'
|
|
36
|
+
};
|
|
48
37
|
|
|
49
38
|
if (composerSettingsComponent) {
|
|
50
39
|
if (
|
|
@@ -55,17 +44,15 @@ const setupComposerSettings = async (workspaceConfigs) => {
|
|
|
55
44
|
composerSettingsComponent.pharConfigPath = composerJsonFormattedPath;
|
|
56
45
|
}
|
|
57
46
|
|
|
58
|
-
const
|
|
47
|
+
const interpreterConfig = composerSettingsComponent.execution && composerSettingsComponent.execution.interpreter;
|
|
59
48
|
|
|
60
|
-
if (
|
|
61
|
-
hasChanges = true;
|
|
62
|
-
pharConfig[pharPathKey] = composerPharFormattedPath;
|
|
63
|
-
} else if (!pharConfig && isComposerPharExists) {
|
|
49
|
+
if (!interpreterConfig) {
|
|
64
50
|
hasChanges = true;
|
|
65
51
|
composerSettingsComponent.execution = composerSettingsComponent.execution || {};
|
|
66
|
-
composerSettingsComponent.execution.
|
|
67
|
-
|
|
68
|
-
|
|
52
|
+
composerSettingsComponent.execution.interpreter = defaultInterpreterConfig;
|
|
53
|
+
} else if (interpreterConfig[nameKey] !== defaultInterpreterConfig[nameKey]) {
|
|
54
|
+
hasChanges = true;
|
|
55
|
+
composerSettingsComponent.execution.interpreter[nameKey] = defaultInterpreterConfig[nameKey];
|
|
69
56
|
}
|
|
70
57
|
} else {
|
|
71
58
|
hasChanges = true;
|
|
@@ -74,9 +61,7 @@ const setupComposerSettings = async (workspaceConfigs) => {
|
|
|
74
61
|
...defaultComposerSettingsProperties,
|
|
75
62
|
pharConfigPath: composerJsonFormattedPath,
|
|
76
63
|
execution: {
|
|
77
|
-
|
|
78
|
-
[pharPathKey]: composerPharFormattedPath
|
|
79
|
-
}
|
|
64
|
+
interpreter: defaultInterpreterConfig
|
|
80
65
|
}
|
|
81
66
|
});
|
|
82
67
|
}
|
|
@@ -3,9 +3,15 @@ const pathExists = require('../../../../util/path-exists');
|
|
|
3
3
|
const { setupXMLStructure } = require('../setup-xml-structure');
|
|
4
4
|
const setupComposerSettings = require('./composer-settings-config');
|
|
5
5
|
const setupFormatOnSave = require('./format-setting-config');
|
|
6
|
+
const setupMessDetectorProjectConfiguration = require('./mess-detector-project-configuration-config');
|
|
7
|
+
const setupPHPCodeSnifferProjectConfiguration = require('./php-code-sniffer-project-configuration-config');
|
|
8
|
+
const setupPHPCSFixerProjectConfiguration = require('./php-cs-fixer-project-configuration-config');
|
|
6
9
|
const setupPHPDebugGeneral = require('./php-debug-general-config');
|
|
7
10
|
const setupPHPServers = require('./php-server-config');
|
|
11
|
+
const setupPHPStanProjectConfiguration = require('./php-stan-project-configuration-config.js');
|
|
12
|
+
const setupPHPWorkspaceProjectConfiguration = require('./php-workspace-project-configuration-config');
|
|
8
13
|
const setupPropertiesComponent = require('./properties-component-config');
|
|
14
|
+
const setupPSalmProjectConfiguration = require('./psalm-project-configuration-config.js');
|
|
9
15
|
const setupRunManager = require('./run-manager-config');
|
|
10
16
|
const { getWorkspaceConfig } = require('./workspace-config');
|
|
11
17
|
|
|
@@ -20,8 +26,15 @@ const setupWorkspaceConfig = () => ({
|
|
|
20
26
|
const workspaceConfiguration = setupXMLStructure(await loadXmlFile(workspaceConfig.path));
|
|
21
27
|
const workspaceConfigs = workspaceConfiguration.project.component;
|
|
22
28
|
const hasChanges = await Promise.all([
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
setupMessDetectorProjectConfiguration(workspaceConfigs),
|
|
30
|
+
setupPHPCSFixerProjectConfiguration(workspaceConfigs),
|
|
31
|
+
setupPHPCodeSnifferProjectConfiguration(workspaceConfigs),
|
|
32
|
+
setupPHPStanProjectConfiguration(workspaceConfigs),
|
|
33
|
+
setupPSalmProjectConfiguration(workspaceConfigs),
|
|
34
|
+
setupPHPWorkspaceProjectConfiguration(workspaceConfigs, ctx),
|
|
35
|
+
setupPHPDebugGeneral(workspaceConfigs),
|
|
36
|
+
setupPHPServers(workspaceConfigs, workspaceConfig, ctx),
|
|
37
|
+
setupComposerSettings(workspaceConfigs, ctx),
|
|
25
38
|
setupRunManager(workspaceConfigs, workspaceConfig),
|
|
26
39
|
setupPropertiesComponent(workspaceConfigs)
|
|
27
40
|
]);
|
|
@@ -39,11 +52,17 @@ const setupWorkspaceConfig = () => ({
|
|
|
39
52
|
const workspaceConfigs = workspaceConfiguration.project.component;
|
|
40
53
|
|
|
41
54
|
await Promise.all([
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
setupMessDetectorProjectConfiguration(workspaceConfigs),
|
|
56
|
+
setupPHPCSFixerProjectConfiguration(workspaceConfigs),
|
|
57
|
+
setupPHPCodeSnifferProjectConfiguration(workspaceConfigs),
|
|
58
|
+
setupPHPStanProjectConfiguration(workspaceConfigs),
|
|
59
|
+
setupPSalmProjectConfiguration(workspaceConfigs),
|
|
60
|
+
setupPHPDebugGeneral(workspaceConfigs),
|
|
61
|
+
setupPHPServers(workspaceConfigs, workspaceConfig, ctx),
|
|
62
|
+
setupPHPWorkspaceProjectConfiguration(workspaceConfigs, ctx),
|
|
44
63
|
setupRunManager(workspaceConfigs, workspaceConfig),
|
|
45
64
|
setupPropertiesComponent(workspaceConfigs),
|
|
46
|
-
setupComposerSettings(workspaceConfigs),
|
|
65
|
+
setupComposerSettings(workspaceConfigs, ctx),
|
|
47
66
|
setupFormatOnSave(workspaceConfigs)
|
|
48
67
|
]);
|
|
49
68
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const { nameKey, valueKey } = require('../keys');
|
|
2
|
+
|
|
3
|
+
const MESS_DETECTOR_PROJECT_CONFIGURATION_COMPONENT_NAME = 'MessDetectorProjectConfiguration';
|
|
4
|
+
|
|
5
|
+
const selectedConfigurationIdName = 'selectedConfigurationId';
|
|
6
|
+
const value = 'DEFAULT_INTERPRETER';
|
|
7
|
+
|
|
8
|
+
const defaultOption = {
|
|
9
|
+
[nameKey]: selectedConfigurationIdName,
|
|
10
|
+
[valueKey]: value
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {Array} workspaceConfigs
|
|
15
|
+
* @returns {Promise<Boolean>}
|
|
16
|
+
*/
|
|
17
|
+
const setupMessDetectorProjectConfiguration = async (workspaceConfigs) => {
|
|
18
|
+
let hasChanges = false;
|
|
19
|
+
const messDetectorProjectConfigurationComponent = workspaceConfigs.find(
|
|
20
|
+
(workspaceConfig) => workspaceConfig[nameKey] === MESS_DETECTOR_PROJECT_CONFIGURATION_COMPONENT_NAME
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
if (messDetectorProjectConfigurationComponent) {
|
|
24
|
+
if (messDetectorProjectConfigurationComponent.option && !Array.isArray(messDetectorProjectConfigurationComponent.option)) {
|
|
25
|
+
hasChanges = true;
|
|
26
|
+
messDetectorProjectConfigurationComponent.option = [messDetectorProjectConfigurationComponent.option];
|
|
27
|
+
} else if (!messDetectorProjectConfigurationComponent.option) {
|
|
28
|
+
hasChanges = true;
|
|
29
|
+
messDetectorProjectConfigurationComponent.option = [];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (
|
|
33
|
+
messDetectorProjectConfigurationComponent.option.length > 0
|
|
34
|
+
&& !messDetectorProjectConfigurationComponent.option.some((option) => option[nameKey] === selectedConfigurationIdName)
|
|
35
|
+
) {
|
|
36
|
+
messDetectorProjectConfigurationComponent.option = [defaultOption];
|
|
37
|
+
hasChanges = true;
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
hasChanges = true;
|
|
41
|
+
workspaceConfigs.push({
|
|
42
|
+
[nameKey]: MESS_DETECTOR_PROJECT_CONFIGURATION_COMPONENT_NAME,
|
|
43
|
+
option: [defaultOption]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return hasChanges;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
module.exports = setupMessDetectorProjectConfiguration;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const { nameKey, valueKey } = require('../keys');
|
|
2
|
+
|
|
3
|
+
const PHP_CODE_SNIFFER_PROJECT_CONFIGURATION_COMPONENT_NAME = 'PHPCodeSnifferProjectConfiguration';
|
|
4
|
+
|
|
5
|
+
const selectedConfigurationIdName = 'selectedConfigurationId';
|
|
6
|
+
const value = 'DEFAULT_INTERPRETER';
|
|
7
|
+
|
|
8
|
+
const defaultOption = {
|
|
9
|
+
[nameKey]: selectedConfigurationIdName,
|
|
10
|
+
[valueKey]: value
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {Array} workspaceConfigs
|
|
15
|
+
* @returns {Promise<Boolean>}
|
|
16
|
+
*/
|
|
17
|
+
const setupPHPCodeSnifferProjectConfiguration = async (workspaceConfigs) => {
|
|
18
|
+
let hasChanges = false;
|
|
19
|
+
const phpCodeSnifferProjectConfigurationComponent = workspaceConfigs.find(
|
|
20
|
+
(workspaceConfig) => workspaceConfig[nameKey] === PHP_CODE_SNIFFER_PROJECT_CONFIGURATION_COMPONENT_NAME
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
if (phpCodeSnifferProjectConfigurationComponent) {
|
|
24
|
+
if (phpCodeSnifferProjectConfigurationComponent.option && !Array.isArray(phpCodeSnifferProjectConfigurationComponent.option)) {
|
|
25
|
+
hasChanges = true;
|
|
26
|
+
phpCodeSnifferProjectConfigurationComponent.option = [phpCodeSnifferProjectConfigurationComponent.option];
|
|
27
|
+
} else if (!phpCodeSnifferProjectConfigurationComponent.option) {
|
|
28
|
+
hasChanges = true;
|
|
29
|
+
phpCodeSnifferProjectConfigurationComponent.option = [];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (
|
|
33
|
+
phpCodeSnifferProjectConfigurationComponent.option.length > 0
|
|
34
|
+
&& !phpCodeSnifferProjectConfigurationComponent.option.some((option) => option[nameKey] === selectedConfigurationIdName)
|
|
35
|
+
) {
|
|
36
|
+
phpCodeSnifferProjectConfigurationComponent.option = [defaultOption];
|
|
37
|
+
hasChanges = true;
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
hasChanges = true;
|
|
41
|
+
workspaceConfigs.push({
|
|
42
|
+
[nameKey]: PHP_CODE_SNIFFER_PROJECT_CONFIGURATION_COMPONENT_NAME,
|
|
43
|
+
option: [defaultOption]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return hasChanges;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
module.exports = setupPHPCodeSnifferProjectConfiguration;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const { nameKey, valueKey } = require('../keys');
|
|
2
|
+
|
|
3
|
+
const PHP_CS_FIXER_PROJECT_CONFIGURATION_COMPONENT_NAME = 'PHPCSFixerProjectConfiguration';
|
|
4
|
+
|
|
5
|
+
const selectedConfigurationIdName = 'selectedConfigurationId';
|
|
6
|
+
const value = 'DEFAULT_INTERPRETER';
|
|
7
|
+
|
|
8
|
+
const defaultOption = {
|
|
9
|
+
[nameKey]: selectedConfigurationIdName,
|
|
10
|
+
[valueKey]: value
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {Array} workspaceConfigs
|
|
15
|
+
* @returns {Promise<Boolean>}
|
|
16
|
+
*/
|
|
17
|
+
const setupPHPCSFixerProjectConfiguration = async (workspaceConfigs) => {
|
|
18
|
+
let hasChanges = false;
|
|
19
|
+
const phpCSFixeProjectConfigurationComponent = workspaceConfigs.find(
|
|
20
|
+
(workspaceConfig) => workspaceConfig[nameKey] === PHP_CS_FIXER_PROJECT_CONFIGURATION_COMPONENT_NAME
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
if (phpCSFixeProjectConfigurationComponent) {
|
|
24
|
+
if (phpCSFixeProjectConfigurationComponent.option && !Array.isArray(phpCSFixeProjectConfigurationComponent.option)) {
|
|
25
|
+
hasChanges = true;
|
|
26
|
+
phpCSFixeProjectConfigurationComponent.option = [phpCSFixeProjectConfigurationComponent.option];
|
|
27
|
+
} else if (!phpCSFixeProjectConfigurationComponent.option) {
|
|
28
|
+
hasChanges = true;
|
|
29
|
+
phpCSFixeProjectConfigurationComponent.option = [];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (
|
|
33
|
+
phpCSFixeProjectConfigurationComponent.option.length > 0
|
|
34
|
+
&& !phpCSFixeProjectConfigurationComponent.option.some((option) => option[nameKey] === selectedConfigurationIdName)
|
|
35
|
+
) {
|
|
36
|
+
phpCSFixeProjectConfigurationComponent.option = [defaultOption];
|
|
37
|
+
hasChanges = true;
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
hasChanges = true;
|
|
41
|
+
workspaceConfigs.push({
|
|
42
|
+
[nameKey]: PHP_CS_FIXER_PROJECT_CONFIGURATION_COMPONENT_NAME,
|
|
43
|
+
option: [defaultOption]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return hasChanges;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
module.exports = setupPHPCSFixerProjectConfiguration;
|