@scandipwa/magento-scripts 1.14.1-alpha.1 → 1.14.1-alpha.12
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/cma-config.js +16 -0
- package/lib/config/dependencies-for-platforms.js +15 -3
- 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 +255 -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/config/xml-parser.js +5 -3
- 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-phpstorm-config/database-config.js +5 -4
- package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +12 -10
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +0 -3
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +0 -3
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +1 -1
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +0 -3
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +0 -3
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +1 -4
- package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +1 -4
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +1 -11
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +1 -6
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +1 -11
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +2 -3
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +1 -4
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +2 -4
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +1 -11
- 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/adjust-full-page-cache.js +26 -0
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +1 -1
- package/lib/tasks/magento/setup-magento/delete-admin-users.js +1 -1
- package/lib/tasks/magento/setup-magento/delete-customers.js +7 -4
- package/lib/tasks/magento/setup-magento/delete-orders.js +6 -4
- package/lib/tasks/magento/setup-magento/disable-2fa.js +4 -12
- 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 +13 -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 +27 -54
- package/lib/tasks/php/compile.js +6 -4
- package/lib/tasks/php/configure.js +7 -66
- package/lib/tasks/php/extensions/disable.js +2 -1
- package/lib/tasks/php/extensions/enable.js +2 -1
- package/lib/tasks/php/extensions/index.js +74 -0
- package/lib/tasks/php/extensions/install.js +3 -3
- package/lib/tasks/php/index.js +8 -7
- package/lib/tasks/php/install-sodium.js +93 -0
- 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 +7 -3
- package/lib/tasks/php/validate-php.js +67 -0
- package/lib/tasks/php-fpm/start-php-fpm.js +4 -2
- package/lib/tasks/requirements/composer.js +7 -5
- 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/dependency/mac.js +18 -3
- package/lib/tasks/requirements/docker/index.js +96 -40
- package/lib/tasks/requirements/docker/install-on-mac.js +29 -0
- 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 +8 -5
- package/lib/tasks/requirements/node-version.js +2 -1
- package/lib/tasks/requirements/php-version.js +29 -25
- package/lib/tasks/requirements/phpbrew/index.js +2 -1
- package/lib/tasks/requirements/phpbrew/install.js +14 -2
- package/lib/tasks/requirements/phpbrew/version.js +2 -1
- package/lib/tasks/requirements/platform.js +5 -3
- package/lib/tasks/requirements/rosetta.js +32 -0
- package/lib/tasks/start.js +8 -9
- 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 +11 -3
- package/lib/tasks/theme/symlink-theme.js +26 -4
- package/lib/util/CSA-theme.js +4 -0
- package/lib/util/analytics.js +337 -0
- package/lib/util/arch.js +1 -1
- 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/exec-async-command.d.ts +2 -0
- package/lib/util/exec-async-command.js +31 -15
- package/lib/util/exec-async.js +9 -0
- package/lib/util/get-brew-bin-path.js +64 -0
- 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 +15 -5
- package/lib/util/instance-metadata.js +4 -3
- 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 +7 -3
- package/lib/util/request.js +0 -0
- package/lib/util/resolve-configuration-with-overrides.js +2 -1
- package/lib/util/run-composer.js +5 -3
- package/lib/util/run-magento.js +3 -2
- package/lib/util/run-php.js +14 -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 +6 -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
|
@@ -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
|
/**
|
|
@@ -7,7 +8,9 @@ const updatePhpBrew = () => ({
|
|
|
7
8
|
title: 'Updating PHPBrew PHP versions',
|
|
8
9
|
task: async ({ config: { php } }, task) => {
|
|
9
10
|
try {
|
|
10
|
-
const knownPhpVersions = await execAsyncSpawn('phpbrew known'
|
|
11
|
+
const knownPhpVersions = await execAsyncSpawn('phpbrew known', {
|
|
12
|
+
useRosetta2: true
|
|
13
|
+
});
|
|
11
14
|
|
|
12
15
|
if (knownPhpVersions.includes(`${php.version}`)) {
|
|
13
16
|
task.skip();
|
|
@@ -17,10 +20,11 @@ const updatePhpBrew = () => ({
|
|
|
17
20
|
await execAsyncSpawn('phpbrew known --update', {
|
|
18
21
|
callback: (t) => {
|
|
19
22
|
task.output = t;
|
|
20
|
-
}
|
|
23
|
+
},
|
|
24
|
+
useRosetta2: true
|
|
21
25
|
});
|
|
22
26
|
} catch (e) {
|
|
23
|
-
throw new
|
|
27
|
+
throw new UnknownError(`Unexpected error while updating phpbrew known php versions\n\n${e}`);
|
|
24
28
|
}
|
|
25
29
|
},
|
|
26
30
|
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>}
|
|
@@ -31,11 +32,12 @@ const startPhpFpm = () => ({
|
|
|
31
32
|
{
|
|
32
33
|
callback: (t) => {
|
|
33
34
|
task.output = t;
|
|
34
|
-
}
|
|
35
|
+
},
|
|
36
|
+
useRosetta2: true
|
|
35
37
|
}
|
|
36
38
|
);
|
|
37
39
|
} catch (e) {
|
|
38
|
-
throw new
|
|
40
|
+
throw new UnknownError(`Error during PHP-FPM start\n\n${e}`);
|
|
39
41
|
}
|
|
40
42
|
},
|
|
41
43
|
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();
|
|
@@ -86,8 +88,8 @@ ${ logger.style.misc('Password') } (${ logger.style.misc('Private key') }):`,
|
|
|
86
88
|
const authContent = {
|
|
87
89
|
'http-basic': {
|
|
88
90
|
'repo.magento.com': {
|
|
89
|
-
username: usernameCredentials,
|
|
90
|
-
password: passwordCredentials
|
|
91
|
+
username: usernameCredentials.trim(),
|
|
92
|
+
password: passwordCredentials.trim()
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
};
|
|
@@ -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,14 +1,28 @@
|
|
|
1
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
1
2
|
const dependenciesForPlatforms = require('../../../config/dependencies-for-platforms');
|
|
3
|
+
const KnownError = require('../../../errors/known-error');
|
|
2
4
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
5
|
+
const {
|
|
6
|
+
BREW_BIN_PATH_ARM_NATIVE,
|
|
7
|
+
BREW_BIN_PATH_ARM_ROSETTA,
|
|
8
|
+
getBrewCommand
|
|
9
|
+
} = require('../../../util/get-brew-bin-path');
|
|
3
10
|
const installDependenciesTask = require('../../../util/install-dependencies-task');
|
|
4
|
-
|
|
11
|
+
const pathExists = require('../../../util/path-exists');
|
|
5
12
|
/**
|
|
6
13
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
7
14
|
*/
|
|
8
15
|
const macDependenciesCheck = () => ({
|
|
9
16
|
title: 'Checking MacOS dependencies',
|
|
10
17
|
task: async (ctx, task) => {
|
|
11
|
-
|
|
18
|
+
if (ctx.arch === 'arm64') {
|
|
19
|
+
if (!await pathExists(BREW_BIN_PATH_ARM_ROSETTA) && await pathExists(BREW_BIN_PATH_ARM_NATIVE)) {
|
|
20
|
+
throw new KnownError(`Missing rosetta brew!
|
|
21
|
+
Please make sure that you have installed brew in rosetta2 terminal!
|
|
22
|
+
Follow the instructions: ${logger.style.link('https://docs.create-magento-app.com/getting-started/prerequisites/installation-on-macos/installation-on-macos-apple-silicon')}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const installedDependencies = (await execAsyncSpawn(`${await getBrewCommand()} list`)).split('\n');
|
|
12
26
|
|
|
13
27
|
const dependenciesToInstall = dependenciesForPlatforms
|
|
14
28
|
.darwin
|
|
@@ -19,7 +33,8 @@ const macDependenciesCheck = () => ({
|
|
|
19
33
|
return task.newListr(
|
|
20
34
|
installDependenciesTask({
|
|
21
35
|
platform: 'darwin',
|
|
22
|
-
dependenciesToInstall
|
|
36
|
+
dependenciesToInstall,
|
|
37
|
+
useMacNativeEnvironment: false
|
|
23
38
|
})
|
|
24
39
|
);
|
|
25
40
|
}
|
|
@@ -1,11 +1,94 @@
|
|
|
1
1
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
2
|
-
const
|
|
2
|
+
const KnownError = require('../../../errors/known-error');
|
|
3
3
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
4
|
-
const
|
|
4
|
+
const openBrowser = require('../../../util/open-browser');
|
|
5
5
|
const installDocker = require('./install');
|
|
6
|
+
const installDockerOnMac = require('./install-on-mac');
|
|
6
7
|
const { checkDockerSocketPermissions } = require('./permissions');
|
|
8
|
+
const checkDockerStatus = require('./running-status');
|
|
7
9
|
const getDockerVersion = require('./version');
|
|
8
10
|
|
|
11
|
+
const dockerInstallPromptLinux = async (task) => {
|
|
12
|
+
const automaticallyInstallDocker = await task.prompt({
|
|
13
|
+
type: 'Confirm',
|
|
14
|
+
message: `You don't have Docker installed!
|
|
15
|
+
Do you want to install it automatically?
|
|
16
|
+
NOTE: After installation it's recommended to log out and log back in so your group membership is re-evaluated!`
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if (automaticallyInstallDocker) {
|
|
20
|
+
return task.newListr([
|
|
21
|
+
installDocker(),
|
|
22
|
+
getDockerVersion(),
|
|
23
|
+
{
|
|
24
|
+
task: (ctx) => {
|
|
25
|
+
task.title = `Using docker version ${ctx.dockerVersion}`;
|
|
26
|
+
|
|
27
|
+
throw new KnownError(
|
|
28
|
+
`Docker is installed successfully!
|
|
29
|
+
Please log out and log back to so your group membership is re-evaluated!
|
|
30
|
+
Learn more here: ${ logger.style.link('https://docs.docker.com/engine/install/linux-postinstall/') }`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
]);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
throw new KnownError('Docker is not installed!');
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// maybe in the future docker will be possible to install on wsl from terminal...
|
|
41
|
+
const dockerInstallPromptWindows = () => {
|
|
42
|
+
throw new KnownError(
|
|
43
|
+
`You don't have Docker installed!
|
|
44
|
+
Follow this instructions to install Docker on Windows:
|
|
45
|
+
${ logger.style.link('https://docs.create-magento-app.com/getting-started/prerequisites/windows-requirements#2-install-docker-desktop-for-windows') }`
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param {import('listr2').ListrTaskWrapper} task
|
|
52
|
+
*/
|
|
53
|
+
const dockerInstallPromptMacOS = async (task) => {
|
|
54
|
+
const confirmationToInstallDocker = await task.prompt({
|
|
55
|
+
type: 'Select',
|
|
56
|
+
message: `You don't have Docker installed!
|
|
57
|
+
Would you like to install it automatically using brew cask or you prefer to install it manually?`,
|
|
58
|
+
choices: [
|
|
59
|
+
{
|
|
60
|
+
name: 'automatic',
|
|
61
|
+
message: 'Install Docker using brew cask'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'manually',
|
|
65
|
+
message: 'Install Docker manually'
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (confirmationToInstallDocker === 'automatic') {
|
|
71
|
+
return task.newListr([
|
|
72
|
+
installDockerOnMac(),
|
|
73
|
+
checkDockerStatus(),
|
|
74
|
+
getDockerVersion(),
|
|
75
|
+
{
|
|
76
|
+
task: (ctx) => {
|
|
77
|
+
task.title = `Using Docker version ${ctx.dockerVersion}`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
]);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const dockerInstallLink = 'https://docs.create-magento-app.com/getting-started/prerequisites/installation-on-macos#3.-install-docker-for-mac';
|
|
84
|
+
await openBrowser(dockerInstallLink);
|
|
85
|
+
|
|
86
|
+
throw new KnownError(
|
|
87
|
+
`Follow this instructions to install Docker on Mac:
|
|
88
|
+
${ logger.style.link(dockerInstallLink) }`
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
9
92
|
/**
|
|
10
93
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
11
94
|
*/
|
|
@@ -17,50 +100,23 @@ const checkDocker = () => ({
|
|
|
17
100
|
});
|
|
18
101
|
|
|
19
102
|
if (code !== 0) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
message: `You don't have Docker installed!
|
|
25
|
-
Do you want to install it automatically?
|
|
26
|
-
NOTE: After installation it's recommended to log out and log back in so your group membership is re-evaluated!`
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
if (automaticallyInstallDocker) {
|
|
30
|
-
return task.newListr([
|
|
31
|
-
installDocker(),
|
|
32
|
-
getDockerVersion(),
|
|
33
|
-
{
|
|
34
|
-
task: (ctx) => {
|
|
35
|
-
task.title = `Using docker version ${ctx.dockerVersion}`;
|
|
36
|
-
|
|
37
|
-
throw new Error(
|
|
38
|
-
`Docker is installed successfully!
|
|
39
|
-
Please log out and log back to so your group membership is re-evaluated!
|
|
40
|
-
Learn more here: ${ logger.style.link('https://docs.docker.com/engine/install/linux-postinstall/') }`
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
]);
|
|
103
|
+
if (ctx.platform === 'linux' && !ctx.isWsl) {
|
|
104
|
+
const result = await dockerInstallPromptLinux(task);
|
|
105
|
+
if (result) {
|
|
106
|
+
return result;
|
|
45
107
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
} else if (isWsl) {
|
|
49
|
-
throw new Error(
|
|
50
|
-
`You don't have Docker installed!
|
|
51
|
-
Follow this instructions to install Docker on Windows:
|
|
52
|
-
${ logger.style.link('https://docs.create-magento-app.com/getting-started/prerequisites/windows-requirements#2-install-docker-desktop-for-windows') }`
|
|
53
|
-
);
|
|
108
|
+
} else if (ctx.isWsl) {
|
|
109
|
+
dockerInstallPromptWindows();
|
|
54
110
|
} else {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
);
|
|
111
|
+
const result = await dockerInstallPromptMacOS(task);
|
|
112
|
+
if (result) {
|
|
113
|
+
return result;
|
|
114
|
+
}
|
|
60
115
|
}
|
|
61
116
|
}
|
|
62
117
|
|
|
63
118
|
return task.newListr([
|
|
119
|
+
checkDockerStatus(),
|
|
64
120
|
getDockerVersion(),
|
|
65
121
|
{
|
|
66
122
|
task: (ctx) => {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
2
|
+
const { getBrewCommand } = require('../../../util/get-brew-bin-path');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
6
|
+
*/
|
|
7
|
+
const installDockerOnMac = () => ({
|
|
8
|
+
title: 'Installing Docker on Mac OS',
|
|
9
|
+
task: async (ctx, task) => {
|
|
10
|
+
const interval = !ctx.verbose ? setInterval(() => {
|
|
11
|
+
task.output = `Installing Docker on Mac... Yep, still in progress ${new Date().toUTCString()}`;
|
|
12
|
+
}, 5000) : null;
|
|
13
|
+
|
|
14
|
+
await execAsyncSpawn(`${await getBrewCommand({ native: true })} install --cask docker`, {
|
|
15
|
+
callback: !ctx.verbose ? undefined : (t) => {
|
|
16
|
+
task.output = t;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
if (!ctx.verbose) {
|
|
21
|
+
clearInterval(interval);
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
options: {
|
|
25
|
+
bottomBar: 10
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
module.exports = installDockerOnMac;
|
|
@@ -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
|
}
|