@scandipwa/magento-scripts 1.14.1-alpha.3 → 1.14.1-alpha.4
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 +28 -1
- package/lib/commands/execute.js +2 -1
- package/lib/config/docker.js +45 -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-varnish-config.js +51 -0
- package/lib/tasks/file-system/index.js +3 -1
- 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 +21 -6
- 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/index.js +5 -5
- package/lib/tasks/requirements/php-version.js +3 -1
- package/lib/tasks/status/index.js +1 -1
- 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 +2 -2
- package/lib/util/config-file-validator.js +11 -1
- package/lib/util/config-php-json.js +19 -0
- package/lib/util/php-task.js +6 -2
- package/lib/util/run-php.js +7 -1
- package/package.json +2 -2
- package/typings/context.d.ts +1 -0
- package/typings/index.d.ts +19 -0
- package/lib/tasks/magento/setup-magento/adjust-magento-configuration.js +0 -27
- package/lib/tasks/magento/setup-magento/disable-page-cache.js +0 -11
|
@@ -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,10 @@
|
|
|
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
6
|
const setupPersistedQuery = require('../../theme/setup-persisted-query');
|
|
7
|
+
const varnishConfigSetup = require('./varnish-config');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @type {({ onlyInstallMagento: boolean }) => import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
@@ -35,11 +35,15 @@ const migrateDatabase = (options = {}) => ({
|
|
|
35
35
|
setupPersistedQuery(),
|
|
36
36
|
upgradeMagento(),
|
|
37
37
|
magentoTask('cache:enable'),
|
|
38
|
+
varnishConfigSetup(),
|
|
38
39
|
configureElasticsearch()
|
|
39
40
|
], {
|
|
40
41
|
concurrent: false,
|
|
41
42
|
exitOnError: true,
|
|
42
|
-
ctx
|
|
43
|
+
ctx,
|
|
44
|
+
rendererOptions: {
|
|
45
|
+
collapse: false
|
|
46
|
+
}
|
|
43
47
|
});
|
|
44
48
|
}
|
|
45
49
|
const { code } = await runMagentoCommand('setup:db:status', {
|
|
@@ -52,11 +56,15 @@ const migrateDatabase = (options = {}) => ({
|
|
|
52
56
|
// no setup is needed, but still to be sure configure ES
|
|
53
57
|
return task.newListr([
|
|
54
58
|
setupPersistedQuery(),
|
|
59
|
+
varnishConfigSetup(),
|
|
55
60
|
configureElasticsearch()
|
|
56
61
|
], {
|
|
57
62
|
concurrent: false,
|
|
58
63
|
exitOnError: true,
|
|
59
|
-
ctx
|
|
64
|
+
ctx,
|
|
65
|
+
rendererOptions: {
|
|
66
|
+
collapse: false
|
|
67
|
+
}
|
|
60
68
|
});
|
|
61
69
|
}
|
|
62
70
|
case 1: {
|
|
@@ -71,23 +79,30 @@ const migrateDatabase = (options = {}) => ({
|
|
|
71
79
|
setupPersistedQuery(),
|
|
72
80
|
upgradeMagento(),
|
|
73
81
|
magentoTask('cache:enable'),
|
|
82
|
+
varnishConfigSetup(),
|
|
74
83
|
configureElasticsearch()
|
|
75
84
|
], {
|
|
76
85
|
concurrent: false,
|
|
77
86
|
exitOnError: true,
|
|
78
|
-
ctx
|
|
87
|
+
ctx,
|
|
88
|
+
rendererOptions: {
|
|
89
|
+
collapse: false
|
|
90
|
+
}
|
|
79
91
|
});
|
|
80
92
|
}
|
|
81
93
|
case 2: {
|
|
82
94
|
return task.newListr([
|
|
83
95
|
setupPersistedQuery(),
|
|
84
|
-
|
|
96
|
+
varnishConfigSetup(),
|
|
85
97
|
configureElasticsearch(),
|
|
86
98
|
upgradeMagento()
|
|
87
99
|
], {
|
|
88
100
|
concurrent: false,
|
|
89
101
|
exitOnError: true,
|
|
90
|
-
ctx
|
|
102
|
+
ctx,
|
|
103
|
+
rendererOptions: {
|
|
104
|
+
collapse: false
|
|
105
|
+
}
|
|
91
106
|
});
|
|
92
107
|
}
|
|
93
108
|
default: {
|
|
@@ -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();
|
|
@@ -13,17 +13,17 @@ const checkRequirements = () => ({
|
|
|
13
13
|
task: (ctx, task) => task.newListr([
|
|
14
14
|
// checking if user is on supported platform
|
|
15
15
|
checkPlatform(),
|
|
16
|
+
// check the Docker installation
|
|
17
|
+
checkDocker(),
|
|
18
|
+
// check for Node.js version
|
|
19
|
+
checkNodeVersion(),
|
|
16
20
|
// check the PHPBrew installation
|
|
17
21
|
checkPHPbrew(),
|
|
18
22
|
// check installed PHP version
|
|
19
23
|
checkPHPVersion(),
|
|
20
|
-
// check the Docker installation
|
|
21
|
-
checkDocker(),
|
|
22
24
|
// check for COMPOSER_AUTH or auth.json
|
|
23
25
|
// localAuthJson(),
|
|
24
|
-
checkComposer()
|
|
25
|
-
// check for Node.js version
|
|
26
|
-
checkNodeVersion()
|
|
26
|
+
checkComposer()
|
|
27
27
|
], {
|
|
28
28
|
concurrent: false,
|
|
29
29
|
exitOnError: true,
|
|
@@ -99,7 +99,7 @@ const checkPHPVersion = () => ({
|
|
|
99
99
|
task: async (ctx, task) => {
|
|
100
100
|
const phpVersionResponse = await execAsyncSpawn('php --version');
|
|
101
101
|
|
|
102
|
-
const phpVersionResponseResult = phpVersionResponse.match(/PHP\s(\d
|
|
102
|
+
const phpVersionResponseResult = phpVersionResponse.match(/PHP\s(\d+\.\d+\.\d+)/i);
|
|
103
103
|
|
|
104
104
|
if (phpVersionResponseResult && phpVersionResponseResult.length > 0) {
|
|
105
105
|
const phpVersion = phpVersionResponseResult[1];
|
|
@@ -123,6 +123,8 @@ To fix that we will build special PHP version that will be used by PHPBrew, plea
|
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
+
|
|
127
|
+
task.title = `Using PHP version ${phpVersion} in system`;
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
130
|
});
|
|
@@ -91,7 +91,7 @@ const prettyStatus = async (ctx) => {
|
|
|
91
91
|
.addLine(`Image: ${logger.style.file(container.image)}`)
|
|
92
92
|
.addLine(`Network: ${logger.style.link(container.network)}`);
|
|
93
93
|
|
|
94
|
-
if (container.ports.length > 0) {
|
|
94
|
+
if (container.ports && container.ports.length > 0) {
|
|
95
95
|
block.addLine('Port forwarding:');
|
|
96
96
|
container.ports.forEach((port) => {
|
|
97
97
|
const { host, hostPort, containerPort } = parsePort(port);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const symlinkTheme = require('./symlink-theme');
|
|
2
2
|
const installTheme = require('./install-theme');
|
|
3
|
-
const
|
|
3
|
+
const disableFullPageCache = require('../magento/setup-magento/disable-full-page-cache');
|
|
4
4
|
const disablePageBuilder = require('../magento/setup-magento/disable-page-builder');
|
|
5
5
|
const buildTheme = require('./build-theme');
|
|
6
6
|
const upgradeMagento = require('../magento/setup-magento/upgrade-magento');
|
|
@@ -53,7 +53,7 @@ const linkTheme = () => ({
|
|
|
53
53
|
updateEnvPHP(),
|
|
54
54
|
setupPersistedQuery(),
|
|
55
55
|
upgradeMagento(),
|
|
56
|
-
|
|
56
|
+
disableFullPageCache(),
|
|
57
57
|
...(isPageBuilderInstalled && Number(isPagebuilderEnabled) ? [disablePageBuilder()] : []),
|
|
58
58
|
buildTheme(theme)
|
|
59
59
|
]);
|
|
@@ -8,7 +8,7 @@ const runMagentoCommand = require('../../util/run-magento');
|
|
|
8
8
|
* @type {() => import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
9
9
|
*/
|
|
10
10
|
const persistedQuerySetup = () => ({
|
|
11
|
-
title: 'Setting up
|
|
11
|
+
title: 'Setting up Redis configuration for persisted queries',
|
|
12
12
|
task: async (ctx, task) => {
|
|
13
13
|
const { ports, magentoVersion, verbose = false } = ctx;
|
|
14
14
|
const composerLockData = await getJsonfileData(path.join(process.cwd(), 'composer.lock'));
|
|
@@ -29,8 +29,8 @@ const persistedQuerySetup = () => ({
|
|
|
29
29
|
if (
|
|
30
30
|
persistedQueryConfig
|
|
31
31
|
&& persistedQueryConfig.redis
|
|
32
|
-
&& persistedQueryConfig.redis.port === ports.redis
|
|
33
|
-
&& persistedQueryConfig.redis.
|
|
32
|
+
&& persistedQueryConfig.redis.port === `${ ports.redis }`
|
|
33
|
+
&& persistedQueryConfig.redis.host === 'localhost'
|
|
34
34
|
) {
|
|
35
35
|
task.skip();
|
|
36
36
|
return;
|
|
@@ -5,7 +5,7 @@ const symlinkTheme = require('./symlink-theme');
|
|
|
5
5
|
const installTheme = require('./install-theme');
|
|
6
6
|
const setupPersistedQuery = require('./setup-persisted-query');
|
|
7
7
|
const upgradeMagento = require('../magento/setup-magento/upgrade-magento');
|
|
8
|
-
const
|
|
8
|
+
const disableFullPageCache = require('../magento/setup-magento/disable-full-page-cache');
|
|
9
9
|
const buildTheme = require('./build-theme');
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -80,7 +80,7 @@ const setupThemes = () => ({
|
|
|
80
80
|
])
|
|
81
81
|
})).concat([
|
|
82
82
|
upgradeMagento(),
|
|
83
|
-
|
|
83
|
+
disableFullPageCache(),
|
|
84
84
|
setupPersistedQuery()
|
|
85
85
|
])
|
|
86
86
|
);
|
|
@@ -72,6 +72,15 @@ const nginxConfigurationSchema = Joi.object({
|
|
|
72
72
|
configTemplate: Joi.string().optional().custom(fileExistsValidator)
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* @type {Joi.ObjectSchema<import('../../typings').NginxConfiguration>}
|
|
77
|
+
*/
|
|
78
|
+
const varnishConfigurationSchema = Joi.object({
|
|
79
|
+
enabled: Joi.boolean().optional(),
|
|
80
|
+
version: Joi.string().optional(),
|
|
81
|
+
configTemplate: Joi.string().optional().custom(fileExistsValidator)
|
|
82
|
+
});
|
|
83
|
+
|
|
75
84
|
/**
|
|
76
85
|
* @type {Joi.ObjectSchema<import('../../typings').ServiceWithVersion>}
|
|
77
86
|
*/
|
|
@@ -101,7 +110,8 @@ const configurationSchema = Joi.object({
|
|
|
101
110
|
mysql: serviceConfigurationSchema.optional(),
|
|
102
111
|
elasticsearch: serviceConfigurationSchema.optional(),
|
|
103
112
|
redis: serviceConfigurationSchema.optional(),
|
|
104
|
-
composer: composerConfigurationSchema.optional()
|
|
113
|
+
composer: composerConfigurationSchema.optional(),
|
|
114
|
+
varnish: varnishConfigurationSchema.optional()
|
|
105
115
|
});
|
|
106
116
|
|
|
107
117
|
/**
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const runPhpCode = require('./run-php');
|
|
3
|
+
|
|
4
|
+
const configPhpToJson = async (projectPath = process.cwd(), { magentoVersion }) => {
|
|
5
|
+
const { code, result } = await runPhpCode(`-r "echo json_encode(require '${path.join(projectPath, 'app', 'etc', 'config.php')}');"`, {
|
|
6
|
+
magentoVersion
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
if (code !== 0) {
|
|
10
|
+
throw new Error(result);
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(result);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
throw new Error(`Ooops! Something went wrong when trying to parse app/etc/config.php file!\n\n${e}\n\nFile result: ${result}`);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
module.exports = configPhpToJson;
|
package/lib/util/php-task.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
const runPhpCode = require('./run-php');
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @type {(
|
|
4
|
+
* @type {(
|
|
5
|
+
* command: string,
|
|
6
|
+
* options: { noTitle: boolean, env: Record<string, string> }
|
|
7
|
+
* ) => import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
5
8
|
*/
|
|
6
9
|
const phpTask = (command, options = {}) => ({
|
|
7
10
|
title: !options.noTitle ? `Running command 'php ${command}` : undefined,
|
|
@@ -10,7 +13,8 @@ const phpTask = (command, options = {}) => ({
|
|
|
10
13
|
task.output = t;
|
|
11
14
|
},
|
|
12
15
|
throwNonZeroCode: true,
|
|
13
|
-
magentoVersion
|
|
16
|
+
magentoVersion,
|
|
17
|
+
env: options.env
|
|
14
18
|
})
|
|
15
19
|
});
|
|
16
20
|
|
package/lib/util/run-php.js
CHANGED
|
@@ -10,6 +10,7 @@ const { getConfigFromMagentoVersion, defaultConfiguration } = require('../config
|
|
|
10
10
|
* @param {() => {}} options.callback
|
|
11
11
|
* @param {Boolean} options.throwNonZeroCode Throw if command return non 0 code.
|
|
12
12
|
* @param {String} options.magentoVersion Magento version for config
|
|
13
|
+
* @param {Record<string, string>} options.env Environment variables
|
|
13
14
|
*/
|
|
14
15
|
const runPhpCode = async (command, options = {}) => {
|
|
15
16
|
const {
|
|
@@ -17,7 +18,12 @@ const runPhpCode = async (command, options = {}) => {
|
|
|
17
18
|
magentoVersion = defaultConfiguration.magentoVersion
|
|
18
19
|
} = options;
|
|
19
20
|
const { php } = await getConfigFromMagentoVersion(magentoVersion);
|
|
20
|
-
|
|
21
|
+
let spawnCommand = `${php.binPath} -c ${php.iniPath} ${command}`;
|
|
22
|
+
if (options.env && Object.keys(options.env).length > 0) {
|
|
23
|
+
const env = Object.entries(options.env).map(([key, value]) => `${key}=${value}`).join(' ');
|
|
24
|
+
spawnCommand = `${env} ${spawnCommand}`;
|
|
25
|
+
}
|
|
26
|
+
const { code, result } = await execAsyncSpawn(spawnCommand, {
|
|
21
27
|
...options,
|
|
22
28
|
withCode: true
|
|
23
29
|
});
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Scripts and configuration used by CMA.",
|
|
4
4
|
"homepage": "https://docs.create-magento-app.com/",
|
|
5
5
|
"repository": "github:scandipwa/create-magento-app",
|
|
6
|
-
"version": "1.14.1-alpha.
|
|
6
|
+
"version": "1.14.1-alpha.4",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./typings/index.d.ts",
|
|
9
9
|
"license": "OSL-3.0",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"mysql",
|
|
52
52
|
"scandipwa"
|
|
53
53
|
],
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "41436e9871ef44477f79f93c751b5d7315de8187"
|
|
55
55
|
}
|
package/typings/context.d.ts
CHANGED
package/typings/index.d.ts
CHANGED
|
@@ -21,6 +21,20 @@ export interface NginxConfiguration extends ServiceWithVersion {
|
|
|
21
21
|
configTemplate: string
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
export interface VarnishConfiguration extends ServiceWithVersion {
|
|
25
|
+
/**
|
|
26
|
+
* Enable or disable Varnish in the project
|
|
27
|
+
*/
|
|
28
|
+
enabled: boolean
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Configuration file location
|
|
32
|
+
*
|
|
33
|
+
* @example ./my-varnish-config.vcl
|
|
34
|
+
*/
|
|
35
|
+
configTemplate: string
|
|
36
|
+
}
|
|
37
|
+
|
|
24
38
|
export interface PHPExtension extends Record<string, unknown> {
|
|
25
39
|
version?: string
|
|
26
40
|
/**
|
|
@@ -175,6 +189,11 @@ export interface CMAConfiguration {
|
|
|
175
189
|
* Composer configuration
|
|
176
190
|
*/
|
|
177
191
|
composer: ServiceWithVersion
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Varnish configuration
|
|
195
|
+
*/
|
|
196
|
+
varnish: VarnishConfiguration
|
|
178
197
|
}
|
|
179
198
|
/**
|
|
180
199
|
* Magento configuration
|