@scandipwa/magento-scripts 1.14.1-alpha.2 → 1.14.1-alpha.5
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/config/docker.js +46 -9
- package/lib/config/get-port-config.js +2 -1
- package/lib/config/port-config.js +1 -0
- package/lib/config/templates/magentorc.template +3 -5
- package/lib/config/templates/php.template.ini +6 -4
- package/lib/config/templates/varnish.template.vcl +241 -0
- package/lib/config/versions/magento-2.3.0.js +9 -0
- package/lib/config/versions/magento-2.3.1.js +9 -0
- package/lib/config/versions/magento-2.3.2-p2.js +9 -0
- package/lib/config/versions/magento-2.3.2.js +9 -0
- package/lib/config/versions/magento-2.3.3-p1.js +9 -0
- package/lib/config/versions/magento-2.3.3.js +9 -0
- package/lib/config/versions/magento-2.3.4-p2.js +9 -0
- package/lib/config/versions/magento-2.3.4.js +9 -0
- package/lib/config/versions/magento-2.3.5-p1.js +9 -0
- package/lib/config/versions/magento-2.3.5-p2.js +9 -0
- package/lib/config/versions/magento-2.3.5.js +9 -0
- package/lib/config/versions/magento-2.3.6-p1.js +9 -0
- package/lib/config/versions/magento-2.3.6.js +9 -0
- package/lib/config/versions/magento-2.3.7-p1.js +9 -0
- package/lib/config/versions/magento-2.3.7-p2.js +9 -0
- package/lib/config/versions/magento-2.3.7-p3.js +9 -0
- package/lib/config/versions/magento-2.3.7.js +9 -0
- package/lib/config/versions/magento-2.4.0-p1.js +9 -0
- package/lib/config/versions/magento-2.4.0.js +9 -0
- package/lib/config/versions/magento-2.4.1-p1.js +9 -0
- package/lib/config/versions/magento-2.4.1.js +9 -0
- package/lib/config/versions/magento-2.4.2-p1.js +9 -0
- package/lib/config/versions/magento-2.4.2-p2.js +9 -0
- package/lib/config/versions/magento-2.4.2.js +9 -0
- package/lib/config/versions/magento-2.4.3-p1.js +9 -0
- package/lib/config/versions/magento-2.4.3-p2.js +9 -0
- package/lib/config/versions/magento-2.4.3.js +9 -0
- package/lib/config/versions/magento-2.4.4.js +9 -0
- package/lib/tasks/cli/create-bashrc-config.js +5 -2
- package/lib/tasks/docker/containers.js +10 -8
- package/lib/tasks/docker/volumes.js +4 -4
- package/lib/tasks/file-system/create-nginx-config.js +5 -0
- package/lib/tasks/file-system/create-php-storm-config.js +82 -0
- package/lib/tasks/file-system/create-varnish-config.js +51 -0
- package/lib/tasks/file-system/index.js +4 -2
- 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/increase-admin-session-lifetime.js +14 -16
- package/lib/tasks/magento/setup-magento/migrate-database.js +24 -11
- package/lib/tasks/magento/setup-magento/upgrade-magento.js +17 -3
- package/lib/tasks/magento/setup-magento/varnish-config.js +63 -0
- package/lib/tasks/mysql/fix-db.js +2 -2
- package/lib/tasks/php/index.js +1 -1
- package/lib/tasks/php/update-env-php.js +16 -1
- package/lib/tasks/php/update-env.php +54 -12
- package/lib/tasks/requirements/docker/index.js +2 -0
- package/lib/tasks/requirements/docker/install.js +11 -11
- package/lib/tasks/requirements/docker/running-status.js +137 -0
- package/lib/tasks/requirements/docker/version.js +2 -0
- package/lib/tasks/requirements/index.js +5 -5
- package/lib/tasks/requirements/php-version.js +3 -1
- package/lib/tasks/start.js +5 -14
- package/lib/tasks/status/index.js +1 -1
- package/lib/tasks/theme/build-theme.js +26 -8
- package/lib/tasks/theme/install-theme.js +16 -4
- package/lib/tasks/theme/link-theme.js +2 -2
- package/lib/tasks/theme/setup-persisted-query.js +3 -3
- package/lib/tasks/theme/setup-themes.js +3 -2
- package/lib/tasks/theme/symlink-theme.js +18 -3
- package/lib/util/config-file-validator.js +11 -1
- package/lib/util/config-php-json.js +19 -0
- package/lib/util/instance-metadata.js +1 -7
- package/lib/util/is-running-root.js +3 -0
- package/lib/util/match-filesystem.js +2 -1
- package/lib/util/php-task.js +6 -2
- package/lib/util/run-php.js +7 -1
- package/lib/util/systemctl.js +46 -0
- package/package.json +2 -3
- package/typings/context.d.ts +2 -2
- package/typings/index.d.ts +19 -0
- package/lib/config/xml-parser.js +0 -61
- package/lib/tasks/file-system/create-phpstorm-config/database-config.js +0 -248
- package/lib/tasks/file-system/create-phpstorm-config/eslint-config.js +0 -85
- package/lib/tasks/file-system/create-phpstorm-config/exclude-folder-config.js +0 -154
- package/lib/tasks/file-system/create-phpstorm-config/index.js +0 -27
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/coding-standard-config.js +0 -29
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/config.js +0 -54
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/custom-ruleset-path-config.js +0 -31
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/default-properties-config.js +0 -42
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/eslint-inspection-config.js +0 -37
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/index.js +0 -80
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/magento-coding-standard-config.js +0 -29
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/mess-detector-validation-inspection-config.js +0 -145
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/paths.js +0 -20
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-fixer-validation-inspection-config.js +0 -60
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/php-cs-validation-inspection-config.js +0 -119
- package/lib/tasks/file-system/create-phpstorm-config/inspection-tools-config/stylelint-inspection-config.js +0 -37
- package/lib/tasks/file-system/create-phpstorm-config/keys.js +0 -14
- package/lib/tasks/file-system/create-phpstorm-config/php-config/index.js +0 -67
- package/lib/tasks/file-system/create-phpstorm-config/php-config/mess-detector-config.js +0 -57
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-code-sniffer-config.js +0 -76
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-cs-fixer-config.js +0 -63
- package/lib/tasks/file-system/create-phpstorm-config/php-config/php-project-shared-configuration-config.js +0 -69
- package/lib/tasks/file-system/create-phpstorm-config/stylelint-config.js +0 -77
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/composer-settings-config.js +0 -98
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/format-setting-config.js +0 -57
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/index.js +0 -66
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-debug-general-config.js +0 -64
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/php-server-config.js +0 -60
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/properties-component-config.js +0 -51
- package/lib/tasks/file-system/create-phpstorm-config/workspace-config/run-manager-config.js +0 -74
- package/lib/tasks/file-system/create-phpstorm-config/xml-utils.js +0 -5
- package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -27
- package/lib/tasks/magento/setup-magento/disable-page-cache.js +0 -11
- package/typings/phpstorm.d.ts +0 -33
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const setConfigFile = require('../../util/set-config');
|
|
2
|
+
const pathExists = require('../../util/path-exists');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
|
|
6
|
+
const createPhpStormConfig = () => ({
|
|
7
|
+
title: 'Setting PHPStorm config',
|
|
8
|
+
task: async ({ config: { phpStorm }, ports }) => {
|
|
9
|
+
const { phpLanguageLevel } = phpStorm.php;
|
|
10
|
+
const jdbcUrl = `jdbc:mysql://localhost:${ports.mysql}/magento`;
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
await setConfigFile({
|
|
14
|
+
configPathname: phpStorm.xdebug.path,
|
|
15
|
+
template: phpStorm.xdebug.templatePath,
|
|
16
|
+
overwrite: true,
|
|
17
|
+
templateArgs: {
|
|
18
|
+
phpStorm
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
} catch (e) {
|
|
22
|
+
throw new Error(`Unexpected error accrued during workspace.xml config creation\n\n${e}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
await setConfigFile({
|
|
27
|
+
configPathname: phpStorm.php.path,
|
|
28
|
+
template: phpStorm.php.templatePath,
|
|
29
|
+
overwrite: true,
|
|
30
|
+
templateArgs: {
|
|
31
|
+
phpLanguageLevel
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
} catch (e) {
|
|
35
|
+
throw new Error(`Unexpected error accrued during php.xml config creation\n\n${e}`);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
await setConfigFile({
|
|
40
|
+
configPathname: phpStorm.database.dataSourcesLocal.path,
|
|
41
|
+
template: phpStorm.database.dataSourcesLocal.templatePath,
|
|
42
|
+
overwrite: true,
|
|
43
|
+
templateArgs: {
|
|
44
|
+
phpStorm
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
} catch (e) {
|
|
48
|
+
throw new Error(`Unexpected error accrued during dataSources.local.xml config creation\n\n${e}`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
await setConfigFile({
|
|
53
|
+
configPathname: phpStorm.database.dataSources.path,
|
|
54
|
+
template: phpStorm.database.dataSources.templatePath,
|
|
55
|
+
overwrite: true,
|
|
56
|
+
templateArgs: {
|
|
57
|
+
phpStorm,
|
|
58
|
+
jdbcUrl
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
} catch (e) {
|
|
62
|
+
throw new Error(`Unexpected error accrued during dataSources.xml config creation\n\n${e}`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!await pathExists(path.resolve('./.idea/dataSources'))) {
|
|
66
|
+
await fs.promises.mkdir(path.resolve('./.idea/dataSources'));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
await setConfigFile({
|
|
71
|
+
configPathname: phpStorm.inspectionTools.path,
|
|
72
|
+
template: phpStorm.inspectionTools.templatePath,
|
|
73
|
+
overwrite: true,
|
|
74
|
+
templateArgs: {}
|
|
75
|
+
});
|
|
76
|
+
} catch (e) {
|
|
77
|
+
throw new Error(`Unexpected error accrued during Project_Default.xml config creation\n\n${e}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
module.exports = createPhpStormConfig;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const os = require('os');
|
|
2
|
+
const path = require('path');
|
|
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
|
+
} = ctx;
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
configuration: {
|
|
25
|
+
varnish
|
|
26
|
+
}
|
|
27
|
+
} = overridenConfiguration;
|
|
28
|
+
|
|
29
|
+
const isLinux = os.platform() === 'linux';
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
await setConfigFile({
|
|
33
|
+
configPathname: path.join(
|
|
34
|
+
cacheDir,
|
|
35
|
+
'varnish',
|
|
36
|
+
'default.vcl'
|
|
37
|
+
),
|
|
38
|
+
template: varnish.configTemplate,
|
|
39
|
+
overwrite: true,
|
|
40
|
+
templateArgs: {
|
|
41
|
+
hostMachine: (isLinux && !isWsl) ? '127.0.0.1' : 'host.docker.internal',
|
|
42
|
+
hostPort: (isLinux && !isWsl) ? ports.app : 80
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
} catch (e) {
|
|
46
|
+
throw new Error(`Unexpected error accrued during varnish config creation\n\n${e}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
module.exports = createVarnishConfig;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const createNginxConfig = require('./create-nginx-config');
|
|
2
2
|
const createPhpConfig = require('./create-php-config');
|
|
3
3
|
const createPhpFpmConfig = require('./create-php-fpm-config');
|
|
4
|
-
const createPhpStormConfig = require('./create-
|
|
4
|
+
const createPhpStormConfig = require('./create-php-storm-config');
|
|
5
|
+
const createVarnishConfig = require('./create-varnish-config');
|
|
5
6
|
const createVSCodeConfig = require('./create-vscode-config');
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -14,7 +15,8 @@ const prepareFileSystem = () => ({
|
|
|
14
15
|
createPhpFpmConfig(),
|
|
15
16
|
createPhpConfig(),
|
|
16
17
|
createPhpStormConfig(),
|
|
17
|
-
createVSCodeConfig()
|
|
18
|
+
createVSCodeConfig(),
|
|
19
|
+
createVarnishConfig()
|
|
18
20
|
], {
|
|
19
21
|
concurrent: true
|
|
20
22
|
})
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -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: {
|
|
@@ -4,9 +4,23 @@ const magentoTask = require('../../../util/magento-task');
|
|
|
4
4
|
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
5
|
*/
|
|
6
6
|
const upgradeMagento = () => ({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
skip: (ctx) => {
|
|
8
|
+
if ('isSetupUpgradeNeeded' in ctx) {
|
|
9
|
+
return !ctx.isSetupUpgradeNeeded;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return false;
|
|
13
|
+
},
|
|
14
|
+
task: (_ctx, task) => task.newListr([
|
|
15
|
+
magentoTask('setup:upgrade --no-interaction'),
|
|
16
|
+
{
|
|
17
|
+
task: (ctx) => {
|
|
18
|
+
ctx.isSetupUpgradeNeeded = false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
], {
|
|
22
|
+
concurrent: false
|
|
23
|
+
})
|
|
10
24
|
});
|
|
11
25
|
|
|
12
26
|
module.exports = upgradeMagento;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const { updateTableValues } = require('../../../util/database');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @type {() => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
|
+
*/
|
|
6
|
+
const varnishConfigSetup = () => ({
|
|
7
|
+
title: 'Varnish setup',
|
|
8
|
+
task: async (ctx, task) => {
|
|
9
|
+
const {
|
|
10
|
+
config: {
|
|
11
|
+
overridenConfiguration: {
|
|
12
|
+
configuration: {
|
|
13
|
+
varnish: {
|
|
14
|
+
enabled: varnishEnabled
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
mysqlConnection,
|
|
20
|
+
ports
|
|
21
|
+
} = ctx;
|
|
22
|
+
|
|
23
|
+
if (varnishEnabled) {
|
|
24
|
+
await updateTableValues('core_config_data', [
|
|
25
|
+
{
|
|
26
|
+
path: 'system/full_page_cache/varnish/backend_host',
|
|
27
|
+
value: 'localhost'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
path: 'system/full_page_cache/varnish/backend_port',
|
|
31
|
+
value: ports.varnish
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
path: 'system/full_page_cache/varnish/access_list',
|
|
35
|
+
value: 'localhost'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
path: 'system/full_page_cache/caching_application',
|
|
39
|
+
value: '2'
|
|
40
|
+
}
|
|
41
|
+
], { mysqlConnection, task });
|
|
42
|
+
} else {
|
|
43
|
+
// delete varnish configuration if exists
|
|
44
|
+
await mysqlConnection.query(`
|
|
45
|
+
DELETE FROM core_config_data WHERE path LIKE '%varnish%';
|
|
46
|
+
`);
|
|
47
|
+
|
|
48
|
+
// update cache policy to not use varnish
|
|
49
|
+
// 0 - magento cache, 2 - varnish cache
|
|
50
|
+
await updateTableValues('core_config_data', [
|
|
51
|
+
{
|
|
52
|
+
path: 'system/full_page_cache/caching_application',
|
|
53
|
+
value: '0'
|
|
54
|
+
}
|
|
55
|
+
], { mysqlConnection, task });
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
options: {
|
|
59
|
+
bottomBar: 10
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
module.exports = varnishConfigSetup;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const adjustMagentoConfiguration = require('../magento/setup-magento/adjust-magento-configuration');
|
|
2
1
|
const configureElasticsearch = require('../magento/setup-magento/configure-elasticsearch');
|
|
3
2
|
const deleteAdminUsers = require('../magento/setup-magento/delete-admin-users');
|
|
4
3
|
const deleteCustomers = require('../magento/setup-magento/delete-customers');
|
|
5
4
|
const deleteOrders = require('../magento/setup-magento/delete-orders');
|
|
5
|
+
const varnishConfigSetup = require('../magento/setup-magento/varnish-config');
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -24,7 +24,7 @@ const disableForeignKeyCheck = () => ({
|
|
|
24
24
|
const fixDB = () => ({
|
|
25
25
|
title: 'Fixing database',
|
|
26
26
|
task: async (ctx, task) => task.newListr([
|
|
27
|
-
|
|
27
|
+
varnishConfigSetup(),
|
|
28
28
|
configureElasticsearch(),
|
|
29
29
|
{
|
|
30
30
|
title: 'Deleting customers data',
|
package/lib/tasks/php/index.js
CHANGED
|
@@ -14,8 +14,23 @@ const updateEnvPHP = () => ({
|
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
const useVarinsh = ctx.config.overridenConfiguration.configuration.varnish.enabled ? '1' : '';
|
|
18
|
+
const varnishHost = '127.0.0.1';
|
|
19
|
+
const varnishPort = ctx.ports.varnish;
|
|
20
|
+
const previousVarnishPort = ctx.cachedPorts
|
|
21
|
+
? ctx.cachedPorts.varnish
|
|
22
|
+
: ctx.cachedPorts;
|
|
23
|
+
|
|
17
24
|
return task.newListr(
|
|
18
|
-
phpTask(`-f ${ path.join(__dirname, 'update-env.php') }`, {
|
|
25
|
+
phpTask(`-f ${ path.join(__dirname, 'update-env.php') }`, {
|
|
26
|
+
noTitle: true,
|
|
27
|
+
env: {
|
|
28
|
+
USE_VARNISH: useVarinsh,
|
|
29
|
+
VARNISH_PORT: `${ varnishPort }`,
|
|
30
|
+
VARNISH_HOST: varnishHost,
|
|
31
|
+
PREVIOUS_VARNISH_PORT: `${ previousVarnishPort }`
|
|
32
|
+
}
|
|
33
|
+
})
|
|
19
34
|
);
|
|
20
35
|
}
|
|
21
36
|
});
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
function varexport($expression, $return=
|
|
3
|
+
function varexport($expression, $return=false): string
|
|
4
4
|
{
|
|
5
|
-
$export = var_export($expression,
|
|
5
|
+
$export = var_export($expression, true);
|
|
6
6
|
$export = preg_replace("/^([ ]*)(.*)/m", '$1$1$2', $export);
|
|
7
7
|
$array = preg_split("/\r\n|\n|\r/", $export);
|
|
8
|
-
$array = preg_replace(["/\s*array\s\($/", "/\)(,)?$/", "/\s=>\s$/"], [
|
|
8
|
+
$array = preg_replace(["/\s*array\s\($/", "/\)(,)?$/", "/\s=>\s$/"], [null, ']$1', ' => ['], $array);
|
|
9
9
|
$export = join(PHP_EOL, array_filter(["["] + $array));
|
|
10
|
-
if ((bool)$return)
|
|
10
|
+
if ((bool)$return) {
|
|
11
|
+
return $export;
|
|
12
|
+
} else {
|
|
13
|
+
echo $export;
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
16
|
|
|
13
17
|
function joinpaths(): string
|
|
@@ -15,13 +19,16 @@ function joinpaths(): string
|
|
|
15
19
|
$paths = array();
|
|
16
20
|
|
|
17
21
|
foreach (func_get_args() as $arg) {
|
|
18
|
-
if ($arg !== '') {
|
|
22
|
+
if ($arg !== '') {
|
|
23
|
+
$paths[] = $arg;
|
|
24
|
+
}
|
|
19
25
|
}
|
|
20
26
|
|
|
21
|
-
return preg_replace('#/+#','/',join('/', $paths));
|
|
27
|
+
return preg_replace('#/+#', '/', join('/', $paths));
|
|
22
28
|
}
|
|
23
29
|
|
|
24
|
-
class EnvUpdater
|
|
30
|
+
class EnvUpdater
|
|
31
|
+
{
|
|
25
32
|
|
|
26
33
|
/**
|
|
27
34
|
* @var array
|
|
@@ -33,7 +40,8 @@ class EnvUpdater {
|
|
|
33
40
|
*/
|
|
34
41
|
private $portConfig;
|
|
35
42
|
|
|
36
|
-
public function loadConfig()
|
|
43
|
+
public function loadConfig()
|
|
44
|
+
{
|
|
37
45
|
$this->config = require './app/etc/env.php';
|
|
38
46
|
}
|
|
39
47
|
|
|
@@ -53,7 +61,8 @@ class EnvUpdater {
|
|
|
53
61
|
return $this->portConfig;
|
|
54
62
|
}
|
|
55
63
|
|
|
56
|
-
public function loadPortConfig()
|
|
64
|
+
public function loadPortConfig()
|
|
65
|
+
{
|
|
57
66
|
$portConfigContent = file_get_contents('./node_modules/.create-magento-app-cache/port-config.json');
|
|
58
67
|
if ($portConfigContent === false) {
|
|
59
68
|
throw new Error('Port config file does not exists in cache directory');
|
|
@@ -67,7 +76,8 @@ class EnvUpdater {
|
|
|
67
76
|
$this->portConfig = $portConfigJsonData;
|
|
68
77
|
}
|
|
69
78
|
|
|
70
|
-
public function modifyConfig()
|
|
79
|
+
public function modifyConfig()
|
|
80
|
+
{
|
|
71
81
|
// update mysql config
|
|
72
82
|
if (isset($this->config['db']['connection']['default'])) {
|
|
73
83
|
$conn = &$this->config['db']['connection']['default'];
|
|
@@ -122,16 +132,48 @@ class EnvUpdater {
|
|
|
122
132
|
}
|
|
123
133
|
}
|
|
124
134
|
}
|
|
135
|
+
|
|
136
|
+
$httpCacheHosts = &$this->config['http_cache_hosts'];
|
|
137
|
+
$httpCacheHosts = [];
|
|
138
|
+
|
|
139
|
+
if (getenv('USE_VARNISH') == '1') {
|
|
140
|
+
$varnishHost = getenv('VARNISH_HOST');
|
|
141
|
+
$varnishPort = getenv('VARNISH_PORT');
|
|
142
|
+
$previousVarnishPort = getenv('PREVIOUS_VARNISH_PORT');
|
|
143
|
+
$varnishConfig = [
|
|
144
|
+
'host' => $varnishHost,
|
|
145
|
+
'port' => $varnishPort
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
if (isset($httpCacheHosts)) {
|
|
149
|
+
$varnishHostExists = false;
|
|
150
|
+
foreach ($httpCacheHosts as $host) {
|
|
151
|
+
if ($host['host'] == $varnishHost && $host['port'] == $previousVarnishPort) {
|
|
152
|
+
$host['port'] = $varnishPort;
|
|
153
|
+
$varnishHostExists = true;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (!$varnishHostExists) {
|
|
159
|
+
$httpCacheHosts = [$varnishConfig];
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
$this->config['http_cache_hosts'] = [$varnishConfig];
|
|
163
|
+
}
|
|
164
|
+
}
|
|
125
165
|
}
|
|
126
166
|
|
|
127
|
-
public function saveConfig(string $filePath)
|
|
167
|
+
public function saveConfig(string $filePath)
|
|
168
|
+
{
|
|
128
169
|
file_put_contents(
|
|
129
170
|
$filePath,
|
|
130
171
|
'<?php'.PHP_EOL.'return '.varexport($this->config, true).';' . PHP_EOL
|
|
131
172
|
);
|
|
132
173
|
}
|
|
133
174
|
|
|
134
|
-
public function update()
|
|
175
|
+
public function update()
|
|
176
|
+
{
|
|
135
177
|
$this->loadConfig();
|
|
136
178
|
$this->loadPortConfig();
|
|
137
179
|
$this->modifyConfig();
|
|
@@ -4,6 +4,7 @@ const { execAsyncSpawn } = require('../../../util/exec-async-command');
|
|
|
4
4
|
const getIsWsl = require('../../../util/is-wsl');
|
|
5
5
|
const installDocker = require('./install');
|
|
6
6
|
const { checkDockerSocketPermissions } = require('./permissions');
|
|
7
|
+
const checkDockerStatus = require('./running-status');
|
|
7
8
|
const getDockerVersion = require('./version');
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -61,6 +62,7 @@ ${ logger.style.link('https://docs.create-magento-app.com/getting-started/prereq
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
return task.newListr([
|
|
65
|
+
checkDockerStatus(),
|
|
64
66
|
getDockerVersion(),
|
|
65
67
|
{
|
|
66
68
|
task: (ctx) => {
|