@scandipwa/magento-scripts 2.0.0-alpha.2 → 2.0.0-alpha.20
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/exec.js +71 -0
- package/index.js +1 -1
- package/lib/commands/cli.js +14 -1
- package/lib/commands/execute.js +2 -57
- package/lib/commands/start.js +24 -3
- package/lib/commands/status.js +9 -1
- package/lib/config/config.js +20 -2
- package/lib/config/docker.js +86 -53
- package/lib/config/get-project-configuration.js +5 -0
- package/lib/config/index.js +10 -3
- package/lib/config/php/versions/php-7.2.js +1 -0
- package/lib/config/php/versions/php-7.3.js +1 -0
- package/lib/config/php/versions/php-7.4.js +1 -0
- package/lib/config/php/versions/php-8.1.js +1 -0
- package/lib/config/php-config.js +4 -3
- package/lib/config/port-config.js +3 -1
- package/lib/config/services/composer/versions/composer-1.js +13 -0
- package/lib/config/services/composer/versions/composer-2.js +8 -0
- package/lib/config/services/composer/versions/index.js +4 -0
- package/lib/config/services/maildev/index.js +7 -0
- package/lib/config/services/nginx/versions/index.js +3 -0
- package/lib/config/services/nginx/versions/nginx-1.18.js +11 -0
- package/lib/config/{ssl-terminator → services/ssl-terminator}/index.js +3 -0
- package/lib/config/templates/magentorc.template +6 -5
- package/lib/config/templates/php-debug.template.ini +31 -0
- package/lib/config/templates/php-fpm.template.conf +1 -2
- package/lib/config/templates/php.template.ini +5 -201
- package/lib/config/templates/ssl-terminator.template.conf +10 -3
- package/lib/config/templates/varnish.template.vcl +20 -13
- package/lib/config/varnish/varnish-6-0.js +4 -0
- package/lib/config/varnish/varnish-6-6.js +4 -0
- package/lib/config/varnish/varnish-7-0.js +4 -0
- package/lib/config/versions/magento-2.2.10.js +41 -0
- package/lib/config/versions/magento-2.3.0.js +8 -10
- package/lib/config/versions/magento-2.3.1.js +8 -10
- package/lib/config/versions/magento-2.3.2-p1.js +8 -10
- package/lib/config/versions/magento-2.3.2-p2.js +8 -10
- package/lib/config/versions/magento-2.3.2.js +8 -10
- package/lib/config/versions/magento-2.3.3-p1.js +8 -10
- package/lib/config/versions/magento-2.3.3.js +8 -10
- package/lib/config/versions/magento-2.3.4-p1.js +8 -10
- package/lib/config/versions/magento-2.3.4-p2.js +8 -10
- package/lib/config/versions/magento-2.3.4.js +8 -10
- package/lib/config/versions/magento-2.3.5-p1.js +8 -10
- package/lib/config/versions/magento-2.3.5-p2.js +8 -10
- package/lib/config/versions/magento-2.3.5.js +8 -10
- package/lib/config/versions/magento-2.3.6-p1.js +8 -10
- package/lib/config/versions/magento-2.3.6.js +8 -10
- package/lib/config/versions/magento-2.3.7-p1.js +8 -10
- package/lib/config/versions/magento-2.3.7-p2.js +8 -10
- package/lib/config/versions/magento-2.3.7-p3.js +8 -10
- package/lib/config/versions/magento-2.3.7-p4.js +42 -0
- package/lib/config/versions/magento-2.3.7.js +8 -10
- package/lib/config/versions/magento-2.4.0-p1.js +8 -10
- package/lib/config/versions/magento-2.4.0.js +8 -10
- package/lib/config/versions/magento-2.4.1-p1.js +8 -10
- package/lib/config/versions/magento-2.4.1.js +8 -10
- package/lib/config/versions/magento-2.4.2-p1.js +8 -10
- package/lib/config/versions/magento-2.4.2-p2.js +8 -10
- package/lib/config/versions/magento-2.4.2.js +8 -10
- package/lib/config/versions/magento-2.4.3-p1.js +8 -10
- package/lib/config/versions/magento-2.4.3-p2.js +8 -10
- package/lib/config/versions/magento-2.4.3-p3.js +44 -0
- package/lib/config/versions/magento-2.4.3.js +8 -10
- package/lib/config/versions/magento-2.4.4-p1.js +44 -0
- package/lib/config/versions/magento-2.4.4.js +8 -10
- package/lib/config/versions/magento-2.4.5.js +44 -0
- package/lib/tasks/cli/create-bashrc-config.js +1 -1
- package/lib/tasks/composer/local-auth-json.js +1 -1
- package/lib/tasks/database/connect-to-database.js +6 -3
- package/lib/tasks/database/create-magento-database.js +5 -2
- package/lib/tasks/database/create-magento-user.js +50 -0
- package/lib/tasks/database/default-magento-database.js +3 -0
- package/lib/tasks/database/default-magento-user.js +7 -0
- package/lib/tasks/database/import-dump-to-database.js +3 -2
- package/lib/tasks/docker/api.d.ts +25 -1
- package/lib/tasks/docker/api.js +31 -1
- package/lib/tasks/docker/containers/container-api.d.ts +21 -0
- package/lib/tasks/docker/containers/container-api.js +82 -17
- package/lib/tasks/docker/containers/tasks.js +44 -13
- package/lib/tasks/docker/convert-composer-home-to-composer-cache-volume.js +52 -0
- package/lib/tasks/docker/convert-mysql-to-mariadb.js +2 -2
- package/lib/tasks/docker/image/image-api.d.ts +44 -0
- package/lib/tasks/docker/image/image-api.js +30 -2
- package/lib/tasks/docker/index.js +6 -1
- package/lib/tasks/docker/project-image-builder.js +36 -13
- package/lib/tasks/docker/system/index.js +5 -0
- package/lib/tasks/docker/system/system-api.d.ts +71 -0
- package/lib/tasks/docker/system/system-api.js +29 -0
- package/lib/tasks/docker/volume/index.js +2 -1
- package/lib/tasks/docker/volume/tasks.js +67 -9
- package/lib/tasks/docker/volume/volume-api.d.ts +40 -0
- package/lib/tasks/docker/volume/volume-api.js +54 -1
- package/lib/tasks/execute.js +100 -0
- package/lib/tasks/file-system/create-nginx-config.js +3 -5
- package/lib/tasks/file-system/create-php-config.js +2 -23
- package/lib/tasks/file-system/create-php-debug-config.js +45 -0
- package/lib/tasks/file-system/create-php-fpm-config.js +2 -4
- package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +13 -3
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +1 -1
- package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -7
- package/lib/tasks/file-system/create-varnish-config.js +4 -7
- package/lib/tasks/file-system/index.js +2 -0
- package/lib/tasks/magento/enable-magento-composer-plugins.js +85 -30
- package/lib/tasks/magento/install-magento-project.js +3 -2
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +2 -4
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +3 -6
- package/lib/tasks/magento/setup-magento/index.js +2 -0
- package/lib/tasks/magento/setup-magento/install-magento.js +8 -10
- package/lib/tasks/magento/setup-magento/set-base-url.js +1 -1
- package/lib/tasks/magento/setup-magento/set-mail-config.js +26 -0
- package/lib/tasks/magento/setup-magento/varnish-config.js +4 -9
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +17 -16
- package/lib/tasks/php/php-container.js +7 -3
- package/lib/tasks/php/update-env-php.js +3 -4
- package/lib/tasks/{prefix → project-config}/index.js +6 -6
- package/lib/tasks/requirements/composer-credentials.js +7 -3
- package/lib/tasks/requirements/docker/context.js +88 -0
- package/lib/tasks/requirements/docker/index.js +114 -20
- package/lib/tasks/requirements/docker/install.js +21 -7
- package/lib/tasks/requirements/docker/permissions.js +2 -11
- package/lib/tasks/requirements/docker/running-status.js +94 -24
- package/lib/tasks/requirements/docker/version.js +1 -0
- package/lib/tasks/requirements/index.js +0 -2
- package/lib/tasks/requirements/php-version.js +4 -2
- package/lib/tasks/start.js +27 -8
- package/lib/tasks/status/index.js +29 -20
- package/lib/tasks/stop.js +2 -0
- package/lib/tasks/theme/retrieve-theme-data.js +11 -1
- package/lib/util/config-file-validator.js +15 -2
- package/lib/util/execute-in-container.js +62 -0
- package/lib/util/instance-metadata.js +14 -2
- package/lib/util/systemctl.js +62 -13
- package/package.json +4 -3
- package/typings/context.d.ts +11 -0
- package/typings/index.d.ts +42 -1
- package/lib/tasks/execute/index.js +0 -26
- package/lib/tasks/requirements/dependency/arch.js +0 -50
- package/lib/tasks/requirements/dependency/centos.js +0 -36
- package/lib/tasks/requirements/dependency/fedora.js +0 -36
- package/lib/tasks/requirements/dependency/index.js +0 -33
- package/lib/tasks/requirements/dependency/mac.js +0 -124
- package/lib/tasks/requirements/dependency/ubuntu.js +0 -83
- package/yarn-error.log +0 -9660
|
@@ -12,6 +12,7 @@ const magentoTask = require('../../../util/magento-task');
|
|
|
12
12
|
const urnHighlighter = require('./urn-highlighter');
|
|
13
13
|
const adjustFullPageCache = require('./adjust-full-page-cache');
|
|
14
14
|
const updateEnvPHP = require('../../php/update-env-php');
|
|
15
|
+
const setMailConfig = require('./set-mail-config');
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* @param {Object} [options]
|
|
@@ -40,6 +41,7 @@ const setupMagento = (options = {}) => ({
|
|
|
40
41
|
task: (ctx, task) => task.newListr([
|
|
41
42
|
setBaseUrl(),
|
|
42
43
|
setUrlRewrite(),
|
|
44
|
+
setMailConfig(),
|
|
43
45
|
increaseAdminSessionLifetime()
|
|
44
46
|
], {
|
|
45
47
|
concurrent: true
|
|
@@ -5,6 +5,8 @@ const UnknownError = require('../../../errors/unknown-error');
|
|
|
5
5
|
const runMagentoCommand = require('../../../util/run-magento');
|
|
6
6
|
const envPhpToJson = require('../../../util/env-php-json');
|
|
7
7
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
8
|
+
const { defaultMagentoDatabase } = require('../../database/default-magento-database');
|
|
9
|
+
const defaultMagentoUser = require('../../database/default-magento-user');
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* @param {Object} [param0]
|
|
@@ -20,16 +22,14 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
20
22
|
const {
|
|
21
23
|
magentoVersion,
|
|
22
24
|
config: {
|
|
23
|
-
docker,
|
|
24
25
|
magentoConfiguration
|
|
25
26
|
},
|
|
26
27
|
ports,
|
|
27
|
-
databaseConnection
|
|
28
|
+
databaseConnection,
|
|
29
|
+
isDockerDesktop
|
|
28
30
|
} = ctx;
|
|
29
31
|
|
|
30
|
-
const
|
|
31
|
-
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
32
|
-
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
32
|
+
const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
|
|
33
33
|
|
|
34
34
|
const [tableResponse] = await databaseConnection.query(
|
|
35
35
|
'SELECT * FROM information_schema.tables WHERE table_schema = \'magento\' AND table_name = \'admin_user\' LIMIT 1;'
|
|
@@ -73,8 +73,6 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
73
73
|
await databaseConnection.query('SET FOREIGN_KEY_CHECKS = 1;');
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
|
|
77
|
-
const { mariadb: { env } } = docker.getContainers(ports);
|
|
78
76
|
const envPhpData = await envPhpToJson(ctx);
|
|
79
77
|
|
|
80
78
|
const envPhpHaveEncryptionKey = envPhpData && envPhpData.crypt && envPhpData.crypt.key && envPhpData.crypt.key;
|
|
@@ -127,9 +125,9 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
127
125
|
--cache-backend-redis-port='${ ports.redis }' \
|
|
128
126
|
--cache-backend-redis-db='0't \
|
|
129
127
|
--db-host='${ hostMachine }:${ ports.mariadb }' \
|
|
130
|
-
--db-name='${
|
|
131
|
-
--db-user='${
|
|
132
|
-
--db-password='${
|
|
128
|
+
--db-name='${ defaultMagentoDatabase }' \
|
|
129
|
+
--db-user='${ defaultMagentoUser.user }' \
|
|
130
|
+
--db-password='${ defaultMagentoUser.password }' \
|
|
133
131
|
--backend-frontname='${ magentoConfiguration.adminuri }' \
|
|
134
132
|
--no-interaction`;
|
|
135
133
|
|
|
@@ -17,7 +17,7 @@ module.exports = () => ({
|
|
|
17
17
|
databaseConnection
|
|
18
18
|
} = ctx;
|
|
19
19
|
const isNgrok = host.endsWith('ngrok.io');
|
|
20
|
-
const enableSecureFrontend = ssl.enabled ? '1' : '0';
|
|
20
|
+
const enableSecureFrontend = (ctx.config.overridenConfiguration.configuration.varnish.enabled && ssl.enabled) ? '1' : '0';
|
|
21
21
|
const location = `${host}${ !isNgrok && ports.sslTerminator !== 80 ? `:${ports.sslTerminator }` : '' }/`;
|
|
22
22
|
const secureLocation = `${host}/`; // SSL will work only on port 443, so you cannot run multiple projects with SSL at the same time.
|
|
23
23
|
const httpUrl = `http://${location}`;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const { updateTableValues } = require('../../../util/database');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
|
+
*/
|
|
6
|
+
const setMailConfig = () => ({
|
|
7
|
+
title: 'Setting up mail configuration',
|
|
8
|
+
task: async ({ databaseConnection, ports, isDockerDesktop }, task) => {
|
|
9
|
+
await updateTableValues('core_config_data', [
|
|
10
|
+
{
|
|
11
|
+
path: 'system/smtp/port',
|
|
12
|
+
value: `${ ports.maildevSMTP }`
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
path: 'system/smtp/disable',
|
|
16
|
+
value: '0'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
path: 'system/smtp/host',
|
|
20
|
+
value: isDockerDesktop ? 'host.docker.internal' : 'localhost'
|
|
21
|
+
}
|
|
22
|
+
], { databaseConnection, task });
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
module.exports = setMailConfig;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
const os = require('os');
|
|
2
1
|
const { updateTableValues } = require('../../../util/database');
|
|
3
|
-
const getIsWsl = require('../../../util/is-wsl');
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
@@ -20,18 +18,15 @@ const varnishConfigSetup = () => ({
|
|
|
20
18
|
},
|
|
21
19
|
databaseConnection,
|
|
22
20
|
ports,
|
|
23
|
-
debug
|
|
21
|
+
debug,
|
|
22
|
+
isDockerDesktop
|
|
24
23
|
} = ctx;
|
|
25
24
|
|
|
26
|
-
const isLinux = os.platform() === 'linux';
|
|
27
|
-
const isWsl = await getIsWsl();
|
|
28
|
-
const isNativeLinux = isLinux && !isWsl;
|
|
29
|
-
|
|
30
25
|
if (!debug && varnishEnabled) {
|
|
31
26
|
await updateTableValues('core_config_data', [
|
|
32
27
|
{
|
|
33
28
|
path: 'system/full_page_cache/varnish/backend_host',
|
|
34
|
-
value:
|
|
29
|
+
value: isDockerDesktop ? 'host.docker.internal' : 'localhost'
|
|
35
30
|
},
|
|
36
31
|
{
|
|
37
32
|
path: 'system/full_page_cache/varnish/backend_port',
|
|
@@ -39,7 +34,7 @@ const varnishConfigSetup = () => ({
|
|
|
39
34
|
},
|
|
40
35
|
{
|
|
41
36
|
path: 'system/full_page_cache/varnish/access_list',
|
|
42
|
-
value:
|
|
37
|
+
value: isDockerDesktop ? 'host.docker.internal,localhost' : 'localhost'
|
|
43
38
|
},
|
|
44
39
|
{
|
|
45
40
|
path: 'system/full_page_cache/caching_application',
|
|
@@ -4,9 +4,9 @@ const fs = require('fs');
|
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const { request } = require('smol-request');
|
|
6
6
|
const KnownError = require('../../../errors/known-error');
|
|
7
|
-
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
8
7
|
const { NginxParser } = require('../../../util/nginx-logs-parser');
|
|
9
8
|
const sleep = require('../../../util/sleep');
|
|
9
|
+
const { containerApi } = require('../../docker/containers');
|
|
10
10
|
|
|
11
11
|
const pathToWorkingHealthCheckPhp = path.join(__dirname, '..', '..', 'php', 'working_health_check.php');
|
|
12
12
|
const pathToProjectsHealthCheckPhp = path.join(process.cwd(), 'pub', 'health_check.php');
|
|
@@ -17,19 +17,18 @@ const pathToHealthCheckBackupPhp = path.join(process.cwd(), 'pub', 'health_check
|
|
|
17
17
|
*/
|
|
18
18
|
const getIsHealthCheckRequestBroken = async (ctx) => {
|
|
19
19
|
const { nginx } = ctx.config.docker.getContainers(ctx.ports);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return parsedRequests.every((parsedRequest) => parsedRequest.status !== '200');
|
|
20
|
+
const parser = new NginxParser(
|
|
21
|
+
'$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"'
|
|
22
|
+
);
|
|
23
|
+
const parsedLogs = await containerApi.logs({
|
|
24
|
+
name: nginx.name,
|
|
25
|
+
parser: (line) => parser.parseLine(line)
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const healthCheckRequests = parsedLogs
|
|
29
|
+
.filter((line) => line.request.includes('/health_check.php'));
|
|
30
|
+
|
|
31
|
+
return healthCheckRequests.every((parsedRequest) => parsedRequest.status !== '200');
|
|
33
32
|
};
|
|
34
33
|
|
|
35
34
|
/**
|
|
@@ -37,12 +36,14 @@ const getIsHealthCheckRequestBroken = async (ctx) => {
|
|
|
37
36
|
*/
|
|
38
37
|
const waitingForVarnish = () => ({
|
|
39
38
|
title: 'Waiting for Varnish to return code 200',
|
|
40
|
-
skip: (ctx) => ctx.debug
|
|
39
|
+
skip: (ctx) => ctx.debug
|
|
40
|
+
|| !ctx.config.overridenConfiguration.configuration.varnish.enabled
|
|
41
|
+
|| ctx.config.overridenConfiguration.ssl.enabled
|
|
42
|
+
|| !ctx.config.overridenConfiguration.configuration.varnish.healthCheck,
|
|
41
43
|
task: async (ctx, task) => {
|
|
42
44
|
const pureMagentoVersion = ctx.magentoVersion.match(/^([0-9]+\.[0-9]+\.[0-9]+)/)[1];
|
|
43
45
|
|
|
44
46
|
const isMagento23 = semver.satisfies(pureMagentoVersion, '<2.4');
|
|
45
|
-
|
|
46
47
|
let tries = 0;
|
|
47
48
|
while (tries < 10) {
|
|
48
49
|
try {
|
|
@@ -10,9 +10,13 @@ const { containerApi } = require('../docker/containers');
|
|
|
10
10
|
const runPHPContainerCommand = async (ctx, command, options = {}) => {
|
|
11
11
|
const { php } = ctx.config.docker.getContainers(ctx.ports);
|
|
12
12
|
|
|
13
|
-
const containers = await containerApi.ls({
|
|
13
|
+
const containers = await containerApi.ls({
|
|
14
|
+
formatToJSON: true,
|
|
15
|
+
all: true,
|
|
16
|
+
filter: `name=${php.name}`
|
|
17
|
+
});
|
|
14
18
|
|
|
15
|
-
if (containers.
|
|
19
|
+
if (containers.length > 0) {
|
|
16
20
|
return execPHPContainerCommand(ctx, command, options);
|
|
17
21
|
}
|
|
18
22
|
|
|
@@ -25,7 +29,7 @@ const runPHPContainerCommand = async (ctx, command, options = {}) => {
|
|
|
25
29
|
},
|
|
26
30
|
options.useXDebugContainer
|
|
27
31
|
? {
|
|
28
|
-
image:
|
|
32
|
+
image: php.debugImage
|
|
29
33
|
}
|
|
30
34
|
: {},
|
|
31
35
|
{
|
|
@@ -19,11 +19,10 @@ const updateEnvPHP = () => ({
|
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
const { isDockerDesktop, platform } = ctx;
|
|
22
23
|
const { php } = ctx.config.docker.getContainers(ctx.ports);
|
|
23
24
|
|
|
24
|
-
const
|
|
25
|
-
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
26
|
-
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
25
|
+
const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
|
|
27
26
|
|
|
28
27
|
const useVarnish = (!ctx.debug && ctx.config.overridenConfiguration.configuration.varnish.enabled) ? '1' : '';
|
|
29
28
|
const varnishHost = hostMachine;
|
|
@@ -78,7 +77,7 @@ const updateEnvPHP = () => ({
|
|
|
78
77
|
image: php.image,
|
|
79
78
|
detach: false,
|
|
80
79
|
rm: true,
|
|
81
|
-
user:
|
|
80
|
+
user: platform === 'linux' ? `${os.userInfo().uid}:${os.userInfo().gid}` : ''
|
|
82
81
|
});
|
|
83
82
|
|
|
84
83
|
task.output = result;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
+
const { setProjectConfig } = require('../../config/config');
|
|
1
2
|
const { setPrefix: setPrefixUtil } = require('../../util/prefix');
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
5
6
|
*/
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
title: 'Settings project prefix',
|
|
7
|
+
const setProjectConfigTask = () => ({
|
|
8
|
+
title: 'Settings project config',
|
|
9
9
|
task: (ctx) => {
|
|
10
10
|
const { config: { overridenConfiguration: { prefix } } } = ctx;
|
|
11
11
|
|
|
12
12
|
setPrefixUtil(prefix);
|
|
13
|
+
|
|
14
|
+
setProjectConfig('debug', ctx.debug);
|
|
13
15
|
},
|
|
14
16
|
options: {
|
|
15
17
|
showTimer: false
|
|
16
18
|
}
|
|
17
19
|
});
|
|
18
20
|
|
|
19
|
-
module.exports = {
|
|
20
|
-
setPrefix
|
|
21
|
-
};
|
|
21
|
+
module.exports = { setProjectConfigTask };
|
|
@@ -96,9 +96,9 @@ ${ logger.style.misc('Password') } (${ logger.style.misc('Private key') }):`,
|
|
|
96
96
|
};
|
|
97
97
|
|
|
98
98
|
const authJsonContent = JSON.stringify(authContent, null, 4);
|
|
99
|
-
const authEnvContent = `export COMPOSER_AUTH='${JSON.stringify(authContent)}'`;
|
|
99
|
+
const authEnvContent = `export COMPOSER_AUTH='${JSON.stringify(authContent, null, 0)}'`;
|
|
100
100
|
|
|
101
|
-
process.env.COMPOSER_AUTH = authJsonContent;
|
|
101
|
+
process.env.COMPOSER_AUTH = JSON.stringify(JSON.parse(authJsonContent), null, 0);
|
|
102
102
|
|
|
103
103
|
if (configureLocation === 'auth.json') {
|
|
104
104
|
await fs.promises.writeFile(authJsonPath, authJsonContent, 'utf-8');
|
|
@@ -175,7 +175,11 @@ Would you like to load them now?`
|
|
|
175
175
|
|
|
176
176
|
if (loadCredentialsFrom) {
|
|
177
177
|
const credentialsLine = lines.find((line) => line.startsWith('export COMPOSER_AUTH='));
|
|
178
|
-
process.env.COMPOSER_AUTH =
|
|
178
|
+
process.env.COMPOSER_AUTH = JSON.stringify(
|
|
179
|
+
JSON.parse(credentialsLine.replace('export COMPOSER_AUTH=', '').replace(/'/ig, '').trim()),
|
|
180
|
+
null,
|
|
181
|
+
0
|
|
182
|
+
);
|
|
179
183
|
problems.delete(MISSING_COMPOSER_AUTH_ENV);
|
|
180
184
|
}
|
|
181
185
|
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
2
|
+
const os = require('os');
|
|
3
|
+
const { cmaGlobalConfig } = require('../../../config/cma-config');
|
|
4
|
+
const { getCachedPorts } = require('../../../config/get-port-config');
|
|
5
|
+
const { getSystemConfigTask } = require('../../../config/system-config');
|
|
6
|
+
const UnknownError = require('../../../errors/unknown-error');
|
|
7
|
+
const { execCommandTask } = require('../../../util/exec-async-command');
|
|
8
|
+
const createCacheFolder = require('../../cache/create-cache-folder');
|
|
9
|
+
const { dockerApi } = require('../../docker');
|
|
10
|
+
const { stopContainers } = require('../../docker/containers');
|
|
11
|
+
const { getDockerEngineAndDesktopServiceStatus } = require('./running-status');
|
|
12
|
+
const getMagentoVersionConfig = require('../../../config/get-magento-version-config');
|
|
13
|
+
const checkConfigurationFile = require('../../../config/check-configuration-file');
|
|
14
|
+
const getProjectConfiguration = require('../../../config/get-project-configuration');
|
|
15
|
+
const getDockerVersion = require('./version');
|
|
16
|
+
|
|
17
|
+
const USE_DEFAULT_DOCKER_DESKTOP_CONTEXT_ANSWER = 'useDefaultDockerDesktopContext';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
21
|
+
*/
|
|
22
|
+
const checkDockerDesktopContext = () => ({
|
|
23
|
+
task: async (ctx, task) => {
|
|
24
|
+
if (os.platform() !== 'linux' || !ctx.isDockerDesktop) {
|
|
25
|
+
task.skip();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
task.title = 'Checking contexts for Docker Desktop';
|
|
30
|
+
|
|
31
|
+
const contexts = await dockerApi.context({ formatToJSON: true });
|
|
32
|
+
const currentlyUsedContext = contexts.find((c) => c.Current);
|
|
33
|
+
|
|
34
|
+
if (!currentlyUsedContext) {
|
|
35
|
+
throw new UnknownError('We haven\'t found contexts in Docker...');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const { engine } = await getDockerEngineAndDesktopServiceStatus();
|
|
39
|
+
|
|
40
|
+
if (currentlyUsedContext.Name !== 'default' && engine.exists) {
|
|
41
|
+
if (cmaGlobalConfig.get(USE_DEFAULT_DOCKER_DESKTOP_CONTEXT_ANSWER) === false) {
|
|
42
|
+
task.skip();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const confirmContextChange = await task.prompt({
|
|
47
|
+
type: 'Select',
|
|
48
|
+
message: `Do you want to change current Docker Desktop context (${logger.style.code(currentlyUsedContext.Name)}) to ${logger.style.code('default')}?`,
|
|
49
|
+
choices: [
|
|
50
|
+
{
|
|
51
|
+
name: 'yes',
|
|
52
|
+
message: 'Yes'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'no',
|
|
56
|
+
message: 'No, I don\'t know what this means, but you can ask again on next start.'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: 'skip',
|
|
60
|
+
// eslint-disable-next-line max-len
|
|
61
|
+
message: 'I do know what this means and I DON\'T want to change context for Docker. Also, save this answer to never ask again.'
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
if (confirmContextChange === 'skip') {
|
|
67
|
+
cmaGlobalConfig.set(USE_DEFAULT_DOCKER_DESKTOP_CONTEXT_ANSWER, false);
|
|
68
|
+
task.skip();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (confirmContextChange === 'yes') {
|
|
72
|
+
return task.newListr([
|
|
73
|
+
getMagentoVersionConfig(),
|
|
74
|
+
checkConfigurationFile(),
|
|
75
|
+
getProjectConfiguration(),
|
|
76
|
+
createCacheFolder(),
|
|
77
|
+
getSystemConfigTask(),
|
|
78
|
+
getCachedPorts(),
|
|
79
|
+
stopContainers(),
|
|
80
|
+
execCommandTask('docker context use default'),
|
|
81
|
+
getDockerVersion()
|
|
82
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
module.exports = checkDockerDesktopContext;
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
+
const os = require('os');
|
|
1
2
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
3
|
+
const { cmaGlobalConfig } = require('../../../config/cma-config');
|
|
2
4
|
const KnownError = require('../../../errors/known-error');
|
|
3
5
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
4
6
|
const openBrowser = require('../../../util/open-browser');
|
|
5
|
-
const
|
|
7
|
+
const checkDockerDesktopContext = require('./context');
|
|
8
|
+
const { installDockerEngine } = require('./install');
|
|
6
9
|
const installDockerOnMac = require('./install-on-mac');
|
|
7
10
|
const { checkDockerPerformance } = require('./performance');
|
|
8
11
|
const { checkDockerSocketPermissions } = require('./permissions');
|
|
9
|
-
const checkDockerStatus = require('./running-status');
|
|
12
|
+
const { checkDockerStatus, getDockerEngineAndDesktopServiceStatus } = require('./running-status');
|
|
10
13
|
const getDockerVersion = require('./version');
|
|
14
|
+
const getIsWsl = require('../../../util/is-wsl');
|
|
15
|
+
|
|
16
|
+
const USE_DOCKER_ENGINE_WITH_DOCKER_DESKTOP_ANSWER = 'useDockerEngineWithDockerDesktop';
|
|
11
17
|
|
|
12
18
|
const setVersionInContextTask = (task) => ({
|
|
13
19
|
task: (ctx) => {
|
|
14
|
-
if (
|
|
20
|
+
if (os.platform() === 'darwin' && ctx.dockerServerData && ctx.dockerServerData.Platform && ctx.dockerServerData.Platform.Name) {
|
|
15
21
|
task.title = `Using ${ctx.dockerServerData.Platform.Name} for Mac`;
|
|
16
22
|
} else {
|
|
17
23
|
task.title = `Using Docker version ${ctx.dockerVersion}`;
|
|
@@ -19,32 +25,72 @@ const setVersionInContextTask = (task) => ({
|
|
|
19
25
|
}
|
|
20
26
|
});
|
|
21
27
|
|
|
22
|
-
const dockerInstallPromptLinux = async (task) => {
|
|
23
|
-
const automaticallyInstallDocker = await task.prompt({
|
|
24
|
-
type: '
|
|
28
|
+
const dockerInstallPromptLinux = async (task, { skipPrompt = false } = {}) => {
|
|
29
|
+
const automaticallyInstallDocker = skipPrompt ? 'yes' : await task.prompt({
|
|
30
|
+
type: 'Select',
|
|
25
31
|
message: `You don't have Docker installed!
|
|
26
32
|
Do you want to install it automatically?
|
|
27
|
-
|
|
33
|
+
`,
|
|
34
|
+
choices: [
|
|
35
|
+
{
|
|
36
|
+
name: 'yes',
|
|
37
|
+
message: 'Yes, I to install Docker automatically'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'no',
|
|
41
|
+
message: 'No, I want to install Docker myself'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'skip',
|
|
45
|
+
message: 'Skip installing Docker'
|
|
46
|
+
}
|
|
47
|
+
]
|
|
28
48
|
});
|
|
29
49
|
|
|
30
|
-
if (automaticallyInstallDocker) {
|
|
50
|
+
if (automaticallyInstallDocker === 'yes') {
|
|
31
51
|
return task.newListr([
|
|
32
|
-
|
|
52
|
+
installDockerEngine(),
|
|
53
|
+
checkDockerSocketPermissions(),
|
|
33
54
|
getDockerVersion(),
|
|
34
55
|
{
|
|
35
|
-
task: (ctx) => {
|
|
56
|
+
task: async (ctx) => {
|
|
36
57
|
task.title = `Using docker version ${ctx.dockerVersion}`;
|
|
37
58
|
|
|
59
|
+
const confirmLogOut = await task.prompt({
|
|
60
|
+
type: 'Select',
|
|
61
|
+
message: 'Docker installed successfully!\n',
|
|
62
|
+
choices: [
|
|
63
|
+
{
|
|
64
|
+
name: 'log-out',
|
|
65
|
+
message: `${logger.style.command('[Recommended]')} Now I will log out and log back it (or restart my system) to re-evaluate group membership`
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'skip',
|
|
69
|
+
message: 'Skip log out and proceed with installation'
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
if (confirmLogOut === 'skip') {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
38
78
|
throw new KnownError(
|
|
39
79
|
`Docker is installed successfully!
|
|
40
|
-
Please log out and log back
|
|
80
|
+
Please log out and log back in (or restart your system) so your group membership is re-evaluated!
|
|
41
81
|
Learn more here: ${ logger.style.link('https://docs.docker.com/engine/install/linux-postinstall/') }`
|
|
42
82
|
);
|
|
43
83
|
}
|
|
44
|
-
}
|
|
84
|
+
},
|
|
85
|
+
checkDockerStatus(),
|
|
86
|
+
checkDockerDesktopContext()
|
|
45
87
|
]);
|
|
46
88
|
}
|
|
47
89
|
|
|
90
|
+
if (automaticallyInstallDocker === 'skip') {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
48
94
|
throw new KnownError('Docker is not installed!');
|
|
49
95
|
};
|
|
50
96
|
|
|
@@ -64,7 +110,8 @@ const dockerInstallPromptMacOS = async (task) => {
|
|
|
64
110
|
const confirmationToInstallDocker = await task.prompt({
|
|
65
111
|
type: 'Select',
|
|
66
112
|
message: `You don't have Docker installed!
|
|
67
|
-
Would you like to install it automatically using brew cask or you prefer to install it manually
|
|
113
|
+
Would you like to install it automatically using brew cask or you prefer to install it manually?
|
|
114
|
+
`,
|
|
68
115
|
choices: [
|
|
69
116
|
{
|
|
70
117
|
name: 'automatic',
|
|
@@ -80,6 +127,7 @@ Would you like to install it automatically using brew cask or you prefer to inst
|
|
|
80
127
|
if (confirmationToInstallDocker === 'automatic') {
|
|
81
128
|
return task.newListr([
|
|
82
129
|
installDockerOnMac(),
|
|
130
|
+
checkDockerSocketPermissions(),
|
|
83
131
|
checkDockerStatus(),
|
|
84
132
|
getDockerVersion(),
|
|
85
133
|
setVersionInContextTask(task)
|
|
@@ -106,24 +154,71 @@ const checkDocker = () => ({
|
|
|
106
154
|
});
|
|
107
155
|
|
|
108
156
|
if (code !== 0) {
|
|
109
|
-
if (
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
112
|
-
|
|
157
|
+
if (os.platform() === 'linux') {
|
|
158
|
+
const isWsl = await getIsWsl();
|
|
159
|
+
if (!isWsl) {
|
|
160
|
+
const { engine } = await getDockerEngineAndDesktopServiceStatus();
|
|
161
|
+
if (!engine.exists) {
|
|
162
|
+
const result = await dockerInstallPromptLinux(task);
|
|
163
|
+
if (result) {
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
} else if (isWsl) {
|
|
168
|
+
dockerInstallPromptWindows();
|
|
113
169
|
}
|
|
114
|
-
} else if (ctx.isWsl) {
|
|
115
|
-
dockerInstallPromptWindows();
|
|
116
170
|
} else {
|
|
117
171
|
const result = await dockerInstallPromptMacOS(task);
|
|
118
172
|
if (result) {
|
|
119
173
|
return result;
|
|
120
174
|
}
|
|
121
175
|
}
|
|
176
|
+
} else if (os.platform() === 'linux') {
|
|
177
|
+
const { engine, desktop } = await getDockerEngineAndDesktopServiceStatus();
|
|
178
|
+
if (!engine.exists
|
|
179
|
+
&& desktop.exists
|
|
180
|
+
&& cmaGlobalConfig.get(USE_DOCKER_ENGINE_WITH_DOCKER_DESKTOP_ANSWER) !== false
|
|
181
|
+
) {
|
|
182
|
+
const confirmInstallingDockerEngine = await task.prompt({
|
|
183
|
+
type: 'Select',
|
|
184
|
+
message: `Looks like you have Docker Desktop installed on Linux system, but Docker Engine is not installed.
|
|
185
|
+
Do you want to install it and use it's context together with Docker Desktop?
|
|
186
|
+
`,
|
|
187
|
+
choices: [
|
|
188
|
+
{
|
|
189
|
+
name: 'yes',
|
|
190
|
+
message: 'Sure, if it means I will have less issues with my setup!'
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: 'no',
|
|
194
|
+
message: 'No. But you can ask me again later.'
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
name: 'skip',
|
|
198
|
+
message: 'No. And don\'t ask me again.'
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
if (confirmInstallingDockerEngine === 'skip') {
|
|
204
|
+
cmaGlobalConfig.set(USE_DOCKER_ENGINE_WITH_DOCKER_DESKTOP_ANSWER, false);
|
|
205
|
+
} else if (confirmInstallingDockerEngine === 'yes') {
|
|
206
|
+
const result = await dockerInstallPromptLinux(task, {
|
|
207
|
+
skipPrompt: true
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
if (result) {
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
122
215
|
}
|
|
123
216
|
|
|
124
217
|
return task.newListr([
|
|
218
|
+
checkDockerSocketPermissions(),
|
|
125
219
|
checkDockerStatus(),
|
|
126
220
|
getDockerVersion(),
|
|
221
|
+
checkDockerDesktopContext(),
|
|
127
222
|
setVersionInContextTask(task)
|
|
128
223
|
]);
|
|
129
224
|
}
|
|
@@ -134,7 +229,6 @@ const checkDocker = () => ({
|
|
|
134
229
|
*/
|
|
135
230
|
module.exports = () => ({
|
|
136
231
|
task: (ctx, task) => task.newListr([
|
|
137
|
-
checkDockerSocketPermissions(),
|
|
138
232
|
checkDocker(),
|
|
139
233
|
checkDockerPerformance()
|
|
140
234
|
], {
|
|
@@ -17,8 +17,8 @@ const postInstallSteps = [
|
|
|
17
17
|
/**
|
|
18
18
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
19
19
|
*/
|
|
20
|
-
const
|
|
21
|
-
title: 'Installing Docker',
|
|
20
|
+
const installDockerEngine = () => ({
|
|
21
|
+
title: 'Installing Docker Engine',
|
|
22
22
|
task: async (ctx, task) => {
|
|
23
23
|
const distro = await osPlatform();
|
|
24
24
|
switch (distro) {
|
|
@@ -32,12 +32,21 @@ const installDocker = () => ({
|
|
|
32
32
|
...postInstallSteps
|
|
33
33
|
]);
|
|
34
34
|
}
|
|
35
|
-
case 'Fedora':
|
|
35
|
+
case 'Fedora': {
|
|
36
|
+
return task.newListr([
|
|
37
|
+
executeSudoCommand('sudo dnf -y install dnf-plugins-core'),
|
|
38
|
+
executeSudoCommand('sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo'),
|
|
39
|
+
executeSudoCommand('sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin'),
|
|
40
|
+
enableAndStartDockerCommand(),
|
|
41
|
+
...postInstallSteps
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
36
44
|
case 'CentOS': {
|
|
37
45
|
return task.newListr([
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
executeSudoCommand('sudo yum install -y yum-utils'),
|
|
47
|
+
executeSudoCommand('sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo'),
|
|
48
|
+
executeSudoCommand('sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin'),
|
|
49
|
+
...postInstallSteps
|
|
41
50
|
]);
|
|
42
51
|
}
|
|
43
52
|
case 'Ubuntu': {
|
|
@@ -53,7 +62,12 @@ const installDocker = () => ({
|
|
|
53
62
|
Your distro ${distro} is not supported by automatic installation.`);
|
|
54
63
|
}
|
|
55
64
|
}
|
|
65
|
+
},
|
|
66
|
+
options: {
|
|
67
|
+
bottomBar: 10
|
|
56
68
|
}
|
|
57
69
|
});
|
|
58
70
|
|
|
59
|
-
module.exports =
|
|
71
|
+
module.exports = {
|
|
72
|
+
installDockerEngine
|
|
73
|
+
};
|