diff --git a/docs/generated/cli/affected-apps.md b/docs/generated/cli/affected-apps.md deleted file mode 100644 index 061a8f679aa930..00000000000000 --- a/docs/generated/cli/affected-apps.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -title: 'affected:apps - CLI command' -description: 'Print applications affected by changes' ---- - -# affected:apps - - **Deprecated:** Use `nx print-affected --type=app --select=projects` instead. This command will be removed in v15. - - Print applications affected by changes - -## Usage - -```shell -nx affected:apps -``` - -Install `nx` globally to invoke the command directly using `nx`, or use `npx nx`, `yarn nx`, or `pnpm nx`. - -### Examples - -Print the names of all the apps affected by changing the index.ts file: - -```shell - nx affected:apps --files=libs/mylib/src/index.ts -``` - -Print the names of all the apps affected by the changes between main and HEAD (e.g., PR): - -```shell - nx affected:apps --base=main --head=HEAD -``` - -Print the names of all the apps affected by the last commit on main: - -```shell - nx affected:apps --base=main~1 --head=main -``` - -## Options - -### all - -Type: `boolean` - -All projects - -### base - -Type: `string` - -Base of the current branch (usually main) - -### exclude - -Type: `string` - -Exclude certain projects from being processed - -### files - -Type: `string` - -Change the way Nx is calculating the affected command by providing directly changed files, list of files delimited by commas or spaces - -### head - -Type: `string` - -Latest commit of the current branch (usually HEAD) - -### help - -Type: `boolean` - -Show help - -### plain - -Produces a plain output for affected:apps and affected:libs - -### uncommitted - -Type: `boolean` - -Uncommitted changes - -### untracked - -Type: `boolean` - -Untracked changes - -### version - -Type: `boolean` - -Show version number diff --git a/docs/generated/cli/affected-libs.md b/docs/generated/cli/affected-libs.md deleted file mode 100644 index 392bf868686cbc..00000000000000 --- a/docs/generated/cli/affected-libs.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -title: 'affected:libs - CLI command' -description: 'Print libraries affected by changes' ---- - -# affected:libs - - **Deprecated:** Use `nx print-affected --type=lib --select=projects` instead. This command will be removed in v15. - - Print libraries affected by changes - -## Usage - -```shell -nx affected:libs -``` - -Install `nx` globally to invoke the command directly using `nx`, or use `npx nx`, `yarn nx`, or `pnpm nx`. - -### Examples - -Print the names of all the libs affected by changing the index.ts file: - -```shell - nx affected:libs --files=libs/mylib/src/index.ts -``` - -Print the names of all the libs affected by the changes between main and HEAD (e.g., PR): - -```shell - nx affected:libs --base=main --head=HEAD -``` - -Print the names of all the libs affected by the last commit on main: - -```shell - nx affected:libs --base=main~1 --head=main -``` - -## Options - -### all - -Type: `boolean` - -All projects - -### base - -Type: `string` - -Base of the current branch (usually main) - -### exclude - -Type: `string` - -Exclude certain projects from being processed - -### files - -Type: `string` - -Change the way Nx is calculating the affected command by providing directly changed files, list of files delimited by commas or spaces - -### head - -Type: `string` - -Latest commit of the current branch (usually HEAD) - -### help - -Type: `boolean` - -Show help - -### plain - -Produces a plain output for affected:apps and affected:libs - -### uncommitted - -Type: `boolean` - -Uncommitted changes - -### untracked - -Type: `boolean` - -Untracked changes - -### version - -Type: `boolean` - -Show version number diff --git a/docs/generated/manifests/menus.json b/docs/generated/manifests/menus.json index 128975e487624e..d5b1fa2bab068e 100644 --- a/docs/generated/manifests/menus.json +++ b/docs/generated/manifests/menus.json @@ -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", diff --git a/docs/generated/manifests/packages.json b/docs/generated/manifests/packages.json index 0c2ca9e99dcd5d..9495624119a214 100644 --- a/docs/generated/manifests/packages.json +++ b/docs/generated/manifests/packages.json @@ -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", diff --git a/docs/generated/packages-metadata.json b/docs/generated/packages-metadata.json index 297d4fa1ee4c05..23ddbf677d58a7 100644 --- a/docs/generated/packages-metadata.json +++ b/docs/generated/packages-metadata.json @@ -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", diff --git a/docs/generated/packages/nx/documents/affected-apps.md b/docs/generated/packages/nx/documents/affected-apps.md deleted file mode 100644 index 061a8f679aa930..00000000000000 --- a/docs/generated/packages/nx/documents/affected-apps.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -title: 'affected:apps - CLI command' -description: 'Print applications affected by changes' ---- - -# affected:apps - - **Deprecated:** Use `nx print-affected --type=app --select=projects` instead. This command will be removed in v15. - - Print applications affected by changes - -## Usage - -```shell -nx affected:apps -``` - -Install `nx` globally to invoke the command directly using `nx`, or use `npx nx`, `yarn nx`, or `pnpm nx`. - -### Examples - -Print the names of all the apps affected by changing the index.ts file: - -```shell - nx affected:apps --files=libs/mylib/src/index.ts -``` - -Print the names of all the apps affected by the changes between main and HEAD (e.g., PR): - -```shell - nx affected:apps --base=main --head=HEAD -``` - -Print the names of all the apps affected by the last commit on main: - -```shell - nx affected:apps --base=main~1 --head=main -``` - -## Options - -### all - -Type: `boolean` - -All projects - -### base - -Type: `string` - -Base of the current branch (usually main) - -### exclude - -Type: `string` - -Exclude certain projects from being processed - -### files - -Type: `string` - -Change the way Nx is calculating the affected command by providing directly changed files, list of files delimited by commas or spaces - -### head - -Type: `string` - -Latest commit of the current branch (usually HEAD) - -### help - -Type: `boolean` - -Show help - -### plain - -Produces a plain output for affected:apps and affected:libs - -### uncommitted - -Type: `boolean` - -Uncommitted changes - -### untracked - -Type: `boolean` - -Untracked changes - -### version - -Type: `boolean` - -Show version number diff --git a/docs/generated/packages/nx/documents/affected-libs.md b/docs/generated/packages/nx/documents/affected-libs.md deleted file mode 100644 index 392bf868686cbc..00000000000000 --- a/docs/generated/packages/nx/documents/affected-libs.md +++ /dev/null @@ -1,98 +0,0 @@ ---- -title: 'affected:libs - CLI command' -description: 'Print libraries affected by changes' ---- - -# affected:libs - - **Deprecated:** Use `nx print-affected --type=lib --select=projects` instead. This command will be removed in v15. - - Print libraries affected by changes - -## Usage - -```shell -nx affected:libs -``` - -Install `nx` globally to invoke the command directly using `nx`, or use `npx nx`, `yarn nx`, or `pnpm nx`. - -### Examples - -Print the names of all the libs affected by changing the index.ts file: - -```shell - nx affected:libs --files=libs/mylib/src/index.ts -``` - -Print the names of all the libs affected by the changes between main and HEAD (e.g., PR): - -```shell - nx affected:libs --base=main --head=HEAD -``` - -Print the names of all the libs affected by the last commit on main: - -```shell - nx affected:libs --base=main~1 --head=main -``` - -## Options - -### all - -Type: `boolean` - -All projects - -### base - -Type: `string` - -Base of the current branch (usually main) - -### exclude - -Type: `string` - -Exclude certain projects from being processed - -### files - -Type: `string` - -Change the way Nx is calculating the affected command by providing directly changed files, list of files delimited by commas or spaces - -### head - -Type: `string` - -Latest commit of the current branch (usually HEAD) - -### help - -Type: `boolean` - -Show help - -### plain - -Produces a plain output for affected:apps and affected:libs - -### uncommitted - -Type: `boolean` - -Uncommitted changes - -### untracked - -Type: `boolean` - -Untracked changes - -### version - -Type: `boolean` - -Show version number diff --git a/docs/map.json b/docs/map.json index 5346792d787eeb..92c720ace174e2 100644 --- a/docs/map.json +++ b/docs/map.json @@ -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", diff --git a/docs/shared/reference/commands.md b/docs/shared/reference/commands.md index a1107722ff8d3d..5847225a0b1a97 100644 --- a/docs/shared/reference/commands.md +++ b/docs/shared/reference/commands.md @@ -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) diff --git a/e2e/nx-run/src/affected-graph.test.ts b/e2e/nx-run/src/affected-graph.test.ts index 3098d538d4814c..82d025d5cf3262 100644 --- a/e2e/nx-run/src/affected-graph.test.ts +++ b/e2e/nx-run/src/affected-graph.test.ts @@ -66,60 +66,64 @@ describe('Nx Affected and Graph Tests', () => { expect( ( await runCLIAsync( - `affected:apps --files="libs/${mylib}/src/index.ts" --plain`, + `print-affected --select projects --files="libs/${mylib}/src/index.ts"`, { 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 +215,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(runCLI(output)).not.toContain(myapp); + expect(runCLI(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,9 +240,10 @@ 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); } }); @@ -244,9 +251,10 @@ describe('Nx Affected and Graph Tests', () => { 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 +267,11 @@ describe('Nx Affected and Graph Tests', () => { runCommand('git commit -m "setup test"'); updateFile(`libs/${mylib}/index.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) => ({ diff --git a/nx-dev/nx-dev-e2e/src/e2e/additional-api-references.cy.ts b/nx-dev/nx-dev-e2e/src/e2e/additional-api-references.cy.ts index 5bfc2c9246bbc7..16d94dd474e6f3 100644 --- a/nx-dev/nx-dev-e2e/src/e2e/additional-api-references.cy.ts +++ b/nx-dev/nx-dev-e2e/src/e2e/additional-api-references.cy.ts @@ -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' }, diff --git a/packages/nx/src/command-line/affected.ts b/packages/nx/src/command-line/affected.ts index e4102a0a05485a..5e16d4bc1047b9 100644 --- a/packages/nx/src/command-line/affected.ts +++ b/packages/nx/src/command-line/affected.ts @@ -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); diff --git a/packages/nx/src/command-line/examples.ts b/packages/nx/src/command-line/examples.ts index 8c0d598ab1cf7a..1f80509e4163a6 100644 --- a/packages/nx/src/command-line/examples.ts +++ b/packages/nx/src/command-line/examples.ts @@ -169,40 +169,6 @@ export const examples: Record = { '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: [ diff --git a/packages/nx/src/command-line/nx-commands.ts b/packages/nx/src/command-line/nx-commands.ts index 3c1a2eac6ecec1..994f2d141bbad9 100644 --- a/packages/nx/src/command-line/nx-commands.ts +++ b/packages/nx/src/command-line/nx-commands.ts @@ -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',