@scandipwa/magento-scripts 2.4.11 → 2.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +8 -0
- package/lib/commands/cleanup.js +5 -1
- package/lib/commands/cli.js +6 -2
- package/lib/commands/import-db.js +13 -0
- package/lib/commands/link.js +12 -6
- package/lib/commands/logs.js +7 -1
- package/lib/commands/start.js +7 -2
- package/lib/commands/status.js +46 -5
- package/lib/commands/stop.js +9 -5
- package/lib/config/check-configuration-file.js +7 -5
- package/lib/config/docker.js +2 -1
- package/lib/config/get-magento-version-config.js +2 -0
- package/lib/tasks/database/create-magento-user.js +26 -6
- package/lib/tasks/database/fix-db.js +6 -4
- package/lib/tasks/database/import-dump-to-database.js +55 -48
- package/lib/tasks/database/import-remote-db/ssh/index.js +22 -16
- package/lib/tasks/database/import-remote-db/ssh/regular-server.js +7 -5
- package/lib/tasks/execute.js +3 -6
- package/lib/tasks/import-dump.js +18 -16
- package/lib/tasks/magento/enable-magento-composer-plugins.js +7 -5
- package/lib/tasks/magento/setup-magento/index-products.js +17 -15
- package/lib/tasks/magento/setup-magento/install-magento.js +35 -31
- package/lib/tasks/requirements/composer-credentials.js +41 -24
- package/lib/tasks/requirements/docker/context.js +24 -22
- package/lib/tasks/requirements/docker/permissions.js +12 -10
- package/lib/tasks/requirements/docker/running-status.js +31 -21
- package/lib/tasks/start.js +1 -1
- package/lib/tasks/status/index.js +185 -4
- package/lib/util/execute-in-container.js +6 -12
- package/package.json +2 -2
- package/typings/context.d.ts +11 -0
package/lib/tasks/import-dump.js
CHANGED
|
@@ -51,22 +51,24 @@ const importDump = () => ({
|
|
|
51
51
|
},
|
|
52
52
|
task: async (subCtx, subTask) => {
|
|
53
53
|
const doYouWantToRunSetupOnEmptyDB =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
54
|
+
subCtx.nonInteractive
|
|
55
|
+
? 'skip'
|
|
56
|
+
: await subTask.prompt({
|
|
57
|
+
type: 'Select',
|
|
58
|
+
message: `We detected that Magento is not installed in database. Do you want to install Magento in database BEFORE importing database dump?`,
|
|
59
|
+
choices: [
|
|
60
|
+
{
|
|
61
|
+
name: 'try-install',
|
|
62
|
+
message:
|
|
63
|
+
'Try installing Magento before importing database'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'skip',
|
|
67
|
+
message:
|
|
68
|
+
'Skip installing Magento and import database dump right away!'
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
})
|
|
70
72
|
|
|
71
73
|
if (doYouWantToRunSetupOnEmptyDB === 'skip') {
|
|
72
74
|
subTask.skip()
|
|
@@ -180,16 +180,18 @@ const enableMagentoComposerPlugins = () => ({
|
|
|
180
180
|
})
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
const answerForEnablingPlugins =
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
const answerForEnablingPlugins = ctx.nonInteractive
|
|
184
|
+
? 'all-individual'
|
|
185
|
+
: await task.prompt({
|
|
186
|
+
type: 'Select',
|
|
187
|
+
message: `Composer 2.2 requires manually allowing composer-plugins to run.
|
|
186
188
|
Magento requires the following plugins to correctly operate:
|
|
187
189
|
|
|
188
190
|
${missingPluginsFromAllowPlugins.map((p) => logger.style.code(p)).join('\n')}
|
|
189
191
|
|
|
190
192
|
Do you want to enable them all or disable some of them?`,
|
|
191
|
-
|
|
192
|
-
|
|
193
|
+
choices: pluginOptions
|
|
194
|
+
})
|
|
193
195
|
|
|
194
196
|
switch (answerForEnablingPlugins.toLowerCase()) {
|
|
195
197
|
case 'all': {
|
|
@@ -22,21 +22,23 @@ const indexProducts = () => ({
|
|
|
22
22
|
({ status }) => status !== 'valid'
|
|
23
23
|
)
|
|
24
24
|
|
|
25
|
-
const doYouWantToSkipIndexingPart =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
const doYouWantToSkipIndexingPart = ctx.nonInteractive
|
|
26
|
+
? 'index'
|
|
27
|
+
: await task.prompt({
|
|
28
|
+
type: 'Select',
|
|
29
|
+
message: `Do you want to index the products? (There are ${invalidIndexers.length} invalid indexers, total indexers: ${data[0].length})\n`,
|
|
30
|
+
choices: [
|
|
31
|
+
{
|
|
32
|
+
name: 'index',
|
|
33
|
+
message: 'Yes, index them please'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'skip',
|
|
37
|
+
message:
|
|
38
|
+
'Skip, do not index them. I will do it later myself'
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
})
|
|
40
42
|
|
|
41
43
|
if (doYouWantToSkipIndexingPart === 'skip') {
|
|
42
44
|
task.skip()
|
|
@@ -51,26 +51,28 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
51
51
|
response && response.length > 0 && response[0]
|
|
52
52
|
|
|
53
53
|
if (usersWithUsernameAdmin && usersWithUsernameAdmin.length > 0) {
|
|
54
|
-
const confirmDeleteAdminUsers =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
const confirmDeleteAdminUsers = ctx.nonInteractive
|
|
55
|
+
? 'delete-all'
|
|
56
|
+
: await task.prompt({
|
|
57
|
+
type: 'Select',
|
|
58
|
+
message: `In order to install Magento in database you will need to delete admin user with username ${logger.style.command(
|
|
59
|
+
'admin'
|
|
60
|
+
)}`,
|
|
61
|
+
choices: [
|
|
62
|
+
{
|
|
63
|
+
name: 'delete-all',
|
|
64
|
+
message: `Delete all admin users (${logger.style.code(
|
|
65
|
+
'Recommended'
|
|
66
|
+
)})`
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'delete-only-admin',
|
|
70
|
+
message: `Delete only admin user with ${logger.style.command(
|
|
71
|
+
'admin'
|
|
72
|
+
)} username`
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
})
|
|
74
76
|
|
|
75
77
|
await databaseConnection.query('SET FOREIGN_KEY_CHECKS = 0;')
|
|
76
78
|
|
|
@@ -183,7 +185,7 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
183
185
|
--cache-backend='redis' \
|
|
184
186
|
--cache-backend-redis-server='${hostMachine}' \
|
|
185
187
|
--cache-backend-redis-port='${ports.redis}' \
|
|
186
|
-
--cache-backend-redis-db='0'
|
|
188
|
+
--cache-backend-redis-db='0' \
|
|
187
189
|
--db-host='${hostMachine}:${ports.mariadb}' \
|
|
188
190
|
--db-name='${defaultMagentoDatabase}' \
|
|
189
191
|
--db-user='${defaultMagentoUser.user}' \
|
|
@@ -219,21 +221,23 @@ const installMagento = ({ isDbEmpty = false } = {}) => ({
|
|
|
219
221
|
)
|
|
220
222
|
)
|
|
221
223
|
) {
|
|
222
|
-
const confirmToWipeEnvPhp =
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
224
|
+
const confirmToWipeEnvPhp = ctx.nonInteractive
|
|
225
|
+
? true
|
|
226
|
+
: await task.prompt({
|
|
227
|
+
type: 'Confirm',
|
|
228
|
+
message: `We detected that your encryption key in ${logger.style.file(
|
|
229
|
+
'app/etc/env.php'
|
|
230
|
+
)} file is not accepted by Magento installer.
|
|
227
231
|
To fix this issue we will need to ${logger.style.misc(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
+
'DELETE'
|
|
233
|
+
)} ${logger.style.file(
|
|
234
|
+
'app/etc/env.php'
|
|
235
|
+
)} file. It will be recreated but existing encryption key but if you any custom configuration in it will be lost.
|
|
232
236
|
|
|
233
237
|
Without this you will not be able to install Magento at this moment.
|
|
234
238
|
|
|
235
239
|
Do you want to continue?`
|
|
236
|
-
|
|
240
|
+
})
|
|
237
241
|
|
|
238
242
|
if (confirmToWipeEnvPhp) {
|
|
239
243
|
try {
|
|
@@ -209,23 +209,25 @@ const checkComposerCredentials = () => ({
|
|
|
209
209
|
|
|
210
210
|
if (composerAuthInRcFile) {
|
|
211
211
|
doConfigure = false
|
|
212
|
-
const loadCredentialsFrom =
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
212
|
+
const loadCredentialsFrom = ctx.nonInteractive
|
|
213
|
+
? true
|
|
214
|
+
: await task.prompt({
|
|
215
|
+
type: 'Confirm',
|
|
216
|
+
message: `We detected that you have ${logger.style.misc(
|
|
217
|
+
'COMPOSER_AUTH'
|
|
218
|
+
)} environment variable set in ${logger.style.file(
|
|
219
|
+
shellConfigFilePath
|
|
220
|
+
)} file,
|
|
219
221
|
but we do not see this variable inside ${logger.style.code(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
+
'magento-scripts'
|
|
223
|
+
)} process.
|
|
222
224
|
|
|
223
225
|
${logger.style.misc(
|
|
224
226
|
"! Don't forget to reload your shell after process is finished !"
|
|
225
227
|
)}
|
|
226
228
|
|
|
227
229
|
Would you like to load them now?`
|
|
228
|
-
|
|
230
|
+
})
|
|
229
231
|
|
|
230
232
|
if (loadCredentialsFrom) {
|
|
231
233
|
const credentialsLine = lines.find((line) =>
|
|
@@ -249,6 +251,19 @@ Would you like to load them now?`
|
|
|
249
251
|
}
|
|
250
252
|
|
|
251
253
|
if (doConfigure) {
|
|
254
|
+
if (ctx.nonInteractive) {
|
|
255
|
+
throw new KnownError(
|
|
256
|
+
`Composer credentials are required but were not found in ${logger.style.misc(
|
|
257
|
+
'$COMPOSER_AUTH'
|
|
258
|
+
)} or ${logger.style.file('./auth.json')}.
|
|
259
|
+
|
|
260
|
+
Provide them non-interactively by setting the ${logger.style.misc(
|
|
261
|
+
'$COMPOSER_AUTH'
|
|
262
|
+
)} environment variable or by creating an ${logger.style.file(
|
|
263
|
+
'./auth.json'
|
|
264
|
+
)} file, then run the command again.`
|
|
265
|
+
)
|
|
266
|
+
}
|
|
252
267
|
return task.newListr(configureComposerCredentials())
|
|
253
268
|
}
|
|
254
269
|
}
|
|
@@ -306,20 +321,22 @@ Do you want to remove them now? File will be overwritten.`
|
|
|
306
321
|
: null
|
|
307
322
|
|
|
308
323
|
if (message) {
|
|
309
|
-
const response =
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
324
|
+
const response = ctx.nonInteractive
|
|
325
|
+
? 'skip'
|
|
326
|
+
: await task.prompt({
|
|
327
|
+
message,
|
|
328
|
+
type: 'Select',
|
|
329
|
+
choices: [
|
|
330
|
+
{
|
|
331
|
+
name: 'overwrite',
|
|
332
|
+
message: 'Yes, please!'
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
name: 'skip',
|
|
336
|
+
message: "No, I know what I'm doing"
|
|
337
|
+
}
|
|
338
|
+
]
|
|
339
|
+
})
|
|
323
340
|
|
|
324
341
|
if (response === 'overwrite') {
|
|
325
342
|
if (repoMagentoCredentials.username) {
|
|
@@ -48,29 +48,31 @@ const checkDockerDesktopContext = () => ({
|
|
|
48
48
|
return
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
const confirmContextChange =
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
51
|
+
const confirmContextChange = ctx.nonInteractive
|
|
52
|
+
? 'no'
|
|
53
|
+
: await task.prompt({
|
|
54
|
+
type: 'Select',
|
|
55
|
+
message: `Do you want to change current Docker Desktop context (${logger.style.code(
|
|
56
|
+
currentlyUsedContext.Name
|
|
57
|
+
)}) to ${logger.style.code('default')}?`,
|
|
58
|
+
choices: [
|
|
59
|
+
{
|
|
60
|
+
name: 'yes',
|
|
61
|
+
message: 'Yes'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: 'no',
|
|
65
|
+
message:
|
|
66
|
+
"No, I don't know what this means, but you can ask again on next start."
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'skip',
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
message:
|
|
72
|
+
"I do know what this means and I DON'T want to change context for Docker. Also, save this answer to never ask again."
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
})
|
|
74
76
|
|
|
75
77
|
if (confirmContextChange === 'skip') {
|
|
76
78
|
cmaGlobalConfig.set(
|
|
@@ -21,22 +21,24 @@ const checkDockerSocketPermissions = () => ({
|
|
|
21
21
|
} catch (e) {
|
|
22
22
|
// check for permission
|
|
23
23
|
if (Math.abs(e.errno) === Math.abs(os.constants.errno.EACCES)) {
|
|
24
|
-
const confirmPrompt =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
const confirmPrompt = ctx.nonInteractive
|
|
25
|
+
? false
|
|
26
|
+
: await task.prompt({
|
|
27
|
+
type: 'Confirm',
|
|
28
|
+
message: `We detected that your Docker socket, located in ${logger.style.file(
|
|
29
|
+
dockerSocketPath
|
|
30
|
+
)}, have permissions set, that prevents user (${logger.style.misc(
|
|
31
|
+
os.userInfo().username
|
|
32
|
+
)}) from accessing it.
|
|
31
33
|
|
|
32
34
|
We can fix it by running the following command: ${logger.style.command(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
fixCommand
|
|
36
|
+
)}
|
|
35
37
|
|
|
36
38
|
Would you like to fix this permission issue?
|
|
37
39
|
|
|
38
40
|
Otherwise installation will likely fail.`
|
|
39
|
-
|
|
41
|
+
})
|
|
40
42
|
|
|
41
43
|
if (confirmPrompt) {
|
|
42
44
|
return task.newListr(executeSudoCommand(fixCommand))
|
|
@@ -61,11 +61,13 @@ const checkDockerStatusMacOS = () => ({
|
|
|
61
61
|
result.includes('Is the docker daemon running?') ||
|
|
62
62
|
result.includes('docker: command not found')
|
|
63
63
|
) {
|
|
64
|
-
const dockerOpenAppConfirmation =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
const dockerOpenAppConfirmation = ctx.nonInteractive
|
|
65
|
+
? false
|
|
66
|
+
: await task.prompt({
|
|
67
|
+
type: 'Confirm',
|
|
68
|
+
message:
|
|
69
|
+
'Looks like Docker is not running, would you like us to open a Docker for Mac application and wait for it to start up?'
|
|
70
|
+
})
|
|
69
71
|
|
|
70
72
|
if (
|
|
71
73
|
dockerOpenAppConfirmation &&
|
|
@@ -136,12 +138,14 @@ const checkDockerStatusLinux = () => ({
|
|
|
136
138
|
|
|
137
139
|
if (engine.exists) {
|
|
138
140
|
if (!engine.isEnabled && !engine.isRunning) {
|
|
139
|
-
const dockerStartConfirmation =
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
const dockerStartConfirmation = ctx.nonInteractive
|
|
142
|
+
? false
|
|
143
|
+
: await task.prompt({
|
|
144
|
+
type: 'Confirm',
|
|
145
|
+
message: `Looks like Docker Engine is not enabled and not running, would you like to enable and run it?
|
|
142
146
|
|
|
143
147
|
This action requires root privileges.`
|
|
144
|
-
|
|
148
|
+
})
|
|
145
149
|
|
|
146
150
|
if (dockerStartConfirmation) {
|
|
147
151
|
await engine.service.enableAndStart()
|
|
@@ -150,12 +154,14 @@ const checkDockerStatusLinux = () => ({
|
|
|
150
154
|
}
|
|
151
155
|
task.skip('User skipped running Docker')
|
|
152
156
|
} else if (!engine.isRunning) {
|
|
153
|
-
const dockerStartConfirmation =
|
|
154
|
-
|
|
155
|
-
|
|
157
|
+
const dockerStartConfirmation = ctx.nonInteractive
|
|
158
|
+
? false
|
|
159
|
+
: await task.prompt({
|
|
160
|
+
type: 'Confirm',
|
|
161
|
+
message: `Looks like Docker Engine is not running, would you like to run it?
|
|
156
162
|
|
|
157
163
|
This action requires root privileges.`
|
|
158
|
-
|
|
164
|
+
})
|
|
159
165
|
|
|
160
166
|
if (dockerStartConfirmation) {
|
|
161
167
|
await engine.service.start()
|
|
@@ -166,12 +172,14 @@ const checkDockerStatusLinux = () => ({
|
|
|
166
172
|
}
|
|
167
173
|
} else if (desktop.exists) {
|
|
168
174
|
if (!desktop.isEnabled && !desktop.isRunning) {
|
|
169
|
-
const dockerStartConfirmation =
|
|
170
|
-
|
|
171
|
-
|
|
175
|
+
const dockerStartConfirmation = ctx.nonInteractive
|
|
176
|
+
? false
|
|
177
|
+
: await task.prompt({
|
|
178
|
+
type: 'Confirm',
|
|
179
|
+
message: `Looks like Docker Desktop is not enabled and not running, would you like to enable and run it?
|
|
172
180
|
|
|
173
181
|
This action requires root privileges.`
|
|
174
|
-
|
|
182
|
+
})
|
|
175
183
|
|
|
176
184
|
if (dockerStartConfirmation) {
|
|
177
185
|
await desktop.service.enableAndStart()
|
|
@@ -180,12 +188,14 @@ const checkDockerStatusLinux = () => ({
|
|
|
180
188
|
}
|
|
181
189
|
task.skip('User skipped running Docker')
|
|
182
190
|
} else if (!desktop.isRunning) {
|
|
183
|
-
const dockerStartConfirmation =
|
|
184
|
-
|
|
185
|
-
|
|
191
|
+
const dockerStartConfirmation = ctx.nonInteractive
|
|
192
|
+
? false
|
|
193
|
+
: await task.prompt({
|
|
194
|
+
type: 'Confirm',
|
|
195
|
+
message: `Looks like Docker Desktop is not running, would you like to run it?
|
|
186
196
|
|
|
187
197
|
This action requires root privileges.`
|
|
188
|
-
|
|
198
|
+
})
|
|
189
199
|
|
|
190
200
|
if (dockerStartConfirmation) {
|
|
191
201
|
await desktop.service.start()
|