@scandipwa/magento-scripts 1.14.1-alpha.0 → 1.14.1-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +13 -0
- package/lib/commands/cli.js +28 -1
- package/lib/commands/execute.js +2 -1
- package/lib/commands/logs.js +1 -0
- package/lib/commands/start.js +18 -5
- package/lib/config/dependencies-for-platforms.js +12 -2
- package/lib/config/docker.js +89 -15
- package/lib/config/get-port-config.js +9 -3
- package/lib/config/index.js +2 -1
- package/lib/config/php/extensions/libsodium.js +2 -1
- package/lib/config/port-config.js +3 -1
- package/lib/config/scandipwa-versions.js +2 -1
- package/lib/config/ssl-terminator/index.js +10 -0
- package/lib/config/system-config.js +34 -5
- package/lib/config/templates/magentorc.template +3 -5
- package/lib/config/templates/nginx.template.conf +0 -14
- package/lib/config/templates/php.template.ini +6 -4
- package/lib/config/templates/ssl-terminator.template.conf +27 -0
- package/lib/config/templates/varnish.template.vcl +250 -0
- package/lib/config/varnish/varnish-6-0.js +11 -0
- package/lib/config/varnish/varnish-6-6.js +11 -0
- package/lib/config/varnish/varnish-7-0.js +11 -0
- package/lib/config/versions/magento-2.3.0.js +9 -1
- package/lib/config/versions/magento-2.3.1.js +9 -1
- package/lib/config/versions/magento-2.3.2-p2.js +9 -1
- package/lib/config/versions/magento-2.3.2.js +9 -1
- package/lib/config/versions/magento-2.3.3-p1.js +9 -1
- package/lib/config/versions/magento-2.3.3.js +9 -1
- package/lib/config/versions/magento-2.3.4-p2.js +9 -1
- package/lib/config/versions/magento-2.3.4.js +9 -1
- package/lib/config/versions/magento-2.3.5-p1.js +9 -1
- package/lib/config/versions/magento-2.3.5-p2.js +9 -1
- package/lib/config/versions/magento-2.3.5.js +9 -1
- package/lib/config/versions/magento-2.3.6-p1.js +9 -1
- package/lib/config/versions/magento-2.3.6.js +9 -1
- package/lib/config/versions/magento-2.3.7-p1.js +9 -1
- package/lib/config/versions/magento-2.3.7-p2.js +9 -1
- package/lib/config/versions/magento-2.3.7-p3.js +9 -1
- package/lib/config/versions/magento-2.3.7.js +9 -1
- package/lib/config/versions/magento-2.4.0-p1.js +9 -1
- package/lib/config/versions/magento-2.4.0.js +9 -1
- package/lib/config/versions/magento-2.4.1-p1.js +9 -1
- package/lib/config/versions/magento-2.4.1.js +9 -1
- package/lib/config/versions/magento-2.4.2-p1.js +9 -1
- package/lib/config/versions/magento-2.4.2-p2.js +9 -1
- package/lib/config/versions/magento-2.4.2.js +9 -1
- package/lib/config/versions/magento-2.4.3-p1.js +9 -1
- package/lib/config/versions/magento-2.4.3-p2.js +9 -1
- package/lib/config/versions/magento-2.4.3.js +9 -1
- package/lib/config/versions/magento-2.4.4.js +9 -1
- package/lib/errors/known-error.js +15 -0
- package/lib/errors/unknown-error.js +15 -0
- package/lib/tasks/cli/create-bashrc-config.js +7 -3
- package/lib/tasks/composer/index.js +5 -3
- package/lib/tasks/composer/local-auth-json.js +4 -2
- package/lib/tasks/docker/containers.js +13 -8
- package/lib/tasks/docker/network.js +2 -1
- package/lib/tasks/docker/volumes.js +4 -4
- package/lib/tasks/file-system/create-nginx-config.js +9 -40
- package/lib/tasks/file-system/create-php-config.js +2 -1
- package/lib/tasks/file-system/create-php-fpm-config.js +2 -1
- package/lib/tasks/file-system/create-php-storm-config.js +6 -5
- package/lib/tasks/file-system/create-ssl-terminator-config.js +96 -0
- package/lib/tasks/file-system/create-varnish-config.js +53 -0
- package/lib/tasks/file-system/create-vscode-config.js +3 -2
- package/lib/tasks/file-system/index.js +5 -1
- package/lib/tasks/magento/enable-magento-composer-plugins.js +3 -2
- package/lib/tasks/magento/install-magento.js +7 -5
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +1 -1
- package/lib/tasks/magento/setup-magento/disable-2fa.js +4 -12
- package/lib/tasks/magento/setup-magento/disable-full-page-cache.js +20 -0
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +2 -1
- package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +14 -16
- package/lib/tasks/magento/setup-magento/index.js +3 -1
- package/lib/tasks/magento/setup-magento/install-magento.js +2 -1
- package/lib/tasks/magento/setup-magento/migrate-database.js +24 -11
- package/lib/tasks/magento/setup-magento/set-base-url.js +7 -2
- package/lib/tasks/magento/setup-magento/upgrade-magento.js +27 -3
- package/lib/tasks/magento/setup-magento/varnish-config.js +69 -0
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +41 -0
- package/lib/tasks/mysql/connect-to-mysql.js +2 -1
- package/lib/tasks/mysql/fix-db.js +2 -2
- package/lib/tasks/mysql/import-dump-to-mysql.js +4 -2
- package/lib/tasks/mysql/import-remote-db/index.js +2 -1
- package/lib/tasks/mysql/import-remote-db/ssh/index.js +2 -1
- package/lib/tasks/mysql/import-remote-db/ssh/regular-server.js +2 -1
- package/lib/tasks/php/bundled-extensions.js +28 -0
- package/lib/tasks/php/compile-options.js +18 -48
- package/lib/tasks/php/compile.js +4 -3
- package/lib/tasks/php/configure.js +7 -66
- package/lib/tasks/php/extensions/index.js +71 -0
- package/lib/tasks/php/index.js +8 -7
- package/lib/tasks/php/update-env-php.js +16 -1
- package/lib/tasks/php/update-env.php +56 -12
- package/lib/tasks/php/update-phpbrew.js +2 -1
- package/lib/tasks/php/validate-php.js +67 -0
- package/lib/tasks/php-fpm/start-php-fpm.js +2 -1
- package/lib/tasks/requirements/composer.js +5 -3
- package/lib/tasks/requirements/dependency/arch.js +2 -1
- package/lib/tasks/requirements/dependency/centos.js +2 -1
- package/lib/tasks/requirements/dependency/fedora.js +2 -1
- package/lib/tasks/requirements/docker/index.js +7 -4
- package/lib/tasks/requirements/docker/install.js +13 -12
- package/lib/tasks/requirements/docker/running-status.js +138 -0
- package/lib/tasks/requirements/docker/version.js +3 -0
- package/lib/tasks/requirements/index.js +5 -5
- package/lib/tasks/requirements/node-version.js +2 -1
- package/lib/tasks/requirements/php-version.js +8 -4
- package/lib/tasks/requirements/phpbrew/index.js +2 -1
- package/lib/tasks/requirements/phpbrew/install.js +2 -1
- package/lib/tasks/requirements/phpbrew/version.js +2 -1
- package/lib/tasks/requirements/platform.js +3 -2
- package/lib/tasks/start.js +11 -10
- package/lib/tasks/status/index.js +25 -9
- package/lib/tasks/theme/build-theme.js +27 -8
- package/lib/tasks/theme/install-theme.js +18 -5
- package/lib/tasks/theme/link-theme.js +2 -2
- package/lib/tasks/theme/retrieve-theme-data.js +2 -1
- package/lib/tasks/theme/setup-persisted-query.js +5 -4
- package/lib/tasks/theme/setup-themes.js +5 -3
- package/lib/tasks/theme/symlink-theme.js +20 -4
- package/lib/util/analytics.js +337 -0
- package/lib/util/config-file-validator.js +14 -2
- package/lib/util/config-php-json.js +20 -0
- package/lib/util/env-php-json.js +3 -2
- package/lib/util/get-installed-magento-version.js +3 -2
- package/lib/util/get-jsonfile-data.js +2 -1
- package/lib/util/install-dependencies-task.js +4 -4
- package/lib/util/instance-metadata.js +11 -4
- package/lib/util/ip.js +45 -1
- package/lib/util/is-running-root.js +3 -0
- package/lib/util/magento-task.js +20 -9
- package/lib/util/match-filesystem.js +2 -1
- package/lib/util/php-task.js +6 -2
- package/lib/util/request.js +0 -0
- package/lib/util/resolve-configuration-with-overrides.js +2 -1
- package/lib/util/run-composer.js +3 -2
- package/lib/util/run-magento.js +3 -2
- package/lib/util/run-php.js +10 -3
- package/lib/util/systemctl.js +46 -0
- package/lib/util/wait-for-it.js +3 -2
- package/package.json +4 -3
- package/typings/context.d.ts +5 -1
- package/typings/index.d.ts +32 -1
- package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -27
- package/lib/tasks/magento/setup-magento/disable-page-cache.js +0 -11
|
@@ -20,10 +20,10 @@ const create = ({
|
|
|
20
20
|
const createVolumes = () => ({
|
|
21
21
|
title: 'Creating volumes',
|
|
22
22
|
task: async ({ config: { docker } }, task) => {
|
|
23
|
-
const volumeList = (await execAsyncSpawn('docker volume ls
|
|
23
|
+
const volumeList = (await execAsyncSpawn('docker volume ls --format "{{.Name}}"')).split('\n');
|
|
24
24
|
|
|
25
25
|
const missingVolumes = Object.values(docker.volumes).filter(
|
|
26
|
-
({ name }) => !volumeList.
|
|
26
|
+
({ name }) => !volumeList.includes(name)
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
if (missingVolumes.length === 0) {
|
|
@@ -41,10 +41,10 @@ const createVolumes = () => ({
|
|
|
41
41
|
const removeVolumes = () => ({
|
|
42
42
|
title: 'Removing volumes',
|
|
43
43
|
task: async ({ config: { docker } }, task) => {
|
|
44
|
-
const volumeList = (await execAsyncSpawn('docker volume ls
|
|
44
|
+
const volumeList = (await execAsyncSpawn('docker volume ls --format "{{.Name}}"')).split('\n');
|
|
45
45
|
|
|
46
46
|
const deployedVolumes = Object.values(docker.volumes).filter(
|
|
47
|
-
({ name }) => volumeList.
|
|
47
|
+
({ name }) => volumeList.includes(name)
|
|
48
48
|
);
|
|
49
49
|
|
|
50
50
|
if (deployedVolumes.length === 0) {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
const os = require('os');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const fs = require('fs');
|
|
4
3
|
const setConfigFile = require('../../util/set-config');
|
|
5
|
-
const
|
|
6
|
-
const { isIpAddress } = require('../../util/ip');
|
|
4
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
7
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -23,41 +21,13 @@ const createNginxConfig = () => ({
|
|
|
23
21
|
const {
|
|
24
22
|
configuration: {
|
|
25
23
|
nginx
|
|
26
|
-
},
|
|
27
|
-
ssl,
|
|
28
|
-
host
|
|
29
|
-
} = overridenConfiguration;
|
|
30
|
-
|
|
31
|
-
if (ssl.enabled) {
|
|
32
|
-
if (!(await pathExists(ssl.ssl_certificate))) {
|
|
33
|
-
throw new Error('ssl.ssl_certificate file does not exist!');
|
|
34
|
-
}
|
|
35
|
-
if (!(await pathExists(ssl.ssl_certificate_key))) {
|
|
36
|
-
throw new Error('ssl.ssl_certificate_key file does not exist!');
|
|
37
24
|
}
|
|
25
|
+
} = overridenConfiguration;
|
|
38
26
|
|
|
39
|
-
await fs.promises.copyFile(
|
|
40
|
-
ssl.ssl_certificate,
|
|
41
|
-
path.join(
|
|
42
|
-
baseConfig.cacheDir,
|
|
43
|
-
'nginx',
|
|
44
|
-
'conf.d',
|
|
45
|
-
'ssl_certificate.pem'
|
|
46
|
-
)
|
|
47
|
-
);
|
|
48
|
-
await fs.promises.copyFile(
|
|
49
|
-
ssl.ssl_certificate_key,
|
|
50
|
-
path.join(
|
|
51
|
-
baseConfig.cacheDir,
|
|
52
|
-
'nginx',
|
|
53
|
-
'conf.d',
|
|
54
|
-
'ssl_certificate-key.pem'
|
|
55
|
-
)
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const networkToBindTo = isIpAddress(host) ? host : '127.0.0.1';
|
|
60
27
|
const isLinux = os.platform() === 'linux';
|
|
28
|
+
const isNativeLinux = isLinux && !isWsl;
|
|
29
|
+
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
30
|
+
const hostPort = isNativeLinux ? ports.app : 80;
|
|
61
31
|
|
|
62
32
|
try {
|
|
63
33
|
await setConfigFile({
|
|
@@ -72,14 +42,13 @@ const createNginxConfig = () => ({
|
|
|
72
42
|
templateArgs: {
|
|
73
43
|
ports,
|
|
74
44
|
mageRoot: baseConfig.magentoDir,
|
|
75
|
-
hostMachine
|
|
76
|
-
hostPort
|
|
77
|
-
config: overridenConfiguration
|
|
78
|
-
networkToBindTo
|
|
45
|
+
hostMachine,
|
|
46
|
+
hostPort,
|
|
47
|
+
config: overridenConfiguration
|
|
79
48
|
}
|
|
80
49
|
});
|
|
81
50
|
} catch (e) {
|
|
82
|
-
throw new
|
|
51
|
+
throw new UnknownError(`Unexpected error accrued during nginx config creation\n\n${e}`);
|
|
83
52
|
}
|
|
84
53
|
}
|
|
85
54
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const semver = require('semver');
|
|
2
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
2
3
|
const setConfigFile = require('../../util/set-config');
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -21,7 +22,7 @@ const createPhpConfig = () => ({
|
|
|
21
22
|
}
|
|
22
23
|
});
|
|
23
24
|
} catch (e) {
|
|
24
|
-
throw new
|
|
25
|
+
throw new UnknownError(`Unexpected error accrued during php.ini config creation\n\n${e}`);
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
2
3
|
const setConfigFile = require('../../util/set-config');
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -17,7 +18,7 @@ const createPhpFpmConfig = () => ({
|
|
|
17
18
|
}
|
|
18
19
|
});
|
|
19
20
|
} catch (e) {
|
|
20
|
-
throw new
|
|
21
|
+
throw new UnknownError(`Unexpected error accrued during php-fpm config creation\n\n${e}`);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
});
|
|
@@ -2,6 +2,7 @@ const setConfigFile = require('../../util/set-config');
|
|
|
2
2
|
const pathExists = require('../../util/path-exists');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs');
|
|
5
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
5
6
|
|
|
6
7
|
const createPhpStormConfig = () => ({
|
|
7
8
|
title: 'Setting PHPStorm config',
|
|
@@ -19,7 +20,7 @@ const createPhpStormConfig = () => ({
|
|
|
19
20
|
}
|
|
20
21
|
});
|
|
21
22
|
} catch (e) {
|
|
22
|
-
throw new
|
|
23
|
+
throw new UnknownError(`Unexpected error accrued during workspace.xml config creation\n\n${e}`);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
try {
|
|
@@ -32,7 +33,7 @@ const createPhpStormConfig = () => ({
|
|
|
32
33
|
}
|
|
33
34
|
});
|
|
34
35
|
} catch (e) {
|
|
35
|
-
throw new
|
|
36
|
+
throw new UnknownError(`Unexpected error accrued during php.xml config creation\n\n${e}`);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
try {
|
|
@@ -45,7 +46,7 @@ const createPhpStormConfig = () => ({
|
|
|
45
46
|
}
|
|
46
47
|
});
|
|
47
48
|
} catch (e) {
|
|
48
|
-
throw new
|
|
49
|
+
throw new UnknownError(`Unexpected error accrued during dataSources.local.xml config creation\n\n${e}`);
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
try {
|
|
@@ -59,7 +60,7 @@ const createPhpStormConfig = () => ({
|
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
62
|
} catch (e) {
|
|
62
|
-
throw new
|
|
63
|
+
throw new UnknownError(`Unexpected error accrued during dataSources.xml config creation\n\n${e}`);
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
if (!await pathExists(path.resolve('./.idea/dataSources'))) {
|
|
@@ -74,7 +75,7 @@ const createPhpStormConfig = () => ({
|
|
|
74
75
|
templateArgs: {}
|
|
75
76
|
});
|
|
76
77
|
} catch (e) {
|
|
77
|
-
throw new
|
|
78
|
+
throw new UnknownError(`Unexpected error accrued during Project_Default.xml config creation\n\n${e}`);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
const os = require('os');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const setConfigFile = require('../../util/set-config');
|
|
5
|
+
const pathExists = require('../../util/path-exists');
|
|
6
|
+
const { isIpAddress } = require('../../util/ip');
|
|
7
|
+
const KnownError = require('../../errors/known-error');
|
|
8
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
12
|
+
*/
|
|
13
|
+
const createSSLTerminatorConfig = () => ({
|
|
14
|
+
title: 'Setting ssl terminator config',
|
|
15
|
+
task: async (ctx) => {
|
|
16
|
+
const {
|
|
17
|
+
ports,
|
|
18
|
+
config: {
|
|
19
|
+
overridenConfiguration,
|
|
20
|
+
baseConfig
|
|
21
|
+
},
|
|
22
|
+
isWsl
|
|
23
|
+
} = ctx;
|
|
24
|
+
|
|
25
|
+
const {
|
|
26
|
+
configuration: {
|
|
27
|
+
sslTerminator
|
|
28
|
+
},
|
|
29
|
+
ssl,
|
|
30
|
+
host
|
|
31
|
+
} = overridenConfiguration;
|
|
32
|
+
|
|
33
|
+
if (ssl.enabled) {
|
|
34
|
+
if (!(await pathExists(ssl.ssl_certificate))) {
|
|
35
|
+
throw new KnownError('ssl.ssl_certificate file does not exist!');
|
|
36
|
+
}
|
|
37
|
+
if (!(await pathExists(ssl.ssl_certificate_key))) {
|
|
38
|
+
throw new KnownError('ssl.ssl_certificate_key file does not exist!');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const nginxCacheDir = path.join(baseConfig.cacheDir, 'nginx', 'conf.d');
|
|
42
|
+
if (!await pathExists(nginxCacheDir)) {
|
|
43
|
+
await fs.promises.mkdir(nginxCacheDir, { recursive: true });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
await fs.promises.copyFile(
|
|
47
|
+
ssl.ssl_certificate,
|
|
48
|
+
path.join(
|
|
49
|
+
baseConfig.cacheDir,
|
|
50
|
+
'ssl-terminator',
|
|
51
|
+
'conf.d',
|
|
52
|
+
'ssl_certificate.pem'
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
await fs.promises.copyFile(
|
|
56
|
+
ssl.ssl_certificate_key,
|
|
57
|
+
path.join(
|
|
58
|
+
baseConfig.cacheDir,
|
|
59
|
+
'ssl-terminator',
|
|
60
|
+
'conf.d',
|
|
61
|
+
'ssl_certificate-key.pem'
|
|
62
|
+
)
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const networkToBindTo = isIpAddress(host) ? host : '127.0.0.1';
|
|
67
|
+
const isLinux = os.platform() === 'linux';
|
|
68
|
+
const isNativeLinux = isLinux && !isWsl;
|
|
69
|
+
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
70
|
+
const hostPort = isNativeLinux ? ports.sslTerminator : 80;
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
await setConfigFile({
|
|
74
|
+
configPathname: path.join(
|
|
75
|
+
baseConfig.cacheDir,
|
|
76
|
+
'ssl-terminator',
|
|
77
|
+
'conf.d',
|
|
78
|
+
'default.conf'
|
|
79
|
+
),
|
|
80
|
+
template: sslTerminator.configTemplate,
|
|
81
|
+
overwrite: true,
|
|
82
|
+
templateArgs: {
|
|
83
|
+
ports,
|
|
84
|
+
hostMachine,
|
|
85
|
+
hostPort,
|
|
86
|
+
config: overridenConfiguration,
|
|
87
|
+
networkToBindTo
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
} catch (e) {
|
|
91
|
+
throw new UnknownError(`Unexpected error accrued during ssl terminator config creation\n\n${e}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
module.exports = createSSLTerminatorConfig;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
3
|
+
const setConfigFile = require('../../util/set-config');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
7
|
+
*/
|
|
8
|
+
const createVarnishConfig = () => ({
|
|
9
|
+
title: 'Setting Varnish config',
|
|
10
|
+
skip: (ctx) => !ctx.config.overridenConfiguration.configuration.varnish.enabled,
|
|
11
|
+
task: async (ctx) => {
|
|
12
|
+
const {
|
|
13
|
+
ports,
|
|
14
|
+
config: {
|
|
15
|
+
overridenConfiguration,
|
|
16
|
+
baseConfig: {
|
|
17
|
+
cacheDir
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
isWsl,
|
|
21
|
+
platform
|
|
22
|
+
} = ctx;
|
|
23
|
+
|
|
24
|
+
const {
|
|
25
|
+
configuration: {
|
|
26
|
+
varnish
|
|
27
|
+
}
|
|
28
|
+
} = overridenConfiguration;
|
|
29
|
+
|
|
30
|
+
const isLinux = platform === 'linux';
|
|
31
|
+
const isNativeLinux = isLinux && !isWsl;
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
await setConfigFile({
|
|
35
|
+
configPathname: path.join(
|
|
36
|
+
cacheDir,
|
|
37
|
+
'varnish',
|
|
38
|
+
'default.vcl'
|
|
39
|
+
),
|
|
40
|
+
template: varnish.configTemplate,
|
|
41
|
+
overwrite: true,
|
|
42
|
+
templateArgs: {
|
|
43
|
+
hostMachine: isNativeLinux ? '127.0.0.1' : 'host.docker.internal',
|
|
44
|
+
nginxPort: ports.app
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
} catch (e) {
|
|
48
|
+
throw new UnknownError(`Unexpected error accrued during varnish config creation\n\n${e}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
module.exports = createVarnishConfig;
|
|
@@ -5,6 +5,7 @@ const os = require('os');
|
|
|
5
5
|
const hjson = require('hjson');
|
|
6
6
|
const pathExists = require('../../util/path-exists');
|
|
7
7
|
const setConfigFile = require('../../util/set-config');
|
|
8
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
8
9
|
|
|
9
10
|
const phpXDebug2port = 9111;
|
|
10
11
|
const phpXDebug3port = 9003;
|
|
@@ -87,7 +88,7 @@ const createPhpFpmConfig = () => ({
|
|
|
87
88
|
try {
|
|
88
89
|
await fs.promises.mkdir(path.join(process.cwd(), '.vscode'));
|
|
89
90
|
} catch (e) {
|
|
90
|
-
throw new
|
|
91
|
+
throw new UnknownError(`Unable to creade .vscode directory in your project!\n\n${e}`);
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
|
|
@@ -103,7 +104,7 @@ const createPhpFpmConfig = () => ({
|
|
|
103
104
|
}
|
|
104
105
|
});
|
|
105
106
|
} catch (e) {
|
|
106
|
-
throw new
|
|
107
|
+
throw new UnknownError(`Unexpected error accrued during launch.json config creation!\n\n${e}`);
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
});
|
|
@@ -2,6 +2,8 @@ const createNginxConfig = require('./create-nginx-config');
|
|
|
2
2
|
const createPhpConfig = require('./create-php-config');
|
|
3
3
|
const createPhpFpmConfig = require('./create-php-fpm-config');
|
|
4
4
|
const createPhpStormConfig = require('./create-php-storm-config');
|
|
5
|
+
const createSSLTerminatorConfig = require('./create-ssl-terminator-config');
|
|
6
|
+
const createVarnishConfig = require('./create-varnish-config');
|
|
5
7
|
const createVSCodeConfig = require('./create-vscode-config');
|
|
6
8
|
|
|
7
9
|
/**
|
|
@@ -10,11 +12,13 @@ const createVSCodeConfig = require('./create-vscode-config');
|
|
|
10
12
|
const prepareFileSystem = () => ({
|
|
11
13
|
title: 'Preparing file system',
|
|
12
14
|
task: (ctx, task) => task.newListr([
|
|
15
|
+
createSSLTerminatorConfig(),
|
|
13
16
|
createNginxConfig(),
|
|
14
17
|
createPhpFpmConfig(),
|
|
15
18
|
createPhpConfig(),
|
|
16
19
|
createPhpStormConfig(),
|
|
17
|
-
createVSCodeConfig()
|
|
20
|
+
createVSCodeConfig(),
|
|
21
|
+
createVarnishConfig()
|
|
18
22
|
], {
|
|
19
23
|
concurrent: true
|
|
20
24
|
})
|
|
@@ -4,6 +4,7 @@ const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
|
4
4
|
const semver = require('semver');
|
|
5
5
|
const pathExists = require('../../util/path-exists');
|
|
6
6
|
const getJsonfileData = require('../../util/get-jsonfile-data');
|
|
7
|
+
const KnownError = require('../../errors/known-error');
|
|
7
8
|
|
|
8
9
|
const vendorPath = path.join(process.cwd(), 'vendor');
|
|
9
10
|
const composerJsonPath = path.join(process.cwd(), 'composer.json');
|
|
@@ -121,7 +122,7 @@ Do you want to enable them all or disable some of them?`,
|
|
|
121
122
|
encoding: 'utf-8'
|
|
122
123
|
});
|
|
123
124
|
} else {
|
|
124
|
-
throw new
|
|
125
|
+
throw new KnownError('Please confirm your choice or choose other option.');
|
|
125
126
|
}
|
|
126
127
|
break;
|
|
127
128
|
}
|
|
@@ -153,7 +154,7 @@ Do you want to enable them all or disable some of them?`,
|
|
|
153
154
|
encoding: 'utf-8'
|
|
154
155
|
});
|
|
155
156
|
} else {
|
|
156
|
-
throw new
|
|
157
|
+
throw new KnownError('Please confirm your choice or choose other option.');
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
break;
|
|
@@ -6,6 +6,8 @@ const moveFile = require('../../util/move-file');
|
|
|
6
6
|
const pathExists = require('../../util/path-exists');
|
|
7
7
|
const getJsonFileData = require('../../util/get-jsonfile-data');
|
|
8
8
|
const rmdirSafe = require('../../util/rmdir-safe');
|
|
9
|
+
const KnownError = require('../../errors/known-error');
|
|
10
|
+
const UnknownError = require('../../errors/unknown-error');
|
|
9
11
|
|
|
10
12
|
const magentoProductEnterpriseEdition = 'magento/product-enterprise-edition';
|
|
11
13
|
const magentoProductCommunityEdition = 'magento/product-community-edition';
|
|
@@ -58,7 +60,7 @@ const adjustComposerJson = async ({
|
|
|
58
60
|
composerData.require[magentoProductCommunityEdition]
|
|
59
61
|
&& composerData.require[magentoProductEnterpriseEdition]
|
|
60
62
|
) {
|
|
61
|
-
throw new
|
|
63
|
+
throw new KnownError('Somehow, both Magento editions are installed!\nPlease choose only one edition an modify your composer.json manually!');
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
const oppositeEdition = [magentoProductCommunityEdition, magentoProductEnterpriseEdition]
|
|
@@ -66,7 +68,7 @@ const adjustComposerJson = async ({
|
|
|
66
68
|
|
|
67
69
|
// if opposite edition is installed than selected in config file, throw an error
|
|
68
70
|
if (composerData.require[oppositeEdition]) {
|
|
69
|
-
throw new
|
|
71
|
+
throw new KnownError(`You have installed ${oppositeEdition} but selected magento.edition as ${magentoEdition} in config file!
|
|
70
72
|
|
|
71
73
|
Change magento edition in config file or manually reinstall correct magento edition!`);
|
|
72
74
|
}
|
|
@@ -187,11 +189,11 @@ const installMagento = () => ({
|
|
|
187
189
|
});
|
|
188
190
|
} catch (e) {
|
|
189
191
|
if (e.message.includes('man-in-the-middle attack')) {
|
|
190
|
-
throw new
|
|
191
|
-
|
|
192
|
+
throw new KnownError(`Probably you haven't setup pubkeys in composer.
|
|
193
|
+
Please run composer diagnose in cli to get mode.\n\n${e}`);
|
|
192
194
|
}
|
|
193
195
|
|
|
194
|
-
throw new
|
|
196
|
+
throw new UnknownError(`Unexpected error during composer install.\n\n${e}`);
|
|
195
197
|
}
|
|
196
198
|
ctx.magentoFirstInstall = true;
|
|
197
199
|
},
|
|
@@ -4,7 +4,7 @@ const { updateTableValues, isTableExists } = require('../../../util/database');
|
|
|
4
4
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
5
|
*/
|
|
6
6
|
module.exports = () => ({
|
|
7
|
-
title: 'Configuring
|
|
7
|
+
title: 'Configuring Elasticsearch',
|
|
8
8
|
skip: async (ctx) => !(await isTableExists('magento', 'core_config_data', ctx)),
|
|
9
9
|
task: async ({ ports, mysqlConnection }, task) => {
|
|
10
10
|
await updateTableValues('core_config_data', [
|
|
@@ -1,23 +1,15 @@
|
|
|
1
|
+
const configPhpToJson = require('../../../util/config-php-json');
|
|
1
2
|
const runMagentoCommand = require('../../../util/run-magento');
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
6
|
*/
|
|
6
7
|
module.exports = () => ({
|
|
7
|
-
title: 'Disabling 2fa for admin
|
|
8
|
+
title: 'Disabling 2fa for admin',
|
|
8
9
|
task: async ({ magentoVersion }, task) => {
|
|
9
|
-
const {
|
|
10
|
-
magentoVersion,
|
|
11
|
-
throwNonZeroCode: false
|
|
12
|
-
});
|
|
10
|
+
const { modules } = await configPhpToJson(process.cwd(), { magentoVersion });
|
|
13
11
|
|
|
14
|
-
if (
|
|
15
|
-
task.skip();
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Disable 2FA due admin login issue
|
|
20
|
-
if (result.includes('Module is enabled')) {
|
|
12
|
+
if (modules.Magento_TwoFactorAuth !== 0) {
|
|
21
13
|
await runMagentoCommand('module:disable Magento_TwoFactorAuth', {
|
|
22
14
|
magentoVersion
|
|
23
15
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const envPhpToJson = require('../../../util/env-php-json');
|
|
2
|
+
const magentoTask = require('../../../util/magento-task');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
6
|
+
*/
|
|
7
|
+
const disableFullPageCache = () => ({
|
|
8
|
+
title: 'Disabling full_page cache in Magento',
|
|
9
|
+
task: async ({ magentoVersion }, task) => {
|
|
10
|
+
const { cache_types } = await envPhpToJson(process.cwd(), { magentoVersion });
|
|
11
|
+
|
|
12
|
+
if (cache_types.full_page !== 0) {
|
|
13
|
+
return task.newListr(magentoTask('cache:disable full_page'));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
task.skip();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
module.exports = disableFullPageCache;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
2
2
|
const os = require('os');
|
|
3
|
+
const UnknownError = require('../../../errors/unknown-error');
|
|
3
4
|
|
|
4
5
|
const isLinux = os.platform() === 'linux';
|
|
5
6
|
|
|
@@ -15,7 +16,7 @@ module.exports = () => ({
|
|
|
15
16
|
const result = await execAsyncSpawn(`docker exec ${ name } redis-cli -h ${ host } -p ${ port } -n 0 flushdb`);
|
|
16
17
|
|
|
17
18
|
if (!result.trim().includes('OK')) {
|
|
18
|
-
throw new
|
|
19
|
+
throw new UnknownError(`Unexpected output from redis flush command: ${result}`);
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
});
|
|
@@ -5,22 +5,20 @@ const { updateTableValues } = require('../../../util/database');
|
|
|
5
5
|
*/
|
|
6
6
|
const increaseAdminSessionLifetime = () => ({
|
|
7
7
|
title: 'Increase admin session lifetime to 1 month',
|
|
8
|
-
task: async (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
23
|
-
}
|
|
8
|
+
task: async ({ mysqlConnection }, task) => updateTableValues('core_config_data', [
|
|
9
|
+
{
|
|
10
|
+
path: 'admin/security/session_lifetime',
|
|
11
|
+
value: '2800000'
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
path: 'admin/security/password_lifetime',
|
|
15
|
+
value: null
|
|
16
|
+
}
|
|
17
|
+
], {
|
|
18
|
+
mysqlConnection,
|
|
19
|
+
task
|
|
20
|
+
})
|
|
21
|
+
|
|
24
22
|
});
|
|
25
23
|
|
|
26
24
|
module.exports = increaseAdminSessionLifetime;
|
|
@@ -11,6 +11,7 @@ const updateEnvPHP = require('../../php/update-env-php');
|
|
|
11
11
|
const increaseAdminSessionLifetime = require('./increase-admin-session-lifetime');
|
|
12
12
|
const magentoTask = require('../../../util/magento-task');
|
|
13
13
|
const urnHighlighter = require('./urn-highlighter');
|
|
14
|
+
const waitingForVarnish = require('./waiting-for-varnish');
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* @type {({ onlyInstallMagento: boolean }) => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
@@ -48,7 +49,8 @@ const setupMagento = (options = {}) => ({
|
|
|
48
49
|
disableMaintenanceMode(),
|
|
49
50
|
disable2fa(),
|
|
50
51
|
urnHighlighter(),
|
|
51
|
-
magentoTask('cache:flush')
|
|
52
|
+
magentoTask('cache:flush'),
|
|
53
|
+
waitingForVarnish()
|
|
52
54
|
], {
|
|
53
55
|
concurrent: false,
|
|
54
56
|
exitOnError: true,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const semver = require('semver');
|
|
2
|
+
const UnknownError = require('../../../errors/unknown-error');
|
|
2
3
|
const runMagentoCommand = require('../../../util/run-magento');
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -86,7 +87,7 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
86
87
|
|
|
87
88
|
if (!installed) {
|
|
88
89
|
const errorMessages = errors.map((e) => e.message).join('\n\n');
|
|
89
|
-
throw new
|
|
90
|
+
throw new UnknownError(`Unable to install Magento!\n${errorMessages}`);
|
|
90
91
|
}
|
|
91
92
|
},
|
|
92
93
|
options: {
|