mirror of
https://github.com/Lifeforge-app/lifeforge.git
synced 2026-06-28 23:05:48 +00:00
fix(cli): add proper removal of symlink when uninstalling package
This commit is contained in:
@@ -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<void> {
|
||||
|
||||
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)
|
||||
|
||||
@@ -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<void> {
|
||||
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)}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user