diff --git a/tools/src/commands/locales/handlers/uninstallLocaleHandler.ts b/tools/src/commands/locales/handlers/uninstallLocaleHandler.ts index 21ce76f7c..f90c2b8bd 100644 --- a/tools/src/commands/locales/handlers/uninstallLocaleHandler.ts +++ b/tools/src/commands/locales/handlers/uninstallLocaleHandler.ts @@ -1,5 +1,7 @@ import fs from 'fs' +import path from 'path' +import { ROOT_DIR } from '@/constants/constants' import { bunInstall } from '@/utils/commands' import Logging from '@/utils/logging' import normalizePackage from '@/utils/normalizePackage' @@ -28,6 +30,9 @@ export async function uninstallLocaleHandler(langCode: string): Promise { Logging.info(`Uninstalling ${Logging.highlight(fullName)}...`) + const symlinkPath = path.join(ROOT_DIR, 'node_modules', fullName) + + fs.rmSync(symlinkPath, { recursive: true, force: true }) fs.rmSync(targetDir, { recursive: true, force: true }) removeDependency(fullName) diff --git a/tools/src/commands/modules/handlers/uninstallModuleHandler.ts b/tools/src/commands/modules/handlers/uninstallModuleHandler.ts index 900439400..bb9434705 100644 --- a/tools/src/commands/modules/handlers/uninstallModuleHandler.ts +++ b/tools/src/commands/modules/handlers/uninstallModuleHandler.ts @@ -1,40 +1,49 @@ import fs from 'fs' +import path from 'path' +import { ROOT_DIR } from '@/constants/constants' import { bunInstall } from '@/utils/commands' import Logging from '@/utils/logging' import { findPackageName, removeDependency } from '@/utils/packageJson' import normalizePackage from '../../../utils/normalizePackage' +import generateRouteRegistry from '../functions/registry/generateRouteRegistry' import generateSchemaRegistry from '../functions/registry/generateSchemaRegistry' -import generateServerRegistry from '../functions/registry/generateServerRegistry' export async function uninstallModuleHandler( - moduleName: string + moduleNames: string[] ): Promise { - const { targetDir, fullName } = normalizePackage(moduleName) + const uninstalled: string[] = [] - if (!findPackageName(fullName)) { - Logging.actionableError( - `Module ${Logging.highlight(fullName)} not found`, - 'Run "bun forge modules list" to see installed modules' - ) + for (const moduleName of moduleNames) { + const { targetDir, fullName } = normalizePackage(moduleName) - return + if (!findPackageName(fullName)) { + Logging.actionableError( + `Module ${Logging.highlight(fullName)} not found`, + 'Run "bun forge modules list" to see installed modules' + ) + continue + } + + Logging.info(`Uninstalling ${Logging.highlight(fullName)}...`) + removeDependency(fullName) + + const symlinkPath = path.join(ROOT_DIR, 'node_modules', fullName) + + fs.rmSync(symlinkPath, { recursive: true, force: true }) + fs.rmSync(targetDir, { recursive: true, force: true }) + uninstalled.push(moduleName) + Logging.success(`Uninstalled ${Logging.highlight(fullName)}`) } - Logging.info(`Uninstalling ${Logging.highlight(fullName)}...`) - - removeDependency(fullName) - - fs.rmSync(targetDir, { recursive: true, force: true }) + if (uninstalled.length === 0) { + return + } bunInstall() Logging.info('Regenerating registries...') - - generateServerRegistry() - + generateRouteRegistry() generateSchemaRegistry() - - Logging.success(`Uninstalled ${Logging.highlight(fullName)}`) }