From f1e66e386d8c70f4920dbc8d213d7a5c45fddef8 Mon Sep 17 00:00:00 2001 From: Matej Cerny Date: Tue, 3 Jun 2025 00:16:13 +0200 Subject: [PATCH 1/4] fix(init): ask before showing modules selector --- packages/nuxi/src/commands/init.ts | 50 ++++++++++++++++++------------ 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/packages/nuxi/src/commands/init.ts b/packages/nuxi/src/commands/init.ts index 70236c569..56d1c03a2 100644 --- a/packages/nuxi/src/commands/init.ts +++ b/packages/nuxi/src/commands/init.ts @@ -255,8 +255,8 @@ export default defineCommand({ ) } // ...or offer to install official modules (if not offline) - else if (!ctx.args.offline && !ctx.args.preferOffline) { - const response = await $fetch<{ + else { + const modulesPromise = $fetch<{ modules: { npm: string type: 'community' | 'official' @@ -264,27 +264,39 @@ export default defineCommand({ }[] }>('https://api.nuxt.com/modules') - const officialModules = response.modules - .filter(module => module.type === 'official' && module.npm !== '@nuxt/devtools') - - const selectedOfficialModules = await logger.prompt( - `Would you like to install any of the official modules?`, + const wantsUserModules = await logger.prompt( + `Would you like to install any Nuxt modules?`, { - type: 'multiselect', - options: officialModules.map(module => ({ - label: `${colors.bold(colors.greenBright(module.npm))} – ${module.description.replace(/\.$/, '')}`, - value: module.npm, - })), - required: false, + type: 'confirm', + cancel: 'reject', }, - ) + ).catch(() => process.exit(1)) + + if (!ctx.args.offline && !ctx.args.preferOffline && wantsUserModules) { + const response = await modulesPromise + + const officialModules = response.modules + .filter(module => module.type === 'official' && module.npm !== '@nuxt/devtools') + + const selectedOfficialModules = await logger.prompt( + `Would you like to install any of the official modules?`, + { + type: 'multiselect', + options: officialModules.map(module => ({ + label: `${colors.bold(colors.greenBright(module.npm))} – ${module.description.replace(/\.$/, '')}`, + value: module.npm, + })), + required: false, + }, + ) - if (selectedOfficialModules === undefined) { - process.exit(1) - } + if (selectedOfficialModules === undefined) { + process.exit(1) + } - if (selectedOfficialModules.length > 0) { - modulesToAdd.push(...(selectedOfficialModules as unknown as string[])) + if (selectedOfficialModules.length > 0) { + modulesToAdd.push(...(selectedOfficialModules as unknown as string[])) + } } } From d31e8f4702714c455c17c3a631930645bbd9e71a Mon Sep 17 00:00:00 2001 From: Matej Cerny Date: Tue, 3 Jun 2025 00:26:58 +0200 Subject: [PATCH 2/4] fix(init): update prompt message for module selection --- packages/nuxi/src/commands/init.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nuxi/src/commands/init.ts b/packages/nuxi/src/commands/init.ts index 56d1c03a2..8b1f8fe45 100644 --- a/packages/nuxi/src/commands/init.ts +++ b/packages/nuxi/src/commands/init.ts @@ -279,7 +279,7 @@ export default defineCommand({ .filter(module => module.type === 'official' && module.npm !== '@nuxt/devtools') const selectedOfficialModules = await logger.prompt( - `Would you like to install any of the official modules?`, + 'Pick the modules to install:', { type: 'multiselect', options: officialModules.map(module => ({ From 48cbe2df4b47ef9a4e9d81aee7e8c8908d5cda1f Mon Sep 17 00:00:00 2001 From: Matej Cerny Date: Tue, 3 Jun 2025 00:38:07 +0200 Subject: [PATCH 3/4] fix(init): prioritize offline mode checks for module installation prompt --- packages/nuxi/src/commands/init.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nuxi/src/commands/init.ts b/packages/nuxi/src/commands/init.ts index 8b1f8fe45..5c8e6c7ae 100644 --- a/packages/nuxi/src/commands/init.ts +++ b/packages/nuxi/src/commands/init.ts @@ -255,7 +255,7 @@ export default defineCommand({ ) } // ...or offer to install official modules (if not offline) - else { + else if (!ctx.args.offline && !ctx.args.preferOffline) { const modulesPromise = $fetch<{ modules: { npm: string @@ -272,7 +272,7 @@ export default defineCommand({ }, ).catch(() => process.exit(1)) - if (!ctx.args.offline && !ctx.args.preferOffline && wantsUserModules) { + if (wantsUserModules) { const response = await modulesPromise const officialModules = response.modules From 8a85c4b012c40e3a537eaa749354a0b6fb4d6ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20=C4=8Cern=C3=BD?= Date: Wed, 4 Jun 2025 14:18:18 +0200 Subject: [PATCH 4/4] fix: update prompt to mention official modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Damian Głowala --- packages/nuxi/src/commands/init.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nuxi/src/commands/init.ts b/packages/nuxi/src/commands/init.ts index 5c8e6c7ae..58fcd4ee6 100644 --- a/packages/nuxi/src/commands/init.ts +++ b/packages/nuxi/src/commands/init.ts @@ -265,7 +265,7 @@ export default defineCommand({ }>('https://api.nuxt.com/modules') const wantsUserModules = await logger.prompt( - `Would you like to install any Nuxt modules?`, + `Would you like to install any of the official modules?`, { type: 'confirm', cancel: 'reject',