@scandipwa/magento-scripts 2.2.3 → 2.3.1
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/status.js +4 -4
- package/lib/config/docker.js +41 -17
- package/lib/config/services/opensearch/default-os-env.js +10 -0
- package/lib/config/services/opensearch/versions/index.js +11 -0
- package/lib/config/services/opensearch/versions/opensearch-1.2.js +15 -0
- package/lib/config/services/opensearch/versions/opensearch-1.3.js +15 -0
- package/lib/config/services/opensearch/versions/opensearch-2.12.js +14 -0
- package/lib/config/services/opensearch/versions/opensearch-2.5.js +15 -0
- package/lib/config/versions/index.js +2 -1
- package/lib/config/versions/magento-2.2.10.js +3 -1
- package/lib/config/versions/magento-2.3.0.js +3 -1
- package/lib/config/versions/magento-2.3.1.js +3 -1
- package/lib/config/versions/magento-2.3.2-p1.js +3 -1
- package/lib/config/versions/magento-2.3.2-p2.js +3 -1
- package/lib/config/versions/magento-2.3.2.js +3 -1
- package/lib/config/versions/magento-2.3.3-p1.js +3 -1
- package/lib/config/versions/magento-2.3.3.js +3 -1
- package/lib/config/versions/magento-2.3.4-p1.js +3 -1
- package/lib/config/versions/magento-2.3.4-p2.js +3 -1
- package/lib/config/versions/magento-2.3.4.js +3 -1
- package/lib/config/versions/magento-2.3.5-p1.js +3 -1
- package/lib/config/versions/magento-2.3.5-p2.js +3 -1
- package/lib/config/versions/magento-2.3.5.js +3 -1
- package/lib/config/versions/magento-2.3.6-p1.js +3 -1
- package/lib/config/versions/magento-2.3.6.js +3 -1
- package/lib/config/versions/magento-2.3.7-p1.js +3 -1
- package/lib/config/versions/magento-2.3.7-p2.js +3 -1
- package/lib/config/versions/magento-2.3.7-p3.js +3 -1
- package/lib/config/versions/magento-2.3.7-p4.js +3 -1
- package/lib/config/versions/magento-2.3.7.js +3 -1
- package/lib/config/versions/magento-2.4.0-p1.js +3 -1
- package/lib/config/versions/magento-2.4.0.js +3 -1
- package/lib/config/versions/magento-2.4.1-p1.js +3 -1
- package/lib/config/versions/magento-2.4.1.js +3 -1
- package/lib/config/versions/magento-2.4.2-p1.js +3 -1
- package/lib/config/versions/magento-2.4.2-p2.js +3 -1
- package/lib/config/versions/magento-2.4.2.js +3 -1
- package/lib/config/versions/magento-2.4.3-p1.js +3 -1
- package/lib/config/versions/magento-2.4.3-p2.js +3 -1
- package/lib/config/versions/magento-2.4.3-p3.js +3 -1
- package/lib/config/versions/magento-2.4.3.js +3 -1
- package/lib/config/versions/magento-2.4.4-p1.js +3 -1
- package/lib/config/versions/magento-2.4.4-p2.js +3 -1
- package/lib/config/versions/magento-2.4.4-p3.js +3 -1
- package/lib/config/versions/magento-2.4.4-p4.js +3 -1
- package/lib/config/versions/magento-2.4.4-p5.js +3 -1
- package/lib/config/versions/magento-2.4.4-p6.js +3 -1
- package/lib/config/versions/magento-2.4.4-p7.js +3 -1
- package/lib/config/versions/magento-2.4.4-p8.js +3 -1
- package/lib/config/versions/magento-2.4.4.js +3 -1
- package/lib/config/versions/magento-2.4.5-p1.js +3 -1
- package/lib/config/versions/magento-2.4.5-p2.js +3 -1
- package/lib/config/versions/magento-2.4.5-p3.js +3 -1
- package/lib/config/versions/magento-2.4.5-p4.js +3 -1
- package/lib/config/versions/magento-2.4.5-p5.js +3 -1
- package/lib/config/versions/magento-2.4.5-p6.js +3 -1
- package/lib/config/versions/magento-2.4.5-p7.js +3 -1
- package/lib/config/versions/magento-2.4.5.js +3 -1
- package/lib/config/versions/magento-2.4.6-p1.js +3 -1
- package/lib/config/versions/magento-2.4.6-p2.js +3 -1
- package/lib/config/versions/magento-2.4.6-p3.js +3 -1
- package/lib/config/versions/magento-2.4.6-p4.js +3 -1
- package/lib/config/versions/magento-2.4.6-p5.js +3 -1
- package/lib/config/versions/magento-2.4.6.js +3 -1
- package/lib/config/versions/magento-2.4.7-beta1.js +3 -1
- package/lib/config/versions/magento-2.4.7-beta2.js +3 -1
- package/lib/config/versions/magento-2.4.7-beta3.js +3 -1
- package/lib/config/versions/magento-2.4.7.js +3 -1
- package/lib/tasks/database/fix-db.js +1 -1
- package/lib/tasks/magento/setup-magento/configure-searchengine.js +392 -0
- package/lib/tasks/magento/setup-magento/install-magento.js +49 -4
- package/lib/tasks/magento/setup-magento/migrate-database.js +5 -5
- package/lib/tasks/magento/setup-magento/set-base-url.js +3 -1
- package/lib/tasks/requirements/opensearch-version.js +49 -0
- package/lib/tasks/requirements/searchengine-version.js +20 -0
- package/lib/tasks/start.js +2 -2
- package/lib/util/config-file-validator.js +11 -0
- package/lib/util/database.js +32 -1
- package/lib/util/resolve-configuration-with-overrides.js +6 -0
- package/package.json +2 -2
- package/typings/context.d.ts +2 -0
- package/typings/index.d.ts +26 -0
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +0 -131
package/lib/util/database.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Update table in **magento** database
|
|
3
3
|
* @param {String} table Table name
|
|
4
4
|
* @param {{ path: string, value: string | number | null }[]} values
|
|
5
|
-
* @param {{ databaseConnection: import('../../typings/context').ListrContext['databaseConnection'], task:
|
|
5
|
+
* @param {{ databaseConnection: import('../../typings/context').ListrContext['databaseConnection'], task: { skip(): void } }} param2
|
|
6
6
|
*/
|
|
7
7
|
const updateTableValues = async (
|
|
8
8
|
table,
|
|
@@ -78,6 +78,36 @@ const updateTableValues = async (
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Insert values into table in **magento** database
|
|
83
|
+
* @description Will not insert values that already exist in the table
|
|
84
|
+
* @param {string} table Table name
|
|
85
|
+
* @param {{ path: string, value: string | number | null }[]} values
|
|
86
|
+
* @param {{ databaseConnection: import('../../typings/context').ListrContext['databaseConnection'] }} param2
|
|
87
|
+
*/
|
|
88
|
+
const insertTableValues = async (table, values, { databaseConnection }) => {
|
|
89
|
+
const [rows] = await databaseConnection.query(`
|
|
90
|
+
SELECT * FROM ${table}
|
|
91
|
+
WHERE ${values.map((p) => `path = '${p.path}'`).join(' OR ')};
|
|
92
|
+
`)
|
|
93
|
+
|
|
94
|
+
if (rows.filter(Boolean).length !== values.length) {
|
|
95
|
+
const lostConfigs = values.filter(
|
|
96
|
+
(p) => !rows.some((row) => row.path === p.path)
|
|
97
|
+
)
|
|
98
|
+
for (const config of lostConfigs) {
|
|
99
|
+
await databaseConnection.query(
|
|
100
|
+
`
|
|
101
|
+
INSERT INTO ${table}
|
|
102
|
+
(scope, path, value)
|
|
103
|
+
VALUES ('default', ?, ?);
|
|
104
|
+
`,
|
|
105
|
+
[config.path, config.value]
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
81
111
|
/**
|
|
82
112
|
* @param {String} database
|
|
83
113
|
* @param {String} tableName
|
|
@@ -182,6 +212,7 @@ const databaseQuery = async (
|
|
|
182
212
|
|
|
183
213
|
module.exports = {
|
|
184
214
|
updateTableValues,
|
|
215
|
+
insertTableValues,
|
|
185
216
|
isTableExists,
|
|
186
217
|
databaseQuery
|
|
187
218
|
}
|
|
@@ -31,6 +31,12 @@ const resolveConfigurationWithOverrides = async (
|
|
|
31
31
|
configuration,
|
|
32
32
|
userConfiguration
|
|
33
33
|
)
|
|
34
|
+
// let chosenEngine = overridenConfiguration.configuration.searchengine.engine
|
|
35
|
+
// const newSearchEngineConfiguration = {
|
|
36
|
+
// ...overridenConfiguration.configuration.searchengine,
|
|
37
|
+
// ...overridenConfiguration.configuration[chosenEngine]
|
|
38
|
+
// }
|
|
39
|
+
// overridenConfiguration.configuration.searchengine = newSearchEngineConfiguration
|
|
34
40
|
|
|
35
41
|
return {
|
|
36
42
|
userConfiguration,
|
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.
|
|
6
|
+
"version": "2.3.1",
|
|
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.10.4",
|
|
60
60
|
"@types/yargs": "^17.0.13"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "5c776393a371d995d72d060200bc82be44f0fa1f"
|
|
63
63
|
}
|
package/typings/context.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export interface ListrContext {
|
|
|
24
24
|
composerVersion: string
|
|
25
25
|
phpVersion: string
|
|
26
26
|
elasticSearchVersion: string
|
|
27
|
+
openSearchVersion: string
|
|
27
28
|
port?: number
|
|
28
29
|
ports: {
|
|
29
30
|
app: number
|
|
@@ -32,6 +33,7 @@ export interface ListrContext {
|
|
|
32
33
|
mariadb: number
|
|
33
34
|
redis: number
|
|
34
35
|
elasticsearch: number
|
|
36
|
+
opensearch: number
|
|
35
37
|
varnish: number
|
|
36
38
|
sslTerminator: number
|
|
37
39
|
maildevSMTP: number
|
package/typings/index.d.ts
CHANGED
|
@@ -16,6 +16,13 @@ export interface ServiceWithImage {
|
|
|
16
16
|
image: string
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
export interface ServiceWithoutImage {
|
|
20
|
+
/**
|
|
21
|
+
* Service Docker image
|
|
22
|
+
*/
|
|
23
|
+
image: string
|
|
24
|
+
}
|
|
25
|
+
|
|
19
26
|
export interface MariaDBConfiguration extends ServiceWithImage {
|
|
20
27
|
/**
|
|
21
28
|
* Use MariaDB [optimizer-switch](https://mariadb.com/kb/en/optimizer-switch/) configuration.
|
|
@@ -50,6 +57,15 @@ export interface ElasticSearchConfiguration extends ServiceWithImage {
|
|
|
50
57
|
env: Record<string, unknown>
|
|
51
58
|
}
|
|
52
59
|
|
|
60
|
+
export interface OpenSearchSearchConfiguration extends ServiceWithoutImage {
|
|
61
|
+
/**
|
|
62
|
+
* Environmental variables used for OpenSearch container
|
|
63
|
+
*/
|
|
64
|
+
env: Record<string, unknown>
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type SearchEngineConfiguration = 'elasticsearch' | 'opensearch'
|
|
68
|
+
|
|
53
69
|
export interface VarnishConfiguration extends ServiceWithImage {
|
|
54
70
|
/**
|
|
55
71
|
* Enable or disable Varnish in the project
|
|
@@ -282,6 +298,16 @@ export interface CMAConfiguration {
|
|
|
282
298
|
*/
|
|
283
299
|
elasticsearch: ElasticSearchConfiguration
|
|
284
300
|
|
|
301
|
+
/**
|
|
302
|
+
* OpenSearch configuration
|
|
303
|
+
*/
|
|
304
|
+
opensearch: OpenSearchSearchConfiguration
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Search engine configuration
|
|
308
|
+
*/
|
|
309
|
+
searchengine?: SearchEngineConfiguration
|
|
310
|
+
|
|
285
311
|
/**
|
|
286
312
|
* Redis configuration
|
|
287
313
|
*/
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
const semver = require('semver')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const { updateTableValues, isTableExists } = require('../../../util/database')
|
|
4
|
-
const getJsonfileData = require('../../../util/get-jsonfile-data')
|
|
5
|
-
const runComposerCommand = require('../../../util/run-composer')
|
|
6
|
-
|
|
7
|
-
const magentoModuleElasticSearch8 = 'magento/module-elasticsearch-8'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @param {import('../../../../typings/context').ListrContext} ctx
|
|
11
|
-
*/
|
|
12
|
-
const isNeedToInstallElasticSearch8Module = async (ctx) => {
|
|
13
|
-
/**
|
|
14
|
-
* @type {{ packages: { name: string, version: string }[] } | null}
|
|
15
|
-
*/
|
|
16
|
-
const composerLockData = await getJsonfileData(
|
|
17
|
-
path.join(ctx.config.baseConfig.magentoDir, 'composer.lock')
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
if (!composerLockData) {
|
|
21
|
-
return true
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return !composerLockData.packages.some(
|
|
25
|
-
({ name }) => name === magentoModuleElasticSearch8
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
31
|
-
*/
|
|
32
|
-
const configureElasticSearchInDatabase = () => ({
|
|
33
|
-
title: 'Configuring Elasticsearch',
|
|
34
|
-
skip: async (ctx) => {
|
|
35
|
-
const isCoreConfigDataExists = await isTableExists(
|
|
36
|
-
'magento',
|
|
37
|
-
'core_config_data',
|
|
38
|
-
ctx
|
|
39
|
-
)
|
|
40
|
-
if (isCoreConfigDataExists) {
|
|
41
|
-
const elasticsearchConfig = await ctx.databaseConnection.query(
|
|
42
|
-
`SELECT path,value FROM core_config_data WHERE path='catalog/search/engine';`
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
if (elasticsearchConfig.length > 0) {
|
|
46
|
-
const { major: parsedESMajorVersion } = semver.parse(
|
|
47
|
-
ctx.elasticSearchVersion
|
|
48
|
-
) || { major: 7 }
|
|
49
|
-
const elasticsearchSearchEngine = `elasticsearch${parsedESMajorVersion}`
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
elasticsearchConfig[0].value === elasticsearchSearchEngine
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return false
|
|
58
|
-
},
|
|
59
|
-
task: async (ctx, task) => {
|
|
60
|
-
const { ports, databaseConnection, isDockerDesktop } = ctx
|
|
61
|
-
const hostMachine = !isDockerDesktop
|
|
62
|
-
? '127.0.0.1'
|
|
63
|
-
: 'host.docker.internal'
|
|
64
|
-
|
|
65
|
-
const { major: parsedESMajorVersion } = semver.parse(
|
|
66
|
-
ctx.elasticSearchVersion
|
|
67
|
-
) || { major: 7 }
|
|
68
|
-
|
|
69
|
-
const elasticsearchConfig = {
|
|
70
|
-
'catalog/search/engine': `elasticsearch${parsedESMajorVersion}`,
|
|
71
|
-
[`catalog/search/elasticsearch${parsedESMajorVersion}_server_hostname`]:
|
|
72
|
-
hostMachine,
|
|
73
|
-
[`catalog/search/elasticsearch${parsedESMajorVersion}_server_port`]: `${ports.elasticsearch}`
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
await updateTableValues(
|
|
77
|
-
'core_config_data',
|
|
78
|
-
Object.entries(elasticsearchConfig).map(([path, value]) => ({
|
|
79
|
-
path,
|
|
80
|
-
value
|
|
81
|
-
})),
|
|
82
|
-
{ databaseConnection, task }
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
89
|
-
*/
|
|
90
|
-
const installElasticSearch8Module = () => ({
|
|
91
|
-
title: 'Installing Magento ElasticSearch8 Module',
|
|
92
|
-
task: async (ctx, task) => {
|
|
93
|
-
await runComposerCommand(
|
|
94
|
-
ctx,
|
|
95
|
-
`require ${magentoModuleElasticSearch8} --update-with-all-dependencies`,
|
|
96
|
-
{
|
|
97
|
-
callback: !ctx.verbose
|
|
98
|
-
? undefined
|
|
99
|
-
: (t) => {
|
|
100
|
-
task.output = t
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
)
|
|
104
|
-
},
|
|
105
|
-
options: {
|
|
106
|
-
bottomBar: 10
|
|
107
|
-
}
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
112
|
-
*/
|
|
113
|
-
module.exports = () => ({
|
|
114
|
-
task: async (ctx, task) => {
|
|
115
|
-
const { major: parsedESMajorVersion } = semver.parse(
|
|
116
|
-
ctx.elasticSearchVersion
|
|
117
|
-
) || { major: 7 }
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
parsedESMajorVersion === 8 &&
|
|
121
|
-
(await isNeedToInstallElasticSearch8Module(ctx))
|
|
122
|
-
) {
|
|
123
|
-
return task.newListr([
|
|
124
|
-
installElasticSearch8Module(),
|
|
125
|
-
configureElasticSearchInDatabase()
|
|
126
|
-
])
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return task.newListr(configureElasticSearchInDatabase())
|
|
130
|
-
}
|
|
131
|
-
})
|