@scandipwa/magento-scripts 1.14.0 → 1.14.1-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/config/templates/php-fpm.template.conf +1 -0
- package/lib/config/versions/magento-2.3.7-p2.js +47 -0
- package/lib/config/versions/magento-2.3.7-p3.js +47 -0
- package/lib/config/versions/magento-2.4.3-p2.js +51 -0
- package/lib/config/versions/magento-2.4.4.js +51 -0
- package/lib/config/xml-parser.js +61 -0
- package/lib/tasks/file-system/create-phpstorm-config/database-config.js +248 -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 +29 -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 +31 -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 +29 -0
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +145 -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 +119 -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 +57 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +76 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +63 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +69 -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 +98 -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 +60 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +51 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +74 -0
- package/lib/tasks/file-system/create-phpstorm-config/xml-utils.js +5 -0
- package/lib/tasks/file-system/index.js +1 -1
- package/lib/tasks/start.js +6 -2
- package/lib/util/instance-metadata.js +7 -1
- package/package.json +13 -2
- package/typings/context.d.ts +2 -0
- package/typings/phpstorm.d.ts +33 -0
- package/lib/tasks/file-system/create-php-storm-config.js +0 -82
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
|
|
4
|
+
module.exports = ({ templateDir } = {}) => ({
|
|
5
|
+
magentoVersion: '2.3.7-p2',
|
|
6
|
+
configuration: {
|
|
7
|
+
php: {
|
|
8
|
+
version: '7.4.27',
|
|
9
|
+
configTemplate: path.join(templateDir || '', 'php.template.ini'),
|
|
10
|
+
extensions: {
|
|
11
|
+
gd: {},
|
|
12
|
+
intl: {},
|
|
13
|
+
zlib: {},
|
|
14
|
+
openssl: {},
|
|
15
|
+
sockets: {},
|
|
16
|
+
SimpleXML: {},
|
|
17
|
+
xdebug: {
|
|
18
|
+
version: '3.1.2'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
nginx: {
|
|
23
|
+
version: '1.18.0',
|
|
24
|
+
configTemplate: path.join(templateDir || '', 'nginx.template.conf')
|
|
25
|
+
},
|
|
26
|
+
redis: {
|
|
27
|
+
version: '6'
|
|
28
|
+
},
|
|
29
|
+
mysql: {
|
|
30
|
+
version: '5.7'
|
|
31
|
+
},
|
|
32
|
+
mariadb: {
|
|
33
|
+
version: '10.2'
|
|
34
|
+
},
|
|
35
|
+
elasticsearch: {
|
|
36
|
+
version: '7.9.3'
|
|
37
|
+
},
|
|
38
|
+
composer: {
|
|
39
|
+
version: '2'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
magento: defaultMagentoConfig,
|
|
43
|
+
host: 'localhost',
|
|
44
|
+
ssl: {
|
|
45
|
+
enabled: false
|
|
46
|
+
}
|
|
47
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
|
|
4
|
+
module.exports = ({ templateDir } = {}) => ({
|
|
5
|
+
magentoVersion: '2.3.7-p3',
|
|
6
|
+
configuration: {
|
|
7
|
+
php: {
|
|
8
|
+
version: '7.4.27',
|
|
9
|
+
configTemplate: path.join(templateDir || '', 'php.template.ini'),
|
|
10
|
+
extensions: {
|
|
11
|
+
gd: {},
|
|
12
|
+
intl: {},
|
|
13
|
+
zlib: {},
|
|
14
|
+
openssl: {},
|
|
15
|
+
sockets: {},
|
|
16
|
+
SimpleXML: {},
|
|
17
|
+
xdebug: {
|
|
18
|
+
version: '3.1.2'
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
nginx: {
|
|
23
|
+
version: '1.18.0',
|
|
24
|
+
configTemplate: path.join(templateDir || '', 'nginx.template.conf')
|
|
25
|
+
},
|
|
26
|
+
redis: {
|
|
27
|
+
version: '6'
|
|
28
|
+
},
|
|
29
|
+
mysql: {
|
|
30
|
+
version: '5.7'
|
|
31
|
+
},
|
|
32
|
+
mariadb: {
|
|
33
|
+
version: '10.2'
|
|
34
|
+
},
|
|
35
|
+
elasticsearch: {
|
|
36
|
+
version: '7.9.3'
|
|
37
|
+
},
|
|
38
|
+
composer: {
|
|
39
|
+
version: '2'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
magento: defaultMagentoConfig,
|
|
43
|
+
host: 'localhost',
|
|
44
|
+
ssl: {
|
|
45
|
+
enabled: false
|
|
46
|
+
}
|
|
47
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
const { libsodium } = require('../php/extensions');
|
|
4
|
+
|
|
5
|
+
module.exports = ({ templateDir } = {}) => ({
|
|
6
|
+
magentoVersion: '2.4.3-p2',
|
|
7
|
+
isDefault: true,
|
|
8
|
+
configuration: {
|
|
9
|
+
php: {
|
|
10
|
+
version: '7.4.27',
|
|
11
|
+
configTemplate: path.join(templateDir || '', 'php.template.ini'),
|
|
12
|
+
extensions: {
|
|
13
|
+
gd: {},
|
|
14
|
+
intl: {},
|
|
15
|
+
zlib: {},
|
|
16
|
+
openssl: {},
|
|
17
|
+
sockets: {},
|
|
18
|
+
SimpleXML: {},
|
|
19
|
+
libsodium,
|
|
20
|
+
fileinfo: {},
|
|
21
|
+
xdebug: {
|
|
22
|
+
version: '3.1.2'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
nginx: {
|
|
27
|
+
version: '1.18.0',
|
|
28
|
+
configTemplate: path.join(templateDir || '', 'nginx.template.conf')
|
|
29
|
+
},
|
|
30
|
+
redis: {
|
|
31
|
+
version: '6.0'
|
|
32
|
+
},
|
|
33
|
+
mysql: {
|
|
34
|
+
version: '8.0'
|
|
35
|
+
},
|
|
36
|
+
mariadb: {
|
|
37
|
+
version: '10.4'
|
|
38
|
+
},
|
|
39
|
+
elasticsearch: {
|
|
40
|
+
version: '7.12.1'
|
|
41
|
+
},
|
|
42
|
+
composer: {
|
|
43
|
+
version: '2'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
magento: defaultMagentoConfig,
|
|
47
|
+
host: 'localhost',
|
|
48
|
+
ssl: {
|
|
49
|
+
enabled: false
|
|
50
|
+
}
|
|
51
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const { defaultMagentoConfig } = require('../magento-config');
|
|
3
|
+
const { libsodium } = require('../php/extensions');
|
|
4
|
+
|
|
5
|
+
module.exports = ({ templateDir } = {}) => ({
|
|
6
|
+
magentoVersion: '2.4.4',
|
|
7
|
+
isDefault: true,
|
|
8
|
+
configuration: {
|
|
9
|
+
php: {
|
|
10
|
+
version: '8.1.4',
|
|
11
|
+
configTemplate: path.join(templateDir || '', 'php.template.ini'),
|
|
12
|
+
extensions: {
|
|
13
|
+
gd: {},
|
|
14
|
+
intl: {},
|
|
15
|
+
zlib: {},
|
|
16
|
+
openssl: {},
|
|
17
|
+
sockets: {},
|
|
18
|
+
SimpleXML: {},
|
|
19
|
+
libsodium,
|
|
20
|
+
fileinfo: {},
|
|
21
|
+
xdebug: {
|
|
22
|
+
version: '3.1.4'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
nginx: {
|
|
27
|
+
version: '1.18.0',
|
|
28
|
+
configTemplate: path.join(templateDir || '', 'nginx.template.conf')
|
|
29
|
+
},
|
|
30
|
+
redis: {
|
|
31
|
+
version: '6.0'
|
|
32
|
+
},
|
|
33
|
+
mysql: {
|
|
34
|
+
version: '8.0'
|
|
35
|
+
},
|
|
36
|
+
mariadb: {
|
|
37
|
+
version: '10.4'
|
|
38
|
+
},
|
|
39
|
+
elasticsearch: {
|
|
40
|
+
version: '7.16.3'
|
|
41
|
+
},
|
|
42
|
+
composer: {
|
|
43
|
+
version: '2'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
magento: defaultMagentoConfig,
|
|
47
|
+
host: 'localhost',
|
|
48
|
+
ssl: {
|
|
49
|
+
enabled: false
|
|
50
|
+
}
|
|
51
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const { XMLParser, XMLBuilder } = require('fast-xml-parser');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const pathExists = require('../util/path-exists');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @type {import('fast-xml-parser').X2jOptions}
|
|
8
|
+
*/
|
|
9
|
+
const xmlParserConfig = {
|
|
10
|
+
ignoreAttributes: false,
|
|
11
|
+
parseAttributeValue: false,
|
|
12
|
+
trimValues: true,
|
|
13
|
+
allowBooleanAttributes: true
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @type {Partial<import('fast-xml-parser').XmlBuilderOptions>}
|
|
18
|
+
*/
|
|
19
|
+
const xmlBuilderConfig = {
|
|
20
|
+
...xmlParserConfig,
|
|
21
|
+
format: true,
|
|
22
|
+
suppressEmptyNode: true,
|
|
23
|
+
suppressBooleanAttributes: false
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const parser = new XMLParser(xmlParserConfig);
|
|
27
|
+
const builder = new XMLBuilder(xmlBuilderConfig);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Load xml file to js object
|
|
31
|
+
* @param {String} filePath
|
|
32
|
+
*/
|
|
33
|
+
const loadXmlFile = async (filePath) => {
|
|
34
|
+
const fileData = await fs.promises.readFile(filePath, 'utf-8');
|
|
35
|
+
|
|
36
|
+
return parser.parse(fileData);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Build xml from js object and write it to file
|
|
41
|
+
* @param {String} filePath
|
|
42
|
+
* @param {String} fileData
|
|
43
|
+
*/
|
|
44
|
+
const buildXmlFile = async (filePath, fileData) => {
|
|
45
|
+
const xmlFileData = builder.build(fileData);
|
|
46
|
+
|
|
47
|
+
const { dir } = path.parse(filePath);
|
|
48
|
+
|
|
49
|
+
if (!await pathExists(dir)) {
|
|
50
|
+
await fs.promises.mkdir(dir, {
|
|
51
|
+
recursive: true
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
await fs.promises.writeFile(filePath, xmlFileData, 'utf-8');
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
module.exports = {
|
|
59
|
+
loadXmlFile,
|
|
60
|
+
buildXmlFile
|
|
61
|
+
};
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
const { loadXmlFile, buildXmlFile } = require('../../../config/xml-parser');
|
|
3
|
+
const pathExists = require('../../../util/path-exists');
|
|
4
|
+
const setConfigFile = require('../../../util/set-config');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Get link to data-source field, create fields if necessary
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} data
|
|
10
|
+
* @param {Object} defaultData Default data structure that will be used if original data is missing
|
|
11
|
+
*/
|
|
12
|
+
const getToDataSource = (data, defaultData) => {
|
|
13
|
+
if (!data.project) {
|
|
14
|
+
data.project = defaultData.project;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (!data.project.component) {
|
|
18
|
+
data.project.component = defaultData.project.component;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (!data.project.component['data-source']) {
|
|
22
|
+
data.project.component['data-source'] = defaultData.project.component['data-source'];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return data.project.component['data-source'];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
30
|
+
*/
|
|
31
|
+
const setupDataSourceLocalConfig = () => ({
|
|
32
|
+
title: 'Set up datasource local configuration',
|
|
33
|
+
task: async (ctx, task) => {
|
|
34
|
+
const {
|
|
35
|
+
config: {
|
|
36
|
+
phpStorm,
|
|
37
|
+
phpStorm: {
|
|
38
|
+
database
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
} = ctx;
|
|
42
|
+
|
|
43
|
+
if (await pathExists(database.dataSourcesLocal.path)) {
|
|
44
|
+
let hasChanges = false;
|
|
45
|
+
const dataSourcesLocalData = await loadXmlFile(database.dataSourcesLocal.path);
|
|
46
|
+
const dataSource = getToDataSource(
|
|
47
|
+
dataSourcesLocalData,
|
|
48
|
+
{
|
|
49
|
+
project: {
|
|
50
|
+
'@_version': '4',
|
|
51
|
+
component: {
|
|
52
|
+
'@_name': 'dataSourceStorageLocal',
|
|
53
|
+
'@_created-in': 'PS-212.5284.49',
|
|
54
|
+
'data-source': {
|
|
55
|
+
'@_uuid': 'a2eadb3c-6fc9-4d85-b5f4-d8114906ce2f'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
if (dataSource['@_name'] !== database.dataSourceManagerName) {
|
|
63
|
+
hasChanges = true;
|
|
64
|
+
dataSource['@_name'] = database.dataSourceManagerName;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (dataSource['@_uuid'] === undefined) {
|
|
68
|
+
hasChanges = true;
|
|
69
|
+
dataSource['@_uuid'] = 'a2eadb3c-6fc9-4d85-b5f4-d8114906ce2f';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const defaultDatabaseInfoConfig = {
|
|
73
|
+
'@_product': '',
|
|
74
|
+
'@_version': '',
|
|
75
|
+
'@_jdbc-version': '',
|
|
76
|
+
'@_driver-name': '',
|
|
77
|
+
'@_driver-version': '',
|
|
78
|
+
'@_dbms': 'MYSQL',
|
|
79
|
+
'@_exact-version': '0'
|
|
80
|
+
};
|
|
81
|
+
const isDatabaseInfoChangeNeeded = dataSource['database-info']
|
|
82
|
+
? Object.entries(defaultDatabaseInfoConfig)
|
|
83
|
+
.some(([key]) => !(key in dataSource['database-info']))
|
|
84
|
+
: true;
|
|
85
|
+
|
|
86
|
+
if (isDatabaseInfoChangeNeeded) {
|
|
87
|
+
hasChanges = true;
|
|
88
|
+
if (!dataSource['database-info']) {
|
|
89
|
+
dataSource['database-info'] = defaultDatabaseInfoConfig;
|
|
90
|
+
} else {
|
|
91
|
+
Object.entries(defaultDatabaseInfoConfig).forEach(([key, value]) => {
|
|
92
|
+
if (!(key in dataSource['database-info'])) {
|
|
93
|
+
dataSource['database-info'][key] = value;
|
|
94
|
+
}
|
|
95
|
+
// ^^^ only set missing properties, only ones should be in place
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const dataSourceDefaultData = {
|
|
101
|
+
'secret-storage': 'master_key',
|
|
102
|
+
'user-name': 'magento'
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const isDataSourceDataChangeNeeded = dataSource
|
|
106
|
+
? Object.entries(dataSourceDefaultData)
|
|
107
|
+
.some(([key, value]) => dataSource[key] !== value)
|
|
108
|
+
: true;
|
|
109
|
+
|
|
110
|
+
if (isDataSourceDataChangeNeeded) {
|
|
111
|
+
hasChanges = true;
|
|
112
|
+
Object.entries(dataSourceDefaultData).forEach(([key, value]) => {
|
|
113
|
+
dataSource[key] = value;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (!('schema-mapping' in dataSource)) {
|
|
118
|
+
hasChanges = true;
|
|
119
|
+
dataSource['schema-mapping'] = '';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (hasChanges) {
|
|
123
|
+
await buildXmlFile(database.dataSourcesLocal.path, dataSourcesLocalData);
|
|
124
|
+
} else {
|
|
125
|
+
task.skip();
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
try {
|
|
129
|
+
await setConfigFile({
|
|
130
|
+
configPathname: phpStorm.database.dataSourcesLocal.path,
|
|
131
|
+
template: phpStorm.database.dataSourcesLocal.templatePath,
|
|
132
|
+
overwrite: true,
|
|
133
|
+
templateArgs: {
|
|
134
|
+
phpStorm
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
} catch (e) {
|
|
138
|
+
throw new Error(`Unexpected error accrued during dataSources.local.xml config creation\n\n${e}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
146
|
+
*/
|
|
147
|
+
const setupDataSourceConfig = () => ({
|
|
148
|
+
task: async (ctx, task) => {
|
|
149
|
+
const {
|
|
150
|
+
config: {
|
|
151
|
+
phpStorm,
|
|
152
|
+
phpStorm: {
|
|
153
|
+
database
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
ports
|
|
157
|
+
} = ctx;
|
|
158
|
+
const jdbcUrl = `jdbc:mysql://localhost:${ports.mysql}/magento`;
|
|
159
|
+
|
|
160
|
+
if (await pathExists(database.dataSources.path)) {
|
|
161
|
+
let hasChanges = false;
|
|
162
|
+
const dataSourcesData = await loadXmlFile(database.dataSources.path);
|
|
163
|
+
const dataSource = getToDataSource(
|
|
164
|
+
dataSourcesData,
|
|
165
|
+
{
|
|
166
|
+
project: {
|
|
167
|
+
'@_version': '4',
|
|
168
|
+
component: {
|
|
169
|
+
'@_name': 'DataSourceManagerImpl',
|
|
170
|
+
'@_format': 'xml',
|
|
171
|
+
'@_multifile-model': true,
|
|
172
|
+
'data-source': {
|
|
173
|
+
'@_source': 'LOCAL',
|
|
174
|
+
'@_uuid': 'a2eadb3c-6fc9-4d85-b5f4-d8114906ce2f'
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
if (dataSource['@_uuid'] === undefined) {
|
|
182
|
+
hasChanges = true;
|
|
183
|
+
dataSource['@_uuid'] = 'a2eadb3c-6fc9-4d85-b5f4-d8114906ce2f';
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const expectedDataSourceData = {
|
|
187
|
+
'@_name': database.dataSourceManagerName,
|
|
188
|
+
'driver-ref': 'mysql.8',
|
|
189
|
+
synchronize: true,
|
|
190
|
+
'jdbc-driver': 'com.mysql.cj.jdbc.Driver',
|
|
191
|
+
'jdbc-url': jdbcUrl,
|
|
192
|
+
'working-dir': '$ProjectFileDir$',
|
|
193
|
+
'@_source': 'LOCAL'
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const isDataSourceNeedChanges = dataSource
|
|
197
|
+
? Object.entries(expectedDataSourceData)
|
|
198
|
+
.some(([key]) => !(key in dataSource))
|
|
199
|
+
: true;
|
|
200
|
+
|
|
201
|
+
if (isDataSourceNeedChanges) {
|
|
202
|
+
hasChanges = true;
|
|
203
|
+
if (!dataSource) {
|
|
204
|
+
dataSourcesData.project.component['data-source'] = expectedDataSourceData;
|
|
205
|
+
} else {
|
|
206
|
+
Object.entries(expectedDataSourceData).forEach(([key, value]) => {
|
|
207
|
+
if (!(key in dataSource)) {
|
|
208
|
+
dataSource[key] = value;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (hasChanges) {
|
|
215
|
+
await buildXmlFile(database.dataSources.path, dataSourcesData);
|
|
216
|
+
} else {
|
|
217
|
+
task.skip();
|
|
218
|
+
}
|
|
219
|
+
} else {
|
|
220
|
+
try {
|
|
221
|
+
await setConfigFile({
|
|
222
|
+
configPathname: phpStorm.database.dataSources.path,
|
|
223
|
+
template: phpStorm.database.dataSources.templatePath,
|
|
224
|
+
overwrite: true,
|
|
225
|
+
templateArgs: {
|
|
226
|
+
phpStorm,
|
|
227
|
+
jdbcUrl
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
} catch (e) {
|
|
231
|
+
throw new Error(`Unexpected error accrued during dataSources.xml config creation\n\n${e}`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
239
|
+
*/
|
|
240
|
+
const setupDatabaseConfig = () => ({
|
|
241
|
+
title: 'Set up database configuration',
|
|
242
|
+
task: (ctx, task) => task.newListr([
|
|
243
|
+
setupDataSourceLocalConfig(),
|
|
244
|
+
setupDataSourceConfig()
|
|
245
|
+
])
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
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(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;
|