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

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 (39) hide show
  1. package/lib/config/xml-parser.js +61 -0
  2. package/lib/tasks/file-system/create-phpstorm-config/database-config.js +248 -0
  3. package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +83 -0
  4. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +154 -0
  5. package/lib/tasks/file-system/create-phpstorm-config/index.js +27 -0
  6. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +29 -0
  7. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/config.js +54 -0
  8. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +31 -0
  9. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +42 -0
  10. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/eslint-inspection-config.js +37 -0
  11. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/index.js +80 -0
  12. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +29 -0
  13. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +145 -0
  14. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/paths.js +20 -0
  15. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-fixer-validation-inspection-config.js +60 -0
  16. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +119 -0
  17. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/stylelint-inspection-config.js +37 -0
  18. package/lib/tasks/file-system/create-phpstorm-config/keys.js +14 -0
  19. package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +67 -0
  20. package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +57 -0
  21. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +76 -0
  22. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +63 -0
  23. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +69 -0
  24. package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +77 -0
  25. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +98 -0
  26. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/format-setting-config.js +57 -0
  27. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +66 -0
  28. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +64 -0
  29. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +60 -0
  30. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +51 -0
  31. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +74 -0
  32. package/lib/tasks/file-system/create-phpstorm-config/xml-utils.js +5 -0
  33. package/lib/tasks/file-system/index.js +1 -1
  34. package/lib/tasks/start.js +6 -2
  35. package/lib/util/instance-metadata.js +7 -1
  36. package/package.json +3 -2
  37. package/typings/context.d.ts +2 -0
  38. package/typings/phpstorm.d.ts +33 -0
  39. package/lib/tasks/file-system/create-php-storm-config.js +0 -82
@@ -0,0 +1,60 @@
1
+ const { nameKey } = require('../keys');
2
+
3
+ const PHP_SERVERS_COMPONENT_NAME = 'PhpServers';
4
+
5
+ const hostKey = '@_host';
6
+
7
+ /**
8
+ * @param {Array} workspaceConfigs
9
+ * @param {import('../../../../../typings/phpstorm').PHPStormConfig} phpStormConfiguration
10
+ * @returns {Promise<Boolean>}
11
+ */
12
+ const setupPHPServers = async (workspaceConfigs, phpStormConfiguration) => {
13
+ const { xdebug } = phpStormConfiguration;
14
+ let hasChanges = false;
15
+ const phpServersComponent = workspaceConfigs.find(
16
+ (workspaceConfig) => workspaceConfig[nameKey] === PHP_SERVERS_COMPONENT_NAME
17
+ );
18
+
19
+ const defaultServerConfig = {
20
+ [hostKey]: xdebug.debugServerAddress,
21
+ id: '7e16e907-9ce3-4559-9d26-a30a5650d11f',
22
+ [nameKey]: xdebug.serverName
23
+ };
24
+
25
+ if (phpServersComponent) {
26
+ if (phpServersComponent.servers && !Array.isArray(phpServersComponent.servers)) {
27
+ hasChanges = true;
28
+ phpServersComponent.servers = [phpServersComponent.servers];
29
+ } else if (!phpServersComponent.servers) {
30
+ hasChanges = true;
31
+ phpServersComponent.servers = [];
32
+ }
33
+
34
+ const serverConfiguration = phpServersComponent.servers.find((server) => server.server[nameKey] === xdebug.serverName);
35
+
36
+ if (serverConfiguration && serverConfiguration.server[hostKey] !== xdebug.debugServerAddress) {
37
+ hasChanges = true;
38
+ serverConfiguration.server[hostKey] = xdebug.debugServerAddress;
39
+ } else if (!serverConfiguration) {
40
+ hasChanges = true;
41
+ phpServersComponent.servers.push({
42
+ server: defaultServerConfig
43
+ });
44
+ }
45
+ } else {
46
+ hasChanges = true;
47
+ workspaceConfigs.push({
48
+ [nameKey]: PHP_SERVERS_COMPONENT_NAME,
49
+ servers: [
50
+ {
51
+ server: defaultServerConfig
52
+ }
53
+ ]
54
+ });
55
+ }
56
+
57
+ return hasChanges;
58
+ };
59
+
60
+ module.exports = setupPHPServers;
@@ -0,0 +1,51 @@
1
+ const path = require('path');
2
+ // const { baseConfig } = require('../../../../config');
3
+ const { getCSAThemes } = require('../../../../util/CSA-theme');
4
+ const pathExists = require('../../../../util/path-exists');
5
+ const { nameKey } = require('../keys');
6
+ // const { formatPathForPHPStormConfig } = require('../xml-utils');
7
+
8
+ const PROPERTIES_COMPONENT_NAME = 'PropertiesComponent';
9
+
10
+ const defaultProperties = {
11
+ keyToString: {
12
+ 'RunOnceActivity.OpenProjectViewOnStart': 'true',
13
+ 'RunOnceActivity.ShowReadmeOnStart': 'true'
14
+ }
15
+ };
16
+
17
+ /**
18
+ * @param {Array} workspaceConfigs
19
+ * @returns {Promise<Boolean>}
20
+ */
21
+ const setupPropertiesComponent = async (workspaceConfigs) => {
22
+ let hasChanges = false;
23
+ const propertiesComponent = workspaceConfigs.find(
24
+ (workspaceConfig) => workspaceConfig[nameKey] === PROPERTIES_COMPONENT_NAME
25
+ );
26
+
27
+ if (propertiesComponent) {
28
+ // check later
29
+ } else {
30
+ hasChanges = true;
31
+ const themes = await getCSAThemes();
32
+ if (themes.length > 0) {
33
+ const theme = themes[0];
34
+ const themeESLintPath = path.join(process.cwd(), theme.themePath, 'node_modules', 'eslint');
35
+ if (await pathExists(themeESLintPath)) {
36
+ defaultProperties.keyToString['node.js.selected.package.eslint'] = themeESLintPath;
37
+ defaultProperties.keyToString['js.linters.configure.manually.selectedeslint'] = 'true';
38
+ defaultProperties.keyToString['node.js.detected.package.eslint'] = 'true';
39
+ defaultProperties.keyToString['settings.editor.selected.configurable'] = 'settings.javascript.linters.eslint';
40
+ }
41
+ }
42
+ workspaceConfigs.push({
43
+ [nameKey]: PROPERTIES_COMPONENT_NAME,
44
+ '#text': JSON.stringify(defaultProperties)
45
+ });
46
+ }
47
+
48
+ return hasChanges;
49
+ };
50
+
51
+ module.exports = setupPropertiesComponent;
@@ -0,0 +1,74 @@
1
+ const { nameKey } = require('../keys');
2
+
3
+ const RUN_MANAGER_COMPONENT_NAME = 'RunManager';
4
+
5
+ const PHP_REMOTE_DEBUG_RUN_CONFIGURATION_TYPE = 'PhpRemoteDebugRunConfigurationType';
6
+
7
+ const serverNameKey = '@_server_name';
8
+ const sessionIdKey = '@_session_id';
9
+
10
+ /**
11
+ * @param {Array} workspaceConfigs
12
+ * @param {import('../../../../../typings/phpstorm').PHPStormConfig} phpStormConfiguration
13
+ * @returns {Promise<Boolean>}
14
+ */
15
+ const setupRunManager = async (workspaceConfigs, phpStormConfiguration) => {
16
+ const { xdebug } = phpStormConfiguration;
17
+ let hasChanges = false;
18
+ const runManagerComponent = workspaceConfigs.find(
19
+ (workspaceConfig) => workspaceConfig[nameKey] === RUN_MANAGER_COMPONENT_NAME
20
+ );
21
+
22
+ const defaultRunManagerConfiguration = {
23
+ [nameKey]: xdebug.runManagerName,
24
+ '@_type': PHP_REMOTE_DEBUG_RUN_CONFIGURATION_TYPE,
25
+ '@_factoryName': 'PHP Remote Debug',
26
+ '@_filter_connections': 'FILTER',
27
+ [serverNameKey]: xdebug.serverName,
28
+ [sessionIdKey]: xdebug.sessionId,
29
+ method: {
30
+ '@_v': '2'
31
+ }
32
+ };
33
+
34
+ if (runManagerComponent) {
35
+ if (runManagerComponent.configuration && !Array.isArray(runManagerComponent.configuration)) {
36
+ hasChanges = true;
37
+ runManagerComponent.configuration = [runManagerComponent.configuration];
38
+ } else if (!runManagerComponent.configuration) {
39
+ hasChanges = true;
40
+ runManagerComponent.configuration = [];
41
+ }
42
+
43
+ const phpRemoteDebugRunConfiguration = runManagerComponent.configuration.find(
44
+ (configuration) => configuration['@_type'] === PHP_REMOTE_DEBUG_RUN_CONFIGURATION_TYPE && configuration[nameKey] === xdebug.runManagerName
45
+ );
46
+
47
+ if (phpRemoteDebugRunConfiguration) {
48
+ if (phpRemoteDebugRunConfiguration[serverNameKey] !== xdebug.serverName) {
49
+ hasChanges = true;
50
+ phpRemoteDebugRunConfiguration[serverNameKey] = xdebug.serverName;
51
+ }
52
+
53
+ if (phpRemoteDebugRunConfiguration[sessionIdKey] !== xdebug.sessionId) {
54
+ hasChanges = true;
55
+ phpRemoteDebugRunConfiguration[sessionIdKey] = xdebug.sessionId;
56
+ }
57
+ } else {
58
+ hasChanges = true;
59
+ runManagerComponent.configuration.push(defaultRunManagerConfiguration);
60
+ }
61
+ } else {
62
+ hasChanges = true;
63
+ workspaceConfigs.push({
64
+ [nameKey]: RUN_MANAGER_COMPONENT_NAME,
65
+ configuration: [
66
+ defaultRunManagerConfiguration
67
+ ]
68
+ });
69
+ }
70
+
71
+ return hasChanges;
72
+ };
73
+
74
+ module.exports = setupRunManager;
@@ -0,0 +1,5 @@
1
+ const formatPathForPHPStormConfig = (p) => p.replace(process.cwd(), '$PROJECT_DIR$');
2
+
3
+ module.exports = {
4
+ formatPathForPHPStormConfig
5
+ };
@@ -1,7 +1,7 @@
1
1
  const createNginxConfig = require('./create-nginx-config');
2
2
  const createPhpConfig = require('./create-php-config');
3
3
  const createPhpFpmConfig = require('./create-php-fpm-config');
4
- const createPhpStormConfig = require('./create-php-storm-config');
4
+ const createPhpStormConfig = require('./create-phpstorm-config');
5
5
  const createVSCodeConfig = require('./create-vscode-config');
6
6
 
7
7
  /**
@@ -29,6 +29,7 @@ const convertLegacyVolumes = require('./docker/convert-legacy-volumes');
29
29
  const enableMagentoComposerPlugins = require('./magento/enable-magento-composer-plugins');
30
30
  const getIsWsl = require('../util/is-wsl');
31
31
  const checkForXDGOpen = require('../util/xdg-open-exists');
32
+ const { getInstanceMetadata, constants: { WEB_LOCATION_TITLE } } = require('../util/instance-metadata');
32
33
 
33
34
  /**
34
35
  * @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
@@ -189,8 +190,11 @@ const start = () => ({
189
190
 
190
191
  return false;
191
192
  },
192
- task: ({ ports, config: { overridenConfiguration: { host, ssl } } }) => {
193
- openBrowser(`${ssl.enabled ? 'https' : 'http'}://${host}${ssl.enabled || ports.app === 80 ? '' : `:${ports.app}`}/`);
193
+ task: (ctx) => {
194
+ const instanceMetadata = getInstanceMetadata(ctx);
195
+ const locationOnTheWeb = instanceMetadata.frontend.find(({ title }) => title === WEB_LOCATION_TITLE);
196
+
197
+ openBrowser(locationOnTheWeb.text);
194
198
  },
195
199
  options: {
196
200
  showTimer: false
@@ -70,5 +70,11 @@ const getInstanceMetadata = (ctx) => {
70
70
  };
71
71
 
72
72
  module.exports = {
73
- getInstanceMetadata
73
+ getInstanceMetadata,
74
+ constants: {
75
+ WEB_LOCAL_LOCATION_TITLE,
76
+ WEB_LOCATION_TITLE,
77
+ WEB_ADMIN_LOCATION_TITLE,
78
+ WEB_ADMIN_CREDENTIALS_TITLE
79
+ }
74
80
  };
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.0",
6
+ "version": "1.14.1-alpha.1",
7
7
  "main": "./index.js",
8
8
  "types": "./typings/index.d.ts",
9
9
  "license": "OSL-3.0",
@@ -26,6 +26,7 @@
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",
29
30
  "hjson": "^3.2.2",
30
31
  "is-installed-globally": "0.4.0",
31
32
  "joi": "17.6.0",
@@ -51,5 +52,5 @@
51
52
  "mysql",
52
53
  "scandipwa"
53
54
  ],
54
- "gitHead": "055ef1bd01035af8eaf80dffa087e77c67938fa8"
55
+ "gitHead": "cc46e60ca1d44d6e00b151e03af5cc7f56a5e54a"
55
56
  }
@@ -1,6 +1,7 @@
1
1
  import mysql2 from 'mysql2';
2
2
 
3
3
  import { CMAConfiguration, PHPExtensions } from './index';
4
+ import { PHPStormConfig } from './phpstorm';
4
5
 
5
6
  export interface ListrContext {
6
7
  magentoVersion: string
@@ -82,6 +83,7 @@ export interface ListrContext {
82
83
  overridenConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
83
84
  userConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
84
85
  nonOverridenConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
86
+ phpStorm: PHPStormConfig
85
87
  }
86
88
  systemConfiguration: {
87
89
  analytics: boolean
@@ -0,0 +1,33 @@
1
+ export interface PHPStormConfig {
2
+ xdebug: {
3
+ v2Port: string;
4
+ v3Port: string;
5
+ debugServerAddress: string;
6
+ serverName: string;
7
+ runManagerName: string;
8
+ sessionId: string;
9
+ path: string;
10
+ templatePath: string;
11
+ }
12
+ php: {
13
+ phpLanguageLevel: string;
14
+ path: string;
15
+ templatePath: string;
16
+ }
17
+ database: {
18
+ driver: string;
19
+ dataSourceManagerName: string;
20
+ dataSourcesLocal: {
21
+ path: string;
22
+ templatePath: string;
23
+ }
24
+ dataSources: {
25
+ path: string;
26
+ templatePath: string;
27
+ }
28
+ }
29
+ inspectionTools: {
30
+ path: string;
31
+ templatePath: string;
32
+ }
33
+ }
@@ -1,82 +0,0 @@
1
- const setConfigFile = require('../../util/set-config');
2
- const pathExists = require('../../util/path-exists');
3
- const path = require('path');
4
- const fs = require('fs');
5
-
6
- const createPhpStormConfig = () => ({
7
- title: 'Setting PHPStorm config',
8
- task: async ({ config: { phpStorm }, ports }) => {
9
- const { phpLanguageLevel } = phpStorm.php;
10
- const jdbcUrl = `jdbc:mysql://localhost:${ports.mysql}/magento`;
11
-
12
- try {
13
- await setConfigFile({
14
- configPathname: phpStorm.xdebug.path,
15
- template: phpStorm.xdebug.templatePath,
16
- overwrite: true,
17
- templateArgs: {
18
- phpStorm
19
- }
20
- });
21
- } catch (e) {
22
- throw new Error(`Unexpected error accrued during workspace.xml config creation\n\n${e}`);
23
- }
24
-
25
- try {
26
- await setConfigFile({
27
- configPathname: phpStorm.php.path,
28
- template: phpStorm.php.templatePath,
29
- overwrite: true,
30
- templateArgs: {
31
- phpLanguageLevel
32
- }
33
- });
34
- } catch (e) {
35
- throw new Error(`Unexpected error accrued during php.xml config creation\n\n${e}`);
36
- }
37
-
38
- try {
39
- await setConfigFile({
40
- configPathname: phpStorm.database.dataSourcesLocal.path,
41
- template: phpStorm.database.dataSourcesLocal.templatePath,
42
- overwrite: true,
43
- templateArgs: {
44
- phpStorm
45
- }
46
- });
47
- } catch (e) {
48
- throw new Error(`Unexpected error accrued during dataSources.local.xml config creation\n\n${e}`);
49
- }
50
-
51
- try {
52
- await setConfigFile({
53
- configPathname: phpStorm.database.dataSources.path,
54
- template: phpStorm.database.dataSources.templatePath,
55
- overwrite: true,
56
- templateArgs: {
57
- phpStorm,
58
- jdbcUrl
59
- }
60
- });
61
- } catch (e) {
62
- throw new Error(`Unexpected error accrued during dataSources.xml config creation\n\n${e}`);
63
- }
64
-
65
- if (!await pathExists(path.resolve('./.idea/dataSources'))) {
66
- await fs.promises.mkdir(path.resolve('./.idea/dataSources'));
67
- }
68
-
69
- try {
70
- await setConfigFile({
71
- configPathname: phpStorm.inspectionTools.path,
72
- template: phpStorm.inspectionTools.templatePath,
73
- overwrite: true,
74
- templateArgs: {}
75
- });
76
- } catch (e) {
77
- throw new Error(`Unexpected error accrued during Project_Default.xml config creation\n\n${e}`);
78
- }
79
- }
80
- });
81
-
82
- module.exports = createPhpStormConfig;