@aws/nx-plugin 0.1.6 → 0.2.1

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 (126) hide show
  1. package/LICENSE-THIRD-PARTY +1554 -3241
  2. package/generators.json +1 -13
  3. package/package.json +14 -14
  4. package/src/cloudscape-website/app/README.md +84 -48
  5. package/src/cloudscape-website/app/__snapshots__/generator.spec.ts.snap +168 -233
  6. package/src/cloudscape-website/app/files/app/README.md.template +44 -0
  7. package/src/cloudscape-website/app/files/app/src/layouts/App/index.tsx.template +40 -43
  8. package/src/cloudscape-website/app/files/app/src/layouts/App/navitems.ts.template +3 -3
  9. package/src/cloudscape-website/app/files/app/src/layouts/Routes/index.tsx.template +4 -6
  10. package/src/cloudscape-website/app/files/app/src/main.tsx.template +7 -10
  11. package/src/cloudscape-website/app/files/app/src/pages/Home/index.tsx.template +0 -2
  12. package/src/cloudscape-website/app/files/common/constructs/src/app/static-websites/__websiteNameKebabCase__.ts.template +13 -0
  13. package/src/cloudscape-website/app/files/common/constructs/src/{__websiteNameKebabCase__ → core}/static-website.ts.template +79 -144
  14. package/src/cloudscape-website/app/generator.js +90 -74
  15. package/src/cloudscape-website/app/generator.js.map +1 -1
  16. package/src/cloudscape-website/app/schema.d.ts +3 -5
  17. package/src/cloudscape-website/app/schema.json +1 -24
  18. package/src/cloudscape-website/cognito-auth/README.md +53 -32
  19. package/src/cloudscape-website/cognito-auth/__snapshots__/generator.spec.ts.snap +162 -124
  20. package/src/cloudscape-website/cognito-auth/files/app/components/CognitoAuth/index.tsx.template +53 -39
  21. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/core/user-identity.ts.template +168 -0
  22. package/src/cloudscape-website/cognito-auth/generator.js +130 -47
  23. package/src/cloudscape-website/cognito-auth/generator.js.map +1 -1
  24. package/src/cloudscape-website/cognito-auth/schema.d.ts +1 -0
  25. package/src/cloudscape-website/cognito-auth/schema.json +7 -1
  26. package/src/cloudscape-website/runtime-config/__snapshots__/generator.spec.ts.snap +20 -15
  27. package/src/cloudscape-website/runtime-config/files/app/components/RuntimeConfig/index.tsx.template +7 -10
  28. package/src/cloudscape-website/runtime-config/files/app/hooks/useRuntimeConfig.tsx.template +13 -0
  29. package/src/cloudscape-website/runtime-config/generator.js +4 -2
  30. package/src/cloudscape-website/runtime-config/generator.js.map +1 -1
  31. package/src/infra/app/README.md +71 -46
  32. package/src/infra/app/__snapshots__/generator.spec.ts.snap +184 -305
  33. package/src/infra/app/files/app/README.md.template +76 -0
  34. package/src/infra/app/files/app/src/main.ts.template +18 -0
  35. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/aws-prototyping.guard +1282 -0
  36. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/cfn-nag.guard +6839 -0
  37. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/hipaa-security.guard +2807 -0
  38. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/nist-csf.guard +2585 -0
  39. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/pci-dss-3-2-1.guard +2236 -0
  40. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-reliability-pillar.guard +885 -0
  41. package/src/infra/app/files/common/constructs/src/core/cfn-guard-rules/wa-security-pillar.guard +2205 -0
  42. package/src/infra/app/files/common/constructs/src/core/cfn-guard.ts.template +63 -0
  43. package/src/infra/app/generator.js +36 -7
  44. package/src/infra/app/generator.js.map +1 -1
  45. package/src/infra/app/schema.d.ts +10 -1
  46. package/src/infra/app/schema.json +16 -8
  47. package/src/trpc/backend/README.md +102 -80
  48. package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +42 -19
  49. package/src/trpc/backend/files/backend/README.md.template +33 -0
  50. package/src/trpc/backend/files/common/constructs/src/app/trpc-apis/__apiNameKebabCase__.ts.template +18 -0
  51. package/src/trpc/backend/files/common/constructs/src/{__apiNameKebabCase__/index.ts.template → core/trpc-api.ts.template} +12 -16
  52. package/src/trpc/backend/files/schema/README.md.template +33 -0
  53. package/src/trpc/backend/generator.js +30 -44
  54. package/src/trpc/backend/generator.js.map +1 -1
  55. package/src/trpc/backend/schema.d.ts +3 -1
  56. package/src/trpc/backend/schema.json +8 -13
  57. package/src/trpc/react/README.md +46 -66
  58. package/src/trpc/react/__snapshots__/generator.spec.ts.snap +104 -65
  59. package/src/trpc/react/files/src/components/TrpcClients/IsolatedTrpcProvider.tsx.template +75 -0
  60. package/src/trpc/react/files/src/components/TrpcClients/TrpcApis.tsx.template +1 -0
  61. package/src/trpc/react/files/src/components/TrpcClients/TrpcClientProviders.tsx.template +10 -0
  62. package/src/trpc/react/files/src/components/TrpcClients/index.tsx.template +5 -0
  63. package/src/trpc/react/files/src/hooks/useSigV4.tsx.template +38 -0
  64. package/src/trpc/react/files/src/hooks/use__apiNameClassName__.tsx.template +3 -0
  65. package/src/trpc/react/generator.js +124 -25
  66. package/src/trpc/react/generator.js.map +1 -1
  67. package/src/trpc/react/schema.json +2 -2
  68. package/src/ts/lib/__snapshots__/generator.spec.ts.snap +47 -93
  69. package/src/ts/lib/eslint.d.ts +1 -2
  70. package/src/ts/lib/eslint.js +62 -21
  71. package/src/ts/lib/eslint.js.map +1 -1
  72. package/src/ts/lib/files/README.md.template +33 -0
  73. package/src/ts/lib/generator.js +44 -5
  74. package/src/ts/lib/generator.js.map +1 -1
  75. package/src/ts/lib/schema.d.ts +1 -4
  76. package/src/ts/lib/schema.json +2 -21
  77. package/src/ts/lib/ts-project-utils.js +3 -18
  78. package/src/ts/lib/ts-project-utils.js.map +1 -1
  79. package/src/ts/lib/vitest.js +12 -0
  80. package/src/ts/lib/vitest.js.map +1 -1
  81. package/src/utils/ast.d.ts +13 -0
  82. package/src/utils/ast.js +102 -0
  83. package/src/utils/ast.js.map +1 -0
  84. package/src/utils/files/common/constructs/src/app/index.ts.template +0 -0
  85. package/src/utils/files/common/constructs/src/{runtime-config → core}/runtime-config.ts.template +3 -5
  86. package/src/utils/files/common/constructs/src/index.ts.template +2 -1
  87. package/src/utils/files/common/readme/README.md.template +33 -0
  88. package/src/utils/files/common/types/src/runtime-config.ts.template +2 -13
  89. package/src/utils/format.d.ts +1 -1
  90. package/src/utils/format.js +2 -2
  91. package/src/utils/format.js.map +1 -1
  92. package/src/utils/names.d.ts +2 -0
  93. package/src/utils/names.js +27 -0
  94. package/src/utils/names.js.map +1 -0
  95. package/src/utils/npm-scope.js.map +1 -1
  96. package/src/utils/paths.js.map +1 -1
  97. package/src/utils/shared-constructs.js +37 -4
  98. package/src/utils/shared-constructs.js.map +1 -1
  99. package/src/utils/test.d.ts +2 -0
  100. package/src/utils/test.js +19 -0
  101. package/src/utils/test.js.map +1 -0
  102. package/src/utils/versions.d.ts +15 -9
  103. package/src/utils/versions.js +14 -8
  104. package/src/utils/versions.js.map +1 -1
  105. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/cloudfront-web-acl.ts.template +0 -317
  106. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/index.ts.template +0 -4
  107. package/src/cloudscape-website/app/files/common/constructs/src/__websiteNameKebabCase__/webacl_event_handler/index.ts.template +0 -301
  108. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/index.ts.template +0 -4
  109. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/user-identity.ts.template +0 -66
  110. package/src/cloudscape-website/cognito-auth/files/common/constructs/src/identity/userpool-with-mfa.ts.template +0 -70
  111. package/src/gitlab/generator.d.ts +0 -8
  112. package/src/gitlab/generator.js +0 -16
  113. package/src/gitlab/generator.js.map +0 -1
  114. package/src/gitlab/schema.d.ts +0 -9
  115. package/src/gitlab/schema.json +0 -52
  116. package/src/infra/app/files/src/main.ts.template +0 -37
  117. package/src/trpc/react/files/src/components/TRPCClientProvider/index.tsx.template +0 -34
  118. package/src/trpc/react/files/src/hooks/useTrpc.tsx.template +0 -5
  119. package/src/ts/cjs-to-esm/generator.d.ts +0 -12
  120. package/src/ts/cjs-to-esm/generator.js +0 -189
  121. package/src/ts/cjs-to-esm/generator.js.map +0 -1
  122. package/src/ts/cjs-to-esm/schema.d.ts +0 -9
  123. package/src/ts/cjs-to-esm/schema.json +0 -28
  124. /package/src/infra/app/files/{cdk.json → app/cdk.json} +0 -0
  125. /package/src/infra/app/files/{src → app/src}/stacks/application-stack.ts.template +0 -0
  126. /package/src/utils/files/common/constructs/src/{runtime-config → core}/index.ts.template +0 -0
@@ -2,18 +2,7 @@
2
2
 
3
3
  exports[`infra generator > should add required dependencies to package.json > dependencies 1`] = `
4
4
  {
5
- "@aws/pdk": "^0.25.7",
6
- "aws-cdk": "^2.166.0",
7
- "aws-cdk-lib": "^2.166.0",
8
- "constructs": "^10.4.2",
9
- "esbuild": "^0.24.0",
10
- "source-map-support": "^0.5.21",
11
- }
12
- `;
13
-
14
- exports[`infra generator > should add required dependencies to package.json > dependencies 2`] = `
15
- {
16
- "@aws/pdk": "^0.25.7",
5
+ "@cdklabs/cdk-validator-cfnguard": "^0.0.60",
17
6
  "aws-cdk": "^2.166.0",
18
7
  "aws-cdk-lib": "^2.166.0",
19
8
  "constructs": "^10.4.2",
@@ -25,55 +14,33 @@ exports[`infra generator > should add required dependencies to package.json > de
25
14
  exports[`infra generator > should add required dependencies to package.json > dev-dependencies 1`] = `
26
15
  {
27
16
  "@eslint/js": "^9.8.0",
28
- "@nx/eslint": "20.0.10",
29
- "@nx/eslint-plugin": "20.0.10",
17
+ "@nx/eslint": "20.4.0",
18
+ "@nx/eslint-plugin": "20.4.0",
19
+ "@nx/js": "20.4.0",
20
+ "@nx/vite": "20.4.0",
21
+ "@nx/web": "20.4.0",
22
+ "@swc-node/register": "~1.9.1",
23
+ "@swc/core": "~1.5.7",
24
+ "@swc/helpers": "~0.5.11",
25
+ "@vitest/coverage-v8": "^1.0.4",
26
+ "@vitest/ui": "^1.3.1",
30
27
  "eslint": "^9.8.0",
31
28
  "eslint-config-prettier": "^9.0.0",
29
+ "eslint-plugin-prettier": "^5.2.2",
30
+ "jsdom": "~22.1.0",
31
+ "prettier": "^3.4.2",
32
32
  "tsx": "^4.19.2",
33
- "typescript-eslint": "^8.0.0",
34
- }
35
- `;
36
-
37
- exports[`infra generator > should add required dependencies to package.json > dev-dependencies 2`] = `
38
- {
39
- "@eslint/js": "^9.8.0",
40
- "@nx/eslint": "20.3.1",
41
- "@nx/eslint-plugin": "20.3.1",
42
- "eslint": "^9.8.0",
43
- "eslint-config-prettier": "^9.0.0",
44
- "tsx": "^4.19.2",
45
- "typescript-eslint": "^8.13.0",
33
+ "typescript": "~5.7.2",
34
+ "typescript-eslint": "^8.19.0",
35
+ "vite": "^5.0.0",
36
+ "vitest": "^1.3.1",
46
37
  }
47
38
  `;
48
39
 
49
40
  exports[`infra generator > should add required dependencies to package.json > package-json 1`] = `
50
41
  {
51
42
  "dependencies": {
52
- "@aws/pdk": "^0.25.7",
53
- "aws-cdk": "^2.166.0",
54
- "aws-cdk-lib": "^2.166.0",
55
- "constructs": "^10.4.2",
56
- "esbuild": "^0.24.0",
57
- "source-map-support": "^0.5.21",
58
- },
59
- "devDependencies": {
60
- "@eslint/js": "^9.8.0",
61
- "@nx/eslint": "20.0.10",
62
- "@nx/eslint-plugin": "20.0.10",
63
- "eslint": "^9.8.0",
64
- "eslint-config-prettier": "^9.0.0",
65
- "tsx": "^4.19.2",
66
- "typescript-eslint": "^8.0.0",
67
- },
68
- "name": "@proj/source",
69
- "type": "module",
70
- }
71
- `;
72
-
73
- exports[`infra generator > should add required dependencies to package.json > package-json 2`] = `
74
- {
75
- "dependencies": {
76
- "@aws/pdk": "^0.25.7",
43
+ "@cdklabs/cdk-validator-cfnguard": "^0.0.60",
77
44
  "aws-cdk": "^2.166.0",
78
45
  "aws-cdk-lib": "^2.166.0",
79
46
  "constructs": "^10.4.2",
@@ -82,55 +49,43 @@ exports[`infra generator > should add required dependencies to package.json > pa
82
49
  },
83
50
  "devDependencies": {
84
51
  "@eslint/js": "^9.8.0",
85
- "@nx/eslint": "20.3.1",
86
- "@nx/eslint-plugin": "20.3.1",
52
+ "@nx/eslint": "20.4.0",
53
+ "@nx/eslint-plugin": "20.4.0",
54
+ "@nx/js": "20.4.0",
55
+ "@nx/vite": "20.4.0",
56
+ "@nx/web": "20.4.0",
57
+ "@swc-node/register": "~1.9.1",
58
+ "@swc/core": "~1.5.7",
59
+ "@swc/helpers": "~0.5.11",
60
+ "@vitest/coverage-v8": "^1.0.4",
61
+ "@vitest/ui": "^1.3.1",
87
62
  "eslint": "^9.8.0",
88
63
  "eslint-config-prettier": "^9.0.0",
64
+ "eslint-plugin-prettier": "^5.2.2",
65
+ "jsdom": "~22.1.0",
66
+ "prettier": "^3.4.2",
89
67
  "tsx": "^4.19.2",
90
- "typescript-eslint": "^8.13.0",
91
- },
92
- "name": "@proj/source",
93
- "type": "module",
94
- }
95
- `;
96
-
97
- exports[`infra generator > should add required dependencies to package.json > package-json 3`] = `
98
- {
99
- "dependencies": {
100
- "@aws/pdk": "^0.25.7",
101
- "aws-cdk": "^2.166.0",
102
- "aws-cdk-lib": "^2.166.0",
103
- "constructs": "^10.4.2",
104
- "esbuild": "^0.24.0",
105
- "source-map-support": "^0.5.21",
106
- },
107
- "devDependencies": {
108
- "@eslint/js": "^9.8.0",
109
- "@nx/eslint": "20.3.1",
110
- "@nx/eslint-plugin": "20.3.1",
111
- "eslint": "^9.8.0",
112
- "eslint-config-prettier": "^9.0.0",
113
- "tsx": "^4.19.2",
114
- "typescript-eslint": "^8.13.0",
68
+ "typescript": "~5.7.2",
69
+ "typescript-eslint": "^8.19.0",
70
+ "vite": "^5.0.0",
71
+ "vitest": "^1.3.1",
115
72
  },
116
73
  "name": "@proj/source",
117
74
  "type": "module",
75
+ "workspaces": [
76
+ "packages/*",
77
+ "packages/common/*",
78
+ ],
118
79
  }
119
80
  `;
120
81
 
121
82
  exports[`infra generator > should configure project.json with correct targets > build-target 1`] = `
122
83
  {
123
- "cache": true,
124
84
  "dependsOn": [
125
- "^build",
126
- ],
127
- "executor": "nx:run-commands",
128
- "options": {
129
- "command": "cdk synth",
130
- "cwd": "packages/test",
131
- },
132
- "outputs": [
133
- "{workspaceRoot}/dist/packages/test/cdk.out",
85
+ "lint",
86
+ "compile",
87
+ "test",
88
+ "synth",
134
89
  ],
135
90
  }
136
91
  `;
@@ -155,17 +110,11 @@ exports[`infra generator > should configure project.json with correct targets >
155
110
  "tags": [],
156
111
  "targets": {
157
112
  "build": {
158
- "cache": true,
159
113
  "dependsOn": [
160
- "^build",
161
- ],
162
- "executor": "nx:run-commands",
163
- "options": {
164
- "command": "cdk synth",
165
- "cwd": "packages/test",
166
- },
167
- "outputs": [
168
- "{workspaceRoot}/dist/packages/test/cdk.out",
114
+ "lint",
115
+ "compile",
116
+ "test",
117
+ "synth",
169
118
  ],
170
119
  },
171
120
  "compile": {
@@ -174,9 +123,9 @@ exports[`infra generator > should configure project.json with correct targets >
174
123
  "assets": [
175
124
  "packages/test/*.md",
176
125
  ],
177
- "main": "packages/test/src/index.ts",
126
+ "main": "packages/test/src/main.ts",
178
127
  "outputPath": "dist/packages/test",
179
- "tsConfig": "packages/test/tsconfig.lib.json",
128
+ "tsConfig": "packages/test/tsconfig.json",
180
129
  },
181
130
  "outputs": [
182
131
  "{options.outputPath}",
@@ -192,13 +141,27 @@ exports[`infra generator > should configure project.json with correct targets >
192
141
  "lint": {
193
142
  "executor": "@nx/eslint:lint",
194
143
  },
144
+ "synth": {
145
+ "cache": true,
146
+ "dependsOn": [
147
+ "^build",
148
+ ],
149
+ "executor": "nx:run-commands",
150
+ "options": {
151
+ "command": "cdk synth",
152
+ "cwd": "packages/test",
153
+ },
154
+ "outputs": [
155
+ "{workspaceRoot}/dist/packages/test/cdk.out",
156
+ ],
157
+ },
195
158
  "test": {
196
- "executor": "@nx/jest:jest",
159
+ "executor": "@nx/vite:test",
197
160
  "options": {
198
- "jestConfig": "packages/test/jest.config.ts",
161
+ "reportsDirectory": "../../coverage/packages/test",
199
162
  },
200
163
  "outputs": [
201
- "{workspaceRoot}/coverage/{projectRoot}",
164
+ "{options.reportsDirectory}",
202
165
  ],
203
166
  },
204
167
  },
@@ -275,43 +238,24 @@ exports[`infra generator > should generate consistent file content across runs >
275
238
  }
276
239
  }
277
240
  ",
278
- "src/main.ts": "import { CdkGraph, FilterPreset, Filters } from '@aws/pdk/cdk-graph';
279
- import { CdkGraphDiagramPlugin } from '@aws/pdk/cdk-graph-plugin-diagram';
280
- import { CdkGraphThreatComposerPlugin } from '@aws/pdk/cdk-graph-plugin-threat-composer';
281
- import { AwsPrototypingChecks, PDKNag } from '@aws/pdk/pdk-nag';
241
+ "src/main.ts": "import { App } from 'aws-cdk-lib';
282
242
  import { ApplicationStack } from './stacks/application-stack.js';
243
+ import { CfnGuardValidator, RuleSet } from ':proj/common-constructs';
283
244
 
284
- /* eslint-disable @typescript-eslint/no-floating-promises */
285
- (async () => {
286
- const app = PDKNag.app({
287
- nagPacks: [new AwsPrototypingChecks()],
288
- });
289
-
290
- // Use this to deploy your own sandbox environment (assumes your CLI credentials)
291
- new ApplicationStack(app, 'test-sandbox', {
292
- env: {
293
- account: process.env.CDK_DEFAULT_ACCOUNT,
294
- region: process.env.CDK_DEFAULT_REGION,
295
- },
296
- });
297
-
298
- const graph = new CdkGraph(app, {
299
- plugins: [
300
- new CdkGraphDiagramPlugin({
301
- defaults: {
302
- filterPlan: {
303
- preset: FilterPreset.COMPACT,
304
- filters: [{ store: Filters.pruneCustomResources() }],
305
- },
306
- },
307
- }),
308
- new CdkGraphThreatComposerPlugin(),
309
- ],
310
- });
245
+ const app = new App({
246
+ policyValidationBeta1: [new CfnGuardValidator(RuleSet.AWS_PROTOTYPING)],
247
+ });
248
+
249
+ // Use this to deploy your own sandbox environment (assumes your CLI credentials)
250
+ new ApplicationStack(app, 'test-sandbox', {
251
+ env: {
252
+ account: process.env.CDK_DEFAULT_ACCOUNT,
253
+ region: process.env.CDK_DEFAULT_REGION,
254
+ },
255
+ crossRegionReferences: true,
256
+ });
311
257
 
312
- app.synth();
313
- await graph.report();
314
- })();
258
+ app.synth();
315
259
  ",
316
260
  "src/stacks/application-stack.ts": "import * as cdk from 'aws-cdk-lib';
317
261
  import { Construct } from 'constructs';
@@ -413,43 +357,24 @@ exports[`infra generator > should generate files with correct content > cdk-json
413
357
  `;
414
358
 
415
359
  exports[`infra generator > should generate files with correct content > main-ts 1`] = `
416
- "import { CdkGraph, FilterPreset, Filters } from '@aws/pdk/cdk-graph';
417
- import { CdkGraphDiagramPlugin } from '@aws/pdk/cdk-graph-plugin-diagram';
418
- import { CdkGraphThreatComposerPlugin } from '@aws/pdk/cdk-graph-plugin-threat-composer';
419
- import { AwsPrototypingChecks, PDKNag } from '@aws/pdk/pdk-nag';
360
+ "import { App } from 'aws-cdk-lib';
420
361
  import { ApplicationStack } from './stacks/application-stack.js';
362
+ import { CfnGuardValidator, RuleSet } from ':proj/common-constructs';
421
363
 
422
- /* eslint-disable @typescript-eslint/no-floating-promises */
423
- (async () => {
424
- const app = PDKNag.app({
425
- nagPacks: [new AwsPrototypingChecks()],
426
- });
427
-
428
- // Use this to deploy your own sandbox environment (assumes your CLI credentials)
429
- new ApplicationStack(app, 'test-sandbox', {
430
- env: {
431
- account: process.env.CDK_DEFAULT_ACCOUNT,
432
- region: process.env.CDK_DEFAULT_REGION,
433
- },
434
- });
435
-
436
- const graph = new CdkGraph(app, {
437
- plugins: [
438
- new CdkGraphDiagramPlugin({
439
- defaults: {
440
- filterPlan: {
441
- preset: FilterPreset.COMPACT,
442
- filters: [{ store: Filters.pruneCustomResources() }],
443
- },
444
- },
445
- }),
446
- new CdkGraphThreatComposerPlugin(),
447
- ],
448
- });
364
+ const app = new App({
365
+ policyValidationBeta1: [new CfnGuardValidator(RuleSet.AWS_PROTOTYPING)],
366
+ });
449
367
 
450
- app.synth();
451
- await graph.report();
452
- })();
368
+ // Use this to deploy your own sandbox environment (assumes your CLI credentials)
369
+ new ApplicationStack(app, 'test-sandbox', {
370
+ env: {
371
+ account: process.env.CDK_DEFAULT_ACCOUNT,
372
+ region: process.env.CDK_DEFAULT_REGION,
373
+ },
374
+ crossRegionReferences: true,
375
+ });
376
+
377
+ app.synth();
453
378
  "
454
379
  `;
455
380
 
@@ -531,33 +456,36 @@ exports[`infra generator > should generate files with correct content > project-
531
456
  "tags": [],
532
457
  "targets": {
533
458
  "build": {
534
- "cache": true,
535
- "executor": "nx:run-commands",
536
- "outputs": ["{workspaceRoot}/dist/packages/test/cdk.out"],
537
- "dependsOn": ["^build"],
459
+ "dependsOn": ["lint", "compile", "test", "synth"]
460
+ },
461
+ "compile": {
462
+ "executor": "@nx/js:tsc",
463
+ "outputs": ["{options.outputPath}"],
538
464
  "options": {
539
- "cwd": "packages/test",
540
- "command": "cdk synth"
465
+ "outputPath": "dist/packages/test",
466
+ "main": "packages/test/src/main.ts",
467
+ "tsConfig": "packages/test/tsconfig.json",
468
+ "assets": ["packages/test/*.md"]
541
469
  }
542
470
  },
543
471
  "lint": {
544
472
  "executor": "@nx/eslint:lint"
545
473
  },
546
474
  "test": {
547
- "executor": "@nx/jest:jest",
548
- "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
475
+ "executor": "@nx/vite:test",
476
+ "outputs": ["{options.reportsDirectory}"],
549
477
  "options": {
550
- "jestConfig": "packages/test/jest.config.ts"
478
+ "reportsDirectory": "../../coverage/packages/test"
551
479
  }
552
480
  },
553
- "compile": {
554
- "executor": "@nx/js:tsc",
555
- "outputs": ["{options.outputPath}"],
481
+ "synth": {
482
+ "cache": true,
483
+ "executor": "nx:run-commands",
484
+ "outputs": ["{workspaceRoot}/dist/packages/test/cdk.out"],
485
+ "dependsOn": ["^build"],
556
486
  "options": {
557
- "outputPath": "dist/packages/test",
558
- "main": "packages/test/src/index.ts",
559
- "tsConfig": "packages/test/tsconfig.lib.json",
560
- "assets": ["packages/test/*.md"]
487
+ "cwd": "packages/test",
488
+ "command": "cdk synth"
561
489
  }
562
490
  },
563
491
  "deploy": {
@@ -570,43 +498,24 @@ exports[`infra generator > should generate files with correct content > project-
570
498
  }
571
499
  }
572
500
  ",
573
- "src/main.ts": "import { CdkGraph, FilterPreset, Filters } from '@aws/pdk/cdk-graph';
574
- import { CdkGraphDiagramPlugin } from '@aws/pdk/cdk-graph-plugin-diagram';
575
- import { CdkGraphThreatComposerPlugin } from '@aws/pdk/cdk-graph-plugin-threat-composer';
576
- import { AwsPrototypingChecks, PDKNag } from '@aws/pdk/pdk-nag';
501
+ "src/main.ts": "import { App } from 'aws-cdk-lib';
577
502
  import { ApplicationStack } from './stacks/application-stack.js';
503
+ import { CfnGuardValidator, RuleSet } from ':proj/common-constructs';
578
504
 
579
- /* eslint-disable @typescript-eslint/no-floating-promises */
580
- (async () => {
581
- const app = PDKNag.app({
582
- nagPacks: [new AwsPrototypingChecks()],
583
- });
584
-
585
- // Use this to deploy your own sandbox environment (assumes your CLI credentials)
586
- new ApplicationStack(app, 'test-sandbox', {
587
- env: {
588
- account: process.env.CDK_DEFAULT_ACCOUNT,
589
- region: process.env.CDK_DEFAULT_REGION,
590
- },
591
- });
592
-
593
- const graph = new CdkGraph(app, {
594
- plugins: [
595
- new CdkGraphDiagramPlugin({
596
- defaults: {
597
- filterPlan: {
598
- preset: FilterPreset.COMPACT,
599
- filters: [{ store: Filters.pruneCustomResources() }],
600
- },
601
- },
602
- }),
603
- new CdkGraphThreatComposerPlugin(),
604
- ],
605
- });
505
+ const app = new App({
506
+ policyValidationBeta1: [new CfnGuardValidator(RuleSet.AWS_PROTOTYPING)],
507
+ });
508
+
509
+ // Use this to deploy your own sandbox environment (assumes your CLI credentials)
510
+ new ApplicationStack(app, 'test-sandbox', {
511
+ env: {
512
+ account: process.env.CDK_DEFAULT_ACCOUNT,
513
+ region: process.env.CDK_DEFAULT_REGION,
514
+ },
515
+ crossRegionReferences: true,
516
+ });
606
517
 
607
- app.synth();
608
- await graph.report();
609
- })();
518
+ app.synth();
610
519
  ",
611
520
  "src/stacks/application-stack.ts": "import * as cdk from 'aws-cdk-lib';
612
521
  import { Construct } from 'constructs';
@@ -698,43 +607,24 @@ exports[`infra generator > should generate valid CDK application code > cdk-json
698
607
  `;
699
608
 
700
609
  exports[`infra generator > should generate valid CDK application code > main-ts-content 1`] = `
701
- "import { CdkGraph, FilterPreset, Filters } from '@aws/pdk/cdk-graph';
702
- import { CdkGraphDiagramPlugin } from '@aws/pdk/cdk-graph-plugin-diagram';
703
- import { CdkGraphThreatComposerPlugin } from '@aws/pdk/cdk-graph-plugin-threat-composer';
704
- import { AwsPrototypingChecks, PDKNag } from '@aws/pdk/pdk-nag';
610
+ "import { App } from 'aws-cdk-lib';
705
611
  import { ApplicationStack } from './stacks/application-stack.js';
612
+ import { CfnGuardValidator, RuleSet } from ':proj/common-constructs';
706
613
 
707
- /* eslint-disable @typescript-eslint/no-floating-promises */
708
- (async () => {
709
- const app = PDKNag.app({
710
- nagPacks: [new AwsPrototypingChecks()],
711
- });
712
-
713
- // Use this to deploy your own sandbox environment (assumes your CLI credentials)
714
- new ApplicationStack(app, 'test-sandbox', {
715
- env: {
716
- account: process.env.CDK_DEFAULT_ACCOUNT,
717
- region: process.env.CDK_DEFAULT_REGION,
718
- },
719
- });
720
-
721
- const graph = new CdkGraph(app, {
722
- plugins: [
723
- new CdkGraphDiagramPlugin({
724
- defaults: {
725
- filterPlan: {
726
- preset: FilterPreset.COMPACT,
727
- filters: [{ store: Filters.pruneCustomResources() }],
728
- },
729
- },
730
- }),
731
- new CdkGraphThreatComposerPlugin(),
732
- ],
733
- });
614
+ const app = new App({
615
+ policyValidationBeta1: [new CfnGuardValidator(RuleSet.AWS_PROTOTYPING)],
616
+ });
617
+
618
+ // Use this to deploy your own sandbox environment (assumes your CLI credentials)
619
+ new ApplicationStack(app, 'test-sandbox', {
620
+ env: {
621
+ account: process.env.CDK_DEFAULT_ACCOUNT,
622
+ region: process.env.CDK_DEFAULT_REGION,
623
+ },
624
+ crossRegionReferences: true,
625
+ });
734
626
 
735
- app.synth();
736
- await graph.report();
737
- })();
627
+ app.synth();
738
628
  "
739
629
  `;
740
630
 
@@ -822,43 +712,24 @@ exports[`infra generator > should handle custom project names correctly > custom
822
712
  }
823
713
  }
824
714
  ",
825
- "src/main.ts": "import { CdkGraph, FilterPreset, Filters } from '@aws/pdk/cdk-graph';
826
- import { CdkGraphDiagramPlugin } from '@aws/pdk/cdk-graph-plugin-diagram';
827
- import { CdkGraphThreatComposerPlugin } from '@aws/pdk/cdk-graph-plugin-threat-composer';
828
- import { AwsPrototypingChecks, PDKNag } from '@aws/pdk/pdk-nag';
715
+ "src/main.ts": "import { App } from 'aws-cdk-lib';
829
716
  import { ApplicationStack } from './stacks/application-stack.js';
717
+ import { CfnGuardValidator, RuleSet } from ':proj/common-constructs';
830
718
 
831
- /* eslint-disable @typescript-eslint/no-floating-promises */
832
- (async () => {
833
- const app = PDKNag.app({
834
- nagPacks: [new AwsPrototypingChecks()],
835
- });
836
-
837
- // Use this to deploy your own sandbox environment (assumes your CLI credentials)
838
- new ApplicationStack(app, 'custom-infra-sandbox', {
839
- env: {
840
- account: process.env.CDK_DEFAULT_ACCOUNT,
841
- region: process.env.CDK_DEFAULT_REGION,
842
- },
843
- });
844
-
845
- const graph = new CdkGraph(app, {
846
- plugins: [
847
- new CdkGraphDiagramPlugin({
848
- defaults: {
849
- filterPlan: {
850
- preset: FilterPreset.COMPACT,
851
- filters: [{ store: Filters.pruneCustomResources() }],
852
- },
853
- },
854
- }),
855
- new CdkGraphThreatComposerPlugin(),
856
- ],
857
- });
719
+ const app = new App({
720
+ policyValidationBeta1: [new CfnGuardValidator(RuleSet.AWS_PROTOTYPING)],
721
+ });
858
722
 
859
- app.synth();
860
- await graph.report();
861
- })();
723
+ // Use this to deploy your own sandbox environment (assumes your CLI credentials)
724
+ new ApplicationStack(app, 'custom-infra-sandbox', {
725
+ env: {
726
+ account: process.env.CDK_DEFAULT_ACCOUNT,
727
+ region: process.env.CDK_DEFAULT_REGION,
728
+ },
729
+ crossRegionReferences: true,
730
+ });
731
+
732
+ app.synth();
862
733
  ",
863
734
  "src/stacks/application-stack.ts": "import * as cdk from 'aws-cdk-lib';
864
735
  import { Construct } from 'constructs';
@@ -884,17 +755,11 @@ exports[`infra generator > should handle custom project names correctly > custom
884
755
  "tags": [],
885
756
  "targets": {
886
757
  "build": {
887
- "cache": true,
888
758
  "dependsOn": [
889
- "^build",
890
- ],
891
- "executor": "nx:run-commands",
892
- "options": {
893
- "command": "cdk synth",
894
- "cwd": "packages/custom-infra",
895
- },
896
- "outputs": [
897
- "{workspaceRoot}/dist/packages/custom-infra/cdk.out",
759
+ "lint",
760
+ "compile",
761
+ "test",
762
+ "synth",
898
763
  ],
899
764
  },
900
765
  "compile": {
@@ -903,9 +768,9 @@ exports[`infra generator > should handle custom project names correctly > custom
903
768
  "assets": [
904
769
  "packages/custom-infra/*.md",
905
770
  ],
906
- "main": "packages/custom-infra/src/index.ts",
771
+ "main": "packages/custom-infra/src/main.ts",
907
772
  "outputPath": "dist/packages/custom-infra",
908
- "tsConfig": "packages/custom-infra/tsconfig.lib.json",
773
+ "tsConfig": "packages/custom-infra/tsconfig.json",
909
774
  },
910
775
  "outputs": [
911
776
  "{options.outputPath}",
@@ -921,13 +786,27 @@ exports[`infra generator > should handle custom project names correctly > custom
921
786
  "lint": {
922
787
  "executor": "@nx/eslint:lint",
923
788
  },
789
+ "synth": {
790
+ "cache": true,
791
+ "dependsOn": [
792
+ "^build",
793
+ ],
794
+ "executor": "nx:run-commands",
795
+ "options": {
796
+ "command": "cdk synth",
797
+ "cwd": "packages/custom-infra",
798
+ },
799
+ "outputs": [
800
+ "{workspaceRoot}/dist/packages/custom-infra/cdk.out",
801
+ ],
802
+ },
924
803
  "test": {
925
- "executor": "@nx/jest:jest",
804
+ "executor": "@nx/vite:test",
926
805
  "options": {
927
- "jestConfig": "packages/custom-infra/jest.config.ts",
806
+ "reportsDirectory": "../../coverage/packages/custom-infra",
928
807
  },
929
808
  "outputs": [
930
- "{workspaceRoot}/coverage/{projectRoot}",
809
+ "{options.reportsDirectory}",
931
810
  ],
932
811
  },
933
812
  },