@aws/nx-plugin 1.0.0-rc.79 → 1.0.0-rc.80

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 (469) hide show
  1. package/generators.json +10 -0
  2. package/migrations.json +1 -1
  3. package/package.json +1 -1
  4. package/src/agentcore-gateway/agent-connection/generator.d.ts +1 -1
  5. package/src/agentcore-gateway/agent-connection/generator.js.map +1 -1
  6. package/src/agentcore-gateway/agent-connection/schema.d.js.map +1 -1
  7. package/src/agentcore-gateway/agent-connection/schema.d.ts +1 -1
  8. package/src/agentcore-gateway/attach-upstream.js.map +1 -1
  9. package/src/agentcore-gateway/gateway-connection/generator.d.ts +1 -1
  10. package/src/agentcore-gateway/gateway-connection/generator.js.map +1 -1
  11. package/src/agentcore-gateway/gateway-connection/schema.d.js.map +1 -1
  12. package/src/agentcore-gateway/gateway-connection/schema.d.ts +1 -1
  13. package/src/agentcore-gateway/generator.d.ts +3 -3
  14. package/src/agentcore-gateway/generator.js.map +1 -1
  15. package/src/agentcore-gateway/mcp-connection/generator.d.ts +1 -1
  16. package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -1
  17. package/src/agentcore-gateway/mcp-connection/schema.d.js.map +1 -1
  18. package/src/agentcore-gateway/mcp-connection/schema.d.ts +1 -1
  19. package/src/agentcore-gateway/react-connection/generator.d.ts +1 -1
  20. package/src/agentcore-gateway/react-connection/generator.js.map +1 -1
  21. package/src/agentcore-gateway/react-connection/schema.d.js.map +1 -1
  22. package/src/agentcore-gateway/react-connection/schema.d.ts +1 -1
  23. package/src/agentcore-gateway/schema.d.js.map +1 -1
  24. package/src/agentcore-gateway/schema.d.ts +1 -1
  25. package/src/agentcore-harness/generator.d.ts +4 -4
  26. package/src/agentcore-harness/generator.js.map +1 -1
  27. package/src/agentcore-harness/schema.d.js.map +1 -1
  28. package/src/agentcore-harness/schema.d.ts +1 -1
  29. package/src/connection/agent-local-dev.d.ts +1 -1
  30. package/src/connection/agent-local-dev.js.map +1 -1
  31. package/src/connection/agent-runtime-config.js.map +1 -1
  32. package/src/connection/gateway-runtime-config.js.map +1 -1
  33. package/src/connection/generator.d.ts +2 -2
  34. package/src/connection/generator.js.map +1 -1
  35. package/src/connection/local-dev.js.map +1 -1
  36. package/src/connection/scaffold-catalog.d.ts +1 -1
  37. package/src/connection/scaffold-catalog.js +6 -6
  38. package/src/connection/scaffold-catalog.js.map +1 -1
  39. package/src/connection/schema-resolver.d.ts +1 -1
  40. package/src/connection/schema-resolver.js.map +1 -1
  41. package/src/index.d.ts +1 -1
  42. package/src/index.js.map +1 -1
  43. package/src/infra/app/generator.d.ts +7 -7
  44. package/src/infra/app/generator.js.map +1 -1
  45. package/src/init/generator.d.ts +3 -3
  46. package/src/init/generator.js.map +1 -1
  47. package/src/init/schema.d.js.map +1 -1
  48. package/src/init/schema.d.ts +2 -2
  49. package/src/internal/test-matrix/generator.js.map +1 -1
  50. package/src/license/config-types.d.ts +2 -2
  51. package/src/license/config-types.js.map +1 -1
  52. package/src/license/config.d.ts +2 -2
  53. package/src/license/config.js.map +1 -1
  54. package/src/license/dependency-check/check.d.ts +2 -2
  55. package/src/license/dependency-check/check.js.map +1 -1
  56. package/src/license/dependency-check/collectors/collector.js.map +1 -1
  57. package/src/license/dependency-check/collectors/python-collector.js.map +1 -1
  58. package/src/license/dependency-check/evaluator.d.ts +1 -1
  59. package/src/license/dependency-check/evaluator.js.map +1 -1
  60. package/src/license/dependency-check/executor.js.map +1 -1
  61. package/src/license/dependency-check/pre-approved.d.ts +1 -1
  62. package/src/license/dependency-check/pre-approved.js.map +1 -1
  63. package/src/license/dependency-check/types.d.ts +1 -1
  64. package/src/license/dependency-check/types.js.map +1 -1
  65. package/src/license/generator.d.ts +1 -1
  66. package/src/license/generator.js.map +1 -1
  67. package/src/license/index.d.ts +4 -4
  68. package/src/license/index.js.map +1 -1
  69. package/src/license/known-exceptions.d.ts +1 -1
  70. package/src/license/known-exceptions.js.map +1 -1
  71. package/src/license/sync/generator.js.map +1 -1
  72. package/src/license/sync/project-file-sync.d.ts +1 -1
  73. package/src/license/sync/project-file-sync.js.map +1 -1
  74. package/src/mcp-server/dev-server.js.map +1 -1
  75. package/src/mcp-server/generator-info.d.ts +3 -3
  76. package/src/mcp-server/generator-info.js.map +1 -1
  77. package/src/mcp-server/guide-pipeline.d.ts +1 -1
  78. package/src/mcp-server/guide-pipeline.js.map +1 -1
  79. package/src/mcp-server/guide-render.js.map +1 -1
  80. package/src/mcp-server/index.js.map +1 -1
  81. package/src/mcp-server/mdx-ast.js.map +1 -1
  82. package/src/mcp-server/server.js.map +1 -1
  83. package/src/mcp-server/tools/add-to-existing-project.d.ts +1 -1
  84. package/src/mcp-server/tools/add-to-existing-project.js.map +1 -1
  85. package/src/mcp-server/tools/create-workspace-command.js.map +1 -1
  86. package/src/mcp-server/tools/general-guidance.d.ts +1 -1
  87. package/src/mcp-server/tools/general-guidance.js +1 -1
  88. package/src/mcp-server/tools/general-guidance.js.map +1 -1
  89. package/src/mcp-server/tools/generator-guide.d.ts +1 -1
  90. package/src/mcp-server/tools/generator-guide.js.map +1 -1
  91. package/src/mcp-server/tools/list-generators.d.ts +1 -1
  92. package/src/mcp-server/tools/list-generators.js.map +1 -1
  93. package/src/mcp-server/tools/upgrade-workspace.d.ts +1 -1
  94. package/src/mcp-server/tools/upgrade-workspace.js.map +1 -1
  95. package/src/migrations/latest/apt-security-updates-in-container-images/migration.js.map +1 -1
  96. package/src/migrations/latest/dynamodb-configurable-encryption/migration.js.map +1 -1
  97. package/src/migrations/latest/py-agent-ag-ui-hooks/migration.js.map +1 -1
  98. package/src/migrations/latest/py-agent-session-id-middleware-extraction/migration.js.map +1 -1
  99. package/src/migrations/latest/remove-mcp-inspector-license-exceptions/migration.js.map +1 -1
  100. package/src/migrations/latest/static-website-configurable-waf-encryption/migration.js.map +1 -1
  101. package/src/migrations/latest/ts-agent-session-id-middleware-extraction/migration.js.map +1 -1
  102. package/src/migrations/latest/user-identity-configurable-mfa/migration.js.map +1 -1
  103. package/src/migrations/v1.0.0-rc.50/0001-modernize-function-props-cast/migration.js.map +1 -1
  104. package/src/migrations/v1.0.0-rc.50/0002-restrict-cors-to-custom-domains/migration.js.map +1 -1
  105. package/src/migrations/v1.0.0-rc.50/0003-terraform-bootstrap-adopt-existing-bucket/migration.js.map +1 -1
  106. package/src/migrations/v1.0.0-rc.52/0001-user-identity-waf-allow-localhost-callback/migration.js.map +1 -1
  107. package/src/migrations/v1.0.0-rc.54/0001-order-access-log-delivery-after-bucket-policy/migration.js.map +1 -1
  108. package/src/migrations/v1.0.0-rc.55/0001-backfill-generator-metadata/migration.d.ts +1 -1
  109. package/src/migrations/v1.0.0-rc.55/0001-backfill-generator-metadata/migration.js.map +1 -1
  110. package/src/migrations/v1.0.0-rc.56/0001-dynamodb-local-remove-optimize-flag/migration.js.map +1 -1
  111. package/src/migrations/v1.0.0-rc.57/0001-ts-agent-session-management-support/migration.js.map +1 -1
  112. package/src/migrations/v1.0.0-rc.58/0001-smithy-ssdk-bundle-pins/migration.js.map +1 -1
  113. package/src/migrations/v1.0.0-rc.59/0001-gateway-agent-targets/migration.js.map +1 -1
  114. package/src/migrations/v1.0.0-rc.60/0001-gateway-cognito-passthrough/migration.js.map +1 -1
  115. package/src/migrations/v1.0.0-rc.60/0002-waf-log-group-removal/migration.js.map +1 -1
  116. package/src/migrations/v1.0.0-rc.60/0003-strip-pip-from-python-images/migration.js.map +1 -1
  117. package/src/migrations/v1.0.0-rc.61/0001-py-agent-lifespan-construction/migration.js.map +1 -1
  118. package/src/migrations/v1.0.0-rc.62/0001-rename-load-runtime-config-target/migration.js.map +1 -1
  119. package/src/migrations/v1.0.0-rc.63/0001-add-deploy-sandbox-target/migration.js.map +1 -1
  120. package/src/migrations/v1.0.0-rc.64/0001-smithy-build-without-docker/migration.js.map +1 -1
  121. package/src/migrations/v1.0.0-rc.65/0001-vite-config-import-meta-dirname/migration.js.map +1 -1
  122. package/src/migrations/v1.0.0-rc.65/0002-rolldown-code-splitting/migration.js.map +1 -1
  123. package/src/migrations/v1.0.0-rc.67/0001-smithy-server-package-rename/migration.js.map +1 -1
  124. package/src/migrations/v1.0.0-rc.68/0001-translate-script-whole-file-writes/migration.js.map +1 -1
  125. package/src/migrations/v1.0.0-rc.70/0001-py-agent-a2a-lifespan-construction/migration.js.map +1 -1
  126. package/src/migrations/v1.0.0-rc.71/0001-py-agent-a2a-httpx-client-per-call/migration.js.map +1 -1
  127. package/src/migrations/v1.0.0-rc.72/0001-py-agent-session-management-support/migration.js.map +1 -1
  128. package/src/open-api/ts-client/generator.d.ts +1 -1
  129. package/src/open-api/ts-client/generator.js.map +1 -1
  130. package/src/open-api/ts-hooks/generator.d.ts +1 -1
  131. package/src/open-api/ts-hooks/generator.js.map +1 -1
  132. package/src/open-api/ts-hooks/generator.spec.tsx +6 -6
  133. package/src/open-api/ts-metadata/generator.d.ts +1 -1
  134. package/src/open-api/ts-metadata/generator.js.map +1 -1
  135. package/src/open-api/utils/codegen-data/languages.d.ts +1 -1
  136. package/src/open-api/utils/codegen-data/languages.js.map +1 -1
  137. package/src/open-api/utils/codegen-data.d.ts +2 -2
  138. package/src/open-api/utils/codegen-data.js.map +1 -1
  139. package/src/open-api/utils/normalise.d.ts +1 -1
  140. package/src/open-api/utils/normalise.js.map +1 -1
  141. package/src/open-api/utils/parse.d.ts +1 -1
  142. package/src/open-api/utils/parse.js.map +1 -1
  143. package/src/open-api/utils/parser.d.ts +2 -2
  144. package/src/open-api/utils/parser.js.map +1 -1
  145. package/src/open-api/utils/refs.d.ts +1 -1
  146. package/src/open-api/utils/refs.js.map +1 -1
  147. package/src/preset/generator.d.ts +3 -3
  148. package/src/preset/generator.js.map +1 -1
  149. package/src/preset/schema.d.js.map +1 -1
  150. package/src/preset/schema.d.ts +3 -3
  151. package/src/py/agent/a2a-connection/generator.d.ts +3 -3
  152. package/src/py/agent/a2a-connection/generator.js.map +1 -1
  153. package/src/py/agent/a2a-connection/schema.d.js.map +1 -1
  154. package/src/py/agent/a2a-connection/schema.d.ts +1 -1
  155. package/src/py/agent/gateway-connection/generator.d.ts +3 -3
  156. package/src/py/agent/gateway-connection/generator.js.map +1 -1
  157. package/src/py/agent/gateway-connection/schema.d.js.map +1 -1
  158. package/src/py/agent/gateway-connection/schema.d.ts +1 -1
  159. package/src/py/agent/generator.d.ts +3 -3
  160. package/src/py/agent/generator.js.map +1 -1
  161. package/src/py/agent/mcp-connection/generator.d.ts +3 -3
  162. package/src/py/agent/mcp-connection/generator.js.map +1 -1
  163. package/src/py/agent/mcp-connection/schema.d.js.map +1 -1
  164. package/src/py/agent/mcp-connection/schema.d.ts +1 -1
  165. package/src/py/agent/react-connection/generator.d.ts +12 -12
  166. package/src/py/agent/react-connection/generator.js.map +1 -1
  167. package/src/py/agent/react-connection/local-dev.d.ts +1 -1
  168. package/src/py/agent/react-connection/local-dev.js.map +1 -1
  169. package/src/py/agent/react-connection/schema.d.js.map +1 -1
  170. package/src/py/agent/react-connection/schema.d.ts +1 -1
  171. package/src/py/agent/schema.d.js.map +1 -1
  172. package/src/py/agent/schema.d.ts +1 -1
  173. package/src/py/api/generator.d.ts +1 -1
  174. package/src/py/api/generator.js.map +1 -1
  175. package/src/py/api/schema.d.js.map +1 -1
  176. package/src/py/api/schema.d.ts +1 -1
  177. package/src/py/dynamodb/agent-connection/generator.d.ts +1 -1
  178. package/src/py/dynamodb/agent-connection/generator.js.map +1 -1
  179. package/src/py/dynamodb/agent-connection/schema.d.js.map +1 -1
  180. package/src/py/dynamodb/agent-connection/schema.d.ts +1 -1
  181. package/src/py/dynamodb/fast-api-connection/generator.d.ts +1 -1
  182. package/src/py/dynamodb/fast-api-connection/generator.js.map +1 -1
  183. package/src/py/dynamodb/generator.d.ts +4 -4
  184. package/src/py/dynamodb/generator.js.map +1 -1
  185. package/src/py/dynamodb/mcp-server-connection/generator.d.ts +1 -1
  186. package/src/py/dynamodb/mcp-server-connection/generator.js.map +1 -1
  187. package/src/py/dynamodb/mcp-server-connection/schema.d.js.map +1 -1
  188. package/src/py/dynamodb/mcp-server-connection/schema.d.ts +1 -1
  189. package/src/py/dynamodb/schema.d.js.map +1 -1
  190. package/src/py/dynamodb/schema.d.ts +1 -1
  191. package/src/py/fast-api/generator.d.ts +3 -3
  192. package/src/py/fast-api/generator.js.map +1 -1
  193. package/src/py/fast-api/react/generator.d.ts +3 -3
  194. package/src/py/fast-api/react/generator.js.map +1 -1
  195. package/src/py/fast-api/react/open-api.js.map +1 -1
  196. package/src/py/fast-api/schema.d.js.map +1 -1
  197. package/src/py/fast-api/schema.d.ts +1 -1
  198. package/src/py/lambda-function/files/handler/__lambdaFunctionSnakeCase__.py.template +1 -1
  199. package/src/py/lambda-function/generator.d.ts +10 -4
  200. package/src/py/lambda-function/generator.js +8 -1
  201. package/src/py/lambda-function/generator.js.map +1 -1
  202. package/src/py/lambda-function/schema.d.js.map +1 -1
  203. package/src/py/lambda-function/schema.d.ts +2 -2
  204. package/src/py/lambda-function/schema.json +1 -1
  205. package/src/py/mcp-server/generator.d.ts +3 -3
  206. package/src/py/mcp-server/generator.js.map +1 -1
  207. package/src/py/mcp-server/schema.d.js.map +1 -1
  208. package/src/py/mcp-server/schema.d.ts +1 -1
  209. package/src/py/project/generator.d.ts +2 -2
  210. package/src/py/project/generator.js.map +1 -1
  211. package/src/py/project/schema.json +1 -0
  212. package/src/py/rdb/agent-connection/generator.d.ts +1 -1
  213. package/src/py/rdb/agent-connection/generator.js.map +1 -1
  214. package/src/py/rdb/agent-connection/schema.d.js.map +1 -1
  215. package/src/py/rdb/agent-connection/schema.d.ts +1 -1
  216. package/src/py/rdb/fast-api-connection/generator.d.ts +1 -1
  217. package/src/py/rdb/fast-api-connection/generator.js.map +1 -1
  218. package/src/py/rdb/generator.d.ts +3 -3
  219. package/src/py/rdb/generator.js.map +1 -1
  220. package/src/py/rdb/mcp-server-connection/generator.d.ts +1 -1
  221. package/src/py/rdb/mcp-server-connection/generator.js.map +1 -1
  222. package/src/py/rdb/mcp-server-connection/schema.d.js.map +1 -1
  223. package/src/py/rdb/mcp-server-connection/schema.d.ts +1 -1
  224. package/src/sdk/agentcore-gateway.d.ts +1 -1
  225. package/src/sdk/agentcore-gateway.js.map +1 -1
  226. package/src/sdk/agentcore-harness.d.ts +1 -1
  227. package/src/sdk/agentcore-harness.js.map +1 -1
  228. package/src/sdk/connection.d.ts +1 -1
  229. package/src/sdk/connection.js.map +1 -1
  230. package/src/sdk/license.d.ts +3 -3
  231. package/src/sdk/license.js.map +1 -1
  232. package/src/sdk/open-api.d.ts +3 -3
  233. package/src/sdk/open-api.js.map +1 -1
  234. package/src/sdk/py.d.ts +7 -7
  235. package/src/sdk/py.js.map +1 -1
  236. package/src/sdk/smithy.d.ts +1 -1
  237. package/src/sdk/smithy.js.map +1 -1
  238. package/src/sdk/terraform.d.ts +1 -1
  239. package/src/sdk/terraform.js.map +1 -1
  240. package/src/sdk/ts.d.ts +18 -18
  241. package/src/sdk/ts.js.map +1 -1
  242. package/src/sdk/utils/ast.d.ts +1 -1
  243. package/src/sdk/utils/ast.js.map +1 -1
  244. package/src/sdk/utils/format.d.ts +1 -1
  245. package/src/sdk/utils/format.js.map +1 -1
  246. package/src/sdk/utils/test.d.ts +1 -1
  247. package/src/sdk/utils/test.js.map +1 -1
  248. package/src/smithy/project/generator.d.ts +4 -4
  249. package/src/smithy/project/generator.js.map +1 -1
  250. package/src/smithy/react-connection/generator.d.ts +3 -3
  251. package/src/smithy/react-connection/generator.js.map +1 -1
  252. package/src/smithy/ts/api/generator.d.ts +3 -3
  253. package/src/smithy/ts/api/generator.js.map +1 -1
  254. package/src/smithy/ts/api/schema.d.js.map +1 -1
  255. package/src/smithy/ts/api/schema.d.ts +1 -1
  256. package/src/terraform/project/generator.d.ts +5 -5
  257. package/src/terraform/project/generator.js.map +1 -1
  258. package/src/trpc/backend/generator.d.ts +3 -3
  259. package/src/trpc/backend/generator.js.map +1 -1
  260. package/src/trpc/backend/schema.d.js.map +1 -1
  261. package/src/trpc/backend/schema.d.ts +1 -1
  262. package/src/trpc/react/generator.d.ts +3 -3
  263. package/src/trpc/react/generator.js.map +1 -1
  264. package/src/ts/agent/a2a-connection/generator.d.ts +3 -3
  265. package/src/ts/agent/a2a-connection/generator.js.map +1 -1
  266. package/src/ts/agent/a2a-connection/schema.d.js.map +1 -1
  267. package/src/ts/agent/a2a-connection/schema.d.ts +1 -1
  268. package/src/ts/agent/gateway-connection/generator.d.ts +3 -3
  269. package/src/ts/agent/gateway-connection/generator.js.map +1 -1
  270. package/src/ts/agent/gateway-connection/schema.d.js.map +1 -1
  271. package/src/ts/agent/gateway-connection/schema.d.ts +1 -1
  272. package/src/ts/agent/generator.d.ts +3 -3
  273. package/src/ts/agent/generator.js.map +1 -1
  274. package/src/ts/agent/mcp-connection/generator.d.ts +3 -3
  275. package/src/ts/agent/mcp-connection/generator.js.map +1 -1
  276. package/src/ts/agent/mcp-connection/schema.d.js.map +1 -1
  277. package/src/ts/agent/mcp-connection/schema.d.ts +1 -1
  278. package/src/ts/agent/react-connection/generator.d.ts +11 -11
  279. package/src/ts/agent/react-connection/generator.js.map +1 -1
  280. package/src/ts/agent/react-connection/local-dev.d.ts +1 -1
  281. package/src/ts/agent/react-connection/local-dev.js.map +1 -1
  282. package/src/ts/agent/react-connection/schema.d.js.map +1 -1
  283. package/src/ts/agent/react-connection/schema.d.ts +1 -1
  284. package/src/ts/agent/schema.d.js.map +1 -1
  285. package/src/ts/agent/schema.d.ts +1 -1
  286. package/src/ts/api/generator.d.ts +1 -1
  287. package/src/ts/api/generator.js.map +1 -1
  288. package/src/ts/api/schema.d.js.map +1 -1
  289. package/src/ts/api/schema.d.ts +1 -1
  290. package/src/ts/astro-docs/generator.d.ts +3 -3
  291. package/src/ts/astro-docs/generator.js.map +1 -1
  292. package/src/ts/dcr-proxy/generator.d.ts +5 -5
  293. package/src/ts/dcr-proxy/generator.js.map +1 -1
  294. package/src/ts/dcr-proxy/schema.d.js.map +1 -1
  295. package/src/ts/dcr-proxy/schema.d.ts +1 -1
  296. package/src/ts/docs/generator.d.ts +1 -1
  297. package/src/ts/docs/generator.js.map +1 -1
  298. package/src/ts/dynamodb/agent-connection/generator.d.ts +1 -1
  299. package/src/ts/dynamodb/agent-connection/generator.js.map +1 -1
  300. package/src/ts/dynamodb/agent-connection/schema.d.js.map +1 -1
  301. package/src/ts/dynamodb/agent-connection/schema.d.ts +1 -1
  302. package/src/ts/dynamodb/generator.d.ts +5 -5
  303. package/src/ts/dynamodb/generator.js +1 -0
  304. package/src/ts/dynamodb/generator.js.map +1 -1
  305. package/src/ts/dynamodb/mcp-server-connection/generator.d.ts +1 -1
  306. package/src/ts/dynamodb/mcp-server-connection/generator.js.map +1 -1
  307. package/src/ts/dynamodb/mcp-server-connection/schema.d.js.map +1 -1
  308. package/src/ts/dynamodb/mcp-server-connection/schema.d.ts +1 -1
  309. package/src/ts/dynamodb/schema.d.js.map +1 -1
  310. package/src/ts/dynamodb/schema.d.ts +1 -1
  311. package/src/ts/dynamodb/smithy-connection/generator.d.ts +1 -1
  312. package/src/ts/dynamodb/smithy-connection/generator.js.map +1 -1
  313. package/src/ts/dynamodb/trpc-connection/generator.d.ts +1 -1
  314. package/src/ts/dynamodb/trpc-connection/generator.js.map +1 -1
  315. package/src/ts/lambda-function/generator.d.ts +5 -5
  316. package/src/ts/lambda-function/generator.js.map +1 -1
  317. package/src/ts/lambda-function/schema.d.js.map +1 -1
  318. package/src/ts/lambda-function/schema.d.ts +1 -1
  319. package/src/ts/lib/biome.d.ts +1 -1
  320. package/src/ts/lib/biome.js.map +1 -1
  321. package/src/ts/lib/generator.d.ts +3 -3
  322. package/src/ts/lib/generator.js.map +1 -1
  323. package/src/ts/lib/ts-project-utils.d.ts +3 -3
  324. package/src/ts/lib/ts-project-utils.js.map +1 -1
  325. package/src/ts/lib/vitest.d.ts +2 -2
  326. package/src/ts/lib/vitest.js.map +1 -1
  327. package/src/ts/mcp-server/generator.d.ts +3 -3
  328. package/src/ts/mcp-server/generator.js.map +1 -1
  329. package/src/ts/mcp-server/schema.d.js.map +1 -1
  330. package/src/ts/mcp-server/schema.d.ts +1 -1
  331. package/src/ts/nx-generator/generator.d.ts +2 -2
  332. package/src/ts/nx-generator/generator.js.map +1 -1
  333. package/src/ts/nx-migration/generator.d.ts +3 -3
  334. package/src/ts/nx-migration/generator.js.map +1 -1
  335. package/src/ts/nx-plugin/generator.d.ts +3 -3
  336. package/src/ts/nx-plugin/generator.js.map +1 -1
  337. package/src/ts/nx-plugin/utils.d.ts +1 -1
  338. package/src/ts/nx-plugin/utils.js.map +1 -1
  339. package/src/ts/rdb/agent-connection/generator.d.ts +1 -1
  340. package/src/ts/rdb/agent-connection/generator.js.map +1 -1
  341. package/src/ts/rdb/agent-connection/schema.d.js.map +1 -1
  342. package/src/ts/rdb/agent-connection/schema.d.ts +1 -1
  343. package/src/ts/rdb/generator.d.ts +4 -4
  344. package/src/ts/rdb/generator.js +1 -0
  345. package/src/ts/rdb/generator.js.map +1 -1
  346. package/src/ts/rdb/mcp-server-connection/generator.d.ts +1 -1
  347. package/src/ts/rdb/mcp-server-connection/generator.js.map +1 -1
  348. package/src/ts/rdb/mcp-server-connection/schema.d.js.map +1 -1
  349. package/src/ts/rdb/mcp-server-connection/schema.d.ts +1 -1
  350. package/src/ts/rdb/schema.d.js.map +1 -1
  351. package/src/ts/rdb/schema.d.ts +1 -1
  352. package/src/ts/rdb/smithy-connection/generator.d.ts +1 -1
  353. package/src/ts/rdb/smithy-connection/generator.js.map +1 -1
  354. package/src/ts/rdb/trpc-connection/generator.d.ts +1 -1
  355. package/src/ts/rdb/trpc-connection/generator.js.map +1 -1
  356. package/src/ts/react-website/agui/generator.d.ts +2 -2
  357. package/src/ts/react-website/agui/generator.js.map +1 -1
  358. package/src/ts/react-website/app/generator.d.ts +3 -3
  359. package/src/ts/react-website/app/generator.js.map +1 -1
  360. package/src/ts/react-website/app/schema.d.js.map +1 -1
  361. package/src/ts/react-website/app/schema.d.ts +2 -2
  362. package/src/ts/react-website/cognito-auth/generator.d.ts +5 -5
  363. package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
  364. package/src/ts/react-website/cognito-auth/schema.d.js.map +1 -1
  365. package/src/ts/react-website/cognito-auth/schema.d.ts +1 -1
  366. package/src/ts/react-website/cognito-auth/utils.js.map +1 -1
  367. package/src/ts/react-website/runtime-config/generator.d.ts +1 -1
  368. package/src/ts/react-website/runtime-config/generator.js.map +1 -1
  369. package/src/ts/sync/generator.d.ts +1 -1
  370. package/src/ts/sync/generator.js.map +1 -1
  371. package/src/ts/website/app/generator.d.ts +1 -1
  372. package/src/ts/website/app/generator.js.map +1 -1
  373. package/src/ts/website/app/schema.d.js.map +1 -1
  374. package/src/ts/website/app/schema.d.ts +2 -2
  375. package/src/ts/website/auth/generator.d.ts +1 -1
  376. package/src/ts/website/auth/generator.js.map +1 -1
  377. package/src/ts/website/auth/schema.d.js.map +1 -1
  378. package/src/ts/website/auth/schema.d.ts +1 -1
  379. package/src/utils/add-dependencies.d.ts +1 -1
  380. package/src/utils/add-dependencies.js.map +1 -1
  381. package/src/utils/agent-chat/agent-chat.js.map +1 -1
  382. package/src/utils/agent-connection/agent-connection.d.ts +2 -2
  383. package/src/utils/agent-connection/agent-connection.js.map +1 -1
  384. package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +4 -4
  385. package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
  386. package/src/utils/api-constructs/api-constructs.d.ts +3 -3
  387. package/src/utils/api-constructs/api-constructs.js.map +1 -1
  388. package/src/utils/api-constructs/open-api-metadata.d.ts +1 -1
  389. package/src/utils/api-constructs/open-api-metadata.js.map +1 -1
  390. package/src/utils/ast/website.js.map +1 -1
  391. package/src/utils/ast.js +6 -0
  392. package/src/utils/ast.js.map +1 -1
  393. package/src/utils/bundle/bundle.d.ts +1 -1
  394. package/src/utils/bundle/bundle.js.map +1 -1
  395. package/src/utils/commands.d.ts +1 -1
  396. package/src/utils/commands.js.map +1 -1
  397. package/src/utils/config/index.d.ts +6 -6
  398. package/src/utils/config/index.js.map +1 -1
  399. package/src/utils/config/utils.d.ts +1 -1
  400. package/src/utils/config/utils.js.map +1 -1
  401. package/src/utils/connection/open-api/react.d.ts +1 -1
  402. package/src/utils/connection/open-api/react.js.map +1 -1
  403. package/src/utils/containers.js.map +1 -1
  404. package/src/utils/dcr-proxy-constructs/dcr-proxy-constructs.d.ts +1 -1
  405. package/src/utils/dcr-proxy-constructs/dcr-proxy-constructs.js.map +1 -1
  406. package/src/utils/declared-dependencies.d.ts +1 -1
  407. package/src/utils/declared-dependencies.js.map +1 -1
  408. package/src/utils/dependencies.js.map +1 -1
  409. package/src/utils/docker.d.ts +1 -1
  410. package/src/utils/docker.js.map +1 -1
  411. package/src/utils/dynamodb-constructs/dynamodb-constructs.d.ts +1 -1
  412. package/src/utils/dynamodb-constructs/dynamodb-constructs.js.map +1 -1
  413. package/src/utils/format.js.map +1 -1
  414. package/src/utils/fs.d.ts +1 -1
  415. package/src/utils/fs.js.map +1 -1
  416. package/src/utils/function-constructs/function-constructs.d.ts +1 -1
  417. package/src/utils/function-constructs/function-constructs.js.map +1 -1
  418. package/src/utils/iac.d.ts +2 -2
  419. package/src/utils/iac.js.map +1 -1
  420. package/src/utils/identity-constructs/identity-constructs.d.ts +2 -2
  421. package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
  422. package/src/utils/init.d.ts +3 -3
  423. package/src/utils/init.js.map +1 -1
  424. package/src/utils/install.d.ts +1 -1
  425. package/src/utils/install.js.map +1 -1
  426. package/src/utils/mcp.js.map +1 -1
  427. package/src/utils/metrics.d.ts +1 -1
  428. package/src/utils/metrics.js.map +1 -1
  429. package/src/utils/migration-manifest.d.ts +1 -1
  430. package/src/utils/migration-manifest.js.map +1 -1
  431. package/src/utils/nx.d.ts +3 -3
  432. package/src/utils/nx.js.map +1 -1
  433. package/src/utils/paths.js.map +1 -1
  434. package/src/utils/pkg-manager.d.ts +1 -1
  435. package/src/utils/pkg-manager.js.map +1 -1
  436. package/src/utils/pnpm-workspace.js.map +1 -1
  437. package/src/utils/project-package-json.js.map +1 -1
  438. package/src/utils/py.d.ts +2 -2
  439. package/src/utils/py.js.map +1 -1
  440. package/src/utils/rdb-constructs/rdb-constructs.d.ts +2 -2
  441. package/src/utils/rdb-constructs/rdb-constructs.js.map +1 -1
  442. package/src/utils/shared-constructs-constants.js.map +1 -1
  443. package/src/utils/shared-constructs.d.ts +3 -3
  444. package/src/utils/shared-constructs.js.map +1 -1
  445. package/src/utils/shared-dynamodb-scripts.d.ts +1 -1
  446. package/src/utils/shared-dynamodb-scripts.js.map +1 -1
  447. package/src/utils/shared-infra-config.js.map +1 -1
  448. package/src/utils/shared-infra-scripts.d.ts +2 -2
  449. package/src/utils/shared-infra-scripts.js.map +1 -1
  450. package/src/utils/shared-rdb-scripts.d.ts +1 -1
  451. package/src/utils/shared-rdb-scripts.js.map +1 -1
  452. package/src/utils/shared-scripts.js.map +1 -1
  453. package/src/utils/shared-shadcn.d.ts +1 -1
  454. package/src/utils/shared-shadcn.js.map +1 -1
  455. package/src/utils/smithy.js.map +1 -1
  456. package/src/utils/test.js.map +1 -1
  457. package/src/utils/version-upgrade-migration/migration.js.map +1 -1
  458. package/src/utils/version-upgrade-migration/nx-package-updates.js.map +1 -1
  459. package/src/utils/version-upgrade-migration/owned-dependencies.d.ts +1 -1
  460. package/src/utils/version-upgrade-migration/owned-dependencies.js.map +1 -1
  461. package/src/utils/version-upgrade-migration/register.js.map +1 -1
  462. package/src/utils/version-upgrade-migration/sync-embedded-versions.d.ts +1 -1
  463. package/src/utils/version-upgrade-migration/sync-embedded-versions.js.map +1 -1
  464. package/src/utils/version-upgrade-migration/sync-metrics-version.js.map +1 -1
  465. package/src/utils/version-upgrade-migration/sync-vended-versions.js.map +1 -1
  466. package/src/utils/versions.d.ts +1 -1
  467. package/src/utils/versions.js.map +1 -1
  468. package/src/utils/website-constructs/website-constructs.d.ts +2 -2
  469. package/src/utils/website-constructs/website-constructs.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/init.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readNxJson,\n type Tree,\n updateJson,\n updateNxJson,\n} from '@nx/devkit';\nimport { initGenerator } from '@nx/js';\nimport { readFileSync } from 'fs';\nimport yaml from 'js-yaml';\nimport GeneratorsJson from '../../generators.json' with { type: 'json' };\nimport { SYNC_GENERATOR_NAME as TS_SYNC_GENERATOR_NAME } from '../ts/sync/generator';\nimport { BASE_TSCONFIG_COMPILER_OPTIONS } from './base-tsconfig';\nimport {\n ensureAwsNxPluginConfig,\n updateAwsNxPluginConfig,\n} from './config/utils';\nimport { type Containers, inferContainers } from './containers';\nimport {\n type DependencyDeclaration,\n forDependencies,\n type MustDeclare,\n} from './declared-dependencies';\nimport {\n addDependenciesToPackageJson,\n detectWorkspacePackageManager,\n} from './dependencies';\nimport { getDefaultBiomeConfig } from './format';\nimport type { Iac } from './iac';\nimport { configureMcpServers } from './mcp';\nimport { getNpmScope } from './npm-scope';\nimport {\n mergeTargetDefault,\n nxPluginMcpDependency,\n nxPluginSelfDependency,\n} from './nx';\nimport { getPackageManagerDisplayCommands } from './pkg-manager';\nimport { workspaceGlobs } from './project-package-json';\nimport { type ITsDepVersion, withVersions } from './versions';\n\nconst WORKSPACES = ['packages/*'];\nconst NX_TYPESCRIPT_SYNC_GENERATOR = '@nx/js:typescript-sync';\n\n/** Dependencies a caller must declare to apply the workspace init. */\nexport const INIT_DEPENDENCIES = [\n { name: 'nx' },\n { name: '@nx/js' },\n { name: '@nx/workspace' },\n { name: 'typescript' },\n { name: '@biomejs/biome' },\n] as const satisfies readonly { name: ITsDepVersion }[];\n\n// Built dependencies whose install scripts the generated workspace trusts.\n// `onlyBuiltDependencies` is the pnpm 10 key (silently ignored by pnpm 11);\n// pnpm 11 reads `allowBuilds` instead. Any dep NOT in this allowlist will\n// have its install scripts skipped with a warning — matching pnpm 10's\n// default behaviour. The user can opt-in later via `pnpm approve-builds`.\nexport const PNPM_BUILT_DEPENDENCIES = ['@swc/core', 'esbuild', 'nx', 'sharp'];\n\n/**\n * Options controlling how the workspace is initialised. These mirror the\n * preset schema so a workspace created via the preset and one initialised via\n * the `init` generator end up in the same shape.\n */\nexport interface ApplyWorkspaceInitOptions {\n /** The IaC provider to record in the plugin config. */\n readonly iac: Iac;\n /**\n * The container engine to record. `undefined`/`'infer'` picks docker when\n * installed, else finch.\n */\n readonly containers?: Containers | 'infer';\n /** Whether to configure MCP servers for coding agents. Defaults to true. */\n readonly mcp?: boolean;\n /**\n * How to treat the generated workspace README. The preset owns the README of\n * a greenfield workspace (`Overwrite`); the `init` generator must not clobber\n * an existing workspace's README (`KeepExisting`, the default).\n */\n readonly readmeOverwriteStrategy?: OverwriteStrategy;\n /**\n * Whether to overwrite root package.json scripts that already exist. The\n * preset owns a greenfield workspace's scripts (`true`); the `init`\n * generator must not clobber an existing workspace's scripts (`false`,\n * the default) — it only adds the convenience scripts that are absent.\n */\n readonly overwriteScripts?: boolean;\n /**\n * Whether generators use the package manager's dependency catalog. On pnpm\n * this also sets `catalogMode: strict` so `pnpm add` records new deps in the\n * catalog. Defaults to true.\n */\n readonly catalogs?: boolean;\n}\n\n/**\n * Add or repair the pnpm `allowBuilds` / `onlyBuiltDependencies` allowlist for\n * the workspace's `packages` globs, without clobbering any packages the user\n * has already declared.\n *\n * A workspace not created by the preset commonly has either no\n * `pnpm-workspace.yaml`, one missing the `packages` globs, or one carrying the\n * broken `set this to true or false` placeholder pnpm writes when it skips a\n * build script. This makes the file self-consistent so the first generator's\n * install doesn't fail with `ERR_PNPM_IGNORED_BUILDS`.\n */\nconst setUpPnpmWorkspace = (tree: Tree, catalogs: boolean) => {\n const existing = tree.exists('pnpm-workspace.yaml')\n ? ((yaml.load(tree.read('pnpm-workspace.yaml', 'utf-8') ?? '') as Record<\n string,\n unknown\n >) ?? {})\n : {};\n\n // Preserve any packages globs the user already has, ensuring ours are present.\n const packages = Array.from(\n new Set([...((existing.packages as string[]) ?? []), ...WORKSPACES]),\n );\n\n const allowBuilds = {\n ...(typeof existing.allowBuilds === 'object' && existing.allowBuilds\n ? (existing.allowBuilds as Record<string, unknown>)\n : {}),\n // Overwrite any non-boolean (e.g. the \"set this to true or false\"\n // placeholder) with an explicit true for the deps we trust.\n ...Object.fromEntries(PNPM_BUILT_DEPENDENCIES.map((dep) => [dep, true])),\n };\n\n // `strict` makes `pnpm add` record new deps in the catalog; it only gates\n // that flow, so pre-declared direct ranges (e.g. tslib) still install.\n // Preserve an explicit user choice.\n const catalogMode = catalogs\n ? (existing.catalogMode ?? 'strict')\n : existing.catalogMode;\n\n tree.write(\n 'pnpm-workspace.yaml',\n yaml.dump(\n {\n ...existing,\n packages,\n allowBuilds,\n onlyBuiltDependencies: PNPM_BUILT_DEPENDENCIES,\n ...(catalogMode ? { catalogMode } : {}),\n },\n { quotingType: \"'\" },\n ),\n );\n};\n\n/**\n * Configure the workspace's package manager for a monorepo layout.\n *\n * pnpm workspaces are declared in `pnpm-workspace.yaml`; every other package\n * manager reads the `workspaces` field of the root `package.json`.\n */\nconst setUpWorkspaces = (tree: Tree, catalogs: boolean) => {\n if (detectWorkspacePackageManager(tree) === 'pnpm') {\n setUpPnpmWorkspace(tree, catalogs);\n } else {\n updateJson(tree, 'package.json', (json) => {\n // The `workspaces` field may be the object form ({ \"packages\": [...] })\n // accepted by yarn and bun — extend the globs while preserving the form.\n const globs = Array.from(\n new Set([...workspaceGlobs(json.workspaces), ...WORKSPACES]),\n );\n return {\n ...json,\n workspaces:\n json.workspaces !== undefined && !Array.isArray(json.workspaces)\n ? { ...json.workspaces, packages: globs }\n : globs,\n };\n });\n }\n};\n\n/**\n * Ensure the workspace has a `tsconfig.base.json`.\n *\n * `@nx/js` `initGenerator` (with `addTsPlugin`) normally creates this, but it\n * short-circuits when the workspace already has a root `tsconfig.json` — in\n * which case no base file is written and the next project generator fails with\n * `Cannot find tsconfig.base.json`. So we create a compatible one when it's\n * absent. An existing base is left untouched: the user may have tuned it, and\n * rewriting shared compiler options can break other projects (see the\n * \"add to an existing workspace\" guide).\n */\nconst ensureBaseTsConfig = (tree: Tree) => {\n if (tree.exists('tsconfig.base.json')) {\n return;\n }\n tree.write(\n 'tsconfig.base.json',\n JSON.stringify(\n {\n compilerOptions: {\n ...BASE_TSCONFIG_COMPILER_OPTIONS,\n customConditions: [getNpmScope(tree)],\n },\n },\n null,\n 2,\n ),\n );\n};\n\n/**\n * Ensure the workspace has a root `tsconfig.json`.\n *\n * Nx's `@nx/js:typescript-sync` generator hard-fails with\n * `Missing root \"tsconfig.json\"` when it's absent. The plugin's TypeScript\n * projects reference each other via this file, so we guarantee a minimal one\n * exists (sync populates its `references`).\n */\nconst ensureRootTsConfig = (tree: Tree) => {\n if (tree.exists('tsconfig.json')) {\n return;\n }\n tree.write(\n 'tsconfig.json',\n JSON.stringify(\n {\n extends: './tsconfig.base.json',\n files: [],\n references: [],\n },\n null,\n 2,\n ),\n );\n};\n\n/**\n * Transform an Nx workspace into one ready to run `@aws/nx-plugin` generators.\n *\n * This is the deterministic core shared by the workspace preset and the `init`\n * generator. It is safe to re-run: every step is idempotent (config merges,\n * keyed nx.json / package.json entries, create-if-missing files), so running\n * it against an already-initialised workspace is a no-op.\n *\n * It preserves the workspace's module format: the root package.json `type`\n * field is owned by the preset (written from its `--module` option) and left\n * untouched here. It does NOT rewrite an existing `tsconfig.base.json`'s\n * compiler options, migrate a workspace's package manager, or restructure\n * existing projects — those are decisions for the user (see the \"add to an\n * existing workspace\" guide).\n */\nexport const applyWorkspaceInit = async <const D extends DependencyDeclaration>(\n tree: Tree,\n {\n iac,\n containers,\n mcp,\n readmeOverwriteStrategy = OverwriteStrategy.KeepExisting,\n overwriteScripts = false,\n catalogs = true,\n }: ApplyWorkspaceInitOptions,\n declaration: D & MustDeclare<typeof INIT_DEPENDENCIES, D>,\n) => {\n const resolvedContainers =\n !containers || containers === 'infer' ? inferContainers() : containers;\n\n // The catalogs flag is written explicitly (even when true) so the workspace\n // records its dependency-management choice.\n await ensureAwsNxPluginConfig(tree);\n await updateAwsNxPluginConfig(tree, {\n iac: { provider: iac },\n containers: { engine: resolvedContainers },\n packageManager: { catalogs },\n });\n\n // Set up the TypeScript plugin, base tsconfig, formatter etc. `@nx/js`\n // creates `tsconfig.base.json` when absent, but skips it when a root\n // `tsconfig.json` already exists — so we ensure both explicitly below.\n await initGenerator(tree, {\n formatter: 'none',\n addTsPlugin: true,\n });\n\n ensureBaseTsConfig(tree);\n ensureRootTsConfig(tree);\n\n setUpWorkspaces(tree, catalogs);\n\n const nxJson = readNxJson(tree);\n updateNxJson(tree, {\n ...nxJson,\n // Preserve an explicit analytics choice in an existing workspace.\n analytics: (nxJson as { analytics?: boolean }).analytics ?? false,\n targetDefaults: {\n ...nxJson.targetDefaults,\n compile: mergeTargetDefault(nxJson.targetDefaults?.compile, (base) => ({\n ...base,\n syncGenerators: [\n ...(base.syncGenerators ?? []).filter(\n (g) =>\n ![TS_SYNC_GENERATOR_NAME, NX_TYPESCRIPT_SYNC_GENERATOR].includes(\n g,\n ),\n ),\n NX_TYPESCRIPT_SYNC_GENERATOR,\n TS_SYNC_GENERATOR_NAME,\n ],\n })),\n },\n });\n\n const CONVENIENCE_SCRIPTS = {\n dev: 'nx run-many --target dev',\n build: 'nx run-many --target build',\n lint: 'nx run-many --target lint --configuration=fix',\n test: 'nx run-many --target test --all',\n // Trivy container image scanning is not part of `build` (its result\n // depends on the ever-changing vulnerability database); run it explicitly,\n // e.g. in CI.\n trivy: 'nx run-many --target trivy --all',\n 'build:skip-lint': 'nx run-many --target build --configuration=skip-lint',\n 'build:all': 'nx run-many --target build --all',\n 'affected:all': 'nx affected --target build',\n };\n updateJson(tree, 'package.json', (packageJson) => ({\n ...packageJson,\n // The root `type` field is owned by the preset (written explicitly from\n // its `--module` option). `init` preserves an existing workspace's field\n // as-is: an ESM workspace already carries `type: \"module\"` (that is how\n // the format is inferred), and introducing a `type` into a CommonJS\n // workspace that lacks one changes behaviour for frameworks that parse it\n // (e.g. Next.js starts treating the app's ESM source as CJS).\n scripts: overwriteScripts\n ? { ...packageJson.scripts, ...CONVENIENCE_SCRIPTS }\n : { ...CONVENIENCE_SCRIPTS, ...packageJson.scripts },\n }));\n\n // Pin the workspace's `nx` to the version the plugin's @nx/* packages are\n // built against. A mismatched workspace nx (even a patch apart) hoists a\n // second nested nx under @nx/js, and the two instances deadlock `nx sync`.\n // `@nx/js` must be a root dependency for the `@nx/js:typescript-sync`\n // generator registered in nx.json to resolve (npm doesn't hoist the\n // plugin's own copy reliably).\n addDependenciesToPackageJson(\n tree,\n {},\n {\n ...withVersions(forDependencies<typeof INIT_DEPENDENCIES>(declaration), [\n 'nx',\n '@nx/js',\n '@nx/workspace',\n ]),\n ...withVersions(forDependencies<typeof INIT_DEPENDENCIES>(declaration), [\n 'typescript',\n '@biomejs/biome',\n ]),\n // Declare the plugin the generators are running from, plus the MCP server\n // package the vended config runs, so both are pinned in the workspace's\n // lockfile and upgrading them upgrades what the agents use.\n ...nxPluginSelfDependency(tree),\n ...nxPluginMcpDependency(tree),\n },\n );\n\n // Write biome.json for formatting and linting\n if (!tree.exists('biome.json')) {\n tree.write(\n 'biome.json',\n JSON.stringify(getDefaultBiomeConfig(tree), null, 2),\n );\n }\n\n generateFiles(\n tree, // the virtual file system\n joinPathFragments(import.meta.dirname, '..', 'preset', 'files'),\n '.',\n {\n projectName: getNpmScope(tree),\n generators: Object.entries(GeneratorsJson.generators)\n .filter(([_, v]) => !v['hidden'])\n .map(([k, v]) => ({ name: k, description: v.description })),\n ...(() => {\n const cmds = getPackageManagerDisplayCommands();\n return {\n pkgMgrCmd: cmds.exec,\n buildCmd: `${cmds.run} build`,\n lintCmd: `${cmds.run} lint`,\n };\n })(),\n },\n {\n overwriteStrategy: readmeOverwriteStrategy,\n },\n );\n\n if (mcp !== false) {\n configureMcpServers(tree);\n }\n};\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readNxJson","updateJson","updateNxJson","initGenerator","yaml","GeneratorsJson","type","SYNC_GENERATOR_NAME","TS_SYNC_GENERATOR_NAME","BASE_TSCONFIG_COMPILER_OPTIONS","ensureAwsNxPluginConfig","updateAwsNxPluginConfig","inferContainers","forDependencies","addDependenciesToPackageJson","detectWorkspacePackageManager","getDefaultBiomeConfig","configureMcpServers","getNpmScope","mergeTargetDefault","nxPluginMcpDependency","nxPluginSelfDependency","getPackageManagerDisplayCommands","workspaceGlobs","withVersions","WORKSPACES","NX_TYPESCRIPT_SYNC_GENERATOR","INIT_DEPENDENCIES","name","PNPM_BUILT_DEPENDENCIES","setUpPnpmWorkspace","tree","catalogs","existing","exists","load","read","packages","Array","from","Set","allowBuilds","Object","fromEntries","map","dep","catalogMode","write","dump","onlyBuiltDependencies","quotingType","setUpWorkspaces","json","globs","workspaces","undefined","isArray","ensureBaseTsConfig","JSON","stringify","compilerOptions","customConditions","ensureRootTsConfig","extends","files","references","applyWorkspaceInit","iac","containers","mcp","readmeOverwriteStrategy","KeepExisting","overwriteScripts","declaration","resolvedContainers","provider","engine","packageManager","formatter","addTsPlugin","nxJson","analytics","targetDefaults","compile","base","syncGenerators","filter","g","includes","CONVENIENCE_SCRIPTS","dev","build","lint","test","trivy","packageJson","scripts","dirname","projectName","generators","entries","_","v","k","description","cmds","pkgMgrCmd","exec","buildCmd","run","lintCmd","overwriteStrategy"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,UAAU,EAEVC,UAAU,EACVC,YAAY,QACP,aAAa;AACpB,SAASC,aAAa,QAAQ,SAAS;AAEvC,OAAOC,UAAU,UAAU;AAC3B,OAAOC,oBAAoB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACzE,SAASC,uBAAuBC,sBAAsB,QAAQ,0BAAuB;AACrF,SAASC,8BAA8B,QAAQ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GC,EAAE,GAAK,CAACA,CAAC,CAAC,SAAS,EAC/B1D,GAAG,CAAC,CAAC,CAAC2D,GAAGD,EAAE,GAAM,CAAA;gBAAE1E,MAAM2E;gBAAGC,aAAaF,EAAEE,WAAW;YAAC,CAAA;QAC1D,GAAG,AAAC,CAAA;YACF,MAAMC,OAAOnF;YACb,OAAO;gBACLoF,WAAWD,KAAKE,IAAI;gBACpBC,UAAU,GAAGH,KAAKI,GAAG,CAAC,MAAM,CAAC;gBAC7BC,SAAS,GAAGL,KAAKI,GAAG,CAAC,KAAK,CAAC;YAC7B;QACF,CAAA,GAAI;IACN,GACA;QACEE,mBAAmBzC;IACrB;IAGF,IAAID,QAAQ,OAAO;QACjBpD,oBAAoBc;IACtB;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/init.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readNxJson,\n type Tree,\n updateJson,\n updateNxJson,\n} from '@nx/devkit';\nimport { initGenerator } from '@nx/js';\nimport { readFileSync } from 'fs';\nimport yaml from 'js-yaml';\nimport GeneratorsJson from '../../generators.json' with { type: 'json' };\nimport { SYNC_GENERATOR_NAME as TS_SYNC_GENERATOR_NAME } from '../ts/sync/generator.js';\nimport { BASE_TSCONFIG_COMPILER_OPTIONS } from './base-tsconfig.js';\nimport {\n ensureAwsNxPluginConfig,\n updateAwsNxPluginConfig,\n} from './config/utils.js';\nimport { type Containers, inferContainers } from './containers.js';\nimport {\n type DependencyDeclaration,\n forDependencies,\n type MustDeclare,\n} from './declared-dependencies.js';\nimport {\n addDependenciesToPackageJson,\n detectWorkspacePackageManager,\n} from './dependencies.js';\nimport { getDefaultBiomeConfig } from './format.js';\nimport type { Iac } from './iac.js';\nimport { configureMcpServers } from './mcp.js';\nimport { getNpmScope } from './npm-scope.js';\nimport {\n mergeTargetDefault,\n nxPluginMcpDependency,\n nxPluginSelfDependency,\n} from './nx.js';\nimport { getPackageManagerDisplayCommands } from './pkg-manager.js';\nimport { workspaceGlobs } from './project-package-json.js';\nimport { type ITsDepVersion, withVersions } from './versions.js';\n\nconst WORKSPACES = ['packages/*'];\nconst NX_TYPESCRIPT_SYNC_GENERATOR = '@nx/js:typescript-sync';\n\n/** Dependencies a caller must declare to apply the workspace init. */\nexport const INIT_DEPENDENCIES = [\n { name: 'nx' },\n { name: '@nx/js' },\n { name: '@nx/workspace' },\n { name: 'typescript' },\n { name: '@biomejs/biome' },\n] as const satisfies readonly { name: ITsDepVersion }[];\n\n// Built dependencies whose install scripts the generated workspace trusts.\n// `onlyBuiltDependencies` is the pnpm 10 key (silently ignored by pnpm 11);\n// pnpm 11 reads `allowBuilds` instead. Any dep NOT in this allowlist will\n// have its install scripts skipped with a warning — matching pnpm 10's\n// default behaviour. The user can opt-in later via `pnpm approve-builds`.\nexport const PNPM_BUILT_DEPENDENCIES = ['@swc/core', 'esbuild', 'nx', 'sharp'];\n\n/**\n * Options controlling how the workspace is initialised. These mirror the\n * preset schema so a workspace created via the preset and one initialised via\n * the `init` generator end up in the same shape.\n */\nexport interface ApplyWorkspaceInitOptions {\n /** The IaC provider to record in the plugin config. */\n readonly iac: Iac;\n /**\n * The container engine to record. `undefined`/`'infer'` picks docker when\n * installed, else finch.\n */\n readonly containers?: Containers | 'infer';\n /** Whether to configure MCP servers for coding agents. Defaults to true. */\n readonly mcp?: boolean;\n /**\n * How to treat the generated workspace README. The preset owns the README of\n * a greenfield workspace (`Overwrite`); the `init` generator must not clobber\n * an existing workspace's README (`KeepExisting`, the default).\n */\n readonly readmeOverwriteStrategy?: OverwriteStrategy;\n /**\n * Whether to overwrite root package.json scripts that already exist. The\n * preset owns a greenfield workspace's scripts (`true`); the `init`\n * generator must not clobber an existing workspace's scripts (`false`,\n * the default) — it only adds the convenience scripts that are absent.\n */\n readonly overwriteScripts?: boolean;\n /**\n * Whether generators use the package manager's dependency catalog. On pnpm\n * this also sets `catalogMode: strict` so `pnpm add` records new deps in the\n * catalog. Defaults to true.\n */\n readonly catalogs?: boolean;\n}\n\n/**\n * Add or repair the pnpm `allowBuilds` / `onlyBuiltDependencies` allowlist for\n * the workspace's `packages` globs, without clobbering any packages the user\n * has already declared.\n *\n * A workspace not created by the preset commonly has either no\n * `pnpm-workspace.yaml`, one missing the `packages` globs, or one carrying the\n * broken `set this to true or false` placeholder pnpm writes when it skips a\n * build script. This makes the file self-consistent so the first generator's\n * install doesn't fail with `ERR_PNPM_IGNORED_BUILDS`.\n */\nconst setUpPnpmWorkspace = (tree: Tree, catalogs: boolean) => {\n const existing = tree.exists('pnpm-workspace.yaml')\n ? ((yaml.load(tree.read('pnpm-workspace.yaml', 'utf-8') ?? '') as Record<\n string,\n unknown\n >) ?? {})\n : {};\n\n // Preserve any packages globs the user already has, ensuring ours are present.\n const packages = Array.from(\n new Set([...((existing.packages as string[]) ?? []), ...WORKSPACES]),\n );\n\n const allowBuilds = {\n ...(typeof existing.allowBuilds === 'object' && existing.allowBuilds\n ? (existing.allowBuilds as Record<string, unknown>)\n : {}),\n // Overwrite any non-boolean (e.g. the \"set this to true or false\"\n // placeholder) with an explicit true for the deps we trust.\n ...Object.fromEntries(PNPM_BUILT_DEPENDENCIES.map((dep) => [dep, true])),\n };\n\n // `strict` makes `pnpm add` record new deps in the catalog; it only gates\n // that flow, so pre-declared direct ranges (e.g. tslib) still install.\n // Preserve an explicit user choice.\n const catalogMode = catalogs\n ? (existing.catalogMode ?? 'strict')\n : existing.catalogMode;\n\n tree.write(\n 'pnpm-workspace.yaml',\n yaml.dump(\n {\n ...existing,\n packages,\n allowBuilds,\n onlyBuiltDependencies: PNPM_BUILT_DEPENDENCIES,\n ...(catalogMode ? { catalogMode } : {}),\n },\n { quotingType: \"'\" },\n ),\n );\n};\n\n/**\n * Configure the workspace's package manager for a monorepo layout.\n *\n * pnpm workspaces are declared in `pnpm-workspace.yaml`; every other package\n * manager reads the `workspaces` field of the root `package.json`.\n */\nconst setUpWorkspaces = (tree: Tree, catalogs: boolean) => {\n if (detectWorkspacePackageManager(tree) === 'pnpm') {\n setUpPnpmWorkspace(tree, catalogs);\n } else {\n updateJson(tree, 'package.json', (json) => {\n // The `workspaces` field may be the object form ({ \"packages\": [...] })\n // accepted by yarn and bun — extend the globs while preserving the form.\n const globs = Array.from(\n new Set([...workspaceGlobs(json.workspaces), ...WORKSPACES]),\n );\n return {\n ...json,\n workspaces:\n json.workspaces !== undefined && !Array.isArray(json.workspaces)\n ? { ...json.workspaces, packages: globs }\n : globs,\n };\n });\n }\n};\n\n/**\n * Ensure the workspace has a `tsconfig.base.json`.\n *\n * `@nx/js` `initGenerator` (with `addTsPlugin`) normally creates this, but it\n * short-circuits when the workspace already has a root `tsconfig.json` — in\n * which case no base file is written and the next project generator fails with\n * `Cannot find tsconfig.base.json`. So we create a compatible one when it's\n * absent. An existing base is left untouched: the user may have tuned it, and\n * rewriting shared compiler options can break other projects (see the\n * \"add to an existing workspace\" guide).\n */\nconst ensureBaseTsConfig = (tree: Tree) => {\n if (tree.exists('tsconfig.base.json')) {\n return;\n }\n tree.write(\n 'tsconfig.base.json',\n JSON.stringify(\n {\n compilerOptions: {\n ...BASE_TSCONFIG_COMPILER_OPTIONS,\n customConditions: [getNpmScope(tree)],\n },\n },\n null,\n 2,\n ),\n );\n};\n\n/**\n * Ensure the workspace has a root `tsconfig.json`.\n *\n * Nx's `@nx/js:typescript-sync` generator hard-fails with\n * `Missing root \"tsconfig.json\"` when it's absent. The plugin's TypeScript\n * projects reference each other via this file, so we guarantee a minimal one\n * exists (sync populates its `references`).\n */\nconst ensureRootTsConfig = (tree: Tree) => {\n if (tree.exists('tsconfig.json')) {\n return;\n }\n tree.write(\n 'tsconfig.json',\n JSON.stringify(\n {\n extends: './tsconfig.base.json',\n files: [],\n references: [],\n },\n null,\n 2,\n ),\n );\n};\n\n/**\n * Transform an Nx workspace into one ready to run `@aws/nx-plugin` generators.\n *\n * This is the deterministic core shared by the workspace preset and the `init`\n * generator. It is safe to re-run: every step is idempotent (config merges,\n * keyed nx.json / package.json entries, create-if-missing files), so running\n * it against an already-initialised workspace is a no-op.\n *\n * It preserves the workspace's module format: the root package.json `type`\n * field is owned by the preset (written from its `--module` option) and left\n * untouched here. It does NOT rewrite an existing `tsconfig.base.json`'s\n * compiler options, migrate a workspace's package manager, or restructure\n * existing projects — those are decisions for the user (see the \"add to an\n * existing workspace\" guide).\n */\nexport const applyWorkspaceInit = async <const D extends DependencyDeclaration>(\n tree: Tree,\n {\n iac,\n containers,\n mcp,\n readmeOverwriteStrategy = OverwriteStrategy.KeepExisting,\n overwriteScripts = false,\n catalogs = true,\n }: ApplyWorkspaceInitOptions,\n declaration: D & MustDeclare<typeof INIT_DEPENDENCIES, D>,\n) => {\n const resolvedContainers =\n !containers || containers === 'infer' ? inferContainers() : containers;\n\n // The catalogs flag is written explicitly (even when true) so the workspace\n // records its dependency-management choice.\n await ensureAwsNxPluginConfig(tree);\n await updateAwsNxPluginConfig(tree, {\n iac: { provider: iac },\n containers: { engine: resolvedContainers },\n packageManager: { catalogs },\n });\n\n // Set up the TypeScript plugin, base tsconfig, formatter etc. `@nx/js`\n // creates `tsconfig.base.json` when absent, but skips it when a root\n // `tsconfig.json` already exists — so we ensure both explicitly below.\n await initGenerator(tree, {\n formatter: 'none',\n addTsPlugin: true,\n });\n\n ensureBaseTsConfig(tree);\n ensureRootTsConfig(tree);\n\n setUpWorkspaces(tree, catalogs);\n\n const nxJson = readNxJson(tree);\n updateNxJson(tree, {\n ...nxJson,\n // Preserve an explicit analytics choice in an existing workspace.\n analytics: (nxJson as { analytics?: boolean }).analytics ?? false,\n targetDefaults: {\n ...nxJson.targetDefaults,\n compile: mergeTargetDefault(nxJson.targetDefaults?.compile, (base) => ({\n ...base,\n syncGenerators: [\n ...(base.syncGenerators ?? []).filter(\n (g) =>\n ![TS_SYNC_GENERATOR_NAME, NX_TYPESCRIPT_SYNC_GENERATOR].includes(\n g,\n ),\n ),\n NX_TYPESCRIPT_SYNC_GENERATOR,\n TS_SYNC_GENERATOR_NAME,\n ],\n })),\n },\n });\n\n const CONVENIENCE_SCRIPTS = {\n dev: 'nx run-many --target dev',\n build: 'nx run-many --target build',\n lint: 'nx run-many --target lint --configuration=fix',\n test: 'nx run-many --target test --all',\n // Trivy container image scanning is not part of `build` (its result\n // depends on the ever-changing vulnerability database); run it explicitly,\n // e.g. in CI.\n trivy: 'nx run-many --target trivy --all',\n 'build:skip-lint': 'nx run-many --target build --configuration=skip-lint',\n 'build:all': 'nx run-many --target build --all',\n 'affected:all': 'nx affected --target build',\n };\n updateJson(tree, 'package.json', (packageJson) => ({\n ...packageJson,\n // The root `type` field is owned by the preset (written explicitly from\n // its `--module` option). `init` preserves an existing workspace's field\n // as-is: an ESM workspace already carries `type: \"module\"` (that is how\n // the format is inferred), and introducing a `type` into a CommonJS\n // workspace that lacks one changes behaviour for frameworks that parse it\n // (e.g. Next.js starts treating the app's ESM source as CJS).\n scripts: overwriteScripts\n ? { ...packageJson.scripts, ...CONVENIENCE_SCRIPTS }\n : { ...CONVENIENCE_SCRIPTS, ...packageJson.scripts },\n }));\n\n // Pin the workspace's `nx` to the version the plugin's @nx/* packages are\n // built against. A mismatched workspace nx (even a patch apart) hoists a\n // second nested nx under @nx/js, and the two instances deadlock `nx sync`.\n // `@nx/js` must be a root dependency for the `@nx/js:typescript-sync`\n // generator registered in nx.json to resolve (npm doesn't hoist the\n // plugin's own copy reliably).\n addDependenciesToPackageJson(\n tree,\n {},\n {\n ...withVersions(forDependencies<typeof INIT_DEPENDENCIES>(declaration), [\n 'nx',\n '@nx/js',\n '@nx/workspace',\n ]),\n ...withVersions(forDependencies<typeof INIT_DEPENDENCIES>(declaration), [\n 'typescript',\n '@biomejs/biome',\n ]),\n // Declare the plugin the generators are running from, plus the MCP server\n // package the vended config runs, so both are pinned in the workspace's\n // lockfile and upgrading them upgrades what the agents use.\n ...nxPluginSelfDependency(tree),\n ...nxPluginMcpDependency(tree),\n },\n );\n\n // Write biome.json for formatting and linting\n if (!tree.exists('biome.json')) {\n tree.write(\n 'biome.json',\n JSON.stringify(getDefaultBiomeConfig(tree), null, 2),\n );\n }\n\n generateFiles(\n tree, // the virtual file system\n joinPathFragments(import.meta.dirname, '..', 'preset', 'files'),\n '.',\n {\n projectName: getNpmScope(tree),\n generators: Object.entries(GeneratorsJson.generators)\n .filter(([_, v]) => !v['hidden'])\n .map(([k, v]) => ({ name: k, description: v.description })),\n ...(() => {\n const cmds = getPackageManagerDisplayCommands();\n return {\n pkgMgrCmd: cmds.exec,\n buildCmd: `${cmds.run} build`,\n lintCmd: `${cmds.run} lint`,\n };\n })(),\n },\n {\n overwriteStrategy: readmeOverwriteStrategy,\n },\n );\n\n if (mcp !== false) {\n configureMcpServers(tree);\n }\n};\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readNxJson","updateJson","updateNxJson","initGenerator","yaml","GeneratorsJson","type","SYNC_GENERATOR_NAME","TS_SYNC_GENERATOR_NAME","BASE_TSCONFIG_COMPILER_OPTIONS","ensureAwsNxPluginConfig","updateAwsNxPluginConfig","inferContainers","forDependencies","addDependenciesToPackageJson","detectWorkspacePackageManager","getDefaultBiomeConfig","configureMcpServers","getNpmScope","mergeTargetDefault","nxPluginMcpDependency","nxPluginSelfDependency","getPackageManagerDisplayCommands","workspaceGlobs","withVersions","WORKSPACES","NX_TYPESCRIPT_SYNC_GENERATOR","INIT_DEPENDENCIES","name","PNPM_BUILT_DEPENDENCIES","setUpPnpmWorkspace","tree","catalogs","existing","exists","load","read","packages","Array","from","Set","allowBuilds","Object","fromEntries","map","dep","catalogMode","write","dump","onlyBuiltDependencies","quotingType","setUpWorkspaces","json","globs","workspaces","undefined","isArray","ensureBaseTsConfig","JSON","stringify","compilerOptions","customConditions","ensureRootTsConfig","extends","files","references","applyWorkspaceInit","iac","containers","mcp","readmeOverwriteStrategy","KeepExisting","overwriteScripts","declaration","resolvedContainers","provider","engine","packageManager","formatter","addTsPlugin","nxJson","analytics","targetDefaults","compile","base","syncGenerators","filter","g","includes","CONVENIENCE_SCRIPTS","dev","build","lint","test","trivy","packageJson","scripts","dirname","projectName","generators","entries","_","v","k","description","cmds","pkgMgrCmd","exec","buildCmd","run","lintCmd","overwriteStrategy"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,UAAU,EAEVC,UAAU,EACVC,YAAY,QACP,aAAa;AACpB,SAASC,aAAa,QAAQ,SAAS;AAEvC,OAAOC,UAAU,UAAU;AAC3B,OAAOC,oBAAoB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACzE,SAASC,uBAAuBC,sBAAsB,QAAQ,0BAA0B;AACxF,SAASC,8BAA8B,QAAQ,qBAAqB;AACpE,SACEC,uBAAuB,EACvBC,uBAAuB,QAClB,oBAAoB;AAC3B,SAA0BC,eAAe,QAAQ,kBAAkB;AACnE,SAEEC,eAAe,QAEV,6BAA6B;AACpC,SACEC,4BAA4B,EAC5BC,6BAA6B,QACxB,oBAAoB;AAC3B,SAASC,qBAAqB,QAAQ,cAAc;AAEpD,SAASC,mBAAmB,QAAQ,WAAW;AAC/C,SAASC,WAAW,QAAQ,iBAAiB;AAC7C,SACEC,kBAAkB,EAClBC,qBAAqB,EACrBC,sBAAsB,QACjB,UAAU;AACjB,SAASC,gCAAgC,QAAQ,mBAAmB;AACpE,SAASC,cAAc,QAAQ,4BAA4B;AAC3D,SAA6BC,YAAY,QAAQ,gBAAgB;AAEjE,MAAMC,aAAa;IAAC;CAAa;AACjC,MAAMC,+BAA+B;AAErC,oEAAoE,GACpE,OAAO,MAAMC,oBAAoB;IAC/B;QAAEC,MAAM;IAAK;IACb;QAAEA,MAAM;IAAS;IACjB;QAAEA,MAAM;IAAgB;IACxB;QAAEA,MAAM;IAAa;IACrB;QAAEA,MAAM;IAAiB;CAC1B,CAAuD;AAExD,2EAA2E;AAC3E,4EAA4E;AAC5E,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AAC;QACF,GAAGjD,aAAaX,gBAA0C4D,cAAc;YACtE;YACA;SACD,CAAC;QACF,0EAA0E;QAC1E,wEAAwE;QACxE,4DAA4D;QAC5D,GAAGpD,uBAAuBU,KAAK;QAC/B,GAAGX,sBAAsBW,KAAK;IAChC;IAGF,8CAA8C;IAC9C,IAAI,CAACA,KAAKG,MAAM,CAAC,eAAe;QAC9BH,KAAKgB,KAAK,CACR,cACAW,KAAKC,SAAS,CAAC3C,sBAAsBe,OAAO,MAAM;IAEtD;IAEAlC,cACEkC,MACAjC,kBAAkB,YAAYmG,OAAO,EAAE,MAAM,UAAU,UACvD,KACA;QACEC,aAAahF,YAAYa;QACzBoE,YAAYzD,OAAO0D,OAAO,CAAC/F,eAAe8F,UAAU,EACjDb,MAAM,CAAC,CAAC,CAACe,GAAGC,EAAE,GAAK,CAACA,CAAC,CAAC,SAAS,EAC/B1D,GAAG,CAAC,CAAC,CAAC2D,GAAGD,EAAE,GAAM,CAAA;gBAAE1E,MAAM2E;gBAAGC,aAAaF,EAAEE,WAAW;YAAC,CAAA;QAC1D,GAAG,AAAC,CAAA;YACF,MAAMC,OAAOnF;YACb,OAAO;gBACLoF,WAAWD,KAAKE,IAAI;gBACpBC,UAAU,GAAGH,KAAKI,GAAG,CAAC,MAAM,CAAC;gBAC7BC,SAAS,GAAGL,KAAKI,GAAG,CAAC,KAAK,CAAC;YAC7B;QACF,CAAA,GAAI;IACN,GACA;QACEE,mBAAmBzC;IACrB;IAGF,IAAID,QAAQ,OAAO;QACjBpD,oBAAoBc;IACtB;AACF,EAAE"}
@@ -1,5 +1,5 @@
1
1
  import { type Tree } from '@nx/devkit';
2
- import type { ITsDepVersion } from './versions';
2
+ import type { ITsDepVersion } from './versions.js';
3
3
  /**
4
4
  * Languages whose dependencies a generator may install.
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/install.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { installPackagesTask, type Tree } from '@nx/devkit';\nimport { Logger, UVProvider } from './nxlv-python';\nimport type { ITsDepVersion } from './versions';\n\n/**\n * Languages whose dependencies a generator may install.\n */\nexport type InstallLanguage = 'typescript' | 'python';\n\nexport interface InstallDependenciesOptions {\n /** Languages to install dependencies for. */\n languages: InstallLanguage[];\n /**\n * Packages that must resolve from the workspace after this generator, because\n * a config file it writes (e.g. `vite.config.mts`) imports them and Nx loads\n * that config when computing the project graph. When the caller prefers to\n * defer installing, we honour that only if these already resolve.\n *\n * The per-language graph deps in `LANGUAGE_GRAPH_DEPS` are always included, so\n * callers only list packages beyond those.\n */\n ensureResolvable?: ITsDepVersion[];\n}\n\n/**\n * Packages each language always needs resolvable for Nx to compute the project\n * graph, so a deferred install still runs whenever it would otherwise break.\n */\nconst LANGUAGE_GRAPH_DEPS: Record<InstallLanguage, string[]> = {\n typescript: ['vitest'], // every TypeScript project has a `vitest.config.mts`\n python: ['@nxlv/python'], // every Python project registers this inference plugin\n};\n\n/**\n * Returns true if every package is linked at `<root>/node_modules/<pkg>`.\n *\n * This is the condition Nx's inferred plugins need when they load a generated\n * config (e.g. `vite.config.mts`) during graph computation: the config's\n * imports resolve from inside the workspace's own `node_modules`. We avoid\n * `require.resolve`, which can succeed via an ancestor `node_modules` even when\n * the package isn't linked here. `existsSync` follows symlinks, so pnpm's store\n * links resolve, and Nx always uses a `node_modules` linker (never PnP).\n */\nconst allResolvable = (root: string, packages: string[]): boolean =>\n packages.every((pkg) => existsSync(join(root, 'node_modules', pkg)));\n\n/**\n * Installs dependencies for the given languages.\n *\n * Call from a generator's returned callback:\n * `return () => installDependencies(tree, options.preferInstallDependencies, { ... })`.\n *\n * `preferInstallDependencies` is a preference: when `false` the install is\n * deferred so a batch installs once at the end — unless an `ensureResolvable`\n * package is missing, in which case it runs anyway so the next `nx` command can\n * still compute the project graph.\n */\nexport const installDependencies = async (\n tree: Tree,\n preferInstallDependencies: boolean | undefined,\n options: InstallDependenciesOptions,\n): Promise<void> => {\n const { languages, ensureResolvable = [] } = options;\n const mustResolve = [\n ...ensureResolvable,\n ...languages.flatMap((language) => LANGUAGE_GRAPH_DEPS[language]),\n ];\n if (\n preferInstallDependencies === false &&\n allResolvable(tree.root, mustResolve)\n ) {\n return;\n }\n if (languages.includes('typescript')) {\n // Force the install: devkit's default only installs when the root\n // package.json changed, but deps land in per-project manifests.\n installPackagesTask(tree, true);\n }\n if (languages.includes('python')) {\n await new UVProvider(tree.root, new Logger(), tree).install();\n }\n};\n"],"names":["existsSync","join","installPackagesTask","Logger","UVProvider","LANGUAGE_GRAPH_DEPS","typescript","python","allResolvable","root","packages","every","pkg","installDependencies","tree","preferInstallDependencies","options","languages","ensureResolvable","mustResolve","flatMap","language","includes","install"],"mappings":"AAAA;;;CAGC,GACD,SAASA,UAAU,QAAQ,UAAU;AACrC,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,mBAAmB,QAAmB,aAAa;AAC5D,SAASC,MAAM,EAAEC,UAAU,QAAQ,mBAAgB;AAuBnD;;;CAGC,GACD,MAAMC,sBAAyD;IAC7DC,YAAY;QAAC;KAAS;IACtBC,QAAQ;QAAC;KAAe;AAC1B;AAEA;;;;;;;;;CASC,GACD,MAAMC,gBAAgB,CAACC,MAAcC,WACnCA,SAASC,KAAK,CAAC,CAACC,MAAQZ,WAAWC,KAAKQ,MAAM,gBAAgBG;AAEhE;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,sBAAsB,OACjCC,MACAC,2BACAC;IAEA,MAAM,EAAEC,SAAS,EAAEC,mBAAmB,EAAE,EAAE,GAAGF;IAC7C,MAAMG,cAAc;WACfD;WACAD,UAAUG,OAAO,CAAC,CAACC,WAAahB,mBAAmB,CAACgB,SAAS;KACjE;IACD,IACEN,8BAA8B,SAC9BP,cAAcM,KAAKL,IAAI,EAAEU,cACzB;QACA;IACF;IACA,IAAIF,UAAUK,QAAQ,CAAC,eAAe;QACpC,kEAAkE;QAClE,gEAAgE;QAChEpB,oBAAoBY,MAAM;IAC5B;IACA,IAAIG,UAAUK,QAAQ,CAAC,WAAW;QAChC,MAAM,IAAIlB,WAAWU,KAAKL,IAAI,EAAE,IAAIN,UAAUW,MAAMS,OAAO;IAC7D;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/install.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { installPackagesTask, type Tree } from '@nx/devkit';\nimport { Logger, UVProvider } from './nxlv-python.js';\nimport type { ITsDepVersion } from './versions.js';\n\n/**\n * Languages whose dependencies a generator may install.\n */\nexport type InstallLanguage = 'typescript' | 'python';\n\nexport interface InstallDependenciesOptions {\n /** Languages to install dependencies for. */\n languages: InstallLanguage[];\n /**\n * Packages that must resolve from the workspace after this generator, because\n * a config file it writes (e.g. `vite.config.mts`) imports them and Nx loads\n * that config when computing the project graph. When the caller prefers to\n * defer installing, we honour that only if these already resolve.\n *\n * The per-language graph deps in `LANGUAGE_GRAPH_DEPS` are always included, so\n * callers only list packages beyond those.\n */\n ensureResolvable?: ITsDepVersion[];\n}\n\n/**\n * Packages each language always needs resolvable for Nx to compute the project\n * graph, so a deferred install still runs whenever it would otherwise break.\n */\nconst LANGUAGE_GRAPH_DEPS: Record<InstallLanguage, string[]> = {\n typescript: ['vitest'], // every TypeScript project has a `vitest.config.mts`\n python: ['@nxlv/python'], // every Python project registers this inference plugin\n};\n\n/**\n * Returns true if every package is linked at `<root>/node_modules/<pkg>`.\n *\n * This is the condition Nx's inferred plugins need when they load a generated\n * config (e.g. `vite.config.mts`) during graph computation: the config's\n * imports resolve from inside the workspace's own `node_modules`. We avoid\n * `require.resolve`, which can succeed via an ancestor `node_modules` even when\n * the package isn't linked here. `existsSync` follows symlinks, so pnpm's store\n * links resolve, and Nx always uses a `node_modules` linker (never PnP).\n */\nconst allResolvable = (root: string, packages: string[]): boolean =>\n packages.every((pkg) => existsSync(join(root, 'node_modules', pkg)));\n\n/**\n * Installs dependencies for the given languages.\n *\n * Call from a generator's returned callback:\n * `return () => installDependencies(tree, options.preferInstallDependencies, { ... })`.\n *\n * `preferInstallDependencies` is a preference: when `false` the install is\n * deferred so a batch installs once at the end — unless an `ensureResolvable`\n * package is missing, in which case it runs anyway so the next `nx` command can\n * still compute the project graph.\n */\nexport const installDependencies = async (\n tree: Tree,\n preferInstallDependencies: boolean | undefined,\n options: InstallDependenciesOptions,\n): Promise<void> => {\n const { languages, ensureResolvable = [] } = options;\n const mustResolve = [\n ...ensureResolvable,\n ...languages.flatMap((language) => LANGUAGE_GRAPH_DEPS[language]),\n ];\n if (\n preferInstallDependencies === false &&\n allResolvable(tree.root, mustResolve)\n ) {\n return;\n }\n if (languages.includes('typescript')) {\n // Force the install: devkit's default only installs when the root\n // package.json changed, but deps land in per-project manifests.\n installPackagesTask(tree, true);\n }\n if (languages.includes('python')) {\n await new UVProvider(tree.root, new Logger(), tree).install();\n }\n};\n"],"names":["existsSync","join","installPackagesTask","Logger","UVProvider","LANGUAGE_GRAPH_DEPS","typescript","python","allResolvable","root","packages","every","pkg","installDependencies","tree","preferInstallDependencies","options","languages","ensureResolvable","mustResolve","flatMap","language","includes","install"],"mappings":"AAAA;;;CAGC,GACD,SAASA,UAAU,QAAQ,UAAU;AACrC,SAASC,IAAI,QAAQ,YAAY;AACjC,SAASC,mBAAmB,QAAmB,aAAa;AAC5D,SAASC,MAAM,EAAEC,UAAU,QAAQ,mBAAmB;AAuBtD;;;CAGC,GACD,MAAMC,sBAAyD;IAC7DC,YAAY;QAAC;KAAS;IACtBC,QAAQ;QAAC;KAAe;AAC1B;AAEA;;;;;;;;;CASC,GACD,MAAMC,gBAAgB,CAACC,MAAcC,WACnCA,SAASC,KAAK,CAAC,CAACC,MAAQZ,WAAWC,KAAKQ,MAAM,gBAAgBG;AAEhE;;;;;;;;;;CAUC,GACD,OAAO,MAAMC,sBAAsB,OACjCC,MACAC,2BACAC;IAEA,MAAM,EAAEC,SAAS,EAAEC,mBAAmB,EAAE,EAAE,GAAGF;IAC7C,MAAMG,cAAc;WACfD;WACAD,UAAUG,OAAO,CAAC,CAACC,WAAahB,mBAAmB,CAACgB,SAAS;KACjE;IACD,IACEN,8BAA8B,SAC9BP,cAAcM,KAAKL,IAAI,EAAEU,cACzB;QACA;IACF;IACA,IAAIF,UAAUK,QAAQ,CAAC,eAAe;QACpC,kEAAkE;QAClE,gEAAgE;QAChEpB,oBAAoBY,MAAM;IAC5B;IACA,IAAIG,UAAUK,QAAQ,CAAC,WAAW;QAChC,MAAM,IAAIlB,WAAWU,KAAKL,IAAI,EAAE,IAAIN,UAAUW,MAAMS,OAAO;IAC7D;AACF,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/mcp.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { readJson, type Tree, writeJson } from '@nx/devkit';\nimport { updateToml } from './toml';\n\n/**\n * Name of the Nx Plugin for AWS MCP server, used as the key in each agent's config.\n */\nexport const NX_PLUGIN_MCP_SERVER_NAME = 'nx-plugin-for-aws';\n\n/**\n * Command used to launch the Nx Plugin for AWS MCP server.\n */\nexport const NX_PLUGIN_MCP_SERVER_COMMAND = 'npx';\n\n/**\n * Package providing the Nx Plugin for AWS MCP server.\n */\nexport const NX_PLUGIN_MCP_PACKAGE_NAME = '@aws/nx-plugin-mcp';\n\n/**\n * Arguments used to launch the Nx Plugin for AWS MCP server.\n *\n * npx prefers a locally installed package over the registry, and generators\n * declare this package as a workspace devDependency, so the server tracks the\n * version in the workspace's lockfile. `-y` falls back to fetching from the\n * registry for a workspace where it isn't installed.\n */\nexport const NX_PLUGIN_MCP_SERVER_ARGS = ['-y', NX_PLUGIN_MCP_PACKAGE_NAME];\n\n/**\n * A single stdio MCP server entry, shared by agents that use the `mcpServers` config shape.\n */\nconst stdioServerEntry = () => ({\n command: NX_PLUGIN_MCP_SERVER_COMMAND,\n args: NX_PLUGIN_MCP_SERVER_ARGS,\n});\n\n/**\n * Merge the Nx Plugin for AWS MCP server into a JSON config file under the given key,\n * preserving any other servers already configured. Creates the file if it does not exist.\n */\nconst mergeJsonMcpConfig = (\n tree: Tree,\n filePath: string,\n key: 'mcpServers' | 'servers',\n entry: Record<string, unknown>,\n) => {\n const config = tree.exists(filePath) ? readJson(tree, filePath) : {};\n config[key] = {\n ...config[key],\n [NX_PLUGIN_MCP_SERVER_NAME]: entry,\n };\n writeJson(tree, filePath, config);\n};\n\n/**\n * Configure the Nx Plugin for AWS MCP server across the project-level config locations\n * used by common coding agents, so agents working in the workspace can use it to scaffold\n * AWS projects with the Nx Plugin for AWS.\n *\n * Existing servers and unrelated config in each file are preserved.\n */\nexport const configureMcpServers = (tree: Tree) => {\n // Agents using the `mcpServers` config shape (Claude Code, Cursor, Kiro, Gemini CLI)\n const mcpServersFiles = [\n '.mcp.json', // Claude Code\n '.cursor/mcp.json', // Cursor\n '.kiro/settings/mcp.json', // Kiro\n '.gemini/settings.json', // Gemini CLI\n ];\n for (const filePath of mcpServersFiles) {\n mergeJsonMcpConfig(tree, filePath, 'mcpServers', stdioServerEntry());\n }\n\n // GitHub Copilot uses the `servers` key with an explicit `type`\n mergeJsonMcpConfig(tree, '.vscode/mcp.json', 'servers', {\n type: 'stdio',\n ...stdioServerEntry(),\n });\n\n // OpenAI Codex CLI uses TOML under the `mcp_servers` table\n const codexConfig = '.codex/config.toml';\n if (!tree.exists(codexConfig)) {\n tree.write(codexConfig, '');\n }\n updateToml(tree, codexConfig, (prev) => ({\n ...prev,\n mcp_servers: {\n ...(prev.mcp_servers as object),\n [NX_PLUGIN_MCP_SERVER_NAME]: {\n command: NX_PLUGIN_MCP_SERVER_COMMAND,\n args: NX_PLUGIN_MCP_SERVER_ARGS,\n },\n },\n }));\n};\n"],"names":["readJson","writeJson","updateToml","NX_PLUGIN_MCP_SERVER_NAME","NX_PLUGIN_MCP_SERVER_COMMAND","NX_PLUGIN_MCP_PACKAGE_NAME","NX_PLUGIN_MCP_SERVER_ARGS","stdioServerEntry","command","args","mergeJsonMcpConfig","tree","filePath","key","entry","config","exists","configureMcpServers","mcpServersFiles","type","codexConfig","write","prev","mcp_servers"],"mappings":"AAAA;;;CAGC,GACD,SAASA,QAAQ,EAAaC,SAAS,QAAQ,aAAa;AAC5D,SAASC,UAAU,QAAQ,YAAS;AAEpC;;CAEC,GACD,OAAO,MAAMC,4BAA4B,oBAAoB;AAE7D;;CAEC,GACD,OAAO,MAAMC,+BAA+B,MAAM;AAElD;;CAEC,GACD,OAAO,MAAMC,6BAA6B,qBAAqB;AAE/D;;;;;;;CAOC,GACD,OAAO,MAAMC,4BAA4B;IAAC;IAAMD;CAA2B,CAAC;AAE5E;;CAEC,GACD,MAAME,mBAAmB,IAAO,CAAA;QAC9BC,SAASJ;QACTK,MAAMH;IACR,CAAA;AAEA;;;CAGC,GACD,MAAMI,qBAAqB,CACzBC,MACAC,UACAC,KACAC;IAEA,MAAMC,SAASJ,KAAKK,MAAM,CAACJ,YAAYZ,SAASW,MAAMC,YAAY,CAAC;IACnEG,MAAM,CAACF,IAAI,GAAG;QACZ,GAAGE,MAAM,CAACF,IAAI;QACd,CAACV,0BAA0B,EAAEW;IAC/B;IACAb,UAAUU,MAAMC,UAAUG;AAC5B;AAEA;;;;;;CAMC,GACD,OAAO,MAAME,sBAAsB,CAACN;IAClC,qFAAqF;IACrF,MAAMO,kBAAkB;QACtB;QACA;QACA;QACA;KACD;IACD,KAAK,MAAMN,YAAYM,gBAAiB;QACtCR,mBAAmBC,MAAMC,UAAU,cAAcL;IACnD;IAEA,gEAAgE;IAChEG,mBAAmBC,MAAM,oBAAoB,WAAW;QACtDQ,MAAM;QACN,GAAGZ,kBAAkB;IACvB;IAEA,2DAA2D;IAC3D,MAAMa,cAAc;IACpB,IAAI,CAACT,KAAKK,MAAM,CAACI,cAAc;QAC7BT,KAAKU,KAAK,CAACD,aAAa;IAC1B;IACAlB,WAAWS,MAAMS,aAAa,CAACE,OAAU,CAAA;YACvC,GAAGA,IAAI;YACPC,aAAa;gBACX,GAAID,KAAKC,WAAW;gBACpB,CAACpB,0BAA0B,EAAE;oBAC3BK,SAASJ;oBACTK,MAAMH;gBACR;YACF;QACF,CAAA;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/mcp.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { readJson, type Tree, writeJson } from '@nx/devkit';\nimport { updateToml } from './toml.js';\n\n/**\n * Name of the Nx Plugin for AWS MCP server, used as the key in each agent's config.\n */\nexport const NX_PLUGIN_MCP_SERVER_NAME = 'nx-plugin-for-aws';\n\n/**\n * Command used to launch the Nx Plugin for AWS MCP server.\n */\nexport const NX_PLUGIN_MCP_SERVER_COMMAND = 'npx';\n\n/**\n * Package providing the Nx Plugin for AWS MCP server.\n */\nexport const NX_PLUGIN_MCP_PACKAGE_NAME = '@aws/nx-plugin-mcp';\n\n/**\n * Arguments used to launch the Nx Plugin for AWS MCP server.\n *\n * npx prefers a locally installed package over the registry, and generators\n * declare this package as a workspace devDependency, so the server tracks the\n * version in the workspace's lockfile. `-y` falls back to fetching from the\n * registry for a workspace where it isn't installed.\n */\nexport const NX_PLUGIN_MCP_SERVER_ARGS = ['-y', NX_PLUGIN_MCP_PACKAGE_NAME];\n\n/**\n * A single stdio MCP server entry, shared by agents that use the `mcpServers` config shape.\n */\nconst stdioServerEntry = () => ({\n command: NX_PLUGIN_MCP_SERVER_COMMAND,\n args: NX_PLUGIN_MCP_SERVER_ARGS,\n});\n\n/**\n * Merge the Nx Plugin for AWS MCP server into a JSON config file under the given key,\n * preserving any other servers already configured. Creates the file if it does not exist.\n */\nconst mergeJsonMcpConfig = (\n tree: Tree,\n filePath: string,\n key: 'mcpServers' | 'servers',\n entry: Record<string, unknown>,\n) => {\n const config = tree.exists(filePath) ? readJson(tree, filePath) : {};\n config[key] = {\n ...config[key],\n [NX_PLUGIN_MCP_SERVER_NAME]: entry,\n };\n writeJson(tree, filePath, config);\n};\n\n/**\n * Configure the Nx Plugin for AWS MCP server across the project-level config locations\n * used by common coding agents, so agents working in the workspace can use it to scaffold\n * AWS projects with the Nx Plugin for AWS.\n *\n * Existing servers and unrelated config in each file are preserved.\n */\nexport const configureMcpServers = (tree: Tree) => {\n // Agents using the `mcpServers` config shape (Claude Code, Cursor, Kiro, Gemini CLI)\n const mcpServersFiles = [\n '.mcp.json', // Claude Code\n '.cursor/mcp.json', // Cursor\n '.kiro/settings/mcp.json', // Kiro\n '.gemini/settings.json', // Gemini CLI\n ];\n for (const filePath of mcpServersFiles) {\n mergeJsonMcpConfig(tree, filePath, 'mcpServers', stdioServerEntry());\n }\n\n // GitHub Copilot uses the `servers` key with an explicit `type`\n mergeJsonMcpConfig(tree, '.vscode/mcp.json', 'servers', {\n type: 'stdio',\n ...stdioServerEntry(),\n });\n\n // OpenAI Codex CLI uses TOML under the `mcp_servers` table\n const codexConfig = '.codex/config.toml';\n if (!tree.exists(codexConfig)) {\n tree.write(codexConfig, '');\n }\n updateToml(tree, codexConfig, (prev) => ({\n ...prev,\n mcp_servers: {\n ...(prev.mcp_servers as object),\n [NX_PLUGIN_MCP_SERVER_NAME]: {\n command: NX_PLUGIN_MCP_SERVER_COMMAND,\n args: NX_PLUGIN_MCP_SERVER_ARGS,\n },\n },\n }));\n};\n"],"names":["readJson","writeJson","updateToml","NX_PLUGIN_MCP_SERVER_NAME","NX_PLUGIN_MCP_SERVER_COMMAND","NX_PLUGIN_MCP_PACKAGE_NAME","NX_PLUGIN_MCP_SERVER_ARGS","stdioServerEntry","command","args","mergeJsonMcpConfig","tree","filePath","key","entry","config","exists","configureMcpServ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EAAE;oBAC3BK,SAASJ;oBACTK,MAAMH;gBACR;YACF;QACF,CAAA;AACF,EAAE"}
@@ -3,7 +3,7 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { type Tree } from '@nx/devkit';
6
- import { type NxGeneratorInfo } from './nx';
6
+ import { type NxGeneratorInfo } from './nx.js';
7
7
  export declare const METRIC_ID = "uksb-4wk0bqpg5s";
8
8
  export declare const METRICS_ASPECT_FILE_PATH: string;
9
9
  export declare const TERRAFORM_METRICS_FILE_PATH: string;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/metrics.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { joinPathFragments, type Tree } from '@nx/devkit';\nimport { appendToArrayViaGritQL, applyGritQL, captureAllGritQL } from './ast';\nimport { formatFilesInSubtree } from './format';\nimport { getPackageVersion, type NxGeneratorInfo } from './nx';\nimport {\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n SHARED_TERRAFORM_DIR,\n} from './shared-constructs-constants';\n\n// Used to identify @aws/nx-plugin in AWS metrics\nexport const METRIC_ID = 'uksb-4wk0bqpg5s';\n\n// File in which the MetricsAspect may exist (CDK)\nexport const METRICS_ASPECT_FILE_PATH = joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'core',\n 'app.ts',\n);\n\n// File in which the Terraform metrics CloudFormation stack may exist\nexport const TERRAFORM_METRICS_FILE_PATH = joinPathFragments(\n PACKAGES_DIR,\n SHARED_TERRAFORM_DIR,\n 'src',\n 'metrics',\n 'metrics.tf',\n);\n\n// GritQL `within` clause to scope matches to the MetricsAspect class body\nconst WITHIN_METRICS_ASPECT =\n '$old <: within `class MetricsAspect implements $_ { $_ }`';\n\n// Strip the surrounding quotes from a captured string literal (eg 'g1' or \"g1\")\nconst unquote = (literal: string): string => literal.slice(1, -1);\n\n// Extracts the existing metric tags from the CDK MetricsAspect tags array\nconst readCdkMetricTags = async (tree: Tree): Promise<string[]> =>\n (\n await captureAllGritQL(\n tree,\n METRICS_ASPECT_FILE_PATH,\n `\\`$tag\\` where { $tag <: string(), $tag <: within \\`const tags: string[] = $_\\` }`,\n )\n ).map(unquote);\n\n// Extracts the existing metric tags from the Terraform metric_tags array\nconst readTerraformMetricTags = async (tree: Tree): Promise<string[]> =>\n (\n await captureAllGritQL(\n tree,\n TERRAFORM_METRICS_FILE_PATH,\n '`\"$tag\"` where { $tag <: within `metric_tags = $_` }',\n )\n ).map(unquote);\n\n/**\n * Instruments metrics by updating the MetricsAspect in common/constructs/src/core/app.ts if the file exists,\n * and/or updating the Terraform metrics CloudFormation stack if it exists.\n *\n * Both files are converged to the same tag set (the union of tags already\n * present in either file plus the incoming generators). This keeps the tag set\n * deterministic regardless of the order in which metrics files are created\n * across a multi-generator run, so re-running the same set of generators does\n * not grow the tags.\n */\nexport const addGeneratorMetricsIfApplicable = async (\n tree: Tree,\n generatorInfo: NxGeneratorInfo[],\n) => {\n const cdkExists = tree.exists(METRICS_ASPECT_FILE_PATH);\n const terraformExists = tree.exists(TERRAFORM_METRICS_FILE_PATH);\n\n if (!cdkExists && !terraformExists) {\n return;\n }\n\n // Converge both files to the union of all known tags so the set is stable\n // regardless of when each metrics file was created.\n const tags = [\n ...new Set([\n ...(await readCdkMetricTags(tree)),\n ...(await readTerraformMetricTags(tree)),\n ...generatorInfo.map((info) => info.metric),\n ]),\n ];\n\n if (cdkExists) {\n await updateCdkMetrics(tree, tags);\n }\n\n if (terraformExists) {\n await updateTerraformMetrics(tree, tags);\n }\n};\n\n/**\n * Updates the CDK MetricsAspect with the metric id, version and tags\n */\nconst updateCdkMetrics = async (tree: Tree, tags: string[]) => {\n // Update the id\n await applyGritQL(\n tree,\n METRICS_ASPECT_FILE_PATH,\n `\\`const id = $old\\` => \\`const id = '${METRIC_ID}'\\`` +\n ` where { ${WITHIN_METRICS_ASPECT} }`,\n );\n\n // Update the version\n await applyGritQL(\n tree,\n METRICS_ASPECT_FILE_PATH,\n `\\`const version = $old\\` => \\`const version = '${getPackageVersion()}'\\`` +\n ` where { ${WITHIN_METRICS_ASPECT} }`,\n );\n\n // Add each tag, leaving existing tags in place to keep re-runs stable\n for (const tag of tags) {\n await applyGritQL(\n tree,\n METRICS_ASPECT_FILE_PATH,\n `\\`const tags: string[] = $old\\`` +\n ` where { ${WITHIN_METRICS_ASPECT},` +\n ` if ($old <: \\`[]\\`) { $old => \\`['${tag}']\\` }` +\n ` else { $old <: \\`[$items]\\` where { $items += \\`, '${tag}'\\` } },` +\n ` $old <: not contains \\`'${tag}'\\` }`,\n );\n }\n\n await formatFilesInSubtree(tree, METRICS_ASPECT_FILE_PATH);\n};\n\n/**\n * Updates the Terraform metrics CloudFormation stack with the metric id, version and tags\n */\nconst updateTerraformMetrics = async (tree: Tree, tags: string[]) => {\n // Update metric_id\n await applyGritQL(\n tree,\n TERRAFORM_METRICS_FILE_PATH,\n `\\`metric_id = $old\\` => \\`metric_id = \"${METRIC_ID}\"\\``,\n );\n\n // Update metric_version\n await applyGritQL(\n tree,\n TERRAFORM_METRICS_FILE_PATH,\n `\\`metric_version = $old\\` => \\`metric_version = \"${getPackageVersion()}\"\\``,\n );\n\n // Add each tag, leaving existing tags in place to keep re-runs stable\n for (const tag of tags) {\n await appendToArrayViaGritQL(\n tree,\n TERRAFORM_METRICS_FILE_PATH,\n 'metric_tags =',\n `\"${tag}\"`,\n );\n }\n};\n"],"names":["joinPathFragments","appendToArrayViaGritQL","applyGritQL","captureAllGritQL","formatFilesInSubtree","getPackageVersion","PACKAGES_DIR","SHARED_CONSTRUCTS_DIR","SHARED_TERRAFORM_DIR","METRIC_ID","METRICS_ASPECT_FILE_PATH","TERRAFORM_METRICS_FILE_PATH","WITHIN_METRICS_ASPECT","unquote","literal","slice","readCdkMetricTags","tree","map","readTerraformMetricTags","addGeneratorMetricsIfApplicable","generatorInfo","cdkExists","exists","terraformExists","tags","Set","info","metric","updateCdkMetrics","updateTerraformMetrics","tag"],"mappings":"AAAA;;;CAGC,GACD,SAASA,iBAAiB,QAAmB,aAAa;AAC1D,SAASC,sBAAsB,EAAEC,WAAW,EAAEC,gBAAgB,QAAQ,WAAQ;AAC9E,SAASC,oBAAoB,QAAQ,cAAW;AAChD,SAASC,iBAAiB,QAA8B,UAAO;AAC/D,SACEC,YAAY,EACZC,qBAAqB,EACrBC,oBAAoB,QACf,mCAAgC;AAEvC,iDAAiD;AACjD,OAAO,MAAMC,YAAY,kBAAkB;AAE3C,kDAAkD;AAClD,OAAO,MAAMC,2BAA2BV,kBACtCM,cACAC,uBACA,OACA,QACA,UACA;AAEF,qEAAqE;AACrE,OAAO,MAAMI,8BAA8BX,kBACzCM,cACAE,sBACA,OACA,WACA,cACA;AAEF,0EAA0E;AAC1E,MAAMI,wBACJ;AAEF,gFAAgF;AAChF,MAAMC,UAAU,CAACC,UAA4BA,QAAQC,KAAK,CAAC,GAAG,CAAC;AAE/D,0EAA0E;AAC1E,MAAMC,oBAAoB,OAAOC,OAC/B,AACE,CAAA,MAAMd,iBACJc,MACAP,0BACA,CAAC,iFAAiF,CAAC,CACrF,EACAQ,GAAG,CAACL;AAER,yEAAyE;AACzE,MAAMM,0BAA0B,OAAOF,OACrC,AACE,CAAA,MAAMd,iBACJc,MACAN,6BACA,uDACF,EACAO,GAAG,CAACL;AAER;;;;;;;;;CASC,GACD,OAAO,MAAMO,kCAAkC,OAC7CH,MACAI;IAEA,MAAMC,YAAYL,KAAKM,MAAM,CAACb;IAC9B,MAAMc,kBAAkBP,KAAKM,MAAM,CAACZ;IAEpC,IAAI,CAACW,aAAa,CAACE,iBAAiB;QAClC;IACF;IAEA,0EAA0E;IAC1E,oDAAoD;IACpD,MAAMC,OAAO;WACR,IAAIC,IAAI;eACL,MAAMV,kBAAkBC;eACxB,MAAME,wBAAwBF;eAC/BI,cAAcH,GAAG,CAAC,CAACS,OAASA,KAAKC,M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Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { joinPathFragments, type Tree } from '@nx/devkit';\nimport {\n appendToArrayViaGritQL,\n applyGritQL,\n captureAllGritQL,\n} from './ast.js';\nimport { formatFilesInSubtree } from './format.js';\nimport { getPackageVersion, type NxGeneratorInfo } from './nx.js';\nimport {\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n SHARED_TERRAFORM_DIR,\n} from './shared-constructs-constants.js';\n\n// Used to identify @aws/nx-plugin in AWS metrics\nexport const METRIC_ID = 'uksb-4wk0bqpg5s';\n\n// File in which the MetricsAspect may exist (CDK)\nexport const METRICS_ASPECT_FILE_PATH = joinPathFragments(\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n 'src',\n 'core',\n 'app.ts',\n);\n\n// File in which the Terraform metrics CloudFormation stack may exist\nexport const TERRAFORM_METRICS_FILE_PATH = joinPathFragments(\n PACKAGES_DIR,\n SHARED_TERRAFORM_DIR,\n 'src',\n 'metrics',\n 'metrics.tf',\n);\n\n// GritQL `within` clause to scope matches to the MetricsAspect class body\nconst WITHIN_METRICS_ASPECT =\n '$old <: within `class MetricsAspect implements $_ { $_ }`';\n\n// Strip the surrounding quotes from a captured string literal (eg 'g1' or \"g1\")\nconst unquote = (literal: string): string => literal.slice(1, -1);\n\n// Extracts the existing metric tags from the CDK MetricsAspect tags array\nconst readCdkMetricTags = async (tree: Tree): Promise<string[]> =>\n (\n await captureAllGritQL(\n tree,\n METRICS_ASPECT_FILE_PATH,\n `\\`$tag\\` where { $tag <: string(), $tag <: within \\`const tags: string[] = $_\\` }`,\n )\n ).map(unquote);\n\n// Extracts the existing metric tags from the Terraform metric_tags array\nconst readTerraformMetricTags = async (tree: Tree): Promise<string[]> =>\n (\n await captureAllGritQL(\n tree,\n TERRAFORM_METRICS_FILE_PATH,\n '`\"$tag\"` where { $tag <: within `metric_tags = $_` }',\n )\n ).map(unquote);\n\n/**\n * Instruments metrics by updating the MetricsAspect in common/constructs/src/core/app.ts if the file exists,\n * and/or updating the Terraform metrics CloudFormation stack if it exists.\n *\n * Both files are converged to the same tag set (the union of tags already\n * present in either file plus the incoming generators). This keeps the tag set\n * deterministic regardless of the order in which metrics files are created\n * across a multi-generator run, so re-running the same set of generators does\n * not grow the tags.\n */\nexport const addGeneratorMetricsIfApplicable = async (\n tree: Tree,\n generatorInfo: NxGeneratorInfo[],\n) => {\n const cdkExists = tree.exists(METRICS_ASPECT_FILE_PATH);\n const terraformExists = tree.exists(TERRAFORM_METRICS_FILE_PATH);\n\n if (!cdkExists && !terraformExists) {\n return;\n }\n\n // Converge both files to the union of all known tags so the set is stable\n // regardless of when each metrics file was created.\n const tags = [\n ...new Set([\n ...(await readCdkMetricTags(tree)),\n ...(await readTerraformMetricTags(tree)),\n ...generatorInfo.map((info) => info.metric),\n ]),\n ];\n\n if (cdkExists) {\n await updateCdkMetrics(tree, tags);\n }\n\n if (terraformExists) {\n await updateTerraformMetrics(tree, tags);\n }\n};\n\n/**\n * Updates the CDK MetricsAspect with the metric id, version and tags\n */\nconst updateCdkMetrics = async (tree: Tree, tags: string[]) => {\n // Update the id\n await applyGritQL(\n tree,\n METRICS_ASPECT_FILE_PATH,\n `\\`const id = $old\\` => \\`const id = '${METRIC_ID}'\\`` +\n ` where { ${WITHIN_METRICS_ASPECT} }`,\n );\n\n // Update the version\n await applyGritQL(\n tree,\n METRICS_ASPECT_FILE_PATH,\n `\\`const version = $old\\` => \\`const version = '${getPackageVersion()}'\\`` +\n ` where { ${WITHIN_METRICS_ASPECT} }`,\n );\n\n // Add each tag, leaving existing tags in place to keep re-runs stable\n for (const tag of tags) {\n await applyGritQL(\n tree,\n METRICS_ASPECT_FILE_PATH,\n `\\`const tags: string[] = $old\\`` +\n ` where { ${WITHIN_METRICS_ASPECT},` +\n ` if ($old <: \\`[]\\`) { $old => \\`['${tag}']\\` }` +\n ` else { $old <: \\`[$items]\\` where { $items += \\`, '${tag}'\\` } },` +\n ` $old <: not contains \\`'${tag}'\\` }`,\n );\n }\n\n await formatFilesInSubtree(tree, METRICS_ASPECT_FILE_PATH);\n};\n\n/**\n * Updates the Terraform metrics CloudFormation stack with the metric id, version and tags\n */\nconst updateTerraformMetrics = async (tree: Tree, tags: string[]) => {\n // Update metric_id\n await applyGritQL(\n tree,\n TERRAFORM_METRICS_FILE_PATH,\n `\\`metric_id = $old\\` => \\`metric_id = \"${METRIC_ID}\"\\``,\n );\n\n // Update metric_version\n await applyGritQL(\n tree,\n TERRAFORM_METRICS_FILE_PATH,\n `\\`metric_version = $old\\` => \\`metric_version = \"${getPackageVersion()}\"\\``,\n );\n\n // Add each tag, leaving existing tags in place to keep re-runs stable\n for (const tag of tags) {\n await appendToArrayViaGritQL(\n tree,\n TERRAFORM_METRICS_FILE_PATH,\n 'metric_tags =',\n `\"${tag}\"`,\n );\n }\n};\n"],"names":["joinPathFragments","appendToArrayViaGritQL","applyGritQL","captureAllGritQL","formatFilesInSubtree","getPackageVersion","PACKAGES_DIR","SHARED_CONSTRUCTS_DIR","SHARED_TERRAFORM_DIR","METRIC_ID","METRICS_ASPECT_FILE_PATH","TERRAFORM_METRICS_FILE_PATH","WITHIN_METRICS_ASPECT","unquote","literal","slice","readCdkMetricTags","tree","map","readTerraformMetricTags","addGeneratorMetricsIfApplicable","generatorInfo","cdkExists","exists","terraformExists","tags","Set","info","metric","updateCdkMetrics","updateTerraformMetrics","tag"],"mappings":"AAAA;;;CAGC,GACD,SAASA,iBAAiB,QAAmB,aAAa;AAC1D,SACEC,sBAAsB,EACtBC,WAAW,EACXC,gBAAgB,QACX,WAAW;AAClB,SAASC,oBAAoB,QAAQ,cAAc;AACnD,SAASC,iBAAiB,QAA8B,UAAU;AAClE,SACEC,YAAY,EACZC,qBAAqB,EACrBC,oBAAoB,QACf,mCAAmC;AAE1C,iDAAiD;AACjD,OAAO,MAAMC,YAAY,kBAAkB;AAE3C,kDAAkD;AAClD,OAAO,MAAMC,2BAA2BV,kBACt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AAC,GACxE,CAAC,SAAS,EAAEO,sBAAsB,EAAE,CAAC;IAGzC,sEAAsE;IACtE,KAAK,MAAMmB,OAAON,KAAM;QACtB,MAAMvB,YACJe,MACAP,0BACA,CAAC,+BAA+B,CAAC,GAC/B,CAAC,SAAS,EAAEE,sBAAsB,CAAC,CAAC,GACpC,CAAC,mCAAmC,EAAEmB,IAAI,MAAM,CAAC,GACjD,CAAC,oDAAoD,EAAEA,IAAI,QAAQ,CAAC,GACpE,CAAC,yBAAyB,EAAEA,IAAI,KAAK,CAAC;IAE5C;IAEA,MAAM3B,qBAAqBa,MAAMP;AACnC;AAEA;;CAEC,GACD,MAAMoB,yBAAyB,OAAOb,MAAYQ;IAChD,mBAAmB;IACnB,MAAMvB,YACJe,MACAN,6BACA,CAAC,uCAAuC,EAAEF,UAAU,GAAG,CAAC;IAG1D,wBAAwB;IACxB,MAAMP,YACJe,MACAN,6BACA,CAAC,iDAAiD,EAAEN,oBAAoB,GAAG,CAAC;IAG9E,sEAAsE;IACtE,KAAK,MAAM0B,OAAON,KAAM;QACtB,MAAMxB,uBACJgB,MACAN,6BACA,iBACA,CAAC,CAAC,EAAEoB,IAAI,CAAC,CAAC;IAEd;AACF"}
@@ -2,7 +2,7 @@
2
2
  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- import type { MigrationsJson } from './migration-versions';
5
+ import type { MigrationsJson } from './migration-versions.js';
6
6
  /**
7
7
  * `migrations.json` is assembled from the plugin's source rather than committed,
8
8
  * so two PRs each adding a migration touch disjoint files and never conflict on
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/migration-manifest.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { MigrationsJson } from './migration-versions';\nimport {\n isValidVersion,\n LATEST_MIGRATIONS_DIR,\n migrationKey,\n} from './migration-versions';\nimport { sortObjectKeys } from './object';\n\n/**\n * `migrations.json` is assembled from the plugin's source rather than committed,\n * so two PRs each adding a migration touch disjoint files and never conflict on\n * a shared manifest.\n *\n * The pieces it is assembled from:\n * - one folder per migration under `src/migrations/<dir>/<name>/`, where `<dir>`\n * is `latest` until a release claims it and `v<version>` after — the folder\n * carries a `metadata.json` (its description) beside the code, and its files\n * discriminate the kind: a `migration.ts` makes it deterministic, a `prompt.md`\n * agentic, both hybrid;\n * - `packageJsonUpdates.json`, the nx bumps the weekly update maintains, kept in\n * its own file so that churn never shares an edit with a migration PR;\n * - the version sync entry, a fixed `everyMigration` codemod that runs on every\n * upgrade and so has no folder.\n *\n * The assembled manifest is unversioned — release-time stamping resolves versions\n * (see `migration-versions.ts`).\n */\n\n/** JSON schema the manifest declares, matching what nx expects. */\nexport const MIGRATIONS_JSON_SCHEMA = 'http://json-schema.org/schema';\n\n/** Key the version sync migration is registered under. */\nexport const SYNC_VENDED_MIGRATION_KEY = 'sync-vended-versions';\n\n/**\n * The version sync migration entry. Committed as code rather than a folder: it\n * carries no release-specific registration and must run on every upgrade, so it\n * is fixed and can't conflict.\n */\nexport const syncVendedMigrationEntry = (): NonNullable<\n MigrationsJson['generators']\n>[string] => ({\n description:\n 'Sync vended dependency versions and the tracked plugin version to those vended by this release',\n implementation: './src/utils/version-upgrade-migration/migration',\n everyMigration: true,\n});\n\n/** A migration folder discovered under `src/migrations`. */\nexport interface DiscoveredMigration {\n /** Folder grouping the migration by release: `latest` or `v<version>`. */\n dir: string;\n /** Migration folder name. */\n name: string;\n /** Description read from the folder's `metadata.json`. */\n description: string;\n /** A `migration.ts` is present, so the migration has a codemod. */\n hasImplementation: boolean;\n /** A `prompt.md` is present, so the migration hands off to an agent. */\n hasPrompt: boolean;\n}\n\n/** Registration for a single discovered migration folder. */\nconst migrationEntry = (\n migration: DiscoveredMigration,\n): NonNullable<MigrationsJson['generators']>[string] => {\n const path = `./src/migrations/${migration.dir}/${migration.name}`;\n return {\n // A migration in a `v<version>` folder has already been claimed by that\n // release; its version is the folder. One in `latest` is left for stamping.\n ...(migration.dir !== LATEST_MIGRATIONS_DIR &&\n isValidVersion(migration.dir.replace(/^v/, ''))\n ? { version: migration.dir.replace(/^v/, '') }\n : {}),\n description: migration.description,\n ...(migration.hasImplementation\n ? { implementation: `${path}/migration` }\n : {}),\n ...(migration.hasPrompt ? { prompt: `${path}/prompt.md` } : {}),\n };\n};\n\n/**\n * Assemble the plugin's `migrations.json` from its source pieces: the discovered\n * migration folders, the version sync entry, and the nx `packageJsonUpdates`.\n *\n * Deterministic — keys are sorted — so regenerating always yields the same file.\n *\n * @param pluginName the plugin package name the manifest is for\n * @param migrations migration folders discovered under `src/migrations`\n * @param packageJsonUpdates parsed `packageJsonUpdates.json`, if present\n */\nexport const assembleMigrations = (\n pluginName: string,\n migrations: DiscoveredMigration[],\n packageJsonUpdates?: MigrationsJson['packageJsonUpdates'],\n): MigrationsJson => ({\n $schema: MIGRATIONS_JSON_SCHEMA,\n name: pluginName,\n generators: sortObjectKeys({\n [SYNC_VENDED_MIGRATION_KEY]: syncVendedMigrationEntry(),\n ...Object.fromEntries(\n migrations.map((migration) => [\n migrationKey(migration.dir, migration.name),\n migrationEntry(migration),\n ]),\n ),\n }),\n ...(packageJsonUpdates && Object.keys(packageJsonUpdates).length > 0\n ? { packageJsonUpdates }\n : {}),\n});\n"],"names":["isValidVersion","LATEST_MIGRATIONS_DIR","migrationKey","sortObjectKeys","MIGRATIONS_JSON_SCHEMA","SYNC_VENDED_MIGRATION_KEY","syncVendedMigrationEntry","description","implementation","everyMigration","migrationEntry","migration","path","dir","name","replace","version","hasImplementation","hasPrompt","prompt","assembleMigrations","pluginName","migrations","packageJsonUpdates","$schema","generators","Object","fromEntries","map","keys","length"],"mappings":"AAAA;;;CAGC,GAED,SACEA,cAAc,EACdC,qBAAqB,EACrBC,YAAY,QACP,0BAAuB;AAC9B,SAASC,cAAc,QAAQ,cAAW;AAE1C;;;;;;;;;;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AA,EAAG"}
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/migration-manifest.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { MigrationsJson } from './migration-versions.js';\nimport {\n isValidVersion,\n LATEST_MIGRATIONS_DIR,\n migrationKey,\n} from './migration-versions.js';\nimport { sortObjectKeys } from './object.js';\n\n/**\n * `migrations.json` is assembled from the plugin's source rather than committed,\n * so two PRs each adding a migration touch disjoint files and never conflict on\n * a shared manifest.\n *\n * The pieces it is assembled from:\n * - one folder per migration under `src/migrations/<dir>/<name>/`, where `<dir>`\n * is `latest` until a release claims it and `v<version>` after — the folder\n * carries a `metadata.json` (its description) beside the code, and its files\n * discriminate the kind: a `migration.ts` makes it deterministic, a `prompt.md`\n * agentic, both hybrid;\n * - `packageJsonUpdates.json`, the nx bumps the weekly update maintains, kept in\n * its own file so that churn never shares an edit with a migration PR;\n * - the version sync entry, a fixed `everyMigration` codemod that runs on every\n * upgrade and so has no folder.\n *\n * The assembled manifest is unversioned — release-time stamping resolves versions\n * (see `migration-versions.ts`).\n */\n\n/** JSON schema the manifest declares, matching what nx expects. */\nexport const MIGRATIONS_JSON_SCHEMA = 'http://json-schema.org/schema';\n\n/** Key the version sync migration is registered under. */\nexport const SYNC_VENDED_MIGRATION_KEY = 'sync-vended-versions';\n\n/**\n * The version sync migration entry. Committed as code rather than a folder: it\n * carries no release-specific registration and must run on every upgrade, so it\n * is fixed and can't conflict.\n */\nexport const syncVendedMigrationEntry = (): NonNullable<\n MigrationsJson['generators']\n>[string] => ({\n description:\n 'Sync vended dependency versions and the tracked plugin version to those vended by this release',\n implementation: './src/utils/version-upgrade-migration/migration',\n everyMigration: true,\n});\n\n/** A migration folder discovered under `src/migrations`. */\nexport interface DiscoveredMigration {\n /** Folder grouping the migration by release: `latest` or `v<version>`. */\n dir: string;\n /** Migration folder name. */\n name: string;\n /** Description read from the folder's `metadata.json`. */\n description: string;\n /** A `migration.ts` is present, so the migration has a codemod. */\n hasImplementation: boolean;\n /** A `prompt.md` is present, so the migration hands off to an agent. */\n hasPrompt: boolean;\n}\n\n/** Registration for a single discovered migration folder. */\nconst migrationEntry = (\n migration: DiscoveredMigration,\n): NonNullable<MigrationsJson['generators']>[string] => {\n const path = `./src/migrations/${migration.dir}/${migration.name}`;\n return {\n // A migration in a `v<version>` folder has already been claimed by that\n // release; its version is the folder. One in `latest` is left for stamping.\n ...(migration.dir !== LATEST_MIGRATIONS_DIR &&\n isValidVersion(migration.dir.replace(/^v/, ''))\n ? { version: migration.dir.replace(/^v/, '') }\n : {}),\n description: migration.description,\n ...(migration.hasImplementation\n ? { implementation: `${path}/migration` }\n : {}),\n ...(migration.hasPrompt ? { prompt: `${path}/prompt.md` } : {}),\n };\n};\n\n/**\n * Assemble the plugin's `migrations.json` from its source pieces: the discovered\n * migration folders, the version sync entry, and the nx `packageJsonUpdates`.\n *\n * Deterministic — keys are sorted — so regenerating always yields the same file.\n *\n * @param pluginName the plugin package name the manifest is for\n * @param migrations migration folders discovered under `src/migrations`\n * @param packageJsonUpdates parsed `packageJsonUpdates.json`, if present\n */\nexport const assembleMigrations = (\n pluginName: string,\n migrations: DiscoveredMigration[],\n packageJsonUpdates?: MigrationsJson['packageJsonUpdates'],\n): MigrationsJson => ({\n $schema: MIGRATIONS_JSON_SCHEMA,\n name: pluginName,\n generators: sortObjectKeys({\n [SYNC_VENDED_MIGRATION_KEY]: syncVendedMigrationEntry(),\n ...Object.fromEntries(\n migrations.map((migration) => [\n migrationKey(migration.dir, migration.name),\n migrationEntry(migration),\n ]),\n ),\n }),\n ...(packageJsonUpdates && Object.keys(packageJsonUpdates).length > 0\n ? { packageJsonUpdates }\n : {}),\n});\n"],"names":["isValidVersion","LATEST_MIGRATIONS_DIR","migrationKey","sortObjectKeys","MIGRATIONS_JSON_SCHEMA","SYNC_VENDED_MIGRATION_KEY","syncVendedMigrationEntry","description","implementation","everyMigration","migrationEntry","migration","path","dir","name","replace","version","hasImplementation","hasPrompt","prompt","assembleMigrations","pluginName","migrations","packageJsonUpdates","$schema","generators","Object","fromEntries","map","keys","length"],"mappings":"AAAA;;;CAGC,GAED,SACEA,cAAc,EACdC,qBAAqB,EACrBC,YAAY,QACP,0BAA0B;AACjC,SAASC,cAAc,QAAQ,cAAc;AAE7C;;;;;;;;;;;;;;;;;;CAkBC,GAED,iEAAiE,GACjE,OAAO,MAAMC,yBAAyB,gCAAgC;AAEtE,wDAAwD,GACxD,OAAO,MAAMC,4BAA4B,uBAAuB;AAEhE;;;;CAIC,GACD,OAAO,MAAMC,2BAA2B,IAE1B,CAAA;QACZC,aACE;QACFC,gBAAgB;QAChBC,gBAAgB;IAClB,CAAA,EAAG;AAgBH,2DAA2D,GAC3D,MAAMC,iBAAiB,CACrBC;IAEA,MAAMC,OAAO,CAAC,iBAAiB,EAAED,UAAUE,GAAG,CAAC,CAAC,EAAEF,UAAUG,IAAI,EAAE;IAClE,OAAO;QACL,wEAAwE;QACxE,4EAA4E;QAC5E,GAAIH,UAAUE,GAAG,KAAKZ,yBACtBD,eAAeW,UAAUE,GAAG,CAACE,OAAO,CAAC,MAAM,OACvC;YAAEC,SAASL,UAAUE,GAAG,CAACE,OAAO,CAAC,MAAM;QAAI,IAC3C,CAAC,CAAC;QACNR,aAAaI,UAAUJ,WAAW;QAClC,GAAII,UAAUM,iBAAiB,GAC3B;YAAET,gBAAgB,GAAGI,KAAK,UAAU,CAAC;QAAC,IACtC,CAAC,CAAC;QACN,GAAID,UAAUO,SAAS,GAAG;YAAEC,QAAQ,GAAGP,KAAK,UAAU,CAAC;QAAC,IAAI,CAAC,CAAC;IAChE;AACF;AAEA;;;;;;;;;CASC,GACD,OAAO,MAAMQ,qBAAqB,CAChCC,YACAC,YACAC,qBACoB,CAAA;QACpBC,SAASpB;QACTU,MAAMO;QACNI,YAAYtB,eAAe;YACzB,CAACE,0BAA0B,EAAEC;YAC7B,GAAGoB,OAAOC,WAAW,CACnBL,WAAWM,GAAG,CAAC,CAACjB,YAAc;oBAC5BT,aAAaS,UAAUE,GAAG,EAAEF,UAAUG,IAAI;oBAC1CJ,eAAeC;iBAChB,EACF;QACH;QACA,GAAIY,sBAAsBG,OAAOG,IAAI,CAACN,oBAAoBO,MAAM,GAAG,IAC/D;YAAEP;QAAmB,IACrB,CAAC,CAAC;IACR,CAAA,EAAG"}
package/src/utils/nx.d.ts CHANGED
@@ -3,9 +3,9 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { type ProjectConfiguration, type TargetConfiguration, type TargetDefaultValue, type Tree } from '@nx/devkit';
6
- export type { GeneratorInfo, NxGeneratorInfo } from './generators';
7
- export { buildGeneratorInfoList } from './generators';
8
- import { type GeneratorInfo } from './generators';
6
+ export type { GeneratorInfo, NxGeneratorInfo } from './generators.js';
7
+ export { buildGeneratorInfoList } from './generators.js';
8
+ import { type GeneratorInfo } from './generators.js';
9
9
  /**
10
10
  * List Nx Plugin for AWS generators
11
11
  * @param includeHidden include hidden generators (default false)
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/nx.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n getProjects,\n type ProjectConfiguration,\n readJson,\n readProjectConfiguration,\n type TargetConfiguration,\n type TargetDefaultValue,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport * as path from 'path';\nimport PackageJson from '../../package.json' with { type: 'json' };\nimport { NX_PLUGIN_MCP_PACKAGE_NAME } from './mcp';\nimport { toSnakeCase } from './names';\nimport { getNpmScope, getNpmScopePrefix } from './npm-scope';\n\nexport type { GeneratorInfo, NxGeneratorInfo } from './generators';\nexport { buildGeneratorInfoList } from './generators';\n\nimport { buildGeneratorInfoList, type GeneratorInfo } from './generators';\n\nconst GENERATORS = buildGeneratorInfoList(\n path.resolve(import.meta.dirname, '..', '..'),\n);\n\n/**\n * List Nx Plugin for AWS generators\n * @param includeHidden include hidden generators (default false)\n */\nexport const listGenerators = (includeHidden = false) =>\n GENERATORS.filter((g) => includeHidden || !g.hidden);\n\n/**\n * Return generator information. Call this from a generator method with import.meta.filename\n */\nexport const getGeneratorInfo = (generatorFileName: string): GeneratorInfo => {\n const { dir, name } = path.parse(path.resolve(generatorFileName));\n const resolvedFactoryPath = path.join(dir, name);\n return GENERATORS.find(\n (generatorInfo) =>\n generatorInfo.resolvedFactoryPath === resolvedFactoryPath,\n );\n};\n\nexport const getPackageVersion = () => {\n return PackageJson.version;\n};\n\n/**\n * True inside the plugin's own monorepo, where the plugin is the source rather\n * than a dependency.\n */\nexport const isNxPluginForAwsWorkspace = (tree: Tree): boolean => {\n const rootPackageJson = tree.exists('package.json')\n ? readJson(tree, 'package.json')\n : undefined;\n return rootPackageJson?.name === '@aws/nx-plugin-source';\n};\n\n/**\n * The `@aws/nx-plugin` devDependency entry for a workspace the plugin generates\n * into, keyed to the version the running generators come from. Empty inside the\n * plugin's own monorepo.\n */\nexport const nxPluginSelfDependency = (tree: Tree): Record<string, string> =>\n isNxPluginForAwsWorkspace(tree)\n ? {}\n : { [PackageJson.name]: `^${PackageJson.version}` };\n\n/**\n * The `@aws/nx-plugin-mcp` devDependency entry, keyed to the running generators'\n * version — the two packages are released in lockstep. Declaring it pins the MCP\n * server the vended config runs in the workspace's lockfile, so upgrading it\n * upgrades the server. Empty inside the plugin's own monorepo.\n */\nexport const nxPluginMcpDependency = (tree: Tree): Record<string, string> =>\n isNxPluginForAwsWorkspace(tree)\n ? {}\n : { [NX_PLUGIN_MCP_PACKAGE_NAME]: `^${PackageJson.version}` };\n\n/**\n * Read a project configuration where the project name may not be fully qualified (ie may omit the scope prefix)\n */\nexport const readProjectConfigurationUnqualified = (\n tree: Tree,\n projectName: string,\n) => {\n try {\n return readProjectConfiguration(tree, projectName);\n } catch (e) {\n // Attempt to find the project without the scope\n const project = [...getProjects(tree).values()].find(\n (p) =>\n p.name &&\n (p.name === `${getNpmScopePrefix(tree)}${projectName}` || // TypeScript fully-qualified name\n p.name === `${toSnakeCase(getNpmScope(tree))}.${projectName}`), // Python fully-qualified name\n );\n if (project) {\n return project;\n }\n throw e;\n }\n};\n\n/**\n * Returns whether a project with the given name already exists in the workspace.\n * The project name may be unqualified (ie may omit the scope prefix).\n */\nexport const projectExists = (tree: Tree, projectName: string): boolean => {\n try {\n readProjectConfigurationUnqualified(tree, projectName);\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Add metadata about the generator that generated the project to the project.json\n */\nexport const addGeneratorMetadata = (\n tree: Tree,\n projectName: string,\n info: { id: string },\n additionalMetadata?: { [key: string]: any },\n) => {\n const config = readProjectConfigurationUnqualified(tree, projectName);\n const metadata = {\n ...config?.metadata,\n generator: info.id,\n ...additionalMetadata,\n };\n // Skip the write when nothing changed so re-running doesn't reserialize\n // project.json. metadata is plain JSON built in a fixed key order, so a\n // stringify comparison is exact here.\n if (JSON.stringify(config?.metadata) === JSON.stringify(metadata)) {\n return;\n }\n // Place metadata immediately before targets so the serialized key order is\n // identical whether or not metadata already existed (matching the order Nx\n // normalizes a read config to), keeping the change a pure metadata insert.\n const { targets, ...rest } = config;\n updateProjectConfiguration(tree, config.name, {\n ...rest,\n metadata: metadata as any,\n ...(targets ? { targets } : {}),\n });\n};\n\n/**\n * Represents a component entry in project metadata\n */\nexport interface ComponentMetadata {\n readonly generator: string;\n readonly name?: string;\n /**\n * What this entry wires up. For a connection that is the target — the thing\n * being connected to — paired with `sourcePath` below.\n */\n readonly path?: string;\n /**\n * The component the connection is made *from*, when both ends are components\n * of a project rather than whole projects.\n *\n * A connection records the project it lives on and the target it reaches, which\n * alone can't tell which of several components on that project is wired up.\n * Recorded as a path for the same reason `path` is: it identifies a component\n * within its project without depending on a name that may repeat.\n */\n readonly sourcePath?: string;\n [key: string]: any;\n}\n\n/**\n * Add metadata about the generator that generated the component to the project.json\n *\n * A connection between two components passes the source's path as\n * `additionalMetadata.sourcePath`, so the pair is identifiable rather than just\n * the two projects.\n */\nexport const addComponentGeneratorMetadata = (\n tree: Tree,\n projectName: string,\n info: { id: string },\n componentPath: string,\n componentName?: string,\n additionalMetadata?: { [key: string]: any },\n) => {\n const config = readProjectConfigurationUnqualified(tree, projectName);\n\n const existingComponents = (config?.metadata as any)?.components ?? [];\n const alreadyAdded = existingComponents.filter(\n (c: any) => c.generator === info.id && c.name === componentName,\n );\n\n if (alreadyAdded.length === 0) {\n const componentMetadata: ComponentMetadata = {\n generator: info.id,\n path: componentPath,\n ...(componentName ? { name: componentName } : {}),\n ...additionalMetadata,\n };\n // Place metadata before targets for a stable serialized key order.\n const { targets, ...rest } = config;\n updateProjectConfiguration(tree, config.name, {\n ...rest,\n metadata: {\n ...config?.metadata,\n components: [...existingComponents, componentMetadata],\n } as any,\n ...(targets ? { targets } : {}),\n });\n }\n};\n\n/**\n * Merge a generator's own config into an `nx.json` `targetDefaults` value,\n * preserving whatever the workspace already had. `apply` receives the config to\n * layer onto and returns the merged config (e.g. `(base) => ({ cache: true,\n * ...base })`); it must be idempotent so re-running the generator is a no-op.\n *\n * Nx 23.1 widened each value to either a config object or an ordered array of\n * filtered entries. The plugin only contributes unfiltered (catch-all) config,\n * so the input's shape is preserved: an object (or unset) stays an object;\n * an array keeps the user's filtered entries and `apply` merges into its first\n * unfiltered entry, prepending one as the base if none exists (Nx layers later\n * matches on top, so our catch-all must stay first to not override a filter).\n */\nexport const mergeTargetDefault = (\n value: TargetDefaultValue | undefined,\n apply: (base: Partial<TargetConfiguration>) => Partial<TargetConfiguration>,\n): TargetDefaultValue => {\n if (!Array.isArray(value)) {\n return apply(value ?? {});\n }\n const catchAllIndex = value.findIndex((entry) => entry.filter === undefined);\n if (catchAllIndex === -1) {\n return [apply({}), ...value];\n }\n return value.map((entry, index) =>\n index === catchAllIndex ? apply(entry) : entry,\n );\n};\n\n/**\n * A single entry in an Nx `dependsOn` array.\n * Matches the shape accepted by Nx without requiring a devkit type import.\n */\nexport type TargetDependency =\n | string\n | {\n projects?: string | string[];\n target: string;\n params?: 'ignore' | 'forward';\n };\n\nconst targetDependencyEquals = (a: TargetDependency, b: TargetDependency) => {\n if (typeof a === 'string' || typeof b === 'string') {\n return a === b;\n }\n if (a.target !== b.target || a.params !== b.params) {\n return false;\n }\n const aProjects = Array.isArray(a.projects)\n ? a.projects\n : a.projects !== undefined\n ? [a.projects]\n : [];\n const bProjects = Array.isArray(b.projects)\n ? b.projects\n : b.projects !== undefined\n ? [b.projects]\n : [];\n if (aProjects.length !== bProjects.length) {\n return false;\n }\n return aProjects.every((p, i) => p === bProjects[i]);\n};\n\n// The order target properties are authored in. Nx preserves a target's\n// authored key order when it reads then rewrites an existing project.json,\n// except `options` and `configurations`, which it always moves to the end (in\n// that order). Keeping `options`/`configurations` last here therefore makes a\n// generator's first-run output byte-identical to subsequent runs (idempotency);\n// the remaining keys are ordered to read intuitively.\nconst NX_TARGET_KEY_ORDER = [\n 'executor',\n 'dependsOn',\n 'continuous',\n 'cache',\n 'inputs',\n 'outputs',\n 'metadata',\n 'defaultConfiguration',\n 'options',\n 'configurations',\n];\n\n/**\n * Reorder a target's keys to match Nx's own serialization order. Nx reorders\n * target properties when it rewrites an existing project.json, so applying the\n * same order when first authoring a target keeps generators idempotent.\n */\nexport const normalizeTargetKeyOrder = <T extends object>(target: T): T =>\n Object.fromEntries(\n Object.entries(target as Record<string, unknown>).sort(([a], [b]) => {\n const ai = NX_TARGET_KEY_ORDER.indexOf(a);\n const bi = NX_TARGET_KEY_ORDER.indexOf(b);\n return (\n (ai === -1 ? NX_TARGET_KEY_ORDER.length : ai) -\n (bi === -1 ? NX_TARGET_KEY_ORDER.length : bi)\n );\n }),\n ) as T;\n\n/**\n * Mutate the project to add the dependency to the target if not already present\n * Adds the target if not present.\n *\n * Accepts either a string target name (e.g. `'build'`) or a dependency config\n * object (e.g. `{ projects: ['foo'], target: 'dev' }`). Deduplicates\n * using deep equality so re-running a generator does not grow `dependsOn`.\n */\nexport const addDependencyToTargetIfNotPresent = (\n project: ProjectConfiguration,\n target: string,\n dependency: TargetDependency,\n) => {\n project.targets ??= {};\n project.targets[target] ??= {};\n project.targets[target].dependsOn ??= [];\n const dependsOn = project.targets[target].dependsOn;\n // Leave existing dependencies in place so re-running does not reorder them;\n // only append when the dependency is genuinely absent.\n if (!dependsOn.some((d) => targetDependencyEquals(d, dependency))) {\n dependsOn.push(dependency);\n }\n // Keep key order aligned with Nx's so first run matches subsequent runs.\n project.targets[target] = normalizeTargetKeyOrder(project.targets[target]);\n};\n\n/**\n * Register a component's `<name>-dev` target under the project-level `dev`\n * target, so `nx run <project>:dev` starts every component in the project.\n *\n * Component generators author their own continuous `<name>-dev` runner and call\n * this to aggregate it. Every component added to the project accumulates its\n * `<name>-dev` under `dev`. Nx keys tasks by `project:target`, so any\n * dependencies shared between components run exactly once.\n */\nexport const addComponentDevTarget = (\n targets: Record<string, ProjectConfiguration['targets'][string]>,\n componentDevTargetName: string,\n) => {\n targets['dev'] ??= { continuous: true, dependsOn: [] };\n const projectDev = targets['dev'];\n projectDev.continuous = true;\n projectDev.dependsOn ??= [];\n // Append in component-creation order; dedupe keeps re-runs idempotent.\n if (!projectDev.dependsOn.includes(componentDevTargetName)) {\n projectDev.dependsOn.push(componentDevTargetName);\n }\n targets['dev'] = normalizeTargetKeyOrder(projectDev);\n};\n"],"names":["getProjects","readJson","readProjectConfiguration","updateProjectConfiguration","path","PackageJson","type","NX_PLUGIN_MCP_PACKAGE_NAME","toSnakeCase","getNpmScope","getNpmScopePrefix","buildGeneratorInfoList","GENERATORS","resolve","dirname","listGenerators","includeHidden","filter","g","hidden","getGeneratorInfo","generatorFileName","dir","name","parse","resolvedFactoryPath","join","find","generatorInfo","getPackageVersion","version","isNxPluginForAwsWorkspace","tree","rootPackageJson","exists","undefined","nxPluginSelfDependency","nxPluginMcpDependency","readProjectConfigurationUnqualified","projectName","e","project","values","p","projectExists","addGeneratorMetadata","info","additionalMetadata","config","metadata","generator","id","JSON","stringify","targets","rest","addComponentGeneratorMetadata","componentPath","componentName","existingComponents","components","alreadyAdded","c","length","componentMetadata","mergeTargetDefault","value","apply","Array","isArray","catchAllIndex","findIndex","entry","map","index","targetDependencyEquals","a","b","target","params","aProjects","projects","bProjects","every","i","NX_TARGET_KEY_ORDER","normalizeTargetKeyOrder","Object","fromEntries","entries","sort","ai","indexOf","bi","addDependencyToTargetIfNotPresent","dependency","dependsOn","some","d","push","addComponentDevTarget","componentDevTargetName","continuous","projectDev","includes"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EAEXC,QAAQ,EACRC,wBAAwB,EAIxBC,0BAA0B,QACrB,aAAa;AACpB,YAAYC,UAAU,OAAO;AAC7B,OAAOC,iBAAiB,0BAA0B;IAAEC,MAAM;AAAO,EAAE;AACnE,SAASC,0BAA0B,QAAQ,WAAQ;AACnD,SAASC,WAAW,QAAQ,aAAU;AACtC,SAASC,WAAW,EAAEC,iBAAiB,QAAQ,iBAAc;AAG7D,SAASC,sBAAsB,QAAQ,kBAAe;AAEtD,SAASA,sBAAsB,QAA4B,kBAAe;AAE1E,MAAMC,aAAaD,uBACjBP,KAAKS,OAAO,CAAC,YAAYC,OAAO,EAAE,MAAM;AAG1C;;;CAGC,GACD,OAAO,MAAMC,iBAAiB,CAACC,gBAAgB,KAAK,GAClDJ,WAAWK,MAAM,CAAC,CAACC,IAAMF,iBAAiB,CAACE,EAAEC,MAAM,EAAE;AAEvD;;CAEC,GACD,OAAO,MAAMC,mBAAmB,CAACC;IAC/B,MAAM,EAAEC,GAAG,EAAEC,IAAI,EAAE,GAAGnB,KAAKoB,KAAK,CAACpB,KAAKS,OAAO,CAACQ;IAC9C,MAAMI,sBAAsBrB,KAAKsB,IAAI,CAACJ,KAAKC;IAC3C,OAAOX,WAAWe,IAAI,CACpB,CAACC,gBACCA,cAAcH,mBAAmB,KAAKA;AAE5C,EAAE;AAEF,OAAO,MAAMI,oBAAoB;IAC/B,OAAOxB,YAAYyB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IACvE,IAAI,CAACO,WAAWP,SAAS,CAACQ,QAAQ,CAACH,yBAAyB;QAC1DE,WAAWP,SAAS,CAACG,IAAI,CAACE;IAC5B;IACA/C,OAAO,CAAC,MAAM,GAAGgC,wBAAwBiB;AAC3C,EAAE"}
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/nx.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n getProjects,\n type ProjectConfiguration,\n readJson,\n readProjectConfiguration,\n type TargetConfiguration,\n type TargetDefaultValue,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport * as path from 'path';\nimport PackageJson from '../../package.json' with { type: 'json' };\nimport { NX_PLUGIN_MCP_PACKAGE_NAME } from './mcp.js';\nimport { toSnakeCase } from './names.js';\nimport { getNpmScope, getNpmScopePrefix } from './npm-scope.js';\n\nexport type { GeneratorInfo, NxGeneratorInfo } from './generators.js';\nexport { buildGeneratorInfoList } from './generators.js';\n\nimport { buildGeneratorInfoList, type GeneratorInfo } from './generators.js';\n\nconst GENERATORS = buildGeneratorInfoList(\n path.resolve(import.meta.dirname, '..', '..'),\n);\n\n/**\n * List Nx Plugin for AWS generators\n * @param includeHidden include hidden generators (default false)\n */\nexport const listGenerators = (includeHidden = false) =>\n GENERATORS.filter((g) => includeHidden || !g.hidden);\n\n/**\n * Return generator information. Call this from a generator method with import.meta.filename\n */\nexport const getGeneratorInfo = (generatorFileName: string): GeneratorInfo => {\n const { dir, name } = path.parse(path.resolve(generatorFileName));\n const resolvedFactoryPath = path.join(dir, name);\n return GENERATORS.find(\n (generatorInfo) =>\n generatorInfo.resolvedFactoryPath === resolvedFactoryPath,\n );\n};\n\nexport const getPackageVersion = () => {\n return PackageJson.version;\n};\n\n/**\n * True inside the plugin's own monorepo, where the plugin is the source rather\n * than a dependency.\n */\nexport const isNxPluginForAwsWorkspace = (tree: Tree): boolean => {\n const rootPackageJson = tree.exists('package.json')\n ? readJson(tree, 'package.json')\n : undefined;\n return rootPackageJson?.name === '@aws/nx-plugin-source';\n};\n\n/**\n * The `@aws/nx-plugin` devDependency entry for a workspace the plugin generates\n * into, keyed to the version the running generators come from. Empty inside the\n * plugin's own monorepo.\n */\nexport const nxPluginSelfDependency = (tree: Tree): Record<string, string> =>\n isNxPluginForAwsWorkspace(tree)\n ? {}\n : { [PackageJson.name]: `^${PackageJson.version}` };\n\n/**\n * The `@aws/nx-plugin-mcp` devDependency entry, keyed to the running generators'\n * version — the two packages are released in lockstep. Declaring it pins the MCP\n * server the vended config runs in the workspace's lockfile, so upgrading it\n * upgrades the server. Empty inside the plugin's own monorepo.\n */\nexport const nxPluginMcpDependency = (tree: Tree): Record<string, string> =>\n isNxPluginForAwsWorkspace(tree)\n ? {}\n : { [NX_PLUGIN_MCP_PACKAGE_NAME]: `^${PackageJson.version}` };\n\n/**\n * Read a project configuration where the project name may not be fully qualified (ie may omit the scope prefix)\n */\nexport const readProjectConfigurationUnqualified = (\n tree: Tree,\n projectName: string,\n) => {\n try {\n return readProjectConfiguration(tree, projectName);\n } catch (e) {\n // Attempt to find the project without the scope\n const project = [...getProjects(tree).values()].find(\n (p) =>\n p.name &&\n (p.name === `${getNpmScopePrefix(tree)}${projectName}` || // TypeScript fully-qualified name\n p.name === `${toSnakeCase(getNpmScope(tree))}.${projectName}`), // Python fully-qualified name\n );\n if (project) {\n return project;\n }\n throw e;\n }\n};\n\n/**\n * Returns whether a project with the given name already exists in the workspace.\n * The project name may be unqualified (ie may omit the scope prefix).\n */\nexport const projectExists = (tree: Tree, projectName: string): boolean => {\n try {\n readProjectConfigurationUnqualified(tree, projectName);\n return true;\n } catch {\n return false;\n }\n};\n\n/**\n * Add metadata about the generator that generated the project to the project.json\n */\nexport const addGeneratorMetadata = (\n tree: Tree,\n projectName: string,\n info: { id: string },\n additionalMetadata?: { [key: string]: any },\n) => {\n const config = readProjectConfigurationUnqualified(tree, projectName);\n const metadata = {\n ...config?.metadata,\n generator: info.id,\n ...additionalMetadata,\n };\n // Skip the write when nothing changed so re-running doesn't reserialize\n // project.json. metadata is plain JSON built in a fixed key order, so a\n // stringify comparison is exact here.\n if (JSON.stringify(config?.metadata) === JSON.stringify(metadata)) {\n return;\n }\n // Place metadata immediately before targets so the serialized key order is\n // identical whether or not metadata already existed (matching the order Nx\n // normalizes a read config to), keeping the change a pure metadata insert.\n const { targets, ...rest } = config;\n updateProjectConfiguration(tree, config.name, {\n ...rest,\n metadata: metadata as any,\n ...(targets ? { targets } : {}),\n });\n};\n\n/**\n * Represents a component entry in project metadata\n */\nexport interface ComponentMetadata {\n readonly generator: string;\n readonly name?: string;\n /**\n * What this entry wires up. For a connection that is the target — the thing\n * being connected to — paired with `sourcePath` below.\n */\n readonly path?: string;\n /**\n * The component the connection is made *from*, when both ends are components\n * of a project rather than whole projects.\n *\n * A connection records the project it lives on and the target it reaches, which\n * alone can't tell which of several components on that project is wired up.\n * Recorded as a path for the same reason `path` is: it identifies a component\n * within its project without depending on a name that may repeat.\n */\n readonly sourcePath?: string;\n [key: string]: any;\n}\n\n/**\n * Add metadata about the generator that generated the component to the project.json\n *\n * A connection between two components passes the source's path as\n * `additionalMetadata.sourcePath`, so the pair is identifiable rather than just\n * the two projects.\n */\nexport const addComponentGeneratorMetadata = (\n tree: Tree,\n projectName: string,\n info: { id: string },\n componentPath: string,\n componentName?: string,\n additionalMetadata?: { [key: string]: any },\n) => {\n const config = readProjectConfigurationUnqualified(tree, projectName);\n\n const existingComponents = (config?.metadata as any)?.components ?? [];\n const alreadyAdded = existingComponents.filter(\n (c: any) => c.generator === info.id && c.name === componentName,\n );\n\n if (alreadyAdded.length === 0) {\n const componentMetadata: ComponentMetadata = {\n generator: info.id,\n path: componentPath,\n ...(componentName ? { name: componentName } : {}),\n ...additionalMetadata,\n };\n // Place metadata before targets for a stable serialized key order.\n const { targets, ...rest } = config;\n updateProjectConfiguration(tree, config.name, {\n ...rest,\n metadata: {\n ...config?.metadata,\n components: [...existingComponents, componentMetadata],\n } as any,\n ...(targets ? { targets } : {}),\n });\n }\n};\n\n/**\n * Merge a generator's own config into an `nx.json` `targetDefaults` value,\n * preserving whatever the workspace already had. `apply` receives the config to\n * layer onto and returns the merged config (e.g. `(base) => ({ cache: true,\n * ...base })`); it must be idempotent so re-running the generator is a no-op.\n *\n * Nx 23.1 widened each value to either a config object or an ordered array of\n * filtered entries. The plugin only contributes unfiltered (catch-all) config,\n * so the input's shape is preserved: an object (or unset) stays an object;\n * an array keeps the user's filtered entries and `apply` merges into its first\n * unfiltered entry, prepending one as the base if none exists (Nx layers later\n * matches on top, so our catch-all must stay first to not override a filter).\n */\nexport const mergeTargetDefault = (\n value: TargetDefaultValue | undefined,\n apply: (base: Partial<TargetConfiguration>) => Partial<TargetConfiguration>,\n): TargetDefaultValue => {\n if (!Array.isArray(value)) {\n return apply(value ?? {});\n }\n const catchAllIndex = value.findIndex((entry) => entry.filter === undefined);\n if (catchAllIndex === -1) {\n return [apply({}), ...value];\n }\n return value.map((entry, index) =>\n index === catchAllIndex ? apply(entry) : entry,\n );\n};\n\n/**\n * A single entry in an Nx `dependsOn` array.\n * Matches the shape accepted by Nx without requiring a devkit type import.\n */\nexport type TargetDependency =\n | string\n | {\n projects?: string | string[];\n target: string;\n params?: 'ignore' | 'forward';\n };\n\nconst targetDependencyEquals = (a: TargetDependency, b: TargetDependency) => {\n if (typeof a === 'string' || typeof b === 'string') {\n return a === b;\n }\n if (a.target !== b.target || a.params !== b.params) {\n return false;\n }\n const aProjects = Array.isArray(a.projects)\n ? a.projects\n : a.projects !== undefined\n ? [a.projects]\n : [];\n const bProjects = Array.isArray(b.projects)\n ? b.projects\n : b.projects !== undefined\n ? [b.projects]\n : [];\n if (aProjects.length !== bProjects.length) {\n return false;\n }\n return aProjects.every((p, i) => p === bProjects[i]);\n};\n\n// The order target properties are authored in. Nx preserves a target's\n// authored key order when it reads then rewrites an existing project.json,\n// except `options` and `configurations`, which it always moves to the end (in\n// that order). Keeping `options`/`configurations` last here therefore makes a\n// generator's first-run output byte-identical to subsequent runs (idempotency);\n// the remaining keys are ordered to read intuitively.\nconst NX_TARGET_KEY_ORDER = [\n 'executor',\n 'dependsOn',\n 'continuous',\n 'cache',\n 'inputs',\n 'outputs',\n 'metadata',\n 'defaultConfiguration',\n 'options',\n 'configurations',\n];\n\n/**\n * Reorder a target's keys to match Nx's own serialization order. Nx reorders\n * target properties when it rewrites an existing project.json, so applying the\n * same order when first authoring a target keeps generators idempotent.\n */\nexport const normalizeTargetKeyOrder = <T extends object>(target: T): T =>\n Object.fromEntries(\n Object.entries(target as Record<string, unknown>).sort(([a], [b]) => {\n const ai = NX_TARGET_KEY_ORDER.indexOf(a);\n const bi = NX_TARGET_KEY_ORDER.indexOf(b);\n return (\n (ai === -1 ? NX_TARGET_KEY_ORDER.length : ai) -\n (bi === -1 ? NX_TARGET_KEY_ORDER.length : bi)\n );\n }),\n ) as T;\n\n/**\n * Mutate the project to add the dependency to the target if not already present\n * Adds the target if not present.\n *\n * Accepts either a string target name (e.g. `'build'`) or a dependency config\n * object (e.g. `{ projects: ['foo'], target: 'dev' }`). Deduplicates\n * using deep equality so re-running a generator does not grow `dependsOn`.\n */\nexport const addDependencyToTargetIfNotPresent = (\n project: ProjectConfiguration,\n target: string,\n dependency: TargetDependency,\n) => {\n project.targets ??= {};\n project.targets[target] ??= {};\n project.targets[target].dependsOn ??= [];\n const dependsOn = project.targets[target].dependsOn;\n // Leave existing dependencies in place so re-running does not reorder them;\n // only append when the dependency is genuinely absent.\n if (!dependsOn.some((d) => targetDependencyEquals(d, dependency))) {\n dependsOn.push(dependency);\n }\n // Keep key order aligned with Nx's so first run matches subsequent runs.\n project.targets[target] = normalizeTargetKeyOrder(project.targets[target]);\n};\n\n/**\n * Register a component's `<name>-dev` target under the project-level `dev`\n * target, so `nx run <project>:dev` starts every component in the project.\n *\n * Component generators author their own continuous `<name>-dev` runner and call\n * this to aggregate it. Every component added to the project accumulates its\n * `<name>-dev` under `dev`. Nx keys tasks by `project:target`, so any\n * dependencies shared between components run exactly once.\n */\nexport const addComponentDevTarget = (\n targets: Record<string, ProjectConfiguration['targets'][string]>,\n componentDevTargetName: string,\n) => {\n targets['dev'] ??= { continuous: true, dependsOn: [] };\n const projectDev = targets['dev'];\n projectDev.continuous = true;\n projectDev.dependsOn ??= [];\n // Append in component-creation order; dedupe keeps re-runs idempotent.\n if (!projectDev.dependsOn.includes(componentDevTargetName)) {\n projectDev.dependsOn.push(componentDevTargetName);\n }\n targets['dev'] = normalizeTargetKeyOrder(projectDev);\n};\n"],"names":["getProjects","readJson","readProjectConfiguration","updateProjectConfiguration","path","PackageJson","type","NX_PLUGIN_MCP_PACKAGE_NAME","toSnakeCase","getNpmScope","getNpmScopePrefix","buildGeneratorInfoList","GENERATORS","resolve","dirname","listGenerators","includeHidden","filter","g","hidden","getGeneratorInfo","generatorFileName","dir","name","parse","resolvedFactoryPath","join","find","generatorInfo","getPackageVersion","version","isNxPluginForAwsWorkspace","tree","rootPackageJson","exists","undefined","nxPluginSelfDependency","nxPluginMcpDependency","readProjectConfigurationUnqualified","projectName","e","project","values","p","projectExists","addGeneratorMetadata","info","additionalMetadata","config","metadata","generator","id","JSON","stringify","targets","rest","addComponentGeneratorMetadata","componentPath","componentName","existingComponents","components","alreadyAdded","c","length","componentMetadata","mergeTargetDefault","value","apply","Array","isArray","catchAllIndex","findIndex","entry","map","index","targetDependencyEquals","a","b","target","params","aProjects","projects","bProjects","every","i","NX_TARGET_KEY_ORDER","normalizeTargetKeyOrder","Object","fromEntries","entries","sort","ai","indexOf","bi","addDependencyToTargetIfNotPresent","dependency","dependsOn","some","d","push","addComponentDevTarget","componentDevTargetName","continuous","projectDev","includes"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EAEXC,QAAQ,EACRC,wBAAwB,EAIxBC,0BAA0B,QACrB,aAAa;AACpB,YAAYC,UAAU,OAAO;AAC7B,OAAOC,iBAAiB,0BAA0B;IAAEC,MAAM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OAAO,MAAMC,oCAAoC,CAC/CrD,SACAqC,QACAiB;IAEAtD,QAAQa,OAAO,KAAK,CAAC;IACrBb,QAAQa,OAAO,CAACwB,OAAO,KAAK,CAAC;IAC7BrC,QAAQa,OAAO,CAACwB,OAAO,CAACkB,SAAS,KAAK,EAAE;IACxC,MAAMA,YAAYvD,QAAQa,OAAO,CAACwB,OAAO,CAACkB,SAAS;IACnD,4EAA4E;IAC5E,uDAAuD;IACvD,IAAI,CAACA,UAAUC,IAAI,CAAC,CAACC,IAAMvB,uBAAuBuB,GAAGH,cAAc;QACjEC,UAAUG,IAAI,CAACJ;IACjB;IACA,yEAAyE;IACzEtD,QAAQa,OAAO,CAACwB,OAAO,GAAGQ,wBAAwB7C,QAAQa,OAAO,CAACwB,OAAO;AAC3E,EAAE;AAEF;;;;;;;;CAQC,GACD,OAAO,MAAMsB,wBAAwB,CACnC9C,SACA+C;IAEA/C,OAAO,CAAC,MAAM,KAAK;QAAEgD,YAAY;QAAMN,WAAW,EAAE;IAAC;IACrD,MAAMO,aAAajD,OAAO,CAAC,MAAM;IACjCiD,WAAWD,UAAU,GAAG;IACxBC,WAAWP,SAAS,KAAK,EAAE;IAC3B,uEAAuE;IACvE,IAAI,CAACO,WAAWP,SAAS,CAACQ,QAAQ,CAACH,yBAAyB;QAC1DE,WAAWP,SAAS,CAACG,IAAI,CAACE;IAC5B;IACA/C,OAAO,CAAC,MAAM,GAAGgC,wBAAwBiB;AAC3C,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/paths.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { ProjectConfiguration, Tree } from '@nx/devkit';\nimport * as path from 'path';\nimport { readProjectConfigurationUnqualified } from './nx';\n\nexport const getRelativePathToRoot = (\n tree: Tree,\n projectName: string,\n): string => {\n const projectConfig = readProjectConfigurationUnqualified(tree, projectName);\n const projectRoot = projectConfig.root;\n return getRelativePathToRootByDirectory(projectRoot);\n};\n\nexport const getRelativePathToRootByDirectory = (directory: string): string => {\n // Count the number of path segments to determine how many '../' we need\n const levels = directory.split('/').filter(Boolean).length;\n // Create the relative path back to root\n return '../'.repeat(levels);\n};\n\n/**\n * Convert an absolute path within a project to a path relative to the project root.\n */\nexport const toProjectRelativePath = (\n projectConfiguration: ProjectConfiguration,\n absolutePath: string,\n): string => {\n return path.relative(projectConfiguration.root, absolutePath);\n};\n"],"names":["path","readProjectConfigurationUnqualified","getRelativePathToRoot","tree","projectName","projectConfig","projectRoot","root","getRelativePathToRootByDirectory","directory","levels","split","filter","Boolean","length","repeat","toProjectRelativePath","projectConfiguration","absolutePath","relative"],"mappings":"AAAA;;;CAGC,GAED,YAAYA,UAAU,OAAO;AAC7B,SAASC,mCAAmC,QAAQ,UAAO;AAE3D,OAAO,MAAMC,wBAAwB,CACnCC,MACAC;IAEA,MAAMC,gBAAgBJ,oCAAoCE,MAAMC;IAChE,MAAME,cAAcD,cAAcE,IAAI;IACtC,OAAOC,iCAAiCF;AAC1C,EAAE;AAEF,OAAO,MAAME,mCAAmC,CAACC;IAC/C,wEAAwE;IACxE,MAAMC,SAASD,UAAUE,KAAK,CAAC,KAAKC,MAAM,CAACC,SAASC,MAAM;IAC1D,wCAAwC;IACxC,OAAO,MAAMC,MAAM,CAACL;AACtB,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMM,wBAAwB,CACnCC,sBACAC;IAEA,OAAOlB,KAAKmB,QAAQ,CAACF,qBAAqBV,IAAI,EAAEW;AAClD,EAAE"}
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/paths.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { ProjectConfiguration, Tree } from '@nx/devkit';\nimport * as path from 'path';\nimport { readProjectConfigurationUnqualified } from './nx.js';\n\nexport const getRelativePathToRoot = (\n tree: Tree,\n projectName: string,\n): string => {\n const projectConfig = readProjectConfigurationUnqualified(tree, projectName);\n const projectRoot = projectConfig.root;\n return getRelativePathToRootByDirectory(projectRoot);\n};\n\nexport const getRelativePathToRootByDirectory = (directory: string): string => {\n // Count the number of path segments to determine how many '../' we need\n const levels = directory.split('/').filter(Boolean).length;\n // Create the relative path back to root\n return '../'.repeat(levels);\n};\n\n/**\n * Convert an absolute path within a project to a path relative to the project root.\n */\nexport const toProjectRelativePath = (\n projectConfiguration: ProjectConfiguration,\n absolutePath: string,\n): string => {\n return path.relative(projectConfiguration.root, absolutePath);\n};\n"],"names":["path","readProjectConfigurationUnqualified","getRelativePathToRoot","tree","projectName","projectConfig","projectRoot","root","getRelativePathToRootByDirectory","directory","levels","split","filter","Boolean","length","repeat","toProjectRelativePath","projectConfiguration","absolutePath","relative"],"mappings":"AAAA;;;CAGC,GAED,YAAYA,UAAU,OAAO;AAC7B,SAASC,mCAAmC,QAAQ,UAAU;AAE9D,OAAO,MAAMC,wBAAwB,CACnCC,MACAC;IAEA,MAAMC,gBAAgBJ,oCAAoCE,MAAMC;IAChE,MAAME,cAAcD,cAAcE,IAAI;IACtC,OAAOC,iCAAiCF;AAC1C,EAAE;AAEF,OAAO,MAAME,mCAAmC,CAACC;IAC/C,wEAAwE;IACxE,MAAMC,SAASD,UAAUE,KAAK,CAAC,KAAKC,MAAM,CAACC,SAASC,MAAM;IAC1D,wCAAwC;IACxC,OAAO,MAAMC,MAAM,CAACL;AACtB,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMM,wBAAwB,CACnCC,sBACAC;IAEA,OAAOlB,KAAKmB,QAAQ,CAACF,qBAAqBV,IAAI,EAAEW;AAClD,EAAE"}
@@ -1,4 +1,4 @@
1
- import { type PackageManagerDisplayCommands } from './commands';
1
+ import { type PackageManagerDisplayCommands } from './commands.js';
2
2
  export type { PackageManagerDisplayCommands };
3
3
  /**
4
4
  * Returns display-friendly command prefixes for the detected package manager.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/pkg-manager.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { detectPackageManager } from '@nx/devkit';\nimport {\n PACKAGE_MANAGER_COMMANDS,\n type PackageManagerDisplayCommands,\n} from './commands';\n\nexport type { PackageManagerDisplayCommands };\n\n/**\n * Returns display-friendly command prefixes for the detected package manager.\n */\nexport const getPackageManagerDisplayCommands = (\n pm = detectPackageManager(),\n): PackageManagerDisplayCommands =>\n PACKAGE_MANAGER_COMMANDS[pm] ?? PACKAGE_MANAGER_COMMANDS['npm'];\n"],"names":["detectPackageManager","PACKAGE_MANAGER_COMMANDS","getPackageManagerDisplayCommands","pm"],"mappings":"AAAA;;;CAGC,GACD,SAASA,oBAAoB,QAAQ,aAAa;AAClD,SACEC,wBAAwB,QAEnB,gBAAa;AAIpB;;CAEC,GACD,OAAO,MAAMC,mCAAmC,CAC9CC,KAAKH,sBAAsB,GAE3BC,wBAAwB,CAACE,GAAG,IAAIF,wBAAwB,CAAC,MAAM,CAAC"}
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/pkg-manager.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { detectPackageManager } from '@nx/devkit';\nimport {\n PACKAGE_MANAGER_COMMANDS,\n type PackageManagerDisplayCommands,\n} from './commands.js';\n\nexport type { PackageManagerDisplayCommands };\n\n/**\n * Returns display-friendly command prefixes for the detected package manager.\n */\nexport const getPackageManagerDisplayCommands = (\n pm = detectPackageManager(),\n): PackageManagerDisplayCommands =>\n PACKAGE_MANAGER_COMMANDS[pm] ?? PACKAGE_MANAGER_COMMANDS['npm'];\n"],"names":["detectPackageManager","PACKAGE_MANAGER_COMMANDS","getPackageManagerDisplayCommands","pm"],"mappings":"AAAA;;;CAGC,GACD,SAASA,oBAAoB,QAAQ,aAAa;AAClD,SACEC,wBAAwB,QAEnB,gBAAgB;AAIvB;;CAEC,GACD,OAAO,MAAMC,mCAAmC,CAC9CC,KAAKH,sBAAsB,GAE3BC,wBAAwB,CAACE,GAAG,IAAIF,wBAAwB,CAAC,MAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/pnpm-workspace.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { Tree } from '@nx/devkit';\nimport yaml from 'js-yaml';\nimport { detectWorkspacePackageManager } from './dependencies';\n\nconst WORKSPACE_FILE = 'pnpm-workspace.yaml';\n\ninterface PnpmWorkspaceYaml {\n allowBuilds?: Record<string, boolean>;\n onlyBuiltDependencies?: string[];\n [key: string]: unknown;\n}\n\n/**\n * Merge `allowBuilds` (pnpm 11) / `onlyBuiltDependencies` (pnpm 10) entries\n * into the generated workspace's `pnpm-workspace.yaml`. No-op for non-pnpm\n * workspaces.\n *\n * Generators call this when they introduce a dependency whose install\n * script pnpm would otherwise reject under pnpm 11's default\n * `strictDepBuilds=true`. Keeping the allowlist explicit — rather than\n * globally disabling strictness — preserves the supply-chain audit pnpm 11\n * intends: each build-script dep is reviewed by the generator author and\n * entered as either `true` (run the script) or `false` (known dep we\n * don't want to run but have seen).\n *\n * Only `true` entries are also added to `onlyBuiltDependencies` (pnpm 10's\n * allowlist has no equivalent of the `false` decision).\n */\nexport const registerPnpmBuiltDependencies = (\n tree: Tree,\n entries: Record<string, boolean>,\n): void => {\n if (detectWorkspacePackageManager(tree) !== 'pnpm') {\n return;\n }\n if (!tree.exists(WORKSPACE_FILE)) {\n return;\n }\n\n const original = tree.read(WORKSPACE_FILE, 'utf-8') ?? '';\n const parsed = (yaml.load(original) as PnpmWorkspaceYaml | null) ?? {};\n\n const allowBuilds = { ...(parsed.allowBuilds ?? {}) };\n const onlyBuiltDependencies = new Set(parsed.onlyBuiltDependencies ?? []);\n let changed = false;\n\n for (const [pkg, decision] of Object.entries(entries)) {\n if (allowBuilds[pkg] !== decision) {\n allowBuilds[pkg] = decision;\n changed = true;\n }\n if (decision === true && !onlyBuiltDependencies.has(pkg)) {\n onlyBuiltDependencies.add(pkg);\n changed = true;\n }\n }\n\n if (!changed) {\n return;\n }\n\n parsed.allowBuilds = allowBuilds;\n parsed.onlyBuiltDependencies = [...onlyBuiltDependencies];\n\n tree.write(WORKSPACE_FILE, yaml.dump(parsed, { quotingType: \"'\" }));\n};\n"],"names":["yaml","detectWorkspacePackageManager","WORKSPACE_FILE","registerPnpmBuiltDependencies","tree","entries","exists","original","read","parsed","load","allowBuilds","onlyBuiltDependencies","Set","changed","pkg","decision","Object","has","add","write","dump","quotingType"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,UAAU,UAAU;AAC3B,SAASC,6BAA6B,QAAQ,oBAAiB;AAE/D,MAAMC,iBAAiB;AAQvB;;;;;;;;;;;;;;;CAeC,GACD,OAAO,MAAMC,gCAAgC,CAC3CC,MACAC;IAEA,IAAIJ,8BAA8BG,UAAU,QAAQ;QAClD;IACF;IACA,IAAI,CAACA,KAAKE,MAAM,CAACJ,iBAAiB;QAChC;IACF;IAEA,MAAMK,WAAWH,KAAKI,IAAI,CAACN,gBAAgB,YAAY;IACvD,MAAMO,SAAS,AAACT,KAAKU,IAAI,CAACH,aAA0C,CAAC;IAErE,MAAMI,cAAc;QAAE,GAAIF,OAAOE,WAAW,IAAI,CAAC,CAAC;IAAE;IACpD,MAAMC,wBAAwB,IAAIC,IAAIJ,OAAOG,qBAAqB,IAAI,EAAE;IACxE,IAAIE,UAAU;IAEd,KAAK,MAAM,CAACC,KAAKC,SAAS,IAAIC,OAAOZ,OAAO,CAACA,SAAU;QACrD,IAAIM,WAAW,CAACI,IAAI,KAAKC,UAAU;YACjCL,WAAW,CAACI,IAAI,GAAGC;YACnBF,UAAU;QACZ;QACA,IAAIE,aAAa,QAAQ,CAACJ,sBAAsBM,GAAG,CAACH,MAAM;YACxDH,sBAAsBO,GAAG,CAACJ;YAC1BD,UAAU;QACZ;IACF;IAEA,IAAI,CAACA,SAAS;QACZ;IACF;IAEAL,OAAOE,WAAW,GAAGA;IACrBF,OAAOG,qBAAqB,GAAG;WAAIA;KAAsB;IAEzDR,KAAKgB,KAAK,CAAClB,gBAAgBF,KAAKqB,IAAI,CAACZ,QAAQ;QAAEa,aAAa;IAAI;AAClE,EAAE"}
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/pnpm-workspace.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { Tree } from '@nx/devkit';\nimport yaml from 'js-yaml';\nimport { detectWorkspacePackageManager } from './dependencies.js';\n\nconst WORKSPACE_FILE = 'pnpm-workspace.yaml';\n\ninterface PnpmWorkspaceYaml {\n allowBuilds?: Record<string, boolean>;\n onlyBuiltDependencies?: string[];\n [key: string]: unknown;\n}\n\n/**\n * Merge `allowBuilds` (pnpm 11) / `onlyBuiltDependencies` (pnpm 10) entries\n * into the generated workspace's `pnpm-workspace.yaml`. No-op for non-pnpm\n * workspaces.\n *\n * Generators call this when they introduce a dependency whose install\n * script pnpm would otherwise reject under pnpm 11's default\n * `strictDepBuilds=true`. Keeping the allowlist explicit — rather than\n * globally disabling strictness — preserves the supply-chain audit pnpm 11\n * intends: each build-script dep is reviewed by the generator author and\n * entered as either `true` (run the script) or `false` (known dep we\n * don't want to run but have seen).\n *\n * Only `true` entries are also added to `onlyBuiltDependencies` (pnpm 10's\n * allowlist has no equivalent of the `false` decision).\n */\nexport const registerPnpmBuiltDependencies = (\n tree: Tree,\n entries: Record<string, boolean>,\n): void => {\n if (detectWorkspacePackageManager(tree) !== 'pnpm') {\n return;\n }\n if (!tree.exists(WORKSPACE_FILE)) {\n return;\n }\n\n const original = tree.read(WORKSPACE_FILE, 'utf-8') ?? '';\n const parsed = (yaml.load(original) as PnpmWorkspaceYaml | null) ?? {};\n\n const allowBuilds = { ...(parsed.allowBuilds ?? {}) };\n const onlyBuiltDependencies = new Set(parsed.onlyBuiltDependencies ?? []);\n let changed = false;\n\n for (const [pkg, decision] of Object.entries(entries)) {\n if (allowBuilds[pkg] !== decision) {\n allowBuilds[pkg] = decision;\n changed = true;\n }\n if (decision === true && !onlyBuiltDependencies.has(pkg)) {\n onlyBuiltDependencies.add(pkg);\n changed = true;\n }\n }\n\n if (!changed) {\n return;\n }\n\n parsed.allowBuilds = allowBuilds;\n parsed.onlyBuiltDependencies = [...onlyBuiltDependencies];\n\n tree.write(WORKSPACE_FILE, yaml.dump(parsed, { quotingType: \"'\" }));\n};\n"],"names":["yaml","detectWorkspacePackageManager","WORKSPACE_FILE","registerPnpmBuiltDependencies","tree","entries","exists","original","read","parsed","load","allowBuilds","onlyBuiltDependencies","Set","changed","pkg","decision","Object","has","add","write","dump","quotingType"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,UAAU,UAAU;AAC3B,SAASC,6BAA6B,QAAQ,oBAAoB;AAElE,MAAMC,iBAAiB;AAQvB;;;;;;;;;;;;;;;CAeC,GACD,OAAO,MAAMC,gCAAgC,CAC3CC,MACAC;IAEA,IAAIJ,8BAA8BG,UAAU,QAAQ;QAClD;IACF;IACA,IAAI,CAACA,KAAKE,MAAM,CAACJ,iBAAiB;QAChC;IACF;IAEA,MAAMK,WAAWH,KAAKI,IAAI,CAACN,gBAAgB,YAAY;IACvD,MAAMO,SAAS,AAACT,KAAKU,IAAI,CAACH,aAA0C,CAAC;IAErE,MAAMI,cAAc;QAAE,GAAIF,OAAOE,WAAW,IAAI,CAAC,CAAC;IAAE;IACpD,MAAMC,wBAAwB,IAAIC,IAAIJ,OAAOG,qBAAqB,IAAI,EAAE;IACxE,IAAIE,UAAU;IAEd,KAAK,MAAM,CAACC,KAAKC,SAAS,IAAIC,OAAOZ,OAAO,CAACA,SAAU;QACrD,IAAIM,WAAW,CAACI,IAAI,KAAKC,UAAU;YACjCL,WAAW,CAACI,IAAI,GAAGC;YACnBF,UAAU;QACZ;QACA,IAAIE,aAAa,QAAQ,CAACJ,sBAAsBM,GAAG,CAACH,MAAM;YACxDH,sBAAsBO,GAAG,CAACJ;YAC1BD,UAAU;QACZ;IACF;IAEA,IAAI,CAACA,SAAS;QACZ;IACF;IAEAL,OAAOE,WAAW,GAAGA;IACrBF,OAAOG,qBAAqB,GAAG;WAAIA;KAAsB;IAEzDR,KAAKgB,KAAK,CAAClB,gBAAgBF,KAAKqB,IAAI,CAACZ,QAAQ;QAAEa,aAAa;IAAI;AAClE,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/project-package-json.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n joinPathFragments,\n readJson,\n type Tree,\n updateJson,\n writeJson,\n} from '@nx/devkit';\nimport yaml from 'js-yaml';\nimport { minimatch } from 'minimatch';\nimport { detectWorkspacePackageManager } from './dependencies';\nimport { isEsmWorkspace } from './module-format';\n\nexport interface EnsureProjectPackageJsonOptions {\n /** Directory of the project relative to the workspace root */\n readonly dir: string;\n /** Full package name including scope (eg @foo/bar) */\n readonly fullyQualifiedName: string;\n /** Module format. Defaults to the workspace format, written explicitly. */\n readonly esm?: boolean;\n}\n\n/**\n * Ensure the project has its own minimal private package.json, so the workspace\n * follows the standard npm package layout (package managers link projects,\n * filtered installs work, nearest-package.json `type` lookup resolves).\n * Cross-project imports resolve via tsconfig `paths` aliases, not the manifest.\n */\nexport const ensureProjectPackageJson = (\n tree: Tree,\n options: EnsureProjectPackageJsonOptions,\n): void => {\n const packageJsonPath = joinPathFragments(options.dir, 'package.json');\n const esm = options.esm ?? isEsmWorkspace(tree);\n\n if (!tree.exists(packageJsonPath)) {\n writeJson(tree, packageJsonPath, {\n name: options.fullyQualifiedName,\n version: '0.0.0',\n private: true,\n });\n }\n\n updateJson(tree, packageJsonPath, (packageJson) => {\n // Strip @nx/js's default `./dist` entry points: that path doesn't exist in\n // this layout (tsc outputs to `dist/<project>/tsc` at the root) and imports\n // resolve via tsconfig aliases. User-customised entry points are kept.\n for (const field of ['main', 'module', 'types'] as const) {\n if (packageJson[field]?.startsWith('./dist/')) {\n delete packageJson[field];\n }\n }\n if (packageJson.exports?.['.']?.import?.startsWith('./dist/')) {\n // Drop only the stale default entry; user-added subpath exports are kept.\n // Its './package.json' companion is dropped too, since an exports map\n // without '.' would block root imports.\n delete packageJson.exports['.'];\n const remaining = Object.keys(packageJson.exports);\n if (\n remaining.length === 0 ||\n (remaining.length === 1 && remaining[0] === './package.json')\n ) {\n delete packageJson.exports;\n }\n }\n return {\n ...packageJson,\n name: options.fullyQualifiedName,\n private: packageJson.private ?? true,\n // Written explicitly so the module format is stable however consumed.\n type: esm ? 'module' : 'commonjs',\n };\n });\n\n ensureWorkspaceGlobCovers(tree, options.dir);\n};\n\n/**\n * Ensure the package manager's workspace globs match the given project\n * directory, so the project's package.json participates in workspace\n * resolution and filtered installs.\n *\n * pnpm reads globs from `pnpm-workspace.yaml`; other package managers read\n * the root package.json `workspaces` field. A directory not covered by an\n * existing glob is added as an exact entry.\n */\nexport const ensureWorkspaceGlobCovers = (tree: Tree, dir: string): void => {\n // Update whichever markers the workspace carries (both when both are\n // present, e.g. the test helper).\n const usePnpmWorkspace = detectWorkspacePackageManager(tree) === 'pnpm';\n\n if (usePnpmWorkspace) {\n const parsed =\n (yaml.load(tree.read('pnpm-workspace.yaml', 'utf-8') ?? '') as Record<\n string,\n unknown\n >) ?? {};\n const packages = (parsed.packages as string[]) ?? [];\n if (!globsCover(packages, dir)) {\n tree.write(\n 'pnpm-workspace.yaml',\n yaml.dump(\n { ...parsed, packages: [...packages, dir] },\n { quotingType: \"'\" },\n ),\n );\n }\n }\n\n if (tree.exists('package.json')) {\n const { workspaces } = readJson<{ workspaces?: WorkspacesField }>(\n tree,\n 'package.json',\n );\n if (\n workspaces !== undefined &&\n !globsCover(workspaceGlobs(workspaces), dir)\n ) {\n updateJson(tree, 'package.json', (packageJson) => ({\n ...packageJson,\n workspaces: appendWorkspaceGlob(packageJson.workspaces, dir),\n }));\n } else if (workspaces === undefined && !usePnpmWorkspace) {\n updateJson(tree, 'package.json', (packageJson) => ({\n ...packageJson,\n workspaces: [dir],\n }));\n }\n }\n};\n\n/**\n * The root package.json `workspaces` field: an array of globs, or the object\n * form (`{ \"packages\": [...] }`) accepted by yarn and bun.\n */\nexport type WorkspacesField = string[] | { packages?: string[] };\n\n/** The workspace globs carried by either form of the `workspaces` field. */\nexport const workspaceGlobs = (\n workspaces: WorkspacesField | undefined,\n): string[] =>\n Array.isArray(workspaces) ? workspaces : (workspaces?.packages ?? []);\n\n/** Append a glob to the `workspaces` field, preserving its existing form. */\nconst appendWorkspaceGlob = (\n workspaces: WorkspacesField | undefined,\n glob: string,\n): WorkspacesField => {\n const globs = [...workspaceGlobs(workspaces), glob];\n return workspaces !== undefined && !Array.isArray(workspaces)\n ? { ...workspaces, packages: globs }\n : globs;\n};\n\n/**\n * Whether the workspace globs match the directory. Negated globs (`!foo`)\n * always exclude, regardless of where they appear in the list — package\n * managers apply exclusions after expanding the positive patterns, so\n * ordering is not significant.\n */\nconst globsCover = (globs: string[], dir: string): boolean =>\n globs.some((glob) => !glob.startsWith('!') && minimatch(dir, glob)) &&\n !globs.some((glob) => glob.startsWith('!') && minimatch(dir, glob.slice(1)));\n"],"names":["joinPathFragments","readJson","updateJson","writeJson","yaml","minimatch","detectWorkspacePackageManager","isEsmWorkspace","ensureProjectPackageJson","tree","options","packageJsonPath","dir","esm","exists","name","fullyQualifiedName","version","private","packageJson","field","startsWith","exports","import","remaining","Object","keys","length","type","ensureWorkspaceGlobCovers","usePnpmWorkspace","parsed","load","read","packages","globsCover","write","dump","quotingType","workspaces","undefined","workspaceGlobs","appendWorkspaceGlob","Array","isArray","glob","globs","some","slice"],"mappings":"AAAA;;;CAG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KAAK;IACnD,OAAON,eAAeC,aAAa,CAACG,MAAMC,OAAO,CAACL,cAC9C;QAAE,GAAGA,UAAU;QAAEL,UAAUY;IAAM,IACjCA;AACN;AAEA;;;;;CAKC,GACD,MAAMX,aAAa,CAACW,OAAiBlC,MACnCkC,MAAMC,IAAI,CAAC,CAACF,OAAS,CAACA,KAAKxB,UAAU,CAAC,QAAQhB,UAAUO,KAAKiC,UAC7D,CAACC,MAAMC,IAAI,CAAC,CAACF,OAASA,KAAKxB,UAAU,CAAC,QAAQhB,UAAUO,KAAKiC,KAAKG,KAAK,CAAC"}
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/project-package-json.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n joinPathFragments,\n readJson,\n type Tree,\n updateJson,\n writeJson,\n} from '@nx/devkit';\nimport yaml from 'js-yaml';\nimport { minimatch } from 'minimatch';\nimport { detectWorkspacePackageManager } from './dependencies.js';\nimport { isEsmWorkspace } from './module-format.js';\n\nexport interface EnsureProjectPackageJsonOptions {\n /** Directory of the project relative to the workspace root */\n readonly dir: string;\n /** Full package name including scope (eg @foo/bar) */\n readonly fullyQualifiedName: string;\n /** Module format. Defaults to the workspace format, written explicitly. */\n readonly esm?: boolean;\n}\n\n/**\n * Ensure the project has its own minimal private package.json, so the workspace\n * follows the standard npm package layout (package managers link projects,\n * filtered installs work, nearest-package.json `type` lookup resolves).\n * Cross-project imports resolve via tsconfig `paths` aliases, not the manifest.\n */\nexport const ensureProjectPackageJson = (\n tree: Tree,\n options: EnsureProjectPackageJsonOptions,\n): void => {\n const packageJsonPath = joinPathFragments(options.dir, 'package.json');\n const esm = options.esm ?? isEsmWorkspace(tree);\n\n if (!tree.exists(packageJsonPath)) {\n writeJson(tree, packageJsonPath, {\n name: options.fullyQualifiedName,\n version: '0.0.0',\n private: true,\n });\n }\n\n updateJson(tree, packageJsonPath, (packageJson) => {\n // Strip @nx/js's default `./dist` entry points: that path doesn't exist in\n // this layout (tsc outputs to `dist/<project>/tsc` at the root) and imports\n // resolve via tsconfig aliases. User-customised entry points are kept.\n for (const field of ['main', 'module', 'types'] as const) {\n if (packageJson[field]?.startsWith('./dist/')) {\n delete packageJson[field];\n }\n }\n if (packageJson.exports?.['.']?.import?.startsWith('./dist/')) {\n // Drop only the stale default entry; user-added subpath exports are kept.\n // Its './package.json' companion is dropped too, since an exports map\n // without '.' would block root imports.\n delete packageJson.exports['.'];\n const remaining = Object.keys(packageJson.exports);\n if (\n remaining.length === 0 ||\n (remaining.length === 1 && remaining[0] === './package.json')\n ) {\n delete packageJson.exports;\n }\n }\n return {\n ...packageJson,\n name: options.fullyQualifiedName,\n private: packageJson.private ?? true,\n // Written explicitly so the module format is stable however consumed.\n type: esm ? 'module' : 'commonjs',\n };\n });\n\n ensureWorkspaceGlobCovers(tree, options.dir);\n};\n\n/**\n * Ensure the package manager's workspace globs match the given project\n * directory, so the project's package.json participates in workspace\n * resolution and filtered installs.\n *\n * pnpm reads globs from `pnpm-workspace.yaml`; other package managers read\n * the root package.json `workspaces` field. A directory not covered by an\n * existing glob is added as an exact entry.\n */\nexport const ensureWorkspaceGlobCovers = (tree: Tree, dir: string): void => {\n // Update whichever markers the workspace carries (both when both are\n // present, e.g. the test helper).\n const usePnpmWorkspace = detectWorkspacePackageManager(tree) === 'pnpm';\n\n if (usePnpmWorkspace) {\n const parsed =\n (yaml.load(tree.read('pnpm-workspace.yaml', 'utf-8') ?? '') as Record<\n string,\n unknown\n >) ?? {};\n const packages = (parsed.packages as string[]) ?? [];\n if (!globsCover(packages, dir)) {\n tree.write(\n 'pnpm-workspace.yaml',\n yaml.dump(\n { ...parsed, packages: [...packages, dir] },\n { quotingType: \"'\" },\n ),\n );\n }\n }\n\n if (tree.exists('package.json')) {\n const { workspaces } = readJson<{ workspaces?: WorkspacesField }>(\n tree,\n 'package.json',\n );\n if (\n workspaces !== undefined &&\n !globsCover(workspaceGlobs(workspaces), dir)\n ) {\n updateJson(tree, 'package.json', (packageJson) => ({\n ...packageJson,\n workspaces: appendWorkspaceGlob(packageJson.workspaces, dir),\n }));\n } else if (workspaces === undefined && !usePnpmWorkspace) {\n updateJson(tree, 'package.json', (packageJson) => ({\n ...packageJson,\n workspaces: [dir],\n }));\n }\n }\n};\n\n/**\n * The root package.json `workspaces` field: an array of globs, or the object\n * form (`{ \"packages\": [...] }`) accepted by yarn and bun.\n */\nexport type WorkspacesField = string[] | { packages?: string[] };\n\n/** The workspace globs carried by either form of the `workspaces` field. */\nexport const workspaceGlobs = (\n workspaces: WorkspacesField | undefined,\n): string[] =>\n Array.isArray(workspaces) ? workspaces : (workspaces?.packages ?? []);\n\n/** Append a glob to the `workspaces` field, preserving its existing form. */\nconst appendWorkspaceGlob = (\n workspaces: WorkspacesField | undefined,\n glob: string,\n): WorkspacesField => {\n const globs = [...workspaceGlobs(workspaces), glob];\n return workspaces !== undefined && !Array.isArray(workspaces)\n ? { ...workspaces, packages: globs }\n : globs;\n};\n\n/**\n * Whether the workspace globs match the directory. Negated globs (`!foo`)\n * always exclude, regardless of where they appear in the list — package\n * managers apply exclusions after expanding the positive patterns, so\n * ordering is not significant.\n */\nconst globsCover = (globs: string[], dir: string): boolean =>\n globs.some((glob) => !glob.startsWith('!') && minimatch(dir, glob)) &&\n !globs.some((glob) => glob.startsWith('!') && minimatch(dir, glob.slice(1)));\n"],"names":["joinPathFragments","readJson","updateJson","writeJson","yaml","minimatch","detectWorkspacePackageManager","isEsmWorkspace","ensureProjectPackageJson","tree","options","packageJsonPath","dir","esm","exists","name","fullyQualifiedName","version","private","packageJson","field","startsWith","exports","import","remaining","Object","keys","length","type","ensureWorkspaceGlobCovers","usePnpmWorkspace","parsed","load","read","packages","globsCover","write","dump","quotingType","workspaces","undefined","workspaceGlobs","appendWorkspaceGlob","Array","isArray","glob","globs","some","slice"],"mappings":"AAAA;;;CAGC,GACD,SACEA,iBAAiB,EACjBC,QAAQ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,MAAMC,OAAO,CAACL,cAC9C;QAAE,GAAGA,UAAU;QAAEL,UAAUY;IAAM,IACjCA;AACN;AAEA;;;;;CAKC,GACD,MAAMX,aAAa,CAACW,OAAiBlC,MACnCkC,MAAMC,IAAI,CAAC,CAACF,OAAS,CAACA,KAAKxB,UAAU,CAAC,QAAQhB,UAAUO,KAAKiC,UAC7D,CAACC,MAAMC,IAAI,CAAC,CAACF,OAASA,KAAKxB,UAAU,CAAC,QAAQhB,UAAUO,KAAKiC,KAAKG,KAAK,CAAC"}
package/src/utils/py.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type Tree } from '@nx/devkit';
2
- import type { DeclaredPy, DependencyDeclaration } from './declared-dependencies';
3
- import { type IPyDepVersion } from './versions';
2
+ import type { DeclaredPy, DependencyDeclaration } from './declared-dependencies.js';
3
+ import { type IPyDepVersion } from './versions.js';
4
4
  /**
5
5
  * Add dependencies to a pyproject.toml file
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/py.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { parse, stringify } from '@iarna/toml';\nimport { joinPathFragments, type Tree } from '@nx/devkit';\nimport { parsePipRequirementsLine } from 'pip-requirements-js';\nimport type {\n DeclaredPy,\n DependencyDeclaration,\n} from './declared-dependencies';\nimport { normalizeDistributionName } from './names';\nimport type { UVPyprojectToml } from './nxlv-python';\nimport { readToml, updateToml } from './toml';\nimport { type IPyDepVersion, PY_VERSIONS, withPyVersions } from './versions';\n\n// Dedup key that distinguishes bare packages from the same package with\n// extras (e.g. `foo` vs `foo[bar]`), so adding a bare dep doesn't drop a\n// previously-added variant with extras.\nconst depKey = (dep: string): string => {\n const parsed = parsePipRequirementsLine(dep);\n if (parsed?.type !== 'ProjectName') {\n return dep;\n }\n const extras = [...(parsed.extras ?? [])].sort().join(',');\n return extras ? `${parsed.name}[${extras}]` : parsed.name;\n};\n\nconst mergeDeps = (\n declaration: DependencyDeclaration,\n existing: readonly string[] | undefined,\n deps: readonly IPyDepVersion[],\n): string[] => {\n // Update deps in place by key so re-running does not reorder the list:\n // existing deps keep their position (with their version refreshed), and only\n // genuinely-new deps are appended.\n const incoming = new Map(\n withPyVersions(declaration, deps).map((d) => [depKey(d), d]),\n );\n const merged = (existing ?? []).map(\n (dep) => incoming.get(depKey(dep)) ?? dep,\n );\n const existingKeys = new Set((existing ?? []).map(depKey));\n for (const [key, dep] of incoming) {\n if (!existingKeys.has(key)) {\n merged.push(dep);\n }\n }\n return merged;\n};\n\n/**\n * Add dependencies to a pyproject.toml file\n */\nexport const addDependenciesToPyProjectToml = <\n const D extends DependencyDeclaration,\n>(\n tree: Tree,\n projectRoot: string,\n declaration: D,\n deps: readonly DeclaredPy<D>[],\n) => {\n const projectToml = parse(\n tree.read(joinPathFragments(projectRoot, 'pyproject.toml'), 'utf8'),\n ) as UVPyprojectToml;\n projectToml.project.dependencies = mergeDeps(\n declaration,\n projectToml.project?.dependencies,\n deps,\n );\n tree.write(\n joinPathFragments(projectRoot, 'pyproject.toml'),\n stringify(projectToml),\n );\n};\n\nexport const addDependenciesToDependencyGroupInPyProjectToml = <\n const D extends DependencyDeclaration,\n>(\n tree: Tree,\n projectRoot: string,\n group: string,\n declaration: D,\n deps: readonly DeclaredPy<D>[],\n) => {\n const projectToml = parse(\n tree.read(joinPathFragments(projectRoot, 'pyproject.toml'), 'utf8'),\n ) as UVPyprojectToml;\n projectToml['dependency-groups'] = {\n ...projectToml['dependency-groups'],\n [group]: mergeDeps(\n declaration,\n projectToml['dependency-groups']?.[group],\n deps,\n ),\n };\n tree.write(\n joinPathFragments(projectRoot, 'pyproject.toml'),\n stringify(projectToml),\n );\n};\n\nexport interface UvxWithDep {\n dep: string;\n version: string;\n specifier?: string;\n}\n\n/**\n * Render a uvx command for a given dependency\n * Pins the version to the one specified in versions.ts\n * Optionally specify withDeps to render uvx --with dep==version\n */\nexport const uvxCommand = (\n dep: IPyDepVersion,\n args?: string,\n withDeps?: UvxWithDep[],\n): string => {\n // Pins the tool for a one-off invocation; nothing is added to a manifest, so\n // this needs no declaration.\n return `uvx --from ${dep}${PY_VERSIONS[dep]} ${\n withDeps\n ? `${withDeps\n .map(\n ({ dep, version, specifier }) =>\n `--with ${dep}${specifier ?? '=='}${version}`,\n )\n .join(' ')} `\n : ''\n }${dep}${args ? ` ${args}` : ''}`;\n};\n\n/**\n * Resolve the PEP 503 distribution name of a Python project from its\n * `pyproject.toml` `[project].name`, falling back to normalising the supplied\n * Nx project id when the project has no readable pyproject yet.\n *\n * This is the authoritative name uv writes into `uv.lock`, so it is the value\n * that must appear in a dependent's `[project].dependencies` /\n * `[tool.uv.sources]` for `@nxlv/python` to infer the workspace dependency\n * edge. Always normalised so the result is a valid distribution name even if\n * an older project still carries a dotted `[project].name`.\n */\nconst getPyDistributionName = (\n tree: Tree,\n project: { name?: string; root: string },\n): string => {\n const pyprojectPath = joinPathFragments(project.root, 'pyproject.toml');\n const projectName = tree.exists(pyprojectPath)\n ? (readToml(tree, pyprojectPath) as unknown as UVPyprojectToml).project\n ?.name\n : undefined;\n return normalizeDistributionName(projectName ?? project.name ?? '');\n};\n\n/**\n * Add a workspace dependency from one Python project to another.\n * Adds the dependency to [project].dependencies and [tool.uv.sources].\n *\n * Both projects are passed as Nx project configurations (not names): the\n * dependency's PEP 503 distribution name is derived from its own\n * `pyproject.toml` here, so callers cannot accidentally pass the dotted Nx id\n * (which @nxlv/python splits on `.` and drops, losing the project-graph edge).\n * This is the single entry point all generators use to wire a Python workspace\n * dependency.\n */\nexport const addWorkspaceDependencyToPyProject = (\n tree: Tree,\n dependentProject: { name?: string; root: string },\n dependencyProject: { name?: string; root: string },\n): void => {\n const pyprojectPath = joinPathFragments(\n dependentProject.root,\n 'pyproject.toml',\n );\n if (!tree.exists(pyprojectPath)) {\n return;\n }\n\n const distributionName = getPyDistributionName(tree, dependencyProject);\n\n updateToml(tree, pyprojectPath, (toml: UVPyprojectToml) => {\n // Add to [project].dependencies if not already present\n const deps = toml.project?.dependencies ?? [];\n if (\n !deps.some(\n (d) =>\n d === distributionName ||\n d.startsWith(`${distributionName}>=`) ||\n d.startsWith(`${distributionName}==`),\n )\n ) {\n toml.project.dependencies = [...deps, distributionName];\n }\n\n // Add to [tool.uv.sources] with workspace = true\n toml.tool = toml.tool ?? {};\n (toml.tool as any).uv = (toml.tool as any).uv ?? {};\n (toml.tool as any).uv.sources = (toml.tool as any).uv.sources ?? {};\n (toml.tool as any).uv.sources[distributionName] = {\n workspace: true,\n };\n\n return toml;\n });\n};\n"],"names":["parse","stringify","joinPathFragments","parsePipRequirementsLine","normalizeDistributionName","readToml","updateToml","PY_VERSIONS","withPyVersions","depKey","dep","parsed","type","extras","sort","join","name","mergeDeps","declaration","existing","deps","incoming","Map","map","d","merged","get","existingKeys","Set","key","has","push","addDependenciesToPyProjectToml","tree","projectRoot","projectToml","read","project","dependencies","write","addDependenciesToDependencyGroupInPyProjectToml","group","uvxCommand","args","withDeps","version","specifier","getPyDistributionName","pyprojectPath","root","projectName","exists","undefined","addWorkspaceDependencyToPyProject","dependentProject","dependencyProject","distributionName","toml","some","startsWith","tool","uv","sources","workspace"],"mappings":"AAAA;;;CAGC,GACD,SAASA,KAAK,EAAEC,SAAS,QAAQ,cAAc;AAC/C,SAASC,iBAAiB,QAAmB,aAAa;AAC1D,SAASC,wBAAwB,QAAQ,sBAAsB;AAK/D,SAASC,yBAAyB,QAAQ,aAAU;AAEpD,SAASC,QAAQ,EAAEC,UAAU,QAAQ,YAAS;AAC9C,SAA6BC,WAAW,EAAEC,cAAc,QAAQ,gBAAa;AAE7E,wEAAwE;AACxE,yEAAyE;AACzE,wCAAwC;AACxC,MAAMC,SAAS,CAACC;IACd,MAAMC,SAASR,yBAAyBO;IACxC,IAAIC,QAAQC,SAAS,eAAe;QAClC,OAAOF;IACT;IACA,MAAMG,SAAS;WAAKF,OAAOE,MAAM,IAAI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AMgC,oBACNhC,EAAEmC,UAAU,CAAC,GAAGH,iBAAiB,EAAE,CAAC,KACpChC,EAAEmC,UAAU,CAAC,GAAGH,iBAAiB,EAAE,CAAC,IAExC;YACAC,KAAKpB,OAAO,CAACC,YAAY,GAAG;mBAAIlB;gBAAMoC;aAAiB;QACzD;QAEA,iDAAiD;QACjDC,KAAKG,IAAI,GAAGH,KAAKG,IAAI,IAAI,CAAC;QACzBH,KAAKG,IAAI,CAASC,EAAE,GAAG,AAACJ,KAAKG,IAAI,CAASC,EAAE,IAAI,CAAC;QACjDJ,KAAKG,IAAI,CAASC,EAAE,CAACC,OAAO,GAAG,AAACL,KAAKG,IAAI,CAASC,EAAE,CAACC,OAAO,IAAI,CAAC;QACjEL,KAAKG,IAAI,CAASC,EAAE,CAACC,OAAO,CAACN,iBAAiB,GAAG;YAChDO,WAAW;QACb;QAEA,OAAON;IACT;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/py.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { parse, stringify } from '@iarna/toml';\nimport { joinPathFragments, type Tree } from '@nx/devkit';\nimport { parsePipRequirementsLine } from 'pip-requirements-js';\nimport type {\n DeclaredPy,\n DependencyDeclaration,\n} from './declared-dependencies.js';\nimport { normalizeDistributionName } from './names.js';\nimport type { UVPyprojectToml } from './nxlv-python.js';\nimport { readToml, updateToml } from './toml.js';\nimport { type IPyDepVersion, PY_VERSIONS, withPyVersions } from './versions.js';\n\n// Dedup key that distinguishes bare packages from the same package with\n// extras (e.g. `foo` vs `foo[bar]`), so adding a bare dep doesn't drop a\n// previously-added variant with extras.\nconst depKey = (dep: string): string => {\n const parsed = parsePipRequirementsLine(dep);\n if (parsed?.type !== 'ProjectName') {\n return dep;\n }\n const extras = [...(parsed.extras ?? [])].sort().join(',');\n return extras ? `${parsed.name}[${extras}]` : parsed.name;\n};\n\nconst mergeDeps = (\n declaration: DependencyDeclaration,\n existing: readonly string[] | undefined,\n deps: readonly IPyDepVersion[],\n): string[] => {\n // Update deps in place by key so re-running does not reorder the list:\n // existing deps keep their position (with their version refreshed), and only\n // genuinely-new deps are appended.\n const incoming = new Map(\n withPyVersions(declaration, deps).map((d) => [depKey(d), d]),\n );\n const merged = (existing ?? []).map(\n (dep) => incoming.get(depKey(dep)) ?? dep,\n );\n const existingKeys = new Set((existing ?? []).map(depKey));\n for (const [key, dep] of incoming) {\n if (!existingKeys.has(key)) {\n merged.push(dep);\n }\n }\n return merged;\n};\n\n/**\n * Add dependencies to a pyproject.toml file\n */\nexport const addDependenciesToPyProjectToml = <\n const D extends DependencyDeclaration,\n>(\n tree: Tree,\n projectRoot: string,\n declaration: D,\n deps: readonly DeclaredPy<D>[],\n) => {\n const projectToml = parse(\n tree.read(joinPathFragments(projectRoot, 'pyproject.toml'), 'utf8'),\n ) as UVPyprojectToml;\n projectToml.project.dependencies = mergeDeps(\n declaration,\n projectToml.project?.dependencies,\n deps,\n );\n tree.write(\n joinPathFragments(projectRoot, 'pyproject.toml'),\n stringify(projectToml),\n );\n};\n\nexport const addDependenciesToDependencyGroupInPyProjectToml = <\n const D extends DependencyDeclaration,\n>(\n tree: Tree,\n projectRoot: string,\n group: string,\n declaration: D,\n deps: readonly DeclaredPy<D>[],\n) => {\n const projectToml = parse(\n tree.read(joinPathFragments(projectRoot, 'pyproject.toml'), 'utf8'),\n ) as UVPyprojectToml;\n projectToml['dependency-groups'] = {\n ...projectToml['dependency-groups'],\n [group]: mergeDeps(\n declaration,\n projectToml['dependency-groups']?.[group],\n deps,\n ),\n };\n tree.write(\n joinPathFragments(projectRoot, 'pyproject.toml'),\n stringify(projectToml),\n );\n};\n\nexport interface UvxWithDep {\n dep: string;\n version: string;\n specifier?: string;\n}\n\n/**\n * Render a uvx command for a given dependency\n * Pins the version to the one specified in versions.ts\n * Optionally specify withDeps to render uvx --with dep==version\n */\nexport const uvxCommand = (\n dep: IPyDepVersion,\n args?: string,\n withDeps?: UvxWithDep[],\n): string => {\n // Pins the tool for a one-off invocation; nothing is added to a manifest, so\n // this needs no declaration.\n return `uvx --from ${dep}${PY_VERSIONS[dep]} ${\n withDeps\n ? `${withDeps\n .map(\n ({ dep, version, specifier }) =>\n `--with ${dep}${specifier ?? '=='}${version}`,\n )\n .join(' ')} `\n : ''\n }${dep}${args ? ` ${args}` : ''}`;\n};\n\n/**\n * Resolve the PEP 503 distribution name of a Python project from its\n * `pyproject.toml` `[project].name`, falling back to normalising the supplied\n * Nx project id when the project has no readable pyproject yet.\n *\n * This is the authoritative name uv writes into `uv.lock`, so it is the value\n * that must appear in a dependent's `[project].dependencies` /\n * `[tool.uv.sources]` for `@nxlv/python` to infer the workspace dependency\n * edge. Always normalised so the result is a valid distribution name even if\n * an older project still carries a dotted `[project].name`.\n */\nconst getPyDistributionName = (\n tree: Tree,\n project: { name?: string; root: string },\n): string => {\n const pyprojectPath = joinPathFragments(project.root, 'pyproject.toml');\n const projectName = tree.exists(pyprojectPath)\n ? (readToml(tree, pyprojectPath) as unknown as UVPyprojectToml).project\n ?.name\n : undefined;\n return normalizeDistributionName(projectName ?? project.name ?? '');\n};\n\n/**\n * Add a workspace dependency from one Python project to another.\n * Adds the dependency to [project].dependencies and [tool.uv.sources].\n *\n * Both projects are passed as Nx project configurations (not names): the\n * dependency's PEP 503 distribution name is derived from its own\n * `pyproject.toml` here, so callers cannot accidentally pass the dotted Nx id\n * (which @nxlv/python splits on `.` and drops, losing the project-graph edge).\n * This is the single entry point all generators use to wire a Python workspace\n * dependency.\n */\nexport const addWorkspaceDependencyToPyProject = (\n tree: Tree,\n dependentProject: { name?: string; root: string },\n dependencyProject: { name?: string; root: string },\n): void => {\n const pyprojectPath = joinPathFragments(\n dependentProject.root,\n 'pyproject.toml',\n );\n if (!tree.exists(pyprojectPath)) {\n return;\n }\n\n const distributionName = getPyDistributionName(tree, dependencyProject);\n\n updateToml(tree, pyprojectPath, (toml: UVPyprojectToml) => {\n // Add to [project].dependencies if not already present\n const deps = toml.project?.dependencies ?? [];\n if (\n !deps.some(\n (d) =>\n d === distributionName ||\n d.startsWith(`${distributionName}>=`) ||\n d.startsWith(`${distributionName}==`),\n )\n ) {\n toml.project.dependencies = [...deps, distributionName];\n }\n\n // Add to [tool.uv.sources] with workspace = true\n toml.tool = toml.tool ?? {};\n (toml.tool as any).uv = (toml.tool as any).uv ?? {};\n (toml.tool as any).uv.sources = (toml.tool as any).uv.sources ?? {};\n (toml.tool as any).uv.sources[distributionName] = {\n workspace: true,\n };\n\n return toml;\n });\n};\n"],"names":["parse","stringify","joinPathFragments","parsePipRequirementsLine","normalizeDistributionName","readToml","updateToml","PY_VERSIONS","withPyVersions","depKey","dep","parsed","type","extras","sort","join","name","mergeDeps","declaration","existing","deps","incoming","Map","map","d","merged","get","existingKeys","Set","key","has","push","addDependenciesToPyProjectToml","tree","projectRoot","projectToml","read","project","dependencies","write","addDependenciesToDependencyGroupInPyProjectToml","group","uvxCommand","args","withDeps","version","specifier","getPyDistributionName","pyprojectPath","root","projectName","exists","undefined","addWorkspaceDependencyToPyProject","dependentProject","dependencyProject","distributionName","toml","some","startsWith","tool","uv","sources","workspace"],"mappings":"AAAA;;;CAGC,GACD,SAASA,KAAK,EAAEC,SAAS,QAAQ,cAAc;AAC/C,SAASC,iBAAiB,QAAmB,aAAa;AAC1D,SAASC,wBAAwB,QAAQ,sBAAsB;AAK/D,SAASC,yBAAyB,QAAQ,aAAa;AAEvD,SAASC,QAAQ,EAAEC,UAAU,QAAQ,YAAY;AACjD,SAA6BC,WAAW,EAAEC,cAAc,QAAQ,gBAAgB;AAEhF,wEAAwE;AACxE,yEAAyE;AACzE,wCAAwC;AACxC,MAAMC,SAAS,CAACC;IACd,MAAMC,SAASR,yBAAyBO;IACxC,IAAIC,QAAQC,SAAS,eAAe;QAClC,OAAOF;IACT;IACA,MAAMG,SAAS;WAAKF,OAAOE,MAAM,IAAI,EAAE;KAAE,CAACC,IAAI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AAU,CAAC,GAAGH,iBAAiB,EAAE,CAAC,KACpChC,EAAEmC,UAAU,CAAC,GAAGH,iBAAiB,EAAE,CAAC,IAExC;YACAC,KAAKpB,OAAO,CAACC,YAAY,GAAG;mBAAIlB;gBAAMoC;aAAiB;QACzD;QAEA,iDAAiD;QACjDC,KAAKG,IAAI,GAAGH,KAAKG,IAAI,IAAI,CAAC;QACzBH,KAAKG,IAAI,CAASC,EAAE,GAAG,AAACJ,KAAKG,IAAI,CAASC,EAAE,IAAI,CAAC;QACjDJ,KAAKG,IAAI,CAASC,EAAE,CAACC,OAAO,GAAG,AAACL,KAAKG,IAAI,CAASC,EAAE,CAACC,OAAO,IAAI,CAAC;QACjEL,KAAKG,IAAI,CAASC,EAAE,CAACC,OAAO,CAACN,iBAAiB,GAAG;YAChDO,WAAW;QACb;QAEA,OAAON;IACT;AACF,EAAE"}
@@ -3,8 +3,8 @@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { type Tree } from '@nx/devkit';
6
- import type { Containers } from '../containers';
7
- import type { Iac } from '../iac';
6
+ import type { Containers } from '../containers.js';
7
+ import type { Iac } from '../iac.js';
8
8
  export interface AddRdbConstructOptions {
9
9
  projectName: string;
10
10
  projectRoot: string;