Skip to content

Commit

Permalink
fix(core): import-projects should add project.json file for new proje…
Browse files Browse the repository at this point in the history
…cts (#675)
  • Loading branch information
AgentEnder authored Apr 12, 2023
1 parent b902ba7 commit 69068af
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions packages/core/src/generators/import-projects/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
formatFiles,
getProjects,
getWorkspaceLayout,
joinPathFragments,
logger,
names,
ProjectConfiguration,
Expand Down Expand Up @@ -32,17 +33,19 @@ export default async function (
const installTask = await initGenerator(host, null, dotnetClient);

const projectFiles = await getProjectFilesInWorkspace(host);
const existingProjectRoots = Array.from(getProjects(host).values()).map(
(x) => x.root,
);
const existingProjectJsonDirectories = getDirectoriesWithProjectJson(host);
for (const projectFile of projectFiles.newLibs) {
if (!existingProjectRoots.some((x) => projectFile.startsWith(x))) {
if (
!existingProjectJsonDirectories.some((x) => projectFile.startsWith(x))
) {
await addNewDotnetProject(host, projectFile, false);
logger.log('Found new library', projectFile);
}
}
for (const projectFile of projectFiles.newApps) {
if (!existingProjectRoots.some((x) => projectFile.startsWith(x))) {
if (
!existingProjectJsonDirectories.some((x) => projectFile.startsWith(x))
) {
await addNewDotnetProject(host, projectFile, true);
logger.log('Found new application', projectFile);
}
Expand Down Expand Up @@ -111,3 +114,13 @@ async function checkIfTestProject(host: Tree, path: string): Promise<boolean> {
});
return isTestProject;
}
function getDirectoriesWithProjectJson(host: Tree) {
const nxProjects = getProjects(host);
const collected: string[] = [];
for (const proj of nxProjects.values()) {
if (host.exists(joinPathFragments(proj.root, 'project.json'))) {
collected.push(proj.root);
}
}
return collected;
}

0 comments on commit 69068af

Please sign in to comment.