@scandipwa/magento-scripts 1.14.1-alpha.7 → 1.15.0

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 (177) hide show
  1. package/lib/commands/cli.js +9 -4
  2. package/lib/commands/logs.js +1 -0
  3. package/lib/commands/start.js +18 -5
  4. package/lib/config/cma-config.js +16 -0
  5. package/lib/config/dependencies-for-platforms.js +15 -3
  6. package/lib/config/docker.js +46 -13
  7. package/lib/config/get-port-config.js +7 -2
  8. package/lib/config/index.js +2 -1
  9. package/lib/config/php/extensions/libsodium.js +2 -1
  10. package/lib/config/port-config.js +2 -1
  11. package/lib/config/scandipwa-versions.js +2 -1
  12. package/lib/config/ssl-terminator/index.js +10 -0
  13. package/lib/config/system-config.js +34 -5
  14. package/lib/config/templates/magentorc.template +2 -0
  15. package/lib/config/templates/nginx.template.conf +0 -31
  16. package/lib/config/templates/ssl-terminator.template.conf +27 -0
  17. package/lib/config/templates/varnish.template.vcl +9 -4
  18. package/lib/config/versions/magento-2.3.0.js +3 -1
  19. package/lib/config/versions/magento-2.3.1.js +3 -1
  20. package/lib/config/versions/magento-2.3.2-p2.js +3 -1
  21. package/lib/config/versions/magento-2.3.2.js +3 -1
  22. package/lib/config/versions/magento-2.3.3-p1.js +3 -1
  23. package/lib/config/versions/magento-2.3.3.js +3 -1
  24. package/lib/config/versions/magento-2.3.4-p2.js +3 -1
  25. package/lib/config/versions/magento-2.3.4.js +3 -1
  26. package/lib/config/versions/magento-2.3.5-p1.js +3 -1
  27. package/lib/config/versions/magento-2.3.5-p2.js +3 -1
  28. package/lib/config/versions/magento-2.3.5.js +3 -1
  29. package/lib/config/versions/magento-2.3.6-p1.js +3 -1
  30. package/lib/config/versions/magento-2.3.6.js +3 -1
  31. package/lib/config/versions/magento-2.3.7-p1.js +3 -1
  32. package/lib/config/versions/magento-2.3.7-p2.js +3 -1
  33. package/lib/config/versions/magento-2.3.7-p3.js +3 -1
  34. package/lib/config/versions/magento-2.3.7.js +3 -1
  35. package/lib/config/versions/magento-2.4.0-p1.js +3 -1
  36. package/lib/config/versions/magento-2.4.0.js +3 -1
  37. package/lib/config/versions/magento-2.4.1-p1.js +3 -1
  38. package/lib/config/versions/magento-2.4.1.js +3 -1
  39. package/lib/config/versions/magento-2.4.2-p1.js +3 -1
  40. package/lib/config/versions/magento-2.4.2-p2.js +3 -1
  41. package/lib/config/versions/magento-2.4.2.js +3 -1
  42. package/lib/config/versions/magento-2.4.3-p1.js +3 -1
  43. package/lib/config/versions/magento-2.4.3-p2.js +3 -1
  44. package/lib/config/versions/magento-2.4.3.js +3 -1
  45. package/lib/config/versions/magento-2.4.4.js +3 -1
  46. package/lib/config/xml-parser.js +63 -0
  47. package/lib/errors/known-error.js +15 -0
  48. package/lib/errors/unknown-error.js +15 -0
  49. package/lib/tasks/cli/create-bashrc-config.js +2 -1
  50. package/lib/tasks/composer/index.js +5 -3
  51. package/lib/tasks/composer/local-auth-json.js +8 -4
  52. package/lib/tasks/docker/network.js +2 -1
  53. package/lib/tasks/execute/index.js +2 -3
  54. package/lib/tasks/file-system/create-nginx-config.js +4 -43
  55. package/lib/tasks/file-system/create-php-config.js +2 -1
  56. package/lib/tasks/file-system/create-php-fpm-config.js +2 -1
  57. package/lib/tasks/file-system/create-phpstorm-config/database-config.js +249 -0
  58. package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +85 -0
  59. package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +154 -0
  60. package/lib/tasks/file-system/create-phpstorm-config/index.js +27 -0
  61. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +26 -0
  62. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/config.js +54 -0
  63. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +28 -0
  64. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +42 -0
  65. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/eslint-inspection-config.js +37 -0
  66. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/index.js +80 -0
  67. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +26 -0
  68. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +142 -0
  69. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/paths.js +20 -0
  70. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-fixer-validation-inspection-config.js +60 -0
  71. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +116 -0
  72. package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/stylelint-inspection-config.js +37 -0
  73. package/lib/tasks/file-system/create-phpstorm-config/keys.js +14 -0
  74. package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +67 -0
  75. package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +54 -0
  76. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +66 -0
  77. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +58 -0
  78. package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +59 -0
  79. package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +77 -0
  80. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +97 -0
  81. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/format-setting-config.js +57 -0
  82. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +66 -0
  83. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +64 -0
  84. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +57 -0
  85. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +49 -0
  86. package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +64 -0
  87. package/lib/tasks/file-system/create-phpstorm-config/xml-utils.js +5 -0
  88. package/lib/tasks/file-system/create-ssl-terminator-config.js +96 -0
  89. package/lib/tasks/file-system/create-varnish-config.js +2 -1
  90. package/lib/tasks/file-system/create-vscode-config.js +3 -2
  91. package/lib/tasks/file-system/index.js +3 -1
  92. package/lib/tasks/magento/enable-magento-composer-plugins.js +3 -2
  93. package/lib/tasks/magento/install-magento.js +7 -5
  94. package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +26 -0
  95. package/lib/tasks/magento/setup-magento/delete-admin-users.js +1 -1
  96. package/lib/tasks/magento/setup-magento/delete-customers.js +7 -4
  97. package/lib/tasks/magento/setup-magento/delete-orders.js +6 -4
  98. package/lib/tasks/magento/setup-magento/flush-redis-config.js +2 -1
  99. package/lib/tasks/magento/setup-magento/index.js +3 -1
  100. package/lib/tasks/magento/setup-magento/install-magento.js +2 -1
  101. package/lib/tasks/magento/setup-magento/set-base-url.js +7 -2
  102. package/lib/tasks/magento/setup-magento/upgrade-magento.js +11 -1
  103. package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +41 -0
  104. package/lib/tasks/mysql/connect-to-mysql.js +2 -1
  105. package/lib/tasks/mysql/import-dump-to-mysql.js +13 -2
  106. package/lib/tasks/mysql/import-remote-db/index.js +2 -1
  107. package/lib/tasks/mysql/import-remote-db/ssh/index.js +2 -1
  108. package/lib/tasks/mysql/import-remote-db/ssh/regular-server.js +2 -1
  109. package/lib/tasks/php/bundled-extensions.js +28 -0
  110. package/lib/tasks/php/compile-options.js +27 -54
  111. package/lib/tasks/php/compile.js +6 -4
  112. package/lib/tasks/php/configure.js +7 -66
  113. package/lib/tasks/php/extensions/disable.js +2 -1
  114. package/lib/tasks/php/extensions/enable.js +2 -1
  115. package/lib/tasks/php/extensions/index.js +74 -0
  116. package/lib/tasks/php/extensions/install.js +3 -3
  117. package/lib/tasks/php/index.js +7 -6
  118. package/lib/tasks/php/install-sodium.js +93 -0
  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 +59 -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 +94 -40
  128. package/lib/tasks/requirements/docker/install-on-mac.js +29 -0
  129. package/lib/tasks/requirements/docker/install.js +2 -1
  130. package/lib/tasks/requirements/docker/running-status.js +32 -31
  131. package/lib/tasks/requirements/docker/version.js +2 -1
  132. package/lib/tasks/requirements/index.js +3 -0
  133. package/lib/tasks/requirements/node-version.js +2 -1
  134. package/lib/tasks/requirements/php-version.js +26 -24
  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 +10 -2
  141. package/lib/tasks/status/index.js +24 -8
  142. package/lib/tasks/theme/build-theme.js +2 -1
  143. package/lib/tasks/theme/install-theme.js +2 -1
  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 +2 -1
  147. package/lib/tasks/theme/setup-themes.js +10 -3
  148. package/lib/tasks/theme/symlink-theme.js +8 -1
  149. package/lib/util/CSA-theme.js +4 -0
  150. package/lib/util/analytics.js +317 -0
  151. package/lib/util/arch.js +1 -1
  152. package/lib/util/config-file-validator.js +4 -2
  153. package/lib/util/config-php-json.js +3 -2
  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 +11 -4
  163. package/lib/util/ip.js +47 -1
  164. package/lib/util/magento-task.js +20 -9
  165. package/lib/util/php-task.js +7 -7
  166. package/lib/util/request.js +0 -0
  167. package/lib/util/resolve-configuration-with-overrides.js +2 -1
  168. package/lib/util/run-composer.js +5 -3
  169. package/lib/util/run-magento.js +3 -2
  170. package/lib/util/run-php.js +7 -2
  171. package/lib/util/wait-for-it.js +3 -2
  172. package/package.json +5 -3
  173. package/typings/context.d.ts +4 -0
  174. package/typings/index.d.ts +13 -1
  175. package/typings/phpstorm.d.ts +33 -0
  176. package/lib/tasks/file-system/create-php-storm-config.js +0 -82
  177. package/lib/tasks/magento/setup-magento/disable-full-page-cache.js +0 -20
@@ -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
  },
@@ -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;
@@ -29,6 +29,9 @@ const convertLegacyVolumes = require('./docker/convert-legacy-volumes');
29
29
  const enableMagentoComposerPlugins = require('./magento/enable-magento-composer-plugins');
30
30
  const getIsWsl = require('../util/is-wsl');
31
31
  const checkForXDGOpen = require('../util/xdg-open-exists');
32
+ const { getInstanceMetadata, constants: { WEB_LOCATION_TITLE } } = require('../util/instance-metadata');
33
+ const validatePHPInstallation = require('./php/validate-php');
34
+ const installSodiumExtension = require('./php/install-sodium');
32
35
 
33
36
  /**
34
37
  * @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
@@ -111,7 +114,9 @@ const configureProject = () => ({
111
114
  exitOnError: true
112
115
  })
113
116
  },
117
+ installSodiumExtension(),
114
118
  configurePhp(),
119
+ validatePHPInstallation(),
115
120
  installPrestissimo(),
116
121
  installMagento(),
117
122
  enableMagentoComposerPlugins(),
@@ -184,8 +189,11 @@ const start = () => ({
184
189
 
185
190
  return false;
186
191
  },
187
- task: ({ ports, config: { overridenConfiguration: { host, ssl } } }) => {
188
- openBrowser(`${ssl.enabled ? 'https' : 'http'}://${host}${ssl.enabled || ports.app === 80 ? '' : `:${ports.app}`}/`);
192
+ task: (ctx) => {
193
+ const instanceMetadata = getInstanceMetadata(ctx);
194
+ const locationOnTheWeb = instanceMetadata.frontend.find(({ title }) => title === WEB_LOCATION_TITLE);
195
+
196
+ openBrowser(locationOnTheWeb.link);
189
197
  },
190
198
  options: {
191
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
  },
@@ -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
 
@@ -3,6 +3,7 @@ const pathExists = require('../../util/path-exists');
3
3
  const { execAsyncSpawn } = require('../../util/exec-async-command');
4
4
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
5
5
  const matchFilesystem = require('../../util/match-filesystem');
6
+ const UnknownError = require('../../errors/unknown-error');
6
7
 
7
8
  /**
8
9
  * @type {(theme: import('../../../typings/theme').Theme) => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
@@ -26,7 +27,7 @@ const buildTheme = ({ themePath }) => ({
26
27
  }
27
28
  });
28
29
  } catch (e) {
29
- throw new Error(`We were unable to install theme dependencies in ${themePath} using ${logger.style.code(commandToInstallDependencies)} command!
30
+ throw new UnknownError(`We were unable to install theme dependencies in ${themePath} using ${logger.style.code(commandToInstallDependencies)} command!
30
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.`);
31
32
  }
32
33
  }
@@ -1,4 +1,5 @@
1
1
  const path = require('path');
2
+ const UnknownError = require('../../errors/unknown-error');
2
3
  const getJsonfileData = require('../../util/get-jsonfile-data');
3
4
  const runComposerCommand = require('../../util/run-composer');
4
5
 
@@ -24,7 +25,7 @@ const installTheme = (theme) => ({
24
25
  }
25
26
  });
26
27
  } catch (e) {
27
- throw new Error(
28
+ throw new UnknownError(
28
29
  `Unexpected error while installing theme.
29
30
  See ERROR log below.\n\n${e}`
30
31
  );
@@ -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
  ]);
@@ -1,4 +1,5 @@
1
1
  const path = require('path');
2
+ const KnownError = require('../../errors/known-error');
2
3
  const getJsonfileData = require('../../util/get-jsonfile-data');
3
4
  const pathExists = require('../../util/path-exists');
4
5
 
@@ -26,7 +27,7 @@ const retrieveThemeData = (themePath) => ({
26
27
  const composerData = await getJsonfileData(path.join(absoluteThemePath, 'composer.json'));
27
28
 
28
29
  if (!composerData) {
29
- throw new Error(`composer.json file not found in "${themePath}"`);
30
+ throw new KnownError(`composer.json file not found in "${themePath}"`);
30
31
  }
31
32
 
32
33
  ctx.themePath = themePath;
@@ -1,4 +1,5 @@
1
1
  const path = require('path');
2
+ const UnknownError = require('../../errors/unknown-error');
2
3
  const envPhpToJson = require('../../util/env-php-json');
3
4
  const getJsonfileData = require('../../util/get-jsonfile-data');
4
5
  const runMagentoCommand = require('../../util/run-magento');
@@ -51,7 +52,7 @@ const persistedQuerySetup = () => ({
51
52
  magentoVersion
52
53
  });
53
54
  } catch (e) {
54
- throw new Error(
55
+ throw new UnknownError(
55
56
  `Unexpected error while setting redis for pq!.
56
57
  See ERROR log below.\n\n${e}`
57
58
  );
@@ -5,8 +5,9 @@ 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
+ const KnownError = require('../../errors/known-error');
10
11
 
11
12
  /**
12
13
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
@@ -16,6 +17,12 @@ const setupThemes = () => ({
16
17
  task: async (ctx, task) => {
17
18
  const { config: { baseConfig } } = ctx;
18
19
  const composerData = await getJsonfileData(path.join(baseConfig.magentoDir, 'composer.json'));
20
+
21
+ if (!composerData.repositories) {
22
+ task.skip();
23
+ return;
24
+ }
25
+
19
26
  const composerLocalPaths = Array.isArray(composerData.repositories)
20
27
  ? composerData.repositories.filter((repo) => repo.type === 'path')
21
28
  : Object.values(composerData.repositories).filter((repo) => repo.type === 'path');
@@ -61,7 +68,7 @@ const setupThemes = () => ({
61
68
  const composerData = await getJsonfileData(path.join(absoluteThemePath, 'composer.json'));
62
69
 
63
70
  if (!composerData) {
64
- throw new Error(`composer.json file not found in "${themePath}"`);
71
+ throw new KnownError(`composer.json file not found in "${themePath}"`);
65
72
  }
66
73
 
67
74
  return {
@@ -81,7 +88,7 @@ const setupThemes = () => ({
81
88
  ])
82
89
  })).concat([
83
90
  upgradeMagento(),
84
- disableFullPageCache(),
91
+ adjustFullPageCache(),
85
92
  setupPersistedQuery()
86
93
  ])
87
94
  );
@@ -1,4 +1,5 @@
1
1
  const path = require('path');
2
+ const UnknownError = require('../../errors/unknown-error');
2
3
  const getJsonfileData = require('../../util/get-jsonfile-data');
3
4
  const runComposerCommand = require('../../util/run-composer');
4
5
 
@@ -10,6 +11,12 @@ const symlinkTheme = (theme) => ({
10
11
  task: async (ctx, task) => {
11
12
  const { magentoVersion, verbose = false } = ctx;
12
13
  const composerJsonData = await getJsonfileData(path.join(process.cwd(), 'composer.json'));
14
+
15
+ if (!composerJsonData.repositories) {
16
+ task.skip();
17
+ return;
18
+ }
19
+
13
20
  const repositories = Array.isArray(composerJsonData.repositories)
14
21
  ? composerJsonData.repositories.reduce((acc, repo, index) => ({ ...acc, [`${index}`]: repo }), {})
15
22
  : composerJsonData.repositories;
@@ -27,7 +34,7 @@ const symlinkTheme = (theme) => ({
27
34
  }
28
35
  });
29
36
  } catch (e) {
30
- throw new Error(
37
+ throw new UnknownError(
31
38
  `Unexpected error while configuring theme symbolic link.
32
39
  See ERROR log above.\n\n${e}`
33
40
  );
@@ -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