@scandipwa/magento-scripts 2.1.4 → 2.2.0-alpha.0
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 +24 -10
- package/lib/config/get-magento-version-config.js +4 -1
- package/lib/config/php-config.js +2 -1
- package/lib/config/services/composer/versions/composer-1.js +1 -1
- package/lib/config/services/composer/versions/composer-2.2.js +8 -0
- package/lib/config/services/composer/versions/composer-2.js +1 -1
- package/lib/config/services/composer/versions/index.js +2 -1
- package/lib/config/services/elasticsearch/versions/elasticsearch-8.4.js +4 -1
- package/lib/config/services/elasticsearch/versions/elasticsearch-8.5.js +4 -1
- package/lib/config/services/elasticsearch/versions/elasticsearch-8.7.js +14 -0
- package/lib/config/services/elasticsearch/versions/index.js +3 -1
- package/lib/config/services/mysql/versions/mysql-8.0.js +1 -1
- package/lib/config/services/php/default-php-env.js +6 -0
- package/lib/config/services/php/versions/php-7.2.js +3 -1
- package/lib/config/services/php/versions/php-7.3.js +3 -1
- package/lib/config/services/php/versions/php-7.4.js +3 -1
- package/lib/config/services/php/versions/php-8.1.js +3 -1
- package/lib/config/services/php/versions/php-8.2.js +3 -1
- package/lib/config/ssl-config.js +9 -0
- package/lib/config/templates/nginx.fastcgi_params.template +2 -2
- package/lib/config/templates/nginx.template.conf +19 -2
- package/lib/config/templates/ssl-terminator.template.conf +2 -6
- package/lib/config/versions/index.js +16 -33
- package/lib/config/versions/magento-2.2.10.js +1 -9
- package/lib/config/versions/magento-2.3.0.js +1 -9
- package/lib/config/versions/magento-2.3.1.js +1 -9
- package/lib/config/versions/magento-2.3.2-p1.js +1 -9
- package/lib/config/versions/magento-2.3.2-p2.js +1 -9
- package/lib/config/versions/magento-2.3.2.js +1 -9
- package/lib/config/versions/magento-2.3.3-p1.js +1 -9
- package/lib/config/versions/magento-2.3.3.js +1 -9
- package/lib/config/versions/magento-2.3.4-p1.js +1 -9
- package/lib/config/versions/magento-2.3.4-p2.js +1 -9
- package/lib/config/versions/magento-2.3.4.js +1 -9
- package/lib/config/versions/magento-2.3.5-p1.js +1 -9
- package/lib/config/versions/magento-2.3.5-p2.js +1 -9
- package/lib/config/versions/magento-2.3.5.js +1 -14
- package/lib/config/versions/magento-2.3.6-p1.js +1 -9
- package/lib/config/versions/magento-2.3.6.js +1 -9
- package/lib/config/versions/magento-2.3.7-p1.js +1 -9
- package/lib/config/versions/magento-2.3.7-p2.js +1 -9
- package/lib/config/versions/magento-2.3.7-p3.js +1 -9
- package/lib/config/versions/magento-2.3.7-p4.js +1 -9
- package/lib/config/versions/magento-2.3.7.js +1 -9
- package/lib/config/versions/magento-2.4.0-p1.js +1 -9
- package/lib/config/versions/magento-2.4.0.js +1 -9
- package/lib/config/versions/magento-2.4.1-p1.js +1 -9
- package/lib/config/versions/magento-2.4.1.js +1 -9
- package/lib/config/versions/magento-2.4.2-p1.js +2 -10
- package/lib/config/versions/magento-2.4.2-p2.js +2 -10
- package/lib/config/versions/magento-2.4.2.js +1 -9
- package/lib/config/versions/magento-2.4.3-p1.js +2 -10
- package/lib/config/versions/magento-2.4.3-p2.js +2 -10
- package/lib/config/versions/magento-2.4.3-p3.js +2 -10
- package/lib/config/versions/magento-2.4.3.js +2 -10
- package/lib/config/versions/magento-2.4.4-p1.js +4 -13
- package/lib/config/versions/magento-2.4.4-p2.js +4 -13
- package/lib/config/versions/magento-2.4.4-p3.js +4 -13
- package/lib/config/versions/magento-2.4.4-p4.js +2 -10
- package/lib/config/versions/magento-2.4.4-p5.js +39 -0
- package/lib/config/versions/magento-2.4.4-p6.js +39 -0
- package/lib/config/versions/magento-2.4.4.js +4 -13
- package/lib/config/versions/magento-2.4.5-p1.js +4 -13
- package/lib/config/versions/magento-2.4.5-p2.js +4 -13
- package/lib/config/versions/magento-2.4.5-p3.js +2 -10
- package/lib/config/versions/magento-2.4.5-p4.js +39 -0
- package/lib/config/versions/magento-2.4.5-p5.js +39 -0
- package/lib/config/versions/magento-2.4.5.js +3 -12
- package/lib/config/versions/magento-2.4.6-p1.js +2 -10
- package/lib/config/versions/magento-2.4.6-p2.js +39 -0
- package/lib/config/versions/magento-2.4.6-p3.js +39 -0
- package/lib/config/versions/magento-2.4.6.js +2 -10
- package/lib/config/versions/magento-2.4.7-beta2.js +39 -0
- package/lib/tasks/database/import-remote-db/ssh/database-dump-command.js +0 -2
- package/lib/tasks/database/import-remote-db/ssh/readymage.js +29 -28
- package/lib/tasks/docker/containers/container-api.d.ts +5 -0
- package/lib/tasks/docker/containers/container-api.js +4 -1
- package/lib/tasks/docker/project-image-builder.js +21 -0
- package/lib/tasks/file-system/create-nginx-config.js +7 -2
- package/lib/tasks/file-system/create-ssl-terminator-config.js +9 -7
- package/lib/tasks/magento/install-magento-project.js +10 -7
- package/lib/tasks/magento/setup-magento/configure-elasticsearch.js +1 -1
- package/lib/tasks/magento/setup-magento/index-products.js +41 -1
- package/lib/tasks/magento/setup-magento/index.js +4 -1
- package/lib/tasks/magento/setup-magento/set-base-url.js +121 -13
- package/lib/tasks/requirements/elasticsearch-version.js +62 -6
- package/lib/util/config-file-validator.js +60 -19
- package/lib/util/config-php-json.js +2 -0
- package/lib/util/database.js +83 -1
- package/lib/util/instance-metadata.js +16 -19
- package/lib/util/match-filesystem.js +1 -0
- package/lib/util/run-magento.js +1 -0
- package/package.json +2 -2
- package/tsconfig.json +2 -1
- package/typings/common.d.ts +53 -0
- package/typings/index.d.ts +55 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const sodium = require('../services/php/extensions/sodium')
|
|
2
|
+
const {
|
|
3
|
+
magento24PHPExtensionList
|
|
4
|
+
} = require('../magento/required-php-extensions')
|
|
5
|
+
const { php81 } = require('../services/php/versions')
|
|
6
|
+
const { sslTerminator } = require('../services/ssl-terminator')
|
|
7
|
+
const { varnish73 } = require('../services/varnish')
|
|
8
|
+
const { repo } = require('../services/php/base-repo')
|
|
9
|
+
const { nginx118 } = require('../services/nginx/versions')
|
|
10
|
+
const { composer22 } = require('../services/composer/versions')
|
|
11
|
+
const { maildev } = require('../services/maildev')
|
|
12
|
+
const { redis70 } = require('../services/redis')
|
|
13
|
+
const { mariadb106 } = require('../services/mariadb/versions')
|
|
14
|
+
const { elasticsearch85 } = require('../services/elasticsearch/versions')
|
|
15
|
+
const { mysql80 } = require('../services/mysql/versions')
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @type {import('../../../typings/common').MagentoVersionConfigurationFunction}
|
|
19
|
+
*/
|
|
20
|
+
module.exports = ({ templateDir }) => ({
|
|
21
|
+
magentoVersion: '2.4.6-p3',
|
|
22
|
+
isDefault: true,
|
|
23
|
+
configuration: {
|
|
24
|
+
php: php81({
|
|
25
|
+
templateDir,
|
|
26
|
+
extensions: { ...magento24PHPExtensionList, sodium },
|
|
27
|
+
baseImage: `${repo}:php-8.1-magento-2.4`
|
|
28
|
+
}),
|
|
29
|
+
nginx: nginx118({ templateDir }),
|
|
30
|
+
redis: redis70(),
|
|
31
|
+
mysql: mysql80(),
|
|
32
|
+
mariadb: mariadb106(),
|
|
33
|
+
elasticsearch: elasticsearch85(),
|
|
34
|
+
composer: composer22(),
|
|
35
|
+
varnish: varnish73({ templateDir }),
|
|
36
|
+
sslTerminator: sslTerminator({ templateDir }),
|
|
37
|
+
maildev: maildev()
|
|
38
|
+
}
|
|
39
|
+
})
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const { defaultMagentoConfig } = require('../magento-config')
|
|
2
1
|
const sodium = require('../services/php/extensions/sodium')
|
|
3
2
|
const {
|
|
4
3
|
magento24PHPExtensionList
|
|
@@ -16,13 +15,11 @@ const { elasticsearch84 } = require('../services/elasticsearch/versions')
|
|
|
16
15
|
const { mysql80 } = require('../services/mysql/versions')
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
|
-
* @
|
|
20
|
-
* @param {string} param0.templateDir
|
|
21
|
-
* @returns {import('../../../typings/index').CMAConfiguration & { magentoVersion: string, isDefault?: boolean }}
|
|
18
|
+
* @type {import('../../../typings/common').MagentoVersionConfigurationFunction}
|
|
22
19
|
*/
|
|
23
20
|
module.exports = ({ templateDir }) => ({
|
|
24
21
|
magentoVersion: '2.4.6',
|
|
25
|
-
isDefault:
|
|
22
|
+
isDefault: false,
|
|
26
23
|
configuration: {
|
|
27
24
|
php: php81({
|
|
28
25
|
templateDir,
|
|
@@ -38,10 +35,5 @@ module.exports = ({ templateDir }) => ({
|
|
|
38
35
|
varnish: varnish71({ templateDir }),
|
|
39
36
|
sslTerminator: sslTerminator({ templateDir }),
|
|
40
37
|
maildev: maildev()
|
|
41
|
-
},
|
|
42
|
-
magento: defaultMagentoConfig,
|
|
43
|
-
host: 'localhost',
|
|
44
|
-
ssl: {
|
|
45
|
-
enabled: false
|
|
46
38
|
}
|
|
47
39
|
})
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const sodium = require('../services/php/extensions/sodium')
|
|
2
|
+
const {
|
|
3
|
+
magento24PHPExtensionList
|
|
4
|
+
} = require('../magento/required-php-extensions')
|
|
5
|
+
const { php82 } = require('../services/php/versions')
|
|
6
|
+
const { sslTerminator } = require('../services/ssl-terminator')
|
|
7
|
+
const { varnish73 } = require('../services/varnish')
|
|
8
|
+
const { repo } = require('../services/php/base-repo')
|
|
9
|
+
const { nginx118 } = require('../services/nginx/versions')
|
|
10
|
+
const { composer22 } = require('../services/composer/versions')
|
|
11
|
+
const { maildev } = require('../services/maildev')
|
|
12
|
+
const { redis70 } = require('../services/redis')
|
|
13
|
+
const { mariadb106 } = require('../services/mariadb/versions')
|
|
14
|
+
const { elasticsearch87 } = require('../services/elasticsearch/versions')
|
|
15
|
+
const { mysql80 } = require('../services/mysql/versions')
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @type {import('../../../typings/common').MagentoVersionConfigurationFunction}
|
|
19
|
+
*/
|
|
20
|
+
module.exports = ({ templateDir }) => ({
|
|
21
|
+
magentoVersion: '2.4.7-beta2',
|
|
22
|
+
isDefault: false,
|
|
23
|
+
configuration: {
|
|
24
|
+
php: php82({
|
|
25
|
+
templateDir,
|
|
26
|
+
extensions: { ...magento24PHPExtensionList, sodium },
|
|
27
|
+
baseImage: `${repo}:php-8.2-magento-2.4`
|
|
28
|
+
}),
|
|
29
|
+
nginx: nginx118({ templateDir }),
|
|
30
|
+
redis: redis70(),
|
|
31
|
+
mysql: mysql80(),
|
|
32
|
+
mariadb: mariadb106(),
|
|
33
|
+
elasticsearch: elasticsearch87(),
|
|
34
|
+
composer: composer22(),
|
|
35
|
+
varnish: varnish73({ templateDir }),
|
|
36
|
+
sslTerminator: sslTerminator({ templateDir }),
|
|
37
|
+
maildev: maildev()
|
|
38
|
+
}
|
|
39
|
+
})
|
|
@@ -21,36 +21,37 @@ const readymageSSH = () => ({
|
|
|
21
21
|
task.output =
|
|
22
22
|
'Making remote database dump files without customers data...'
|
|
23
23
|
|
|
24
|
+
const firstCommand = [
|
|
25
|
+
...databaseDumpCommandWithOptions,
|
|
26
|
+
...[...orderTables, ...customerTables].map(
|
|
27
|
+
(table) => `--ignore-table=magento.${table}`
|
|
28
|
+
),
|
|
29
|
+
'--result-file=dump-0.sql'
|
|
30
|
+
].join(' ')
|
|
31
|
+
|
|
24
32
|
/**
|
|
25
33
|
* create dump without customers and orders
|
|
26
34
|
*/
|
|
27
|
-
await ssh.execCommand(
|
|
28
|
-
[
|
|
29
|
-
...databaseDumpCommandWithOptions,
|
|
30
|
-
...[...orderTables, ...customerTables].map(
|
|
31
|
-
(table) => `--ignore-table=magento.${table}`
|
|
32
|
-
),
|
|
33
|
-
'--result-file=dump-0.sql'
|
|
34
|
-
].join(' ')
|
|
35
|
-
)
|
|
35
|
+
await ssh.execCommand(firstCommand)
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
37
|
+
const secondCommand = [
|
|
38
|
+
...databaseDumpCommandWithOptions,
|
|
39
|
+
'--no-data',
|
|
40
|
+
'--result-file=dump-1.sql',
|
|
41
|
+
...[...orderTables, ...customerTables]
|
|
42
|
+
].join(' ')
|
|
43
|
+
|
|
44
|
+
await ssh.execCommand(secondCommand)
|
|
45
45
|
} else {
|
|
46
46
|
task.output =
|
|
47
47
|
'Making remote database dump file with customers data...'
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
|
|
49
|
+
const command = [
|
|
50
|
+
...databaseDumpCommandWithOptions,
|
|
51
|
+
'--result-file=dump.sql'
|
|
52
|
+
].join(' ')
|
|
53
|
+
|
|
54
|
+
await ssh.execCommand(command)
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
if (!noCompress) {
|
|
@@ -73,14 +74,14 @@ const readymageSSH = () => ({
|
|
|
73
74
|
task.output = 'Downloading dump files...'
|
|
74
75
|
if (noCompress) {
|
|
75
76
|
await execAsyncSpawn(
|
|
76
|
-
`scp ${sshConnectString}:${remotePwd}/dump-0.sql .`
|
|
77
|
+
`scp -O ${sshConnectString}:${remotePwd}/dump-0.sql .`
|
|
77
78
|
)
|
|
78
79
|
await execAsyncSpawn(
|
|
79
|
-
`scp ${sshConnectString}:${remotePwd}/dump-1.sql .`
|
|
80
|
+
`scp -O ${sshConnectString}:${remotePwd}/dump-1.sql .`
|
|
80
81
|
)
|
|
81
82
|
} else {
|
|
82
83
|
await execAsyncSpawn(
|
|
83
|
-
`scp ${sshConnectString}:${remotePwd}/dump.sql.gz .`
|
|
84
|
+
`scp -O ${sshConnectString}:${remotePwd}/dump.sql.gz .`
|
|
84
85
|
)
|
|
85
86
|
|
|
86
87
|
task.output = 'Extracting dump files...'
|
|
@@ -93,11 +94,11 @@ const readymageSSH = () => ({
|
|
|
93
94
|
task.output = 'Downloading dump file...'
|
|
94
95
|
if (noCompress) {
|
|
95
96
|
await execAsyncSpawn(
|
|
96
|
-
`scp ${sshConnectString}:${remotePwd}/dump.sql .`
|
|
97
|
+
`scp -o StrictHostKeyChecking=no -O ${sshConnectString}:${remotePwd}/dump.sql .`
|
|
97
98
|
)
|
|
98
99
|
} else {
|
|
99
100
|
await execAsyncSpawn(
|
|
100
|
-
`scp ${sshConnectString}:${remotePwd}/dump.sql.gz .`
|
|
101
|
+
`scp -o StrictHostKeyChecking=no -O ${sshConnectString}:${remotePwd}/dump.sql.gz .`
|
|
101
102
|
)
|
|
102
103
|
|
|
103
104
|
task.output = 'Extracting dump file...'
|
|
@@ -145,6 +145,11 @@ export interface ContainerRunOptions {
|
|
|
145
145
|
network?: string
|
|
146
146
|
|
|
147
147
|
expose?: (string | number)[]
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Memory option [docs](https://docs.docker.com/engine/reference/commandline/run/#memory)
|
|
151
|
+
*/
|
|
152
|
+
memory?: string
|
|
148
153
|
}
|
|
149
154
|
|
|
150
155
|
export function run<T>(
|
|
@@ -25,7 +25,8 @@ const runCommand = (options) => {
|
|
|
25
25
|
detach = true,
|
|
26
26
|
rm = false,
|
|
27
27
|
tty = false,
|
|
28
|
-
user
|
|
28
|
+
user,
|
|
29
|
+
memory
|
|
29
30
|
} = options
|
|
30
31
|
|
|
31
32
|
const detachArg = (detach && '-d') || ''
|
|
@@ -59,6 +60,7 @@ const runCommand = (options) => {
|
|
|
59
60
|
(tmpfs.length > 0 && tmpfs.map((t) => `--tmpfs=${t}`)) || ''
|
|
60
61
|
const userArg = (user && `--user=${user}`) || ''
|
|
61
62
|
const addHostArg = (addHost && `--add-host=${addHost}`) || ''
|
|
63
|
+
const memoryArg = (memory && `--memory=${memory}`) || ''
|
|
62
64
|
|
|
63
65
|
const dockerCommand = [
|
|
64
66
|
'docker',
|
|
@@ -80,6 +82,7 @@ const runCommand = (options) => {
|
|
|
80
82
|
tmpfsArg,
|
|
81
83
|
userArg,
|
|
82
84
|
addHostArg,
|
|
85
|
+
memoryArg,
|
|
83
86
|
image,
|
|
84
87
|
command
|
|
85
88
|
]
|
|
@@ -193,6 +193,27 @@ const buildDockerFileInstructions = async (ctx, { image, tag }) => {
|
|
|
193
193
|
})
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
+
if (ctx.config.overridenConfiguration.configuration.newRelic.enabled) {
|
|
197
|
+
const { agentVersion, licenseKey } =
|
|
198
|
+
ctx.config.overridenConfiguration.configuration.newRelic
|
|
199
|
+
|
|
200
|
+
// eslint-disable-next-line max-len
|
|
201
|
+
dockerFileInstructions.run('apk add --no-cache gcompat')
|
|
202
|
+
.run(`curl -L https://download.newrelic.com/php_agent/archive/${agentVersion}/newrelic-php5-${agentVersion}-linux.tar.gz | tar -C /tmp -zx \
|
|
203
|
+
&& export NR_INSTALL_USE_CP_NOT_LN=1 \
|
|
204
|
+
&& export NR_INSTALL_SILENT=1 \
|
|
205
|
+
&& /tmp/newrelic-php5-${agentVersion}-linux/newrelic-install install \
|
|
206
|
+
&& rm -rf /tmp/newrelic-php5-* /tmp/nrinstall*`)
|
|
207
|
+
.run(`sed -i -e "s/REPLACE_WITH_REAL_KEY/${licenseKey}/" \
|
|
208
|
+
-e "s/newrelic.appname[[:space:]]=[[:space:]].*/newrelic.appname=\\"${
|
|
209
|
+
ctx.config.baseConfig.prefix
|
|
210
|
+
}\\"/" \
|
|
211
|
+
-e '\\$anewrelic.daemon.address="${
|
|
212
|
+
ctx.isDockerDesktop ? 'host.docker.internal' : 'localhost'
|
|
213
|
+
}:31339"' \
|
|
214
|
+
\\$PHP_INI_DIR/conf.d/newrelic.ini`)
|
|
215
|
+
}
|
|
216
|
+
|
|
196
217
|
return dockerFileInstructions
|
|
197
218
|
}
|
|
198
219
|
|
|
@@ -15,13 +15,16 @@ const createNginxConfig = () => ({
|
|
|
15
15
|
} = ctx
|
|
16
16
|
|
|
17
17
|
const {
|
|
18
|
-
configuration: { nginx }
|
|
18
|
+
configuration: { nginx },
|
|
19
|
+
storeDomains
|
|
19
20
|
} = overridenConfiguration
|
|
20
21
|
|
|
21
22
|
const hostMachine = !isDockerDesktop
|
|
22
23
|
? '127.0.0.1'
|
|
23
24
|
: 'host.docker.internal'
|
|
24
25
|
const hostPort = !isDockerDesktop ? ports.app : 80
|
|
26
|
+
const useStoreDomainMapping =
|
|
27
|
+
storeDomains && Object.keys(storeDomains).length > 1
|
|
25
28
|
|
|
26
29
|
try {
|
|
27
30
|
await setConfigFile({
|
|
@@ -38,7 +41,9 @@ const createNginxConfig = () => ({
|
|
|
38
41
|
mageRoot: baseConfig.containerMagentoDir,
|
|
39
42
|
hostMachine,
|
|
40
43
|
hostPort,
|
|
41
|
-
config: overridenConfiguration
|
|
44
|
+
config: overridenConfiguration,
|
|
45
|
+
storeDomains,
|
|
46
|
+
useStoreDomainMapping
|
|
42
47
|
}
|
|
43
48
|
})
|
|
44
49
|
} catch (e) {
|
|
@@ -2,7 +2,6 @@ const path = require('path')
|
|
|
2
2
|
const fs = require('fs')
|
|
3
3
|
const setConfigFile = require('../../util/set-config')
|
|
4
4
|
const pathExists = require('../../util/path-exists')
|
|
5
|
-
const { isIpAddress } = require('../../util/ip')
|
|
6
5
|
const KnownError = require('../../errors/known-error')
|
|
7
6
|
const UnknownError = require('../../errors/unknown-error')
|
|
8
7
|
|
|
@@ -21,14 +20,19 @@ const createSSLTerminatorConfig = () => ({
|
|
|
21
20
|
|
|
22
21
|
const {
|
|
23
22
|
configuration: { sslTerminator },
|
|
24
|
-
ssl
|
|
25
|
-
host
|
|
23
|
+
ssl
|
|
26
24
|
} = overridenConfiguration
|
|
27
25
|
|
|
28
|
-
if (ssl.enabled) {
|
|
26
|
+
if (ssl.enabled && !ssl.external_provider) {
|
|
27
|
+
if (!ssl.ssl_certificate) {
|
|
28
|
+
throw new KnownError('ssl.ssl_certificate is not defined!')
|
|
29
|
+
}
|
|
29
30
|
if (!(await pathExists(ssl.ssl_certificate))) {
|
|
30
31
|
throw new KnownError('ssl.ssl_certificate file does not exist!')
|
|
31
32
|
}
|
|
33
|
+
if (!ssl.ssl_certificate_key) {
|
|
34
|
+
throw new KnownError('ssl.ssl_certificate_key is not defined!')
|
|
35
|
+
}
|
|
32
36
|
if (!(await pathExists(ssl.ssl_certificate_key))) {
|
|
33
37
|
throw new KnownError(
|
|
34
38
|
'ssl.ssl_certificate_key file does not exist!'
|
|
@@ -66,7 +70,6 @@ const createSSLTerminatorConfig = () => ({
|
|
|
66
70
|
)
|
|
67
71
|
}
|
|
68
72
|
|
|
69
|
-
const networkToBindTo = isIpAddress(host) ? host : '127.0.0.1'
|
|
70
73
|
const hostMachine = !isDockerDesktop
|
|
71
74
|
? '127.0.0.1'
|
|
72
75
|
: 'host.docker.internal'
|
|
@@ -87,7 +90,6 @@ const createSSLTerminatorConfig = () => ({
|
|
|
87
90
|
hostMachine,
|
|
88
91
|
hostPort,
|
|
89
92
|
config: overridenConfiguration,
|
|
90
|
-
networkToBindTo,
|
|
91
93
|
debug
|
|
92
94
|
}
|
|
93
95
|
})
|
|
@@ -111,7 +113,7 @@ const createSSLTerminatorConfig = () => ({
|
|
|
111
113
|
),
|
|
112
114
|
overwrite: true,
|
|
113
115
|
templateArgs: {
|
|
114
|
-
|
|
116
|
+
sslEnabled: ssl.enabled
|
|
115
117
|
}
|
|
116
118
|
})
|
|
117
119
|
} catch (e) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
2
|
const fs = require('fs')
|
|
3
|
+
const semver = require('semver')
|
|
3
4
|
const logger = require('@scandipwa/scandipwa-dev-utils/logger')
|
|
4
5
|
const runComposerCommand = require('../../util/run-composer')
|
|
5
6
|
const matchFilesystem = require('../../util/match-filesystem')
|
|
@@ -12,6 +13,8 @@ const { runPHPContainerCommand } = require('../php/php-container')
|
|
|
12
13
|
const magentoProductEnterpriseEdition = 'magento/product-enterprise-edition'
|
|
13
14
|
const magentoProductCommunityEdition = 'magento/product-community-edition'
|
|
14
15
|
|
|
16
|
+
const magentoRootUpdatePlugin = 'magento/composer-root-update-plugin'
|
|
17
|
+
|
|
15
18
|
/**
|
|
16
19
|
* @param {import('../../../typings/context').ListrContext} ctx
|
|
17
20
|
* @param {import('listr2').ListrTaskWrapper<import('../../../typings/context').ListrContext, any>} task
|
|
@@ -61,15 +64,15 @@ const adjustComposerJson = async (
|
|
|
61
64
|
)
|
|
62
65
|
}
|
|
63
66
|
|
|
67
|
+
const isPHP7 = semver.satisfies(ctx.phpVersion, '^7.x.x')
|
|
68
|
+
const rootUpdatePluginVersion = isPHP7 ? '^1' : '^2'
|
|
69
|
+
|
|
64
70
|
// if composer-root-update-plugin is not installed in composer, install it.
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
!composerData.require['magento/composer-root-update-plugin']
|
|
68
|
-
) {
|
|
69
|
-
task.output = 'Installing magento/composer-root-update-plugin!'
|
|
71
|
+
if (composerData && !composerData.require[magentoRootUpdatePlugin]) {
|
|
72
|
+
task.output = `Installing ${magentoRootUpdatePlugin}:${rootUpdatePluginVersion}!`
|
|
70
73
|
await runComposerCommand(
|
|
71
74
|
ctx,
|
|
72
|
-
|
|
75
|
+
`require ${magentoRootUpdatePlugin}:${rootUpdatePluginVersion}`,
|
|
73
76
|
{
|
|
74
77
|
callback: !ctx.verbose
|
|
75
78
|
? undefined
|
|
@@ -195,7 +198,7 @@ const installMagentoProject = () => ({
|
|
|
195
198
|
}
|
|
196
199
|
|
|
197
200
|
task.title = `Installing Magento ${magentoPackageVersion}`
|
|
198
|
-
task.output =
|
|
201
|
+
task.output = `Creating Magento ${magentoPackageVersion} project`
|
|
199
202
|
|
|
200
203
|
if (!(await pathExists(path.join(process.cwd(), 'composer.json')))) {
|
|
201
204
|
await createMagentoProject(ctx, task, {
|
|
@@ -92,7 +92,7 @@ const installElasticSearch8Module = () => ({
|
|
|
92
92
|
task: async (ctx, task) => {
|
|
93
93
|
await runComposerCommand(
|
|
94
94
|
ctx,
|
|
95
|
-
`require ${magentoModuleElasticSearch8} --with-all-dependencies`,
|
|
95
|
+
`require ${magentoModuleElasticSearch8} --update-with-all-dependencies`,
|
|
96
96
|
{
|
|
97
97
|
callback: !ctx.verbose
|
|
98
98
|
? undefined
|
|
@@ -1,10 +1,50 @@
|
|
|
1
1
|
const magentoTask = require('../../../util/magento-task')
|
|
2
|
+
// const runMagentoCommand = require('../../../util/run-magento')
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
6
|
*/
|
|
6
7
|
const indexProducts = () => ({
|
|
7
|
-
|
|
8
|
+
title: 'Index Products',
|
|
9
|
+
task: async (ctx, task) => {
|
|
10
|
+
const { databaseConnection } = ctx
|
|
11
|
+
/** @type {{ indexer_id: string, status: string }[][]} */
|
|
12
|
+
const data = await databaseConnection.query(
|
|
13
|
+
`select indexer_id,status from indexer_state;`
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
if (data.length === 0) {
|
|
17
|
+
task.skip('No indexers found')
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const invalidIndexers = data[0].filter(
|
|
22
|
+
({ status }) => status !== 'valid'
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const doYouWantToSkipIndexingPart = await task.prompt({
|
|
26
|
+
type: 'Select',
|
|
27
|
+
message: `Do you want to index the products? (There are ${invalidIndexers.length} invalid indexers, total indexers: ${data[0].length})\n`,
|
|
28
|
+
choices: [
|
|
29
|
+
{
|
|
30
|
+
name: 'index',
|
|
31
|
+
message: 'Yes, index them please'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: 'skip',
|
|
35
|
+
message:
|
|
36
|
+
'Skip, do not index them. I will do it later myself'
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
if (doYouWantToSkipIndexingPart === 'skip') {
|
|
42
|
+
task.skip()
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return task.newListr(magentoTask('index:reindex'))
|
|
47
|
+
},
|
|
8
48
|
retry: 2
|
|
9
49
|
})
|
|
10
50
|
|
|
@@ -1,34 +1,96 @@
|
|
|
1
|
-
const { updateTableValues } = require('../../../util/database')
|
|
1
|
+
const { updateTableValues, databaseQuery } = require('../../../util/database')
|
|
2
|
+
const KnownError = require('../../../errors/known-error')
|
|
2
3
|
|
|
3
4
|
/**
|
|
5
|
+
* @param {number} scopeId
|
|
6
|
+
* @param {string} code
|
|
7
|
+
* @param {string} host
|
|
4
8
|
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
5
9
|
*/
|
|
6
|
-
|
|
7
|
-
title:
|
|
10
|
+
const setBaseUrlForScope = (scopeId, code, host) => ({
|
|
11
|
+
title: `store code ${code} at ${host}`,
|
|
8
12
|
task: async (ctx, task) => {
|
|
9
13
|
const {
|
|
10
14
|
ports,
|
|
11
15
|
config: {
|
|
12
|
-
overridenConfiguration: {
|
|
13
|
-
}
|
|
14
|
-
databaseConnection
|
|
16
|
+
overridenConfiguration: { ssl }
|
|
17
|
+
}
|
|
15
18
|
} = ctx
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
|
|
20
|
+
if (host.startsWith('http://') || host.startsWith('https://')) {
|
|
21
|
+
throw new KnownError(
|
|
22
|
+
`Host ${host} should not contain protocol, only domain name. Check your configuration in cma.js!`
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
const location = `${host}${
|
|
19
|
-
|
|
20
|
-
?
|
|
21
|
-
:
|
|
27
|
+
ssl.enabled || ports.sslTerminator === 80
|
|
28
|
+
? ''
|
|
29
|
+
: `:${ports.sslTerminator}`
|
|
22
30
|
}/`
|
|
23
31
|
const secureLocation = `${host}/` // SSL will work only on port 443, so you cannot run multiple projects with SSL at the same time.
|
|
24
32
|
const httpUrl = `http://${location}`
|
|
25
33
|
const httpsUrl = `https://${secureLocation}`
|
|
34
|
+
const table = 'core_config_data'
|
|
35
|
+
const values = [
|
|
36
|
+
{
|
|
37
|
+
path: 'web/unsecure/base_url',
|
|
38
|
+
value: httpUrl
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
path: 'web/unsecure/base_link_url',
|
|
42
|
+
value: httpUrl
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
path: 'web/secure/base_url',
|
|
46
|
+
value: httpsUrl
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
path: 'web/secure/base_link_url',
|
|
50
|
+
value: httpsUrl
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
task.title = `store ${code} at ${ssl.enabled ? httpsUrl : httpUrl}`
|
|
55
|
+
|
|
56
|
+
await Promise.all(
|
|
57
|
+
values.map(async ({ path, value }) => {
|
|
58
|
+
await databaseQuery(
|
|
59
|
+
{
|
|
60
|
+
table,
|
|
61
|
+
where: [
|
|
62
|
+
['scope_id', '=', scopeId],
|
|
63
|
+
['path', '=', path]
|
|
64
|
+
],
|
|
65
|
+
data: {
|
|
66
|
+
value
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
ctx
|
|
70
|
+
)
|
|
71
|
+
})
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @returns {import('listr2').ListrTask<import('../../../../typings/context').ListrContext>}
|
|
78
|
+
*/
|
|
79
|
+
const setBaseUrl = () => ({
|
|
80
|
+
title: 'Setting base url for stores',
|
|
81
|
+
task: async (ctx, task) => {
|
|
82
|
+
const {
|
|
83
|
+
config: {
|
|
84
|
+
overridenConfiguration: { ssl, storeDomains }
|
|
85
|
+
},
|
|
86
|
+
databaseConnection
|
|
87
|
+
} = ctx
|
|
88
|
+
|
|
89
|
+
const enableSecureFrontend = ssl.enabled ? '1' : '0'
|
|
26
90
|
|
|
27
91
|
await updateTableValues(
|
|
28
92
|
'core_config_data',
|
|
29
93
|
[
|
|
30
|
-
{ path: 'web/unsecure/base_url', value: httpUrl },
|
|
31
|
-
{ path: 'web/secure/base_url', value: httpsUrl },
|
|
32
94
|
{
|
|
33
95
|
path: 'web/secure/use_in_frontend',
|
|
34
96
|
value: enableSecureFrontend
|
|
@@ -45,5 +107,51 @@ module.exports = () => ({
|
|
|
45
107
|
],
|
|
46
108
|
{ databaseConnection, task }
|
|
47
109
|
)
|
|
110
|
+
|
|
111
|
+
/** @type {{ website_id: number, code: string }[][]}} */
|
|
112
|
+
const [storeWebsites] = await databaseConnection.query(
|
|
113
|
+
`select * from store_website;`
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
if (!storeWebsites || storeWebsites.length === 0) {
|
|
117
|
+
throw new KnownError(
|
|
118
|
+
`No store websites found in database, store_website table is empty or does not exist`
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const storeDomainsWithMapping = Object.entries(storeDomains).reduce(
|
|
123
|
+
(acc, [key, val]) => {
|
|
124
|
+
const storeWebsite = storeWebsites.find(
|
|
125
|
+
({ code }) => code === key
|
|
126
|
+
)
|
|
127
|
+
if (storeWebsite) {
|
|
128
|
+
return {
|
|
129
|
+
...acc,
|
|
130
|
+
[storeWebsite.code]: {
|
|
131
|
+
websiteId: storeWebsite.website_id,
|
|
132
|
+
domain: val
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return acc
|
|
138
|
+
},
|
|
139
|
+
{}
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
return task.newListr(
|
|
143
|
+
Object.entries(storeDomainsWithMapping).map(
|
|
144
|
+
([storeCode, { websiteId, domain }]) =>
|
|
145
|
+
setBaseUrlForScope(websiteId, storeCode, domain)
|
|
146
|
+
),
|
|
147
|
+
{
|
|
148
|
+
concurrent: true,
|
|
149
|
+
rendererOptions: {
|
|
150
|
+
collapse: false
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
)
|
|
48
154
|
}
|
|
49
155
|
})
|
|
156
|
+
|
|
157
|
+
module.exports = setBaseUrl
|