@scandipwa/magento-scripts 2.0.0-alpha.8 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/cli.js +18 -1
- package/lib/commands/logs.js +28 -2
- package/lib/commands/start.js +24 -3
- package/lib/commands/status.js +9 -1
- package/lib/config/config.js +20 -2
- package/lib/config/dependencies-for-platforms.js +1 -1
- package/lib/config/docker.js +94 -54
- 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 +12 -5
- package/lib/config/templates/nginx.fastcgi_params.template +29 -0
- 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 +2 -0
- 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 +8 -10
- 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 +8 -10
- package/lib/config/versions/magento-2.4.3.js +8 -10
- package/lib/config/versions/magento-2.4.4-p1.js +8 -10
- package/lib/config/versions/magento-2.4.4.js +8 -10
- package/lib/config/versions/magento-2.4.5.js +8 -10
- package/lib/tasks/cli/create-bashrc-config.js +4 -2
- 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 +37 -14
- 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 +11 -9
- 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/index.js +2 -1
- package/lib/tasks/file-system/create-ssl-terminator-config.js +23 -8
- package/lib/tasks/file-system/create-varnish-config.js +4 -7
- package/lib/tasks/file-system/create-vscode-config.js +2 -1
- package/lib/tasks/file-system/index.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 -13
- package/lib/tasks/magento/setup-magento/set-base-url.js +2 -1
- package/lib/tasks/magento/setup-magento/set-mail-config.js +22 -0
- package/lib/tasks/magento/setup-magento/varnish-config.js +4 -9
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +15 -16
- package/lib/tasks/php/php-container.js +1 -1
- package/lib/tasks/php/update-env-php.js +3 -5
- 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 +111 -19
- 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 +60 -21
- package/lib/tasks/stop.js +2 -0
- package/lib/tasks/theme/retrieve-theme-data.js +12 -2
- package/lib/util/config-file-validator.js +17 -3
- package/lib/util/execute-in-container.js +35 -5
- package/lib/util/instance-metadata.js +14 -2
- package/lib/util/systemctl.js +62 -13
- package/package.json +2 -2
- package/typings/context.d.ts +11 -0
- package/typings/index.d.ts +46 -1
- 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
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
const semver = require('semver');
|
|
2
1
|
const UnknownError = require('../../errors/unknown-error');
|
|
3
2
|
const setConfigFile = require('../../util/set-config');
|
|
4
|
-
const { getEnabledExtensionsFromImage } = require('../docker/project-image-builder');
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -9,32 +7,13 @@ const { getEnabledExtensionsFromImage } = require('../docker/project-image-build
|
|
|
9
7
|
const createPhpConfig = () => ({
|
|
10
8
|
title: 'Setting PHP config',
|
|
11
9
|
task: async (ctx) => {
|
|
12
|
-
const {
|
|
13
|
-
config: {
|
|
14
|
-
php,
|
|
15
|
-
baseConfig
|
|
16
|
-
},
|
|
17
|
-
debug
|
|
18
|
-
} = ctx;
|
|
19
|
-
const containers = ctx.config.docker.getContainers(ctx.ports);
|
|
20
|
-
const phpExtensions = await getEnabledExtensionsFromImage(containers.php.debugImage);
|
|
21
|
-
const isXDebug2 = semver.satisfies(phpExtensions.xdebug, '2');
|
|
22
|
-
|
|
23
|
-
const isLinux = ctx.platform === 'linux';
|
|
24
|
-
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
25
|
-
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
10
|
+
const { config: { php } } = ctx;
|
|
26
11
|
|
|
27
12
|
try {
|
|
28
13
|
await setConfigFile({
|
|
29
14
|
configPathname: php.iniPath,
|
|
30
15
|
template: php.iniTemplatePath,
|
|
31
|
-
overwrite: true
|
|
32
|
-
templateArgs: {
|
|
33
|
-
debug,
|
|
34
|
-
mageRoot: baseConfig.containerMagentoDir,
|
|
35
|
-
isXDebug2,
|
|
36
|
-
hostMachine
|
|
37
|
-
}
|
|
16
|
+
overwrite: true
|
|
38
17
|
});
|
|
39
18
|
} catch (e) {
|
|
40
19
|
throw new UnknownError(`Unexpected error accrued during php.ini config creation\n\n${e}`);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const semver = require('semver');
|
|
2
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
3
|
+
const setConfigFile = require('../../util/set-config');
|
|
4
|
+
const { getEnabledExtensionsFromImage } = require('../docker/project-image-builder');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
8
|
+
*/
|
|
9
|
+
const createPhpDebugConfig = () => ({
|
|
10
|
+
title: 'Setting PHP XDebug config',
|
|
11
|
+
skip: (ctx) => !ctx.debug,
|
|
12
|
+
task: async (ctx) => {
|
|
13
|
+
const {
|
|
14
|
+
config: {
|
|
15
|
+
php,
|
|
16
|
+
baseConfig
|
|
17
|
+
},
|
|
18
|
+
debug,
|
|
19
|
+
isDockerDesktop
|
|
20
|
+
} = ctx;
|
|
21
|
+
const containers = ctx.config.docker.getContainers(ctx.ports);
|
|
22
|
+
const phpExtensions = await getEnabledExtensionsFromImage(containers.php.debugImage);
|
|
23
|
+
const isXDebug2 = semver.satisfies(phpExtensions.xdebug, '2');
|
|
24
|
+
|
|
25
|
+
const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
await setConfigFile({
|
|
29
|
+
configPathname: php.debugIniPath,
|
|
30
|
+
template: php.debugTemplatePath,
|
|
31
|
+
overwrite: true,
|
|
32
|
+
templateArgs: {
|
|
33
|
+
debug,
|
|
34
|
+
mageRoot: baseConfig.containerMagentoDir,
|
|
35
|
+
isXDebug2,
|
|
36
|
+
hostMachine
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
} catch (e) {
|
|
40
|
+
throw new UnknownError(`Unexpected error accrued during xdebug.ini config creation\n\n${e}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
module.exports = createPhpDebugConfig;
|
|
@@ -7,10 +7,8 @@ const setConfigFile = require('../../util/set-config');
|
|
|
7
7
|
const createPhpFpmConfig = () => ({
|
|
8
8
|
title: 'Setting php-fpm config',
|
|
9
9
|
task: async (ctx) => {
|
|
10
|
-
const { config: { php } } = ctx;
|
|
11
|
-
const
|
|
12
|
-
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
13
|
-
const port = isNativeLinux ? ctx.ports.fpm : 9000;
|
|
10
|
+
const { config: { php }, isDockerDesktop } = ctx;
|
|
11
|
+
const port = !isDockerDesktop ? ctx.ports.fpm : 9000;
|
|
14
12
|
|
|
15
13
|
try {
|
|
16
14
|
await setConfigFile({
|
|
@@ -26,11 +26,21 @@ const mustBeIncludedPaths = [
|
|
|
26
26
|
/**
|
|
27
27
|
* Will retrieve project config file path from module.xml
|
|
28
28
|
*
|
|
29
|
-
* @returns {Promise<String>}
|
|
29
|
+
* @returns {Promise<String | null>}
|
|
30
30
|
*/
|
|
31
31
|
const getProjectConfigFilePath = async () => {
|
|
32
32
|
const modulesConfigData = await loadXmlFile(pathToModulesConfig);
|
|
33
|
-
|
|
33
|
+
const {
|
|
34
|
+
project: {
|
|
35
|
+
component: {
|
|
36
|
+
modules: {
|
|
37
|
+
module
|
|
38
|
+
} = {}
|
|
39
|
+
} = {}
|
|
40
|
+
} = {}
|
|
41
|
+
} = modulesConfigData || {};
|
|
42
|
+
const filePath = module && module['@_filepath'];
|
|
43
|
+
return filePath ? filePath.replace('$PROJECT_DIR$', process.cwd()) : null;
|
|
34
44
|
};
|
|
35
45
|
|
|
36
46
|
const setupDefaultsForExcludedFoldersConfig = (projectConfigData) => {
|
|
@@ -138,7 +148,7 @@ const setupExcludedFoldersConfig = () => ({
|
|
|
138
148
|
task: async (ctx, task) => {
|
|
139
149
|
if (await pathExists(pathToModulesConfig)) {
|
|
140
150
|
const projectFilePath = await getProjectConfigFilePath();
|
|
141
|
-
if (await pathExists(projectFilePath)) {
|
|
151
|
+
if (projectFilePath && await pathExists(projectFilePath)) {
|
|
142
152
|
const projectConfigData = await loadXmlFile(projectFilePath);
|
|
143
153
|
setupDefaultsForExcludedFoldersConfig(projectConfigData);
|
|
144
154
|
const hasChanges = setupExcludedFolders(projectConfigData);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const os = require('os');
|
|
2
1
|
const path = require('path');
|
|
3
2
|
const fs = require('fs');
|
|
4
3
|
const setConfigFile = require('../../util/set-config');
|
|
@@ -19,8 +18,8 @@ const createSSLTerminatorConfig = () => ({
|
|
|
19
18
|
overridenConfiguration,
|
|
20
19
|
baseConfig
|
|
21
20
|
},
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
debug,
|
|
22
|
+
isDockerDesktop
|
|
24
23
|
} = ctx;
|
|
25
24
|
|
|
26
25
|
const {
|
|
@@ -65,10 +64,8 @@ const createSSLTerminatorConfig = () => ({
|
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
const networkToBindTo = isIpAddress(host) ? host : '127.0.0.1';
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
71
|
-
const hostPort = isNativeLinux ? ports.sslTerminator : 80;
|
|
67
|
+
const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
|
|
68
|
+
const hostPort = !isDockerDesktop ? ports.sslTerminator : 80;
|
|
72
69
|
|
|
73
70
|
try {
|
|
74
71
|
await setConfigFile({
|
|
@@ -90,7 +87,25 @@ const createSSLTerminatorConfig = () => ({
|
|
|
90
87
|
}
|
|
91
88
|
});
|
|
92
89
|
} catch (e) {
|
|
93
|
-
throw new UnknownError(`Unexpected error
|
|
90
|
+
throw new UnknownError(`Unexpected error appeared during ssl terminator config creation\n\n${e}`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// fixes ngrok error "ngrok.io redirected you too many times"
|
|
94
|
+
try {
|
|
95
|
+
await setConfigFile({
|
|
96
|
+
configPathname: path.join(
|
|
97
|
+
baseConfig.cacheDir,
|
|
98
|
+
'ssl-terminator',
|
|
99
|
+
'fastcgi_params'
|
|
100
|
+
),
|
|
101
|
+
template: path.join(baseConfig.templateDir, 'nginx.fastcgi_params.template'),
|
|
102
|
+
overwrite: true,
|
|
103
|
+
templateArgs: {
|
|
104
|
+
isNgrok: host.endsWith('ngrok.io')
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
} catch (e) {
|
|
108
|
+
throw new UnknownError(`Unexpected error appeared during ssl terminator fastcgi_params config creation\n\n${e}`);
|
|
94
109
|
}
|
|
95
110
|
}
|
|
96
111
|
});
|
|
@@ -17,8 +17,7 @@ const createVarnishConfig = () => ({
|
|
|
17
17
|
cacheDir
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
|
-
|
|
21
|
-
platform
|
|
20
|
+
isDockerDesktop
|
|
22
21
|
} = ctx;
|
|
23
22
|
|
|
24
23
|
const {
|
|
@@ -27,9 +26,6 @@ const createVarnishConfig = () => ({
|
|
|
27
26
|
}
|
|
28
27
|
} = overridenConfiguration;
|
|
29
28
|
|
|
30
|
-
const isLinux = platform === 'linux';
|
|
31
|
-
const isNativeLinux = isLinux && !isWsl;
|
|
32
|
-
|
|
33
29
|
try {
|
|
34
30
|
await setConfigFile({
|
|
35
31
|
configPathname: path.join(
|
|
@@ -40,8 +36,9 @@ const createVarnishConfig = () => ({
|
|
|
40
36
|
template: varnish.configTemplate,
|
|
41
37
|
overwrite: true,
|
|
42
38
|
templateArgs: {
|
|
43
|
-
hostMachine:
|
|
44
|
-
nginxPort: ports.app
|
|
39
|
+
hostMachine: !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal',
|
|
40
|
+
nginxPort: ports.app,
|
|
41
|
+
healthCheck: varnish.healthCheck
|
|
45
42
|
}
|
|
46
43
|
});
|
|
47
44
|
} catch (e) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const createMariaDBConfig = require('./create-mariadb-config');
|
|
2
2
|
const createNginxConfig = require('./create-nginx-config');
|
|
3
3
|
const createPhpConfig = require('./create-php-config');
|
|
4
|
+
const createPhpDebugConfig = require('./create-php-debug-config');
|
|
4
5
|
const createPhpFpmConfig = require('./create-php-fpm-config');
|
|
5
6
|
const createPhpStormConfig = require('./create-phpstorm-config');
|
|
6
7
|
const createSSLTerminatorConfig = require('./create-ssl-terminator-config');
|
|
@@ -17,13 +18,13 @@ const prepareFileSystem = () => ({
|
|
|
17
18
|
createNginxConfig(),
|
|
18
19
|
createPhpFpmConfig(),
|
|
19
20
|
createPhpConfig(),
|
|
21
|
+
createPhpDebugConfig(),
|
|
20
22
|
createPhpStormConfig(),
|
|
21
23
|
createVSCodeConfig(),
|
|
22
24
|
createVarnishConfig(),
|
|
23
25
|
createMariaDBConfig()
|
|
24
26
|
], {
|
|
25
|
-
concurrent: true
|
|
26
|
-
exitOnError: false
|
|
27
|
+
concurrent: true
|
|
27
28
|
})
|
|
28
29
|
});
|
|
29
30
|
|
|
@@ -7,10 +7,8 @@ module.exports = () => ({
|
|
|
7
7
|
title: 'Configuring Elasticsearch',
|
|
8
8
|
skip: async (ctx) => !(await isTableExists('magento', 'core_config_data', ctx)),
|
|
9
9
|
task: async (ctx, task) => {
|
|
10
|
-
const { ports, databaseConnection } = ctx;
|
|
11
|
-
const
|
|
12
|
-
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
13
|
-
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
10
|
+
const { ports, databaseConnection, isDockerDesktop } = ctx;
|
|
11
|
+
const hostMachine = !isDockerDesktop ? '127.0.0.1' : 'host.docker.internal';
|
|
14
12
|
await updateTableValues('core_config_data', [
|
|
15
13
|
{ path: 'catalog/search/engine', value: 'elasticsearch7' },
|
|
16
14
|
{ path: 'catalog/search/elasticsearch7_server_hostname', value: hostMachine },
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
2
|
-
const os = require('os');
|
|
3
2
|
const UnknownError = require('../../../errors/unknown-error');
|
|
4
3
|
|
|
5
|
-
const isLinux = os.platform() === 'linux';
|
|
6
|
-
|
|
7
4
|
/**
|
|
8
5
|
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
9
6
|
*/
|
|
10
7
|
module.exports = () => ({
|
|
11
8
|
title: 'Flushing Magento redis cache',
|
|
12
|
-
task: async ({ ports, config: { docker } }) => {
|
|
9
|
+
task: async ({ ports, config: { docker }, isDockerDesktop }) => {
|
|
13
10
|
const { redis: { name } } = docker.getContainers(ports);
|
|
14
|
-
const host =
|
|
15
|
-
const port =
|
|
11
|
+
const host = !isDockerDesktop ? 'localhost' : 'host.docker.internal';
|
|
12
|
+
const port = !isDockerDesktop ? '6379' : ports.redis;
|
|
16
13
|
const result = await execAsyncSpawn(`docker exec ${ name } redis-cli -h ${ host } -p ${ port } -n 0 flushdb`);
|
|
17
14
|
|
|
18
15
|
if (!result.trim().includes('OK')) {
|
|
@@ -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
|
|
|
@@ -143,9 +141,6 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
143
141
|
installed = true;
|
|
144
142
|
} catch (e) {
|
|
145
143
|
errors.push(e);
|
|
146
|
-
if (tries === 2) {
|
|
147
|
-
throw e;
|
|
148
|
-
}
|
|
149
144
|
}
|
|
150
145
|
|
|
151
146
|
if (installed) {
|
|
@@ -17,7 +17,7 @@ module.exports = () => ({
|
|
|
17
17
|
databaseConnection
|
|
18
18
|
} = ctx;
|
|
19
19
|
const isNgrok = host.endsWith('ngrok.io');
|
|
20
|
-
const enableSecureFrontend = (
|
|
20
|
+
const enableSecureFrontend = (isNgrok || 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}`;
|
|
@@ -28,6 +28,7 @@ module.exports = () => ({
|
|
|
28
28
|
{ path: 'web/secure/base_url', value: httpsUrl },
|
|
29
29
|
{ path: 'web/secure/use_in_frontend', value: enableSecureFrontend },
|
|
30
30
|
{ path: 'web/secure/use_in_adminhtml', value: enableSecureFrontend },
|
|
31
|
+
{ path: 'web/secure/enable_upgrade_insecure', value: enableSecureFrontend },
|
|
31
32
|
{ path: 'web/cookie/cookie_domain', value: null }
|
|
32
33
|
], { databaseConnection, task });
|
|
33
34
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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: 'smtp/configuration_option/port',
|
|
12
|
+
value: `${ ports.maildevSMTP }`
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
path: 'smtp/configuration_option/host',
|
|
16
|
+
value: isDockerDesktop ? 'host.docker.internal' : 'localhost'
|
|
17
|
+
}
|
|
18
|
+
], { databaseConnection, task });
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
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
|
/**
|
|
@@ -39,12 +38,12 @@ const waitingForVarnish = () => ({
|
|
|
39
38
|
title: 'Waiting for Varnish to return code 200',
|
|
40
39
|
skip: (ctx) => ctx.debug
|
|
41
40
|
|| !ctx.config.overridenConfiguration.configuration.varnish.enabled
|
|
42
|
-
|| ctx.config.overridenConfiguration.ssl.enabled
|
|
41
|
+
|| ctx.config.overridenConfiguration.ssl.enabled
|
|
42
|
+
|| !ctx.config.overridenConfiguration.configuration.varnish.healthCheck,
|
|
43
43
|
task: async (ctx, task) => {
|
|
44
44
|
const pureMagentoVersion = ctx.magentoVersion.match(/^([0-9]+\.[0-9]+\.[0-9]+)/)[1];
|
|
45
45
|
|
|
46
46
|
const isMagento23 = semver.satisfies(pureMagentoVersion, '<2.4');
|
|
47
|
-
|
|
48
47
|
let tries = 0;
|
|
49
48
|
while (tries < 10) {
|
|
50
49
|
try {
|
|
@@ -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;
|
|
@@ -53,7 +52,6 @@ const updateEnvPHP = () => ({
|
|
|
53
52
|
|| persistedQueryConfig.redis.host === hostMachine)
|
|
54
53
|
) {
|
|
55
54
|
SETUP_PQ = '';
|
|
56
|
-
return;
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
57
|
}
|
|
@@ -78,7 +76,7 @@ const updateEnvPHP = () => ({
|
|
|
78
76
|
image: php.image,
|
|
79
77
|
detach: false,
|
|
80
78
|
rm: true,
|
|
81
|
-
user:
|
|
79
|
+
user: platform === 'linux' ? `${os.userInfo().uid}:${os.userInfo().gid}` : ''
|
|
82
80
|
});
|
|
83
81
|
|
|
84
82
|
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
|
}
|