@aws/nx-plugin 1.0.0-rc.32 → 1.0.0-rc.34

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 (277) hide show
  1. package/LICENSE-THIRD-PARTY +75 -86
  2. package/generators.json +27 -0
  3. package/package.json +10 -10
  4. package/src/connection/generator.js +12 -1
  5. package/src/connection/generator.js.map +1 -1
  6. package/src/connection/supported-connections.d.ts +10 -1
  7. package/src/connection/supported-connections.js +13 -0
  8. package/src/connection/supported-connections.js.map +1 -1
  9. package/src/infra/app/__snapshots__/generator.spec.ts.snap +21 -21
  10. package/src/infra/app/files/app/src/main.ts.template +1 -1
  11. package/src/infra/app/files/app/src/stages/application-stage.ts.template +1 -1
  12. package/src/infra/app/generator.js +3 -1
  13. package/src/infra/app/generator.js.map +1 -1
  14. package/src/open-api/ts-client/__snapshots__/generator.complex-types.spec.ts.snap +12 -12
  15. package/src/open-api/ts-client/__snapshots__/generator.composite-types.spec.ts.snap +74 -10
  16. package/src/open-api/ts-client/__snapshots__/generator.content-type.spec.ts.snap +22 -4
  17. package/src/open-api/ts-client/__snapshots__/generator.duplicate-types.spec.ts.snap +53 -8
  18. package/src/open-api/ts-client/__snapshots__/generator.edge-cases.spec.ts.snap +32 -4
  19. package/src/open-api/ts-client/__snapshots__/generator.fast-api-gaps.spec.ts.snap +736 -0
  20. package/src/open-api/ts-client/__snapshots__/generator.fast-api.spec.ts.snap +86 -11
  21. package/src/open-api/ts-client/__snapshots__/generator.multipart.spec.ts.snap +21 -3
  22. package/src/open-api/ts-client/__snapshots__/generator.primitive-types.spec.ts.snap +2 -2
  23. package/src/open-api/ts-client/__snapshots__/generator.request.spec.ts.snap +6 -6
  24. package/src/open-api/ts-client/__snapshots__/generator.reserved-keywords.spec.ts.snap +2 -2
  25. package/src/open-api/ts-client/__snapshots__/generator.spec-compliance.spec.ts.snap +1883 -0
  26. package/src/open-api/ts-client/__snapshots__/generator.tags.spec.ts.snap +4 -4
  27. package/src/open-api/ts-client/files/client.gen.ts.template +196 -13
  28. package/src/open-api/ts-client/files/types.gen.ts.template +2 -0
  29. package/src/open-api/ts-client/generator.js +27 -2
  30. package/src/open-api/ts-client/generator.js.map +1 -1
  31. package/src/open-api/ts-hooks/files/options-proxy.gen.ts.template +2 -2
  32. package/src/open-api/ts-hooks/generator.js +5 -1
  33. package/src/open-api/ts-hooks/generator.js.map +1 -1
  34. package/src/open-api/utils/codegen-data/languages.js +6 -0
  35. package/src/open-api/utils/codegen-data/languages.js.map +1 -1
  36. package/src/open-api/utils/codegen-data/types.d.ts +16 -1
  37. package/src/open-api/utils/codegen-data/types.js.map +1 -1
  38. package/src/open-api/utils/codegen-data.js +71 -0
  39. package/src/open-api/utils/codegen-data.js.map +1 -1
  40. package/src/open-api/utils/normalise.js +53 -8
  41. package/src/open-api/utils/normalise.js.map +1 -1
  42. package/src/open-api/utils/parser.js +48 -15
  43. package/src/open-api/utils/parser.js.map +1 -1
  44. package/src/preset/__snapshots__/generator.spec.ts.snap +5 -3
  45. package/src/preset/generator.d.ts +1 -1
  46. package/src/preset/generator.js +5 -2
  47. package/src/preset/generator.js.map +1 -1
  48. package/src/preset/schema.d.js.map +1 -1
  49. package/src/preset/schema.d.ts +2 -0
  50. package/src/preset/schema.json +6 -0
  51. package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +7 -7
  52. package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +8 -8
  53. package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +89 -3
  54. package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
  55. package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +12 -12
  56. package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
  57. package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +91 -5
  58. package/src/py/rdb/__snapshots__/generator.spec.ts.snap +2038 -0
  59. package/src/py/rdb/agent-connection/__snapshots__/generator.spec.ts.snap +104 -0
  60. package/src/py/rdb/agent-connection/generator.d.ts +10 -0
  61. package/src/py/rdb/agent-connection/generator.js +46 -0
  62. package/src/py/rdb/agent-connection/generator.js.map +1 -0
  63. package/src/py/rdb/agent-connection/schema.d.js +8 -0
  64. package/src/py/rdb/agent-connection/schema.d.js.map +1 -0
  65. package/src/py/rdb/agent-connection/schema.d.ts +15 -0
  66. package/src/py/rdb/agent-connection/schema.json +27 -0
  67. package/src/py/rdb/fast-api-connection/__snapshots__/generator.spec.ts.snap +44 -0
  68. package/src/py/rdb/fast-api-connection/files/__apiModuleName__/dependencies/__rdbNameSnake__.py.template +14 -0
  69. package/src/py/rdb/fast-api-connection/generator.d.ts +10 -0
  70. package/src/py/rdb/fast-api-connection/generator.js +54 -0
  71. package/src/py/rdb/fast-api-connection/generator.js.map +1 -0
  72. package/src/py/rdb/fast-api-connection/schema.d.js +8 -0
  73. package/src/py/rdb/fast-api-connection/schema.d.js.map +1 -0
  74. package/src/py/rdb/fast-api-connection/schema.d.ts +13 -0
  75. package/src/py/rdb/fast-api-connection/schema.json +23 -0
  76. package/src/py/rdb/files/Dockerfile.create-db-user.template +10 -0
  77. package/src/py/rdb/files/Dockerfile.migration.template +10 -0
  78. package/src/py/rdb/files/__name__/__init__.py.template +3 -0
  79. package/src/py/rdb/files/__name__/connection.py.template +55 -0
  80. package/src/py/rdb/files/__name__/create_db_user_handler.py.template +97 -0
  81. package/src/py/rdb/files/__name__/migration_handler.py.template +36 -0
  82. package/src/py/rdb/files/__name__/models/__init__.py.template +3 -0
  83. package/src/py/rdb/files/__name__/models/example.py.template +8 -0
  84. package/src/py/rdb/files/__name__/utils.py.template +104 -0
  85. package/src/py/rdb/files/alembic.ini.template +38 -0
  86. package/src/py/rdb/files/config.json.template +14 -0
  87. package/src/py/rdb/files/migrations/env.py.template +80 -0
  88. package/src/py/rdb/files/migrations/script.py.mako.template +28 -0
  89. package/src/py/rdb/generator.d.ts +6 -0
  90. package/src/py/rdb/generator.js +263 -0
  91. package/src/py/rdb/generator.js.map +1 -0
  92. package/src/py/rdb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +101 -0
  93. package/src/py/rdb/mcp-server-connection/generator.d.ts +10 -0
  94. package/src/py/rdb/mcp-server-connection/generator.js +46 -0
  95. package/src/py/rdb/mcp-server-connection/generator.js.map +1 -0
  96. package/src/py/rdb/mcp-server-connection/schema.d.js +8 -0
  97. package/src/py/rdb/mcp-server-connection/schema.d.js.map +1 -0
  98. package/src/py/rdb/mcp-server-connection/schema.d.ts +15 -0
  99. package/src/py/rdb/mcp-server-connection/schema.json +27 -0
  100. package/src/py/rdb/schema.d.js +6 -0
  101. package/src/py/rdb/schema.d.js.map +1 -0
  102. package/src/py/rdb/schema.d.ts +16 -0
  103. package/src/py/rdb/schema.json +77 -0
  104. package/src/py/rdb/utils.d.ts +6 -0
  105. package/src/py/rdb/utils.js +16 -0
  106. package/src/py/rdb/utils.js.map +1 -0
  107. package/src/sdk/py.d.ts +2 -0
  108. package/src/sdk/py.js +1 -0
  109. package/src/sdk/py.js.map +1 -1
  110. package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +7 -7
  111. package/src/smithy/ts/api/files/handler.ts.template +2 -2
  112. package/src/smithy/ts/api/files/local-server.ts.template +2 -2
  113. package/src/smithy/ts/api/files/operations/echo.ts.template +2 -2
  114. package/src/smithy/ts/api/files/service.ts.template +3 -3
  115. package/src/smithy/ts/api/generator.js +3 -1
  116. package/src/smithy/ts/api/generator.js.map +1 -1
  117. package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +12 -12
  118. package/src/trpc/backend/files/src/client/index.ts.template +1 -1
  119. package/src/trpc/backend/files/src/handler.ts.template +1 -1
  120. package/src/trpc/backend/files/src/index.ts.template +5 -5
  121. package/src/trpc/backend/files/src/init.ts.template +1 -1
  122. package/src/trpc/backend/files/src/local-server.ts.template +1 -1
  123. package/src/trpc/backend/files/src/middleware/index.ts.template +7 -7
  124. package/src/trpc/backend/files/src/procedures/echo.ts.template +2 -2
  125. package/src/trpc/backend/files/src/router.ts.template +2 -2
  126. package/src/trpc/backend/files/src/schema/index.ts.template +1 -1
  127. package/src/trpc/backend/generator.js +3 -1
  128. package/src/trpc/backend/generator.js.map +1 -1
  129. package/src/ts/agent/__snapshots__/generator.spec.ts.snap +89 -3
  130. package/src/ts/agent/a2a-connection/files/agent-connection/app/__targetAgentKebabCase__-client-strands.ts.template +2 -2
  131. package/src/ts/agent/a2a-connection/generator.js +3 -1
  132. package/src/ts/agent/a2a-connection/generator.js.map +1 -1
  133. package/src/ts/agent/files/a2a/index.ts.template +1 -1
  134. package/src/ts/agent/files/ag-ui/index.ts.template +1 -1
  135. package/src/ts/agent/files/http/client.ts.template +2 -2
  136. package/src/ts/agent/files/http/index.ts.template +2 -2
  137. package/src/ts/agent/files/http/router.ts.template +3 -3
  138. package/src/ts/agent/gateway-connection/files/agent-connection/app/__gatewayKebabCase__-client-strands.ts.template +2 -2
  139. package/src/ts/agent/gateway-connection/generator.js +3 -1
  140. package/src/ts/agent/gateway-connection/generator.js.map +1 -1
  141. package/src/ts/agent/generator.js +5 -2
  142. package/src/ts/agent/generator.js.map +1 -1
  143. package/src/ts/agent/mcp-connection/files/agent-connection/app/__mcpServerKebabCase__-client-strands.ts.template +2 -2
  144. package/src/ts/agent/mcp-connection/generator.js +3 -1
  145. package/src/ts/agent/mcp-connection/generator.js.map +1 -1
  146. package/src/ts/astro-docs/files/translation/scripts/translate.ts.template +3 -2
  147. package/src/ts/astro-docs/generator.js +2 -0
  148. package/src/ts/astro-docs/generator.js.map +1 -1
  149. package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
  150. package/src/ts/dynamodb/files/src/client.ts.template +5 -2
  151. package/src/ts/dynamodb/files/src/entities/example.ts.template +1 -1
  152. package/src/ts/dynamodb/files/src/entities/index.ts.template +1 -1
  153. package/src/ts/dynamodb/files/src/index.ts.template +2 -2
  154. package/src/ts/dynamodb/generator.js +3 -1
  155. package/src/ts/dynamodb/generator.js.map +1 -1
  156. package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
  157. package/src/ts/lib/generator.js +7 -1
  158. package/src/ts/lib/generator.js.map +1 -1
  159. package/src/ts/lib/ts-project-utils.js +19 -4
  160. package/src/ts/lib/ts-project-utils.js.map +1 -1
  161. package/src/ts/lib/types.d.ts +6 -0
  162. package/src/ts/lib/types.js.map +1 -1
  163. package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +94 -8
  164. package/src/ts/mcp-server/generator.js +3 -2
  165. package/src/ts/mcp-server/generator.js.map +1 -1
  166. package/src/ts/nx-generator/files/local/generator.ts.template +2 -2
  167. package/src/ts/nx-generator/files/nx-plugin-for-aws/generator/generator.ts.template +2 -2
  168. package/src/ts/nx-generator/generator.js +5 -2
  169. package/src/ts/nx-generator/generator.js.map +1 -1
  170. package/src/ts/nx-plugin/files/mcp-server/server.ts.template +5 -5
  171. package/src/ts/nx-plugin/files/mcp-server/tools/create-workspace-command.ts.template +2 -2
  172. package/src/ts/nx-plugin/files/mcp-server/tools/general-guidance.ts.template +1 -1
  173. package/src/ts/nx-plugin/files/mcp-server/tools/generator-guide.ts.template +2 -2
  174. package/src/ts/nx-plugin/files/mcp-server/tools/list-generators.ts.template +2 -2
  175. package/src/ts/nx-plugin/files/mcp-server/utils.ts.template +3 -3
  176. package/src/ts/nx-plugin/generator.js +3 -1
  177. package/src/ts/nx-plugin/generator.js.map +1 -1
  178. package/src/ts/nx-plugin/utils.js +7 -4
  179. package/src/ts/nx-plugin/utils.js.map +1 -1
  180. package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +149 -177
  181. package/src/ts/rdb/files/src/create-db-user-handler.ts.template +2 -2
  182. package/src/ts/rdb/files/src/index.ts.template +1 -1
  183. package/src/ts/rdb/files/src/migration-handler.ts.template +1 -1
  184. package/src/ts/rdb/files/src/prisma.ts.template +7 -4
  185. package/src/ts/rdb/generator.js +7 -4
  186. package/src/ts/rdb/generator.js.map +1 -1
  187. package/src/ts/rdb/schema.json +1 -1
  188. package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +45 -45
  189. package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +2 -2
  190. package/src/utils/agent-chat/agent-chat.js +3 -1
  191. package/src/utils/agent-chat/agent-chat.js.map +1 -1
  192. package/src/utils/agent-chat/files/a2a/chat.ts.template +1 -1
  193. package/src/utils/agent-chat/files/ag-ui/chat.ts.template +1 -1
  194. package/src/utils/agent-chat/files/http-py/chat.ts.template +2 -2
  195. package/src/utils/agent-chat/files/http-ts/chat.ts.template +1 -1
  196. package/src/utils/agent-connection/agent-connection.js +4 -1
  197. package/src/utils/agent-connection/agent-connection.js.map +1 -1
  198. package/src/utils/agent-connection/files/core-a2a/agentcore-a2a-client-config.ts.template +2 -2
  199. package/src/utils/agent-connection/files/core-auth/agentcore-fetch.ts.template +1 -1
  200. package/src/utils/agent-connection/files/core-gateway/agentcore-gateway-mcp-transport.ts.template +2 -2
  201. package/src/utils/agent-connection/files/core-mcp/agentcore-mcp-transport.ts.template +2 -2
  202. package/src/utils/agent-connection/files/core-shared/agentcore-transport.ts.template +1 -1
  203. package/src/utils/agent-connection/files/core-strands/a2a/agentcore-a2a-client-strands.ts.template +1 -1
  204. package/src/utils/agent-connection/files/core-strands/base/with-session-id-strands.ts.template +1 -1
  205. package/src/utils/agent-connection/files/core-strands/gateway/agentcore-gateway-mcp-client-strands.ts.template +1 -1
  206. package/src/utils/agent-connection/files/core-strands/mcp/agentcore-mcp-client-strands.ts.template +1 -1
  207. package/src/utils/agent-core-constructs/agent-core-constructs.js +10 -3
  208. package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
  209. package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +3 -3
  210. package/src/utils/agent-core-constructs/files/cdk/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.ts.template +4 -4
  211. package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/agentcore-gateway.ts.template +1 -1
  212. package/src/utils/agent-core-constructs/files/terraform/app/agent-core/__nameKebabCase__/__nameKebabCase__.tf.template +27 -0
  213. package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +60 -1
  214. package/src/utils/api-constructs/api-constructs.js +8 -2
  215. package/src/utils/api-constructs/api-constructs.js.map +1 -1
  216. package/src/utils/api-constructs/files/cdk/app/apis/http/__apiNameKebabCase__.ts.template +8 -8
  217. package/src/utils/api-constructs/files/cdk/app/apis/rest/__apiNameKebabCase__.ts.template +8 -8
  218. package/src/utils/api-constructs/files/cdk/core/api/http/http-api.ts.template +3 -3
  219. package/src/utils/api-constructs/files/cdk/core/api/rest/api-gateway-account/index.js.template +32 -20
  220. package/src/utils/api-constructs/files/cdk/core/api/rest/api-gateway-account.ts.template +1 -1
  221. package/src/utils/api-constructs/files/cdk/core/api/rest/rest-api.ts.template +4 -4
  222. package/src/utils/api-constructs/files/cdk/core/api/trpc/trpc-utils.ts.template +1 -1
  223. package/src/utils/ast.js +16 -0
  224. package/src/utils/ast.js.map +1 -1
  225. package/src/utils/commands.d.ts +1 -1
  226. package/src/utils/commands.js +4 -1
  227. package/src/utils/commands.js.map +1 -1
  228. package/src/utils/dynamodb-constructs/dynamodb-constructs.js +9 -2
  229. package/src/utils/dynamodb-constructs/dynamodb-constructs.js.map +1 -1
  230. package/src/utils/dynamodb-constructs/files/cdk/app/dynamodb/__nameKebabCase__.ts.template +3 -3
  231. package/src/utils/dynamodb-constructs/files/cdk/core/dynamodb.ts.template +1 -1
  232. package/src/utils/files/common/constructs/src/core/index.ts.template +4 -4
  233. package/src/utils/files/common/constructs/src/index.ts.template +2 -2
  234. package/src/utils/files/common/infra-config/src/index.ts.template +3 -3
  235. package/src/utils/files/common/infra-config/src/resolve-stage.ts.template +2 -2
  236. package/src/utils/files/common/infra-config/src/stages.config.ts.template +1 -1
  237. package/src/utils/files/common/scripts/src/infra/infra-deploy.ts.template +1 -1
  238. package/src/utils/files/common/scripts/src/infra/infra-destroy.ts.template +1 -1
  239. package/src/utils/files/common/scripts/src/infra/stage-credentials/run.ts.template +3 -3
  240. package/src/utils/files/common/shadcn/src/index.ts.template +2 -2
  241. package/src/utils/function-constructs/files/cdk/app/lambda-functions/__nameKebabCase__.ts.template +1 -1
  242. package/src/utils/function-constructs/function-constructs.js +3 -1
  243. package/src/utils/function-constructs/function-constructs.js.map +1 -1
  244. package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +2 -2
  245. package/src/utils/identity-constructs/identity-constructs.js +5 -1
  246. package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
  247. package/src/utils/module-format.d.ts +28 -0
  248. package/src/utils/module-format.js +28 -0
  249. package/src/utils/module-format.js.map +1 -0
  250. package/src/utils/rdb-constructs/files/cdk/app/dbs/__nameKebabCase__.ts.template +61 -17
  251. package/src/utils/rdb-constructs/files/cdk/core/rdb/aurora.ts.template +68 -78
  252. package/src/utils/rdb-constructs/files/terraform/app/dbs/__nameKebabCase__/__nameKebabCase__.tf.template +88 -8
  253. package/src/utils/rdb-constructs/files/terraform/core/rdb/aurora/aurora.tf.template +5 -32
  254. package/src/utils/rdb-constructs/rdb-constructs.d.ts +11 -1
  255. package/src/utils/rdb-constructs/rdb-constructs.js +9 -2
  256. package/src/utils/rdb-constructs/rdb-constructs.js.map +1 -1
  257. package/src/utils/shared-constructs.js +12 -22
  258. package/src/utils/shared-constructs.js.map +1 -1
  259. package/src/utils/shared-infra-config.js +3 -1
  260. package/src/utils/shared-infra-config.js.map +1 -1
  261. package/src/utils/shared-infra-scripts.js +3 -1
  262. package/src/utils/shared-infra-scripts.js.map +1 -1
  263. package/src/utils/shared-rdb-scripts.js +5 -1
  264. package/src/utils/shared-rdb-scripts.js.map +1 -1
  265. package/src/utils/shared-shadcn.js +3 -1
  266. package/src/utils/shared-shadcn.js.map +1 -1
  267. package/src/utils/test.d.ts +2 -0
  268. package/src/utils/test.js +7 -1
  269. package/src/utils/test.js.map +1 -1
  270. package/src/utils/versions.d.ts +73 -69
  271. package/src/utils/versions.js +71 -67
  272. package/src/utils/versions.js.map +1 -1
  273. package/src/utils/website-constructs/files/cdk/app/static-websites/__websiteNameKebabCase__.ts.template +2 -2
  274. package/src/utils/website-constructs/files/cdk/core/static-website.ts.template +2 -2
  275. package/src/utils/website-constructs/website-constructs.js +9 -2
  276. package/src/utils/website-constructs/website-constructs.js.map +1 -1
  277. package/src/utils/files/terraform/scripts/reset-runtime-config.ts.template +0 -25
@@ -9,20 +9,20 @@ export interface NxGeneratorInfo {
9
9
 
10
10
  export const getPackageName = (): string =>
11
11
  JSON.parse(
12
- fs.readFileSync(path.resolve(import.meta.dirname, '../../package.json'), 'utf-8'),
12
+ fs.readFileSync(path.resolve(<% if (esm) { %>import.meta.dirname<% } else { %>__dirname<% } %>, '../../package.json'), 'utf-8'),
13
13
  ).name;
14
14
 
15
15
  export const listGenerators = (): NxGeneratorInfo[] =>
16
16
  Object.entries(
17
17
  JSON.parse(
18
18
  fs.readFileSync(
19
- path.resolve(import.meta.dirname, '../../generators.json'),
19
+ path.resolve(<% if (esm) { %>import.meta.dirname<% } else { %>__dirname<% } %>, '../../generators.json'),
20
20
  'utf-8',
21
21
  ),
22
22
  ).generators,
23
23
  ).map(([id, info]: any) => ({
24
24
  id,
25
- resolvedPath: path.resolve(import.meta.dirname, '..', '..', info.factory, '..'),
25
+ resolvedPath: path.resolve(<% if (esm) { %>import.meta.dirname<% } else { %>__dirname<% } %>, '..', '..', info.factory, '..'),
26
26
  description: info.description,
27
27
  }));
28
28
 
@@ -5,6 +5,7 @@
5
5
  import { formatFilesInSubtree } from "../../utils/format.js";
6
6
  import { installDependencies } from "../../utils/install.js";
7
7
  import { addGeneratorMetricsIfApplicable } from "../../utils/metrics.js";
8
+ import { esmVars } from "../../utils/module-format.js";
8
9
  import { addDependencyToTargetIfNotPresent, addGeneratorMetadata, getGeneratorInfo, readProjectConfigurationUnqualified } from "../../utils/nx.js";
9
10
  import { sortObjectKeys } from "../../utils/object.js";
10
11
  import tsProjectGenerator, { getTsLibDetails } from "../lib/generator.js";
@@ -85,7 +86,8 @@ export const tsNxPluginGenerator = async (tree, options)=>{
85
86
  tree.delete(joinPathFragments(mcpPath, 'resources', 'sample-guidance.ts'));
86
87
  // Add generator MCP server
87
88
  generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', 'mcp-server'), mcpPath, {
88
- name: fullyQualifiedName
89
+ name: fullyQualifiedName,
90
+ ...esmVars(tree)
89
91
  }, {
90
92
  overwriteStrategy: OverwriteStrategy.KeepExisting
91
93
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator';\nimport tsMcpServerGenerator from '../mcp-server/generator';\nimport type { TsNxPluginGeneratorSchema } from './schema';\nimport { configureTsProjectAsNxPlugin } from './utils';\n\nexport const TS_NX_PLUGIN_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsNxPluginGenerator = async (\n tree: Tree,\n options: TsNxPluginGeneratorSchema,\n): Promise<GeneratorCallback> => {\n // Generate a TypeScript project as the base\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, options);\n await tsProjectGenerator(tree, {\n ...options,\n preferInstallDependencies: false,\n });\n\n // Configure the typescript project as an Nx Plugin\n configureTsProjectAsNxPlugin(tree, fullyQualifiedName);\n\n // Add a \"package\" target which creates a package which can be published to NPM\n const project = readProjectConfigurationUnqualified(tree, fullyQualifiedName);\n project.targets = {\n ...project.targets,\n package: {\n executor: '@nx/js:tsc',\n outputs: ['{options.outputPath}'],\n options: {\n outputPath: `dist/{projectRoot}/package`,\n main: `{projectRoot}/src/index.ts`,\n tsConfig: `{projectRoot}/tsconfig.lib.json`,\n assets: [\n `{projectRoot}/*.md`,\n `{projectRoot}/LICENSE*`,\n `{projectRoot}/NOTICE`,\n {\n input: './{projectRoot}/src',\n glob: '**/!(*.ts)',\n output: './src',\n },\n {\n input: './{projectRoot}/src',\n glob: '**/*.d.ts',\n output: './src',\n },\n {\n input: './{projectRoot}',\n glob: 'generators.json',\n output: '.',\n },\n {\n input: './{projectRoot}',\n glob: 'executors.json',\n output: '.',\n },\n ],\n },\n },\n build: {\n ...project.targets?.build,\n },\n };\n // Append the package dependency without moving an existing entry, so re-runs\n // do not reorder the build dependencies.\n addDependencyToTargetIfNotPresent(project, 'build', 'package');\n // Sort targets so their order is stable regardless of insertion order.\n project.targets = sortObjectKeys(project.targets);\n updateProjectConfiguration(tree, fullyQualifiedName, project);\n\n // Add an MCP Server\n await tsMcpServerGenerator(tree, {\n project: fullyQualifiedName,\n infra: 'none',\n iac: 'cdk', // not used\n preferInstallDependencies: false,\n });\n\n const mcpPath = joinPathFragments(project.sourceRoot, 'mcp-server');\n const mcpServerPath = joinPathFragments(mcpPath, 'server.ts');\n\n // Remove the sample server and tools\n tree.delete(mcpServerPath);\n tree.delete(joinPathFragments(mcpPath, 'tools', 'add.ts'));\n tree.delete(joinPathFragments(mcpPath, 'resources', 'sample-guidance.ts'));\n\n // Add generator MCP server\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'mcp-server'),\n mcpPath,\n {\n name: fullyQualifiedName,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n addGeneratorMetadata(tree, project.name, TS_NX_PLUGIN_GENERATOR_INFO);\n\n await addGeneratorMetricsIfApplicable(tree, [TS_NX_PLUGIN_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsNxPluginGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","sortObjectKeys","tsProjectGenerator","getTsLibDetails","tsMcpServerGenerator","configureTsProjectAsNxPlugin","TS_NX_PLUGIN_GENERATOR_INFO","filename","tsNxPluginGenerator","tree","options","fullyQualifiedName","dir","preferInstallDependencies","project","targets","package","executor","outputs","outputPath","main","tsConfig","assets","input","glob","output","build","infra","iac","mcpPath","sourceRoot","mcpServerPath","delete","dirname","name","overwriteStrategy","KeepExisting","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAGjBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SACEC,iCAAiC,EACjCC,oBAAoB,EACpBC,gBAAgB,EAEhBC,mCAAmC,QAC9B,oBAAiB;AACxB,SAASC,cAAc,QAAQ,wBAAqB;AACpD,OAAOC,sBAAsBC,eAAe,QAAQ,sBAAmB;AACvE,OAAOC,0BAA0B,6BAA0B;AAE3D,SAASC,4BAA4B,QAAQ,aAAU;AAEvD,OAAO,MAAMC,8BAA+CP,iBAC1D,YAAYQ,QAAQ,EACpB;AAEF,OAAO,MAAMC,sBAAsB,OACjCC,MACAC;IAEA,4CAA4C;IAC5C,MAAM,EAAEC,kBAAkB,EAAEC,GAAG,EAAE,GAAGT,gBAAgBM,MAAMC;IAC1D,MAAMR,mBAAmBO,MAAM;QAC7B,GAAGC,OAAO;QACVG,2BAA2B;IAC7B;IAEA,mDAAmD;IACnDR,6BAA6BI,MAAME;IAEnC,+EAA+E;IAC/E,MAAMG,UAAUd,oCAAoCS,MAAME;IAC1DG,QAAQC,OAAO,GAAG;QAChB,GAAGD,QAAQC,OAAO;QAClBC,SAAS;YACPC,UAAU;YACVC,SAAS;gBAAC;aAAuB;YACjCR,SAAS;gBACPS,YAAY,CAAC,0BAA0B,CAAC;gBACxCC,MAAM,CAAC,0BAA0B,CAAC;gBAClCC,UAAU,CAAC,+BAA+B,CAAC;gBAC3CC,QAAQ;oBACN,CAAC,kBAAkB,CAAC;oBACpB,CAAC,sBAAsB,CAAC;oBACxB,CAAC,oBAAoB,CAAC;oBACtB;wBACEC,OAAO;wBACPC,MAAM;wBACNC,QAAQ;oBACV;oBACA;wBACEF,OAAO;wBACPC,MAAM;wBACNC,QAAQ;oBACV;oBACA;wBACEF,OAAO;wBACPC,MAAM;wBACNC,QAAQ;oBACV;oBACA;wBACEF,OAAO;wBACPC,MAAM;wBACNC,QAAQ;oBACV;iBACD;YACH;QACF;QACAC,OAAO;YACL,GAAGZ,QAAQC,OAAO,EAAEW,KAAK;QAC3B;IACF;IACA,6EAA6E;IAC7E,yCAAyC;IACzC7B,kCAAkCiB,SAAS,SAAS;IACpD,uEAAuE;IACvEA,QAAQC,OAAO,GAAGd,eAAea,QAAQC,OAAO;IAChDtB,2BAA2BgB,MAAME,oBAAoBG;IAErD,oBAAoB;IACpB,MAAMV,qBAAqBK,MAAM;QAC/BK,SAASH;QACTgB,OAAO;QACPC,KAAK;QACLf,2BAA2B;IAC7B;IAEA,MAAMgB,UAAUtC,kBAAkBuB,QAAQgB,UAAU,EAAE;IACtD,MAAMC,gBAAgBxC,kBAAkBsC,SAAS;IAEjD,qCAAqC;IACrCpB,KAAKuB,MAAM,CAACD;IACZtB,KAAKuB,MAAM,CAACzC,kBAAkBsC,SAAS,SAAS;IAChDpB,KAAKuB,MAAM,CAACzC,kBAAkBsC,SAAS,aAAa;IAEpD,2BAA2B;IAC3BvC,cACEmB,MACAlB,kBAAkB,YAAY0C,OAAO,EAAE,SAAS,eAChDJ,SACA;QACEK,MAAMvB;IACR,GACA;QAAEwB,mBAAmB3C,kBAAkB4C,YAAY;IAAC;IAGtDtC,qBAAqBW,MAAMK,QAAQoB,IAAI,EAAE5B;IAEzC,MAAMV,gCAAgCa,MAAM;QAACH;KAA4B;IAEzE,MAAMZ,qBAAqBe;IAC3B,OAAO,IACLd,oBAAoBc,MAAMC,QAAQG,yBAAyB,EAAE;YAC3DwB,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAe7B,oBAAoB"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { esmVars } from '../../utils/module-format';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator';\nimport tsMcpServerGenerator from '../mcp-server/generator';\nimport type { TsNxPluginGeneratorSchema } from './schema';\nimport { configureTsProjectAsNxPlugin } from './utils';\n\nexport const TS_NX_PLUGIN_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsNxPluginGenerator = async (\n tree: Tree,\n options: TsNxPluginGeneratorSchema,\n): Promise<GeneratorCallback> => {\n // Generate a TypeScript project as the base\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, options);\n await tsProjectGenerator(tree, {\n ...options,\n preferInstallDependencies: false,\n });\n\n // Configure the typescript project as an Nx Plugin\n configureTsProjectAsNxPlugin(tree, fullyQualifiedName);\n\n // Add a \"package\" target which creates a package which can be published to NPM\n const project = readProjectConfigurationUnqualified(tree, fullyQualifiedName);\n project.targets = {\n ...project.targets,\n package: {\n executor: '@nx/js:tsc',\n outputs: ['{options.outputPath}'],\n options: {\n outputPath: `dist/{projectRoot}/package`,\n main: `{projectRoot}/src/index.ts`,\n tsConfig: `{projectRoot}/tsconfig.lib.json`,\n assets: [\n `{projectRoot}/*.md`,\n `{projectRoot}/LICENSE*`,\n `{projectRoot}/NOTICE`,\n {\n input: './{projectRoot}/src',\n glob: '**/!(*.ts)',\n output: './src',\n },\n {\n input: './{projectRoot}/src',\n glob: '**/*.d.ts',\n output: './src',\n },\n {\n input: './{projectRoot}',\n glob: 'generators.json',\n output: '.',\n },\n {\n input: './{projectRoot}',\n glob: 'executors.json',\n output: '.',\n },\n ],\n },\n },\n build: {\n ...project.targets?.build,\n },\n };\n // Append the package dependency without moving an existing entry, so re-runs\n // do not reorder the build dependencies.\n addDependencyToTargetIfNotPresent(project, 'build', 'package');\n // Sort targets so their order is stable regardless of insertion order.\n project.targets = sortObjectKeys(project.targets);\n updateProjectConfiguration(tree, fullyQualifiedName, project);\n\n // Add an MCP Server\n await tsMcpServerGenerator(tree, {\n project: fullyQualifiedName,\n infra: 'none',\n iac: 'cdk', // not used\n preferInstallDependencies: false,\n });\n\n const mcpPath = joinPathFragments(project.sourceRoot, 'mcp-server');\n const mcpServerPath = joinPathFragments(mcpPath, 'server.ts');\n\n // Remove the sample server and tools\n tree.delete(mcpServerPath);\n tree.delete(joinPathFragments(mcpPath, 'tools', 'add.ts'));\n tree.delete(joinPathFragments(mcpPath, 'resources', 'sample-guidance.ts'));\n\n // Add generator MCP server\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'mcp-server'),\n mcpPath,\n {\n name: fullyQualifiedName,\n ...esmVars(tree),\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n addGeneratorMetadata(tree, project.name, TS_NX_PLUGIN_GENERATOR_INFO);\n\n await addGeneratorMetricsIfApplicable(tree, [TS_NX_PLUGIN_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsNxPluginGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","esmVars","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","sortObjectKeys","tsProjectGenerator","getTsLibDetails","tsMcpServerGenerator","configureTsProjectAsNxPlugin","TS_NX_PLUGIN_GENERATOR_INFO","filename","tsNxPluginGenerator","tree","options","fullyQualifiedName","dir","preferInstallDependencies","project","targets","package","executor","outputs","outputPath","main","tsConfig","assets","input","glob","output","build","infra","iac","mcpPath","sourceRoot","mcpServerPath","delete","dirname","name","overwriteStrategy","KeepExisting","languages"],"mappings":"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"}
@@ -5,6 +5,7 @@
5
5
  import PackageJson from "../../../package.json" with {
6
6
  type: 'json'
7
7
  };
8
+ import { isEsmWorkspace } from "../../utils/module-format.js";
8
9
  import { readProjectConfigurationUnqualified } from "../../utils/nx.js";
9
10
  import { withVersions } from "../../utils/versions.js";
10
11
  /**
@@ -30,11 +31,13 @@ import { withVersions } from "../../utils/versions.js";
30
31
  name: project.name
31
32
  });
32
33
  }
34
+ const esm = isEsmWorkspace(tree);
33
35
  updateJson(tree, pluginPackageJsonPath, (pkg)=>{
34
- // Mark the plugin as ESM so Nx loads its `.ts` generators as ES modules via
35
- // Node's native type stripping (the workspace root is also `type: module`).
36
- pkg.type ??= 'module';
37
- pkg.main ??= './src/index.js';
36
+ // Match the plugin's module system to the workspace. Nx loads `.ts`
37
+ // generators via Node's native type stripping, as ESM (workspace root is
38
+ // `type: module`) or CommonJS accordingly.
39
+ pkg.type ??= esm ? 'module' : 'commonjs';
40
+ pkg.main ??= esm ? './src/index.js' : './src/index';
38
41
  pkg.generators ??= './generators.json';
39
42
  return pkg;
40
43
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/utils.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addDependenciesToPackageJson,\n joinPathFragments,\n readJson,\n type Tree,\n updateJson,\n writeJson,\n} from '@nx/devkit';\nimport PackageJson from '../../../package.json' with { type: 'json' };\nimport { readProjectConfigurationUnqualified } from '../../utils/nx';\nimport { withVersions } from '../../utils/versions';\n\n/**\n * Configures a TypeScript project as an Nx Plugin\n */\nexport const configureTsProjectAsNxPlugin = (\n tree: Tree,\n projectName: string,\n) => {\n const project = readProjectConfigurationUnqualified(tree, projectName);\n\n const tsConfigPath = joinPathFragments(project.root, 'tsconfig.json');\n if (!tree.exists(tsConfigPath)) {\n throw new Error(\n `Selected plugin project ${projectName} is not a TypeScript project`,\n );\n }\n\n // Create an empty generators.json if one dosn't exist\n const generatorsJsonPath = joinPathFragments(project.root, 'generators.json');\n if (!tree.exists(generatorsJsonPath)) {\n writeJson(tree, generatorsJsonPath, {\n generators: {},\n });\n }\n\n // Create a package.json if one doesn't exist, and configure \"type\", \"main\"\n // and \"generators\"\n const pluginPackageJsonPath = joinPathFragments(project.root, 'package.json');\n if (!tree.exists(pluginPackageJsonPath)) {\n writeJson(tree, pluginPackageJsonPath, {\n name: project.name,\n });\n }\n updateJson(tree, pluginPackageJsonPath, (pkg) => {\n // Mark the plugin as ESM so Nx loads its `.ts` generators as ES modules via\n // Node's native type stripping (the workspace root is also `type: module`).\n pkg.type ??= 'module';\n pkg.main ??= './src/index.js';\n pkg.generators ??= './generators.json';\n return pkg;\n });\n\n const rootPackageJson = tree.exists('package.json')\n ? readJson(tree, 'package.json')\n : undefined;\n const isNxPluginForAws = rootPackageJson?.name === '@aws/nx-plugin-source';\n\n if (!isNxPluginForAws) {\n // Add the required dependencies to the root package.json, and project's package.json\n const deps = {\n ...withVersions(['@nx/devkit']),\n // Include dependency on @aws/nx-plugin\n [PackageJson.name]: `^${PackageJson.version}`,\n };\n // Generated workspaces are `\"type\": \"module\"`, so Nx loads the plugin's\n // `.ts` generators as ESM via Node's native type stripping — no swc/ts-node\n // transpiler is required.\n addDependenciesToPackageJson(tree, {}, deps);\n addDependenciesToPackageJson(tree, deps, {}, pluginPackageJsonPath);\n }\n};\n"],"names":["addDependenciesToPackageJson","joinPathFragments","readJson","updateJson","writeJson","PackageJson","type","readProjectConfigurationUnqualified","withVersions","configureTsProjectAsNxPlugin","tree","projectName","project","tsConfigPath","root","exists","Error","generatorsJsonPath","generators","pluginPackageJsonPath","name","pkg","main","rootPackageJson","undefined","isNxPluginForAws","deps","version"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAC5BC,iBAAiB,EACjBC,QAAQ,EAERC,UAAU,EACVC,SAAS,QACJ,aAAa;AACpB,OAAOC,iBAAiB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACtE,SAASC,mCAAmC,QAAQ,oBAAiB;AACrE,SAASC,YAAY,QAAQ,0BAAuB;AAEpD;;CAEC,GACD,OAAO,MAAMC,+BAA+B,CAC1CC,MACAC;IAEA,MAAMC,UAAUL,oCAAoCG,MAAMC;IAE1D,MAAME,eAAeZ,kBAAkBW,QAAQE,IAAI,EAAE;IACrD,IAAI,CAACJ,KAAKK,MAAM,CAACF,eAAe;QAC9B,MAAM,IAAIG,MACR,CAAC,wBAAwB,EAAEL,YAAY,4BAA4B,CAAC;IAExE;IAEA,sDAAsD;IACtD,MAAMM,qBAAqBhB,kBAAkBW,QAAQE,IAAI,EAAE;IAC3D,IAAI,CAACJ,KAAKK,MAAM,CAACE,qBAAqB;QACpCb,UAAUM,MAAMO,oBAAoB;YAClCC,YAAY,CAAC;QACf;IACF;IAEA,2EAA2E;IAC3E,mBAAmB;IACnB,MAAMC,wBAAwBlB,kBAAkBW,QAAQE,IAAI,EAAE;IAC9D,IAAI,CAACJ,KAAKK,MAAM,CAACI,wBAAwB;QACvCf,UAAUM,MAAMS,uBAAuB;YACrCC,MAAMR,QAAQQ,IAAI;QACpB;IACF;IACAjB,WAAWO,MAAMS,uBAAuB,CAACE;QACvC,4EAA4E;QAC5E,4EAA4E;QAC5EA,IAAIf,IAAI,KAAK;QACbe,IAAIC,IAAI,KAAK;QACbD,IAAIH,UAAU,KAAK;QACnB,OAAOG;IACT;IAEA,MAAME,kBAAkBb,KAAKK,MAAM,CAAC,kBAChCb,SAASQ,MAAM,kBACfc;IACJ,MAAMC,mBAAmBF,iBAAiBH,SAAS;IAEnD,IAAI,CAACK,kBAAkB;QACrB,qFAAqF;QACrF,MAAMC,OAAO;YACX,GAAGlB,aAAa;gBAAC;aAAa,CAAC;YAC/B,uCAAuC;YACvC,CAACH,YAAYe,IAAI,CAAC,EAAE,CAAC,CAAC,EAAEf,YAAYsB,OAAO,EAAE;QAC/C;QACA,wEAAwE;QACxE,4EAA4E;QAC5E,0BAA0B;QAC1B3B,6BAA6BU,MAAM,CAAC,GAAGgB;QACvC1B,6BAA6BU,MAAMgB,MAAM,CAAC,GAAGP;IAC/C;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/nx-plugin/utils.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addDependenciesToPackageJson,\n joinPathFragments,\n readJson,\n type Tree,\n updateJson,\n writeJson,\n} from '@nx/devkit';\nimport PackageJson from '../../../package.json' with { type: 'json' };\nimport { isEsmWorkspace } from '../../utils/module-format';\nimport { readProjectConfigurationUnqualified } from '../../utils/nx';\nimport { withVersions } from '../../utils/versions';\n\n/**\n * Configures a TypeScript project as an Nx Plugin\n */\nexport const configureTsProjectAsNxPlugin = (\n tree: Tree,\n projectName: string,\n) => {\n const project = readProjectConfigurationUnqualified(tree, projectName);\n\n const tsConfigPath = joinPathFragments(project.root, 'tsconfig.json');\n if (!tree.exists(tsConfigPath)) {\n throw new Error(\n `Selected plugin project ${projectName} is not a TypeScript project`,\n );\n }\n\n // Create an empty generators.json if one dosn't exist\n const generatorsJsonPath = joinPathFragments(project.root, 'generators.json');\n if (!tree.exists(generatorsJsonPath)) {\n writeJson(tree, generatorsJsonPath, {\n generators: {},\n });\n }\n\n // Create a package.json if one doesn't exist, and configure \"type\", \"main\"\n // and \"generators\"\n const pluginPackageJsonPath = joinPathFragments(project.root, 'package.json');\n if (!tree.exists(pluginPackageJsonPath)) {\n writeJson(tree, pluginPackageJsonPath, {\n name: project.name,\n });\n }\n const esm = isEsmWorkspace(tree);\n updateJson(tree, pluginPackageJsonPath, (pkg) => {\n // Match the plugin's module system to the workspace. Nx loads `.ts`\n // generators via Node's native type stripping, as ESM (workspace root is\n // `type: module`) or CommonJS accordingly.\n pkg.type ??= esm ? 'module' : 'commonjs';\n pkg.main ??= esm ? './src/index.js' : './src/index';\n pkg.generators ??= './generators.json';\n return pkg;\n });\n\n const rootPackageJson = tree.exists('package.json')\n ? readJson(tree, 'package.json')\n : undefined;\n const isNxPluginForAws = rootPackageJson?.name === '@aws/nx-plugin-source';\n\n if (!isNxPluginForAws) {\n // Add the required dependencies to the root package.json, and project's package.json\n const deps = {\n ...withVersions(['@nx/devkit']),\n // Include dependency on @aws/nx-plugin\n [PackageJson.name]: `^${PackageJson.version}`,\n };\n // Generated workspaces are `\"type\": \"module\"`, so Nx loads the plugin's\n // `.ts` generators as ESM via Node's native type stripping — no swc/ts-node\n // transpiler is required.\n addDependenciesToPackageJson(tree, {}, deps);\n addDependenciesToPackageJson(tree, deps, {}, pluginPackageJsonPath);\n }\n};\n"],"names":["addDependenciesToPackageJson","joinPathFragments","readJson","updateJson","writeJson","PackageJson","type","isEsmWorkspace","readProjectConfigurationUnqualified","withVersions","configureTsProjectAsNxPlugin","tree","projectName","project","tsConfigPath","root","exists","Error","generatorsJsonPath","generators","pluginPackageJsonPath","name","esm","pkg","main","rootPackageJson","undefined","isNxPluginForAws","deps","version"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAC5BC,iBAAiB,EACjBC,QAAQ,EAERC,UAAU,EACVC,SAAS,QACJ,aAAa;AACpB,OAAOC,iBAAiB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACtE,SAASC,cAAc,QAAQ,+BAA4B;AAC3D,SAASC,mCAAmC,QAAQ,oBAAiB;AACrE,SAASC,YAAY,QAAQ,0BAAuB;AAEpD;;CAEC,GACD,OAAO,MAAMC,+BAA+B,CAC1CC,MACAC;IAEA,MAAMC,UAAUL,oCAAoCG,MAAMC;IAE1D,MAAME,eAAeb,kBAAkBY,QAAQE,IAAI,EAAE;IACrD,IAAI,CAACJ,KAAKK,MAAM,CAACF,eAAe;QAC9B,MAAM,IAAIG,MACR,CAAC,wBAAwB,EAAEL,YAAY,4BAA4B,CAAC;IAExE;IAEA,sDAAsD;IACtD,MAAMM,qBAAqBjB,kBAAkBY,QAAQE,IAAI,EAAE;IAC3D,IAAI,CAACJ,KAAKK,MAAM,CAACE,qBAAqB;QACpCd,UAAUO,MAAMO,oBAAoB;YAClCC,YAAY,CAAC;QACf;IACF;IAEA,2EAA2E;IAC3E,mBAAmB;IACnB,MAAMC,wBAAwBnB,kBAAkBY,QAAQE,IAAI,EAAE;IAC9D,IAAI,CAACJ,KAAKK,MAAM,CAACI,wBAAwB;QACvChB,UAAUO,MAAMS,uBAAuB;YACrCC,MAAMR,QAAQQ,IAAI;QACpB;IACF;IACA,MAAMC,MAAMf,eAAeI;IAC3BR,WAAWQ,MAAMS,uBAAuB,CAACG;QACvC,oEAAoE;QACpE,yEAAyE;QACzE,2CAA2C;QAC3CA,IAAIjB,IAAI,KAAKgB,MAAM,WAAW;QAC9BC,IAAIC,IAAI,KAAKF,MAAM,mBAAmB;QACtCC,IAAIJ,UAAU,KAAK;QACnB,OAAOI;IACT;IAEA,MAAME,kBAAkBd,KAAKK,MAAM,CAAC,kBAChCd,SAASS,MAAM,kBACfe;IACJ,MAAMC,mBAAmBF,iBAAiBJ,SAAS;IAEnD,IAAI,CAACM,kBAAkB;QACrB,qFAAqF;QACrF,MAAMC,OAAO;YACX,GAAGnB,aAAa;gBAAC;aAAa,CAAC;YAC/B,uCAAuC;YACvC,CAACJ,YAAYgB,IAAI,CAAC,EAAE,CAAC,CAAC,EAAEhB,YAAYwB,OAAO,EAAE;QAC/C;QACA,wEAAwE;QACxE,4EAA4E;QAC5E,0BAA0B;QAC1B7B,6BAA6BW,MAAM,CAAC,GAAGiB;QACvC5B,6BAA6BW,MAAMiB,MAAM,CAAC,GAAGR;IAC/C;AACF,EAAE"}