fix(schematics): update arguments to better match expectations
Changes `nx affected:libs` to print out library names. Changes `nx affected:build` to build all projects that have the `build` architype
This commit is contained in:
parent
7db42520a4
commit
3a1796a5d1
@ -99,7 +99,7 @@ export function affected(
|
|||||||
libs = getAffectedLibs(p.files)
|
libs = getAffectedLibs(p.files)
|
||||||
.filter(project => !parsedArgs.exclude.includes(project))
|
.filter(project => !parsedArgs.exclude.includes(project))
|
||||||
.filter(
|
.filter(
|
||||||
project =>
|
project =>
|
||||||
!parsedArgs.onlyFailed || !workspaceResults.getResult(project)
|
!parsedArgs.onlyFailed || !workspaceResults.getResult(project)
|
||||||
)
|
)
|
||||||
projects = getAffectedProjects(p.files)
|
projects = getAffectedProjects(p.files)
|
||||||
@ -120,7 +120,7 @@ export function affected(
|
|||||||
console.log(apps.join(' '));
|
console.log(apps.join(' '));
|
||||||
break;
|
break;
|
||||||
case 'build':
|
case 'build':
|
||||||
build(apps, parsedArgs, workspaceResults);
|
build(projects, parsedArgs, workspaceResults);
|
||||||
break;
|
break;
|
||||||
case 'test':
|
case 'test':
|
||||||
test(projects, parsedArgs, workspaceResults);
|
test(projects, parsedArgs, workspaceResults);
|
||||||
@ -135,7 +135,8 @@ export function affected(
|
|||||||
generateGraph(yargsParser(rest), projects);
|
generateGraph(yargsParser(rest), projects);
|
||||||
break;
|
break;
|
||||||
case 'lib':
|
case 'lib':
|
||||||
build(libs, parsedArgs, workspaceResults);
|
console.log(libs.join(' '))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,13 +145,24 @@ function printError(e: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function build(
|
function build(
|
||||||
apps: string[],
|
projects: string[],
|
||||||
parsedArgs: YargsAffectedOptions,
|
parsedArgs: YargsAffectedOptions,
|
||||||
workspaceResults: WorkspaceResults
|
workspaceResults: WorkspaceResults
|
||||||
) {
|
) {
|
||||||
if (apps.length > 0) {
|
|
||||||
|
const depGraph = readDepGraph();
|
||||||
|
const sortedProjects = topologicallySortProjects(depGraph);
|
||||||
|
const sortedAffectedProjects = sortedProjects.filter(
|
||||||
|
pp => projects.indexOf(pp) > -1
|
||||||
|
);
|
||||||
|
const projectsToBuild = sortedAffectedProjects.filter(p => {
|
||||||
|
const matchingProject = depGraph.projects.find(pp => pp.name === p);
|
||||||
|
return !!matchingProject.architect['build'];
|
||||||
|
});
|
||||||
|
|
||||||
|
if (projectsToBuild.length > 0) {
|
||||||
const normalizedArgs = filterNxSpecificArgs(parsedArgs);
|
const normalizedArgs = filterNxSpecificArgs(parsedArgs);
|
||||||
let message = `Building ${apps.join(', ')}`;
|
let message = `Building ${projectsToBuild.join(', ')}`;
|
||||||
if (normalizedArgs.length > 0) {
|
if (normalizedArgs.length > 0) {
|
||||||
message += ` with flags: ${normalizedArgs.join(' ')}`;
|
message += ` with flags: ${normalizedArgs.join(' ')}`;
|
||||||
}
|
}
|
||||||
@ -158,7 +170,7 @@ function build(
|
|||||||
|
|
||||||
runCommand(
|
runCommand(
|
||||||
'build',
|
'build',
|
||||||
apps,
|
projectsToBuild,
|
||||||
parsedArgs,
|
parsedArgs,
|
||||||
normalizedArgs,
|
normalizedArgs,
|
||||||
workspaceResults,
|
workspaceResults,
|
||||||
@ -167,7 +179,7 @@ function build(
|
|||||||
'Build failed.'
|
'Build failed.'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.log('No apps to build');
|
console.log('No projects to build');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ yargs
|
|||||||
)
|
)
|
||||||
.command(
|
.command(
|
||||||
'affected:build',
|
'affected:build',
|
||||||
'Build applications affected by changes',
|
'Build applications and publishable libraries affected by changes',
|
||||||
yargs => withAffectedOptions(withParallel(yargs)),
|
yargs => withAffectedOptions(withParallel(yargs)),
|
||||||
args => affected('build', args, process.argv.slice(3))
|
args => affected('build', args, process.argv.slice(3))
|
||||||
)
|
)
|
||||||
@ -37,9 +37,9 @@ yargs
|
|||||||
args => affected('test', args, process.argv.slice(3))
|
args => affected('test', args, process.argv.slice(3))
|
||||||
)
|
)
|
||||||
.command(
|
.command(
|
||||||
'affected:lib',
|
'affected:libs',
|
||||||
'Build libraries affected by changes',
|
'Print libraries affected by changes',
|
||||||
yargs => withAffectedOptions(withParallel(yargs)),
|
withAffectedOptions,
|
||||||
args => affected('lib', args, process.argv.slice(3))
|
args => affected('lib', args, process.argv.slice(3))
|
||||||
)
|
)
|
||||||
.command(
|
.command(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user