@scandipwa/magento-scripts 1.13.4 → 1.14.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 (37) hide show
  1. package/lib/commands/start.js +23 -12
  2. package/lib/config/dependencies-for-platforms.js +10 -5
  3. package/lib/config/versions/magento-2.3.0.js +3 -1
  4. package/lib/config/versions/magento-2.3.1.js +3 -1
  5. package/lib/config/versions/magento-2.3.2-p2.js +3 -1
  6. package/lib/config/versions/magento-2.3.2.js +3 -1
  7. package/lib/config/versions/magento-2.3.3-p1.js +3 -1
  8. package/lib/config/versions/magento-2.3.3.js +3 -1
  9. package/lib/config/versions/magento-2.3.4-p2.js +3 -1
  10. package/lib/config/versions/magento-2.3.4.js +3 -1
  11. package/lib/config/versions/magento-2.3.5-p1.js +3 -1
  12. package/lib/config/versions/magento-2.3.5-p2.js +3 -1
  13. package/lib/config/versions/magento-2.3.5.js +3 -1
  14. package/lib/config/versions/magento-2.3.6-p1.js +3 -1
  15. package/lib/config/versions/magento-2.3.6.js +3 -1
  16. package/lib/tasks/composer/index.js +1 -1
  17. package/lib/tasks/docker/containers.js +16 -4
  18. package/lib/tasks/link.js +2 -0
  19. package/lib/tasks/magento/setup-magento/disable-page-builder.js +11 -0
  20. package/lib/tasks/magento/setup-magento/set-base-url.js +2 -1
  21. package/lib/tasks/php/compile-options.js +4 -3
  22. package/lib/tasks/php/compile.js +4 -4
  23. package/lib/tasks/php/index.js +22 -8
  24. package/lib/tasks/requirements/composer.js +211 -19
  25. package/lib/tasks/requirements/dependency/index.js +4 -6
  26. package/lib/tasks/requirements/docker/index.js +12 -1
  27. package/lib/tasks/requirements/docker/install.js +4 -6
  28. package/lib/tasks/requirements/docker/permissions.js +58 -0
  29. package/lib/tasks/requirements/docker/version.js +2 -9
  30. package/lib/tasks/requirements/index.js +1 -2
  31. package/lib/tasks/requirements/phpbrew/install.js +4 -6
  32. package/lib/tasks/status/index.js +24 -9
  33. package/lib/tasks/theme/link-theme.js +25 -1
  34. package/lib/util/instance-metadata.js +74 -0
  35. package/lib/util/os-platform.js +45 -3
  36. package/package.json +7 -8
  37. package/readme.md +54 -124
@@ -9,9 +9,12 @@ const systeminformation = require('systeminformation');
9
9
  const { getCSAThemes } = require('../util/CSA-theme');
10
10
  const shouldUseYarn = require('@scandipwa/scandipwa-dev-utils/should-use-yarn');
11
11
  const ConsoleBlock = require('../util/console-block');
12
+ const { getInstanceMetadata } = require('../util/instance-metadata');
12
13
 
13
14
  const cmaGaTrackingId = 'UA-127741417-7';
14
15
 
16
+ googleAnalytics.setGaTrackingId(cmaGaTrackingId);
17
+
15
18
  /**
16
19
  * @param {import('yargs')} yargs
17
20
  */
@@ -64,6 +67,9 @@ module.exports = (yargs) => {
64
67
  default: false
65
68
  }),
66
69
  async (args = {}) => {
70
+ /**
71
+ * @type {Listr<import('../../typings/context').ListrContext>}
72
+ */
67
73
  const tasks = new Listr(
68
74
  start(), {
69
75
  exitOnError: true,
@@ -75,7 +81,7 @@ module.exports = (yargs) => {
75
81
  }
76
82
  }
77
83
  );
78
- const timeStamp = Date.now() / 1000;
84
+ const timeStamp = Date.now();
79
85
 
80
86
  if (args.debug) {
81
87
  logger.warn('You are running in debug mode. Magento setup will be slow.');
@@ -90,20 +96,27 @@ module.exports = (yargs) => {
90
96
  const ctx = await tasks.run();
91
97
 
92
98
  const {
93
- ports,
94
- config: { magentoConfiguration, overridenConfiguration: { host, ssl } },
95
99
  systemConfiguration: { analytics }
96
100
  } = ctx;
97
101
 
98
- const webLocation = `${ssl.enabled ? 'https' : 'http'}://${host}${ssl.enabled || ports.app === 80 ? '' : `:${ports.app}`}/`;
102
+ const instanceMetadata = getInstanceMetadata(ctx);
99
103
 
100
104
  const block = new ConsoleBlock();
101
105
  block
102
106
  .addHeader('Magento 2')
103
- .addEmptyLine()
104
- .addLine(`Web location: ${logger.style.link(webLocation)}`)
105
- .addLine(`Magento Admin panel location: ${logger.style.link(`${webLocation}${magentoConfiguration.adminuri}`)}`)
106
- .addLine(`Magento Admin panel credentials: ${logger.style.misc(magentoConfiguration.user)} - ${logger.style.misc(magentoConfiguration.password)}`);
107
+ .addEmptyLine();
108
+
109
+ block.addLine(logger.style.misc('Frontend'));
110
+ instanceMetadata.frontend.forEach(({ title, text }) => {
111
+ block.addLine(` ${title}: ${text}`);
112
+ });
113
+
114
+ block.addEmptyLine();
115
+
116
+ block.addLine(logger.style.misc('Admin'));
117
+ instanceMetadata.admin.forEach(({ title, text }) => {
118
+ block.addLine(` ${title}: ${text}`);
119
+ });
107
120
 
108
121
  const themes = await getCSAThemes();
109
122
  if (themes.length > 0) {
@@ -143,10 +156,8 @@ module.exports = (yargs) => {
143
156
  }
144
157
 
145
158
  try {
146
- googleAnalytics.setGaTrackingId(cmaGaTrackingId);
147
-
148
159
  if (!process.isFirstStart) {
149
- await googleAnalytics.trackTiming('CMA start time', Date.now() / 1000 - timeStamp);
160
+ await googleAnalytics.trackTiming('CMA start time', Date.now() - timeStamp);
150
161
  googleAnalytics.printAboutAnalytics();
151
162
  process.exit(0);
152
163
  }
@@ -160,7 +171,7 @@ module.exports = (yargs) => {
160
171
  const paramInfo = `Platform: ${platform} ${kernel}, CPU model: ${manufacturer} ${brand}, RAM amount: ${totalRam}MB`;
161
172
 
162
173
  await googleAnalytics.trackEvent('Params', paramInfo, 0, 'OS');
163
- await googleAnalytics.trackTiming('CMA first start time', Date.now() / 1000 - timeStamp);
174
+ await googleAnalytics.trackTiming('CMA first start time', Date.now() - timeStamp);
164
175
  googleAnalytics.printAboutAnalytics();
165
176
  } catch (e) {
166
177
  await googleAnalytics.trackError(e.message || e);
@@ -15,7 +15,8 @@ const dependenciesForPlatforms = {
15
15
  'libxml2',
16
16
  'openssl@1.1'
17
17
  ],
18
- installCommand: (deps) => `brew install ${deps}`
18
+ installCommand: (deps) => `brew install ${deps}`,
19
+ packageManager: 'brew'
19
20
  },
20
21
  'Arch Linux': {
21
22
  dependencies: [
@@ -35,7 +36,8 @@ const dependenciesForPlatforms = {
35
36
  'perl',
36
37
  'libsodium'
37
38
  ],
38
- installCommand: (deps) => `sudo pacman -S ${deps} --noconfirm`
39
+ installCommand: (deps) => `sudo pacman -S ${deps} --noconfirm`,
40
+ packageManager: 'pacman'
39
41
  },
40
42
  Fedora: {
41
43
  dependencies: [
@@ -51,7 +53,8 @@ const dependenciesForPlatforms = {
51
53
  'libtool-ltdl-devel',
52
54
  'oniguruma-devel'
53
55
  ],
54
- installCommand: (deps) => `sudo yum install ${deps} -y`
56
+ installCommand: (deps) => `sudo yum install ${deps} -y`,
57
+ packageManager: 'yum'
55
58
  },
56
59
  CentOS: {
57
60
  dependencies: [
@@ -67,7 +70,8 @@ const dependenciesForPlatforms = {
67
70
  'libtool-ltdl-devel',
68
71
  'oniguruma-devel'
69
72
  ],
70
- installCommand: (deps) => `sudo yum install --enablerepo=PowerTools ${deps} -y`
73
+ installCommand: (deps) => `sudo yum install --enablerepo=PowerTools ${deps} -y`,
74
+ packageManager: 'yum'
71
75
  },
72
76
  Ubuntu: {
73
77
  dependencies: [
@@ -95,7 +99,8 @@ const dependenciesForPlatforms = {
95
99
  'autoconf',
96
100
  'cmake'
97
101
  ],
98
- installCommand: (deps) => `sudo apt-get install ${deps} -y`
102
+ installCommand: (deps) => `sudo apt install ${deps} -y`,
103
+ packageManager: 'apt'
99
104
  }
100
105
  };
101
106
 
@@ -8,7 +8,9 @@ module.exports = ({ templateDir } = {}) => ({
8
8
  version: '7.2.33',
9
9
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
10
10
  extensions: {
11
- gd: {},
11
+ gd: {
12
+ macosOptions: '--with-zlib-dir=$(brew --prefix zlib) --with-freetype-dir=$(brew --prefix freetype)'
13
+ },
12
14
  intl: {},
13
15
  zlib: {},
14
16
  openssl: {},
@@ -8,7 +8,9 @@ module.exports = ({ templateDir } = {}) => ({
8
8
  version: '7.2.33',
9
9
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
10
10
  extensions: {
11
- gd: {},
11
+ gd: {
12
+ macosOptions: '--with-zlib-dir=$(brew --prefix zlib) --with-freetype-dir=$(brew --prefix freetype)'
13
+ },
12
14
  intl: {},
13
15
  zlib: {},
14
16
  openssl: {},
@@ -8,7 +8,9 @@ module.exports = ({ templateDir } = {}) => ({
8
8
  version: '7.2.33',
9
9
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
10
10
  extensions: {
11
- gd: {},
11
+ gd: {
12
+ macosOptions: '--with-zlib-dir=$(brew --prefix zlib) --with-freetype-dir=$(brew --prefix freetype)'
13
+ },
12
14
  intl: {},
13
15
  zlib: {},
14
16
  openssl: {},
@@ -8,7 +8,9 @@ module.exports = ({ templateDir } = {}) => ({
8
8
  version: '7.2.33',
9
9
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
10
10
  extensions: {
11
- gd: {},
11
+ gd: {
12
+ macosOptions: '--with-zlib-dir=$(brew --prefix zlib) --with-freetype-dir=$(brew --prefix freetype)'
13
+ },
12
14
  intl: {},
13
15
  zlib: {},
14
16
  openssl: {},
@@ -8,7 +8,9 @@ module.exports = ({ templateDir } = {}) => ({
8
8
  version: '7.3.28',
9
9
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
10
10
  extensions: {
11
- gd: {},
11
+ gd: {
12
+ macosOptions: '--with-zlib-dir=$(brew --prefix zlib) --with-freetype-dir=$(brew --prefix freetype)'
13
+ },
12
14
  intl: {},
13
15
  zlib: {},
14
16
  openssl: {},
@@ -8,7 +8,9 @@ module.exports = ({ templateDir } = {}) => ({
8
8
  version: '7.3.28',
9
9
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
10
10
  extensions: {
11
- gd: {},
11
+ gd: {
12
+ macosOptions: '--with-zlib-dir=$(brew --prefix zlib) --with-freetype-dir=$(brew --prefix freetype)'
13
+ },
12
14
  intl: {},
13
15
  zlib: {},
14
16
  openssl: {},
@@ -8,7 +8,9 @@ module.exports = ({ templateDir } = {}) => ({
8
8
  version: '7.3.28',
9
9
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
10
10
  extensions: {
11
- gd: {},
11
+ gd: {
12
+ macosOptions: '--with-zlib-dir=$(brew --prefix zlib) --with-freetype-dir=$(brew --prefix freetype)'
13
+ },
12
14
  intl: {},
13
15
  zlib: {},
14
16
  openssl: {},
@@ -8,7 +8,9 @@ module.exports = ({ templateDir } = {}) => ({
8
8
  version: '7.3.28',
9
9
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
10
10
  extensions: {
11
- gd: {},
11
+ gd: {
12
+ macosOptions: '--with-zlib-dir=$(brew --prefix zlib) --with-freetype-dir=$(brew --prefix freetype)'
13
+ },
12
14
  intl: {},
13
15
  zlib: {},
14
16
  openssl: {},
@@ -8,7 +8,9 @@ module.exports = ({ templateDir } = {}) => ({
8
8
  version: '7.3.28',
9
9
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
10
10
  extensions: {
11
- gd: {},
11
+ gd: {
12
+ macosOptions: '--with-zlib-dir=$(brew --prefix zlib) --with-freetype-dir=$(brew --prefix freetype)'
13
+ },
12
14
  intl: {},
13
15
  zlib: {},
14
16
  openssl: {},
@@ -8,7 +8,9 @@ module.exports = ({ templateDir } = {}) => ({
8
8
  version: '7.3.28',
9
9
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
10
10
  extensions: {
11
- gd: {},
11
+ gd: {
12
+ macosOptions: '--with-zlib-dir=$(brew --prefix zlib) --with-freetype-dir=$(brew --prefix freetype)'
13
+ },
12
14
  intl: {},
13
15
  zlib: {},
14
16
  openssl: {},
@@ -8,7 +8,9 @@ module.exports = ({ templateDir } = {}) => ({
8
8
  version: '7.3.28',
9
9
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
10
10
  extensions: {
11
- gd: {},
11
+ gd: {
12
+ macosOptions: '--with-zlib-dir=$(brew --prefix zlib) --with-freetype-dir=$(brew --prefix freetype)'
13
+ },
12
14
  intl: {},
13
15
  zlib: {},
14
16
  openssl: {},
@@ -8,7 +8,9 @@ module.exports = ({ templateDir } = {}) => ({
8
8
  version: '7.3.28',
9
9
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
10
10
  extensions: {
11
- gd: {},
11
+ gd: {
12
+ macosOptions: '--with-zlib-dir=$(brew --prefix zlib) --with-freetype-dir=$(brew --prefix freetype)'
13
+ },
12
14
  intl: {},
13
15
  zlib: {},
14
16
  openssl: {},
@@ -8,7 +8,9 @@ module.exports = ({ templateDir } = {}) => ({
8
8
  version: '7.3.28',
9
9
  configTemplate: path.join(templateDir || '', 'php.template.ini'),
10
10
  extensions: {
11
- gd: {},
11
+ gd: {
12
+ macosOptions: '--with-zlib-dir=$(brew --prefix zlib) --with-freetype-dir=$(brew --prefix freetype)'
13
+ },
12
14
  intl: {},
13
15
  zlib: {},
14
16
  openssl: {},
@@ -17,7 +17,7 @@ const getComposerVersion = async ({ composer, php }) => {
17
17
 
18
18
  const composerVersion = safeRegexExtract({
19
19
  string: composerVersionOutput,
20
- regex: /Composer version ([\d.]+)/i,
20
+ regex: /composer.+(\d+\.\d+\.\d+)/i,
21
21
  onNoMatch: () => {
22
22
  throw new Error(`
23
23
  No composer version found in composer version output!\n\n${composerVersionOutput}
@@ -1,8 +1,22 @@
1
+ /* eslint-disable max-len */
1
2
  const { execAsyncSpawn } = require('../../util/exec-async-command');
2
3
 
4
+ /**
5
+ * @param {Object} options
6
+ * @param {number[]} [options.ports] Publish or expose port [docs](https://docs.docker.com/engine/reference/commandline/run/#publish-or-expose-port--p---expose)
7
+ * @param {number[]} [options.mounts] Add bind mounts or volumes using the --mount flag [docs](https://docs.docker.com/engine/reference/commandline/run/#add-bind-mounts-or-volumes-using-the---mount-flag)
8
+ * @param {number[]} [options.mountVolumes] Mount volume [docs](https://docs.docker.com/engine/reference/commandline/run/#mount-volume--v---read-only)
9
+ * @param {Record<string, string>} [options.env] Set environment variables [docs](https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file)
10
+ * @param {string} [options.image]
11
+ * @param {string} [options.restart] Restart policies [docs](https://docs.docker.com/engine/reference/commandline/run/#restart-policies---restart)
12
+ * @param {string} [options.name] Container name
13
+ * @param {string} [options.entrypoint] Container entrypoint
14
+ * @param {string} [options.command] Container command
15
+ * @param {Record<"cmd" | "interval" | "retries" | "start-period" | "timeout", string>} [options.healthCheck] Container heathcheck properties
16
+ * @param {string[]} [options.securityOptions] Security options [docs](https://docs.docker.com/engine/reference/commandline/run/#optional-security-options---security-opt)
17
+ */
3
18
  const run = (options) => {
4
19
  const {
5
- expose = [],
6
20
  ports = [],
7
21
  mounts = [],
8
22
  mountVolumes = [],
@@ -19,7 +33,6 @@ const run = (options) => {
19
33
 
20
34
  const restartArg = restart && `--restart ${ restart }`;
21
35
  const networkArg = network && `--network ${ network }`;
22
- const exposeArgs = expose.map((port) => `--expose ${ port }`).join(' ');
23
36
  const portsArgs = ports.map((port) => `-p ${ port }`).join(' ');
24
37
  const mountsArgs = mounts.map((mount) => `--mount ${ mount }`).join(' ');
25
38
  const mountVolumesArgs = mountVolumes.map((mount) => `-v ${mount}`).join(' ');
@@ -36,7 +49,6 @@ const run = (options) => {
36
49
  nameArg,
37
50
  networkArg,
38
51
  restartArg,
39
- exposeArgs,
40
52
  portsArgs,
41
53
  mountsArgs,
42
54
  mountVolumesArgs,
@@ -139,7 +151,7 @@ const stopContainers = () => ({
139
151
 
140
152
  const getContainerStatus = async (containerName) => {
141
153
  try {
142
- return JSON.parse(await execAsyncSpawn(`docker inspect --format='{{json .State.Health}}' ${containerName}`));
154
+ return JSON.parse(await execAsyncSpawn(`docker inspect --format='{{json .State}}' ${containerName}`));
143
155
  } catch {
144
156
  return null;
145
157
  }
package/lib/tasks/link.js CHANGED
@@ -6,6 +6,7 @@ const linkTheme = require('./theme/link-theme');
6
6
  const { startServices } = require('./docker');
7
7
  const { startPhpFpm } = require('./php-fpm');
8
8
  const checkConfigurationFile = require('../config/check-configuration-file');
9
+ const { connectToMySQL } = require('./mysql');
9
10
 
10
11
  /**
11
12
  * @type {(theme: string) => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
@@ -18,6 +19,7 @@ const linkTask = (themePath) => ({
18
19
  getCachedPorts(),
19
20
  startServices(),
20
21
  startPhpFpm(),
22
+ connectToMySQL(),
21
23
  retrieveThemeData(themePath),
22
24
  linkTheme()
23
25
  ])
@@ -0,0 +1,11 @@
1
+ const magentoTask = require('../../../util/magento-task');
2
+
3
+ /**
4
+ * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
5
+ */
6
+ const disablePageBuilder = () => ({
7
+ title: 'Disabling page builder in Magento',
8
+ task: (ctx, task) => task.newListr(magentoTask('config:set cms/pagebuilder/enabled 0'))
9
+ });
10
+
11
+ module.exports = disablePageBuilder;
@@ -11,8 +11,9 @@ module.exports = () => ({
11
11
  config: { overridenConfiguration: { host, ssl } },
12
12
  mysqlConnection
13
13
  } = ctx;
14
+ const isNgrok = host.endsWith('ngrok.io');
14
15
  const enableSecureFrontend = ssl.enabled ? '1' : '0';
15
- const location = `${host}${ ports.app !== 80 ? `:${ports.app}` : '' }/`;
16
+ const location = `${host}${ !isNgrok && ports.app !== 80 ? `:${ports.app}` : '' }/`;
16
17
  const secureLocation = `${host}/`; // SSL will work only on port 443, so you cannot run multiple projects with SSL at the same time.
17
18
  const httpUrl = `http://${location}`;
18
19
  const httpsUrl = `https://${secureLocation}`;
@@ -44,7 +44,7 @@ const compileOptions = {
44
44
  '+bz2="$(brew --prefix bzip2)"',
45
45
  '+bcmath',
46
46
  '+ctype',
47
- '+curl=$(brew --prefix curl-openssl)',
47
+ '+curl=$(brew --prefix curl)',
48
48
  '+intl=$(brew --prefix icu4c)',
49
49
  '+dom',
50
50
  '+filter',
@@ -70,11 +70,12 @@ const compileOptions = {
70
70
  ],
71
71
  env: {
72
72
  // eslint-disable-next-line max-len
73
- PKG_CONFIG_PATH: '$PKG_CONFIG_PATH:$(brew --prefix libxml2)/lib/pkgconfig:$(brew --prefix icu4c)/lib/pkgconfig:$(brew --prefix openssl@1.1)/lib/pkgconfig:$(brew --prefix curl-openssl@1.1)/lib/pkgconfig:$(brew --prefix zlib)/lib/pkgconfig',
73
+ PKG_CONFIG_PATH: '$PKG_CONFIG_PATH:$(brew --prefix libxml2)/lib/pkgconfig:$(brew --prefix icu4c)/lib/pkgconfig:$(brew --prefix openssl@1.1)/lib/pkgconfig:$(brew --prefix curl)/lib/pkgconfig:$(brew --prefix zlib)/lib/pkgconfig',
74
74
  CPATH: '$CPATH:$(brew --prefix openssl@1.1)/include',
75
75
  CXX: 'g++ -DTRUE=1 -DFALSE=0',
76
76
  CC: 'gcc -DTRUE=1 -DFALSE=0',
77
- LDFLAGS: '$(brew --prefix openssl@1.1)/lib/libssl.dylib $(brew --prefix openssl@1.1)/lib/libcrypto.dylib'
77
+ LDFLAGS: '$(brew --prefix openssl@1.1)/lib/libssl.dylib $(brew --prefix openssl@1.1)/lib/libcrypto.dylib',
78
+ CFLAGS: '-Wno-implicit-function-declaration' // https://github.com/phpbrew/phpbrew/issues/1222
78
79
  }
79
80
  }
80
81
  };
@@ -1,4 +1,4 @@
1
- const osPlatform = require('../../util/os-platform');
1
+ const systeminformation = require('systeminformation');
2
2
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
3
3
  const { execAsyncSpawn } = require('../../util/exec-async-command');
4
4
  const compileOptions = require('./compile-options');
@@ -11,12 +11,12 @@ const compile = () => ({
11
11
  task: async ({ config: { php } }, task) => {
12
12
  const platformCompileOptions = compileOptions[process.platform];
13
13
  if (process.platform === 'linux') {
14
- const { dist } = await osPlatform();
15
- if (['Fedora', 'Manjaro'].some((distro) => dist.includes(distro))) {
14
+ const { distro } = await systeminformation.osInfo();
15
+ if (['Fedora', 'Manjaro'].some((d) => distro.includes(d))) {
16
16
  platformCompileOptions.extraOptions.push('--with-libdir=lib64');
17
17
  }
18
18
  }
19
- const commandEnv = Object.entries(platformCompileOptions.env || {}).map(([key, value]) => `${key}="${value}"`).join(' && ');
19
+ const commandEnv = Object.entries(platformCompileOptions.env || {}).map(([key, value]) => `export ${key}="${value}"`).join(' && ');
20
20
  const phpCompileCommand = `${commandEnv ? `${commandEnv} && ` : ''} \
21
21
  phpbrew install -j ${platformCompileOptions.cpuCount} ${php.version} ${platformCompileOptions.variants.join(' ')} \
22
22
  -- ${platformCompileOptions.extraOptions.join(' ')}`;
@@ -1,4 +1,5 @@
1
1
  const fs = require('fs');
2
+ const path = require('path');
2
3
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
3
4
  const pathExists = require('../../util/path-exists');
4
5
  const compile = require('./compile');
@@ -24,15 +25,28 @@ const installPhp = () => ({
24
25
  task.title = `Installing PHP ${php.version}`;
25
26
 
26
27
  try {
27
- const hasPHPVersion = (
28
- await fs.promises.readdir(phpbrewConfig.phpPath, {
29
- encoding: 'utf-8',
30
- withFileTypes: true
31
- })
32
- )
33
- .some((f) => f.isDirectory() && f.name === `php-${php.version}`);
28
+ const hasPHPVersionDirectory = (
29
+ await Promise.all(
30
+ (
31
+ await fs.promises.readdir(phpbrewConfig.phpPath, {
32
+ encoding: 'utf-8',
33
+ withFileTypes: true
34
+ })
35
+ ).map(async (f) => {
36
+ if (!f.isDirectory()) {
37
+ return false;
38
+ }
34
39
 
35
- if (hasPHPVersion && !recompilePhp) {
40
+ if (f.name !== `php-${php.version}`) {
41
+ return false;
42
+ }
43
+
44
+ return pathExists(path.join(phpbrewConfig.phpPath, f.name, 'bin', 'php'));
45
+ })
46
+ ))
47
+ .includes(true);
48
+
49
+ if (hasPHPVersionDirectory && !recompilePhp) {
36
50
  task.skip();
37
51
  // eslint-disable-next-line consistent-return
38
52
  return;