@aws/nx-plugin 0.43.0 → 0.45.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 (43) hide show
  1. package/LICENSE-THIRD-PARTY +0 -40255
  2. package/package.json +7 -7
  3. package/src/infra/app/__snapshots__/generator.spec.ts.snap +78 -323
  4. package/src/infra/app/files/app/README.md.template +1 -1
  5. package/src/infra/app/files/app/src/main.ts.template +2 -3
  6. package/src/infra/app/files/app/src/stacks/application-stack.ts.template +3 -3
  7. package/src/infra/app/files/app/src/stages/application-stage.ts.template +16 -0
  8. package/src/infra/app/generator.js +1 -1
  9. package/src/infra/app/generator.js.map +1 -1
  10. package/src/license/__snapshots__/config.spec.ts.snap +3 -3
  11. package/src/license/config.js +5 -3
  12. package/src/license/config.js.map +1 -1
  13. package/src/mcp-server/tools/create-workspace-command.js +1 -1
  14. package/src/preset/__snapshots__/generator.spec.ts.snap +3 -3
  15. package/src/py/project/generator.js +16 -1
  16. package/src/py/project/generator.js.map +1 -1
  17. package/src/ts/lib/__snapshots__/generator.spec.ts.snap +1 -1
  18. package/src/ts/nx-plugin/__snapshots__/generator.spec.ts.snap +1 -1
  19. package/src/ts/nx-plugin/files/mcp-server/tools/create-workspace-command.ts.template +1 -1
  20. package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +55 -500
  21. package/src/ts/react-website/app/files/common/constructs/src/app/static-websites/__websiteNameKebabCase__.ts.template +1 -0
  22. package/src/ts/react-website/app/files/common/constructs/src/core/static-website.ts.template +3 -2
  23. package/src/ts/react-website/app/generator.js +1 -1
  24. package/src/ts/react-website/app/generator.js.map +1 -1
  25. package/src/ts/react-website/cognito-auth/generator.js +0 -25
  26. package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
  27. package/src/ts/react-website/runtime-config/__snapshots__/generator.spec.ts.snap +10 -9
  28. package/src/ts/react-website/runtime-config/files/app/components/RuntimeConfig/index.tsx.template +3 -1
  29. package/src/ts/react-website/runtime-config/files/app/hooks/useRuntimeConfig.tsx.template +1 -2
  30. package/src/utils/__snapshots__/shared-constructs.spec.ts.snap +7 -19
  31. package/src/utils/api-constructs/api-constructs.js +0 -30
  32. package/src/utils/api-constructs/api-constructs.js.map +1 -1
  33. package/src/utils/files/common/constructs/src/core/runtime-config.ts.template +8 -9
  34. package/src/utils/shared-constructs-constants.d.ts +0 -2
  35. package/src/utils/shared-constructs-constants.js +1 -3
  36. package/src/utils/shared-constructs-constants.js.map +1 -1
  37. package/src/utils/shared-constructs.js +0 -21
  38. package/src/utils/shared-constructs.js.map +1 -1
  39. package/src/utils/versions.d.ts +2 -2
  40. package/src/utils/versions.js +1 -1
  41. package/src/utils/versions.js.map +1 -1
  42. package/src/utils/files/common/types/src/index.ts.template +0 -1
  43. package/src/utils/files/common/types/src/runtime-config.ts.template +0 -2
@@ -41,6 +41,7 @@ export default defineConfig(() => ({
41
41
  },
42
42
  },
43
43
  test: {
44
+ name: '@proj/test-app',
44
45
  watch: false,
45
46
  globals: true,
46
47
  environment: 'jsdom',
@@ -95,6 +96,7 @@ export default defineConfig(() => ({
95
96
  },
96
97
  },
97
98
  test: {
99
+ name: '@proj/test-app',
98
100
  watch: false,
99
101
  globals: true,
100
102
  environment: 'jsdom',
@@ -157,7 +159,7 @@ export default [
157
159
  'error',
158
160
  {
159
161
  enforceBuildableLibDependency: true,
160
- allow: ['^.*/eslint(\\\\.base)?\\\\.config\\\\.[cm]?js$'],
162
+ allow: ['^.*/eslint(\\\\.base)?\\\\.config\\\\.[cm]?[jt]s$'],
161
163
  depConstraints: [
162
164
  {
163
165
  sourceTag: '*',
@@ -307,12 +309,12 @@ exports[`react-website generator > Tanstack router integration > should generate
307
309
  },
308
310
  "devDependencies": {
309
311
  "@eslint/js": "^9.8.0",
310
- "@nx/eslint": "21.0.3",
311
- "@nx/eslint-plugin": "21.0.3",
312
- "@nx/js": "21.0.3",
313
- "@nx/react": "21.0.3",
314
- "@nx/vite": "21.0.3",
315
- "@nx/web": "21.0.3",
312
+ "@nx/eslint": "21.4.1",
313
+ "@nx/eslint-plugin": "21.4.1",
314
+ "@nx/js": "21.4.1",
315
+ "@nx/react": "21.4.1",
316
+ "@nx/vite": "21.4.1",
317
+ "@nx/web": "21.4.1",
316
318
  "@swc-node/register": "~1.9.1",
317
319
  "@swc/cli": "~0.6.0",
318
320
  "@swc/core": "~1.5.7",
@@ -337,8 +339,8 @@ exports[`react-website generator > Tanstack router integration > should generate
337
339
  "jsdom": "~22.1.0",
338
340
  "jsonc-eslint-parser": "^2.4.0",
339
341
  "prettier": "^3.5.3",
340
- "typescript": "~5.7.2",
341
- "typescript-eslint": "^8.19.0",
342
+ "typescript": "~5.8.2",
343
+ "typescript-eslint": "^8.29.0",
342
344
  "vite": "^6.0.0",
343
345
  "vite-tsconfig-paths": "^5.1.4",
344
346
  "vitest": "^3.0.0"
@@ -396,7 +398,7 @@ export default [
396
398
  'warn',
397
399
  {
398
400
  ignoredFiles: [
399
- '{projectRoot}/eslint.config.{js,cjs,mjs}',
401
+ '{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}',
400
402
  '{projectRoot}/vite.config.{js,ts,mjs,mts}',
401
403
  ],
402
404
  },
@@ -462,6 +464,7 @@ import { StaticWebsite } from '../../core/index.js';
462
464
  export class TestApp extends StaticWebsite {
463
465
  constructor(scope: Construct, id: string) {
464
466
  super(scope, id, {
467
+ websiteName: 'TestApp',
465
468
  websiteFilePath: url.fileURLToPath(
466
469
  new URL('../../../../../../dist/test-app/bundle', import.meta.url),
467
470
  ),
@@ -508,25 +511,24 @@ export * from './runtime-config.js';
508
511
  `;
509
512
 
510
513
  exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/constructs/src/core/runtime-config.ts 1`] = `
511
- "import type { IRuntimeConfig } from ':proj/common-types';
512
- import { Stack } from 'aws-cdk-lib';
514
+ "import { Stack, Stage } from 'aws-cdk-lib';
513
515
  import { Construct } from 'constructs';
514
516
 
515
517
  const RuntimeConfigKey = '__RuntimeConfig__';
516
518
 
517
519
  export class RuntimeConfig extends Construct {
518
- private readonly _runtimeConfig: Partial<IRuntimeConfig> = {};
520
+ private readonly _runtimeConfig: any = {};
519
521
 
520
522
  static ensure(scope: Construct): RuntimeConfig {
521
- const stack = Stack.of(scope);
523
+ const parent = Stage.of(scope) ?? Stack.of(scope);
522
524
  return (
523
- RuntimeConfig.of(scope) ?? new RuntimeConfig(stack, RuntimeConfigKey)
525
+ RuntimeConfig.of(scope) ?? new RuntimeConfig(parent, RuntimeConfigKey)
524
526
  );
525
527
  }
526
528
 
527
529
  static of(scope: Construct): RuntimeConfig | undefined {
528
- const stack = Stack.of(scope);
529
- return stack.node.tryFindChild(RuntimeConfigKey) as
530
+ const parent = Stage.of(scope) ?? Stack.of(scope);
531
+ return parent.node.tryFindChild(RuntimeConfigKey) as
530
532
  | RuntimeConfig
531
533
  | undefined;
532
534
  }
@@ -535,7 +537,7 @@ export class RuntimeConfig extends Construct {
535
537
  super(scope, id);
536
538
  }
537
539
 
538
- get config(): Partial<IRuntimeConfig> {
540
+ get config(): any {
539
541
  return this._runtimeConfig;
540
542
  }
541
543
  }
@@ -561,6 +563,7 @@ import { CfnWebACL } from 'aws-cdk-lib/aws-wafv2';
561
563
  const DEFAULT_RUNTIME_CONFIG_FILENAME = 'runtime-config.json';
562
564
 
563
565
  export interface StaticWebsiteProps {
566
+ readonly websiteName: string;
564
567
  readonly websiteFilePath: string;
565
568
  }
566
569
 
@@ -580,7 +583,7 @@ export class StaticWebsite extends Construct {
580
583
  constructor(
581
584
  scope: Construct,
582
585
  id: string,
583
- { websiteFilePath }: StaticWebsiteProps,
586
+ { websiteFilePath, websiteName }: StaticWebsiteProps,
584
587
  ) {
585
588
  super(scope, id);
586
589
  this.node.setContext(
@@ -677,7 +680,7 @@ export class StaticWebsite extends Construct {
677
680
  new CfnOutput(this, 'DistributionDomainName', {
678
681
  value: this.cloudFrontDistribution.domainName,
679
682
  });
680
- new CfnOutput(this, 'WebsiteBucketName', {
683
+ new CfnOutput(this, \`\${websiteName}WebsiteBucketName\`, {
681
684
  value: this.websiteBucket.bucketName,
682
685
  });
683
686
  }
@@ -835,229 +838,7 @@ export default defineConfig(() => ({
835
838
  // plugins: [ nxViteTsPaths() ],
836
839
  // },
837
840
  test: {
838
- watch: false,
839
- globals: true,
840
- environment: 'jsdom',
841
- include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
842
- reporters: ['default'],
843
- coverage: {
844
- reportsDirectory: './test-output/vitest/coverage',
845
- provider: 'v8' as const,
846
- },
847
- passWithNoTests: true,
848
- },
849
- }));
850
- "
851
- `;
852
-
853
- exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/types/README.md 1`] = `
854
- "# @proj/common-types
855
-
856
- This library was generated with [@aws/nx-plugin](https://github.com/awslabs/nx-plugin-for-aws/).
857
-
858
- ## Building
859
-
860
- Run \`npx nx build @proj/common-types [--skip-nx-cache]\` to build the application.
861
-
862
- ## Running unit tests
863
-
864
- Run \`npx nx test @proj/common-types\` to execute the unit tests via Vitest.
865
-
866
- ### Updating snapshots
867
-
868
- To update snapshots, run the following command:
869
-
870
- \`npx nx test @proj/common-types --configuration=update-snapshot\`
871
-
872
- ## Run lint
873
-
874
- Run \`npx nx lint @proj/common-types\`
875
-
876
- ### Fixable issues
877
-
878
- You can also automatiaclly fix some lint errors by running the following command:
879
-
880
- \`npx nx lint @proj/common-types --configuration=fix\`
881
-
882
- ## Useful links
883
-
884
- - [common-types reference docs](TODO)
885
- - [Learn more about NX](https://nx.dev/getting-started/intro)
886
- "
887
- `;
888
-
889
- exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/types/eslint.config.mjs 1`] = `
890
- "import baseConfig from '../../../eslint.config.mjs';
891
-
892
- export default [
893
- ...baseConfig,
894
- {
895
- files: ['**/*.json'],
896
- rules: {
897
- '@nx/dependency-checks': [
898
- 'warn',
899
- {
900
- ignoredFiles: [
901
- '{projectRoot}/eslint.config.{js,cjs,mjs}',
902
- '{projectRoot}/vite.config.{js,ts,mjs,mts}',
903
- ],
904
- },
905
- ],
906
- },
907
- languageOptions: {
908
- parser: await import('jsonc-eslint-parser'),
909
- },
910
- },
911
- ];
912
- "
913
- `;
914
-
915
- exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/types/project.json 1`] = `
916
- "{
917
- "name": "@proj/common-types",
918
- "$schema": "../../../node_modules/nx/schemas/project-schema.json",
919
- "sourceRoot": "packages/common/types/src",
920
- "projectType": "library",
921
- "tags": [],
922
- "targets": {
923
- "build": {
924
- "dependsOn": ["lint", "compile", "test"]
925
- },
926
- "compile": {
927
- "executor": "nx:run-commands",
928
- "outputs": ["{workspaceRoot}/dist/packages/common/types/tsc"],
929
- "options": {
930
- "command": "tsc --build tsconfig.lib.json",
931
- "cwd": "{projectRoot}"
932
- }
933
- },
934
- "test": {
935
- "executor": "@nx/vite:test",
936
- "outputs": ["{options.reportsDirectory}"],
937
- "options": {
938
- "reportsDirectory": "../../../coverage/packages/common/types"
939
- }
940
- }
941
- },
942
- "metadata": {
943
- "generator": "ts#project"
944
- }
945
- }
946
- "
947
- `;
948
-
949
- exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/types/src/index.ts 1`] = `
950
- "export * from './runtime-config.js';
951
- "
952
- `;
953
-
954
- exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/types/src/runtime-config.ts 1`] = `
955
- "// eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-empty-interface
956
- export interface IRuntimeConfig {}
957
- "
958
- `;
959
-
960
- exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/types/tsconfig.json 1`] = `
961
- "{
962
- "extends": "../../../tsconfig.base.json",
963
- "files": [],
964
- "include": [],
965
- "references": [
966
- {
967
- "path": "./tsconfig.lib.json"
968
- },
969
- {
970
- "path": "./tsconfig.spec.json"
971
- }
972
- ],
973
- "compilerOptions": {}
974
- }
975
- "
976
- `;
977
-
978
- exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/types/tsconfig.lib.json 1`] = `
979
- "{
980
- "extends": "../../../tsconfig.base.json",
981
- "compilerOptions": {
982
- "rootDir": ".",
983
- "outDir": "../../../dist/packages/common/types/tsc",
984
- "tsBuildInfoFile": "../../../dist/packages/common/types/tsc/tsconfig.lib.tsbuildinfo",
985
- "emitDeclarationOnly": false,
986
- "module": "nodenext",
987
- "moduleResolution": "nodenext",
988
- "types": ["node"]
989
- },
990
- "include": ["src/**/*.ts"],
991
- "references": [],
992
- "exclude": [
993
- "vite.config.ts",
994
- "vite.config.mts",
995
- "vitest.config.ts",
996
- "vitest.config.mts",
997
- "src/**/*.test.ts",
998
- "src/**/*.spec.ts",
999
- "src/**/*.test.tsx",
1000
- "src/**/*.spec.tsx",
1001
- "src/**/*.test.js",
1002
- "src/**/*.spec.js",
1003
- "src/**/*.test.jsx",
1004
- "src/**/*.spec.jsx"
1005
- ]
1006
- }
1007
- "
1008
- `;
1009
-
1010
- exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/types/tsconfig.spec.json 1`] = `
1011
- "{
1012
- "extends": "../../../tsconfig.base.json",
1013
- "compilerOptions": {
1014
- "outDir": "./out-tsc/vitest",
1015
- "types": [
1016
- "vitest/globals",
1017
- "vitest/importMeta",
1018
- "vite/client",
1019
- "node",
1020
- "vitest"
1021
- ],
1022
- "module": "nodenext",
1023
- "moduleResolution": "nodenext"
1024
- },
1025
- "include": [
1026
- "vite.config.ts",
1027
- "vite.config.mts",
1028
- "vitest.config.ts",
1029
- "vitest.config.mts",
1030
- "src/**/*.test.ts",
1031
- "src/**/*.spec.ts",
1032
- "src/**/*.test.tsx",
1033
- "src/**/*.spec.tsx",
1034
- "src/**/*.test.js",
1035
- "src/**/*.spec.js",
1036
- "src/**/*.test.jsx",
1037
- "src/**/*.spec.jsx",
1038
- "src/**/*.d.ts"
1039
- ],
1040
- "references": [
1041
- {
1042
- "path": "./tsconfig.lib.json"
1043
- }
1044
- ]
1045
- }
1046
- "
1047
- `;
1048
-
1049
- exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/types/vite.config.ts 1`] = `
1050
- "import { defineConfig } from 'vite';
1051
-
1052
- export default defineConfig(() => ({
1053
- root: __dirname,
1054
- cacheDir: '../../../node_modules/.vite/packages/common/types',
1055
- plugins: [],
1056
- // Uncomment this if you are using workers.
1057
- // worker: {
1058
- // plugins: [ nxViteTsPaths() ],
1059
- // },
1060
- test: {
841
+ name: '@proj/common-constructs',
1061
842
  watch: false,
1062
843
  globals: true,
1063
844
  environment: 'jsdom',
@@ -1078,7 +859,6 @@ exports[`react-website generator > Tanstack router integration > should generate
1078
859
  - 'packages/*'
1079
860
  - 'test-app'
1080
861
  - 'packages/common/*'
1081
- - 'packages/common/constructs'
1082
862
  "
1083
863
  `;
1084
864
 
@@ -1216,7 +996,7 @@ exports[`react-website generator > Tanstack router integration > should generate
1216
996
  "description": "Load runtime config from your deployed stack for dev purposes. You must set your AWS CLI credentials whilst calling 'pnpm exec nx run @proj/test-app:load:runtime-config'"
1217
997
  },
1218
998
  "options": {
1219
- "command": "aws s3 cp s3://\`aws cloudformation describe-stacks --query \\"Stacks[?StackName=='proj-infra-sandbox'][].Outputs[?contains(OutputKey, 'WebsiteBucketName')].OutputValue\\" --output text\`/runtime-config.json './test-app/public/runtime-config.json'"
999
+ "command": "aws s3 cp s3://\`aws cloudformation describe-stacks --query \\"Stacks[?starts_with(StackName, 'proj-')][].Outputs[] | [?contains(OutputKey, 'TestAppWebsiteBucketName')].OutputValue\\" --output text\`/runtime-config.json './test-app/public/runtime-config.json'"
1220
1000
  }
1221
1001
  },
1222
1002
  "preview": {
@@ -1588,6 +1368,7 @@ export default defineConfig(() => ({
1588
1368
  },
1589
1369
  },
1590
1370
  test: {
1371
+ name: '@proj/test-app',
1591
1372
  watch: false,
1592
1373
  globals: true,
1593
1374
  environment: 'jsdom',
@@ -1607,7 +1388,6 @@ exports[`react-website generator > Tanstack router integration > should generate
1607
1388
  "{
1608
1389
  "compilerOptions": {
1609
1390
  "paths": {
1610
- ":proj/common-types": ["packages/common/types/src/index.ts"],
1611
1391
  ":proj/test-app": ["test-app/src/index.ts"],
1612
1392
  ":proj/common-constructs": ["packages/common/constructs/src/index.ts"]
1613
1393
  },
@@ -1624,9 +1404,6 @@ exports[`react-website generator > Tanstack router integration > should generate
1624
1404
  {
1625
1405
  "path": "./test-app"
1626
1406
  },
1627
- {
1628
- "path": "./packages/common/types"
1629
- },
1630
1407
  {
1631
1408
  "path": "./packages/common/constructs"
1632
1409
  }
@@ -1679,7 +1456,7 @@ export default [
1679
1456
  'error',
1680
1457
  {
1681
1458
  enforceBuildableLibDependency: true,
1682
- allow: ['^.*/eslint(\\\\.base)?\\\\.config\\\\.[cm]?js$'],
1459
+ allow: ['^.*/eslint(\\\\.base)?\\\\.config\\\\.[cm]?[jt]s$'],
1683
1460
  depConstraints: [
1684
1461
  {
1685
1462
  sourceTag: '*',
@@ -1830,12 +1607,12 @@ exports[`react-website generator > Tanstack router integration > should generate
1830
1607
  },
1831
1608
  "devDependencies": {
1832
1609
  "@eslint/js": "^9.8.0",
1833
- "@nx/eslint": "21.0.3",
1834
- "@nx/eslint-plugin": "21.0.3",
1835
- "@nx/js": "21.0.3",
1836
- "@nx/react": "21.0.3",
1837
- "@nx/vite": "21.0.3",
1838
- "@nx/web": "21.0.3",
1610
+ "@nx/eslint": "21.4.1",
1611
+ "@nx/eslint-plugin": "21.4.1",
1612
+ "@nx/js": "21.4.1",
1613
+ "@nx/react": "21.4.1",
1614
+ "@nx/vite": "21.4.1",
1615
+ "@nx/web": "21.4.1",
1839
1616
  "@swc-node/register": "~1.9.1",
1840
1617
  "@swc/cli": "~0.6.0",
1841
1618
  "@swc/core": "~1.5.7",
@@ -1864,8 +1641,8 @@ exports[`react-website generator > Tanstack router integration > should generate
1864
1641
  "jsdom": "~22.1.0",
1865
1642
  "jsonc-eslint-parser": "^2.4.0",
1866
1643
  "prettier": "^3.5.3",
1867
- "typescript": "~5.7.2",
1868
- "typescript-eslint": "^8.19.0",
1644
+ "typescript": "~5.8.2",
1645
+ "typescript-eslint": "^8.29.0",
1869
1646
  "vite": "^6.0.0",
1870
1647
  "vite-tsconfig-paths": "^5.1.4",
1871
1648
  "vitest": "^3.0.0"
@@ -1923,7 +1700,7 @@ export default [
1923
1700
  'warn',
1924
1701
  {
1925
1702
  ignoredFiles: [
1926
- '{projectRoot}/eslint.config.{js,cjs,mjs}',
1703
+ '{projectRoot}/eslint.config.{js,cjs,mjs,ts,cts,mts}',
1927
1704
  '{projectRoot}/vite.config.{js,ts,mjs,mts}',
1928
1705
  ],
1929
1706
  },
@@ -1989,6 +1766,7 @@ import { StaticWebsite } from '../../core/index.js';
1989
1766
  export class TestApp extends StaticWebsite {
1990
1767
  constructor(scope: Construct, id: string) {
1991
1768
  super(scope, id, {
1769
+ websiteName: 'TestApp',
1992
1770
  websiteFilePath: url.fileURLToPath(
1993
1771
  new URL('../../../../../../dist/test-app/bundle', import.meta.url),
1994
1772
  ),
@@ -2035,25 +1813,24 @@ export * from './runtime-config.js';
2035
1813
  `;
2036
1814
 
2037
1815
  exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/constructs/src/core/runtime-config.ts 1`] = `
2038
- "import type { IRuntimeConfig } from ':proj/common-types';
2039
- import { Stack } from 'aws-cdk-lib';
1816
+ "import { Stack, Stage } from 'aws-cdk-lib';
2040
1817
  import { Construct } from 'constructs';
2041
1818
 
2042
1819
  const RuntimeConfigKey = '__RuntimeConfig__';
2043
1820
 
2044
1821
  export class RuntimeConfig extends Construct {
2045
- private readonly _runtimeConfig: Partial<IRuntimeConfig> = {};
1822
+ private readonly _runtimeConfig: any = {};
2046
1823
 
2047
1824
  static ensure(scope: Construct): RuntimeConfig {
2048
- const stack = Stack.of(scope);
1825
+ const parent = Stage.of(scope) ?? Stack.of(scope);
2049
1826
  return (
2050
- RuntimeConfig.of(scope) ?? new RuntimeConfig(stack, RuntimeConfigKey)
1827
+ RuntimeConfig.of(scope) ?? new RuntimeConfig(parent, RuntimeConfigKey)
2051
1828
  );
2052
1829
  }
2053
1830
 
2054
1831
  static of(scope: Construct): RuntimeConfig | undefined {
2055
- const stack = Stack.of(scope);
2056
- return stack.node.tryFindChild(RuntimeConfigKey) as
1832
+ const parent = Stage.of(scope) ?? Stack.of(scope);
1833
+ return parent.node.tryFindChild(RuntimeConfigKey) as
2057
1834
  | RuntimeConfig
2058
1835
  | undefined;
2059
1836
  }
@@ -2062,7 +1839,7 @@ export class RuntimeConfig extends Construct {
2062
1839
  super(scope, id);
2063
1840
  }
2064
1841
 
2065
- get config(): Partial<IRuntimeConfig> {
1842
+ get config(): any {
2066
1843
  return this._runtimeConfig;
2067
1844
  }
2068
1845
  }
@@ -2088,6 +1865,7 @@ import { CfnWebACL } from 'aws-cdk-lib/aws-wafv2';
2088
1865
  const DEFAULT_RUNTIME_CONFIG_FILENAME = 'runtime-config.json';
2089
1866
 
2090
1867
  export interface StaticWebsiteProps {
1868
+ readonly websiteName: string;
2091
1869
  readonly websiteFilePath: string;
2092
1870
  }
2093
1871
 
@@ -2107,7 +1885,7 @@ export class StaticWebsite extends Construct {
2107
1885
  constructor(
2108
1886
  scope: Construct,
2109
1887
  id: string,
2110
- { websiteFilePath }: StaticWebsiteProps,
1888
+ { websiteFilePath, websiteName }: StaticWebsiteProps,
2111
1889
  ) {
2112
1890
  super(scope, id);
2113
1891
  this.node.setContext(
@@ -2204,7 +1982,7 @@ export class StaticWebsite extends Construct {
2204
1982
  new CfnOutput(this, 'DistributionDomainName', {
2205
1983
  value: this.cloudFrontDistribution.domainName,
2206
1984
  });
2207
- new CfnOutput(this, 'WebsiteBucketName', {
1985
+ new CfnOutput(this, \`\${websiteName}WebsiteBucketName\`, {
2208
1986
  value: this.websiteBucket.bucketName,
2209
1987
  });
2210
1988
  }
@@ -2362,229 +2140,7 @@ export default defineConfig(() => ({
2362
2140
  // plugins: [ nxViteTsPaths() ],
2363
2141
  // },
2364
2142
  test: {
2365
- watch: false,
2366
- globals: true,
2367
- environment: 'jsdom',
2368
- include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
2369
- reporters: ['default'],
2370
- coverage: {
2371
- reportsDirectory: './test-output/vitest/coverage',
2372
- provider: 'v8' as const,
2373
- },
2374
- passWithNoTests: true,
2375
- },
2376
- }));
2377
- "
2378
- `;
2379
-
2380
- exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/types/README.md 1`] = `
2381
- "# @proj/common-types
2382
-
2383
- This library was generated with [@aws/nx-plugin](https://github.com/awslabs/nx-plugin-for-aws/).
2384
-
2385
- ## Building
2386
-
2387
- Run \`npx nx build @proj/common-types [--skip-nx-cache]\` to build the application.
2388
-
2389
- ## Running unit tests
2390
-
2391
- Run \`npx nx test @proj/common-types\` to execute the unit tests via Vitest.
2392
-
2393
- ### Updating snapshots
2394
-
2395
- To update snapshots, run the following command:
2396
-
2397
- \`npx nx test @proj/common-types --configuration=update-snapshot\`
2398
-
2399
- ## Run lint
2400
-
2401
- Run \`npx nx lint @proj/common-types\`
2402
-
2403
- ### Fixable issues
2404
-
2405
- You can also automatiaclly fix some lint errors by running the following command:
2406
-
2407
- \`npx nx lint @proj/common-types --configuration=fix\`
2408
-
2409
- ## Useful links
2410
-
2411
- - [common-types reference docs](TODO)
2412
- - [Learn more about NX](https://nx.dev/getting-started/intro)
2413
- "
2414
- `;
2415
-
2416
- exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/types/eslint.config.mjs 1`] = `
2417
- "import baseConfig from '../../../eslint.config.mjs';
2418
-
2419
- export default [
2420
- ...baseConfig,
2421
- {
2422
- files: ['**/*.json'],
2423
- rules: {
2424
- '@nx/dependency-checks': [
2425
- 'warn',
2426
- {
2427
- ignoredFiles: [
2428
- '{projectRoot}/eslint.config.{js,cjs,mjs}',
2429
- '{projectRoot}/vite.config.{js,ts,mjs,mts}',
2430
- ],
2431
- },
2432
- ],
2433
- },
2434
- languageOptions: {
2435
- parser: await import('jsonc-eslint-parser'),
2436
- },
2437
- },
2438
- ];
2439
- "
2440
- `;
2441
-
2442
- exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/types/project.json 1`] = `
2443
- "{
2444
- "name": "@proj/common-types",
2445
- "$schema": "../../../node_modules/nx/schemas/project-schema.json",
2446
- "sourceRoot": "packages/common/types/src",
2447
- "projectType": "library",
2448
- "tags": [],
2449
- "targets": {
2450
- "build": {
2451
- "dependsOn": ["lint", "compile", "test"]
2452
- },
2453
- "compile": {
2454
- "executor": "nx:run-commands",
2455
- "outputs": ["{workspaceRoot}/dist/packages/common/types/tsc"],
2456
- "options": {
2457
- "command": "tsc --build tsconfig.lib.json",
2458
- "cwd": "{projectRoot}"
2459
- }
2460
- },
2461
- "test": {
2462
- "executor": "@nx/vite:test",
2463
- "outputs": ["{options.reportsDirectory}"],
2464
- "options": {
2465
- "reportsDirectory": "../../../coverage/packages/common/types"
2466
- }
2467
- }
2468
- },
2469
- "metadata": {
2470
- "generator": "ts#project"
2471
- }
2472
- }
2473
- "
2474
- `;
2475
-
2476
- exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/types/src/index.ts 1`] = `
2477
- "export * from './runtime-config.js';
2478
- "
2479
- `;
2480
-
2481
- exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/types/src/runtime-config.ts 1`] = `
2482
- "// eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-empty-interface
2483
- export interface IRuntimeConfig {}
2484
- "
2485
- `;
2486
-
2487
- exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/types/tsconfig.json 1`] = `
2488
- "{
2489
- "extends": "../../../tsconfig.base.json",
2490
- "files": [],
2491
- "include": [],
2492
- "references": [
2493
- {
2494
- "path": "./tsconfig.lib.json"
2495
- },
2496
- {
2497
- "path": "./tsconfig.spec.json"
2498
- }
2499
- ],
2500
- "compilerOptions": {}
2501
- }
2502
- "
2503
- `;
2504
-
2505
- exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/types/tsconfig.lib.json 1`] = `
2506
- "{
2507
- "extends": "../../../tsconfig.base.json",
2508
- "compilerOptions": {
2509
- "rootDir": ".",
2510
- "outDir": "../../../dist/packages/common/types/tsc",
2511
- "tsBuildInfoFile": "../../../dist/packages/common/types/tsc/tsconfig.lib.tsbuildinfo",
2512
- "emitDeclarationOnly": false,
2513
- "module": "nodenext",
2514
- "moduleResolution": "nodenext",
2515
- "types": ["node"]
2516
- },
2517
- "include": ["src/**/*.ts"],
2518
- "references": [],
2519
- "exclude": [
2520
- "vite.config.ts",
2521
- "vite.config.mts",
2522
- "vitest.config.ts",
2523
- "vitest.config.mts",
2524
- "src/**/*.test.ts",
2525
- "src/**/*.spec.ts",
2526
- "src/**/*.test.tsx",
2527
- "src/**/*.spec.tsx",
2528
- "src/**/*.test.js",
2529
- "src/**/*.spec.js",
2530
- "src/**/*.test.jsx",
2531
- "src/**/*.spec.jsx"
2532
- ]
2533
- }
2534
- "
2535
- `;
2536
-
2537
- exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/types/tsconfig.spec.json 1`] = `
2538
- "{
2539
- "extends": "../../../tsconfig.base.json",
2540
- "compilerOptions": {
2541
- "outDir": "./out-tsc/vitest",
2542
- "types": [
2543
- "vitest/globals",
2544
- "vitest/importMeta",
2545
- "vite/client",
2546
- "node",
2547
- "vitest"
2548
- ],
2549
- "module": "nodenext",
2550
- "moduleResolution": "nodenext"
2551
- },
2552
- "include": [
2553
- "vite.config.ts",
2554
- "vite.config.mts",
2555
- "vitest.config.ts",
2556
- "vitest.config.mts",
2557
- "src/**/*.test.ts",
2558
- "src/**/*.spec.ts",
2559
- "src/**/*.test.tsx",
2560
- "src/**/*.spec.tsx",
2561
- "src/**/*.test.js",
2562
- "src/**/*.spec.js",
2563
- "src/**/*.test.jsx",
2564
- "src/**/*.spec.jsx",
2565
- "src/**/*.d.ts"
2566
- ],
2567
- "references": [
2568
- {
2569
- "path": "./tsconfig.lib.json"
2570
- }
2571
- ]
2572
- }
2573
- "
2574
- `;
2575
-
2576
- exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/types/vite.config.ts 1`] = `
2577
- "import { defineConfig } from 'vite';
2578
-
2579
- export default defineConfig(() => ({
2580
- root: __dirname,
2581
- cacheDir: '../../../node_modules/.vite/packages/common/types',
2582
- plugins: [],
2583
- // Uncomment this if you are using workers.
2584
- // worker: {
2585
- // plugins: [ nxViteTsPaths() ],
2586
- // },
2587
- test: {
2143
+ name: '@proj/common-constructs',
2588
2144
  watch: false,
2589
2145
  globals: true,
2590
2146
  environment: 'jsdom',
@@ -2605,7 +2161,6 @@ exports[`react-website generator > Tanstack router integration > should generate
2605
2161
  - 'packages/*'
2606
2162
  - 'test-app'
2607
2163
  - 'packages/common/*'
2608
- - 'packages/common/constructs'
2609
2164
  "
2610
2165
  `;
2611
2166
 
@@ -2743,7 +2298,7 @@ exports[`react-website generator > Tanstack router integration > should generate
2743
2298
  "description": "Load runtime config from your deployed stack for dev purposes. You must set your AWS CLI credentials whilst calling 'pnpm exec nx run @proj/test-app:load:runtime-config'"
2744
2299
  },
2745
2300
  "options": {
2746
- "command": "aws s3 cp s3://\`aws cloudformation describe-stacks --query \\"Stacks[?StackName=='proj-infra-sandbox'][].Outputs[?contains(OutputKey, 'WebsiteBucketName')].OutputValue\\" --output text\`/runtime-config.json './test-app/public/runtime-config.json'"
2301
+ "command": "aws s3 cp s3://\`aws cloudformation describe-stacks --query \\"Stacks[?starts_with(StackName, 'proj-')][].Outputs[] | [?contains(OutputKey, 'TestAppWebsiteBucketName')].OutputValue\\" --output text\`/runtime-config.json './test-app/public/runtime-config.json'"
2747
2302
  }
2748
2303
  },
2749
2304
  "preview": {
@@ -3354,6 +2909,7 @@ export default defineConfig(() => ({
3354
2909
  },
3355
2910
  },
3356
2911
  test: {
2912
+ name: '@proj/test-app',
3357
2913
  watch: false,
3358
2914
  globals: true,
3359
2915
  environment: 'jsdom',
@@ -3373,7 +2929,6 @@ exports[`react-website generator > Tanstack router integration > should generate
3373
2929
  "{
3374
2930
  "compilerOptions": {
3375
2931
  "paths": {
3376
- ":proj/common-types": ["packages/common/types/src/index.ts"],
3377
2932
  ":proj/test-app": ["test-app/src/index.ts"],
3378
2933
  ":proj/common-constructs": ["packages/common/constructs/src/index.ts"]
3379
2934
  },
@@ -3390,9 +2945,6 @@ exports[`react-website generator > Tanstack router integration > should generate
3390
2945
  {
3391
2946
  "path": "./test-app"
3392
2947
  },
3393
- {
3394
- "path": "./packages/common/types"
3395
- },
3396
2948
  {
3397
2949
  "path": "./packages/common/constructs"
3398
2950
  }
@@ -3470,6 +3022,7 @@ export default defineConfig(() => ({
3470
3022
  },
3471
3023
  },
3472
3024
  test: {
3025
+ name: '@proj/test-app',
3473
3026
  watch: false,
3474
3027
  globals: true,
3475
3028
  environment: 'jsdom',
@@ -3739,6 +3292,7 @@ import { CfnWebACL } from 'aws-cdk-lib/aws-wafv2';
3739
3292
  const DEFAULT_RUNTIME_CONFIG_FILENAME = 'runtime-config.json';
3740
3293
 
3741
3294
  export interface StaticWebsiteProps {
3295
+ readonly websiteName: string;
3742
3296
  readonly websiteFilePath: string;
3743
3297
  }
3744
3298
 
@@ -3758,7 +3312,7 @@ export class StaticWebsite extends Construct {
3758
3312
  constructor(
3759
3313
  scope: Construct,
3760
3314
  id: string,
3761
- { websiteFilePath }: StaticWebsiteProps,
3315
+ { websiteFilePath, websiteName }: StaticWebsiteProps,
3762
3316
  ) {
3763
3317
  super(scope, id);
3764
3318
  this.node.setContext(
@@ -3855,7 +3409,7 @@ export class StaticWebsite extends Construct {
3855
3409
  new CfnOutput(this, 'DistributionDomainName', {
3856
3410
  value: this.cloudFrontDistribution.domainName,
3857
3411
  });
3858
- new CfnOutput(this, 'WebsiteBucketName', {
3412
+ new CfnOutput(this, \`\${websiteName}WebsiteBucketName\`, {
3859
3413
  value: this.websiteBucket.bucketName,
3860
3414
  });
3861
3415
  }
@@ -3914,6 +3468,7 @@ import { StaticWebsite } from '../../core/index.js';
3914
3468
  export class TestApp extends StaticWebsite {
3915
3469
  constructor(scope: Construct, id: string) {
3916
3470
  super(scope, id, {
3471
+ websiteName: 'TestApp',
3917
3472
  websiteFilePath: url.fileURLToPath(
3918
3473
  new URL('../../../../../../dist/test-app/bundle', import.meta.url),
3919
3474
  ),