@scandipwa/magento-scripts 1.14.1-alpha.0 → 1.14.1-alpha.11
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/index.js +13 -0
- package/lib/commands/cli.js +28 -1
- package/lib/commands/execute.js +2 -1
- package/lib/commands/logs.js +1 -0
- package/lib/commands/start.js +18 -5
- package/lib/config/dependencies-for-platforms.js +12 -2
- package/lib/config/docker.js +89 -15
- package/lib/config/get-port-config.js +9 -3
- package/lib/config/index.js +2 -1
- package/lib/config/php/extensions/libsodium.js +2 -1
- package/lib/config/port-config.js +3 -1
- package/lib/config/scandipwa-versions.js +2 -1
- package/lib/config/ssl-terminator/index.js +10 -0
- package/lib/config/system-config.js +34 -5
- package/lib/config/templates/magentorc.template +3 -5
- package/lib/config/templates/nginx.template.conf +0 -14
- package/lib/config/templates/php.template.ini +6 -4
- package/lib/config/templates/ssl-terminator.template.conf +27 -0
- package/lib/config/templates/varnish.template.vcl +250 -0
- package/lib/config/varnish/varnish-6-0.js +11 -0
- package/lib/config/varnish/varnish-6-6.js +11 -0
- package/lib/config/varnish/varnish-7-0.js +11 -0
- package/lib/config/versions/magento-2.3.0.js +9 -1
- package/lib/config/versions/magento-2.3.1.js +9 -1
- package/lib/config/versions/magento-2.3.2-p2.js +9 -1
- package/lib/config/versions/magento-2.3.2.js +9 -1
- package/lib/config/versions/magento-2.3.3-p1.js +9 -1
- package/lib/config/versions/magento-2.3.3.js +9 -1
- package/lib/config/versions/magento-2.3.4-p2.js +9 -1
- package/lib/config/versions/magento-2.3.4.js +9 -1
- package/lib/config/versions/magento-2.3.5-p1.js +9 -1
- package/lib/config/versions/magento-2.3.5-p2.js +9 -1
- package/lib/config/versions/magento-2.3.5.js +9 -1
- package/lib/config/versions/magento-2.3.6-p1.js +9 -1
- package/lib/config/versions/magento-2.3.6.js +9 -1
- package/lib/config/versions/magento-2.3.7-p1.js +9 -1
- package/lib/config/versions/magento-2.3.7-p2.js +9 -1
- package/lib/config/versions/magento-2.3.7-p3.js +9 -1
- package/lib/config/versions/magento-2.3.7.js +9 -1
- package/lib/config/versions/magento-2.4.0-p1.js +9 -1
- package/lib/config/versions/magento-2.4.0.js +9 -1
- package/lib/config/versions/magento-2.4.1-p1.js +9 -1
- package/lib/config/versions/magento-2.4.1.js +9 -1
- package/lib/config/versions/magento-2.4.2-p1.js +9 -1
- package/lib/config/versions/magento-2.4.2-p2.js +9 -1
- package/lib/config/versions/magento-2.4.2.js +9 -1
- package/lib/config/versions/magento-2.4.3-p1.js +9 -1
- package/lib/config/versions/magento-2.4.3-p2.js +9 -1
- package/lib/config/versions/magento-2.4.3.js +9 -1
- package/lib/config/versions/magento-2.4.4.js +9 -1
- package/lib/errors/known-error.js +15 -0
- package/lib/errors/unknown-error.js +15 -0
- package/lib/tasks/cli/create-bashrc-config.js +7 -3
- package/lib/tasks/composer/index.js +5 -3
- package/lib/tasks/composer/local-auth-json.js +4 -2
- package/lib/tasks/docker/containers.js +13 -8
- package/lib/tasks/docker/network.js +2 -1
- package/lib/tasks/docker/volumes.js +4 -4
- package/lib/tasks/file-system/create-nginx-config.js +9 -40
- package/lib/tasks/file-system/create-php-config.js +2 -1
- package/lib/tasks/file-system/create-php-fpm-config.js +2 -1
- package/lib/tasks/file-system/create-php-storm-config.js +6 -5
- package/lib/tasks/file-system/create-ssl-terminator-config.js +96 -0
- package/lib/tasks/file-system/create-varnish-config.js +53 -0
- package/lib/tasks/file-system/create-vscode-config.js +3 -2
- package/lib/tasks/file-system/index.js +5 -1
- package/lib/tasks/magento/enable-magento-composer-plugins.js +3 -2
- package/lib/tasks/magento/install-magento.js +7 -5
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +1 -1
- package/lib/tasks/magento/setup-magento/disable-2fa.js +4 -12
- package/lib/tasks/magento/setup-magento/disable-full-page-cache.js +20 -0
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +2 -1
- package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +14 -16
- package/lib/tasks/magento/setup-magento/index.js +3 -1
- package/lib/tasks/magento/setup-magento/install-magento.js +2 -1
- package/lib/tasks/magento/setup-magento/migrate-database.js +24 -11
- package/lib/tasks/magento/setup-magento/set-base-url.js +7 -2
- package/lib/tasks/magento/setup-magento/upgrade-magento.js +27 -3
- package/lib/tasks/magento/setup-magento/varnish-config.js +69 -0
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +41 -0
- package/lib/tasks/mysql/connect-to-mysql.js +2 -1
- package/lib/tasks/mysql/fix-db.js +2 -2
- package/lib/tasks/mysql/import-dump-to-mysql.js +4 -2
- package/lib/tasks/mysql/import-remote-db/index.js +2 -1
- package/lib/tasks/mysql/import-remote-db/ssh/index.js +2 -1
- package/lib/tasks/mysql/import-remote-db/ssh/regular-server.js +2 -1
- package/lib/tasks/php/bundled-extensions.js +28 -0
- package/lib/tasks/php/compile-options.js +18 -48
- package/lib/tasks/php/compile.js +4 -3
- package/lib/tasks/php/configure.js +7 -66
- package/lib/tasks/php/extensions/index.js +71 -0
- package/lib/tasks/php/index.js +8 -7
- package/lib/tasks/php/update-env-php.js +16 -1
- package/lib/tasks/php/update-env.php +56 -12
- package/lib/tasks/php/update-phpbrew.js +2 -1
- package/lib/tasks/php/validate-php.js +67 -0
- package/lib/tasks/php-fpm/start-php-fpm.js +2 -1
- package/lib/tasks/requirements/composer.js +5 -3
- package/lib/tasks/requirements/dependency/arch.js +2 -1
- package/lib/tasks/requirements/dependency/centos.js +2 -1
- package/lib/tasks/requirements/dependency/fedora.js +2 -1
- package/lib/tasks/requirements/docker/index.js +7 -4
- package/lib/tasks/requirements/docker/install.js +13 -12
- package/lib/tasks/requirements/docker/running-status.js +138 -0
- package/lib/tasks/requirements/docker/version.js +3 -0
- package/lib/tasks/requirements/index.js +5 -5
- package/lib/tasks/requirements/node-version.js +2 -1
- package/lib/tasks/requirements/php-version.js +8 -4
- package/lib/tasks/requirements/phpbrew/index.js +2 -1
- package/lib/tasks/requirements/phpbrew/install.js +2 -1
- package/lib/tasks/requirements/phpbrew/version.js +2 -1
- package/lib/tasks/requirements/platform.js +3 -2
- package/lib/tasks/start.js +11 -10
- package/lib/tasks/status/index.js +25 -9
- package/lib/tasks/theme/build-theme.js +27 -8
- package/lib/tasks/theme/install-theme.js +18 -5
- package/lib/tasks/theme/link-theme.js +2 -2
- package/lib/tasks/theme/retrieve-theme-data.js +2 -1
- package/lib/tasks/theme/setup-persisted-query.js +5 -4
- package/lib/tasks/theme/setup-themes.js +5 -3
- package/lib/tasks/theme/symlink-theme.js +20 -4
- package/lib/util/analytics.js +337 -0
- package/lib/util/config-file-validator.js +14 -2
- package/lib/util/config-php-json.js +20 -0
- package/lib/util/env-php-json.js +3 -2
- package/lib/util/get-installed-magento-version.js +3 -2
- package/lib/util/get-jsonfile-data.js +2 -1
- package/lib/util/install-dependencies-task.js +4 -4
- package/lib/util/instance-metadata.js +11 -4
- package/lib/util/ip.js +45 -1
- package/lib/util/is-running-root.js +3 -0
- package/lib/util/magento-task.js +20 -9
- package/lib/util/match-filesystem.js +2 -1
- package/lib/util/php-task.js +6 -2
- package/lib/util/request.js +0 -0
- package/lib/util/resolve-configuration-with-overrides.js +2 -1
- package/lib/util/run-composer.js +3 -2
- package/lib/util/run-magento.js +3 -2
- package/lib/util/run-php.js +10 -3
- package/lib/util/systemctl.js +46 -0
- package/lib/util/wait-for-it.js +3 -2
- package/package.json +4 -3
- package/typings/context.d.ts +5 -1
- package/typings/index.d.ts +32 -1
- package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -27
- package/lib/tasks/magento/setup-magento/disable-page-cache.js +0 -11
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
5
|
+
const pathExists = require('../../../util/path-exists');
|
|
6
|
+
const phpbrewConfig = require('../../../config/phpbrew');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get enabled extensions list with versions
|
|
10
|
+
* @param {import('../../../../typings/context').ListrContext['config']} param0
|
|
11
|
+
* @returns {Promise<{[key: string]: string}}>}
|
|
12
|
+
*/
|
|
13
|
+
const getEnabledExtensions = async ({ php }) => {
|
|
14
|
+
const output = await execAsyncSpawn(
|
|
15
|
+
`${ php.binPath } -c ${php.iniPath} -r 'foreach (get_loaded_extensions() as $extension) echo "$extension:" . phpversion($extension) . "\n";'`
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
return output
|
|
19
|
+
.split('\n')
|
|
20
|
+
.map((m) => {
|
|
21
|
+
// eslint-disable-next-line no-unused-vars
|
|
22
|
+
const [_, moduleName, moduleVersion] = m.match(/(.+):(.+)/i);
|
|
23
|
+
|
|
24
|
+
return [moduleName, moduleVersion];
|
|
25
|
+
})
|
|
26
|
+
.reduce((acc, [name, version]) => ({ ...acc, [name]: version }), {});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get disabled extensions list
|
|
31
|
+
* @param {import('../../../../typings/context').ListrContext['config']} param0
|
|
32
|
+
* @returns {Promise<string[]>}
|
|
33
|
+
*/
|
|
34
|
+
const getDisabledExtensions = async ({ php }) => {
|
|
35
|
+
const extensionsIniDirectory = path.join(phpbrewConfig.phpPath, `php-${php.version}`, 'var', 'db');
|
|
36
|
+
|
|
37
|
+
if (!await pathExists(extensionsIniDirectory)) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const extensionIniList = await fs.promises.readdir(
|
|
42
|
+
extensionsIniDirectory,
|
|
43
|
+
{
|
|
44
|
+
encoding: 'utf-8',
|
|
45
|
+
withFileTypes: true
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return extensionIniList.filter((f) => f.isFile() && f.name.endsWith('.disabled')).map((f) => f.name.replace('.disabled', ''));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Get installed extensions
|
|
54
|
+
* @param {import('../../../../typings/context').ListrContext['config']} param0
|
|
55
|
+
* @returns {Promise<string[]>}
|
|
56
|
+
*/
|
|
57
|
+
const getInstalledExtensions = async ({ php }) => {
|
|
58
|
+
const extensionDirectory = path.join(phpbrewConfig.buildPath, `php-${php.version}`, 'ext');
|
|
59
|
+
|
|
60
|
+
const availableExtensions = await fs.promises.readdir(extensionDirectory, {
|
|
61
|
+
encoding: 'utf-8'
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return availableExtensions;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
module.exports = {
|
|
68
|
+
getEnabledExtensions,
|
|
69
|
+
getDisabledExtensions,
|
|
70
|
+
getInstalledExtensions
|
|
71
|
+
};
|
package/lib/tasks/php/index.js
CHANGED
|
@@ -2,10 +2,11 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
4
4
|
const pathExists = require('../../util/path-exists');
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const compilePhp = require('./compile');
|
|
6
|
+
const configurePhp = require('./configure');
|
|
7
7
|
const updatePhpBrew = require('./update-phpbrew');
|
|
8
8
|
const phpbrewConfig = require('../../config/phpbrew');
|
|
9
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -17,7 +18,7 @@ const installPhp = () => ({
|
|
|
17
18
|
const phpBinExists = await pathExists(php.binPath);
|
|
18
19
|
|
|
19
20
|
if (phpBinExists && !recompilePhp) {
|
|
20
|
-
task.title = `Using PHP version ${php.version}`;
|
|
21
|
+
task.title = `Using PHP version ${php.version} in project`;
|
|
21
22
|
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
@@ -52,7 +53,7 @@ const installPhp = () => ({
|
|
|
52
53
|
return;
|
|
53
54
|
}
|
|
54
55
|
} catch (e) {
|
|
55
|
-
throw new
|
|
56
|
+
throw new UnknownError(
|
|
56
57
|
`Failed to extract the list of installed PHP versions.
|
|
57
58
|
Possibly, you forgot to setup PHPBrew?
|
|
58
59
|
Follow these instruction: ${ logger.style.link('https://phpbrew.github.io/phpbrew/#setting-up') }
|
|
@@ -63,7 +64,7 @@ const installPhp = () => ({
|
|
|
63
64
|
// eslint-disable-next-line consistent-return
|
|
64
65
|
return task.newListr([
|
|
65
66
|
updatePhpBrew(),
|
|
66
|
-
|
|
67
|
+
compilePhp()
|
|
67
68
|
], {
|
|
68
69
|
concurrent: false,
|
|
69
70
|
exitOnError: true
|
|
@@ -73,6 +74,6 @@ const installPhp = () => ({
|
|
|
73
74
|
|
|
74
75
|
module.exports = {
|
|
75
76
|
installPhp,
|
|
76
|
-
compilePhp
|
|
77
|
-
configurePhp
|
|
77
|
+
compilePhp,
|
|
78
|
+
configurePhp
|
|
78
79
|
};
|
|
@@ -14,8 +14,23 @@ const updateEnvPHP = () => ({
|
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
const useVarnish = ctx.config.overridenConfiguration.configuration.varnish.enabled ? '1' : '';
|
|
18
|
+
const varnishHost = '127.0.0.1';
|
|
19
|
+
const varnishPort = ctx.ports.varnish;
|
|
20
|
+
const previousVarnishPort = ctx.cachedPorts
|
|
21
|
+
? ctx.cachedPorts.varnish
|
|
22
|
+
: ctx.cachedPorts;
|
|
23
|
+
|
|
17
24
|
return task.newListr(
|
|
18
|
-
phpTask(`-f ${ path.join(__dirname, 'update-env.php') }`, {
|
|
25
|
+
phpTask(`-f ${ path.join(__dirname, 'update-env.php') }`, {
|
|
26
|
+
noTitle: true,
|
|
27
|
+
env: {
|
|
28
|
+
USE_VARNISH: useVarnish,
|
|
29
|
+
VARNISH_PORT: `${ varnishPort }`,
|
|
30
|
+
VARNISH_HOST: varnishHost,
|
|
31
|
+
PREVIOUS_VARNISH_PORT: `${ previousVarnishPort }`
|
|
32
|
+
}
|
|
33
|
+
})
|
|
19
34
|
);
|
|
20
35
|
}
|
|
21
36
|
});
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
function varexport($expression, $return=
|
|
3
|
+
function varexport($expression, $return=false): string
|
|
4
4
|
{
|
|
5
|
-
$export = var_export($expression,
|
|
5
|
+
$export = var_export($expression, true);
|
|
6
6
|
$export = preg_replace("/^([ ]*)(.*)/m", '$1$1$2', $export);
|
|
7
7
|
$array = preg_split("/\r\n|\n|\r/", $export);
|
|
8
|
-
$array = preg_replace(["/\s*array\s\($/", "/\)(,)?$/", "/\s=>\s$/"], [
|
|
8
|
+
$array = preg_replace(["/\s*array\s\($/", "/\)(,)?$/", "/\s=>\s$/"], [null, ']$1', ' => ['], $array);
|
|
9
9
|
$export = join(PHP_EOL, array_filter(["["] + $array));
|
|
10
|
-
if ((bool)$return)
|
|
10
|
+
if ((bool)$return) {
|
|
11
|
+
return $export;
|
|
12
|
+
} else {
|
|
13
|
+
echo $export;
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
function joinpaths(): string
|
|
@@ -15,13 +19,16 @@ function joinpaths(): string
|
|
|
15
19
|
$paths = array();
|
|
16
20
|
|
|
17
21
|
foreach (func_get_args() as $arg) {
|
|
18
|
-
if ($arg !== '') {
|
|
22
|
+
if ($arg !== '') {
|
|
23
|
+
$paths[] = $arg;
|
|
24
|
+
}
|
|
19
25
|
}
|
|
20
26
|
|
|
21
|
-
return preg_replace('#/+#','/',join('/', $paths));
|
|
27
|
+
return preg_replace('#/+#', '/', join('/', $paths));
|
|
22
28
|
}
|
|
23
29
|
|
|
24
|
-
class EnvUpdater
|
|
30
|
+
class EnvUpdater
|
|
31
|
+
{
|
|
25
32
|
|
|
26
33
|
/**
|
|
27
34
|
* @var array
|
|
@@ -33,7 +40,8 @@ class EnvUpdater {
|
|
|
33
40
|
*/
|
|
34
41
|
private $portConfig;
|
|
35
42
|
|
|
36
|
-
public function loadConfig()
|
|
43
|
+
public function loadConfig()
|
|
44
|
+
{
|
|
37
45
|
$this->config = require './app/etc/env.php';
|
|
38
46
|
}
|
|
39
47
|
|
|
@@ -53,7 +61,8 @@ class EnvUpdater {
|
|
|
53
61
|
return $this->portConfig;
|
|
54
62
|
}
|
|
55
63
|
|
|
56
|
-
public function loadPortConfig()
|
|
64
|
+
public function loadPortConfig()
|
|
65
|
+
{
|
|
57
66
|
$portConfigContent = file_get_contents('./node_modules/.create-magento-app-cache/port-config.json');
|
|
58
67
|
if ($portConfigContent === false) {
|
|
59
68
|
throw new Error('Port config file does not exists in cache directory');
|
|
@@ -67,7 +76,8 @@ class EnvUpdater {
|
|
|
67
76
|
$this->portConfig = $portConfigJsonData;
|
|
68
77
|
}
|
|
69
78
|
|
|
70
|
-
public function modifyConfig()
|
|
79
|
+
public function modifyConfig()
|
|
80
|
+
{
|
|
71
81
|
// update mysql config
|
|
72
82
|
if (isset($this->config['db']['connection']['default'])) {
|
|
73
83
|
$conn = &$this->config['db']['connection']['default'];
|
|
@@ -122,16 +132,50 @@ class EnvUpdater {
|
|
|
122
132
|
}
|
|
123
133
|
}
|
|
124
134
|
}
|
|
135
|
+
|
|
136
|
+
$httpCacheHosts = &$this->config['http_cache_hosts'];
|
|
137
|
+
$httpCacheHosts = [];
|
|
138
|
+
|
|
139
|
+
if (getenv('USE_VARNISH') == '1') {
|
|
140
|
+
$varnishHost = getenv('VARNISH_HOST');
|
|
141
|
+
$varnishPort = getenv('VARNISH_PORT');
|
|
142
|
+
$previousVarnishPort = getenv('PREVIOUS_VARNISH_PORT');
|
|
143
|
+
$varnishConfig = [
|
|
144
|
+
'host' => $varnishHost,
|
|
145
|
+
'port' => $varnishPort
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
if (isset($httpCacheHosts)) {
|
|
149
|
+
$varnishHostExists = false;
|
|
150
|
+
foreach ($httpCacheHosts as $host) {
|
|
151
|
+
if ($host['host'] == $varnishHost && $host['port'] == $previousVarnishPort) {
|
|
152
|
+
$host['port'] = $varnishPort;
|
|
153
|
+
$varnishHostExists = true;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (!$varnishHostExists) {
|
|
159
|
+
$httpCacheHosts = [$varnishConfig];
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
$this->config['http_cache_hosts'] = [$varnishConfig];
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
unset($this->config['http_cache_hosts']);
|
|
166
|
+
}
|
|
125
167
|
}
|
|
126
168
|
|
|
127
|
-
public function saveConfig(string $filePath)
|
|
169
|
+
public function saveConfig(string $filePath)
|
|
170
|
+
{
|
|
128
171
|
file_put_contents(
|
|
129
172
|
$filePath,
|
|
130
173
|
'<?php'.PHP_EOL.'return '.varexport($this->config, true).';' . PHP_EOL
|
|
131
174
|
);
|
|
132
175
|
}
|
|
133
176
|
|
|
134
|
-
public function update()
|
|
177
|
+
public function update()
|
|
178
|
+
{
|
|
135
179
|
$this->loadConfig();
|
|
136
180
|
$this->loadPortConfig();
|
|
137
181
|
$this->modifyConfig();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
1
2
|
const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -20,7 +21,7 @@ const updatePhpBrew = () => ({
|
|
|
20
21
|
}
|
|
21
22
|
});
|
|
22
23
|
} catch (e) {
|
|
23
|
-
throw new
|
|
24
|
+
throw new UnknownError(`Unexpected error while updating phpbrew known php versions\n\n${e}`);
|
|
24
25
|
}
|
|
25
26
|
},
|
|
26
27
|
options: {
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
2
|
+
const { bundledExtensions } = require('./bundled-extensions');
|
|
3
|
+
const configurePHP = require('./configure');
|
|
4
|
+
const { getEnabledExtensions } = require('./extensions');
|
|
5
|
+
const { installPhp } = require('./index');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
9
|
+
*/
|
|
10
|
+
const validatePHPInstallation = () => ({
|
|
11
|
+
title: 'Validating PHP installation',
|
|
12
|
+
task: async (ctx, task) => {
|
|
13
|
+
const enabledExtensions = await getEnabledExtensions(ctx.config);
|
|
14
|
+
const enabledExtensionsKeys = Object.keys(enabledExtensions);
|
|
15
|
+
|
|
16
|
+
enabledExtensionsKeys.push('fpm');
|
|
17
|
+
|
|
18
|
+
if (enabledExtensionsKeys.some((ext) => ext.includes('mysql'))) {
|
|
19
|
+
enabledExtensionsKeys.push('mysql');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const missingBundledExtensions = bundledExtensions.filter(
|
|
23
|
+
(ext) => !enabledExtensionsKeys.some(
|
|
24
|
+
(ex) => ex.toLowerCase() === ext.toLowerCase()
|
|
25
|
+
)
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
if (missingBundledExtensions.length > 0) {
|
|
29
|
+
const selectedOption = await task.prompt({
|
|
30
|
+
type: 'Select',
|
|
31
|
+
message: `Your PHP version compiled by PHPBrew is missing important extensions that are bundled by default by ${logger.style.misc('magento-scripts')}
|
|
32
|
+
Maybe you ran PHPBrew by yourself?
|
|
33
|
+
|
|
34
|
+
Please, consider recompiling PHP using ${logger.style.misc('magento-scripts')}.
|
|
35
|
+
|
|
36
|
+
${logger.style.command('npm start -- --recompile-php')}
|
|
37
|
+
`,
|
|
38
|
+
choices: [
|
|
39
|
+
{
|
|
40
|
+
name: 'recompile-php',
|
|
41
|
+
message: `I want ${logger.style.misc('magento-scripts')} to recompile PHP`
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'skip',
|
|
45
|
+
message: 'I am sure that it is okay and want to continue with this setup'
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
if (selectedOption === 'skip') {
|
|
51
|
+
task.skip('User skipped PHP recompilation');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
ctx.recompilePhp = true;
|
|
56
|
+
|
|
57
|
+
return task.newListr([
|
|
58
|
+
installPhp(),
|
|
59
|
+
configurePHP()
|
|
60
|
+
], {
|
|
61
|
+
concurrent: false
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
module.exports = validatePHPInstallation;
|
|
@@ -2,6 +2,7 @@ const { execAsyncSpawn } = require('../../util/exec-async-command');
|
|
|
2
2
|
const getPhpConfig = require('../../config/php-config');
|
|
3
3
|
const { getBaseConfig } = require('../../config/index');
|
|
4
4
|
const getProcessId = require('./get-process-id');
|
|
5
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -35,7 +36,7 @@ const startPhpFpm = () => ({
|
|
|
35
36
|
}
|
|
36
37
|
);
|
|
37
38
|
} catch (e) {
|
|
38
|
-
throw new
|
|
39
|
+
throw new UnknownError(`Error during PHP-FPM start\n\n${e}`);
|
|
39
40
|
}
|
|
40
41
|
},
|
|
41
42
|
options: {
|
|
@@ -3,6 +3,8 @@ const fs = require('fs');
|
|
|
3
3
|
const os = require('os');
|
|
4
4
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
5
5
|
const pathExists = require('../../util/path-exists');
|
|
6
|
+
const KnownError = require('../../errors/known-error');
|
|
7
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
6
8
|
|
|
7
9
|
const authJsonPath = path.join(process.cwd(), 'auth.json');
|
|
8
10
|
const shellName = process.env.SHELL.split('/').pop();
|
|
@@ -112,7 +114,7 @@ ${ logger.style.misc('Password') } (${ logger.style.misc('Private key') }):`,
|
|
|
112
114
|
break;
|
|
113
115
|
}
|
|
114
116
|
default: {
|
|
115
|
-
throw new
|
|
117
|
+
throw new KnownError(
|
|
116
118
|
`Unfortunately we cannot automatically add credentials for your shell ${process.env.SHELL}!
|
|
117
119
|
|
|
118
120
|
You will need to that manually!
|
|
@@ -195,7 +197,7 @@ Would you like to load them now?`
|
|
|
195
197
|
|
|
196
198
|
process.env.COMPOSER_AUTH = composerAuthFileContent;
|
|
197
199
|
} catch (e) {
|
|
198
|
-
throw new
|
|
200
|
+
throw new UnknownError(
|
|
199
201
|
`We found an error in your ${ logger.style.file('./auth.json') } file.
|
|
200
202
|
|
|
201
203
|
Make sure that this file contains a valid JSON!
|
|
@@ -211,7 +213,7 @@ Error message that we got: ${e}`
|
|
|
211
213
|
try {
|
|
212
214
|
composerAuthContent = JSON.parse(process.env.COMPOSER_AUTH);
|
|
213
215
|
} catch (e) {
|
|
214
|
-
throw new
|
|
216
|
+
throw new UnknownError(
|
|
215
217
|
`We found an error in your ${ logger.style.misc('$COMPOSER_AUTH') } environment variable.
|
|
216
218
|
|
|
217
219
|
Make sure that this variable contains a valid JSON!
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const dependenciesForPlatforms = require('../../../config/dependencies-for-platforms');
|
|
2
|
+
const UnknownError = require('../../../errors/unknown-error');
|
|
2
3
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
3
4
|
const installDependenciesTask = require('../../../util/install-dependencies-task');
|
|
4
5
|
|
|
@@ -15,7 +16,7 @@ const archDependenciesCheck = () => ({
|
|
|
15
16
|
const result = pkg.match(pkgRegex);
|
|
16
17
|
|
|
17
18
|
if (!result) {
|
|
18
|
-
throw new
|
|
19
|
+
throw new UnknownError(`Package without a version!\n\n${pkg}\n\nHOW?`);
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
return result[1];
|
|
@@ -11,9 +11,10 @@ const centosDependenciesCheck = () => ({
|
|
|
11
11
|
const installedDependencies = (await execAsyncSpawn('yum list installed')).split('\n')
|
|
12
12
|
.filter((pkg) => !pkg.toLowerCase().includes('installed packages'))
|
|
13
13
|
.map((pkg) => pkg.match(/^(\S+)/i))
|
|
14
|
-
.filter(
|
|
14
|
+
.filter(Boolean)
|
|
15
15
|
.map((pkg) => pkg[1])
|
|
16
16
|
.map((pkg) => pkg.match(/^(\S+)\.\S+/i))
|
|
17
|
+
.filter(Boolean)
|
|
17
18
|
.map((pkg) => pkg[1]);
|
|
18
19
|
|
|
19
20
|
const dependenciesToInstall = dependenciesForPlatforms
|
|
@@ -11,9 +11,10 @@ const fedoraDependenciesCheck = () => ({
|
|
|
11
11
|
const installedDependencies = (await execAsyncSpawn('yum list installed')).split('\n')
|
|
12
12
|
.filter((pkg) => !pkg.toLowerCase().includes('installed packages'))
|
|
13
13
|
.map((pkg) => pkg.match(/^(\S+)/i))
|
|
14
|
-
.filter(
|
|
14
|
+
.filter(Boolean)
|
|
15
15
|
.map((pkg) => pkg[1])
|
|
16
16
|
.map((pkg) => pkg.match(/^(\S+)\.\S+/i))
|
|
17
|
+
.filter(Boolean)
|
|
17
18
|
.map((pkg) => pkg[1]);
|
|
18
19
|
|
|
19
20
|
const dependenciesToInstall = dependenciesForPlatforms
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
2
2
|
const os = require('os');
|
|
3
|
+
const KnownError = require('../../../errors/known-error');
|
|
3
4
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
4
5
|
const getIsWsl = require('../../../util/is-wsl');
|
|
5
6
|
const installDocker = require('./install');
|
|
6
7
|
const { checkDockerSocketPermissions } = require('./permissions');
|
|
8
|
+
const checkDockerStatus = require('./running-status');
|
|
7
9
|
const getDockerVersion = require('./version');
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -34,7 +36,7 @@ NOTE: After installation it's recommended to log out and log back in so your gro
|
|
|
34
36
|
task: (ctx) => {
|
|
35
37
|
task.title = `Using docker version ${ctx.dockerVersion}`;
|
|
36
38
|
|
|
37
|
-
throw new
|
|
39
|
+
throw new KnownError(
|
|
38
40
|
`Docker is installed successfully!
|
|
39
41
|
Please log out and log back to so your group membership is re-evaluated!
|
|
40
42
|
Learn more here: ${ logger.style.link('https://docs.docker.com/engine/install/linux-postinstall/') }`
|
|
@@ -44,15 +46,15 @@ Learn more here: ${ logger.style.link('https://docs.docker.com/engine/install/li
|
|
|
44
46
|
]);
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
throw new
|
|
49
|
+
throw new KnownError('Docker is not installed!');
|
|
48
50
|
} else if (isWsl) {
|
|
49
|
-
throw new
|
|
51
|
+
throw new KnownError(
|
|
50
52
|
`You don't have Docker installed!
|
|
51
53
|
Follow this instructions to install Docker on Windows:
|
|
52
54
|
${ logger.style.link('https://docs.create-magento-app.com/getting-started/prerequisites/windows-requirements#2-install-docker-desktop-for-windows') }`
|
|
53
55
|
);
|
|
54
56
|
} else {
|
|
55
|
-
throw new
|
|
57
|
+
throw new KnownError(
|
|
56
58
|
`You don't have Docker installed!
|
|
57
59
|
Follow this instructions to install Docker on Mac:
|
|
58
60
|
${ logger.style.link('https://docs.create-magento-app.com/getting-started/prerequisites/installation-on-macos#3-install-docker-for-mac') }`
|
|
@@ -61,6 +63,7 @@ ${ logger.style.link('https://docs.create-magento-app.com/getting-started/prereq
|
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
return task.newListr([
|
|
66
|
+
checkDockerStatus(),
|
|
64
67
|
getDockerVersion(),
|
|
65
68
|
{
|
|
66
69
|
task: (ctx) => {
|
|
@@ -2,6 +2,11 @@ const osPlatform = require('../../../util/os-platform');
|
|
|
2
2
|
const { execCommandTask } = require('../../../util/exec-async-command');
|
|
3
3
|
const installDependenciesTask = require('../../../util/install-dependencies-task');
|
|
4
4
|
const executeSudoCommand = require('../../../util/execute-sudo-command');
|
|
5
|
+
const KnownError = require('../../../errors/known-error');
|
|
6
|
+
|
|
7
|
+
const downloadDockerInstallScriptCommand = () => execCommandTask('curl -fsSL https://get.docker.com -o get-docker.sh');
|
|
8
|
+
const runDockerInstallScriptCommand = () => executeSudoCommand('sudo sh get-docker.sh');
|
|
9
|
+
const enableAndStartDockerCommand = () => executeSudoCommand('sudo systemctl enable docker --now');
|
|
5
10
|
|
|
6
11
|
const postInstallSteps = [
|
|
7
12
|
executeSudoCommand('[ $(getent group docker) ] && sudo groupadd docker', {
|
|
@@ -9,7 +14,6 @@ const postInstallSteps = [
|
|
|
9
14
|
}),
|
|
10
15
|
executeSudoCommand(`sudo usermod -aG docker ${process.env.USER}`)
|
|
11
16
|
];
|
|
12
|
-
|
|
13
17
|
/**
|
|
14
18
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
15
19
|
*/
|
|
@@ -24,31 +28,28 @@ const installDocker = () => ({
|
|
|
24
28
|
platform: 'Arch Linux',
|
|
25
29
|
dependenciesToInstall: ['docker']
|
|
26
30
|
}),
|
|
27
|
-
|
|
28
|
-
executeSudoCommand('sudo systemctl enable docker.service'),
|
|
31
|
+
enableAndStartDockerCommand(),
|
|
29
32
|
...postInstallSteps
|
|
30
33
|
]);
|
|
31
34
|
}
|
|
32
35
|
case 'Fedora':
|
|
33
36
|
case 'CentOS': {
|
|
34
37
|
return task.newListr([
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
executeSudoCommand('sudo systemctl enable docker')
|
|
38
|
+
downloadDockerInstallScriptCommand(),
|
|
39
|
+
runDockerInstallScriptCommand(),
|
|
40
|
+
enableAndStartDockerCommand()
|
|
39
41
|
]);
|
|
40
42
|
}
|
|
41
43
|
case 'Ubuntu': {
|
|
42
44
|
return task.newListr([
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
executeSudoCommand('sudo systemctl enable docker.service'),
|
|
45
|
+
downloadDockerInstallScriptCommand(),
|
|
46
|
+
runDockerInstallScriptCommand(),
|
|
47
|
+
enableAndStartDockerCommand(),
|
|
47
48
|
...postInstallSteps
|
|
48
49
|
]);
|
|
49
50
|
}
|
|
50
51
|
default: {
|
|
51
|
-
throw new
|
|
52
|
+
throw new KnownError(`Docker is not installed!
|
|
52
53
|
Your distro ${distro} is not supported by automatic installation.`);
|
|
53
54
|
}
|
|
54
55
|
}
|