@scandipwa/magento-scripts 1.14.1-alpha.1 → 1.14.1-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +13 -0
- package/lib/commands/cli.js +28 -1
- package/lib/commands/execute.js +2 -1
- package/lib/commands/logs.js +1 -0
- package/lib/commands/start.js +18 -5
- package/lib/config/cma-config.js +16 -0
- package/lib/config/dependencies-for-platforms.js +15 -3
- package/lib/config/docker.js +89 -15
- package/lib/config/get-port-config.js +9 -3
- package/lib/config/index.js +2 -1
- package/lib/config/php/extensions/libsodium.js +2 -1
- package/lib/config/port-config.js +3 -1
- package/lib/config/scandipwa-versions.js +2 -1
- package/lib/config/ssl-terminator/index.js +10 -0
- package/lib/config/system-config.js +34 -5
- package/lib/config/templates/magentorc.template +3 -5
- package/lib/config/templates/nginx.template.conf +0 -14
- package/lib/config/templates/php.template.ini +6 -4
- package/lib/config/templates/ssl-terminator.template.conf +27 -0
- package/lib/config/templates/varnish.template.vcl +255 -0
- package/lib/config/varnish/varnish-6-0.js +11 -0
- package/lib/config/varnish/varnish-6-6.js +11 -0
- package/lib/config/varnish/varnish-7-0.js +11 -0
- package/lib/config/versions/magento-2.3.0.js +9 -1
- package/lib/config/versions/magento-2.3.1.js +9 -1
- package/lib/config/versions/magento-2.3.2-p2.js +9 -1
- package/lib/config/versions/magento-2.3.2.js +9 -1
- package/lib/config/versions/magento-2.3.3-p1.js +9 -1
- package/lib/config/versions/magento-2.3.3.js +9 -1
- package/lib/config/versions/magento-2.3.4-p2.js +9 -1
- package/lib/config/versions/magento-2.3.4.js +9 -1
- package/lib/config/versions/magento-2.3.5-p1.js +9 -1
- package/lib/config/versions/magento-2.3.5-p2.js +9 -1
- package/lib/config/versions/magento-2.3.5.js +9 -1
- package/lib/config/versions/magento-2.3.6-p1.js +9 -1
- package/lib/config/versions/magento-2.3.6.js +9 -1
- package/lib/config/versions/magento-2.3.7-p1.js +9 -1
- package/lib/config/versions/magento-2.3.7-p2.js +9 -1
- package/lib/config/versions/magento-2.3.7-p3.js +9 -1
- package/lib/config/versions/magento-2.3.7.js +9 -1
- package/lib/config/versions/magento-2.4.0-p1.js +9 -1
- package/lib/config/versions/magento-2.4.0.js +9 -1
- package/lib/config/versions/magento-2.4.1-p1.js +9 -1
- package/lib/config/versions/magento-2.4.1.js +9 -1
- package/lib/config/versions/magento-2.4.2-p1.js +9 -1
- package/lib/config/versions/magento-2.4.2-p2.js +9 -1
- package/lib/config/versions/magento-2.4.2.js +9 -1
- package/lib/config/versions/magento-2.4.3-p1.js +9 -1
- package/lib/config/versions/magento-2.4.3-p2.js +9 -1
- package/lib/config/versions/magento-2.4.3.js +9 -1
- package/lib/config/versions/magento-2.4.4.js +9 -1
- package/lib/config/xml-parser.js +5 -3
- package/lib/errors/known-error.js +15 -0
- package/lib/errors/unknown-error.js +15 -0
- package/lib/tasks/cli/create-bashrc-config.js +7 -3
- package/lib/tasks/composer/index.js +5 -3
- package/lib/tasks/composer/local-auth-json.js +4 -2
- package/lib/tasks/docker/containers.js +13 -8
- package/lib/tasks/docker/network.js +2 -1
- package/lib/tasks/docker/volumes.js +4 -4
- package/lib/tasks/file-system/create-nginx-config.js +9 -40
- package/lib/tasks/file-system/create-php-config.js +2 -1
- package/lib/tasks/file-system/create-php-fpm-config.js +2 -1
- package/lib/tasks/file-system/create-phpstorm-config/database-config.js +5 -4
- package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +12 -10
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +0 -3
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +0 -3
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +1 -1
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +0 -3
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +0 -3
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +1 -4
- package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +1 -4
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +1 -11
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +1 -6
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +1 -11
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +2 -3
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +1 -4
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +2 -4
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +1 -11
- package/lib/tasks/file-system/create-ssl-terminator-config.js +96 -0
- package/lib/tasks/file-system/create-varnish-config.js +53 -0
- package/lib/tasks/file-system/create-vscode-config.js +3 -2
- package/lib/tasks/file-system/index.js +5 -1
- package/lib/tasks/magento/enable-magento-composer-plugins.js +3 -2
- package/lib/tasks/magento/install-magento.js +7 -5
- package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +26 -0
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +1 -1
- package/lib/tasks/magento/setup-magento/delete-admin-users.js +1 -1
- package/lib/tasks/magento/setup-magento/delete-customers.js +7 -4
- package/lib/tasks/magento/setup-magento/delete-orders.js +6 -4
- package/lib/tasks/magento/setup-magento/disable-2fa.js +4 -12
- package/lib/tasks/magento/setup-magento/flush-redis-config.js +2 -1
- package/lib/tasks/magento/setup-magento/increase-admin-session-lifetime.js +14 -16
- package/lib/tasks/magento/setup-magento/index.js +3 -1
- package/lib/tasks/magento/setup-magento/install-magento.js +2 -1
- package/lib/tasks/magento/setup-magento/migrate-database.js +24 -11
- package/lib/tasks/magento/setup-magento/set-base-url.js +7 -2
- package/lib/tasks/magento/setup-magento/upgrade-magento.js +27 -3
- package/lib/tasks/magento/setup-magento/varnish-config.js +69 -0
- package/lib/tasks/magento/setup-magento/waiting-for-varnish.js +41 -0
- package/lib/tasks/mysql/connect-to-mysql.js +2 -1
- package/lib/tasks/mysql/fix-db.js +2 -2
- package/lib/tasks/mysql/import-dump-to-mysql.js +13 -2
- package/lib/tasks/mysql/import-remote-db/index.js +2 -1
- package/lib/tasks/mysql/import-remote-db/ssh/index.js +2 -1
- package/lib/tasks/mysql/import-remote-db/ssh/regular-server.js +2 -1
- package/lib/tasks/php/bundled-extensions.js +28 -0
- package/lib/tasks/php/compile-options.js +27 -54
- package/lib/tasks/php/compile.js +6 -4
- package/lib/tasks/php/configure.js +7 -66
- package/lib/tasks/php/extensions/disable.js +2 -1
- package/lib/tasks/php/extensions/enable.js +2 -1
- package/lib/tasks/php/extensions/index.js +74 -0
- package/lib/tasks/php/extensions/install.js +3 -3
- package/lib/tasks/php/index.js +8 -7
- package/lib/tasks/php/install-sodium.js +93 -0
- package/lib/tasks/php/update-env-php.js +16 -1
- package/lib/tasks/php/update-env.php +56 -12
- package/lib/tasks/php/update-phpbrew.js +7 -3
- package/lib/tasks/php/validate-php.js +67 -0
- package/lib/tasks/php-fpm/start-php-fpm.js +4 -2
- package/lib/tasks/requirements/composer.js +7 -5
- package/lib/tasks/requirements/dependency/arch.js +2 -1
- package/lib/tasks/requirements/dependency/centos.js +2 -1
- package/lib/tasks/requirements/dependency/fedora.js +2 -1
- package/lib/tasks/requirements/dependency/mac.js +18 -3
- package/lib/tasks/requirements/docker/index.js +96 -40
- package/lib/tasks/requirements/docker/install-on-mac.js +29 -0
- package/lib/tasks/requirements/docker/install.js +13 -12
- package/lib/tasks/requirements/docker/running-status.js +138 -0
- package/lib/tasks/requirements/docker/version.js +3 -0
- package/lib/tasks/requirements/index.js +8 -5
- package/lib/tasks/requirements/node-version.js +2 -1
- package/lib/tasks/requirements/php-version.js +29 -25
- package/lib/tasks/requirements/phpbrew/index.js +2 -1
- package/lib/tasks/requirements/phpbrew/install.js +14 -2
- package/lib/tasks/requirements/phpbrew/version.js +2 -1
- package/lib/tasks/requirements/platform.js +5 -3
- package/lib/tasks/requirements/rosetta.js +32 -0
- package/lib/tasks/start.js +8 -9
- package/lib/tasks/status/index.js +25 -9
- package/lib/tasks/theme/build-theme.js +27 -8
- package/lib/tasks/theme/install-theme.js +18 -5
- package/lib/tasks/theme/link-theme.js +2 -2
- package/lib/tasks/theme/retrieve-theme-data.js +2 -1
- package/lib/tasks/theme/setup-persisted-query.js +5 -4
- package/lib/tasks/theme/setup-themes.js +11 -3
- package/lib/tasks/theme/symlink-theme.js +26 -4
- package/lib/util/CSA-theme.js +4 -0
- package/lib/util/analytics.js +337 -0
- package/lib/util/arch.js +1 -1
- package/lib/util/config-file-validator.js +14 -2
- package/lib/util/config-php-json.js +20 -0
- package/lib/util/env-php-json.js +3 -2
- package/lib/util/exec-async-command.d.ts +2 -0
- package/lib/util/exec-async-command.js +31 -15
- package/lib/util/exec-async.js +9 -0
- package/lib/util/get-brew-bin-path.js +64 -0
- package/lib/util/get-installed-magento-version.js +3 -2
- package/lib/util/get-jsonfile-data.js +2 -1
- package/lib/util/install-dependencies-task.js +15 -5
- package/lib/util/instance-metadata.js +4 -3
- package/lib/util/ip.js +45 -1
- package/lib/util/is-running-root.js +3 -0
- package/lib/util/magento-task.js +20 -9
- package/lib/util/match-filesystem.js +2 -1
- package/lib/util/php-task.js +7 -3
- package/lib/util/request.js +0 -0
- package/lib/util/resolve-configuration-with-overrides.js +2 -1
- package/lib/util/run-composer.js +5 -3
- package/lib/util/run-magento.js +3 -2
- package/lib/util/run-php.js +14 -3
- package/lib/util/systemctl.js +46 -0
- package/lib/util/wait-for-it.js +3 -2
- package/package.json +4 -3
- package/typings/context.d.ts +6 -1
- package/typings/index.d.ts +32 -1
- package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -27
- package/lib/tasks/magento/setup-magento/disable-page-cache.js +0 -11
|
@@ -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-phpstorm-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
|
},
|
|
@@ -0,0 +1,26 @@
|
|
|
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: 'Adjusting full_page cache setting',
|
|
9
|
+
task: async ({ magentoVersion, config }, task) => {
|
|
10
|
+
const { cache_types } = await envPhpToJson(process.cwd(), { magentoVersion });
|
|
11
|
+
|
|
12
|
+
if (cache_types.full_page !== 0 && !config.overridenConfiguration.configuration.varnish.enabled) {
|
|
13
|
+
task.title = 'Disabling full_page cache in Magento';
|
|
14
|
+
return task.newListr(magentoTask('cache:disable full_page'));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (config.overridenConfiguration.configuration.varnish.enabled && cache_types.full_page !== 1) {
|
|
18
|
+
task.title = 'Enabling full_page cache in Magento (Varnish is enabled)';
|
|
19
|
+
return task.newListr(magentoTask('cache:enable full_page'));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
task.skip();
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
module.exports = disableFullPageCache;
|
|
@@ -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,7 +1,7 @@
|
|
|
1
1
|
const { isTableExists } = require('../../../util/database');
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
4
|
+
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
5
|
*/
|
|
6
6
|
const deleteAdminUsers = () => ({
|
|
7
7
|
title: 'Deleting old admin users',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { customerTables } = require('../../mysql/magento-tables');
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
4
|
+
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
5
|
*/
|
|
6
6
|
const deleteCustomers = () => ({
|
|
7
7
|
title: 'Deleting customers',
|
|
@@ -12,10 +12,13 @@ const deleteCustomers = () => ({
|
|
|
12
12
|
task.skip();
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
+
|
|
16
|
+
const [rows] = await mysqlConnection.query('select TABLE_NAME from information_schema.TABLES;');
|
|
17
|
+
|
|
15
18
|
await Promise.all(
|
|
16
|
-
customerTables
|
|
17
|
-
(tableName) =>
|
|
18
|
-
|
|
19
|
+
customerTables
|
|
20
|
+
.filter((tableName) => rows.some((row) => row.TABLE_NAME === tableName))
|
|
21
|
+
.map((tableName) => mysqlConnection.query(`TRUNCATE TABLE \`${ tableName }\`;`))
|
|
19
22
|
);
|
|
20
23
|
}
|
|
21
24
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { orderTables } = require('../../mysql/magento-tables');
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
4
|
+
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
5
|
*/
|
|
6
6
|
const deleteOrders = () => ({
|
|
7
7
|
title: 'Deleting orders',
|
|
@@ -13,10 +13,12 @@ const deleteOrders = () => ({
|
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
const [rows] = await mysqlConnection.query('select TABLE_NAME from information_schema.TABLES;');
|
|
17
|
+
|
|
16
18
|
await Promise.all(
|
|
17
|
-
orderTables
|
|
18
|
-
(tableName) =>
|
|
19
|
-
|
|
19
|
+
orderTables
|
|
20
|
+
.filter((tableName) => rows.some((row) => row.TABLE_NAME === tableName))
|
|
21
|
+
.map((tableName) => mysqlConnection.query(`TRUNCATE TABLE \`${ tableName }\`;`))
|
|
20
22
|
);
|
|
21
23
|
}
|
|
22
24
|
});
|
|
@@ -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
|
});
|
|
@@ -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: {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
const magentoTask = require('../../../util/magento-task');
|
|
2
2
|
const runMagentoCommand = require('../../../util/run-magento');
|
|
3
|
-
const adjustMagentoConfiguration = require('./adjust-magento-configuration');
|
|
4
3
|
const configureElasticsearch = require('./configure-elasticsearch');
|
|
5
4
|
const installMagento = require('./install-magento');
|
|
6
5
|
const upgradeMagento = require('./upgrade-magento');
|
|
7
|
-
const
|
|
6
|
+
const varnishConfigSetup = require('./varnish-config');
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* @type {({ onlyInstallMagento: boolean }) => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
@@ -25,6 +24,7 @@ const migrateDatabase = (options = {}) => ({
|
|
|
25
24
|
|
|
26
25
|
if (tableCount === 0) {
|
|
27
26
|
if (options.onlyInstallMagento) {
|
|
27
|
+
ctx.isSetupUpgradeNeeded = false;
|
|
28
28
|
return task.newListr(
|
|
29
29
|
installMagento({ isDbEmpty: true })
|
|
30
30
|
);
|
|
@@ -32,14 +32,17 @@ const migrateDatabase = (options = {}) => ({
|
|
|
32
32
|
|
|
33
33
|
return task.newListr([
|
|
34
34
|
installMagento({ isDbEmpty: true }),
|
|
35
|
-
setupPersistedQuery(),
|
|
36
35
|
upgradeMagento(),
|
|
37
36
|
magentoTask('cache:enable'),
|
|
37
|
+
varnishConfigSetup(),
|
|
38
38
|
configureElasticsearch()
|
|
39
39
|
], {
|
|
40
40
|
concurrent: false,
|
|
41
41
|
exitOnError: true,
|
|
42
|
-
ctx
|
|
42
|
+
ctx,
|
|
43
|
+
rendererOptions: {
|
|
44
|
+
collapse: false
|
|
45
|
+
}
|
|
43
46
|
});
|
|
44
47
|
}
|
|
45
48
|
const { code } = await runMagentoCommand('setup:db:status', {
|
|
@@ -49,18 +52,23 @@ const migrateDatabase = (options = {}) => ({
|
|
|
49
52
|
|
|
50
53
|
switch (code) {
|
|
51
54
|
case 0: {
|
|
55
|
+
ctx.isSetupUpgradeNeeded = false;
|
|
52
56
|
// no setup is needed, but still to be sure configure ES
|
|
53
57
|
return task.newListr([
|
|
54
|
-
|
|
58
|
+
varnishConfigSetup(),
|
|
55
59
|
configureElasticsearch()
|
|
56
60
|
], {
|
|
57
61
|
concurrent: false,
|
|
58
62
|
exitOnError: true,
|
|
59
|
-
ctx
|
|
63
|
+
ctx,
|
|
64
|
+
rendererOptions: {
|
|
65
|
+
collapse: false
|
|
66
|
+
}
|
|
60
67
|
});
|
|
61
68
|
}
|
|
62
69
|
case 1: {
|
|
63
70
|
if (options.onlyInstallMagento) {
|
|
71
|
+
ctx.isSetupUpgradeNeeded = false;
|
|
64
72
|
return task.newListr(
|
|
65
73
|
installMagento()
|
|
66
74
|
);
|
|
@@ -68,26 +76,31 @@ const migrateDatabase = (options = {}) => ({
|
|
|
68
76
|
|
|
69
77
|
return task.newListr([
|
|
70
78
|
installMagento(),
|
|
71
|
-
setupPersistedQuery(),
|
|
72
79
|
upgradeMagento(),
|
|
73
80
|
magentoTask('cache:enable'),
|
|
81
|
+
varnishConfigSetup(),
|
|
74
82
|
configureElasticsearch()
|
|
75
83
|
], {
|
|
76
84
|
concurrent: false,
|
|
77
85
|
exitOnError: true,
|
|
78
|
-
ctx
|
|
86
|
+
ctx,
|
|
87
|
+
rendererOptions: {
|
|
88
|
+
collapse: false
|
|
89
|
+
}
|
|
79
90
|
});
|
|
80
91
|
}
|
|
81
92
|
case 2: {
|
|
82
93
|
return task.newListr([
|
|
83
|
-
|
|
84
|
-
adjustMagentoConfiguration(),
|
|
94
|
+
varnishConfigSetup(),
|
|
85
95
|
configureElasticsearch(),
|
|
86
96
|
upgradeMagento()
|
|
87
97
|
], {
|
|
88
98
|
concurrent: false,
|
|
89
99
|
exitOnError: true,
|
|
90
|
-
ctx
|
|
100
|
+
ctx,
|
|
101
|
+
rendererOptions: {
|
|
102
|
+
collapse: false
|
|
103
|
+
}
|
|
91
104
|
});
|
|
92
105
|
}
|
|
93
106
|
default: {
|
|
@@ -8,12 +8,17 @@ module.exports = () => ({
|
|
|
8
8
|
task: async (ctx, task) => {
|
|
9
9
|
const {
|
|
10
10
|
ports,
|
|
11
|
-
config: {
|
|
11
|
+
config: {
|
|
12
|
+
overridenConfiguration: {
|
|
13
|
+
host,
|
|
14
|
+
ssl
|
|
15
|
+
}
|
|
16
|
+
},
|
|
12
17
|
mysqlConnection
|
|
13
18
|
} = ctx;
|
|
14
19
|
const isNgrok = host.endsWith('ngrok.io');
|
|
15
20
|
const enableSecureFrontend = ssl.enabled ? '1' : '0';
|
|
16
|
-
const location = `${host}${ !isNgrok && ports.
|
|
21
|
+
const location = `${host}${ !isNgrok && ports.sslTerminator !== 80 ? `:${ports.sslTerminator }` : '' }/`;
|
|
17
22
|
const secureLocation = `${host}/`; // SSL will work only on port 443, so you cannot run multiple projects with SSL at the same time.
|
|
18
23
|
const httpUrl = `http://${location}`;
|
|
19
24
|
const httpsUrl = `https://${secureLocation}`;
|
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
const magentoTask = require('../../../util/magento-task');
|
|
2
|
+
const logger = require('@scandipwa/scandipwa-dev-utils/logger');
|
|
3
|
+
const KnownError = require('../../../errors/known-error');
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
7
|
*/
|
|
6
8
|
const upgradeMagento = () => ({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
skip: (ctx) => {
|
|
10
|
+
if ('isSetupUpgradeNeeded' in ctx) {
|
|
11
|
+
return !ctx.isSetupUpgradeNeeded;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return false;
|
|
15
|
+
},
|
|
16
|
+
task: (_ctx, task) => task.newListr([
|
|
17
|
+
magentoTask('setup:upgrade --no-interaction', {
|
|
18
|
+
onError: (e) => {
|
|
19
|
+
throw new KnownError(`Magento setup:upgrade command failed!
|
|
20
|
+
You can try disabling failed module and try again.
|
|
21
|
+
To disable module, open ${logger.style.misc('cli')} and type the following command: ${logger.style.command('m module:disable <module-name>')}
|
|
22
|
+
|
|
23
|
+
Error: ${e}`);
|
|
24
|
+
}
|
|
25
|
+
}),
|
|
26
|
+
{
|
|
27
|
+
task: (ctx) => {
|
|
28
|
+
ctx.isSetupUpgradeNeeded = false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
], {
|
|
32
|
+
concurrent: false
|
|
33
|
+
})
|
|
10
34
|
});
|
|
11
35
|
|
|
12
36
|
module.exports = upgradeMagento;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const os = require('os');
|
|
2
|
+
const { updateTableValues } = require('../../../util/database');
|
|
3
|
+
const getIsWsl = require('../../../util/is-wsl');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
7
|
+
*/
|
|
8
|
+
const varnishConfigSetup = () => ({
|
|
9
|
+
title: 'Varnish setup',
|
|
10
|
+
task: async (ctx, task) => {
|
|
11
|
+
const {
|
|
12
|
+
config: {
|
|
13
|
+
overridenConfiguration: {
|
|
14
|
+
configuration: {
|
|
15
|
+
varnish: {
|
|
16
|
+
enabled: varnishEnabled
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
mysqlConnection,
|
|
22
|
+
ports
|
|
23
|
+
} = ctx;
|
|
24
|
+
|
|
25
|
+
const isLinux = os.platform() === 'linux';
|
|
26
|
+
const isWsl = await getIsWsl();
|
|
27
|
+
// const host = (isLinux && !isWsl) ? 'localhost' : 'host.docker.internal';
|
|
28
|
+
|
|
29
|
+
if (varnishEnabled) {
|
|
30
|
+
await updateTableValues('core_config_data', [
|
|
31
|
+
{
|
|
32
|
+
path: 'system/full_page_cache/varnish/backend_host',
|
|
33
|
+
value: 'localhost'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
path: 'system/full_page_cache/varnish/backend_port',
|
|
37
|
+
value: ports.varnish
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
path: 'system/full_page_cache/varnish/access_list',
|
|
41
|
+
value: (!isLinux || isWsl) ? 'host.docker.internal,localhost' : 'localhost'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
path: 'system/full_page_cache/caching_application',
|
|
45
|
+
value: '2'
|
|
46
|
+
}
|
|
47
|
+
], { mysqlConnection, task });
|
|
48
|
+
} else {
|
|
49
|
+
// delete varnish configuration if exists
|
|
50
|
+
await mysqlConnection.query(`
|
|
51
|
+
DELETE FROM core_config_data WHERE path LIKE '%varnish%';
|
|
52
|
+
`);
|
|
53
|
+
|
|
54
|
+
// update cache policy to not use varnish
|
|
55
|
+
// 0 - magento cache, 2 - varnish cache
|
|
56
|
+
await updateTableValues('core_config_data', [
|
|
57
|
+
{
|
|
58
|
+
path: 'system/full_page_cache/caching_application',
|
|
59
|
+
value: '0'
|
|
60
|
+
}
|
|
61
|
+
], { mysqlConnection, task });
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
options: {
|
|
65
|
+
bottomBar: 10
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
module.exports = varnishConfigSetup;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const { request } = require('smol-request');
|
|
2
|
+
const KnownError = require('../../../errors/known-error');
|
|
3
|
+
const sleep = require('../../../util/sleep');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
7
|
+
*/
|
|
8
|
+
const waitingForVarnish = () => ({
|
|
9
|
+
title: 'Waiting for Varnish to return code 200',
|
|
10
|
+
skip: (ctx) => !ctx.config.overridenConfiguration.configuration.varnish.enabled,
|
|
11
|
+
task: async (ctx) => {
|
|
12
|
+
let tries = 0;
|
|
13
|
+
while (tries < 10) {
|
|
14
|
+
try {
|
|
15
|
+
const response = await request(`http://localhost:${ctx.ports.sslTerminator}/`, {
|
|
16
|
+
responseType: 'headers'
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if (response.status !== 200) {
|
|
20
|
+
tries++;
|
|
21
|
+
await sleep(2000);
|
|
22
|
+
} else {
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
} catch (e) {
|
|
26
|
+
tries++;
|
|
27
|
+
await sleep(200);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (tries === 10) {
|
|
32
|
+
throw new KnownError(`After 20 seconds website is still responding with non-200 code, which might indicate issue with setup.
|
|
33
|
+
Or Varnish is still loading...
|
|
34
|
+
|
|
35
|
+
Please check the logs!`);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
exitOnError: false
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
module.exports = waitingForVarnish;
|