@aws/nx-plugin 0.88.0 → 0.89.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 (174) hide show
  1. package/LICENSE-THIRD-PARTY +688 -54
  2. package/bin/aws-nx-mcp.js +3 -4
  3. package/bin/aws-nx-mcp.js.map +1 -1
  4. package/package.json +2 -2
  5. package/src/connection/generator.js +20 -26
  6. package/src/connection/generator.js.map +1 -1
  7. package/src/connection/serve-local.js +7 -9
  8. package/src/connection/serve-local.js.map +1 -1
  9. package/src/infra/app/generator.js +152 -143
  10. package/src/infra/app/generator.js.map +1 -1
  11. package/src/license/config.js +90 -79
  12. package/src/license/config.js.map +1 -1
  13. package/src/license/generator.js +20 -15
  14. package/src/license/generator.js.map +1 -1
  15. package/src/license/sync/generator.js +71 -77
  16. package/src/license/sync/generator.js.map +1 -1
  17. package/src/license/sync/project-file-sync.js +13 -6
  18. package/src/license/sync/project-file-sync.js.map +1 -1
  19. package/src/mcp-server/generator-info.js +28 -34
  20. package/src/mcp-server/generator-info.js.map +1 -1
  21. package/src/mcp-server/index.js +3 -4
  22. package/src/mcp-server/index.js.map +1 -1
  23. package/src/mcp-server/tools/general-guidance.js +8 -11
  24. package/src/mcp-server/tools/general-guidance.js.map +1 -1
  25. package/src/mcp-server/tools/generator-guide.js +3 -4
  26. package/src/mcp-server/tools/generator-guide.js.map +1 -1
  27. package/src/open-api/ts-client/generator.js +8 -8
  28. package/src/open-api/ts-client/generator.js.map +1 -1
  29. package/src/open-api/ts-hooks/generator.js +4 -4
  30. package/src/open-api/ts-hooks/generator.js.map +1 -1
  31. package/src/open-api/ts-metadata/generator.js +4 -4
  32. package/src/open-api/ts-metadata/generator.js.map +1 -1
  33. package/src/open-api/utils/codegen-data/languages.js +1 -2
  34. package/src/open-api/utils/codegen-data/languages.js.map +1 -1
  35. package/src/open-api/utils/codegen-data.js +90 -92
  36. package/src/open-api/utils/codegen-data.js.map +1 -1
  37. package/src/open-api/utils/normalise.js +34 -34
  38. package/src/open-api/utils/normalise.js.map +1 -1
  39. package/src/open-api/utils/parse.js +3 -3
  40. package/src/open-api/utils/parse.js.map +1 -1
  41. package/src/open-api/utils/refs.js +1 -1
  42. package/src/open-api/utils/refs.js.map +1 -1
  43. package/src/preset/__snapshots__/generator.spec.ts.snap +2 -1
  44. package/src/preset/generator.js +51 -24
  45. package/src/preset/generator.js.map +1 -1
  46. package/src/py/fast-api/generator.js +18 -13
  47. package/src/py/fast-api/generator.js.map +1 -1
  48. package/src/py/fast-api/react/generator.js +8 -10
  49. package/src/py/fast-api/react/generator.js.map +1 -1
  50. package/src/py/fast-api/react/open-api.js +15 -7
  51. package/src/py/fast-api/react/open-api.js.map +1 -1
  52. package/src/py/lambda-function/generator.js +18 -16
  53. package/src/py/lambda-function/generator.js.map +1 -1
  54. package/src/py/mcp-server/generator.js +36 -24
  55. package/src/py/mcp-server/generator.js.map +1 -1
  56. package/src/py/project/generator.js +36 -24
  57. package/src/py/project/generator.js.map +1 -1
  58. package/src/py/strands-agent/generator.js +21 -16
  59. package/src/py/strands-agent/generator.js.map +1 -1
  60. package/src/py/strands-agent/mcp-connection/generator.js +30 -32
  61. package/src/py/strands-agent/mcp-connection/generator.js.map +1 -1
  62. package/src/smithy/project/generator.js +6 -8
  63. package/src/smithy/project/generator.js.map +1 -1
  64. package/src/smithy/react-connection/generator.js +14 -17
  65. package/src/smithy/react-connection/generator.js.map +1 -1
  66. package/src/smithy/ts/api/generator.js +17 -11
  67. package/src/smithy/ts/api/generator.js.map +1 -1
  68. package/src/terraform/project/generator.js +191 -189
  69. package/src/terraform/project/generator.js.map +1 -1
  70. package/src/trpc/backend/generator.js +95 -83
  71. package/src/trpc/backend/generator.js.map +1 -1
  72. package/src/trpc/react/__snapshots__/generator.spec.ts.snap +12 -9
  73. package/src/trpc/react/files/src/components/__apiNameClassName__ClientProvider.tsx.template +1 -1
  74. package/src/trpc/react/files/src/hooks/use__apiNameClassName__.tsx.template +3 -3
  75. package/src/trpc/react/generator.js +75 -76
  76. package/src/trpc/react/generator.js.map +1 -1
  77. package/src/ts/lambda-function/generator.js +15 -12
  78. package/src/ts/lambda-function/generator.js.map +1 -1
  79. package/src/ts/lib/eslint.js +19 -8
  80. package/src/ts/lib/eslint.js.map +1 -1
  81. package/src/ts/lib/generator.js +44 -19
  82. package/src/ts/lib/generator.js.map +1 -1
  83. package/src/ts/lib/ts-project-utils.js +53 -30
  84. package/src/ts/lib/ts-project-utils.js.map +1 -1
  85. package/src/ts/lib/vitest.js +13 -3
  86. package/src/ts/lib/vitest.js.map +1 -1
  87. package/src/ts/mcp-server/generator.js +22 -17
  88. package/src/ts/mcp-server/generator.js.map +1 -1
  89. package/src/ts/nx-generator/generator.js +40 -31
  90. package/src/ts/nx-generator/generator.js.map +1 -1
  91. package/src/ts/nx-plugin/generator.js +14 -11
  92. package/src/ts/nx-plugin/generator.js.map +1 -1
  93. package/src/ts/nx-plugin/utils.js +11 -10
  94. package/src/ts/nx-plugin/utils.js.map +1 -1
  95. package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +4 -6
  96. package/src/ts/react-website/app/generator.js +291 -253
  97. package/src/ts/react-website/app/generator.js.map +1 -1
  98. package/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap +1 -5
  99. package/src/ts/react-website/cognito-auth/generator.js +86 -90
  100. package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
  101. package/src/ts/react-website/cognito-auth/utils.js +14 -21
  102. package/src/ts/react-website/cognito-auth/utils.js.map +1 -1
  103. package/src/ts/react-website/runtime-config/generator.js +33 -30
  104. package/src/ts/react-website/runtime-config/generator.js.map +1 -1
  105. package/src/ts/strands-agent/generator.js +18 -13
  106. package/src/ts/strands-agent/generator.js.map +1 -1
  107. package/src/ts/strands-agent/mcp-connection/generator.js +15 -17
  108. package/src/ts/strands-agent/mcp-connection/generator.js.map +1 -1
  109. package/src/ts/sync/generator.js +36 -14
  110. package/src/ts/sync/generator.js.map +1 -1
  111. package/src/utils/agent-connection/agent-connection.js +62 -68
  112. package/src/utils/agent-connection/agent-connection.js.map +1 -1
  113. package/src/utils/agent-core-constructs/agent-core-constructs.js +14 -16
  114. package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
  115. package/src/utils/api-constructs/api-constructs.js +8 -10
  116. package/src/utils/api-constructs/api-constructs.js.map +1 -1
  117. package/src/utils/api-constructs/open-api-metadata.js +1 -2
  118. package/src/utils/api-constructs/open-api-metadata.js.map +1 -1
  119. package/src/utils/ast/website.js +3 -4
  120. package/src/utils/ast/website.js.map +1 -1
  121. package/src/utils/ast.js +20 -23
  122. package/src/utils/ast.js.map +1 -1
  123. package/src/utils/bundle/bundle.js +14 -14
  124. package/src/utils/bundle/bundle.js.map +1 -1
  125. package/src/utils/config/utils.js +9 -9
  126. package/src/utils/config/utils.js.map +1 -1
  127. package/src/utils/connection/open-api/react.js +28 -23
  128. package/src/utils/connection/open-api/react.js.map +1 -1
  129. package/src/utils/format.js +50 -47
  130. package/src/utils/format.js.map +1 -1
  131. package/src/utils/fs.js +1 -0
  132. package/src/utils/fs.js.map +1 -1
  133. package/src/utils/function-constructs/function-constructs.js +16 -12
  134. package/src/utils/function-constructs/function-constructs.js.map +1 -1
  135. package/src/utils/git.js +2 -3
  136. package/src/utils/git.js.map +1 -1
  137. package/src/utils/iac.js +4 -6
  138. package/src/utils/iac.js.map +1 -1
  139. package/src/utils/identity-constructs/identity-constructs.js +6 -7
  140. package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
  141. package/src/utils/js.js +7 -8
  142. package/src/utils/js.js.map +1 -1
  143. package/src/utils/metrics.js +12 -13
  144. package/src/utils/metrics.js.map +1 -1
  145. package/src/utils/mock-project-graph.js +3 -6
  146. package/src/utils/mock-project-graph.js.map +1 -1
  147. package/src/utils/names.js +8 -3
  148. package/src/utils/names.js.map +1 -1
  149. package/src/utils/npm-scope.js +1 -1
  150. package/src/utils/npm-scope.js.map +1 -1
  151. package/src/utils/nx.js +42 -19
  152. package/src/utils/nx.js.map +1 -1
  153. package/src/utils/nxlv-python.d.ts +124 -5
  154. package/src/utils/nxlv-python.js +5 -14
  155. package/src/utils/nxlv-python.js.map +1 -1
  156. package/src/utils/pkg-manager.js +1 -1
  157. package/src/utils/pkg-manager.js.map +1 -1
  158. package/src/utils/port.js +4 -6
  159. package/src/utils/port.js.map +1 -1
  160. package/src/utils/py.js +12 -12
  161. package/src/utils/py.js.map +1 -1
  162. package/src/utils/shared-constructs.js +67 -72
  163. package/src/utils/shared-constructs.js.map +1 -1
  164. package/src/utils/shared-infra-config.js +24 -26
  165. package/src/utils/shared-infra-config.js.map +1 -1
  166. package/src/utils/shared-scripts.js +24 -26
  167. package/src/utils/shared-scripts.js.map +1 -1
  168. package/src/utils/shared-shadcn.js +64 -53
  169. package/src/utils/shared-shadcn.js.map +1 -1
  170. package/src/utils/versions.d.ts +5 -1
  171. package/src/utils/versions.js +8 -4
  172. package/src/utils/versions.js.map +1 -1
  173. package/src/utils/website-constructs/website-constructs.js +9 -11
  174. package/src/utils/website-constructs/website-constructs.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/utils.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,uCAOoB;AACpB,uCAAqE;AACrE,mDAAoD;AACpD,iFAAgD;AAEhD;;GAEG;AACI,MAAM,4BAA4B,GAAG,CAC1C,IAAU,EACV,WAAmB,EACnB,EAAE;IACF,MAAM,OAAO,GAAG,IAAA,wCAAmC,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAEvE,MAAM,YAAY,GAAG,IAAA,0BAAiB,EAAC,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IACtE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CACb,2BAA2B,WAAW,8BAA8B,CACrE,CAAC;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AE,IAAI,KAAK,uBAAuB,CAAC;IAE3E,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,qFAAqF;QACrF,MAAM,IAAI,GAAG;YACX,GAAG,IAAA,uBAAY,EAAC,CAAC,YAAY,CAAC,CAAC;YAC/B,uCAAuC;YACvC,CAAC,sBAAW,CAAC,IAAI,CAAC,EAAE,IAAI,sBAAW,CAAC,OAAO,EAAE;SAC9C,CAAC;QACF,IAAA,qCAA4B,EAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;QAC7C,IAAA,qCAA4B,EAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,qBAAqB,CAAC,CAAC;IACtE,CAAC;AACH,CAAC,CAAC;AA3DW,QAAA,4BAA4B,gCA2DvC"}
@@ -2446,10 +2446,9 @@ exports[`react-website generator > Tanstack router integration > should generate
2446
2446
  "{
2447
2447
  "compilerOptions": {
2448
2448
  "paths": {
2449
- ":proj/test-app": ["test-app/src/index.ts"],
2450
- ":proj/common-constructs": ["packages/common/constructs/src/index.ts"]
2449
+ ":proj/test-app": ["./test-app/src/index.ts"],
2450
+ ":proj/common-constructs": ["./packages/common/constructs/src/index.ts"]
2451
2451
  },
2452
- "baseUrl": ".",
2453
2452
  "rootDir": "."
2454
2453
  }
2455
2454
  }
@@ -4235,10 +4234,9 @@ exports[`react-website generator > Tanstack router integration > should generate
4235
4234
  "{
4236
4235
  "compilerOptions": {
4237
4236
  "paths": {
4238
- ":proj/test-app": ["test-app/src/index.ts"],
4239
- ":proj/common-constructs": ["packages/common/constructs/src/index.ts"]
4237
+ ":proj/test-app": ["./test-app/src/index.ts"],
4238
+ ":proj/common-constructs": ["./packages/common/constructs/src/index.ts"]
4240
4239
  },
4241
- "baseUrl": ".",
4242
4240
  "rootDir": "."
4243
4241
  }
4244
4242
  }
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.REACT_WEBSITE_APP_GENERATOR_INFO = exports.SUPPORTED_UX_PROVIDERS = void 0;
4
4
  exports.tsReactWebsiteGenerator = tsReactWebsiteGenerator;
5
- const tslib_1 = require("tslib");
6
5
  /**
7
6
  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
8
7
  * SPDX-License-Identifier: Apache-2.0
@@ -29,280 +28,319 @@ const website_constructs_1 = require("../../../utils/website-constructs/website-
29
28
  const iac_1 = require("../../../utils/iac");
30
29
  exports.SUPPORTED_UX_PROVIDERS = ['None', 'Cloudscape', 'Shadcn'];
31
30
  exports.REACT_WEBSITE_APP_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
32
- function tsReactWebsiteGenerator(tree, schema) {
33
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
34
- var _a, _b, _c, _d, _e, _f;
35
- const enableTailwind = (_a = schema.enableTailwind) !== null && _a !== void 0 ? _a : true;
36
- const enableTanstackRouter = (_b = schema.enableTanstackRouter) !== null && _b !== void 0 ? _b : true;
37
- const uxProvider = (_c = schema.uxProvider) !== null && _c !== void 0 ? _c : 'Cloudscape';
38
- if (uxProvider === 'Shadcn' && !enableTailwind) {
39
- throw new Error('Shadcn requires TailwindCSS to be enabled.');
40
- }
41
- const npmScopePrefix = (0, npm_scope_1.getNpmScopePrefix)(tree);
42
- const scopeAlias = (0, npm_scope_1.toScopeAlias)(npmScopePrefix);
43
- const websiteNameClassName = (0, names_1.toClassName)(schema.name);
44
- const websiteNameKebabCase = (0, names_1.toKebabCase)(schema.name);
45
- const fullyQualifiedName = `${npmScopePrefix}${websiteNameKebabCase}`;
46
- // NB: interactive nx generator cli can pass empty string
47
- const websiteContentPath = (0, devkit_1.joinPathFragments)(schema.directory || '.', schema.subDirectory || websiteNameKebabCase);
48
- // TODO: consider exposing and supporting e2e tests
49
- const e2eTestRunner = 'none';
50
- yield (0, react_1.applicationGenerator)(tree, Object.assign(Object.assign({}, schema), { name: fullyQualifiedName, directory: websiteContentPath, routing: false, e2eTestRunner, linter: 'eslint', bundler: 'vite', unitTestRunner: 'vitest', useProjectJson: true, style: 'css' }));
51
- // Replace with simpler sample source code
52
- tree.delete((0, devkit_1.joinPathFragments)(websiteContentPath, 'src'));
53
- const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, fullyQualifiedName);
54
- const targets = projectConfiguration.targets;
55
- // Configure load:runtime-config target based on IaC provider
56
- const iacProvider = yield (0, iac_1.resolveIacProvider)(tree, schema.iacProvider);
57
- if (iacProvider === 'CDK') {
58
- targets['load:runtime-config'] = {
59
- executor: 'nx:run-commands',
60
- metadata: {
61
- description: `Load runtime config from your deployed stack for dev purposes. You must set your AWS CLI credentials whilst calling '${(0, pkg_manager_1.getPackageManagerDisplayCommands)().exec} nx run ${fullyQualifiedName}:load:runtime-config'`,
62
- },
63
- options: {
64
- command: `aws s3 cp s3://\`aws cloudformation describe-stacks --query "Stacks[?starts_with(StackName, '${(0, names_1.kebabCase)(npmScopePrefix)}-')][].Outputs[] | [?contains(OutputKey, '${websiteNameClassName}WebsiteBucketName')].OutputValue" --output text\`/runtime-config.json "{projectRoot}/public/runtime-config.json"`,
65
- },
66
- };
67
- }
68
- else if (iacProvider === 'Terraform') {
69
- targets['load:runtime-config'] = {
70
- executor: 'nx:run-commands',
71
- metadata: {
72
- description: "Load runtime config from most recently applied terraform env for dev purposes. Copies the runtime config from the Terraform dist directory to the website's public directory.",
73
- },
74
- options: {
75
- command: 'node -e "const fs=require(\'fs\');fs.mkdirSync(process.env.DEST_DIR,{recursive:true});fs.copyFileSync(process.env.SRC_FILE,process.env.DEST_FILE);"',
76
- env: {
77
- SRC_FILE: 'dist/packages/common/terraform/runtime-config.json',
78
- DEST_DIR: `{projectRoot}/public`,
79
- DEST_FILE: `{projectRoot}/public/runtime-config.json`,
80
- },
81
- },
82
- };
83
- }
84
- else {
85
- throw new Error(`Unknown iacProvider: ${iacProvider}. Supported providers are: CDK, Terraform`);
86
- }
87
- const buildTarget = targets['build'];
88
- targets['compile'] = {
89
- dependsOn: ['bundle'],
31
+ async function tsReactWebsiteGenerator(tree, schema) {
32
+ const enableTailwind = schema.enableTailwind ?? true;
33
+ const enableTanstackRouter = schema.enableTanstackRouter ?? true;
34
+ const uxProvider = schema.uxProvider ?? 'Cloudscape';
35
+ if (uxProvider === 'Shadcn' && !enableTailwind) {
36
+ throw new Error('Shadcn requires TailwindCSS to be enabled.');
37
+ }
38
+ const npmScopePrefix = (0, npm_scope_1.getNpmScopePrefix)(tree);
39
+ const scopeAlias = (0, npm_scope_1.toScopeAlias)(npmScopePrefix);
40
+ const websiteNameClassName = (0, names_1.toClassName)(schema.name);
41
+ const websiteNameKebabCase = (0, names_1.toKebabCase)(schema.name);
42
+ const fullyQualifiedName = `${npmScopePrefix}${websiteNameKebabCase}`;
43
+ // NB: interactive nx generator cli can pass empty string
44
+ const websiteContentPath = (0, devkit_1.joinPathFragments)(schema.directory || '.', schema.subDirectory || websiteNameKebabCase);
45
+ // TODO: consider exposing and supporting e2e tests
46
+ const e2eTestRunner = 'none';
47
+ await (0, react_1.applicationGenerator)(tree, {
48
+ ...schema,
49
+ name: fullyQualifiedName,
50
+ directory: websiteContentPath,
51
+ routing: false,
52
+ e2eTestRunner,
53
+ linter: 'eslint',
54
+ bundler: 'vite',
55
+ unitTestRunner: 'vitest',
56
+ useProjectJson: true,
57
+ style: 'css',
58
+ });
59
+ // Replace with simpler sample source code
60
+ tree.delete((0, devkit_1.joinPathFragments)(websiteContentPath, 'src'));
61
+ const projectConfiguration = (0, devkit_1.readProjectConfiguration)(tree, fullyQualifiedName);
62
+ const targets = projectConfiguration.targets;
63
+ // Configure load:runtime-config target based on IaC provider
64
+ const iacProvider = await (0, iac_1.resolveIacProvider)(tree, schema.iacProvider);
65
+ if (iacProvider === 'CDK') {
66
+ targets['load:runtime-config'] = {
90
67
  executor: 'nx:run-commands',
91
- outputs: ['{workspaceRoot}/dist/{projectRoot}/tsc'],
92
- options: {
93
- command: 'tsc --build tsconfig.app.json',
94
- cwd: '{projectRoot}',
68
+ metadata: {
69
+ description: `Load runtime config from your deployed stack for dev purposes. You must set your AWS CLI credentials whilst calling '${(0, pkg_manager_1.getPackageManagerDisplayCommands)().exec} nx run ${fullyQualifiedName}:load:runtime-config'`,
95
70
  },
96
- };
97
- targets['bundle'] = Object.assign(Object.assign({}, buildTarget), { options: Object.assign(Object.assign({}, buildTarget.options), { outputPath: 'dist/{projectRoot}/bundle' }) });
98
- targets['build'] = {
99
- dependsOn: [
100
- 'lint',
101
- 'compile',
102
- 'bundle',
103
- 'test',
104
- ...((_d = buildTarget.dependsOn) !== null && _d !== void 0 ? _d : []),
105
- ],
106
71
  options: {
107
- outputPath: 'dist/{projectRoot}/bundle',
72
+ command: `aws s3 cp s3://\`aws cloudformation describe-stacks --query "Stacks[?starts_with(StackName, '${(0, names_1.kebabCase)(npmScopePrefix)}-')][].Outputs[] | [?contains(OutputKey, '${websiteNameClassName}WebsiteBucketName')].OutputValue" --output text\`/runtime-config.json "{projectRoot}/public/runtime-config.json"`,
108
73
  },
109
74
  };
110
- targets['test'] = Object.assign(Object.assign({}, targets['test']), { options: Object.assign(Object.assign({}, ((_f = (_e = targets['test']) === null || _e === void 0 ? void 0 : _e.options) !== null && _f !== void 0 ? _f : {})), { reportsDirectory: '{workspaceRoot}/coverage/{projectRoot}' }) });
111
- // Add a serve-local target for running the website and its dependencies locally
112
- targets['serve-local'] = {
113
- executor: '@nx/vite:dev-server',
75
+ }
76
+ else if (iacProvider === 'Terraform') {
77
+ targets['load:runtime-config'] = {
78
+ executor: 'nx:run-commands',
79
+ metadata: {
80
+ description: "Load runtime config from most recently applied terraform env for dev purposes. Copies the runtime config from the Terraform dist directory to the website's public directory.",
81
+ },
114
82
  options: {
115
- buildTarget: `${fullyQualifiedName}:build:development`,
116
- hmr: true,
117
- mode: 'serve-local',
83
+ command: 'node -e "const fs=require(\'fs\');fs.mkdirSync(process.env.DEST_DIR,{recursive:true});fs.copyFileSync(process.env.SRC_FILE,process.env.DEST_FILE);"',
84
+ env: {
85
+ SRC_FILE: 'dist/packages/common/terraform/runtime-config.json',
86
+ DEST_DIR: `{projectRoot}/public`,
87
+ DEST_FILE: `{projectRoot}/public/runtime-config.json`,
88
+ },
118
89
  },
119
- continuous: true,
120
90
  };
121
- projectConfiguration.targets = (0, object_1.sortObjectKeys)(targets);
122
- (0, devkit_1.updateProjectConfiguration)(tree, fullyQualifiedName, projectConfiguration);
123
- (0, nx_1.addGeneratorMetadata)(tree, projectConfiguration.name, exports.REACT_WEBSITE_APP_GENERATOR_INFO, {
124
- uxProvider,
125
- });
126
- yield (0, ts_project_utils_1.configureTsProject)(tree, {
127
- dir: websiteContentPath,
128
- fullyQualifiedName,
129
- });
130
- if (uxProvider === 'Shadcn') {
131
- yield (0, shared_shadcn_1.sharedShadcnGenerator)(tree);
132
- }
133
- yield (0, shared_constructs_1.sharedConstructsGenerator)(tree, {
134
- iacProvider,
135
- });
136
- yield (0, website_constructs_1.addWebsiteInfra)(tree, {
137
- iacProvider,
138
- websiteProjectName: fullyQualifiedName,
139
- scopeAlias,
140
- websiteContentPath: (0, devkit_1.joinPathFragments)('dist', websiteContentPath),
141
- websiteNameKebabCase,
142
- websiteNameClassName,
91
+ }
92
+ else {
93
+ throw new Error(`Unknown iacProvider: ${iacProvider}. Supported providers are: CDK, Terraform`);
94
+ }
95
+ const buildTarget = targets['build'];
96
+ targets['compile'] = {
97
+ dependsOn: ['bundle'],
98
+ executor: 'nx:run-commands',
99
+ outputs: ['{workspaceRoot}/dist/{projectRoot}/tsc'],
100
+ options: {
101
+ command: 'tsc --build tsconfig.app.json',
102
+ cwd: '{projectRoot}',
103
+ },
104
+ };
105
+ targets['bundle'] = {
106
+ ...buildTarget,
107
+ options: {
108
+ ...buildTarget.options,
109
+ outputPath: 'dist/{projectRoot}/bundle',
110
+ },
111
+ };
112
+ targets['build'] = {
113
+ dependsOn: [
114
+ 'lint',
115
+ 'compile',
116
+ 'bundle',
117
+ 'test',
118
+ ...(buildTarget.dependsOn ?? []),
119
+ ],
120
+ options: {
121
+ outputPath: 'dist/{projectRoot}/bundle',
122
+ },
123
+ };
124
+ targets['test'] = {
125
+ ...targets['test'],
126
+ options: {
127
+ ...(targets['test']?.options ?? {}),
128
+ reportsDirectory: '{workspaceRoot}/coverage/{projectRoot}',
129
+ },
130
+ };
131
+ // Add a serve-local target for running the website and its dependencies locally
132
+ targets['serve-local'] = {
133
+ executor: '@nx/vite:dev-server',
134
+ options: {
135
+ buildTarget: `${fullyQualifiedName}:build:development`,
136
+ hmr: true,
137
+ mode: 'serve-local',
138
+ },
139
+ continuous: true,
140
+ };
141
+ projectConfiguration.targets = (0, object_1.sortObjectKeys)(targets);
142
+ (0, devkit_1.updateProjectConfiguration)(tree, fullyQualifiedName, projectConfiguration);
143
+ (0, nx_1.addGeneratorMetadata)(tree, projectConfiguration.name, exports.REACT_WEBSITE_APP_GENERATOR_INFO, {
144
+ uxProvider,
145
+ });
146
+ await (0, ts_project_utils_1.configureTsProject)(tree, {
147
+ dir: websiteContentPath,
148
+ fullyQualifiedName,
149
+ });
150
+ if (uxProvider === 'Shadcn') {
151
+ await (0, shared_shadcn_1.sharedShadcnGenerator)(tree);
152
+ }
153
+ await (0, shared_constructs_1.sharedConstructsGenerator)(tree, {
154
+ iacProvider,
155
+ });
156
+ await (0, website_constructs_1.addWebsiteInfra)(tree, {
157
+ iacProvider,
158
+ websiteProjectName: fullyQualifiedName,
159
+ scopeAlias,
160
+ websiteContentPath: (0, devkit_1.joinPathFragments)('dist', websiteContentPath),
161
+ websiteNameKebabCase,
162
+ websiteNameClassName,
163
+ });
164
+ const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, fullyQualifiedName);
165
+ const libraryRoot = projectConfig.root;
166
+ const sharedShadcnStylesImport = (0, path_1.relative)((0, devkit_1.joinPathFragments)(libraryRoot, 'src'), (0, devkit_1.joinPathFragments)(shared_constructs_constants_1.PACKAGES_DIR, shared_constructs_constants_1.SHARED_SHADCN_DIR, 'src', 'styles', 'globals.css'))
167
+ .split(path_1.sep)
168
+ .join('/');
169
+ const sharedShadcnTsconfigRef = (0, path_1.relative)((0, devkit_1.joinPathFragments)(tree.root, websiteContentPath), (0, devkit_1.joinPathFragments)(tree.root, shared_constructs_constants_1.PACKAGES_DIR, shared_constructs_constants_1.SHARED_SHADCN_DIR, 'tsconfig.json'))
170
+ .split(path_1.sep)
171
+ .join('/');
172
+ const templateOptions = {
173
+ ...schema,
174
+ fullyQualifiedName,
175
+ pkgMgrCmd: (0, pkg_manager_1.getPackageManagerDisplayCommands)().exec,
176
+ enableTailwind,
177
+ enableTanstackRouter,
178
+ scopeAlias,
179
+ sharedShadcnStylesImport,
180
+ };
181
+ tree.delete((0, devkit_1.joinPathFragments)(libraryRoot, 'src', 'app'));
182
+ const appCommonTemplatePath = (0, devkit_1.joinPathFragments)(__dirname, './files/app/common');
183
+ const appTemplatePath = (0, devkit_1.joinPathFragments)(__dirname, `./files/app/${uxProvider.toLowerCase()}`);
184
+ (0, devkit_1.generateFiles)(tree, // the virtual file system
185
+ appCommonTemplatePath, // path to the file templates
186
+ libraryRoot, // destination path of the files
187
+ templateOptions, // config object to replace variable in file templates
188
+ {
189
+ overwriteStrategy: devkit_1.OverwriteStrategy.Overwrite,
190
+ });
191
+ (0, devkit_1.generateFiles)(tree, // the virtual file system
192
+ appTemplatePath, // path to the file templates
193
+ libraryRoot, // destination path of the files
194
+ templateOptions, // config object to replace variable in file templates
195
+ {
196
+ overwriteStrategy: devkit_1.OverwriteStrategy.Overwrite,
197
+ });
198
+ if (enableTanstackRouter) {
199
+ const routerCommonTemplatePath = (0, devkit_1.joinPathFragments)(__dirname, './files/tanstack-router/common');
200
+ const routerTemplatePath = (0, devkit_1.joinPathFragments)(__dirname, `./files/tanstack-router/${uxProvider.toLowerCase()}`);
201
+ (0, devkit_1.generateFiles)(tree, routerCommonTemplatePath, libraryRoot, templateOptions, {
202
+ overwriteStrategy: devkit_1.OverwriteStrategy.Overwrite,
143
203
  });
144
- const projectConfig = (0, devkit_1.readProjectConfiguration)(tree, fullyQualifiedName);
145
- const libraryRoot = projectConfig.root;
146
- const sharedShadcnStylesImport = (0, path_1.relative)((0, devkit_1.joinPathFragments)(libraryRoot, 'src'), (0, devkit_1.joinPathFragments)(shared_constructs_constants_1.PACKAGES_DIR, shared_constructs_constants_1.SHARED_SHADCN_DIR, 'src', 'styles', 'globals.css'))
147
- .split(path_1.sep)
148
- .join('/');
149
- const sharedShadcnTsconfigRef = (0, path_1.relative)((0, devkit_1.joinPathFragments)(tree.root, websiteContentPath), (0, devkit_1.joinPathFragments)(tree.root, shared_constructs_constants_1.PACKAGES_DIR, shared_constructs_constants_1.SHARED_SHADCN_DIR, 'tsconfig.json'))
150
- .split(path_1.sep)
151
- .join('/');
152
- const templateOptions = Object.assign(Object.assign({}, schema), { fullyQualifiedName, pkgMgrCmd: (0, pkg_manager_1.getPackageManagerDisplayCommands)().exec, enableTailwind,
153
- enableTanstackRouter,
154
- scopeAlias,
155
- sharedShadcnStylesImport });
156
- tree.delete((0, devkit_1.joinPathFragments)(libraryRoot, 'src', 'app'));
157
- const appCommonTemplatePath = (0, devkit_1.joinPathFragments)(__dirname, './files/app/common');
158
- const appTemplatePath = (0, devkit_1.joinPathFragments)(__dirname, `./files/app/${uxProvider.toLowerCase()}`);
159
- (0, devkit_1.generateFiles)(tree, // the virtual file system
160
- appCommonTemplatePath, // path to the file templates
161
- libraryRoot, // destination path of the files
162
- templateOptions, // config object to replace variable in file templates
204
+ (0, devkit_1.generateFiles)(tree, routerTemplatePath, libraryRoot, templateOptions, // config object to replace variable in file templates
163
205
  {
164
206
  overwriteStrategy: devkit_1.OverwriteStrategy.Overwrite,
165
207
  });
208
+ tree.delete((0, devkit_1.joinPathFragments)(websiteContentPath, 'src', 'app.tsx'));
209
+ }
210
+ if (e2eTestRunner !== 'none') {
211
+ const e2eFullyQualifiedName = `${fullyQualifiedName}-e2e`;
212
+ const e2eRoot = (0, devkit_1.readProjectConfiguration)(tree, e2eFullyQualifiedName).root;
166
213
  (0, devkit_1.generateFiles)(tree, // the virtual file system
167
- appTemplatePath, // path to the file templates
168
- libraryRoot, // destination path of the files
169
- templateOptions, // config object to replace variable in file templates
170
- {
171
- overwriteStrategy: devkit_1.OverwriteStrategy.Overwrite,
214
+ (0, devkit_1.joinPathFragments)(__dirname, `./files/e2e/${e2eTestRunner}`), // path to the file templates
215
+ e2eRoot, // destination path of the files
216
+ { ...schema, ...(0, devkit_1.names)(fullyQualifiedName) }, {
217
+ overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting,
218
+ });
219
+ await (0, ts_project_utils_1.configureTsProject)(tree, {
220
+ fullyQualifiedName: e2eFullyQualifiedName,
221
+ dir: e2eRoot,
172
222
  });
223
+ }
224
+ const viteConfigPath = (0, devkit_1.joinPathFragments)(libraryRoot, 'vite.config.mts');
225
+ if (tree.exists(viteConfigPath)) {
226
+ // Add Tanstack Router import if enabled
173
227
  if (enableTanstackRouter) {
174
- const routerCommonTemplatePath = (0, devkit_1.joinPathFragments)(__dirname, './files/tanstack-router/common');
175
- const routerTemplatePath = (0, devkit_1.joinPathFragments)(__dirname, `./files/tanstack-router/${uxProvider.toLowerCase()}`);
176
- (0, devkit_1.generateFiles)(tree, routerCommonTemplatePath, libraryRoot, templateOptions, {
177
- overwriteStrategy: devkit_1.OverwriteStrategy.Overwrite,
178
- });
179
- (0, devkit_1.generateFiles)(tree, routerTemplatePath, libraryRoot, templateOptions, // config object to replace variable in file templates
180
- {
181
- overwriteStrategy: devkit_1.OverwriteStrategy.Overwrite,
182
- });
183
- tree.delete((0, devkit_1.joinPathFragments)(websiteContentPath, 'src', 'app.tsx'));
228
+ await (0, ast_1.addDestructuredImport)(tree, viteConfigPath, ['tanstackRouter'], '@tanstack/router-plugin/vite');
229
+ await (0, ast_1.addDestructuredImport)(tree, viteConfigPath, ['resolve'], 'path');
184
230
  }
185
- if (e2eTestRunner !== 'none') {
186
- const e2eFullyQualifiedName = `${fullyQualifiedName}-e2e`;
187
- const e2eRoot = (0, devkit_1.readProjectConfiguration)(tree, e2eFullyQualifiedName).root;
188
- (0, devkit_1.generateFiles)(tree, // the virtual file system
189
- (0, devkit_1.joinPathFragments)(__dirname, `./files/e2e/${e2eTestRunner}`), // path to the file templates
190
- e2eRoot, Object.assign(Object.assign({}, schema), (0, devkit_1.names)(fullyQualifiedName)), {
191
- overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting,
192
- });
193
- yield (0, ts_project_utils_1.configureTsProject)(tree, {
194
- fullyQualifiedName: e2eFullyQualifiedName,
195
- dir: e2eRoot,
196
- });
231
+ await (0, ast_1.addSingleImport)(tree, viteConfigPath, 'tsconfigPaths', 'vite-tsconfig-paths');
232
+ // Add TailwindCSS import if enabled
233
+ if (enableTailwind) {
234
+ await (0, ast_1.addSingleImport)(tree, viteConfigPath, 'tailwindcss', '@tailwindcss/vite');
197
235
  }
198
- const viteConfigPath = (0, devkit_1.joinPathFragments)(libraryRoot, 'vite.config.mts');
199
- if (tree.exists(viteConfigPath)) {
200
- // Add Tanstack Router import if enabled
201
- if (enableTanstackRouter) {
202
- yield (0, ast_1.addDestructuredImport)(tree, viteConfigPath, ['tanstackRouter'], '@tanstack/router-plugin/vite');
203
- yield (0, ast_1.addDestructuredImport)(tree, viteConfigPath, ['resolve'], 'path');
204
- }
205
- yield (0, ast_1.addSingleImport)(tree, viteConfigPath, 'tsconfigPaths', 'vite-tsconfig-paths');
206
- // Add TailwindCSS import if enabled
207
- if (enableTailwind) {
208
- yield (0, ast_1.addSingleImport)(tree, viteConfigPath, 'tailwindcss', '@tailwindcss/vite');
209
- }
210
- (0, ast_1.replaceIfExists)(tree, viteConfigPath, 'ObjectLiteralExpression', (node) => {
211
- const updatedProperties = node.properties.map((prop) => {
212
- if ((0, typescript_1.isPropertyAssignment)(prop) && prop.name.getText() === 'build') {
213
- const buildConfig = prop.initializer;
214
- return typescript_1.factory.createPropertyAssignment('build', typescript_1.factory.createObjectLiteralExpression(buildConfig.properties.map((buildProp) => {
215
- if ((0, typescript_1.isPropertyAssignment)(buildProp) &&
216
- buildProp.name.getText() === 'outDir') {
217
- return typescript_1.factory.createPropertyAssignment('outDir', typescript_1.factory.createStringLiteral((0, devkit_1.joinPathFragments)((0, paths_1.getRelativePathToRoot)(tree, fullyQualifiedName), 'dist', websiteContentPath)));
218
- }
219
- return buildProp;
220
- }), true));
221
- }
222
- else if ((0, typescript_1.isPropertyAssignment)(prop) &&
223
- prop.name.getText() === 'plugins') {
224
- const pluginsConfig = prop.initializer;
225
- const pluginsArray = [...pluginsConfig.elements];
226
- if (enableTanstackRouter) {
227
- pluginsArray.unshift(typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('tanstackRouter'), undefined, [
228
- typescript_1.factory.createObjectLiteralExpression([
229
- typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier('routesDirectory'), typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('resolve'), undefined, [
230
- typescript_1.factory.createIdentifier('__dirname'),
231
- typescript_1.factory.createStringLiteral('src/routes'),
232
- ])),
233
- typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier('generatedRouteTree'), typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('resolve'), undefined, [
234
- typescript_1.factory.createIdentifier('__dirname'),
235
- typescript_1.factory.createStringLiteral('src/routeTree.gen.ts'),
236
- ])),
237
- ]),
238
- ]));
239
- }
240
- // Add TailwindCSS plugin if enabled
241
- if (enableTailwind) {
242
- pluginsArray.push(typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('tailwindcss'), undefined, []));
236
+ (0, ast_1.replaceIfExists)(tree, viteConfigPath, 'ObjectLiteralExpression', (node) => {
237
+ const updatedProperties = node.properties.map((prop) => {
238
+ if ((0, typescript_1.isPropertyAssignment)(prop) && prop.name.getText() === 'build') {
239
+ const buildConfig = prop.initializer;
240
+ return typescript_1.factory.createPropertyAssignment('build', typescript_1.factory.createObjectLiteralExpression(buildConfig.properties.map((buildProp) => {
241
+ if ((0, typescript_1.isPropertyAssignment)(buildProp) &&
242
+ buildProp.name.getText() === 'outDir') {
243
+ return typescript_1.factory.createPropertyAssignment('outDir', typescript_1.factory.createStringLiteral((0, devkit_1.joinPathFragments)((0, paths_1.getRelativePathToRoot)(tree, fullyQualifiedName), 'dist', websiteContentPath)));
243
244
  }
244
- pluginsArray.push(typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('tsconfigPaths'), undefined, []));
245
- return typescript_1.factory.createPropertyAssignment('plugins', typescript_1.factory.createArrayLiteralExpression(pluginsArray, true));
245
+ return buildProp;
246
+ }), true));
247
+ }
248
+ else if ((0, typescript_1.isPropertyAssignment)(prop) &&
249
+ prop.name.getText() === 'plugins') {
250
+ const pluginsConfig = prop.initializer;
251
+ const pluginsArray = [...pluginsConfig.elements];
252
+ if (enableTanstackRouter) {
253
+ pluginsArray.unshift(typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('tanstackRouter'), undefined, [
254
+ typescript_1.factory.createObjectLiteralExpression([
255
+ typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier('routesDirectory'), typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('resolve'), undefined, [
256
+ typescript_1.factory.createIdentifier('__dirname'),
257
+ typescript_1.factory.createStringLiteral('src/routes'),
258
+ ])),
259
+ typescript_1.factory.createPropertyAssignment(typescript_1.factory.createIdentifier('generatedRouteTree'), typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('resolve'), undefined, [
260
+ typescript_1.factory.createIdentifier('__dirname'),
261
+ typescript_1.factory.createStringLiteral('src/routeTree.gen.ts'),
262
+ ])),
263
+ ]),
264
+ ]));
246
265
  }
247
- return prop;
248
- });
249
- return typescript_1.factory.createObjectLiteralExpression(updatedProperties, true);
250
- });
251
- (0, ast_1.replaceIfExists)(tree, viteConfigPath, 'ObjectLiteralExpression', (node) => {
252
- return typescript_1.factory.createObjectLiteralExpression([
253
- typescript_1.factory.createPropertyAssignment('define', typescript_1.factory.createObjectLiteralExpression([
254
- typescript_1.factory.createPropertyAssignment('global', typescript_1.factory.createObjectLiteralExpression()),
255
- ], true)),
256
- ...node.properties,
257
- ], true);
266
+ // Add TailwindCSS plugin if enabled
267
+ if (enableTailwind) {
268
+ pluginsArray.push(typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('tailwindcss'), undefined, []));
269
+ }
270
+ pluginsArray.push(typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier('tsconfigPaths'), undefined, []));
271
+ return typescript_1.factory.createPropertyAssignment('plugins', typescript_1.factory.createArrayLiteralExpression(pluginsArray, true));
272
+ }
273
+ return prop;
258
274
  });
259
- }
260
- (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(websiteContentPath, 'tsconfig.json'), (tsconfig) => (Object.assign(Object.assign({}, tsconfig), { compilerOptions: Object.assign(Object.assign({}, tsconfig.compilerOptions), { moduleResolution: 'Bundler', module: 'Preserve' }) })));
261
- const outDirToRootRelativePath = (0, path_1.relative)((0, devkit_1.joinPathFragments)(tree.root, websiteContentPath), tree.root);
262
- const distDir = (0, devkit_1.joinPathFragments)(outDirToRootRelativePath, 'dist', websiteContentPath, 'tsc');
263
- (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(websiteContentPath, 'tsconfig.app.json'), (tsconfig) => {
264
- var _a;
265
- return (Object.assign(Object.assign({}, tsconfig), { compilerOptions: Object.assign(Object.assign({}, tsconfig.compilerOptions), { outDir: distDir, tsBuildInfoFile: (0, devkit_1.joinPathFragments)(distDir, 'tsconfig.lib.tsbuildinfo'), lib: ['DOM'] }), references: uxProvider === 'Shadcn'
266
- ? [
267
- ...((_a = tsconfig.references) !== null && _a !== void 0 ? _a : []).filter((ref) => ref.path !== sharedShadcnTsconfigRef),
268
- {
269
- path: sharedShadcnTsconfigRef,
270
- },
271
- ]
272
- : tsconfig.references }));
275
+ return typescript_1.factory.createObjectLiteralExpression(updatedProperties, true);
273
276
  });
274
- const devDependencies = [
275
- 'vite-tsconfig-paths',
276
- '@nx/react',
277
- '@vitest/ui',
278
- ];
279
- const dependencies = ['react', 'react-dom'];
280
- if (uxProvider === 'Cloudscape') {
281
- dependencies.push('@cloudscape-design/components', '@cloudscape-design/board-components', '@cloudscape-design/global-styles');
282
- }
283
- else if (uxProvider === 'Shadcn') {
284
- // not required to add any dependencies because dependencies are added by the common/shadcn package.
285
- }
286
- // Add TailwindCSS dependencies if enabled
287
- if (enableTailwind) {
288
- dependencies.push('tailwindcss');
289
- devDependencies.push('@tailwindcss/vite');
290
- }
291
- if (enableTanstackRouter) {
292
- dependencies.push('@tanstack/react-router');
293
- devDependencies.push('@tanstack/router-plugin', '@tanstack/router-generator', '@tanstack/virtual-file-routes', '@tanstack/router-utils');
277
+ (0, ast_1.replaceIfExists)(tree, viteConfigPath, 'ObjectLiteralExpression', (node) => {
278
+ return typescript_1.factory.createObjectLiteralExpression([
279
+ typescript_1.factory.createPropertyAssignment('define', typescript_1.factory.createObjectLiteralExpression([
280
+ typescript_1.factory.createPropertyAssignment('global', typescript_1.factory.createObjectLiteralExpression()),
281
+ ], true)),
282
+ ...node.properties,
283
+ ], true);
284
+ });
285
+ }
286
+ (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(websiteContentPath, 'tsconfig.json'), (tsconfig) => ({
287
+ ...tsconfig,
288
+ compilerOptions: {
289
+ ...tsconfig.compilerOptions,
290
+ moduleResolution: 'Bundler',
291
+ module: 'Preserve',
292
+ },
293
+ }));
294
+ const outDirToRootRelativePath = (0, path_1.relative)((0, devkit_1.joinPathFragments)(tree.root, websiteContentPath), tree.root);
295
+ const distDir = (0, devkit_1.joinPathFragments)(outDirToRootRelativePath, 'dist', websiteContentPath, 'tsc');
296
+ (0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(websiteContentPath, 'tsconfig.app.json'), (tsconfig) => ({
297
+ ...tsconfig,
298
+ compilerOptions: {
299
+ ...tsconfig.compilerOptions,
300
+ outDir: distDir,
301
+ tsBuildInfoFile: (0, devkit_1.joinPathFragments)(distDir, 'tsconfig.lib.tsbuildinfo'),
302
+ lib: ['DOM'],
303
+ },
304
+ references: uxProvider === 'Shadcn'
305
+ ? [
306
+ ...(tsconfig.references ?? []).filter((ref) => ref.path !== sharedShadcnTsconfigRef),
307
+ {
308
+ path: sharedShadcnTsconfigRef,
309
+ },
310
+ ]
311
+ : tsconfig.references,
312
+ }));
313
+ const devDependencies = [
314
+ 'vite-tsconfig-paths',
315
+ '@nx/react',
316
+ '@vitest/ui',
317
+ ];
318
+ const dependencies = ['react', 'react-dom'];
319
+ if (uxProvider === 'Cloudscape') {
320
+ dependencies.push('@cloudscape-design/components', '@cloudscape-design/board-components', '@cloudscape-design/global-styles');
321
+ }
322
+ else if (uxProvider === 'Shadcn') {
323
+ // not required to add any dependencies because dependencies are added by the common/shadcn package.
324
+ }
325
+ // Add TailwindCSS dependencies if enabled
326
+ if (enableTailwind) {
327
+ dependencies.push('tailwindcss');
328
+ devDependencies.push('@tailwindcss/vite');
329
+ }
330
+ if (enableTanstackRouter) {
331
+ dependencies.push('@tanstack/react-router');
332
+ devDependencies.push('@tanstack/router-plugin', '@tanstack/router-generator', '@tanstack/virtual-file-routes', '@tanstack/router-utils');
333
+ }
334
+ (0, devkit_1.addDependenciesToPackageJson)(tree, (0, versions_1.withVersions)(dependencies), (0, versions_1.withVersions)(devDependencies));
335
+ await (0, metrics_1.addGeneratorMetricsIfApplicable)(tree, [
336
+ exports.REACT_WEBSITE_APP_GENERATOR_INFO,
337
+ ]);
338
+ await (0, format_1.formatFilesInSubtree)(tree);
339
+ return () => {
340
+ if (!schema.skipInstall) {
341
+ (0, devkit_1.installPackagesTask)(tree);
294
342
  }
295
- (0, devkit_1.addDependenciesToPackageJson)(tree, (0, versions_1.withVersions)(dependencies), (0, versions_1.withVersions)(devDependencies));
296
- yield (0, metrics_1.addGeneratorMetricsIfApplicable)(tree, [
297
- exports.REACT_WEBSITE_APP_GENERATOR_INFO,
298
- ]);
299
- yield (0, format_1.formatFilesInSubtree)(tree);
300
- return () => {
301
- if (!schema.skipInstall) {
302
- (0, devkit_1.installPackagesTask)(tree);
303
- }
304
- };
305
- });
343
+ };
306
344
  }
307
345
  exports.default = tsReactWebsiteGenerator;
308
346
  //# sourceMappingURL=generator.js.map