@scandipwa/magento-scripts 2.4.2-alpha.1 → 2.4.2-alpha.2
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/config/docker.js +14 -18
- package/lib/tasks/docker/convert-mysql-to-mariadb.js +3 -13
- package/lib/tasks/docker/project-image-builder.js +10 -6
- package/lib/tasks/magento/setup-magento/configure-searchengine.js +4 -0
- package/lib/tasks/magento/setup-magento/enable-full-page-cache-with-varnish.js +30 -0
- package/lib/tasks/magento/setup-magento/index.js +2 -7
- package/lib/tasks/magento/setup-magento/migrate-database.js +21 -3
- package/lib/tasks/requirements/searchengine-version.js +60 -8
- package/lib/tasks/start.js +1 -10
- package/lib/tasks/theme/link-theme.js +2 -2
- package/package.json +2 -2
- package/lib/tasks/magento/setup-magento/adjust-full-page-cache.js +0 -42
- package/lib/tasks/requirements/elasticsearch-version.js +0 -87
- package/lib/tasks/requirements/opensearch-version.js +0 -71
package/lib/config/docker.js
CHANGED
|
@@ -73,11 +73,11 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
73
73
|
redis: {
|
|
74
74
|
name: `${prefix}_redis-data`
|
|
75
75
|
},
|
|
76
|
-
elasticsearch: {
|
|
77
|
-
name: `${prefix}_elasticsearch-data`
|
|
78
|
-
},
|
|
79
76
|
opensearch: {
|
|
80
|
-
name:
|
|
77
|
+
name:
|
|
78
|
+
searchengine === 'elasticsearch'
|
|
79
|
+
? `${prefix}_elasticsearch-data`
|
|
80
|
+
: `${prefix}_opensearch-data`
|
|
81
81
|
},
|
|
82
82
|
maildev: {
|
|
83
83
|
name: `${prefix}_maildev-data`
|
|
@@ -394,15 +394,13 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
394
394
|
ports: [`127.0.0.1:${ports.elasticsearch}:9200`],
|
|
395
395
|
forwardedPorts: [`127.0.0.1:${ports.elasticsearch}:9200`],
|
|
396
396
|
mountVolumes: [
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
target: '/usr/share/opensearch/data'
|
|
405
|
-
})
|
|
397
|
+
containerVolume({
|
|
398
|
+
source: volumes.opensearch.name,
|
|
399
|
+
target:
|
|
400
|
+
searchengine === 'elasticsearch'
|
|
401
|
+
? '/usr/share/elasticsearch/data'
|
|
402
|
+
: '/usr/share/opensearch/data'
|
|
403
|
+
})
|
|
406
404
|
],
|
|
407
405
|
env:
|
|
408
406
|
searchengine === 'elasticsearch'
|
|
@@ -426,9 +424,7 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
426
424
|
: elasticsearch.image
|
|
427
425
|
: opensearch.image
|
|
428
426
|
}`,
|
|
429
|
-
name: `${prefix}_${searchengine}
|
|
430
|
-
serviceReadyLog:
|
|
431
|
-
searchengine === 'elasticsearch' ? '"started"' : '] started'
|
|
427
|
+
name: `${prefix}_${searchengine}`
|
|
432
428
|
},
|
|
433
429
|
maildev: {
|
|
434
430
|
_: 'MailDev',
|
|
@@ -450,7 +446,7 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
450
446
|
mountVolumes: [
|
|
451
447
|
containerVolume({
|
|
452
448
|
source: volumes.maildev.name,
|
|
453
|
-
target: '/tmp
|
|
449
|
+
target: '/tmp'
|
|
454
450
|
})
|
|
455
451
|
],
|
|
456
452
|
env: {
|
|
@@ -460,7 +456,7 @@ module.exports = async (ctx, overridenConfiguration, baseConfig) => {
|
|
|
460
456
|
MAILDEV_WEB_PORT: isDockerDesktop
|
|
461
457
|
? '1080'
|
|
462
458
|
: ports.maildevWeb,
|
|
463
|
-
MAILDEV_MAIL_DIRECTORY: '/tmp
|
|
459
|
+
MAILDEV_MAIL_DIRECTORY: '/tmp'
|
|
464
460
|
},
|
|
465
461
|
name: `${prefix}_maildev`,
|
|
466
462
|
network: isDockerDesktop ? network.name : 'host',
|
|
@@ -24,7 +24,7 @@ const { createCacheFolder } = require('../cache')
|
|
|
24
24
|
const { getSystemConfigTask } = require('../../config/system-config')
|
|
25
25
|
const sleep = require('../../util/sleep')
|
|
26
26
|
const { setProjectConfigTask } = require('../project-config')
|
|
27
|
-
const
|
|
27
|
+
const checkSearchEngineVersion = require('../requirements/searchengine-version')
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
@@ -235,23 +235,13 @@ Please wait, this will take some time and do not restart the MySQL container unt
|
|
|
235
235
|
dockerNetwork.tasks.createNetwork(),
|
|
236
236
|
createVolumes(),
|
|
237
237
|
buildProjectImage(),
|
|
238
|
-
|
|
239
|
-
task: (ctx, subTask) =>
|
|
240
|
-
subTask.newListr(
|
|
241
|
-
[
|
|
242
|
-
checkPHPVersion(),
|
|
243
|
-
checkElasticSearchVersion()
|
|
244
|
-
],
|
|
245
|
-
{
|
|
246
|
-
concurrent: true
|
|
247
|
-
}
|
|
248
|
-
)
|
|
249
|
-
},
|
|
238
|
+
checkPHPVersion(),
|
|
250
239
|
getComposerVersionTask(),
|
|
251
240
|
prepareFileSystem(),
|
|
252
241
|
installMagentoProject(),
|
|
253
242
|
enableMagentoComposerPlugins(),
|
|
254
243
|
startServices(),
|
|
244
|
+
checkSearchEngineVersion(),
|
|
255
245
|
connectToDatabase(),
|
|
256
246
|
importDumpToDatabase(),
|
|
257
247
|
{
|
|
@@ -316,9 +316,11 @@ const buildProjectImage = () => ({
|
|
|
316
316
|
${dockerFileInstructions}
|
|
317
317
|
EOF`,
|
|
318
318
|
{
|
|
319
|
-
callback:
|
|
320
|
-
|
|
321
|
-
|
|
319
|
+
callback: !ctx.verbose
|
|
320
|
+
? undefined
|
|
321
|
+
: (t) => {
|
|
322
|
+
task.output = t
|
|
323
|
+
}
|
|
322
324
|
}
|
|
323
325
|
)
|
|
324
326
|
} catch (e) {
|
|
@@ -344,9 +346,11 @@ EOF`,
|
|
|
344
346
|
${debugImageInstructions}
|
|
345
347
|
EOF`,
|
|
346
348
|
{
|
|
347
|
-
callback:
|
|
348
|
-
|
|
349
|
-
|
|
349
|
+
callback: !ctx.verbose
|
|
350
|
+
? undefined
|
|
351
|
+
: (t) => {
|
|
352
|
+
task.output = t
|
|
353
|
+
}
|
|
350
354
|
}
|
|
351
355
|
)
|
|
352
356
|
} catch (e) {
|
|
@@ -167,6 +167,8 @@ const configureElasticSearchInDatabase = () => ({
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
)
|
|
170
|
+
|
|
171
|
+
task.title = `Using Elasticsearch ${ctx.elasticSearchVersion}`
|
|
170
172
|
}
|
|
171
173
|
})
|
|
172
174
|
|
|
@@ -356,6 +358,8 @@ const configureOpenSearchInDatabase = () => ({
|
|
|
356
358
|
}
|
|
357
359
|
}
|
|
358
360
|
)
|
|
361
|
+
|
|
362
|
+
task.title = `Using OpenSearch ${ctx.openSearchVersion}`
|
|
359
363
|
}
|
|
360
364
|
})
|
|
361
365
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const envPhpToJson = require('../../../util/env-php-json')
|
|
2
|
+
const magentoTask = require('../../../util/magento-task')
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
6
|
+
*/
|
|
7
|
+
const enableFullPageCacheWithVarnish = () => ({
|
|
8
|
+
skip: (ctx) => {
|
|
9
|
+
const { varnish } = ctx.config.overridenConfiguration.configuration
|
|
10
|
+
|
|
11
|
+
return !varnish.enabled
|
|
12
|
+
},
|
|
13
|
+
task: async (ctx, task) => {
|
|
14
|
+
const envData = await envPhpToJson(ctx)
|
|
15
|
+
if (
|
|
16
|
+
envData &&
|
|
17
|
+
envData.cache_types &&
|
|
18
|
+
typeof envData.cache_types.full_page === 'number' &&
|
|
19
|
+
envData.cache_types.full_page !== 1
|
|
20
|
+
) {
|
|
21
|
+
task.title =
|
|
22
|
+
'Enabling full_page cache in Magento (Varnish is enabled)'
|
|
23
|
+
return task.newListr(magentoTask('cache:enable full_page'))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
task.skip()
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
module.exports = enableFullPageCacheWithVarnish
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
const flushRedisConfig = require('./flush-redis-config')
|
|
2
|
-
const waitingForRedis = require('./waiting-for-redis')
|
|
3
2
|
const migrateDatabase = require('./migrate-database')
|
|
4
3
|
const createAdmin = require('./create-admin')
|
|
5
4
|
const setDeploymentMode = require('./set-deployment-mode')
|
|
6
5
|
const setBaseUrl = require('./set-base-url')
|
|
7
6
|
const disableMaintenanceMode = require('./disable-maintenance-mode')
|
|
8
|
-
const disable2fa = require('./disable-2fa')
|
|
9
7
|
const setUrlRewrite = require('./set-url-rewrite')
|
|
10
8
|
const increaseAdminSessionLifetime = require('./increase-admin-session-lifetime')
|
|
11
9
|
const magentoTask = require('../../../util/magento-task')
|
|
12
10
|
const urnHighlighter = require('./urn-highlighter')
|
|
13
|
-
const
|
|
11
|
+
const enableFullPageCacheWithVarnish = require('./enable-full-page-cache-with-varnish')
|
|
14
12
|
const updateEnvPHP = require('../../php/update-env-php')
|
|
15
13
|
const setMailConfig = require('./set-mail-config')
|
|
16
14
|
const { setupMagentoFilePermissions } = require('./setup-file-permissions')
|
|
@@ -27,14 +25,12 @@ const setupMagento = (options = {}) => ({
|
|
|
27
25
|
if (options.onlyInstallMagento) {
|
|
28
26
|
return task.newListr([
|
|
29
27
|
flushRedisConfig(),
|
|
30
|
-
waitingForRedis(),
|
|
31
28
|
migrateDatabase({ onlyInstallMagento: true })
|
|
32
29
|
])
|
|
33
30
|
}
|
|
34
31
|
|
|
35
32
|
return task.newListr(
|
|
36
33
|
[
|
|
37
|
-
waitingForRedis(),
|
|
38
34
|
setupMagentoFilePermissions(),
|
|
39
35
|
updateEnvPHP(),
|
|
40
36
|
migrateDatabase(),
|
|
@@ -60,9 +56,8 @@ const setupMagento = (options = {}) => ({
|
|
|
60
56
|
createAdmin(),
|
|
61
57
|
setDeploymentMode(),
|
|
62
58
|
disableMaintenanceMode(),
|
|
63
|
-
disable2fa(),
|
|
64
59
|
urnHighlighter(),
|
|
65
|
-
|
|
60
|
+
enableFullPageCacheWithVarnish(),
|
|
66
61
|
magentoTask('cache:flush')
|
|
67
62
|
],
|
|
68
63
|
{
|
|
@@ -9,6 +9,7 @@ const varnishConfigSetup = require('./varnish-config')
|
|
|
9
9
|
const pathExists = require('../../../util/path-exists')
|
|
10
10
|
const updateEnvPHP = require('../../php/update-env-php')
|
|
11
11
|
const UnknownError = require('../../../errors/unknown-error')
|
|
12
|
+
const checkSearchEngineVersion = require('../../requirements/searchengine-version')
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @param {Object} [options]
|
|
@@ -19,6 +20,7 @@ const migrateDatabase = (options = {}) => ({
|
|
|
19
20
|
title: 'Migrating database',
|
|
20
21
|
task: async (ctx, task) => {
|
|
21
22
|
const { databaseConnection } = ctx
|
|
23
|
+
const { varnish } = ctx.config.overridenConfiguration.configuration
|
|
22
24
|
|
|
23
25
|
const [[{ tableCount }]] = await databaseConnection.query(`
|
|
24
26
|
SELECT count(*) AS tableCount
|
|
@@ -44,12 +46,17 @@ const migrateDatabase = (options = {}) => ({
|
|
|
44
46
|
|
|
45
47
|
return task.newListr(
|
|
46
48
|
[
|
|
49
|
+
checkSearchEngineVersion(),
|
|
47
50
|
installMagento({ isDbEmpty: true }),
|
|
48
51
|
updateEnvPHP(),
|
|
49
52
|
varnishConfigSetup(),
|
|
50
53
|
configureSearchEngine(),
|
|
51
54
|
upgradeMagento(),
|
|
52
|
-
magentoTask(
|
|
55
|
+
magentoTask(
|
|
56
|
+
`cache:disable block_html layout${
|
|
57
|
+
!varnish.enabled ? ' full_page' : ''
|
|
58
|
+
}`
|
|
59
|
+
)
|
|
53
60
|
],
|
|
54
61
|
{
|
|
55
62
|
concurrent: false,
|
|
@@ -75,7 +82,11 @@ const migrateDatabase = (options = {}) => ({
|
|
|
75
82
|
ctx.isSetupUpgradeNeeded = false
|
|
76
83
|
// no setup is needed, but still to be sure configure ES
|
|
77
84
|
return task.newListr(
|
|
78
|
-
[
|
|
85
|
+
[
|
|
86
|
+
checkSearchEngineVersion(),
|
|
87
|
+
varnishConfigSetup(),
|
|
88
|
+
configureSearchEngine()
|
|
89
|
+
],
|
|
79
90
|
{
|
|
80
91
|
concurrent: false,
|
|
81
92
|
exitOnError: true,
|
|
@@ -90,6 +101,7 @@ const migrateDatabase = (options = {}) => ({
|
|
|
90
101
|
if (options.onlyInstallMagento) {
|
|
91
102
|
ctx.isSetupUpgradeNeeded = false
|
|
92
103
|
return task.newListr([
|
|
104
|
+
checkSearchEngineVersion(),
|
|
93
105
|
installMagentoProject(),
|
|
94
106
|
installMagento()
|
|
95
107
|
])
|
|
@@ -97,13 +109,18 @@ const migrateDatabase = (options = {}) => ({
|
|
|
97
109
|
|
|
98
110
|
return task.newListr(
|
|
99
111
|
[
|
|
112
|
+
checkSearchEngineVersion(),
|
|
100
113
|
installMagentoProject(),
|
|
101
114
|
installMagento(),
|
|
102
115
|
updateEnvPHP(),
|
|
103
116
|
varnishConfigSetup(),
|
|
104
117
|
configureSearchEngine(),
|
|
105
118
|
upgradeMagento(),
|
|
106
|
-
magentoTask(
|
|
119
|
+
magentoTask(
|
|
120
|
+
`cache:disable block_html layout${
|
|
121
|
+
!varnish.enabled ? ' full_page' : ''
|
|
122
|
+
}`
|
|
123
|
+
)
|
|
107
124
|
],
|
|
108
125
|
{
|
|
109
126
|
concurrent: false,
|
|
@@ -118,6 +135,7 @@ const migrateDatabase = (options = {}) => ({
|
|
|
118
135
|
case 2: {
|
|
119
136
|
return task.newListr(
|
|
120
137
|
[
|
|
138
|
+
checkSearchEngineVersion(),
|
|
121
139
|
varnishConfigSetup(),
|
|
122
140
|
configureSearchEngine(),
|
|
123
141
|
upgradeMagento()
|
|
@@ -1,18 +1,70 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const { request } = require('smol-request')
|
|
2
|
+
const UnknownError = require('../../errors/unknown-error')
|
|
3
|
+
const waitForLogs = require('../../util/wait-for-logs')
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
6
7
|
*/
|
|
7
8
|
const checkSearchEngineVersion = () => ({
|
|
8
9
|
task: async (ctx, task) => {
|
|
9
|
-
const {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const {
|
|
11
|
+
ports,
|
|
12
|
+
config: {
|
|
13
|
+
overridenConfiguration: {
|
|
14
|
+
configuration: { searchengine }
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
} = ctx
|
|
18
|
+
|
|
19
|
+
const { elasticsearch } = ctx.config.docker.getContainers(ports)
|
|
20
|
+
|
|
21
|
+
await waitForLogs({
|
|
22
|
+
containerName: elasticsearch.name,
|
|
23
|
+
matchText:
|
|
24
|
+
searchengine === 'elasticsearch' ? '"started"' : '] started'
|
|
25
|
+
})
|
|
14
26
|
|
|
15
|
-
|
|
27
|
+
try {
|
|
28
|
+
const response = await request(
|
|
29
|
+
`http://localhost:${ports.elasticsearch}/`,
|
|
30
|
+
{
|
|
31
|
+
method: 'GET',
|
|
32
|
+
responseType: 'json'
|
|
33
|
+
}
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
if (response.status !== 200) {
|
|
37
|
+
if (
|
|
38
|
+
ctx.config.overridenConfiguration.configuration
|
|
39
|
+
.searchengine === 'opensearch'
|
|
40
|
+
) {
|
|
41
|
+
throw new UnknownError(
|
|
42
|
+
`OpenSearch container is not running!\n\nStatus code: ${response.status}, Response: ${response.data.message}`
|
|
43
|
+
)
|
|
44
|
+
} else {
|
|
45
|
+
throw new UnknownError(
|
|
46
|
+
`ElasticSearch container is not running!\n\nStatus code: ${response.status}, Response: ${response.data.message}`
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const searchEngineVersion = response.data.version.number
|
|
52
|
+
if (searchengine === 'elasticsearch') {
|
|
53
|
+
ctx.elasticSearchVersion = searchEngineVersion
|
|
54
|
+
} else {
|
|
55
|
+
ctx.openSearchVersion = searchEngineVersion
|
|
56
|
+
}
|
|
57
|
+
} catch (e) {
|
|
58
|
+
if (searchengine === 'opensearch') {
|
|
59
|
+
throw new UnknownError(
|
|
60
|
+
`Cannot connect to OpenSearch container!\n\n${e.message}`
|
|
61
|
+
)
|
|
62
|
+
} else {
|
|
63
|
+
throw new UnknownError(
|
|
64
|
+
`Cannot connect to ElasticSearch container!\n\n${e.message}`
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
16
68
|
}
|
|
17
69
|
})
|
|
18
70
|
|
package/lib/tasks/start.js
CHANGED
|
@@ -38,7 +38,6 @@ const { setProjectConfigTask } = require('./project-config')
|
|
|
38
38
|
const {
|
|
39
39
|
convertComposerHomeToComposerCacheVolume
|
|
40
40
|
} = require('./docker/convert-composer-home-to-composer-cache-volume')
|
|
41
|
-
const checkSearchEngineVersion = require('./requirements/searchengine-version')
|
|
42
41
|
|
|
43
42
|
/**
|
|
44
43
|
* @returns {import('listr2').ListrTask<import('../../typings/context').ListrContext>}
|
|
@@ -129,15 +128,7 @@ const configureProject = () => ({
|
|
|
129
128
|
{ concurrent: true }
|
|
130
129
|
)
|
|
131
130
|
},
|
|
132
|
-
|
|
133
|
-
task: (ctx, subTask) =>
|
|
134
|
-
subTask.newListr(
|
|
135
|
-
[checkPHPVersion(), checkSearchEngineVersion()],
|
|
136
|
-
{
|
|
137
|
-
concurrent: true
|
|
138
|
-
}
|
|
139
|
-
)
|
|
140
|
-
},
|
|
131
|
+
checkPHPVersion(),
|
|
141
132
|
buildProjectImage(),
|
|
142
133
|
getComposerVersionTask(),
|
|
143
134
|
prepareFileSystem(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const symlinkTheme = require('./symlink-theme')
|
|
2
2
|
const installTheme = require('./install-theme')
|
|
3
|
-
const
|
|
3
|
+
const enableFullPageCacheWithVarnish = require('../magento/setup-magento/enable-full-page-cache-with-varnish')
|
|
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')
|
|
@@ -55,7 +55,7 @@ const linkTheme = () => ({
|
|
|
55
55
|
installTheme(theme),
|
|
56
56
|
updateEnvPHP(),
|
|
57
57
|
upgradeMagento(),
|
|
58
|
-
|
|
58
|
+
enableFullPageCacheWithVarnish(),
|
|
59
59
|
...(isPageBuilderInstalled && Number(isPagebuilderEnabled)
|
|
60
60
|
? [disablePageBuilder()]
|
|
61
61
|
: []),
|
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": "2.4.2-alpha.
|
|
6
|
+
"version": "2.4.2-alpha.2",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./typings/index.d.ts",
|
|
9
9
|
"license": "OSL-3.0",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"@types/node": "^20.14.11",
|
|
60
60
|
"@types/yargs": "^17.0.32"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "3b0fbecf1e4a2ac197e21a53b5433cafeb81eaae"
|
|
63
63
|
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
const envPhpToJson = require('../../../util/env-php-json')
|
|
2
|
-
const magentoTask = require('../../../util/magento-task')
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
6
|
-
*/
|
|
7
|
-
const disableFullPageCache = () => ({
|
|
8
|
-
title: 'Adjusting full_page cache setting',
|
|
9
|
-
task: async (ctx, task) => {
|
|
10
|
-
const envData = await envPhpToJson(ctx)
|
|
11
|
-
if (
|
|
12
|
-
envData &&
|
|
13
|
-
envData.cache_types &&
|
|
14
|
-
typeof envData.cache_types.full_page === 'number'
|
|
15
|
-
) {
|
|
16
|
-
if (
|
|
17
|
-
envData.cache_types.full_page !== 0 &&
|
|
18
|
-
!ctx.config.overridenConfiguration.configuration.varnish.enabled
|
|
19
|
-
) {
|
|
20
|
-
task.title = 'Disabling full_page cache in Magento'
|
|
21
|
-
return task.newListr(magentoTask('cache:disable full_page'))
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
ctx.config.overridenConfiguration.configuration.varnish
|
|
26
|
-
.enabled &&
|
|
27
|
-
envData.cache_types.full_page !== 1
|
|
28
|
-
) {
|
|
29
|
-
task.title =
|
|
30
|
-
'Enabling full_page cache in Magento (Varnish is enabled)'
|
|
31
|
-
return task.newListr(magentoTask('cache:enable full_page'))
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
task.skip('full_page cache type is not set in env.php')
|
|
35
|
-
return
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
task.skip()
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
module.exports = disableFullPageCache
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
const { getPort } = require('../../config/port-config')
|
|
2
|
-
const KnownError = require('../../errors/known-error')
|
|
3
|
-
const UnknownError = require('../../errors/unknown-error')
|
|
4
|
-
const { containerApi } = require('../docker/containers')
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
8
|
-
*/
|
|
9
|
-
const checkElasticSearchVersion = () => ({
|
|
10
|
-
title: 'Checking container ElasticSearch version',
|
|
11
|
-
task: async (ctx, task) => {
|
|
12
|
-
const { elasticsearch } =
|
|
13
|
-
ctx.config.overridenConfiguration.configuration
|
|
14
|
-
const { ports } = ctx
|
|
15
|
-
|
|
16
|
-
const { elasticsearch: elasticSearchContainer } =
|
|
17
|
-
ctx.config.docker.getContainers(ports)
|
|
18
|
-
|
|
19
|
-
let elasticSearchVersionResponse
|
|
20
|
-
|
|
21
|
-
const elasticSearchContainerRunning = await containerApi.ls({
|
|
22
|
-
filter: `name=${elasticSearchContainer.name}`,
|
|
23
|
-
formatToJSON: true
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
elasticSearchContainerRunning.length !== 0 &&
|
|
28
|
-
elasticSearchContainerRunning[0].State === 'running'
|
|
29
|
-
) {
|
|
30
|
-
elasticSearchVersionResponse = await containerApi.exec({
|
|
31
|
-
command: 'elasticsearch --version',
|
|
32
|
-
container: elasticSearchContainer.name
|
|
33
|
-
})
|
|
34
|
-
} else {
|
|
35
|
-
try {
|
|
36
|
-
const availableElasticSearchPort = await getPort(
|
|
37
|
-
ports.elasticsearch
|
|
38
|
-
)
|
|
39
|
-
elasticSearchVersionResponse = await containerApi.run({
|
|
40
|
-
...elasticsearch,
|
|
41
|
-
command: 'elasticsearch --version',
|
|
42
|
-
detach: false,
|
|
43
|
-
rm: true,
|
|
44
|
-
ports: [`127.0.0.1:${availableElasticSearchPort}:9200`],
|
|
45
|
-
memory: '2gb'
|
|
46
|
-
})
|
|
47
|
-
} catch (e) {
|
|
48
|
-
elasticSearchVersionResponse = e.message
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
ctx.cgroupVersion === 'v2' &&
|
|
54
|
-
elasticSearchVersionResponse.includes(
|
|
55
|
-
'Cannot invoke "jdk.internal.platform.CgroupInfo.getMountPoint()" because "anyController" is null'
|
|
56
|
-
)
|
|
57
|
-
) {
|
|
58
|
-
throw new KnownError(`ElasticSearch failed to start up due to a JVM bug with CGroup version 2.
|
|
59
|
-
Similar issue on StackOverflow: https://stackoverflow.com/q/71532170.
|
|
60
|
-
|
|
61
|
-
Right now is check if OpenSearch works with your version of Magento.
|
|
62
|
-
Follow the documentation: https://docs.create-magento-app.com/getting-started/config-file#searchengine-opensearch-elasticsearch
|
|
63
|
-
|
|
64
|
-
If it will not help, try updating ElasticSearch image version: https://docs.create-magento-app.com/getting-started/config-file#elasticsearch
|
|
65
|
-
`)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const elasticSearchVersionResponseResult =
|
|
69
|
-
elasticSearchVersionResponse.match(/Version:\s(\d+\.\d+\.\d+)/i)
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
elasticSearchVersionResponseResult &&
|
|
73
|
-
elasticSearchVersionResponseResult.length > 0
|
|
74
|
-
) {
|
|
75
|
-
const elasticSearchVersion = elasticSearchVersionResponseResult[1]
|
|
76
|
-
|
|
77
|
-
ctx.elasticSearchVersion = elasticSearchVersion
|
|
78
|
-
task.title = `Using ElasticSearch version ${elasticSearchVersion} in container`
|
|
79
|
-
} else {
|
|
80
|
-
throw new UnknownError(
|
|
81
|
-
`Cannot retrieve ElasticSearch Version!\n\n${elasticSearchVersionResponse}`
|
|
82
|
-
)
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
module.exports = checkElasticSearchVersion
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
const { getPort } = require('../../config/port-config')
|
|
2
|
-
const UnknownError = require('../../errors/unknown-error')
|
|
3
|
-
const { containerApi } = require('../docker/containers')
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @returns {import('listr2').ListrTask<import('../../../typings/context').ListrContext>}
|
|
7
|
-
*/
|
|
8
|
-
const checkOpenSearchVersion = () => ({
|
|
9
|
-
title: 'Checking container OpenSearch version',
|
|
10
|
-
task: async (ctx, task) => {
|
|
11
|
-
const { opensearch } = ctx.config.overridenConfiguration.configuration
|
|
12
|
-
const { ports } = ctx
|
|
13
|
-
|
|
14
|
-
const { elasticsearch: openSearchContainer } =
|
|
15
|
-
ctx.config.docker.getContainers(ports)
|
|
16
|
-
|
|
17
|
-
let openSearchVersionResponse
|
|
18
|
-
|
|
19
|
-
const openSearchContainerRunning = await containerApi.ls({
|
|
20
|
-
filter: `name=${openSearchContainer.name}`,
|
|
21
|
-
formatToJSON: true
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
openSearchContainerRunning.length !== 0 &&
|
|
26
|
-
openSearchContainerRunning[0].State === 'running'
|
|
27
|
-
) {
|
|
28
|
-
openSearchVersionResponse = await containerApi.exec({
|
|
29
|
-
command: 'opensearch --version',
|
|
30
|
-
container: openSearchContainer.name
|
|
31
|
-
})
|
|
32
|
-
} else {
|
|
33
|
-
try {
|
|
34
|
-
const availableOpenSearchPort = await getPort(
|
|
35
|
-
ports.elasticsearch
|
|
36
|
-
)
|
|
37
|
-
openSearchVersionResponse = await containerApi.run({
|
|
38
|
-
...opensearch,
|
|
39
|
-
command: 'opensearch --version',
|
|
40
|
-
detach: false,
|
|
41
|
-
rm: true,
|
|
42
|
-
ports: [`127.0.0.1:${availableOpenSearchPort}:9200`],
|
|
43
|
-
memory: '2gb'
|
|
44
|
-
})
|
|
45
|
-
} catch (e) {
|
|
46
|
-
openSearchVersionResponse = e.message
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const openSearchVersionResponseResult = openSearchVersionResponse.match(
|
|
51
|
-
/Version:\s(\d+\.\d+\.\d+)/i
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
if (
|
|
55
|
-
openSearchVersionResponseResult &&
|
|
56
|
-
openSearchVersionResponseResult.length > 0
|
|
57
|
-
) {
|
|
58
|
-
const openSearchVersion = openSearchVersionResponseResult[1]
|
|
59
|
-
|
|
60
|
-
ctx.openSearchVersion = openSearchVersion
|
|
61
|
-
task.title = `Using OpenSearch version ${openSearchVersion} in container`
|
|
62
|
-
} else {
|
|
63
|
-
throw new UnknownError(
|
|
64
|
-
`Cannot retrieve OpenSearch Version!\n\n${openSearchVersionResponse}`
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
exitOnError: false
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
module.exports = checkOpenSearchVersion
|