Skip to content

Commit

Permalink
fix(schematics): topologically sort projects for `affected:build --al…
Browse files Browse the repository at this point in the history
…l` in v7

Closes nrwl#1302

Aligns behaviour of `affected --base=[SHA] --head=[SHA]` and `affected --all`
  • Loading branch information
dherges committed May 1, 2019
1 parent df6cd70 commit 1e4b5c5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/schematics/src/command-line/affected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
getAllLibNames,
getProjectNames,
parseFiles,
getAllProjectNamesWithTarget,
getAllProjectsWithTarget,
getAffectedProjectsWithTarget,
readAngularJson
} from './shared';
Expand Down Expand Up @@ -122,7 +122,7 @@ function getProjects(
all: boolean
) {
const projects = all
? getAllProjectNamesWithTarget(target)
? getAllProjectsWithTarget(target)
: getAffectedProjectsWithTarget(target)(parseFiles(parsedArgs).files);

return projects
Expand Down
10 changes: 10 additions & 0 deletions packages/schematics/src/command-line/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,16 @@ export function getAllProjectNamesWithTarget(target: string) {
return getProjectNames(p => p.architect[target]);
}

export function getAllProjectsWithTarget(target: string) {
const angularJson = readAngularJson();
const nxJson = readNxJson();
const projects = getProjectNodes(angularJson, nxJson);
const dependencies = readDependencies(nxJson.npmScope, projects);
const sortedProjects = topologicallySortProjects(projects, dependencies);

return sortedProjects.filter(p => p.architect[target]).map(p => p.name);
}

export function getProjectNames(
predicate?: (projectNode: ProjectNode) => boolean
): string[] {
Expand Down

0 comments on commit 1e4b5c5

Please sign in to comment.