Skip to content

Commit

Permalink
feat(nx): refactor nx list to also show plugins with builders and uni…
Browse files Browse the repository at this point in the history
…nstalled approved plugins
  • Loading branch information
jdpearce authored and vsavkin committed Nov 11, 2019
1 parent 58dba00 commit 607bcfd
Show file tree
Hide file tree
Showing 20 changed files with 525 additions and 246 deletions.
41 changes: 41 additions & 0 deletions docs/angular/api-workspace/npmscripts/list-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# list [plugin]

Lists installed plugins, capabilities of installed plugins and other available plugins.

## Usage

```bash
nx list [plugin]
```

Install `@nrwl/cli` globally to invoke the command directly using `nx`, or use `npm run nx` or `yarn nx`.

### Examples

List the plugins installed in the current workspace:

```bash
nx list
```

List the schematics and builders available in the `@nrwl/web` plugin if it is installed (If the plugin is not installed `nx` will show advice on how to add it to your workspace):

```bash
nx list @nrwl/web
```

## Options

### help

Show help

### plugin

Default: `null`

The name of an installed plugin to query

### version

Show version number
35 changes: 0 additions & 35 deletions docs/angular/api-workspace/npmscripts/list-schematic-collection.md

This file was deleted.

6 changes: 4 additions & 2 deletions docs/angular/getting-started/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,18 @@ Nx comes with a `list` feature which enables you to see the capabilities that ha
nx list
```

This will output a list of all the collections you have just added, alongside some that Angular comes with out of the box like `@schematics/angular`.
This will output a list of all the plugins you have just added, alongside some that Angular comes with out of the box like `@schematics/angular`.

To list the capabilities within a specific collection :
To list the capabilities within a specific plugin :

```bash
nx list @nrwl/web
```

This will list all the capabilities in the `@nrwl/web` collection.

`nx list` will also output a list of Nrwl-approved plugins that you may want to consider adding to your workspace.

## Creating an application

After the capability is added, you can now create your first application via:
Expand Down
41 changes: 41 additions & 0 deletions docs/react/api-workspace/npmscripts/list-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# list [plugin]

Lists installed plugins, capabilities of installed plugins and other available plugins.

## Usage

```bash
nx list [plugin]
```

Install `@nrwl/cli` globally to invoke the command directly using `nx`, or use `npm run nx` or `yarn nx`.

### Examples

List the plugins installed in the current workspace:

```bash
nx list
```

List the schematics and builders available in the `@nrwl/web` plugin if it is installed (If the plugin is not installed `nx` will show advice on how to add it to your workspace):

```bash
nx list @nrwl/web
```

## Options

### help

Show help

### plugin

Default: `null`

The name of an installed plugin to query

### version

Show version number
35 changes: 0 additions & 35 deletions docs/react/api-workspace/npmscripts/list-schematic-collection.md

This file was deleted.

2 changes: 2 additions & 0 deletions docs/react/guides/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ nx list @nrwl/web

This will list all the schematics in the `@nrwl/web` collection.

`nx list` will also output a list of Nrwl-approved plugins that you may want to consider adding to your workspace.

> Visit the [CLI Commands](/react/guides/cli#cli-commands) section to see more available commands.
## Workspaces and project files
Expand Down
41 changes: 41 additions & 0 deletions docs/web/api-workspace/npmscripts/list-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# list [plugin]

Lists installed plugins, capabilities of installed plugins and other available plugins.

## Usage

```bash
nx list [plugin]
```

Install `@nrwl/cli` globally to invoke the command directly using `nx`, or use `npm run nx` or `yarn nx`.

### Examples

List the plugins installed in the current workspace:

```bash
nx list
```

List the schematics and builders available in the `@nrwl/web` plugin if it is installed (If the plugin is not installed `nx` will show advice on how to add it to your workspace):

```bash
nx list @nrwl/web
```

## Options

### help

Show help

### plugin

Default: `null`

The name of an installed plugin to query

### version

Show version number
35 changes: 0 additions & 35 deletions docs/web/api-workspace/npmscripts/list-schematic-collection.md

This file was deleted.

2 changes: 2 additions & 0 deletions docs/web/guides/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ nx list @nrwl/web

This will list all the schematics in the `@nrwl/web` collection.

`nx list` will also output a list of Nrwl-approved plugins that you may want to consider adding to your workspace.

> Visit the [CLI Commands](/web/guides/cli#cli-commands) section to see more available commands.
## Workspaces and project files
Expand Down
18 changes: 13 additions & 5 deletions e2e/help.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { forEachCli, ensureProject, runCommand, runCLI, cli } from './utils';
import { ensureProject, forEachCli, runCLI } from './utils';

forEachCli('nx', () => {
describe('Help', () => {
it('should should help', async () => {
it('should show help', async () => {
ensureProject();

const mainHelp = runCLI(`--help`);
let mainHelp = runCLI(`--help`);
expect(mainHelp).toContain('Run a target for a project');
expect(mainHelp).toContain('Run task for affected projects');

mainHelp = runCLI(`help`);
expect(mainHelp).toContain('Run a target for a project');
expect(mainHelp).toContain('Run task for affected projects');

Expand All @@ -25,10 +29,14 @@ forEachCli('nx', () => {

forEachCli('angular', () => {
describe('Help', () => {
it('should should help', async () => {
it('should show help', async () => {
ensureProject();

const mainHelp = runCLI(`--help`);
let mainHelp = runCLI(`--help`);
expect(mainHelp).toContain('Run a target for a project');
expect(mainHelp).toContain('Run task for affected projects');

mainHelp = runCLI(`help`);
expect(mainHelp).toContain('Run a target for a project');
expect(mainHelp).toContain('Run task for affected projects');

Expand Down
64 changes: 48 additions & 16 deletions e2e/list.test.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,69 @@
import { ensureProject, forEachCli, runCommand } from './utils';
import { renameSync } from 'fs';
import { forEachCli, newProject, runCommand, tmpProjPath } from './utils';

const testTimeout = 120000;

forEachCli(() => {
describe('list', () => {
beforeEach(() => {
ensureProject();
newProject();
});

it(
`should list available collections`,
`should work`,
async () => {
const listOutput = runCommand('npm run nx list');
let listOutput = runCommand('npm run nx -- list');

expect(listOutput).toContain('NX Installed plugins');

expect(listOutput).toContain('Available collections');
// just check for some, not all
expect(listOutput).toContain('@nrwl/angular');
expect(listOutput).toContain('@schematics/angular');
expect(listOutput).toContain('@ngrx/store');
},
testTimeout
);

it(
`should list available schematics in a collection`,
async () => {
const listOutput = runCommand('npm run nx list @nrwl/angular');
expect(listOutput).not.toContain('NX Also available');

expect(listOutput).toContain('Available schematics in @nrwl/angular');
// just check for some, not all
expect(listOutput).toContain('init');
expect(listOutput).toContain('application');
// temporarily make it look like this isn't installed
renameSync(
tmpProjPath('node_modules/@nrwl/angular'),
tmpProjPath('node_modules/@nrwl/angular_tmp')
);

listOutput = runCommand('npm run nx -- list');
expect(listOutput).toContain('NX Also available');

// look for specific plugin
listOutput = runCommand('npm run nx -- list @nrwl/workspace');

expect(listOutput).toContain('Capabilities in @nrwl/workspace');

// check for schematics
expect(listOutput).toContain('workspace');
expect(listOutput).toContain('ng-add');
expect(listOutput).toContain('library');

// check for builders
expect(listOutput).toContain('run-commands');

// look for uninstalled approved plugin
listOutput = runCommand('npm run nx -- list @nrwl/angular');

expect(listOutput).toContain(
'NX NOTE @nrwl/angular is not currently installed'
);

// look for an unknown plugin
listOutput = runCommand('npm run nx -- list @wibble/fish');

expect(listOutput).toContain(
'NX ERROR Could not find plugin @wibble/fish'
);

// put back the @nrwl/angular module (or all the other e2e tests after this will fail)
renameSync(
tmpProjPath('node_modules/@nrwl/angular_tmp'),
tmpProjPath('node_modules/@nrwl/angular')
);
},
testTimeout
);
Expand Down

0 comments on commit 607bcfd

Please sign in to comment.