Skip to content

Commit

Permalink
feat(core): tag nx-dotnet projects
Browse files Browse the repository at this point in the history
NxDotnet needs to be able to identify projects it created
when analyzing the dependency graph. Adding this tag allows
filtering for projects created by nx-dotnet.
  • Loading branch information
AgentEnder committed Apr 26, 2021
1 parent 4c6e91a commit 6442d94
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions packages/core/src/generators/utils/generate-project.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ describe('nx-dotnet project generator', () => {
expect(config).toBeDefined();
});

it('should tag generated projects', async () => {
await GenerateProject(appTree, options, dotnetClient, 'library');
const config = readProjectConfiguration(appTree, 'test');
expect(config.tags).toContain('nx-dotnet');
});

it('should run successfully for applications', async () => {
await GenerateProject(appTree, options, dotnetClient, 'application');
const config = readProjectConfiguration(appTree, 'test');
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/generators/utils/generate-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function normalizeOptions(
const parsedTags = options.tags
? options.tags.split(',').map((s) => s.trim())
: [];
parsedTags.push('nx-dotnet');

const npmScope = names(readWorkspaceConfiguration(host).npmScope).className;
const featureScope = projectDirectory
Expand Down
9 changes: 6 additions & 3 deletions packages/core/src/graph/process-project-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ export function processProjectGraph(

Object.entries(context.workspace.projects).forEach(([name, project]) => {
try {
visitProject(builder, context, project, name);
if (project.tags?.some((x) => x === 'nx-dotnet')) {
visitProject(builder, context, project, name);
}
} catch {
console.warn(`Failed to generate .NET dependencies for ${name}`);
console.warn(
`nx-dotnet encountered an error parsing dependencies for ${name}`
);
}
});

Expand All @@ -31,7 +35,6 @@ function visitProject(
project: ProjectConfiguration,
projectName: string
) {
console.log('Looking for dependencies for ', projectName);
getDependantProjectsForNxProject(
projectName,
context.workspace,
Expand Down

0 comments on commit 6442d94

Please sign in to comment.