@scandipwa/magento-scripts 1.16.1 → 2.0.0-alpha.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 +2 -4
- package/lib/commands/execute.js +28 -3
- package/lib/commands/start.js +37 -15
- package/lib/commands/status.js +2 -0
- package/lib/config/docker.js +65 -42
- package/lib/config/get-project-configuration.js +3 -1
- package/lib/config/index.js +10 -7
- package/lib/config/magento/required-php-extensions/index.js +29 -0
- package/lib/config/magento/required-php-extensions/magento-2.3.js +19 -0
- package/lib/config/magento/required-php-extensions/magento-2.4.js +29 -0
- package/lib/config/php/base-repo.js +3 -0
- package/lib/config/php/extensions/apcu.js +12 -0
- package/lib/config/php/extensions/bcmath.js +7 -0
- package/lib/config/php/extensions/curl.js +11 -0
- package/lib/config/php/extensions/gd.js +14 -0
- package/lib/config/php/extensions/index.js +18 -2
- package/lib/config/php/extensions/intl.js +10 -0
- package/lib/config/php/extensions/opcache.js +10 -0
- package/lib/config/php/extensions/pdo_mysql.js +7 -0
- package/lib/config/php/extensions/soap.js +10 -0
- package/lib/config/php/extensions/sodium.js +10 -0
- package/lib/config/php/extensions/xdebug.js +8 -5
- package/lib/config/php/extensions/xsl.js +10 -0
- package/lib/config/php/extensions/zip.js +10 -0
- package/lib/config/php/{releases → versions}/index.js +0 -0
- package/lib/config/php/versions/php-7.2.js +23 -0
- package/lib/config/php/versions/php-7.3.js +23 -0
- package/lib/config/php/versions/php-7.4.js +23 -0
- package/lib/config/php/versions/php-8.1.js +23 -0
- package/lib/config/php-config.js +8 -12
- package/lib/config/port-config.js +1 -5
- package/lib/config/templates/magentorc.template +3 -3
- package/lib/config/templates/php-fpm.template.conf +3 -3
- package/lib/config/templates/php.template.ini +12 -6
- package/lib/config/templates/ssl-terminator.template.conf +1 -1
- package/lib/config/templates/vscode-launch.template.json +3 -1
- package/lib/config/versions/magento-2.3.0.js +8 -2
- package/lib/config/versions/magento-2.3.1.js +8 -2
- package/lib/config/versions/magento-2.3.2-p1.js +44 -0
- package/lib/config/versions/magento-2.3.2-p2.js +8 -2
- package/lib/config/versions/magento-2.3.2.js +8 -2
- package/lib/config/versions/magento-2.3.3-p1.js +8 -2
- package/lib/config/versions/magento-2.3.3.js +8 -2
- package/lib/config/versions/magento-2.3.4-p1.js +44 -0
- package/lib/config/versions/magento-2.3.4-p2.js +8 -2
- package/lib/config/versions/magento-2.3.4.js +8 -2
- package/lib/config/versions/magento-2.3.5-p1.js +8 -2
- package/lib/config/versions/magento-2.3.5-p2.js +8 -2
- package/lib/config/versions/magento-2.3.5.js +8 -2
- package/lib/config/versions/magento-2.3.6-p1.js +8 -2
- package/lib/config/versions/magento-2.3.6.js +8 -2
- package/lib/config/versions/magento-2.3.7-p1.js +8 -2
- package/lib/config/versions/magento-2.3.7-p2.js +8 -2
- package/lib/config/versions/magento-2.3.7-p3.js +8 -2
- package/lib/config/versions/magento-2.3.7.js +8 -2
- package/lib/config/versions/magento-2.4.0-p1.js +9 -3
- package/lib/config/versions/magento-2.4.0.js +9 -3
- package/lib/config/versions/magento-2.4.1-p1.js +6 -5
- package/lib/config/versions/magento-2.4.1.js +9 -2
- package/lib/config/versions/magento-2.4.2-p1.js +6 -5
- package/lib/config/versions/magento-2.4.2-p2.js +6 -6
- package/lib/config/versions/magento-2.4.2.js +6 -6
- package/lib/config/versions/magento-2.4.3-p1.js +7 -7
- package/lib/config/versions/magento-2.4.3-p2.js +7 -7
- package/lib/config/versions/magento-2.4.3.js +7 -7
- package/lib/config/versions/magento-2.4.4.js +9 -2
- package/lib/tasks/cleanup.js +2 -2
- package/lib/tasks/composer/index.js +14 -104
- package/lib/tasks/docker/api.d.ts +71 -0
- package/lib/tasks/docker/api.js +30 -0
- package/lib/tasks/docker/containers/container-api.d.ts +128 -0
- package/lib/tasks/docker/containers/container-api.js +153 -0
- package/lib/tasks/docker/containers/index.js +19 -0
- package/lib/tasks/docker/containers/tasks.js +215 -0
- package/lib/tasks/docker/convert-legacy-volumes.js +7 -3
- package/lib/tasks/docker/image/image-api.d.ts +34 -0
- package/lib/tasks/docker/image/image-api.js +49 -0
- package/lib/tasks/docker/image/index.js +5 -0
- package/lib/tasks/docker/index.js +1 -13
- package/lib/tasks/docker/network/index.js +7 -0
- package/lib/tasks/docker/network/network-api.d.ts +103 -0
- package/lib/tasks/docker/network/network-api.js +99 -0
- package/lib/tasks/docker/{network.js → network/tasks.js} +17 -10
- package/lib/tasks/docker/project-image-builder.js +167 -0
- package/lib/tasks/docker/volumes.js +1 -1
- package/lib/tasks/file-system/create-nginx-config.js +2 -3
- package/lib/tasks/file-system/create-php-config.js +20 -5
- package/lib/tasks/file-system/create-php-fpm-config.js +8 -4
- package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +41 -29
- package/lib/tasks/file-system/create-phpstorm-config/index.js +2 -0
- package/lib/tasks/file-system/create-phpstorm-config/keys.js +15 -1
- package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +4 -1
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-config.js +3 -3
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-interpreters-config.js +81 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/index.js +42 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/php-docker-settings-config.js +9 -0
- package/lib/tasks/file-system/create-phpstorm-config/php-docker-settings-config/setup-php-docker-container-settings-config.js +66 -0
- package/lib/tasks/file-system/create-phpstorm-config/setup-xml-structure.js +11 -9
- package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +2 -1
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +15 -30
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +24 -5
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/mess-detector-project-configuration-config.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-code-sniffer-project-configuration-config.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-cs-fixer-project-configuration-config.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +15 -15
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +29 -3
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-stan-project-configuration-config.js.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-workspace-project-configuration-config.js +42 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/psalm-project-configuration-config.js.js +50 -0
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/workspace-config.js +0 -2
- package/lib/tasks/file-system/create-ssl-terminator-config.js +4 -2
- package/lib/tasks/file-system/create-vscode-config.js +57 -42
- package/lib/tasks/file-system/index.js +2 -1
- package/lib/tasks/link.js +1 -2
- package/lib/tasks/magento/install-magento-project.js +31 -63
- package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +4 -4
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +6 -2
- package/lib/tasks/magento/setup-magento/create-admin.js +5 -6
- package/lib/tasks/magento/setup-magento/disable-2fa.js +3 -5
- package/lib/tasks/magento/setup-magento/disable-maintenance-mode.js +3 -4
- package/lib/tasks/magento/setup-magento/install-magento.js +10 -9
- package/lib/tasks/magento/setup-magento/migrate-database.js +7 -8
- package/lib/tasks/magento/setup-magento/set-deployment-mode.js +4 -4
- package/lib/tasks/magento/setup-magento/varnish-config.js +6 -4
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +128 -3
- package/lib/tasks/mysql/connect-to-mysql.js +34 -21
- package/lib/tasks/mysql/import-dump-to-mysql.js +46 -3
- package/lib/tasks/php/php-container.js +108 -0
- package/lib/tasks/php/update-env-php.js +35 -19
- package/lib/tasks/php/update-env.php +61 -56
- package/lib/tasks/php/working_health_check.php +85 -0
- package/lib/tasks/requirements/{composer.js → composer-credentials.js} +3 -1
- package/lib/tasks/requirements/docker/index.js +15 -12
- package/lib/tasks/requirements/docker/performance.js +54 -0
- package/lib/tasks/requirements/docker/version.js +8 -8
- package/lib/tasks/requirements/index.js +5 -8
- package/lib/tasks/requirements/php-version.js +8 -116
- package/lib/tasks/requirements/platform.js +12 -25
- package/lib/tasks/start.js +38 -47
- package/lib/tasks/status/index.js +4 -10
- package/lib/tasks/stop.js +0 -2
- package/lib/tasks/theme/install-theme.js +1 -1
- package/lib/tasks/theme/symlink-theme.js +2 -3
- package/lib/util/config-php-json.js +13 -4
- package/lib/util/dockerfile-builder/build-instructions.js +197 -0
- package/lib/util/dockerfile-builder/index.js +276 -0
- package/lib/util/dockerfile-builder/types.d.ts +123 -0
- package/lib/util/env-php-json.js +10 -6
- package/lib/util/exec-async-command.js +3 -9
- package/lib/util/macos-version.js +20 -0
- package/lib/util/magento-task.js +3 -4
- package/lib/util/nginx-logs-parser.js +122 -0
- package/lib/util/php-task.js +3 -6
- package/lib/util/prefix.js +1 -1
- package/lib/util/run-composer.js +6 -14
- package/lib/util/run-container-image.js +17 -0
- package/lib/util/run-magento.js +6 -14
- package/lib/util/run-php.js +6 -17
- package/package.json +9 -9
- package/typings/context.d.ts +3 -9
- package/typings/index.d.ts +38 -57
- package/lib/config/composer.js +0 -11
- package/lib/config/php/extensions/libsodium.js +0 -36
- package/lib/config/php/releases/php-7.2.js +0 -25
- package/lib/config/php/releases/php-7.3.js +0 -25
- package/lib/config/php/releases/php-7.4.js +0 -23
- package/lib/config/php/releases/php-8.1.js +0 -25
- package/lib/config/phpbrew.js +0 -12
- package/lib/tasks/composer/install-prestissimo.js +0 -103
- package/lib/tasks/docker/containers.js +0 -231
- package/lib/tasks/php/bundled-extensions.js +0 -27
- package/lib/tasks/php/compile-options.js +0 -56
- package/lib/tasks/php/compile.js +0 -55
- package/lib/tasks/php/configure.js +0 -89
- package/lib/tasks/php/extensions/disable.js +0 -49
- package/lib/tasks/php/extensions/enable.js +0 -52
- package/lib/tasks/php/extensions/index.js +0 -80
- package/lib/tasks/php/extensions/install.js +0 -54
- package/lib/tasks/php/index.js +0 -79
- package/lib/tasks/php/install-sodium.js +0 -93
- package/lib/tasks/php/update-phpbrew.js +0 -45
- package/lib/tasks/php/validate-php.js +0 -67
- package/lib/tasks/php-fpm/get-process-id.js +0 -14
- package/lib/tasks/php-fpm/index.js +0 -4
- package/lib/tasks/php-fpm/start-php-fpm.js +0 -49
- package/lib/tasks/php-fpm/stop-php-fpm.js +0 -48
- package/lib/tasks/requirements/phpbrew/index.js +0 -61
- package/lib/tasks/requirements/phpbrew/install.js +0 -159
- package/lib/tasks/requirements/phpbrew/version.js +0 -28
|
@@ -1,32 +1,27 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const fs = require('fs');
|
|
3
|
-
const
|
|
3
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
4
4
|
const runComposerCommand = require('../../util/run-composer');
|
|
5
5
|
const matchFilesystem = require('../../util/match-filesystem');
|
|
6
|
-
const moveFile = require('../../util/move-file');
|
|
7
6
|
const pathExists = require('../../util/path-exists');
|
|
8
7
|
const getJsonFileData = require('../../util/get-jsonfile-data');
|
|
9
|
-
const rmdirSafe = require('../../util/rmdir-safe');
|
|
10
8
|
const KnownError = require('../../errors/known-error');
|
|
11
9
|
const UnknownError = require('../../errors/unknown-error');
|
|
12
|
-
const
|
|
10
|
+
const { runPHPContainerCommand } = require('../php/php-container');
|
|
13
11
|
|
|
14
12
|
const magentoProductEnterpriseEdition = 'magento/product-enterprise-edition';
|
|
15
13
|
const magentoProductCommunityEdition = 'magento/product-community-edition';
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
|
-
*
|
|
16
|
+
* @param {import('../../../typings/context').ListrContext} ctx
|
|
17
|
+
* @param {import('listr2').ListrTaskWrapper<import('../../../typings/context').ListrContext>} task
|
|
19
18
|
*/
|
|
20
|
-
const adjustComposerJson = async ({
|
|
21
|
-
baseConfig,
|
|
19
|
+
const adjustComposerJson = async (ctx, task, {
|
|
22
20
|
magentoEdition,
|
|
23
21
|
magentoProductSelectedEdition,
|
|
24
|
-
|
|
25
|
-
magentoPackageVersion,
|
|
26
|
-
task,
|
|
27
|
-
verbose
|
|
22
|
+
magentoPackageVersion
|
|
28
23
|
}) => {
|
|
29
|
-
const composerData = await getJsonFileData(path.join(baseConfig.magentoDir, 'composer.json'));
|
|
24
|
+
const composerData = await getJsonFileData(path.join(ctx.config.baseConfig.magentoDir, 'composer.json'));
|
|
30
25
|
|
|
31
26
|
// fix composer magento repository
|
|
32
27
|
if (composerData && (!composerData.repositories
|
|
@@ -37,9 +32,8 @@ const adjustComposerJson = async ({
|
|
|
37
32
|
&& !Object.values(composerData.repositories).some((repo) => repo.type === 'composer' && repo.url.includes('repo.magento.com')))
|
|
38
33
|
)) {
|
|
39
34
|
task.output = 'No Magento repository is set in composer.json! Setting up...';
|
|
40
|
-
await runComposerCommand('config repo.0 composer https://repo.magento.com', {
|
|
41
|
-
|
|
42
|
-
callback: !verbose ? undefined : (t) => {
|
|
35
|
+
await runComposerCommand(ctx, 'config repo.0 composer https://repo.magento.com', {
|
|
36
|
+
callback: !ctx.verbose ? undefined : (t) => {
|
|
43
37
|
task.output = t;
|
|
44
38
|
}
|
|
45
39
|
});
|
|
@@ -48,10 +42,9 @@ const adjustComposerJson = async ({
|
|
|
48
42
|
// if composer-root-update-plugin is not installed in composer, install it.
|
|
49
43
|
if (composerData && !composerData.require['magento/composer-root-update-plugin']) {
|
|
50
44
|
task.output = 'Installing magento/composer-root-update-plugin!';
|
|
51
|
-
await runComposerCommand('require magento/composer-root-update-plugin:^1',
|
|
45
|
+
await runComposerCommand(ctx, 'require magento/composer-root-update-plugin:^1',
|
|
52
46
|
{
|
|
53
|
-
|
|
54
|
-
callback: !verbose ? undefined : (t) => {
|
|
47
|
+
callback: !ctx.verbose ? undefined : (t) => {
|
|
55
48
|
task.output = t;
|
|
56
49
|
}
|
|
57
50
|
});
|
|
@@ -62,7 +55,8 @@ const adjustComposerJson = async ({
|
|
|
62
55
|
&& composerData.require[magentoProductCommunityEdition]
|
|
63
56
|
&& composerData.require[magentoProductEnterpriseEdition]
|
|
64
57
|
) {
|
|
65
|
-
throw new KnownError(
|
|
58
|
+
throw new KnownError(`Somehow, both Magento editions are installed!
|
|
59
|
+
Please choose only one edition an modify your composer.json manually!`);
|
|
66
60
|
}
|
|
67
61
|
|
|
68
62
|
const oppositeEdition = [magentoProductCommunityEdition, magentoProductEnterpriseEdition]
|
|
@@ -76,13 +70,11 @@ Change magento edition in config file or manually reinstall correct magento edit
|
|
|
76
70
|
}
|
|
77
71
|
|
|
78
72
|
// if magento package is not installed in composer, require it.
|
|
79
|
-
|
|
80
73
|
if (composerData && !composerData.require[magentoProductSelectedEdition]) {
|
|
81
74
|
task.output = `Installing ${magentoProductSelectedEdition}=${magentoPackageVersion}!`;
|
|
82
|
-
await runComposerCommand(`require ${magentoProductSelectedEdition}:${magentoPackageVersion}`,
|
|
75
|
+
await runComposerCommand(ctx, `require ${magentoProductSelectedEdition}:${magentoPackageVersion}`,
|
|
83
76
|
{
|
|
84
|
-
|
|
85
|
-
callback: !verbose ? undefined : (t) => {
|
|
77
|
+
callback: !ctx.verbose ? undefined : (t) => {
|
|
86
78
|
task.output = t;
|
|
87
79
|
}
|
|
88
80
|
});
|
|
@@ -90,16 +82,14 @@ Change magento edition in config file or manually reinstall correct magento edit
|
|
|
90
82
|
};
|
|
91
83
|
|
|
92
84
|
/**
|
|
93
|
-
*
|
|
85
|
+
* @param {import('../../../typings/context').ListrContext} ctx
|
|
86
|
+
* @param {import('listr2').ListrTaskWrapper<import('../../../typings/context').ListrContext>} task
|
|
94
87
|
*/
|
|
95
|
-
const createMagentoProject = async ({
|
|
88
|
+
const createMagentoProject = async (ctx, task, {
|
|
96
89
|
magentoProject,
|
|
97
|
-
magentoPackageVersion
|
|
98
|
-
magentoVersion,
|
|
99
|
-
task,
|
|
100
|
-
verbose
|
|
90
|
+
magentoPackageVersion
|
|
101
91
|
}) => {
|
|
102
|
-
const tempDir =
|
|
92
|
+
const tempDir = `/tmp/magento-tmpdir-${Date.now()}`;
|
|
103
93
|
const installCommand = [
|
|
104
94
|
'create-project',
|
|
105
95
|
`--repository=https://repo.magento.com/ ${magentoProject}=${magentoPackageVersion}`,
|
|
@@ -107,22 +97,8 @@ const createMagentoProject = async ({
|
|
|
107
97
|
`"${tempDir}"`
|
|
108
98
|
];
|
|
109
99
|
|
|
110
|
-
await
|
|
111
|
-
|
|
112
|
-
{
|
|
113
|
-
magentoVersion,
|
|
114
|
-
callback: !verbose ? undefined : (t) => {
|
|
115
|
-
task.output = t;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
await moveFile({
|
|
121
|
-
from: path.join(tempDir, 'composer.json'),
|
|
122
|
-
to: path.join(process.cwd(), 'composer.json')
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
await rmdirSafe(tempDir);
|
|
100
|
+
await runPHPContainerCommand(ctx, `composer ${installCommand.join(' ')} \n
|
|
101
|
+
&& mv ${tempDir}/composer.json /var/www/html/composer.json`);
|
|
126
102
|
};
|
|
127
103
|
|
|
128
104
|
/**
|
|
@@ -131,7 +107,7 @@ const createMagentoProject = async ({
|
|
|
131
107
|
const installMagentoProject = () => ({
|
|
132
108
|
title: 'Installing Magento Project',
|
|
133
109
|
task: async (ctx, task) => {
|
|
134
|
-
const {
|
|
110
|
+
const { config: { baseConfig, overridenConfiguration } } = ctx;
|
|
135
111
|
const {
|
|
136
112
|
magento: { edition: magentoEdition },
|
|
137
113
|
magentoVersion: magentoPackageVersion
|
|
@@ -141,15 +117,10 @@ const installMagentoProject = () => ({
|
|
|
141
117
|
const magentoProject = `magento/project-${magentoEdition}-edition`;
|
|
142
118
|
|
|
143
119
|
if (await pathExists(path.join(baseConfig.magentoDir, 'composer.json'))) {
|
|
144
|
-
await adjustComposerJson({
|
|
145
|
-
baseConfig,
|
|
146
|
-
isEnterprise,
|
|
120
|
+
await adjustComposerJson(ctx, task, {
|
|
147
121
|
magentoEdition,
|
|
148
122
|
magentoPackageVersion,
|
|
149
|
-
magentoProductSelectedEdition
|
|
150
|
-
magentoVersion,
|
|
151
|
-
task,
|
|
152
|
-
verbose
|
|
123
|
+
magentoProductSelectedEdition
|
|
153
124
|
});
|
|
154
125
|
}
|
|
155
126
|
|
|
@@ -173,12 +144,9 @@ const installMagentoProject = () => ({
|
|
|
173
144
|
task.output = 'Creating Magento project';
|
|
174
145
|
|
|
175
146
|
if (!await pathExists(path.join(process.cwd(), 'composer.json'))) {
|
|
176
|
-
await createMagentoProject({
|
|
147
|
+
await createMagentoProject(ctx, task, {
|
|
177
148
|
magentoProject,
|
|
178
|
-
magentoPackageVersion
|
|
179
|
-
magentoVersion,
|
|
180
|
-
task,
|
|
181
|
-
verbose
|
|
149
|
+
magentoPackageVersion
|
|
182
150
|
});
|
|
183
151
|
}
|
|
184
152
|
|
|
@@ -187,18 +155,18 @@ const installMagentoProject = () => ({
|
|
|
187
155
|
recursive: true
|
|
188
156
|
});
|
|
189
157
|
}
|
|
158
|
+
|
|
190
159
|
try {
|
|
191
|
-
await runComposerCommand('install',
|
|
160
|
+
await runComposerCommand(ctx, 'install',
|
|
192
161
|
{
|
|
193
|
-
|
|
194
|
-
callback: !verbose ? undefined : (t) => {
|
|
162
|
+
callback: !ctx.verbose ? undefined : (t) => {
|
|
195
163
|
task.output = t;
|
|
196
164
|
}
|
|
197
165
|
});
|
|
198
166
|
} catch (e) {
|
|
199
167
|
if (e.message.includes('man-in-the-middle attack')) {
|
|
200
168
|
throw new KnownError(`Probably you haven't setup pubkeys in composer.
|
|
201
|
-
Please run ${logger.style.command('composer diagnose')} in cli to get mode.\n\n${e}`);
|
|
169
|
+
Please run ${logger.style.command('composer diagnose')} in cli to get mode.\n\n${e}`);
|
|
202
170
|
}
|
|
203
171
|
|
|
204
172
|
throw new UnknownError(`Unexpected error during composer install.\n\n${e}`);
|
|
@@ -6,15 +6,15 @@ const magentoTask = require('../../../util/magento-task');
|
|
|
6
6
|
*/
|
|
7
7
|
const disableFullPageCache = () => ({
|
|
8
8
|
title: 'Adjusting full_page cache setting',
|
|
9
|
-
task: async (
|
|
10
|
-
const { cache_types } = await envPhpToJson(
|
|
9
|
+
task: async (ctx, task) => {
|
|
10
|
+
const { cache_types } = await envPhpToJson(ctx);
|
|
11
11
|
if (cache_types && typeof cache_types.full_page === 'number') {
|
|
12
|
-
if (cache_types.full_page !== 0 && !config.overridenConfiguration.configuration.varnish.enabled) {
|
|
12
|
+
if (cache_types.full_page !== 0 && !ctx.config.overridenConfiguration.configuration.varnish.enabled) {
|
|
13
13
|
task.title = 'Disabling full_page cache in Magento';
|
|
14
14
|
return task.newListr(magentoTask('cache:disable full_page'));
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
if (config.overridenConfiguration.configuration.varnish.enabled && cache_types.full_page !== 1) {
|
|
17
|
+
if (ctx.config.overridenConfiguration.configuration.varnish.enabled && cache_types.full_page !== 1) {
|
|
18
18
|
task.title = 'Enabling full_page cache in Magento (Varnish is enabled)';
|
|
19
19
|
return task.newListr(magentoTask('cache:enable full_page'));
|
|
20
20
|
}
|
|
@@ -6,10 +6,14 @@ const { updateTableValues, isTableExists } = require('../../../util/database');
|
|
|
6
6
|
module.exports = () => ({
|
|
7
7
|
title: 'Configuring Elasticsearch',
|
|
8
8
|
skip: async (ctx) => !(await isTableExists('magento', 'core_config_data', ctx)),
|
|
9
|
-
task: async (
|
|
9
|
+
task: async (ctx, task) => {
|
|
10
|
+
const { ports, mysqlConnection } = ctx;
|
|
11
|
+
const isLinux = ctx.platform === 'linux';
|
|
12
|
+
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
13
|
+
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
10
14
|
await updateTableValues('core_config_data', [
|
|
11
15
|
{ path: 'catalog/search/engine', value: 'elasticsearch7' },
|
|
12
|
-
{ path: 'catalog/search/elasticsearch7_server_hostname', value:
|
|
16
|
+
{ path: 'catalog/search/elasticsearch7_server_hostname', value: hostMachine },
|
|
13
17
|
{ path: 'catalog/search/elasticsearch7_server_port', value: `${ports.elasticsearch}` }
|
|
14
18
|
], { mysqlConnection, task });
|
|
15
19
|
}
|
|
@@ -5,8 +5,9 @@ const runMagentoCommand = require('../../../util/run-magento');
|
|
|
5
5
|
*/
|
|
6
6
|
module.exports = () => ({
|
|
7
7
|
title: 'Creating admin user',
|
|
8
|
-
task: async (
|
|
9
|
-
const
|
|
8
|
+
task: async (ctx, task) => {
|
|
9
|
+
const { config: { magentoConfiguration } } = ctx;
|
|
10
|
+
const [[{ userCount }]] = await ctx.mysqlConnection.query(`
|
|
10
11
|
SELECT count(*) AS userCount
|
|
11
12
|
FROM admin_user
|
|
12
13
|
WHERE username = ?;
|
|
@@ -17,13 +18,11 @@ module.exports = () => ({
|
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
await runMagentoCommand(`admin:user:create \
|
|
21
|
+
await runMagentoCommand(ctx, `admin:user:create \
|
|
21
22
|
--admin-firstname='${ magentoConfiguration.first_name }' \
|
|
22
23
|
--admin-lastname='${ magentoConfiguration.last_name }' \
|
|
23
24
|
--admin-email='${ magentoConfiguration.email }' \
|
|
24
25
|
--admin-user='${ magentoConfiguration.user }' \
|
|
25
|
-
--admin-password='${ magentoConfiguration.password }'
|
|
26
|
-
magentoVersion
|
|
27
|
-
});
|
|
26
|
+
--admin-password='${ magentoConfiguration.password }'`);
|
|
28
27
|
}
|
|
29
28
|
});
|
|
@@ -6,13 +6,11 @@ const runMagentoCommand = require('../../../util/run-magento');
|
|
|
6
6
|
*/
|
|
7
7
|
module.exports = () => ({
|
|
8
8
|
title: 'Disabling 2fa for admin',
|
|
9
|
-
task: async (
|
|
10
|
-
const { modules } = await configPhpToJson(
|
|
9
|
+
task: async (ctx, task) => {
|
|
10
|
+
const { modules } = await configPhpToJson(ctx);
|
|
11
11
|
|
|
12
12
|
if (modules.Magento_TwoFactorAuth !== undefined && modules.Magento_TwoFactorAuth !== 0) {
|
|
13
|
-
await runMagentoCommand('module:disable Magento_TwoFactorAuth'
|
|
14
|
-
magentoVersion
|
|
15
|
-
});
|
|
13
|
+
await runMagentoCommand(ctx, 'module:disable Magento_TwoFactorAuth');
|
|
16
14
|
|
|
17
15
|
return;
|
|
18
16
|
}
|
|
@@ -5,9 +5,8 @@ const runMagentoCommand = require('../../../util/run-magento');
|
|
|
5
5
|
*/
|
|
6
6
|
const disableMaintenanceMode = () => ({
|
|
7
7
|
title: 'Disabling maintenance mode',
|
|
8
|
-
task: async (
|
|
9
|
-
const { result } = await runMagentoCommand('maintenance:status', {
|
|
10
|
-
magentoVersion,
|
|
8
|
+
task: async (ctx, task) => {
|
|
9
|
+
const { result } = await runMagentoCommand(ctx, 'maintenance:status', {
|
|
11
10
|
throwNonZeroCode: false
|
|
12
11
|
});
|
|
13
12
|
|
|
@@ -16,7 +15,7 @@ const disableMaintenanceMode = () => ({
|
|
|
16
15
|
return;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
await runMagentoCommand('maintenance:disable'
|
|
18
|
+
await runMagentoCommand(ctx, 'maintenance:disable');
|
|
20
19
|
}
|
|
21
20
|
});
|
|
22
21
|
|
|
@@ -27,6 +27,10 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
27
27
|
mysqlConnection
|
|
28
28
|
} = ctx;
|
|
29
29
|
|
|
30
|
+
const isLinux = ctx.platform === 'linux';
|
|
31
|
+
const isNativeLinux = isLinux && !ctx.isWsl;
|
|
32
|
+
const hostMachine = isNativeLinux ? '127.0.0.1' : 'host.docker.internal';
|
|
33
|
+
|
|
30
34
|
const [tableResponse] = await mysqlConnection.query(
|
|
31
35
|
'SELECT * FROM information_schema.tables WHERE table_schema = \'magento\' AND table_name = \'admin_user\' LIMIT 1;'
|
|
32
36
|
);
|
|
@@ -71,9 +75,7 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
const { mysql: { env } } = docker.getContainers(ports);
|
|
74
|
-
const envPhpData = await envPhpToJson(
|
|
75
|
-
magentoVersion: ctx.magentoVersion
|
|
76
|
-
});
|
|
78
|
+
const envPhpData = await envPhpToJson(ctx);
|
|
77
79
|
|
|
78
80
|
const envPhpHaveEncryptionKey = envPhpData && envPhpData.crypt && envPhpData.crypt.key && envPhpData.crypt.key;
|
|
79
81
|
|
|
@@ -95,7 +97,7 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
95
97
|
|
|
96
98
|
const elasticsearchConfiguration = ` \
|
|
97
99
|
--search-engine='elasticsearch7' \
|
|
98
|
-
--elasticsearch-host='
|
|
100
|
+
--elasticsearch-host='${ hostMachine }' \
|
|
99
101
|
--elasticsearch-port='${ ports.elasticsearch }'`;
|
|
100
102
|
|
|
101
103
|
/**
|
|
@@ -114,25 +116,24 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
114
116
|
${ !isMagento23 ? elasticsearchConfiguration : '' } \
|
|
115
117
|
${encryptionKeyOption || ''} \
|
|
116
118
|
--session-save=redis \
|
|
117
|
-
--session-save-redis-host='
|
|
119
|
+
--session-save-redis-host='${ hostMachine }' \
|
|
118
120
|
--session-save-redis-port='${ ports.redis }' \
|
|
119
121
|
--session-save-redis-log-level='3' \
|
|
120
122
|
--session-save-redis-max-concurrency='30' \
|
|
121
123
|
--session-save-redis-db='1' \
|
|
122
124
|
--session-save-redis-disable-locking='1' \
|
|
123
125
|
--cache-backend='redis' \
|
|
124
|
-
--cache-backend-redis-server='
|
|
126
|
+
--cache-backend-redis-server='${ hostMachine }' \
|
|
125
127
|
--cache-backend-redis-port='${ ports.redis }' \
|
|
126
128
|
--cache-backend-redis-db='0't \
|
|
127
|
-
--db-host='
|
|
129
|
+
--db-host='${ hostMachine }:${ ports.mysql }' \
|
|
128
130
|
--db-name='${ env.MYSQL_DATABASE }' \
|
|
129
131
|
--db-user='${ env.MYSQL_USER }' \
|
|
130
132
|
--db-password='${ env.MYSQL_PASSWORD }' \
|
|
131
133
|
--backend-frontname='${ magentoConfiguration.adminuri }' \
|
|
132
134
|
--no-interaction`;
|
|
133
135
|
|
|
134
|
-
await runMagentoCommand(command, {
|
|
135
|
-
magentoVersion,
|
|
136
|
+
await runMagentoCommand(ctx, command, {
|
|
136
137
|
throwNonZeroCode: true,
|
|
137
138
|
callback: !ctx.verbose ? undefined : (t) => {
|
|
138
139
|
task.output = t;
|
|
@@ -17,10 +17,7 @@ const updateEnvPHP = require('../../php/update-env-php');
|
|
|
17
17
|
const migrateDatabase = (options = {}) => ({
|
|
18
18
|
title: 'Migrating database',
|
|
19
19
|
task: async (ctx, task) => {
|
|
20
|
-
const {
|
|
21
|
-
magentoVersion,
|
|
22
|
-
mysqlConnection
|
|
23
|
-
} = ctx;
|
|
20
|
+
const { mysqlConnection } = ctx;
|
|
24
21
|
|
|
25
22
|
const [[{ tableCount }]] = await mysqlConnection.query(`
|
|
26
23
|
SELECT count(*) AS tableCount
|
|
@@ -35,12 +32,14 @@ const migrateDatabase = (options = {}) => ({
|
|
|
35
32
|
) {
|
|
36
33
|
if (options.onlyInstallMagento) {
|
|
37
34
|
ctx.isSetupUpgradeNeeded = false;
|
|
38
|
-
return task.newListr(
|
|
35
|
+
return task.newListr([
|
|
36
|
+
updateEnvPHP(),
|
|
39
37
|
installMagento({ isDbEmpty: true })
|
|
40
|
-
);
|
|
38
|
+
]);
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
return task.newListr([
|
|
42
|
+
updateEnvPHP(),
|
|
44
43
|
installMagento({ isDbEmpty: true }),
|
|
45
44
|
updateEnvPHP(),
|
|
46
45
|
varnishConfigSetup(),
|
|
@@ -57,8 +56,7 @@ const migrateDatabase = (options = {}) => ({
|
|
|
57
56
|
});
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
const { code } = await runMagentoCommand('setup:db:status', {
|
|
61
|
-
magentoVersion,
|
|
59
|
+
const { code } = await runMagentoCommand(ctx, 'setup:db:status', {
|
|
62
60
|
throwNonZeroCode: false
|
|
63
61
|
});
|
|
64
62
|
|
|
@@ -90,6 +88,7 @@ const migrateDatabase = (options = {}) => ({
|
|
|
90
88
|
|
|
91
89
|
return task.newListr([
|
|
92
90
|
installMagentoProject(),
|
|
91
|
+
updateEnvPHP(),
|
|
93
92
|
installMagento(),
|
|
94
93
|
updateEnvPHP(),
|
|
95
94
|
varnishConfigSetup(),
|
|
@@ -6,10 +6,10 @@ const runMagentoCommand = require('../../../util/run-magento');
|
|
|
6
6
|
*/
|
|
7
7
|
module.exports = () => ({
|
|
8
8
|
title: 'Switching Magento mode',
|
|
9
|
-
task: async (
|
|
10
|
-
const {
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
task: async (ctx, task) => {
|
|
10
|
+
const { config: { magentoConfiguration: { mode } } } = ctx;
|
|
11
|
+
const { result } = await runMagentoCommand(ctx, 'deploy:mode:show', {
|
|
12
|
+
throwNonZeroCode: false
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
if (result.includes(mode)) {
|
|
@@ -19,17 +19,19 @@ const varnishConfigSetup = () => ({
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
mysqlConnection,
|
|
22
|
-
ports
|
|
22
|
+
ports,
|
|
23
|
+
debug
|
|
23
24
|
} = ctx;
|
|
24
25
|
|
|
25
26
|
const isLinux = os.platform() === 'linux';
|
|
26
27
|
const isWsl = await getIsWsl();
|
|
28
|
+
const isNativeLinux = isLinux && !isWsl;
|
|
27
29
|
|
|
28
|
-
if (varnishEnabled) {
|
|
30
|
+
if (!debug && varnishEnabled) {
|
|
29
31
|
await updateTableValues('core_config_data', [
|
|
30
32
|
{
|
|
31
33
|
path: 'system/full_page_cache/varnish/backend_host',
|
|
32
|
-
value: 'localhost'
|
|
34
|
+
value: !isNativeLinux ? 'host.docker.internal' : 'localhost'
|
|
33
35
|
},
|
|
34
36
|
{
|
|
35
37
|
path: 'system/full_page_cache/varnish/backend_port',
|
|
@@ -37,7 +39,7 @@ const varnishConfigSetup = () => ({
|
|
|
37
39
|
},
|
|
38
40
|
{
|
|
39
41
|
path: 'system/full_page_cache/varnish/access_list',
|
|
40
|
-
value:
|
|
42
|
+
value: !isNativeLinux ? 'host.docker.internal,localhost' : 'localhost'
|
|
41
43
|
},
|
|
42
44
|
{
|
|
43
45
|
path: 'system/full_page_cache/caching_application',
|
|
@@ -1,14 +1,48 @@
|
|
|
1
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
2
|
+
const semver = require('semver');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
1
5
|
const { request } = require('smol-request');
|
|
2
6
|
const KnownError = require('../../../errors/known-error');
|
|
7
|
+
const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
8
|
+
const { NginxParser } = require('../../../util/nginx-logs-parser');
|
|
3
9
|
const sleep = require('../../../util/sleep');
|
|
4
10
|
|
|
11
|
+
const pathToWorkingHealthCheckPhp = path.join(__dirname, '..', '..', 'php', 'working_health_check.php');
|
|
12
|
+
const pathToProjectsHealthCheckPhp = path.join(process.cwd(), 'pub', 'health_check.php');
|
|
13
|
+
const pathToHealthCheckBackupPhp = path.join(process.cwd(), 'pub', 'health_check-super-backup-file.php');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {import('../../../../typings/context').ListrContext} ctx
|
|
17
|
+
*/
|
|
18
|
+
const getIsHealthCheckRequestBroken = async (ctx) => {
|
|
19
|
+
const { nginx } = ctx.config.docker.getContainers(ctx.ports);
|
|
20
|
+
|
|
21
|
+
const nginxLogs = await execAsyncSpawn(`docker logs ${nginx.name}`);
|
|
22
|
+
|
|
23
|
+
const healthCheckRequests = nginxLogs
|
|
24
|
+
.split('\n')
|
|
25
|
+
.filter((line) => line.includes('"GET /health_check.php HTTP/1.1"'));
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line max-len
|
|
28
|
+
const parser = new NginxParser('$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"');
|
|
29
|
+
|
|
30
|
+
const parsedRequests = healthCheckRequests.map((line) => parser.parseLine(line));
|
|
31
|
+
|
|
32
|
+
return parsedRequests.every((parsedRequest) => parsedRequest.status !== '200');
|
|
33
|
+
};
|
|
34
|
+
|
|
5
35
|
/**
|
|
6
36
|
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
7
37
|
*/
|
|
8
38
|
const waitingForVarnish = () => ({
|
|
9
39
|
title: 'Waiting for Varnish to return code 200',
|
|
10
|
-
skip: (ctx) => !ctx.config.overridenConfiguration.configuration.varnish.enabled,
|
|
11
|
-
task: async (ctx) => {
|
|
40
|
+
skip: (ctx) => ctx.debug || !ctx.config.overridenConfiguration.configuration.varnish.enabled,
|
|
41
|
+
task: async (ctx, task) => {
|
|
42
|
+
const pureMagentoVersion = ctx.magentoVersion.match(/^([0-9]+\.[0-9]+\.[0-9]+)/)[1];
|
|
43
|
+
|
|
44
|
+
const isMagento23 = semver.satisfies(pureMagentoVersion, '<2.4');
|
|
45
|
+
|
|
12
46
|
let tries = 0;
|
|
13
47
|
while (tries < 10) {
|
|
14
48
|
try {
|
|
@@ -28,6 +62,94 @@ const waitingForVarnish = () => ({
|
|
|
28
62
|
}
|
|
29
63
|
}
|
|
30
64
|
|
|
65
|
+
if (tries === 10 && isMagento23) {
|
|
66
|
+
const isHealthCheckRequestBroken = await getIsHealthCheckRequestBroken(ctx);
|
|
67
|
+
if (isHealthCheckRequestBroken) {
|
|
68
|
+
const confirm = await task.prompt({
|
|
69
|
+
type: 'Select',
|
|
70
|
+
message: `We detected that your Magento instance is experiencing problems with Varnish server.
|
|
71
|
+
Health Check request is returning status 500.
|
|
72
|
+
|
|
73
|
+
Do you want to try resolving this issue by replacing ${logger.style.file('./pub/health_check.php')} file content with content from newer Magento version (2.4.4)?`,
|
|
74
|
+
choices: [
|
|
75
|
+
{
|
|
76
|
+
name: 'yes',
|
|
77
|
+
message: 'Okay, let\'s try that'
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'no',
|
|
81
|
+
message: 'I will try to fix this myself, thanks for the info!'
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
if (confirm === 'yes') {
|
|
87
|
+
await fs.promises.writeFile(
|
|
88
|
+
pathToHealthCheckBackupPhp,
|
|
89
|
+
await fs.promises.readFile(pathToProjectsHealthCheckPhp, 'utf-8'),
|
|
90
|
+
'utf-8'
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
task.output = `Backup made! Available at ${logger.style.file(pathToHealthCheckBackupPhp)}`;
|
|
94
|
+
|
|
95
|
+
await fs.promises.writeFile(
|
|
96
|
+
pathToProjectsHealthCheckPhp,
|
|
97
|
+
await fs.promises.readFile(pathToWorkingHealthCheckPhp, 'utf-8'),
|
|
98
|
+
'utf-8'
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
task.output = `${logger.style.file('./pub/health_check.php')} content is replaced, waiting for nginx logs...`;
|
|
102
|
+
|
|
103
|
+
let connectionFixed = false;
|
|
104
|
+
|
|
105
|
+
for (let i = 0; i < 10; i++) {
|
|
106
|
+
try {
|
|
107
|
+
const response = await request(`http://localhost:${ctx.ports.sslTerminator}/`, {
|
|
108
|
+
responseType: 'headers'
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
if (response.status !== 200) {
|
|
112
|
+
await sleep(2000);
|
|
113
|
+
} else {
|
|
114
|
+
connectionFixed = true;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
} catch (e) {
|
|
118
|
+
await sleep(200);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (connectionFixed) {
|
|
123
|
+
task.output = 'Connection looks good!';
|
|
124
|
+
const secondConfirm = await task.prompt({
|
|
125
|
+
type: 'Select',
|
|
126
|
+
message: `Okay, looks like it helped!
|
|
127
|
+
Do you want to keep backed up ${logger.style.file('health_check.php')} file?`,
|
|
128
|
+
choices: [
|
|
129
|
+
{
|
|
130
|
+
name: 'no',
|
|
131
|
+
message: 'I don\'t think I will need it anymore, thanks'
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'yes',
|
|
135
|
+
message: 'I will keep it, maybe it will be useful (X to doubt)'
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
if (secondConfirm === 'no') {
|
|
141
|
+
await fs.promises.rm(pathToHealthCheckBackupPhp);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
task.skip('User choose to fix issue himself');
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
31
153
|
if (tries === 10) {
|
|
32
154
|
throw new KnownError(`After 20 seconds website is still responding with non-200 code, which might indicate issue with setup.
|
|
33
155
|
Or Varnish is still loading...
|
|
@@ -35,7 +157,10 @@ Or Varnish is still loading...
|
|
|
35
157
|
Please check the logs!`);
|
|
36
158
|
}
|
|
37
159
|
},
|
|
38
|
-
exitOnError: false
|
|
160
|
+
exitOnError: false,
|
|
161
|
+
options: {
|
|
162
|
+
bottomBar: 10
|
|
163
|
+
}
|
|
39
164
|
});
|
|
40
165
|
|
|
41
166
|
module.exports = waitingForVarnish;
|