Skip to content

Commit 69068af

Browse files
authored
fix(core): import-projects should add project.json file for new projects (#675)
1 parent b902ba7 commit 69068af

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

packages/core/src/generators/import-projects/generator.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
formatFiles,
44
getProjects,
55
getWorkspaceLayout,
6+
joinPathFragments,
67
logger,
78
names,
89
ProjectConfiguration,
@@ -32,17 +33,19 @@ export default async function (
3233
const installTask = await initGenerator(host, null, dotnetClient);
3334

3435
const projectFiles = await getProjectFilesInWorkspace(host);
35-
const existingProjectRoots = Array.from(getProjects(host).values()).map(
36-
(x) => x.root,
37-
);
36+
const existingProjectJsonDirectories = getDirectoriesWithProjectJson(host);
3837
for (const projectFile of projectFiles.newLibs) {
39-
if (!existingProjectRoots.some((x) => projectFile.startsWith(x))) {
38+
if (
39+
!existingProjectJsonDirectories.some((x) => projectFile.startsWith(x))
40+
) {
4041
await addNewDotnetProject(host, projectFile, false);
4142
logger.log('Found new library', projectFile);
4243
}
4344
}
4445
for (const projectFile of projectFiles.newApps) {
45-
if (!existingProjectRoots.some((x) => projectFile.startsWith(x))) {
46+
if (
47+
!existingProjectJsonDirectories.some((x) => projectFile.startsWith(x))
48+
) {
4649
await addNewDotnetProject(host, projectFile, true);
4750
logger.log('Found new application', projectFile);
4851
}
@@ -111,3 +114,13 @@ async function checkIfTestProject(host: Tree, path: string): Promise<boolean> {
111114
});
112115
return isTestProject;
113116
}
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

Comments
 (0)