@scandipwa/magento-scripts 1.12.0-alpha.0 → 1.13.0-alpha.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.
- package/.eslintrc +0 -0
- package/LICENSE +0 -0
- package/lib/config/check-configuration-file.js +10 -8
- package/lib/config/dependencies-for-platforms.js +0 -1
- package/lib/config/index.js +2 -2
- package/lib/config/{php.js → php-config.js} +0 -0
- package/lib/config/phpbrew.js +12 -0
- package/lib/config/{php-storm.js → phpstorm/debug-config.js} +0 -0
- package/lib/config/save-config.js +0 -0
- package/lib/config/templates/cma-config.template.js +0 -0
- package/lib/config/templates/magentorc.template +0 -0
- package/lib/config/templates/php-fpm.template.conf +0 -0
- package/lib/config/templates/vscode-launch.template.json +15 -0
- package/lib/config/versions/magento-2.3.0.js +1 -1
- package/lib/config/versions/magento-2.3.1.js +1 -1
- package/lib/config/versions/magento-2.3.2-p2.js +1 -1
- package/lib/config/versions/magento-2.3.2.js +1 -1
- package/lib/config/versions/magento-2.3.3-p1.js +1 -1
- package/lib/config/versions/magento-2.3.3.js +1 -1
- package/lib/config/versions/magento-2.3.4-p2.js +1 -1
- package/lib/config/versions/magento-2.3.4.js +1 -1
- package/lib/config/versions/magento-2.3.5-p1.js +1 -1
- package/lib/config/versions/magento-2.3.5-p2.js +1 -1
- package/lib/config/versions/magento-2.3.5.js +1 -1
- package/lib/config/versions/magento-2.3.6-p1.js +1 -1
- package/lib/config/versions/magento-2.3.6.js +1 -1
- package/lib/config/versions/magento-2.3.7-p1.js +2 -2
- package/lib/config/versions/magento-2.3.7.js +2 -2
- package/lib/config/versions/magento-2.4.0-p1.js +2 -2
- package/lib/config/versions/magento-2.4.0.js +2 -2
- package/lib/config/versions/magento-2.4.1-p1.js +2 -2
- package/lib/config/versions/magento-2.4.1.js +2 -2
- package/lib/config/versions/magento-2.4.2-p1.js +2 -2
- package/lib/config/versions/magento-2.4.2-p2.js +2 -2
- package/lib/config/versions/magento-2.4.2.js +2 -2
- package/lib/config/versions/magento-2.4.3-p1.js +2 -2
- package/lib/config/versions/magento-2.4.3.js +2 -2
- package/lib/tasks/cache/index.js +0 -0
- package/lib/tasks/cli/index.js +0 -0
- package/lib/tasks/composer/index.js +27 -5
- package/lib/tasks/execute/index.js +0 -0
- package/lib/tasks/file-system/create-vscode-config.js +111 -0
- package/lib/tasks/file-system/index.js +3 -1
- package/lib/tasks/magento/enable-magento-composer-plugins.js +173 -0
- package/lib/tasks/magento/index.js +0 -0
- package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -0
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +0 -0
- package/lib/tasks/magento/setup-magento/create-admin.js +0 -0
- package/lib/tasks/magento/setup-magento/delete-admin-users.js +0 -0
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +0 -0
- package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +0 -0
- package/lib/tasks/magento/setup-magento/set-base-url.js +0 -0
- package/lib/tasks/magento/setup-magento/set-deployment-mode.js +0 -0
- package/lib/tasks/magento/setup-magento/set-url-rewrite.js +0 -0
- package/lib/tasks/magento/setup-magento/waiting-for-redis.js +0 -0
- package/lib/tasks/mysql/index.js +0 -0
- package/lib/tasks/php/compile.js +4 -5
- package/lib/tasks/php/configure.js +28 -3
- package/lib/tasks/php/extensions/disable.js +2 -1
- package/lib/tasks/php/extensions/enable.js +2 -1
- package/lib/tasks/php/extensions/install.js +2 -1
- package/lib/tasks/php/index.js +10 -4
- package/lib/tasks/php/update-phpbrew.js +0 -0
- package/lib/tasks/php-fpm/index.js +0 -0
- package/lib/tasks/php-fpm/start-php-fpm.js +1 -1
- package/lib/tasks/php-fpm/stop-php-fpm.js +1 -1
- package/lib/tasks/requirements/dependency/arch.js +0 -0
- package/lib/tasks/requirements/dependency/centos.js +2 -2
- package/lib/tasks/requirements/dependency/fedora.js +0 -0
- package/lib/tasks/requirements/dependency/index.js +1 -4
- package/lib/tasks/requirements/dependency/mac.js +0 -0
- package/lib/tasks/requirements/dependency/ubuntu.js +0 -0
- package/lib/tasks/requirements/docker/install.js +1 -1
- package/lib/tasks/requirements/index.js +5 -3
- package/lib/tasks/requirements/php-version.js +113 -0
- package/lib/tasks/requirements/phpbrew/install.js +2 -4
- package/lib/tasks/start.js +2 -0
- package/lib/util/clean-object.js +0 -0
- package/lib/util/config-file-validator.js +7 -1
- package/lib/util/download-file.js +0 -0
- package/lib/util/ip.js +0 -0
- package/lib/util/match-filesystem.js +0 -0
- package/lib/util/move-file.js +0 -0
- package/lib/util/path-exists-sync.js +0 -0
- package/lib/util/portscanner.js +0 -0
- package/lib/util/run-composer.js +0 -0
- package/lib/util/run-magento.js +0 -0
- package/lib/util/run-php.js +0 -0
- package/lib/util/set-config.js +0 -0
- package/lib/util/sleep.js +0 -0
- package/lib/util/wait-for-it.js +0 -0
- package/lib/util/wait-for-logs.js +0 -0
- package/package.json +3 -2
package/.eslintrc
CHANGED
|
File without changes
|
package/LICENSE
CHANGED
|
File without changes
|
|
@@ -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:
|
|
41
|
+
edition: magentoEdition.toLowerCase()
|
|
40
42
|
});
|
|
41
43
|
}
|
|
42
44
|
|
package/lib/config/index.js
CHANGED
|
@@ -4,10 +4,10 @@ const {
|
|
|
4
4
|
getConfigurations,
|
|
5
5
|
defaultConfiguration
|
|
6
6
|
} = require('./versions');
|
|
7
|
-
const getPhpConfig = require('./php');
|
|
7
|
+
const getPhpConfig = require('./php-config');
|
|
8
8
|
const getComposerConfig = require('./composer');
|
|
9
9
|
const { getMagentoConfig } = require('./magento-config');
|
|
10
|
-
const { getPhpStormConfig } = require('./
|
|
10
|
+
const { getPhpStormConfig } = require('./phpstorm/debug-config');
|
|
11
11
|
const resolveConfigurationWithOverrides = require('../util/resolve-configuration-with-overrides');
|
|
12
12
|
const { getPrefix, folderName } = require('../util/prefix');
|
|
13
13
|
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const os = require('os');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const homePath = process.env.PHPBREW_HOME || path.join(os.homedir(), '.phpbrew');
|
|
5
|
+
const phpbrewConfig = {
|
|
6
|
+
homePath,
|
|
7
|
+
buildPath: path.join(homePath, 'build'),
|
|
8
|
+
phpPath: path.join(homePath, 'php'),
|
|
9
|
+
bashrcPath: path.join(homePath, 'bashrc')
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
module.exports = phpbrewConfig;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"name": "Listen for XDebug",
|
|
9
|
+
"type": "php",
|
|
10
|
+
"request": "launch",
|
|
11
|
+
"port": <%~ it.XDebugPort %>,
|
|
12
|
+
"runtimeExecutable": "<%~ it.PHPBinPath %>"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}
|
|
@@ -5,7 +5,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
5
5
|
magentoVersion: '2.3.7-p1',
|
|
6
6
|
configuration: {
|
|
7
7
|
php: {
|
|
8
|
-
version: '7.4.
|
|
8
|
+
version: '7.4.27',
|
|
9
9
|
configTemplate: path.join(templateDir || '', 'php.template.ini'),
|
|
10
10
|
extensions: {
|
|
11
11
|
gd: {},
|
|
@@ -15,7 +15,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
15
15
|
sockets: {},
|
|
16
16
|
SimpleXML: {},
|
|
17
17
|
xdebug: {
|
|
18
|
-
version: '
|
|
18
|
+
version: '3.1.2'
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
},
|
|
@@ -5,7 +5,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
5
5
|
magentoVersion: '2.3.7',
|
|
6
6
|
configuration: {
|
|
7
7
|
php: {
|
|
8
|
-
version: '7.4.
|
|
8
|
+
version: '7.4.27',
|
|
9
9
|
configTemplate: path.join(templateDir || '', 'php.template.ini'),
|
|
10
10
|
extensions: {
|
|
11
11
|
gd: {},
|
|
@@ -15,7 +15,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
15
15
|
sockets: {},
|
|
16
16
|
SimpleXML: {},
|
|
17
17
|
xdebug: {
|
|
18
|
-
version: '
|
|
18
|
+
version: '3.1.2'
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
},
|
|
@@ -5,7 +5,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
5
5
|
magentoVersion: '2.4.0-p1',
|
|
6
6
|
configuration: {
|
|
7
7
|
php: {
|
|
8
|
-
version: '7.4.
|
|
8
|
+
version: '7.4.27',
|
|
9
9
|
configTemplate: path.join(templateDir || '', 'php.template.ini'),
|
|
10
10
|
extensions: {
|
|
11
11
|
gd: {},
|
|
@@ -15,7 +15,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
15
15
|
sockets: {},
|
|
16
16
|
SimpleXML: {},
|
|
17
17
|
xdebug: {
|
|
18
|
-
version: '3.
|
|
18
|
+
version: '3.1.2'
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
},
|
|
@@ -5,7 +5,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
5
5
|
magentoVersion: '2.4.0',
|
|
6
6
|
configuration: {
|
|
7
7
|
php: {
|
|
8
|
-
version: '7.4.
|
|
8
|
+
version: '7.4.27',
|
|
9
9
|
configTemplate: path.join(templateDir || '', 'php.template.ini'),
|
|
10
10
|
extensions: {
|
|
11
11
|
gd: {},
|
|
@@ -15,7 +15,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
15
15
|
sockets: {},
|
|
16
16
|
SimpleXML: {},
|
|
17
17
|
xdebug: {
|
|
18
|
-
version: '3.
|
|
18
|
+
version: '3.1.2'
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
},
|
|
@@ -6,7 +6,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
6
6
|
magentoVersion: '2.4.1-p1',
|
|
7
7
|
configuration: {
|
|
8
8
|
php: {
|
|
9
|
-
version: '7.4.
|
|
9
|
+
version: '7.4.27',
|
|
10
10
|
configTemplate: path.join(templateDir || '', 'php.template.ini'),
|
|
11
11
|
extensions: {
|
|
12
12
|
gd: {},
|
|
@@ -17,7 +17,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
17
17
|
SimpleXML: {},
|
|
18
18
|
libsodium,
|
|
19
19
|
xdebug: {
|
|
20
|
-
version: '3.
|
|
20
|
+
version: '3.1.2'
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
},
|
|
@@ -5,7 +5,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
5
5
|
magentoVersion: '2.4.1',
|
|
6
6
|
configuration: {
|
|
7
7
|
php: {
|
|
8
|
-
version: '7.4.
|
|
8
|
+
version: '7.4.27',
|
|
9
9
|
configTemplate: path.join(templateDir || '', 'php.template.ini'),
|
|
10
10
|
extensions: {
|
|
11
11
|
gd: {},
|
|
@@ -15,7 +15,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
15
15
|
sockets: {},
|
|
16
16
|
SimpleXML: {},
|
|
17
17
|
xdebug: {
|
|
18
|
-
version: '3.
|
|
18
|
+
version: '3.1.2'
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
},
|
|
@@ -7,7 +7,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
7
7
|
isDefault: true,
|
|
8
8
|
configuration: {
|
|
9
9
|
php: {
|
|
10
|
-
version: '7.4.
|
|
10
|
+
version: '7.4.27',
|
|
11
11
|
configTemplate: path.join(templateDir || '', 'php.template.ini'),
|
|
12
12
|
extensions: {
|
|
13
13
|
gd: {},
|
|
@@ -19,7 +19,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
19
19
|
libsodium,
|
|
20
20
|
fileinfo: {},
|
|
21
21
|
xdebug: {
|
|
22
|
-
version: '3.
|
|
22
|
+
version: '3.1.2'
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
},
|
|
@@ -7,7 +7,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
7
7
|
isDefault: true,
|
|
8
8
|
configuration: {
|
|
9
9
|
php: {
|
|
10
|
-
version: '7.4.
|
|
10
|
+
version: '7.4.27',
|
|
11
11
|
configTemplate: path.join(templateDir || '', 'php.template.ini'),
|
|
12
12
|
extensions: {
|
|
13
13
|
gd: {},
|
|
@@ -19,7 +19,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
19
19
|
libsodium,
|
|
20
20
|
fileinfo: {},
|
|
21
21
|
xdebug: {
|
|
22
|
-
version: '3.
|
|
22
|
+
version: '3.1.2'
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
},
|
|
@@ -6,7 +6,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
6
6
|
magentoVersion: '2.4.2',
|
|
7
7
|
configuration: {
|
|
8
8
|
php: {
|
|
9
|
-
version: '7.4.
|
|
9
|
+
version: '7.4.27',
|
|
10
10
|
configTemplate: path.join(templateDir || '', 'php.template.ini'),
|
|
11
11
|
extensions: {
|
|
12
12
|
gd: {},
|
|
@@ -18,7 +18,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
18
18
|
libsodium,
|
|
19
19
|
fileinfo: {},
|
|
20
20
|
xdebug: {
|
|
21
|
-
version: '3.
|
|
21
|
+
version: '3.1.2'
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
},
|
|
@@ -7,7 +7,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
7
7
|
isDefault: true,
|
|
8
8
|
configuration: {
|
|
9
9
|
php: {
|
|
10
|
-
version: '7.4.
|
|
10
|
+
version: '7.4.27',
|
|
11
11
|
configTemplate: path.join(templateDir || '', 'php.template.ini'),
|
|
12
12
|
extensions: {
|
|
13
13
|
gd: {},
|
|
@@ -19,7 +19,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
19
19
|
libsodium,
|
|
20
20
|
fileinfo: {},
|
|
21
21
|
xdebug: {
|
|
22
|
-
version: '3.
|
|
22
|
+
version: '3.1.2'
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
},
|
|
@@ -7,7 +7,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
7
7
|
isDefault: true,
|
|
8
8
|
configuration: {
|
|
9
9
|
php: {
|
|
10
|
-
version: '7.4.
|
|
10
|
+
version: '7.4.27',
|
|
11
11
|
configTemplate: path.join(templateDir || '', 'php.template.ini'),
|
|
12
12
|
extensions: {
|
|
13
13
|
gd: {},
|
|
@@ -19,7 +19,7 @@ module.exports = ({ templateDir } = {}) => ({
|
|
|
19
19
|
libsodium,
|
|
20
20
|
fileinfo: {},
|
|
21
21
|
xdebug: {
|
|
22
|
-
version: '3.
|
|
22
|
+
version: '3.1.2'
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
},
|
package/lib/tasks/cache/index.js
CHANGED
|
File without changes
|
package/lib/tasks/cli/index.js
CHANGED
|
File without changes
|
|
@@ -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(`
|
|
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,9 +43,16 @@ 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 }) => {
|
|
50
|
+
const composerVersion = /^\d$/.test(composer.version)
|
|
51
|
+
? `latest-${composer.version}.x`
|
|
52
|
+
: composer.version;
|
|
53
|
+
|
|
35
54
|
try {
|
|
36
|
-
await downloadFile(`https://getcomposer.org/download
|
|
55
|
+
await downloadFile(`https://getcomposer.org/download/${composerVersion}/composer.phar`, {
|
|
37
56
|
destination: composer.binPath
|
|
38
57
|
});
|
|
39
58
|
} catch (e) {
|
|
@@ -59,11 +78,14 @@ const installComposer = () => ({
|
|
|
59
78
|
await downloadComposerBinary({ composer });
|
|
60
79
|
} else {
|
|
61
80
|
const currentComposerVersion = await getComposerVersion({ composer, php });
|
|
81
|
+
const expectedComposerVersion = /^\d$/.test(composer.version)
|
|
82
|
+
? `${composer.version}.x`
|
|
83
|
+
: composer.version;
|
|
62
84
|
|
|
63
|
-
if (!semver.satisfies(currentComposerVersion,
|
|
85
|
+
if (!semver.satisfies(currentComposerVersion, expectedComposerVersion)) {
|
|
64
86
|
const continueComposerBinaryVersionSwitch = await task.prompt({
|
|
65
87
|
type: 'Select',
|
|
66
|
-
message: `You have Composer ${logger.style.misc(`${currentComposerVersion}`)} while your Magento version requires ${logger.style.misc(
|
|
88
|
+
message: `You have Composer ${logger.style.misc(`${currentComposerVersion}`)} while your Magento version requires ${logger.style.misc(expectedComposerVersion)}!`,
|
|
67
89
|
choices: [
|
|
68
90
|
{
|
|
69
91
|
message: `Continue with current installed version (${logger.style.misc(`${currentComposerVersion}`)})`,
|
|
@@ -86,7 +108,7 @@ const installComposer = () => ({
|
|
|
86
108
|
break;
|
|
87
109
|
}
|
|
88
110
|
case 'exit': {
|
|
89
|
-
throw new Error(`Current composer version ${logger.style.misc(`v${currentComposerVersion}`)} is not compatible with version ${logger.style.misc(
|
|
111
|
+
throw new Error(`Current composer version ${logger.style.misc(`v${currentComposerVersion}`)} is not compatible with version ${logger.style.misc(expectedComposerVersion)}!`);
|
|
90
112
|
}
|
|
91
113
|
case 'continue':
|
|
92
114
|
default: {
|
|
File without changes
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const semver = require('semver');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const hjson = require('hjson');
|
|
6
|
+
const pathExists = require('../../util/path-exists');
|
|
7
|
+
const setConfigFile = require('../../util/set-config');
|
|
8
|
+
|
|
9
|
+
const phpXDebug2port = 9111;
|
|
10
|
+
const phpXDebug3port = 9003;
|
|
11
|
+
const listenForXDebugConfigName = 'Listen for XDebug';
|
|
12
|
+
|
|
13
|
+
const vscodeLaunchConfigPath = path.join(process.cwd(), '.vscode', 'launch.json');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {import('../../../typings/context').ListrContext['config']['php']} php
|
|
17
|
+
*/
|
|
18
|
+
const getCurrentXDebugPort = (php) => (semver.satisfies(php.extensions.xdebug.version, '>=3')
|
|
19
|
+
? phpXDebug3port
|
|
20
|
+
: phpXDebug2port);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {import('../../../typings/context').ListrContext['config']['php']} php
|
|
24
|
+
*/
|
|
25
|
+
const getPHPBinPathWithHomeVariable = (php) => php.binPath.replace(os.homedir(), '$HOME');
|
|
26
|
+
/**
|
|
27
|
+
* @param {import('../../../typings/context').ListrContext['config']['php']} php
|
|
28
|
+
*/
|
|
29
|
+
const addPHPDebugConfig = (vscodeLaunchConfig, php) => {
|
|
30
|
+
const phpXDebugConfig = vscodeLaunchConfig.configurations.find(
|
|
31
|
+
({ name }) => name === listenForXDebugConfigName
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const phpXDebugPort = getCurrentXDebugPort(php);
|
|
35
|
+
const phpBingPath = getPHPBinPathWithHomeVariable(php);
|
|
36
|
+
|
|
37
|
+
if (!phpXDebugConfig) {
|
|
38
|
+
vscodeLaunchConfig.configurations.push({
|
|
39
|
+
name: listenForXDebugConfigName,
|
|
40
|
+
type: 'php',
|
|
41
|
+
request: 'launch',
|
|
42
|
+
port: phpXDebugPort,
|
|
43
|
+
runtimeExecutable: phpBingPath
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (
|
|
50
|
+
phpXDebugConfig.port !== phpXDebugPort
|
|
51
|
+
&& phpXDebugConfig.runtimeExecutable !== phpBingPath
|
|
52
|
+
) {
|
|
53
|
+
phpXDebugConfig.port = phpXDebugPort;
|
|
54
|
+
phpXDebugConfig.runtimeExecutable = phpBingPath;
|
|
55
|
+
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return false;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
64
|
+
*/
|
|
65
|
+
const createPhpFpmConfig = () => ({
|
|
66
|
+
title: 'Setting VSCode config',
|
|
67
|
+
task: async ({ config: { php, baseConfig } }, task) => {
|
|
68
|
+
if (await pathExists(vscodeLaunchConfigPath)) {
|
|
69
|
+
const vscodeLaunchConfig = hjson.parse(await fs.promises.readFile(vscodeLaunchConfigPath, 'utf-8'), {
|
|
70
|
+
keepWsc: true
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const vscodeConfigEdited = addPHPDebugConfig(vscodeLaunchConfig, php);
|
|
74
|
+
|
|
75
|
+
// if vscode config is up-to-date, skip task
|
|
76
|
+
if (!vscodeConfigEdited) {
|
|
77
|
+
task.skip();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
await fs.promises.writeFile(vscodeLaunchConfigPath, hjson.stringify(vscodeLaunchConfig));
|
|
82
|
+
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (!await pathExists(path.join(process.cwd(), '.vscode'))) {
|
|
87
|
+
try {
|
|
88
|
+
await fs.promises.mkdir(path.join(process.cwd(), '.vscode'));
|
|
89
|
+
} catch (e) {
|
|
90
|
+
throw new Error(`Unable to creade .vscode directory in your project!\n\n${e}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
try {
|
|
95
|
+
const phpXDebugPort = getCurrentXDebugPort(php);
|
|
96
|
+
const vscodeLaunchConfigTemplatePath = path.join(baseConfig.templateDir, 'vscode-launch.template.json');
|
|
97
|
+
await setConfigFile({
|
|
98
|
+
template: vscodeLaunchConfigTemplatePath,
|
|
99
|
+
configPathname: vscodeLaunchConfigPath,
|
|
100
|
+
templateArgs: {
|
|
101
|
+
XDebugPort: phpXDebugPort,
|
|
102
|
+
PHPBinPath: getPHPBinPathWithHomeVariable(php)
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
} catch (e) {
|
|
106
|
+
throw new Error(`Unexpected error accrued during launch.json config creation!\n\n${e}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
module.exports = createPhpFpmConfig;
|