@scandipwa/magento-scripts 1.12.1 → 1.13.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.
@@ -11,18 +11,12 @@ const setConfigFile = require('../util/set-config');
11
11
  */
12
12
  const checkConfigurationFile = () => ({
13
13
  title: 'Checking configuration file',
14
- task: async (ctx) => {
14
+ task: async (ctx, task) => {
15
15
  const { projectPath = process.cwd() } = ctx;
16
16
  const { cacheDir, templateDir } = getBaseConfig(projectPath);
17
17
  const configJSFilePath = path.join(projectPath, 'cma.js');
18
18
  const magentoConfigFilePath = path.join(cacheDir, 'app-config.json');
19
19
 
20
- if (ctx.edition) {
21
- if (!['community', 'enterprise'].includes(ctx.edition)) {
22
- throw new Error(`Magento edition "${ctx.edition}" does not exists or not supported!`);
23
- }
24
- }
25
-
26
20
  if (!await pathExists(configJSFilePath)) {
27
21
  const legacyMagentoConfigExists = await pathExists(magentoConfigFilePath);
28
22
 
@@ -35,8 +29,16 @@ const checkConfigurationFile = () => ({
35
29
 
36
30
  magentoConfiguration = legacyMagentoConfig.magento || legacyMagentoConfig;
37
31
  } else {
32
+ const magentoEdition = await task.prompt({
33
+ type: 'Select',
34
+ message: `Please select Magento edition you want to install.
35
+
36
+ Note that Enterprise edition requires Magento Enterprise License keys.`,
37
+ choices: ['Community', 'Enterprise']
38
+ });
39
+
38
40
  magentoConfiguration = deepmerge(defaultMagentoConfig, {
39
- edition: ctx.edition || 'community'
41
+ edition: magentoEdition.toLowerCase()
40
42
  });
41
43
  }
42
44
 
@@ -1,7 +1,7 @@
1
1
  const os = require('os');
2
2
  const path = require('path');
3
3
 
4
- const homePath = process.env.PHPBREW_HOME || os.homedir();
4
+ const homePath = process.env.PHPBREW_HOME || path.join(os.homedir(), '.phpbrew');
5
5
  const phpbrewConfig = {
6
6
  homePath,
7
7
  buildPath: path.join(homePath, 'build'),
@@ -36,7 +36,7 @@ module.exports = ({ templateDir } = {}) => ({
36
36
  version: '7.9.3'
37
37
  },
38
38
  composer: {
39
- version: '2.1.14'
39
+ version: '2'
40
40
  }
41
41
  },
42
42
  magento: defaultMagentoConfig,
@@ -36,7 +36,7 @@ module.exports = ({ templateDir } = {}) => ({
36
36
  version: '7.9.3'
37
37
  },
38
38
  composer: {
39
- version: '2.1.14'
39
+ version: '2'
40
40
  }
41
41
  },
42
42
  magento: defaultMagentoConfig,
@@ -40,7 +40,7 @@ module.exports = ({ templateDir } = {}) => ({
40
40
  version: '7.12.1'
41
41
  },
42
42
  composer: {
43
- version: '2.1.14'
43
+ version: '2'
44
44
  }
45
45
  },
46
46
  magento: defaultMagentoConfig,
@@ -40,7 +40,7 @@ module.exports = ({ templateDir } = {}) => ({
40
40
  version: '7.12.1'
41
41
  },
42
42
  composer: {
43
- version: '2.1.14'
43
+ version: '2'
44
44
  }
45
45
  },
46
46
  magento: defaultMagentoConfig,
@@ -39,7 +39,7 @@ module.exports = ({ templateDir } = {}) => ({
39
39
  version: '7.12.1'
40
40
  },
41
41
  composer: {
42
- version: '2.1.14'
42
+ version: '2'
43
43
  }
44
44
  },
45
45
  magento: defaultMagentoConfig,
@@ -40,7 +40,7 @@ module.exports = ({ templateDir } = {}) => ({
40
40
  version: '7.12.1'
41
41
  },
42
42
  composer: {
43
- version: '2.1.14'
43
+ version: '2'
44
44
  }
45
45
  },
46
46
  magento: defaultMagentoConfig,
@@ -40,7 +40,7 @@ module.exports = ({ templateDir } = {}) => ({
40
40
  version: '7.12.1'
41
41
  },
42
42
  composer: {
43
- version: '2.1.14'
43
+ version: '2'
44
44
  }
45
45
  },
46
46
  magento: defaultMagentoConfig,
@@ -1,4 +1,5 @@
1
1
  const fs = require('fs');
2
+ const path = require('path');
2
3
  const semver = require('semver');
3
4
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
4
5
  const downloadFile = require('../../util/download-file');
@@ -8,6 +9,7 @@ const safeRegexExtract = require('../../util/safe-regex-extract');
8
9
  const installPrestissimo = require('./install-prestissimo');
9
10
 
10
11
  /**
12
+ * @param {import('../../../typings/context').ListrContext['config']} param0
11
13
  * @returns {Promise<string>}
12
14
  */
13
15
  const getComposerVersion = async ({ composer, php }) => {
@@ -17,13 +19,23 @@ const getComposerVersion = async ({ composer, php }) => {
17
19
  string: composerVersionOutput,
18
20
  regex: /Composer version ([\d.]+)/i,
19
21
  onNoMatch: () => {
20
- throw new Error(`No composer version found in composer version output!\n\n${composerVersionOutput}`);
22
+ throw new Error(`
23
+ No composer version found in composer version output!\n\n${composerVersionOutput}
24
+
25
+ Follow steps below to resolve this issue:
26
+ 1. Check ${logger.style.file(path.relative(process.cwd(), composer.binPath))} file content, inside this file should be Composer PHP code.
27
+ 2. If file content is not correct, try deleting this file and run ${logger.style.command('start')} command again, CMA will try re-download this file.
28
+ 3. If steps above didn't help, manually download Composer version ${composer.version} from ${logger.style.code('https://getcomposer.org/download/')} and put it inside cache directory ${logger.style.file(path.relative(process.cwd(), composer.dirPath))} with ${logger.style.code('composer.phar')} file name.
29
+ `);
21
30
  }
22
31
  });
23
32
 
24
33
  return composerVersion;
25
34
  };
26
35
 
36
+ /**
37
+ * @param {import('../../../typings/context').ListrContext['config']} param0
38
+ */
27
39
  const createComposerDir = async ({ composer }) => {
28
40
  const dirExists = await pathExists(composer.dirPath);
29
41
  if (!dirExists) {
@@ -31,6 +43,9 @@ const createComposerDir = async ({ composer }) => {
31
43
  }
32
44
  };
33
45
 
46
+ /**
47
+ * @param {import('../../../typings/context').ListrContext['config']} param0
48
+ */
34
49
  const downloadComposerBinary = async ({ composer }) => {
35
50
  const composerVersion = /^\d$/.test(composer.version)
36
51
  ? `latest-${composer.version}.x`
@@ -0,0 +1,173 @@
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
4
+ const semver = require('semver');
5
+ const pathExists = require('../../util/path-exists');
6
+ const getJsonfileData = require('../../util/get-jsonfile-data');
7
+
8
+ const vendorPath = path.join(process.cwd(), 'vendor');
9
+ const composerJsonPath = path.join(process.cwd(), 'composer.json');
10
+
11
+ /**
12
+ * @returns {Promise<string[]}
13
+ */
14
+ const getInstalledComposerPlugins = async () => {
15
+ const rootVendorFolders = await fs.promises.readdir(vendorPath, {
16
+ encoding: 'utf-8',
17
+ withFileTypes: true
18
+ });
19
+
20
+ const composerPlugins = (await Promise.all(
21
+ rootVendorFolders.map(async (f) => {
22
+ if (f.isDirectory()) {
23
+ const vendorDirectoryPath = path.join(vendorPath, f.name);
24
+
25
+ const vendorPackages = await fs.promises.readdir(vendorDirectoryPath, {
26
+ encoding: 'utf-8',
27
+ withFileTypes: true
28
+ });
29
+
30
+ const vendorPackagesComposerPlugins = (await Promise.all(
31
+ vendorPackages.map(async (p) => {
32
+ if (p.isDirectory()) {
33
+ const vendorPackageComposerJsonPath = path.join(vendorDirectoryPath, p.name, 'composer.json');
34
+
35
+ if (await pathExists(vendorPackageComposerJsonPath)) {
36
+ const {
37
+ name: vendorPackageName,
38
+ type: vendorPackageType
39
+ } = JSON.parse(await fs.promises.readFile(vendorPackageComposerJsonPath, {
40
+ encoding: 'utf-8'
41
+ }));
42
+
43
+ if (vendorPackageType === 'composer-plugin') {
44
+ return vendorPackageName;
45
+ }
46
+
47
+ return null;
48
+ }
49
+ }
50
+
51
+ return null;
52
+ })
53
+ )).filter((p) => typeof p === 'string');
54
+
55
+ return vendorPackagesComposerPlugins;
56
+ }
57
+
58
+ return null;
59
+ })
60
+ ))
61
+ .reduce((acc, val) => acc.concat(val), []) // flattens the array
62
+ .filter((p) => typeof p === 'string');
63
+
64
+ return composerPlugins;
65
+ };
66
+
67
+ /**
68
+ * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
69
+ */
70
+ const enableMagentoComposerPlugins = () => ({
71
+ task: async (ctx, task) => {
72
+ if (!semver.satisfies(ctx.composerVersion, '^2.2.0')) {
73
+ task.skip();
74
+ return;
75
+ }
76
+
77
+ task.title = 'Checking allowed composer plugins...';
78
+
79
+ const composerPlugins = await getInstalledComposerPlugins();
80
+ const composerJsonData = await getJsonfileData(composerJsonPath);
81
+ const {
82
+ config: {
83
+ 'allow-plugins': allowPlugins = {}
84
+ }
85
+ } = composerJsonData;
86
+ const allowPluginsKeys = Object.keys(allowPlugins);
87
+
88
+ if (
89
+ allowPluginsKeys.length === 0
90
+ || composerPlugins.some((p) => !allowPluginsKeys.includes(p))
91
+ ) {
92
+ const missingPlugins = composerPlugins.filter((p) => !allowPluginsKeys.includes(p));
93
+ const answerForEnablingPlugins = await task.prompt({
94
+ type: 'Select',
95
+ message: `Composer 2.2 requires manually allowing composer-plugins to run.
96
+ Magento requires the following plugins to correctly operate:
97
+
98
+ ${missingPlugins.map((p) => logger.style.code(p)).join('\n')}
99
+
100
+ Do you want to enable them all or disable some of them?`,
101
+ choices: ['Enable all', 'Configure manually', 'Skip this step']
102
+ });
103
+
104
+ switch (answerForEnablingPlugins.toLowerCase()) {
105
+ case 'enable all': {
106
+ const userConfirmation = await task.prompt({
107
+ type: 'Confirm',
108
+ message: `Please confirm enabling of the following plugins:\n\n${missingPlugins.map((p) => logger.style.code(p)).join('\n')}\n`
109
+ });
110
+
111
+ if (userConfirmation) {
112
+ composerJsonData.config = {
113
+ ...composerJsonData.config,
114
+ 'allow-plugins': {
115
+ ...allowPlugins,
116
+ ...missingPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
117
+ }
118
+ };
119
+
120
+ await fs.promises.writeFile(composerJsonPath, JSON.stringify(composerJsonData, null, 4), {
121
+ encoding: 'utf-8'
122
+ });
123
+ } else {
124
+ throw new Error('Please confirm your choice or choose other option.');
125
+ }
126
+ break;
127
+ }
128
+ case 'configure manually': {
129
+ const userEnabledPlugins = await task.prompt({
130
+ type: 'MultiSelect',
131
+ message: 'Please pick plugins you want to enable!',
132
+ choices: missingPlugins.map((p) => ({ name: p }))
133
+ });
134
+
135
+ const userConfirmation = await task.prompt({
136
+ type: 'Confirm',
137
+ message: `Please confirm enabling of the following plugins:\n\n${userEnabledPlugins.map((p) => logger.style.code(p)).join('\n')}\n`
138
+ });
139
+
140
+ if (userConfirmation) {
141
+ const disabledPlugins = composerPlugins.filter((p) => !userEnabledPlugins.includes(p));
142
+
143
+ composerJsonData.config = {
144
+ ...composerJsonData.config,
145
+ 'allow-plugins': {
146
+ ...allowPlugins,
147
+ ...disabledPlugins.reduce((acc, val) => ({ ...acc, [val]: false }), {}),
148
+ ...userEnabledPlugins.reduce((acc, val) => ({ ...acc, [val]: true }), {})
149
+ }
150
+ };
151
+
152
+ await fs.promises.writeFile(composerJsonPath, JSON.stringify(composerJsonData, null, 4), {
153
+ encoding: 'utf-8'
154
+ });
155
+ } else {
156
+ throw new Error('Please confirm your choice or choose other option.');
157
+ }
158
+
159
+ break;
160
+ }
161
+ case 'skip this step': {
162
+ task.skip();
163
+ break;
164
+ }
165
+ default: {
166
+ //
167
+ }
168
+ }
169
+ }
170
+ }
171
+ });
172
+
173
+ module.exports = enableMagentoComposerPlugins;
@@ -1,4 +1,3 @@
1
- const os = require('os');
2
1
  const osPlatform = require('../../util/os-platform');
3
2
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
4
3
  const { execAsyncSpawn } = require('../../util/exec-async-command');
@@ -10,8 +9,8 @@ const compileOptions = require('./compile-options');
10
9
  const compile = () => ({
11
10
  title: 'Compiling PHP',
12
11
  task: async ({ config: { php } }, task) => {
13
- const platformCompileOptions = compileOptions[os.platform()];
14
- if (os.platform() === 'linux') {
12
+ const platformCompileOptions = compileOptions[process.platform];
13
+ if (process.platform === 'linux') {
15
14
  const { dist } = await osPlatform();
16
15
  if (['Fedora', 'Manjaro'].some((distro) => dist.includes(distro))) {
17
16
  platformCompileOptions.extraOptions.push('--with-libdir=lib64');
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable max-len */
2
+ const phpbrewConfig = require('../../../config/phpbrew');
2
3
  const { execAsyncSpawn } = require('../../../util/exec-async-command');
3
4
 
4
5
  /**
@@ -20,7 +21,7 @@ const disableExtension = (extensionName) => ({
20
21
  if (hooks && hooks.preDisable) {
21
22
  await Promise.resolve(hooks.preDisable(config));
22
23
  }
23
- await execAsyncSpawn(`source ~/.phpbrew/bashrc && \
24
+ await execAsyncSpawn(`source ${phpbrewConfig.bashrcPath} && \
24
25
  phpbrew use ${ php.version } && \
25
26
  phpbrew ext disable ${ extensionName }`,
26
27
  {
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable max-len */
2
+ const phpbrewConfig = require('../../../config/phpbrew');
2
3
  const { execAsyncSpawn } = require('../../../util/exec-async-command');
3
4
 
4
5
  /**
@@ -22,7 +23,7 @@ const enableExtension = (extensionName, extensionOptions) => ({
22
23
  await Promise.resolve(hooks.postEnable(config));
23
24
  }
24
25
 
25
- await execAsyncSpawn(`source ~/.phpbrew/bashrc && \
26
+ await execAsyncSpawn(`source ${phpbrewConfig.bashrcPath} && \
26
27
  phpbrew use ${ php.version } && \
27
28
  phpbrew ext enable ${ extensionName }`,
28
29
  {
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable max-len */
2
2
  const macosVersion = require('macos-version');
3
+ const phpbrewConfig = require('../../../config/phpbrew');
3
4
  const { execAsyncSpawn } = require('../../../util/exec-async-command');
4
5
 
5
6
  /**
@@ -25,7 +26,7 @@ const installExtension = (extensionName, extensionOptions) => ({
25
26
  await Promise.resolve(hooks.preInstall(config));
26
27
  }
27
28
 
28
- await execAsyncSpawn(`source ~/.phpbrew/bashrc && \
29
+ await execAsyncSpawn(`source ${phpbrewConfig.bashrcPath} && \
29
30
  phpbrew use ${ php.version } && \
30
31
  phpbrew ext install ${ extensionName }${ extensionOptions.version ? ` ${extensionOptions.version}` : ''}${ options ? ` -- ${ options }` : ''}`,
31
32
  {
@@ -1,9 +1,10 @@
1
+ const fs = require('fs');
1
2
  const logger = require('@scandipwa/scandipwa-dev-utils/logger');
2
- const { execAsyncSpawn } = require('../../util/exec-async-command');
3
3
  const pathExists = require('../../util/path-exists');
4
4
  const compile = require('./compile');
5
5
  const configure = require('./configure');
6
6
  const updatePhpBrew = require('./update-phpbrew');
7
+ const phpbrewConfig = require('../../config/phpbrew');
7
8
 
8
9
  /**
9
10
  * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
@@ -21,12 +22,17 @@ const installPhp = () => ({
21
22
  }
22
23
 
23
24
  task.title = `Installing PHP ${php.version}`;
24
- const versionRegex = new RegExp(php.version);
25
25
 
26
26
  try {
27
- const phpVersions = await execAsyncSpawn('phpbrew list');
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
34
 
29
- if (versionRegex.test(phpVersions) && !recompilePhp) {
35
+ if (hasPHPVersion && !recompilePhp) {
30
36
  task.skip();
31
37
  // eslint-disable-next-line consistent-return
32
38
  return;
@@ -5,7 +5,7 @@ const installDependenciesTask = require('../../../util/install-dependencies-task
5
5
  /**
6
6
  * @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
7
7
  */
8
- const fedoraDependenciesCheck = () => ({
8
+ const centosDependenciesCheck = () => ({
9
9
  title: 'Checking CentOS dependencies',
10
10
  task: async (ctx, task) => {
11
11
  const installedDependencies = (await execAsyncSpawn('yum list installed')).split('\n')
@@ -32,4 +32,4 @@ const fedoraDependenciesCheck = () => ({
32
32
  }
33
33
  });
34
34
 
35
- module.exports = fedoraDependenciesCheck;
35
+ module.exports = centosDependenciesCheck;
@@ -1,4 +1,3 @@
1
- const os = require('os');
2
1
  const osPlatform = require('../../../util/os-platform');
3
2
  const archDependenciesCheck = require('./arch');
4
3
  const fedoraDependenciesCheck = require('./fedora');
@@ -7,9 +6,7 @@ const ubuntuDependenciesCheck = require('./ubuntu');
7
6
  const macDependenciesCheck = require('./mac');
8
7
 
9
8
  const dependencyCheck = async () => {
10
- const currentPlatform = os.platform();
11
-
12
- if (currentPlatform === 'darwin') {
9
+ if (process.platform === 'darwin') {
13
10
  return macDependenciesCheck();
14
11
  }
15
12
 
@@ -45,7 +45,7 @@ const installDocker = () => ({
45
45
  execCommandTask('curl -fsSL https://get.docker.com -o get-docker.sh'),
46
46
  executeSudoCommand('sudo sh get-docker.sh'),
47
47
  executeSudoCommand('sudo service docker start'),
48
- executeSudoCommand('sudo service docker enable'),
48
+ executeSudoCommand('sudo systemctl enable docker.service'),
49
49
  ...postInstallSteps
50
50
  ]);
51
51
  }
@@ -1,8 +1,9 @@
1
1
  const checkPlatform = require('./platform');
2
- const checkPhpbrew = require('./phpbrew');
2
+ const checkPHPbrew = require('./phpbrew');
3
3
  const checkComposer = require('./composer');
4
4
  const checkDocker = require('./docker');
5
5
  const checkNodeVersion = require('./node-version');
6
+ const checkPHPVersion = require('./php-version');
6
7
  const localAuthJson = require('../composer/local-auth-json');
7
8
 
8
9
  /**
@@ -11,11 +12,12 @@ const localAuthJson = require('../composer/local-auth-json');
11
12
  const checkRequirements = () => ({
12
13
  title: 'Checking requirements',
13
14
  task: (ctx, task) => task.newListr([
14
- // TODO add support for mac
15
15
  // checking if user is on supported platform
16
16
  checkPlatform(),
17
17
  // check the PHPBrew installation
18
- checkPhpbrew(),
18
+ checkPHPbrew(),
19
+ // check installed PHP version
20
+ checkPHPVersion(),
19
21
  // check the Docker installation
20
22
  checkDocker(),
21
23
  // check for COMPOSER_AUTH or auth.json
@@ -0,0 +1,130 @@
1
+ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const semver = require('semver');
5
+ const phpbrewConfig = require('../../config/phpbrew');
6
+ const { execAsyncSpawn } = require('../../util/exec-async-command');
7
+ const pathExists = require('../../util/path-exists');
8
+ const compileOptions = require('../php/compile-options');
9
+
10
+ const latestStablePHP74 = '7.4.27';
11
+ const phpbrewPHPName = `php-${latestStablePHP74}-phpbrew`;
12
+
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
+ /**
32
+ * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
33
+ */
34
+ const installPHPForPHPBrew = () => ({
35
+ title: `Installing PHP ${latestStablePHP74} for PHPBrew...`,
36
+ task: async (ctx, task) => {
37
+ const platformCompileOptions = compileOptionsForPhp[process.platform];
38
+
39
+ if (!await pathExists(path.join(phpbrewConfig.phpPath, `${phpbrewPHPName}`, 'bin'))) {
40
+ const commandEnv = Object.entries(platformCompileOptions.env || {}).map(([key, value]) => `${key}="${value}"`).join(' ');
41
+
42
+ // eslint-disable-next-line max-len
43
+ const compileCommand = `${commandEnv ? `${commandEnv} && ` : ''}phpbrew install -j ${platformCompileOptions.cpuCount} ${latestStablePHP74} as ${phpbrewPHPName} ${platformCompileOptions.variants.join(' ')}`;
44
+
45
+ try {
46
+ await execAsyncSpawn(
47
+ compileCommand,
48
+ {
49
+ callback: (t) => {
50
+ task.output = t;
51
+ }
52
+ }
53
+ );
54
+ } catch (e) {
55
+ throw new Error(
56
+ `Failed to compile the required by PHPBrew PHP version.
57
+ Tried compiling the PHP version ${ latestStablePHP74 }.
58
+ Use your favorite search engine to resolve the issue.
59
+ See error details in the output below.\n\n${e}`
60
+ );
61
+ }
62
+ }
63
+
64
+ try {
65
+ const phpbrewInitFileContent = `# DO NOT EDIT THIS FILE
66
+
67
+ export PHPBREW_ROOT=${phpbrewConfig.homePath}
68
+ export PHPBREW_HOME=${phpbrewConfig.homePath}
69
+ export PHPBREW_PHP=${phpbrewPHPName}
70
+ export PHPBREW_PATH=${phpbrewConfig.homePath}/php/${phpbrewPHPName}/bin
71
+ # Run this command to configure your shell:
72
+ # eval "$(phpbrew env)"\n`;
73
+
74
+ await fs.promises.writeFile(
75
+ path.join(phpbrewConfig.homePath, 'init'),
76
+ phpbrewInitFileContent,
77
+ {
78
+ encoding: 'utf-8'
79
+ }
80
+ );
81
+ } catch (e) {
82
+ throw new Error(`Something went wrong when trying to switch PHP to ${phpbrewPHPName}!\n\n${e}`);
83
+ }
84
+
85
+ throw new Error(`You will need to restart your terminal and run ${logger.style.command('start')} again.
86
+
87
+ You can use keyboard shortcut ${logger.style.command('CTRL+D')} to close terminal.`);
88
+ },
89
+ options: {
90
+ bottomBar: 10
91
+ }
92
+ });
93
+
94
+ /**
95
+ * @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
96
+ */
97
+ const checkPHPVersion = () => ({
98
+ title: 'Checking system PHP version',
99
+ task: async (ctx, task) => {
100
+ const phpVersionResponse = await execAsyncSpawn('php --version');
101
+
102
+ const phpVersionResponseResult = phpVersionResponse.match(/^PHP\s(\d\.\d\.\d)/i);
103
+
104
+ if (phpVersionResponseResult.length > 0) {
105
+ const phpVersion = phpVersionResponseResult[1];
106
+
107
+ if (semver.satisfies(phpVersion, '>=8.1.x')) {
108
+ const userConfirmation = await task.prompt({
109
+ type: 'Confirm',
110
+ message: `You have PHP ${phpVersion} installed in the system.
111
+ PHPBrew can work with this version but it will have a lot of warning.
112
+ To fix that we will build special PHP version that will be used by PHPBrew, please confirm this action.`
113
+ });
114
+
115
+ if (userConfirmation) {
116
+ return task.newListr(
117
+ installPHPForPHPBrew,
118
+ {
119
+ rendererOptions: {
120
+ collapse: false
121
+ }
122
+ }
123
+ );
124
+ }
125
+ }
126
+ }
127
+ }
128
+ });
129
+
130
+ module.exports = checkPHPVersion;
@@ -12,7 +12,7 @@ const installDependenciesTask = require('../../../util/install-dependencies-task
12
12
  const installPHPBrewDependencies = () => ({
13
13
  title: 'Installing PHPBrew dependencies',
14
14
  task: async (ctx, task) => {
15
- if (os.platform() === 'darwin') {
15
+ if (process.platform === 'darwin') {
16
16
  return task.newListr(
17
17
  installDependenciesTask({
18
18
  platform: 'darwin',
@@ -183,9 +183,7 @@ Then you can continue installation.`);
183
183
  const installPHPBrew = () => ({
184
184
  title: 'Installing PHPBrew',
185
185
  task: async (ctx, task) => {
186
- const currentPlatform = os.platform();
187
-
188
- if (currentPlatform === 'darwin') {
186
+ if (process.platform === 'darwin') {
189
187
  return task.newListr([
190
188
  installXcode(),
191
189
  installPHPBrewDependencies(),
@@ -26,6 +26,7 @@ const setupThemes = require('./theme/setup-themes');
26
26
  const pkg = require('../../package.json');
27
27
  const checkConfigurationFile = require('../config/check-configuration-file');
28
28
  const convertLegacyVolumes = require('./docker/convert-legacy-volumes');
29
+ const enableMagentoComposerPlugins = require('./magento/enable-magento-composer-plugins');
29
30
 
30
31
  /**
31
32
  * @type {() => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
@@ -111,6 +112,7 @@ const configureProject = () => ({
111
112
  configurePhp(),
112
113
  installPrestissimo(),
113
114
  installMagento(),
115
+ enableMagentoComposerPlugins(),
114
116
  startServices(),
115
117
  startPhpFpm(),
116
118
  connectToMySQL()
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Scripts and configuration used by CMA.",
4
4
  "homepage": "https://docs.create-magento-app.com/",
5
5
  "repository": "github:scandipwa/create-magento-app",
6
- "version": "1.12.1",
6
+ "version": "1.13.0",
7
7
  "main": "./index.js",
8
8
  "types": "./typings/index.d.ts",
9
9
  "license": "OSL-3.0",
@@ -42,5 +42,5 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "gitHead": "079d0a72e1abeaaa3b529406c328ce2aa0d224d7"
45
+ "gitHead": "ea9caf4db8672b0cf197e49cd4c9002eea84a113"
46
46
  }