@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
|
@@ -5,29 +5,31 @@
|
|
|
5
5
|
import { INFRA_APP_GENERATOR_INFO } from "../../../infra/app/generator.js";
|
|
6
6
|
import { formatFilesInSubtree } from "../../../utils/format.js";
|
|
7
7
|
/**
|
|
8
|
-
* Deploy using CloudFormation express mode from the deploy
|
|
9
|
-
*
|
|
8
|
+
* Deploy using CloudFormation express mode from the deploy-sandbox target of
|
|
9
|
+
* ts#infra projects, and wait for full stabilization everywhere else.
|
|
10
10
|
*
|
|
11
|
-
* Express mode completes each resource operation as soon as its configuration
|
|
12
|
-
*
|
|
13
|
-
* iteration cycle for development deploys.
|
|
11
|
+
* Express mode completes each resource operation as soon as its configuration is
|
|
12
|
+
* applied rather than waiting for full stabilization, which is a much faster
|
|
13
|
+
* iteration cycle for development deploys. It returns before resources have
|
|
14
|
+
* settled, so it suits only the stage you iterate on.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*/ const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
* `deploy-sandbox` therefore gets it, since it only ever deploys the sandbox
|
|
17
|
+
* stage. `deploy` names whichever stage you give it, including beta and prod, and
|
|
18
|
+
* `deploy-ci` runs from a pipeline - both wait for full stabilization.
|
|
19
|
+
*/ const EXPRESS_FLAG = '--express';
|
|
20
|
+
const NO_EXPRESS_FLAG = '--no-express';
|
|
21
|
+
/** Whether `deploy-sandbox` should carry the flag, and `deploy` should not. */ const WANTS_EXPRESS = {
|
|
22
|
+
'deploy-sandbox': true,
|
|
23
|
+
deploy: false
|
|
24
|
+
};
|
|
23
25
|
/**
|
|
24
26
|
* Whether the command is one of the deploy commands this migration vends -
|
|
25
27
|
* either a direct `cdk deploy`, or the stage-config `infra-deploy.ts` script
|
|
26
28
|
* that wraps it. Anything else has been hand-written and is reported rather
|
|
27
29
|
* than rewritten.
|
|
28
30
|
*/ const isGeneratedDeployCommand = (command)=>/(^|\s)cdk\s+deploy(\s|$)/.test(command) || command.includes('infra-deploy.ts');
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
const divergedNextStep = (projectName, target, wantsExpress)=>wantsExpress ? `${projectName}: its ${target} target has been customised, so it was left as it is. Add "${EXPRESS_FLAG}" to the target's command to deploy using CloudFormation express mode.` : `${projectName}: its ${target} target has been customised, so it was left as it is. Remove "${EXPRESS_FLAG}" from the target's command so it waits for full resource stabilization - this target can name any stage, including production.`;
|
|
32
|
+
/** Drops the flag wherever it sits, leaving the rest of the command untouched. */ const withoutExpress = (command)=>command.split(/\s+/).filter((arg)=>arg !== EXPRESS_FLAG).join(' ');
|
|
31
33
|
export default async function migration(tree) {
|
|
32
34
|
const nextSteps = [];
|
|
33
35
|
let migrated = false;
|
|
@@ -36,35 +38,31 @@ export default async function migration(tree) {
|
|
|
36
38
|
continue;
|
|
37
39
|
}
|
|
38
40
|
let projectChanged = false;
|
|
39
|
-
for (const targetName of
|
|
41
|
+
for (const [targetName, wantsExpress] of Object.entries(WANTS_EXPRESS)){
|
|
40
42
|
const target = project.targets?.[targetName];
|
|
41
43
|
const command = target?.options?.command;
|
|
42
44
|
if (!target || typeof command !== 'string') {
|
|
43
45
|
continue;
|
|
44
46
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
const args = command.split(/\s+/);
|
|
48
|
+
const hasExpress = args.includes(EXPRESS_FLAG);
|
|
49
|
+
// Already in the wanted state, so re-running - and a project generated
|
|
50
|
+
// after this change - is a no-op.
|
|
51
|
+
if (hasExpress === wantsExpress) {
|
|
48
52
|
continue;
|
|
49
53
|
}
|
|
50
54
|
// `--no-express` is a deliberate opt-out, so honour it rather than
|
|
51
55
|
// flipping the user back to express mode.
|
|
52
|
-
if (
|
|
56
|
+
if (wantsExpress && args.includes(NO_EXPRESS_FLAG)) {
|
|
53
57
|
continue;
|
|
54
58
|
}
|
|
55
59
|
if (!isGeneratedDeployCommand(command)) {
|
|
56
|
-
nextSteps.push(divergedNextStep(name, targetName));
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
// When stages are configured, `deploy` deploys whichever stage is named,
|
|
60
|
-
// including beta and prod, so it stays on full stabilization. Only its
|
|
61
|
-
// sandbox counterpart opts into express mode.
|
|
62
|
-
if (targetName === 'deploy' && isStageConfigDeploy(command)) {
|
|
60
|
+
nextSteps.push(divergedNextStep(name, targetName, wantsExpress));
|
|
63
61
|
continue;
|
|
64
62
|
}
|
|
65
63
|
// Appended last so it stays clear of the stage pattern, which the
|
|
66
64
|
// stage-config deploy script reads from the first positional argument.
|
|
67
|
-
target.options.command = `${command} ${EXPRESS_FLAG}
|
|
65
|
+
target.options.command = wantsExpress ? `${command} ${EXPRESS_FLAG}` : withoutExpress(command);
|
|
68
66
|
projectChanged = true;
|
|
69
67
|
}
|
|
70
68
|
if (projectChanged) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.0.0-rc.94/0001-infra-deploy-express-mode/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n getProjects,\n type MigrationReturnObject,\n type TargetConfiguration,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { INFRA_APP_GENERATOR_INFO } from '../../../infra/app/generator.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\n\n/**\n * Deploy using CloudFormation express mode from the deploy-sandbox target of\n * ts#infra projects, and wait for full stabilization everywhere else.\n *\n * Express mode completes each resource operation as soon as its configuration is\n * applied rather than waiting for full stabilization, which is a much faster\n * iteration cycle for development deploys. It returns before resources have\n * settled, so it suits only the stage you iterate on.\n *\n * `deploy-sandbox` therefore gets it, since it only ever deploys the sandbox\n * stage. `deploy` names whichever stage you give it, including beta and prod, and\n * `deploy-ci` runs from a pipeline - both wait for full stabilization.\n */\n\nconst EXPRESS_FLAG = '--express';\nconst NO_EXPRESS_FLAG = '--no-express';\n\n/** Whether `deploy-sandbox` should carry the flag, and `deploy` should not. */\nconst WANTS_EXPRESS: Record<string, boolean> = {\n 'deploy-sandbox': true,\n deploy: false,\n};\n\n/**\n * Whether the command is one of the deploy commands this migration vends -\n * either a direct `cdk deploy`, or the stage-config `infra-deploy.ts` script\n * that wraps it. Anything else has been hand-written and is reported rather\n * than rewritten.\n */\nconst isGeneratedDeployCommand = (command: string): boolean =>\n /(^|\\s)cdk\\s+deploy(\\s|$)/.test(command) ||\n command.includes('infra-deploy.ts');\n\nconst divergedNextStep = (\n projectName: string,\n target: string,\n wantsExpress: boolean,\n): string =>\n wantsExpress\n ? `${projectName}: its ${target} target has been customised, so it was left as it is. Add \"${EXPRESS_FLAG}\" to the target's command to deploy using CloudFormation express mode.`\n : `${projectName}: its ${target} target has been customised, so it was left as it is. Remove \"${EXPRESS_FLAG}\" from the target's command so it waits for full resource stabilization - this target can name any stage, including production.`;\n\n/** Drops the flag wherever it sits, leaving the rest of the command untouched. */\nconst withoutExpress = (command: string): string =>\n command\n .split(/\\s+/)\n .filter((arg) => arg !== EXPRESS_FLAG)\n .join(' ');\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n const nextSteps: string[] = [];\n let migrated = false;\n\n for (const [name, project] of getProjects(tree)) {\n if (\n (project.metadata as { generator?: string } | undefined)?.generator !==\n INFRA_APP_GENERATOR_INFO.id\n ) {\n continue;\n }\n\n let projectChanged = false;\n\n for (const [targetName, wantsExpress] of Object.entries(WANTS_EXPRESS)) {\n const target: TargetConfiguration | undefined =\n project.targets?.[targetName];\n const command = target?.options?.command;\n if (!target || typeof command !== 'string') {\n continue;\n }\n\n const args = command.split(/\\s+/);\n const hasExpress = args.includes(EXPRESS_FLAG);\n\n // Already in the wanted state, so re-running - and a project generated\n // after this change - is a no-op.\n if (hasExpress === wantsExpress) {\n continue;\n }\n\n // `--no-express` is a deliberate opt-out, so honour it rather than\n // flipping the user back to express mode.\n if (wantsExpress && args.includes(NO_EXPRESS_FLAG)) {\n continue;\n }\n\n if (!isGeneratedDeployCommand(command)) {\n nextSteps.push(divergedNextStep(name, targetName, wantsExpress));\n continue;\n }\n\n // Appended last so it stays clear of the stage pattern, which the\n // stage-config deploy script reads from the first positional argument.\n target.options.command = wantsExpress\n ? `${command} ${EXPRESS_FLAG}`\n : withoutExpress(command);\n projectChanged = true;\n }\n\n if (projectChanged) {\n updateProjectConfiguration(tree, name, project);\n migrated = true;\n }\n }\n\n if (migrated) {\n await formatFilesInSubtree(tree);\n }\n\n return { nextSteps };\n}\n"],"names":["getProjects","updateProjectConfiguration","INFRA_APP_GENERATOR_INFO","formatFilesInSubtree","EXPRESS_FLAG","NO_EXPRESS_FLAG","WANTS_EXPRESS","deploy","isGeneratedDeployCommand","command","test","includes","divergedNextStep","projectName","target","wantsExpress","withoutExpress","split","filter","arg","join","migration","tree","nextSteps","migrated","name","project","metadata","generator","id","projectChanged","targetName","Object","entries","targets","options","args","hasExpress","push"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EAIXC,0BAA0B,QACrB,aAAa;AACpB,SAASC,wBAAwB,QAAQ,kCAAkC;AAC3E,SAASC,oBAAoB,QAAQ,2BAA2B;AAEhE;;;;;;;;;;;;CAYC,GAED,MAAMC,eAAe;AACrB,MAAMC,kBAAkB;AAExB,6EAA6E,GAC7E,MAAMC,gBAAyC;IAC7C,kBAAkB;IAClBC,QAAQ;AACV;AAEA;;;;;CAKC,GACD,MAAMC,2BAA2B,CAACC,UAChC,2BAA2BC,IAAI,CAACD,YAChCA,QAAQE,QAAQ,CAAC;AAEnB,MAAMC,mBAAmB,CACvBC,aACAC,QACAC,eAEAA,eACI,GAAGF,YAAY,MAAM,EAAEC,OAAO,2DAA2D,EAAEV,aAAa,sEAAsE,CAAC,GAC/K,GAAGS,YAAY,MAAM,EAAEC,OAAO,8DAA8D,EAAEV,aAAa,+HAA+H,CAAC;AAEjP,gFAAgF,GAChF,MAAMY,iBAAiB,CAACP,UACtBA,QACGQ,KAAK,CAAC,OACNC,MAAM,CAAC,CAACC,MAAQA,QAAQf,cACxBgB,IAAI,CAAC;AAEV,eAAe,eAAeC,UAC5BC,IAAU;IAEV,MAAMC,YAAsB,EAAE;IAC9B,IAAIC,WAAW;IAEf,KAAK,MAAM,CAACC,MAAMC,QAAQ,IAAI1B,YAAYsB,MAAO;QAC/C,IACE,AAACI,QAAQC,QAAQ,EAAyCC,cAC1D1B,yBAAyB2B,EAAE,EAC3B;YACA;QACF;QAEA,IAAIC,iBAAiB;QAErB,KAAK,MAAM,CAACC,YAAYhB,aAAa,IAAIiB,OAAOC,OAAO,CAAC3B,eAAgB;YACtE,MAAMQ,SACJY,QAAQQ,OAAO,EAAE,CAACH,WAAW;YAC/B,MAAMtB,UAAUK,QAAQqB,SAAS1B;YACjC,IAAI,CAACK,UAAU,OAAOL,YAAY,UAAU;gBAC1C;YACF;YAEA,MAAM2B,OAAO3B,QAAQQ,KAAK,CAAC;YAC3B,MAAMoB,aAAaD,KAAKzB,QAAQ,CAACP;YAEjC,uEAAuE;YACvE,kCAAkC;YAClC,IAAIiC,eAAetB,cAAc;gBAC/B;YACF;YAEA,mEAAmE;YACnE,0CAA0C;YAC1C,IAAIA,gBAAgBqB,KAAKzB,QAAQ,CAACN,kBAAkB;gBAClD;YACF;YAEA,IAAI,CAACG,yBAAyBC,UAAU;gBACtCc,UAAUe,IAAI,CAAC1B,iBAAiBa,MAAMM,YAAYhB;gBAClD;YACF;YAEA,kEAAkE;YAClE,uEAAuE;YACvED,OAAOqB,OAAO,CAAC1B,OAAO,GAAGM,eACrB,GAAGN,QAAQ,CAAC,EAAEL,cAAc,GAC5BY,eAAeP;YACnBqB,iBAAiB;QACnB;QAEA,IAAIA,gBAAgB;YAClB7B,2BAA2BqB,MAAMG,MAAMC;YACvCF,WAAW;QACb;IACF;IAEA,IAAIA,UAAU;QACZ,MAAMrB,qBAAqBmB;IAC7B;IAEA,OAAO;QAAEC;IAAU;AACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.0.0-rc.94/0002-shx-fs-commands/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addDependenciesToPackageJson,\n getProjects,\n type MigrationReturnObject,\n type ProjectConfiguration,\n removeDependenciesFromPackageJson,\n type TargetConfiguration,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\nimport { TS_VERSIONS } from '../../../utils/versions.js';\n\n/**\n * One `shx` replaces the four single purpose filesystem CLIs the targets ran.\n * Its `cp` is several times faster than `ncp` on a large tree, and a single\n * dependency covers every operation the generators vend.\n *\n * `shx cp -R` follows POSIX `cp`, which nests the source inside an existing\n * destination rather than merging into it, so a directory copy becomes\n * `shx cp -R <src>/. <dst>`. That form also copies dotfiles, which a `<src>/*`\n * glob would silently skip — `node_modules/.bin` depends on them. A file copy\n * needs neither, so it stays a plain `shx cp`.\n *\n * Whether an `ncp` copied a file or a directory is not recoverable from the\n * command, so each source is matched against the shapes the generators vend. A\n * command that matches none of them has been edited by the user, and is left\n * alone and reported: rewriting it with the wrong form would either nest a\n * directory a level too deep or fail outright.\n *\n * A `cpy` becomes two commands rather than one joined by `&&`, which is a shell\n * operator and so no more portable than the builtins `shx` replaces.\n */\n\n/** The four CLIs this replaces, dropped from the root manifest. */\nconst REPLACED_PACKAGES = ['ncp', 'rimraf', 'make-dir-cli', 'cpy-cli'];\n\n/**\n * Sources the generators copy as a whole directory. Everything else they copy\n * names a single file, so an unmatched source is neither and is left untouched.\n *\n * - a Python bundle (`bundle-arm`/`bundle-x86`), copied into a package or an\n * image build context\n * - a Python module tree, copied into a code package under its module name\n * - the generated Server SDK, copied into a Smithy API's `src/generated`\n * - `prisma` and Alembic `migrations`, copied into a migration bundle\n */\nconst DIRECTORY_SOURCE = [\n /(^|\\/)bundle-(arm|x86)$/,\n /(^|\\/)build\\/ssdk$/,\n /(^|\\/)prisma$/,\n /(^|\\/)migrations$/,\n];\n\n/**\n * Files the generators copy whose name carries no extension, so the extension\n * test below would otherwise read them as directories. A `Dockerfile` variant is\n * renamed on the way in (`Dockerfile.migration` -> `Dockerfile`), so this matches\n * the source's leading segment rather than the whole name.\n */\nconst EXTENSIONLESS_FILE = /(^|\\/)Dockerfile(\\.[^/]+)?$/;\n\n/**\n * A Python code package copies the project's source root in under the module\n * name, which is the same segment repeated — `.../src/my_agent my_agent`. The\n * source is a directory whose name is the project's, so it is recognised by the\n * destination repeating the source's last segment rather than by a fixed name.\n */\nconst isModuleTreeCopy = (src: string, dst: string): boolean => {\n const segment = src.split('/').pop();\n return (\n !!segment && !segment.includes('.') && dst.split('/').pop() === segment\n );\n};\n\nconst isDirectorySource = (src: string, dst: string): boolean =>\n !EXTENSIONLESS_FILE.test(src) &&\n (DIRECTORY_SOURCE.some((p) => p.test(src)) || isModuleTreeCopy(src, dst));\n\n/**\n * A copy naming a file on both sides, which every other vended `ncp` does. A\n * name carrying an extension is a file — as is a `Dockerfile`, which does not.\n */\nconst isFileCopy = (src: string, dst: string): boolean => {\n const [s, d] = [src.split('/').pop() ?? '', dst.split('/').pop() ?? ''];\n return (\n (s.includes('.') || EXTENSIONLESS_FILE.test(src)) &&\n (d.includes('.') || EXTENSIONLESS_FILE.test(dst))\n );\n};\n\nconst NCP = /^ncp\\s+(\\S+)\\s+(\\S+)$/;\nconst RIMRAF = /^rimraf\\s+(\\S+)$/;\nconst MAKE_DIR = /^make-dir\\s+(\\S+)$/;\n/** The one shape `cpGlobToFile` vends, whose glob is quoted and dest renamed. */\nconst CPY = /^cpy\\s+\"([^\"]+)\"\\s+(\\S+)\\s+--flat\\s+--rename=(\\S+)$/;\n\n/**\n * Rewrite one command into the commands that replace it, or return null to leave\n * it alone. Anything already using `shx` is returned unchanged so a re-run is a\n * no-op.\n */\nconst rewrite = (command: string): string[] | null => {\n const trimmed = command.trim();\n\n const rimraf = RIMRAF.exec(trimmed);\n if (rimraf) return [`shx rm -rf ${rimraf[1]}`];\n\n const makeDir = MAKE_DIR.exec(trimmed);\n if (makeDir) return [`shx mkdir -p ${makeDir[1]}`];\n\n const cpy = CPY.exec(trimmed);\n if (cpy) {\n // `shx cp` writes through to a named destination file and fails if its\n // parent is missing, so the destination directory is a step of its own.\n return [`shx mkdir -p ${cpy[2]}`, `shx cp \"${cpy[1]}\" ${cpy[2]}/${cpy[3]}`];\n }\n\n const ncp = NCP.exec(trimmed);\n if (ncp) {\n const [, src, dst] = ncp;\n if (isDirectorySource(src, dst)) return [`shx cp -R ${src}/. ${dst}`];\n if (isFileCopy(src, dst)) return [`shx cp ${src} ${dst}`];\n return null;\n }\n\n return null;\n};\n\n/** Whether a command is one this migration is responsible for rewriting. */\nconst isReplacedCommand = (command: string): boolean =>\n /^(ncp|rimraf|make-dir|cpy)\\s/.test(command.trim());\n\nconst divergedStep = (\n projectName: string,\n targetName: string,\n command: string,\n) =>\n `${projectName}:${targetName}: left \\`${command}\\` untouched - it does not match a copy the generator produced, so whether it copies a file or a directory could not be determined. Replace it by hand with \\`shx cp <src> <dst>\\` for a file, or \\`shx cp -R <src>/. <dst>\\` for a directory (the trailing \\`/.\\` merges the contents instead of nesting the directory inside the destination).`;\n\n/**\n * Rewrite every command a target runs, in place. Commands are either strings or\n * `{ command }` objects, and a target uses `command` for a single one.\n *\n * One command can become several, which are steps of the same operation and so\n * must run in order — the target is pinned to `parallel: false` when that\n * happens.\n */\nconst migrateTarget = (\n projectName: string,\n targetName: string,\n target: TargetConfiguration,\n nextSteps: string[],\n): boolean => {\n const options = target.options as\n | { command?: unknown; commands?: unknown; parallel?: unknown }\n | undefined;\n if (!options) return false;\n\n let changed = false;\n let split = false;\n\n /** The commands replacing one, or the original where it is left alone. */\n const rewriteOne = (command: string): string[] => {\n if (!isReplacedCommand(command)) return [command];\n const replacement = rewrite(command);\n if (replacement === null) {\n nextSteps.push(divergedStep(projectName, targetName, command.trim()));\n return [command];\n }\n changed = true;\n if (replacement.length > 1) split = true;\n return replacement;\n };\n\n if (typeof options.command === 'string') {\n const replacement = rewriteOne(options.command);\n if (replacement.length > 1) {\n // `commands` is the only option that runs more than one.\n delete options.command;\n options.commands = replacement;\n } else {\n options.command = replacement[0];\n }\n } else if (Array.isArray(options.commands)) {\n options.commands = options.commands.flatMap((entry) => {\n if (typeof entry === 'string') return rewriteOne(entry);\n if (\n entry &&\n typeof entry === 'object' &&\n typeof (entry as { command?: unknown }).command === 'string'\n ) {\n const e = entry as { command: string };\n return rewriteOne(e.command).map((command) => ({ ...e, command }));\n }\n return [entry];\n });\n }\n\n if (split) options.parallel = false;\n\n return changed;\n};\n\n/** Every command every target in the workspace runs. */\nconst allCommands = (tree: Tree): string[] => {\n const commands: string[] = [];\n for (const [, project] of getProjects(tree)) {\n for (const target of Object.values(project.targets ?? {})) {\n const options = target.options as\n | { command?: unknown; commands?: unknown }\n | undefined;\n if (typeof options?.command === 'string') commands.push(options.command);\n if (Array.isArray(options?.commands)) {\n for (const entry of options.commands) {\n if (typeof entry === 'string') commands.push(entry);\n else if (\n typeof (entry as { command?: unknown })?.command === 'string'\n )\n commands.push((entry as { command: string }).command);\n }\n }\n }\n }\n return commands;\n};\n\n/** The CLI a package provides, as the rewritten commands would name it. */\nconst CLI_NAME: Record<string, string> = {\n ncp: 'ncp',\n rimraf: 'rimraf',\n 'make-dir-cli': 'make-dir',\n 'cpy-cli': 'cpy',\n};\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n const nextSteps: string[] = [];\n\n for (const [projectName, project] of getProjects(tree)) {\n let changed = false;\n\n for (const [targetName, target] of Object.entries(project.targets ?? {})) {\n changed =\n migrateTarget(projectName, targetName, target, nextSteps) || changed;\n }\n\n if (changed) {\n updateProjectConfiguration(\n tree,\n projectName,\n project as ProjectConfiguration,\n );\n }\n }\n\n addDependenciesToPackageJson(tree, {}, { shx: TS_VERSIONS.shx });\n\n // Only the CLIs nothing runs any more: a command this migration declined to\n // rewrite, or one the user added, still needs the package it calls.\n const commands = allCommands(tree);\n const unused = REPLACED_PACKAGES.filter(\n (pkg) =>\n !commands.some((c) =>\n new RegExp(`(^|[^\\\\w-])${CLI_NAME[pkg]}\\\\s`).test(c),\n ),\n );\n removeDependenciesFromPackageJson(tree, unused, unused);\n\n await formatFilesInSubtree(tree);\n\n return { nextSteps };\n}\n"],"names":["addDependenciesToPackageJson","getProjects","removeDependenciesFromPackageJson","updateProjectConfiguration","formatFilesInSubtree","TS_VERSIONS","REPLACED_PACKAGES","DIRECTORY_SOURCE","EXTENSIONLESS_FILE","isModuleTreeCopy","src","dst","segment","split","pop","includes","isDirectorySource","test","some","p","isFileCopy","s","d","NCP","RIMRAF","MAKE_DIR","CPY","rewrite","command","trimmed","trim","rimraf","exec","makeDir","cpy","ncp","isReplacedCommand","divergedStep","projectName","targetName","migrateTarget","target","nextSteps","options","changed","rewriteOne","replacement","push","length","commands","Array","isArray","flatMap","entry","e","map","parallel","allCommands","tree","project","Object","values","targets","CLI_NAME","migration","entries","shx","unused","filter","pkg","c","RegExp"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAC5BC,WAAW,EAGXC,iCAAiC,EAGjCC,0BAA0B,QACrB,aAAa;AACpB,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,WAAW,QAAQ,6BAA6B;AAEzD;;;;;;;;;;;;;;;;;;;CAmBC,GAED,iEAAiE,GACjE,MAAMC,oBAAoB;IAAC;IAAO;IAAU;IAAgB;CAAU;AAEtE;;;;;;;;;CASC,GACD,MAAMC,mBAAmB;IACvB;IACA;IACA;IACA;CACD;AAED;;;;;CAKC,GACD,MAAMC,qBAAqB;AAE3B;;;;;CAKC,GACD,MAAMC,mBAAmB,CAACC,KAAaC;IACrC,MAAMC,UAAUF,IAAIG,KAAK,CAAC,KAAKC,GAAG;IAClC,OACE,CAAC,CAACF,WAAW,CAACA,QAAQG,QAAQ,CAAC,QAAQJ,IAAIE,KAAK,CAAC,KAAKC,GAAG,OAAOF;AAEpE;AAEA,MAAMI,oBAAoB,CAACN,KAAaC,MACtC,CAACH,mBAAmBS,IAAI,CAACP,QACxBH,CAAAA,iBAAiBW,IAAI,CAAC,CAACC,IAAMA,EAAEF,IAAI,CAACP,SAASD,iBAAiBC,KAAKC,IAAG;AAEzE;;;CAGC,GACD,MAAMS,aAAa,C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AAI;YACxElB,UACEJ,cAAcF,aAAaC,YAAYE,QAAQC,cAAcE;QACjE;QAEA,IAAIA,SAAS;YACXzC,2BACEuD,MACApB,aACAqB;QAEJ;IACF;IAEA3D,6BAA6B0D,MAAM,CAAC,GAAG;QAAEQ,KAAK7D,YAAY6D,GAAG;IAAC;IAE9D,4EAA4E;IAC5E,oEAAoE;IACpE,MAAMjB,WAAWQ,YAAYC;IAC7B,MAAMS,SAAS7D,kBAAkB8D,MAAM,CACrC,CAACC,MACC,CAACpB,SAAS/B,IAAI,CAAC,CAACoD,IACd,IAAIC,OAAO,CAAC,WAAW,EAAER,QAAQ,CAACM,IAAI,CAAC,GAAG,CAAC,EAAEpD,IAAI,CAACqD;IAGxDpE,kCAAkCwD,MAAMS,QAAQA;IAEhD,MAAM/D,qBAAqBsD;IAE3B,OAAO;QAAEhB;IAAU;AACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.0.0-rc.94/0003-agent-core-vendor-target/migration.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 joinPathFragments,\n type MigrationReturnObject,\n type ProjectConfiguration,\n type TargetConfiguration,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport {\n ADOT_VENDOR_TARGET_NAME,\n adotVendorDir,\n} from '../../../utils/agent-core-packaging.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\n\n/**\n * A TypeScript AgentCore code package installed the AWS Distro for OpenTelemetry\n * into the package directory as its last packaging step. That target's `inputs`\n * are the project's source, so editing an agent re-ran the install — several\n * seconds of npm work whose result depends only on the pinned ADOT version.\n *\n * The install moves to its own target Nx caches independently. It declares no\n * `inputs`, since the version it pins is part of the command and Nx hashes a\n * target's configuration, so a version bump still invalidates it while a source\n * edit no longer does. Packaging copies the vendored tree instead.\n *\n * The vendor directory is a sibling of the package directory, not a path inside\n * it: Nx replaces a cached target's whole declared output directory on restore,\n * so nesting one target's output inside another's makes each wipe the other's\n * work on a cache hit.\n *\n * A packaging target that no longer matches the shape the generator vended has\n * been reworked by the user, so it is left untouched and reported.\n *\n * The filesystem commands are spelled with `shx`: the migration that replaced the\n * single purpose CLIs was committed first, and `latest` migrations run in the\n * order their folders were committed, so it has already run by the time this one\n * does.\n */\n\n/** The ADOT install as the packaging target ran it, capturing its `--prefix`. */\nconst ADOT_INSTALL =\n /^npm install --prefix (\\S+) .*@aws\\/aws-distro-opentelemetry-node-autoinstrumentation@(\\S+)\\s*$/;\n\nconst divergedStep = (projectName: string, targetName: string) =>\n `${projectName}:${targetName}: installs the OpenTelemetry distro but no longer matches the shape the generator produced - left untouched. To stop the install re-running whenever the project's source changes, move it to its own target with no \\`inputs\\` and an \\`outputs\\` directory outside this target's, and copy that directory in here instead.`;\n\n/** Commands a target runs, as plain strings. */\nconst commandsOf = (target: TargetConfiguration): string[] => {\n const { commands } = (target.options ?? {}) as { commands?: unknown };\n return Array.isArray(commands)\n ? commands.filter((c): c is string => typeof c === 'string')\n : [];\n};\n\n/**\n * Copy the vendored `node_modules` into the package. `-R` and the trailing `/.`\n * merge the directory's contents rather than nesting it inside the destination.\n */\nconst copyCommand = (vendorDir: string, packageDir: string): string =>\n `shx cp -R ${joinPathFragments(vendorDir, 'node_modules')}/. ${joinPathFragments(packageDir, 'node_modules')}`;\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n const nextSteps: string[] = [];\n\n for (const [projectName, project] of getProjects(tree)) {\n let changed = false;\n const vendorDir = adotVendorDir(project.root);\n\n for (const [targetName, target] of Object.entries(project.targets ?? {})) {\n if (targetName === ADOT_VENDOR_TARGET_NAME) continue;\n\n const commands = commandsOf(target);\n const installIndex = commands.findIndex((c) => ADOT_INSTALL.test(c));\n if (installIndex < 0) continue;\n\n const install = commands[installIndex];\n const [, prefix] = ADOT_INSTALL.exec(install)!;\n\n // The install targets the directory this target packages into, and it\n // copies the bundle in with shx. Anything else has been reworked.\n const packageDir = prefix;\n const copiesBundle = commands.some(\n (c) => c !== install && c.startsWith('shx cp '),\n );\n const declaresPackageOutput = (target.outputs ?? []).some((o) =>\n o.endsWith(packageDir),\n );\n if (!copiesBundle || !declaresPackageOutput) {\n nextSteps.push(divergedStep(projectName, targetName));\n continue;\n }\n\n project.targets![ADOT_VENDOR_TARGET_NAME] ??= {\n cache: true,\n inputs: [],\n outputs: [`{workspaceRoot}/${vendorDir}`],\n executor: 'nx:run-commands',\n options: {\n commands: [\n `shx rm -rf ${vendorDir}`,\n `shx mkdir -p ${vendorDir}`,\n install.replace(prefix, vendorDir),\n ],\n parallel: false,\n },\n };\n\n const updated = [...commands];\n updated[installIndex] = copyCommand(vendorDir, packageDir);\n target.options!.commands = updated;\n target.dependsOn = [\n ...(target.dependsOn ?? []),\n ADOT_VENDOR_TARGET_NAME,\n ].filter((d, i, all) => all.indexOf(d) === i);\n\n changed = true;\n }\n\n if (changed) {\n updateProjectConfiguration(\n tree,\n projectName,\n project as ProjectConfiguration,\n );\n }\n }\n\n await formatFilesInSubtree(tree);\n\n return { nextSteps };\n}\n"],"names":["getProjects","joinPathFragments","updateProjectConfiguration","ADOT_VENDOR_TARGET_NAME","adotVendorDir","formatFilesInSubtree","ADOT_INSTALL","divergedStep","projectName","targetName","commandsOf","target","commands","options","Array","isArray","filter","c","copyCommand","vendorDir","packageDir","migration","tree","nextSteps","project","changed","root","Object","entries","targets","installIndex","findIndex","test","install","prefix","exec","copiesBundle","some","startsWith","declaresPackageOutput","outputs","o","endsWith","push","cache","inputs","executor","replace","parallel","updated","dependsOn","d","i","all","indexOf"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EACXC,iBAAiB,EAKjBC,0BAA0B,QACrB,aAAa;AACpB,SACEC,uBAAuB,EACvBC,aAAa,QACR,yCAAyC;AAChD,SAASC,oBAAoB,QAAQ,2BAA2B;AAEhE;;;;;;;;;;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AAAD,EAAGH,IAAI,CAAC,CAACI,IACzDA,EAAEC,QAAQ,CAACtB;YAEb,IAAI,CAACgB,gBAAgB,CAACG,uBAAuB;gBAC3ChB,UAAUoB,IAAI,CAACpC,aAAaC,aAAaC;gBACzC;YACF;YAEAe,QAAQK,OAAO,AAAC,CAAC1B,wBAAwB,KAAK;gBAC5CyC,OAAO;gBACPC,QAAQ,EAAE;gBACVL,SAAS;oBAAC,CAAC,gBAAgB,EAAErB,WAAW;iBAAC;gBACzC2B,UAAU;gBACVjC,SAAS;oBACPD,UAAU;wBACR,CAAC,WAAW,EAAEO,WAAW;wBACzB,CAAC,aAAa,EAAEA,WAAW;wBAC3Bc,QAAQc,OAAO,CAACb,QAAQf;qBACzB;oBACD6B,UAAU;gBACZ;YACF;YAEA,MAAMC,UAAU;mBAAIrC;aAAS;YAC7BqC,OAAO,CAACnB,aAAa,GAAGZ,YAAYC,WAAWC;YAC/CT,OAAOE,OAAO,CAAED,QAAQ,GAAGqC;YAC3BtC,OAAOuC,SAAS,GAAG;mBACbvC,OAAOuC,SAAS,IAAI,EAAE;gBAC1B/C;aACD,CAACa,MAAM,CAAC,CAACmC,GAAGC,GAAGC,MAAQA,IAAIC,OAAO,CAACH,OAAOC;YAE3C3B,UAAU;QACZ;QAEA,IAAIA,SAAS;YACXvB,2BACEoB,MACAd,aACAgB;QAEJ;IACF;IAEA,MAAMnB,qBAAqBiB;IAE3B,OAAO;QAAEC;IAAU;AACrB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { type MigrationReturnObject, type Tree } from '@nx/devkit';
|
|
6
|
+
export default function migration(tree: Tree): Promise<MigrationReturnObject>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.0.0-rc.95/0001-rolldown-config-bundle-transient/migration.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 joinPathFragments,\n type MigrationReturnObject,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport {\n BIOME_ROLLDOWN_CONFIG_BUNDLE_EXCLUDE,\n formatFilesInSubtree,\n ROLLDOWN_CONFIG_BUNDLE_GLOB,\n} from '../../../utils/format.js';\nimport { updateGitIgnore } from '../../../utils/git.js';\n\n/**\n * Keep rolldown's transient config bundle out of Biome's and git's reach.\n *\n * Loading a `rolldown.config.ts` bundles it to `rolldown.config.<hash>.js` in the\n * config's own directory, imports it, then unlinks it. The `bundle`, `format` and\n * `lint` targets of a project all run concurrently, so a `format` sweeping the\n * project mid-bundle sees a machine-generated file and reports it unformatted —\n * failing the target for no fault of the source. Being git-visible, the file\n * could also be committed, or picked up by `license#sync`, which builds its\n * candidate set from git-visible files rather than from `biome.json`.\n *\n * Guardrails:\n * - The Biome exclude is anchored to the excludes we vend. A workspace whose\n * `files.includes` has diverged keeps its own list, and is reported via\n * `nextSteps` instead.\n * - Only projects carrying a `rolldown.config.ts` get the git ignore, matching\n * where the generator writes it.\n * - Idempotent: both edits are guarded on the pattern already being present.\n */\n\n/** The config filename whose loading produces the transient bundle. */\nconst ROLLDOWN_CONFIG = 'rolldown.config.ts';\n\n/**\n * Exclude the transient bundle from Biome. Anchored to `!**\\/out-tsc`, the\n * build-output exclude the vended list places these next to — without it the list\n * has diverged from the one we vend, so leave it to the user.\n */\nconst excludeFromBiome = (tree: Tree): string[] => {\n if (!tree.exists('biome.json')) {\n return [];\n }\n let unrecognised = false;\n updateJson(tree, 'biome.json', (biome) => {\n const includes: unknown = biome?.files?.includes;\n if (\n !Array.isArray(includes) ||\n includes.includes(BIOME_ROLLDOWN_CONFIG_BUNDLE_EXCLUDE)\n ) {\n return biome;\n }\n if (!includes.includes('!**/out-tsc')) {\n unrecognised = true;\n return biome;\n }\n return {\n ...biome,\n files: {\n ...biome.files,\n includes: includes.flatMap((include) =>\n include === '!**/out-tsc'\n ? [include, BIOME_ROLLDOWN_CONFIG_BUNDLE_EXCLUDE]\n : [include],\n ),\n },\n };\n });\n return unrecognised\n ? [\n `\\`biome.json\\`: add \\`\"${BIOME_ROLLDOWN_CONFIG_BUNDLE_EXCLUDE}\"\\` to \\`files.includes\\` so the transient bundle rolldown writes while loading a TypeScript config is never formatted or linted. Its \\`files.includes\\` has diverged from the vended list, so it was left as it is.`,\n ]\n : [];\n};\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n const nextSteps: string[] = [...excludeFromBiome(tree)];\n\n for (const [, project] of getProjects(tree)) {\n if (!tree.exists(joinPathFragments(project.root, ROLLDOWN_CONFIG))) {\n continue;\n }\n updateGitIgnore(tree, project.root, (patterns) =>\n patterns.includes(ROLLDOWN_CONFIG_BUNDLE_GLOB)\n ? patterns\n : [...patterns, ROLLDOWN_CONFIG_BUNDLE_GLOB],\n );\n }\n\n await formatFilesInSubtree(tree);\n\n return { nextSteps };\n}\n"],"names":["getProjects","joinPathFragments","updateJson","BIOME_ROLLDOWN_CONFIG_BUNDLE_EXCLUDE","formatFilesInSubtree","ROLLDOWN_CONFIG_BUNDLE_GLOB","updateGitIgnore","ROLLDOWN_CONFIG","excludeFromBiome","tree","exists","unrecognised","biome","includes","files","Array","isArray","flatMap","include","migration","nextSteps","project","root","patterns"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EACXC,iBAAiB,EAGjBC,UAAU,QACL,aAAa;AACpB,SACEC,oCAAoC,EACpCC,oBAAoB,EACpBC,2BAA2B,QACtB,2BAA2B;AAClC,SAASC,eAAe,QAAQ,wBAAwB;AAExD;;;;;;;;;;;;;;;;;;CAkBC,GAED,qEAAqE,GACrE,MAAMC,kBAAkB;AAExB;;;;CAIC,GACD,MAAMC,mBAAmB,CAACC;IACxB,IAAI,CAACA,KAAKC,MAAM,CAAC,eAAe;QAC9B,OAAO,EAAE;IACX;IACA,IAAIC,eAAe;IACnBT,WAAWO,MAAM,cAAc,CAACG;QAC9B,MAAMC,WAAoBD,OAAOE,OAAOD;QACxC,IACE,CAACE,MAAMC,OAAO,CAACH,aACfA,SAASA,QAAQ,CAACV,uCAClB;YACA,OAAOS;QACT;QACA,IAAI,CAACC,SAASA,QAAQ,CAAC,gBAAgB;YACrCF,eAAe;YACf,OAAOC;QACT;QACA,OAAO;YACL,GAAGA,KAAK;YACRE,OAAO;gBACL,GAAGF,MAAME,KAAK;gBACdD,UAAUA,SAASI,OAAO,CAAC,CAACC,UAC1BA,YAAY,gBACR;wBAACA;wBAASf;qBAAqC,GAC/C;wBAACe;qBAAQ;YAEjB;QACF;IACF;IACA,OAAOP,eACH;QACE,CAAC,uBAAuB,EAAER,qCAAqC,oNAAoN,CAAC;KACrR,GACD,EAAE;AACR;AAEA,eAAe,eAAegB,UAC5BV,IAAU;IAEV,MAAMW,YAAsB;WAAIZ,iBAAiBC;KAAM;IAEvD,KAAK,MAAM,GAAGY,QAAQ,IAAIrB,YAAYS,MAAO;QAC3C,IAAI,CAACA,KAAKC,MAAM,CAACT,kBAAkBoB,QAAQC,IAAI,EAAEf,mBAAmB;YAClE;QACF;QACAD,gBAAgBG,MAAMY,QAAQC,IAAI,EAAE,CAACC,WACnCA,SAASV,QAAQ,CAACR,+BACdkB,WACA;mBAAIA;gBAAUlB;aAA4B;IAElD;IAEA,MAAMD,qBAAqBK;IAE3B,OAAO;QAAEW;IAAU;AACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.0.0-rc.95/0002-agent-connection-pin-strands-peers/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { joinPathFragments, type Tree } from '@nx/devkit';\nimport { AGENT_CONNECTION_PROJECT_DIR } from '../../../utils/agent-connection/agent-connection.js';\nimport { addDependenciesToPackageJson } from '../../../utils/dependencies.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\nimport { TS_VERSIONS } from '../../../utils/versions.js';\n\nconst CLIENT_S3 = '@aws-sdk/client-s3';\nconst STRANDS_SDK = '@strands-agents/sdk';\n\n/**\n * `@aws-sdk/client-s3` is an optional peer of `@strands-agents/sdk` that the\n * shared agent-connection project never imports, so it went undeclared. pnpm\n * then auto-installs its own copy there while a project that does declare it\n * gets the catalog's, and those two resolutions give `@strands-agents/sdk` two\n * peer-suffixed instances of the same version.\n *\n * Anything importing both projects then sees two nominal identities of every SDK\n * type — `Agent`, `McpClient`, `Plugin` — and fails to compile with \"Types have\n * separate declarations of a private property\". Declaring it keeps the version\n * on the catalog, collapsing both to one instance.\n */\nexport default async function migration(tree: Tree): Promise<void> {\n const packageJsonPath = joinPathFragments(\n AGENT_CONNECTION_PROJECT_DIR,\n 'package.json',\n );\n if (!tree.exists(packageJsonPath)) {\n return;\n }\n\n // Only where a strands client is actually present — that is what pulls the peer.\n const packageJson = JSON.parse(tree.read(packageJsonPath, 'utf-8') ?? '{}');\n if (!packageJson.dependencies?.[STRANDS_SDK]) {\n return;\n }\n\n addDependenciesToPackageJson(\n tree,\n { [CLIENT_S3]: TS_VERSIONS[CLIENT_S3] },\n {},\n packageJsonPath,\n );\n\n await formatFilesInSubtree(tree);\n}\n"],"names":["joinPathFragments","AGENT_CONNECTION_PROJECT_DIR","addDependenciesToPackageJson","formatFilesInSubtree","TS_VERSIONS","CLIENT_S3","STRANDS_SDK","migration","tree","packageJsonPath","exists","packageJson","JSON","parse","read","dependencies"],"mappings":"AAAA;;;CAGC,GACD,SAASA,iBAAiB,QAAmB,aAAa;AAC1D,SAASC,4BAA4B,QAAQ,sDAAsD;AACnG,SAASC,4BAA4B,QAAQ,iCAAiC;AAC9E,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,WAAW,QAAQ,6BAA6B;AAEzD,MAAMC,YAAY;AAClB,MAAMC,cAAc;AAEpB;;;;;;;;;;;CAWC,GACD,eAAe,eAAeC,UAAUC,IAAU;IAChD,MAAMC,kBAAkBT,kBACtBC,8BACA;IAEF,IAAI,CAACO,KAAKE,MAAM,CAACD,kBAAkB;QACjC;IACF;IAEA,iFAAiF;IACjF,MAAME,cAAcC,KAAKC,KAAK,CAACL,KAAKM,IAAI,CAACL,iBAAiB,YAAY;IACtE,IAAI,CAACE,YAAYI,YAAY,EAAE,CAACT,YAAY,EAAE;QAC5C;IACF;IAEAJ,6BACEM,MACA;QAAE,CAACH,UAAU,EAAED,WAAW,CAACC,UAAU;IAAC,GACtC,CAAC,GACDI;IAGF,MAAMN,qBAAqBK;AAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.0.0-rc.95/0003-ignore-package-manager-temp-files/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { Tree } from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\nimport { updateGitIgnore } from '../../../utils/git.js';\n\n/** The temporary files pnpm writes while materialising packages. */\nconst TEMP_FILE_PATTERN = '_tmp_*';\n\n/**\n * pnpm creates `_tmp_<pid>_<hash>` files at the workspace root while it\n * materialises packages. Left unignored, Nx's watcher invalidates the project\n * graph on every install, so a watch-mode `dev` target running at the time\n * rebuilds the graph continuously and never starts the command it wraps.\n */\nexport default async function migration(tree: Tree): Promise<void> {\n // Only pnpm writes these, so key off its lockfile rather than the workspace\n // file — a workspace on another package manager may still carry one.\n if (!tree.exists('pnpm-lock.yaml')) {\n return;\n }\n\n updateGitIgnore(tree, '.', (patterns) =>\n patterns.includes(TEMP_FILE_PATTERN)\n ? patterns\n : [...patterns, TEMP_FILE_PATTERN],\n );\n\n await formatFilesInSubtree(tree);\n}\n"],"names":["formatFilesInSubtree","updateGitIgnore","TEMP_FILE_PATTERN","migration","tree","exists","patterns","includes"],"mappings":"AAAA;;;CAGC,GAED,SAASA,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,eAAe,QAAQ,wBAAwB;AAExD,kEAAkE,GAClE,MAAMC,oBAAoB;AAE1B;;;;;CAKC,GACD,eAAe,eAAeC,UAAUC,IAAU;IAChD,4EAA4E;IAC5E,qEAAqE;IACrE,IAAI,CAACA,KAAKC,MAAM,CAAC,mBAAmB;QAClC;IACF;IAEAJ,gBAAgBG,MAAM,KAAK,CAACE,WAC1BA,SAASC,QAAQ,CAACL,qBACdI,WACA;eAAIA;YAAUJ;SAAkB;IAGtC,MAAMF,qBAAqBI;AAC7B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { type MigrationReturnObject, type Tree } from '@nx/devkit';
|
|
6
|
+
export default function migration(tree: Tree): Promise<MigrationReturnObject>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.0.0-rc.95/0004-shadcn-package-imports-exports/migration.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 joinPathFragments,\n type MigrationReturnObject,\n readJson,\n type Tree,\n updateJson,\n} from '@nx/devkit';\nimport { REACT_WEBSITE_APP_GENERATOR_INFO } from '../../../ts/react-website/app/generator.js';\nimport { applyGritQL, matchGritQL } from '../../../utils/ast.js';\nimport {\n addDependenciesToPackageJson,\n getLocalDependencySpecifier,\n} from '../../../utils/dependencies.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\nimport {\n PACKAGES_DIR,\n SHARED_SHADCN_DIR,\n} from '../../../utils/shared-constructs-constants.js';\nimport { getSharedShadcnFullyQualifiedName } from '../../../utils/shared-shadcn.js';\n\n/**\n * Move the shared shadcn package off a `tsconfig.base.json` `paths` alias onto\n * `package.json` `imports`/`exports`.\n *\n * shadcn 4.x's CLI resolves `components.json`'s aliases via Node's package\n * resolution (`imports`/`exports`), not tsconfig `paths` - its own resolver\n * naively joins a tsconfig-declared alias against whichever directory it's\n * invoked from, so the repo-root-relative `paths` mapping this plugin used to\n * vend breaks the moment `shadcn add` is run with `-c packages/common/shadcn`\n * (as its own monorepo-root preflight now tells the user to). This migration\n * carries an existing workspace onto the shape today's generators produce:\n * local `#...` imports for the package's own internal component references,\n * a public `exports` map for every other consumer, and a real `workspace:*`\n * dependency on each consumer so that map actually resolves.\n *\n * How to write a migration:\n * - https://nx.dev/docs/kb/migration-generators\n * - What `nextSteps` means: https://nx.dev/docs/reference/devkit/MigrationReturnObject\n *\n * Guardrails:\n * - Only touches a `packages/common/shadcn` this plugin's generators produced\n * (guarded by `components.json`'s aliases still matching the old shape).\n * - Internal imports are rewritten by exact module specifier per file found\n * under `src/{components/ui,lib,hooks}`, so a component a user added by hand\n * after the original generation is covered too, and a specifier the\n * migration doesn't recognise is left alone and reported.\n * - Idempotent: every write is guarded by the old shape still being present.\n */\n\nconst libraryRoot = joinPathFragments(PACKAGES_DIR, SHARED_SHADCN_DIR);\nconst componentsJsonPath = joinPathFragments(libraryRoot, 'components.json');\nconst packageJsonPath = joinPathFragments(libraryRoot, 'package.json');\n\ninterface ComponentsJsonAliases {\n readonly components?: string;\n readonly utils?: string;\n readonly hooks?: string;\n readonly lib?: string;\n readonly ui?: string;\n}\n\nconst oldAliases = (fqn: string): ComponentsJsonAliases => ({\n components: `${fqn}/components`,\n utils: `${fqn}/lib/utils`,\n hooks: `${fqn}/hooks`,\n lib: `${fqn}/lib`,\n ui: `${fqn}/components/ui`,\n});\n\nconst newAliases: Required<ComponentsJsonAliases> = {\n components: '#components',\n utils: '#lib/utils',\n hooks: '#hooks',\n lib: '#lib',\n ui: '#components/ui',\n};\n\nconst newPackageManifestFields = {\n imports: {\n '#components/*': './src/components/*.tsx',\n '#lib/*': './src/lib/*.ts',\n '#hooks/*': './src/hooks/*.ts',\n },\n exports: {\n '.': './src/index.ts',\n './styles/*': './src/styles/*',\n './components/*': './src/components/*.tsx',\n './lib/*': './src/lib/*.ts',\n './hooks/*': './src/hooks/*.ts',\n },\n};\n\n/**\n * Rewrite an import's module specifier, keeping its bindings - `$bindings`\n * holds whatever the file imports, so a binding a user added survives.\n */\nconst importPattern = (from: string, to: string): string =>\n `\\`import { $bindings } from '${from}'\\` => \\`import { $bindings } from '${to}'\\``;\n\n/** Whether the file still imports the old specifier under any other form. */\nconst hasRemainingImport = (from: string): string =>\n `\\`import $_ from '${from}'\\``;\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n const nextSteps: string[] = [];\n\n if (!tree.exists(componentsJsonPath) || !tree.exists(packageJsonPath)) {\n return { nextSteps };\n }\n\n const fullyQualifiedName = getSharedShadcnFullyQualifiedName(tree);\n const currentAliases =\n readJson<{ aliases?: ComponentsJsonAliases }>(tree, componentsJsonPath)\n .aliases ?? {};\n const expectedOldAliases = oldAliases(fullyQualifiedName);\n const onOldShape = (\n Object.keys(newAliases) as (keyof ComponentsJsonAliases)[]\n ).every((key) => currentAliases[key] === expectedOldAliases[key]);\n\n if (!onOldShape) {\n if (\n (Object.keys(newAliases) as (keyof ComponentsJsonAliases)[]).some(\n (key) => currentAliases[key] !== newAliases[key],\n )\n ) {\n nextSteps.push(\n `${componentsJsonPath}: aliases have diverged from both the old and current generated shape - left untouched. Migrate them to the shadcn CLI's imports/exports monorepo pattern by hand: https://ui.shadcn.com/docs/monorepo`,\n );\n }\n await formatFilesInSubtree(tree);\n return { nextSteps };\n }\n\n // Rewrite every source file's internal references to this package's own\n // components/lib/hooks, keyed off the files actually present so a\n // hand-added component is covered too.\n const internalDirs: Array<{\n dir: string;\n extension: string;\n oldSubpath: string;\n newPrefix: string;\n }> = [\n {\n dir: joinPathFragments(libraryRoot, 'src', 'components', 'ui'),\n extension: '.tsx',\n oldSubpath: 'components/ui',\n newPrefix: '#components/ui',\n },\n {\n dir: joinPathFragments(libraryRoot, 'src', 'lib'),\n extension: '.ts',\n oldSubpath: 'lib',\n newPrefix: '#lib',\n },\n {\n dir: joinPathFragments(libraryRoot, 'src', 'hooks'),\n extension: '.ts',\n oldSubpath: 'hooks',\n newPrefix: '#hooks',\n },\n ];\n\n const renames: Array<{ old: string; renamed: string }> = [];\n const sourceFiles: string[] = [];\n for (const { dir, extension, oldSubpath, newPrefix } of internalDirs) {\n if (!tree.exists(dir)) {\n continue;\n }\n for (const entry of tree.children(dir)) {\n if (!entry.endsWith(extension)) {\n continue;\n }\n const baseName = entry.slice(0, -extension.length);\n renames.push({\n old: `${fullyQualifiedName}/${oldSubpath}/${baseName}`,\n renamed: `${newPrefix}/${baseName}`,\n });\n sourceFiles.push(joinPathFragments(dir, entry));\n }\n }\n\n for (const sourceFile of sourceFiles) {\n for (const { old, renamed } of renames) {\n await applyGritQL(tree, sourceFile, importPattern(old, renamed));\n // A namespace or default import of the same specifier is left as it\n // is - reported rather than rewritten, so a diverged file is never\n // clobbered.\n if (await matchGritQL(tree, sourceFile, hasRemainingImport(old))) {\n nextSteps.push(\n `${sourceFile}: still imports '${old}' in a form this migration does not rewrite - update it to '${renamed}' by hand.`,\n );\n }\n }\n }\n\n updateJson(tree, componentsJsonPath, (json) => ({\n ...json,\n aliases: newAliases,\n }));\n\n updateJson(tree, packageJsonPath, (json) => ({\n ...json,\n ...newPackageManifestFields,\n }));\n\n updateJson(tree, 'tsconfig.base.json', (json) => {\n const paths = { ...(json.compilerOptions?.paths ?? {}) };\n delete paths[`${fullyQualifiedName}/*`];\n return {\n ...json,\n compilerOptions: {\n ...json.compilerOptions,\n paths,\n },\n };\n });\n\n // Every website generated with ux=shadcn needs a real dependency on the\n // shared package now that it resolves through `exports`, not `paths`.\n for (const project of getProjects(tree).values()) {\n const metadata = project.metadata as\n | { generator?: string; ux?: string }\n | undefined;\n if (\n metadata?.generator !== REACT_WEBSITE_APP_GENERATOR_INFO.id ||\n metadata.ux !== 'shadcn'\n ) {\n continue;\n }\n addDependenciesToPackageJson(\n tree,\n { [fullyQualifiedName]: getLocalDependencySpecifier(tree) },\n {},\n joinPathFragments(project.root, 'package.json'),\n );\n }\n\n await formatFilesInSubtree(tree);\n\n return { nextSteps };\n}\n"],"names":["getProjects","joinPathFragments","readJson","updateJson","REACT_WEBSITE_APP_GENERATOR_INFO","applyGritQL","matchGritQL","addDependenciesToPackageJson","getLocalDependencySpecifier","formatFilesInSubtree","PACKAGES_DIR","SHARED_SHADCN_DIR","getSharedShadcnFullyQualifiedName","libraryRoot","componentsJsonPath","packageJsonPath","oldAliases","fqn","components","utils","hooks","lib","ui","newAliases","newPackageManifestFields","imports","exports","importPattern","from","to","hasRemainingImport","migration","tree","nextSteps","exists","fullyQualifiedName","currentAliases","aliases","expectedOldAliases","onOldShape","Object","keys","every","key","some","push","internalDirs","dir","extension","oldSubpath","newPrefix","renames","sourceFiles","entry","children","endsWith","baseName","slice","length","old","renamed","sourceFile","json","paths","compilerOptions","project","values","metadata","generator","id","ux","root"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EACXC,iBAAiB,EAEjBC,QAAQ,EAERC,UAAU,QACL,aAAa;AACpB,SAASC,gCAAgC,QAAQ,6CAA6C;AAC9F,SAASC,WAAW,EAAEC,WAAW,QAAQ,wBAAwB;AACjE,SACEC,4BAA4B,EAC5BC,2BAA2B,QACtB,iCAAiC;AACxC,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SACEC,YAAY,EACZC,iBAAiB,QACZ,gDAAgD;AACvD,SAASC,iCAAiC,QAAQ,kCAAkC;AAEpF;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BC,GAED,MAAMC,cAAcZ,kBAAkBS,cAAcC;AACpD,MAAMG,qBAAqBb,kBAAkBY,aAAa;AAC1D,MA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v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`gateway-url-accessor migration > should add the gatewayUrl accessor to the vended core construct 1`] = `
|
|
4
|
+
"import * as agentcore from 'aws-cdk-lib/aws-bedrockagentcore';
|
|
5
|
+
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
6
|
+
import { Construct } from 'constructs';
|
|
7
|
+
|
|
8
|
+
export class AgentCoreGateway extends Construct implements iam.IGrantable {
|
|
9
|
+
public readonly gateway: agentcore.Gateway;
|
|
10
|
+
|
|
11
|
+
constructor(scope: Construct, id: string) {
|
|
12
|
+
super(scope, id);
|
|
13
|
+
this.gateway = undefined as any;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The principal to grant permissions to.
|
|
18
|
+
*/
|
|
19
|
+
public get grantPrincipal(): iam.IPrincipal {
|
|
20
|
+
return this.gateway.role.grantPrincipal;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The gateway's URL endpoint. The Gateway L2 types its own \`gatewayUrl\` as
|
|
25
|
+
* optional and only populates it when created from its own props, so fall
|
|
26
|
+
* back to the CloudFormation attribute.
|
|
27
|
+
*/
|
|
28
|
+
public get gatewayUrl(): string {
|
|
29
|
+
return (
|
|
30
|
+
this.gateway.gatewayUrl ??
|
|
31
|
+
(this.gateway.node.defaultChild as agentcore.CfnGateway).attrGatewayUrl
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public addGateway(
|
|
36
|
+
gateway: Construct & {
|
|
37
|
+
readonly gateway: agentcore.Gateway;
|
|
38
|
+
readonly gatewayName: string;
|
|
39
|
+
readonly gatewayUrl: string;
|
|
40
|
+
},
|
|
41
|
+
props?: {
|
|
42
|
+
gatewayTargetName?: string;
|
|
43
|
+
},
|
|
44
|
+
): agentcore.CfnGatewayTarget {
|
|
45
|
+
const target = this.addGatewayTarget({
|
|
46
|
+
gatewayTargetName: props?.gatewayTargetName ?? gateway.gatewayName,
|
|
47
|
+
gatewayUrl: gateway.gatewayUrl,
|
|
48
|
+
gatewayArn: gateway.gateway.gatewayArn,
|
|
49
|
+
});
|
|
50
|
+
target.node.addDependency(gateway);
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public addGatewayTarget(props: {
|
|
55
|
+
gatewayTargetName: string;
|
|
56
|
+
gatewayUrl: string;
|
|
57
|
+
gatewayArn: string;
|
|
58
|
+
}): agentcore.CfnGatewayTarget {
|
|
59
|
+
return undefined as any;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
"
|
|
63
|
+
`;
|
|
64
|
+
|
|
65
|
+
exports[`gateway-url-accessor migration > should point vended app-level gateway constructs at the accessor 1`] = `
|
|
66
|
+
"import { Construct } from 'constructs';
|
|
67
|
+
import { AgentCoreGateway } from '../../../core/agentcore-gateway/agentcore-gateway';
|
|
68
|
+
import { RuntimeConfig } from '../../../core/runtime-config';
|
|
69
|
+
|
|
70
|
+
export class MyGateway extends AgentCoreGateway {
|
|
71
|
+
public readonly gatewayName = 'my-gateway';
|
|
72
|
+
|
|
73
|
+
constructor(scope: Construct, id: string) {
|
|
74
|
+
super(scope, id);
|
|
75
|
+
|
|
76
|
+
const rc = RuntimeConfig.ensure(this);
|
|
77
|
+
rc.set('agentcore', 'gateways', {
|
|
78
|
+
...rc.get('agentcore').gateways,
|
|
79
|
+
MyGateway: this.gatewayUrl,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
"
|
|
84
|
+
`;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ import { applyGritQL, GRIT_INSERT_PLACEHOLDER, insertViaGritQL, matchGritQL } from "../../../utils/ast.js";
|
|
5
|
+
import { formatFilesInSubtree } from "../../../utils/format.js";
|
|
6
|
+
import { PACKAGES_DIR, SHARED_CONSTRUCTS_DIR } from "../../../utils/shared-constructs-constants.js";
|
|
7
|
+
/**
|
|
8
|
+
* The CDK `Gateway` L2 types its `gatewayUrl` as `string | undefined`, so
|
|
9
|
+
* reaching through the vended `AgentCoreGateway` construct to
|
|
10
|
+
* `gateway.gateway.gatewayUrl` does not typecheck where a `string` is required —
|
|
11
|
+
* the DCR proxy's `upstreamUrl`, for example. `AgentCoreGateway` gains a
|
|
12
|
+
* non-optional `gatewayUrl` accessor falling back to the CloudFormation
|
|
13
|
+
* attribute, which `addGateway` and the vended app-level gateway constructs then
|
|
14
|
+
* read.
|
|
15
|
+
*/ const CONSTRUCTS_SRC = `${PACKAGES_DIR}/${SHARED_CONSTRUCTS_DIR}/src`;
|
|
16
|
+
const GATEWAY_CONSTRUCT_FILE = `${CONSTRUCTS_SRC}/core/agentcore-gateway/agentcore-gateway.ts`;
|
|
17
|
+
const GATEWAYS_DIR = `${CONSTRUCTS_SRC}/app/gateways`;
|
|
18
|
+
const GATEWAY_URL_ACCESSOR = `/**
|
|
19
|
+
* The gateway's URL endpoint. The Gateway L2 types its own \`gatewayUrl\` as
|
|
20
|
+
* optional and only populates it when created from its own props, so fall
|
|
21
|
+
* back to the CloudFormation attribute.
|
|
22
|
+
*/
|
|
23
|
+
public get gatewayUrl(): string {
|
|
24
|
+
return (
|
|
25
|
+
this.gateway.gatewayUrl ??
|
|
26
|
+
(this.gateway.node.defaultChild as agentcore.CfnGateway).attrGatewayUrl
|
|
27
|
+
);
|
|
28
|
+
}`;
|
|
29
|
+
const divergedCoreMessage = `${GATEWAY_CONSTRUCT_FILE}: the AgentCoreGateway construct has diverged from the generated shape - left untouched. To use a gateway's URL where a \`string\` is required, add a \`public get gatewayUrl(): string\` accessor returning \`this.gateway.gatewayUrl ?? (this.gateway.node.defaultChild as agentcore.CfnGateway).attrGatewayUrl\`.`;
|
|
30
|
+
/**
|
|
31
|
+
* Add the `gatewayUrl` accessor to the vended core construct, and route
|
|
32
|
+
* `addGateway` and the shape it requires of its argument through it. Returns
|
|
33
|
+
* whether the core construct ends up carrying the accessor — app-level
|
|
34
|
+
* constructs may only be pointed at it once it exists.
|
|
35
|
+
*/ const migrateCoreConstruct = async (tree, nextSteps)=>{
|
|
36
|
+
if (!tree.exists(GATEWAY_CONSTRUCT_FILE)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const hasAccessor = await matchGritQL(tree, GATEWAY_CONSTRUCT_FILE, '`public get gatewayUrl(): string { $_ }`');
|
|
40
|
+
if (!hasAccessor) {
|
|
41
|
+
// Anchored on the grantPrincipal accessor, present in every vended version.
|
|
42
|
+
const added = await insertViaGritQL(tree, GATEWAY_CONSTRUCT_FILE, `\`public get grantPrincipal(): iam.IPrincipal { $body }\` as $accessor => \`$accessor
|
|
43
|
+
|
|
44
|
+
${GRIT_INSERT_PLACEHOLDER}\``, GATEWAY_URL_ACCESSOR);
|
|
45
|
+
if (!added) {
|
|
46
|
+
nextSteps.push(divergedCoreMessage);
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const addGatewayUsesAccessor = await matchGritQL(tree, GATEWAY_CONSTRUCT_FILE, '`gatewayUrl: gateway.gatewayUrl`');
|
|
51
|
+
if (!addGatewayUsesAccessor) {
|
|
52
|
+
// The accessor is part of the shape addGateway requires of its argument.
|
|
53
|
+
await applyGritQL(tree, GATEWAY_CONSTRUCT_FILE, `\`readonly gatewayName: string\` as $member => \`$member;
|
|
54
|
+
readonly gatewayUrl: string\``);
|
|
55
|
+
// addGateway reads the accessor rather than repeating the fallback inline.
|
|
56
|
+
await applyGritQL(tree, GATEWAY_CONSTRUCT_FILE, `\`this.addGatewayTarget({ gatewayTargetName: $name, gatewayUrl: $url, gatewayArn: $arn })\` where {
|
|
57
|
+
$url <: contains \`attrGatewayUrl\`
|
|
58
|
+
} => \`this.addGatewayTarget({
|
|
59
|
+
gatewayTargetName: $name,
|
|
60
|
+
gatewayUrl: gateway.gatewayUrl,
|
|
61
|
+
gatewayArn: $arn,
|
|
62
|
+
})\``);
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Point each vended app-level gateway construct's runtime config entry at the
|
|
68
|
+
* accessor.
|
|
69
|
+
*/ const migrateAppConstructs = async (tree)=>{
|
|
70
|
+
if (!tree.exists(GATEWAYS_DIR)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
for (const dir of tree.children(GATEWAYS_DIR)){
|
|
74
|
+
const constructFile = `${GATEWAYS_DIR}/${dir}/${dir}.ts`;
|
|
75
|
+
if (!tree.exists(constructFile)) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
await applyGritQL(tree, constructFile, '`this.gateway.gatewayUrl` => `this.gatewayUrl`');
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
export default async function migration(tree) {
|
|
82
|
+
const nextSteps = [];
|
|
83
|
+
// The app constructs read the accessor, so they may only be migrated once the
|
|
84
|
+
// core construct carries it.
|
|
85
|
+
if (await migrateCoreConstruct(tree, nextSteps)) {
|
|
86
|
+
await migrateAppConstructs(tree);
|
|
87
|
+
}
|
|
88
|
+
await formatFilesInSubtree(tree);
|
|
89
|
+
return {
|
|
90
|
+
nextSteps
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.0.0-rc.97/0001-gateway-url-accessor/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { MigrationReturnObject, Tree } from '@nx/devkit';\nimport {\n applyGritQL,\n GRIT_INSERT_PLACEHOLDER,\n insertViaGritQL,\n matchGritQL,\n} from '../../../utils/ast.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\nimport {\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n} from '../../../utils/shared-constructs-constants.js';\n\n/**\n * The CDK `Gateway` L2 types its `gatewayUrl` as `string | undefined`, so\n * reaching through the vended `AgentCoreGateway` construct to\n * `gateway.gateway.gatewayUrl` does not typecheck where a `string` is required —\n * the DCR proxy's `upstreamUrl`, for example. `AgentCoreGateway` gains a\n * non-optional `gatewayUrl` accessor falling back to the CloudFormation\n * attribute, which `addGateway` and the vended app-level gateway constructs then\n * read.\n */\n\nconst CONSTRUCTS_SRC = `${PACKAGES_DIR}/${SHARED_CONSTRUCTS_DIR}/src`;\n\nconst GATEWAY_CONSTRUCT_FILE = `${CONSTRUCTS_SRC}/core/agentcore-gateway/agentcore-gateway.ts`;\n\nconst GATEWAYS_DIR = `${CONSTRUCTS_SRC}/app/gateways`;\n\nconst GATEWAY_URL_ACCESSOR = `/**\n * The gateway's URL endpoint. The Gateway L2 types its own \\`gatewayUrl\\` as\n * optional and only populates it when created from its own props, so fall\n * back to the CloudFormation attribute.\n */\n public get gatewayUrl(): string {\n return (\n this.gateway.gatewayUrl ??\n (this.gateway.node.defaultChild as agentcore.CfnGateway).attrGatewayUrl\n );\n }`;\n\nconst divergedCoreMessage = `${GATEWAY_CONSTRUCT_FILE}: the AgentCoreGateway construct has diverged from the generated shape - left untouched. To use a gateway's URL where a \\`string\\` is required, add a \\`public get gatewayUrl(): string\\` accessor returning \\`this.gateway.gatewayUrl ?? (this.gateway.node.defaultChild as agentcore.CfnGateway).attrGatewayUrl\\`.`;\n\n/**\n * Add the `gatewayUrl` accessor to the vended core construct, and route\n * `addGateway` and the shape it requires of its argument through it. Returns\n * whether the core construct ends up carrying the accessor — app-level\n * constructs may only be pointed at it once it exists.\n */\nconst migrateCoreConstruct = async (\n tree: Tree,\n nextSteps: string[],\n): Promise<boolean> => {\n if (!tree.exists(GATEWAY_CONSTRUCT_FILE)) {\n return false;\n }\n\n const hasAccessor = await matchGritQL(\n tree,\n GATEWAY_CONSTRUCT_FILE,\n '`public get gatewayUrl(): string { $_ }`',\n );\n\n if (!hasAccessor) {\n // Anchored on the grantPrincipal accessor, present in every vended version.\n const added = await insertViaGritQL(\n tree,\n GATEWAY_CONSTRUCT_FILE,\n `\\`public get grantPrincipal(): iam.IPrincipal { $body }\\` as $accessor => \\`$accessor\n\n ${GRIT_INSERT_PLACEHOLDER}\\``,\n GATEWAY_URL_ACCESSOR,\n );\n if (!added) {\n nextSteps.push(divergedCoreMessage);\n return false;\n }\n }\n\n const addGatewayUsesAccessor = await matchGritQL(\n tree,\n GATEWAY_CONSTRUCT_FILE,\n '`gatewayUrl: gateway.gatewayUrl`',\n );\n\n if (!addGatewayUsesAccessor) {\n // The accessor is part of the shape addGateway requires of its argument.\n await applyGritQL(\n tree,\n GATEWAY_CONSTRUCT_FILE,\n `\\`readonly gatewayName: string\\` as $member => \\`$member;\n readonly gatewayUrl: string\\``,\n );\n\n // addGateway reads the accessor rather than repeating the fallback inline.\n await applyGritQL(\n tree,\n GATEWAY_CONSTRUCT_FILE,\n `\\`this.addGatewayTarget({ gatewayTargetName: $name, gatewayUrl: $url, gatewayArn: $arn })\\` where {\n $url <: contains \\`attrGatewayUrl\\`\n} => \\`this.addGatewayTarget({\n gatewayTargetName: $name,\n gatewayUrl: gateway.gatewayUrl,\n gatewayArn: $arn,\n })\\``,\n );\n }\n\n return true;\n};\n\n/**\n * Point each vended app-level gateway construct's runtime config entry at the\n * accessor.\n */\nconst migrateAppConstructs = async (tree: Tree): Promise<void> => {\n if (!tree.exists(GATEWAYS_DIR)) {\n return;\n }\n for (const dir of tree.children(GATEWAYS_DIR)) {\n const constructFile = `${GATEWAYS_DIR}/${dir}/${dir}.ts`;\n if (!tree.exists(constructFile)) {\n continue;\n }\n await applyGritQL(\n tree,\n constructFile,\n '`this.gateway.gatewayUrl` => `this.gatewayUrl`',\n );\n }\n};\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n const nextSteps: string[] = [];\n\n // The app constructs read the accessor, so they may only be migrated once the\n // core construct carries it.\n if (await migrateCoreConstruct(tree, nextSteps)) {\n await migrateAppConstructs(tree);\n }\n\n await formatFilesInSubtree(tree);\n\n return { nextSteps };\n}\n"],"names":["applyGritQL","GRIT_INSERT_PLACEHOLDER","insertViaGritQL","matchGritQL","formatFilesInSubtree","PACKAGES_DIR","SHARED_CONSTRUCTS_DIR","CONSTRUCTS_SRC","GATEWAY_CONSTRUCT_FILE","GATEWAYS_DIR","GATEWAY_URL_ACCESSOR","divergedCoreMessage","migrateCoreConstruct","tree","nextSteps","exists","hasAccessor","added","push","addGatewayUsesAccessor","migrateAppConstructs","dir","children","constructFile","migration"],"mappings":"AAAA;;;CAGC,GAED,SACEA,WAAW,EACXC,uBAAuB,EACvBC,eAAe,EACfC,WAAW,QACN,wBAAwB;AAC/B,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SACEC,YAAY,EACZC,qBAAqB,QAChB,gDAAgD;AAEvD;;;;;;;;CAQC,GAED,MAAMC,iBAAiB,GAAGF,aAAa,CAAC,EAAEC,sBAAsB,IAAI,CAAC;AAErE,MAAME,yBAAyB,GAAGD,eAAe,4CAA4C,CAAC;AAE9F,MAAME,eAAe,GAAGF,eAAe,aAAa,CAAC;AAErD,MAAMG,uBAAuB,CAAC;;;;;;;;;;GAU3B,CAAC;AAEJ,MAAMC,sBAAsB,GAAGH,uBAAuB,oTAAoT,CAAC;AAE3W;;;;;CAKC,GACD,MAAMI,uBAAuB,OAC3BC,MACAC;IAEA,IAAI,CAACD,KAAKE,MAAM,CAACP,yBAAyB;QACxC,OAAO;IACT;IAEA,MAAMQ,cAAc,MAAMb,YACxBU,MACAL,wBACA;IAGF,IAAI,CAACQ,aAAa;QAChB,4EAA4E;QAC5E,MAAMC,QAAQ,MAAMf,gBAClBW,MACAL,wBACA,CAAC;;EAEL,EAAEP,wBAAwB,EAAE,CAAC,EACzBS;QAEF,IAAI,CAACO,OAAO;YACVH,UAAUI,IAAI,CAACP;YACf,OAAO;QACT;IACF;IAEA,MAAMQ,yBAAyB,MAAMhB,YACnCU,MACAL,wBACA;IAGF,IAAI,CAACW,wBAAwB;QAC3B,yEAAyE;QACzE,MAAMnB,YACJa,MACAL,wBACA,CAAC;mCAC4B,CAAC;QAGhC,2EAA2E;QAC3E,MAAMR,YACJa,MACAL,wBACA,CAAC;;;;;;QAMC,CAAC;IAEP;IAEA,OAAO;AACT;AAEA;;;CAGC,GACD,MAAMY,uBAAuB,OAAOP;IAClC,IAAI,CAACA,KAAKE,MAAM,CAACN,eAAe;QAC9B;IACF;IACA,KAAK,MAAMY,OAAOR,KAAKS,QAAQ,CAACb,cAAe;QAC7C,MAAMc,gBAAgB,GAAGd,aAAa,CAAC,EAAEY,IAAI,CAAC,EAAEA,IAAI,GAAG,CAAC;QACxD,IAAI,CAACR,KAAKE,MAAM,CAACQ,gBAAgB;YAC/B;QACF;QACA,MAAMvB,YACJa,MACAU,eACA;IAEJ;AACF;AAEA,eAAe,eAAeC,UAC5BX,IAAU;IAEV,MAAMC,YAAsB,EAAE;IAE9B,8EAA8E;IAC9E,6BAA6B;IAC7B,IAAI,MAAMF,qBAAqBC,MAAMC,YAAY;QAC/C,MAAMM,qBAAqBP;IAC7B;IAEA,MAAMT,qBAAqBS;IAE3B,OAAO;QAAEC;IAAU;AACrB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { type MigrationReturnObject, type Tree } from '@nx/devkit';
|
|
6
|
+
export default function migration(tree: Tree): Promise<MigrationReturnObject>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ import { getProjects, updateProjectConfiguration } from "@nx/devkit";
|
|
5
|
+
import { INFRA_APP_GENERATOR_INFO } from "../../../infra/app/generator.js";
|
|
6
|
+
import { formatFilesInSubtree } from "../../../utils/format.js";
|
|
7
|
+
/**
|
|
8
|
+
* Point the CDK infrastructure `checkov` target's cache inputs at the project
|
|
9
|
+
* rather than at the synth output directory.
|
|
10
|
+
*
|
|
11
|
+
* The target declared `["{workspaceRoot}/dist/{projectRoot}/cdk.out"]`, a
|
|
12
|
+
* fileset input. Nx resolves a fileset against the files it tracks, and `dist`
|
|
13
|
+
* is gitignored — so the input matched nothing and hashed to a constant. Once
|
|
14
|
+
* the scan had been cached, every later run was a hit: adding a non-compliant
|
|
15
|
+
* resource to a stack left `build` reporting success, and restored a
|
|
16
|
+
* `checkov_report.json` recording zero resources scanned.
|
|
17
|
+
*
|
|
18
|
+
* `["default"]` is what its `synth` sibling declares. It covers the project's
|
|
19
|
+
* own sources and carries the transitive `dependentTasksOutputFiles` entry from
|
|
20
|
+
* `nx.json`, which Nx resolves against the upstream `synth` task — so the hash
|
|
21
|
+
* follows the template the scan actually reads.
|
|
22
|
+
*/ const CHECKOV_TARGET = 'checkov';
|
|
23
|
+
/** The inputs the pre-fix generator declared, replaced in place. */ const VENDED_INPUTS = [
|
|
24
|
+
'{workspaceRoot}/dist/{projectRoot}/cdk.out'
|
|
25
|
+
];
|
|
26
|
+
/** The inputs the generator declares now, matching the `synth` sibling. */ const FIXED_INPUTS = [
|
|
27
|
+
'default'
|
|
28
|
+
];
|
|
29
|
+
const divergedMessage = (projectName)=>`${projectName}:${CHECKOV_TARGET}: its \`inputs\` have diverged from the generated shape - left untouched. Confirm they cover the synthesized template the scan reads: an input pointed only at \`dist\` matches no tracked file, so the scan can report a cached pass on infrastructure it never scanned.`;
|
|
30
|
+
/** Whether a target's inputs are exactly the ones the generator vended. */ const hasVendedInputs = (target)=>Array.isArray(target.inputs) && target.inputs.length === VENDED_INPUTS.length && target.inputs.every((input, index)=>input === VENDED_INPUTS[index]);
|
|
31
|
+
export default async function migration(tree) {
|
|
32
|
+
const nextSteps = [];
|
|
33
|
+
for (const [projectName, project] of getProjects(tree)){
|
|
34
|
+
const generator = project.metadata?.generator;
|
|
35
|
+
if (generator !== INFRA_APP_GENERATOR_INFO.id) continue;
|
|
36
|
+
const target = project.targets?.[CHECKOV_TARGET];
|
|
37
|
+
if (!target) continue;
|
|
38
|
+
// A target already declaring the fixed inputs needs nothing, which also
|
|
39
|
+
// makes a re-run — and a project generated after the fix — a no-op.
|
|
40
|
+
if (Array.isArray(target.inputs) && target.inputs.length === FIXED_INPUTS.length && target.inputs.every((input, index)=>input === FIXED_INPUTS[index])) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (!hasVendedInputs(target)) {
|
|
44
|
+
nextSteps.push(divergedMessage(projectName));
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
target.inputs = [
|
|
48
|
+
...FIXED_INPUTS
|
|
49
|
+
];
|
|
50
|
+
updateProjectConfiguration(tree, projectName, project);
|
|
51
|
+
}
|
|
52
|
+
await formatFilesInSubtree(tree);
|
|
53
|
+
return {
|
|
54
|
+
nextSteps
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/migrations/v1.0.0-rc.97/0002-checkov-scan-cache-inputs/migration.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n getProjects,\n type MigrationReturnObject,\n type ProjectConfiguration,\n type TargetConfiguration,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { INFRA_APP_GENERATOR_INFO } from '../../../infra/app/generator.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\n\n/**\n * Point the CDK infrastructure `checkov` target's cache inputs at the project\n * rather than at the synth output directory.\n *\n * The target declared `[\"{workspaceRoot}/dist/{projectRoot}/cdk.out\"]`, a\n * fileset input. Nx resolves a fileset against the files it tracks, and `dist`\n * is gitignored — so the input matched nothing and hashed to a constant. Once\n * the scan had been cached, every later run was a hit: adding a non-compliant\n * resource to a stack left `build` reporting success, and restored a\n * `checkov_report.json` recording zero resources scanned.\n *\n * `[\"default\"]` is what its `synth` sibling declares. It covers the project's\n * own sources and carries the transitive `dependentTasksOutputFiles` entry from\n * `nx.json`, which Nx resolves against the upstream `synth` task — so the hash\n * follows the template the scan actually reads.\n */\n\nconst CHECKOV_TARGET = 'checkov';\n\n/** The inputs the pre-fix generator declared, replaced in place. */\nconst VENDED_INPUTS = ['{workspaceRoot}/dist/{projectRoot}/cdk.out'];\n\n/** The inputs the generator declares now, matching the `synth` sibling. */\nconst FIXED_INPUTS = ['default'];\n\nconst divergedMessage = (projectName: string) =>\n `${projectName}:${CHECKOV_TARGET}: its \\`inputs\\` have diverged from the generated shape - left untouched. Confirm they cover the synthesized template the scan reads: an input pointed only at \\`dist\\` matches no tracked file, so the scan can report a cached pass on infrastructure it never scanned.`;\n\n/** Whether a target's inputs are exactly the ones the generator vended. */\nconst hasVendedInputs = (target: TargetConfiguration): boolean =>\n Array.isArray(target.inputs) &&\n target.inputs.length === VENDED_INPUTS.length &&\n target.inputs.every((input, index) => input === VENDED_INPUTS[index]);\n\nexport default async function migration(\n tree: Tree,\n): Promise<MigrationReturnObject> {\n const nextSteps: string[] = [];\n\n for (const [projectName, project] of getProjects(tree)) {\n const generator = (project.metadata as { generator?: string } | undefined)\n ?.generator;\n if (generator !== INFRA_APP_GENERATOR_INFO.id) continue;\n\n const target = project.targets?.[CHECKOV_TARGET];\n if (!target) continue;\n\n // A target already declaring the fixed inputs needs nothing, which also\n // makes a re-run — and a project generated after the fix — a no-op.\n if (\n Array.isArray(target.inputs) &&\n target.inputs.length === FIXED_INPUTS.length &&\n target.inputs.every((input, index) => input === FIXED_INPUTS[index])\n ) {\n continue;\n }\n\n if (!hasVendedInputs(target)) {\n nextSteps.push(divergedMessage(projectName));\n continue;\n }\n\n target.inputs = [...FIXED_INPUTS];\n updateProjectConfiguration(\n tree,\n projectName,\n project as ProjectConfiguration,\n );\n }\n\n await formatFilesInSubtree(tree);\n\n return { nextSteps };\n}\n"],"names":["getProjects","updateProjectConfiguration","INFRA_APP_GENERATOR_INFO","formatFilesInSubtree","CHECKOV_TARGET","VENDED_INPUTS","FIXED_INPUTS","divergedMessage","projectName","hasVendedInputs","target","Array","isArray","inputs","length","every","input","index","migration","tree","nextSteps","project","generator","metadata","id","targets","push"],"mappings":"AAAA;;;CAGC,GACD,SACEA,WAAW,EAKXC,0BAA0B,QACrB,aAAa;AACpB,SAASC,wBAAwB,QAAQ,kCAAkC;AAC3E,SAASC,oBAAoB,QAAQ,2BAA2B;AAEhE;;;;;;;;;;;;;;;CAeC,GAED,MAAMC,iBAAiB;AAEvB,kEAAkE,GAClE,MAAMC,gBAAgB;IAAC;CAA6C;AAEpE,yEAAyE,GACzE,MAAMC,eAAe;IAAC;CAAU;AAEhC,MAAMC,kBAAkB,CAACC,cACvB,GAAGA,YAAY,CAAC,EAAEJ,eAAe,yQAAyQ,CAAC;AAE7S,yEAAyE,GACzE,MAAMK,kBAAkB,CAACC,SACvBC,MAAMC,OAAO,CAACF,OAAOG,MAAM,KAC3BH,OAAOG,MAAM,CAACC,MAAM,KAAKT,cAAcS,MAAM,IAC7CJ,OAAOG,MAAM,CAACE,KAAK,CAAC,CAACC,OAAOC,QAAUD,UAAUX,aAAa,CAACY,MAAM;AAEtE,eAAe,eAAeC,UAC5BC,IAAU;IAEV,MAAMC,YAAsB,EAAE;IAE9B,KAAK,MAAM,CAACZ,aAAaa,QAAQ,IAAIrB,YAAYmB,MAAO;QACtD,MAAMG,YAAaD,QAAQE,QAAQ,EAC/BD;QACJ,IAAIA,cAAcpB,yBAAyBsB,EAAE,EAAE;QAE/C,MAAMd,SAASW,QAAQI,OAAO,EAAE,CAACrB,eAAe;QAChD,IAAI,CAACM,QAAQ;QAEb,wEAAwE;QACxE,oEAAoE;QACpE,IACEC,MAAMC,OAAO,CAACF,OAAOG,MAAM,KAC3BH,OAAOG,MAAM,CAACC,MAAM,KAAKR,aAAaQ,MAAM,IAC5CJ,OAAOG,MAAM,CAACE,KAAK,CAAC,CAACC,OAAOC,QAAUD,UAAUV,YAAY,CAACW,MAAM,GACnE;YACA;QACF;QAEA,IAAI,CAACR,gBAAgBC,SAAS;YAC5BU,UAAUM,IAAI,CAACnB,gBAAgBC;YAC/B;QACF;QAEAE,OAAOG,MAAM,GAAG;eAAIP;SAAa;QACjCL,2BACEkB,MACAX,aACAa;IAEJ;IAEA,MAAMlB,qBAAqBgB;IAE3B,OAAO;QAAEC;IAAU;AACrB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { type MigrationReturnObject, type Tree } from '@nx/devkit';
|
|
6
|
+
export default function migration(tree: Tree): Promise<MigrationReturnObject>;
|