|
3 | 3 | formatFiles, |
4 | 4 | getProjects, |
5 | 5 | getWorkspaceLayout, |
| 6 | + joinPathFragments, |
6 | 7 | logger, |
7 | 8 | names, |
8 | 9 | ProjectConfiguration, |
@@ -32,17 +33,19 @@ export default async function ( |
32 | 33 | const installTask = await initGenerator(host, null, dotnetClient); |
33 | 34 |
|
34 | 35 | const projectFiles = await getProjectFilesInWorkspace(host); |
35 | | - const existingProjectRoots = Array.from(getProjects(host).values()).map( |
36 | | - (x) => x.root, |
37 | | - ); |
| 36 | + const existingProjectJsonDirectories = getDirectoriesWithProjectJson(host); |
38 | 37 | for (const projectFile of projectFiles.newLibs) { |
39 | | - if (!existingProjectRoots.some((x) => projectFile.startsWith(x))) { |
| 38 | + if ( |
| 39 | + !existingProjectJsonDirectories.some((x) => projectFile.startsWith(x)) |
| 40 | + ) { |
40 | 41 | await addNewDotnetProject(host, projectFile, false); |
41 | 42 | logger.log('Found new library', projectFile); |
42 | 43 | } |
43 | 44 | } |
44 | 45 | for (const projectFile of projectFiles.newApps) { |
45 | | - if (!existingProjectRoots.some((x) => projectFile.startsWith(x))) { |
| 46 | + if ( |
| 47 | + !existingProjectJsonDirectories.some((x) => projectFile.startsWith(x)) |
| 48 | + ) { |
46 | 49 | await addNewDotnetProject(host, projectFile, true); |
47 | 50 | logger.log('Found new application', projectFile); |
48 | 51 | } |
@@ -111,3 +114,13 @@ async function checkIfTestProject(host: Tree, path: string): Promise<boolean> { |
111 | 114 | }); |
112 | 115 | return isTestProject; |
113 | 116 | } |
| 117 | +function getDirectoriesWithProjectJson(host: Tree) { |
| 118 | + const nxProjects = getProjects(host); |
| 119 | + const collected: string[] = []; |
| 120 | + for (const proj of nxProjects.values()) { |
| 121 | + if (host.exists(joinPathFragments(proj.root, 'project.json'))) { |
| 122 | + collected.push(proj.root); |
| 123 | + } |
| 124 | + } |
| 125 | + return collected; |
| 126 | +} |
0 commit comments