Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add a variety of usages for nx show #17073

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions docs/generated/cli/show.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ Show all projects in the workspace:
nx show projects
```

Show all projects with names starting with "api-". The pattern option is useful to see which projects would be selected by run-many.:

```shell
nx show projects --pattern=api-*
```

Show all projects with a serve target:

```shell
nx show projects --with-target serve
```

Show affected projects in the workspace:

```shell
Expand All @@ -35,6 +47,18 @@ Show affected projects in the workspace, excluding end-to-end projects:
nx show projects --affected --exclude *-e2e
```

Show detailed information about "my-app" in a json format.:

```shell
nx show project my-app
```

Show information about "my-app" in a human readable format.:

```shell
nx show project my-app --json false
```

## Options

### help
Expand All @@ -43,6 +67,12 @@ Type: `boolean`

Show help

### json

Type: `boolean`

Output JSON

### version

Type: `boolean`
Expand Down Expand Up @@ -97,6 +127,12 @@ Type: `boolean`

Show help

##### projects

Type: `string`

Show only projects that match a given pattern.

##### uncommitted

Type: `boolean`
Expand All @@ -114,3 +150,37 @@ Untracked changes
Type: `boolean`

Show version number

##### withTarget

Type: `string`

Show only projects that have a specific target

### project

Show a list of targets in the workspace.

```shell
nx show project <projectName>
```

#### Options

##### help

Type: `boolean`

Show help

##### projectName

Type: `string`

Show targets for the given project

##### version

Type: `boolean`

Show version number
70 changes: 70 additions & 0 deletions docs/generated/packages/nx/documents/show.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ Show all projects in the workspace:
nx show projects
```

Show all projects with names starting with "api-". The pattern option is useful to see which projects would be selected by run-many.:

```shell
nx show projects --pattern=api-*
```

Show all projects with a serve target:

```shell
nx show projects --with-target serve
```

Show affected projects in the workspace:

```shell
Expand All @@ -35,6 +47,18 @@ Show affected projects in the workspace, excluding end-to-end projects:
nx show projects --affected --exclude *-e2e
```

Show detailed information about "my-app" in a json format.:

```shell
nx show project my-app
```

Show information about "my-app" in a human readable format.:

```shell
nx show project my-app --json false
```

## Options

### help
Expand All @@ -43,6 +67,12 @@ Type: `boolean`

Show help

### json

Type: `boolean`

Output JSON

### version

Type: `boolean`
Expand Down Expand Up @@ -97,6 +127,12 @@ Type: `boolean`

Show help

##### projects

Type: `string`

Show only projects that match a given pattern.

##### uncommitted

Type: `boolean`
Expand All @@ -114,3 +150,37 @@ Untracked changes
Type: `boolean`

Show version number

##### withTarget

Type: `string`

Show only projects that have a specific target

### project

Show a list of targets in the workspace.

```shell
nx show project <projectName>
```

#### Options

##### help

Type: `boolean`

Show help

##### projectName

Type: `string`

Show targets for the given project

##### version

Type: `boolean`

Show version number
22 changes: 20 additions & 2 deletions e2e/nx-misc/src/misc.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NxJsonConfiguration } from '@nx/devkit';
import type { NxJsonConfiguration, ProjectConfiguration } from '@nx/devkit';
import {
cleanupProject,
createNonNxProjectDirectory,
Expand Down Expand Up @@ -37,7 +37,7 @@ describe('Nx Commands', () => {
runCLI('show projects').replace(/.*nx show projects( --verbose)?\n/, '')
).toEqual('');

runCLI(`generate @nx/web:app ${app1}`);
runCLI(`generate @nx/web:app ${app1} --tags e2etag`);
runCLI(`generate @nx/web:app ${app2}`);

const s = runCLI('show projects').split('\n');
Expand All @@ -47,6 +47,24 @@ describe('Nx Commands', () => {
expect(s).toContain(app2);
expect(s).toContain(`${app1}-e2e`);
expect(s).toContain(`${app2}-e2e`);

const withTag = JSON.parse(runCLI('show projects -p tag:e2etag --json'));
expect(withTag).toEqual([app1]);

const withTargets = JSON.parse(
runCLI('show projects --with-target e2e --json')
);
expect(withTargets).toEqual([`${app1}-e2e`, `${app2}-e2e`]);
});

it('should show detailed project info', () => {
const app = uniq('myapp');
runCLI(`generate @nx/web:app ${app}`);
const project: ProjectConfiguration = JSON.parse(
runCLI(`show project ${app}`)
);
expect(project.targets.build).toBeDefined();
expect(project.targets.lint).toBeDefined();
});
});

Expand Down
3 changes: 1 addition & 2 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,5 @@
"build-storybook": {
"inputs": ["default", "^production", "{workspaceRoot}/.storybook/**/*"]
}
},
"plugins": ["@monodon/rust"]
}
}
22 changes: 22 additions & 0 deletions packages/nx/src/command-line/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,17 @@ export const examples: Record<string, Example[]> = {
description: 'Show all projects in the workspace',
},

{
command: 'show projects --pattern=api-*',
description:
'Show all projects with names starting with "api-". The pattern option is useful to see which projects would be selected by run-many.',
},

{
command: 'show projects --with-target serve',
description: 'Show all projects with a serve target',
},

{
command: 'show projects --affected',
description: 'Show affected projects in the workspace',
Expand All @@ -355,6 +366,17 @@ export const examples: Record<string, Example[]> = {
description:
'Show affected projects in the workspace, excluding end-to-end projects',
},

{
command: 'show project my-app',
description: 'Show detailed information about "my-app" in a json format.',
},

{
command: 'show project my-app --json false',
description:
'Show information about "my-app" in a human readable format.',
},
],
watch: [
{
Expand Down
Loading