@scandipwa/magento-scripts 1.14.1-alpha.11 → 1.14.1-alpha.12

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 (79) hide show
  1. package/lib/config/cma-config.js +16 -0
  2. package/lib/config/dependencies-for-platforms.js +3 -1
  3. package/lib/config/templates/varnish.template.vcl +9 -4
  4. package/lib/config/xml-parser.js +63 -0
  5. package/lib/tasks/file-system/create-phpstorm-config/database-config.js +249 -0
  6. package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +85 -0
  7. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +154 -0
  8. package/lib/tasks/file-system/create-phpstorm-config/index.js +27 -0
  9. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +26 -0
  10. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/config.js +54 -0
  11. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +28 -0
  12. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +42 -0
  13. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/eslint-inspection-config.js +37 -0
  14. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/index.js +80 -0
  15. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +26 -0
  16. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +142 -0
  17. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/paths.js +20 -0
  18. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-fixer-validation-inspection-config.js +60 -0
  19. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +116 -0
  20. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/stylelint-inspection-config.js +37 -0
  21. package/lib/tasks/file-system/create-phpstorm-config/keys.js +14 -0
  22. package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +67 -0
  23. package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +54 -0
  24. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +66 -0
  25. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +58 -0
  26. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +59 -0
  27. package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +77 -0
  28. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +97 -0
  29. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/format-setting-config.js +57 -0
  30. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +66 -0
  31. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +64 -0
  32. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +57 -0
  33. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +49 -0
  34. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +64 -0
  35. package/lib/tasks/file-system/create-phpstorm-config/xml-utils.js +5 -0
  36. package/lib/tasks/file-system/index.js +1 -1
  37. package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +26 -0
  38. package/lib/tasks/magento/setup-magento/delete-admin-users.js +1 -1
  39. package/lib/tasks/magento/setup-magento/delete-customers.js +7 -4
  40. package/lib/tasks/magento/setup-magento/delete-orders.js +6 -4
  41. package/lib/tasks/mysql/import-dump-to-mysql.js +9 -0
  42. package/lib/tasks/php/compile-options.js +13 -10
  43. package/lib/tasks/php/compile.js +2 -1
  44. package/lib/tasks/php/extensions/disable.js +2 -1
  45. package/lib/tasks/php/extensions/enable.js +2 -1
  46. package/lib/tasks/php/extensions/index.js +4 -1
  47. package/lib/tasks/php/extensions/install.js +3 -3
  48. package/lib/tasks/php/install-sodium.js +93 -0
  49. package/lib/tasks/php/update-phpbrew.js +5 -2
  50. package/lib/tasks/php-fpm/start-php-fpm.js +2 -1
  51. package/lib/tasks/requirements/composer.js +2 -2
  52. package/lib/tasks/requirements/dependency/mac.js +18 -3
  53. package/lib/tasks/requirements/docker/index.js +93 -40
  54. package/lib/tasks/requirements/docker/install-on-mac.js +29 -0
  55. package/lib/tasks/requirements/docker/running-status.js +30 -30
  56. package/lib/tasks/requirements/index.js +3 -0
  57. package/lib/tasks/requirements/php-version.js +21 -21
  58. package/lib/tasks/requirements/phpbrew/install.js +12 -1
  59. package/lib/tasks/requirements/platform.js +2 -1
  60. package/lib/tasks/requirements/rosetta.js +32 -0
  61. package/lib/tasks/start.js +2 -0
  62. package/lib/tasks/theme/link-theme.js +2 -2
  63. package/lib/tasks/theme/setup-themes.js +8 -2
  64. package/lib/tasks/theme/symlink-theme.js +6 -0
  65. package/lib/util/CSA-theme.js +4 -0
  66. package/lib/util/arch.js +1 -1
  67. package/lib/util/exec-async-command.d.ts +2 -0
  68. package/lib/util/exec-async-command.js +31 -15
  69. package/lib/util/exec-async.js +9 -0
  70. package/lib/util/get-brew-bin-path.js +64 -0
  71. package/lib/util/install-dependencies-task.js +11 -1
  72. package/lib/util/php-task.js +7 -7
  73. package/lib/util/run-composer.js +2 -1
  74. package/lib/util/run-php.js +4 -0
  75. package/package.json +3 -2
  76. package/typings/context.d.ts +3 -0
  77. package/typings/phpstorm.d.ts +33 -0
  78. package/lib/tasks/file-system/create-php-storm-config.js +0 -83
  79. package/lib/tasks/magento/setup-magento/disable-full-page-cache.js +0 -20
@@ -0,0 +1,64 @@
1
+ const { getArch, getArchSync } = require('./arch');
2
+
3
+ const BREW_BIN_PATH_INTEL = '/usr/local/bin/brew';
4
+ const BREW_BIN_PATH_ARM_ROSETTA = '/usr/local/homebrew/bin/brew';
5
+ // native is not used ATM
6
+ const BREW_BIN_PATH_ARM_NATIVE = '/opt/homebrew/bin/brew';
7
+
8
+ const getBrewBinPath = async () => {
9
+ const arch = await getArch();
10
+
11
+ if (arch === 'arm64') {
12
+ return BREW_BIN_PATH_ARM_ROSETTA;
13
+ }
14
+
15
+ return BREW_BIN_PATH_INTEL;
16
+ };
17
+
18
+ const getBrewBinPathSync = () => {
19
+ const arch = getArchSync();
20
+
21
+ if (arch === 'arm64') {
22
+ return BREW_BIN_PATH_ARM_ROSETTA;
23
+ }
24
+
25
+ return BREW_BIN_PATH_INTEL;
26
+ };
27
+
28
+ const getBrewCommand = async ({ native } = { native: false }) => {
29
+ const arch = await getArch();
30
+
31
+ if (arch === 'arm64') {
32
+ if (native) {
33
+ return `arch -arm64 ${BREW_BIN_PATH_ARM_NATIVE}`;
34
+ }
35
+
36
+ return `arch -x86_64 ${BREW_BIN_PATH_ARM_ROSETTA}`;
37
+ }
38
+
39
+ return BREW_BIN_PATH_INTEL;
40
+ };
41
+
42
+ const getBrewCommandSync = ({ native } = { native: false }) => {
43
+ const arch = getArchSync();
44
+
45
+ if (arch === 'arm64') {
46
+ if (native) {
47
+ return `arch -arm64 ${BREW_BIN_PATH_ARM_NATIVE}`;
48
+ }
49
+
50
+ return `arch -x86_64 ${BREW_BIN_PATH_ARM_ROSETTA}`;
51
+ }
52
+
53
+ return BREW_BIN_PATH_INTEL;
54
+ };
55
+
56
+ module.exports = {
57
+ getBrewBinPath,
58
+ getBrewBinPathSync,
59
+ getBrewCommand,
60
+ getBrewCommandSync,
61
+ BREW_BIN_PATH_INTEL,
62
+ BREW_BIN_PATH_ARM_ROSETTA,
63
+ BREW_BIN_PATH_ARM_NATIVE
64
+ };
@@ -10,13 +10,23 @@ const KnownError = require('../errors/known-error');
10
10
  * @param {object} options
11
11
  * @param {keyof dependenciesForPlatforms} options.platform Platform
12
12
  * @param {string[]} options.dependenciesToInstall List of dependencies to install
13
+ * @param {boolean} options.useMacNativeEnvironment Use Mac native environment
13
14
  * @returns {import('listr2').ListrTask<import('../../typings/context').ListrContext>}
14
15
  */
15
16
  const installDependenciesTask = (options) => ({
16
17
  title: 'Installing missing dependencies',
17
18
  task: async (ctx, task) => {
18
19
  const { dependenciesToInstall, platform } = options;
19
- const cmd = dependenciesForPlatforms[platform].installCommand(dependenciesToInstall.join(' '));
20
+ let cmd;
21
+ if (os.platform() === 'darwin') {
22
+ if (options.useMacNativeEnvironment) {
23
+ cmd = dependenciesForPlatforms[platform].installCommand(dependenciesToInstall.join(' '), { native: true });
24
+ } else {
25
+ cmd = dependenciesForPlatforms[platform].installCommand(dependenciesToInstall.join(' '));
26
+ }
27
+ } else {
28
+ cmd = dependenciesForPlatforms[platform].installCommand(dependenciesToInstall.join(' '));
29
+ }
20
30
  const installCommand = logger.style.code(cmd);
21
31
  const dependenciesWordFormatter = `dependenc${dependenciesToInstall.length > 1 ? 'ies' : 'y'}`;
22
32
  task.title = `Installing missing dependencies: ${ logger.style.code(dependenciesToInstall.join(', ')) }`;
@@ -1,20 +1,20 @@
1
1
  const runPhpCode = require('./run-php');
2
2
 
3
3
  /**
4
- * @type {(
5
- * command: string,
6
- * options: { noTitle: boolean, env: Record<string, string> }
7
- * ) => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
4
+ * @param {String} command
5
+ * @param {{ noTitle: boolean, env: Record<string, string> }} options
6
+ * @returns {import('listr2').ListrTask<import('../../typings/context').ListrContext>}
8
7
  */
9
8
  const phpTask = (command, options = {}) => ({
10
9
  title: !options.noTitle ? `Running command 'php ${command}` : undefined,
11
- task: ({ magentoVersion }, task) => runPhpCode(command, {
10
+ task: (ctx, task) => runPhpCode(command, {
12
11
  callback: (t) => {
13
12
  task.output = t;
14
13
  },
15
14
  throwNonZeroCode: true,
16
- magentoVersion,
17
- env: options.env
15
+ magentoVersion: ctx.magentoVersion,
16
+ env: options.env,
17
+ useRosettaOnMac: ctx.arch === 'arm64' && ctx.platform === 'darwin'
18
18
  })
19
19
  });
20
20
 
@@ -21,7 +21,8 @@ const runComposerCommand = async (command, options = {}) => {
21
21
  const { code, result } = await execAsyncSpawn(`${php.binPath} -c ${php.iniPath} ${composer.binPath} ${command}`, {
22
22
  ...options,
23
23
  cwd: magentoDir,
24
- withCode: true
24
+ withCode: true,
25
+ useRosetta2: true
25
26
  });
26
27
 
27
28
  if (throwNonZeroCode && code !== 0) {
@@ -12,6 +12,7 @@ const UnknownError = require('../errors/unknown-error');
12
12
  * @param {Boolean} options.throwNonZeroCode Throw if command return non 0 code.
13
13
  * @param {String} options.magentoVersion Magento version for config
14
14
  * @param {Record<string, string>} options.env Environment variables
15
+ * @param {Boolean} options.useRosettaOnMac Use Rosetta 2 on MacOS
15
16
  */
16
17
  const runPhpCode = async (command, options = {}) => {
17
18
  const {
@@ -24,6 +25,9 @@ const runPhpCode = async (command, options = {}) => {
24
25
  const env = Object.entries(options.env).map(([key, value]) => `${key}=${value}`).join(' ');
25
26
  spawnCommand = `${env} ${spawnCommand}`;
26
27
  }
28
+ if (options.useRosettaOnMac) {
29
+ spawnCommand = `arch -x86_64 bash -c '${spawnCommand}'`;
30
+ }
27
31
  const { code, result } = await execAsyncSpawn(spawnCommand, {
28
32
  ...options,
29
33
  withCode: true
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.11",
6
+ "version": "1.14.1-alpha.12",
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",
@@ -52,5 +53,5 @@
52
53
  "mysql",
53
54
  "scandipwa"
54
55
  ],
55
- "gitHead": "3e86a5870f29d0b24ac3f65ff5fdbe96ef5bd025"
56
+ "gitHead": "c765f4fe97f9d09cabfd928fc127484eb2cac911"
56
57
  }
@@ -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
@@ -18,6 +19,7 @@ export interface ListrContext {
18
19
  arch: 'arm64' | 'x64'
19
20
  isArm: boolean
20
21
  isWsl: boolean
22
+ isArmMac: boolean
21
23
  platform?: NodeJS.Platform
22
24
  platformVersion?: string
23
25
  /**
@@ -85,6 +87,7 @@ export interface ListrContext {
85
87
  overridenConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
86
88
  userConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
87
89
  nonOverridenConfiguration: Omit<CMAConfiguration, 'prefix' | 'useNonOverlappingPorts'>
90
+ phpStorm: PHPStormConfig
88
91
  }
89
92
  systemConfiguration: {
90
93
  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,83 +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
- const UnknownError = require('../../errors/unknown-error');
6
-
7
- const createPhpStormConfig = () => ({
8
- title: 'Setting PHPStorm config',
9
- task: async ({ config: { phpStorm }, ports }) => {
10
- const { phpLanguageLevel } = phpStorm.php;
11
- const jdbcUrl = `jdbc:mysql://localhost:${ports.mysql}/magento`;
12
-
13
- try {
14
- await setConfigFile({
15
- configPathname: phpStorm.xdebug.path,
16
- template: phpStorm.xdebug.templatePath,
17
- overwrite: true,
18
- templateArgs: {
19
- phpStorm
20
- }
21
- });
22
- } catch (e) {
23
- throw new UnknownError(`Unexpected error accrued during workspace.xml config creation\n\n${e}`);
24
- }
25
-
26
- try {
27
- await setConfigFile({
28
- configPathname: phpStorm.php.path,
29
- template: phpStorm.php.templatePath,
30
- overwrite: true,
31
- templateArgs: {
32
- phpLanguageLevel
33
- }
34
- });
35
- } catch (e) {
36
- throw new UnknownError(`Unexpected error accrued during php.xml config creation\n\n${e}`);
37
- }
38
-
39
- try {
40
- await setConfigFile({
41
- configPathname: phpStorm.database.dataSourcesLocal.path,
42
- template: phpStorm.database.dataSourcesLocal.templatePath,
43
- overwrite: true,
44
- templateArgs: {
45
- phpStorm
46
- }
47
- });
48
- } catch (e) {
49
- throw new UnknownError(`Unexpected error accrued during dataSources.local.xml config creation\n\n${e}`);
50
- }
51
-
52
- try {
53
- await setConfigFile({
54
- configPathname: phpStorm.database.dataSources.path,
55
- template: phpStorm.database.dataSources.templatePath,
56
- overwrite: true,
57
- templateArgs: {
58
- phpStorm,
59
- jdbcUrl
60
- }
61
- });
62
- } catch (e) {
63
- throw new UnknownError(`Unexpected error accrued during dataSources.xml config creation\n\n${e}`);
64
- }
65
-
66
- if (!await pathExists(path.resolve('./.idea/dataSources'))) {
67
- await fs.promises.mkdir(path.resolve('./.idea/dataSources'));
68
- }
69
-
70
- try {
71
- await setConfigFile({
72
- configPathname: phpStorm.inspectionTools.path,
73
- template: phpStorm.inspectionTools.templatePath,
74
- overwrite: true,
75
- templateArgs: {}
76
- });
77
- } catch (e) {
78
- throw new UnknownError(`Unexpected error accrued during Project_Default.xml config creation\n\n${e}`);
79
- }
80
- }
81
- });
82
-
83
- module.exports = createPhpStormConfig;
@@ -1,20 +0,0 @@
1
- const envPhpToJson = require('../../../util/env-php-json');
2
- const magentoTask = require('../../../util/magento-task');
3
-
4
- /**
5
- * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
6
- */
7
- const disableFullPageCache = () => ({
8
- title: 'Disabling full_page cache in Magento',
9
- task: async ({ magentoVersion }, task) => {
10
- const { cache_types } = await envPhpToJson(process.cwd(), { magentoVersion });
11
-
12
- if (cache_types.full_page !== 0) {
13
- return task.newListr(magentoTask('cache:disable full_page'));
14
- }
15
-
16
- task.skip();
17
- }
18
- });
19
-
20
- module.exports = disableFullPageCache;