Skip to content

Commit

Permalink
feat(core): add --no-deps flag
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Jul 26, 2024
1 parent 4a3a8a9 commit 900ad3d
Show file tree
Hide file tree
Showing 16 changed files with 115 additions and 6 deletions.
8 changes: 8 additions & 0 deletions docs/generated/cli/affected.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ Type: `string`

Exclude certain projects from being processed

### excludeTaskDependencies

Type: `boolean`

Default: `false`

Skips running dependent tasks first

### files

Type: `string`
Expand Down
8 changes: 8 additions & 0 deletions docs/generated/cli/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,14 @@ Type: `string`

Exclude certain projects from being processed

##### excludeTaskDependencies

Type: `boolean`

Default: `false`

Skips running dependent tasks first

##### first-release

Type: `boolean`
Expand Down
8 changes: 8 additions & 0 deletions docs/generated/cli/run-many.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ Type: `string`

Exclude certain projects from being processed

### excludeTaskDependencies

Type: `boolean`

Default: `false`

Skips running dependent tasks first

### graph

Type: `string`
Expand Down
8 changes: 8 additions & 0 deletions docs/generated/cli/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ Type: `string`

Exclude certain projects from being processed

### excludeTaskDependencies

Type: `boolean`

Default: `false`

Skips running dependent tasks first

### graph

Type: `string`
Expand Down
8 changes: 8 additions & 0 deletions docs/generated/packages/nx/documents/affected.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ Type: `string`

Exclude certain projects from being processed

### excludeTaskDependencies

Type: `boolean`

Default: `false`

Skips running dependent tasks first

### files

Type: `string`
Expand Down
8 changes: 8 additions & 0 deletions docs/generated/packages/nx/documents/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,14 @@ Type: `string`

Exclude certain projects from being processed

##### excludeTaskDependencies

Type: `boolean`

Default: `false`

Skips running dependent tasks first

##### first-release

Type: `boolean`
Expand Down
8 changes: 8 additions & 0 deletions docs/generated/packages/nx/documents/run-many.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ Type: `string`

Exclude certain projects from being processed

### excludeTaskDependencies

Type: `boolean`

Default: `false`

Skips running dependent tasks first

### graph

Type: `string`
Expand Down
8 changes: 8 additions & 0 deletions docs/generated/packages/nx/documents/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ Type: `string`

Exclude certain projects from being processed

### excludeTaskDependencies

Type: `boolean`

Default: `false`

Skips running dependent tasks first

### graph

Type: `string`
Expand Down
34 changes: 34 additions & 0 deletions e2e/nx/src/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,40 @@ describe('Nx Running Tests', () => {
const output = runCLI(`echo ${mylib}`);
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', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/command-line/affected/affected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function affected(
(TargetDependencyConfig | string)[]
> = {},
extraOptions = {
excludeTaskDependencies: false,
excludeTaskDependencies: args.excludeTaskDependencies,
loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
} as {
excludeTaskDependencies: boolean;
Expand Down
4 changes: 3 additions & 1 deletion packages/nx/src/command-line/release/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ export async function releasePublish(
* for dependencies, because that could cause projects outset of the filtered set to be published.
*/
const shouldExcludeTaskDependencies =
_args.projects?.length > 0 || _args.groups?.length > 0;
_args.projects?.length > 0 ||
_args.groups?.length > 0 ||
args.excludeTaskDependencies;

let overallExitStatus = 0;

Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/command-line/run-many/run-many.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function runMany(
(TargetDependencyConfig | string)[]
> = {},
extraOptions = {
excludeTaskDependencies: false,
excludeTaskDependencies: args.excludeTaskDependencies,
loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
} as {
excludeTaskDependencies: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/command-line/run/run-one.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function runOne(
(TargetDependencyConfig | string)[]
> = {},
extraOptions = {
excludeTaskDependencies: false,
excludeTaskDependencies: args.excludeTaskDependencies,
loadDotEnvFiles: process.env.NX_LOAD_DOT_ENV_FILES !== 'false',
} as {
excludeTaskDependencies: boolean;
Expand Down
6 changes: 6 additions & 0 deletions packages/nx/src/command-line/yargs-utils/shared-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface RunOptions {
dte: boolean;
batch: boolean;
useAgents: boolean;
excludeTaskDependencies: boolean;
}

export function withRunOptions<T>(yargs: Argv<T>): Argv<T & RunOptions> {
Expand Down Expand Up @@ -79,6 +80,11 @@ export function withRunOptions<T>(yargs: Argv<T>): Argv<T & RunOptions> {
type: 'boolean',
default: false,
})
.options('excludeTaskDependencies', {
describe: 'Skips running dependent tasks first',
type: 'boolean',
default: false,
})
.options('cloud', {
type: 'boolean',
hidden: true,
Expand Down
6 changes: 4 additions & 2 deletions packages/nx/src/commands-runner/create-command-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ export function createCommandGraph(
nxArgs: NxArgs
): CommandGraph {
const dependencies: Record<string, string[]> = {};
for (const projectName of projectNames) {
recursiveResolveDeps(projectGraph, projectName, dependencies);
if (!nxArgs.excludeTaskDependencies) {
for (const projectName of projectNames) {
recursiveResolveDeps(projectGraph, projectName, dependencies);
}
}
const roots = Object.keys(dependencies).filter(
(d) => dependencies[d].length === 0
Expand Down
1 change: 1 addition & 0 deletions packages/nx/src/utils/command-line-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export interface NxArgs {
nxIgnoreCycles?: boolean;
type?: string;
batch?: boolean;
excludeTaskDependencies?: boolean;
}

export function createOverrides(__overrides_unparsed__: string[] = []) {
Expand Down

0 comments on commit 900ad3d

Please sign in to comment.