@aws/nx-plugin 1.0.6 → 1.0.8

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 (84) hide show
  1. package/LICENSE-THIRD-PARTY +3 -3
  2. package/migrations.json +26 -1
  3. package/package.json +1 -1
  4. package/src/infra/app/__snapshots__/generator.spec.ts.snap +10 -0
  5. package/src/infra/app/files/app/README.md.template +12 -0
  6. package/src/infra/app/generator.js +8 -0
  7. package/src/infra/app/generator.js.map +1 -1
  8. package/src/migrations/latest/cache-inputs-outputs/metadata.json +3 -0
  9. package/src/migrations/latest/cache-inputs-outputs/migration.d.ts +6 -0
  10. package/src/migrations/latest/cache-inputs-outputs/migration.js +176 -0
  11. package/src/migrations/latest/cache-inputs-outputs/migration.js.map +1 -0
  12. package/src/migrations/latest/infra-test-loop/metadata.json +3 -0
  13. package/src/migrations/latest/infra-test-loop/migration.d.ts +6 -0
  14. package/src/migrations/latest/infra-test-loop/migration.js +110 -0
  15. package/src/migrations/latest/infra-test-loop/migration.js.map +1 -0
  16. package/src/migrations/latest/pin-strands-express-peer/metadata.json +3 -0
  17. package/src/migrations/latest/pin-strands-express-peer/migration.d.ts +29 -0
  18. package/src/migrations/latest/pin-strands-express-peer/migration.js +58 -0
  19. package/src/migrations/latest/pin-strands-express-peer/migration.js.map +1 -0
  20. package/src/migrations/latest/py-dynamodb-type-base-model-meta/metadata.json +3 -0
  21. package/src/migrations/latest/py-dynamodb-type-base-model-meta/migration.d.ts +6 -0
  22. package/src/migrations/latest/py-dynamodb-type-base-model-meta/migration.js +87 -0
  23. package/src/migrations/latest/py-dynamodb-type-base-model-meta/migration.js.map +1 -0
  24. package/src/migrations/latest/rdb-drop-lambda-rie/metadata.json +3 -0
  25. package/src/migrations/latest/rdb-drop-lambda-rie/migration.d.ts +6 -0
  26. package/src/migrations/latest/rdb-drop-lambda-rie/migration.js +105 -0
  27. package/src/migrations/latest/rdb-drop-lambda-rie/migration.js.map +1 -0
  28. package/src/migrations/v1.0.0-rc.90/0004-python-test-input-scoping/migration.js +8 -2
  29. package/src/migrations/v1.0.0-rc.90/0004-python-test-input-scoping/migration.js.map +1 -1
  30. package/src/open-api/py-client/files/client/__clientModuleName__.py.template +17 -6
  31. package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +4 -4
  32. package/src/py/dynamodb/files/__name__/entities/base.py.template +2 -2
  33. package/src/py/rdb/__snapshots__/generator.spec.ts.snap +20 -8
  34. package/src/py/rdb/files/Dockerfile.create-db-user.template +5 -2
  35. package/src/py/rdb/files/Dockerfile.migration.template +5 -2
  36. package/src/smithy/project/__snapshots__/generator.spec.ts.snap +9 -0
  37. package/src/smithy/project/generator.d.ts +9 -0
  38. package/src/smithy/project/generator.js +15 -0
  39. package/src/smithy/project/generator.js.map +1 -1
  40. package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +2 -0
  41. package/src/terraform/project/generator.js +2 -4
  42. package/src/terraform/project/generator.js.map +1 -1
  43. package/src/ts/agent/a2a-connection/generator.d.ts +26 -30
  44. package/src/ts/agent/a2a-connection/generator.js +9 -5
  45. package/src/ts/agent/a2a-connection/generator.js.map +1 -1
  46. package/src/ts/agent/gateway-connection/generator.d.ts +5 -7
  47. package/src/ts/agent/gateway-connection/generator.js +12 -0
  48. package/src/ts/agent/gateway-connection/generator.js.map +1 -1
  49. package/src/ts/agent/generator.d.ts +3 -8
  50. package/src/ts/agent/generator.js +16 -2
  51. package/src/ts/agent/generator.js.map +1 -1
  52. package/src/ts/agent/mcp-connection/generator.d.ts +5 -7
  53. package/src/ts/agent/mcp-connection/generator.js +12 -0
  54. package/src/ts/agent/mcp-connection/generator.js.map +1 -1
  55. package/src/ts/astro-docs/generator.d.ts +4 -4
  56. package/src/ts/astro-docs/generator.js +10 -4
  57. package/src/ts/astro-docs/generator.js.map +1 -1
  58. package/src/ts/lib/__snapshots__/generator.spec.ts.snap +1 -1
  59. package/src/ts/lib/generator.d.ts +14 -3
  60. package/src/ts/lib/generator.js +18 -7
  61. package/src/ts/lib/generator.js.map +1 -1
  62. package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +4 -2
  63. package/src/ts/rdb/files/Dockerfile.template +4 -2
  64. package/src/ts/rdb/generator.js +4 -0
  65. package/src/ts/rdb/generator.js.map +1 -1
  66. package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +102 -2
  67. package/src/utils/__snapshots__/cdk-test-setup.spec.ts.snap +25 -0
  68. package/src/utils/agent-connection/agent-connection.d.ts +28 -5
  69. package/src/utils/agent-connection/agent-connection.js +39 -14
  70. package/src/utils/agent-connection/agent-connection.js.map +1 -1
  71. package/src/utils/cdk-test-setup.d.ts +22 -0
  72. package/src/utils/cdk-test-setup.js +38 -0
  73. package/src/utils/cdk-test-setup.js.map +1 -0
  74. package/src/utils/files/cdk-test-setup/tests/global-setup.ts.template +45 -0
  75. package/src/utils/shared-constructs.js +2 -0
  76. package/src/utils/shared-constructs.js.map +1 -1
  77. package/src/utils/test/python-dependencies.d.ts +6 -0
  78. package/src/utils/test/python-dependencies.js +9 -0
  79. package/src/utils/test/python-dependencies.js.map +1 -1
  80. package/src/utils/test/warm-python-cache.js +40 -21
  81. package/src/utils/test/warm-python-cache.js.map +1 -1
  82. package/src/utils/versions.d.ts +2 -2
  83. package/src/utils/versions.js +2 -2
  84. package/src/utils/versions.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/astro-docs/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addProjectConfiguration,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type ProjectConfiguration,\n type Tree,\n} from '@nx/devkit';\nimport { addTsDependencies } from '../../utils/add-dependencies.js';\nimport { declareDependencies } from '../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { isEsmWorkspace } from '../../utils/module-format.js';\nimport { toKebabCase } from '../../utils/names.js';\nimport { getNpmScopePrefix } from '../../utils/npm-scope.js';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx.js';\nimport { getPackageManagerDisplayCommands } from '../../utils/pkg-manager.js';\nimport { ensureProjectPackageJson } from '../../utils/project-package-json.js';\nimport type { TsAstroDocsGeneratorSchema } from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface TsAstroDocsMetadata {\n readonly framework: string;\n readonly includeTranslation: boolean;\n readonly includeBlog: boolean;\n}\n\n// Each entry names the branch it belongs to, so the same declaration drives both\n// adding and the version sync.\nexport const DEPENDENCIES = declareDependencies<TsAstroDocsMetadata>()({\n ts: [\n { name: 'astro' },\n // Astro leaves `cookie` external in the prerender bundle, so the emitted\n // `dist` entry imports it directly. Node resolves that from `dist`, which\n // cannot reach astro's own nested copy, so the docs project declares it to\n // keep a compatible one in reach.\n { name: 'cookie' },\n { name: '@astrojs/starlight' },\n { name: 'starlight-blog', when: (m) => m.includeBlog },\n { name: '@strands-agents/sdk', when: (m) => m.includeTranslation },\n { name: 'commander', when: (m) => m.includeTranslation },\n { name: 'fast-glob', when: (m) => m.includeTranslation },\n { name: 'fs-extra', when: (m) => m.includeTranslation },\n { name: 'simple-git', when: (m) => m.includeTranslation },\n { name: '@types/fs-extra', when: (m) => m.includeTranslation, dev: true },\n // The translate target runs its script from the workspace root via tsx.\n { name: 'tsx', when: (m) => m.includeTranslation, dev: true, root: true },\n ],\n});\n\nexport const TS_ASTRO_DOCS_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsAstroDocsGenerator = async (\n tree: Tree,\n schema: TsAstroDocsGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const includeTranslation = !(schema.noTranslation ?? false);\n const includeBlog = !(schema.noBlog ?? false);\n const npmScopePrefix = getNpmScopePrefix(tree);\n const docsNameKebabCase = toKebabCase(schema.name);\n const fullyQualifiedName = `${npmScopePrefix}${docsNameKebabCase}`;\n // NB: interactive nx generator cli can pass empty string\n const dir = joinPathFragments(\n schema.directory || '.',\n schema.subDirectory || docsNameKebabCase,\n );\n\n const alreadyExists = projectExists(tree, fullyQualifiedName);\n\n const targets: ProjectConfiguration['targets'] = {\n // Inputs are left to Nx's implicit `[\"default\", \"^default\"]`. Astro resolves\n // imports from a dependency's source rather than its build output, and this\n // target declares no `dependsOn` for `default`'s transitive\n // `dependentTasksOutputFiles` to resolve against — so `^default` is the only\n // thing keeping a dependency's content in the hash.\n build: {\n executor: 'nx:run-commands',\n options: {\n command: 'astro build',\n cwd: dir,\n },\n outputs: [`{workspaceRoot}/${dir}/dist`],\n cache: true,\n },\n start: {\n executor: 'nx:run-commands',\n options: {\n command: 'astro dev',\n cwd: dir,\n },\n continuous: true,\n },\n serve: {\n dependsOn: ['start'],\n },\n preview: {\n executor: 'nx:run-commands',\n options: {\n command: 'astro preview',\n cwd: dir,\n },\n dependsOn: ['build'],\n continuous: true,\n },\n };\n\n if (includeTranslation) {\n targets['translate'] = {\n executor: 'nx:run-commands',\n options: {\n command: 'tsx ./scripts/translate.ts',\n cwd: dir,\n forwardAllArgs: true,\n },\n };\n }\n\n if (!alreadyExists) {\n addProjectConfiguration(tree, fullyQualifiedName, {\n name: fullyQualifiedName,\n root: dir,\n sourceRoot: joinPathFragments(dir, 'src'),\n projectType: 'application',\n targets,\n });\n }\n\n ensureProjectPackageJson(tree, { dir, fullyQualifiedName });\n\n const templateOptions = {\n fullyQualifiedName,\n title: schema.name,\n includeTranslation,\n includeBlog,\n esm: isEsmWorkspace(tree),\n pkgMgrCmd: getPackageManagerDisplayCommands().exec,\n today: new Date().toISOString().slice(0, 10),\n };\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'base'),\n dir,\n templateOptions,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // The sample blog post is always emitted above — drop it if the user opted out.\n if (!includeBlog) {\n tree.delete(\n joinPathFragments(\n dir,\n 'src',\n 'content',\n 'docs',\n 'en',\n 'blog',\n 'welcome.mdx',\n ),\n );\n }\n\n if (includeTranslation) {\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'translation'),\n dir,\n templateOptions,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n }\n\n // Recorded here and read by the declaration's predicates, so the packages\n // added below are exactly the ones the version sync will own.\n const metadata: TsAstroDocsMetadata = {\n framework: 'astro',\n includeTranslation,\n includeBlog,\n };\n addGeneratorMetadata(\n tree,\n fullyQualifiedName,\n TS_ASTRO_DOCS_GENERATOR_INFO,\n metadata,\n );\n\n addTsDependencies(tree, DEPENDENCIES, { metadata, projectRoot: dir });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_ASTRO_DOCS_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsAstroDocsGenerator;\n"],"names":["addProjectConfiguration","generateFiles","joinPathFragments","OverwriteStrategy","addTsDependencies","declareDependencies","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","isEsmWorkspace","toKebabCase","getNpmScopePrefix","addGeneratorMetadata","getGeneratorInfo","projectExists","getPackageManagerDisplayCommands","ensureProjectPackageJson","DEPENDENCIES","ts","name","when","m","includeBlog","includeTranslation","dev","root","TS_ASTRO_DOCS_GENERATOR_INFO","filename","tsAstroDocsGenerator","tree","schema","noTranslation","noBlog","npmScopePrefix","docsNameKebabCase","fullyQualifiedName","dir","directory","subDirectory","alreadyExists","targets","build","executor","options","command","cwd","outputs","cache","start","continuous","serve","dependsOn","preview","forwardAllArgs","sourceRoot","projectType","templateOptions","title","esm","pkgMgrCmd","exec","today","Date","toISOString","slice","dirname","overwriteStrategy","KeepExisting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":3,"sources":["../../../../../../packages/nx-plugin/src/ts/astro-docs/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addProjectConfiguration,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type ProjectConfiguration,\n type Tree,\n} from '@nx/devkit';\nimport { addTsDependencies } from '../../utils/add-dependencies.js';\nimport { STRANDS_PEER_DEPENDENCY_NAMES } from '../../utils/agent-connection/agent-connection.js';\nimport { declareDependencies } from '../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { isEsmWorkspace } from '../../utils/module-format.js';\nimport { toKebabCase } from '../../utils/names.js';\nimport { getNpmScopePrefix } from '../../utils/npm-scope.js';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx.js';\nimport { getPackageManagerDisplayCommands } from '../../utils/pkg-manager.js';\nimport { ensureProjectPackageJson } from '../../utils/project-package-json.js';\nimport type { TsAstroDocsGeneratorSchema } from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface TsAstroDocsMetadata {\n readonly framework: string;\n readonly includeTranslation: boolean;\n readonly includeBlog: boolean;\n}\n\n// Each entry names the branch it belongs to, so the same declaration drives both\n// adding and the version sync.\nexport const DEPENDENCIES = declareDependencies<TsAstroDocsMetadata>()({\n ts: [\n { name: 'astro' },\n // Astro leaves `cookie` external in the prerender bundle, so the emitted\n // `dist` entry imports it directly. Node resolves that from `dist`, which\n // cannot reach astro's own nested copy, so the docs project declares it to\n // keep a compatible one in reach.\n { name: 'cookie' },\n { name: '@astrojs/starlight' },\n { name: 'starlight-blog', when: (m) => m.includeBlog },\n // @strands-agents/sdk and its peers (STRANDS_PEER_DEPENDENCY_NAMES),\n // under the same includeTranslation guard — translate.ts imports strands\n // directly, and pnpm's peer-suffixing bug (see\n // STRANDS_PEER_DEPENDENCY_NAMES) needs every peer declared alongside it,\n // not just the one translate.ts happens to import.\n ...STRANDS_PEER_DEPENDENCY_NAMES.map((name) => ({\n name,\n when: (m: TsAstroDocsMetadata) => m.includeTranslation,\n })),\n { name: 'commander', when: (m) => m.includeTranslation },\n { name: 'fast-glob', when: (m) => m.includeTranslation },\n { name: 'fs-extra', when: (m) => m.includeTranslation },\n { name: 'simple-git', when: (m) => m.includeTranslation },\n { name: '@types/fs-extra', when: (m) => m.includeTranslation, dev: true },\n // The translate target runs its script from the workspace root via tsx.\n { name: 'tsx', when: (m) => m.includeTranslation, dev: true, root: true },\n ],\n});\n\nexport const TS_ASTRO_DOCS_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsAstroDocsGenerator = async (\n tree: Tree,\n schema: TsAstroDocsGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const includeTranslation = !(schema.noTranslation ?? false);\n const includeBlog = !(schema.noBlog ?? false);\n const npmScopePrefix = getNpmScopePrefix(tree);\n const docsNameKebabCase = toKebabCase(schema.name);\n const fullyQualifiedName = `${npmScopePrefix}${docsNameKebabCase}`;\n // NB: interactive nx generator cli can pass empty string\n const dir = joinPathFragments(\n schema.directory || '.',\n schema.subDirectory || docsNameKebabCase,\n );\n\n const alreadyExists = projectExists(tree, fullyQualifiedName);\n\n const targets: ProjectConfiguration['targets'] = {\n // Inputs are left to Nx's implicit `[\"default\", \"^default\"]`. Astro resolves\n // imports from a dependency's source rather than its build output, and this\n // target declares no `dependsOn` for `default`'s transitive\n // `dependentTasksOutputFiles` to resolve against — so `^default` is the only\n // thing keeping a dependency's content in the hash.\n build: {\n executor: 'nx:run-commands',\n options: {\n command: 'astro build',\n cwd: dir,\n },\n outputs: [`{workspaceRoot}/${dir}/dist`],\n cache: true,\n },\n start: {\n executor: 'nx:run-commands',\n options: {\n command: 'astro dev',\n cwd: dir,\n },\n continuous: true,\n },\n serve: {\n dependsOn: ['start'],\n },\n preview: {\n executor: 'nx:run-commands',\n options: {\n command: 'astro preview',\n cwd: dir,\n },\n dependsOn: ['build'],\n continuous: true,\n },\n };\n\n if (includeTranslation) {\n targets['translate'] = {\n executor: 'nx:run-commands',\n options: {\n command: 'tsx ./scripts/translate.ts',\n cwd: dir,\n forwardAllArgs: true,\n },\n };\n }\n\n if (!alreadyExists) {\n addProjectConfiguration(tree, fullyQualifiedName, {\n name: fullyQualifiedName,\n root: dir,\n sourceRoot: joinPathFragments(dir, 'src'),\n projectType: 'application',\n targets,\n });\n }\n\n ensureProjectPackageJson(tree, { dir, fullyQualifiedName });\n\n const templateOptions = {\n fullyQualifiedName,\n title: schema.name,\n includeTranslation,\n includeBlog,\n esm: isEsmWorkspace(tree),\n pkgMgrCmd: getPackageManagerDisplayCommands().exec,\n today: new Date().toISOString().slice(0, 10),\n };\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'base'),\n dir,\n templateOptions,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // The sample blog post is always emitted above — drop it if the user opted out.\n if (!includeBlog) {\n tree.delete(\n joinPathFragments(\n dir,\n 'src',\n 'content',\n 'docs',\n 'en',\n 'blog',\n 'welcome.mdx',\n ),\n );\n }\n\n if (includeTranslation) {\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'translation'),\n dir,\n templateOptions,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n }\n\n // Recorded here and read by the declaration's predicates, so the packages\n // added below are exactly the ones the version sync will own.\n const metadata: TsAstroDocsMetadata = {\n framework: 'astro',\n includeTranslation,\n includeBlog,\n };\n addGeneratorMetadata(\n tree,\n fullyQualifiedName,\n TS_ASTRO_DOCS_GENERATOR_INFO,\n metadata,\n );\n\n addTsDependencies(tree, DEPENDENCIES, { metadata, projectRoot: dir });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_ASTRO_DOCS_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsAstroDocsGenerator;\n"],"names":["addProjectConfiguration","generateFiles","joinPathFragments","OverwriteStrategy","addTsDependencies","STRANDS_PEER_DEPENDENCY_NAMES","declareDependencies","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","isEsmWorkspace","toKebabCase","getNpmScopePrefix","addGeneratorMetadata","getGeneratorInfo","projectExists","getPackageManagerDisplayCommands","ensureProjectPackageJson","DEPENDENCIES","ts","name","when","m","includeBlog","map","includeTranslation","dev","root","TS_ASTRO_DOCS_GENERATOR_INFO","filename","tsAstroDocsGenerator","tree","schema","noTranslation","noBlog","npmScopePrefix","docsNameKebabCase","fullyQualifiedName","dir","directory","subDirectory","alreadyExists","targets","build","executor","options","command","cwd","outputs","cache","start","continuous","serve","dependsOn","preview","forwardAllArgs","sourceRoot","projectType","templateOptions","title","esm","pkgMgrCmd","exec","today","Date","toISOString","slice","dirname","overwriteStrategy","KeepExisting","delete","metadata","framework","projectRoot","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,uBAAuB,EAEvBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,QAGZ,aAAa;AACpB,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SAASC,6BAA6B,QAAQ,mDAAmD;AACjG,SAASC,mBAAmB,QAAQ,uCAAuC;AAC3E,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,iBAAiB,QAAQ,2BAA2B;AAC7D,SACEC,oBAAoB,EACpBC,gBAAgB,EAEhBC,aAAa,QACR,oBAAoB;AAC3B,SAASC,gCAAgC,QAAQ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,IAAIC,OAAOC,WAAW,GAAGC,KAAK,CAAC,GAAG;IAC3C;IAEAjE,cACE8B,MACA7B,kBAAkB,YAAYiE,OAAO,EAAE,SAAS,SAChD7B,KACAoB,iBACA;QAAEU,mBAAmBjE,kBAAkBkE,YAAY;IAAC;IAGtD,gFAAgF;IAChF,IAAI,CAAC9C,aAAa;QAChBQ,KAAKuC,MAAM,CACTpE,kBACEoC,KACA,OACA,WACA,QACA,MACA,QACA;IAGN;IAEA,IAAIb,oBAAoB;QACtBxB,cACE8B,MACA7B,kBAAkB,YAAYiE,OAAO,EAAE,SAAS,gBAChD7B,KACAoB,iBACA;YAAEU,mBAAmBjE,kBAAkBkE,YAAY;QAAC;IAExD;IAEA,0EAA0E;IAC1E,8DAA8D;IAC9D,MAAME,WAAgC;QACpCC,WAAW;QACX/C;QACAF;IACF;IACAV,qBACEkB,MACAM,oBACAT,8BACA2C;IAGFnE,kBAAkB2B,MAAMb,cAAc;QAAEqD;QAAUE,aAAanC;IAAI;IAEnE,MAAM7B,gCAAgCsB,MAAM;QAACH;KAA6B;IAE1E,MAAMrB,qBAAqBwB;IAC3B,OAAO,IACLvB,oBAAoBuB,MAAMC,OAAO0C,yBAAyB,EAAE;YAC1DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAe7C,qBAAqB"}
@@ -59,7 +59,7 @@ exports[`ts lib generator > should configure named inputs in nx.json 1`] = `
59
59
  "biome": ["default", "{workspaceRoot}/biome.json"],
60
60
  "default": [
61
61
  {
62
- "dependentTasksOutputFiles": "!{reports,coverage}/**",
62
+ "dependentTasksOutputFiles": "!{reports/**,coverage/**,dist/**/checkov/checkov_report.json,dist/**/test-output/vitest/coverage/**}",
63
63
  "transitive": true
64
64
  }
65
65
  ]
@@ -34,14 +34,25 @@ export declare const TS_LIB_GENERATOR_INFO: NxGeneratorInfo;
34
34
  * generators emit generated sources outside `dist` (an OpenAPI client under a
35
35
  * website's `src/generated`, a Smithy SSDK, the Prisma client) and add them to
36
36
  * `.gitignore`, which keeps them out of the project's own fileset — so this
37
- * input is the only thing that hashes them. `reports/` and `coverage/` hold
38
- * pytest's JUnit and coverage XML, which carry a wall-clock timestamp and so
39
- * mint a fresh hash on every test run that would cascade through the graph.
37
+ * input is the only thing that hashes them.
38
+ *
39
+ * The excluded paths are reports nothing downstream reads, and each is
40
+ * rewritten on every run that produces it, which would mint a fresh hash that
41
+ * cascades through the graph:
42
+ * - `reports/` and `coverage/` hold pytest's JUnit and coverage XML, which
43
+ * carry a wall-clock timestamp.
44
+ * - `dist/<project>/checkov/checkov_report.json` is the report a CDK or Terraform
45
+ * project's checkov scan writes, rewritten whenever the scan is uncached.
46
+ * - `dist/<project>/test-output/vitest/coverage/` is vitest's coverage output.
47
+ *
48
+ * Each report is matched by its full path, so a project whose path contains a
49
+ * `checkov` or `coverage` segment keeps its build output hashed.
40
50
  */
41
51
  export declare const DEPENDENT_TASKS_OUTPUT_FILES_INPUT: {
42
52
  dependentTasksOutputFiles: string;
43
53
  transitive: boolean;
44
54
  };
55
+ export declare const VENDED_DEPENDENT_TASKS_OUTPUT_GLOBS: string[];
45
56
  export interface TsLibDetails {
46
57
  /**
47
58
  * Full package name including scope (eg @foo/bar)
@@ -30,19 +30,30 @@ export const TS_LIB_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
30
30
  * generators emit generated sources outside `dist` (an OpenAPI client under a
31
31
  * website's `src/generated`, a Smithy SSDK, the Prisma client) and add them to
32
32
  * `.gitignore`, which keeps them out of the project's own fileset — so this
33
- * input is the only thing that hashes them. `reports/` and `coverage/` hold
34
- * pytest's JUnit and coverage XML, which carry a wall-clock timestamp and so
35
- * mint a fresh hash on every test run that would cascade through the graph.
33
+ * input is the only thing that hashes them.
34
+ *
35
+ * The excluded paths are reports nothing downstream reads, and each is
36
+ * rewritten on every run that produces it, which would mint a fresh hash that
37
+ * cascades through the graph:
38
+ * - `reports/` and `coverage/` hold pytest's JUnit and coverage XML, which
39
+ * carry a wall-clock timestamp.
40
+ * - `dist/<project>/checkov/checkov_report.json` is the report a CDK or Terraform
41
+ * project's checkov scan writes, rewritten whenever the scan is uncached.
42
+ * - `dist/<project>/test-output/vitest/coverage/` is vitest's coverage output.
43
+ *
44
+ * Each report is matched by its full path, so a project whose path contains a
45
+ * `checkov` or `coverage` segment keeps its build output hashed.
36
46
  */ export const DEPENDENT_TASKS_OUTPUT_FILES_INPUT = {
37
- dependentTasksOutputFiles: '!{reports,coverage}/**',
47
+ dependentTasksOutputFiles: '!{reports/**,coverage/**,dist/**/checkov/checkov_report.json,dist/**/test-output/vitest/coverage/**}',
38
48
  transitive: true
39
49
  };
40
50
  // Globs this generator has vended for the dependent-task-output input. Any of
41
- // them is replaced in place, so the entry is neither duplicated nor left at a
42
- // different scope when a generator re-runs.
43
- const VENDED_DEPENDENT_TASKS_OUTPUT_GLOBS = [
51
+ // them is replaced, so the entry is neither duplicated nor left at a different
52
+ // scope when a generator or migration re-runs.
53
+ export const VENDED_DEPENDENT_TASKS_OUTPUT_GLOBS = [
44
54
  '**/*',
45
55
  'dist/**',
56
+ '!{reports,coverage}/**',
46
57
  DEPENDENT_TASKS_OUTPUT_FILES_INPUT.dependentTasksOutputFiles
47
58
  ];
48
59
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n type NxJsonConfiguration,\n OverwriteStrategy,\n readProjectConfiguration,\n type TargetConfiguration,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { libraryGenerator } from '@nx/js';\nimport { declareDependencies } from '../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { isEsmWorkspace } from '../../utils/module-format.js';\nimport { toKebabCase } from '../../utils/names.js';\nimport { getNpmScopePrefix } from '../../utils/npm-scope.js';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n mergeTarget,\n mergeTargetDefault,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx.js';\nimport { sortObjectKeys } from '../../utils/object.js';\nimport { getPackageManagerDisplayCommands } from '../../utils/pkg-manager.js';\nimport type { TsProjectGeneratorSchema } from './schema';\nimport {\n configureTsProject,\n TS_PROJECT_DEPENDENCIES,\n} from './ts-project-utils.js';\nimport { VITEST_DEPENDENCIES } from './vitest.js';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [...VITEST_DEPENDENCIES, ...TS_PROJECT_DEPENDENCIES],\n});\n\nexport const TS_LIB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\n/**\n * Consumes build artifacts produced by a project's dependencies, so a task\n * re-runs when the output it actually reads changes.\n *\n * Test reports are excluded rather than build artifacts included: several\n * generators emit generated sources outside `dist` (an OpenAPI client under a\n * website's `src/generated`, a Smithy SSDK, the Prisma client) and add them to\n * `.gitignore`, which keeps them out of the project's own fileset — so this\n * input is the only thing that hashes them. `reports/` and `coverage/` hold\n * pytest's JUnit and coverage XML, which carry a wall-clock timestamp and so\n * mint a fresh hash on every test run that would cascade through the graph.\n */\nexport const DEPENDENT_TASKS_OUTPUT_FILES_INPUT = {\n dependentTasksOutputFiles: '!{reports,coverage}/**',\n transitive: true,\n};\n\n// Globs this generator has vended for the dependent-task-output input. Any of\n// them is replaced in place, so the entry is neither duplicated nor left at a\n// different scope when a generator re-runs.\nconst VENDED_DEPENDENT_TASKS_OUTPUT_GLOBS = [\n '**/*',\n 'dist/**',\n DEPENDENT_TASKS_OUTPUT_FILES_INPUT.dependentTasksOutputFiles,\n];\n\nexport interface TsLibDetails {\n /**\n * Full package name including scope (eg @foo/bar)\n */\n readonly fullyQualifiedName: string;\n /**\n * Directory of the library relative to the root\n */\n readonly dir: string;\n}\n\n/**\n * Returns details about the TS library to be created\n */\nexport const getTsLibDetails = (\n tree: Tree,\n schema: TsProjectGeneratorSchema,\n): TsLibDetails => {\n const scope = getNpmScopePrefix(tree);\n const normalizedName = toKebabCase(schema.name);\n const fullyQualifiedName = `${scope}${normalizedName}`;\n // NB: interactive nx generator cli can pass empty string\n const dir = joinPathFragments(\n schema.directory || '.',\n schema.subDirectory || normalizedName,\n );\n return { dir, fullyQualifiedName };\n};\n\n/**\n * Generates a typescript project\n */\nexport const tsProjectGenerator = async (\n tree: Tree,\n schema: TsProjectGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, schema);\n // The module format is workspace-wide, established by the preset when the\n // workspace is created, so vending generators always infer it from the tree.\n const esm = isEsmWorkspace(tree);\n\n // Only scaffold the project on first run; on re-run skip creation so user\n // edits are preserved, but continue to (re)apply the configuration below.\n if (!projectExists(tree, fullyQualifiedName)) {\n await libraryGenerator(tree, {\n ...schema,\n name: fullyQualifiedName,\n directory: dir,\n skipPackageJson: true,\n bundler: 'tsc', // TODO: consider supporting others\n linter: 'none',\n unitTestRunner: 'vitest',\n // Register the @nx/vitest plugin so the test target is inferred rather\n // than emitting the deprecated @nx/vitest:test executor target.\n addPlugin: true,\n });\n\n // Replace with simpler sample source code\n tree.delete(joinPathFragments(dir, 'src'));\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n joinPathFragments(dir),\n {\n fullyQualifiedName,\n esm,\n pkgMgrCmd: getPackageManagerDisplayCommands().exec,\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n }\n await configureTsProject(\n tree,\n {\n dir,\n fullyQualifiedName,\n esm,\n },\n DEPENDENCIES,\n );\n\n const projectConfiguration = readProjectConfiguration(\n tree,\n fullyQualifiedName,\n );\n const targets = projectConfiguration.targets;\n\n // Merged rather than assigned so a re-run converges this generator's own\n // configuration without discarding what other generators contributed to the\n // same targets — the `bundle` that ts#lambda-function adds to build and\n // assemble, say, which those targets must keep depending on.\n targets['compile'] = mergeTarget(targets['compile'], {\n executor: 'nx:run-commands',\n outputs: ['{workspaceRoot}/dist/{projectRoot}/tsc'],\n options: {\n command: 'tsc --build tsconfig.lib.json',\n cwd: '{projectRoot}',\n },\n });\n targets['build'] = mergeTarget(targets['build'], {\n dependsOn: ['lint', 'compile', 'test'],\n });\n // The artifact-only sibling of build, which the deploy targets depend on.\n targets['assemble'] = mergeTarget(targets['assemble'], {\n dependsOn: ['compile'],\n });\n projectConfiguration.targets = sortObjectKeys(targets);\n\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfiguration);\n\n addGeneratorMetadata(tree, fullyQualifiedName, TS_LIB_GENERATOR_INFO);\n\n updateJson(tree, 'nx.json', (nxJson: NxJsonConfiguration) => {\n nxJson.namedInputs = {\n ...nxJson.namedInputs,\n default: [\n ...(nxJson.namedInputs?.default ?? []).filter(\n (input) =>\n typeof input !== 'object' ||\n !('dependentTasksOutputFiles' in input) ||\n !(\n VENDED_DEPENDENT_TASKS_OUTPUT_GLOBS.includes(\n input.dependentTasksOutputFiles as string,\n ) && input.transitive\n ),\n ),\n DEPENDENT_TASKS_OUTPUT_FILES_INPUT,\n ],\n };\n\n const withDefaultInput = (base: Partial<TargetConfiguration>) => ({\n ...base,\n inputs: [\n ...(base.inputs ?? []).filter((i) => i !== 'default'),\n 'default',\n ],\n });\n\n nxJson.targetDefaults = {\n ...nxJson.targetDefaults,\n compile: mergeTargetDefault(nxJson.targetDefaults?.compile, (base) => ({\n cache: true,\n ...withDefaultInput(base),\n })),\n build: mergeTargetDefault(nxJson.targetDefaults?.build, (base) => ({\n cache: true,\n ...withDefaultInput(base),\n })),\n test: mergeTargetDefault(nxJson.targetDefaults?.test, withDefaultInput),\n };\n\n // Ensure we only declare a single typescript plugin with the correct settings\n nxJson.plugins = [\n {\n plugin: '@nx/js/typescript',\n options: {\n typecheck: {\n targetName: 'typecheck',\n },\n build: {\n targetName: 'compile',\n configName: 'tsconfig.lib.json',\n buildDepsName: 'build-deps',\n watchDepsName: 'watch-deps',\n },\n },\n },\n ...(nxJson.plugins ?? []).filter(\n (p) => typeof p === 'string' || p.plugin !== '@nx/js/typescript',\n ),\n ];\n\n return nxJson;\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_LIB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n\n // `installDependencies` ensures vitest resolves for the `typescript` language (the\n // generated vitest.config.mts imports it and Nx loads that config when\n // computing the project graph), so a deferred install still runs when needed.\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\nexport default tsProjectGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readProjectConfiguration","updateJson","updateProjectConfiguration","libraryGenerator","declareDependencies","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","isEsmWorkspace","toKebabCase","getNpmScopePrefix","addGeneratorMetadata","getGeneratorInfo","mergeTarget","mergeTargetDefault","projectExists","sortObjectKeys","getPackageManagerDisplayCommands","configureTsProject","TS_PROJECT_DEPENDENCIES","VITEST_DEPENDENCIES","DEPENDENCIES","ts","TS_LIB_GENERATOR_INFO","filename","DEPENDENT_TASKS_OUTPUT_FILES_INPUT","dependentTasksOutputFiles","transitive","VENDED_DEPENDENT_TASKS_OUTPUT_GLOBS","getTsLibDetails","tree","schema","scope","normalizedName","name","fullyQualifiedName","dir","directory","subDirectory","tsProjectGenerator","esm","skipPackageJson","bundler","linter","unitTestRunner","addPlugin","delete","dirname","pkgMgrCmd","exec","overwriteStrategy","KeepExisting","projectConfiguration","targets","executor","outputs","options","command","cwd","dependsOn","nxJson","namedInputs","default","filter","input","includes","withDefaultInput","base","inputs","i","targetDefaults","compile","cache","build","test","plugins","plugin","typecheck","targetName","configName","buildDepsName","watchDepsName","p","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EA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AY;wBACZC,eAAe;wBACfC,eAAe;oBACjB;gBACF;YACF;eACG,AAACrB,CAAAA,OAAOe,OAAO,IAAI,EAAE,AAAD,EAAGZ,MAAM,CAC9B,CAACmB,IAAM,OAAOA,MAAM,YAAYA,EAAEN,MAAM,KAAK;SAEhD;QAED,OAAOhB;IACT;IAEA,MAAMrD,gCAAgCuB,MAAM;QAACP;KAAsB;IAEnE,MAAMlB,qBAAqByB;IAE3B,mFAAmF;IACnF,uEAAuE;IACvE,8EAA8E;IAC9E,OAAO,IACLxB,oBAAoBwB,MAAMC,OAAOoD,yBAAyB,EAAE;YAC1DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AACF,eAAe7C,mBAAmB"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n type NxJsonConfiguration,\n OverwriteStrategy,\n readProjectConfiguration,\n type TargetConfiguration,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { libraryGenerator } from '@nx/js';\nimport { declareDependencies } from '../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { isEsmWorkspace } from '../../utils/module-format.js';\nimport { toKebabCase } from '../../utils/names.js';\nimport { getNpmScopePrefix } from '../../utils/npm-scope.js';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n mergeTarget,\n mergeTargetDefault,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx.js';\nimport { sortObjectKeys } from '../../utils/object.js';\nimport { getPackageManagerDisplayCommands } from '../../utils/pkg-manager.js';\nimport type { TsProjectGeneratorSchema } from './schema';\nimport {\n configureTsProject,\n TS_PROJECT_DEPENDENCIES,\n} from './ts-project-utils.js';\nimport { VITEST_DEPENDENCIES } from './vitest.js';\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [...VITEST_DEPENDENCIES, ...TS_PROJECT_DEPENDENCIES],\n});\n\nexport const TS_LIB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\n/**\n * Consumes build artifacts produced by a project's dependencies, so a task\n * re-runs when the output it actually reads changes.\n *\n * Test reports are excluded rather than build artifacts included: several\n * generators emit generated sources outside `dist` (an OpenAPI client under a\n * website's `src/generated`, a Smithy SSDK, the Prisma client) and add them to\n * `.gitignore`, which keeps them out of the project's own fileset — so this\n * input is the only thing that hashes them.\n *\n * The excluded paths are reports nothing downstream reads, and each is\n * rewritten on every run that produces it, which would mint a fresh hash that\n * cascades through the graph:\n * - `reports/` and `coverage/` hold pytest's JUnit and coverage XML, which\n * carry a wall-clock timestamp.\n * - `dist/<project>/checkov/checkov_report.json` is the report a CDK or Terraform\n * project's checkov scan writes, rewritten whenever the scan is uncached.\n * - `dist/<project>/test-output/vitest/coverage/` is vitest's coverage output.\n *\n * Each report is matched by its full path, so a project whose path contains a\n * `checkov` or `coverage` segment keeps its build output hashed.\n */\nexport const DEPENDENT_TASKS_OUTPUT_FILES_INPUT = {\n dependentTasksOutputFiles:\n '!{reports/**,coverage/**,dist/**/checkov/checkov_report.json,dist/**/test-output/vitest/coverage/**}',\n transitive: true,\n};\n\n// Globs this generator has vended for the dependent-task-output input. Any of\n// them is replaced, so the entry is neither duplicated nor left at a different\n// scope when a generator or migration re-runs.\nexport const VENDED_DEPENDENT_TASKS_OUTPUT_GLOBS = [\n '**/*',\n 'dist/**',\n '!{reports,coverage}/**',\n DEPENDENT_TASKS_OUTPUT_FILES_INPUT.dependentTasksOutputFiles,\n];\n\nexport interface TsLibDetails {\n /**\n * Full package name including scope (eg @foo/bar)\n */\n readonly fullyQualifiedName: string;\n /**\n * Directory of the library relative to the root\n */\n readonly dir: string;\n}\n\n/**\n * Returns details about the TS library to be created\n */\nexport const getTsLibDetails = (\n tree: Tree,\n schema: TsProjectGeneratorSchema,\n): TsLibDetails => {\n const scope = getNpmScopePrefix(tree);\n const normalizedName = toKebabCase(schema.name);\n const fullyQualifiedName = `${scope}${normalizedName}`;\n // NB: interactive nx generator cli can pass empty string\n const dir = joinPathFragments(\n schema.directory || '.',\n schema.subDirectory || normalizedName,\n );\n return { dir, fullyQualifiedName };\n};\n\n/**\n * Generates a typescript project\n */\nexport const tsProjectGenerator = async (\n tree: Tree,\n schema: TsProjectGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, schema);\n // The module format is workspace-wide, established by the preset when the\n // workspace is created, so vending generators always infer it from the tree.\n const esm = isEsmWorkspace(tree);\n\n // Only scaffold the project on first run; on re-run skip creation so user\n // edits are preserved, but continue to (re)apply the configuration below.\n if (!projectExists(tree, fullyQualifiedName)) {\n await libraryGenerator(tree, {\n ...schema,\n name: fullyQualifiedName,\n directory: dir,\n skipPackageJson: true,\n bundler: 'tsc', // TODO: consider supporting others\n linter: 'none',\n unitTestRunner: 'vitest',\n // Register the @nx/vitest plugin so the test target is inferred rather\n // than emitting the deprecated @nx/vitest:test executor target.\n addPlugin: true,\n });\n\n // Replace with simpler sample source code\n tree.delete(joinPathFragments(dir, 'src'));\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n joinPathFragments(dir),\n {\n fullyQualifiedName,\n esm,\n pkgMgrCmd: getPackageManagerDisplayCommands().exec,\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n }\n await configureTsProject(\n tree,\n {\n dir,\n fullyQualifiedName,\n esm,\n },\n DEPENDENCIES,\n );\n\n const projectConfiguration = readProjectConfiguration(\n tree,\n fullyQualifiedName,\n );\n const targets = projectConfiguration.targets;\n\n // Merged rather than assigned so a re-run converges this generator's own\n // configuration without discarding what other generators contributed to the\n // same targets — the `bundle` that ts#lambda-function adds to build and\n // assemble, say, which those targets must keep depending on.\n targets['compile'] = mergeTarget(targets['compile'], {\n executor: 'nx:run-commands',\n outputs: ['{workspaceRoot}/dist/{projectRoot}/tsc'],\n options: {\n command: 'tsc --build tsconfig.lib.json',\n cwd: '{projectRoot}',\n },\n });\n targets['build'] = mergeTarget(targets['build'], {\n dependsOn: ['lint', 'compile', 'test'],\n });\n // The artifact-only sibling of build, which the deploy targets depend on.\n targets['assemble'] = mergeTarget(targets['assemble'], {\n dependsOn: ['compile'],\n });\n projectConfiguration.targets = sortObjectKeys(targets);\n\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfiguration);\n\n addGeneratorMetadata(tree, fullyQualifiedName, TS_LIB_GENERATOR_INFO);\n\n updateJson(tree, 'nx.json', (nxJson: NxJsonConfiguration) => {\n nxJson.namedInputs = {\n ...nxJson.namedInputs,\n default: [\n ...(nxJson.namedInputs?.default ?? []).filter(\n (input) =>\n typeof input !== 'object' ||\n !('dependentTasksOutputFiles' in input) ||\n !(\n VENDED_DEPENDENT_TASKS_OUTPUT_GLOBS.includes(\n input.dependentTasksOutputFiles as string,\n ) && input.transitive\n ),\n ),\n DEPENDENT_TASKS_OUTPUT_FILES_INPUT,\n ],\n };\n\n const withDefaultInput = (base: Partial<TargetConfiguration>) => ({\n ...base,\n inputs: [\n ...(base.inputs ?? []).filter((i) => i !== 'default'),\n 'default',\n ],\n });\n\n nxJson.targetDefaults = {\n ...nxJson.targetDefaults,\n compile: mergeTargetDefault(nxJson.targetDefaults?.compile, (base) => ({\n cache: true,\n ...withDefaultInput(base),\n })),\n build: mergeTargetDefault(nxJson.targetDefaults?.build, (base) => ({\n cache: true,\n ...withDefaultInput(base),\n })),\n test: mergeTargetDefault(nxJson.targetDefaults?.test, withDefaultInput),\n };\n\n // Ensure we only declare a single typescript plugin with the correct settings\n nxJson.plugins = [\n {\n plugin: '@nx/js/typescript',\n options: {\n typecheck: {\n targetName: 'typecheck',\n },\n build: {\n targetName: 'compile',\n configName: 'tsconfig.lib.json',\n buildDepsName: 'build-deps',\n watchDepsName: 'watch-deps',\n },\n },\n },\n ...(nxJson.plugins ?? []).filter(\n (p) => typeof p === 'string' || p.plugin !== '@nx/js/typescript',\n ),\n ];\n\n return nxJson;\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_LIB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n\n // `installDependencies` ensures vitest resolves for the `typescript` language (the\n // generated vitest.config.mts imports it and Nx loads that config when\n // computing the project graph), so a deferred install still runs when needed.\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\nexport default tsProjectGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readProjectConfiguration","updateJson","updateProjectConfiguration","libraryGenerator","declareDependencies","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","isEsmWorkspace","toKebabCase","getNpmScopePrefix","addGeneratorMetadata","getGeneratorInfo","mergeTarget","mergeTargetDefault","projectExists","sortObjectKeys","getPackageManagerDisplayCommands","configureTsProject","TS_PROJECT_DEPENDENCIES","VITEST_DEPENDENCIES","DEPENDENCIES","ts","TS_LIB_GENERATOR_INFO","filename","DEPENDENT_TASKS_OUTPUT_FILES_INPUT","dependentTasksOutputFiles","transitive","VENDED_DEPENDENT_TASKS_OUTPUT_GLOBS","getTsLibDetails","tree","schema","scope","normalizedName","name","fullyQualifiedName","dir","directory","subDirectory","tsProjectGenerator","esm","skipPackageJson","bundler","linter","unitTestRunner","addPlugin","delete","dirname","pkgMgrCmd","exec","overwriteStrategy","KeepExisting","projectConfiguration","targets","executor","outputs","options","command","cwd","dependsOn","nxJson","namedInputs","default","filter","input","includes","withDefaultInput","base","inputs","i","targetDefaults","compile","cache","build","test","plugins","plugin","typecheck","targetName","configName","buildDepsName","watchDepsName","p","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EAEjBC,iBAAiB,EACjBC,wBAAwB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BACZC,eAAe;wBACfC,eAAe;oBACjB;gBACF;YACF;eACG,AAACrB,CAAAA,OAAOe,OAAO,IAAI,EAAE,AAAD,EAAGZ,MAAM,CAC9B,CAACmB,IAAM,OAAOA,MAAM,YAAYA,EAAEN,MAAM,KAAK;SAEhD;QAED,OAAOhB;IACT;IAEA,MAAMrD,gCAAgCuB,MAAM;QAACP;KAAsB;IAEnE,MAAMlB,qBAAqByB;IAE3B,mFAAmF;IACnF,uEAAuE;IACvE,8EAA8E;IAC9E,OAAO,IACLxB,oBAAoBwB,MAAMC,OAAOoD,yBAAyB,EAAE;YAC1DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AACF,eAAe7C,mBAAmB"}
@@ -4525,9 +4525,11 @@ RUN npm install -g npm@12.2.0
4525
4525
  # Patch OS packages beyond the base image's pinned release, and drop the
4526
4526
  # runtime's convenience copy of the AWS SDK (the handler bundle inlines its
4527
4527
  # own dependencies), keeping the image free of known HIGH/CRITICAL
4528
- # vulnerabilities
4528
+ # vulnerabilities. Also drop the Lambda Runtime Interface Emulator: it is only
4529
+ # used for local \`docker run\` emulation outside Lambda, never by the deployed
4530
+ # function, and carries known HIGH vulnerabilities.
4529
4531
  RUN microdnf upgrade -y --releasever latest && microdnf clean all \\
4530
- && rm -rf /var/runtime/node_modules/@aws-sdk
4532
+ && rm -rf /var/runtime/node_modules/@aws-sdk /usr/local/bin/aws-lambda-rie
4531
4533
 
4532
4534
  WORKDIR \${LAMBDA_TASK_ROOT}
4533
4535
 
@@ -6,9 +6,11 @@ RUN npm install -g npm@<%= npmVersion %>
6
6
  # Patch OS packages beyond the base image's pinned release, and drop the
7
7
  # runtime's convenience copy of the AWS SDK (the handler bundle inlines its
8
8
  # own dependencies), keeping the image free of known HIGH/CRITICAL
9
- # vulnerabilities
9
+ # vulnerabilities. Also drop the Lambda Runtime Interface Emulator: it is only
10
+ # used for local `docker run` emulation outside Lambda, never by the deployed
11
+ # function, and carries known HIGH vulnerabilities.
10
12
  RUN microdnf upgrade -y --releasever latest && microdnf clean all \
11
- && rm -rf /var/runtime/node_modules/@aws-sdk
13
+ && rm -rf /var/runtime/node_modules/@aws-sdk /usr/local/bin/aws-lambda-rie
12
14
 
13
15
  WORKDIR ${LAMBDA_TASK_ROOT}
14
16
 
@@ -224,6 +224,10 @@ export const tsRdbGenerator = async (tree, options)=>{
224
224
  }
225
225
  projectConfig.targets.generate = {
226
226
  executor: 'nx:run-commands',
227
+ cache: true,
228
+ inputs: [
229
+ 'default'
230
+ ],
227
231
  outputs: [
228
232
  '{projectRoot}/generated/prisma'
229
233
  ],
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/rdb/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { relative } from 'node:path';\nimport {\n detectPackageManager,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readProjectConfiguration,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n writeJson,\n} from '@nx/devkit';\nimport { addTsDependencies } from '../../utils/add-dependencies.js';\nimport { addStarExport } from '../../utils/ast.js';\nimport {\n addTypeScriptBundleTarget,\n BUNDLE_DEPENDENCIES,\n} from '../../utils/bundle/bundle.js';\nimport { resolveContainers } from '../../utils/containers.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies.js';\nimport {\n addDockerScanTarget,\n DOCKER_DEPENDENCIES,\n IMAGE_BUILD_CACHE,\n NODE_IMAGE_DEPENDENCIES,\n nodeImageVersions,\n PRISMA_IMAGE_DEPENDENCIES,\n} from '../../utils/docker.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs.js';\nimport { updateGitIgnore } from '../../utils/git.js';\nimport { resolveIac } from '../../utils/iac.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { esmVars } from '../../utils/module-format.js';\nimport { kebabCase, snakeCase, toClassName } from '../../utils/names.js';\nimport { getNpmScope } from '../../utils/npm-scope.js';\nimport {\n addArtifactDependencyToTargets,\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../utils/nx.js';\nimport { getRelativePathToRootByDirectory } from '../../utils/paths.js';\nimport { registerPnpmBuiltDependencies } from '../../utils/pnpm-workspace.js';\nimport { assignPort } from '../../utils/port.js';\nimport { addRdbInfra } from '../../utils/rdb-constructs/rdb-constructs.js';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs.js';\nimport {\n type IacMetadata,\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n} from '../../utils/shared-constructs-constants.js';\nimport {\n SHARED_RDB_SCRIPTS_DEPENDENCIES,\n sharedRdbScriptsGenerator,\n} from '../../utils/shared-rdb-scripts.js';\nimport { TS_VERSIONS } from '../../utils/versions.js';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator.js';\nimport type { TsRdbGeneratorSchema } from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface TsRdbMetadata extends IacMetadata {\n readonly engine: TsRdbGeneratorSchema['engine'];\n}\n\n// Each entry names the engine branch it belongs to, so the same declaration\n// drives both adding and the version sync.\nexport const DEPENDENCIES = declareDependencies<TsRdbMetadata>()({\n ts: [\n { name: '@aws-lambda-powertools/parameters' },\n { name: '@aws-sdk/client-appconfigdata' },\n { name: '@aws-sdk/client-secrets-manager' },\n { name: '@aws-sdk/rds-signer' },\n { name: '@prisma/client' },\n { name: '@prisma/adapter-mariadb', when: (m) => m.engine === 'mysql' },\n { name: 'mariadb', when: (m) => m.engine === 'mysql' },\n { name: '@prisma/adapter-pg', when: (m) => m.engine !== 'mysql' },\n { name: 'pg', when: (m) => m.engine !== 'mysql' },\n { name: '@types/aws-lambda', dev: true },\n { name: '@types/pg', when: (m) => m.engine !== 'mysql', dev: true },\n // The prisma CLI and tsx run migration/seed scripts from the root.\n { name: 'prisma', dev: true, root: true },\n { name: 'tsx', dev: true, root: true },\n ...ownedElsewhere(BUNDLE_DEPENDENCIES),\n ...ownedElsewhere(FS_DEPENDENCIES),\n ...ownedElsewhere(DOCKER_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ...ownedElsewhere(SHARED_RDB_SCRIPTS_DEPENDENCIES),\n ...ownedElsewhere(NODE_IMAGE_DEPENDENCIES),\n ...ownedElsewhere(PRISMA_IMAGE_DEPENDENCIES),\n ],\n});\n\nexport const TS_RDB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsRdbGenerator = async (\n tree: Tree,\n options: TsRdbGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const nameKebabCase = kebabCase(options.name);\n const nameClassName = toClassName(options.name);\n const databaseUser = options.databaseUser ?? 'dbadmin';\n const databaseName = snakeCase(options.databaseName ?? options.name);\n const containerEngine = await resolveContainers(tree, 'inherit');\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n });\n\n let projectExists: boolean;\n try {\n readProjectConfiguration(tree, fullyQualifiedName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n await tsProjectGenerator(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n preferInstallDependencies: false,\n });\n }\n\n updateJson(tree, joinPathFragments(dir, 'tsconfig.lib.json'), (tsConfig) => ({\n ...tsConfig,\n include: ['src/**/*.ts', 'generated/prisma/**/*.ts'],\n }));\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n const localDbPort = assignPort(\n tree,\n projectConfig,\n options.engine === 'mysql' ? 3306 : 5432,\n );\n const localDbHost = 'localhost';\n const localDbUser = options.engine === 'mysql' ? 'root' : 'dbadmin';\n const localDbPassword = 'password';\n const containerName = `${getNpmScope(tree)}-${databaseName}`;\n const dockerImage =\n options.engine === 'mysql'\n ? 'public.ecr.aws/docker/library/mysql:8.0.44'\n : 'public.ecr.aws/docker/library/postgres:17.7';\n\n const templateOptions = {\n engine: options.engine,\n runtimeConfigKey: nameClassName,\n databasePackageAlias: fullyQualifiedName,\n databaseProvider: options.engine === 'mysql' ? 'mysql' : 'postgresql',\n prismaVersion: TS_VERSIONS.prisma,\n deepmergeTsVersion: TS_VERSIONS['deepmerge-ts'],\n mysql2Version: TS_VERSIONS.mysql2,\n ...nodeImageVersions(),\n prismaAdapterPackage:\n options.engine === 'mysql'\n ? '@prisma/adapter-mariadb'\n : '@prisma/adapter-pg',\n prismaAdapterClassName:\n options.engine === 'mysql' ? 'PrismaMariaDb' : 'PrismaPg',\n localDbPort,\n localDbHost,\n localDbName: databaseName,\n localDbUser,\n localDbPassword,\n containerEngine,\n containerName,\n dockerImage,\n ...esmVars(tree),\n };\n\n // The Prisma schema and models, the handlers and the prisma client module are\n // all user-editable, so a re-run (to add infrastructure, or after a failed\n // run) must not clobber the user's schema and edits.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n dir,\n templateOptions,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // The barrel re-exports prisma.ts. `tsProjectGenerator` writes a stub index.ts\n // when it creates the project, so the re-export is added to whatever is there\n // rather than replacing it — which also leaves a user's own additions to the\n // barrel alone on a re-run.\n await addStarExport(\n tree,\n joinPathFragments(dir, 'src', 'index.ts'),\n './prisma.js',\n );\n\n // config.json is framework-owned: it carries values derived from the\n // generator's options, so it converges on a re-run with changed options.\n writeJson(tree, joinPathFragments(dir, 'config.json'), {\n runtimeConfigKey: nameClassName,\n localDev: {\n containerEngine,\n containerName,\n image: dockerImage,\n port: localDbPort,\n host: localDbHost,\n dbName: databaseName,\n dbUser: localDbUser,\n dbPassword: localDbPassword,\n dbEngine: options.engine,\n },\n });\n updateGitIgnore(tree, dir, (patterns) => [...patterns, 'generated/prisma']);\n await sharedRdbScriptsGenerator(tree, options.engine, DEPENDENCIES);\n const waitForDbScript =\n options.engine === 'mysql'\n ? 'wait-for-mysql-db.ts'\n : 'wait-for-postgres-db.ts';\n const scriptsDir = relative(\n dir,\n joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'src', 'rdb'),\n );\n const relativePathToRoot = getRelativePathToRootByDirectory(\n projectConfig.root,\n );\n const fs = new FsCommands(tree, DEPENDENCIES);\n const migrationBundleDir = joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'migration',\n );\n const migrationDockerImageTag = `${getNpmScope(tree)}-${kebabCase(options.name)}-migration:latest`;\n\n if (options.infra !== 'none') {\n await addTypeScriptBundleTarget(\n tree,\n projectConfig,\n {\n targetFilePath: 'src/migration-handler.ts',\n bundleOutputDir: 'migration',\n },\n DEPENDENCIES,\n );\n await addTypeScriptBundleTarget(\n tree,\n projectConfig,\n {\n targetFilePath: 'src/create-db-user-handler.ts',\n bundleOutputDir: 'create-db-user',\n },\n DEPENDENCIES,\n );\n const bundleTarget = projectConfig.targets['bundle'];\n // The bundle target starts with a single rolldown `command`. Wrap it with\n // the migration asset copy steps, unless it has already been transformed\n // into a `commands` array on a previous run.\n if (!bundleTarget.options.commands) {\n const rolldownCommand = bundleTarget.options.command;\n delete bundleTarget.options.command;\n bundleTarget.options = {\n ...bundleTarget.options,\n commands: [\n fs.rm(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.mkdir(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.cpDir(\n 'prisma',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma`,\n ),\n fs.cpFile(\n 'prisma.config.ts',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma.config.ts`,\n ),\n fs.cpFile(\n 'Dockerfile',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/Dockerfile`,\n ),\n rolldownCommand,\n ],\n parallel: false,\n };\n }\n }\n\n projectConfig.targets.generate = {\n executor: 'nx:run-commands',\n outputs: ['{projectRoot}/generated/prisma'],\n options: {\n command: 'prisma generate',\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['pull-image'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/pull-image.ts`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['dev'] = {\n executor: 'nx:run-commands',\n dependsOn: ['pull-image'],\n options: {\n command: `tsx ${scriptsDir}/start-container.ts`,\n cwd: '{projectRoot}',\n },\n continuous: true,\n };\n projectConfig.targets['wait-for-db'] = {\n executor: 'nx:run-commands',\n dependsOn: ['dev'],\n options: {\n command: `tsx ${scriptsDir}/${waitForDbScript}`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets.prisma = {\n executor: 'nx:run-commands',\n dependsOn: ['dev', 'wait-for-db'],\n options: {\n cwd: '{projectRoot}',\n command: 'prisma',\n env: {\n LOCAL_DEV: 'true',\n },\n },\n };\n // Recorded in the metadata below so the version sync can tell a CDK project\n // from a Terraform one; undefined when no infrastructure was generated, in\n // which case neither provider's packages were added.\n const iac =\n options.infra !== 'none' ? await resolveIac(tree, options.iac) : undefined;\n\n if (options.infra !== 'none') {\n // The migration image ships under both providers — Terraform pushes the\n // locally built tag, CDK builds the same context as an image asset — so the\n // build and its scan are wired up for either.\n projectConfig.targets['docker'] = {\n cache: IMAGE_BUILD_CACHE,\n executor: 'nx:run-commands',\n options: {\n command: `${containerEngine} build --platform linux/arm64 --provenance=false -t ${migrationDockerImageTag} ${migrationBundleDir}`,\n },\n dependsOn: ['bundle'],\n };\n addArtifactDependencyToTargets(projectConfig, 'docker');\n\n addDockerScanTarget(\n tree,\n {\n project: projectConfig,\n containerEngine,\n trivyTargetName: 'trivy',\n dockerTargetName: 'docker',\n imageTags: [migrationDockerImageTag],\n },\n DEPENDENCIES,\n );\n addArtifactDependencyToTargets(projectConfig, 'bundle');\n }\n addDependencyToTargetIfNotPresent(projectConfig, 'compile', 'generate');\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfig);\n // Recorded here and read by the declaration's predicates, so the packages\n // added below are exactly the ones the version sync will own.\n const metadata: TsRdbMetadata = {\n engine: options.engine,\n ...(iac ? { iac } : {}),\n };\n addGeneratorMetadata(\n tree,\n fullyQualifiedName,\n TS_RDB_GENERATOR_INFO,\n metadata,\n );\n\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, { iac }, DEPENDENCIES);\n await addRdbInfra(tree, {\n iac,\n projectName: fullyQualifiedName,\n projectRoot: dir,\n nameClassName,\n nameKebabCase,\n databasePackageAlias: fullyQualifiedName,\n databaseName,\n adminUser: databaseUser,\n engine: options.engine,\n migrationBundleDir,\n createDbUserBundleDir: joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'create-db-user',\n ),\n framework: options.framework,\n migrationDockerImageTag,\n containerEngine,\n });\n }\n\n addTsDependencies(tree, DEPENDENCIES, {\n metadata,\n projectRoot: projectConfig.root,\n });\n\n // @prisma/adapter-pg depends on @types/pg ^8.16.0. Yarn does not dedupe it to\n // the workspace's pinned @types/pg, so it installs a separate copy under the\n // adapter's own node_modules whenever a newer @types/pg is published. The two\n // copies declare structurally incompatible Pool types, so passing our `new\n // Pool(...)` to `new PrismaPg(...)` fails to compile. Scope the resolution to\n // the adapter so other @types/pg consumers are unaffected. Classic yarn only\n // honours the `**/`-prefixed descriptor in a workspace and berry only the\n // bare one, so declare both.\n if (options.engine === 'postgres' && detectPackageManager() === 'yarn') {\n updateJson(tree, 'package.json', (packageJson) => {\n packageJson.resolutions = {\n ...packageJson.resolutions,\n '**/@prisma/adapter-pg/@types/pg': TS_VERSIONS['@types/pg'],\n '@prisma/adapter-pg/@types/pg': TS_VERSIONS['@types/pg'],\n };\n return packageJson;\n });\n }\n\n registerPnpmBuiltDependencies(tree, {\n '@prisma/engines': false,\n prisma: false,\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_RDB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsRdbGenerator;\n"],"names":["relative","detectPackageManager","generateFiles","joinPathFragments","OverwriteStrategy","readProjectConfiguration","updateJson","updateProjectConfiguration","writeJson","addTsDependencies","addStarExport","addTypeScriptBundleTarget","BUNDLE_DEPENDENCIES","resolveContainers","declareDependencies","ownedElsewhere","addDockerScanTarget","DOCKER_DEPENDENCIES","IMAGE_BUILD_CACHE","NODE_IMAGE_DEPENDENCIES","nodeImageVersions","PRISMA_IMAGE_DEPENDENCIES","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","updateGitIgnore","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","esmVars","kebabCase","snakeCase","toClassName","getNpmScope","addArtifactDependencyToTargets","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","getRelativePathToRootByDirectory","registerPnpmBuiltDependencies","assignPort","addRdbInfra","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","PACKAGES_DIR","SHARED_SCRIPTS_DIR","SHARED_RDB_SCRIPTS_DEPENDENCIES","sharedRdbScriptsGenerator","TS_VERSIONS","tsProjectGenerator","getTsLibDetails","DEPENDENCIES","ts","name","when","m","engine","dev","root","TS_RDB_GENERATOR_INFO","filename","tsRdbGenerator","tree","options","nameKebabCase","nameClassName","databaseUser","databaseName","containerEngine","fullyQualifiedName","dir","directory","subDirectory","projectExists","preferInstallDependencies","tsConfig","include","projectConfig","localDbPort","localDbHost","localDbUser","localDbPassword","containerName","dockerImage","templateOptions","runtimeConfigKey","databasePackageAlias","databaseProvider","prismaVersion","prisma","deepmergeTsVersion","mysql2Version","mysql2","prismaAdapterPackage","prismaAdapterClassName","localDbName","dirname","overwriteStrategy","KeepExisting","localDev","image","port","host","dbName","dbUser","dbPassword","dbEngine","patterns","waitForDbScript","scriptsDir","relativePathToRoot","fs","migrationBundleDir","migrationDockerImageTag","infra","targetFilePath","bundleOutputDir","bundleTarget","targets","commands","rolldownCommand","command","rm","mkdir","cpDir","cpFile","parallel","generate","executor","outputs","cwd","dependsOn","continuous","env","LOCAL_DEV","iac","undefined","cache","project","trivyTargetName","dockerTargetName","imageTags","metadata","projectName","projectRoot","adminUser","createDbUserBundleDir","framework","packageJson","resolutions","languages"],"mappings":"AAAA;;;CAGC,GACD,SAASA,QAAQ,QAAQ,YAAY;AACrC,SACEC,oBAAoB,EAEpBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,wBAAwB,EAExBC,UAAU,EACVC,0BAA0B,EAC1BC,SAAS,QACJ,aAAa;AACpB,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SACEC,yBAAyB,EACzBC,mBAAmB,QACd,+BAA+B;AACtC,SAASC,iBAAiB,QAAQ,4BAA4B;AAC9D,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAuC;AAC9C,SACEC,mBAAmB,EACnBC,mBAAmB,EACnBC,iBAAiB,EACjBC,uBAAuB,EACvBC,iBAAiB,EACjBC,yBAAyB,QACpB,wBAAwB;AAC/B,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,eAAe,EAAEC,UAAU,QAAQ,oBAAoB;AAChE,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,UAAU,QAAQ,qBAAqB;AAChD,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,SAASC,OAAO,QAAQ,+BAA+B;AACvD,SAASC,SAAS,EAAEC,SAAS,EAAEC,WAAW,QAAQ,uBAAuB;AACzE,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SACEC,8BAA8B,EAC9BC,iCAAiC,EACjCC,oBAAoB,EACpBC,gBAAgB,QAEX,oBAAoB;AAC3B,SA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AClC,mBAAmB;QACnB2B,QAAQ;IACV;IAEA,MAAM7D,gCAAgCkC,MAAM;QAACH;KAAsB;IAEnE,MAAMrC,qBAAqBwC;IAC3B,OAAO,IACLnC,oBAAoBmC,MAAMC,QAAQW,yBAAyB,EAAE;YAC3D4E,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAezF,eAAe"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/rdb/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { relative } from 'node:path';\nimport {\n detectPackageManager,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n readProjectConfiguration,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n writeJson,\n} from '@nx/devkit';\nimport { addTsDependencies } from '../../utils/add-dependencies.js';\nimport { addStarExport } from '../../utils/ast.js';\nimport {\n addTypeScriptBundleTarget,\n BUNDLE_DEPENDENCIES,\n} from '../../utils/bundle/bundle.js';\nimport { resolveContainers } from '../../utils/containers.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../utils/declared-dependencies.js';\nimport {\n addDockerScanTarget,\n DOCKER_DEPENDENCIES,\n IMAGE_BUILD_CACHE,\n NODE_IMAGE_DEPENDENCIES,\n nodeImageVersions,\n PRISMA_IMAGE_DEPENDENCIES,\n} from '../../utils/docker.js';\nimport { formatFilesInSubtree } from '../../utils/format.js';\nimport { FS_DEPENDENCIES, FsCommands } from '../../utils/fs.js';\nimport { updateGitIgnore } from '../../utils/git.js';\nimport { resolveIac } from '../../utils/iac.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics.js';\nimport { esmVars } from '../../utils/module-format.js';\nimport { kebabCase, snakeCase, toClassName } from '../../utils/names.js';\nimport { getNpmScope } from '../../utils/npm-scope.js';\nimport {\n addArtifactDependencyToTargets,\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../utils/nx.js';\nimport { getRelativePathToRootByDirectory } from '../../utils/paths.js';\nimport { registerPnpmBuiltDependencies } from '../../utils/pnpm-workspace.js';\nimport { assignPort } from '../../utils/port.js';\nimport { addRdbInfra } from '../../utils/rdb-constructs/rdb-constructs.js';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../utils/shared-constructs.js';\nimport {\n type IacMetadata,\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n} from '../../utils/shared-constructs-constants.js';\nimport {\n SHARED_RDB_SCRIPTS_DEPENDENCIES,\n sharedRdbScriptsGenerator,\n} from '../../utils/shared-rdb-scripts.js';\nimport { TS_VERSIONS } from '../../utils/versions.js';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator.js';\nimport type { TsRdbGeneratorSchema } from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface TsRdbMetadata extends IacMetadata {\n readonly engine: TsRdbGeneratorSchema['engine'];\n}\n\n// Each entry names the engine branch it belongs to, so the same declaration\n// drives both adding and the version sync.\nexport const DEPENDENCIES = declareDependencies<TsRdbMetadata>()({\n ts: [\n { name: '@aws-lambda-powertools/parameters' },\n { name: '@aws-sdk/client-appconfigdata' },\n { name: '@aws-sdk/client-secrets-manager' },\n { name: '@aws-sdk/rds-signer' },\n { name: '@prisma/client' },\n { name: '@prisma/adapter-mariadb', when: (m) => m.engine === 'mysql' },\n { name: 'mariadb', when: (m) => m.engine === 'mysql' },\n { name: '@prisma/adapter-pg', when: (m) => m.engine !== 'mysql' },\n { name: 'pg', when: (m) => m.engine !== 'mysql' },\n { name: '@types/aws-lambda', dev: true },\n { name: '@types/pg', when: (m) => m.engine !== 'mysql', dev: true },\n // The prisma CLI and tsx run migration/seed scripts from the root.\n { name: 'prisma', dev: true, root: true },\n { name: 'tsx', dev: true, root: true },\n ...ownedElsewhere(BUNDLE_DEPENDENCIES),\n ...ownedElsewhere(FS_DEPENDENCIES),\n ...ownedElsewhere(DOCKER_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ...ownedElsewhere(SHARED_RDB_SCRIPTS_DEPENDENCIES),\n ...ownedElsewhere(NODE_IMAGE_DEPENDENCIES),\n ...ownedElsewhere(PRISMA_IMAGE_DEPENDENCIES),\n ],\n});\n\nexport const TS_RDB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsRdbGenerator = async (\n tree: Tree,\n options: TsRdbGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const nameKebabCase = kebabCase(options.name);\n const nameClassName = toClassName(options.name);\n const databaseUser = options.databaseUser ?? 'dbadmin';\n const databaseName = snakeCase(options.databaseName ?? options.name);\n const containerEngine = await resolveContainers(tree, 'inherit');\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n });\n\n let projectExists: boolean;\n try {\n readProjectConfiguration(tree, fullyQualifiedName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n await tsProjectGenerator(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n preferInstallDependencies: false,\n });\n }\n\n updateJson(tree, joinPathFragments(dir, 'tsconfig.lib.json'), (tsConfig) => ({\n ...tsConfig,\n include: ['src/**/*.ts', 'generated/prisma/**/*.ts'],\n }));\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n const localDbPort = assignPort(\n tree,\n projectConfig,\n options.engine === 'mysql' ? 3306 : 5432,\n );\n const localDbHost = 'localhost';\n const localDbUser = options.engine === 'mysql' ? 'root' : 'dbadmin';\n const localDbPassword = 'password';\n const containerName = `${getNpmScope(tree)}-${databaseName}`;\n const dockerImage =\n options.engine === 'mysql'\n ? 'public.ecr.aws/docker/library/mysql:8.0.44'\n : 'public.ecr.aws/docker/library/postgres:17.7';\n\n const templateOptions = {\n engine: options.engine,\n runtimeConfigKey: nameClassName,\n databasePackageAlias: fullyQualifiedName,\n databaseProvider: options.engine === 'mysql' ? 'mysql' : 'postgresql',\n prismaVersion: TS_VERSIONS.prisma,\n deepmergeTsVersion: TS_VERSIONS['deepmerge-ts'],\n mysql2Version: TS_VERSIONS.mysql2,\n ...nodeImageVersions(),\n prismaAdapterPackage:\n options.engine === 'mysql'\n ? '@prisma/adapter-mariadb'\n : '@prisma/adapter-pg',\n prismaAdapterClassName:\n options.engine === 'mysql' ? 'PrismaMariaDb' : 'PrismaPg',\n localDbPort,\n localDbHost,\n localDbName: databaseName,\n localDbUser,\n localDbPassword,\n containerEngine,\n containerName,\n dockerImage,\n ...esmVars(tree),\n };\n\n // The Prisma schema and models, the handlers and the prisma client module are\n // all user-editable, so a re-run (to add infrastructure, or after a failed\n // run) must not clobber the user's schema and edits.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n dir,\n templateOptions,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // The barrel re-exports prisma.ts. `tsProjectGenerator` writes a stub index.ts\n // when it creates the project, so the re-export is added to whatever is there\n // rather than replacing it — which also leaves a user's own additions to the\n // barrel alone on a re-run.\n await addStarExport(\n tree,\n joinPathFragments(dir, 'src', 'index.ts'),\n './prisma.js',\n );\n\n // config.json is framework-owned: it carries values derived from the\n // generator's options, so it converges on a re-run with changed options.\n writeJson(tree, joinPathFragments(dir, 'config.json'), {\n runtimeConfigKey: nameClassName,\n localDev: {\n containerEngine,\n containerName,\n image: dockerImage,\n port: localDbPort,\n host: localDbHost,\n dbName: databaseName,\n dbUser: localDbUser,\n dbPassword: localDbPassword,\n dbEngine: options.engine,\n },\n });\n updateGitIgnore(tree, dir, (patterns) => [...patterns, 'generated/prisma']);\n await sharedRdbScriptsGenerator(tree, options.engine, DEPENDENCIES);\n const waitForDbScript =\n options.engine === 'mysql'\n ? 'wait-for-mysql-db.ts'\n : 'wait-for-postgres-db.ts';\n const scriptsDir = relative(\n dir,\n joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'src', 'rdb'),\n );\n const relativePathToRoot = getRelativePathToRootByDirectory(\n projectConfig.root,\n );\n const fs = new FsCommands(tree, DEPENDENCIES);\n const migrationBundleDir = joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'migration',\n );\n const migrationDockerImageTag = `${getNpmScope(tree)}-${kebabCase(options.name)}-migration:latest`;\n\n if (options.infra !== 'none') {\n await addTypeScriptBundleTarget(\n tree,\n projectConfig,\n {\n targetFilePath: 'src/migration-handler.ts',\n bundleOutputDir: 'migration',\n },\n DEPENDENCIES,\n );\n await addTypeScriptBundleTarget(\n tree,\n projectConfig,\n {\n targetFilePath: 'src/create-db-user-handler.ts',\n bundleOutputDir: 'create-db-user',\n },\n DEPENDENCIES,\n );\n const bundleTarget = projectConfig.targets['bundle'];\n // The bundle target starts with a single rolldown `command`. Wrap it with\n // the migration asset copy steps, unless it has already been transformed\n // into a `commands` array on a previous run.\n if (!bundleTarget.options.commands) {\n const rolldownCommand = bundleTarget.options.command;\n delete bundleTarget.options.command;\n bundleTarget.options = {\n ...bundleTarget.options,\n commands: [\n fs.rm(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.mkdir(`${relativePathToRoot}dist/{projectRoot}/bundle/migration`),\n fs.cpDir(\n 'prisma',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma`,\n ),\n fs.cpFile(\n 'prisma.config.ts',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/prisma.config.ts`,\n ),\n fs.cpFile(\n 'Dockerfile',\n `${relativePathToRoot}dist/{projectRoot}/bundle/migration/Dockerfile`,\n ),\n rolldownCommand,\n ],\n parallel: false,\n };\n }\n }\n\n projectConfig.targets.generate = {\n executor: 'nx:run-commands',\n cache: true,\n inputs: ['default'],\n outputs: ['{projectRoot}/generated/prisma'],\n options: {\n command: 'prisma generate',\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['pull-image'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/pull-image.ts`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['dev'] = {\n executor: 'nx:run-commands',\n dependsOn: ['pull-image'],\n options: {\n command: `tsx ${scriptsDir}/start-container.ts`,\n cwd: '{projectRoot}',\n },\n continuous: true,\n };\n projectConfig.targets['wait-for-db'] = {\n executor: 'nx:run-commands',\n dependsOn: ['dev'],\n options: {\n command: `tsx ${scriptsDir}/${waitForDbScript}`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets.prisma = {\n executor: 'nx:run-commands',\n dependsOn: ['dev', 'wait-for-db'],\n options: {\n cwd: '{projectRoot}',\n command: 'prisma',\n env: {\n LOCAL_DEV: 'true',\n },\n },\n };\n // Recorded in the metadata below so the version sync can tell a CDK project\n // from a Terraform one; undefined when no infrastructure was generated, in\n // which case neither provider's packages were added.\n const iac =\n options.infra !== 'none' ? await resolveIac(tree, options.iac) : undefined;\n\n if (options.infra !== 'none') {\n // The migration image ships under both providers — Terraform pushes the\n // locally built tag, CDK builds the same context as an image asset — so the\n // build and its scan are wired up for either.\n projectConfig.targets['docker'] = {\n cache: IMAGE_BUILD_CACHE,\n executor: 'nx:run-commands',\n options: {\n command: `${containerEngine} build --platform linux/arm64 --provenance=false -t ${migrationDockerImageTag} ${migrationBundleDir}`,\n },\n dependsOn: ['bundle'],\n };\n addArtifactDependencyToTargets(projectConfig, 'docker');\n\n addDockerScanTarget(\n tree,\n {\n project: projectConfig,\n containerEngine,\n trivyTargetName: 'trivy',\n dockerTargetName: 'docker',\n imageTags: [migrationDockerImageTag],\n },\n DEPENDENCIES,\n );\n addArtifactDependencyToTargets(projectConfig, 'bundle');\n }\n addDependencyToTargetIfNotPresent(projectConfig, 'compile', 'generate');\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfig);\n // Recorded here and read by the declaration's predicates, so the packages\n // added below are exactly the ones the version sync will own.\n const metadata: TsRdbMetadata = {\n engine: options.engine,\n ...(iac ? { iac } : {}),\n };\n addGeneratorMetadata(\n tree,\n fullyQualifiedName,\n TS_RDB_GENERATOR_INFO,\n metadata,\n );\n\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, { iac }, DEPENDENCIES);\n await addRdbInfra(tree, {\n iac,\n projectName: fullyQualifiedName,\n projectRoot: dir,\n nameClassName,\n nameKebabCase,\n databasePackageAlias: fullyQualifiedName,\n databaseName,\n adminUser: databaseUser,\n engine: options.engine,\n migrationBundleDir,\n createDbUserBundleDir: joinPathFragments(\n 'dist',\n projectConfig.root,\n 'bundle',\n 'create-db-user',\n ),\n framework: options.framework,\n migrationDockerImageTag,\n containerEngine,\n });\n }\n\n addTsDependencies(tree, DEPENDENCIES, {\n metadata,\n projectRoot: projectConfig.root,\n });\n\n // @prisma/adapter-pg depends on @types/pg ^8.16.0. Yarn does not dedupe it to\n // the workspace's pinned @types/pg, so it installs a separate copy under the\n // adapter's own node_modules whenever a newer @types/pg is published. The two\n // copies declare structurally incompatible Pool types, so passing our `new\n // Pool(...)` to `new PrismaPg(...)` fails to compile. Scope the resolution to\n // the adapter so other @types/pg consumers are unaffected. Classic yarn only\n // honours the `**/`-prefixed descriptor in a workspace and berry only the\n // bare one, so declare both.\n if (options.engine === 'postgres' && detectPackageManager() === 'yarn') {\n updateJson(tree, 'package.json', (packageJson) => {\n packageJson.resolutions = {\n ...packageJson.resolutions,\n '**/@prisma/adapter-pg/@types/pg': TS_VERSIONS['@types/pg'],\n '@prisma/adapter-pg/@types/pg': TS_VERSIONS['@types/pg'],\n };\n return packageJson;\n });\n }\n\n registerPnpmBuiltDependencies(tree, {\n '@prisma/engines': false,\n prisma: false,\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_RDB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsRdbGenerator;\n"],"names":["relative","detectPackageManager","generateFiles","joinPathFragments","OverwriteStrategy","readProjectConfiguration","updateJson","updateProjectConfiguration","writeJson","addTsDependencies","addStarExport","addTypeScriptBundleTarget","BUNDLE_DEPENDENCIES","resolveContainers","declareDependencies","ownedElsewhere","addDockerScanTarget","DOCKER_DEPENDENCIES","IMAGE_BUILD_CACHE","NODE_IMAGE_DEPENDENCIES","nodeImageVersions","PRISMA_IMAGE_DEPENDENCIES","formatFilesInSubtree","FS_DEPENDENCIES","FsCommands","updateGitIgnore","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","esmVars","kebabCase","snakeCase","toClassName","getNpmScope","addArtifactDependencyToTargets","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","getRelativePathToRootByDirectory","registerPnpmBuiltDependencies","assignPort","addRdbInfra","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","PACKAGES_DIR","SHARED_SCRIPTS_DIR","SHARED_RDB_SCRIPTS_DEPENDENCIES","sharedRdbScriptsGenerator","TS_VERSIONS","tsProjectGenerator","getTsLibDetails","DEPENDENCIES","ts","name","when","m","engine","dev","root","TS_RDB_GENERATOR_INFO","filename","tsRdbGenerator","tree","options","nameKebabCase","nameClassName","databaseUser","databaseName","containerEngine","fullyQualifiedName","dir","directory","subDirectory","projectExists","preferInstallDependencies","tsConfig","include","projectConfig","localDbPort","localDbHost","localDbUser","localDbPassword","containerName","dockerImage","templateOptions","runtimeConfigKey","databasePackageAlias","databaseProvider","prismaVersion","prisma","deepmergeTsVersion","mysql2Version","mysql2","prismaAdapterPackage","prismaAdapterClassName","localDbName","dirname","overwriteStrategy","KeepExisting","localDev","image","port","host","dbName","dbUser","dbPassword","dbEngine","patterns","waitForDbScript","scriptsDir","relativePathToRoot","fs","migrationBundleDir","migrationDockerImageTag","infra","targetFilePath","bundleOutputDir","bundleTarget","targets","commands","rolldownCommand","command","rm","mkdir","cpDir","cpFile","parallel","generate","executor","cache","inputs","outputs","cwd","dependsOn","continuous","env","LOCAL_DEV","iac","undefined","project","trivyTargetName","dockerTargetName","imageTags","metadata","projectName","projectRoot","adminUser","createDbUserBundleDir","framework","packageJson","resolutions","languages"],"mappings":"AAAA;;;CAGC,GACD,SAASA,QAAQ,QAAQ,YAAY;AACrC,SACEC,oBAAoB,EAEpBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EACjBC,wBAAwB,EAExBC,UAAU,EACVC,0BAA0B,EAC1BC,SAAS,QACJ,aAAa;AACpB,SAASC,iBAAiB,QAAQ,kCAAkC;AACpE,SAASC,aAAa,QAAQ,qBAAqB;AACnD,SACEC,yBAAyB,EACzBC,mBAAmB,QACd,+BAA+B;AACtC,SAASC,iBAAiB,QAAQ,4BAA4B;AAC9D,SACEC,mBAAmB,EACnBC,cAAc,QACT,uCAAuC;AAC9C,SACEC,mBAAmB,EACnBC,mBAAmB,EACnBC,iBAAiB,EACjBC,uBAAuB,EACvBC,iBAAiB,EACjBC,yBAAyB,QACpB,wBAAwB;AAC/B,SAASC,oBAAoB,QAAQ,wBAAwB;AAC7D,SAASC,eAAe,EAAEC,UAAU,QAAQ,oBAAoB;AAChE,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,UAAU,QAAQ,qBAAqB;AAChD,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,SAASC,OAAO,QAAQ,+BAA+B;AACvD,SAASC,SAAS,EAAEC,SAAS,EAAEC,WAAW,QAAQ,uBAAuB;AACzE,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SACEC,8BAA8B,EAC9BC,iCAAiC,EACjCC,oBAAoB,EACpBC,gBAAgB,QAEX,oBAAoB;AAC3B,SAASC,gCAAgC,QAAQ,uBAAuB;AACxE,SAASC,6BAA6B,QAAQ,gCAAgC;AAC9E,SAASC,UAAU,QAAQ,sBAAsB;AACjD,SAASC,WAAW,QAAQ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;IAEnE,MAAMrC,qBAAqBwC;IAC3B,OAAO,IACLnC,oBAAoBmC,MAAMC,QAAQW,yBAAyB,EAAE;YAC3D6E,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAe1F,eAAe"}
@@ -1227,7 +1227,7 @@ exports[`react-website generator > Tanstack router integration > should generate
1227
1227
  "biome": ["default", "{workspaceRoot}/biome.json"],
1228
1228
  "default": [
1229
1229
  {
1230
- "dependentTasksOutputFiles": "!{reports,coverage}/**",
1230
+ "dependentTasksOutputFiles": "!{reports/**,coverage/**,dist/**/checkov/checkov_report.json,dist/**/test-output/vitest/coverage/**}",
1231
1231
  "transitive": true
1232
1232
  }
1233
1233
  ]
@@ -2202,6 +2202,55 @@ export * from './core/index.js';
2202
2202
  "
2203
2203
  `;
2204
2204
 
2205
+ exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/constructs/tests/global-setup.ts 1`] = `
2206
+ "import { existsSync, mkdtempSync, rmSync } from 'node:fs';
2207
+ import { tmpdir } from 'node:os';
2208
+ import { join } from 'node:path';
2209
+ import { setTimeout as sleep } from 'node:timers/promises';
2210
+
2211
+ const VARIABLES = ['TMPDIR', 'TEMP', 'TMP', 'CDK_CONTEXT_JSON'];
2212
+
2213
+ const remove = (dir: string) => {
2214
+ try {
2215
+ rmSync(dir, { recursive: true, force: true });
2216
+ } catch {
2217
+ // Retried below.
2218
+ }
2219
+ return !existsSync(dir);
2220
+ };
2221
+
2222
+ export default function setup() {
2223
+ const previous = VARIABLES.map((name) => [name, process.env[name]] as const);
2224
+ const dir = mkdtempSync(join(tmpdir(), 'cdk-test-'));
2225
+ process.env.TMPDIR = dir;
2226
+ process.env.TEMP = dir;
2227
+ process.env.TMP = dir;
2228
+ process.env.CDK_CONTEXT_JSON = JSON.stringify({
2229
+ ...JSON.parse(process.env.CDK_CONTEXT_JSON ?? '{}'),
2230
+ 'aws:cdk:bundling-stacks': [],
2231
+ });
2232
+
2233
+ return async () => {
2234
+ // Exiting workers may still be deleting their cdk.out here, so retry.
2235
+ const deadline = Date.now() + 2000;
2236
+ while (!remove(dir) && Date.now() < deadline) {
2237
+ await sleep(50);
2238
+ }
2239
+ if (existsSync(dir)) {
2240
+ console.warn(\`Could not remove the CDK test directory \${dir}\`);
2241
+ }
2242
+ for (const [name, value] of previous) {
2243
+ if (value === undefined) {
2244
+ delete process.env[name];
2245
+ } else {
2246
+ process.env[name] = value;
2247
+ }
2248
+ }
2249
+ };
2250
+ }
2251
+ "
2252
+ `;
2253
+
2205
2254
  exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > packages/common/constructs/tsconfig.json 1`] = `
2206
2255
  "{
2207
2256
  "extends": "../../../tsconfig.base.json",
@@ -2302,6 +2351,7 @@ export default defineConfig(() => ({
2302
2351
  root: import.meta.dirname,
2303
2352
  cacheDir: '../../../node_modules/.vite/packages/common/constructs',
2304
2353
  test: {
2354
+ globalSetup: ['./tests/global-setup.ts'],
2305
2355
  passWithNoTests: true,
2306
2356
  name: '@proj/common-constructs',
2307
2357
  watch: false,
@@ -3103,7 +3153,7 @@ exports[`react-website generator > Tanstack router integration > should generate
3103
3153
  "biome": ["default", "{workspaceRoot}/biome.json"],
3104
3154
  "default": [
3105
3155
  {
3106
- "dependentTasksOutputFiles": "!{reports,coverage}/**",
3156
+ "dependentTasksOutputFiles": "!{reports/**,coverage/**,dist/**/checkov/checkov_report.json,dist/**/test-output/vitest/coverage/**}",
3107
3157
  "transitive": true
3108
3158
  }
3109
3159
  ]
@@ -4082,6 +4132,55 @@ export * from './core/index.js';
4082
4132
  "
4083
4133
  `;
4084
4134
 
4135
+ exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/constructs/tests/global-setup.ts 1`] = `
4136
+ "import { existsSync, mkdtempSync, rmSync } from 'node:fs';
4137
+ import { tmpdir } from 'node:os';
4138
+ import { join } from 'node:path';
4139
+ import { setTimeout as sleep } from 'node:timers/promises';
4140
+
4141
+ const VARIABLES = ['TMPDIR', 'TEMP', 'TMP', 'CDK_CONTEXT_JSON'];
4142
+
4143
+ const remove = (dir: string) => {
4144
+ try {
4145
+ rmSync(dir, { recursive: true, force: true });
4146
+ } catch {
4147
+ // Retried below.
4148
+ }
4149
+ return !existsSync(dir);
4150
+ };
4151
+
4152
+ export default function setup() {
4153
+ const previous = VARIABLES.map((name) => [name, process.env[name]] as const);
4154
+ const dir = mkdtempSync(join(tmpdir(), 'cdk-test-'));
4155
+ process.env.TMPDIR = dir;
4156
+ process.env.TEMP = dir;
4157
+ process.env.TMP = dir;
4158
+ process.env.CDK_CONTEXT_JSON = JSON.stringify({
4159
+ ...JSON.parse(process.env.CDK_CONTEXT_JSON ?? '{}'),
4160
+ 'aws:cdk:bundling-stacks': [],
4161
+ });
4162
+
4163
+ return async () => {
4164
+ // Exiting workers may still be deleting their cdk.out here, so retry.
4165
+ const deadline = Date.now() + 2000;
4166
+ while (!remove(dir) && Date.now() < deadline) {
4167
+ await sleep(50);
4168
+ }
4169
+ if (existsSync(dir)) {
4170
+ console.warn(\`Could not remove the CDK test directory \${dir}\`);
4171
+ }
4172
+ for (const [name, value] of previous) {
4173
+ if (value === undefined) {
4174
+ delete process.env[name];
4175
+ } else {
4176
+ process.env[name] = value;
4177
+ }
4178
+ }
4179
+ };
4180
+ }
4181
+ "
4182
+ `;
4183
+
4085
4184
  exports[`react-website generator > Tanstack router integration > should generate website with router correctly > packages/common/constructs/tsconfig.json 1`] = `
4086
4185
  "{
4087
4186
  "extends": "../../../tsconfig.base.json",
@@ -4182,6 +4281,7 @@ export default defineConfig(() => ({
4182
4281
  root: import.meta.dirname,
4183
4282
  cacheDir: '../../../node_modules/.vite/packages/common/constructs',
4184
4283
  test: {
4284
+ globalSetup: ['./tests/global-setup.ts'],
4185
4285
  passWithNoTests: true,
4186
4286
  name: '@proj/common-constructs',
4187
4287
  watch: false,
@@ -0,0 +1,25 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`cdk test global setup > addCdkTestGlobalSetup > should keep the infra vitest config well formed 1`] = `
4
+ "import { defineConfig } from 'vitest/config';
5
+
6
+ export default defineConfig(() => ({
7
+ root: import.meta.dirname,
8
+ cacheDir: '../../node_modules/.vite/packages/infra',
9
+ test: {
10
+ globalSetup: ['./tests/global-setup.ts'],
11
+ passWithNoTests: true,
12
+ name: '@proj/infra',
13
+ watch: false,
14
+ globals: true,
15
+ environment: 'jsdom',
16
+ include: ['{src,tests}/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
17
+ reporters: ['default'],
18
+ coverage: {
19
+ reportsDirectory: '../../dist/packages/infra/test-output/vitest/coverage',
20
+ provider: 'v8' as const,
21
+ },
22
+ },
23
+ }));
24
+ "
25
+ `;
@@ -5,6 +5,31 @@
5
5
  import { type Tree } from '@nx/devkit';
6
6
  import { type DependencyDeclaration, type MustDeclare, type MustDeclarePy } from '../declared-dependencies.js';
7
7
  import { type IPyDepVersion } from '../versions.js';
8
+ /**
9
+ * `@strands-agents/sdk` and its optional peers that are vended in
10
+ * `versions.ts` and reachable at a floating version via a transitive
11
+ * dependency (e.g. `@modelcontextprotocol/sdk` floats `express: ^5.2.1`).
12
+ * pnpm suffixes each installed copy of a package by the versions of its
13
+ * resolved peers, so an importer that declares strands without also
14
+ * declaring every one of these can resolve a peer to a different version
15
+ * than the pin every other importer uses — splitting `@strands-agents/sdk`
16
+ * into two peer-suffixed instances of the same version. Anything importing
17
+ * both instances then sees two nominal identities of every SDK type and
18
+ * fails to compile with TS2322/TS2345.
19
+ *
20
+ * `@strands-agents/sdk`'s other optional peers (`@a2a-js/sdk`,
21
+ * `@smithy/types`) are vended too, but nothing outside strands' own peer
22
+ * declaration pulls either one in at a floating version, so they are not
23
+ * part of this set — see `strands-optional-peer-drift.md`'s reachability
24
+ * check.
25
+ *
26
+ * Every site that declares `@strands-agents/sdk` must declare this whole
27
+ * tuple alongside it, in whichever shape that site expresses dependencies
28
+ * (a plain `{ name }` entry, a `when`/`root`-qualified declaration, or a
29
+ * `TS_TEMPLATE_DEPS`-style name array) — this is the one place the three
30
+ * names are listed.
31
+ */
32
+ export declare const STRANDS_PEER_DEPENDENCY_NAMES: readonly ["@strands-agents/sdk", "express", "@aws-sdk/client-s3"];
8
33
  /** TypeScript dependencies a caller must declare to emit agent-connection clients. */
9
34
  export declare const AGENT_CONNECTION_DEPENDENCIES: readonly [{
10
35
  readonly name: "@aws-lambda-powertools/parameters";
@@ -16,11 +41,9 @@ export declare const AGENT_CONNECTION_DEPENDENCIES: readonly [{
16
41
  readonly name: "@modelcontextprotocol/sdk";
17
42
  }, {
18
43
  readonly name: "@a2a-js/sdk";
19
- }, {
20
- readonly name: "@strands-agents/sdk";
21
- }, {
22
- readonly name: "@aws-sdk/client-s3";
23
- }];
44
+ }, ...{
45
+ name: "@aws-sdk/client-s3" | "@strands-agents/sdk" | "express";
46
+ }[]];
24
47
  /** Python dependencies a caller must declare to emit agent-connection clients. */
25
48
  export declare const AGENT_CONNECTION_PY_DEPENDENCIES: readonly [{
26
49
  readonly name: "aws-lambda-powertools";