feat(core): add --exclude-task-dependencies flag (#27137)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior There is no option to exclude dependent tasks when running Nx. ## Expected Behavior There is a flag, `--exclude-task-dependencies`, to exclude task deps from running. This is inline with other tools: - [dotnet cli](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-build#:~:text=%2D%2Dno%2D-,dependencies,-Ignores%20project%2Dto) ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #18053
This commit is contained in:
parent
04fb62dccb
commit
9a556f45b8
@ -117,6 +117,14 @@ Type: `string`
|
|||||||
|
|
||||||
Exclude certain projects from being processed
|
Exclude certain projects from being processed
|
||||||
|
|
||||||
|
### excludeTaskDependencies
|
||||||
|
|
||||||
|
Type: `boolean`
|
||||||
|
|
||||||
|
Default: `false`
|
||||||
|
|
||||||
|
Skips running dependent tasks first
|
||||||
|
|
||||||
### files
|
### files
|
||||||
|
|
||||||
Type: `string`
|
Type: `string`
|
||||||
|
|||||||
@ -309,6 +309,14 @@ Type: `string`
|
|||||||
|
|
||||||
Exclude certain projects from being processed
|
Exclude certain projects from being processed
|
||||||
|
|
||||||
|
##### excludeTaskDependencies
|
||||||
|
|
||||||
|
Type: `boolean`
|
||||||
|
|
||||||
|
Default: `false`
|
||||||
|
|
||||||
|
Skips running dependent tasks first
|
||||||
|
|
||||||
##### first-release
|
##### first-release
|
||||||
|
|
||||||
Type: `boolean`
|
Type: `boolean`
|
||||||
|
|||||||
@ -119,6 +119,14 @@ Type: `string`
|
|||||||
|
|
||||||
Exclude certain projects from being processed
|
Exclude certain projects from being processed
|
||||||
|
|
||||||
|
### excludeTaskDependencies
|
||||||
|
|
||||||
|
Type: `boolean`
|
||||||
|
|
||||||
|
Default: `false`
|
||||||
|
|
||||||
|
Skips running dependent tasks first
|
||||||
|
|
||||||
### graph
|
### graph
|
||||||
|
|
||||||
Type: `string`
|
Type: `string`
|
||||||
|
|||||||
@ -87,6 +87,14 @@ Type: `string`
|
|||||||
|
|
||||||
Exclude certain projects from being processed
|
Exclude certain projects from being processed
|
||||||
|
|
||||||
|
### excludeTaskDependencies
|
||||||
|
|
||||||
|
Type: `boolean`
|
||||||
|
|
||||||
|
Default: `false`
|
||||||
|
|
||||||
|
Skips running dependent tasks first
|
||||||
|
|
||||||
### graph
|
### graph
|
||||||
|
|
||||||
Type: `string`
|
Type: `string`
|
||||||
|
|||||||
@ -117,6 +117,14 @@ Type: `string`
|
|||||||
|
|
||||||
Exclude certain projects from being processed
|
Exclude certain projects from being processed
|
||||||
|
|
||||||
|
### excludeTaskDependencies
|
||||||
|
|
||||||
|
Type: `boolean`
|
||||||
|
|
||||||
|
Default: `false`
|
||||||
|
|
||||||
|
Skips running dependent tasks first
|
||||||
|
|
||||||
### files
|
### files
|
||||||
|
|
||||||
Type: `string`
|
Type: `string`
|
||||||
|
|||||||
@ -309,6 +309,14 @@ Type: `string`
|
|||||||
|
|
||||||
Exclude certain projects from being processed
|
Exclude certain projects from being processed
|
||||||
|
|
||||||
|
##### excludeTaskDependencies
|
||||||
|
|
||||||
|
Type: `boolean`
|
||||||
|
|
||||||
|
Default: `false`
|
||||||
|
|
||||||
|
Skips running dependent tasks first
|
||||||
|
|
||||||
##### first-release
|
##### first-release
|
||||||
|
|
||||||
Type: `boolean`
|
Type: `boolean`
|
||||||
|
|||||||
@ -119,6 +119,14 @@ Type: `string`
|
|||||||
|
|
||||||
Exclude certain projects from being processed
|
Exclude certain projects from being processed
|
||||||
|
|
||||||
|
### excludeTaskDependencies
|
||||||
|
|
||||||
|
Type: `boolean`
|
||||||
|
|
||||||
|
Default: `false`
|
||||||
|
|
||||||
|
Skips running dependent tasks first
|
||||||
|
|
||||||
### graph
|
### graph
|
||||||
|
|
||||||
Type: `string`
|
Type: `string`
|
||||||
|
|||||||
@ -87,6 +87,14 @@ Type: `string`
|
|||||||
|
|
||||||
Exclude certain projects from being processed
|
Exclude certain projects from being processed
|
||||||
|
|
||||||
|
### excludeTaskDependencies
|
||||||
|
|
||||||
|
Type: `boolean`
|
||||||
|
|
||||||
|
Default: `false`
|
||||||
|
|
||||||
|
Skips running dependent tasks first
|
||||||
|
|
||||||
### graph
|
### graph
|
||||||
|
|
||||||
Type: `string`
|
Type: `string`
|
||||||
|
|||||||
@ -254,6 +254,40 @@ describe('Nx Running Tests', () => {
|
|||||||
const output = runCLI(`echo ${mylib}`);
|
const output = runCLI(`echo ${mylib}`);
|
||||||
expect(output).toContain('TWO');
|
expect(output).toContain('TWO');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should not run dependencies if --no-dependencies is passed', () => {
|
||||||
|
const mylib = uniq('mylib');
|
||||||
|
runCLI(`generate @nx/js:lib ${mylib}`);
|
||||||
|
|
||||||
|
updateJson(`libs/${mylib}/project.json`, (c) => {
|
||||||
|
c.targets['one'] = {
|
||||||
|
executor: 'nx:run-commands',
|
||||||
|
options: {
|
||||||
|
command: 'echo ONE',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
c.targets['two'] = {
|
||||||
|
executor: 'nx:run-commands',
|
||||||
|
options: {
|
||||||
|
command: 'echo TWO',
|
||||||
|
},
|
||||||
|
dependsOn: ['one'],
|
||||||
|
};
|
||||||
|
c.targets['three'] = {
|
||||||
|
executor: 'nx:run-commands',
|
||||||
|
options: {
|
||||||
|
command: 'echo THREE',
|
||||||
|
},
|
||||||
|
dependsOn: ['two'],
|
||||||
|
};
|
||||||
|
return c;
|
||||||
|
});
|
||||||
|
|
||||||
|
const output = runCLI(`one ${mylib} --no-deps`);
|
||||||
|
expect(output).toContain('ONE');
|
||||||
|
expect(output).not.toContain('TWO');
|
||||||
|
expect(output).not.toContain('THREE');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Nx Bail', () => {
|
describe('Nx Bail', () => {
|
||||||
|
|||||||
@ -32,7 +32,7 @@ export async function affected(
|
|||||||
(TargetDependencyConfig | string)[]
|
(TargetDependencyConfig | string)[]
|
||||||
> = {},
|
> = {},
|
||||||
extraOptions = {
|
extraOptions = {
|
||||||
excludeTaskDependencies: false,
|
excludeTaskDependencies: args.excludeTaskDependencies,
|
||||||
loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
|
loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
|
||||||
} as {
|
} as {
|
||||||
excludeTaskDependencies: boolean;
|
excludeTaskDependencies: boolean;
|
||||||
|
|||||||
@ -79,7 +79,9 @@ export async function releasePublish(
|
|||||||
* for dependencies, because that could cause projects outset of the filtered set to be published.
|
* for dependencies, because that could cause projects outset of the filtered set to be published.
|
||||||
*/
|
*/
|
||||||
const shouldExcludeTaskDependencies =
|
const shouldExcludeTaskDependencies =
|
||||||
_args.projects?.length > 0 || _args.groups?.length > 0;
|
_args.projects?.length > 0 ||
|
||||||
|
_args.groups?.length > 0 ||
|
||||||
|
args.excludeTaskDependencies;
|
||||||
|
|
||||||
let overallExitStatus = 0;
|
let overallExitStatus = 0;
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ export async function runMany(
|
|||||||
(TargetDependencyConfig | string)[]
|
(TargetDependencyConfig | string)[]
|
||||||
> = {},
|
> = {},
|
||||||
extraOptions = {
|
extraOptions = {
|
||||||
excludeTaskDependencies: false,
|
excludeTaskDependencies: args.excludeTaskDependencies,
|
||||||
loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
|
loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
|
||||||
} as {
|
} as {
|
||||||
excludeTaskDependencies: boolean;
|
excludeTaskDependencies: boolean;
|
||||||
|
|||||||
@ -28,7 +28,7 @@ export async function runOne(
|
|||||||
(TargetDependencyConfig | string)[]
|
(TargetDependencyConfig | string)[]
|
||||||
> = {},
|
> = {},
|
||||||
extraOptions = {
|
extraOptions = {
|
||||||
excludeTaskDependencies: false,
|
excludeTaskDependencies: args.excludeTaskDependencies,
|
||||||
loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
|
loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
|
||||||
} as {
|
} as {
|
||||||
excludeTaskDependencies: boolean;
|
excludeTaskDependencies: boolean;
|
||||||
|
|||||||
@ -27,6 +27,7 @@ export interface RunOptions {
|
|||||||
dte: boolean;
|
dte: boolean;
|
||||||
batch: boolean;
|
batch: boolean;
|
||||||
useAgents: boolean;
|
useAgents: boolean;
|
||||||
|
excludeTaskDependencies: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function withRunOptions<T>(yargs: Argv<T>): Argv<T & RunOptions> {
|
export function withRunOptions<T>(yargs: Argv<T>): Argv<T & RunOptions> {
|
||||||
@ -79,6 +80,11 @@ export function withRunOptions<T>(yargs: Argv<T>): Argv<T & RunOptions> {
|
|||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
})
|
})
|
||||||
|
.options('excludeTaskDependencies', {
|
||||||
|
describe: 'Skips running dependent tasks first',
|
||||||
|
type: 'boolean',
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
.options('cloud', {
|
.options('cloud', {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
hidden: true,
|
hidden: true,
|
||||||
|
|||||||
@ -50,8 +50,10 @@ export function createCommandGraph(
|
|||||||
nxArgs: NxArgs
|
nxArgs: NxArgs
|
||||||
): CommandGraph {
|
): CommandGraph {
|
||||||
const dependencies: Record<string, string[]> = {};
|
const dependencies: Record<string, string[]> = {};
|
||||||
for (const projectName of projectNames) {
|
if (!nxArgs.excludeTaskDependencies) {
|
||||||
recursiveResolveDeps(projectGraph, projectName, dependencies);
|
for (const projectName of projectNames) {
|
||||||
|
recursiveResolveDeps(projectGraph, projectName, dependencies);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const roots = Object.keys(dependencies).filter(
|
const roots = Object.keys(dependencies).filter(
|
||||||
(d) => dependencies[d].length === 0
|
(d) => dependencies[d].length === 0
|
||||||
|
|||||||
@ -36,6 +36,7 @@ export interface NxArgs {
|
|||||||
nxIgnoreCycles?: boolean;
|
nxIgnoreCycles?: boolean;
|
||||||
type?: string;
|
type?: string;
|
||||||
batch?: boolean;
|
batch?: boolean;
|
||||||
|
excludeTaskDependencies?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createOverrides(__overrides_unparsed__: string[] = []) {
|
export function createOverrides(__overrides_unparsed__: string[] = []) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user