Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: nuxt module installation #131

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/commands/CSS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/Devtools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/Linters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/commands/Templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/sideBar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down
10 changes: 5 additions & 5 deletions src/utils/dependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down