@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.
@@ -51,22 +51,24 @@ const importDump = () => ({
51
51
  },
52
52
  task: async (subCtx, subTask) => {
53
53
  const doYouWantToRunSetupOnEmptyDB =
54
- await subTask.prompt({
55
- type: 'Select',
56
- message: `We detected that Magento is not installed in database. Do you want to install Magento in database BEFORE importing database dump?`,
57
- choices: [
58
- {
59
- name: 'try-install',
60
- message:
61
- 'Try installing Magento before importing database'
62
- },
63
- {
64
- name: 'skip',
65
- message:
66
- 'Skip installing Magento and import database dump right away!'
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 = await task.prompt({
184
- type: 'Select',
185
- message: `Composer 2.2 requires manually allowing composer-plugins to run.
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
- choices: pluginOptions
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 = 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
- })
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 = await task.prompt({
55
- type: 'Select',
56
- message: `In order to install Magento in database you will need to delete admin user with username ${logger.style.command(
57
- 'admin'
58
- )}`,
59
- choices: [
60
- {
61
- name: 'delete-all',
62
- message: `Delete all admin users (${logger.style.code(
63
- 'Recommended'
64
- )})`
65
- },
66
- {
67
- name: 'delete-only-admin',
68
- message: `Delete only admin user with ${logger.style.command(
69
- 'admin'
70
- )} username`
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't \
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 = await task.prompt({
223
- type: 'Confirm',
224
- message: `We detected that your encryption key in ${logger.style.file(
225
- 'app/etc/env.php'
226
- )} file is not accepted by Magento installer.
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
- 'DELETE'
229
- )} ${logger.style.file(
230
- 'app/etc/env.php'
231
- )} file. It will be recreated but existing encryption key but if you any custom configuration in it will be lost.
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 = await task.prompt({
213
- type: 'Confirm',
214
- message: `We detected that you have ${logger.style.misc(
215
- 'COMPOSER_AUTH'
216
- )} environment variable set in ${logger.style.file(
217
- shellConfigFilePath
218
- )} file,
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
- 'magento-scripts'
221
- )} process.
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 = await task.prompt({
310
- message,
311
- type: 'Select',
312
- choices: [
313
- {
314
- name: 'overwrite',
315
- message: 'Yes, please!'
316
- },
317
- {
318
- name: 'skip',
319
- message: "No, I know what I'm doing"
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 = await task.prompt({
52
- type: 'Select',
53
- message: `Do you want to change current Docker Desktop context (${logger.style.code(
54
- currentlyUsedContext.Name
55
- )}) to ${logger.style.code('default')}?`,
56
- choices: [
57
- {
58
- name: 'yes',
59
- message: 'Yes'
60
- },
61
- {
62
- name: 'no',
63
- message:
64
- "No, I don't know what this means, but you can ask again on next start."
65
- },
66
- {
67
- name: 'skip',
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
- message:
70
- "I do know what this means and I DON'T want to change context for Docker. Also, save this answer to never ask again."
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 = await task.prompt({
25
- type: 'Confirm',
26
- message: `We detected that your Docker socket, located in ${logger.style.file(
27
- dockerSocketPath
28
- )}, have permissions set, that prevents user (${logger.style.misc(
29
- os.userInfo().username
30
- )}) from accessing it.
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
- fixCommand
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 = await task.prompt({
65
- type: 'Confirm',
66
- message:
67
- 'Looks like Docker is not running, would you like us to open a Docker for Mac application and wait for it to start up?'
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 = await task.prompt({
140
- type: 'Confirm',
141
- message: `Looks like Docker Engine is not enabled and not running, would you like to enable and run it?
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 = await task.prompt({
154
- type: 'Confirm',
155
- message: `Looks like Docker Engine is not running, would you like to run it?
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 = await task.prompt({
170
- type: 'Confirm',
171
- message: `Looks like Docker Desktop is not enabled and not running, would you like to enable and run it?
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 = await task.prompt({
184
- type: 'Confirm',
185
- message: `Looks like Docker Desktop is not running, would you like to run it?
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()
@@ -176,7 +176,7 @@ const start = () => ({
176
176
  {
177
177
  title: 'Opening browser',
178
178
  skip: async (ctx) => {
179
- if (ctx.noOpen) {
179
+ if (ctx.open === false) {
180
180
  return true
181
181
  }
182
182