From 6c6b1256be3f415aa6021d8c99708be644e37a9d Mon Sep 17 00:00:00 2001 From: selemondev Date: Sat, 23 Mar 2024 16:03:56 +0300 Subject: [PATCH] fix: nuxt module installation --- src/commands/CSS.ts | 10 +++++----- src/commands/Devtools.ts | 2 +- src/commands/Linters.ts | 4 ++-- src/commands/Templates.ts | 4 ++-- src/sideBar/index.ts | 3 +-- src/utils/dependency.ts | 10 +++++----- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/commands/CSS.ts b/src/commands/CSS.ts index ee710ef..c34b828 100644 --- a/src/commands/CSS.ts +++ b/src/commands/CSS.ts @@ -58,8 +58,8 @@ const configureTailwind = () => { if (selections !== undefined && selections.length > 0) { if (selections.includes(TailwindOptions.installModule)) { const moduleName = '@nuxtjs/tailwindcss' - const tailwindCommand = await getInstallationCommand('tailwindcss', true) - const moduleCommand = await getInstallationCommand(moduleName, true) + const tailwindCommand = await getInstallationCommand('tailwindcss') + const moduleCommand = await getInstallationCommand(moduleName) if (!isNuxtTwo()) { await runCommand({ @@ -127,7 +127,7 @@ const configureWindi = async () => { if (selections !== undefined && selections.length > 0) { if (selections.includes(WindiOptions.installModule)) { const moduleName = 'nuxt-windicss' - const command = await getInstallationCommand(moduleName, true) + const command = await getInstallationCommand(moduleName) await runCommand({ command, @@ -175,7 +175,7 @@ const configureUno = async () => { if (selections !== undefined && selections.length > 0) { if (selections.includes(UnoCSSOptions.installModule)) { const moduleName = '@unocss/nuxt' - const command = await getInstallationCommand(moduleName, true) + const command = await getInstallationCommand(moduleName) await runCommand({ command, @@ -223,7 +223,7 @@ const configureVuetify = async () => { if (selections !== undefined && selections.length > 0) { if (selections.includes(VuetifyOptions.installModule)) { const moduleName = '@nuxtjs/vuetify' - const command = await getInstallationCommand(moduleName, true) + const command = await getInstallationCommand(moduleName) await runCommand({ command, diff --git a/src/commands/Devtools.ts b/src/commands/Devtools.ts index d3d6851..7ad41a5 100644 --- a/src/commands/Devtools.ts +++ b/src/commands/Devtools.ts @@ -98,7 +98,7 @@ async function installDevtools() { "Close" ); if (response === "Install") { - const command = await getInstallationCommand(moduleName, true); + const command = await getInstallationCommand(moduleName); await runCommand({ command, diff --git a/src/commands/Linters.ts b/src/commands/Linters.ts index 9617145..83b7162 100644 --- a/src/commands/Linters.ts +++ b/src/commands/Linters.ts @@ -46,7 +46,7 @@ const configureEslint = () => { if (selections !== undefined && selections.length > 0) { if (selections.includes(EslintOptions.installModule)) { const moduleName = '@nuxtjs/eslint-config-typescript eslint' - const command = await getInstallationCommand(moduleName, true) + const command = await getInstallationCommand(moduleName) await runCommand({ command, @@ -101,7 +101,7 @@ const configureStylelint = () => { if (selections.includes(StylelintOptions.installModule)) { const moduleName = 'stylelint @nuxtjs/stylelint-module stylelint-config-recommended-vue' - const command = await getInstallationCommand(moduleName, true) + const command = await getInstallationCommand(moduleName) await runCommand({ command, diff --git a/src/commands/Templates.ts b/src/commands/Templates.ts index e12e69e..cab67d0 100644 --- a/src/commands/Templates.ts +++ b/src/commands/Templates.ts @@ -24,7 +24,7 @@ export const configurePug = (options: string[] = defaultOptions) => { if (selections !== undefined && selections.length > 0) { if (selections.includes(PugConfigurationSteps.installPug)) { const moduleName = 'pug' - const command = await getInstallationCommand(moduleName, true) + const command = await getInstallationCommand(moduleName) await runCommand({ command, @@ -36,7 +36,7 @@ export const configurePug = (options: string[] = defaultOptions) => { if (selections.includes(PugConfigurationSteps.installLanguagePlugin)) { const moduleName = '@vue/language-plugin-pug' - const command = await getInstallationCommand(moduleName, true) + const command = await getInstallationCommand(moduleName) await runCommand({ command, diff --git a/src/sideBar/index.ts b/src/sideBar/index.ts index ccddedd..b201e9d 100644 --- a/src/sideBar/index.ts +++ b/src/sideBar/index.ts @@ -224,8 +224,7 @@ export class ModulesView implements vscode.WebviewViewProvider { private async installModule(module: any) { const command = await getInstallationCommand( - module.npm, - module['dependency-type'] === 'dev' ? true : false + module.npm ) await vscode.window.withProgress( { diff --git a/src/utils/dependency.ts b/src/utils/dependency.ts index f0b4a25..917b1a7 100644 --- a/src/utils/dependency.ts +++ b/src/utils/dependency.ts @@ -153,16 +153,16 @@ export const detectPackageManagerByName = () => { return undefined } -export const getInstallationCommand = async (packageName: string, devFlag: boolean) => { +export const getInstallationCommand = async (packageName: string) => { const packageManager = detectPackageManagerByName() const defaultPackageManager = nuxtrConfiguration().defaultPackageManager const installationCommand: any = { - Yarn: `yarn add ${packageName} ${devFlag ? '-D' : ''}`, - NPM: `npm install ${packageName} ${devFlag ? '-D' : ''}`, - pnpm: `pnpm add ${packageName} ${devFlag ? '-D' : ''}`, - Bun: `bun install ${packageName} ${devFlag ? '-D' : ''}`, + Yarn: `yarn add ${packageName} -D`, + NPM: `npm install ${packageName} -D`, + pnpm: `pnpm add ${packageName} -D`, + Bun: `bun install ${packageName} -D`, } if (packageManager) {