Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): remove deprecated affected commands
Browse files Browse the repository at this point in the history
AgentEnder committed Apr 19, 2023
1 parent 81f5603 commit 7b65bb4
Showing 14 changed files with 33 additions and 615 deletions.
98 changes: 0 additions & 98 deletions docs/generated/cli/affected-apps.md

This file was deleted.

98 changes: 0 additions & 98 deletions docs/generated/cli/affected-libs.md

This file was deleted.

16 changes: 0 additions & 16 deletions docs/generated/manifests/menus.json
Original file line number Diff line number Diff line change
@@ -5374,22 +5374,6 @@
"children": [],
"disableCollapsible": false
},
{
"name": "affected:apps",
"path": "/packages/nx/documents/affected-apps",
"id": "affected-apps",
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "affected:libs",
"path": "/packages/nx/documents/affected-libs",
"id": "affected-libs",
"isExternal": false,
"children": [],
"disableCollapsible": false
},
{
"name": "print-affected",
"path": "/packages/nx/documents/print-affected",
22 changes: 0 additions & 22 deletions docs/generated/manifests/packages.json
Original file line number Diff line number Diff line change
@@ -1558,28 +1558,6 @@
"tags": [],
"originalFilePath": "generated/cli/affected-graph"
},
"/packages/nx/documents/affected-apps": {
"id": "affected-apps",
"name": "affected:apps",
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
"file": "generated/packages/nx/documents/affected-apps",
"itemList": [],
"isExternal": false,
"path": "/packages/nx/documents/affected-apps",
"tags": [],
"originalFilePath": "generated/cli/affected-apps"
},
"/packages/nx/documents/affected-libs": {
"id": "affected-libs",
"name": "affected:libs",
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
"file": "generated/packages/nx/documents/affected-libs",
"itemList": [],
"isExternal": false,
"path": "/packages/nx/documents/affected-libs",
"tags": [],
"originalFilePath": "generated/cli/affected-libs"
},
"/packages/nx/documents/print-affected": {
"id": "print-affected",
"name": "print-affected",
22 changes: 0 additions & 22 deletions docs/generated/packages-metadata.json
Original file line number Diff line number Diff line change
@@ -1539,28 +1539,6 @@
"tags": [],
"originalFilePath": "generated/cli/affected-graph"
},
{
"id": "affected-apps",
"name": "affected:apps",
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
"file": "generated/packages/nx/documents/affected-apps",
"itemList": [],
"isExternal": false,
"path": "nx/documents/affected-apps",
"tags": [],
"originalFilePath": "generated/cli/affected-apps"
},
{
"id": "affected-libs",
"name": "affected:libs",
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
"file": "generated/packages/nx/documents/affected-libs",
"itemList": [],
"isExternal": false,
"path": "nx/documents/affected-libs",
"tags": [],
"originalFilePath": "generated/cli/affected-libs"
},
{
"id": "print-affected",
"name": "print-affected",
98 changes: 0 additions & 98 deletions docs/generated/packages/nx/documents/affected-apps.md

This file was deleted.

98 changes: 0 additions & 98 deletions docs/generated/packages/nx/documents/affected-libs.md

This file was deleted.

10 changes: 0 additions & 10 deletions docs/map.json
Original file line number Diff line number Diff line change
@@ -1532,16 +1532,6 @@
"id": "affected-dep-graph",
"file": "generated/cli/affected-graph"
},
{
"name": "affected:apps",
"id": "affected-apps",
"file": "generated/cli/affected-apps"
},
{
"name": "affected:libs",
"id": "affected-libs",
"file": "generated/cli/affected-libs"
},
{
"name": "print-affected",
"id": "print-affected",
2 changes: 0 additions & 2 deletions docs/shared/reference/commands.md
Original file line number Diff line number Diff line change
@@ -9,8 +9,6 @@
- [run-many](/packages/nx/documents/run-many)
- [affected](/packages/nx/documents/affected)
- [affected:graph](/packages/nx/documents/affected-dep-graph)
- [affected:apps](/packages/nx/documents/affected-apps)
- [affected:libs](/packages/nx/documents/affected-libs)
- [print-affected](/packages/nx/documents/print-affected)
- [format:check](/packages/nx/documents/format-check)
- [format:write](/packages/nx/documents/format-write)
66 changes: 32 additions & 34 deletions e2e/nx-run/src/affected-graph.test.ts
Original file line number Diff line number Diff line change
@@ -63,63 +63,58 @@ describe('Nx Affected and Graph Tests', () => {
});
`
);
expect(
(
await runCLIAsync(
`affected:apps --files="libs/${mylib}/src/index.ts" --plain`,
{ silent: true }
)
).stdout.trim()
).toEqual(myapp);

const affectedApps = runCLI(
`affected:apps --files="libs/${mylib}/src/index.ts"`
`print-affected --files="libs/${mylib}/src/index.ts" --select projects`
);
expect(affectedApps).toContain(myapp);
expect(affectedApps).not.toContain(myapp2);
expect(affectedApps).not.toContain(`${myapp}-e2e`);

const implicitlyAffectedApps = runCLI(
'affected:apps --files="tsconfig.base.json"'
'print-affected --select projects --files="tsconfig.base.json"'
);
expect(implicitlyAffectedApps).toContain(myapp);
expect(implicitlyAffectedApps).toContain(myapp2);

const noAffectedApps = runCLI('affected:apps --files="README.md"');
const noAffectedApps = runCLI(
'print-affected --select projects --files="README.md"'
);
expect(noAffectedApps).not.toContain(myapp);
expect(noAffectedApps).not.toContain(myapp2);

expect(
(
await runCLIAsync(
`affected:libs --files="libs/${mylib}/src/index.ts" --plain`,
`print-affected --select projects --files="libs/${mylib}/src/index.ts"`,
{ silent: true }
)
).stdout.trim()
).toEqual(`${mylib} ${mypublishablelib}`);

const affectedLibs = runCLI(
`affected:libs --files="libs/${mylib}/src/index.ts"`
`print-affected --select projects --files="libs/${mylib}/src/index.ts"`
);
expect(affectedLibs).toContain(mypublishablelib);
expect(affectedLibs).toContain(mylib);
expect(affectedLibs).not.toContain(mylib2);

const implicitlyAffectedLibs = runCLI(
'affected:libs --files="tsconfig.base.json"'
'print-affected --select projects --files="tsconfig.base.json"'
);
expect(implicitlyAffectedLibs).toContain(mypublishablelib);
expect(implicitlyAffectedLibs).toContain(mylib);
expect(implicitlyAffectedLibs).toContain(mylib2);

const noAffectedLibsNonExistentFile = runCLI(
'affected:libs --files="tsconfig.json"'
'print-affected --select projects --files="tsconfig.json"'
);
expect(noAffectedLibsNonExistentFile).not.toContain(mypublishablelib);
expect(noAffectedLibsNonExistentFile).not.toContain(mylib);
expect(noAffectedLibsNonExistentFile).not.toContain(mylib2);

const noAffectedLibs = runCLI('affected:libs --files="README.md"');
const noAffectedLibs = runCLI(
'print-affected --select projects --files="README.md"'
);
expect(noAffectedLibs).not.toContain(mypublishablelib);
expect(noAffectedLibs).not.toContain(mylib);
expect(noAffectedLibs).not.toContain(mylib2);
@@ -211,18 +206,20 @@ describe('Nx Affected and Graph Tests', () => {
// TODO: investigate why affected gives different results on windows
if (isNotWindows()) {
runCLI(`generate @nrwl/web:app ${myapp}`);
expect(runCLI('affected:apps')).toContain(myapp);
expect(runCLI('print-affected --select projects')).toContain(myapp);
runCommand(`git add . && git commit -am "add ${myapp}"`);

runCLI(`generate @nrwl/web:app ${myapp2}`);
expect(runCLI('affected:apps')).not.toContain(myapp);
expect(runCLI('affected:apps')).toContain(myapp2);
let output = runCLI('print-affected --select projects');
expect(output).not.toContain(myapp);
expect(output).toContain(myapp2);
runCommand(`git add . && git commit -am "add ${myapp2}"`);

runCLI(`generate @nrwl/js:lib ${mylib}`);
expect(runCLI('affected:apps')).not.toContain(myapp);
expect(runCLI('affected:apps')).not.toContain(myapp2);
expect(runCLI('affected:libs')).toContain(mylib);
output = runCLI('print-affected --select projects');
expect(output).not.toContain(myapp);
expect(output).not.toContain(myapp2);
expect(output).toContain(mylib);
}
}, 1000000);

@@ -234,19 +231,21 @@ describe('Nx Affected and Graph Tests', () => {
...config,
tags: ['tag'],
}));
expect(runCLI('affected:apps')).toContain(myapp);
expect(runCLI('affected:apps')).not.toContain(myapp2);
expect(runCLI('affected:libs')).not.toContain(mylib);
const output = runCLI('print-affected --select projects');
expect(output).toContain(myapp);
expect(output).not.toContain(myapp2);
expect(output).not.toContain(mylib);
}
});

it('should affect all projects by removing projects', () => {
generateAll();
const root = readResolvedConfiguration().projects[mylib].root;
removeFile(root);
expect(runCLI('affected:apps')).toContain(myapp);
expect(runCLI('affected:apps')).toContain(myapp2);
expect(runCLI('affected:libs')).not.toContain(mylib);
const output = runCLI('print-affected --select projects');
expect(output).toContain(myapp);
expect(output).toContain(myapp2);
expect(output).not.toContain(mylib);
});

it('should detect changes to implicitly dependant projects', () => {
@@ -259,12 +258,11 @@ describe('Nx Affected and Graph Tests', () => {
runCommand('git commit -m "setup test"');
updateFile(`libs/${mylib}/index.html`, '<html></html>');

const affectedApps = runCLI('affected:apps');
const affectedLibs = runCLI('affected:libs');
const output = runCLI('print-affected --select projects');

expect(affectedApps).toContain(myapp);
expect(affectedApps).not.toContain(myapp2);
expect(affectedLibs).toContain(mylib);
expect(output).toContain(myapp);
expect(output).not.toContain(myapp2);
expect(output).toContain(mylib);

// Clear implicit deps to not interfere with other tests.
updateProjectConfig(myapp, (config) => ({
2 changes: 0 additions & 2 deletions nx-dev/nx-dev-e2e/src/e2e/additional-api-references.cy.ts
Original file line number Diff line number Diff line change
@@ -14,8 +14,6 @@ describe('nx-dev: Additional API references section', () => {
{ title: 'run-many', path: '/cli/run-many' },
{ title: 'affected', path: '/cli/affected' },
{ title: 'affected:graph', path: '/cli/affected-dep-graph' },
{ title: 'affected:apps', path: '/cli/affected-apps' },
{ title: 'affected:libs', path: '/cli/affected-libs' },
{ title: 'print-affected', path: '/cli/print-affected' },
{ title: 'format:check', path: '/cli/format-check' },
{ title: 'format:write', path: '/cli/format-write' },
42 changes: 1 addition & 41 deletions packages/nx/src/command-line/affected.ts
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ import { workspaceConfigurationCheck } from '../utils/workspace-configuration-ch
import { findMatchingProjects } from '../utils/find-matching-projects';

export async function affected(
command: 'apps' | 'libs' | 'graph' | 'print-affected' | 'affected',
command: 'graph' | 'print-affected' | 'affected',
args: { [k: string]: any },
extraTargetDependencies: Record<
string,
@@ -51,46 +51,6 @@ export async function affected(

try {
switch (command) {
case 'apps':
const apps = projects
.filter((p) => p.type === 'app')
.map((p) => p.name);
if (args.plain) {
console.log(apps.join(' '));
} else {
if (apps.length) {
output.warn({
title:
'Deprecated: Use "nx print-affected --type=app --select=projects" instead. This command will be removed in v16.',
});
output.log({
title: 'Affected apps:',
bodyLines: apps.map((app) => `${output.dim('-')} ${app}`),
});
}
}
break;

case 'libs':
const libs = projects
.filter((p) => p.type === 'lib')
.map((p) => p.name);
if (args.plain) {
console.log(libs.join(' '));
} else {
if (libs.length) {
output.warn({
title:
'Deprecated: Use "nx print-affected --type=lib --select=projects" instead. This command will be removed in v16.',
});
output.log({
title: 'Affected libs:',
bodyLines: libs.map((lib) => `${output.dim('-')} ${lib}`),
});
}
}
break;

case 'graph':
const projectNames = projects.map((p) => p.name);
await generateGraph(args as any, projectNames);
34 changes: 0 additions & 34 deletions packages/nx/src/command-line/examples.ts
Original file line number Diff line number Diff line change
@@ -169,40 +169,6 @@ export const examples: Record<string, Example[]> = {
'Run lint for all the projects affected by the last commit on main',
},
],
'affected:apps': [
{
command: 'affected:apps --files=libs/mylib/src/index.ts',
description:
'Print the names of all the apps affected by changing the index.ts file',
},
{
command: 'affected:apps --base=main --head=HEAD',
description:
'Print the names of all the apps affected by the changes between main and HEAD (e.g., PR)',
},
{
command: 'affected:apps --base=main~1 --head=main',
description:
'Print the names of all the apps affected by the last commit on main',
},
],
'affected:libs': [
{
command: 'affected:libs --files=libs/mylib/src/index.ts',
description:
'Print the names of all the libs affected by changing the index.ts file',
},
{
command: 'affected:libs --base=main --head=HEAD',
description:
'Print the names of all the libs affected by the changes between main and HEAD (e.g., PR)',
},
{
command: 'affected:libs --base=main~1 --head=main',
description:
'Print the names of all the libs affected by the last commit on main',
},
],
'format:write': [],
'format:check': [],
graph: [
40 changes: 0 additions & 40 deletions packages/nx/src/command-line/nx-commands.ts
Original file line number Diff line number Diff line change
@@ -149,40 +149,6 @@ export const commandsObject = yargs
target: 'e2e',
}),
})
.command({
command: 'affected:apps',
deprecated:
'Use `nx print-affected --type=app --select=projects` instead. This command will be removed in v15.',
describe: `Print applications affected by changes`,
builder: (yargs) =>
linkToNxDevAndExamples(
withAffectedOptions(withPlainOption(yargs)),
'affected:apps'
),
handler: async (args) => {
await (await import('./affected')).affected('apps', { ...args });
process.exit(0);
},
})
.command({
command: 'affected:libs',
deprecated:
'Use `nx print-affected --type=lib --select=projects` instead. This command will be removed in v15.',
describe: 'Print libraries affected by changes',
builder: (yargs) =>
linkToNxDevAndExamples(
withAffectedOptions(withPlainOption(yargs)),
'affected:libs'
),
handler: async (args) => {
await (
await import('./affected')
).affected('libs', {
...args,
});
process.exit(0);
},
})
.command({
command: 'affected:graph',
describe: 'Graph dependencies affected by changes',
@@ -472,12 +438,6 @@ function withPrintAffectedOptions(yargs: yargs.Argv): yargs.Argv {
});
}

function withPlainOption(yargs: yargs.Argv): yargs.Argv {
return yargs.option('plain', {
describe: 'Produces a plain output for affected:apps and affected:libs',
});
}

function withExcludeOption(yargs: yargs.Argv): yargs.Argv {
return yargs.option('exclude', {
describe: 'Exclude certain projects from being processed',

0 comments on commit 7b65bb4

Please sign in to comment.