@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
@@ -1,13 +1,94 @@
1
1
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
2
- const os = require('os');
3
2
  const KnownError = require('../../../errors/known-error');
4
3
  const { execAsyncSpawn } = require('../../../util/exec-async-command');
5
- const getIsWsl = require('../../../util/is-wsl');
4
+ const openBrowser = require('../../../util/open-browser');
6
5
  const installDocker = require('./install');
6
+ const installDockerOnMac = require('./install-on-mac');
7
7
  const { checkDockerSocketPermissions } = require('./permissions');
8
8
  const checkDockerStatus = require('./running-status');
9
9
  const getDockerVersion = require('./version');
10
10
 
11
+ const dockerInstallPromptLinux = async (task) => {
12
+ const automaticallyInstallDocker = await task.prompt({
13
+ type: 'Confirm',
14
+ message: `You don't have Docker installed!
15
+ Do you want to install it automatically?
16
+ NOTE: After installation it's recommended to log out and log back in so your group membership is re-evaluated!`
17
+ });
18
+
19
+ if (automaticallyInstallDocker) {
20
+ return task.newListr([
21
+ installDocker(),
22
+ getDockerVersion(),
23
+ {
24
+ task: (ctx) => {
25
+ task.title = `Using docker version ${ctx.dockerVersion}`;
26
+
27
+ throw new KnownError(
28
+ `Docker is installed successfully!
29
+ Please log out and log back to so your group membership is re-evaluated!
30
+ Learn more here: ${ logger.style.link('https://docs.docker.com/engine/install/linux-postinstall/') }`
31
+ );
32
+ }
33
+ }
34
+ ]);
35
+ }
36
+
37
+ throw new KnownError('Docker is not installed!');
38
+ };
39
+
40
+ // maybe in the future docker will be possible to install on wsl from terminal...
41
+ const dockerInstallPromptWindows = () => {
42
+ throw new KnownError(
43
+ `You don't have Docker installed!
44
+ Follow this instructions to install Docker on Windows:
45
+ ${ logger.style.link('https://docs.create-magento-app.com/getting-started/prerequisites/windows-requirements#2-install-docker-desktop-for-windows') }`
46
+ );
47
+ };
48
+
49
+ /**
50
+ *
51
+ * @param {import('listr2').ListrTaskWrapper} task
52
+ */
53
+ const dockerInstallPromptMacOS = async (task) => {
54
+ const confirmationToInstallDocker = await task.prompt({
55
+ type: 'Select',
56
+ message: `You don't have Docker installed!
57
+ Would you like to install it automatically using brew cask or you prefer to install it manually?`,
58
+ choices: [
59
+ {
60
+ name: 'automatic',
61
+ message: 'Install Docker using brew cask'
62
+ },
63
+ {
64
+ name: 'manually',
65
+ message: 'Install Docker manually'
66
+ }
67
+ ]
68
+ });
69
+
70
+ if (confirmationToInstallDocker === 'automatic') {
71
+ return task.newListr([
72
+ installDockerOnMac(),
73
+ checkDockerStatus(),
74
+ getDockerVersion(),
75
+ {
76
+ task: (ctx) => {
77
+ task.title = `Using Docker version ${ctx.dockerVersion}`;
78
+ }
79
+ }
80
+ ]);
81
+ }
82
+
83
+ const dockerInstallLink = 'https://docs.create-magento-app.com/getting-started/prerequisites/installation-on-macos#3.-install-docker-for-mac';
84
+ await openBrowser(dockerInstallLink);
85
+
86
+ throw new KnownError(
87
+ `Follow this instructions to install Docker on Mac:
88
+ ${ logger.style.link(dockerInstallLink) }`
89
+ );
90
+ };
91
+
11
92
  /**
12
93
  * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
13
94
  */
@@ -19,46 +100,18 @@ const checkDocker = () => ({
19
100
  });
20
101
 
21
102
  if (code !== 0) {
22
- const isWsl = await getIsWsl();
23
- if (os.platform() === 'linux' && !isWsl) {
24
- const automaticallyInstallDocker = await task.prompt({
25
- type: 'Confirm',
26
- message: `You don't have Docker installed!
27
- Do you want to install it automatically?
28
- NOTE: After installation it's recommended to log out and log back in so your group membership is re-evaluated!`
29
- });
30
-
31
- if (automaticallyInstallDocker) {
32
- return task.newListr([
33
- installDocker(),
34
- getDockerVersion(),
35
- {
36
- task: (ctx) => {
37
- task.title = `Using docker version ${ctx.dockerVersion}`;
38
-
39
- throw new KnownError(
40
- `Docker is installed successfully!
41
- Please log out and log back to so your group membership is re-evaluated!
42
- Learn more here: ${ logger.style.link('https://docs.docker.com/engine/install/linux-postinstall/') }`
43
- );
44
- }
45
- }
46
- ]);
103
+ if (ctx.platform === 'linux' && !ctx.isWsl) {
104
+ const result = await dockerInstallPromptLinux(task);
105
+ if (result) {
106
+ return result;
47
107
  }
48
-
49
- throw new KnownError('Docker is not installed!');
50
- } else if (isWsl) {
51
- throw new KnownError(
52
- `You don't have Docker installed!
53
- Follow this instructions to install Docker on Windows:
54
- ${ logger.style.link('https://docs.create-magento-app.com/getting-started/prerequisites/windows-requirements#2-install-docker-desktop-for-windows') }`
55
- );
108
+ } else if (ctx.isWsl) {
109
+ dockerInstallPromptWindows();
56
110
  } else {
57
- throw new KnownError(
58
- `You don't have Docker installed!
59
- Follow this instructions to install Docker on Mac:
60
- ${ logger.style.link('https://docs.create-magento-app.com/getting-started/prerequisites/installation-on-macos#3-install-docker-for-mac') }`
61
- );
111
+ const result = await dockerInstallPromptMacOS(task);
112
+ if (result) {
113
+ return result;
114
+ }
62
115
  }
63
116
  }
64
117
 
@@ -0,0 +1,29 @@
1
+ const { execAsyncSpawn } = require('../../../util/exec-async-command');
2
+ const { getBrewCommand } = require('../../../util/get-brew-bin-path');
3
+
4
+ /**
5
+ * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
6
+ */
7
+ const installDockerOnMac = () => ({
8
+ title: 'Installing Docker on Mac OS',
9
+ task: async (ctx, task) => {
10
+ const interval = !ctx.verbose ? setInterval(() => {
11
+ task.output = `Installing Docker on Mac... Yep, still in progress ${new Date().toUTCString()}`;
12
+ }, 5000) : null;
13
+
14
+ await execAsyncSpawn(`${await getBrewCommand({ native: true })} install --cask docker`, {
15
+ callback: !ctx.verbose ? undefined : (t) => {
16
+ task.output = t;
17
+ }
18
+ });
19
+
20
+ if (!ctx.verbose) {
21
+ clearInterval(interval);
22
+ }
23
+ },
24
+ options: {
25
+ bottomBar: 10
26
+ }
27
+ });
28
+
29
+ module.exports = installDockerOnMac;
@@ -1,7 +1,5 @@
1
- const os = require('os');
2
1
  const KnownError = require('../../../errors/known-error');
3
2
  const { execAsyncSpawn } = require('../../../util/exec-async-command');
4
- const getIsWsl = require('../../../util/is-wsl');
5
3
  const pathExists = require('../../../util/path-exists');
6
4
  const sleep = require('../../../util/sleep');
7
5
  const { systemctlControl } = require('../../../util/systemctl');
@@ -20,38 +18,40 @@ const checkDockerStatusMacOS = () => ({
20
18
  task: async (ctx, task) => {
21
19
  const { result, code } = await getDockerVersion();
22
20
 
23
- if (code !== 0 && result.includes('Is the docker daemon running?')) {
24
- const dockerOpenAppConfirmation = await task.prompt({
25
- type: 'Confirm',
26
- message: 'Looks like Docker is not running, would you like us to open a Docker for Mac application and wait for it to start up?'
27
- });
28
-
29
- if (dockerOpenAppConfirmation && await pathExists(pathToDockerApplication)) {
30
- await execAsyncSpawn(`open ${pathToDockerApplication}`);
31
- let ready = false;
32
- let attempts = 0;
33
- while (!ready) {
34
- if (attempts > 24 && !ready) {
35
- throw new KnownError('Docker haven\'t started in 2 mins, exiting...');
36
- }
37
- try {
38
- const { code: startupCode } = await getDockerVersion();
39
- if (startupCode !== 0) {
40
- task.output = `Waiting for Docker to startup for ${attempts * 5} seconds...`;
41
- attempts++;
42
- await sleep(5000);
43
- } else {
44
- ready = true;
21
+ if (code !== 0) {
22
+ if (result.includes('Is the docker daemon running?') || result.includes('docker: command not found')) {
23
+ const dockerOpenAppConfirmation = await task.prompt({
24
+ type: 'Confirm',
25
+ message: 'Looks like Docker is not running, would you like us to open a Docker for Mac application and wait for it to start up?'
26
+ });
27
+
28
+ if (dockerOpenAppConfirmation && await pathExists(pathToDockerApplication)) {
29
+ await execAsyncSpawn(`open ${pathToDockerApplication}`);
30
+ let ready = false;
31
+ let attempts = 0;
32
+ while (!ready) {
33
+ if (attempts > 24 && !ready) {
34
+ throw new KnownError('Docker haven\'t started in 2 mins, exiting...');
45
35
  }
46
- } catch (e) {
36
+ try {
37
+ const { code: startupCode } = await getDockerVersion();
38
+ if (startupCode !== 0) {
39
+ task.output = `Waiting for Docker to startup for ${attempts * 5} seconds...`;
40
+ attempts++;
41
+ await sleep(5000);
42
+ } else {
43
+ ready = true;
44
+ }
45
+ } catch (e) {
47
46
  //
47
+ }
48
48
  }
49
+
50
+ return;
49
51
  }
50
52
 
51
- return;
53
+ task.skip('User skipped running Docker');
52
54
  }
53
-
54
- task.skip('User skipped running Docker');
55
55
  }
56
56
  },
57
57
  options: {
@@ -124,10 +124,10 @@ This action requires root privileges.`
124
124
  const checkDockerStatus = () => ({
125
125
  title: 'Checking Docker status',
126
126
  task: async (ctx, task) => {
127
- if (os.platform() === 'darwin') {
127
+ if (ctx.platform === 'darwin') {
128
128
  return task.newListr(checkDockerStatusMacOS());
129
129
  }
130
- if (!await getIsWsl()) {
130
+ if (!ctx.isWsl) {
131
131
  return task.newListr(checkDockerStatusLinux());
132
132
  }
133
133
 
@@ -4,6 +4,7 @@ const checkComposer = require('./composer');
4
4
  const checkDocker = require('./docker');
5
5
  const checkNodeVersion = require('./node-version');
6
6
  const checkPHPVersion = require('./php-version');
7
+ const checkRosetta = require('./rosetta');
7
8
 
8
9
  /**
9
10
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
@@ -13,6 +14,8 @@ const checkRequirements = () => ({
13
14
  task: (ctx, task) => task.newListr([
14
15
  // checking if user is on supported platform
15
16
  checkPlatform(),
17
+ // check if rosetta 2 is installed or not on m1 macs
18
+ checkRosetta(),
16
19
  // check the Docker installation
17
20
  checkDocker(),
18
21
  // check for Node.js version
@@ -6,43 +6,42 @@ const phpbrewConfig = require('../../config/phpbrew');
6
6
  const KnownError = require('../../errors/known-error');
7
7
  const UnknownError = require('../../errors/unknown-error');
8
8
  const { execAsyncSpawn } = require('../../util/exec-async-command');
9
+ const { getBrewCommandSync } = require('../../util/get-brew-bin-path');
9
10
  const pathExists = require('../../util/path-exists');
10
11
  const compileOptions = require('../php/compile-options');
11
12
 
12
13
  const latestStablePHP74 = '7.4.27';
13
14
  const phpbrewPHPName = `php-${latestStablePHP74}-phpbrew`;
14
15
 
15
- const compileOptionsForPhp = {
16
- linux: {
17
- ...compileOptions.linux,
18
- variants: [
19
- '+default'
20
- ],
21
- extraOptions: []
22
- },
23
- darwin: {
24
- ...compileOptions.darwin,
25
- variants: [
26
- '+default',
27
- '+openssl=$(brew --prefix openssl@1.1)'
28
- ],
29
- extraOptions: []
30
- }
31
- };
32
-
33
16
  /**
34
17
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
35
18
  */
36
19
  const installPHPForPHPBrew = () => ({
37
20
  title: `Installing PHP ${latestStablePHP74} for PHPBrew...`,
38
21
  task: async (ctx, task) => {
22
+ const compileOptionsForPhp = {
23
+ linux: {
24
+ ...compileOptions.linux,
25
+ variants: [
26
+ '+default'
27
+ ],
28
+ extraOptions: []
29
+ },
30
+ darwin: {
31
+ ...compileOptions.darwin,
32
+ variants: [
33
+ '+default',
34
+ `+openssl=$(${getBrewCommandSync({ native: false })} --prefix openssl@1.1)`
35
+ ],
36
+ extraOptions: []
37
+ }
38
+ };
39
39
  const platformCompileOptions = compileOptionsForPhp[process.platform];
40
40
 
41
41
  if (!await pathExists(path.join(phpbrewConfig.phpPath, `${phpbrewPHPName}`, 'bin'))) {
42
42
  const commandEnv = Object.entries(platformCompileOptions.env || {}).map(([key, value]) => `${key}="${value}"`).join(' ');
43
-
44
43
  // eslint-disable-next-line max-len
45
- const compileCommand = `${commandEnv ? `${commandEnv} && ` : ''}phpbrew install -j ${platformCompileOptions.cpuCount} ${latestStablePHP74} as ${phpbrewPHPName} ${platformCompileOptions.variants.join(' ')}`;
44
+ const compileCommand = ` ${commandEnv ? `${commandEnv} && ` : ''}phpbrew install -j ${platformCompileOptions.cpuCount} ${latestStablePHP74} as ${phpbrewPHPName} ${platformCompileOptions.variants.join(' ')}`;
46
45
 
47
46
  try {
48
47
  await execAsyncSpawn(
@@ -50,7 +49,8 @@ const installPHPForPHPBrew = () => ({
50
49
  {
51
50
  callback: (t) => {
52
51
  task.output = t;
53
- }
52
+ },
53
+ useRosetta2: true
54
54
  }
55
55
  );
56
56
  } catch (e) {
@@ -6,6 +6,7 @@ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
6
6
  const installDependenciesTask = require('../../../util/install-dependencies-task');
7
7
  const osPlatform = require('../../../util/os-platform');
8
8
  const KnownError = require('../../../errors/known-error');
9
+ const { getBrewCommand } = require('../../../util/get-brew-bin-path');
9
10
 
10
11
  /**
11
12
  * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
@@ -14,10 +15,20 @@ const installPHPBrewDependencies = () => ({
14
15
  title: 'Installing PHPBrew dependencies',
15
16
  task: async (ctx, task) => {
16
17
  if (process.platform === 'darwin') {
18
+ const installedDependencies = (await execAsyncSpawn(`${await getBrewCommand({ native: true })} list`)).split('\n');
19
+
20
+ const dependenciesToInstall = ['php', 'autoconf', 'pkg-config'].filter((dep) => !installedDependencies.includes(dep));
21
+
22
+ if (dependenciesToInstall.length === 0) {
23
+ task.skip();
24
+ return;
25
+ }
26
+
17
27
  return task.newListr(
18
28
  installDependenciesTask({
19
29
  platform: 'darwin',
20
- dependenciesToInstall: ['php', 'autoconf', 'pkg-config']
30
+ dependenciesToInstall,
31
+ useMacNativeEnvironment: true
21
32
  })
22
33
  );
23
34
  }
@@ -9,7 +9,7 @@ const getIsWsl = require('../../util/is-wsl');
9
9
  const KnownError = require('../../errors/known-error');
10
10
 
11
11
  /**
12
- * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
12
+ * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
13
13
  */
14
14
  const checkPlatform = () => ({
15
15
  title: 'Checking platform',
@@ -37,6 +37,7 @@ const checkPlatform = () => ({
37
37
 
38
38
  ctx.platform = currentPlatform;
39
39
  ctx.platformVersion = currentPlatform !== 'darwin' ? os.release() : macosVersion();
40
+ ctx.isArmMac = ctx.isArm && ctx.platform === 'darwin';
40
41
 
41
42
  const { manufacturer, brand, cores } = await systeminformation.cpu();
42
43
 
@@ -0,0 +1,32 @@
1
+ const { execAsyncSpawn, execCommandTask } = require('../../util/exec-async-command');
2
+
3
+ /**
4
+ * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
5
+ */
6
+ const checkRosetta = () => ({
7
+ skip: (ctx) => !ctx.isArmMac,
8
+ task: async (ctx, task) => {
9
+ task.title = 'Checking Rosetta 2 status';
10
+
11
+ const { code } = await execAsyncSpawn('arch -x86_64 echo "test"', {
12
+ withCode: true
13
+ });
14
+
15
+ if (code === 1) {
16
+ task.output = 'Rosetta 2 is not installed, installing...';
17
+ return task.newListr(
18
+ execCommandTask('softwareupdate --install-rosetta --agree-to-license', {
19
+ pipeInput: true,
20
+ callback: (t) => {
21
+ task.output = t;
22
+ }
23
+ })
24
+ );
25
+ }
26
+ },
27
+ options: {
28
+ bottomBar: 10
29
+ }
30
+ });
31
+
32
+ module.exports = checkRosetta;
@@ -31,6 +31,7 @@ const getIsWsl = require('../util/is-wsl');
31
31
  const checkForXDGOpen = require('../util/xdg-open-exists');
32
32
  const { getInstanceMetadata, constants: { WEB_LOCATION_TITLE } } = require('../util/instance-metadata');
33
33
  const validatePHPInstallation = require('./php/validate-php');
34
+ const installSodiumExtension = require('./php/install-sodium');
34
35
 
35
36
  /**
36
37
  * @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
@@ -113,6 +114,7 @@ const configureProject = () => ({
113
114
  exitOnError: true
114
115
  })
115
116
  },
117
+ installSodiumExtension(),
116
118
  configurePhp(),
117
119
  validatePHPInstallation(),
118
120
  installPrestissimo(),
@@ -1,6 +1,6 @@
1
1
  const symlinkTheme = require('./symlink-theme');
2
2
  const installTheme = require('./install-theme');
3
- const disableFullPageCache = require('../magento/setup-magento/disable-full-page-cache');
3
+ const adjustFullPageCache = require('../magento/setup-magento/adjust-full-page-cache');
4
4
  const disablePageBuilder = require('../magento/setup-magento/disable-page-builder');
5
5
  const buildTheme = require('./build-theme');
6
6
  const upgradeMagento = require('../magento/setup-magento/upgrade-magento');
@@ -53,7 +53,7 @@ const linkTheme = () => ({
53
53
  updateEnvPHP(),
54
54
  setupPersistedQuery(),
55
55
  upgradeMagento(),
56
- disableFullPageCache(),
56
+ adjustFullPageCache(),
57
57
  ...(isPageBuilderInstalled && Number(isPagebuilderEnabled) ? [disablePageBuilder()] : []),
58
58
  buildTheme(theme)
59
59
  ]);
@@ -5,7 +5,7 @@ const symlinkTheme = require('./symlink-theme');
5
5
  const installTheme = require('./install-theme');
6
6
  const setupPersistedQuery = require('./setup-persisted-query');
7
7
  const upgradeMagento = require('../magento/setup-magento/upgrade-magento');
8
- const disableFullPageCache = require('../magento/setup-magento/disable-full-page-cache');
8
+ const adjustFullPageCache = require('../magento/setup-magento/adjust-full-page-cache');
9
9
  const buildTheme = require('./build-theme');
10
10
  const KnownError = require('../../errors/known-error');
11
11
 
@@ -17,6 +17,12 @@ const setupThemes = () => ({
17
17
  task: async (ctx, task) => {
18
18
  const { config: { baseConfig } } = ctx;
19
19
  const composerData = await getJsonfileData(path.join(baseConfig.magentoDir, 'composer.json'));
20
+
21
+ if (!composerData.repositories) {
22
+ task.skip();
23
+ return;
24
+ }
25
+
20
26
  const composerLocalPaths = Array.isArray(composerData.repositories)
21
27
  ? composerData.repositories.filter((repo) => repo.type === 'path')
22
28
  : Object.values(composerData.repositories).filter((repo) => repo.type === 'path');
@@ -82,7 +88,7 @@ const setupThemes = () => ({
82
88
  ])
83
89
  })).concat([
84
90
  upgradeMagento(),
85
- disableFullPageCache(),
91
+ adjustFullPageCache(),
86
92
  setupPersistedQuery()
87
93
  ])
88
94
  );
@@ -11,6 +11,12 @@ const symlinkTheme = (theme) => ({
11
11
  task: async (ctx, task) => {
12
12
  const { magentoVersion, verbose = false } = ctx;
13
13
  const composerJsonData = await getJsonfileData(path.join(process.cwd(), 'composer.json'));
14
+
15
+ if (!composerJsonData.repositories) {
16
+ task.skip();
17
+ return;
18
+ }
19
+
14
20
  const repositories = Array.isArray(composerJsonData.repositories)
15
21
  ? composerJsonData.repositories.reduce((acc, repo, index) => ({ ...acc, [`${index}`]: repo }), {})
16
22
  : composerJsonData.repositories;
@@ -6,6 +6,10 @@ const getCSAThemes = async ({ cwd = process.cwd() } = {}) => {
6
6
  path.join(cwd, 'composer.json')
7
7
  );
8
8
 
9
+ if (!composerData.repositories) {
10
+ return [];
11
+ }
12
+
9
13
  const pathRepositories = Object.entries(composerData.repositories)
10
14
  .filter(([_, repoOptions]) => repoOptions.type === 'path');
11
15
 
package/lib/util/arch.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const macosVersion = require('macos-version');
2
2
  const { execSync } = require('child_process');
3
- const { execAsync } = require('./exec-async-command');
3
+ const { execAsync } = require('./exec-async');
4
4
 
5
5
  /**
6
6
  * Get actual system arch
@@ -9,6 +9,8 @@ interface ExecAsyncSpawnOptions<T extends boolean> {
9
9
  logOutput?: boolean
10
10
  cwd?: string
11
11
  withCode?: T
12
+ // only for mac
13
+ useRosetta2?: boolean
12
14
  }
13
15
 
14
16
  /**
@@ -1,25 +1,42 @@
1
+ const os = require('os');
1
2
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
2
- const { exec, spawn } = require('child_process');
3
-
4
- const execAsync = (command, options) => new Promise((resolve, reject) => {
5
- exec(command, options, (err, stdout) => (err ? reject(err) : resolve(stdout)));
6
- });
3
+ const { spawn } = require('child_process');
4
+ const { getArchSync } = require('./arch');
5
+ const compileOptions = require('../tasks/php/compile-options');
7
6
 
8
7
  const execAsyncSpawn = (command, {
9
8
  callback = () => {},
10
9
  pipeInput,
11
10
  logOutput = false,
12
11
  cwd,
13
- withCode = false
12
+ withCode = false,
13
+ useRosetta2 = false
14
14
  } = {}) => {
15
- const childProcess = spawn(
16
- 'bash',
17
- ['-c', command],
18
- {
19
- stdio: pipeInput ? ['inherit', 'pipe', 'pipe'] : 'pipe',
20
- cwd
21
- }
22
- );
15
+ const spawnOptions = {
16
+ stdio: pipeInput ? ['inherit', 'pipe', 'pipe'] : 'pipe',
17
+ cwd
18
+ };
19
+ let childProcess;
20
+ if (useRosetta2 && os.platform() === 'darwin' && getArchSync() === 'arm64') {
21
+ childProcess = spawn(
22
+ 'arch',
23
+ // eslint-disable-next-line max-len
24
+ ['-x86_64', 'bash', '-c', command],
25
+ {
26
+ ...spawnOptions,
27
+ env: {
28
+ ...process.env,
29
+ PATH: compileOptions.darwin.env.PATH
30
+ }
31
+ }
32
+ );
33
+ } else {
34
+ childProcess = spawn(
35
+ 'bash',
36
+ ['-c', command],
37
+ spawnOptions
38
+ );
39
+ }
23
40
 
24
41
  return new Promise((resolve, reject) => {
25
42
  let stdout = '';
@@ -71,7 +88,6 @@ const execCommandTask = (command, options = {}) => ({
71
88
  });
72
89
 
73
90
  module.exports = {
74
- execAsync,
75
91
  execAsyncSpawn,
76
92
  execCommandTask
77
93
  };
@@ -0,0 +1,9 @@
1
+ const { exec } = require('child_process');
2
+
3
+ const execAsync = (command, options) => new Promise((resolve, reject) => {
4
+ exec(command, options, (err, stdout) => (err ? reject(err) : resolve(stdout)));
5
+ });
6
+
7
+ module.exports = {
8
+ execAsync
9
+ };