@aws/nx-plugin 1.0.0-rc.96 → 1.0.0-rc.98
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.
- package/LICENSE-THIRD-PARTY +9 -9
- package/migrations.json +124 -84
- package/package.json +3 -3
- package/src/agentcore-gateway/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/agentcore-gateway/generator.js +6 -0
- package/src/agentcore-gateway/generator.js.map +1 -1
- package/src/agentcore-gateway/react-connection/__snapshots__/generator.spec.ts.snap +4 -1
- package/src/agentcore-harness/__snapshots__/generator.spec.ts.snap +68 -4
- package/src/agentcore-harness/generator.js +6 -0
- package/src/agentcore-harness/generator.js.map +1 -1
- package/src/connection/gateway-runtime-config.js +1 -1
- package/src/connection/gateway-runtime-config.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +10 -10
- package/src/infra/app/generator.js +39 -9
- package/src/infra/app/generator.js.map +1 -1
- package/src/init/generator.d.ts +1 -1
- package/src/init/generator.js +8 -6
- package/src/init/generator.js.map +1 -1
- package/src/init/schema.d.js.map +1 -1
- package/src/init/schema.d.ts +1 -0
- package/src/init/schema.json +5 -0
- package/src/internal/test-matrix/generator.js +2 -2
- package/src/internal/test-matrix/generator.js.map +1 -1
- package/src/license/sync/generator.d.ts +10 -0
- package/src/license/sync/generator.js +1 -1
- package/src/license/sync/generator.js.map +1 -1
- package/src/mcp-server/server.js +2 -0
- package/src/mcp-server/server.js.map +1 -1
- package/src/mcp-server/tools/best-practices.d.ts +28 -0
- package/src/mcp-server/tools/best-practices.js +43 -0
- package/src/mcp-server/tools/best-practices.js.map +1 -0
- package/src/mcp-server/tools/general-guidance.d.ts +1 -1
- package/src/mcp-server/tools/general-guidance.js +13 -4
- package/src/mcp-server/tools/general-guidance.js.map +1 -1
- package/src/migrations/latest/sandbox-pattern-nested-stacks/metadata.json +3 -0
- package/src/migrations/latest/sandbox-pattern-nested-stacks/migration.js +68 -0
- package/src/migrations/latest/sandbox-pattern-nested-stacks/migration.js.map +1 -0
- package/src/migrations/latest/shadcn-cn-package/metadata.json +3 -0
- package/src/migrations/latest/shadcn-cn-package/migration.js +114 -0
- package/src/migrations/latest/shadcn-cn-package/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.90/0001-dev-target-depends-on-pull-image/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.90/0002-open-api-codegen-executor/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.90/0003-terraform-provider-plugin-cache/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.90/0004-python-test-input-scoping/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.90/0005-vitest-coverage-output-dir/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.90/0006-add-assemble-target/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.90/0007-docker-target-cache-soundness/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.90/0008-declare-cacheable-target-inputs/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.90/0009-terraform-fmt-check/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.92/0001-react-website-unique-dev-ports/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.94/0001-infra-deploy-express-mode/metadata.json +3 -0
- package/src/migrations/{latest/infra-deploy-express-mode → v1.0.0-rc.94/0001-infra-deploy-express-mode}/migration.js +26 -28
- package/src/migrations/v1.0.0-rc.94/0001-infra-deploy-express-mode/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.94/0002-shx-fs-commands/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.94/0003-agent-core-vendor-target/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.95/0001-rolldown-config-bundle-transient/migration.d.ts +6 -0
- package/src/migrations/v1.0.0-rc.95/0001-rolldown-config-bundle-transient/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.95/0002-agent-connection-pin-strands-peers/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.95/0003-ignore-package-manager-temp-files/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.95/0004-shadcn-package-imports-exports/migration.d.ts +6 -0
- package/src/migrations/v1.0.0-rc.95/0004-shadcn-package-imports-exports/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.97/0001-gateway-url-accessor/__snapshots__/migration.spec.ts.snap +84 -0
- package/src/migrations/v1.0.0-rc.97/0001-gateway-url-accessor/metadata.json +3 -0
- package/src/migrations/v1.0.0-rc.97/0001-gateway-url-accessor/migration.d.ts +6 -0
- package/src/migrations/v1.0.0-rc.97/0001-gateway-url-accessor/migration.js +94 -0
- package/src/migrations/v1.0.0-rc.97/0001-gateway-url-accessor/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.97/0002-checkov-scan-cache-inputs/metadata.json +3 -0
- package/src/migrations/v1.0.0-rc.97/0002-checkov-scan-cache-inputs/migration.d.ts +6 -0
- package/src/migrations/v1.0.0-rc.97/0002-checkov-scan-cache-inputs/migration.js +58 -0
- package/src/migrations/v1.0.0-rc.97/0002-checkov-scan-cache-inputs/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.97/0003-terraform-validate-without-backend/metadata.json +3 -0
- package/src/migrations/v1.0.0-rc.97/0003-terraform-validate-without-backend/migration.d.ts +6 -0
- package/src/migrations/v1.0.0-rc.97/0003-terraform-validate-without-backend/migration.js +84 -0
- package/src/migrations/v1.0.0-rc.97/0003-terraform-validate-without-backend/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.97/0004-py-lambda-powertools-context/metadata.json +3 -0
- package/src/migrations/v1.0.0-rc.97/0004-py-lambda-powertools-context/migration.d.ts +6 -0
- package/src/migrations/v1.0.0-rc.97/0004-py-lambda-powertools-context/migration.js +58 -0
- package/src/migrations/v1.0.0-rc.97/0004-py-lambda-powertools-context/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.97/0005-smithy-extension-trait-aliases/__snapshots__/migration.spec.ts.snap +25 -0
- package/src/migrations/v1.0.0-rc.97/0005-smithy-extension-trait-aliases/metadata.json +3 -0
- package/src/migrations/v1.0.0-rc.97/0005-smithy-extension-trait-aliases/migration.d.ts +28 -0
- package/src/migrations/v1.0.0-rc.97/0005-smithy-extension-trait-aliases/migration.js +75 -0
- package/src/migrations/v1.0.0-rc.97/0005-smithy-extension-trait-aliases/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.97/0006-script-project-quality-gates/metadata.json +3 -0
- package/src/migrations/v1.0.0-rc.97/0006-script-project-quality-gates/migration.d.ts +6 -0
- package/src/migrations/v1.0.0-rc.97/0006-script-project-quality-gates/migration.js +53 -0
- package/src/migrations/v1.0.0-rc.97/0006-script-project-quality-gates/migration.js.map +1 -0
- package/src/preset/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/preset/generator.js +4 -25
- package/src/preset/generator.js.map +1 -1
- package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +2 -2
- package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +4 -4
- package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +4 -4
- package/src/py/agent/a2a-connection/generator.d.ts +1 -1
- package/src/py/agent/gateway-connection/generator.d.ts +1 -1
- package/src/py/agent/mcp-connection/generator.d.ts +1 -1
- package/src/py/agent/react-connection/__snapshots__/generator.spec.ts.snap +4 -1
- package/src/py/agent/react-connection/generator.d.ts +1 -7
- package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +10 -12
- package/src/py/dynamodb/generator.js +34 -7
- package/src/py/dynamodb/generator.js.map +1 -1
- package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +12 -12
- package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +4 -3
- package/src/py/lambda-function/files/handler/__lambdaFunctionSnakeCase__.py.template +2 -1
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/py/project/schema.json +3 -1
- package/src/py/rdb/__snapshots__/generator.spec.ts.snap +31 -15
- package/src/py/rdb/files/Dockerfile.create-db-user.template +7 -3
- package/src/py/rdb/files/Dockerfile.migration.template +7 -3
- package/src/py/rdb/generator.js +29 -28
- package/src/py/rdb/generator.js.map +1 -1
- package/src/smithy/project/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/smithy/react-connection/files/model/extensions.smithy.template +3 -3
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +8 -8
- package/src/smithy/ts/api/generator.js +7 -2
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/terraform/project/generator.js +34 -10
- package/src/terraform/project/generator.js.map +1 -1
- package/src/terraform/project/schema.d.js +0 -3
- package/src/terraform/project/schema.d.js.map +1 -1
- package/src/terraform/project/schema.d.ts +0 -4
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +12 -12
- package/src/trpc/backend/generator.js +7 -1
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/react/generator.js +6 -0
- package/src/trpc/react/generator.js.map +1 -1
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/ts/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/agent/gateway-connection/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/agent/generator.js +3 -3
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/agent/react-connection/generator.d.ts +1 -9
- package/src/ts/astro-docs/files/translation/scripts/translate.ts.template +47 -2
- package/src/ts/dcr-proxy/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +6 -4
- package/src/ts/dynamodb/generator.js +30 -6
- package/src/ts/dynamodb/generator.js.map +1 -1
- package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/lib/biome.d.ts +15 -1
- package/src/ts/lib/biome.js +79 -63
- package/src/ts/lib/biome.js.map +1 -1
- package/src/ts/lib/generator.js +11 -7
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/ts-project-utils.d.ts +14 -0
- package/src/ts/lib/ts-project-utils.js +24 -0
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/ts/mcp-server/files/app/http.ts.template +1 -1
- package/src/ts/mcp-server/generator.js +3 -3
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/nx-generator/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/nx-generator/files/local/generator.spec.ts.template +2 -2
- package/src/ts/nx-migration/generator.js +3 -1
- package/src/ts/nx-migration/generator.js.map +1 -1
- package/src/ts/nx-plugin/__snapshots__/generator.spec.ts.snap +1 -25
- package/src/ts/nx-plugin/generator.js +19 -17
- package/src/ts/nx-plugin/generator.js.map +1 -1
- package/src/ts/nx-plugin/utils.d.ts +21 -0
- package/src/ts/nx-plugin/utils.js +41 -1
- package/src/ts/nx-plugin/utils.js.map +1 -1
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +13 -8
- package/src/ts/rdb/files/Dockerfile.template +5 -0
- package/src/ts/rdb/generator.d.ts +8 -0
- package/src/ts/rdb/generator.js +28 -24
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/rdb/trpc-connection/__snapshots__/generator.spec.ts.snap +39 -0
- package/src/ts/rdb/trpc-connection/generator.js +13 -0
- package/src/ts/rdb/trpc-connection/generator.js.map +1 -1
- package/src/ts/react-website/agui/files/common/src/components/__agentNameKebabCase__-chat.tsx.template +9 -0
- package/src/ts/react-website/agui/files/common/src/hooks/useAgui__agentNameClassName__.tsx.template +4 -1
- package/src/ts/react-website/agui/generator.d.ts +1 -5
- package/src/ts/react-website/agui/generator.js +6 -2
- package/src/ts/react-website/agui/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +26 -26
- package/src/ts/react-website/app/generator.d.ts +1 -5
- package/src/ts/react-website/app/generator.js +3 -8
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +2 -2
- package/src/utils/agent-connection/agent-connection.d.ts +2 -1
- package/src/utils/agent-connection/agent-connection.js +6 -1
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-core-constructs/files/cdk/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.ts.template +11 -7
- package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/agentcore-gateway.ts.template +14 -6
- package/src/utils/agent-core-packaging.js +5 -5
- package/src/utils/agent-core-packaging.js.map +1 -1
- package/src/utils/api-constructs/api-constructs.d.ts +5 -0
- package/src/utils/api-constructs/api-constructs.js +8 -0
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/api-constructs/files/cdk/app/apis/http/__apiNameKebabCase__.ts.template +4 -2
- package/src/utils/api-constructs/files/cdk/app/apis/rest/__apiNameKebabCase__.ts.template +4 -2
- package/src/utils/ast.d.ts +10 -0
- package/src/utils/ast.js +87 -15
- package/src/utils/ast.js.map +1 -1
- package/src/utils/dependencies.d.ts +10 -0
- package/src/utils/dependencies.js +93 -1
- package/src/utils/dependencies.js.map +1 -1
- package/src/utils/docker.d.ts +11 -0
- package/src/utils/docker.js +16 -3
- package/src/utils/docker.js.map +1 -1
- package/src/utils/dynamodb-config.d.ts +48 -0
- package/src/utils/dynamodb-config.js +44 -0
- package/src/utils/dynamodb-config.js.map +1 -0
- package/src/utils/dynamodb-constructs/files/cdk/app/dynamodb/__nameKebabCase__.ts.template +8 -4
- package/src/utils/files/common/shadcn/src/components/ui/alert.tsx.template +1 -2
- package/src/utils/files/common/shadcn/src/components/ui/avatar.tsx.template +1 -2
- package/src/utils/files/common/shadcn/src/components/ui/breadcrumb.tsx.template +1 -2
- package/src/utils/files/common/shadcn/src/components/ui/button.tsx.template +1 -2
- package/src/utils/files/common/shadcn/src/components/ui/card.tsx.template +1 -2
- package/src/utils/files/common/shadcn/src/components/ui/input.tsx.template +1 -2
- package/src/utils/files/common/shadcn/src/components/ui/separator.tsx.template +1 -2
- package/src/utils/files/common/shadcn/src/components/ui/sheet.tsx.template +1 -2
- package/src/utils/files/common/shadcn/src/components/ui/sidebar.tsx.template +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/skeleton.tsx.template +1 -1
- package/src/utils/files/common/shadcn/src/components/ui/spinner.tsx.template +1 -2
- package/src/utils/files/common/shadcn/src/components/ui/textarea.tsx.template +1 -2
- package/src/utils/files/common/shadcn/src/components/ui/tooltip.tsx.template +1 -2
- package/src/utils/files/common/shadcn/src/lib/utils.ts.template +1 -6
- package/src/utils/git-secrets.d.ts +28 -0
- package/src/utils/git-secrets.js +66 -0
- package/src/utils/git-secrets.js.map +1 -0
- package/src/utils/init.js +7 -6
- package/src/utils/init.js.map +1 -1
- package/src/utils/local-project-dependency.d.ts +28 -0
- package/src/utils/local-project-dependency.js +40 -0
- package/src/utils/local-project-dependency.js.map +1 -0
- package/src/utils/nx.d.ts +14 -0
- package/src/utils/nx.js +30 -0
- package/src/utils/nx.js.map +1 -1
- package/src/utils/rdb-constructs/files/cdk/app/dbs/__nameKebabCase__.ts.template +11 -6
- package/src/utils/script-project-targets.d.ts +26 -0
- package/src/utils/script-project-targets.js +75 -0
- package/src/utils/script-project-targets.js.map +1 -0
- package/src/utils/shared-shadcn.d.ts +1 -3
- package/src/utils/shared-shadcn.js +1 -4
- package/src/utils/shared-shadcn.js.map +1 -1
- package/src/utils/versions.d.ts +52 -50
- package/src/utils/versions.js +55 -49
- package/src/utils/versions.js.map +1 -1
- package/src/utils/website-constructs/files/cdk/app/static-websites/__websiteNameKebabCase__.ts.template +8 -4
- package/src/migrations/latest/add-assemble-target/migration.js.map +0 -1
- package/src/migrations/latest/agent-connection-pin-strands-peers/migration.js.map +0 -1
- package/src/migrations/latest/agent-core-vendor-target/migration.js.map +0 -1
- package/src/migrations/latest/declare-cacheable-target-inputs/migration.js.map +0 -1
- package/src/migrations/latest/dev-target-depends-on-pull-image/migration.js.map +0 -1
- package/src/migrations/latest/docker-target-cache-soundness/migration.js.map +0 -1
- package/src/migrations/latest/ignore-package-manager-temp-files/migration.js.map +0 -1
- package/src/migrations/latest/infra-deploy-express-mode/metadata.json +0 -3
- package/src/migrations/latest/infra-deploy-express-mode/migration.js.map +0 -1
- package/src/migrations/latest/open-api-codegen-executor/migration.js.map +0 -1
- package/src/migrations/latest/python-test-input-scoping/migration.js.map +0 -1
- package/src/migrations/latest/react-website-unique-dev-ports/migration.js.map +0 -1
- package/src/migrations/latest/rolldown-config-bundle-transient/migration.js.map +0 -1
- package/src/migrations/latest/shadcn-package-imports-exports/migration.js.map +0 -1
- package/src/migrations/latest/shx-fs-commands/migration.js.map +0 -1
- package/src/migrations/latest/terraform-fmt-check/migration.js.map +0 -1
- package/src/migrations/latest/terraform-provider-plugin-cache/migration.js.map +0 -1
- package/src/migrations/latest/vitest-coverage-output-dir/migration.js.map +0 -1
- package/src/py/dynamodb/files/__name__/__init__.py.template +0 -6
- package/src/py/dynamodb/files/__name__/entities/__init__.py.template +0 -4
- package/src/py/dynamodb/files/config.json.template +0 -24
- package/src/ts/dynamodb/files/config.json.template +0 -24
- package/src/ts/dynamodb/files/src/entities/index.ts.template +0 -1
- package/src/ts/dynamodb/files/src/index.ts.template +0 -2
- /package/src/migrations/latest/{add-assemble-target → sandbox-pattern-nested-stacks}/migration.d.ts +0 -0
- /package/src/migrations/latest/{agent-core-vendor-target → shadcn-cn-package}/migration.d.ts +0 -0
- /package/src/migrations/{latest/dev-target-depends-on-pull-image → v1.0.0-rc.90/0001-dev-target-depends-on-pull-image}/metadata.json +0 -0
- /package/src/migrations/{latest/declare-cacheable-target-inputs → v1.0.0-rc.90/0001-dev-target-depends-on-pull-image}/migration.d.ts +0 -0
- /package/src/migrations/{latest/dev-target-depends-on-pull-image → v1.0.0-rc.90/0001-dev-target-depends-on-pull-image}/migration.js +0 -0
- /package/src/migrations/{latest/open-api-codegen-executor → v1.0.0-rc.90/0002-open-api-codegen-executor}/metadata.json +0 -0
- /package/src/migrations/{latest/dev-target-depends-on-pull-image → v1.0.0-rc.90/0002-open-api-codegen-executor}/migration.d.ts +0 -0
- /package/src/migrations/{latest/open-api-codegen-executor → v1.0.0-rc.90/0002-open-api-codegen-executor}/migration.js +0 -0
- /package/src/migrations/{latest/terraform-provider-plugin-cache → v1.0.0-rc.90/0003-terraform-provider-plugin-cache}/metadata.json +0 -0
- /package/src/migrations/{latest/docker-target-cache-soundness → v1.0.0-rc.90/0003-terraform-provider-plugin-cache}/migration.d.ts +0 -0
- /package/src/migrations/{latest/terraform-provider-plugin-cache → v1.0.0-rc.90/0003-terraform-provider-plugin-cache}/migration.js +0 -0
- /package/src/migrations/{latest/python-test-input-scoping → v1.0.0-rc.90/0004-python-test-input-scoping}/metadata.json +0 -0
- /package/src/migrations/{latest/infra-deploy-express-mode → v1.0.0-rc.90/0004-python-test-input-scoping}/migration.d.ts +0 -0
- /package/src/migrations/{latest/python-test-input-scoping → v1.0.0-rc.90/0004-python-test-input-scoping}/migration.js +0 -0
- /package/src/migrations/{latest/vitest-coverage-output-dir → v1.0.0-rc.90/0005-vitest-coverage-output-dir}/metadata.json +0 -0
- /package/src/migrations/{latest/open-api-codegen-executor → v1.0.0-rc.90/0005-vitest-coverage-output-dir}/migration.d.ts +0 -0
- /package/src/migrations/{latest/vitest-coverage-output-dir → v1.0.0-rc.90/0005-vitest-coverage-output-dir}/migration.js +0 -0
- /package/src/migrations/{latest/add-assemble-target → v1.0.0-rc.90/0006-add-assemble-target}/metadata.json +0 -0
- /package/src/migrations/{latest/python-test-input-scoping → v1.0.0-rc.90/0006-add-assemble-target}/migration.d.ts +0 -0
- /package/src/migrations/{latest/add-assemble-target → v1.0.0-rc.90/0006-add-assemble-target}/migration.js +0 -0
- /package/src/migrations/{latest/docker-target-cache-soundness → v1.0.0-rc.90/0007-docker-target-cache-soundness}/metadata.json +0 -0
- /package/src/migrations/{latest/react-website-unique-dev-ports → v1.0.0-rc.90/0007-docker-target-cache-soundness}/migration.d.ts +0 -0
- /package/src/migrations/{latest/docker-target-cache-soundness → v1.0.0-rc.90/0007-docker-target-cache-soundness}/migration.js +0 -0
- /package/src/migrations/{latest/declare-cacheable-target-inputs → v1.0.0-rc.90/0008-declare-cacheable-target-inputs}/metadata.json +0 -0
- /package/src/migrations/{latest/rolldown-config-bundle-transient → v1.0.0-rc.90/0008-declare-cacheable-target-inputs}/migration.d.ts +0 -0
- /package/src/migrations/{latest/declare-cacheable-target-inputs → v1.0.0-rc.90/0008-declare-cacheable-target-inputs}/migration.js +0 -0
- /package/src/migrations/{latest/terraform-fmt-check → v1.0.0-rc.90/0009-terraform-fmt-check}/metadata.json +0 -0
- /package/src/migrations/{latest/shadcn-package-imports-exports → v1.0.0-rc.90/0009-terraform-fmt-check}/migration.d.ts +0 -0
- /package/src/migrations/{latest/terraform-fmt-check → v1.0.0-rc.90/0009-terraform-fmt-check}/migration.js +0 -0
- /package/src/migrations/{latest/react-website-unique-dev-ports → v1.0.0-rc.92/0001-react-website-unique-dev-ports}/metadata.json +0 -0
- /package/src/migrations/{latest/shx-fs-commands → v1.0.0-rc.92/0001-react-website-unique-dev-ports}/migration.d.ts +0 -0
- /package/src/migrations/{latest/react-website-unique-dev-ports → v1.0.0-rc.92/0001-react-website-unique-dev-ports}/migration.js +0 -0
- /package/src/migrations/{latest/terraform-fmt-check → v1.0.0-rc.94/0001-infra-deploy-express-mode}/migration.d.ts +0 -0
- /package/src/migrations/{latest/shx-fs-commands → v1.0.0-rc.94/0002-shx-fs-commands}/metadata.json +0 -0
- /package/src/migrations/{latest/terraform-provider-plugin-cache → v1.0.0-rc.94/0002-shx-fs-commands}/migration.d.ts +0 -0
- /package/src/migrations/{latest/shx-fs-commands → v1.0.0-rc.94/0002-shx-fs-commands}/migration.js +0 -0
- /package/src/migrations/{latest/agent-core-vendor-target → v1.0.0-rc.94/0003-agent-core-vendor-target}/metadata.json +0 -0
- /package/src/migrations/{latest/vitest-coverage-output-dir → v1.0.0-rc.94/0003-agent-core-vendor-target}/migration.d.ts +0 -0
- /package/src/migrations/{latest/agent-core-vendor-target → v1.0.0-rc.94/0003-agent-core-vendor-target}/migration.js +0 -0
- /package/src/migrations/{latest/rolldown-config-bundle-transient → v1.0.0-rc.95/0001-rolldown-config-bundle-transient}/metadata.json +0 -0
- /package/src/migrations/{latest/rolldown-config-bundle-transient → v1.0.0-rc.95/0001-rolldown-config-bundle-transient}/migration.js +0 -0
- /package/src/migrations/{latest/agent-connection-pin-strands-peers → v1.0.0-rc.95/0002-agent-connection-pin-strands-peers}/metadata.json +0 -0
- /package/src/migrations/{latest/agent-connection-pin-strands-peers → v1.0.0-rc.95/0002-agent-connection-pin-strands-peers}/migration.d.ts +0 -0
- /package/src/migrations/{latest/agent-connection-pin-strands-peers → v1.0.0-rc.95/0002-agent-connection-pin-strands-peers}/migration.js +0 -0
- /package/src/migrations/{latest/ignore-package-manager-temp-files → v1.0.0-rc.95/0003-ignore-package-manager-temp-files}/metadata.json +0 -0
- /package/src/migrations/{latest/ignore-package-manager-temp-files → v1.0.0-rc.95/0003-ignore-package-manager-temp-files}/migration.d.ts +0 -0
- /package/src/migrations/{latest/ignore-package-manager-temp-files → v1.0.0-rc.95/0003-ignore-package-manager-temp-files}/migration.js +0 -0
- /package/src/migrations/{latest/shadcn-package-imports-exports → v1.0.0-rc.95/0004-shadcn-package-imports-exports}/metadata.json +0 -0
- /package/src/migrations/{latest/shadcn-package-imports-exports → v1.0.0-rc.95/0004-shadcn-package-imports-exports}/migration.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/internal/test-matrix/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { GeneratorCallback, Tree } from '@nx/devkit';\nimport { agentcoreGatewayGenerator } from '../../sdk/agentcore-gateway.js';\nimport { agentcoreHarnessGenerator } from '../../sdk/agentcore-harness.js';\nimport {\n type ConnectionGeneratorSchema,\n connectionGenerator,\n} from '../../sdk/connection.js';\nimport { licenseGenerator } from '../../sdk/license.js';\nimport {\n type PyAgentGeneratorSchema,\n type PyApiGeneratorSchema,\n type PyRdbGeneratorSchema,\n pyAgentGenerator,\n pyApiGenerator,\n pyDynamoDBGenerator,\n pyLambdaFunctionGenerator,\n pyMcpServerGenerator,\n pyProjectGenerator,\n pyRdbGenerator,\n} from '../../sdk/py.js';\nimport { smithyProjectGenerator } from '../../sdk/smithy.js';\nimport { terraformProjectGenerator } from '../../sdk/terraform.js';\nimport {\n type TsAgentGeneratorSchema,\n type TsApiGeneratorSchema,\n type TsNxMigrationGeneratorSchema,\n type TsRdbGeneratorSchema,\n tsAgentGenerator,\n tsApiGenerator,\n tsAstroDocsGenerator,\n tsDcrProxyGenerator,\n tsDynamoDBGenerator,\n tsInfraGenerator,\n tsLambdaFunctionGenerator,\n tsMcpServerGenerator,\n tsNxGeneratorGenerator,\n tsNxMigrationGenerator,\n tsNxPluginGenerator,\n tsProjectGenerator,\n tsRdbGenerator,\n tsWebsiteAuthGenerator,\n tsWebsiteGenerator,\n} from '../../sdk/ts.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { toSnakeCase } from '../../utils/names.js';\nimport { getNpmScope, getNpmScopePrefix } from '../../utils/npm-scope.js';\nimport type { InternalTestMatrixGeneratorSchema } from './schema';\n\n/**\n * Scaffolds every generator, component and connection permutation the e2e tests\n * cover, by composing the generators in-process on a single tree.\n *\n * This ships with the plugin so each released version carries the matrix of the\n * generators *it* had. A test upgrading an old workspace scaffolds with the\n * released version's own matrix and never has to reason about which generators\n * existed when — driving the CLI from the test repo instead would couple the\n * test to a generator list that only describes today's plugin.\n *\n * Hidden and undocumented: it exists for the e2e suite, not for users.\n *\n * Options are typed against each generator's schema, so adding a required option\n * or changing an enum breaks the build here rather than silently reducing\n * coverage.\n *\n * Projects are generated with `preferInstallDependencies: false` by default and\n * the returned callback installs once. Nothing composed here reads the project\n * graph (only `ts#sync` does, which is not part of the matrix), so no\n * intermediate install is needed.\n */\nexport const internalTestMatrixGenerator = async (\n tree: Tree,\n options: InternalTestMatrixGeneratorSchema = {},\n): Promise<GeneratorCallback> => {\n const preferInstallDependencies = options.preferInstallDependencies ?? false;\n const defaults = { preferInstallDependencies };\n const projectDefaults = { ...defaults, directory: 'packages' };\n // Fully-qualified project names, which differ per language: TypeScript\n // projects are scope-prefixed, Python ones are dotted snake_case. Derived from\n // the workspace rather than hardcoded, so the matrix works in any workspace.\n const ts = (name: string) => `${getNpmScopePrefix(tree)}${name}`;\n const py = (name: string) =>\n `${toSnakeCase(getNpmScope(tree))}.${toSnakeCase(name)}`;\n\n // The infrastructure project every other generator deploys into. Which\n // generator owns it depends on the workspace's IaC provider, so the caller\n // asks for the one matching the workspace it created.\n if (options.infra === 'terraform') {\n await terraformProjectGenerator(tree, {\n name: 'infra',\n type: 'application',\n ...projectDefaults,\n });\n } else {\n await tsInfraGenerator(tree, { name: 'infra', ...projectDefaults });\n // A second CDK app with stage config, which only ts#infra offers.\n await tsInfraGenerator(tree, {\n name: 'infra-with-stages',\n stageConfig: true,\n ...projectDefaults,\n });\n }\n\n // Websites (with and without TanStack Router), a docs site, and auth on each.\n await tsWebsiteGenerator(tree, {\n name: 'website',\n iac: 'inherit',\n ...projectDefaults,\n });\n await tsWebsiteGenerator(tree, {\n name: 'website-no-router',\n tanstackRouter: false,\n iac: 'inherit',\n ...projectDefaults,\n });\n await tsAstroDocsGenerator(tree, { name: 'docs-site', ...defaults });\n await tsWebsiteAuthGenerator(tree, {\n project: ts('website'),\n cognitoDomain: 'test',\n allowSignup: true,\n iac: 'inherit',\n ...defaults,\n });\n await tsWebsiteAuthGenerator(tree, {\n project: ts('website-no-router'),\n cognitoDomain: 'test-no-router',\n allowSignup: true,\n iac: 'inherit',\n ...defaults,\n });\n\n // tRPC APIs — REST + HTTP, with Cognito and custom auth.\n const tsApis: TsApiGeneratorSchema[] = [\n { name: 'my-api', infra: 'rest-lambda', auth: 'iam', iac: 'inherit' },\n { name: 'my-api-http', infra: 'http-lambda', auth: 'iam', iac: 'inherit' },\n // The APIs above take the default `isolated` integration pattern; these\n // cover `shared`.\n {\n name: 'my-api-shared',\n infra: 'rest-lambda',\n auth: 'iam',\n integrationPattern: 'shared',\n iac: 'inherit',\n },\n {\n name: 'my-api-shared-http',\n infra: 'http-lambda',\n auth: 'iam',\n integrationPattern: 'shared',\n iac: 'inherit',\n },\n {\n name: 'my-api-custom',\n infra: 'rest-lambda',\n auth: 'custom',\n iac: 'inherit',\n },\n {\n name: 'my-api-custom-http',\n infra: 'http-lambda',\n auth: 'custom',\n iac: 'inherit',\n },\n {\n name: 'my-smithy-api',\n framework: 'smithy',\n infra: 'rest-lambda',\n auth: 'iam',\n iac: 'inherit',\n },\n ];\n for (const api of tsApis) {\n await tsApiGenerator(tree, { ...api, ...projectDefaults });\n }\n\n // A Smithy shape library; `my-smithy-api` covers consuming one.\n await smithyProjectGenerator(tree, {\n name: 'my-shapes',\n type: 'shapes',\n ...projectDefaults,\n });\n\n // Python FastAPI — REST + HTTP, with Cognito and custom auth.\n const pyApis: PyApiGeneratorSchema[] = [\n { name: 'py-api', infra: 'rest-lambda', auth: 'iam', iac: 'inherit' },\n { name: 'py-api-http', infra: 'http-lambda', auth: 'iam', iac: 'inherit' },\n {\n name: 'py-api-custom',\n infra: 'rest-lambda',\n auth: 'custom',\n iac: 'inherit',\n },\n {\n name: 'py-api-custom-http',\n infra: 'http-lambda',\n auth: 'custom',\n iac: 'inherit',\n },\n ];\n for (const api of pyApis) {\n await pyApiGenerator(tree, { ...api, ...projectDefaults });\n }\n\n // Library projects hosting the components below, each with a lambda function.\n await pyProjectGenerator(tree, {\n name: 'py-project',\n type: 'application',\n ...projectDefaults,\n });\n await tsProjectGenerator(tree, { name: 'ts-project', ...projectDefaults });\n await pyLambdaFunctionGenerator(tree, {\n project: py('py-project'),\n name: 'my-function',\n event: 'Any',\n iac: 'inherit',\n ...defaults,\n });\n await tsLambdaFunctionGenerator(tree, {\n project: 'ts-project',\n name: 'my-function',\n event: 'Any',\n iac: 'inherit',\n ...defaults,\n });\n\n // MCP servers — uninfra'd and hosted on AgentCore.\n await pyMcpServerGenerator(tree, {\n project: 'py_project',\n name: 'my-mcp-server',\n infra: 'agentcore',\n iac: 'inherit',\n ...defaults,\n });\n await tsMcpServerGenerator(tree, {\n project: 'ts-project',\n name: 'my-mcp-server',\n infra: 'none',\n iac: 'inherit',\n ...defaults,\n });\n await tsMcpServerGenerator(tree, {\n project: 'ts-project',\n name: 'hosted-mcp-server',\n infra: 'agentcore',\n iac: 'inherit',\n ...defaults,\n });\n // Container-packaged variants, so both packagings are covered and a workspace\n // mixing them vends one copy of the shared runtime module.\n await tsMcpServerGenerator(tree, {\n project: 'ts-project',\n name: 'ecr-mcp-server',\n infra: 'agentcore-ecr',\n iac: 'inherit',\n ...defaults,\n });\n await pyMcpServerGenerator(tree, {\n project: 'py_project',\n name: 'ecr-mcp-server',\n infra: 'agentcore-ecr',\n iac: 'inherit',\n ...defaults,\n });\n\n // OAuth DCR proxy for Cognito-authenticated MCP servers.\n await tsDcrProxyGenerator(tree, {\n name: 'my-dcr-proxy',\n iac: 'inherit',\n ...projectDefaults,\n });\n\n // TypeScript agents across every protocol and auth permutation. The unnamed\n // one takes the generator's default name, which the connections below use.\n const tsAgents: TsAgentGeneratorSchema[] = [\n {\n project: 'ts-project',\n name: 'my-ts-agent',\n infra: 'none',\n iac: 'inherit',\n },\n { project: 'ts-project', infra: 'agentcore', iac: 'inherit' },\n {\n project: 'ts-project',\n name: 'my-ts-ecr-agent',\n infra: 'agentcore-ecr',\n iac: 'inherit',\n },\n {\n project: 'ts-project',\n name: 'my-ts-a2a-agent',\n protocol: 'a2a',\n infra: 'agentcore',\n iac: 'inherit',\n },\n {\n project: 'ts-project',\n name: 'my-ts-a2a-agent-cognito',\n protocol: 'a2a',\n auth: 'cognito',\n infra: 'agentcore',\n iac: 'inherit',\n },\n {\n project: 'ts-project',\n name: 'my-ts-agui-agent',\n protocol: 'ag-ui',\n infra: 'agentcore',\n iac: 'inherit',\n },\n ];\n for (const agent of tsAgents) {\n await tsAgentGenerator(tree, { ...agent, ...defaults });\n }\n\n // Python agents: Strands across every protocol, plus LangChain in its own\n // project — langchain's dependency closure would push the zip-bundled Lambda\n // in py-project past its unzipped size limit.\n const pyAgents: PyAgentGeneratorSchema[] = [\n {\n project: 'py_project',\n name: 'my-agent',\n infra: 'agentcore',\n iac: 'inherit',\n },\n {\n project: 'py_project',\n name: 'my-py-ecr-agent',\n infra: 'agentcore-ecr',\n iac: 'inherit',\n },\n {\n project: 'py_project',\n name: 'my-py-a2a-agent',\n protocol: 'a2a',\n infra: 'agentcore',\n iac: 'inherit',\n },\n {\n project: 'py_project',\n name: 'my-py-a2a-agent-cognito',\n protocol: 'a2a',\n auth: 'cognito',\n infra: 'agentcore',\n iac: 'inherit',\n },\n {\n project: 'py_project',\n name: 'my-py-agui-agent',\n protocol: 'ag-ui',\n infra: 'agentcore',\n iac: 'inherit',\n },\n ];\n for (const agent of pyAgents) {\n await pyAgentGenerator(tree, { ...agent, ...defaults });\n }\n await pyProjectGenerator(tree, {\n name: 'py-langchain-project',\n type: 'application',\n ...projectDefaults,\n });\n const langchainAgents: PyAgentGeneratorSchema[] = [\n {\n project: 'py_langchain_project',\n name: 'my-py-langchain-agent',\n protocol: 'ag-ui',\n iac: 'inherit',\n },\n {\n project: 'py_langchain_project',\n name: 'my-py-langchain-http-agent',\n protocol: 'http',\n iac: 'inherit',\n },\n {\n project: 'py_langchain_project',\n name: 'my-py-langchain-a2a-agent',\n protocol: 'a2a',\n iac: 'inherit',\n },\n ];\n for (const agent of langchainAgents) {\n await pyAgentGenerator(tree, {\n ...agent,\n framework: 'langchain',\n infra: 'agentcore',\n ...defaults,\n });\n }\n\n // AgentCore gateways, including a parent fronting the first (chained), and\n // an http-protocol gateway fronting agent runtime targets.\n await agentcoreGatewayGenerator(tree, {\n name: 'my-gateway',\n iac: 'inherit',\n ...projectDefaults,\n });\n await agentcoreGatewayGenerator(tree, {\n name: 'parent-gateway',\n iac: 'inherit',\n ...projectDefaults,\n });\n await agentcoreGatewayGenerator(tree, {\n name: 'agent-gateway',\n protocol: 'http',\n iac: 'inherit',\n ...projectDefaults,\n });\n\n // AgentCore Harness — a standalone invocation project.\n await agentcoreHarnessGenerator(tree, {\n name: 'my-harness',\n infra: 'agentcore',\n iac: 'inherit',\n ...projectDefaults,\n });\n\n // Databases — DynamoDB, plus Aurora across both engines and ORMs.\n await tsDynamoDBGenerator(tree, {\n name: 'my-table',\n framework: 'electrodb',\n infra: 'dynamodb',\n iac: 'inherit',\n ...projectDefaults,\n });\n await pyDynamoDBGenerator(tree, {\n name: 'my-py-table',\n framework: 'pynamodb',\n infra: 'dynamodb',\n iac: 'inherit',\n ...projectDefaults,\n });\n const tsRdbs: TsRdbGeneratorSchema[] = [\n {\n name: 'postgres-db',\n infra: 'aurora',\n engine: 'postgres',\n framework: 'prisma',\n iac: 'inherit',\n },\n {\n name: 'my-sql-db',\n infra: 'aurora',\n engine: 'mysql',\n framework: 'prisma',\n iac: 'inherit',\n },\n ];\n for (const rdb of tsRdbs) {\n await tsRdbGenerator(tree, { ...rdb, ...projectDefaults });\n }\n const pyRdbs: PyRdbGeneratorSchema[] = [\n {\n name: 'py-postgres-db',\n infra: 'aurora',\n engine: 'postgres',\n framework: 'sqlmodel',\n iac: 'inherit',\n },\n {\n name: 'py-mysql-db',\n infra: 'aurora',\n engine: 'mysql',\n framework: 'sqlmodel',\n iac: 'inherit',\n },\n ];\n for (const rdb of pyRdbs) {\n await pyRdbGenerator(tree, { ...rdb, ...projectDefaults });\n }\n\n // Every connection edge the matrix covers.\n const connections: ConnectionGeneratorSchema[] = [\n // Website -> API\n { sourceProject: ts('website'), targetProject: ts('my-api') },\n { sourceProject: ts('website-no-router'), targetProject: ts('my-api') },\n { sourceProject: 'website', targetProject: 'py_api' },\n { sourceProject: 'website', targetProject: 'my-smithy-api' },\n // Agent -> MCP server\n {\n sourceProject: 'ts-project',\n sourceComponent: 'agent',\n targetProject: 'ts-project',\n targetComponent: 'hosted-mcp-server',\n },\n {\n sourceProject: 'ts-project',\n sourceComponent: 'my-ts-agui-agent',\n targetProject: 'ts-project',\n targetComponent: 'hosted-mcp-server',\n },\n {\n sourceProject: 'ts-project',\n sourceComponent: 'agent',\n targetProject: 'py_project',\n targetComponent: 'my-mcp-server',\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: 'py_project',\n targetComponent: 'my-mcp-server',\n },\n {\n sourceProject: 'py_langchain_project',\n sourceComponent: 'my-py-langchain-agent',\n targetProject: 'py_project',\n targetComponent: 'my-mcp-server',\n },\n // HTTP agent <-> A2A agent\n {\n sourceProject: 'ts-project',\n sourceComponent: 'agent',\n targetProject: 'ts-project',\n targetComponent: 'my-ts-a2a-agent',\n },\n {\n sourceProject: 'ts-project',\n sourceComponent: 'agent',\n targetProject: 'py_project',\n targetComponent: 'my-py-a2a-agent',\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: 'ts-project',\n targetComponent: 'my-ts-a2a-agent',\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: 'py_project',\n targetComponent: 'my-py-a2a-agent',\n },\n {\n sourceProject: 'py_langchain_project',\n sourceComponent: 'my-py-langchain-agent',\n targetProject: 'py_project',\n targetComponent: 'my-py-a2a-agent',\n },\n // Agent -> gateway, gateway -> MCP server, gateway -> gateway\n {\n sourceProject: 'ts-project',\n sourceComponent: 'agent',\n targetProject: ts('my-gateway'),\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: ts('my-gateway'),\n },\n {\n sourceProject: 'py_langchain_project',\n sourceComponent: 'my-py-langchain-agent',\n targetProject: ts('my-gateway'),\n },\n {\n sourceProject: ts('my-gateway'),\n targetProject: 'ts-project',\n targetComponent: 'hosted-mcp-server',\n },\n {\n sourceProject: ts('my-gateway'),\n targetProject: 'py_project',\n targetComponent: 'my-mcp-server',\n },\n { sourceProject: ts('parent-gateway'), targetProject: ts('my-gateway') },\n // Gateway -> agent (http gateway fronting agent runtime targets: every\n // supported protocol permutation), then website -> gateway.\n {\n sourceProject: ts('agent-gateway'),\n targetProject: 'ts-project',\n targetComponent: 'my-ts-agui-agent',\n },\n {\n sourceProject: ts('agent-gateway'),\n targetProject: 'ts-project',\n targetComponent: 'my-ts-a2a-agent',\n },\n {\n sourceProject: ts('agent-gateway'),\n targetProject: 'py_project',\n targetComponent: 'my-py-agui-agent',\n },\n {\n sourceProject: ts('agent-gateway'),\n targetProject: 'py_project',\n targetComponent: 'my-agent',\n },\n {\n sourceProject: ts('agent-gateway'),\n targetProject: 'py_project',\n targetComponent: 'my-py-a2a-agent',\n },\n {\n sourceProject: ts('website-no-router'),\n targetProject: ts('agent-gateway'),\n },\n // Website -> agent\n {\n sourceProject: ts('website'),\n targetProject: 'ts-project',\n targetComponent: 'agent',\n },\n {\n sourceProject: ts('website'),\n targetProject: 'ts-project',\n targetComponent: 'my-ts-agui-agent',\n },\n {\n sourceProject: ts('website'),\n targetProject: 'py_project',\n targetComponent: 'my-agent',\n },\n {\n sourceProject: ts('website'),\n targetProject: 'py_project',\n targetComponent: 'my-py-agui-agent',\n },\n {\n sourceProject: ts('website'),\n targetProject: 'py_langchain_project',\n targetComponent: 'my-py-langchain-agent',\n },\n {\n sourceProject: ts('website'),\n targetProject: 'py_langchain_project',\n targetComponent: 'my-py-langchain-http-agent',\n },\n // DynamoDB\n { sourceProject: 'my-api', targetProject: ts('my-table') },\n { sourceProject: 'my-smithy-api', targetProject: ts('my-table') },\n {\n sourceProject: 'ts-project',\n sourceComponent: 'my-ts-agent',\n targetProject: ts('my-table'),\n },\n {\n sourceProject: 'ts-project',\n sourceComponent: 'my-mcp-server',\n targetProject: ts('my-table'),\n },\n { sourceProject: 'py_api', targetProject: 'my_py_table' },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: 'my_py_table',\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-mcp-server',\n targetProject: 'my_py_table',\n },\n {\n sourceProject: 'py_langchain_project',\n sourceComponent: 'my-py-langchain-http-agent',\n targetProject: 'my_py_table',\n },\n // Relational databases\n { sourceProject: 'py_api', targetProject: 'py_postgres_db' },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: 'py_postgres_db',\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-mcp-server',\n targetProject: 'py_postgres_db',\n },\n ];\n for (const connection of connections) {\n await connectionGenerator(tree, { ...connection, ...defaults });\n }\n\n // Licensing, then an Nx plugin with a custom generator.\n await licenseGenerator(tree, {\n license: 'Apache-2.0',\n copyrightHolder: 'Amazon.com, Inc. or its affiliates',\n ...defaults,\n });\n await tsNxPluginGenerator(tree, {\n ...projectDefaults,\n name: 'plugin',\n directory: 'tools',\n });\n await tsNxGeneratorGenerator(tree, {\n project: ts('plugin'),\n name: 'my#generator',\n ...defaults,\n });\n\n // A migration of each kind, so the scaffolded codemods compile and the\n // plugin's migrations.json (created by the first run) registers all three.\n const migrations: Omit<TsNxMigrationGeneratorSchema, 'project'>[] = [\n {\n name: 'rename-foo-target',\n description: 'Rename the foo target to bar',\n },\n {\n name: 'migrate-custom-handlers',\n description: 'Update custom handlers for the new API',\n kind: 'agentic',\n },\n {\n name: 'upgrade-framework',\n description: 'Upgrade the framework and reconcile call sites',\n kind: 'hybrid',\n },\n ];\n for (const migration of migrations) {\n await tsNxMigrationGenerator(tree, {\n ...migration,\n project: ts('plugin'),\n ...defaults,\n });\n }\n\n return () =>\n installDependencies(tree, preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\n\nexport default internalTestMatrixGenerator;\n"],"names":["agentcoreGatewayGenerator","agentcoreHarnessGenerator","connectionGenerator","licenseGenerator","pyAgentGenerator","pyApiGenerator","pyDynamoDBGenerator","pyLambdaFunctionGenerator","pyMcpServerGenerator","pyProjectGenerator","pyRdbGenerator","smithyProjectGenerator","terraformProjectGenerator","tsAgentGenerator","tsApiGenerator","tsAstroDocsGenerator","tsDcrProxyGenerator","tsDynamoDBGenerator","tsInfraGenerator","tsLambdaFunctionGenerator","tsMcpServerGenerator","tsNxGeneratorGenerator","tsNxMigrationGenerator","tsNxPluginGenerator","tsProjectGenerator","tsRdbGenerator","tsWebsiteAuthGenerator","tsWebsiteGenerator","installDependencies","toSnakeCase","getNpmScope","getNpmScopePrefix","internalTestMatrixGenerator","tree","options","preferInstallDependencies","defaults","projectDefaults","directory","ts","name","py","infra","type","stageConfig","iac","tanstackRouter","project","cognitoDomain","allowSignup","tsApis","auth","integrationPattern","framework","api","pyApis","event","tsAgents","protocol","agent","pyAgents","langchainAgents","tsRdbs","engine","rdb","pyRdbs","connections","sourceProject","targetProject","sourceComponent","targetComponent","connection","license","copyrightHolder","migrations","description","kind","migration","languages"],"mappings":"AAAA;;;CAGC,GAED,SAASA,yBAAyB,QAAQ,iCAAiC;AAC3E,SAASC,yBAAyB,QAAQ,iCAAiC;AAC3E,SAEEC,mBAAmB,QACd,0BAA0B;AACjC,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAIEC,gBAAgB,EAChBC,cAAc,EACdC,mBAAmB,EACnBC,yBAAyB,EACzBC,oBAAoB,EACpBC,kBAAkB,EAClBC,cAAc,QACT,kBAAkB;AACzB,SAASC,sBAAsB,QAAQ,sBAAsB;AAC7D,SAASC,yBAAyB,QAAQ,yBAAyB;AACnE,SAKEC,gBAAgB,EAChBC,cAAc,EACdC,oBAAoB,EACpBC,mBAAmB,EACnBC,mBAAmB,EACnBC,gBAAgB,EAChBC,yBAAyB,EACzBC,oBAAoB,EACpBC,sBAAsB,EACtBC,sBAAsB,EACtBC,mBAAmB,EACnBC,kBAAkB,EAClBC,cAAc,EACdC,sBAAsB,EACtBC,kBAAkB,QACb,kBAAkB;AACzB,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,S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A;YACED,eAAe;YACfE,iBAAiB;YACjBD,eAAe;QACjB;QACA;YACED,eAAe;YACfE,iBAAiB;YACjBD,eAAe;QACjB;QACA,uBAAuB;QACvB;YAAED,eAAe;YAAUC,eAAe;QAAiB;QAC3D;YACED,eAAe;YACfE,iBAAiB;YACjBD,eAAe;QACjB;QACA;YACED,eAAe;YACfE,iBAAiB;YACjBD,eAAe;QACjB;KACD;IACD,KAAK,MAAMG,cAAcL,YAAa;QACpC,MAAMhE,oBAAoB+B,MAAM;YAAE,GAAGsC,UAAU;YAAE,GAAGnC,QAAQ;QAAC;IAC/D;IAEA,wDAAwD;IACxD,MAAMjC,iBAAiB8B,MAAM;QAC3BuC,SAAS;QACTC,iBAAiB;QACjB,GAAGrC,QAAQ;IACb;IACA,MAAMb,oBAAoBU,MAAM;QAC9B,GAAGI,eAAe;QAClBG,MAAM;QACNF,WAAW;IACb;IACA,MAAMjB,uBAAuBY,MAAM;QACjCc,SAASR,GAAG;QACZC,MAAM;QACN,GAAGJ,QAAQ;IACb;IAEA,uEAAuE;IACvE,2EAA2E;IAC3E,MAAMsC,aAA8D;QAClE;YACElC,MAAM;YACNmC,aAAa;QACf;QACA;YACEnC,MAAM;YACNmC,aAAa;YACbC,MAAM;QACR;QACA;YACEpC,MAAM;YACNmC,aAAa;YACbC,MAAM;QACR;KACD;IACD,KAAK,MAAMC,aAAaH,WAAY;QAClC,MAAMpD,uBAAuBW,MAAM;YACjC,GAAG4C,SAAS;YACZ9B,SAASR,GAAG;YACZ,GAAGH,QAAQ;QACb;IACF;IAEA,OAAO,IACLR,oBAAoBK,MAAME,2BAA2B;YACnD2C,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AAEF,eAAe9C,4BAA4B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/internal/test-matrix/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { GeneratorCallback, Tree } from '@nx/devkit';\nimport { agentcoreGatewayGenerator } from '../../sdk/agentcore-gateway.js';\nimport { agentcoreHarnessGenerator } from '../../sdk/agentcore-harness.js';\nimport {\n type ConnectionGeneratorSchema,\n connectionGenerator,\n} from '../../sdk/connection.js';\nimport { licenseGenerator } from '../../sdk/license.js';\nimport {\n type PyAgentGeneratorSchema,\n type PyApiGeneratorSchema,\n type PyRdbGeneratorSchema,\n pyAgentGenerator,\n pyApiGenerator,\n pyDynamoDBGenerator,\n pyLambdaFunctionGenerator,\n pyMcpServerGenerator,\n pyProjectGenerator,\n pyRdbGenerator,\n} from '../../sdk/py.js';\nimport { smithyProjectGenerator } from '../../sdk/smithy.js';\nimport { terraformProjectGenerator } from '../../sdk/terraform.js';\nimport {\n type TsAgentGeneratorSchema,\n type TsApiGeneratorSchema,\n type TsNxMigrationGeneratorSchema,\n type TsRdbGeneratorSchema,\n tsAgentGenerator,\n tsApiGenerator,\n tsDcrProxyGenerator,\n tsDocsGenerator,\n tsDynamoDBGenerator,\n tsInfraGenerator,\n tsLambdaFunctionGenerator,\n tsMcpServerGenerator,\n tsNxGeneratorGenerator,\n tsNxMigrationGenerator,\n tsNxPluginGenerator,\n tsProjectGenerator,\n tsRdbGenerator,\n tsWebsiteAuthGenerator,\n tsWebsiteGenerator,\n} from '../../sdk/ts.js';\nimport { installDependencies } from '../../utils/install.js';\nimport { toSnakeCase } from '../../utils/names.js';\nimport { getNpmScope, getNpmScopePrefix } from '../../utils/npm-scope.js';\nimport type { InternalTestMatrixGeneratorSchema } from './schema';\n\n/**\n * Scaffolds every generator, component and connection permutation the e2e tests\n * cover, by composing the generators in-process on a single tree.\n *\n * This ships with the plugin so each released version carries the matrix of the\n * generators *it* had. A test upgrading an old workspace scaffolds with the\n * released version's own matrix and never has to reason about which generators\n * existed when — driving the CLI from the test repo instead would couple the\n * test to a generator list that only describes today's plugin.\n *\n * Hidden and undocumented: it exists for the e2e suite, not for users.\n *\n * Options are typed against each generator's schema, so adding a required option\n * or changing an enum breaks the build here rather than silently reducing\n * coverage.\n *\n * Projects are generated with `preferInstallDependencies: false` by default and\n * the returned callback installs once. Nothing composed here reads the project\n * graph (only `ts#sync` does, which is not part of the matrix), so no\n * intermediate install is needed.\n */\nexport const internalTestMatrixGenerator = async (\n tree: Tree,\n options: InternalTestMatrixGeneratorSchema = {},\n): Promise<GeneratorCallback> => {\n const preferInstallDependencies = options.preferInstallDependencies ?? false;\n const defaults = { preferInstallDependencies };\n const projectDefaults = { ...defaults, directory: 'packages' };\n // Fully-qualified project names, which differ per language: TypeScript\n // projects are scope-prefixed, Python ones are dotted snake_case. Derived from\n // the workspace rather than hardcoded, so the matrix works in any workspace.\n const ts = (name: string) => `${getNpmScopePrefix(tree)}${name}`;\n const py = (name: string) =>\n `${toSnakeCase(getNpmScope(tree))}.${toSnakeCase(name)}`;\n\n // The infrastructure project every other generator deploys into. Which\n // generator owns it depends on the workspace's IaC provider, so the caller\n // asks for the one matching the workspace it created.\n if (options.infra === 'terraform') {\n await terraformProjectGenerator(tree, {\n name: 'infra',\n type: 'application',\n ...projectDefaults,\n });\n } else {\n await tsInfraGenerator(tree, { name: 'infra', ...projectDefaults });\n // A second CDK app with stage config, which only ts#infra offers.\n await tsInfraGenerator(tree, {\n name: 'infra-with-stages',\n stageConfig: true,\n ...projectDefaults,\n });\n }\n\n // Websites (with and without TanStack Router), a docs site, and auth on each.\n await tsWebsiteGenerator(tree, {\n name: 'website',\n iac: 'inherit',\n ...projectDefaults,\n });\n await tsWebsiteGenerator(tree, {\n name: 'website-no-router',\n tanstackRouter: false,\n iac: 'inherit',\n ...projectDefaults,\n });\n await tsDocsGenerator(tree, { name: 'docs-site', ...defaults });\n await tsWebsiteAuthGenerator(tree, {\n project: ts('website'),\n cognitoDomain: 'test',\n allowSignup: true,\n iac: 'inherit',\n ...defaults,\n });\n await tsWebsiteAuthGenerator(tree, {\n project: ts('website-no-router'),\n cognitoDomain: 'test-no-router',\n allowSignup: true,\n iac: 'inherit',\n ...defaults,\n });\n\n // tRPC APIs — REST + HTTP, with Cognito and custom auth.\n const tsApis: TsApiGeneratorSchema[] = [\n { name: 'my-api', infra: 'rest-lambda', auth: 'iam', iac: 'inherit' },\n { name: 'my-api-http', infra: 'http-lambda', auth: 'iam', iac: 'inherit' },\n // The APIs above take the default `isolated` integration pattern; these\n // cover `shared`.\n {\n name: 'my-api-shared',\n infra: 'rest-lambda',\n auth: 'iam',\n integrationPattern: 'shared',\n iac: 'inherit',\n },\n {\n name: 'my-api-shared-http',\n infra: 'http-lambda',\n auth: 'iam',\n integrationPattern: 'shared',\n iac: 'inherit',\n },\n {\n name: 'my-api-custom',\n infra: 'rest-lambda',\n auth: 'custom',\n iac: 'inherit',\n },\n {\n name: 'my-api-custom-http',\n infra: 'http-lambda',\n auth: 'custom',\n iac: 'inherit',\n },\n {\n name: 'my-smithy-api',\n framework: 'smithy',\n infra: 'rest-lambda',\n auth: 'iam',\n iac: 'inherit',\n },\n ];\n for (const api of tsApis) {\n await tsApiGenerator(tree, { ...api, ...projectDefaults });\n }\n\n // A Smithy shape library; `my-smithy-api` covers consuming one.\n await smithyProjectGenerator(tree, {\n name: 'my-shapes',\n type: 'shapes',\n ...projectDefaults,\n });\n\n // Python FastAPI — REST + HTTP, with Cognito and custom auth.\n const pyApis: PyApiGeneratorSchema[] = [\n { name: 'py-api', infra: 'rest-lambda', auth: 'iam', iac: 'inherit' },\n { name: 'py-api-http', infra: 'http-lambda', auth: 'iam', iac: 'inherit' },\n {\n name: 'py-api-custom',\n infra: 'rest-lambda',\n auth: 'custom',\n iac: 'inherit',\n },\n {\n name: 'py-api-custom-http',\n infra: 'http-lambda',\n auth: 'custom',\n iac: 'inherit',\n },\n ];\n for (const api of pyApis) {\n await pyApiGenerator(tree, { ...api, ...projectDefaults });\n }\n\n // Library projects hosting the components below, each with a lambda function.\n await pyProjectGenerator(tree, {\n name: 'py-project',\n type: 'application',\n ...projectDefaults,\n });\n await tsProjectGenerator(tree, { name: 'ts-project', ...projectDefaults });\n await pyLambdaFunctionGenerator(tree, {\n project: py('py-project'),\n name: 'my-function',\n event: 'Any',\n iac: 'inherit',\n ...defaults,\n });\n await tsLambdaFunctionGenerator(tree, {\n project: 'ts-project',\n name: 'my-function',\n event: 'Any',\n iac: 'inherit',\n ...defaults,\n });\n\n // MCP servers — uninfra'd and hosted on AgentCore.\n await pyMcpServerGenerator(tree, {\n project: 'py_project',\n name: 'my-mcp-server',\n infra: 'agentcore',\n iac: 'inherit',\n ...defaults,\n });\n await tsMcpServerGenerator(tree, {\n project: 'ts-project',\n name: 'my-mcp-server',\n infra: 'none',\n iac: 'inherit',\n ...defaults,\n });\n await tsMcpServerGenerator(tree, {\n project: 'ts-project',\n name: 'hosted-mcp-server',\n infra: 'agentcore',\n iac: 'inherit',\n ...defaults,\n });\n // Container-packaged variants, so both packagings are covered and a workspace\n // mixing them vends one copy of the shared runtime module.\n await tsMcpServerGenerator(tree, {\n project: 'ts-project',\n name: 'ecr-mcp-server',\n infra: 'agentcore-ecr',\n iac: 'inherit',\n ...defaults,\n });\n await pyMcpServerGenerator(tree, {\n project: 'py_project',\n name: 'ecr-mcp-server',\n infra: 'agentcore-ecr',\n iac: 'inherit',\n ...defaults,\n });\n\n // OAuth DCR proxy for Cognito-authenticated MCP servers.\n await tsDcrProxyGenerator(tree, {\n name: 'my-dcr-proxy',\n iac: 'inherit',\n ...projectDefaults,\n });\n\n // TypeScript agents across every protocol and auth permutation. The unnamed\n // one takes the generator's default name, which the connections below use.\n const tsAgents: TsAgentGeneratorSchema[] = [\n {\n project: 'ts-project',\n name: 'my-ts-agent',\n infra: 'none',\n iac: 'inherit',\n },\n { project: 'ts-project', infra: 'agentcore', iac: 'inherit' },\n {\n project: 'ts-project',\n name: 'my-ts-ecr-agent',\n infra: 'agentcore-ecr',\n iac: 'inherit',\n },\n {\n project: 'ts-project',\n name: 'my-ts-a2a-agent',\n protocol: 'a2a',\n infra: 'agentcore',\n iac: 'inherit',\n },\n {\n project: 'ts-project',\n name: 'my-ts-a2a-agent-cognito',\n protocol: 'a2a',\n auth: 'cognito',\n infra: 'agentcore',\n iac: 'inherit',\n },\n {\n project: 'ts-project',\n name: 'my-ts-agui-agent',\n protocol: 'ag-ui',\n infra: 'agentcore',\n iac: 'inherit',\n },\n ];\n for (const agent of tsAgents) {\n await tsAgentGenerator(tree, { ...agent, ...defaults });\n }\n\n // Python agents: Strands across every protocol, plus LangChain in its own\n // project — langchain's dependency closure would push the zip-bundled Lambda\n // in py-project past its unzipped size limit.\n const pyAgents: PyAgentGeneratorSchema[] = [\n {\n project: 'py_project',\n name: 'my-agent',\n infra: 'agentcore',\n iac: 'inherit',\n },\n {\n project: 'py_project',\n name: 'my-py-ecr-agent',\n infra: 'agentcore-ecr',\n iac: 'inherit',\n },\n {\n project: 'py_project',\n name: 'my-py-a2a-agent',\n protocol: 'a2a',\n infra: 'agentcore',\n iac: 'inherit',\n },\n {\n project: 'py_project',\n name: 'my-py-a2a-agent-cognito',\n protocol: 'a2a',\n auth: 'cognito',\n infra: 'agentcore',\n iac: 'inherit',\n },\n {\n project: 'py_project',\n name: 'my-py-agui-agent',\n protocol: 'ag-ui',\n infra: 'agentcore',\n iac: 'inherit',\n },\n ];\n for (const agent of pyAgents) {\n await pyAgentGenerator(tree, { ...agent, ...defaults });\n }\n await pyProjectGenerator(tree, {\n name: 'py-langchain-project',\n type: 'application',\n ...projectDefaults,\n });\n const langchainAgents: PyAgentGeneratorSchema[] = [\n {\n project: 'py_langchain_project',\n name: 'my-py-langchain-agent',\n protocol: 'ag-ui',\n iac: 'inherit',\n },\n {\n project: 'py_langchain_project',\n name: 'my-py-langchain-http-agent',\n protocol: 'http',\n iac: 'inherit',\n },\n {\n project: 'py_langchain_project',\n name: 'my-py-langchain-a2a-agent',\n protocol: 'a2a',\n iac: 'inherit',\n },\n ];\n for (const agent of langchainAgents) {\n await pyAgentGenerator(tree, {\n ...agent,\n framework: 'langchain',\n infra: 'agentcore',\n ...defaults,\n });\n }\n\n // AgentCore gateways, including a parent fronting the first (chained), and\n // an http-protocol gateway fronting agent runtime targets.\n await agentcoreGatewayGenerator(tree, {\n name: 'my-gateway',\n iac: 'inherit',\n ...projectDefaults,\n });\n await agentcoreGatewayGenerator(tree, {\n name: 'parent-gateway',\n iac: 'inherit',\n ...projectDefaults,\n });\n await agentcoreGatewayGenerator(tree, {\n name: 'agent-gateway',\n protocol: 'http',\n iac: 'inherit',\n ...projectDefaults,\n });\n\n // AgentCore Harness — a standalone invocation project.\n await agentcoreHarnessGenerator(tree, {\n name: 'my-harness',\n infra: 'agentcore',\n iac: 'inherit',\n ...projectDefaults,\n });\n\n // Databases — DynamoDB, plus Aurora across both engines and ORMs.\n await tsDynamoDBGenerator(tree, {\n name: 'my-table',\n framework: 'electrodb',\n infra: 'dynamodb',\n iac: 'inherit',\n ...projectDefaults,\n });\n await pyDynamoDBGenerator(tree, {\n name: 'my-py-table',\n framework: 'pynamodb',\n infra: 'dynamodb',\n iac: 'inherit',\n ...projectDefaults,\n });\n const tsRdbs: TsRdbGeneratorSchema[] = [\n {\n name: 'postgres-db',\n infra: 'aurora',\n engine: 'postgres',\n framework: 'prisma',\n iac: 'inherit',\n },\n {\n name: 'my-sql-db',\n infra: 'aurora',\n engine: 'mysql',\n framework: 'prisma',\n iac: 'inherit',\n },\n ];\n for (const rdb of tsRdbs) {\n await tsRdbGenerator(tree, { ...rdb, ...projectDefaults });\n }\n const pyRdbs: PyRdbGeneratorSchema[] = [\n {\n name: 'py-postgres-db',\n infra: 'aurora',\n engine: 'postgres',\n framework: 'sqlmodel',\n iac: 'inherit',\n },\n {\n name: 'py-mysql-db',\n infra: 'aurora',\n engine: 'mysql',\n framework: 'sqlmodel',\n iac: 'inherit',\n },\n ];\n for (const rdb of pyRdbs) {\n await pyRdbGenerator(tree, { ...rdb, ...projectDefaults });\n }\n\n // Every connection edge the matrix covers.\n const connections: ConnectionGeneratorSchema[] = [\n // Website -> API\n { sourceProject: ts('website'), targetProject: ts('my-api') },\n { sourceProject: ts('website-no-router'), targetProject: ts('my-api') },\n { sourceProject: 'website', targetProject: 'py_api' },\n { sourceProject: 'website', targetProject: 'my-smithy-api' },\n // Agent -> MCP server\n {\n sourceProject: 'ts-project',\n sourceComponent: 'agent',\n targetProject: 'ts-project',\n targetComponent: 'hosted-mcp-server',\n },\n {\n sourceProject: 'ts-project',\n sourceComponent: 'my-ts-agui-agent',\n targetProject: 'ts-project',\n targetComponent: 'hosted-mcp-server',\n },\n {\n sourceProject: 'ts-project',\n sourceComponent: 'agent',\n targetProject: 'py_project',\n targetComponent: 'my-mcp-server',\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: 'py_project',\n targetComponent: 'my-mcp-server',\n },\n {\n sourceProject: 'py_langchain_project',\n sourceComponent: 'my-py-langchain-agent',\n targetProject: 'py_project',\n targetComponent: 'my-mcp-server',\n },\n // HTTP agent <-> A2A agent\n {\n sourceProject: 'ts-project',\n sourceComponent: 'agent',\n targetProject: 'ts-project',\n targetComponent: 'my-ts-a2a-agent',\n },\n {\n sourceProject: 'ts-project',\n sourceComponent: 'agent',\n targetProject: 'py_project',\n targetComponent: 'my-py-a2a-agent',\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: 'ts-project',\n targetComponent: 'my-ts-a2a-agent',\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: 'py_project',\n targetComponent: 'my-py-a2a-agent',\n },\n {\n sourceProject: 'py_langchain_project',\n sourceComponent: 'my-py-langchain-agent',\n targetProject: 'py_project',\n targetComponent: 'my-py-a2a-agent',\n },\n // Agent -> gateway, gateway -> MCP server, gateway -> gateway\n {\n sourceProject: 'ts-project',\n sourceComponent: 'agent',\n targetProject: ts('my-gateway'),\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: ts('my-gateway'),\n },\n {\n sourceProject: 'py_langchain_project',\n sourceComponent: 'my-py-langchain-agent',\n targetProject: ts('my-gateway'),\n },\n {\n sourceProject: ts('my-gateway'),\n targetProject: 'ts-project',\n targetComponent: 'hosted-mcp-server',\n },\n {\n sourceProject: ts('my-gateway'),\n targetProject: 'py_project',\n targetComponent: 'my-mcp-server',\n },\n { sourceProject: ts('parent-gateway'), targetProject: ts('my-gateway') },\n // Gateway -> agent (http gateway fronting agent runtime targets: every\n // supported protocol permutation), then website -> gateway.\n {\n sourceProject: ts('agent-gateway'),\n targetProject: 'ts-project',\n targetComponent: 'my-ts-agui-agent',\n },\n {\n sourceProject: ts('agent-gateway'),\n targetProject: 'ts-project',\n targetComponent: 'my-ts-a2a-agent',\n },\n {\n sourceProject: ts('agent-gateway'),\n targetProject: 'py_project',\n targetComponent: 'my-py-agui-agent',\n },\n {\n sourceProject: ts('agent-gateway'),\n targetProject: 'py_project',\n targetComponent: 'my-agent',\n },\n {\n sourceProject: ts('agent-gateway'),\n targetProject: 'py_project',\n targetComponent: 'my-py-a2a-agent',\n },\n {\n sourceProject: ts('website-no-router'),\n targetProject: ts('agent-gateway'),\n },\n // Website -> agent\n {\n sourceProject: ts('website'),\n targetProject: 'ts-project',\n targetComponent: 'agent',\n },\n {\n sourceProject: ts('website'),\n targetProject: 'ts-project',\n targetComponent: 'my-ts-agui-agent',\n },\n {\n sourceProject: ts('website'),\n targetProject: 'py_project',\n targetComponent: 'my-agent',\n },\n {\n sourceProject: ts('website'),\n targetProject: 'py_project',\n targetComponent: 'my-py-agui-agent',\n },\n {\n sourceProject: ts('website'),\n targetProject: 'py_langchain_project',\n targetComponent: 'my-py-langchain-agent',\n },\n {\n sourceProject: ts('website'),\n targetProject: 'py_langchain_project',\n targetComponent: 'my-py-langchain-http-agent',\n },\n // DynamoDB\n { sourceProject: 'my-api', targetProject: ts('my-table') },\n { sourceProject: 'my-smithy-api', targetProject: ts('my-table') },\n {\n sourceProject: 'ts-project',\n sourceComponent: 'my-ts-agent',\n targetProject: ts('my-table'),\n },\n {\n sourceProject: 'ts-project',\n sourceComponent: 'my-mcp-server',\n targetProject: ts('my-table'),\n },\n { sourceProject: 'py_api', targetProject: 'my_py_table' },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: 'my_py_table',\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-mcp-server',\n targetProject: 'my_py_table',\n },\n {\n sourceProject: 'py_langchain_project',\n sourceComponent: 'my-py-langchain-http-agent',\n targetProject: 'my_py_table',\n },\n // Relational databases\n { sourceProject: 'py_api', targetProject: 'py_postgres_db' },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-agent',\n targetProject: 'py_postgres_db',\n },\n {\n sourceProject: 'py_project',\n sourceComponent: 'my-mcp-server',\n targetProject: 'py_postgres_db',\n },\n ];\n for (const connection of connections) {\n await connectionGenerator(tree, { ...connection, ...defaults });\n }\n\n // Licensing, then an Nx plugin with a custom generator.\n await licenseGenerator(tree, {\n license: 'Apache-2.0',\n copyrightHolder: 'Amazon.com, Inc. or its affiliates',\n ...defaults,\n });\n await tsNxPluginGenerator(tree, {\n ...projectDefaults,\n name: 'plugin',\n directory: 'tools',\n });\n await tsNxGeneratorGenerator(tree, {\n project: ts('plugin'),\n name: 'my#generator',\n ...defaults,\n });\n\n // A migration of each kind, so the scaffolded codemods compile and the\n // plugin's migrations.json (created by the first run) registers all three.\n const migrations: Omit<TsNxMigrationGeneratorSchema, 'project'>[] = [\n {\n name: 'rename-foo-target',\n description: 'Rename the foo target to bar',\n },\n {\n name: 'migrate-custom-handlers',\n description: 'Update custom handlers for the new API',\n kind: 'agentic',\n },\n {\n name: 'upgrade-framework',\n description: 'Upgrade the framework and reconcile call sites',\n kind: 'hybrid',\n },\n ];\n for (const migration of migrations) {\n await tsNxMigrationGenerator(tree, {\n ...migration,\n project: ts('plugin'),\n ...defaults,\n });\n }\n\n return () =>\n installDependencies(tree, preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\n\nexport default internalTestMatrixGenerator;\n"],"names":["agentcoreGatewayGenerator","agentcoreHarnessGenerator","connectionGenerator","licenseGenerator","pyAgentGenerator","pyApiGenerator","pyDynamoDBGenerator","pyLambdaFunctionGenerator","pyMcpServerGenerator","pyProjectGenerator","pyRdbGenerator","smithyProjectGenerator","terraformProjectGenerator","tsAgentGenerator","tsApiGenerator","tsDcrProxyGenerator","tsDocsGenerator","tsDynamoDBGenerator","tsInfraGenerator","tsLambdaFunctionGenerator","tsMcpServerGenerator","tsNxGeneratorGenerator","tsNxMigrationGenerator","tsNxPluginGenerator","tsProjectGenerator","tsRdbGenerator","tsWebsiteAuthGenerator","tsWebsiteGenerator","installDependencies","toSnakeCase","getNpmScope","getNpmScopePrefix","internalTestMatrixGenerator","tree","options","preferInstallDependencies","defaults","projectDefaults","directory","ts","name","py","infra","type","stageConfig","iac","tanstackRouter","project","cognitoDomain","allowSignup","tsApis","auth","integrationPattern","framework","api","pyApis","event","tsAgents","protocol","agent","pyAgents","langchainAgents","tsRdbs","engine","rdb","pyRdbs","connections","sourceProject","targetProject","sourceComponent","targetComponent","connection","license","copyrightHolder","migrations","description","kind","migration","languages"],"mappings":"AAAA;;;CAGC,GAED,SAASA,yBAAyB,QAAQ,iCAAiC;AAC3E,SAASC,yBAAyB,QAAQ,iCAAiC;AAC3E,SAEEC,mBAAmB,QACd,0BAA0B;AACjC,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAIEC,gBAAgB,EAChBC,cAAc,EACdC,mBAAmB,EACnBC,yBAAyB,EACzBC,oBAAoB,EACpBC,kBAAkB,EAClBC,cAAc,QACT,kBAAkB;AACzB,SAASC,sBAAsB,QAAQ,sBAAsB;AAC7D,SAASC,yBAAyB,QAAQ,yBAAyB;AACnE,SAKEC,gBAAgB,EAChBC,cAAc,EACdC,mBAAmB,EACnBC,eAAe,EACfC,mBAAmB,EACnBC,gBAAgB,EAChBC,yBAAyB,EACzBC,oBAAoB,EACpBC,sBAAsB,EACtBC,sBAAsB,EACtBC,mBAAmB,EACnBC,kBAAkB,EAClBC,cAAc,EACdC,s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kit';
|
|
6
6
|
import type { SyncGeneratorResult } from 'nx/src/utils/sync-generators';
|
|
7
|
+
import type { CommentSyntax } from '../config-types.js';
|
|
7
8
|
export declare const SYNC_GENERATOR_NAME: string;
|
|
8
9
|
export declare function licenseSyncGenerator(tree: Tree): Promise<SyncGeneratorResult>;
|
|
10
|
+
/**
|
|
11
|
+
* Parse the hashbang, header and body from a file.
|
|
12
|
+
* The header is the first block comment, or consecutive series of line comments found in the file, after the hashbang
|
|
13
|
+
*/
|
|
14
|
+
export declare const parseFile: (content: string, syntax: CommentSyntax) => {
|
|
15
|
+
hashbang: string;
|
|
16
|
+
header: string;
|
|
17
|
+
body: string;
|
|
18
|
+
};
|
|
9
19
|
export default licenseSyncGenerator;
|
|
@@ -178,7 +178,7 @@ export async function licenseSyncGenerator(tree) {
|
|
|
178
178
|
/**
|
|
179
179
|
* Parse the hashbang, header and body from a file.
|
|
180
180
|
* The header is the first block comment, or consecutive series of line comments found in the file, after the hashbang
|
|
181
|
-
*/ const parseFile = (content, syntax)=>{
|
|
181
|
+
*/ export const parseFile = (content, syntax)=>{
|
|
182
182
|
const lines = content.split('\n');
|
|
183
183
|
let i = 0;
|
|
184
184
|
// Hashbangs must always go first, so extract this if it exists
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/license/sync/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n getProjects,\n globAsync,\n joinPathFragments,\n type Tree,\n} from '@nx/devkit';\nimport fastGlob from 'fast-glob';\nimport { minimatch } from 'minimatch';\nimport type { SyncGeneratorResult } from 'nx/src/utils/sync-generators';\nimport { basename } from 'path';\nimport PackageJson from '../../../package.json' with { type: 'json' };\nimport { AWS_NX_PLUGIN_CONFIG_FILE_NAME } from '../../utils/config/utils.js';\nimport { getGitIncludedFiles, isWithinGitRepo } from '../../utils/git.js';\nimport { getGeneratorInfo } from '../../utils/nx.js';\nimport { LANGUAGE_COMMENT_SYNTAX, readLicenseConfig } from '../config.js';\nimport type {\n CommentSyntax,\n LicenseHeaderConfig,\n LicenseHeaderFormat,\n} from '../config-types.js';\nimport {\n PROJECT_FILES_TO_SYNC,\n type ProjectFileToSync,\n syncProjectFile,\n} from './project-file-sync.js';\n\nexport const SYNC_GENERATOR_NAME = `${PackageJson.name}:${getGeneratorInfo(import.meta.filename).id}`;\n\ninterface ProjectFile {\n name: ProjectFileToSync;\n path: string;\n}\n\nexport async function licenseSyncGenerator(\n tree: Tree,\n): Promise<SyncGeneratorResult> {\n const source = (await readLicenseConfig(tree))?.source;\n\n if (!source) {\n // Nothing to do when source licensing (headers + LICENSE files) isn't configured\n return {};\n }\n\n const licenseHeadersUpdated: string[] = [];\n\n if (source.header) {\n // Get all candidate project files for header\n const candidateProjectFiles = await getCandidateProjectFilesForHeader(\n tree,\n source.header,\n );\n\n const headerContentLines = loadHeaderContentLines(tree, source.header);\n\n // Add headers to project files which match the include pattern\n for (const [includePattern, format] of Object.entries(\n source.header.format,\n )) {\n const files = minimatch.match(candidateProjectFiles, includePattern);\n\n files.forEach((file) => {\n const didAdd = addHeader(\n tree,\n file,\n headerContentLines,\n source.header,\n format,\n );\n if (didAdd) {\n licenseHeadersUpdated.push(file);\n }\n });\n }\n }\n\n const projectFilesUpdated: ProjectFile[] = [];\n\n // Helper to check whether a file should be included in the sync based on file exclude configuration\n const isFileIncludedInSync = (path: string): boolean =>\n !(source.files?.exclude ?? []).some((excludePattern) =>\n minimatch(path, excludePattern),\n );\n\n // Sync files in the root, and all projects\n const projectRoots = [\n '.',\n ...[...getProjects(tree).values()].map((p) => p.root),\n ];\n\n // Sync subproject license files and project files\n for (const projectRoot of projectRoots) {\n // Check that this project should have files synced - allows users to specify a project path\n // to exclude from all file syncs\n if (isFileIncludedInSync(projectRoot)) {\n PROJECT_FILES_TO_SYNC.forEach((projectFile) => {\n const projectFilePath = joinPathFragments(projectRoot, projectFile);\n // Check that the specific project file should be synced - allows users to be more granular to\n // decide to eg omit LICENSE file sync but keep package.json sync\n if (isFileIncludedInSync(projectFilePath)) {\n const prevContent = tree.read(projectFilePath, 'utf-8');\n\n syncProjectFile(tree, projectRoot, projectFile, source);\n\n const newContent = tree.read(projectFilePath, 'utf-8');\n\n if (prevContent !== newContent) {\n projectFilesUpdated.push({\n path: projectFilePath,\n name: projectFile,\n });\n }\n }\n });\n }\n }\n\n return {\n outOfSyncMessage: buildOutOfSyncMessage({\n licenseHeadersUpdated,\n projectFilesUpdated,\n }),\n };\n}\n\n/**\n * Build the message to display when the sync generator would make changes to the tree\n */\nconst buildOutOfSyncMessage = (updates: {\n projectFilesUpdated: ProjectFile[];\n licenseHeadersUpdated: string[];\n}): string => {\n let outOfSyncMessage = '';\n\n const pathsByName: { [key: string]: string[] } =\n updates.projectFilesUpdated.reduce(\n (prev, { name, path }) => ({\n ...prev,\n [name]: [...(prev[name] ?? []), path],\n }),\n {},\n );\n Object.entries(pathsByName).forEach(([name, files]) => {\n outOfSyncMessage += `Project ${name} files are out of sync:\\n${files.map((p) => `- ${p}`).join('\\n')}\\n\\n`;\n });\n\n if (updates.licenseHeadersUpdated.length > 0) {\n outOfSyncMessage += `License headers are out of sync in the following source files:\\n${updates.licenseHeadersUpdated.map((p) => `- ${p}`).join('\\n')}\\n\\n`;\n }\n\n return outOfSyncMessage.trim();\n};\n\n/**\n * Load the license header content lines\n */\nconst loadHeaderContentLines = (\n tree: Tree,\n config: LicenseHeaderConfig,\n): string[] => {\n // Load the license header content\n let headerContentLines = [];\n if ('lines' in config.content) {\n headerContentLines = config.content.lines;\n } else {\n if (!tree.exists(config.content.filePath)) {\n throw new Error(\n `Could not find license header content file ${config.content.filePath}`,\n );\n }\n headerContentLines = tree\n .read(config.content.filePath, 'utf-8')\n .split('\\n');\n }\n return headerContentLines;\n};\n\n/**\n * Returns all files in the given tree - both in-memory only and in the filesystem under the tree root\n */\nconst getAllFilesInTree = async (tree: Tree): Promise<string[]> => {\n return [\n ...new Set([\n // Get all files in memory in the tree\n ...(await globAsync(tree, ['*', '**/*'])),\n // Find all files on the filesystem that may not be in memory in the tree\n ...(await fastGlob(['*', '**/*'], { cwd: tree.root, dot: true })),\n ]),\n ].filter((f) => tree.exists(f));\n};\n\n/**\n * Returns the list of project files\n */\nconst getCandidateProjectFilesForHeader = async (\n tree: Tree,\n config: LicenseHeaderConfig,\n): Promise<string[]> => {\n // Prefer, if possible, to treat all non gitignored files as our candidate set such that we honour users .gitignore files\n // If we're not in a git repo, fall back to everything and rely on the user configuring exclusions below\n const projectFiles = isWithinGitRepo(tree)\n ? getGitIncludedFiles(tree)\n : await getAllFilesInTree(tree);\n\n // Remove any files that were excluded in the config\n const ignoredProjectFiles = new Set(\n (config.exclude ?? []).flatMap((pattern) =>\n minimatch.match(projectFiles, pattern),\n ),\n );\n return projectFiles.filter((file) => !ignoredProjectFiles.has(file));\n};\n\n/**\n * Renders a header with the given format\n */\nconst renderHeader = (\n contentLines: string[],\n format: LicenseHeaderFormat,\n): string => {\n return `${format.blockStart ? `${format.blockStart}\\n` : ''}${contentLines.map((line) => `${format.lineStart ?? ''}${line}${format.lineEnd ?? ''}`).join('\\n')}${format.blockEnd ? `\\n${format.blockEnd}` : ''}`;\n};\n\n/**\n * Validates header format to ensure it produces a valid comment\n */\nconst validateFormat = (\n fileExtension: string,\n syntax: CommentSyntax,\n format: LicenseHeaderFormat,\n contentLines: string[],\n): void => {\n const blockStartOpensBlockComment =\n format.blockStart &&\n syntax.block &&\n format.blockStart.startsWith(syntax.block.start);\n const blockEndClosesBlockComment =\n format.blockEnd &&\n syntax.block &&\n format.blockEnd.endsWith(syntax.block.end);\n\n // Block start must start with the block start or line comment\n const validBlockStart =\n !format.blockStart ||\n blockStartOpensBlockComment ||\n (syntax.line && format.blockStart.startsWith(syntax.line));\n // Block end must end with the block end, or begin with the line comment\n const validBlockEnd =\n !format.blockEnd ||\n blockEndClosesBlockComment ||\n (syntax.line && format.blockEnd.startsWith(syntax.line));\n\n // Lines must start with the line comment syntax, unless within a block comment\n const validLineStart =\n !format.lineStart ||\n (syntax.line && format.lineStart.startsWith(syntax.line)) ||\n (blockStartOpensBlockComment && blockEndClosesBlockComment);\n\n if (!validLineStart || !validBlockStart || !validBlockEnd) {\n throw new Error(\n `Provided format for ${fileExtension} file would generate invalid comment syntax. Configured syntax for ${fileExtension} is ${JSON.stringify(syntax, null, 2)}.`,\n );\n }\n\n if (blockStartOpensBlockComment && !blockEndClosesBlockComment) {\n throw new Error(\n `Provided format for ${fileExtension} file opens a block comment with \"${syntax.block.start}\" in blockStart but does not close it with \"${syntax.block.end}\" in blockEnd`,\n );\n }\n\n if (\n blockStartOpensBlockComment &&\n contentLines.some((line) => line.includes(syntax.block.end))\n ) {\n throw new Error(\n `Provided license content would close a block comment early and cause a syntax error! Please remove \"${syntax.block.end}\" from your license text.`,\n );\n }\n\n if (blockStartOpensBlockComment && blockEndClosesBlockComment) {\n if (\n format.blockEnd.lastIndexOf(syntax.block.end) !==\n format.blockEnd.indexOf(syntax.block.end)\n ) {\n throw new Error(\n `Provided format for ${fileExtension} file may cause syntax errors due to closing a block comment multiple times with \"${syntax.block.end}\" in blockEnd`,\n );\n }\n if (format.blockStart.includes(syntax.block.end)) {\n throw new Error(\n `Provided format for ${fileExtension} file may cause syntax errors since it closes the block comment with \"${syntax.block.end}\" in blockStart`,\n );\n }\n }\n};\n\n/**\n * Parse the hashbang, header and body from a file.\n * The header is the first block comment, or consecutive series of line comments found in the file, after the hashbang\n */\nconst parseFile = (\n content: string,\n syntax: CommentSyntax,\n): { hashbang: string; header: string; body: string } => {\n const lines = content.split('\\n');\n let i = 0;\n\n // Hashbangs must always go first, so extract this if it exists\n const hashbangLines = [];\n for (; i < lines.length; i++) {\n if (hashbangLines.length === 0) {\n if (lines[i].startsWith('#!')) {\n hashbangLines.push(lines[i]);\n } else {\n break;\n }\n } else {\n if (lines[i].trim().length === 0) {\n // Preserve any empty lines following the hashbang\n hashbangLines.push(lines[i]);\n } else {\n break;\n }\n }\n }\n\n // After the hashbang, consume the next comment which follows.\n // This could either be all lines of a block comment, or all consecutive line comments until a non line-comment is seen\n const headerLines = [];\n let withinBlockComment = false;\n let withinLineCommentSeries = false;\n for (; i < lines.length; i++) {\n const trimmedLine = lines[i].trim();\n if (\n syntax.block &&\n trimmedLine.endsWith(syntax.block.end) &&\n !withinLineCommentSeries &&\n (withinBlockComment || trimmedLine.startsWith(syntax.block.start))\n ) {\n // Comment ends with the block end, so we've completed the header and therefore break out of the loop\n headerLines.push(lines[i]);\n i++; // Increment here to ensure we point to the next line for the body\n break;\n } else if (\n syntax.block &&\n trimmedLine.startsWith(syntax.block.start) &&\n !withinLineCommentSeries\n ) {\n // Line begins a comment block (without also ending it on the same line), so start consuming the block\n withinBlockComment = true;\n headerLines.push(lines[i]);\n } else if (withinBlockComment) {\n // We haven't yet closed the block comment, so consume this line\n headerLines.push(lines[i]);\n } else if (syntax.line && trimmedLine.startsWith(syntax.line)) {\n // Line starts with the line comment syntax, so consume it\n withinLineCommentSeries = true;\n headerLines.push(lines[i]);\n } else {\n break;\n }\n }\n\n // Body of the file is the rest\n const bodyLines = lines.slice(i);\n\n return {\n hashbang: hashbangLines.join('\\n'),\n header: headerLines.join('\\n'),\n body: bodyLines.join('\\n'),\n };\n};\n\n/**\n * Add a header to the given file according to the header content and license config\n * Returns true if the header was added/updated, and false otherwise.\n */\nconst addHeader = (\n tree: Tree,\n file: string,\n contentLines: string[],\n config: LicenseHeaderConfig,\n format: LicenseHeaderFormat,\n): boolean => {\n const fileName = basename(file);\n const fileNameParts = fileName.split('.');\n const fileExtension = fileNameParts[fileNameParts.length - 1];\n\n const syntax =\n (config.commentSyntax ?? {})[fileExtension] ??\n LANGUAGE_COMMENT_SYNTAX[fileExtension];\n if (!syntax) {\n throw new Error(`Unknown file extension ${fileExtension}. Please configure commentSyntax in ${AWS_NX_PLUGIN_CONFIG_FILE_NAME}, eg:\n\nexport default {\n license: {\n header: {\n ...\n commentSyntax: {\n ${fileExtension}: {\n line: \"//\",\n block: { start: \"/*\", end: \"*/\" }\n }\n }\n }\n }\n} satisfies AwsNxPluginConfig;\n`);\n }\n\n // Check that we would render a valid comment\n validateFormat(fileExtension, syntax, format, contentLines);\n\n const existingContent = tree.read(file, 'utf-8');\n\n const { hashbang, body } = parseFile(existingContent, syntax);\n\n const newContent = [\n ...(hashbang ? [hashbang] : []),\n renderHeader(contentLines, format),\n body,\n ].join('\\n');\n\n // Sanity check that we wouldn't edit the hashbang or body, only the header\n const { hashbang: newHashbang, body: newBody } = parseFile(\n newContent,\n syntax,\n );\n if (hashbang !== newHashbang || body !== newBody) {\n throw new Error(\n `The license header content, or format for ${fileExtension} files would produce a header that cannot be safely replaced in ${file}. Please revise license content and format in ${AWS_NX_PLUGIN_CONFIG_FILE_NAME}`,\n );\n }\n\n if (newContent !== existingContent) {\n tree.write(file, newContent);\n return true;\n }\n\n return false;\n};\n\nexport default licenseSyncGenerator;\n"],"names":["getProjects","globAsync","joinPathFragments","fastGlob","minimatch","basename","PackageJson","type","AWS_NX_PLUGIN_CONFIG_FILE_NAME","getGitIncludedFiles","isWithinGitRepo","getGeneratorInfo","LANGUAGE_COMMENT_SYNTAX","readLicenseConfig","PROJECT_FILES_TO_SYNC","syncProjectFile","SYNC_GENERATOR_NAME","name","filename","id","licenseSyncGenerator","tree","source","licenseHeadersUpdated","header","candidateProjectFiles","getCandidateProjectFilesForHeader","headerContentLines","loadHeaderContentLines","includePattern","format","Object","entries","files","match","forEach","file","didAdd","addHeader","push","projectFilesUpdated","isFileIncludedInSync","path","exclude","some","excludePattern","projectRoots","values","map","p","root","projectRoot","projectFile","projectFilePath","prevContent","read","newContent","outOfSyncMessage","buildOutOfSyncMessage","updates","pathsByName","reduce","prev","join","length","trim","config","content","lines","exists","filePath","Error","split","getAllFilesInTree","Set","cwd","dot","filter","f","projectFiles","ignoredProjectFiles","flatMap","pattern","has","renderHeader","contentLines","blockStart","line","lineStart","lineEnd","blockEnd","validateFormat","fileExtension","syntax","blockStartOpensBlockComment","block","startsWith","start","blockEndClosesBlockComment","endsWith","end","validBlockStart","validBlockEnd","validLineStart","JSON","stringify","includes","lastIndexOf","indexOf","parseFile","i","hashbangLines","headerLines","withinBlockComment","withinLineCommentSeries","trimmedLine","bodyLines","slice","hashbang","body","fileName","fileNameParts","commentSyntax","existingContent","newHashbang","newBody","write"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EACXC,SAAS,EACTC,iBAAiB,QAEZ,aAAa;AACpB,OAAOC,cAAc,YAAY;AACjC,SAASC,SAAS,QAAQ,YAAY;AAEtC,SAASC,QAAQ,QAAQ,OAAO;AAChC,OAAOC,iBAAiB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACtE,SAASC,8BAA8B,QAAQ,8BAA8B;AAC7E,SAASC,mBAAmB,EAAEC,eAAe,QAAQ,qBAAqB;AAC1E,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,uBAAuB,EAAEC,iBAAiB,QAAQ,eAAe;AAM1E,SACEC,qBAAqB,EAErBC,eAAe,QACV,yBAAyB;AAEhC,OAAO,MAAMC,sBAAsB,GAAGV,YAAYW,IAAI,CAAC,CAAC,EAAEN,iBAAiB,YAAYO,QAAQ,EAAEC,EAAE,EAAE,CAAC;AAOtG,OAAO,eAAeC,qBACpBC,IAAU;IAEV,MAAMC,SAAU,CAAA,MAAMT,kBAAkBQ,KAAI,GAAIC;IAEhD,IAAI,CAACA,QAAQ;QACX,iFAAiF;QACjF,OAAO,CAAC;IACV;IAEA,MAAMC,wBAAkC,EAAE;IAE1C,IAAID,OAAOE,MAAM,EAAE;QACjB,6CAA6C;QAC7C,MAAMC,wBAAwB,MAAMC,kCAClCL,MACAC,OAAOE,MAAM;QAGf,MAAMG,qBAAqBC,uBAAuBP,MAAMC,OAAOE,MAAM;QAErE,+DAA+D;QAC/D,KAAK,MAAM,CAACK,gBAAgBC,OAAO,IAAIC,OAAOC,OAAO,CACnDV,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,cAAc;IACxC,IAAI,CAACC,QAAQ;QACX,MAAM,IAAItB,MAAM,CAAC,uBAAuB,EAAEqB,cAAc,oCAAoC,EAAEpF,+BAA+B;;;;;;;QAOzH,EAAEoF,cAAc;;;;;;;;AAQxB,CAAC;IACC;IAEA,6CAA6C;IAC7CD,eAAeC,eAAeC,QAAQ/D,QAAQuD;IAE9C,MAAMsC,kBAAkBtG,KAAKkC,IAAI,CAACnB,MAAM;IAExC,MAAM,EAAEkF,QAAQ,EAAEC,IAAI,EAAE,GAAGV,UAAUc,iBAAiB9B;IAEtD,MAAMrC,aAAa;WACb8D,WAAW;YAACA;SAAS,GAAG,EAAE;QAC9BlC,aAAaC,cAAcvD;QAC3ByF;KACD,CAACxD,IAAI,CAAC;IAEP,2EAA2E;IAC3E,MAAM,EAAEuD,UAAUM,WAAW,EAAEL,MAAMM,OAAO,EAAE,GAAGhB,UAC/CrD,YACAqC;IAEF,IAAIyB,aAAaM,eAAeL,SAASM,SAAS;QAChD,MAAM,IAAItD,MACR,CAAC,0CAA0C,EAAEqB,cAAc,gEAAgE,EAAExD,KAAK,8CAA8C,EAAE5B,gCAAgC;IAEtN;IAEA,IAAIgD,eAAemE,iBAAiB;QAClCtG,KAAKyG,KAAK,CAAC1F,MAAMoB;QACjB,OAAO;IACT;IAEA,OAAO;AACT;AAEA,eAAepC,qBAAqB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/license/sync/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n getProjects,\n globAsync,\n joinPathFragments,\n type Tree,\n} from '@nx/devkit';\nimport fastGlob from 'fast-glob';\nimport { minimatch } from 'minimatch';\nimport type { SyncGeneratorResult } from 'nx/src/utils/sync-generators';\nimport { basename } from 'path';\nimport PackageJson from '../../../package.json' with { type: 'json' };\nimport { AWS_NX_PLUGIN_CONFIG_FILE_NAME } from '../../utils/config/utils.js';\nimport { getGitIncludedFiles, isWithinGitRepo } from '../../utils/git.js';\nimport { getGeneratorInfo } from '../../utils/nx.js';\nimport { LANGUAGE_COMMENT_SYNTAX, readLicenseConfig } from '../config.js';\nimport type {\n CommentSyntax,\n LicenseHeaderConfig,\n LicenseHeaderFormat,\n} from '../config-types.js';\nimport {\n PROJECT_FILES_TO_SYNC,\n type ProjectFileToSync,\n syncProjectFile,\n} from './project-file-sync.js';\n\nexport const SYNC_GENERATOR_NAME = `${PackageJson.name}:${getGeneratorInfo(import.meta.filename).id}`;\n\ninterface ProjectFile {\n name: ProjectFileToSync;\n path: string;\n}\n\nexport async function licenseSyncGenerator(\n tree: Tree,\n): Promise<SyncGeneratorResult> {\n const source = (await readLicenseConfig(tree))?.source;\n\n if (!source) {\n // Nothing to do when source licensing (headers + LICENSE files) isn't configured\n return {};\n }\n\n const licenseHeadersUpdated: string[] = [];\n\n if (source.header) {\n // Get all candidate project files for header\n const candidateProjectFiles = await getCandidateProjectFilesForHeader(\n tree,\n source.header,\n );\n\n const headerContentLines = loadHeaderContentLines(tree, source.header);\n\n // Add headers to project files which match the include pattern\n for (const [includePattern, format] of Object.entries(\n source.header.format,\n )) {\n const files = minimatch.match(candidateProjectFiles, includePattern);\n\n files.forEach((file) => {\n const didAdd = addHeader(\n tree,\n file,\n headerContentLines,\n source.header,\n format,\n );\n if (didAdd) {\n licenseHeadersUpdated.push(file);\n }\n });\n }\n }\n\n const projectFilesUpdated: ProjectFile[] = [];\n\n // Helper to check whether a file should be included in the sync based on file exclude configuration\n const isFileIncludedInSync = (path: string): boolean =>\n !(source.files?.exclude ?? []).some((excludePattern) =>\n minimatch(path, excludePattern),\n );\n\n // Sync files in the root, and all projects\n const projectRoots = [\n '.',\n ...[...getProjects(tree).values()].map((p) => p.root),\n ];\n\n // Sync subproject license files and project files\n for (const projectRoot of projectRoots) {\n // Check that this project should have files synced - allows users to specify a project path\n // to exclude from all file syncs\n if (isFileIncludedInSync(projectRoot)) {\n PROJECT_FILES_TO_SYNC.forEach((projectFile) => {\n const projectFilePath = joinPathFragments(projectRoot, projectFile);\n // Check that the specific project file should be synced - allows users to be more granular to\n // decide to eg omit LICENSE file sync but keep package.json sync\n if (isFileIncludedInSync(projectFilePath)) {\n const prevContent = tree.read(projectFilePath, 'utf-8');\n\n syncProjectFile(tree, projectRoot, projectFile, source);\n\n const newContent = tree.read(projectFilePath, 'utf-8');\n\n if (prevContent !== newContent) {\n projectFilesUpdated.push({\n path: projectFilePath,\n name: projectFile,\n });\n }\n }\n });\n }\n }\n\n return {\n outOfSyncMessage: buildOutOfSyncMessage({\n licenseHeadersUpdated,\n projectFilesUpdated,\n }),\n };\n}\n\n/**\n * Build the message to display when the sync generator would make changes to the tree\n */\nconst buildOutOfSyncMessage = (updates: {\n projectFilesUpdated: ProjectFile[];\n licenseHeadersUpdated: string[];\n}): string => {\n let outOfSyncMessage = '';\n\n const pathsByName: { [key: string]: string[] } =\n updates.projectFilesUpdated.reduce(\n (prev, { name, path }) => ({\n ...prev,\n [name]: [...(prev[name] ?? []), path],\n }),\n {},\n );\n Object.entries(pathsByName).forEach(([name, files]) => {\n outOfSyncMessage += `Project ${name} files are out of sync:\\n${files.map((p) => `- ${p}`).join('\\n')}\\n\\n`;\n });\n\n if (updates.licenseHeadersUpdated.length > 0) {\n outOfSyncMessage += `License headers are out of sync in the following source files:\\n${updates.licenseHeadersUpdated.map((p) => `- ${p}`).join('\\n')}\\n\\n`;\n }\n\n return outOfSyncMessage.trim();\n};\n\n/**\n * Load the license header content lines\n */\nconst loadHeaderContentLines = (\n tree: Tree,\n config: LicenseHeaderConfig,\n): string[] => {\n // Load the license header content\n let headerContentLines = [];\n if ('lines' in config.content) {\n headerContentLines = config.content.lines;\n } else {\n if (!tree.exists(config.content.filePath)) {\n throw new Error(\n `Could not find license header content file ${config.content.filePath}`,\n );\n }\n headerContentLines = tree\n .read(config.content.filePath, 'utf-8')\n .split('\\n');\n }\n return headerContentLines;\n};\n\n/**\n * Returns all files in the given tree - both in-memory only and in the filesystem under the tree root\n */\nconst getAllFilesInTree = async (tree: Tree): Promise<string[]> => {\n return [\n ...new Set([\n // Get all files in memory in the tree\n ...(await globAsync(tree, ['*', '**/*'])),\n // Find all files on the filesystem that may not be in memory in the tree\n ...(await fastGlob(['*', '**/*'], { cwd: tree.root, dot: true })),\n ]),\n ].filter((f) => tree.exists(f));\n};\n\n/**\n * Returns the list of project files\n */\nconst getCandidateProjectFilesForHeader = async (\n tree: Tree,\n config: LicenseHeaderConfig,\n): Promise<string[]> => {\n // Prefer, if possible, to treat all non gitignored files as our candidate set such that we honour users .gitignore files\n // If we're not in a git repo, fall back to everything and rely on the user configuring exclusions below\n const projectFiles = isWithinGitRepo(tree)\n ? getGitIncludedFiles(tree)\n : await getAllFilesInTree(tree);\n\n // Remove any files that were excluded in the config\n const ignoredProjectFiles = new Set(\n (config.exclude ?? []).flatMap((pattern) =>\n minimatch.match(projectFiles, pattern),\n ),\n );\n return projectFiles.filter((file) => !ignoredProjectFiles.has(file));\n};\n\n/**\n * Renders a header with the given format\n */\nconst renderHeader = (\n contentLines: string[],\n format: LicenseHeaderFormat,\n): string => {\n return `${format.blockStart ? `${format.blockStart}\\n` : ''}${contentLines.map((line) => `${format.lineStart ?? ''}${line}${format.lineEnd ?? ''}`).join('\\n')}${format.blockEnd ? `\\n${format.blockEnd}` : ''}`;\n};\n\n/**\n * Validates header format to ensure it produces a valid comment\n */\nconst validateFormat = (\n fileExtension: string,\n syntax: CommentSyntax,\n format: LicenseHeaderFormat,\n contentLines: string[],\n): void => {\n const blockStartOpensBlockComment =\n format.blockStart &&\n syntax.block &&\n format.blockStart.startsWith(syntax.block.start);\n const blockEndClosesBlockComment =\n format.blockEnd &&\n syntax.block &&\n format.blockEnd.endsWith(syntax.block.end);\n\n // Block start must start with the block start or line comment\n const validBlockStart =\n !format.blockStart ||\n blockStartOpensBlockComment ||\n (syntax.line && format.blockStart.startsWith(syntax.line));\n // Block end must end with the block end, or begin with the line comment\n const validBlockEnd =\n !format.blockEnd ||\n blockEndClosesBlockComment ||\n (syntax.line && format.blockEnd.startsWith(syntax.line));\n\n // Lines must start with the line comment syntax, unless within a block comment\n const validLineStart =\n !format.lineStart ||\n (syntax.line && format.lineStart.startsWith(syntax.line)) ||\n (blockStartOpensBlockComment && blockEndClosesBlockComment);\n\n if (!validLineStart || !validBlockStart || !validBlockEnd) {\n throw new Error(\n `Provided format for ${fileExtension} file would generate invalid comment syntax. Configured syntax for ${fileExtension} is ${JSON.stringify(syntax, null, 2)}.`,\n );\n }\n\n if (blockStartOpensBlockComment && !blockEndClosesBlockComment) {\n throw new Error(\n `Provided format for ${fileExtension} file opens a block comment with \"${syntax.block.start}\" in blockStart but does not close it with \"${syntax.block.end}\" in blockEnd`,\n );\n }\n\n if (\n blockStartOpensBlockComment &&\n contentLines.some((line) => line.includes(syntax.block.end))\n ) {\n throw new Error(\n `Provided license content would close a block comment early and cause a syntax error! Please remove \"${syntax.block.end}\" from your license text.`,\n );\n }\n\n if (blockStartOpensBlockComment && blockEndClosesBlockComment) {\n if (\n format.blockEnd.lastIndexOf(syntax.block.end) !==\n format.blockEnd.indexOf(syntax.block.end)\n ) {\n throw new Error(\n `Provided format for ${fileExtension} file may cause syntax errors due to closing a block comment multiple times with \"${syntax.block.end}\" in blockEnd`,\n );\n }\n if (format.blockStart.includes(syntax.block.end)) {\n throw new Error(\n `Provided format for ${fileExtension} file may cause syntax errors since it closes the block comment with \"${syntax.block.end}\" in blockStart`,\n );\n }\n }\n};\n\n/**\n * Parse the hashbang, header and body from a file.\n * The header is the first block comment, or consecutive series of line comments found in the file, after the hashbang\n */\nexport const parseFile = (\n content: string,\n syntax: CommentSyntax,\n): { hashbang: string; header: string; body: string } => {\n const lines = content.split('\\n');\n let i = 0;\n\n // Hashbangs must always go first, so extract this if it exists\n const hashbangLines = [];\n for (; i < lines.length; i++) {\n if (hashbangLines.length === 0) {\n if (lines[i].startsWith('#!')) {\n hashbangLines.push(lines[i]);\n } else {\n break;\n }\n } else {\n if (lines[i].trim().length === 0) {\n // Preserve any empty lines following the hashbang\n hashbangLines.push(lines[i]);\n } else {\n break;\n }\n }\n }\n\n // After the hashbang, consume the next comment which follows.\n // This could either be all lines of a block comment, or all consecutive line comments until a non line-comment is seen\n const headerLines = [];\n let withinBlockComment = false;\n let withinLineCommentSeries = false;\n for (; i < lines.length; i++) {\n const trimmedLine = lines[i].trim();\n if (\n syntax.block &&\n trimmedLine.endsWith(syntax.block.end) &&\n !withinLineCommentSeries &&\n (withinBlockComment || trimmedLine.startsWith(syntax.block.start))\n ) {\n // Comment ends with the block end, so we've completed the header and therefore break out of the loop\n headerLines.push(lines[i]);\n i++; // Increment here to ensure we point to the next line for the body\n break;\n } else if (\n syntax.block &&\n trimmedLine.startsWith(syntax.block.start) &&\n !withinLineCommentSeries\n ) {\n // Line begins a comment block (without also ending it on the same line), so start consuming the block\n withinBlockComment = true;\n headerLines.push(lines[i]);\n } else if (withinBlockComment) {\n // We haven't yet closed the block comment, so consume this line\n headerLines.push(lines[i]);\n } else if (syntax.line && trimmedLine.startsWith(syntax.line)) {\n // Line starts with the line comment syntax, so consume it\n withinLineCommentSeries = true;\n headerLines.push(lines[i]);\n } else {\n break;\n }\n }\n\n // Body of the file is the rest\n const bodyLines = lines.slice(i);\n\n return {\n hashbang: hashbangLines.join('\\n'),\n header: headerLines.join('\\n'),\n body: bodyLines.join('\\n'),\n };\n};\n\n/**\n * Add a header to the given file according to the header content and license config\n * Returns true if the header was added/updated, and false otherwise.\n */\nconst addHeader = (\n tree: Tree,\n file: string,\n contentLines: string[],\n config: LicenseHeaderConfig,\n format: LicenseHeaderFormat,\n): boolean => {\n const fileName = basename(file);\n const fileNameParts = fileName.split('.');\n const fileExtension = fileNameParts[fileNameParts.length - 1];\n\n const syntax =\n (config.commentSyntax ?? {})[fileExtension] ??\n LANGUAGE_COMMENT_SYNTAX[fileExtension];\n if (!syntax) {\n throw new Error(`Unknown file extension ${fileExtension}. Please configure commentSyntax in ${AWS_NX_PLUGIN_CONFIG_FILE_NAME}, eg:\n\nexport default {\n license: {\n header: {\n ...\n commentSyntax: {\n ${fileExtension}: {\n line: \"//\",\n block: { start: \"/*\", end: \"*/\" }\n }\n }\n }\n }\n} satisfies AwsNxPluginConfig;\n`);\n }\n\n // Check that we would render a valid comment\n validateFormat(fileExtension, syntax, format, contentLines);\n\n const existingContent = tree.read(file, 'utf-8');\n\n const { hashbang, body } = parseFile(existingContent, syntax);\n\n const newContent = [\n ...(hashbang ? [hashbang] : []),\n renderHeader(contentLines, format),\n body,\n ].join('\\n');\n\n // Sanity check that we wouldn't edit the hashbang or body, only the header\n const { hashbang: newHashbang, body: newBody } = parseFile(\n newContent,\n syntax,\n );\n if (hashbang !== newHashbang || body !== newBody) {\n throw new Error(\n `The license header content, or format for ${fileExtension} files would produce a header that cannot be safely replaced in ${file}. Please revise license content and format in ${AWS_NX_PLUGIN_CONFIG_FILE_NAME}`,\n );\n }\n\n if (newContent !== existingContent) {\n tree.write(file, newContent);\n return true;\n }\n\n return false;\n};\n\nexport default licenseSyncGenerator;\n"],"names":["getProjects","globAsync","joinPathFragments","fastGlob","minimatch","basename","PackageJson","type","AWS_NX_PLUGIN_CONFIG_FILE_NAME","getGitIncludedFiles","isWithinGitRepo","getGeneratorInfo","LANGUAGE_COMMENT_SYNTAX","readLicenseConfig","PROJECT_FILES_TO_SYNC","syncProjectFile","SYNC_GENERATOR_NAME","name","filename","id","licenseSyncGenerator","tree","source","licenseHeadersUpdated","header","candidateProjectFiles","getCandidateProjectFilesForHeader","headerContentLines","loadHeaderContentLines","includePattern","format","Object","entries","files","match","forEach","file","didAdd","addHeader","push","projectFilesUpdated","isFileIncludedInSync","path","exclude","some","excludePattern","projectRoots","values","map","p","root","projectRoot","projectFile","projectFilePath","prevContent","read","newContent","outOfSyncMessage","buildOutOfSyncMessage","updates","pathsByName","reduce","prev","join","length","trim","config","content","lines","exists","filePath","Error","split","getAllFilesInTree","Set","cwd","dot","filter","f","projectFiles","ignoredProjectFiles","flatMap","pattern","has","renderHeader","contentLines","blockStart","line","lineStart","lineEnd","blockEnd","validateFormat","fileExtension","syntax","blockStartOpensBlockComment","block","startsWith","start","blockEndClosesBlockComment","endsWith","end","validBlockStart","validBlockEnd","validLineStart","JSON","stringify","includes","lastIndexOf","indexOf","parseFile","i","hashbangLines","headerLines","withinBlockComment","withinLineCommentSeries","trimmedLine","bodyLines","slice","hashbang","body","fileName","fileNameParts","commentSyntax","existingContent","newHashbang","newBody","write"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EACXC,SAAS,EACTC,iBAAiB,QAEZ,aAAa;AACpB,OAAOC,cAAc,YAAY;AACjC,SAASC,SAAS,QAAQ,YAAY;AAEtC,SAASC,QAAQ,QAAQ,OAAO;AAChC,OAAOC,iBAAiB,6BAA6B;IAAEC,MAAM;AAAO,EAAE;AACtE,SAASC,8BAA8B,QAAQ,8BAA8B;AAC7E,SAASC,mBAAmB,EAAEC,eAAe,QAAQ,qBAAqB;AAC1E,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,uBAAuB,EAAEC,iBAAiB,QAAQ,eAAe;AAM1E,SACEC,qBAAqB,EAErBC,eAAe,QACV,yBAAyB;AAEhC,OAAO,MAAMC,sBAAsB,GAAGV,YAAYW,IAAI,CAAC,CAAC,EAAEN,iBAAiB,YAAYO,QAAQ,EAAEC,EAAE,EAAE,CAAC;AAOtG,OAAO,eAAeC,qBACpBC,IAAU;IAEV,MAAMC,SAAU,CAAA,MAAMT,kBAAkBQ,KAAI,GAAIC;IAEhD,IAAI,CAACA,QAAQ;QACX,iFAAiF;QACjF,OAAO,CAAC;IACV;IAEA,MAAMC,wBAAkC,EAAE;IAE1C,IAAID,OAAOE,MAAM,EAAE;QACjB,6CAA6C;QAC7C,MAAMC,wBAAwB,MAAMC,kCAClCL,MACAC,OAAOE,MAAM;QAGf,MAAMG,qBAAqBC,uBAAuBP,MAAMC,OAAOE,MAAM;QAErE,+DAA+D;QAC/D,K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wD,aAAa,IAAI,CAAC,CAAA,CAAE,CAAC9B,cAAc,IAC3ChF,uBAAuB,CAACgF,cAAc;IACxC,IAAI,CAACC,QAAQ;QACX,MAAM,IAAItB,MAAM,CAAC,uBAAuB,EAAEqB,cAAc,oCAAoC,EAAEpF,+BAA+B;;;;;;;QAOzH,EAAEoF,cAAc;;;;;;;;AAQxB,CAAC;IACC;IAEA,6CAA6C;IAC7CD,eAAeC,eAAeC,QAAQ/D,QAAQuD;IAE9C,MAAMsC,kBAAkBtG,KAAKkC,IAAI,CAACnB,MAAM;IAExC,MAAM,EAAEkF,QAAQ,EAAEC,IAAI,EAAE,GAAGV,UAAUc,iBAAiB9B;IAEtD,MAAMrC,aAAa;WACb8D,WAAW;YAACA;SAAS,GAAG,EAAE;QAC9BlC,aAAaC,cAAcvD;QAC3ByF;KACD,CAACxD,IAAI,CAAC;IAEP,2EAA2E;IAC3E,MAAM,EAAEuD,UAAUM,WAAW,EAAEL,MAAMM,OAAO,EAAE,GAAGhB,UAC/CrD,YACAqC;IAEF,IAAIyB,aAAaM,eAAeL,SAASM,SAAS;QAChD,MAAM,IAAItD,MACR,CAAC,0CAA0C,EAAEqB,cAAc,gEAAgE,EAAExD,KAAK,8CAA8C,EAAE5B,gCAAgC;IAEtN;IAEA,IAAIgD,eAAemE,iBAAiB;QAClCtG,KAAKyG,KAAK,CAAC1F,MAAMoB;QACjB,OAAO;IACT;IAEA,OAAO;AACT;AAEA,eAAepC,qBAAqB"}
|
package/src/mcp-server/server.js
CHANGED
|
@@ -7,6 +7,7 @@ import PackageJson from "../../package.json" with {
|
|
|
7
7
|
};
|
|
8
8
|
import { listGenerators } from "../utils/nx.js";
|
|
9
9
|
import { addToExistingProjectTool } from "./tools/add-to-existing-project.js";
|
|
10
|
+
import { addBestPracticesTool } from "./tools/best-practices.js";
|
|
10
11
|
import { addCreateWorkspaceCommandTool } from "./tools/create-workspace-command.js";
|
|
11
12
|
import { addGeneralGuidanceTool, TOOL_SELECTION_GUIDE } from "./tools/general-guidance.js";
|
|
12
13
|
import { addGeneratorGuideTool } from "./tools/generator-guide.js";
|
|
@@ -31,6 +32,7 @@ ${TOOL_SELECTION_GUIDE}
|
|
|
31
32
|
`
|
|
32
33
|
});
|
|
33
34
|
addGeneralGuidanceTool(server, generators);
|
|
35
|
+
addBestPracticesTool(server, generators);
|
|
34
36
|
addCreateWorkspaceCommandTool(server);
|
|
35
37
|
addListGeneratorsTool(server, generators);
|
|
36
38
|
addGeneratorGuideTool(server, generators);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/mcp-server/server.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport PackageJson from '../../package.json' with { type: 'json' };\nimport { listGenerators } from '../utils/nx.js';\nimport { addToExistingProjectTool } from './tools/add-to-existing-project.js';\nimport { addCreateWorkspaceCommandTool } from './tools/create-workspace-command.js';\nimport {\n addGeneralGuidanceTool,\n TOOL_SELECTION_GUIDE,\n} from './tools/general-guidance.js';\nimport { addGeneratorGuideTool } from './tools/generator-guide.js';\nimport { addListGeneratorsTool } from './tools/list-generators.js';\nimport { addUpgradeWorkspaceTool } from './tools/upgrade-workspace.js';\n\n/**\n * Create the MCP Server\n */\nexport const createServer = () => {\n const generators = listGenerators();\n\n const server = new McpServer(\n {\n name: 'nx-plugin-for-aws',\n version: PackageJson.version,\n },\n {\n instructions: `# Nx Plugin for AWS MCP Server\n\nThis server provides resources and tools for quickly scaffolding AWS projects within an Nx workspace (monorepo), using the Nx Plugin for AWS (@aws/nx-plugin).\n\nThe Nx Plugin for AWS provides \"generators\" to add projects or functionality to your workspace. Use this to build the foundations of any project you are building\non AWS, if the generators apply to your use case.\n\n${TOOL_SELECTION_GUIDE}\n`,\n },\n );\n\n addGeneralGuidanceTool(server, generators);\n addCreateWorkspaceCommandTool(server);\n addListGeneratorsTool(server, generators);\n addGeneratorGuideTool(server, generators);\n addToExistingProjectTool(server, generators);\n addUpgradeWorkspaceTool(server, generators);\n\n return server;\n};\n"],"names":["McpServer","PackageJson","type","listGenerators","addToExistingProjectTool","addCreateWorkspaceCommandTool","addGeneralGuidanceTool","TOOL_SELECTION_GUIDE","addGeneratorGuideTool","addListGeneratorsTool","addUpgradeWorkspaceTool","createServer","generators","server","name","version","instructions"],"mappings":"AAAA;;;CAGC,GACD,SAASA,SAAS,QAAQ,0CAA0C;AACpE,OAAOC,iBAAiB,0BAA0B;IAAEC,MAAM;AAAO,EAAE;AACnE,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,wBAAwB,QAAQ,qCAAqC;AAC9E,SAASC,6BAA6B,QAAQ,sCAAsC;AACpF,SACEC,sBAAsB,EACtBC,oBAAoB,QACf,8BAA8B;AACrC,SAASC,qBAAqB,QAAQ,6BAA6B;AACnE,SAASC,qBAAqB,QAAQ,6BAA6B;AACnE,SAASC,uBAAuB,QAAQ,+BAA+B;AAEvE;;CAEC,GACD,OAAO,MAAMC,eAAe;IAC1B,MAAMC,
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/mcp-server/server.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport PackageJson from '../../package.json' with { type: 'json' };\nimport { listGenerators } from '../utils/nx.js';\nimport { addToExistingProjectTool } from './tools/add-to-existing-project.js';\nimport { addBestPracticesTool } from './tools/best-practices.js';\nimport { addCreateWorkspaceCommandTool } from './tools/create-workspace-command.js';\nimport {\n addGeneralGuidanceTool,\n TOOL_SELECTION_GUIDE,\n} from './tools/general-guidance.js';\nimport { addGeneratorGuideTool } from './tools/generator-guide.js';\nimport { addListGeneratorsTool } from './tools/list-generators.js';\nimport { addUpgradeWorkspaceTool } from './tools/upgrade-workspace.js';\n\n/**\n * Create the MCP Server\n */\nexport const createServer = () => {\n const generators = listGenerators();\n\n const server = new McpServer(\n {\n name: 'nx-plugin-for-aws',\n version: PackageJson.version,\n },\n {\n instructions: `# Nx Plugin for AWS MCP Server\n\nThis server provides resources and tools for quickly scaffolding AWS projects within an Nx workspace (monorepo), using the Nx Plugin for AWS (@aws/nx-plugin).\n\nThe Nx Plugin for AWS provides \"generators\" to add projects or functionality to your workspace. Use this to build the foundations of any project you are building\non AWS, if the generators apply to your use case.\n\n${TOOL_SELECTION_GUIDE}\n`,\n },\n );\n\n addGeneralGuidanceTool(server, generators);\n addBestPracticesTool(server, generators);\n addCreateWorkspaceCommandTool(server);\n addListGeneratorsTool(server, generators);\n addGeneratorGuideTool(server, generators);\n addToExistingProjectTool(server, generators);\n addUpgradeWorkspaceTool(server, generators);\n\n return server;\n};\n"],"names":["McpServer","PackageJson","type","listGenerators","addToExistingProjectTool","addBestPracticesTool","addCreateWorkspaceCommandTool","addGeneralGuidanceTool","TOOL_SELECTION_GUIDE","addGeneratorGuideTool","addListGeneratorsTool","addUpgradeWorkspaceTool","createServer","generators","server","name","version","instructions"],"mappings":"AAAA;;;CAGC,GACD,SAASA,SAAS,QAAQ,0CAA0C;AACpE,OAAOC,iBAAiB,0BAA0B;IAAEC,MAAM;AAAO,EAAE;AACnE,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,wBAAwB,QAAQ,qCAAqC;AAC9E,SAASC,oBAAoB,QAAQ,4BAA4B;AACjE,SAASC,6BAA6B,QAAQ,sCAAsC;AACpF,SACEC,sBAAsB,EACtBC,oBAAoB,QACf,8BAA8B;AACrC,SAASC,qBAAqB,QAAQ,6BAA6B;AACnE,SAASC,qBAAqB,QAAQ,6BAA6B;AACnE,SAASC,uBAAuB,QAAQ,+BAA+B;AAEvE;;CAEC,GACD,OAAO,MAAMC,eAAe;IAC1B,MAAMC,aAAaV;IAEnB,MAAMW,SAAS,IAAId,UACjB;QACEe,MAAM;QACNC,SAASf,YAAYe,OAAO;IAC9B,GACA;QACEC,cAAc,CAAC;;;;;;;AAOrB,EAAET,qBAAqB;AACvB,CAAC;IACG;IAGFD,uBAAuBO,QAAQD;IAC/BR,qBAAqBS,QAAQD;IAC7BP,8BAA8BQ;IAC9BJ,sBAAsBI,QAAQD;IAC9BJ,sBAAsBK,QAAQD;IAC9BT,yBAAyBU,QAAQD;IACjCF,wBAAwBG,QAAQD;IAEhC,OAAOC;AACT,EAAE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
+
import type { NxGeneratorInfo } from '../../utils/generators.js';
|
|
7
|
+
/**
|
|
8
|
+
* Guide pages documenting behaviour that spans generators, so no single
|
|
9
|
+
* generator owns them and `generator-guide` never returns them. Each is
|
|
10
|
+
* described for the agent so it can pick the ones relevant to its task.
|
|
11
|
+
*/
|
|
12
|
+
export declare const BEST_PRACTICE_PAGES: {
|
|
13
|
+
readonly workspace: "Workspace layout, configuration and common commands";
|
|
14
|
+
readonly 'typescript-project': "Conventions for TypeScript projects";
|
|
15
|
+
readonly 'python-project': "Conventions for Python projects";
|
|
16
|
+
readonly security: "Security controls vended infrastructure carries, and the shared responsibility model";
|
|
17
|
+
readonly 'runtime-config': "How generated projects discover one another through AWS AppConfig";
|
|
18
|
+
readonly 'docker-bundling': "Building and deploying container images";
|
|
19
|
+
readonly 'local-development': "Running projects locally with the serve and dev targets";
|
|
20
|
+
};
|
|
21
|
+
export type BestPracticePage = keyof typeof BEST_PRACTICE_PAGES;
|
|
22
|
+
export declare const BEST_PRACTICE_PAGE_NAMES: BestPracticePage[];
|
|
23
|
+
/**
|
|
24
|
+
* Add a tool which serves the cross-cutting guide pages. Kept separate from
|
|
25
|
+
* `general-guidance` so an agent fetches only the pages its task needs rather
|
|
26
|
+
* than every page on every call.
|
|
27
|
+
*/
|
|
28
|
+
export declare const addBestPracticesTool: (server: McpServer, generators: NxGeneratorInfo[]) => void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ import { z } from "zod";
|
|
5
|
+
import { fetchGuidePages } from "../generator-info.js";
|
|
6
|
+
import { PackageManagerSchema } from "../schema.js";
|
|
7
|
+
/**
|
|
8
|
+
* Guide pages documenting behaviour that spans generators, so no single
|
|
9
|
+
* generator owns them and `generator-guide` never returns them. Each is
|
|
10
|
+
* described for the agent so it can pick the ones relevant to its task.
|
|
11
|
+
*/ export const BEST_PRACTICE_PAGES = {
|
|
12
|
+
workspace: 'Workspace layout, configuration and common commands',
|
|
13
|
+
'typescript-project': 'Conventions for TypeScript projects',
|
|
14
|
+
'python-project': 'Conventions for Python projects',
|
|
15
|
+
security: 'Security controls vended infrastructure carries, and the shared responsibility model',
|
|
16
|
+
'runtime-config': 'How generated projects discover one another through AWS AppConfig',
|
|
17
|
+
'docker-bundling': 'Building and deploying container images',
|
|
18
|
+
'local-development': 'Running projects locally with the serve and dev targets'
|
|
19
|
+
};
|
|
20
|
+
export const BEST_PRACTICE_PAGE_NAMES = Object.keys(BEST_PRACTICE_PAGES);
|
|
21
|
+
/**
|
|
22
|
+
* Add a tool which serves the cross-cutting guide pages. Kept separate from
|
|
23
|
+
* `general-guidance` so an agent fetches only the pages its task needs rather
|
|
24
|
+
* than every page on every call.
|
|
25
|
+
*/ export const addBestPracticesTool = (server, generators)=>{
|
|
26
|
+
server.registerTool('best-practices', {
|
|
27
|
+
title: 'Best Practices',
|
|
28
|
+
description: 'Tool to retrieve guidance which spans generators, rather than applying to one in particular. ' + 'Request the pages relevant to your task:\n' + Object.entries(BEST_PRACTICE_PAGES).map(([page, description])=>`- \`${page}\`: ${description}`).join('\n'),
|
|
29
|
+
inputSchema: {
|
|
30
|
+
packageManager: PackageManagerSchema.optional(),
|
|
31
|
+
pages: z.array(z.enum(BEST_PRACTICE_PAGE_NAMES)).min(1).describe('The guide pages to retrieve.')
|
|
32
|
+
}
|
|
33
|
+
}, async ({ packageManager, pages })=>({
|
|
34
|
+
content: [
|
|
35
|
+
{
|
|
36
|
+
type: 'text',
|
|
37
|
+
text: await fetchGuidePages(pages, generators, packageManager)
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=best-practices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/mcp-server/tools/best-practices.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { NxGeneratorInfo } from '../../utils/generators.js';\nimport { fetchGuidePages } from '../generator-info.js';\nimport { PackageManagerSchema } from '../schema.js';\n\n/**\n * Guide pages documenting behaviour that spans generators, so no single\n * generator owns them and `generator-guide` never returns them. Each is\n * described for the agent so it can pick the ones relevant to its task.\n */\nexport const BEST_PRACTICE_PAGES = {\n workspace: 'Workspace layout, configuration and common commands',\n 'typescript-project': 'Conventions for TypeScript projects',\n 'python-project': 'Conventions for Python projects',\n security:\n 'Security controls vended infrastructure carries, and the shared responsibility model',\n 'runtime-config':\n 'How generated projects discover one another through AWS AppConfig',\n 'docker-bundling': 'Building and deploying container images',\n 'local-development':\n 'Running projects locally with the serve and dev targets',\n} as const satisfies Record<string, string>;\n\nexport type BestPracticePage = keyof typeof BEST_PRACTICE_PAGES;\n\nexport const BEST_PRACTICE_PAGE_NAMES = Object.keys(\n BEST_PRACTICE_PAGES,\n) as BestPracticePage[];\n\n/**\n * Add a tool which serves the cross-cutting guide pages. Kept separate from\n * `general-guidance` so an agent fetches only the pages its task needs rather\n * than every page on every call.\n */\nexport const addBestPracticesTool = (\n server: McpServer,\n generators: NxGeneratorInfo[],\n) => {\n server.registerTool(\n 'best-practices',\n {\n title: 'Best Practices',\n description:\n 'Tool to retrieve guidance which spans generators, rather than applying to one in particular. ' +\n 'Request the pages relevant to your task:\\n' +\n Object.entries(BEST_PRACTICE_PAGES)\n .map(([page, description]) => `- \\`${page}\\`: ${description}`)\n .join('\\n'),\n inputSchema: {\n packageManager: PackageManagerSchema.optional(),\n pages: z\n .array(z.enum(BEST_PRACTICE_PAGE_NAMES))\n .min(1)\n .describe('The guide pages to retrieve.'),\n },\n },\n async ({ packageManager, pages }) => ({\n content: [\n {\n type: 'text' as const,\n text: await fetchGuidePages(pages, generators, packageManager),\n },\n ],\n }),\n );\n};\n"],"names":["z","fetchGuidePages","PackageManagerSchema","BEST_PRACTICE_PAGES","workspace","security","BEST_PRACTICE_PAGE_NAMES","Object","keys","addBestPracticesTool","server","generators","registerTool","title","description","entries","map","page","join","inputSchema","packageManager","optional","pages","array","enum","min","describe","content","type","text"],"mappings":"AAAA;;;CAGC,GAED,SAASA,CAAC,QAAQ,MAAM;AAExB,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,oBAAoB,QAAQ,eAAe;AAEpD;;;;CAIC,GACD,OAAO,MAAMC,sBAAsB;IACjCC,WAAW;IACX,sBAAsB;IACtB,kBAAkB;IAClBC,UACE;IACF,kBACE;IACF,mBAAmB;IACnB,qBACE;AACJ,EAA4C;AAI5C,OAAO,MAAMC,2BAA2BC,OAAOC,IAAI,CACjDL,qBACsB;AAExB;;;;CAIC,GACD,OAAO,MAAMM,uBAAuB,CAClCC,QACAC;IAEAD,OAAOE,YAAY,CACjB,kBACA;QACEC,OAAO;QACPC,aACE,kGACA,+CACAP,OAAOQ,OAAO,CAACZ,qBACZa,GAAG,CAAC,CAAC,CAACC,MAAMH,YAAY,GAAK,CAAC,IAAI,EAAEG,KAAK,IAAI,EAAEH,aAAa,EAC5DI,IAAI,CAAC;QACVC,aAAa;YACXC,gBAAgBlB,qBAAqBmB,QAAQ;YAC7CC,OAAOtB,EACJuB,KAAK,CAACvB,EAAEwB,IAAI,CAAClB,2BACbmB,GAAG,CAAC,GACJC,QAAQ,CAAC;QACd;IACF,GACA,OAAO,EAAEN,cAAc,EAAEE,KAAK,EAAE,GAAM,CAAA;YACpCK,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,MAAM5B,gBAAgBqB,OAAOX,YAAYS;gBACjD;aACD;QACH,CAAA;AAEJ,EAAE"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
6
|
import type { NxGeneratorInfo } from '../../utils/generators.js';
|
|
7
|
-
export declare const TOOL_SELECTION_GUIDE = "## Tool Selection Guide\n\n- Use the `general-guidance` tool for guidance and best practices for working with Nx and the Nx Plugin for AWS.\n- Use the `create-workspace-command` tool to discover how to create a workspace to start a new project.\n- Use the `add-to-existing-project` tool when adding the plugin to an existing Nx workspace or non-Nx monorepo, or when troubleshooting configuration errors in such a workspace.\n- Use the `upgrade-workspace` tool when upgrading Nx or the Nx Plugin for AWS to a newer version.\n- Use the `list-generators` tool to discover the available generators and how to run them.\n- Use the `generator-guide` tool to retrieve detailed information about a specific generator.";
|
|
7
|
+
export declare const TOOL_SELECTION_GUIDE = "## Tool Selection Guide\n\n- Use the `general-guidance` tool for guidance and best practices for working with Nx and the Nx Plugin for AWS.\n- Use the `best-practices` tool for guidance which spans generators rather than applying to one in particular, such as workspace layout, security, runtime configuration, container builds and local development.\n- Use the `create-workspace-command` tool to discover how to create a workspace to start a new project.\n- Use the `add-to-existing-project` tool when adding the plugin to an existing Nx workspace or non-Nx monorepo, or when troubleshooting configuration errors in such a workspace.\n- Use the `upgrade-workspace` tool when upgrading Nx or the Nx Plugin for AWS to a newer version.\n- Use the `list-generators` tool to discover the available generators and how to run them.\n- Use the `generator-guide` tool to retrieve detailed information about a specific generator.";
|
|
8
8
|
/**
|
|
9
9
|
* Add a tool which provides general guidance for using Nx and the Nx Plugin for AWS
|
|
10
10
|
*/
|
|
@@ -4,9 +4,20 @@
|
|
|
4
4
|
*/ import { IAC_PROVIDERS } from "../../utils/iac-providers.js";
|
|
5
5
|
import { buildNxCommand, fetchGuidePages } from "../generator-info.js";
|
|
6
6
|
import { PACKAGE_MANAGERS } from "../schema.js";
|
|
7
|
+
import { BEST_PRACTICE_PAGE_NAMES } from "./best-practices.js";
|
|
8
|
+
/**
|
|
9
|
+
* The cross-cutting pages every agent needs regardless of task, inlined here
|
|
10
|
+
* so a workspace's conventions land without a second tool call. The rest are
|
|
11
|
+
* served on demand by `best-practices`.
|
|
12
|
+
*/ const GENERAL_GUIDANCE_PAGES = [
|
|
13
|
+
'workspace',
|
|
14
|
+
'typescript-project',
|
|
15
|
+
'python-project'
|
|
16
|
+
];
|
|
7
17
|
export const TOOL_SELECTION_GUIDE = `## Tool Selection Guide
|
|
8
18
|
|
|
9
19
|
- Use the \`general-guidance\` tool for guidance and best practices for working with Nx and the Nx Plugin for AWS.
|
|
20
|
+
- Use the \`best-practices\` tool for guidance which spans generators rather than applying to one in particular, such as workspace layout, security, runtime configuration, container builds and local development.
|
|
10
21
|
- Use the \`create-workspace-command\` tool to discover how to create a workspace to start a new project.
|
|
11
22
|
- Use the \`add-to-existing-project\` tool when adding the plugin to an existing Nx workspace or non-Nx monorepo, or when troubleshooting configuration errors in such a workspace.
|
|
12
23
|
- Use the \`upgrade-workspace\` tool when upgrading Nx or the Nx Plugin for AWS to a newer version.
|
|
@@ -86,12 +97,10 @@ ${PACKAGE_MANAGERS.map((pm)=>` \`\`\`bash
|
|
|
86
97
|
|
|
87
98
|
## Detailed Guides
|
|
88
99
|
|
|
89
|
-
Please refer to the below documentation for important details regarding workspaces and working with TypeScript or Python projects.
|
|
100
|
+
Please refer to the below documentation for important details regarding workspaces and working with TypeScript or Python projects. Use the \`best-practices\` tool for the remaining cross-cutting guides (${BEST_PRACTICE_PAGE_NAMES.filter((p)=>!GENERAL_GUIDANCE_PAGES.includes(p)).map((p)=>`\`${p}\``).join(', ')}).
|
|
90
101
|
|
|
91
102
|
${await fetchGuidePages([
|
|
92
|
-
|
|
93
|
-
'typescript-project',
|
|
94
|
-
'python-project'
|
|
103
|
+
...GENERAL_GUIDANCE_PAGES
|
|
95
104
|
], generators)}
|
|
96
105
|
|
|
97
106
|
`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/mcp-server/tools/general-guidance.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { NxGeneratorInfo } from '../../utils/generators.js';\nimport { IAC_PROVIDERS } from '../../utils/iac-providers.js';\nimport { buildNxCommand, fetchGuidePages } from '../generator-info.js';\nimport { PACKAGE_MANAGERS } from '../schema.js';\n\nexport const TOOL_SELECTION_GUIDE = `## Tool Selection Guide\n\n- Use the \\`general-guidance\\` tool for guidance and best practices for working with Nx and the Nx Plugin for AWS.\n- Use the \\`create-workspace-command\\` tool to discover how to create a workspace to start a new project.\n- Use the \\`add-to-existing-project\\` tool when adding the plugin to an existing Nx workspace or non-Nx monorepo, or when troubleshooting configuration errors in such a workspace.\n- Use the \\`upgrade-workspace\\` tool when upgrading Nx or the Nx Plugin for AWS to a newer version.\n- Use the \\`list-generators\\` tool to discover the available generators and how to run them.\n- Use the \\`generator-guide\\` tool to retrieve detailed information about a specific generator.`;\n\n/**\n * Add a tool which provides general guidance for using Nx and the Nx Plugin for AWS\n */\nexport const addGeneralGuidanceTool = (\n server: McpServer,\n generators: NxGeneratorInfo[],\n) => {\n server.registerTool(\n 'general-guidance',\n {\n title: 'General Guidance',\n description:\n 'Tool for guidance and best practices for working with Nx and the Nx Plugin for AWS',\n },\n async () => ({\n content: [\n {\n type: 'text' as const,\n text: `# Nx Plugin for AWS Guidance\n\n${TOOL_SELECTION_GUIDE}\n\n## Getting Started\n\n- Choose a package manager first. You can choose between ${PACKAGE_MANAGERS.join(', ')}. It's recommended to use \"pnpm\" if the user has no preference\n- Choose an infrastructure as code (IaC) provider next. You can choose between ${IAC_PROVIDERS.join(', ')}. It's recommended to use CDK if the user has no preference\n- Next, you must create an Nx workspace. Use the \\`create-workspace-command\\` tool for more details, and provide it with your chosen package manager\n- After this, you can start scaffolding the main components of your application using generators. Use the \\`list-generators\\` tool to discover available generators, and the \\`generator-guide\\` tool for more detailed information about a specific generator\n\n## Nx Primer\n\n- Prefix nx commands with the appropriate prefix for your package manager, for example:\n${PACKAGE_MANAGERS.map((pm) => buildNxCommand('<options>', pm)).join(' - \\n')}\n- Each project in your workspace has a file named \\`project.json\\` which contains important project information such as its name, and defines the \"targets\" which can be run for that project, for example building or testing the project\n- Use the command \\`nx reset\\` to reset the Nx daemon when unexpected issues arise\n- After adding dependencies between TypeScript projects, use \\`nx sync\\` to ensure project references are set up correctly\n\n## General Instructions\n\n- Each project declares the third-party runtime dependencies its source imports in its own \\`package.json\\`; shared build/test tooling (test runners, bundlers, etc.) is declared in the root \\`package.json\\` \\`devDependencies\\`. Versions follow a single version policy, recorded in the package manager's dependency catalog where supported (referenced as \\`catalog:\\`). Install with the appropriate command for your package manager:\n - Add a project runtime dependency: \\`pnpm add <package> --filter <project>\\` / \\`yarn workspace <project> add <package>\\` / \\`npm install <package> -w <project>\\` / \\`bun add <package> --cwd <project-directory>\\`\n - Add a shared dev tool at the root: \\`pnpm add -Dw <package>\\` / \\`yarn add -D <package>\\` / \\`npm install --legacy-peer-deps -D <package>\\` / \\`bun install -D <package>\\`\n- The \\`noUndeclaredDependencies\\` lint rule enforces that a project's source only imports packages declared in its own \\`package.json\\`\n- Projects in the same workspace can import one another directly by package name (eg \\`@workspace-name/project-name\\`) without declaring a dependency in \\`package.json\\` — TypeScript path aliases in \\`tsconfig.base.json\\` resolve these imports\n- When specifying project names as arguments to generators, prefer the _fully qualified_ project name, for example \\`@workspace-name/project-name\\`. Check the \\`project.json\\` file for the specific package to find its fully qualified name\n- When no generator exists for a specific framework required, use the base \\`ts#project\\` and \\`py#project\\` generators and build on top.\n- Leave the \\`--infra\\` option at its default value unless the user has explicitly instructed otherwise. Generators choose a sensible default type of infrastructure to deploy the project with, so only override \\`--infra\\` when the user has specified a particular requirement.\n\n## Useful Commands\n\n- Fix lint issues with \\`nx run-many --target lint --configuration=fix --all --output-style=stream\\`\n- Build all projects with \\`nx run-many --target build --all --output-style=stream\\`\n- Prefer importing the CDK constructs vended by generators in \\`packages/common/constructs\\` over writing your own\n\n## Best Practices\n\n- After running a generator, use the \\`nx show projects\\` command to check which projects have been added (if any)\n- Carefully examine the files that have been generated and always refer back to the generator guide when working in a generated project\n- Generate all projects into the \\`packages/\\` directory\n- After making changes to your projects, fix linting issues, then run a full build\n- When it's time to start testing a project, suggest to the user that infrastructure is deployed to AWS. For websites, if a runtime-config.json is needed, use the load-runtime-config target after a deployment to point a local website at a sandbox stack.\n- For CDK infrastructure projects, deploy the sandbox stage with the \\`deploy-sandbox\\` target (eg \\`nx deploy-sandbox infra\\`) rather than passing a stage pattern to \\`deploy\\` — it already targets the sandbox stage declared in \\`main.ts\\`. Likewise \\`destroy-sandbox\\` tears that stage back down.\n\n## Batching Generators\n\nWhen scaffolding several projects in one go, chain generators to avoid a slow dependency install after every generator:\n\n- **Chain generators** with \\`&&\\` in a single command. Pass \\`--prefer-install-dependencies=false\\` on each generator except the last so dependencies install once at the end, for example:\n\n${PACKAGE_MANAGERS.map(\n (pm) => ` \\`\\`\\`bash\n ${buildNxCommand('g @aws/nx-plugin:ts#trpc-api --no-interactive --name=my-app-api --auth=iam --prefer-install-dependencies=false', pm)} && \\\\\n ${buildNxCommand('g @aws/nx-plugin:ts#react-website --no-interactive --name=my-app-website --prefer-install-dependencies=false', pm)} && \\\\\n ${buildNxCommand('g @aws/nx-plugin:connection --no-interactive --sourceProject=@my-app/my-app-website --targetProject=@my-app/my-app-api --prefer-install-dependencies=false', pm)} && \\\\\n ${buildNxCommand('g @aws/nx-plugin:ts#infra --no-interactive --name=infra', pm)} && \\\\\n ${buildNxCommand('sync', pm)}\n \\`\\`\\``,\n).join('\\n')}\n\n- **\\`--prefer-install-dependencies=false\\`** asks a generator to defer its dependency install so the batch installs once at the end (the final generator above omits the flag and installs everything).\n- **\\`nx sync\\`** is required before building — generators modify TypeScript project references.\n\n## Detailed Guides\n\nPlease refer to the below documentation for important details regarding workspaces and working with TypeScript or Python projects.\n\n${await fetchGuidePages(['workspace', 'typescript-project', 'python-project'], generators)}\n\n `,\n },\n ],\n }),\n );\n};\n"],"names":["IAC_PROVIDERS","buildNxCommand","fetchGuidePages","PACKAGE_MANAGERS","TOOL_SELECTION_GUIDE","addGeneralGuidanceTool","server","generators","registerTool","title","description","content","type","text","join","map","pm"],"mappings":"AAAA;;;CAGC,GAGD,SAASA,aAAa,QAAQ,+BAA+B;AAC7D,SAASC,cAAc,EAAEC,eAAe,QAAQ,uBAAuB;AACvE,SAASC,gBAAgB,QAAQ,eAAe;AAEhD,OAAO,MAAMC,uBAAuB,CAAC;;;;;;;+FAO0D,CAAC,CAAC;AAEjG;;CAEC,GACD,OAAO,MAAMC,yBAAyB,CACpCC,QACAC;IAEAD,OAAOE,YAAY,CACjB,oBACA;QACEC,OAAO;QACPC,aACE;IACJ,GACA,UAAa,CAAA;YACXC,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC;;AAEjB,EAAET,qBAAqB;;;;yDAIkC,EAAED,iBAAiBW,IAAI,CAAC,MAAM;+EACR,EAAEd,cAAcc,IAAI,CAAC,MAAM;;;;;;;AAO1G,EAAEX,iBAAiBY,GAAG,CAAC,CAACC,KAAOf,eAAe,aAAae,KAAKF,IAAI,CAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqC9E,EAAEX,iBAAiBY,GAAG,CACpB,CAACC,KAAO,CAAC;EACT,EAAEf,eAAe,kHAAkHe,IAAI;IACrI,EAAEf,eAAe,gHAAgHe,IAAI;IACrI,EAAEf,eAAe,8JAA8Je,IAAI;IACnL,EAAEf,eAAe,2DAA2De,IAAI;IAChF,EAAEf,eAAe,QAAQe,IAAI;QACzB,CAAC,EACPF,IAAI,CAAC,MAAM;;;;;;;;;AASb,EAAE,MAAMZ,gBAAgB;wBAAC;wBAAa;wBAAsB;qBAAiB,EAAEK,YAAY;;IAEvF,CAAC;gBACG;aACD;QACH,CAAA;AAEJ,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/mcp-server/tools/general-guidance.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { NxGeneratorInfo } from '../../utils/generators.js';\nimport { IAC_PROVIDERS } from '../../utils/iac-providers.js';\nimport { buildNxCommand, fetchGuidePages } from '../generator-info.js';\nimport { PACKAGE_MANAGERS } from '../schema.js';\nimport { BEST_PRACTICE_PAGE_NAMES } from './best-practices.js';\n\n/**\n * The cross-cutting pages every agent needs regardless of task, inlined here\n * so a workspace's conventions land without a second tool call. The rest are\n * served on demand by `best-practices`.\n */\nconst GENERAL_GUIDANCE_PAGES = [\n 'workspace',\n 'typescript-project',\n 'python-project',\n] as const;\n\nexport const TOOL_SELECTION_GUIDE = `## Tool Selection Guide\n\n- Use the \\`general-guidance\\` tool for guidance and best practices for working with Nx and the Nx Plugin for AWS.\n- Use the \\`best-practices\\` tool for guidance which spans generators rather than applying to one in particular, such as workspace layout, security, runtime configuration, container builds and local development.\n- Use the \\`create-workspace-command\\` tool to discover how to create a workspace to start a new project.\n- Use the \\`add-to-existing-project\\` tool when adding the plugin to an existing Nx workspace or non-Nx monorepo, or when troubleshooting configuration errors in such a workspace.\n- Use the \\`upgrade-workspace\\` tool when upgrading Nx or the Nx Plugin for AWS to a newer version.\n- Use the \\`list-generators\\` tool to discover the available generators and how to run them.\n- Use the \\`generator-guide\\` tool to retrieve detailed information about a specific generator.`;\n\n/**\n * Add a tool which provides general guidance for using Nx and the Nx Plugin for AWS\n */\nexport const addGeneralGuidanceTool = (\n server: McpServer,\n generators: NxGeneratorInfo[],\n) => {\n server.registerTool(\n 'general-guidance',\n {\n title: 'General Guidance',\n description:\n 'Tool for guidance and best practices for working with Nx and the Nx Plugin for AWS',\n },\n async () => ({\n content: [\n {\n type: 'text' as const,\n text: `# Nx Plugin for AWS Guidance\n\n${TOOL_SELECTION_GUIDE}\n\n## Getting Started\n\n- Choose a package manager first. You can choose between ${PACKAGE_MANAGERS.join(', ')}. It's recommended to use \"pnpm\" if the user has no preference\n- Choose an infrastructure as code (IaC) provider next. You can choose between ${IAC_PROVIDERS.join(', ')}. It's recommended to use CDK if the user has no preference\n- Next, you must create an Nx workspace. Use the \\`create-workspace-command\\` tool for more details, and provide it with your chosen package manager\n- After this, you can start scaffolding the main components of your application using generators. Use the \\`list-generators\\` tool to discover available generators, and the \\`generator-guide\\` tool for more detailed information about a specific generator\n\n## Nx Primer\n\n- Prefix nx commands with the appropriate prefix for your package manager, for example:\n${PACKAGE_MANAGERS.map((pm) => buildNxCommand('<options>', pm)).join(' - \\n')}\n- Each project in your workspace has a file named \\`project.json\\` which contains important project information such as its name, and defines the \"targets\" which can be run for that project, for example building or testing the project\n- Use the command \\`nx reset\\` to reset the Nx daemon when unexpected issues arise\n- After adding dependencies between TypeScript projects, use \\`nx sync\\` to ensure project references are set up correctly\n\n## General Instructions\n\n- Each project declares the third-party runtime dependencies its source imports in its own \\`package.json\\`; shared build/test tooling (test runners, bundlers, etc.) is declared in the root \\`package.json\\` \\`devDependencies\\`. Versions follow a single version policy, recorded in the package manager's dependency catalog where supported (referenced as \\`catalog:\\`). Install with the appropriate command for your package manager:\n - Add a project runtime dependency: \\`pnpm add <package> --filter <project>\\` / \\`yarn workspace <project> add <package>\\` / \\`npm install <package> -w <project>\\` / \\`bun add <package> --cwd <project-directory>\\`\n - Add a shared dev tool at the root: \\`pnpm add -Dw <package>\\` / \\`yarn add -D <package>\\` / \\`npm install --legacy-peer-deps -D <package>\\` / \\`bun install -D <package>\\`\n- The \\`noUndeclaredDependencies\\` lint rule enforces that a project's source only imports packages declared in its own \\`package.json\\`\n- Projects in the same workspace can import one another directly by package name (eg \\`@workspace-name/project-name\\`) without declaring a dependency in \\`package.json\\` — TypeScript path aliases in \\`tsconfig.base.json\\` resolve these imports\n- When specifying project names as arguments to generators, prefer the _fully qualified_ project name, for example \\`@workspace-name/project-name\\`. Check the \\`project.json\\` file for the specific package to find its fully qualified name\n- When no generator exists for a specific framework required, use the base \\`ts#project\\` and \\`py#project\\` generators and build on top.\n- Leave the \\`--infra\\` option at its default value unless the user has explicitly instructed otherwise. Generators choose a sensible default type of infrastructure to deploy the project with, so only override \\`--infra\\` when the user has specified a particular requirement.\n\n## Useful Commands\n\n- Fix lint issues with \\`nx run-many --target lint --configuration=fix --all --output-style=stream\\`\n- Build all projects with \\`nx run-many --target build --all --output-style=stream\\`\n- Prefer importing the CDK constructs vended by generators in \\`packages/common/constructs\\` over writing your own\n\n## Best Practices\n\n- After running a generator, use the \\`nx show projects\\` command to check which projects have been added (if any)\n- Carefully examine the files that have been generated and always refer back to the generator guide when working in a generated project\n- Generate all projects into the \\`packages/\\` directory\n- After making changes to your projects, fix linting issues, then run a full build\n- When it's time to start testing a project, suggest to the user that infrastructure is deployed to AWS. For websites, if a runtime-config.json is needed, use the load-runtime-config target after a deployment to point a local website at a sandbox stack.\n- For CDK infrastructure projects, deploy the sandbox stage with the \\`deploy-sandbox\\` target (eg \\`nx deploy-sandbox infra\\`) rather than passing a stage pattern to \\`deploy\\` — it already targets the sandbox stage declared in \\`main.ts\\`. Likewise \\`destroy-sandbox\\` tears that stage back down.\n\n## Batching Generators\n\nWhen scaffolding several projects in one go, chain generators to avoid a slow dependency install after every generator:\n\n- **Chain generators** with \\`&&\\` in a single command. Pass \\`--prefer-install-dependencies=false\\` on each generator except the last so dependencies install once at the end, for example:\n\n${PACKAGE_MANAGERS.map(\n (pm) => ` \\`\\`\\`bash\n ${buildNxCommand('g @aws/nx-plugin:ts#trpc-api --no-interactive --name=my-app-api --auth=iam --prefer-install-dependencies=false', pm)} && \\\\\n ${buildNxCommand('g @aws/nx-plugin:ts#react-website --no-interactive --name=my-app-website --prefer-install-dependencies=false', pm)} && \\\\\n ${buildNxCommand('g @aws/nx-plugin:connection --no-interactive --sourceProject=@my-app/my-app-website --targetProject=@my-app/my-app-api --prefer-install-dependencies=false', pm)} && \\\\\n ${buildNxCommand('g @aws/nx-plugin:ts#infra --no-interactive --name=infra', pm)} && \\\\\n ${buildNxCommand('sync', pm)}\n \\`\\`\\``,\n).join('\\n')}\n\n- **\\`--prefer-install-dependencies=false\\`** asks a generator to defer its dependency install so the batch installs once at the end (the final generator above omits the flag and installs everything).\n- **\\`nx sync\\`** is required before building — generators modify TypeScript project references.\n\n## Detailed Guides\n\nPlease refer to the below documentation for important details regarding workspaces and working with TypeScript or Python projects. Use the \\`best-practices\\` tool for the remaining cross-cutting guides (${BEST_PRACTICE_PAGE_NAMES.filter(\n (p) => !GENERAL_GUIDANCE_PAGES.includes(p as never),\n )\n .map((p) => `\\`${p}\\``)\n .join(', ')}).\n\n${await fetchGuidePages([...GENERAL_GUIDANCE_PAGES], generators)}\n\n `,\n },\n ],\n }),\n );\n};\n"],"names":["IAC_PROVIDERS","buildNxCommand","fetchGuidePages","PACKAGE_MANAGERS","BEST_PRACTICE_PAGE_NAMES","GENERAL_GUIDANCE_PAGES","TOOL_SELECTION_GUIDE","addGeneralGuidanceTool","server","generators","registerTool","title","description","content","type","text","join","map","pm","filter","p","includes"],"mappings":"AAAA;;;CAGC,GAGD,SAASA,aAAa,QAAQ,+BAA+B;AAC7D,SAASC,c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