@aws/nx-plugin 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/README.md +63 -0
  2. package/generators.json +52 -0
  3. package/package.json +27 -0
  4. package/src/cloudscape-website/app/README.md +253 -0
  5. package/src/cloudscape-website/app/__snapshots__/generator.spec.ts.snap +539 -0
  6. package/src/cloudscape-website/app/files/app/src/config.ts.template +4 -0
  7. package/src/cloudscape-website/app/files/app/src/layouts/App/index.tsx.template +132 -0
  8. package/src/cloudscape-website/app/files/app/src/layouts/App/navitems.ts.template +8 -0
  9. package/src/cloudscape-website/app/files/app/src/layouts/Routes/index.tsx.template +18 -0
  10. package/src/cloudscape-website/app/files/app/src/main.tsx.template +22 -0
  11. package/src/cloudscape-website/app/files/app/src/pages/Home/index.tsx.template +25 -0
  12. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/cloudfront-web-acl.ts.template +317 -0
  13. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/index.ts.template +4 -0
  14. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/static-website.ts.template +237 -0
  15. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/webacl_event_handler/index.ts.template +301 -0
  16. package/src/cloudscape-website/app/files/e2e/cypress/src/e2e/app.cy.ts.template +13 -0
  17. package/src/cloudscape-website/app/files/e2e/cypress/src/support/app.po.ts.template +1 -0
  18. package/src/cloudscape-website/app/files/e2e/playwright/src/example.spec.ts.template +6 -0
  19. package/src/cloudscape-website/app/generator.d.ts +4 -0
  20. package/src/cloudscape-website/app/generator.js +177 -0
  21. package/src/cloudscape-website/app/generator.js.map +1 -0
  22. package/src/cloudscape-website/app/schema.d.js +6 -0
  23. package/src/cloudscape-website/app/schema.d.js.map +1 -0
  24. package/src/cloudscape-website/app/schema.d.ts +35 -0
  25. package/src/cloudscape-website/app/schema.json +189 -0
  26. package/src/cloudscape-website/cognito-auth/README.md +172 -0
  27. package/src/cloudscape-website/cognito-auth/__snapshots__/generator.spec.ts.snap +238 -0
  28. package/src/cloudscape-website/cognito-auth/files/app/components/CognitoAuth/index.tsx.template +50 -0
  29. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/index.ts.template +4 -0
  30. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/user-identity.ts.template +69 -0
  31. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/userpool-with-mfa.ts.template +70 -0
  32. package/src/cloudscape-website/cognito-auth/generator.d.ts +4 -0
  33. package/src/cloudscape-website/cognito-auth/generator.js +100 -0
  34. package/src/cloudscape-website/cognito-auth/generator.js.map +1 -0
  35. package/src/cloudscape-website/cognito-auth/schema.d.js +6 -0
  36. package/src/cloudscape-website/cognito-auth/schema.d.js.map +1 -0
  37. package/src/cloudscape-website/cognito-auth/schema.d.ts +4 -0
  38. package/src/cloudscape-website/cognito-auth/schema.json +36 -0
  39. package/src/cloudscape-website/runtime-config/__snapshots__/generator.spec.ts.snap +112 -0
  40. package/src/cloudscape-website/runtime-config/files/app/components/RuntimeConfig/index.tsx.template +46 -0
  41. package/src/cloudscape-website/runtime-config/generator.d.ts +4 -0
  42. package/src/cloudscape-website/runtime-config/generator.js +74 -0
  43. package/src/cloudscape-website/runtime-config/generator.js.map +1 -0
  44. package/src/cloudscape-website/runtime-config/schema.d.js +6 -0
  45. package/src/cloudscape-website/runtime-config/schema.d.js.map +1 -0
  46. package/src/cloudscape-website/runtime-config/schema.d.ts +3 -0
  47. package/src/cloudscape-website/runtime-config/schema.json +19 -0
  48. package/src/gitlab/files/.gitlab-ci.yml.template +26 -0
  49. package/src/gitlab/generator.d.ts +4 -0
  50. package/src/gitlab/generator.js +26 -0
  51. package/src/gitlab/generator.js.map +1 -0
  52. package/src/gitlab/schema.d.js +6 -0
  53. package/src/gitlab/schema.d.js.map +1 -0
  54. package/src/gitlab/schema.d.ts +5 -0
  55. package/src/gitlab/schema.json +52 -0
  56. package/src/index.d.ts +0 -0
  57. package/src/index.js +3 -0
  58. package/src/index.js.map +1 -0
  59. package/src/infra/app/README.md +175 -0
  60. package/src/infra/app/__snapshots__/generator.spec.ts.snap +864 -0
  61. package/src/infra/app/files/cdk.json +67 -0
  62. package/src/infra/app/files/src/main.ts.template +37 -0
  63. package/src/infra/app/files/src/stacks/application-stack.ts.template +10 -0
  64. package/src/infra/app/generator.d.ts +4 -0
  65. package/src/infra/app/generator.js +75 -0
  66. package/src/infra/app/generator.js.map +1 -0
  67. package/src/infra/app/schema.d.js +6 -0
  68. package/src/infra/app/schema.d.js.map +1 -0
  69. package/src/infra/app/schema.d.ts +6 -0
  70. package/src/infra/app/schema.json +35 -0
  71. package/src/trpc/backend/README.md +549 -0
  72. package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +110 -0
  73. package/src/trpc/backend/files/backend/src/index.ts.template +1 -0
  74. package/src/trpc/backend/files/backend/src/lambdas/index.ts.template +1 -0
  75. package/src/trpc/backend/files/backend/src/lambdas/middleware.ts.template +146 -0
  76. package/src/trpc/backend/files/backend/src/lambdas/router.ts.template +36 -0
  77. package/src/trpc/backend/files/common/constructs/src/__apiNameKebabCase__/index.ts.template +64 -0
  78. package/src/trpc/backend/files/schema/src/index.ts.template +7 -0
  79. package/src/trpc/backend/generator.d.ts +4 -0
  80. package/src/trpc/backend/generator.js +128 -0
  81. package/src/trpc/backend/generator.js.map +1 -0
  82. package/src/trpc/backend/schema.d.js +6 -0
  83. package/src/trpc/backend/schema.d.js.map +1 -0
  84. package/src/trpc/backend/schema.d.ts +8 -0
  85. package/src/trpc/backend/schema.json +44 -0
  86. package/src/trpc/react/README.md +320 -0
  87. package/src/trpc/react/__snapshots__/generator.spec.ts.snap +98 -0
  88. package/src/trpc/react/files/src/components/TRPCClientProvider/index.tsx.template +34 -0
  89. package/src/trpc/react/files/src/hooks/useTrpc.tsx.template +5 -0
  90. package/src/trpc/react/generator.d.ts +4 -0
  91. package/src/trpc/react/generator.js +81 -0
  92. package/src/trpc/react/generator.js.map +1 -0
  93. package/src/trpc/react/schema.d.js +6 -0
  94. package/src/trpc/react/schema.d.js.map +1 -0
  95. package/src/trpc/react/schema.d.ts +5 -0
  96. package/src/trpc/react/schema.json +32 -0
  97. package/src/ts/cjs-to-esm/generator.d.ts +8 -0
  98. package/src/ts/cjs-to-esm/generator.js +201 -0
  99. package/src/ts/cjs-to-esm/generator.js.map +1 -0
  100. package/src/ts/cjs-to-esm/schema.d.js +6 -0
  101. package/src/ts/cjs-to-esm/schema.d.js.map +1 -0
  102. package/src/ts/cjs-to-esm/schema.d.ts +5 -0
  103. package/src/ts/cjs-to-esm/schema.json +28 -0
  104. package/src/ts/lib/README.md +149 -0
  105. package/src/ts/lib/__snapshots__/generator.spec.ts.snap +260 -0
  106. package/src/ts/lib/eslint.d.ts +3 -0
  107. package/src/ts/lib/eslint.js +41 -0
  108. package/src/ts/lib/eslint.js.map +1 -0
  109. package/src/ts/lib/files/src/index.ts.template +3 -0
  110. package/src/ts/lib/generator.d.ts +21 -0
  111. package/src/ts/lib/generator.js +61 -0
  112. package/src/ts/lib/generator.js.map +1 -0
  113. package/src/ts/lib/schema.d.js +6 -0
  114. package/src/ts/lib/schema.d.js.map +1 -0
  115. package/src/ts/lib/schema.d.ts +13 -0
  116. package/src/ts/lib/schema.json +46 -0
  117. package/src/ts/lib/ts-project-utils.d.ts +6 -0
  118. package/src/ts/lib/ts-project-utils.js +107 -0
  119. package/src/ts/lib/ts-project-utils.js.map +1 -0
  120. package/src/ts/lib/types.d.ts +10 -0
  121. package/src/ts/lib/types.js +6 -0
  122. package/src/ts/lib/types.js.map +1 -0
  123. package/src/ts/lib/vitest.d.ts +3 -0
  124. package/src/ts/lib/vitest.js +67 -0
  125. package/src/ts/lib/vitest.js.map +1 -0
  126. package/src/utils/files/common/constructs/src/index.ts.template +1 -0
  127. package/src/utils/files/common/constructs/src/runtime-config/index.ts.template +1 -0
  128. package/src/utils/files/common/constructs/src/runtime-config/runtime-config.ts.template +33 -0
  129. package/src/utils/files/common/types/src/index.ts.template +1 -0
  130. package/src/utils/files/common/types/src/runtime-config.ts.template +13 -0
  131. package/src/utils/npm-scope.d.ts +7 -0
  132. package/src/utils/npm-scope.js +37 -0
  133. package/src/utils/npm-scope.js.map +1 -0
  134. package/src/utils/paths.d.ts +3 -0
  135. package/src/utils/paths.js +32 -0
  136. package/src/utils/paths.js.map +1 -0
  137. package/src/utils/shared-constructs.d.ts +7 -0
  138. package/src/utils/shared-constructs.js +72 -0
  139. package/src/utils/shared-constructs.js.map +1 -0
  140. package/src/utils/versions.d.ts +31 -0
  141. package/src/utils/versions.js +49 -0
  142. package/src/utils/versions.js.map +1 -0
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ default: function() {
13
+ return _default;
14
+ },
15
+ gitlabGenerator: function() {
16
+ return gitlabGenerator;
17
+ }
18
+ });
19
+ const _devkit = require("@nx/devkit");
20
+ async function gitlabGenerator(tree, options) {
21
+ (0, _devkit.generateFiles)(tree, (0, _devkit.joinPathFragments)(__dirname, 'files'), '.', options);
22
+ await (0, _devkit.formatFiles)(tree);
23
+ }
24
+ const _default = gitlabGenerator;
25
+
26
+ //# sourceMappingURL=generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/gitlab/generator.ts"],"sourcesContent":["import { formatFiles, generateFiles, Tree, joinPathFragments } from '@nx/devkit';\nimport { GitlabGeneratorSchema } from './schema';\n\nexport async function gitlabGenerator(\n tree: Tree,\n options: GitlabGeneratorSchema\n) {\n generateFiles(tree, joinPathFragments(__dirname, 'files'), '.', options);\n await formatFiles(tree);\n}\n\nexport default gitlabGenerator;\n"],"names":["gitlabGenerator","tree","options","generateFiles","joinPathFragments","__dirname","formatFiles"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAWA,OAA+B;eAA/B;;IARsBA,eAAe;eAAfA;;;wBAH8C;AAG7D,eAAeA,gBACpBC,IAAU,EACVC,OAA8B;IAE9BC,IAAAA,qBAAa,EAACF,MAAMG,IAAAA,yBAAiB,EAACC,WAAW,UAAU,KAAKH;IAChE,MAAMI,IAAAA,mBAAW,EAACL;AACpB;MAEA,WAAeD"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+
6
+ //# sourceMappingURL=schema.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/gitlab/schema.d.ts"],"names":[],"rangeMappings":"","mappings":""}
@@ -0,0 +1,5 @@
1
+ export interface GitlabGeneratorSchema {
2
+ infraProject: string;
3
+ roleArn: string;
4
+ region: string;
5
+ }
@@ -0,0 +1,52 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "$id": "Gitlab",
4
+ "title": "",
5
+ "type": "object",
6
+ "properties": {
7
+ "infraProject": {
8
+ "description": "The infrastructure project.",
9
+ "type": "string",
10
+ "alias": "dir",
11
+ "x-priority": "important",
12
+ "x-prompt": "the infrastructure project",
13
+ "x-dropdown": "projects"
14
+ },
15
+ "roleArn": {
16
+ "description": "The role ARN to assume.",
17
+ "type": "string",
18
+ "x-priority": "important",
19
+ "x-prompt": "the role ARN to assume"
20
+ },
21
+ "region": {
22
+ "description": "The region to deploy into.",
23
+ "type": "string",
24
+ "x-priority": "important",
25
+ "x-prompt": {
26
+ "message": "Which region would you like to deploy into?",
27
+ "type": "list",
28
+ "items": [
29
+ { "value": "us-east-1", "label": "us-east-1" },
30
+ { "value": "us-east-2", "label": "us-east-2" },
31
+ { "value": "us-west-1", "label": "us-west-1" },
32
+ { "value": "us-west-2", "label": "us-west-2" },
33
+ { "value": "ca-central-1", "label": "ca-central-1" },
34
+ { "value": "eu-west-1", "label": "eu-west-1" },
35
+ { "value": "eu-central-1", "label": "eu-central-1" },
36
+ { "value": "eu-west-2", "label": "eu-west-2" },
37
+ { "value": "eu-west-3", "label": "eu-west-3" },
38
+ { "value": "eu-north-1", "label": "eu-north-1" },
39
+ { "value": "ap-northeast-1", "label": "ap-northeast-1" },
40
+ { "value": "ap-northeast-2", "label": "ap-northeast-2" },
41
+ { "value": "ap-southeast-1", "label": "ap-southeast-1" },
42
+ { "value": "ap-southeast-2", "label": "ap-southeast-2" },
43
+ { "value": "ap-south-1", "label": "ap-south-1" },
44
+ { "value": "sa-east-1", "label": "sa-east-1" },
45
+ { "value": "us-gov-west-1", "label": "us-gov-west-1" },
46
+ { "value": "us-gov-east-1", "label": "us-gov-east-1" }
47
+ ]
48
+ }
49
+ }
50
+ },
51
+ "required": ["infraProject", "roleArn", "region"]
52
+ }
package/src/index.d.ts ADDED
File without changes
package/src/index.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../packages/nx-plugin/src/index.ts"],"names":[],"rangeMappings":"","mappings":""}
@@ -0,0 +1,175 @@
1
+ # Infrastructure App Generator
2
+
3
+ ## Overview
4
+ This generator creates a new AWS CDK infrastructure application. The generated application includes security best practices through PDK Nag checks and provides infrastructure visualization. The codebase is structured using TypeScript and ES Modules (ESM) for modern development practices.
5
+
6
+ ## Usage
7
+
8
+ You can generate a new infrastructure application in two ways:
9
+
10
+ ### 1. Using VSCode IDE
11
+
12
+ First, install the NX Console extension for VSCode:
13
+ 1. Open VSCode
14
+ 2. Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
15
+ 3. Search for "Nx Console"
16
+ 4. Install [Nx Console](https://marketplace.visualstudio.com/items?itemName=nrwl.angular-console)
17
+
18
+ Then generate your application:
19
+ 1. Open the NX Console in VSCode
20
+ 2. Click on "Generate"
21
+ 3. Search for "infra#app"
22
+ 4. Fill in the required parameters in the form
23
+ 5. Click "Run"
24
+
25
+ ### 2. Using CLI
26
+
27
+ Generate the application:
28
+ ```bash
29
+ nx g @aws/nx-plugin:infra#app my-infra --directory=apps/infrastructure
30
+ ```
31
+
32
+ You can also perform a dry-run to see what files would be generated without actually creating them:
33
+ ```bash
34
+ nx g @aws/nx-plugin:infra#app my-infra --directory=apps/infrastructure --dry-run
35
+ ```
36
+
37
+ ## Input Parameters
38
+
39
+ | Parameter | Type | Default | Description |
40
+ |-----------|------|---------|-------------|
41
+ | name* | string | - | The name of the application (required). Must start with a letter and not contain colons. |
42
+ | directory | string | "packages" | The directory to store the application in. |
43
+ | unitTestRunner | string | "vitest" | Test runner for unit tests. Options: jest, vitest, none |
44
+
45
+ *Required parameter
46
+
47
+ ## Expected Output
48
+
49
+ The generator creates an infrastructure application with the following structure:
50
+
51
+ ```
52
+ <directory>/<name>/
53
+ ├── src/
54
+ │ ├── main.ts # Application entry point with CDK and PDK setup
55
+ │ └── stacks/ # CDK stack definitions
56
+ │ └── application-stack.ts # Main application stack
57
+ ├── cdk.json # CDK configuration
58
+ ├── tsconfig.json # TypeScript configuration
59
+ └── project.json # Project configuration and build targets
60
+ ```
61
+
62
+ Additionally, it:
63
+ 1. Configures build settings for CDK synthesis and deployment
64
+ 2. Installs required dependencies:
65
+ - @aws/pdk
66
+ - aws-cdk-lib
67
+ - aws-cdk
68
+ - constructs
69
+ - esbuild
70
+ - source-map-support
71
+ - tsx (dev dependency)
72
+
73
+ ## Features
74
+
75
+ ### 1. PDK Integration
76
+ The generated application includes PDK (Project Development Kit) integration which provides:
77
+ - Security best practices through PDK Nag checks
78
+ - Infrastructure visualization with CDK Graph
79
+ - Threat modeling capabilities through Threat Composer
80
+
81
+ ### 2. Infrastructure Visualization
82
+ The application automatically generates infrastructure diagrams using CDK Graph:
83
+ ```typescript
84
+ const graph = new CdkGraph(app, {
85
+ plugins: [
86
+ new CdkGraphDiagramPlugin({
87
+ defaults: {
88
+ filterPlan: {
89
+ preset: FilterPreset.COMPACT,
90
+ filters: [{ store: Filters.pruneCustomResources() }],
91
+ },
92
+ },
93
+ }),
94
+ new CdkGraphThreatComposerPlugin(),
95
+ ],
96
+ });
97
+ ```
98
+
99
+ ### 3. Security Checks
100
+ PDK Nag is configured with AWS Prototyping Checks to ensure infrastructure security:
101
+ ```typescript
102
+ const app = PDKNag.app({
103
+ nagPacks: [new AwsPrototypingChecks()],
104
+ });
105
+ ```
106
+
107
+ ### 4. Build and Deploy Targets
108
+ The generator configures two main targets in your project.json:
109
+
110
+ 1. **Build Target**
111
+ - Synthesizes CDK templates
112
+ - Caches results for faster subsequent builds
113
+ - Outputs to `dist/<directory>/cdk.out`
114
+
115
+ 2. **Deploy Target**
116
+ - Deploys infrastructure to AWS
117
+ - Configures automatic approval for CI/CD pipelines
118
+ - Uses synthesized templates from the build target
119
+
120
+ ## Working with the Generated Application
121
+
122
+ ### Adding Resources
123
+
124
+ Add AWS resources to your stack in `src/stacks/application-stack.ts`:
125
+
126
+ ```typescript
127
+ import * as cdk from 'aws-cdk-lib';
128
+ import { Construct } from 'constructs';
129
+ import { UserIdentity, StaticWebsite, MyApi } from ':my-org/common-constructs'
130
+ import { HttpIamAuthorizer } from 'aws-cdk-lib/aws-apigatewayv2-authorizers';
131
+
132
+ export class ApplicationStack extends cdk.Stack {
133
+ constructor(scope: Construct, id: string, props?: cdk.StackProps) {
134
+ super(scope, id, props);
135
+
136
+ const identity = new UserIdentity(this, 'UserIdentity');
137
+ const myapi = new MyApi(this, 'MyApi', {
138
+ defaultAuthorizer: new HttpIamAuthorizer(),
139
+ });
140
+ myapi.grantInvokeAccess(identity.identityPool.authenticatedRole);
141
+ new StaticWebsite(this, 'Website');
142
+ }
143
+ }
144
+ ```
145
+
146
+ The generated code serves as a starting point that you can adapt to your specific infrastructure requirements while maintaining security best practices.
147
+
148
+ ### Building the Application
149
+
150
+ To create a production build:
151
+ ```bash
152
+ nx build my-infra
153
+ ```
154
+
155
+ All built code is located in the `dist` folder at the root of your workspace. For example, if your infrastructure application is in `apps/infrastructure/my-infra`, the built code will be in `dist/apps/infrastructure/my-infra`. This includes:
156
+ - Compiled TypeScript files
157
+ - CDK synthesized templates in `dist/apps/infrastructure/my-infra/cdk.out`
158
+ - Generated infrastructure diagrams
159
+ - Source maps for debugging
160
+
161
+ ### Deploying to AWS
162
+
163
+ To deploy your infrastructure:
164
+
165
+ ```bash
166
+ nx deploy my-infra
167
+ ```
168
+
169
+ This command will deploy your infrastructure to AWS using the account and region configured in your AWS CLI.
170
+
171
+ You can also perform a hotswap deployment if you are only making modifications to existing resources via the following command:
172
+
173
+ ```bash
174
+ nx deploy my-infra --hotswap
175
+ ```