Skip to content

Commit c8e6e95

Browse files
committed
feat: consistent naming for generators
Renamed generators to have consistent names: `trpc#api` -> `ts#trpc-api` `ts#lib` -> `ts#project` `cloudscape-website#app` -> `ts#cloudscape-website` `cloudscape-website#cognito-auth` -> `ts#cloudscape-website#auth` `infra#app` -> `ts#infra`
1 parent 67aa51d commit c8e6e95

File tree

18 files changed

+213
-76
lines changed

18 files changed

+213
-76
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pnpm nx serve docs
2323
## Examples
2424

2525
```
26-
pnpm nx generate @aws/nx-plugin:cloudscape-website#app infra --name=infra --directory=lib --unitTestRunner=vitest
26+
pnpm nx generate @aws/nx-plugin:ts#infra infra --name=infra --directory=lib
2727
```
2828

2929
## Security

docs/src/content/docs/guides/example.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ To add components to your project, you can use either the UI in your IDE (Nx Con
7474

7575
1. Select the **Nx** console plugin on the left, and click **Generate (UI)**. The component generator selection list is displayed.
7676
![VSCode Generate UI](/img/nx-generate-ui.png)
77-
2. Choose the generator for the component you want to add. For example, `infra#app`.
77+
2. Choose the generator for the component you want to add. For example, `ts#infra`.
7878
![Component generator](/img/nx-component-generator.png)
7979
3. Fill in the details. The terminal window in the bottom runs a dry run and shows you what files will be created.
8080
4. To proceed, click **Generate**.
@@ -97,7 +97,7 @@ To add components to your project, you can use either the UI in your IDE (Nx Con
9797
For example for infra:
9898

9999
```
100-
pnpm exec nx generate @aws/nx-plugin:infra#app
100+
pnpm exec nx generate @aws/nx-plugin:ts#infra
101101
```
102102

103103
2. Follow the prompts to generate the component and add it to your project.

docs/src/content/docs/guides/tutorial.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ code .
6161
## Step 3: Create the Backend REST API
6262

6363
1. Open **Nx Console** in VS Code and select **Generate (UI)** under **Common NX Commands**.
64-
2. Choose `@aws/nx-plugin - trpc#backend`.
64+
2. Choose `@aws/nx-plugin - ts#trpc-api`.
6565
3. Set the `apiName` to `demo-api` and click **Generate**.
6666

6767
This will create the API inside the `packages/demo-api` folder.
@@ -71,31 +71,31 @@ This will create the API inside the `packages/demo-api` folder.
7171
### Generate the Website
7272

7373
1. In **Nx Console**, select **Generate (UI)**.
74-
2. Choose `@aws/nx-plugin - cloudscape-website#app`.
74+
2. Choose `@aws/nx-plugin - ts#cloudscape-website`.
7575
3. Set the `name` to `demo-website` and click **Generate**.
7676

7777
This scaffolds a new React package with CloudScape UI.
7878

7979
### Enable Cognito Authentication
8080

8181
1. In **Nx Console**, select **Generate (UI)**.
82-
2. Choose `@aws-nx-plugin - cloudscape-website#cognito-auth`.
82+
2. Choose `@aws-nx-plugin - ts#cloudscape-website#cognito-auth`.
8383
3. Set a unique `cognitoDomain`, select `@demo/demo-website`, and check `allowSignup`.
8484
4. Click **Generate**.
8585

8686
### Connect Frontend to Backend
8787

8888
1. In **Nx Console**, select **Generate (UI)**.
89-
2. Choose `@aws-nx-plugin - trpc#react`.
90-
3. Select `@demo/demo-website` for `frontendProjectName` and `@demo/demo-api-backend` for `backendProjectName`.
89+
2. Choose `@aws-nx-plugin - api#connection`.
90+
3. Select `@demo/demo-website` for `sourceProject` and `@demo/demo-api-backend` for `targetProject`.
9191
4. Click **Generate**.
9292

9393
## Step 5: Create CDK Infrastructure
9494

9595
### Generate the CDK App
9696

9797
1. In **Nx Console**, select **Generate (UI)**.
98-
2. Choose `@aws/nx-plugin - infra#app`.
98+
2. Choose `@aws/nx-plugin - ts#infra`.
9999
3. Set `name` to `infra` and click **Generate**.
100100

101101
### Define Cloud Resources
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
title: API Connection
3+
description: Reference documentation for API connections
4+
---
5+
6+
This generator is used to connect projects to APIs. Simply select the source project (the project that will call your API) and target project (your API project), and this generator will handle integrating the two.
7+
8+
## Connecting an API
9+
10+
You can connect a source and target project in two ways:
11+
12+
### 1. Using VSCode IDE
13+
14+
First, install the NX Console extension for VSCode:
15+
16+
1. Open VSCode
17+
2. Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
18+
3. Search for "Nx Console"
19+
4. Install [Nx Console](https://marketplace.visualstudio.com/items?itemName=nrwl.angular-console)
20+
21+
Then generate your API:
22+
23+
1. Open the NX Console in VSCode
24+
2. Click on "Generate"
25+
3. Search for "api-connection"
26+
4. Fill in the required parameters in the form
27+
5. Click "Run"
28+
29+
### 2. Using CLI
30+
31+
Generate the API:
32+
33+
```bash
34+
nx g @aws/nx-plugin:api-connection --sourceProject=my-client-project --targetProject=my-api-project --auth=IAM
35+
```
36+
37+
You can also perform a dry-run to see what files would be generated without actually creating them:
38+
39+
```bash
40+
nx g @aws/nx-plugin:api-connection --sourceProject=my-client-project --targetProject=my-api-project --auth=IAM --dry-run
41+
```
42+
43+
Both methods will add the necessary code and configuration to integrate the source project with the target api project.
44+
45+
### Input Parameters
46+
47+
| Parameter | Type | Default | Description |
48+
| --------------- | ------ | ------- | ------------------------------------------------------------ |
49+
| sourceProject\* | string | - | The name of the project which will call your API (required). |
50+
| targetProject\* | string | - | The name of your API project (required). |
51+
| auth\* | string | "IAM" | Authentication strategy. Options: "IAM", "None" |
52+
53+
\*Required parameter
54+
55+
## Supported Connections
56+
57+
### tRPC
58+
59+
You can connect a React website to a tRPC API. For details, please refer to the [API connection section of the tRPC reference documentation](/reference/trpc/#api-connection-trpc-react).

docs/src/content/docs/reference/trpc.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ description: Reference documentation for tRPC
77

88
The AWS Plugin for Nx makes building APIs with tRPC on AWS easy by providing two main generators:
99

10-
- [`trpc#backend`](#trpc-backend) - Generates the backend code to implement a tRPC API as well as infrastructure to deploy it with API Gateway
11-
- [`trpc#react`](#trpc-react) - Integrates a tRPC API with a React website
10+
- [`ts#trpc-api`](#trpc-api) - Generates the backend code to implement a tRPC API as well as infrastructure to deploy it with API Gateway
11+
- [`api-connection`](#api-connection-trpc-react) - Supports integrating a tRPC API with a React website
1212

13-
## tRPC Backend
13+
## tRPC API
1414

15-
The tRPC Backend generator creates a new tRPC API with AWS CDK infrastructure setup. The generated backend uses AWS Lambda for serverless deployment and includes schema validation using [Zod](https://zod.dev/). It sets up [AWS Lambda Powertools](https://docs.powertools.aws.dev/lambda/typescript/latest/) for observability, including logging, AWS X-Ray tracing and Cloudwatch Metrics.
15+
The tRPC API generator creates a new tRPC API with AWS CDK infrastructure setup. The generated backend uses AWS Lambda for serverless deployment and includes schema validation using [Zod](https://zod.dev/). It sets up [AWS Lambda Powertools](https://docs.powertools.aws.dev/lambda/typescript/latest/) for observability, including logging, AWS X-Ray tracing and Cloudwatch Metrics.
1616

17-
### Generating a new tRPC Backend
17+
### Generating a new tRPC API
1818

19-
You can generate a new tRPC backend in two ways:
19+
You can generate a new tRPC API in two ways:
2020

2121
#### 1. Using VSCode IDE
2222

@@ -31,7 +31,7 @@ Then generate your API:
3131

3232
1. Open the NX Console in VSCode
3333
2. Click on "Generate"
34-
3. Search for "trpc#backend"
34+
3. Search for "ts#trpc-api"
3535
4. Fill in the required parameters in the form
3636
5. Click "Run"
3737

@@ -40,13 +40,13 @@ Then generate your API:
4040
Generate the API:
4141

4242
```bash
43-
nx g @aws/nx-plugin:trpc#backend my-api --directory=apps/api
43+
nx g @aws/nx-plugin:ts#trpc-api my-api --directory=apps/api
4444
```
4545

4646
You can also perform a dry-run to see what files would be generated without actually creating them:
4747

4848
```bash
49-
nx g @aws/nx-plugin:trpc#backend my-api --directory=apps/api --dry-run
49+
nx g @aws/nx-plugin:ts#trpc-api my-api --directory=apps/api --dry-run
5050
```
5151

5252
Both methods will create a new tRPC backend API in the specified directory with all the necessary configuration and infrastructure code.
@@ -395,9 +395,9 @@ const client = createMyApiClient({ url: 'https://my-api-url.example.com/' });
395395
await client.echo.query({ message: 'Hello world!' });
396396
```
397397

398-
If you are calling your API from a React website, consider using the [tRPC React](#trpc-react) generator to configure the client.
398+
If you are calling your API from a React website, consider using the [API Connection](#api-connection-trpc-react) generator to configure the client.
399399

400-
## tRPC React
400+
## API Connection: tRPC React
401401

402402
AWS Plugin for Nx provides a generator to quickly integrate your tRPC API with a React website. It sets up all necessary configuration for connecting to your tRPC backends, including AWS IAM authentication support and proper error handling. The integration provides full end-to-end type safety between your frontend and tRPC backend(s).
403403

@@ -441,7 +441,7 @@ Then add tRPC to your React application:
441441

442442
1. Open the NX Console in VSCode
443443
2. Click on "Generate"
444-
3. Search for "trpc#react"
444+
3. Search for "api-connection"
445445
4. Fill in the required parameters in the form
446446
5. Click "Run"
447447

@@ -450,24 +450,24 @@ Then add tRPC to your React application:
450450
Add tRPC to your React application:
451451

452452
```bash
453-
nx g @aws/nx-plugin:trpc#react --frontendProjectName=my-app --backendProjectName=my-api --auth=IAM
453+
nx g @aws/nx-plugin:api-connection --sourceProject=my-app --targetProject=my-api --auth=IAM
454454
```
455455

456456
You can also perform a dry-run to see what files would be generated without actually creating them:
457457

458458
```bash
459-
nx g @aws/nx-plugin:trpc#react --frontendProjectName=my-app --backendProjectName=my-api --auth=IAM --dry-run
459+
nx g @aws/nx-plugin:api-connection --sourceProject=my-app --targetProject=my-api --auth=IAM --dry-run
460460
```
461461

462462
Both methods will add tRPC client integration to your React application with all the necessary configuration.
463463

464464
### Input Parameters
465465

466-
| Parameter | Type | Default | Description |
467-
| --------------------- | ------ | ------- | ------------------------------------------------------ |
468-
| frontendProjectName\* | string | - | The name of your React application project (required). |
469-
| backendProjectName\* | string | - | The name of your tRPC backend project (required). |
470-
| auth\* | string | "IAM" | Authentication strategy. Options: "IAM", "None" |
466+
| Parameter | Type | Default | Description |
467+
| --------------- | ------ | ------- | ------------------------------------------------------ |
468+
| sourceProject\* | string | - | The name of your React application project (required). |
469+
| targetProject\* | string | - | The name of your tRPC backend project (required). |
470+
| auth\* | string | "IAM" | Authentication strategy. Options: "IAM", "None" |
471471

472472
\*Required parameter
473473

e2e/src/smoke-tests/smoke-test.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,30 @@ export const smokeTest = (
4040
{ ...opts, prefixWithPackageManagerCmd: false, retry: true },
4141
); // This can sometimes fail intermittently so add retries
4242
await runCLI(
43-
`generate @aws/nx-plugin:infra#app --name=infra --no-interactive`,
43+
`generate @aws/nx-plugin:ts#infra --name=infra --no-interactive`,
4444
opts,
4545
);
4646
await runCLI(
47-
`generate @aws/nx-plugin:cloudscape-website#app --name=website --no-interactive`,
47+
`generate @aws/nx-plugin:ts#cloudscape-website --name=website --no-interactive`,
4848
opts,
4949
);
5050
await runCLI(
51-
`generate @aws/nx-plugin:trpc#backend --apiName=my-api --no-interactive`,
51+
`generate @aws/nx-plugin:ts#trpc-api --apiName=my-api --no-interactive`,
5252
opts,
5353
);
5454
await runCLI(
55-
`generate @aws/nx-plugin:cloudscape-website#cognito-auth --project=@e2e-test/website --cognitoDomain=test --no-interactive`,
55+
`generate @aws/nx-plugin:ts#cloudscape-website#auth --project=@e2e-test/website --cognitoDomain=test --no-interactive`,
5656
opts,
5757
);
5858
await runCLI(
59-
`generate @aws/nx-plugin:trpc#react --frontendProjectName=@e2e-test/website --backendProjectName=@e2e-test/my-api-backend --no-interactive`,
59+
`generate @aws/nx-plugin:api-connection --sourceProject=@e2e-test/website --targetProject=@e2e-test/my-api-backend --no-interactive`,
6060
opts,
6161
);
6262
await runCLI(
6363
`generate @aws/nx-plugin:py#fast-api --name=py-api --no-interactive`,
6464
opts,
6565
);
66-
await runCLI(
67-
`generate @aws/nx-plugin:license --no-interactive`,
68-
opts,
69-
);
66+
await runCLI(`generate @aws/nx-plugin:license --no-interactive`, opts);
7067

7168
// Wire up website, cognito and trpc api
7269
writeFileSync(

packages/nx-plugin/LICENSE-THIRD-PARTY

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14541,6 +14541,59 @@ terms above.
1454114541

1454214542
---
1454314543

14544+
The following software may be included in this product: lodash.snakecase (4.1.1)
14545+
This software contains the following license and notice below:
14546+
14547+
Copyright jQuery Foundation and other contributors <https://jquery.org/>
14548+
14549+
Based on Underscore.js, copyright Jeremy Ashkenas,
14550+
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
14551+
14552+
This software consists of voluntary contributions made by many
14553+
individuals. For exact contribution history, see the revision history
14554+
available at https://github.com/lodash/lodash
14555+
14556+
The following license applies to all parts of this software except as
14557+
documented below:
14558+
14559+
====
14560+
14561+
Permission is hereby granted, free of charge, to any person obtaining
14562+
a copy of this software and associated documentation files (the
14563+
"Software"), to deal in the Software without restriction, including
14564+
without limitation the rights to use, copy, modify, merge, publish,
14565+
distribute, sublicense, and/or sell copies of the Software, and to
14566+
permit persons to whom the Software is furnished to do so, subject to
14567+
the following conditions:
14568+
14569+
The above copyright notice and this permission notice shall be
14570+
included in all copies or substantial portions of the Software.
14571+
14572+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14573+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14574+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14575+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
14576+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
14577+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
14578+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14579+
14580+
====
14581+
14582+
Copyright and related rights for sample code are waived via CC0. Sample
14583+
code is defined as all source code displayed within the prose of the
14584+
documentation.
14585+
14586+
CC0: http://creativecommons.org/publicdomain/zero/1.0/
14587+
14588+
====
14589+
14590+
Files located in the node_modules and vendor directories are externally
14591+
maintained libraries used by this software which have their own
14592+
licenses; we recommend you read them, as their terms may differ from the
14593+
terms above.
14594+
14595+
---
14596+
1454414597
The following software may be included in this product: log-symbols (4.1.0)
1454514598
This software contains the following license and notice below:
1454614599

packages/nx-plugin/generators.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"name": "pace",
44
"version": "0.0.1",
55
"generators": {
6-
"ts#lib": {
6+
"ts#project": {
77
"factory": "./src/ts/lib/generator",
88
"schema": "./src/ts/lib/schema.json",
9-
"description": "Generates a TypeScript library"
9+
"description": "Generates a TypeScript project"
1010
},
1111
"py#project": {
1212
"factory": "./src/py/project/generator",
@@ -18,39 +18,39 @@
1818
"schema": "./src/py/fast-api/schema.json",
1919
"description": "Generates a FastAPI Python project"
2020
},
21-
"cloudscape-website#app": {
21+
"ts#cloudscape-website": {
2222
"factory": "./src/cloudscape-website/app/generator",
2323
"schema": "./src/cloudscape-website/app/schema.json",
2424
"description": "Generates a React static website based on Cloudscape"
2525
},
26-
"cloudscape-website#cognito-auth": {
26+
"ts#cloudscape-website#auth": {
2727
"factory": "./src/cloudscape-website/cognito-auth/generator",
2828
"schema": "./src/cloudscape-website/cognito-auth/schema.json",
29-
"description": "Adds cognito auth to an existing cloudscape website"
29+
"description": "Adds auth to an existing cloudscape website"
3030
},
31-
"cloudscape-website#runtime-config": {
31+
"ts#cloudscape-website#runtime-config": {
3232
"factory": "./src/cloudscape-website/runtime-config/generator",
3333
"schema": "./src/cloudscape-website/runtime-config/schema.json",
3434
"description": "Adds runtime config to an existing cloudscape website",
3535
"hidden": true
3636
},
37-
"infra#app": {
37+
"ts#infra": {
3838
"factory": "./src/infra/app/generator",
3939
"schema": "./src/infra/app/schema.json",
4040
"description": "Generates a cdk application"
4141
},
42-
"trpc#api": {
42+
"ts#trpc-api": {
4343
"factory": "./src/trpc/backend/generator",
4444
"schema": "./src/trpc/backend/schema.json",
4545
"description": "creates a trpc backend"
4646
},
47-
"trpc#react": {
47+
"ts#trpc-api#react-connection": {
4848
"factory": "./src/trpc/react/generator",
4949
"schema": "./src/trpc/react/schema.json",
5050
"description": "provides React integration to a React website",
5151
"hidden": true
5252
},
53-
"api#connection": {
53+
"api-connection": {
5454
"factory": "./src/api-connection/generator",
5555
"schema": "./src/api-connection/schema.json",
5656
"description": "Integrates a source project with a target API project"

0 commit comments

Comments
 (0)