@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,249 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
const { loadXmlFile, buildXmlFile } = require('../../../config/xml-parser');
|
|
3
|
+
const UnknownError = require('../../../errors/unknown-error');
|
|
4
|
+
const pathExists = require('../../../util/path-exists');
|
|
5
|
+
const setConfigFile = require('../../../util/set-config');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Get link to data-source field, create fields if necessary
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} data
|
|
11
|
+
* @param {Object} defaultData Default data structure that will be used if original data is missing
|
|
12
|
+
*/
|
|
13
|
+
const getToDataSource = (data, defaultData) => {
|
|
14
|
+
if (!data.project) {
|
|
15
|
+
data.project = defaultData.project;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (!data.project.component) {
|
|
19
|
+
data.project.component = defaultData.project.component;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!data.project.component['data-source']) {
|
|
23
|
+
data.project.component['data-source'] = defaultData.project.component['data-source'];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return data.project.component['data-source'];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
31
|
+
*/
|
|
32
|
+
const setupDataSourceLocalConfig = () => ({
|
|
33
|
+
title: 'Set up datasource local configuration',
|
|
34
|
+
task: async (ctx, task) => {
|
|
35
|
+
const {
|
|
36
|
+
config: {
|
|
37
|
+
phpStorm,
|
|
38
|
+
phpStorm: {
|
|
39
|
+
database
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
} = ctx;
|
|
43
|
+
|
|
44
|
+
if (await pathExists(database.dataSourcesLocal.path)) {
|
|
45
|
+
let hasChanges = false;
|
|
46
|
+
const dataSourcesLocalData = await loadXmlFile(database.dataSourcesLocal.path);
|
|
47
|
+
const dataSource = getToDataSource(
|
|
48
|
+
dataSourcesLocalData,
|
|
49
|
+
{
|
|
50
|
+
project: {
|
|
51
|
+
'@_version': '4',
|
|
52
|
+
component: {
|
|
53
|
+
'@_name': 'dataSourceStorageLocal',
|
|
54
|
+
'@_created-in': 'PS-212.5284.49',
|
|
55
|
+
'data-source': {
|
|
56
|
+
'@_uuid': 'a2eadb3c-6fc9-4d85-b5f4-d8114906ce2f'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
if (!dataSource['@_name']) {
|
|
64
|
+
hasChanges = true;
|
|
65
|
+
dataSource['@_name'] = database.dataSourceManagerName;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!dataSource['@_uuid']) {
|
|
69
|
+
hasChanges = true;
|
|
70
|
+
dataSource['@_uuid'] = 'a2eadb3c-6fc9-4d85-b5f4-d8114906ce2f';
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const defaultDatabaseInfoConfig = {
|
|
74
|
+
'@_product': '',
|
|
75
|
+
'@_version': '',
|
|
76
|
+
'@_jdbc-version': '',
|
|
77
|
+
'@_driver-name': '',
|
|
78
|
+
'@_driver-version': '',
|
|
79
|
+
'@_dbms': 'MYSQL',
|
|
80
|
+
'@_exact-version': '0'
|
|
81
|
+
};
|
|
82
|
+
const isDatabaseInfoChangeNeeded = dataSource['database-info']
|
|
83
|
+
? Object.entries(defaultDatabaseInfoConfig)
|
|
84
|
+
.some(([key]) => !(key in dataSource['database-info']))
|
|
85
|
+
: true;
|
|
86
|
+
|
|
87
|
+
if (isDatabaseInfoChangeNeeded) {
|
|
88
|
+
hasChanges = true;
|
|
89
|
+
if (!dataSource['database-info']) {
|
|
90
|
+
dataSource['database-info'] = defaultDatabaseInfoConfig;
|
|
91
|
+
} else {
|
|
92
|
+
Object.entries(defaultDatabaseInfoConfig).forEach(([key, value]) => {
|
|
93
|
+
if (!(key in dataSource['database-info'])) {
|
|
94
|
+
dataSource['database-info'][key] = value;
|
|
95
|
+
}
|
|
96
|
+
// ^^^ only set missing properties, only ones should be in place
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const dataSourceDefaultData = {
|
|
102
|
+
'secret-storage': 'master_key',
|
|
103
|
+
'user-name': 'magento'
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const isDataSourceDataChangeNeeded = dataSource
|
|
107
|
+
? Object.entries(dataSourceDefaultData)
|
|
108
|
+
.some(([key, value]) => dataSource[key] !== value)
|
|
109
|
+
: true;
|
|
110
|
+
|
|
111
|
+
if (isDataSourceDataChangeNeeded) {
|
|
112
|
+
hasChanges = true;
|
|
113
|
+
Object.entries(dataSourceDefaultData).forEach(([key, value]) => {
|
|
114
|
+
dataSource[key] = value;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (!('schema-mapping' in dataSource)) {
|
|
119
|
+
hasChanges = true;
|
|
120
|
+
dataSource['schema-mapping'] = '';
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (hasChanges) {
|
|
124
|
+
await buildXmlFile(database.dataSourcesLocal.path, dataSourcesLocalData);
|
|
125
|
+
} else {
|
|
126
|
+
task.skip();
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
try {
|
|
130
|
+
await setConfigFile({
|
|
131
|
+
configPathname: phpStorm.database.dataSourcesLocal.path,
|
|
132
|
+
template: phpStorm.database.dataSourcesLocal.templatePath,
|
|
133
|
+
overwrite: true,
|
|
134
|
+
templateArgs: {
|
|
135
|
+
phpStorm
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
} catch (e) {
|
|
139
|
+
throw new UnknownError(`Unexpected error accrued during dataSources.local.xml config creation\n\n${e}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
147
|
+
*/
|
|
148
|
+
const setupDataSourceConfig = () => ({
|
|
149
|
+
task: async (ctx, task) => {
|
|
150
|
+
const {
|
|
151
|
+
config: {
|
|
152
|
+
phpStorm,
|
|
153
|
+
phpStorm: {
|
|
154
|
+
database
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
ports
|
|
158
|
+
} = ctx;
|
|
159
|
+
const jdbcUrl = `jdbc:mysql://localhost:${ports.mysql}/magento`;
|
|
160
|
+
|
|
161
|
+
if (await pathExists(database.dataSources.path)) {
|
|
162
|
+
let hasChanges = false;
|
|
163
|
+
const dataSourcesData = await loadXmlFile(database.dataSources.path);
|
|
164
|
+
const dataSource = getToDataSource(
|
|
165
|
+
dataSourcesData,
|
|
166
|
+
{
|
|
167
|
+
project: {
|
|
168
|
+
'@_version': '4',
|
|
169
|
+
component: {
|
|
170
|
+
'@_name': 'DataSourceManagerImpl',
|
|
171
|
+
'@_format': 'xml',
|
|
172
|
+
'@_multifile-model': true,
|
|
173
|
+
'data-source': {
|
|
174
|
+
'@_source': 'LOCAL',
|
|
175
|
+
'@_uuid': 'a2eadb3c-6fc9-4d85-b5f4-d8114906ce2f'
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
if (dataSource['@_uuid'] === undefined) {
|
|
183
|
+
hasChanges = true;
|
|
184
|
+
dataSource['@_uuid'] = 'a2eadb3c-6fc9-4d85-b5f4-d8114906ce2f';
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const expectedDataSourceData = {
|
|
188
|
+
'@_name': database.dataSourceManagerName,
|
|
189
|
+
'driver-ref': 'mysql.8',
|
|
190
|
+
synchronize: true,
|
|
191
|
+
'jdbc-driver': 'com.mysql.cj.jdbc.Driver',
|
|
192
|
+
'jdbc-url': jdbcUrl,
|
|
193
|
+
'working-dir': '$ProjectFileDir$',
|
|
194
|
+
'@_source': 'LOCAL'
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const isDataSourceNeedChanges = dataSource
|
|
198
|
+
? Object.entries(expectedDataSourceData)
|
|
199
|
+
.some(([key]) => !(key in dataSource))
|
|
200
|
+
: true;
|
|
201
|
+
|
|
202
|
+
if (isDataSourceNeedChanges) {
|
|
203
|
+
hasChanges = true;
|
|
204
|
+
if (!dataSource) {
|
|
205
|
+
dataSourcesData.project.component['data-source'] = expectedDataSourceData;
|
|
206
|
+
} else {
|
|
207
|
+
Object.entries(expectedDataSourceData).forEach(([key, value]) => {
|
|
208
|
+
if (!(key in dataSource)) {
|
|
209
|
+
dataSource[key] = value;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (hasChanges) {
|
|
216
|
+
await buildXmlFile(database.dataSources.path, dataSourcesData);
|
|
217
|
+
} else {
|
|
218
|
+
task.skip();
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
try {
|
|
222
|
+
await setConfigFile({
|
|
223
|
+
configPathname: phpStorm.database.dataSources.path,
|
|
224
|
+
template: phpStorm.database.dataSources.templatePath,
|
|
225
|
+
overwrite: true,
|
|
226
|
+
templateArgs: {
|
|
227
|
+
phpStorm,
|
|
228
|
+
jdbcUrl
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
} catch (e) {
|
|
232
|
+
throw new UnknownError(`Unexpected error accrued during dataSources.xml config creation\n\n${e}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
240
|
+
*/
|
|
241
|
+
const setupDatabaseConfig = () => ({
|
|
242
|
+
title: 'Set up database configuration',
|
|
243
|
+
task: (ctx, task) => task.newListr([
|
|
244
|
+
setupDataSourceLocalConfig(),
|
|
245
|
+
setupDataSourceConfig()
|
|
246
|
+
])
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
module.exports = setupDatabaseConfig;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { loadXmlFile, buildXmlFile } = require('../../../config/xml-parser');
|
|
3
|
+
const pathExists = require('../../../util/path-exists');
|
|
4
|
+
const { valueKey, nameKey } = require('./keys');
|
|
5
|
+
const { getCSAThemes } = require('../../../util/CSA-theme');
|
|
6
|
+
const { formatPathForPHPStormConfig } = require('./xml-utils');
|
|
7
|
+
|
|
8
|
+
const ESLINT_COMPONENT_NAME = 'EslintConfiguration';
|
|
9
|
+
|
|
10
|
+
const pathToESLintConfig = path.join(process.cwd(), '.idea', 'jsLinters', 'eslint.xml');
|
|
11
|
+
|
|
12
|
+
const defaultESLintComponentConfiguration = {
|
|
13
|
+
[nameKey]: ESLINT_COMPONENT_NAME,
|
|
14
|
+
option: {
|
|
15
|
+
[nameKey]: 'fix-on-save',
|
|
16
|
+
[valueKey]: 'true'
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
22
|
+
*/
|
|
23
|
+
const setupESLintConfig = () => ({
|
|
24
|
+
title: 'Set up ESLint configuration',
|
|
25
|
+
task: async (ctx, task) => {
|
|
26
|
+
if (await pathExists(pathToESLintConfig)) {
|
|
27
|
+
let hasChanges = false;
|
|
28
|
+
const esLintConfigurationData = await loadXmlFile(pathToESLintConfig);
|
|
29
|
+
|
|
30
|
+
if (esLintConfigurationData.project.component && !Array.isArray(esLintConfigurationData.project.component)) {
|
|
31
|
+
hasChanges = true;
|
|
32
|
+
esLintConfigurationData.project.component = [esLintConfigurationData.project.component];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const esLintConfigurationComponent = esLintConfigurationData.project.component.find(
|
|
36
|
+
(config) => config[nameKey] === ESLINT_COMPONENT_NAME
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (!esLintConfigurationComponent) {
|
|
40
|
+
hasChanges = true;
|
|
41
|
+
esLintConfigurationData.project.component.push(defaultESLintComponentConfiguration);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (hasChanges) {
|
|
45
|
+
await buildXmlFile(pathToESLintConfig, esLintConfigurationData);
|
|
46
|
+
} else {
|
|
47
|
+
task.skip();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const styleLintConfigurationData = {
|
|
54
|
+
'?xml': {
|
|
55
|
+
'@_version': '1.0',
|
|
56
|
+
'@_encoding': 'UTF-8'
|
|
57
|
+
},
|
|
58
|
+
project: {
|
|
59
|
+
'@_version': '4',
|
|
60
|
+
component: defaultESLintComponentConfiguration
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const themes = await getCSAThemes();
|
|
64
|
+
|
|
65
|
+
if (themes.length > 0) {
|
|
66
|
+
const theme = themes[0];
|
|
67
|
+
if (await pathExists(theme.themePath)) {
|
|
68
|
+
styleLintConfigurationData.project.component['work-dir-pattern'] = {
|
|
69
|
+
[valueKey]: formatPathForPHPStormConfig(theme.themePath)
|
|
70
|
+
};
|
|
71
|
+
const packageJsonPath = path.join(process.cwd(), theme.themePath, 'package.json');
|
|
72
|
+
if (await pathExists(packageJsonPath)) {
|
|
73
|
+
styleLintConfigurationData.project.component['custom-configuration-file'] = {
|
|
74
|
+
'@_used': 'true',
|
|
75
|
+
'@_path': formatPathForPHPStormConfig(packageJsonPath)
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
await buildXmlFile(pathToESLintConfig, styleLintConfigurationData);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
module.exports = setupESLintConfig;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { loadXmlFile, buildXmlFile } = require('../../../config/xml-parser');
|
|
3
|
+
const pathExists = require('../../../util/path-exists');
|
|
4
|
+
const { formatPathForPHPStormConfig } = require('./xml-utils');
|
|
5
|
+
|
|
6
|
+
const pathToModulesConfig = path.join(process.cwd(), '.idea', 'modules.xml');
|
|
7
|
+
const excludeFoldersPaths = [
|
|
8
|
+
'bin',
|
|
9
|
+
'dev',
|
|
10
|
+
'pub',
|
|
11
|
+
'setup',
|
|
12
|
+
'var/cache',
|
|
13
|
+
'var/page_cache',
|
|
14
|
+
'var/log'
|
|
15
|
+
].map((p) => `file://$MODULE_DIR$/${p}`);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Will retrieve project config file path from module.xml
|
|
19
|
+
*
|
|
20
|
+
* @returns {Promise<String>}
|
|
21
|
+
*/
|
|
22
|
+
const getProjectConfigFilePath = async () => {
|
|
23
|
+
const modulesConfigData = await loadXmlFile(pathToModulesConfig);
|
|
24
|
+
return modulesConfigData.project.component.modules.module['@_filepath'].replace('$PROJECT_DIR$', process.cwd());
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @returns {Array<{'@_url': string}>}
|
|
29
|
+
*/
|
|
30
|
+
const getExcludedFoldersConfig = (projectConfigData) => {
|
|
31
|
+
if (!projectConfigData.module) {
|
|
32
|
+
projectConfigData.module = {
|
|
33
|
+
'@_type': 'WEB_MODULE',
|
|
34
|
+
'@_version': '4'
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!projectConfigData.module.component) {
|
|
39
|
+
projectConfigData.module.component = {
|
|
40
|
+
'@_name': 'NewModuleRootManager',
|
|
41
|
+
orderEntry: [
|
|
42
|
+
{
|
|
43
|
+
'@_type': 'inheritedJdk'
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
'@_type': 'sourceFolder',
|
|
47
|
+
'@_forTest': 'false'
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!projectConfigData.module.component.content) {
|
|
54
|
+
projectConfigData.module.component.content = {
|
|
55
|
+
'@_url': 'file://$MODULE_DIR$'
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!projectConfigData.module.component.content.excludeFolder) {
|
|
60
|
+
projectConfigData.module.component.content.excludeFolder = [];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return projectConfigData
|
|
64
|
+
.module.component.content.excludeFolder;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const setupExcludedFolders = (excludedFoldersConfig) => {
|
|
68
|
+
let hasChanges = false;
|
|
69
|
+
// filter excluded folders to get ones that needs to be added to excluded folders list
|
|
70
|
+
const missingExcludedFolders = excludeFoldersPaths
|
|
71
|
+
.filter(
|
|
72
|
+
(excludeFoldersPath) => !excludedFoldersConfig.some(
|
|
73
|
+
(config) => config['@_url'] === excludeFoldersPath
|
|
74
|
+
)
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
if (missingExcludedFolders.length > 0) {
|
|
78
|
+
hasChanges = true;
|
|
79
|
+
missingExcludedFolders.forEach((missingExcludedFolder) => {
|
|
80
|
+
excludedFoldersConfig.unshift({
|
|
81
|
+
'@_url': missingExcludedFolder
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return hasChanges;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const createModulesXML = async () => {
|
|
90
|
+
const filePath = path.join(process.cwd(), '.idea', `${path.parse(process.cwd()).base}.iml`);
|
|
91
|
+
const fileFormattedPath = formatPathForPHPStormConfig(filePath);
|
|
92
|
+
const fileFormattedUrl = `file://${fileFormattedPath}`;
|
|
93
|
+
|
|
94
|
+
const modulesConfig = {
|
|
95
|
+
'?xml': {
|
|
96
|
+
'@_version': '1.0',
|
|
97
|
+
'@_encoding': 'UTF-8'
|
|
98
|
+
},
|
|
99
|
+
project: {
|
|
100
|
+
'@_version': '4',
|
|
101
|
+
component: {
|
|
102
|
+
'@_name': 'ProjectModuleManager',
|
|
103
|
+
modules: [
|
|
104
|
+
{
|
|
105
|
+
module: {
|
|
106
|
+
'@_fileurl': fileFormattedUrl,
|
|
107
|
+
'@_filepath': fileFormattedPath
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
await buildXmlFile(pathToModulesConfig, modulesConfig);
|
|
116
|
+
|
|
117
|
+
return filePath;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
122
|
+
*/
|
|
123
|
+
const setupExcludedFoldersConfig = () => ({
|
|
124
|
+
title: 'Set up excluded folders configuration',
|
|
125
|
+
task: async (ctx, task) => {
|
|
126
|
+
if (await pathExists(pathToModulesConfig)) {
|
|
127
|
+
const projectFilePath = await getProjectConfigFilePath();
|
|
128
|
+
const projectConfigData = await loadXmlFile(projectFilePath);
|
|
129
|
+
const excludedFoldersConfig = getExcludedFoldersConfig(projectConfigData);
|
|
130
|
+
const hasChanges = setupExcludedFolders(excludedFoldersConfig);
|
|
131
|
+
if (hasChanges) {
|
|
132
|
+
await buildXmlFile(projectFilePath, projectConfigData);
|
|
133
|
+
} else {
|
|
134
|
+
task.skip();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const projectFilePath = await createModulesXML();
|
|
141
|
+
const projectConfigData = {
|
|
142
|
+
'?xml': {
|
|
143
|
+
'@_version': '1.0',
|
|
144
|
+
'@_encoding': 'UTF-8'
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
const excludedFoldersConfig = getExcludedFoldersConfig(projectConfigData);
|
|
148
|
+
setupExcludedFolders(excludedFoldersConfig);
|
|
149
|
+
|
|
150
|
+
await buildXmlFile(projectFilePath, projectConfigData);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
module.exports = setupExcludedFoldersConfig;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const setupWorkspaceConfig = require('./workspace-config');
|
|
2
|
+
const setupPhpConfig = require('./php-config');
|
|
3
|
+
const setupDatabaseConfig = require('./database-config');
|
|
4
|
+
const setupInspectionToolsConfig = require('./inspection-tools-config');
|
|
5
|
+
const setupExcludedFoldersConfig = require('./exclude-folder-config');
|
|
6
|
+
const setupStylelintConfig = require('./stylelint-config');
|
|
7
|
+
const setupESLintConfig = require('./eslint-config');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
11
|
+
*/
|
|
12
|
+
const createPhpStormConfig = () => ({
|
|
13
|
+
title: 'Setting PHPStorm config',
|
|
14
|
+
task: (ctx, task) => task.newListr([
|
|
15
|
+
setupWorkspaceConfig(),
|
|
16
|
+
setupPhpConfig(),
|
|
17
|
+
setupDatabaseConfig(),
|
|
18
|
+
setupInspectionToolsConfig(),
|
|
19
|
+
setupExcludedFoldersConfig(),
|
|
20
|
+
setupStylelintConfig(),
|
|
21
|
+
setupESLintConfig()
|
|
22
|
+
], {
|
|
23
|
+
concurrent: true
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
module.exports = createPhpStormConfig;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const { nameKey, valueKey } = require('../keys');
|
|
2
|
+
const {
|
|
3
|
+
options: {
|
|
4
|
+
CODING_STANDARD_OPTION_NAME,
|
|
5
|
+
CUSTOM_CODING_STANDARD_OPTION_VALUE
|
|
6
|
+
}
|
|
7
|
+
} = require('./config');
|
|
8
|
+
|
|
9
|
+
const setupCodingStandardOption = 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]: CUSTOM_CODING_STANDARD_OPTION_VALUE
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return hasChanges;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
module.exports = setupCodingStandardOption;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// inspection tool classes
|
|
2
|
+
const PHP_CS_FIXER_VALIDATION_INSPECTION = 'PhpCSFixerValidationInspection';
|
|
3
|
+
const PHP_CS_VALIDATION_INSPECTION = 'PhpCSValidationInspection';
|
|
4
|
+
const STYLELINT_INSPECTION = 'Stylelint';
|
|
5
|
+
const ESLINT_INSPECTION = 'Eslint';
|
|
6
|
+
const MESS_DETECTOR_VALIDATION_INSPECTION = 'MessDetectorValidationInspection';
|
|
7
|
+
|
|
8
|
+
// options
|
|
9
|
+
const CODING_STANDARD_OPTION_NAME = 'CODING_STANDARD';
|
|
10
|
+
const CUSTOM_CODING_STANDARD_OPTION_VALUE = 'Custom';
|
|
11
|
+
const CUSTOM_RULE_SET_PATH_OPTION_NAME = 'CUSTOM_RULESET_PATH';
|
|
12
|
+
const MAGENTO2_CODING_STANDARD_OPTION_VALUE = 'Magento2';
|
|
13
|
+
const EXTENSIONS_OPTION_NAME = 'EXTENSIONS';
|
|
14
|
+
const WARNING_HIGHLIGHT_LEVEL_NAME_OPTION_NAME = 'WARNING_HIGHLIGHT_LEVEL_NAME';
|
|
15
|
+
const WARNING_HIGHLIGHT_LEVEL_NAME_OPTION_VALUE = 'ERROR';
|
|
16
|
+
const SHOW_SNIFF_NAMES_OPTION_NAME = 'SHOW_SNIFF_NAMES';
|
|
17
|
+
const USE_INSTALLED_PATHS_OPTION_NAME = 'USE_INSTALLED_PATHS';
|
|
18
|
+
const INSTALLED_PATHS_OPTION_NAME = 'INSTALLED_PATHS';
|
|
19
|
+
const CODESIZE_OPTION_NAME = 'CODESIZE';
|
|
20
|
+
const CONTROVERSIAL_OPTION_NAME = 'CONTROVERSIAL';
|
|
21
|
+
const DESIGN_OPTION_NAME = 'DESIGN';
|
|
22
|
+
const UNUSED_CODE_OPTION_NAME = 'UNUSEDCODE';
|
|
23
|
+
const NAMING_OPTION_NAME = 'NAMING';
|
|
24
|
+
const CUSTOM_RULESETS_OPTION_NAME = 'customRulesets';
|
|
25
|
+
const PHP_MD_RULESET_OPTION_VALUE = 'Magento PHPMD rule set';
|
|
26
|
+
|
|
27
|
+
module.exports = {
|
|
28
|
+
options: {
|
|
29
|
+
CODESIZE_OPTION_NAME,
|
|
30
|
+
CONTROVERSIAL_OPTION_NAME,
|
|
31
|
+
DESIGN_OPTION_NAME,
|
|
32
|
+
UNUSED_CODE_OPTION_NAME,
|
|
33
|
+
NAMING_OPTION_NAME,
|
|
34
|
+
CUSTOM_RULESETS_OPTION_NAME,
|
|
35
|
+
PHP_MD_RULESET_OPTION_VALUE,
|
|
36
|
+
CODING_STANDARD_OPTION_NAME,
|
|
37
|
+
CUSTOM_CODING_STANDARD_OPTION_VALUE,
|
|
38
|
+
CUSTOM_RULE_SET_PATH_OPTION_NAME,
|
|
39
|
+
MAGENTO2_CODING_STANDARD_OPTION_VALUE,
|
|
40
|
+
EXTENSIONS_OPTION_NAME,
|
|
41
|
+
WARNING_HIGHLIGHT_LEVEL_NAME_OPTION_NAME,
|
|
42
|
+
WARNING_HIGHLIGHT_LEVEL_NAME_OPTION_VALUE,
|
|
43
|
+
SHOW_SNIFF_NAMES_OPTION_NAME,
|
|
44
|
+
USE_INSTALLED_PATHS_OPTION_NAME,
|
|
45
|
+
INSTALLED_PATHS_OPTION_NAME
|
|
46
|
+
},
|
|
47
|
+
classes: {
|
|
48
|
+
PHP_CS_FIXER_VALIDATION_INSPECTION,
|
|
49
|
+
PHP_CS_VALIDATION_INSPECTION,
|
|
50
|
+
STYLELINT_INSPECTION,
|
|
51
|
+
ESLINT_INSPECTION,
|
|
52
|
+
MESS_DETECTOR_VALIDATION_INSPECTION
|
|
53
|
+
}
|
|
54
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const pathExists = require('../../../../util/path-exists');
|
|
2
|
+
const { phpCSConfigurationPath, phpCSConfigFormattedPath } = require('./paths');
|
|
3
|
+
const { nameKey, valueKey } = require('../keys');
|
|
4
|
+
const {
|
|
5
|
+
options: {
|
|
6
|
+
CUSTOM_RULE_SET_PATH_OPTION_NAME
|
|
7
|
+
}
|
|
8
|
+
} = require('./config');
|
|
9
|
+
|
|
10
|
+
const setupCustomRuleSetPathOption = async (config) => {
|
|
11
|
+
let hasChanges = false;
|
|
12
|
+
const customRuleSetPathOption = config.option.find(
|
|
13
|
+
(option) => option[nameKey] === CUSTOM_RULE_SET_PATH_OPTION_NAME
|
|
14
|
+
);
|
|
15
|
+
const phpCSConfigExists = await pathExists(phpCSConfigurationPath);
|
|
16
|
+
|
|
17
|
+
if (!customRuleSetPathOption && phpCSConfigExists) {
|
|
18
|
+
hasChanges = true;
|
|
19
|
+
config.option.push({
|
|
20
|
+
[nameKey]: CUSTOM_RULE_SET_PATH_OPTION_NAME,
|
|
21
|
+
[valueKey]: phpCSConfigFormattedPath
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return hasChanges;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
module.exports = setupCustomRuleSetPathOption;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
const properties = {
|
|
3
|
+
enabled: 'true',
|
|
4
|
+
enabled_by_default: 'true',
|
|
5
|
+
level: 'ERROR'
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {Object} inspectionTool
|
|
10
|
+
* @param {{
|
|
11
|
+
* enabled: 'true' | 'false',
|
|
12
|
+
* enabled_by_default: 'true' | 'false',
|
|
13
|
+
* level: 'ERROR' | 'WEAK WARNING'
|
|
14
|
+
* }} defaultProperties
|
|
15
|
+
* @returns {Boolean}
|
|
16
|
+
*/
|
|
17
|
+
const setupDefaultProperties = (inspectionTool, defaultProperties = properties) => {
|
|
18
|
+
let hasChanges = false;
|
|
19
|
+
if (!inspectionTool['@_enabled']) {
|
|
20
|
+
hasChanges = true;
|
|
21
|
+
inspectionTool['@_enabled'] = defaultProperties.enabled;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!inspectionTool['@_enabled_by_default']) {
|
|
25
|
+
hasChanges = true;
|
|
26
|
+
inspectionTool['@_enabled_by_default'] = defaultProperties.enabled_by_default;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (!inspectionTool['@_level']) {
|
|
30
|
+
hasChanges = true;
|
|
31
|
+
inspectionTool['@_level'] = defaultProperties.level;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (inspectionTool.option && !Array.isArray(inspectionTool.option)) {
|
|
35
|
+
hasChanges = true;
|
|
36
|
+
inspectionTool.option = [inspectionTool.option];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return hasChanges;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
module.exports = setupDefaultProperties;
|