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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/index.js +13 -0
  2. package/lib/commands/cli.js +28 -1
  3. package/lib/commands/execute.js +2 -1
  4. package/lib/config/docker.js +85 -12
  5. package/lib/config/get-port-config.js +7 -2
  6. package/lib/config/port-config.js +3 -1
  7. package/lib/config/scandipwa-versions.js +2 -1
  8. package/lib/config/ssl-terminator/index.js +10 -0
  9. package/lib/config/templates/magentorc.template +3 -5
  10. package/lib/config/templates/nginx.template.conf +0 -14
  11. package/lib/config/templates/php.template.ini +6 -4
  12. package/lib/config/templates/ssl-terminator.template.conf +27 -0
  13. package/lib/config/templates/varnish.template.vcl +250 -0
  14. package/lib/config/varnish/varnish-6-0.js +11 -0
  15. package/lib/config/varnish/varnish-6-6.js +11 -0
  16. package/lib/config/varnish/varnish-7-0.js +11 -0
  17. package/lib/config/versions/magento-2.3.0.js +9 -1
  18. package/lib/config/versions/magento-2.3.1.js +9 -1
  19. package/lib/config/versions/magento-2.3.2-p2.js +9 -1
  20. package/lib/config/versions/magento-2.3.2.js +9 -1
  21. package/lib/config/versions/magento-2.3.3-p1.js +9 -1
  22. package/lib/config/versions/magento-2.3.3.js +9 -1
  23. package/lib/config/versions/magento-2.3.4-p2.js +9 -1
  24. package/lib/config/versions/magento-2.3.4.js +9 -1
  25. package/lib/config/versions/magento-2.3.5-p1.js +9 -1
  26. package/lib/config/versions/magento-2.3.5-p2.js +9 -1
  27. package/lib/config/versions/magento-2.3.5.js +9 -1
  28. package/lib/config/versions/magento-2.3.6-p1.js +9 -1
  29. package/lib/config/versions/magento-2.3.6.js +9 -1
  30. package/lib/config/versions/magento-2.3.7-p1.js +9 -1
  31. package/lib/config/versions/magento-2.3.7-p2.js +9 -1
  32. package/lib/config/versions/magento-2.3.7-p3.js +9 -1
  33. package/lib/config/versions/magento-2.3.7.js +9 -1
  34. package/lib/config/versions/magento-2.4.0-p1.js +9 -1
  35. package/lib/config/versions/magento-2.4.0.js +9 -1
  36. package/lib/config/versions/magento-2.4.1-p1.js +9 -1
  37. package/lib/config/versions/magento-2.4.1.js +9 -1
  38. package/lib/config/versions/magento-2.4.2-p1.js +9 -1
  39. package/lib/config/versions/magento-2.4.2-p2.js +9 -1
  40. package/lib/config/versions/magento-2.4.2.js +9 -1
  41. package/lib/config/versions/magento-2.4.3-p1.js +9 -1
  42. package/lib/config/versions/magento-2.4.3-p2.js +9 -1
  43. package/lib/config/versions/magento-2.4.3.js +9 -1
  44. package/lib/config/versions/magento-2.4.4.js +9 -1
  45. package/lib/tasks/cli/create-bashrc-config.js +5 -2
  46. package/lib/tasks/docker/containers.js +13 -8
  47. package/lib/tasks/docker/volumes.js +4 -4
  48. package/lib/tasks/file-system/create-nginx-config.js +7 -39
  49. package/lib/tasks/file-system/create-php-storm-config.js +82 -0
  50. package/lib/tasks/file-system/create-ssl-terminator-config.js +94 -0
  51. package/lib/tasks/file-system/create-varnish-config.js +74 -0
  52. package/lib/tasks/file-system/index.js +6 -2
  53. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +1 -1
  54. package/lib/tasks/magento/setup-magento/disable-2fa.js +4 -12
  55. package/lib/tasks/magento/setup-magento/disable-full-page-cache.js +20 -0
  56. package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +14 -16
  57. package/lib/tasks/magento/setup-magento/migrate-database.js +24 -11
  58. package/lib/tasks/magento/setup-magento/set-base-url.js +7 -2
  59. package/lib/tasks/magento/setup-magento/upgrade-magento.js +17 -3
  60. package/lib/tasks/magento/setup-magento/varnish-config.js +69 -0
  61. package/lib/tasks/mysql/fix-db.js +2 -2
  62. package/lib/tasks/php/index.js +1 -1
  63. package/lib/tasks/php/update-env-php.js +16 -1
  64. package/lib/tasks/php/update-env.php +56 -12
  65. package/lib/tasks/requirements/docker/index.js +2 -0
  66. package/lib/tasks/requirements/docker/install.js +11 -11
  67. package/lib/tasks/requirements/docker/running-status.js +137 -0
  68. package/lib/tasks/requirements/docker/version.js +2 -0
  69. package/lib/tasks/requirements/index.js +5 -5
  70. package/lib/tasks/requirements/php-version.js +3 -1
  71. package/lib/tasks/start.js +3 -8
  72. package/lib/tasks/status/index.js +25 -9
  73. package/lib/tasks/theme/build-theme.js +26 -8
  74. package/lib/tasks/theme/install-theme.js +16 -4
  75. package/lib/tasks/theme/link-theme.js +2 -2
  76. package/lib/tasks/theme/setup-persisted-query.js +3 -3
  77. package/lib/tasks/theme/setup-themes.js +3 -2
  78. package/lib/tasks/theme/symlink-theme.js +18 -3
  79. package/lib/util/config-file-validator.js +12 -1
  80. package/lib/util/config-php-json.js +19 -0
  81. package/lib/util/instance-metadata.js +2 -2
  82. package/lib/util/is-running-root.js +3 -0
  83. package/lib/util/match-filesystem.js +2 -1
  84. package/lib/util/php-task.js +6 -2
  85. package/lib/util/run-php.js +7 -1
  86. package/lib/util/systemctl.js +46 -0
  87. package/package.json +2 -3
  88. package/typings/context.d.ts +5 -3
  89. package/typings/index.d.ts +32 -1
  90. package/lib/config/xml-parser.js +0 -61
  91. package/lib/tasks/file-system/create-phpstorm-config/database-config.js +0 -248
  92. package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +0 -83
  93. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +0 -154
  94. package/lib/tasks/file-system/create-phpstorm-config/index.js +0 -27
  95. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +0 -29
  96. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/config.js +0 -54
  97. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +0 -31
  98. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +0 -42
  99. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/eslint-inspection-config.js +0 -37
  100. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/index.js +0 -80
  101. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +0 -29
  102. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +0 -145
  103. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/paths.js +0 -20
  104. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-fixer-validation-inspection-config.js +0 -60
  105. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +0 -119
  106. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/stylelint-inspection-config.js +0 -37
  107. package/lib/tasks/file-system/create-phpstorm-config/keys.js +0 -14
  108. package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +0 -67
  109. package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +0 -57
  110. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +0 -76
  111. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +0 -63
  112. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +0 -69
  113. package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +0 -77
  114. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +0 -98
  115. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/format-setting-config.js +0 -57
  116. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +0 -66
  117. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +0 -64
  118. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +0 -60
  119. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +0 -51
  120. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +0 -74
  121. package/lib/tasks/file-system/create-phpstorm-config/xml-utils.js +0 -5
  122. package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -27
  123. package/lib/tasks/magento/setup-magento/disable-page-cache.js +0 -11
  124. package/typings/phpstorm.d.ts +0 -33
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Scripts and configuration used by CMA.",
4
4
  "homepage": "https://docs.create-magento-app.com/",
5
5
  "repository": "github:scandipwa/create-magento-app",
6
- "version": "1.14.1-alpha.1",
6
+ "version": "1.14.1-alpha.10",
7
7
  "main": "./index.js",
8
8
  "types": "./typings/index.d.ts",
9
9
  "license": "OSL-3.0",
@@ -26,7 +26,6 @@
26
26
  "conf": "10.1.1",
27
27
  "enquirer": "2.3.6",
28
28
  "eta": "1.12.3",
29
- "fast-xml-parser": "^4.0.7",
30
29
  "hjson": "^3.2.2",
31
30
  "is-installed-globally": "0.4.0",
32
31
  "joi": "17.6.0",
@@ -52,5 +51,5 @@
52
51
  "mysql",
53
52
  "scandipwa"
54
53
  ],
55
- "gitHead": "cc46e60ca1d44d6e00b151e03af5cc7f56a5e54a"
54
+ "gitHead": "7d4d0843836447fa9ae49ad9927aa9eb2e92ca98"
56
55
  }
@@ -1,7 +1,6 @@
1
1
  import mysql2 from 'mysql2';
2
2
 
3
3
  import { CMAConfiguration, PHPExtensions } from './index';
4
- import { PHPStormConfig } from './phpstorm';
5
4
 
6
5
  export interface ListrContext {
7
6
  magentoVersion: string
@@ -13,9 +12,12 @@ export interface ListrContext {
13
12
  mysql: number
14
13
  redis: number
15
14
  elasticsearch: number
15
+ varnish: number
16
+ sslTerminator: number
16
17
  }
17
18
  arch: 'arm64' | 'x64'
18
19
  isArm: boolean
20
+ isWsl: boolean
19
21
  platform?: NodeJS.Platform
20
22
  platformVersion?: string
21
23
  /**
@@ -52,7 +54,7 @@ export interface ListrContext {
52
54
  o: string
53
55
  }
54
56
  }>
55
- getContainers(): Record<'nginx' | 'redis' | 'mysql' | 'elasticsearch', {
57
+ getContainers(): Record<'nginx' | 'redis' | 'mysql' | 'elasticsearch' | 'varnish', {
56
58
  _: string
57
59
  ports: string[]
58
60
  healthCheck: {
@@ -83,11 +85,11 @@ export interface ListrContext {
83
85
  overridenConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
84
86
  userConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
85
87
  nonOverridenConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
86
- phpStorm: PHPStormConfig
87
88
  }
88
89
  systemConfiguration: {
89
90
  analytics: boolean
90
91
  useNonOverlappingPorts: boolean
91
92
  }
92
93
  mysqlConnection: mysql2.Connection
94
+ isSetupUpgradeNeeded?: boolean
93
95
  }
@@ -10,7 +10,14 @@ export interface ServiceWithVersion {
10
10
  version: string
11
11
  }
12
12
 
13
- // export inter/
13
+ export interface SSLTerminatorConfiguration extends ServiceWithVersion {
14
+ /**
15
+ * Configuration file location
16
+ *
17
+ * @example ./my-ssl-terminator-config.conf
18
+ */
19
+ configTemplate: string
20
+ }
14
21
 
15
22
  export interface NginxConfiguration extends ServiceWithVersion {
16
23
  /**
@@ -21,6 +28,20 @@ export interface NginxConfiguration extends ServiceWithVersion {
21
28
  configTemplate: string
22
29
  }
23
30
 
31
+ export interface VarnishConfiguration extends ServiceWithVersion {
32
+ /**
33
+ * Enable or disable Varnish in the project
34
+ */
35
+ enabled: boolean
36
+
37
+ /**
38
+ * Configuration file location
39
+ *
40
+ * @example ./my-varnish-config.vcl
41
+ */
42
+ configTemplate: string
43
+ }
44
+
24
45
  export interface PHPExtension extends Record<string, unknown> {
25
46
  version?: string
26
47
  /**
@@ -175,6 +196,16 @@ export interface CMAConfiguration {
175
196
  * Composer configuration
176
197
  */
177
198
  composer: ServiceWithVersion
199
+
200
+ /**
201
+ * Varnish configuration
202
+ */
203
+ varnish: VarnishConfiguration
204
+
205
+ /**
206
+ * SSL Terminator configuration
207
+ */
208
+ sslTerminator: SSLTerminatorConfiguration
178
209
  }
179
210
  /**
180
211
  * Magento configuration
@@ -1,61 +0,0 @@
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
- };
@@ -1,248 +0,0 @@
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;
@@ -1,83 +0,0 @@
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
- const theme = themes[0];
65
-
66
- if (await pathExists(theme.themePath)) {
67
- styleLintConfigurationData.project.component['work-dir-pattern'] = {
68
- [valueKey]: formatPathForPHPStormConfig(theme.themePath)
69
- };
70
- const packageJsonPath = path.join(theme.themePath, 'package.json');
71
- if (await pathExists(packageJsonPath)) {
72
- styleLintConfigurationData.project.component['custom-configuration-file'] = {
73
- '@_used': 'true',
74
- '@_path': formatPathForPHPStormConfig(packageJsonPath)
75
- };
76
- }
77
- }
78
-
79
- await buildXmlFile(pathToESLintConfig, styleLintConfigurationData);
80
- }
81
- });
82
-
83
- module.exports = setupESLintConfig;
@@ -1,154 +0,0 @@
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;
@@ -1,27 +0,0 @@
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;