@@ -82,6 +82,7 @@ export type PluginUninstallDirectoryRemoval = {
8282 kind : "npm" ;
8383 npmRoot : string ;
8484 packageName : string ;
85+ rootKind : "legacy-shared" | "isolated-project" ;
8586 }
8687 | {
8788 kind : "git" ;
@@ -164,7 +165,12 @@ function resolveUninstallDirectoryTarget(params: {
164165function resolveNpmManagedInstall ( params : {
165166 installRecord ?: PluginInstallRecord ;
166167 extensionsDir ?: string ;
167- } ) : { installPath : string ; npmRoot : string ; packageName : string } | null {
168+ } ) : {
169+ installPath : string ;
170+ npmRoot : string ;
171+ packageName : string ;
172+ rootKind : "legacy-shared" | "isolated-project" ;
173+ } | null {
168174 const installPath = params . installRecord ?. installPath ?. trim ( ) ;
169175 if ( params . installRecord ?. source !== "npm" || ! installPath ) {
170176 return null ;
@@ -184,7 +190,7 @@ function resolveNpmManagedInstall(params: {
184190 resolveComparableUninstallPath ( installPath )
185191 ) {
186192 const packageName = resolveNpmPackageNameFromInstallPath ( { installPath, nodeModulesRoot } ) ;
187- return packageName ? { installPath, npmRoot, packageName } : null ;
193+ return packageName ? { installPath, npmRoot, packageName, rootKind : "legacy-shared" } : null ;
188194 }
189195 const projectMatch = resolveNpmManagedProjectInstall ( {
190196 installPath,
@@ -197,10 +203,12 @@ function resolveNpmManagedInstall(params: {
197203 return null ;
198204}
199205
200- function resolveNpmManagedProjectInstall ( params : {
206+ function resolveNpmManagedProjectInstall ( params : { installPath : string ; projectsDir : string } ) : {
201207 installPath : string ;
202- projectsDir : string ;
203- } ) : { installPath : string ; npmRoot : string ; packageName : string } | null {
208+ npmRoot : string ;
209+ packageName : string ;
210+ rootKind : "isolated-project" ;
211+ } | null {
204212 if (
205213 ! isUninstallPathInsideOrEqual ( params . projectsDir , params . installPath ) ||
206214 resolveComparableUninstallPath ( params . projectsDir ) ===
@@ -238,7 +246,12 @@ function resolveNpmManagedProjectInstall(params: {
238246 projectDir : npmRoot ,
239247 npmDir,
240248 } ) ;
241- return { installPath : ownsProjectRoot ? npmRoot : params . installPath , npmRoot, packageName } ;
249+ return {
250+ installPath : ownsProjectRoot ? npmRoot : params . installPath ,
251+ npmRoot,
252+ packageName,
253+ rootKind : "isolated-project" ,
254+ } ;
242255}
243256
244257function resolveNpmPackageNameFromInstallPath ( params : {
@@ -423,6 +436,7 @@ export function planPluginUninstall(params: UninstallPluginParams): PluginUninst
423436 kind : "npm" ,
424437 npmRoot : npmManagedInstall . npmRoot ,
425438 packageName : npmManagedInstall . packageName ,
439+ rootKind : npmManagedInstall . rootKind ,
426440 } ,
427441 }
428442 : gitManagedInstall && deleteTarget === gitManagedInstall . installPath
@@ -453,7 +467,10 @@ function isOwnedNpmRemoval(removal: PluginUninstallDirectoryRemoval): boolean {
453467 return true ;
454468 }
455469 const projectsDir = path . dirname ( cleanup . npmRoot ) ;
456- const projectRoot = path . basename ( projectsDir ) === "projects" ;
470+ const projectRoot = cleanup . rootKind === "isolated-project" ;
471+ if ( projectRoot !== ( path . basename ( projectsDir ) === "projects" ) ) {
472+ return false ;
473+ }
457474 const npmDir = projectRoot ? path . dirname ( projectsDir ) : cleanup . npmRoot ;
458475 if (
459476 projectRoot
@@ -510,9 +527,8 @@ export async function applyPluginUninstallDirectoryRemoval(
510527 return { directoryRemoved : false , warnings } ;
511528 }
512529
513- const removesNpmProject =
514- removal . cleanup ?. kind === "npm" &&
515- path . resolve ( removal . target ) === path . resolve ( removal . cleanup . npmRoot ) ;
530+ const usesLegacySharedNpmRoot =
531+ removal . cleanup ?. kind === "npm" && removal . cleanup . rootKind === "legacy-shared" ;
516532 const npmCleanupManifestPath =
517533 removal . cleanup ?. kind === "npm" ? path . join ( removal . cleanup . npmRoot , "package.json" ) : "" ;
518534 const npmCleanupManifestExists =
@@ -531,7 +547,7 @@ export async function applyPluginUninstallDirectoryRemoval(
531547 if ( ! isOwnedNpmRemoval ( removal ) ) {
532548 return { directoryRemoved : false , warnings : [ ownershipWarning ] } ;
533549 }
534- if ( removal . cleanup ?. kind === "npm" && npmCleanupManifestExists && ! removesNpmProject ) {
550+ if ( removal . cleanup ?. kind === "npm" && npmCleanupManifestExists && usesLegacySharedNpmRoot ) {
535551 const uninstall = await runCommandWithTimeout (
536552 [
537553 "npm" ,
0 commit comments