@scandipwa/magento-scripts 1.14.1-alpha.2 → 1.14.1-alpha.5

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 (115) 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 +46 -9
  5. package/lib/config/get-port-config.js +2 -1
  6. package/lib/config/port-config.js +1 -0
  7. package/lib/config/templates/magentorc.template +3 -5
  8. package/lib/config/templates/php.template.ini +6 -4
  9. package/lib/config/templates/varnish.template.vcl +241 -0
  10. package/lib/config/versions/magento-2.3.0.js +9 -0
  11. package/lib/config/versions/magento-2.3.1.js +9 -0
  12. package/lib/config/versions/magento-2.3.2-p2.js +9 -0
  13. package/lib/config/versions/magento-2.3.2.js +9 -0
  14. package/lib/config/versions/magento-2.3.3-p1.js +9 -0
  15. package/lib/config/versions/magento-2.3.3.js +9 -0
  16. package/lib/config/versions/magento-2.3.4-p2.js +9 -0
  17. package/lib/config/versions/magento-2.3.4.js +9 -0
  18. package/lib/config/versions/magento-2.3.5-p1.js +9 -0
  19. package/lib/config/versions/magento-2.3.5-p2.js +9 -0
  20. package/lib/config/versions/magento-2.3.5.js +9 -0
  21. package/lib/config/versions/magento-2.3.6-p1.js +9 -0
  22. package/lib/config/versions/magento-2.3.6.js +9 -0
  23. package/lib/config/versions/magento-2.3.7-p1.js +9 -0
  24. package/lib/config/versions/magento-2.3.7-p2.js +9 -0
  25. package/lib/config/versions/magento-2.3.7-p3.js +9 -0
  26. package/lib/config/versions/magento-2.3.7.js +9 -0
  27. package/lib/config/versions/magento-2.4.0-p1.js +9 -0
  28. package/lib/config/versions/magento-2.4.0.js +9 -0
  29. package/lib/config/versions/magento-2.4.1-p1.js +9 -0
  30. package/lib/config/versions/magento-2.4.1.js +9 -0
  31. package/lib/config/versions/magento-2.4.2-p1.js +9 -0
  32. package/lib/config/versions/magento-2.4.2-p2.js +9 -0
  33. package/lib/config/versions/magento-2.4.2.js +9 -0
  34. package/lib/config/versions/magento-2.4.3-p1.js +9 -0
  35. package/lib/config/versions/magento-2.4.3-p2.js +9 -0
  36. package/lib/config/versions/magento-2.4.3.js +9 -0
  37. package/lib/config/versions/magento-2.4.4.js +9 -0
  38. package/lib/tasks/cli/create-bashrc-config.js +5 -2
  39. package/lib/tasks/docker/containers.js +10 -8
  40. package/lib/tasks/docker/volumes.js +4 -4
  41. package/lib/tasks/file-system/create-nginx-config.js +5 -0
  42. package/lib/tasks/file-system/create-php-storm-config.js +82 -0
  43. package/lib/tasks/file-system/create-varnish-config.js +51 -0
  44. package/lib/tasks/file-system/index.js +4 -2
  45. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +1 -1
  46. package/lib/tasks/magento/setup-magento/disable-2fa.js +4 -12
  47. package/lib/tasks/magento/setup-magento/disable-full-page-cache.js +20 -0
  48. package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +14 -16
  49. package/lib/tasks/magento/setup-magento/migrate-database.js +24 -11
  50. package/lib/tasks/magento/setup-magento/upgrade-magento.js +17 -3
  51. package/lib/tasks/magento/setup-magento/varnish-config.js +63 -0
  52. package/lib/tasks/mysql/fix-db.js +2 -2
  53. package/lib/tasks/php/index.js +1 -1
  54. package/lib/tasks/php/update-env-php.js +16 -1
  55. package/lib/tasks/php/update-env.php +54 -12
  56. package/lib/tasks/requirements/docker/index.js +2 -0
  57. package/lib/tasks/requirements/docker/install.js +11 -11
  58. package/lib/tasks/requirements/docker/running-status.js +137 -0
  59. package/lib/tasks/requirements/docker/version.js +2 -0
  60. package/lib/tasks/requirements/index.js +5 -5
  61. package/lib/tasks/requirements/php-version.js +3 -1
  62. package/lib/tasks/start.js +5 -14
  63. package/lib/tasks/status/index.js +1 -1
  64. package/lib/tasks/theme/build-theme.js +26 -8
  65. package/lib/tasks/theme/install-theme.js +16 -4
  66. package/lib/tasks/theme/link-theme.js +2 -2
  67. package/lib/tasks/theme/setup-persisted-query.js +3 -3
  68. package/lib/tasks/theme/setup-themes.js +3 -2
  69. package/lib/tasks/theme/symlink-theme.js +18 -3
  70. package/lib/util/config-file-validator.js +11 -1
  71. package/lib/util/config-php-json.js +19 -0
  72. package/lib/util/instance-metadata.js +1 -7
  73. package/lib/util/is-running-root.js +3 -0
  74. package/lib/util/match-filesystem.js +2 -1
  75. package/lib/util/php-task.js +6 -2
  76. package/lib/util/run-php.js +7 -1
  77. package/lib/util/systemctl.js +46 -0
  78. package/package.json +2 -3
  79. package/typings/context.d.ts +2 -2
  80. package/typings/index.d.ts +19 -0
  81. package/lib/config/xml-parser.js +0 -61
  82. package/lib/tasks/file-system/create-phpstorm-config/database-config.js +0 -248
  83. package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +0 -85
  84. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +0 -154
  85. package/lib/tasks/file-system/create-phpstorm-config/index.js +0 -27
  86. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +0 -29
  87. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/config.js +0 -54
  88. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +0 -31
  89. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +0 -42
  90. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/eslint-inspection-config.js +0 -37
  91. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/index.js +0 -80
  92. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +0 -29
  93. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +0 -145
  94. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/paths.js +0 -20
  95. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-fixer-validation-inspection-config.js +0 -60
  96. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +0 -119
  97. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/stylelint-inspection-config.js +0 -37
  98. package/lib/tasks/file-system/create-phpstorm-config/keys.js +0 -14
  99. package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +0 -67
  100. package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +0 -57
  101. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +0 -76
  102. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +0 -63
  103. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +0 -69
  104. package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +0 -77
  105. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +0 -98
  106. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/format-setting-config.js +0 -57
  107. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +0 -66
  108. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +0 -64
  109. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +0 -60
  110. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +0 -51
  111. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +0 -74
  112. package/lib/tasks/file-system/create-phpstorm-config/xml-utils.js +0 -5
  113. package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -27
  114. package/lib/tasks/magento/setup-magento/disable-page-cache.js +0 -11
  115. package/typings/phpstorm.d.ts +0 -33
@@ -1,64 +0,0 @@
1
- const {
2
- nameKey
3
- } = require('../keys');
4
-
5
- const PHP_DEBUG_GENERAL_COMPONENT_NAME = 'PhpDebugGeneral';
6
-
7
- const portKey = '@_port';
8
- const xdebugDebugPortKey = '@_xdebug_debug_port';
9
- const ignoreConnectionsThroughUnregisteredServersKey = '@_ignore_connections_through_unregistered_servers';
10
-
11
- /**
12
- * @param {Array} workspaceConfigs
13
- * @param {import('../../../../../typings/phpstorm').PHPStormConfig} phpStormConfiguration
14
- * @returns {Promise<Boolean>}
15
- */
16
- const setupPHPDebugGeneral = async (workspaceConfigs, phpStormConfiguration) => {
17
- const { xdebug } = phpStormConfiguration;
18
- let hasChanges = false;
19
- const phpDebugGeneralComponent = workspaceConfigs.find(
20
- (workspaceConfig) => workspaceConfig[nameKey] === PHP_DEBUG_GENERAL_COMPONENT_NAME
21
- );
22
-
23
- if (phpDebugGeneralComponent) {
24
- if (phpDebugGeneralComponent.xdebug_debug_ports && !Array.isArray(phpDebugGeneralComponent.xdebug_debug_ports)) {
25
- hasChanges = true;
26
- phpDebugGeneralComponent.xdebug_debug_ports = [phpDebugGeneralComponent.xdebug_debug_ports];
27
- } else if (!phpDebugGeneralComponent.xdebug_debug_ports) {
28
- hasChanges = true;
29
- phpDebugGeneralComponent.xdebug_debug_ports = [];
30
- }
31
-
32
- if (!(xdebugDebugPortKey in phpDebugGeneralComponent)) {
33
- hasChanges = true;
34
- phpDebugGeneralComponent[xdebugDebugPortKey] = xdebug.v3Port;
35
- }
36
-
37
- const missingXDebugPorts = [xdebug.v3Port, xdebug.v2Port].filter(
38
- (port) => !phpDebugGeneralComponent.xdebug_debug_ports.some((xPort) => xPort[portKey] === port)
39
- );
40
-
41
- if (missingXDebugPorts.length > 0) {
42
- hasChanges = true;
43
- missingXDebugPorts.forEach((port) => {
44
- phpDebugGeneralComponent.xdebug_debug_ports.push({
45
- [portKey]: port
46
- });
47
- });
48
- }
49
- } else {
50
- hasChanges = true;
51
- workspaceConfigs.push({
52
- [nameKey]: PHP_DEBUG_GENERAL_COMPONENT_NAME,
53
- [xdebugDebugPortKey]: xdebug.v3Port,
54
- [ignoreConnectionsThroughUnregisteredServersKey]: 'true',
55
- xdebug_debug_ports: [xdebug.v3Port, xdebug.v2Port].map((port) => ({
56
- [portKey]: port
57
- }))
58
- });
59
- }
60
-
61
- return hasChanges;
62
- };
63
-
64
- module.exports = setupPHPDebugGeneral;
@@ -1,60 +0,0 @@
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;
@@ -1,51 +0,0 @@
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;
@@ -1,74 +0,0 @@
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;
@@ -1,5 +0,0 @@
1
- const formatPathForPHPStormConfig = (p) => p.replace(process.cwd(), '$PROJECT_DIR$');
2
-
3
- module.exports = {
4
- formatPathForPHPStormConfig
5
- };
@@ -1,27 +0,0 @@
1
- const { isTableExists } = require('../../../util/database');
2
-
3
- /**
4
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
- */
6
- const adjustMagentoConfiguration = () => ({
7
- title: 'Adjusting Magento Database Configuration',
8
- skip: async (ctx) => !(await isTableExists('magento', 'core_config_data', ctx)),
9
- task: async (ctx) => {
10
- const { mysqlConnection } = ctx;
11
-
12
- // delete varnish configuration if exists
13
- await mysqlConnection.query(`
14
- DELETE FROM core_config_data WHERE path LIKE '%varnish%';
15
- `);
16
-
17
- // update cache policy to not use varnish
18
- // 0 - magento cache, 2 - varnish cache
19
- await mysqlConnection.query(`
20
- UPDATE core_config_data
21
- SET value = ?
22
- WHERE path = ?;
23
- `, ['0', 'system/full_page_cache/caching_application']);
24
- }
25
- });
26
-
27
- module.exports = adjustMagentoConfiguration;
@@ -1,11 +0,0 @@
1
- const magentoTask = require('../../../util/magento-task');
2
-
3
- /**
4
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
- */
6
- const disablePageCache = () => ({
7
- title: 'Disabling full_page cache in Magento',
8
- task: (ctx, task) => task.newListr(magentoTask('cache:disable full_page'))
9
- });
10
-
11
- module.exports = disablePageCache;
@@ -1,33 +0,0 @@
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
- }