@aws/nx-plugin 1.0.0-rc.90 → 1.0.0-rc.92
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 +2 -2
- package/migrations.json +32 -27
- package/package.json +4 -4
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/internal/test-matrix/generator.js +28 -0
- package/src/internal/test-matrix/generator.js.map +1 -1
- package/src/migrations/latest/react-website-unique-dev-ports/metadata.json +3 -0
- package/src/migrations/latest/react-website-unique-dev-ports/migration.js +79 -0
- package/src/migrations/latest/react-website-unique-dev-ports/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.87/0001-add-destroy-sandbox-target/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.87/0002-terraform-rdb-proxy-iam-connect-grant/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.88/0001-python-version-drop-exact-patch/migration.d.ts +6 -0
- package/src/migrations/v1.0.0-rc.88/0001-python-version-drop-exact-patch/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.88/0002-react-website-nx-react-express-override/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.89/0001-nx-parallel-default/migration.js.map +1 -0
- package/src/preset/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +2 -2
- package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +1 -1
- package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +91 -116
- package/src/py/agent/files/package/main.py.template +13 -0
- package/src/py/agent/generator.d.ts +6 -1
- package/src/py/agent/generator.js +82 -45
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/schema.d.js.map +1 -1
- package/src/py/agent/schema.d.ts +2 -1
- package/src/py/agent/schema.json +2 -2
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +66 -115
- package/src/py/mcp-server/files/package/main.py.template +13 -0
- package/src/py/mcp-server/generator.d.ts +6 -1
- package/src/py/mcp-server/generator.js +79 -43
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/mcp-server/schema.d.js.map +1 -1
- package/src/py/mcp-server/schema.d.ts +2 -1
- package/src/py/mcp-server/schema.json +2 -2
- package/src/py/rdb/__snapshots__/generator.spec.ts.snap +14 -61
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +78 -115
- package/src/ts/agent/generator.d.ts +26 -1
- package/src/ts/agent/generator.js +71 -45
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/schema.d.js.map +1 -1
- package/src/ts/agent/schema.d.ts +2 -1
- package/src/ts/agent/schema.json +2 -2
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +65 -114
- package/src/ts/mcp-server/generator.d.ts +26 -1
- package/src/ts/mcp-server/generator.js +66 -38
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/mcp-server/schema.d.js.map +1 -1
- package/src/ts/mcp-server/schema.d.ts +2 -1
- package/src/ts/mcp-server/schema.json +2 -2
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +16 -110
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +12 -10
- package/src/ts/react-website/app/generator.js +16 -0
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +1 -1
- package/src/ts/react-website/cognito-auth/generator.js +14 -2
- package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +25 -6
- package/src/utils/agent-core-constructs/agent-core-constructs.js +36 -7
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +20 -4
- package/src/utils/agent-core-constructs/files/terraform/app/agent-core/__nameKebabCase__/__nameKebabCase__.tf.template +34 -1
- package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +51 -112
- package/src/utils/agent-core-constructs/files/terraform/core/agent-core-code/runtime.tf.template +204 -0
- package/src/utils/agent-core-constructs/files/terraform/core/agent-core-container/runtime.tf.template +235 -0
- package/src/utils/agent-core-packaging.d.ts +119 -0
- package/src/utils/agent-core-packaging.js +131 -0
- package/src/utils/agent-core-packaging.js.map +1 -0
- package/src/utils/agent-core-runtime-resolution.d.ts +35 -0
- package/src/utils/agent-core-runtime-resolution.js +68 -0
- package/src/utils/agent-core-runtime-resolution.js.map +1 -0
- package/src/utils/files/terraform/src/core/asset-ecr/asset-ecr.tf.template +137 -0
- package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +1 -1
- package/src/utils/identity-constructs/files/terraform/core/user-identity/identity/identity.tf.template +1 -4
- package/src/utils/identity-constructs/identity-constructs.d.ts +22 -2
- package/src/utils/identity-constructs/identity-constructs.js +75 -5
- package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
- package/src/utils/port.d.ts +5 -0
- package/src/utils/port.js +1 -1
- package/src/utils/port.js.map +1 -1
- package/src/utils/rdb-constructs/files/terraform/app/dbs/__nameKebabCase__/__nameKebabCase__.tf.template +12 -59
- package/src/utils/versions.d.ts +51 -31
- package/src/utils/versions.js +48 -31
- package/src/utils/versions.js.map +1 -1
- package/src/migrations/latest/add-destroy-sandbox-target/migration.js.map +0 -1
- package/src/migrations/latest/nx-parallel-default/migration.js.map +0 -1
- package/src/migrations/latest/python-version-drop-exact-patch/migration.js.map +0 -1
- package/src/migrations/latest/react-website-nx-react-express-override/migration.js.map +0 -1
- package/src/migrations/latest/terraform-rdb-proxy-iam-connect-grant/migration.js.map +0 -1
- /package/src/migrations/latest/{add-destroy-sandbox-target → react-website-unique-dev-ports}/migration.d.ts +0 -0
- /package/src/migrations/{latest/add-destroy-sandbox-target → v1.0.0-rc.87/0001-add-destroy-sandbox-target}/metadata.json +0 -0
- /package/src/migrations/{latest/python-version-drop-exact-patch → v1.0.0-rc.87/0001-add-destroy-sandbox-target}/migration.d.ts +0 -0
- /package/src/migrations/{latest/add-destroy-sandbox-target → v1.0.0-rc.87/0001-add-destroy-sandbox-target}/migration.js +0 -0
- /package/src/migrations/{latest/terraform-rdb-proxy-iam-connect-grant → v1.0.0-rc.87/0002-terraform-rdb-proxy-iam-connect-grant}/__snapshots__/migration.spec.ts.snap +0 -0
- /package/src/migrations/{latest/terraform-rdb-proxy-iam-connect-grant → v1.0.0-rc.87/0002-terraform-rdb-proxy-iam-connect-grant}/metadata.json +0 -0
- /package/src/migrations/{latest/terraform-rdb-proxy-iam-connect-grant → v1.0.0-rc.87/0002-terraform-rdb-proxy-iam-connect-grant}/migration.d.ts +0 -0
- /package/src/migrations/{latest/terraform-rdb-proxy-iam-connect-grant → v1.0.0-rc.87/0002-terraform-rdb-proxy-iam-connect-grant}/migration.js +0 -0
- /package/src/migrations/{latest/python-version-drop-exact-patch → v1.0.0-rc.88/0001-python-version-drop-exact-patch}/metadata.json +0 -0
- /package/src/migrations/{latest/python-version-drop-exact-patch → v1.0.0-rc.88/0001-python-version-drop-exact-patch}/migration.js +0 -0
- /package/src/migrations/{latest/react-website-nx-react-express-override → v1.0.0-rc.88/0002-react-website-nx-react-express-override}/metadata.json +0 -0
- /package/src/migrations/{latest/react-website-nx-react-express-override → v1.0.0-rc.88/0002-react-website-nx-react-express-override}/migration.d.ts +0 -0
- /package/src/migrations/{latest/react-website-nx-react-express-override → v1.0.0-rc.88/0002-react-website-nx-react-express-override}/migration.js +0 -0
- /package/src/migrations/{latest/nx-parallel-default → v1.0.0-rc.89/0001-nx-parallel-default}/metadata.json +0 -0
- /package/src/migrations/{latest/nx-parallel-default → v1.0.0-rc.89/0001-nx-parallel-default}/migration.d.ts +0 -0
- /package/src/migrations/{latest/nx-parallel-default → v1.0.0-rc.89/0001-nx-parallel-default}/migration.js +0 -0
- /package/src/ts/mcp-server/files/{http.ts.template → app/http.ts.template} +0 -0
- /package/src/ts/mcp-server/files/{index.ts.template → app/index.ts.template} +0 -0
- /package/src/ts/mcp-server/files/{resources → app/resources}/sample-guidance.ts.template +0 -0
- /package/src/ts/mcp-server/files/{server.ts.template → app/server.ts.template} +0 -0
- /package/src/ts/mcp-server/files/{stdio.ts.template → app/stdio.ts.template} +0 -0
- /package/src/ts/mcp-server/files/{tools → app/tools}/divide.ts.template +0 -0
- /package/src/ts/mcp-server/files/{Dockerfile.template → deploy/Dockerfile.template} +0 -0
|
@@ -1647,6 +1647,11 @@ variable "asset_bucket_name" {
|
|
|
1647
1647
|
type = string
|
|
1648
1648
|
}
|
|
1649
1649
|
|
|
1650
|
+
variable "asset_ecr_repository_url" {
|
|
1651
|
+
description = "URL of the shared asset ECR repository the Lambda container images are published to. Instantiate the \`core/asset-ecr\` module once per deployment and pass its \`repository_url\` output here."
|
|
1652
|
+
type = string
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1650
1655
|
data "aws_region" "current" {}
|
|
1651
1656
|
data "aws_caller_identity" "current" {}
|
|
1652
1657
|
|
|
@@ -1738,69 +1743,19 @@ module "add_rdb_to_runtime_config" {
|
|
|
1738
1743
|
}
|
|
1739
1744
|
}
|
|
1740
1745
|
|
|
1741
|
-
resource "aws_ecr_repository" "migration_handler" {
|
|
1742
|
-
#checkov:skip=CKV_AWS_136:AES256 encryption is sufficient for ECR repositories
|
|
1743
|
-
name = "db-migration-\${random_string.suffix.result}"
|
|
1744
|
-
image_tag_mutability = "IMMUTABLE"
|
|
1745
|
-
force_delete = true
|
|
1746
|
-
|
|
1747
|
-
image_scanning_configuration {
|
|
1748
|
-
scan_on_push = true
|
|
1749
|
-
}
|
|
1750
|
-
|
|
1751
|
-
tags = var.tags
|
|
1752
|
-
}
|
|
1753
|
-
|
|
1754
|
-
resource "aws_ecr_repository_policy" "migration_handler" {
|
|
1755
|
-
repository = aws_ecr_repository.migration_handler.name
|
|
1756
|
-
|
|
1757
|
-
policy = jsonencode({
|
|
1758
|
-
Version = "2012-10-17"
|
|
1759
|
-
Statement = [
|
|
1760
|
-
{
|
|
1761
|
-
Sid = "AllowPushPull"
|
|
1762
|
-
Effect = "Allow"
|
|
1763
|
-
Principal = {
|
|
1764
|
-
AWS = "arn:aws:iam::\${data.aws_caller_identity.current.account_id}:root"
|
|
1765
|
-
}
|
|
1766
|
-
Action = [
|
|
1767
|
-
"ecr:BatchCheckLayerAvailability",
|
|
1768
|
-
"ecr:CompleteLayerUpload",
|
|
1769
|
-
"ecr:GetDownloadUrlForLayer",
|
|
1770
|
-
"ecr:InitiateLayerUpload",
|
|
1771
|
-
"ecr:PutImage",
|
|
1772
|
-
"ecr:UploadLayerPart"
|
|
1773
|
-
]
|
|
1774
|
-
},
|
|
1775
|
-
{
|
|
1776
|
-
Sid = "AllowLambdaPull"
|
|
1777
|
-
Effect = "Allow"
|
|
1778
|
-
Principal = {
|
|
1779
|
-
Service = "lambda.amazonaws.com"
|
|
1780
|
-
}
|
|
1781
|
-
Action = [
|
|
1782
|
-
"ecr:BatchCheckLayerAvailability",
|
|
1783
|
-
"ecr:BatchGetImage",
|
|
1784
|
-
"ecr:GetDownloadUrlForLayer"
|
|
1785
|
-
]
|
|
1786
|
-
}
|
|
1787
|
-
]
|
|
1788
|
-
})
|
|
1789
|
-
}
|
|
1790
|
-
|
|
1791
1746
|
data "external" "docker_digest" {
|
|
1792
1747
|
program = ["sh", "-c", "echo '{\\"digest\\":\\"'$(docker inspect \${var.migration_docker_image_tag} --format '{{.Id}}')'\\"}' "]
|
|
1793
1748
|
}
|
|
1794
1749
|
|
|
1795
1750
|
locals {
|
|
1796
1751
|
# Content-based, immutable image tag derived from the local image digest
|
|
1797
|
-
image_tag = replace(data.external.docker_digest.result.digest, "sha256:", "")
|
|
1752
|
+
image_tag = "db-migration-\${replace(data.external.docker_digest.result.digest, "sha256:", "")}"
|
|
1798
1753
|
}
|
|
1799
1754
|
|
|
1800
1755
|
resource "null_resource" "docker_publish" {
|
|
1801
1756
|
triggers = {
|
|
1802
1757
|
docker_digest = data.external.docker_digest.result.digest
|
|
1803
|
-
repository_url =
|
|
1758
|
+
repository_url = var.asset_ecr_repository_url
|
|
1804
1759
|
migration_docker_image_tag = var.migration_docker_image_tag
|
|
1805
1760
|
image_tag = local.image_tag
|
|
1806
1761
|
}
|
|
@@ -1818,8 +1773,6 @@ resource "null_resource" "docker_publish" {
|
|
|
1818
1773
|
IMAGE_TAG = self.triggers.image_tag
|
|
1819
1774
|
}
|
|
1820
1775
|
}
|
|
1821
|
-
|
|
1822
|
-
depends_on = [aws_ecr_repository_policy.migration_handler]
|
|
1823
1776
|
}
|
|
1824
1777
|
|
|
1825
1778
|
resource "aws_iam_role" "migration_handler" {
|
|
@@ -2113,7 +2066,7 @@ resource "aws_lambda_function" "migration_handler" {
|
|
|
2113
2066
|
package_type = "Image"
|
|
2114
2067
|
function_name = local.migration_function_name
|
|
2115
2068
|
role = aws_iam_role.migration_handler.arn
|
|
2116
|
-
image_uri = "\${
|
|
2069
|
+
image_uri = "\${var.asset_ecr_repository_url}:\${local.image_tag}"
|
|
2117
2070
|
memory_size = 1024
|
|
2118
2071
|
timeout = 300
|
|
2119
2072
|
architectures = ["arm64"]
|
|
@@ -3060,6 +3013,11 @@ variable "asset_bucket_name" {
|
|
|
3060
3013
|
type = string
|
|
3061
3014
|
}
|
|
3062
3015
|
|
|
3016
|
+
variable "asset_ecr_repository_url" {
|
|
3017
|
+
description = "URL of the shared asset ECR repository the Lambda container images are published to. Instantiate the \`core/asset-ecr\` module once per deployment and pass its \`repository_url\` output here."
|
|
3018
|
+
type = string
|
|
3019
|
+
}
|
|
3020
|
+
|
|
3063
3021
|
data "aws_region" "current" {}
|
|
3064
3022
|
data "aws_caller_identity" "current" {}
|
|
3065
3023
|
|
|
@@ -3151,69 +3109,19 @@ module "add_rdb_to_runtime_config" {
|
|
|
3151
3109
|
}
|
|
3152
3110
|
}
|
|
3153
3111
|
|
|
3154
|
-
resource "aws_ecr_repository" "migration_handler" {
|
|
3155
|
-
#checkov:skip=CKV_AWS_136:AES256 encryption is sufficient for ECR repositories
|
|
3156
|
-
name = "db-migration-\${random_string.suffix.result}"
|
|
3157
|
-
image_tag_mutability = "IMMUTABLE"
|
|
3158
|
-
force_delete = true
|
|
3159
|
-
|
|
3160
|
-
image_scanning_configuration {
|
|
3161
|
-
scan_on_push = true
|
|
3162
|
-
}
|
|
3163
|
-
|
|
3164
|
-
tags = var.tags
|
|
3165
|
-
}
|
|
3166
|
-
|
|
3167
|
-
resource "aws_ecr_repository_policy" "migration_handler" {
|
|
3168
|
-
repository = aws_ecr_repository.migration_handler.name
|
|
3169
|
-
|
|
3170
|
-
policy = jsonencode({
|
|
3171
|
-
Version = "2012-10-17"
|
|
3172
|
-
Statement = [
|
|
3173
|
-
{
|
|
3174
|
-
Sid = "AllowPushPull"
|
|
3175
|
-
Effect = "Allow"
|
|
3176
|
-
Principal = {
|
|
3177
|
-
AWS = "arn:aws:iam::\${data.aws_caller_identity.current.account_id}:root"
|
|
3178
|
-
}
|
|
3179
|
-
Action = [
|
|
3180
|
-
"ecr:BatchCheckLayerAvailability",
|
|
3181
|
-
"ecr:CompleteLayerUpload",
|
|
3182
|
-
"ecr:GetDownloadUrlForLayer",
|
|
3183
|
-
"ecr:InitiateLayerUpload",
|
|
3184
|
-
"ecr:PutImage",
|
|
3185
|
-
"ecr:UploadLayerPart"
|
|
3186
|
-
]
|
|
3187
|
-
},
|
|
3188
|
-
{
|
|
3189
|
-
Sid = "AllowLambdaPull"
|
|
3190
|
-
Effect = "Allow"
|
|
3191
|
-
Principal = {
|
|
3192
|
-
Service = "lambda.amazonaws.com"
|
|
3193
|
-
}
|
|
3194
|
-
Action = [
|
|
3195
|
-
"ecr:BatchCheckLayerAvailability",
|
|
3196
|
-
"ecr:BatchGetImage",
|
|
3197
|
-
"ecr:GetDownloadUrlForLayer"
|
|
3198
|
-
]
|
|
3199
|
-
}
|
|
3200
|
-
]
|
|
3201
|
-
})
|
|
3202
|
-
}
|
|
3203
|
-
|
|
3204
3112
|
data "external" "docker_digest" {
|
|
3205
3113
|
program = ["sh", "-c", "echo '{\\"digest\\":\\"'$(docker inspect \${var.migration_docker_image_tag} --format '{{.Id}}')'\\"}' "]
|
|
3206
3114
|
}
|
|
3207
3115
|
|
|
3208
3116
|
locals {
|
|
3209
3117
|
# Content-based, immutable image tag derived from the local image digest
|
|
3210
|
-
image_tag = replace(data.external.docker_digest.result.digest, "sha256:", "")
|
|
3118
|
+
image_tag = "db-migration-\${replace(data.external.docker_digest.result.digest, "sha256:", "")}"
|
|
3211
3119
|
}
|
|
3212
3120
|
|
|
3213
3121
|
resource "null_resource" "docker_publish" {
|
|
3214
3122
|
triggers = {
|
|
3215
3123
|
docker_digest = data.external.docker_digest.result.digest
|
|
3216
|
-
repository_url =
|
|
3124
|
+
repository_url = var.asset_ecr_repository_url
|
|
3217
3125
|
migration_docker_image_tag = var.migration_docker_image_tag
|
|
3218
3126
|
image_tag = local.image_tag
|
|
3219
3127
|
}
|
|
@@ -3231,8 +3139,6 @@ resource "null_resource" "docker_publish" {
|
|
|
3231
3139
|
IMAGE_TAG = self.triggers.image_tag
|
|
3232
3140
|
}
|
|
3233
3141
|
}
|
|
3234
|
-
|
|
3235
|
-
depends_on = [aws_ecr_repository_policy.migration_handler]
|
|
3236
3142
|
}
|
|
3237
3143
|
|
|
3238
3144
|
resource "aws_iam_role" "migration_handler" {
|
|
@@ -3526,7 +3432,7 @@ resource "aws_lambda_function" "migration_handler" {
|
|
|
3526
3432
|
package_type = "Image"
|
|
3527
3433
|
function_name = local.migration_function_name
|
|
3528
3434
|
role = aws_iam_role.migration_handler.arn
|
|
3529
|
-
image_uri = "\${
|
|
3435
|
+
image_uri = "\${var.asset_ecr_repository_url}:\${local.image_tag}"
|
|
3530
3436
|
memory_size = 1024
|
|
3531
3437
|
timeout = 300
|
|
3532
3438
|
architectures = ["arm64"]
|
|
@@ -745,7 +745,7 @@ resource "null_resource" "upload_website_files" {
|
|
|
745
745
|
provisioner "local-exec" {
|
|
746
746
|
command = <<-EOT
|
|
747
747
|
cd "$ROOT_PATH"
|
|
748
|
-
uv run --with boto3==1.43.
|
|
748
|
+
uv run --with boto3==1.43.83 python3 -c "
|
|
749
749
|
import os
|
|
750
750
|
import sys
|
|
751
751
|
import boto3
|
|
@@ -868,7 +868,7 @@ resource "null_resource" "cloudfront_invalidation" {
|
|
|
868
868
|
|
|
869
869
|
provisioner "local-exec" {
|
|
870
870
|
command = <<-EOT
|
|
871
|
-
uv run --with boto3==1.43.
|
|
871
|
+
uv run --with boto3==1.43.83 python3 -c "
|
|
872
872
|
import boto3
|
|
873
873
|
import os
|
|
874
874
|
import sys
|
|
@@ -1062,7 +1062,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
1062
1062
|
|
|
1063
1063
|
exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > biome.json 1`] = `
|
|
1064
1064
|
"{
|
|
1065
|
-
"$schema": "https://biomejs.dev/schemas/2.5.
|
|
1065
|
+
"$schema": "https://biomejs.dev/schemas/2.5.11/schema.json",
|
|
1066
1066
|
"root": true,
|
|
1067
1067
|
"formatter": {
|
|
1068
1068
|
"enabled": true,
|
|
@@ -2330,12 +2330,12 @@ catalog:
|
|
|
2330
2330
|
vitest: 4.1.11
|
|
2331
2331
|
'@vitest/coverage-v8': 4.1.11
|
|
2332
2332
|
constructs: 10.8.1
|
|
2333
|
-
aws-cdk-lib: 2.
|
|
2333
|
+
aws-cdk-lib: 2.267.0
|
|
2334
2334
|
'@types/node': 26.4.0
|
|
2335
2335
|
react: 19.2.8
|
|
2336
2336
|
react-dom: 19.2.8
|
|
2337
|
-
'@cloudscape-design/components': 3.0.
|
|
2338
|
-
'@cloudscape-design/board-components': 3.0.
|
|
2337
|
+
'@cloudscape-design/components': 3.0.1356
|
|
2338
|
+
'@cloudscape-design/board-components': 3.0.221
|
|
2339
2339
|
'@cloudscape-design/global-styles': 1.0.67
|
|
2340
2340
|
tailwindcss: 4.3.3
|
|
2341
2341
|
'@nx/react': 23.1.2
|
|
@@ -2441,6 +2441,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2441
2441
|
"projectType": "application",
|
|
2442
2442
|
"tags": [],
|
|
2443
2443
|
"metadata": {
|
|
2444
|
+
"ports": [4200],
|
|
2444
2445
|
"generator": "ts#react-website",
|
|
2445
2446
|
"ux": "cloudscape",
|
|
2446
2447
|
"framework": "react",
|
|
@@ -2934,7 +2935,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2934
2935
|
|
|
2935
2936
|
exports[`react-website generator > Tanstack router integration > should generate website with router correctly > biome.json 1`] = `
|
|
2936
2937
|
"{
|
|
2937
|
-
"$schema": "https://biomejs.dev/schemas/2.5.
|
|
2938
|
+
"$schema": "https://biomejs.dev/schemas/2.5.11/schema.json",
|
|
2938
2939
|
"root": true,
|
|
2939
2940
|
"formatter": {
|
|
2940
2941
|
"enabled": true,
|
|
@@ -4206,12 +4207,12 @@ catalog:
|
|
|
4206
4207
|
vitest: 4.1.11
|
|
4207
4208
|
'@vitest/coverage-v8': 4.1.11
|
|
4208
4209
|
constructs: 10.8.1
|
|
4209
|
-
aws-cdk-lib: 2.
|
|
4210
|
+
aws-cdk-lib: 2.267.0
|
|
4210
4211
|
'@types/node': 26.4.0
|
|
4211
4212
|
react: 19.2.8
|
|
4212
4213
|
react-dom: 19.2.8
|
|
4213
|
-
'@cloudscape-design/components': 3.0.
|
|
4214
|
-
'@cloudscape-design/board-components': 3.0.
|
|
4214
|
+
'@cloudscape-design/components': 3.0.1356
|
|
4215
|
+
'@cloudscape-design/board-components': 3.0.221
|
|
4215
4216
|
'@cloudscape-design/global-styles': 1.0.67
|
|
4216
4217
|
tailwindcss: 4.3.3
|
|
4217
4218
|
'@tanstack/react-router': 1.170.32
|
|
@@ -4323,6 +4324,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
4323
4324
|
"projectType": "application",
|
|
4324
4325
|
"tags": [],
|
|
4325
4326
|
"metadata": {
|
|
4327
|
+
"ports": [4200],
|
|
4326
4328
|
"generator": "ts#react-website",
|
|
4327
4329
|
"ux": "cloudscape",
|
|
4328
4330
|
"framework": "react",
|
|
@@ -17,6 +17,7 @@ import { addGeneratorMetadata, getGeneratorInfo } from "../../../utils/nx.js";
|
|
|
17
17
|
import { sortObjectKeys } from "../../../utils/object.js";
|
|
18
18
|
import { getRelativePathToRoot } from "../../../utils/paths.js";
|
|
19
19
|
import { getPackageManagerDisplayCommands } from "../../../utils/pkg-manager.js";
|
|
20
|
+
import { assignPort } from "../../../utils/port.js";
|
|
20
21
|
import { SHARED_CONSTRUCTS_DEPENDENCIES, sharedConstructsGenerator } from "../../../utils/shared-constructs.js";
|
|
21
22
|
import { PACKAGES_DIR, SHARED_SHADCN_DIR, TERRAFORM_WEBSITE_RUNTIME_CONFIG_FILE } from "../../../utils/shared-constructs-constants.js";
|
|
22
23
|
import { SHADCN_DEPENDENCIES, sharedShadcnGenerator } from "../../../utils/shared-shadcn.js";
|
|
@@ -186,6 +187,16 @@ export async function tsReactWebsiteGenerator(tree, schema) {
|
|
|
186
187
|
}
|
|
187
188
|
const projectConfiguration = readProjectConfiguration(tree, fullyQualifiedName);
|
|
188
189
|
const targets = projectConfiguration.targets;
|
|
190
|
+
// Each website gets its own explicit dev-server port. Vite itself already
|
|
191
|
+
// auto-increments past a port already in use, so two websites don't actually
|
|
192
|
+
// collide — but which port each one lands on then depends on start order and
|
|
193
|
+
// can't be known ahead of time. An explicit, per-project port is what lets
|
|
194
|
+
// the Cognito callback URL allow-list (added when auth is configured) be
|
|
195
|
+
// computed deterministically instead.
|
|
196
|
+
const port = assignPort(tree, projectConfiguration, 4200);
|
|
197
|
+
// @nx/react's vite config defaults to 4200 for the dev server and 4300 for
|
|
198
|
+
// preview; keep that +100 relationship so the pair stays predictable.
|
|
199
|
+
const previewPort = port + 100;
|
|
189
200
|
const infra = schema.infra ?? 'cloudfront-s3';
|
|
190
201
|
// Configure load-runtime-config target based on IaC provider (only when infra is not none)
|
|
191
202
|
const iac = infra !== 'none' ? await resolveIac(tree, schema.iac) : undefined;
|
|
@@ -366,6 +377,11 @@ export async function tsReactWebsiteGenerator(tree, schema) {
|
|
|
366
377
|
// point it at the bundle dir the website infrastructure consumes.
|
|
367
378
|
const outDir = joinPathFragments(getRelativePathToRoot(tree, fullyQualifiedName), 'dist', websiteContentPath, 'bundle');
|
|
368
379
|
await applyGritQL(tree, viteConfigPath, `\`build: { $bprops }\` where { $bprops <: contains \`outDir: $_\` => \`outDir: '${outDir}'\` }`);
|
|
380
|
+
// Replace @nx/react's default dev-server port (4200) with the one assigned above.
|
|
381
|
+
await applyGritQL(tree, viteConfigPath, `\`server: { $sprops }\` where { $sprops <: contains \`port: $_\` => \`port: ${port}\` }`);
|
|
382
|
+
// Likewise for the preview port (@nx/react's default is 4300), so `vite preview`
|
|
383
|
+
// doesn't collide across websites either.
|
|
384
|
+
await applyGritQL(tree, viteConfigPath, `\`preview: { $pprops }\` where { $pprops <: contains \`port: $_\` => \`port: ${previewPort}\` }`);
|
|
369
385
|
// Add plugins to the plugins array
|
|
370
386
|
if (tanstackRouter) {
|
|
371
387
|
// Prepend tanstackRouter (must be first plugin) — rewrite works for both single/multi-element
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/ts/react-website/app/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n detectPackageManager,\n generateFiles,\n joinPathFragments,\n names,\n OverwriteStrategy,\n readProjectConfiguration,\n removeDependenciesFromPackageJson,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { applicationGenerator } from '@nx/react';\nimport { relative, sep } from 'path';\nimport { addTsDependencies } from '../../../utils/add-dependencies.js';\nimport {\n addDestructuredImport,\n addSingleImport,\n appendToArrayViaGritQL,\n applyGritQL,\n} from '../../../utils/ast.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\nimport { resolveIac } from '../../../utils/iac.js';\nimport { installDependencies } from '../../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics.js';\nimport { kebabCase, toClassName, toKebabCase } from '../../../utils/names.js';\nimport { getNpmScopePrefix } from '../../../utils/npm-scope.js';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../../utils/nx.js';\nimport { sortObjectKeys } from '../../../utils/object.js';\nimport { getRelativePathToRoot } from '../../../utils/paths.js';\nimport { getPackageManagerDisplayCommands } from '../../../utils/pkg-manager.js';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../../utils/shared-constructs.js';\nimport {\n type IacMetadata,\n PACKAGES_DIR,\n SHARED_SHADCN_DIR,\n TERRAFORM_WEBSITE_RUNTIME_CONFIG_FILE,\n} from '../../../utils/shared-constructs-constants.js';\nimport {\n SHADCN_DEPENDENCIES,\n sharedShadcnGenerator,\n} from '../../../utils/shared-shadcn.js';\nimport { withVersions } from '../../../utils/versions.js';\nimport {\n addWebsiteInfra,\n WEBSITE_CONSTRUCTS_PY_DEPENDENCIES,\n} from '../../../utils/website-constructs/website-constructs.js';\nimport { configureTsProject } from '../../lib/ts-project-utils.js';\nimport { VITEST_DEPENDENCIES } from '../../lib/vitest.js';\n// typescript factory imports removed — now using GritQL for vite config transforms\nimport type {\n TsReactWebsiteGeneratorSchema,\n WebsiteInfraOption,\n} from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface TsReactWebsiteMetadata extends IacMetadata {\n readonly ux: UxOption;\n readonly framework: string;\n readonly infra: WebsiteInfraOption;\n readonly tailwind: boolean;\n readonly tanstackRouter: boolean;\n}\n\n// Each entry names the branch it belongs to, so the same declaration drives both\n// adding and the version sync.\nexport const DEPENDENCIES = declareDependencies<TsReactWebsiteMetadata>()({\n ts: [\n { name: 'react' },\n { name: 'react-dom' },\n // Build/test tooling imported only from vite.config.mts stays at the root.\n { name: '@nx/react', dev: true, root: true },\n { name: '@vitest/ui', dev: true, root: true },\n {\n name: '@cloudscape-design/components',\n when: (m) => m.ux === 'cloudscape',\n },\n {\n name: '@cloudscape-design/board-components',\n when: (m) => m.ux === 'cloudscape',\n },\n {\n name: '@cloudscape-design/global-styles',\n when: (m) => m.ux === 'cloudscape',\n },\n // Shared shadcn components live in the common/shadcn package, but the\n // website's own generated components (e.g. the tanstack-router sidebar)\n // import lucide-react directly, so the website must declare it.\n {\n name: 'lucide-react',\n when: (m) => m.ux === 'shadcn' && m.tanstackRouter,\n },\n { name: 'tailwindcss', when: (m) => m.tailwind },\n {\n name: '@tailwindcss/vite',\n when: (m) => m.tailwind,\n dev: true,\n root: true,\n },\n { name: '@tanstack/react-router', when: (m) => m.tanstackRouter },\n {\n name: '@tanstack/router-plugin',\n when: (m) => m.tanstackRouter,\n dev: true,\n root: true,\n },\n {\n name: '@tanstack/router-generator',\n when: (m) => m.tanstackRouter,\n dev: true,\n root: true,\n },\n {\n name: '@tanstack/virtual-file-routes',\n when: (m) => m.tanstackRouter,\n dev: true,\n root: true,\n },\n {\n name: '@tanstack/router-utils',\n when: (m) => m.tanstackRouter,\n dev: true,\n root: true,\n },\n // Declared for its pinned version, which goes into npm's `overrides` below.\n { name: 'express', versionOnly: true },\n ...ownedElsewhere(SHADCN_DEPENDENCIES),\n ...ownedElsewhere(VITEST_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n py: ownedElsewhere(WEBSITE_CONSTRUCTS_PY_DEPENDENCIES),\n});\n\nexport const SUPPORTED_UX_PROVIDERS = ['none', 'cloudscape', 'shadcn'] as const;\n\nexport type UxOption = (typeof SUPPORTED_UX_PROVIDERS)[number];\n\nexport type Ux = UxOption;\n\nexport const REACT_WEBSITE_APP_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport async function tsReactWebsiteGenerator(\n tree: Tree,\n schema: TsReactWebsiteGeneratorSchema,\n) {\n const tailwind = schema.tailwind ?? true;\n const tanstackRouter = schema.tanstackRouter ?? true;\n const ux: Ux = schema.ux ?? 'shadcn';\n if (ux === 'shadcn' && !tailwind) {\n throw new Error('Shadcn requires TailwindCSS to be enabled.');\n }\n const npmScopePrefix = getNpmScopePrefix(tree);\n const scopeAlias = npmScopePrefix;\n const websiteNameClassName = toClassName(schema.name);\n const websiteNameKebabCase = toKebabCase(schema.name);\n const fullyQualifiedName = `${npmScopePrefix}${websiteNameKebabCase}`;\n // NB: interactive nx generator cli can pass empty string\n const websiteContentPath = joinPathFragments(\n schema.directory || '.',\n schema.subDirectory || websiteNameKebabCase,\n );\n\n const projectAlreadyExists = tree.exists(\n joinPathFragments(websiteContentPath, 'project.json'),\n );\n\n // TODO: consider exposing and supporting e2e tests\n const e2eTestRunner = 'none';\n\n if (!projectAlreadyExists) {\n await applicationGenerator(tree, {\n ...schema,\n name: fullyQualifiedName,\n directory: websiteContentPath,\n routing: false,\n e2eTestRunner,\n linter: 'none',\n bundler: 'vite',\n unitTestRunner: 'vitest',\n useProjectJson: true,\n style: 'css',\n // Register the @nx/vite and @nx/vitest plugins so build/serve/test\n // targets are inferred rather than emitting deprecated executor targets.\n addPlugin: true,\n });\n\n // Pin the inferred target names. The vite production build is exposed as\n // `bundle` (which produces the deployable artifact), leaving `build` as an\n // aggregator over lint/compile/test/bundle. vite's own typecheck is dropped\n // in favour of the tsc `compile`.\n updateJson(tree, 'nx.json', (nxJson) => {\n for (const plugin of nxJson.plugins ?? []) {\n if (typeof plugin === 'string') continue;\n if (plugin.plugin === '@nx/vite/plugin') {\n plugin.options = {\n ...plugin.options,\n buildTargetName: 'bundle',\n // Map both of vite's inferred dev-server targets onto `serve` so the\n // plugin doesn't emit a separate `dev`; we author our own `dev`\n // below running the local-dev vite mode.\n serveTargetName: 'serve',\n devTargetName: 'serve',\n previewTargetName: 'preview',\n serveStaticTargetName: 'serve-static',\n typecheckTargetName: 'vite:typecheck',\n };\n } else if (plugin.plugin === '@nx/vitest') {\n plugin.options = {\n ...plugin.options,\n testTargetName: 'test',\n };\n }\n }\n return nxJson;\n });\n\n // Replace with simpler sample source code\n tree.delete(joinPathFragments(websiteContentPath, 'src'));\n }\n\n const projectConfiguration = readProjectConfiguration(\n tree,\n fullyQualifiedName,\n );\n\n const targets = projectConfiguration.targets;\n\n const infra = schema.infra ?? 'cloudfront-s3';\n\n // Configure load-runtime-config target based on IaC provider (only when infra is not none)\n const iac = infra !== 'none' ? await resolveIac(tree, schema.iac) : undefined;\n\n if (iac === 'cdk') {\n targets['load-runtime-config'] = {\n executor: 'nx:run-commands',\n metadata: {\n description: `Load runtime config from your deployed stack for dev purposes. You must set your AWS CLI credentials whilst calling '${getPackageManagerDisplayCommands().exec} nx load-runtime-config ${fullyQualifiedName}'`,\n },\n options: {\n command: `aws s3 cp s3://\\`aws cloudformation describe-stacks --query \"Stacks[?starts_with(StackName, '${kebabCase(npmScopePrefix)}-')][].Outputs[] | [?contains(OutputKey, '${websiteNameClassName}WebsiteBucketName')].OutputValue\" --output text\\`/runtime-config.json \"{projectRoot}/public/runtime-config.json\"`,\n },\n };\n } else if (iac === 'terraform') {\n targets['load-runtime-config'] = {\n executor: 'nx:run-commands',\n metadata: {\n description:\n \"Load runtime config from most recently applied terraform env for dev purposes. Copies the runtime config from the Terraform dist directory to the website's public directory.\",\n },\n options: {\n command:\n 'node -e \"const fs=require(\\'fs\\');fs.mkdirSync(process.env.DEST_DIR,{recursive:true});fs.copyFileSync(process.env.SRC_FILE,process.env.DEST_FILE);\"',\n env: {\n SRC_FILE: TERRAFORM_WEBSITE_RUNTIME_CONFIG_FILE,\n DEST_DIR: `{projectRoot}/public`,\n DEST_FILE: `{projectRoot}/public/runtime-config.json`,\n },\n },\n };\n }\n\n if (!projectAlreadyExists) {\n targets['compile'] = {\n // `tsc` needs its dependencies' declarations, which `compile` emits — not\n // their lint or test results.\n dependsOn: ['^compile'],\n executor: 'nx:run-commands',\n outputs: ['{workspaceRoot}/dist/{projectRoot}/tsc'],\n options: {\n command: 'tsc --build tsconfig.app.json',\n cwd: '{projectRoot}',\n },\n };\n // bundle is the @nx/vite/plugin inferred `vite build` (writing to the\n // bundle dir configured in vite.config) — it produces the deployable\n // artifact. build aggregates lint/compile/test/bundle.\n targets['build'] = {\n dependsOn: ['lint', 'compile', 'test', 'bundle'],\n };\n targets['assemble'] = {\n dependsOn: ['compile', 'bundle'],\n };\n\n // Run the website and its connected dependencies locally. Mirrors the\n // inferred `serve` target but with the local-dev vite mode.\n targets['dev'] = {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n command: 'vite --mode local-dev',\n cwd: '{projectRoot}',\n },\n };\n }\n\n projectConfiguration.targets = sortObjectKeys(targets);\n\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfiguration);\n\n // Recorded here and read by the declaration's predicates, so the packages\n // added below are exactly the ones the version sync will own.\n const metadata: TsReactWebsiteMetadata = {\n ux,\n framework: 'react',\n infra,\n tailwind,\n tanstackRouter,\n // Undefined when no infrastructure was generated, so neither provider's\n // packages were added.\n ...(iac ? { iac } : {}),\n };\n addGeneratorMetadata(\n tree,\n projectConfiguration.name,\n REACT_WEBSITE_APP_GENERATOR_INFO,\n metadata,\n );\n\n await configureTsProject(\n tree,\n {\n dir: websiteContentPath,\n fullyQualifiedName,\n },\n DEPENDENCIES,\n );\n\n if (ux === 'shadcn') {\n await sharedShadcnGenerator(tree, DEPENDENCIES);\n }\n\n if (iac) {\n await sharedConstructsGenerator(\n tree,\n {\n iac,\n },\n DEPENDENCIES,\n );\n\n await addWebsiteInfra(tree, {\n iac,\n websiteProjectName: fullyQualifiedName,\n scopeAlias,\n websiteContentPath: joinPathFragments('dist', websiteContentPath),\n websiteNameKebabCase,\n websiteNameClassName,\n });\n }\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n const libraryRoot = projectConfig.root;\n const sharedShadcnStylesImport = relative(\n joinPathFragments(libraryRoot, 'src'),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_SHADCN_DIR,\n 'src',\n 'styles',\n 'globals.css',\n ),\n )\n .split(sep)\n .join('/');\n const sharedShadcnTsconfigRef = relative(\n joinPathFragments(tree.root, websiteContentPath),\n joinPathFragments(\n tree.root,\n PACKAGES_DIR,\n SHARED_SHADCN_DIR,\n 'tsconfig.json',\n ),\n )\n .split(sep)\n .join('/');\n const templateOptions = {\n ...schema,\n fullyQualifiedName,\n pkgMgrCmd: getPackageManagerDisplayCommands().exec,\n tailwind,\n tanstackRouter,\n scopeAlias,\n sharedShadcnStylesImport,\n };\n tree.delete(joinPathFragments(libraryRoot, 'src', 'app'));\n const appCommonTemplatePath = joinPathFragments(\n import.meta.dirname,\n './files/app/common',\n );\n const appTemplatePath = joinPathFragments(\n import.meta.dirname,\n `./files/app/${ux.toLowerCase()}`,\n );\n\n generateFiles(\n tree, // the virtual file system\n appCommonTemplatePath, // path to the file templates\n libraryRoot, // destination path of the files\n templateOptions, // config object to replace variable in file templates\n {\n // User-editable source - preserve any edits on re-run\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree, // the virtual file system\n appTemplatePath, // path to the file templates\n libraryRoot, // destination path of the files\n templateOptions, // config object to replace variable in file templates\n {\n // User-editable source - preserve any edits on re-run\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n if (tanstackRouter) {\n const routerCommonTemplatePath = joinPathFragments(\n import.meta.dirname,\n './files/tanstack-router/common',\n );\n const routerTemplatePath = joinPathFragments(\n import.meta.dirname,\n `./files/tanstack-router/${ux.toLowerCase()}`,\n );\n\n generateFiles(\n tree,\n routerCommonTemplatePath,\n libraryRoot,\n templateOptions,\n {\n // User-editable source (and the TanStack-managed route tree) - preserve on re-run\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree,\n routerTemplatePath,\n libraryRoot,\n templateOptions, // config object to replace variable in file templates\n {\n // User-editable source - preserve any edits on re-run\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n tree.delete(joinPathFragments(websiteContentPath, 'src', 'app.tsx'));\n }\n\n if (e2eTestRunner !== 'none') {\n const e2eFullyQualifiedName = `${fullyQualifiedName}-e2e`;\n const e2eRoot = readProjectConfiguration(tree, e2eFullyQualifiedName).root;\n generateFiles(\n tree, // the virtual file system\n joinPathFragments(import.meta.dirname, `./files/e2e/${e2eTestRunner}`), // path to the file templates\n e2eRoot, // destination path of the files\n { ...schema, ...names(fullyQualifiedName) },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n await configureTsProject(\n tree,\n {\n fullyQualifiedName: e2eFullyQualifiedName,\n dir: e2eRoot,\n },\n DEPENDENCIES,\n );\n }\n const viteConfigPath = joinPathFragments(libraryRoot, 'vite.config.mts');\n\n if (tree.exists(viteConfigPath)) {\n // Add Tanstack Router import if enabled\n if (tanstackRouter) {\n await addDestructuredImport(\n tree,\n viteConfigPath,\n ['tanstackRouter'],\n '@tanstack/router-plugin/vite',\n );\n\n await addDestructuredImport(tree, viteConfigPath, ['resolve'], 'path');\n }\n\n // Add TailwindCSS import if enabled\n if (tailwind) {\n await addSingleImport(\n tree,\n viteConfigPath,\n 'tailwindcss',\n '@tailwindcss/vite',\n );\n }\n\n // Update build.outDir. The inferred `vite build` target writes here, so\n // point it at the bundle dir the website infrastructure consumes.\n const outDir = joinPathFragments(\n getRelativePathToRoot(tree, fullyQualifiedName),\n 'dist',\n websiteContentPath,\n 'bundle',\n );\n await applyGritQL(\n tree,\n viteConfigPath,\n `\\`build: { $bprops }\\` where { $bprops <: contains \\`outDir: $_\\` => \\`outDir: '${outDir}'\\` }`,\n );\n\n // Add plugins to the plugins array\n if (tanstackRouter) {\n // Prepend tanstackRouter (must be first plugin) — rewrite works for both single/multi-element\n await applyGritQL(\n tree,\n viteConfigPath,\n \"`plugins: [$items]` => `plugins: [tanstackRouter({ routesDirectory: resolve(import.meta.dirname, 'src/routes'), generatedRouteTree: resolve(import.meta.dirname, 'src/routeTree.gen.ts') }), $items]` where { $items <: within `defineConfig($_)`, $items <: not contains `tanstackRouter` }\",\n );\n }\n\n if (tailwind) {\n await appendToArrayViaGritQL(\n tree,\n viteConfigPath,\n 'plugins:',\n 'tailwindcss()',\n { scope: 'defineConfig($_)' },\n );\n }\n\n // Use Vite's native tsconfig paths resolution (replaces vite-tsconfig-paths).\n // `dedupe` forces a single copy of react/react-dom into the bundle: each\n // project declares its own react dependency, so without this a workspace\n // library's hoisted copy can produce a second React instance and the\n // \"Invalid hook call\" runtime crash.\n await applyGritQL(\n tree,\n viteConfigPath,\n \"or { `defineConfig(() => ({ $props }))` where { $props <: not some `resolve: $_`, $props += `resolve: { tsconfigPaths: true, dedupe: ['react', 'react-dom'] }` }, `defineConfig({ $props })` where { $props <: not some `resolve: $_`, $props += `resolve: { tsconfigPaths: true, dedupe: ['react', 'react-dom'] }` } }\",\n );\n\n // Add define: { global: {} } to the config (handles both callback and direct forms)\n await applyGritQL(\n tree,\n viteConfigPath,\n 'or { `defineConfig(() => ({ $props }))` where { $props <: not contains `define`, $props += `define: { global: {} }` }, `defineConfig({ $props })` where { $props <: not contains `define`, $props += `define: { global: {} }` } }',\n );\n }\n\n updateJson(\n tree,\n joinPathFragments(websiteContentPath, 'tsconfig.json'),\n (tsconfig) => ({\n ...tsconfig,\n compilerOptions: {\n ...tsconfig.compilerOptions,\n moduleResolution: 'Bundler',\n module: 'Preserve',\n },\n }),\n );\n const outDirToRootRelativePath = relative(\n joinPathFragments(tree.root, websiteContentPath),\n tree.root,\n );\n const distDir = joinPathFragments(\n outDirToRootRelativePath,\n 'dist',\n websiteContentPath,\n 'tsc',\n );\n updateJson(\n tree,\n joinPathFragments(websiteContentPath, 'tsconfig.app.json'),\n (tsconfig) => ({\n ...tsconfig,\n compilerOptions: {\n ...tsconfig.compilerOptions,\n outDir: distDir,\n tsBuildInfoFile: joinPathFragments(distDir, 'tsconfig.lib.tsbuildinfo'),\n lib: ['DOM'],\n },\n references:\n ux === 'shadcn'\n ? [\n ...(tsconfig.references ?? []).filter(\n (ref) => ref.path !== sharedShadcnTsconfigRef,\n ),\n {\n path: sharedShadcnTsconfigRef,\n },\n ]\n : tsconfig.references,\n }),\n );\n\n addTsDependencies(tree, DEPENDENCIES, { metadata, projectRoot: libraryRoot });\n\n // @nx/react declares an optional `express` peer on the major behind the one\n // vended here, for a module-federation dev-server this never runs. npm alone\n // fails the whole install on an optional peer it cannot satisfy, so it gets a\n // scoped override; the other package managers only warn.\n if (detectPackageManager() === 'npm') {\n updateJson(tree, 'package.json', (packageJson) => {\n packageJson.overrides = {\n ...packageJson.overrides,\n '@nx/react': {\n ...packageJson.overrides?.['@nx/react'],\n ...withVersions(DEPENDENCIES, ['express']),\n },\n };\n return packageJson;\n });\n }\n\n // @nx/react's applicationGenerator seeds react/react-dom into the root\n // manifest. The website now declares its own pinned versions, so drop the\n // root copies: without catalogs (npm) the root's floating range resolves to\n // a different version than the website's pin, installing a second React and\n // producing the \"Invalid hook call\" runtime crash.\n removeDependenciesFromPackageJson(tree, ['react', 'react-dom'], []);\n\n await addGeneratorMetricsIfApplicable(tree, [\n REACT_WEBSITE_APP_GENERATOR_INFO,\n ]);\n\n // TanStack Router's vite plugin owns this website's route tree and rewrites it\n // in its own (unformatted) shape whenever the config is loaded — including when\n // Nx computes the project graph — so formatting it here would only make\n // generation non-idempotent. The vended biome config excludes `**/*.gen.*`, so\n // the workspace's own `format` target leaves it alone too.\n await formatFilesInSubtree(tree, undefined, {\n ignore: tanstackRouter\n ? [joinPathFragments(libraryRoot, 'src', 'routeTree.gen.ts')]\n : [],\n });\n // The generated vite.config.mts imports these, and Nx's inferred `@nx/vite`\n // plugin loads that config when computing the project graph — so they must be\n // installed even if the caller would otherwise prefer to defer.\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript'],\n ensureResolvable: [\n ...(tailwind ? (['@tailwindcss/vite'] as const) : []),\n ...(tanstackRouter ? (['@tanstack/router-plugin'] as const) : []),\n ],\n });\n}\nexport default tsReactWebsiteGenerator;\n"],"names":["detectPackageManager","generateFiles","joinPathFragments","names","OverwriteStrategy","readProjectConfiguration","removeDependenciesFromPackageJson","updateJson","updateProjectConfiguration","applicationGenerator","relative","sep","addTsDependencies","addDestructuredImport","addSingleImport","appendToArrayViaGritQL","applyGritQL","declareDependencies","ownedElsewhere","formatFilesInSubtree","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","toClassName","toKebabCase","getNpmScopePrefix","addGeneratorMetadata","getGeneratorInfo","sortObjectKeys","getRelativePathToRoot","getPackageManagerDisplayCommands","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","PACKAGES_DIR","SHARED_SHADCN_DIR","TERRAFORM_WEBSITE_RUNTIME_CONFIG_FILE","SHADCN_DEPENDENCIES","sharedShadcnGenerator","withVersions","addWebsiteInfra","WEBSITE_CONSTRUCTS_PY_DEPENDENCIES","configureTsProject","VITEST_DEPENDENCIES","DEPENDENCIES","ts","name","dev","root","when","m","ux","tanstackRouter","tailwind","versionOnly","py","SUPPORTED_UX_PROVIDERS","REACT_WEBSITE_APP_GENERATOR_INFO","filename","tsReactWebsiteGenerator","tree","schema","Error","npmScopePrefix","scopeAlias","websiteNameClassName","websiteNameKebabCase","fullyQualifiedName","websiteContentPath","directory","subDirectory","projectAlreadyExists","exists","e2eTestRunner","routing","linter","bundler","unitTestRunner","useProjectJson","style","addPlugin","nxJson","plugin","plugins","options","buildTargetName","serveTargetName","devTargetName","previewTargetName","serveStaticTargetName","typecheckTargetName","testTargetName","delete","projectConfiguration","targets","infra","iac","undefined","executor","metadata","description","exec","command","env","SRC_FILE","DEST_DIR","DEST_FILE","dependsOn","outputs","cwd","continuous","framework","dir","websiteProjectName","projectConfig","libraryRoot","sharedShadcnStylesImport","split","join","sharedShadcnTsconfigRef","templateOptions","pkgMgrCmd","appCommonTemplatePath","dirname","appTemplatePath","toLowerCase","overwriteStrategy","KeepExisting","routerCommonTemplatePath","routerTemplatePath","e2eFullyQualifiedName","e2eRoot","viteConfigPath","outDir","scope","tsconfig","compilerOptions","moduleResolution","module","outDirToRootRelativePath","distDir","tsBuildInfoFile","lib","references","filter","ref","path","projectRoot","packageJson","overrides","ignore","preferInstallDependencies","languages","ensureResolvable"],"mappings":"AAAA;;;CAGC,GACD,SACEA,oBAAoB,EACpBC,aAAa,EACbC,iBAAiB,EACjBC,KAAK,EACLC,iBAAiB,EACjBC,wBAAwB,EACxBC,iCAAiC,EAEjCC,UAAU,EACVC,0BAA0B,QACrB,aAAa;AACpB,SAASC,oBAAoB,QAAQ,YAAY;AACjD,SAASC,QAAQ,EAAEC,GAAG,QAAQ,OAAO;AACrC,SAASC,iBAAiB,QAAQ,qCAAqC;AACvE,SACEC,qBAAqB,EACrBC,eAAe,EACfC,sBAAsB,EACtBC,WAAW,QACN,wBAAwB;AAC/B,SACEC,mBAAmB,EACnBC,cAAc,QACT,0CAA0C;AACjD,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,UAAU,QAAQ,wBAAwB;AACnD,SAASC,mBAAmB,QAAQ,4BAA4B;AAChE,SAASC,+BAA+B,QAAQ,4BAA4B;AAC5E,SAASC,SAAS,EAAEC,WAAW,EAAEC,WAAW,QAAQ,0BAA0B;AAC9E,SAASC,iBAAiB,QAAQ,8BAA8B;AAChE,SACEC,oBAAoB,EACpBC,gBAAgB,QAEX,uBAAuB;AAC9B,SAASC,cAAc,QAAQ,2BAA2B;AAC1D,SAASC,qBAAqB,QAAQ,0BAA0B;AAChE,SAASC,gCAAgC,QAAQ,gCAAgC;AACjF,SACEC,8BAA8B,EAC9BC,yBAAyB,QACpB,sCAAsC;AAC7C,SAEEC,YAAY,EACZC,iBAAiB,EACjBC,qCAAqC,QAChC,gDAAgD;AACvD,SACEC,mBAAmB,EACnBC,qBAAqB,QAChB,kCAAkC;AACzC,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SACEC,eAAe,EACfC,kCAAkC,Q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GAAG9G,aAAaK,cAAc;wBAAC;qBAAU,CAAC;gBAC5C;YACF;YACA,OAAOwG;QACT;IACF;IAEA,uEAAuE;IACvE,0EAA0E;IAC1E,4EAA4E;IAC5E,4EAA4E;IAC5E,mDAAmD;IACnD9I,kCAAkCsD,MAAM;QAAC;QAAS;KAAY,EAAE,EAAE;IAElE,MAAMtC,gCAAgCsC,MAAM;QAC1CH;KACD;IAED,+EAA+E;IAC/E,gFAAgF;IAChF,wEAAwE;IACxE,+EAA+E;IAC/E,2DAA2D;IAC3D,MAAMtC,qBAAqByC,MAAMqC,WAAW;QAC1CqD,QAAQlG,iBACJ;YAAClD,kBAAkBiH,aAAa,OAAO;SAAoB,GAC3D,EAAE;IACR;IACA,4EAA4E;IAC5E,8EAA8E;IAC9E,gEAAgE;IAChE,OAAO,IACL9F,oBAAoBuC,MAAMC,OAAO0F,yBAAyB,EAAE;YAC1DC,WAAW;gBAAC;aAAa;YACzBC,kBAAkB;mBACZpG,WAAY;oBAAC;iBAAoB,GAAa,EAAE;mBAChDD,iBAAkB;oBAAC;iBAA0B,GAAa,EAAE;aACjE;QACH;AACJ;AACA,eAAeO,wBAAwB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/ts/react-website/app/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n detectPackageManager,\n generateFiles,\n joinPathFragments,\n names,\n OverwriteStrategy,\n readProjectConfiguration,\n removeDependenciesFromPackageJson,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { applicationGenerator } from '@nx/react';\nimport { relative, sep } from 'path';\nimport { addTsDependencies } from '../../../utils/add-dependencies.js';\nimport {\n addDestructuredImport,\n addSingleImport,\n appendToArrayViaGritQL,\n applyGritQL,\n} from '../../../utils/ast.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\nimport { resolveIac } from '../../../utils/iac.js';\nimport { installDependencies } from '../../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics.js';\nimport { kebabCase, toClassName, toKebabCase } from '../../../utils/names.js';\nimport { getNpmScopePrefix } from '../../../utils/npm-scope.js';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../../utils/nx.js';\nimport { sortObjectKeys } from '../../../utils/object.js';\nimport { getRelativePathToRoot } from '../../../utils/paths.js';\nimport { getPackageManagerDisplayCommands } from '../../../utils/pkg-manager.js';\nimport { assignPort } from '../../../utils/port.js';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../../utils/shared-constructs.js';\nimport {\n type IacMetadata,\n PACKAGES_DIR,\n SHARED_SHADCN_DIR,\n TERRAFORM_WEBSITE_RUNTIME_CONFIG_FILE,\n} from '../../../utils/shared-constructs-constants.js';\nimport {\n SHADCN_DEPENDENCIES,\n sharedShadcnGenerator,\n} from '../../../utils/shared-shadcn.js';\nimport { withVersions } from '../../../utils/versions.js';\nimport {\n addWebsiteInfra,\n WEBSITE_CONSTRUCTS_PY_DEPENDENCIES,\n} from '../../../utils/website-constructs/website-constructs.js';\nimport { configureTsProject } from '../../lib/ts-project-utils.js';\nimport { VITEST_DEPENDENCIES } from '../../lib/vitest.js';\n// typescript factory imports removed — now using GritQL for vite config transforms\nimport type {\n TsReactWebsiteGeneratorSchema,\n WebsiteInfraOption,\n} from './schema';\n\n/** The metadata this generator records, which its predicates read. */\nexport interface TsReactWebsiteMetadata extends IacMetadata {\n readonly ux: UxOption;\n readonly framework: string;\n readonly infra: WebsiteInfraOption;\n readonly tailwind: boolean;\n readonly tanstackRouter: boolean;\n}\n\n// Each entry names the branch it belongs to, so the same declaration drives both\n// adding and the version sync.\nexport const DEPENDENCIES = declareDependencies<TsReactWebsiteMetadata>()({\n ts: [\n { name: 'react' },\n { name: 'react-dom' },\n // Build/test tooling imported only from vite.config.mts stays at the root.\n { name: '@nx/react', dev: true, root: true },\n { name: '@vitest/ui', dev: true, root: true },\n {\n name: '@cloudscape-design/components',\n when: (m) => m.ux === 'cloudscape',\n },\n {\n name: '@cloudscape-design/board-components',\n when: (m) => m.ux === 'cloudscape',\n },\n {\n name: '@cloudscape-design/global-styles',\n when: (m) => m.ux === 'cloudscape',\n },\n // Shared shadcn components live in the common/shadcn package, but the\n // website's own generated components (e.g. the tanstack-router sidebar)\n // import lucide-react directly, so the website must declare it.\n {\n name: 'lucide-react',\n when: (m) => m.ux === 'shadcn' && m.tanstackRouter,\n },\n { name: 'tailwindcss', when: (m) => m.tailwind },\n {\n name: '@tailwindcss/vite',\n when: (m) => m.tailwind,\n dev: true,\n root: true,\n },\n { name: '@tanstack/react-router', when: (m) => m.tanstackRouter },\n {\n name: '@tanstack/router-plugin',\n when: (m) => m.tanstackRouter,\n dev: true,\n root: true,\n },\n {\n name: '@tanstack/router-generator',\n when: (m) => m.tanstackRouter,\n dev: true,\n root: true,\n },\n {\n name: '@tanstack/virtual-file-routes',\n when: (m) => m.tanstackRouter,\n dev: true,\n root: true,\n },\n {\n name: '@tanstack/router-utils',\n when: (m) => m.tanstackRouter,\n dev: true,\n root: true,\n },\n // Declared for its pinned version, which goes into npm's `overrides` below.\n { name: 'express', versionOnly: true },\n ...ownedElsewhere(SHADCN_DEPENDENCIES),\n ...ownedElsewhere(VITEST_DEPENDENCIES),\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n py: ownedElsewhere(WEBSITE_CONSTRUCTS_PY_DEPENDENCIES),\n});\n\nexport const SUPPORTED_UX_PROVIDERS = ['none', 'cloudscape', 'shadcn'] as const;\n\nexport type UxOption = (typeof SUPPORTED_UX_PROVIDERS)[number];\n\nexport type Ux = UxOption;\n\nexport const REACT_WEBSITE_APP_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport async function tsReactWebsiteGenerator(\n tree: Tree,\n schema: TsReactWebsiteGeneratorSchema,\n) {\n const tailwind = schema.tailwind ?? true;\n const tanstackRouter = schema.tanstackRouter ?? true;\n const ux: Ux = schema.ux ?? 'shadcn';\n if (ux === 'shadcn' && !tailwind) {\n throw new Error('Shadcn requires TailwindCSS to be enabled.');\n }\n const npmScopePrefix = getNpmScopePrefix(tree);\n const scopeAlias = npmScopePrefix;\n const websiteNameClassName = toClassName(schema.name);\n const websiteNameKebabCase = toKebabCase(schema.name);\n const fullyQualifiedName = `${npmScopePrefix}${websiteNameKebabCase}`;\n // NB: interactive nx generator cli can pass empty string\n const websiteContentPath = joinPathFragments(\n schema.directory || '.',\n schema.subDirectory || websiteNameKebabCase,\n );\n\n const projectAlreadyExists = tree.exists(\n joinPathFragments(websiteContentPath, 'project.json'),\n );\n\n // TODO: consider exposing and supporting e2e tests\n const e2eTestRunner = 'none';\n\n if (!projectAlreadyExists) {\n await applicationGenerator(tree, {\n ...schema,\n name: fullyQualifiedName,\n directory: websiteContentPath,\n routing: false,\n e2eTestRunner,\n linter: 'none',\n bundler: 'vite',\n unitTestRunner: 'vitest',\n useProjectJson: true,\n style: 'css',\n // Register the @nx/vite and @nx/vitest plugins so build/serve/test\n // targets are inferred rather than emitting deprecated executor targets.\n addPlugin: true,\n });\n\n // Pin the inferred target names. The vite production build is exposed as\n // `bundle` (which produces the deployable artifact), leaving `build` as an\n // aggregator over lint/compile/test/bundle. vite's own typecheck is dropped\n // in favour of the tsc `compile`.\n updateJson(tree, 'nx.json', (nxJson) => {\n for (const plugin of nxJson.plugins ?? []) {\n if (typeof plugin === 'string') continue;\n if (plugin.plugin === '@nx/vite/plugin') {\n plugin.options = {\n ...plugin.options,\n buildTargetName: 'bundle',\n // Map both of vite's inferred dev-server targets onto `serve` so the\n // plugin doesn't emit a separate `dev`; we author our own `dev`\n // below running the local-dev vite mode.\n serveTargetName: 'serve',\n devTargetName: 'serve',\n previewTargetName: 'preview',\n serveStaticTargetName: 'serve-static',\n typecheckTargetName: 'vite:typecheck',\n };\n } else if (plugin.plugin === '@nx/vitest') {\n plugin.options = {\n ...plugin.options,\n testTargetName: 'test',\n };\n }\n }\n return nxJson;\n });\n\n // Replace with simpler sample source code\n tree.delete(joinPathFragments(websiteContentPath, 'src'));\n }\n\n const projectConfiguration = readProjectConfiguration(\n tree,\n fullyQualifiedName,\n );\n\n const targets = projectConfiguration.targets;\n\n // Each website gets its own explicit dev-server port. Vite itself already\n // auto-increments past a port already in use, so two websites don't actually\n // collide — but which port each one lands on then depends on start order and\n // can't be known ahead of time. An explicit, per-project port is what lets\n // the Cognito callback URL allow-list (added when auth is configured) be\n // computed deterministically instead.\n const port = assignPort(tree, projectConfiguration, 4200);\n // @nx/react's vite config defaults to 4200 for the dev server and 4300 for\n // preview; keep that +100 relationship so the pair stays predictable.\n const previewPort = port + 100;\n\n const infra = schema.infra ?? 'cloudfront-s3';\n\n // Configure load-runtime-config target based on IaC provider (only when infra is not none)\n const iac = infra !== 'none' ? await resolveIac(tree, schema.iac) : undefined;\n\n if (iac === 'cdk') {\n targets['load-runtime-config'] = {\n executor: 'nx:run-commands',\n metadata: {\n description: `Load runtime config from your deployed stack for dev purposes. You must set your AWS CLI credentials whilst calling '${getPackageManagerDisplayCommands().exec} nx load-runtime-config ${fullyQualifiedName}'`,\n },\n options: {\n command: `aws s3 cp s3://\\`aws cloudformation describe-stacks --query \"Stacks[?starts_with(StackName, '${kebabCase(npmScopePrefix)}-')][].Outputs[] | [?contains(OutputKey, '${websiteNameClassName}WebsiteBucketName')].OutputValue\" --output text\\`/runtime-config.json \"{projectRoot}/public/runtime-config.json\"`,\n },\n };\n } else if (iac === 'terraform') {\n targets['load-runtime-config'] = {\n executor: 'nx:run-commands',\n metadata: {\n description:\n \"Load runtime config from most recently applied terraform env for dev purposes. Copies the runtime config from the Terraform dist directory to the website's public directory.\",\n },\n options: {\n command:\n 'node -e \"const fs=require(\\'fs\\');fs.mkdirSync(process.env.DEST_DIR,{recursive:true});fs.copyFileSync(process.env.SRC_FILE,process.env.DEST_FILE);\"',\n env: {\n SRC_FILE: TERRAFORM_WEBSITE_RUNTIME_CONFIG_FILE,\n DEST_DIR: `{projectRoot}/public`,\n DEST_FILE: `{projectRoot}/public/runtime-config.json`,\n },\n },\n };\n }\n\n if (!projectAlreadyExists) {\n targets['compile'] = {\n // `tsc` needs its dependencies' declarations, which `compile` emits — not\n // their lint or test results.\n dependsOn: ['^compile'],\n executor: 'nx:run-commands',\n outputs: ['{workspaceRoot}/dist/{projectRoot}/tsc'],\n options: {\n command: 'tsc --build tsconfig.app.json',\n cwd: '{projectRoot}',\n },\n };\n // bundle is the @nx/vite/plugin inferred `vite build` (writing to the\n // bundle dir configured in vite.config) — it produces the deployable\n // artifact. build aggregates lint/compile/test/bundle.\n targets['build'] = {\n dependsOn: ['lint', 'compile', 'test', 'bundle'],\n };\n targets['assemble'] = {\n dependsOn: ['compile', 'bundle'],\n };\n\n // Run the website and its connected dependencies locally. Mirrors the\n // inferred `serve` target but with the local-dev vite mode.\n targets['dev'] = {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n command: 'vite --mode local-dev',\n cwd: '{projectRoot}',\n },\n };\n }\n\n projectConfiguration.targets = sortObjectKeys(targets);\n\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfiguration);\n\n // Recorded here and read by the declaration's predicates, so the packages\n // added below are exactly the ones the version sync will own.\n const metadata: TsReactWebsiteMetadata = {\n ux,\n framework: 'react',\n infra,\n tailwind,\n tanstackRouter,\n // Undefined when no infrastructure was generated, so neither provider's\n // packages were added.\n ...(iac ? { iac } : {}),\n };\n addGeneratorMetadata(\n tree,\n projectConfiguration.name,\n REACT_WEBSITE_APP_GENERATOR_INFO,\n metadata,\n );\n\n await configureTsProject(\n tree,\n {\n dir: websiteContentPath,\n fullyQualifiedName,\n },\n DEPENDENCIES,\n );\n\n if (ux === 'shadcn') {\n await sharedShadcnGenerator(tree, DEPENDENCIES);\n }\n\n if (iac) {\n await sharedConstructsGenerator(\n tree,\n {\n iac,\n },\n DEPENDENCIES,\n );\n\n await addWebsiteInfra(tree, {\n iac,\n websiteProjectName: fullyQualifiedName,\n scopeAlias,\n websiteContentPath: joinPathFragments('dist', websiteContentPath),\n websiteNameKebabCase,\n websiteNameClassName,\n });\n }\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n const libraryRoot = projectConfig.root;\n const sharedShadcnStylesImport = relative(\n joinPathFragments(libraryRoot, 'src'),\n joinPathFragments(\n PACKAGES_DIR,\n SHARED_SHADCN_DIR,\n 'src',\n 'styles',\n 'globals.css',\n ),\n )\n .split(sep)\n .join('/');\n const sharedShadcnTsconfigRef = relative(\n joinPathFragments(tree.root, websiteContentPath),\n joinPathFragments(\n tree.root,\n PACKAGES_DIR,\n SHARED_SHADCN_DIR,\n 'tsconfig.json',\n ),\n )\n .split(sep)\n .join('/');\n const templateOptions = {\n ...schema,\n fullyQualifiedName,\n pkgMgrCmd: getPackageManagerDisplayCommands().exec,\n tailwind,\n tanstackRouter,\n scopeAlias,\n sharedShadcnStylesImport,\n };\n tree.delete(joinPathFragments(libraryRoot, 'src', 'app'));\n const appCommonTemplatePath = joinPathFragments(\n import.meta.dirname,\n './files/app/common',\n );\n const appTemplatePath = joinPathFragments(\n import.meta.dirname,\n `./files/app/${ux.toLowerCase()}`,\n );\n\n generateFiles(\n tree, // the virtual file system\n appCommonTemplatePath, // path to the file templates\n libraryRoot, // destination path of the files\n templateOptions, // config object to replace variable in file templates\n {\n // User-editable source - preserve any edits on re-run\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree, // the virtual file system\n appTemplatePath, // path to the file templates\n libraryRoot, // destination path of the files\n templateOptions, // config object to replace variable in file templates\n {\n // User-editable source - preserve any edits on re-run\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n if (tanstackRouter) {\n const routerCommonTemplatePath = joinPathFragments(\n import.meta.dirname,\n './files/tanstack-router/common',\n );\n const routerTemplatePath = joinPathFragments(\n import.meta.dirname,\n `./files/tanstack-router/${ux.toLowerCase()}`,\n );\n\n generateFiles(\n tree,\n routerCommonTemplatePath,\n libraryRoot,\n templateOptions,\n {\n // User-editable source (and the TanStack-managed route tree) - preserve on re-run\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n generateFiles(\n tree,\n routerTemplatePath,\n libraryRoot,\n templateOptions, // config object to replace variable in file templates\n {\n // User-editable source - preserve any edits on re-run\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n tree.delete(joinPathFragments(websiteContentPath, 'src', 'app.tsx'));\n }\n\n if (e2eTestRunner !== 'none') {\n const e2eFullyQualifiedName = `${fullyQualifiedName}-e2e`;\n const e2eRoot = readProjectConfiguration(tree, e2eFullyQualifiedName).root;\n generateFiles(\n tree, // the virtual file system\n joinPathFragments(import.meta.dirname, `./files/e2e/${e2eTestRunner}`), // path to the file templates\n e2eRoot, // destination path of the files\n { ...schema, ...names(fullyQualifiedName) },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n await configureTsProject(\n tree,\n {\n fullyQualifiedName: e2eFullyQualifiedName,\n dir: e2eRoot,\n },\n DEPENDENCIES,\n );\n }\n const viteConfigPath = joinPathFragments(libraryRoot, 'vite.config.mts');\n\n if (tree.exists(viteConfigPath)) {\n // Add Tanstack Router import if enabled\n if (tanstackRouter) {\n await addDestructuredImport(\n tree,\n viteConfigPath,\n ['tanstackRouter'],\n '@tanstack/router-plugin/vite',\n );\n\n await addDestructuredImport(tree, viteConfigPath, ['resolve'], 'path');\n }\n\n // Add TailwindCSS import if enabled\n if (tailwind) {\n await addSingleImport(\n tree,\n viteConfigPath,\n 'tailwindcss',\n '@tailwindcss/vite',\n );\n }\n\n // Update build.outDir. The inferred `vite build` target writes here, so\n // point it at the bundle dir the website infrastructure consumes.\n const outDir = joinPathFragments(\n getRelativePathToRoot(tree, fullyQualifiedName),\n 'dist',\n websiteContentPath,\n 'bundle',\n );\n await applyGritQL(\n tree,\n viteConfigPath,\n `\\`build: { $bprops }\\` where { $bprops <: contains \\`outDir: $_\\` => \\`outDir: '${outDir}'\\` }`,\n );\n\n // Replace @nx/react's default dev-server port (4200) with the one assigned above.\n await applyGritQL(\n tree,\n viteConfigPath,\n `\\`server: { $sprops }\\` where { $sprops <: contains \\`port: $_\\` => \\`port: ${port}\\` }`,\n );\n\n // Likewise for the preview port (@nx/react's default is 4300), so `vite preview`\n // doesn't collide across websites either.\n await applyGritQL(\n tree,\n viteConfigPath,\n `\\`preview: { $pprops }\\` where { $pprops <: contains \\`port: $_\\` => \\`port: ${previewPort}\\` }`,\n );\n\n // Add plugins to the plugins array\n if (tanstackRouter) {\n // Prepend tanstackRouter (must be first plugin) — rewrite works for both single/multi-element\n await applyGritQL(\n tree,\n viteConfigPath,\n \"`plugins: [$items]` => `plugins: [tanstackRouter({ routesDirectory: resolve(import.meta.dirname, 'src/routes'), generatedRouteTree: resolve(import.meta.dirname, 'src/routeTree.gen.ts') }), $items]` where { $items <: within `defineConfig($_)`, $items <: not contains `tanstackRouter` }\",\n );\n }\n\n if (tailwind) {\n await appendToArrayViaGritQL(\n tree,\n viteConfigPath,\n 'plugins:',\n 'tailwindcss()',\n { scope: 'defineConfig($_)' },\n );\n }\n\n // Use Vite's native tsconfig paths resolution (replaces vite-tsconfig-paths).\n // `dedupe` forces a single copy of react/react-dom into the bundle: each\n // project declares its own react dependency, so without this a workspace\n // library's hoisted copy can produce a second React instance and the\n // \"Invalid hook call\" runtime crash.\n await applyGritQL(\n tree,\n viteConfigPath,\n \"or { `defineConfig(() => ({ $props }))` where { $props <: not some `resolve: $_`, $props += `resolve: { tsconfigPaths: true, dedupe: ['react', 'react-dom'] }` }, `defineConfig({ $props })` where { $props <: not some `resolve: $_`, $props += `resolve: { tsconfigPaths: true, dedupe: ['react', 'react-dom'] }` } }\",\n );\n\n // Add define: { global: {} } to the config (handles both callback and direct forms)\n await applyGritQL(\n tree,\n viteConfigPath,\n 'or { `defineConfig(() => ({ $props }))` where { $props <: not contains `define`, $props += `define: { global: {} }` }, `defineConfig({ $props })` where { $props <: not contains `define`, $props += `define: { global: {} }` } }',\n );\n }\n\n updateJson(\n tree,\n joinPathFragments(websiteContentPath, 'tsconfig.json'),\n (tsconfig) => ({\n ...tsconfig,\n compilerOptions: {\n ...tsconfig.compilerOptions,\n moduleResolution: 'Bundler',\n module: 'Preserve',\n },\n }),\n );\n const outDirToRootRelativePath = relative(\n joinPathFragments(tree.root, websiteContentPath),\n tree.root,\n );\n const distDir = joinPathFragments(\n outDirToRootRelativePath,\n 'dist',\n websiteContentPath,\n 'tsc',\n );\n updateJson(\n tree,\n joinPathFragments(websiteContentPath, 'tsconfig.app.json'),\n (tsconfig) => ({\n ...tsconfig,\n compilerOptions: {\n ...tsconfig.compilerOptions,\n outDir: distDir,\n tsBuildInfoFile: joinPathFragments(distDir, 'tsconfig.lib.tsbuildinfo'),\n lib: ['DOM'],\n },\n references:\n ux === 'shadcn'\n ? [\n ...(tsconfig.references ?? []).filter(\n (ref) => ref.path !== sharedShadcnTsconfigRef,\n ),\n {\n path: sharedShadcnTsconfigRef,\n },\n ]\n : tsconfig.references,\n }),\n );\n\n addTsDependencies(tree, DEPENDENCIES, { metadata, projectRoot: libraryRoot });\n\n // @nx/react declares an optional `express` peer on the major behind the one\n // vended here, for a module-federation dev-server this never runs. npm alone\n // fails the whole install on an optional peer it cannot satisfy, so it gets a\n // scoped override; the other package managers only warn.\n if (detectPackageManager() === 'npm') {\n updateJson(tree, 'package.json', (packageJson) => {\n packageJson.overrides = {\n ...packageJson.overrides,\n '@nx/react': {\n ...packageJson.overrides?.['@nx/react'],\n ...withVersions(DEPENDENCIES, ['express']),\n },\n };\n return packageJson;\n });\n }\n\n // @nx/react's applicationGenerator seeds react/react-dom into the root\n // manifest. The website now declares its own pinned versions, so drop the\n // root copies: without catalogs (npm) the root's floating range resolves to\n // a different version than the website's pin, installing a second React and\n // producing the \"Invalid hook call\" runtime crash.\n removeDependenciesFromPackageJson(tree, ['react', 'react-dom'], []);\n\n await addGeneratorMetricsIfApplicable(tree, [\n REACT_WEBSITE_APP_GENERATOR_INFO,\n ]);\n\n // TanStack Router's vite plugin owns this website's route tree and rewrites it\n // in its own (unformatted) shape whenever the config is loaded — including when\n // Nx computes the project graph — so formatting it here would only make\n // generation non-idempotent. The vended biome config excludes `**/*.gen.*`, so\n // the workspace's own `format` target leaves it alone too.\n await formatFilesInSubtree(tree, undefined, {\n ignore: tanstackRouter\n ? [joinPathFragments(libraryRoot, 'src', 'routeTree.gen.ts')]\n : [],\n });\n // The generated vite.config.mts imports these, and Nx's inferred `@nx/vite`\n // plugin loads that config when computing the project graph — so they must be\n // installed even if the caller would otherwise prefer to defer.\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript'],\n ensureResolvable: [\n ...(tailwind ? (['@tailwindcss/vite'] as const) : []),\n ...(tanstackRouter ? (['@tanstack/router-plugin'] as const) : []),\n ],\n });\n}\nexport default tsReactWebsiteGenerator;\n"],"names":["detectPackageManager","generateFiles","joinPathFragments","names","OverwriteStrategy","readProjectConfiguration","removeDependenciesFromPackageJson","updateJson","updateProjectConfiguration","applicationGenerator","relative","sep","addTsDependencies","addDestructuredImport","addSingleImport","appendToArrayViaGritQL","applyGritQL","declareDependencies","ownedElsewhere","formatFilesInSubtree","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","toClassName","toKebabCase","getNpmScopePrefix","addGeneratorMetadata","getGeneratorInfo","sortObjectKeys","getRelativePathToRoot","getPackageManagerDisplayCommands","assignPort","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","PACKAGES_DIR","SHARED_SHADCN_DIR","TERRAFORM_WEBSITE_RUNTIME_CONFIG_FILE","SHADCN_DEPENDENCIES","sharedShadcnGenerator","withVersions","addWebsiteInfra","WEBSITE_CONSTRUCTS_PY_DEPENDENCIES","configureTsProject","VITEST_DEPENDENCIES","DEPENDENCIES","ts","name","dev","root","when","m","ux","tanstackRouter","tailwind","versionOnly","py","SUPPORTED_UX_PROVIDERS","REACT_WEBSITE_APP_GENERATOR_INFO","filename","tsReactWebsiteGenerator","tree","schema","Error","npmScopePrefix","scopeAlias","websiteNameClassName","websiteNameKebabCase","fullyQualifiedName","websiteContentPath","directory","subDirectory","projectAlreadyExists","exists","e2eTestRunner","routing","linter","bundler","unitTestRunner","useProjectJson","style","addPlugin","nxJson","plugin","plugins","options","buildTargetName","serveTargetName","devTargetName","previewTargetName","serveStaticTargetName","typecheckTargetName","testTargetName","delete","projectConfiguration","targets","port","previewPort","infra","iac","undefined","executor","metadata","description","exec","command","env","SRC_FILE","DEST_DIR","DEST_FILE","dependsOn","outputs","cwd","continuous","framework","dir","websiteProjectName","projectConfig","libraryRoot","sharedShadcnStylesImport","split","join","sharedShadcnTsconfigRef","templateOptions","pkgMgrCmd","appCommonTemplatePath","dirname","appTemplatePath","toLowerCase","overwriteStrategy","KeepExisting","routerCommonTemplatePath","routerTemplatePath","e2eFullyQualifiedName","e2eRoot","viteConfigPath","outDir","scope","tsconfig","compilerOptions","moduleResolution","module","outDirToRootRelativePath","distDir","tsBuildInfoFile","lib","references","filter","ref","path","projectRoot","packageJson","overrides","ignore","preferInstallDependencies","languages","ensureResolvable"],"mappings":"AAAA;;;CAGC,GACD,SACEA,oBAAoB,EACpBC,aAAa,EACbC,iBAAiB,EACjBC,KAAK,EACLC,iBAAiB,EACjBC,wBAAwB,EACxBC,iCAAiC,EAEjCC,UAAU,EACVC,0BAA0B,QACrB,aAAa;AACpB,SAASC,oBAAoB,QAAQ,YAAY;AACjD,SAASC,QAAQ,EAAEC,GAAG,QAAQ,OAAO;AACrC,SAASC,iBAAiB,QAAQ,qCAAqC;AACvE,SACEC,qBAAqB,EACrBC,eAAe,EACfC,sBAAsB,EACtBC,WAAW,QACN,wBAAwB;AAC/B,SACEC,mBAAmB,EACnBC,cAAc,QACT,0CAA0C;AACjD,SAASC,oBAAoB,QA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AAC;QAAS;KAAY,EAAE,EAAE;IAElE,MAAMvC,gCAAgCuC,MAAM;QAC1CH;KACD;IAED,+EAA+E;IAC/E,gFAAgF;IAChF,wEAAwE;IACxE,+EAA+E;IAC/E,2DAA2D;IAC3D,MAAMvC,qBAAqB0C,MAAMuC,WAAW;QAC1CqD,QAAQpG,iBACJ;YAACnD,kBAAkBoH,aAAa,OAAO;SAAoB,GAC3D,EAAE;IACR;IACA,4EAA4E;IAC5E,8EAA8E;IAC9E,gEAAgE;IAChE,OAAO,IACLjG,oBAAoBwC,MAAMC,OAAO4F,yBAAyB,EAAE;YAC1DC,WAAW;gBAAC;aAAa;YACzBC,kBAAkB;mBACZtG,WAAY;oBAAC;iBAAoB,GAAa,EAAE;mBAChDD,iBAAkB;oBAAC;iBAA0B,GAAa,EAAE;aACjE;QACH;AACJ;AACA,eAAeO,wBAAwB"}
|
|
@@ -16,6 +16,7 @@ import { addGeneratorMetricsIfApplicable } from "../../../utils/metrics.js";
|
|
|
16
16
|
import { getNpmScope } from "../../../utils/npm-scope.js";
|
|
17
17
|
import { addComponentGeneratorMetadata, getGeneratorInfo, readProjectConfigurationUnqualified } from "../../../utils/nx.js";
|
|
18
18
|
import { toProjectRelativePath } from "../../../utils/paths.js";
|
|
19
|
+
import { getExistingProjectPort } from "../../../utils/port.js";
|
|
19
20
|
import { SHARED_CONSTRUCTS_DEPENDENCIES, sharedConstructsGenerator } from "../../../utils/shared-constructs.js";
|
|
20
21
|
import { runtimeConfigGenerator } from "../runtime-config/generator.js";
|
|
21
22
|
import { addCloudscapeAuthMenu, addNoneAuthMenu, addShadcnAuthMenu, deriveCognitoDomainPrefix } from "./utils.js";
|
|
@@ -45,11 +46,22 @@ export async function tsReactWebsiteAuthGenerator(tree, options) {
|
|
|
45
46
|
await sharedConstructsGenerator(tree, {
|
|
46
47
|
iac
|
|
47
48
|
}, DEPENDENCIES);
|
|
48
|
-
|
|
49
|
+
// Falls back to Vite's own defaults when the website predates per-project
|
|
50
|
+
// port assignment, matching the shared construct's own defaults.
|
|
51
|
+
const localDevServerPort = getExistingProjectPort(projectConfig) ?? 4200;
|
|
52
|
+
const localPreviewPort = localDevServerPort + 100;
|
|
53
|
+
const portsNotAllowListed = await addIdentityInfra(tree, {
|
|
49
54
|
iac,
|
|
50
55
|
allowSignup: options.allowSignup,
|
|
51
|
-
cognitoDomain
|
|
56
|
+
cognitoDomain,
|
|
57
|
+
localCallbackPorts: [
|
|
58
|
+
localDevServerPort,
|
|
59
|
+
localPreviewPort
|
|
60
|
+
]
|
|
52
61
|
});
|
|
62
|
+
if (portsNotAllowListed.length > 0) {
|
|
63
|
+
console.warn(`Could not add ${portsNotAllowListed.map((p)=>`http://localhost:${p}`).join(', ')} to the local callback/logout URLs in the shared user identity ${iac === 'cdk' ? 'construct' : 'module'}, since it no longer matches the generated shape. Add them by hand, otherwise signing in against ${options.project}'s local dev server will fail.`);
|
|
64
|
+
}
|
|
53
65
|
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files', 'app'), srcRoot, options, {
|
|
54
66
|
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
55
67
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/ts/react-website/cognito-auth/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n} from '@nx/devkit';\nimport { readFileSync } from 'fs';\nimport { join } from 'path';\nimport { addTsDependencies } from '../../../utils/add-dependencies.js';\nimport { addHookResultToRouterProviderContext } from '../../../utils/ast/website.js';\nimport {\n addDestructuredImport,\n addSingleImport,\n applyGritQL,\n} from '../../../utils/ast.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\nimport { resolveIac } from '../../../utils/iac.js';\nimport {\n addIdentityInfra,\n IDENTITY_CONSTRUCTS_PY_DEPENDENCIES,\n} from '../../../utils/identity-constructs/identity-constructs.js';\nimport { installDependencies } from '../../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics.js';\nimport { getNpmScope } from '../../../utils/npm-scope.js';\nimport {\n addComponentGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx.js';\nimport { toProjectRelativePath } from '../../../utils/paths.js';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../../utils/shared-constructs.js';\nimport { runtimeConfigGenerator } from '../runtime-config/generator.js';\nimport type { TsReactWebsiteAuthGeneratorSchema } from './schema';\nimport {\n addCloudscapeAuthMenu,\n addNoneAuthMenu,\n addShadcnAuthMenu,\n deriveCognitoDomainPrefix,\n} from './utils.js';\n\nconst readGritPattern = (name: string): string =>\n readFileSync(\n join(import.meta.dirname, 'grit', `${name}.grit`),\n 'utf-8',\n ).trim();\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [\n { name: 'oidc-client-ts' },\n { name: 'react-oidc-context' },\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n py: ownedElsewhere(IDENTITY_CONSTRUCTS_PY_DEPENDENCIES),\n});\n\nexport const COGNITO_AUTH_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport async function tsReactWebsiteAuthGenerator(\n tree: Tree,\n options: TsReactWebsiteAuthGeneratorSchema,\n) {\n const projectConfig = readProjectConfigurationUnqualified(\n tree,\n options.project,\n );\n const srcRoot = projectConfig.sourceRoot;\n\n const cognitoDomain =\n options.cognitoDomain && options.cognitoDomain.length > 0\n ? options.cognitoDomain\n : deriveCognitoDomainPrefix(getNpmScope(tree), projectConfig.name!);\n\n await runtimeConfigGenerator(tree, {\n project: options.project,\n preferInstallDependencies: false,\n });\n\n const iac = await resolveIac(tree, options.iac);\n\n await sharedConstructsGenerator(\n tree,\n {\n iac,\n },\n DEPENDENCIES,\n );\n\n await addIdentityInfra(tree, {\n iac,\n allowSignup: options.allowSignup,\n cognitoDomain,\n });\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'app'),\n srcRoot,\n options,\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n addTsDependencies(tree, DEPENDENCIES, { projectRoot: projectConfig.root });\n\n const mainTsxPath = joinPathFragments(srcRoot, 'main.tsx');\n\n await addSingleImport(\n tree,\n mainTsxPath,\n 'CognitoAuth',\n './components/CognitoAuth',\n );\n\n await addHookResultToRouterProviderContext(tree, mainTsxPath, {\n hook: 'useAuth',\n module: 'react-oidc-context',\n contextProp: 'auth',\n });\n\n const projectConfiguration = readProjectConfigurationUnqualified(\n tree,\n options.project,\n );\n\n const ux = (\n (projectConfiguration.metadata as any)?.ux ?? 'shadcn'\n ).toLowerCase();\n\n await applyGritQL(tree, mainTsxPath, readGritPattern('cognito-auth-wrapper'));\n // Update App Layout\n const appLayoutTsxPath = joinPathFragments(\n srcRoot,\n 'components',\n 'AppLayout',\n 'index.tsx',\n );\n if (tree.exists(appLayoutTsxPath)) {\n await addDestructuredImport(\n tree,\n appLayoutTsxPath,\n ['useAuth'],\n 'react-oidc-context',\n );\n await applyGritQL(\n tree,\n appLayoutTsxPath,\n readGritPattern('app-layout-use-auth'),\n );\n // TODO: update utils if they exist by appending to the array\n // Add a top-level navigation menu that shows the signed-in user's profile and actions\n switch (ux) {\n case 'cloudscape':\n await addCloudscapeAuthMenu(tree, appLayoutTsxPath);\n break;\n case 'shadcn':\n await addShadcnAuthMenu(tree, appLayoutTsxPath);\n break;\n case 'none':\n await addNoneAuthMenu(tree, appLayoutTsxPath);\n break;\n default:\n throw new Error(\n `Top-level navigation menu to show the signed-in user for ux \"${ux}\" is not implemented.`,\n );\n }\n } else {\n console.info(\n `Skipping update to ${appLayoutTsxPath} as it does not exist.`,\n );\n }\n // End update App Layout\n\n addComponentGeneratorMetadata(\n tree,\n options.project,\n COGNITO_AUTH_GENERATOR_INFO,\n toProjectRelativePath(\n projectConfig,\n joinPathFragments(srcRoot, 'components', 'CognitoAuth'),\n ),\n undefined,\n { iac },\n );\n\n await addGeneratorMetricsIfApplicable(tree, [COGNITO_AUTH_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n}\nexport default tsReactWebsiteAuthGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readFileSync","join","addTsDependencies","addHookResultToRouterProviderContext","addDestructuredImport","addSingleImport","applyGritQL","declareDependencies","ownedElsewhere","formatFilesInSubtree","resolveIac","addIdentityInfra","IDENTITY_CONSTRUCTS_PY_DEPENDENCIES","installDependencies","addGeneratorMetricsIfApplicable","getNpmScope","addComponentGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","toProjectRelativePath","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","runtimeConfigGenerator","addCloudscapeAuthMenu","addNoneAuthMenu","addShadcnAuthMenu","deriveCognitoDomainPrefix","readGritPattern","name","dirname","trim","DEPENDENCIES","ts","py","COGNITO_AUTH_GENERATOR_INFO","filename","tsReactWebsiteAuthGenerator","tree","options","projectConfig","project","srcRoot","sourceRoot","cognitoDomain","length","preferInstallDependencies","iac","allowSignup","overwriteStrategy","KeepExisting","projectRoot","root","mainTsxPath","hook","module","contextProp","projectConfiguration","ux","metadata","toLowerCase","appLayoutTsxPath","exists","Error","console","info","undefined","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,QAEZ,aAAa;AACpB,SAASC,YAAY,QAAQ,KAAK;AAClC,SAASC,IAAI,QAAQ,OAAO;AAC5B,SAASC,iBAAiB,QAAQ,qCAAqC;AACvE,SAASC,oCAAoC,QAAQ,gCAAgC;A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AEL,GAAG,qBAAqB,CAAC;QAE/F;IACF,OAAO;QACLM,QAAQC,IAAI,CACV,CAAC,mBAAmB,EAAEJ,iBAAiB,sBAAsB,CAAC;IAElE;IACA,wBAAwB;IAExB5C,8BACEqB,MACAC,QAAQE,OAAO,EACfN,6BACAf,sBACEoB,eACAzC,kBAAkB2C,SAAS,cAAc,iBAE3CwB,WACA;QAAEnB;IAAI;IAGR,MAAMhC,gCAAgCuB,MAAM;QAACH;KAA4B;IAEzE,MAAMzB,qBAAqB4B;IAC3B,OAAO,IACLxB,oBAAoBwB,MAAMC,QAAQO,yBAAyB,EAAE;YAC3DqB,WAAW;gBAAC;aAAa;QAC3B;AACJ;AACA,eAAe9B,4BAA4B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/ts/react-website/cognito-auth/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n} from '@nx/devkit';\nimport { readFileSync } from 'fs';\nimport { join } from 'path';\nimport { addTsDependencies } from '../../../utils/add-dependencies.js';\nimport { addHookResultToRouterProviderContext } from '../../../utils/ast/website.js';\nimport {\n addDestructuredImport,\n addSingleImport,\n applyGritQL,\n} from '../../../utils/ast.js';\nimport {\n declareDependencies,\n ownedElsewhere,\n} from '../../../utils/declared-dependencies.js';\nimport { formatFilesInSubtree } from '../../../utils/format.js';\nimport { resolveIac } from '../../../utils/iac.js';\nimport {\n addIdentityInfra,\n IDENTITY_CONSTRUCTS_PY_DEPENDENCIES,\n} from '../../../utils/identity-constructs/identity-constructs.js';\nimport { installDependencies } from '../../../utils/install.js';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics.js';\nimport { getNpmScope } from '../../../utils/npm-scope.js';\nimport {\n addComponentGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx.js';\nimport { toProjectRelativePath } from '../../../utils/paths.js';\nimport { getExistingProjectPort } from '../../../utils/port.js';\nimport {\n SHARED_CONSTRUCTS_DEPENDENCIES,\n sharedConstructsGenerator,\n} from '../../../utils/shared-constructs.js';\nimport { runtimeConfigGenerator } from '../runtime-config/generator.js';\nimport type { TsReactWebsiteAuthGeneratorSchema } from './schema';\nimport {\n addCloudscapeAuthMenu,\n addNoneAuthMenu,\n addShadcnAuthMenu,\n deriveCognitoDomainPrefix,\n} from './utils.js';\n\nconst readGritPattern = (name: string): string =>\n readFileSync(\n join(import.meta.dirname, 'grit', `${name}.grit`),\n 'utf-8',\n ).trim();\n\nexport const DEPENDENCIES = declareDependencies()({\n ts: [\n { name: 'oidc-client-ts' },\n { name: 'react-oidc-context' },\n ...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES),\n ],\n py: ownedElsewhere(IDENTITY_CONSTRUCTS_PY_DEPENDENCIES),\n});\n\nexport const COGNITO_AUTH_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport async function tsReactWebsiteAuthGenerator(\n tree: Tree,\n options: TsReactWebsiteAuthGeneratorSchema,\n) {\n const projectConfig = readProjectConfigurationUnqualified(\n tree,\n options.project,\n );\n const srcRoot = projectConfig.sourceRoot;\n\n const cognitoDomain =\n options.cognitoDomain && options.cognitoDomain.length > 0\n ? options.cognitoDomain\n : deriveCognitoDomainPrefix(getNpmScope(tree), projectConfig.name!);\n\n await runtimeConfigGenerator(tree, {\n project: options.project,\n preferInstallDependencies: false,\n });\n\n const iac = await resolveIac(tree, options.iac);\n\n await sharedConstructsGenerator(\n tree,\n {\n iac,\n },\n DEPENDENCIES,\n );\n\n // Falls back to Vite's own defaults when the website predates per-project\n // port assignment, matching the shared construct's own defaults.\n const localDevServerPort = getExistingProjectPort(projectConfig) ?? 4200;\n const localPreviewPort = localDevServerPort + 100;\n\n const portsNotAllowListed = await addIdentityInfra(tree, {\n iac,\n allowSignup: options.allowSignup,\n cognitoDomain,\n localCallbackPorts: [localDevServerPort, localPreviewPort],\n });\n\n if (portsNotAllowListed.length > 0) {\n console.warn(\n `Could not add ${portsNotAllowListed\n .map((p) => `http://localhost:${p}`)\n .join(\n ', ',\n )} to the local callback/logout URLs in the shared user identity ${\n iac === 'cdk' ? 'construct' : 'module'\n }, since it no longer matches the generated shape. Add them by hand, otherwise signing in against ${options.project}'s local dev server will fail.`,\n );\n }\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'app'),\n srcRoot,\n options,\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n addTsDependencies(tree, DEPENDENCIES, { projectRoot: projectConfig.root });\n\n const mainTsxPath = joinPathFragments(srcRoot, 'main.tsx');\n\n await addSingleImport(\n tree,\n mainTsxPath,\n 'CognitoAuth',\n './components/CognitoAuth',\n );\n\n await addHookResultToRouterProviderContext(tree, mainTsxPath, {\n hook: 'useAuth',\n module: 'react-oidc-context',\n contextProp: 'auth',\n });\n\n const projectConfiguration = readProjectConfigurationUnqualified(\n tree,\n options.project,\n );\n\n const ux = (\n (projectConfiguration.metadata as any)?.ux ?? 'shadcn'\n ).toLowerCase();\n\n await applyGritQL(tree, mainTsxPath, readGritPattern('cognito-auth-wrapper'));\n // Update App Layout\n const appLayoutTsxPath = joinPathFragments(\n srcRoot,\n 'components',\n 'AppLayout',\n 'index.tsx',\n );\n if (tree.exists(appLayoutTsxPath)) {\n await addDestructuredImport(\n tree,\n appLayoutTsxPath,\n ['useAuth'],\n 'react-oidc-context',\n );\n await applyGritQL(\n tree,\n appLayoutTsxPath,\n readGritPattern('app-layout-use-auth'),\n );\n // TODO: update utils if they exist by appending to the array\n // Add a top-level navigation menu that shows the signed-in user's profile and actions\n switch (ux) {\n case 'cloudscape':\n await addCloudscapeAuthMenu(tree, appLayoutTsxPath);\n break;\n case 'shadcn':\n await addShadcnAuthMenu(tree, appLayoutTsxPath);\n break;\n case 'none':\n await addNoneAuthMenu(tree, appLayoutTsxPath);\n break;\n default:\n throw new Error(\n `Top-level navigation menu to show the signed-in user for ux \"${ux}\" is not implemented.`,\n );\n }\n } else {\n console.info(\n `Skipping update to ${appLayoutTsxPath} as it does not exist.`,\n );\n }\n // End update App Layout\n\n addComponentGeneratorMetadata(\n tree,\n options.project,\n COGNITO_AUTH_GENERATOR_INFO,\n toProjectRelativePath(\n projectConfig,\n joinPathFragments(srcRoot, 'components', 'CognitoAuth'),\n ),\n undefined,\n { iac },\n );\n\n await addGeneratorMetricsIfApplicable(tree, [COGNITO_AUTH_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n}\nexport default tsReactWebsiteAuthGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readFileSync","join","addTsDependencies","addHookResultToRouterProviderContext","addDestructuredImport","addSingleImport","applyGritQL","declareDependencies","ownedElsewhere","formatFilesInSubtree","resolveIac","addIdentityInfra","IDENTITY_CONSTRUCTS_PY_DEPENDENCIES","installDependencies","addGeneratorMetricsIfApplicable","getNpmScope","addComponentGeneratorMetadata","getGeneratorInfo","readProjectConfigurationUnqualified","toProjectRelativePath","getExistingProjectPort","SHARED_CONSTRUCTS_DEPENDENCIES","sharedConstructsGenerator","runtimeConfigGenerator","addCloudscapeAuthMenu","addNoneAuthMenu","addShadcnAuthMenu","deriveCognitoDomainPrefix","readGritPattern","name","dirname","trim","DEPENDENCIES","ts","py","COGNITO_AUTH_GENERATOR_INFO","filename","tsReactWebsiteAuthGenerator","tree","options","projectConfig","project","srcRoot","sourceRoot","cognitoDomain","length","preferInstallDependencies","iac","localDevServerPort","localPreviewPort","portsNotAllowListed","allowSignup","localCallbackPorts","console","warn","map","p","overwriteStrategy","KeepExisting","projectRoot","root","mainTsxPath","hook","module","contextProp","projectConfiguration","ux","metadata","toLowerCase","appLayoutTsxPath","exists","Error","info","undefined","languages"],"mappings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