@scandipwa/magento-scripts 1.14.1-alpha.1 → 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 (179) 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/commands/logs.js +1 -0
  5. package/lib/commands/start.js +18 -5
  6. package/lib/config/cma-config.js +16 -0
  7. package/lib/config/dependencies-for-platforms.js +15 -3
  8. package/lib/config/docker.js +89 -15
  9. package/lib/config/get-port-config.js +9 -3
  10. package/lib/config/index.js +2 -1
  11. package/lib/config/php/extensions/libsodium.js +2 -1
  12. package/lib/config/port-config.js +3 -1
  13. package/lib/config/scandipwa-versions.js +2 -1
  14. package/lib/config/ssl-terminator/index.js +10 -0
  15. package/lib/config/system-config.js +34 -5
  16. package/lib/config/templates/magentorc.template +3 -5
  17. package/lib/config/templates/nginx.template.conf +0 -14
  18. package/lib/config/templates/php.template.ini +6 -4
  19. package/lib/config/templates/ssl-terminator.template.conf +27 -0
  20. package/lib/config/templates/varnish.template.vcl +255 -0
  21. package/lib/config/varnish/varnish-6-0.js +11 -0
  22. package/lib/config/varnish/varnish-6-6.js +11 -0
  23. package/lib/config/varnish/varnish-7-0.js +11 -0
  24. package/lib/config/versions/magento-2.3.0.js +9 -1
  25. package/lib/config/versions/magento-2.3.1.js +9 -1
  26. package/lib/config/versions/magento-2.3.2-p2.js +9 -1
  27. package/lib/config/versions/magento-2.3.2.js +9 -1
  28. package/lib/config/versions/magento-2.3.3-p1.js +9 -1
  29. package/lib/config/versions/magento-2.3.3.js +9 -1
  30. package/lib/config/versions/magento-2.3.4-p2.js +9 -1
  31. package/lib/config/versions/magento-2.3.4.js +9 -1
  32. package/lib/config/versions/magento-2.3.5-p1.js +9 -1
  33. package/lib/config/versions/magento-2.3.5-p2.js +9 -1
  34. package/lib/config/versions/magento-2.3.5.js +9 -1
  35. package/lib/config/versions/magento-2.3.6-p1.js +9 -1
  36. package/lib/config/versions/magento-2.3.6.js +9 -1
  37. package/lib/config/versions/magento-2.3.7-p1.js +9 -1
  38. package/lib/config/versions/magento-2.3.7-p2.js +9 -1
  39. package/lib/config/versions/magento-2.3.7-p3.js +9 -1
  40. package/lib/config/versions/magento-2.3.7.js +9 -1
  41. package/lib/config/versions/magento-2.4.0-p1.js +9 -1
  42. package/lib/config/versions/magento-2.4.0.js +9 -1
  43. package/lib/config/versions/magento-2.4.1-p1.js +9 -1
  44. package/lib/config/versions/magento-2.4.1.js +9 -1
  45. package/lib/config/versions/magento-2.4.2-p1.js +9 -1
  46. package/lib/config/versions/magento-2.4.2-p2.js +9 -1
  47. package/lib/config/versions/magento-2.4.2.js +9 -1
  48. package/lib/config/versions/magento-2.4.3-p1.js +9 -1
  49. package/lib/config/versions/magento-2.4.3-p2.js +9 -1
  50. package/lib/config/versions/magento-2.4.3.js +9 -1
  51. package/lib/config/versions/magento-2.4.4.js +9 -1
  52. package/lib/config/xml-parser.js +5 -3
  53. package/lib/errors/known-error.js +15 -0
  54. package/lib/errors/unknown-error.js +15 -0
  55. package/lib/tasks/cli/create-bashrc-config.js +7 -3
  56. package/lib/tasks/composer/index.js +5 -3
  57. package/lib/tasks/composer/local-auth-json.js +4 -2
  58. package/lib/tasks/docker/containers.js +13 -8
  59. package/lib/tasks/docker/network.js +2 -1
  60. package/lib/tasks/docker/volumes.js +4 -4
  61. package/lib/tasks/file-system/create-nginx-config.js +9 -40
  62. package/lib/tasks/file-system/create-php-config.js +2 -1
  63. package/lib/tasks/file-system/create-php-fpm-config.js +2 -1
  64. package/lib/tasks/file-system/create-phpstorm-config/database-config.js +5 -4
  65. package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +12 -10
  66. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +0 -3
  67. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +0 -3
  68. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +1 -1
  69. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +0 -3
  70. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +0 -3
  71. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +1 -4
  72. package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +1 -4
  73. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +1 -11
  74. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +1 -6
  75. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +1 -11
  76. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +2 -3
  77. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +1 -4
  78. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +2 -4
  79. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +1 -11
  80. package/lib/tasks/file-system/create-ssl-terminator-config.js +96 -0
  81. package/lib/tasks/file-system/create-varnish-config.js +53 -0
  82. package/lib/tasks/file-system/create-vscode-config.js +3 -2
  83. package/lib/tasks/file-system/index.js +5 -1
  84. package/lib/tasks/magento/enable-magento-composer-plugins.js +3 -2
  85. package/lib/tasks/magento/install-magento.js +7 -5
  86. package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +26 -0
  87. package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +1 -1
  88. package/lib/tasks/magento/setup-magento/delete-admin-users.js +1 -1
  89. package/lib/tasks/magento/setup-magento/delete-customers.js +7 -4
  90. package/lib/tasks/magento/setup-magento/delete-orders.js +6 -4
  91. package/lib/tasks/magento/setup-magento/disable-2fa.js +4 -12
  92. package/lib/tasks/magento/setup-magento/flush-redis-config.js +2 -1
  93. package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +14 -16
  94. package/lib/tasks/magento/setup-magento/index.js +3 -1
  95. package/lib/tasks/magento/setup-magento/install-magento.js +2 -1
  96. package/lib/tasks/magento/setup-magento/migrate-database.js +24 -11
  97. package/lib/tasks/magento/setup-magento/set-base-url.js +7 -2
  98. package/lib/tasks/magento/setup-magento/upgrade-magento.js +27 -3
  99. package/lib/tasks/magento/setup-magento/varnish-config.js +69 -0
  100. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +41 -0
  101. package/lib/tasks/mysql/connect-to-mysql.js +2 -1
  102. package/lib/tasks/mysql/fix-db.js +2 -2
  103. package/lib/tasks/mysql/import-dump-to-mysql.js +13 -2
  104. package/lib/tasks/mysql/import-remote-db/index.js +2 -1
  105. package/lib/tasks/mysql/import-remote-db/ssh/index.js +2 -1
  106. package/lib/tasks/mysql/import-remote-db/ssh/regular-server.js +2 -1
  107. package/lib/tasks/php/bundled-extensions.js +28 -0
  108. package/lib/tasks/php/compile-options.js +27 -54
  109. package/lib/tasks/php/compile.js +6 -4
  110. package/lib/tasks/php/configure.js +7 -66
  111. package/lib/tasks/php/extensions/disable.js +2 -1
  112. package/lib/tasks/php/extensions/enable.js +2 -1
  113. package/lib/tasks/php/extensions/index.js +74 -0
  114. package/lib/tasks/php/extensions/install.js +3 -3
  115. package/lib/tasks/php/index.js +8 -7
  116. package/lib/tasks/php/install-sodium.js +93 -0
  117. package/lib/tasks/php/update-env-php.js +16 -1
  118. package/lib/tasks/php/update-env.php +56 -12
  119. package/lib/tasks/php/update-phpbrew.js +7 -3
  120. package/lib/tasks/php/validate-php.js +67 -0
  121. package/lib/tasks/php-fpm/start-php-fpm.js +4 -2
  122. package/lib/tasks/requirements/composer.js +7 -5
  123. package/lib/tasks/requirements/dependency/arch.js +2 -1
  124. package/lib/tasks/requirements/dependency/centos.js +2 -1
  125. package/lib/tasks/requirements/dependency/fedora.js +2 -1
  126. package/lib/tasks/requirements/dependency/mac.js +18 -3
  127. package/lib/tasks/requirements/docker/index.js +96 -40
  128. package/lib/tasks/requirements/docker/install-on-mac.js +29 -0
  129. package/lib/tasks/requirements/docker/install.js +13 -12
  130. package/lib/tasks/requirements/docker/running-status.js +138 -0
  131. package/lib/tasks/requirements/docker/version.js +3 -0
  132. package/lib/tasks/requirements/index.js +8 -5
  133. package/lib/tasks/requirements/node-version.js +2 -1
  134. package/lib/tasks/requirements/php-version.js +29 -25
  135. package/lib/tasks/requirements/phpbrew/index.js +2 -1
  136. package/lib/tasks/requirements/phpbrew/install.js +14 -2
  137. package/lib/tasks/requirements/phpbrew/version.js +2 -1
  138. package/lib/tasks/requirements/platform.js +5 -3
  139. package/lib/tasks/requirements/rosetta.js +32 -0
  140. package/lib/tasks/start.js +8 -9
  141. package/lib/tasks/status/index.js +25 -9
  142. package/lib/tasks/theme/build-theme.js +27 -8
  143. package/lib/tasks/theme/install-theme.js +18 -5
  144. package/lib/tasks/theme/link-theme.js +2 -2
  145. package/lib/tasks/theme/retrieve-theme-data.js +2 -1
  146. package/lib/tasks/theme/setup-persisted-query.js +5 -4
  147. package/lib/tasks/theme/setup-themes.js +11 -3
  148. package/lib/tasks/theme/symlink-theme.js +26 -4
  149. package/lib/util/CSA-theme.js +4 -0
  150. package/lib/util/analytics.js +337 -0
  151. package/lib/util/arch.js +1 -1
  152. package/lib/util/config-file-validator.js +14 -2
  153. package/lib/util/config-php-json.js +20 -0
  154. package/lib/util/env-php-json.js +3 -2
  155. package/lib/util/exec-async-command.d.ts +2 -0
  156. package/lib/util/exec-async-command.js +31 -15
  157. package/lib/util/exec-async.js +9 -0
  158. package/lib/util/get-brew-bin-path.js +64 -0
  159. package/lib/util/get-installed-magento-version.js +3 -2
  160. package/lib/util/get-jsonfile-data.js +2 -1
  161. package/lib/util/install-dependencies-task.js +15 -5
  162. package/lib/util/instance-metadata.js +4 -3
  163. package/lib/util/ip.js +45 -1
  164. package/lib/util/is-running-root.js +3 -0
  165. package/lib/util/magento-task.js +20 -9
  166. package/lib/util/match-filesystem.js +2 -1
  167. package/lib/util/php-task.js +7 -3
  168. package/lib/util/request.js +0 -0
  169. package/lib/util/resolve-configuration-with-overrides.js +2 -1
  170. package/lib/util/run-composer.js +5 -3
  171. package/lib/util/run-magento.js +3 -2
  172. package/lib/util/run-php.js +14 -3
  173. package/lib/util/systemctl.js +46 -0
  174. package/lib/util/wait-for-it.js +3 -2
  175. package/package.json +4 -3
  176. package/typings/context.d.ts +6 -1
  177. package/typings/index.d.ts +32 -1
  178. package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -27
  179. package/lib/tasks/magento/setup-magento/disable-page-cache.js +0 -11
@@ -0,0 +1,138 @@
1
+ const KnownError = require('../../../errors/known-error');
2
+ const { execAsyncSpawn } = require('../../../util/exec-async-command');
3
+ const pathExists = require('../../../util/path-exists');
4
+ const sleep = require('../../../util/sleep');
5
+ const { systemctlControl } = require('../../../util/systemctl');
6
+
7
+ const pathToDockerApplication = '/Applications/Docker.app';
8
+
9
+ const getDockerVersion = () => execAsyncSpawn('docker version --format {{.Server.Version}}', {
10
+ withCode: true
11
+ });
12
+
13
+ /**
14
+ * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
15
+ */
16
+ const checkDockerStatusMacOS = () => ({
17
+ title: 'Checking Docker status on MacOS',
18
+ task: async (ctx, task) => {
19
+ const { result, code } = await getDockerVersion();
20
+
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...');
35
+ }
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) {
46
+ //
47
+ }
48
+ }
49
+
50
+ return;
51
+ }
52
+
53
+ task.skip('User skipped running Docker');
54
+ }
55
+ }
56
+ },
57
+ options: {
58
+ bottomBar: 10
59
+ }
60
+ });
61
+
62
+ /**
63
+ * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
64
+ */
65
+ const checkDockerStatusWSL = () => ({
66
+ title: 'Checking Docker status on Windows WSL',
67
+ task: async () => {
68
+ const { result, code } = await getDockerVersion();
69
+
70
+ if (code !== 0 && result.includes('Is the docker daemon running?')) {
71
+ throw new KnownError(`Docker is not running!
72
+
73
+ Please open Docker Desktop application for Windows and make sure that Docker is running. Then you can try again!`);
74
+ }
75
+ }
76
+ });
77
+
78
+ /**
79
+ * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
80
+ */
81
+ const checkDockerStatusLinux = () => ({
82
+ title: 'Checking Docker status on Linux',
83
+ task: async (ctx, task) => {
84
+ const dockerService = systemctlControl('docker');
85
+
86
+ const isRunning = await dockerService.isRunning();
87
+ const isEnabled = await dockerService.isEnabled();
88
+
89
+ if (!isEnabled && !isRunning) {
90
+ const dockerStartConfirmation = await task.prompt({
91
+ type: 'Confirm',
92
+ message: `Looks like Docker is not enabled and not running, would you like to enable and run it?
93
+
94
+ This action requires root privileges.`
95
+ });
96
+
97
+ if (dockerStartConfirmation) {
98
+ await dockerService.enableAndStart();
99
+
100
+ return;
101
+ }
102
+ task.skip('User skipped running Docker');
103
+ } else if (!isRunning) {
104
+ const dockerStartConfirmation = await task.prompt({
105
+ type: 'Confirm',
106
+ message: `Looks like Docker is not running, would you like to run it?
107
+
108
+ This action requires root privileges.`
109
+ });
110
+
111
+ if (dockerStartConfirmation) {
112
+ await dockerService.start();
113
+
114
+ return;
115
+ }
116
+ task.skip('User skipped running Docker');
117
+ }
118
+ }
119
+ });
120
+
121
+ /**
122
+ * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
123
+ */
124
+ const checkDockerStatus = () => ({
125
+ title: 'Checking Docker status',
126
+ task: async (ctx, task) => {
127
+ if (ctx.platform === 'darwin') {
128
+ return task.newListr(checkDockerStatusMacOS());
129
+ }
130
+ if (!ctx.isWsl) {
131
+ return task.newListr(checkDockerStatusLinux());
132
+ }
133
+
134
+ return task.newListr(checkDockerStatusWSL());
135
+ }
136
+ });
137
+
138
+ module.exports = checkDockerStatus;
@@ -1,3 +1,4 @@
1
+ const UnknownError = require('../../../errors/unknown-error');
1
2
  const { execAsyncSpawn } = require('../../../util/exec-async-command');
2
3
 
3
4
  /**
@@ -13,6 +14,8 @@ const getDockerVersion = () => ({
13
14
  const dockerVersion = result.split('').filter((c) => /[\d.]/i.test(c)).join('') || result;
14
15
 
15
16
  ctx.dockerVersion = dockerVersion;
17
+ } else {
18
+ throw new UnknownError(`Got unexpected result during Docker version retrieval!\n\n${ result }`);
16
19
  }
17
20
  }
18
21
  });
@@ -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,17 +14,19 @@ 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(),
19
+ // check the Docker installation
20
+ checkDocker(),
21
+ // check for Node.js version
22
+ checkNodeVersion(),
16
23
  // check the PHPBrew installation
17
24
  checkPHPbrew(),
18
25
  // check installed PHP version
19
26
  checkPHPVersion(),
20
- // check the Docker installation
21
- checkDocker(),
22
27
  // check for COMPOSER_AUTH or auth.json
23
28
  // localAuthJson(),
24
- checkComposer(),
25
- // check for Node.js version
26
- checkNodeVersion()
29
+ checkComposer()
27
30
  ], {
28
31
  concurrent: false,
29
32
  exitOnError: true,
@@ -1,4 +1,5 @@
1
1
  const semver = require('semver');
2
+ const KnownError = require('../../errors/known-error');
2
3
 
3
4
  /**
4
5
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
@@ -9,7 +10,7 @@ const checkNodeVersion = () => ({
9
10
  const { node } = process.versions;
10
11
 
11
12
  if (!semver.gte(node, '12.0.0')) {
12
- throw new Error(
13
+ throw new KnownError(
13
14
  `Your Node.js version is out of date!
14
15
  You need to upgrade Node.js to at lease version 12 to work with this software!`
15
16
  );
@@ -3,44 +3,45 @@ const fs = require('fs');
3
3
  const path = require('path');
4
4
  const semver = require('semver');
5
5
  const phpbrewConfig = require('../../config/phpbrew');
6
+ const KnownError = require('../../errors/known-error');
7
+ const UnknownError = require('../../errors/unknown-error');
6
8
  const { execAsyncSpawn } = require('../../util/exec-async-command');
9
+ const { getBrewCommandSync } = require('../../util/get-brew-bin-path');
7
10
  const pathExists = require('../../util/path-exists');
8
11
  const compileOptions = require('../php/compile-options');
9
12
 
10
13
  const latestStablePHP74 = '7.4.27';
11
14
  const phpbrewPHPName = `php-${latestStablePHP74}-phpbrew`;
12
15
 
13
- const compileOptionsForPhp = {
14
- linux: {
15
- ...compileOptions.linux,
16
- variants: [
17
- '+default'
18
- ],
19
- extraOptions: []
20
- },
21
- darwin: {
22
- ...compileOptions.darwin,
23
- variants: [
24
- '+default',
25
- '+openssl=$(brew --prefix openssl@1.1)'
26
- ],
27
- extraOptions: []
28
- }
29
- };
30
-
31
16
  /**
32
17
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
33
18
  */
34
19
  const installPHPForPHPBrew = () => ({
35
20
  title: `Installing PHP ${latestStablePHP74} for PHPBrew...`,
36
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
+ };
37
39
  const platformCompileOptions = compileOptionsForPhp[process.platform];
38
40
 
39
41
  if (!await pathExists(path.join(phpbrewConfig.phpPath, `${phpbrewPHPName}`, 'bin'))) {
40
42
  const commandEnv = Object.entries(platformCompileOptions.env || {}).map(([key, value]) => `${key}="${value}"`).join(' ');
41
-
42
43
  // eslint-disable-next-line max-len
43
- 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(' ')}`;
44
45
 
45
46
  try {
46
47
  await execAsyncSpawn(
@@ -48,11 +49,12 @@ const installPHPForPHPBrew = () => ({
48
49
  {
49
50
  callback: (t) => {
50
51
  task.output = t;
51
- }
52
+ },
53
+ useRosetta2: true
52
54
  }
53
55
  );
54
56
  } catch (e) {
55
- throw new Error(
57
+ throw new KnownError(
56
58
  `Failed to compile the required by PHPBrew PHP version.
57
59
  Tried compiling the PHP version ${ latestStablePHP74 }.
58
60
  Use your favorite search engine to resolve the issue.
@@ -79,10 +81,10 @@ export PHPBREW_PATH=${phpbrewConfig.homePath}/php/${phpbrewPHPName}/bin
79
81
  }
80
82
  );
81
83
  } catch (e) {
82
- throw new Error(`Something went wrong when trying to switch PHP to ${phpbrewPHPName}!\n\n${e}`);
84
+ throw new UnknownError(`Something went wrong when trying to switch PHP to ${phpbrewPHPName}!\n\n${e}`);
83
85
  }
84
86
 
85
- throw new Error(`You will need to restart your terminal and run ${logger.style.command('start')} again.
87
+ throw new KnownError(`You will need to restart your terminal and run ${logger.style.command('start')} again.
86
88
 
87
89
  You can use keyboard shortcut ${logger.style.command('CTRL+D')} to close terminal.`);
88
90
  },
@@ -99,7 +101,7 @@ const checkPHPVersion = () => ({
99
101
  task: async (ctx, task) => {
100
102
  const phpVersionResponse = await execAsyncSpawn('php --version');
101
103
 
102
- const phpVersionResponseResult = phpVersionResponse.match(/PHP\s(\d\.\d\.\d)/i);
104
+ const phpVersionResponseResult = phpVersionResponse.match(/PHP\s(\d+\.\d+\.\d+)/i);
103
105
 
104
106
  if (phpVersionResponseResult && phpVersionResponseResult.length > 0) {
105
107
  const phpVersion = phpVersionResponseResult[1];
@@ -123,6 +125,8 @@ To fix that we will build special PHP version that will be used by PHPBrew, plea
123
125
  );
124
126
  }
125
127
  }
128
+
129
+ task.title = `Using PHP version ${phpVersion} in system`;
126
130
  }
127
131
  }
128
132
  });
@@ -1,4 +1,5 @@
1
1
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
2
+ const KnownError = require('../../../errors/known-error');
2
3
  const { execAsyncSpawn } = require('../../../util/exec-async-command');
3
4
  const installPHPBrew = require('./install');
4
5
  const getPHPBrewVersion = require('./version');
@@ -32,7 +33,7 @@ Do you want to install it automatically?`
32
33
  ]);
33
34
  }
34
35
 
35
- throw new Error(
36
+ throw new KnownError(
36
37
  `To install PHPBrew, you must first make sure the requirements are met.
37
38
  The requirements are available here: ${ logger.style.link('https://github.com/phpbrew/phpbrew/wiki/Requirement') }.
38
39
  Then, you can follow the installation instruction, here: ${ logger.style.link('https://phpbrew.github.io/phpbrew/#installation') }.
@@ -5,6 +5,8 @@ const { execAsyncSpawn } = require('../../../util/exec-async-command');
5
5
  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
+ const KnownError = require('../../../errors/known-error');
9
+ const { getBrewCommand } = require('../../../util/get-brew-bin-path');
8
10
 
9
11
  /**
10
12
  * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
@@ -13,10 +15,20 @@ const installPHPBrewDependencies = () => ({
13
15
  title: 'Installing PHPBrew dependencies',
14
16
  task: async (ctx, task) => {
15
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
+
16
27
  return task.newListr(
17
28
  installDependenciesTask({
18
29
  platform: 'darwin',
19
- dependenciesToInstall: ['php', 'autoconf', 'pkg-config']
30
+ dependenciesToInstall,
31
+ useMacNativeEnvironment: true
20
32
  })
21
33
  );
22
34
  }
@@ -167,7 +179,7 @@ When you ready, press select Yes and installation will continue.`
167
179
  });
168
180
 
169
181
  if (!continueInstall) {
170
- throw new Error(`Add following string to your shells configuration file: ${logger.style.code('[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc')}
182
+ throw new KnownError(`Add following string to your shells configuration file: ${logger.style.code('[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc')}
171
183
 
172
184
  Then you can continue installation.`);
173
185
  }
@@ -1,3 +1,4 @@
1
+ const UnknownError = require('../../../errors/unknown-error');
1
2
  const { execAsyncSpawn } = require('../../../util/exec-async-command');
2
3
  const safeRegexExtract = require('../../../util/safe-regex-extract');
3
4
 
@@ -15,7 +16,7 @@ const getPHPBrewVersion = () => ({
15
16
  string: result,
16
17
  regex: /phpbrew - ([\d.]+)/i,
17
18
  onNoMatch: () => {
18
- throw new Error(`No phpbrew version found in phpbrew version output!\n\n${result}`);
19
+ throw new UnknownError(`No phpbrew version found in phpbrew version output!\n\n${result}`);
19
20
  }
20
21
  });
21
22
 
@@ -6,9 +6,10 @@ const { platforms, darwinMinimalVersion } = require('../../config');
6
6
  const dependencyCheck = require('./dependency');
7
7
  const { getArch } = require('../../util/arch');
8
8
  const getIsWsl = require('../../util/is-wsl');
9
+ const KnownError = require('../../errors/known-error');
9
10
 
10
11
  /**
11
- * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
12
+ * @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
12
13
  */
13
14
  const checkPlatform = () => ({
14
15
  title: 'Checking platform',
@@ -16,14 +17,14 @@ const checkPlatform = () => ({
16
17
  const currentPlatform = os.platform();
17
18
 
18
19
  if (!platforms.includes(currentPlatform)) {
19
- throw new Error(
20
+ throw new KnownError(
20
21
  `Your current OS platform is ${ logger.style.misc(currentPlatform) }.
21
22
  Unfortunately, currently we only support ${ platforms.map((platform) => logger.style.misc(platform)).join(',') }.`
22
23
  );
23
24
  }
24
25
 
25
26
  if (macosVersion.isMacOS && !macosVersion.isGreaterThanOrEqualTo(darwinMinimalVersion)) {
26
- throw new Error(
27
+ throw new KnownError(
27
28
  'Please update your system!',
28
29
  `MacOS bellow version ${ logger.style.misc(darwinMinimalVersion) } is not supported.`
29
30
  );
@@ -36,6 +37,7 @@ const checkPlatform = () => ({
36
37
 
37
38
  ctx.platform = currentPlatform;
38
39
  ctx.platformVersion = currentPlatform !== 'darwin' ? os.release() : macosVersion();
40
+ ctx.isArmMac = ctx.isArm && ctx.platform === 'darwin';
39
41
 
40
42
  const { manufacturer, brand, cores } = await systeminformation.cpu();
41
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;
@@ -30,6 +30,8 @@ const enableMagentoComposerPlugins = require('./magento/enable-magento-composer-
30
30
  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
+ const validatePHPInstallation = require('./php/validate-php');
34
+ const installSodiumExtension = require('./php/install-sodium');
33
35
 
34
36
  /**
35
37
  * @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
@@ -112,7 +114,9 @@ const configureProject = () => ({
112
114
  exitOnError: true
113
115
  })
114
116
  },
117
+ installSodiumExtension(),
115
118
  configurePhp(),
119
+ validatePHPInstallation(),
116
120
  installPrestissimo(),
117
121
  installMagento(),
118
122
  enableMagentoComposerPlugins(),
@@ -127,6 +131,7 @@ const configureProject = () => ({
127
131
  */
128
132
  const finishProjectConfiguration = () => ({
129
133
  title: 'Finishing project configuration',
134
+ skip: ({ skipSetup }) => skipSetup,
130
135
  task: (ctx, task) => task.newListr([
131
136
  {
132
137
  skip: (ctx) => !ctx.importDb,
@@ -144,16 +149,10 @@ const finishProjectConfiguration = () => ({
144
149
  });
145
150
  }
146
151
  },
147
- {
148
- title: 'Setting up themes',
149
- skip: (ctx) => !ctx.magentoFirstInstall,
150
- task: (subCtx, subTask) => subTask.newListr(
151
- setupThemes()
152
- )
153
- }
152
+ setupThemes()
154
153
  ], {
155
154
  rendererOptions: {
156
- collapse: true
155
+ collapse: false
157
156
  }
158
157
  })
159
158
  });
@@ -194,7 +193,7 @@ const start = () => ({
194
193
  const instanceMetadata = getInstanceMetadata(ctx);
195
194
  const locationOnTheWeb = instanceMetadata.frontend.find(({ title }) => title === WEB_LOCATION_TITLE);
196
195
 
197
- openBrowser(locationOnTheWeb.text);
196
+ openBrowser(locationOnTheWeb.link);
198
197
  },
199
198
  options: {
200
199
  showTimer: false
@@ -6,6 +6,7 @@ const { version: packageVersion } = require('../../../package.json');
6
6
  const { getArchSync } = require('../../util/arch');
7
7
  const ConsoleBlock = require('../../util/console-block');
8
8
  const { getComposerVersion } = require('../composer');
9
+ const { getInstanceMetadata } = require('../../util/instance-metadata');
9
10
 
10
11
  /**
11
12
  * @param {string} port
@@ -23,11 +24,8 @@ const parsePort = (port) => {
23
24
 
24
25
  const prettyStatus = async (ctx) => {
25
26
  const {
26
- ports,
27
27
  config: {
28
- magentoConfiguration,
29
28
  baseConfig,
30
- overridenConfiguration: { host, ssl },
31
29
  php,
32
30
  composer
33
31
  },
@@ -91,7 +89,7 @@ const prettyStatus = async (ctx) => {
91
89
  .addLine(`Image: ${logger.style.file(container.image)}`)
92
90
  .addLine(`Network: ${logger.style.link(container.network)}`);
93
91
 
94
- if (container.ports.length > 0) {
92
+ if (container.ports && container.ports.length > 0) {
95
93
  block.addLine('Port forwarding:');
96
94
  container.ports.forEach((port) => {
97
95
  const { host, hostPort, containerPort } = parsePort(port);
@@ -107,15 +105,33 @@ const prettyStatus = async (ctx) => {
107
105
  }
108
106
  });
109
107
 
108
+ const instanceMetadata = getInstanceMetadata(ctx);
109
+
110
110
  block
111
111
  .addEmptyLine()
112
- .addSeparator('Magento status')
113
- .addEmptyLine()
114
- .addLine(`Web location: ${logger.style.link(`${ssl.enabled ? 'https' : 'http'}://${host}${ports.app === 80 ? '' : `:${ports.app}`}/`)}`)
115
- .addLine(`Magento Admin panel location: ${logger.style.link(`${ssl.enabled ? 'https' : 'http'}://${host}${ports.app === 80 ? '' : `:${ports.app}`}/${magentoConfiguration.adminuri}`)}`)
116
- .addLine(`Magento Admin panel credentials: ${logger.style.misc(magentoConfiguration.user)} - ${logger.style.misc(magentoConfiguration.password)}`)
112
+ .addSeparator('Magento 2')
117
113
  .addEmptyLine();
118
114
 
115
+ block.addLine(logger.style.misc('Frontend'));
116
+ instanceMetadata.frontend.forEach(({ title, text }) => {
117
+ block.addLine(` ${title}: ${text}`);
118
+ });
119
+
120
+ block.addEmptyLine();
121
+
122
+ block.addLine(logger.style.misc('Admin'));
123
+ instanceMetadata.admin.forEach(({ title, text }) => {
124
+ block.addLine(` ${title}: ${text}`);
125
+ });
126
+ // block
127
+ // .addEmptyLine()
128
+ // .addSeparator('Magento status')
129
+ // .addEmptyLine()
130
+ // .addLine(`Web location: ${logger.style.link(`${ssl.enabled ? 'https' : 'http'}://${host}${ports.app === 80 ? '' : `:${ports.app}`}/`)}`)
131
+ // .addLine(`Magento Admin panel location: ${logger.style.link(`${ssl.enabled ? 'https' : 'http'}://${host}${ports.app === 80 ? '' : `:${ports.app}`}/${magentoConfiguration.adminuri}`)}`)
132
+ // .addLine(`Magento Admin panel credentials: ${logger.style.misc(magentoConfiguration.user)} - ${logger.style.misc(magentoConfiguration.password)}`)
133
+ // .addEmptyLine();
134
+
119
135
  block.log();
120
136
  };
121
137
 
@@ -1,7 +1,9 @@
1
1
  const path = require('path');
2
2
  const pathExists = require('../../util/path-exists');
3
3
  const { execAsyncSpawn } = require('../../util/exec-async-command');
4
- const shouldUseYarn = require('@scandipwa/scandipwa-dev-utils/should-use-yarn');
4
+ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
5
+ const matchFilesystem = require('../../util/match-filesystem');
6
+ const UnknownError = require('../../errors/unknown-error');
5
7
 
6
8
  /**
7
9
  * @type {(theme: import('../../../typings/theme').Theme) => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
@@ -13,15 +15,32 @@ const buildTheme = ({ themePath }) => ({
13
15
 
14
16
  if (!await pathExists(path.join(themePath, 'node_modules'))) {
15
17
  task.output = 'Installing theme dependencies';
16
- await execAsyncSpawn(shouldUseYarn() ? 'yarn' : 'npm i', {
17
- cwd: path.join(process.cwd(), themePath),
18
- callback: !verbose ? undefined : (t) => {
19
- task.output = t;
20
- }
21
- });
18
+ const commandToInstallDependencies = await pathExists(path.join(themePath, 'package-lock.json'))
19
+ ? 'npm ci'
20
+ : 'npm i';
21
+
22
+ try {
23
+ await execAsyncSpawn(commandToInstallDependencies, {
24
+ cwd: path.join(process.cwd(), themePath),
25
+ callback: !verbose ? undefined : (t) => {
26
+ task.output = t;
27
+ }
28
+ });
29
+ } catch (e) {
30
+ throw new UnknownError(`We were unable to install theme dependencies in ${themePath} using ${logger.style.code(commandToInstallDependencies)} command!
31
+ If you have ${logger.style.file('package-lock.json')} in theme directory make sure it's up to date with ${logger.style.file('package.json')} file content.`);
32
+ }
22
33
  }
23
34
 
24
- if (await pathExists(path.join(themePath, 'magento', 'Magento_Theme'))) {
35
+ const magentoThemeDirPath = path.join(themePath, 'magento', 'Magento_Theme');
36
+ const isMagentoThemeDirMatching = await matchFilesystem(magentoThemeDirPath, {
37
+ templates: true,
38
+ web: [
39
+ 'static'
40
+ ]
41
+ });
42
+
43
+ if (isMagentoThemeDirMatching) {
25
44
  task.skip();
26
45
  return;
27
46
  }
@@ -1,24 +1,37 @@
1
+ const path = require('path');
2
+ const UnknownError = require('../../errors/unknown-error');
3
+ const getJsonfileData = require('../../util/get-jsonfile-data');
1
4
  const runComposerCommand = require('../../util/run-composer');
2
5
 
3
6
  /**
4
7
  * @type {(theme: import('../../../typings/theme').Theme) => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
5
8
  */
6
- const installTheme = ({ composerData }) => ({
9
+ const installTheme = (theme) => ({
7
10
  title: 'Installing theme in composer.json',
8
- task: async ({ magentoVersion, verbose = false }, task) => {
11
+ task: async (ctx, task) => {
12
+ const { magentoVersion, verbose = false } = ctx;
13
+ const composerJsonData = await getJsonfileData(path.join(process.cwd(), 'composer.json'));
14
+
15
+ if (composerJsonData.require[theme.composerData.name]) {
16
+ task.skip();
17
+ return;
18
+ }
19
+
9
20
  try {
10
- await runComposerCommand(`require ${composerData.name}`, {
21
+ await runComposerCommand(`require ${theme.composerData.name}`, {
11
22
  magentoVersion,
12
23
  callback: !verbose ? undefined : (t) => {
13
24
  task.output = t;
14
25
  }
15
26
  });
16
27
  } catch (e) {
17
- throw new Error(
28
+ throw new UnknownError(
18
29
  `Unexpected error while installing theme.
19
- See ERROR log below.\n\n${e}`
30
+ See ERROR log below.\n\n${e}`
20
31
  );
21
32
  }
33
+
34
+ ctx.isSetupUpgradeNeeded = true;
22
35
  },
23
36
  options: {
24
37
  bottomBar: 10