@aws/nx-plugin 1.0.0-rc.95 → 1.0.0-rc.97
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 +234 -38
- package/migrations.json +65 -2
- package/package.json +6 -6
- package/src/agentcore-gateway/__snapshots__/generator.spec.ts.snap +1 -1
- 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 -16
- package/src/infra/app/generator.js +34 -7
- 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/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/checkov-scan-cache-inputs/metadata.json +3 -0
- package/src/migrations/latest/checkov-scan-cache-inputs/migration.d.ts +6 -0
- package/src/migrations/latest/checkov-scan-cache-inputs/migration.js +58 -0
- package/src/migrations/latest/checkov-scan-cache-inputs/migration.js.map +1 -0
- package/src/migrations/latest/gateway-url-accessor/__snapshots__/migration.spec.ts.snap +84 -0
- package/src/migrations/latest/gateway-url-accessor/metadata.json +3 -0
- package/src/migrations/latest/gateway-url-accessor/migration.d.ts +6 -0
- package/src/migrations/latest/gateway-url-accessor/migration.js +94 -0
- package/src/migrations/latest/gateway-url-accessor/migration.js.map +1 -0
- package/src/migrations/latest/infra-deploy-express-mode/metadata.json +1 -1
- package/src/migrations/latest/infra-deploy-express-mode/migration.js +26 -28
- package/src/migrations/latest/infra-deploy-express-mode/migration.js.map +1 -1
- package/src/migrations/latest/py-lambda-powertools-context/metadata.json +3 -0
- package/src/migrations/latest/py-lambda-powertools-context/migration.d.ts +6 -0
- package/src/migrations/latest/py-lambda-powertools-context/migration.js +58 -0
- package/src/migrations/latest/py-lambda-powertools-context/migration.js.map +1 -0
- package/src/migrations/latest/script-project-quality-gates/metadata.json +3 -0
- package/src/migrations/latest/script-project-quality-gates/migration.d.ts +6 -0
- package/src/migrations/latest/script-project-quality-gates/migration.js +53 -0
- package/src/migrations/latest/script-project-quality-gates/migration.js.map +1 -0
- package/src/migrations/latest/smithy-extension-trait-aliases/__snapshots__/migration.spec.ts.snap +25 -0
- package/src/migrations/latest/smithy-extension-trait-aliases/metadata.json +3 -0
- package/src/migrations/latest/smithy-extension-trait-aliases/migration.d.ts +28 -0
- package/src/migrations/latest/smithy-extension-trait-aliases/migration.js +75 -0
- package/src/migrations/latest/smithy-extension-trait-aliases/migration.js.map +1 -0
- package/src/migrations/latest/terraform-validate-without-backend/metadata.json +3 -0
- package/src/migrations/latest/terraform-validate-without-backend/migration.d.ts +6 -0
- package/src/migrations/latest/terraform-validate-without-backend/migration.js +84 -0
- package/src/migrations/latest/terraform-validate-without-backend/migration.js.map +1 -0
- package/src/preset/__snapshots__/generator.spec.ts.snap +3 -5
- package/src/preset/generator.js +4 -25
- package/src/preset/generator.js.map +1 -1
- 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 +29 -0
- package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +8 -10
- package/src/py/dynamodb/generator.js +34 -7
- package/src/py/dynamodb/generator.js.map +1 -1
- package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +2 -1
- package/src/py/lambda-function/files/handler/__lambdaFunctionSnakeCase__.py.template +2 -1
- package/src/py/project/schema.json +3 -1
- package/src/py/rdb/__snapshots__/generator.spec.ts.snap +28 -12
- 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/react-connection/files/model/extensions.smithy.template +3 -3
- 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/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/generator.js +3 -3
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/react-connection/generator.d.ts +37 -0
- package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/ts/dynamodb/generator.js +30 -6
- package/src/ts/dynamodb/generator.js.map +1 -1
- 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.d.ts +13 -0
- package/src/ts/lib/generator.js +14 -9
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/ts-project-utils.d.ts +31 -1
- package/src/ts/lib/ts-project-utils.js +53 -0
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/lib/vitest.d.ts +6 -0
- package/src/ts/lib/vitest.js +16 -1
- package/src/ts/lib/vitest.js.map +1 -1
- package/src/ts/mcp-server/generator.js +3 -3
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +5 -0
- 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 +21 -0
- 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 -22
- package/src/ts/react-website/app/generator.d.ts +42 -0
- package/src/ts/react-website/app/generator.js +4 -8
- package/src/ts/react-website/app/generator.js.map +1 -1
- 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 +33 -0
- package/src/utils/ast.js.map +1 -1
- package/src/utils/dependencies.js +1 -10
- 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/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 +13 -0
- package/src/utils/shared-shadcn.js +3 -2
- package/src/utils/shared-shadcn.js.map +1 -1
- package/src/utils/test.js +15 -0
- package/src/utils/test.js.map +1 -1
- package/src/utils/version-upgrade-migration/sync-vended-versions.js +4 -4
- package/src/utils/version-upgrade-migration/sync-vended-versions.js.map +1 -1
- package/src/utils/versions.d.ts +13 -9
- package/src/utils/versions.js +17 -8
- 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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/ts/react-website/agui/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 ProjectConfiguration,\n type Tree,\n} from '@nx/devkit';\nimport { addAgentRuntimeToConnectionNamespace } from '../../../connection/agent-runtime-config.js';\nimport { addTsDependencies } from '../../../utils/add-dependencies.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 { kebabCase } from '../../../utils/names.js';\nimport { getNpmScopePrefix } from '../../../utils/npm-scope.js';\nimport { registerPnpmBuiltDependencies } from '../../../utils/pnpm-workspace.js';\nimport {\n addSharedShadcnDependency,\n SHADCN_DEPENDENCIES,\n sharedShadcnGenerator,\n} from '../../../utils/shared-shadcn.js';\nimport { runtimeConfigGenerator } from '../runtime-config/generator.js';\n\n/**\n * The values this helper's predicates read. Its callers record them, so the\n * theme and auth branches taken here can be confirmed at upgrade time.\n */\nexport interface AgUiMetadata {\n readonly theme: string;\n readonly auth: string;\n}\n\n// Each entry names the theme or auth branch it belongs to, so the same\n// declaration drives both adding and the version sync.\nexport const DEPENDENCIES = declareDependencies<AgUiMetadata>()({\n ts: [\n { name: '@copilotkit/react-core' },\n { name: '@ag-ui/client' },\n {\n name: '@cloudscape-design/chat-components',\n when: (m) => m.theme === 'cloudscape',\n },\n { name: 'lucide-react', when: (m) => m.theme === 'shadcn' },\n { name: 'oidc-client-ts', when: (m) => m.auth === 'iam' },\n { name: 'aws4fetch', when: (m) => m.auth === 'iam' },\n {\n name: '@aws-sdk/credential-provider-cognito-identity',\n when: (m) => m.auth === 'iam',\n },\n {\n name: 'react-oidc-context',\n when: (m) => m.auth === 'iam' || m.auth === 'cognito',\n },\n { name: '@smithy/types', when: (m) => m.auth === 'iam', dev: true },\n // `sharedShadcnGenerator` adds these to the shared shadcn project it\n // creates, not to the website.\n ...ownedElsewhere(SHADCN_DEPENDENCIES),\n ],\n});\n\nexport type AgUiAuth = 'iam' | 'cognito' | 'none';\n\nexport type AgUiTheme = 'cloudscape' | 'shadcn' | 'default';\n\nexport interface AgUiReactConnectionOptions {\n /** The React website project to connect FROM */\n frontendProjectConfig: ProjectConfiguration;\n /** The AG-UI agent's exposed name (used as CopilotKit's agent key) */\n agentName: string;\n /** PascalCase class name used for component names and runtime config keys */\n agentNameClassName: string;\n /** Auth scheme used by the agent */\n auth: AgUiAuth;\n /**\n * When set, the generated hook reads the gateway's URL from\n * runtimeConfig.gateways and routes to the agent via the gateway's\n * path-based `/<targetName>/invocations` route instead of invoking the\n * runtime directly. The gateway publishes its own URL to the website, so\n * the agent's construct is left unpatched.\n */\n gatewayRoute?: {\n gatewayClassName: string;\n targetName: string;\n };\n}\n\n/**\n * Wires a React website up to an AG-UI agent using CopilotKit and\n * @ag-ui/client's HttpAgent. Agent-server-language agnostic.\n *\n * On first invocation creates a shared `AguiProvider` component (with an empty\n * `selfManagedAgents` registry) and wraps `<App />` in it. Each invocation\n * AST-patches `AguiProvider` to register one more agent hook — running the\n * generator multiple times is idempotent and additive.\n *\n * Also vends a `src/components/copilot` theme module picked from the\n * website's `metadata.ux` (cloudscape / shadcn / default).\n */\nexport const addAgUiReactConnection = async (\n tree: Tree,\n options: AgUiReactConnectionOptions,\n) => {\n const {\n frontendProjectConfig,\n agentName,\n agentNameClassName,\n auth,\n gatewayRoute,\n } = options;\n\n const theme = resolveAgUiTheme(frontendProjectConfig);\n // The values the declaration's predicates read. Callers record the same pair,\n // so what is added here is exactly what the version sync owns.\n const metadata: AgUiMetadata = { theme, auth };\n const scopeAlias = getNpmScopePrefix(tree);\n\n // Generates `src/components/AguiProvider.tsx` (if absent) and\n // `src/hooks/useAgui<AgentName>.tsx`. Existing files are kept so re-running\n // the generator is idempotent.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'common'),\n frontendProjectConfig.root,\n { agentName, agentNameClassName, auth, gatewayRoute },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Shadcn theme imports from the shared shadcn library, so it must exist.\n if (theme === 'shadcn') {\n await sharedShadcnGenerator(tree, DEPENDENCIES);\n addSharedShadcnDependency(tree, frontendProjectConfig.root);\n }\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', theme),\n frontendProjectConfig.root,\n { scopeAlias },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n if (auth === 'iam') {\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n '../../../utils/files/website/hooks/sigv4',\n ),\n joinPathFragments(frontendProjectConfig.sourceRoot, 'hooks'),\n {},\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n }\n\n await runtimeConfigGenerator(tree, {\n project: frontendProjectConfig.name,\n });\n\n // AST-patch AguiProvider to register this agent's hook\n await registerAgentHookInProvider(\n tree,\n frontendProjectConfig,\n agentNameClassName,\n );\n\n // Wrap <App /> in <AguiProvider> in main.tsx (idempotent)\n const mainTsxPath = joinPathFragments(\n frontendProjectConfig.sourceRoot,\n 'main.tsx',\n );\n await addSingleImport(\n tree,\n mainTsxPath,\n 'AguiProvider',\n './components/AguiProvider',\n );\n await applyGritQL(\n tree,\n mainTsxPath,\n `\\`<App />\\` => \\`<AguiProvider><App /></AguiProvider>\\` where { $program <: not contains \\`<AguiProvider>$_</AguiProvider>\\` }`,\n );\n\n // @copilotkit/react-core transitively pulls in @scarf/scarf (telemetry),\n // which has a postinstall script. Under pnpm 11's default\n // `strictDepBuilds=true` that script is treated as an unreviewed build and\n // fails the install. Register it as an explicitly-rejected build so pnpm\n // knows we've seen it and will skip it instead of erroring.\n registerPnpmBuiltDependencies(tree, { '@scarf/scarf': false });\n\n addTsDependencies(tree, DEPENDENCIES, {\n metadata,\n projectRoot: frontendProjectConfig.root,\n });\n\n // Agents only publish their runtime ARN to the 'agentcore' namespace by\n // default, which isn't exposed to the website. Patch the agent's CDK/TF\n // construct to also publish under 'connection' so the browser can read it\n // from runtime-config.json. When routing via a gateway, the gateway\n // publishes its own URL instead.\n if (!gatewayRoute) {\n await addAgentRuntimeToConnectionNamespace(tree, {\n agentNameKebabCase: kebabCase(agentNameClassName),\n agentNameClassName,\n });\n }\n};\n\n/**\n * The theme module this helper vends, from the website's `metadata.ux`. Callers\n * record the resolved value, so the theme predicates read what the code branches\n * on.\n */\nexport const resolveAgUiTheme = (\n frontendProjectConfig: ProjectConfiguration,\n): AgUiTheme => {\n const ux = (\n (frontendProjectConfig.metadata as any)?.ux as string | undefined\n )?.toLowerCase();\n switch (ux) {\n case 'cloudscape':\n return 'cloudscape';\n case 'shadcn':\n return 'shadcn';\n default:\n return 'default';\n }\n};\n\n/**\n * Register this agent's hook in the shared `AguiProvider` using GritQL AST\n * patches. The provider starts out with an empty `selfManagedAgents` registry\n * (from the template); each call appends:\n * - `import { useAgui<Name> } from '../hooks/useAgui<Name>';`\n * - `const <varName> = useAgui<Name>();` before the `useMemo` call\n * - `...<varName>` into the memoised object literal\n * - `<varName>` into the `useMemo` deps array\n *\n * All steps are guarded so re-running produces byte-identical output.\n */\nconst registerAgentHookInProvider = async (\n tree: Tree,\n frontendProjectConfig: ProjectConfiguration,\n agentNameClassName: string,\n) => {\n const providerPath = joinPathFragments(\n frontendProjectConfig.sourceRoot,\n 'components',\n 'AguiProvider.tsx',\n );\n const hookName = `useAgui${agentNameClassName}`;\n // useAguiStoryAgent -> storyAgentAgents\n const varName = `${agentNameClassName.charAt(0).toLowerCase()}${agentNameClassName.slice(1)}Agents`;\n\n // 1. Add the hook import\n await addDestructuredImport(\n tree,\n providerPath,\n [hookName],\n `../hooks/${hookName}`,\n );\n\n // 2. Insert `const <varName> = <hookName>();` before the useMemo declaration\n await applyGritQL(\n tree,\n providerPath,\n `\\`const selfManagedAgents = useMemo<Record<string, AbstractAgent>>($body, $deps);\\` => ` +\n `\\`const ${varName} = ${hookName}();\\nconst selfManagedAgents = useMemo<Record<string, AbstractAgent>>($body, $deps);\\` ` +\n `where { $program <: not contains \\`const ${varName} = ${hookName}()\\` }`,\n );\n\n // 3. Spread `...<varName>` into the memoised object and add `<varName>` to\n // the deps array. Branches on `{}`/`[]` vs populated so both the\n // first-agent and nth-agent cases produce clean output.\n await applyGritQL(\n tree,\n providerPath,\n `\\`useMemo<Record<string, AbstractAgent>>(() => ($obj), $deps)\\` where {` +\n ` $obj <: not contains \\`...${varName}\\`,` +\n ` if ($obj <: \\`{}\\`) { $obj => \\`{ ...${varName} }\\` }` +\n ` else { $obj <: \\`{$items}\\` where { $items += \\`, ...${varName}\\` } },` +\n ` if ($deps <: \\`[]\\`) { $deps => \\`[${varName}]\\` }` +\n ` else { $deps <: \\`[$dd]\\` where { $dd += \\`, ${varName}\\` } }` +\n ` }`,\n );\n};\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","addAgentRuntimeToConnectionNamespace","addTsDependencies","addDestructuredImport","addSingleImport","applyGritQL","declareDependencies","ownedElsewhere","kebabCase","getNpmScopePrefix","registerPnpmBuiltDependencies","addSharedShadcnDependency","SHADCN_DEPENDENCIES","sharedShadcnGenerator","runtimeConfigGenerator","DEPENDENCIES","ts","name","when","m","theme","auth","dev","addAgUiReactConnection","tree","options","frontendProjectConfig","agentName","agentNameClassName","gatewayRoute","resolveAgUiTheme","metadata","scopeAlias","dirname","root","overwriteStrategy","KeepExisting","sourceRoot","project","registerAgentHookInProvider","mainTsxPath","projectRoot","agentNameKebabCase","ux","toLowerCase","providerPath","hookName","varName","charAt","slice"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAA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QAAQ,GAAG,CAAC,GAC1C,CAAC,sCAAsC,EAAEA,QAAQ,MAAM,CAAC,GACxD,CAAC,sDAAsD,EAAEA,QAAQ,OAAO,CAAC,GACzE,CAAC,oCAAoC,EAAEA,QAAQ,KAAK,CAAC,GACrD,CAAC,8CAA8C,EAAEA,QAAQ,MAAM,CAAC,GAChE,CAAC,EAAE,CAAC;AAEV"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/ts/react-website/agui/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 ProjectConfiguration,\n type Tree,\n} from '@nx/devkit';\nimport { addAgentRuntimeToConnectionNamespace } from '../../../connection/agent-runtime-config.js';\nimport { addTsDependencies } from '../../../utils/add-dependencies.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 { kebabCase, snakeCase } from '../../../utils/names.js';\nimport { getNpmScopePrefix } from '../../../utils/npm-scope.js';\nimport { registerPnpmBuiltDependencies } from '../../../utils/pnpm-workspace.js';\nimport {\n addSharedShadcnDependency,\n SHADCN_DEPENDENCIES,\n sharedShadcnGenerator,\n} from '../../../utils/shared-shadcn.js';\nimport { runtimeConfigGenerator } from '../runtime-config/generator.js';\n\n/**\n * The values this helper's predicates read. Its callers record them, so the\n * theme and auth branches taken here can be confirmed at upgrade time.\n */\nexport interface AgUiMetadata {\n readonly theme: string;\n readonly auth: string;\n}\n\n// Each entry names the theme or auth branch it belongs to, so the same\n// declaration drives both adding and the version sync.\nexport const DEPENDENCIES = declareDependencies<AgUiMetadata>()({\n ts: [\n { name: '@copilotkit/react-core' },\n { name: '@ag-ui/client' },\n {\n name: '@cloudscape-design/chat-components',\n when: (m) => m.theme === 'cloudscape',\n },\n { name: 'lucide-react', when: (m) => m.theme === 'shadcn' },\n { name: 'oidc-client-ts', when: (m) => m.auth === 'iam' },\n { name: 'aws4fetch', when: (m) => m.auth === 'iam' },\n {\n name: '@aws-sdk/credential-provider-cognito-identity',\n when: (m) => m.auth === 'iam',\n },\n {\n name: 'react-oidc-context',\n when: (m) => m.auth === 'iam' || m.auth === 'cognito',\n },\n { name: '@smithy/types', when: (m) => m.auth === 'iam', dev: true },\n // `sharedShadcnGenerator` adds these to the shared shadcn project it\n // creates, not to the website.\n ...ownedElsewhere(SHADCN_DEPENDENCIES),\n ],\n});\n\nexport type AgUiAuth = 'iam' | 'cognito' | 'none';\n\nexport type AgUiTheme = 'cloudscape' | 'shadcn' | 'default';\n\nexport interface AgUiReactConnectionOptions {\n /** The React website project to connect FROM */\n frontendProjectConfig: ProjectConfiguration;\n /** The AG-UI agent's exposed name (used as CopilotKit's agent key) */\n agentName: string;\n /** PascalCase class name used for component names and runtime config keys */\n agentNameClassName: string;\n /** Auth scheme used by the agent */\n auth: AgUiAuth;\n /**\n * When set, the generated hook reads the gateway's URL from\n * runtimeConfig.gateways and routes to the agent via the gateway's\n * path-based `/<targetName>/invocations` route instead of invoking the\n * runtime directly. The gateway publishes its own URL to the website, so\n * the agent's construct is left unpatched.\n */\n gatewayRoute?: {\n gatewayClassName: string;\n targetName: string;\n };\n}\n\n/**\n * Wires a React website up to an AG-UI agent using CopilotKit and\n * @ag-ui/client's HttpAgent. Agent-server-language agnostic.\n *\n * On first invocation creates a shared `AguiProvider` component (with an empty\n * `selfManagedAgents` registry) and wraps `<App />` in it. Each invocation\n * AST-patches `AguiProvider` to register one more agent hook — running the\n * generator multiple times is idempotent and additive.\n *\n * Also vends a `src/components/copilot` theme module picked from the\n * website's `metadata.ux` (cloudscape / shadcn / default).\n */\nexport const addAgUiReactConnection = async (\n tree: Tree,\n options: AgUiReactConnectionOptions,\n) => {\n const {\n frontendProjectConfig,\n agentName,\n agentNameClassName,\n auth,\n gatewayRoute,\n } = options;\n\n const theme = resolveAgUiTheme(frontendProjectConfig);\n // The values the declaration's predicates read. Callers record the same pair,\n // so what is added here is exactly what the version sync owns.\n const metadata: AgUiMetadata = { theme, auth };\n const scopeAlias = getNpmScopePrefix(tree);\n\n // Generates `src/components/AguiProvider.tsx` (if absent),\n // `src/components/<agent-name>-chat.tsx` and\n // `src/hooks/useAgui<AgentName>.tsx`. Existing files are kept so re-running\n // the generator is idempotent.\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'common'),\n frontendProjectConfig.root,\n {\n agentName,\n agentNameClassName,\n agentNameKebabCase: kebabCase(agentNameClassName),\n // STORY_AGENT, naming the exported `<name>_ID` constant\n agentNameConstantName: snakeCase(agentNameClassName).toUpperCase(),\n auth,\n gatewayRoute,\n },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // Shadcn theme imports from the shared shadcn library, so it must exist.\n if (theme === 'shadcn') {\n await sharedShadcnGenerator(tree, DEPENDENCIES);\n addSharedShadcnDependency(tree, frontendProjectConfig.root);\n }\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', theme),\n frontendProjectConfig.root,\n { scopeAlias },\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n if (auth === 'iam') {\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n '../../../utils/files/website/hooks/sigv4',\n ),\n joinPathFragments(frontendProjectConfig.sourceRoot, 'hooks'),\n {},\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n }\n\n await runtimeConfigGenerator(tree, {\n project: frontendProjectConfig.name,\n });\n\n // AST-patch AguiProvider to register this agent's hook\n await registerAgentHookInProvider(\n tree,\n frontendProjectConfig,\n agentNameClassName,\n );\n\n // Wrap <App /> in <AguiProvider> in main.tsx (idempotent)\n const mainTsxPath = joinPathFragments(\n frontendProjectConfig.sourceRoot,\n 'main.tsx',\n );\n await addSingleImport(\n tree,\n mainTsxPath,\n 'AguiProvider',\n './components/AguiProvider',\n );\n await applyGritQL(\n tree,\n mainTsxPath,\n `\\`<App />\\` => \\`<AguiProvider><App /></AguiProvider>\\` where { $program <: not contains \\`<AguiProvider>$_</AguiProvider>\\` }`,\n );\n\n // @copilotkit/react-core transitively pulls in @scarf/scarf (telemetry),\n // which has a postinstall script. Under pnpm 11's default\n // `strictDepBuilds=true` that script is treated as an unreviewed build and\n // fails the install. Register it as an explicitly-rejected build so pnpm\n // knows we've seen it and will skip it instead of erroring.\n registerPnpmBuiltDependencies(tree, { '@scarf/scarf': false });\n\n addTsDependencies(tree, DEPENDENCIES, {\n metadata,\n projectRoot: frontendProjectConfig.root,\n });\n\n // Agents only publish their runtime ARN to the 'agentcore' namespace by\n // default, which isn't exposed to the website. Patch the agent's CDK/TF\n // construct to also publish under 'connection' so the browser can read it\n // from runtime-config.json. When routing via a gateway, the gateway\n // publishes its own URL instead.\n if (!gatewayRoute) {\n await addAgentRuntimeToConnectionNamespace(tree, {\n agentNameKebabCase: kebabCase(agentNameClassName),\n agentNameClassName,\n });\n }\n};\n\n/**\n * The theme module this helper vends, from the website's `metadata.ux`. Callers\n * record the resolved value, so the theme predicates read what the code branches\n * on.\n */\nexport const resolveAgUiTheme = (\n frontendProjectConfig: ProjectConfiguration,\n): AgUiTheme => {\n const ux = (\n (frontendProjectConfig.metadata as any)?.ux as string | undefined\n )?.toLowerCase();\n switch (ux) {\n case 'cloudscape':\n return 'cloudscape';\n case 'shadcn':\n return 'shadcn';\n default:\n return 'default';\n }\n};\n\n/**\n * Register this agent's hook in the shared `AguiProvider` using GritQL AST\n * patches. The provider starts out with an empty `selfManagedAgents` registry\n * (from the template); each call appends:\n * - `import { useAgui<Name> } from '../hooks/useAgui<Name>';`\n * - `const <varName> = useAgui<Name>();` before the `useMemo` call\n * - `...<varName>` into the memoised object literal\n * - `<varName>` into the `useMemo` deps array\n *\n * All steps are guarded so re-running produces byte-identical output.\n */\nconst registerAgentHookInProvider = async (\n tree: Tree,\n frontendProjectConfig: ProjectConfiguration,\n agentNameClassName: string,\n) => {\n const providerPath = joinPathFragments(\n frontendProjectConfig.sourceRoot,\n 'components',\n 'AguiProvider.tsx',\n );\n const hookName = `useAgui${agentNameClassName}`;\n // useAguiStoryAgent -> storyAgentAgents\n const varName = `${agentNameClassName.charAt(0).toLowerCase()}${agentNameClassName.slice(1)}Agents`;\n\n // 1. Add the hook import\n await addDestructuredImport(\n tree,\n providerPath,\n [hookName],\n `../hooks/${hookName}`,\n );\n\n // 2. Insert `const <varName> = <hookName>();` before the useMemo declaration\n await applyGritQL(\n tree,\n providerPath,\n `\\`const selfManagedAgents = useMemo<Record<string, AbstractAgent>>($body, $deps);\\` => ` +\n `\\`const ${varName} = ${hookName}();\\nconst selfManagedAgents = useMemo<Record<string, AbstractAgent>>($body, $deps);\\` ` +\n `where { $program <: not contains \\`const ${varName} = ${hookName}()\\` }`,\n );\n\n // 3. Spread `...<varName>` into the memoised object and add `<varName>` to\n // the deps array. Branches on `{}`/`[]` vs populated so both the\n // first-agent and nth-agent cases produce clean output.\n await applyGritQL(\n tree,\n providerPath,\n `\\`useMemo<Record<string, AbstractAgent>>(() => ($obj), $deps)\\` where {` +\n ` $obj <: not contains \\`...${varName}\\`,` +\n ` if ($obj <: \\`{}\\`) { $obj => \\`{ ...${varName} }\\` }` +\n ` else { $obj <: \\`{$items}\\` where { $items += \\`, ...${varName}\\` } },` +\n ` if ($deps <: \\`[]\\`) { $deps => \\`[${varName}]\\` }` +\n ` else { $deps <: \\`[$dd]\\` where { $dd += \\`, ${varName}\\` } }` +\n ` }`,\n );\n};\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","addAgentRuntimeToConnectionNamespace","addTsDependencies","addDestructuredImport","addSingleImport","applyGritQL","declareDependencies","ownedElsewhere","kebabCase","snakeCase","getNpmScopePrefix","registerPnpmBuiltDependencies","addSharedShadcnDependency","SHADCN_DEPENDENCIES","sharedShadcnGenerator","runtimeConfigGenerator","DEPENDENCIES","ts","name","when","m","theme","auth","dev","addAgUiReactConnection","tree","options","frontendProjectConfig","agentName","agentNameClassName","gatewayRoute","resolveAgUiTheme","metadata","scopeAlias","dirname","root","agentNameKebabCase","agentNameConstantName","toUpperCase","overwriteStrategy","KeepExisting","sourceRoot","project","registerAgentHookInProvider","mainTsxPath","projectRoot","ux","toLowerCase","providerPath","hookName","varName","charAt","slice"],"mappings":"AAAA;;;CAGC,GACD,SACEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,QAGZ,aAAa;AACpB,SAASC,oCAAoC,QAAQ,8CAA8C;AACnG,SAASC,iBAAiB,QAAQ,qCAAqC;AACvE,SACEC,qBAAqB,EACrBC,eAAe,EACfC,WAAW,QACN,wBAAwB;AAC/B,SACEC,mBAAmB,EACnBC,cAAc,QACT,0CAA0C;AACjD,SAASC,SAAS,EAAEC,SAAS,QAAQ,0BAA0B;AAC/D,SAASC,iBAAiB,QAAQ,8BAA8B;AAChE,SAASC,6BAA6B,QAAQ,mCAAmC;AACjF,SACEC,yBAAyB,EACzBC,mBAAmB,EACnBC,qBAAqB,QAChB,kCAAkC;AACzC,SAASC,sBAAsB,QAAQ,iCAAiC;AAWxE,uEAAuE;AACvE,uDAAuD;AACvD,OAAO,MAAMC,eAAeV,sBAAoC;IAC9DW,IAAI;QACF;YAAEC,MAAM;QAAyB;QACjC;YAAEA,MAAM;QAAgB;QACxB;YACEA,MAAM;YACNC,MAAM,CAACC,IAAMA,EAAEC,KAAK,KAAK;QAC3B;QACA;YAAEH,MAAM;YAAgBC,MAAM,CAACC,IAAMA,EAAEC,KAAK,KAAK;QAAS;QAC1D;YAAEH,MAAM;YAAkBC,MAAM,CAACC,IAAMA,EAAEE,IAAI,KAAK;QAAM;QACxD;YAAEJ,MAAM;YAAaC,MAAM,CAACC,IAAMA,EAAEE,IAAI,KAAK;QAAM;QACnD;YACEJ,MAAM;YACNC,MAAM,CAACC,IAAMA,EAAEE,IAAI,KAAK;QAC1B;QACA;YACEJ,MAAM;YACNC,MAAM,CAACC,IAAMA,EA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AACC;KAAS,EACV,CAAC,SAAS,EAAEA,UAAU;IAGxB,6EAA6E;IAC7E,MAAM5C,YACJoB,MACAuB,cACA,CAAC,uFAAuF,CAAC,GACvF,CAAC,QAAQ,EAAEE,QAAQ,GAAG,EAAED,SAAS,uFAAuF,CAAC,GACzH,CAAC,yCAAyC,EAAEC,QAAQ,GAAG,EAAED,SAAS,MAAM,CAAC;IAG7E,2EAA2E;IAC3E,oEAAoE;IACpE,2DAA2D;IAC3D,MAAM5C,YACJoB,MACAuB,cACA,CAAC,uEAAuE,CAAC,GACvE,CAAC,2BAA2B,EAAEE,QAAQ,GAAG,CAAC,GAC1C,CAAC,sCAAsC,EAAEA,QAAQ,MAAM,CAAC,GACxD,CAAC,sDAAsD,EAAEA,QAAQ,OAAO,CAAC,GACzE,CAAC,oCAAoC,EAAEA,QAAQ,KAAK,CAAC,GACrD,CAAC,8CAA8C,EAAEA,QAAQ,MAAM,CAAC,GAChE,CAAC,EAAE,CAAC;AAEV"}
|
|
@@ -1058,8 +1058,6 @@ vitest.config.*.timestamp*
|
|
|
1058
1058
|
runtime-config.json"
|
|
1059
1059
|
`;
|
|
1060
1060
|
|
|
1061
|
-
exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > .prettierrc 1`] = `"{"singleQuote":true}"`;
|
|
1062
|
-
|
|
1063
1061
|
exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > biome.json 1`] = `
|
|
1064
1062
|
"{
|
|
1065
1063
|
"$schema": "https://biomejs.dev/schemas/2.5.11/schema.json",
|
|
@@ -1243,11 +1241,11 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
1243
1241
|
"name": "@proj/source",
|
|
1244
1242
|
"dependencies": {},
|
|
1245
1243
|
"devDependencies": {
|
|
1246
|
-
"@nx/js": "23.
|
|
1244
|
+
"@nx/js": "23.2.0",
|
|
1247
1245
|
"@nx/react": "catalog:",
|
|
1248
|
-
"@nx/vite": "23.
|
|
1249
|
-
"@nx/vitest": "
|
|
1250
|
-
"@nx/web": "23.
|
|
1246
|
+
"@nx/vite": "23.2.0",
|
|
1247
|
+
"@nx/vitest": "catalog:",
|
|
1248
|
+
"@nx/web": "23.2.0",
|
|
1251
1249
|
"@swc/helpers": "~0.5.18",
|
|
1252
1250
|
"@tailwindcss/vite": "catalog:",
|
|
1253
1251
|
"@testing-library/dom": "10.4.0",
|
|
@@ -1259,7 +1257,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
1259
1257
|
"@vitest/coverage-v8": "catalog:",
|
|
1260
1258
|
"@vitest/ui": "catalog:",
|
|
1261
1259
|
"jiti": "2.4.2",
|
|
1262
|
-
"jsdom": "
|
|
1260
|
+
"jsdom": "catalog:",
|
|
1263
1261
|
"typescript": "~6.0.3",
|
|
1264
1262
|
"vite": "catalog:",
|
|
1265
1263
|
"vitest": "catalog:"
|
|
@@ -2327,19 +2325,21 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2327
2325
|
- test-app
|
|
2328
2326
|
- packages/common/*
|
|
2329
2327
|
catalog:
|
|
2328
|
+
'@types/node': 26.4.0
|
|
2330
2329
|
vite: 8.2.2
|
|
2331
2330
|
vitest: 4.1.11
|
|
2332
2331
|
'@vitest/coverage-v8': 4.1.11
|
|
2332
|
+
jsdom: 27.4.0
|
|
2333
|
+
'@nx/vitest': 23.2.0
|
|
2333
2334
|
constructs: 10.8.1
|
|
2334
2335
|
aws-cdk-lib: 2.267.0
|
|
2335
|
-
'@types/node': 26.4.0
|
|
2336
2336
|
react: 19.2.8
|
|
2337
2337
|
react-dom: 19.2.8
|
|
2338
2338
|
'@cloudscape-design/components': 3.0.1356
|
|
2339
2339
|
'@cloudscape-design/board-components': 3.0.221
|
|
2340
2340
|
'@cloudscape-design/global-styles': 1.0.67
|
|
2341
2341
|
tailwindcss: 4.3.3
|
|
2342
|
-
'@nx/react': 23.
|
|
2342
|
+
'@nx/react': 23.2.0
|
|
2343
2343
|
'@vitest/ui': 4.1.11
|
|
2344
2344
|
'@tailwindcss/vite': 4.3.3
|
|
2345
2345
|
"
|
|
@@ -2429,7 +2429,9 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2429
2429
|
"react-dom": "catalog:",
|
|
2430
2430
|
"tailwindcss": "catalog:"
|
|
2431
2431
|
},
|
|
2432
|
-
"devDependencies": {
|
|
2432
|
+
"devDependencies": {
|
|
2433
|
+
"@types/node": "catalog:"
|
|
2434
|
+
}
|
|
2433
2435
|
}
|
|
2434
2436
|
"
|
|
2435
2437
|
`;
|
|
@@ -2908,7 +2910,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
2908
2910
|
"
|
|
2909
2911
|
`;
|
|
2910
2912
|
|
|
2911
|
-
exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > vitest.config.
|
|
2913
|
+
exports[`react-website generator > Tanstack router integration > should generate website with no router correctly > vitest.config.mts 1`] = `
|
|
2912
2914
|
"import { defineConfig } from 'vitest/config';
|
|
2913
2915
|
|
|
2914
2916
|
export default defineConfig({
|
|
@@ -2932,8 +2934,6 @@ vitest.config.*.timestamp*
|
|
|
2932
2934
|
runtime-config.json"
|
|
2933
2935
|
`;
|
|
2934
2936
|
|
|
2935
|
-
exports[`react-website generator > Tanstack router integration > should generate website with router correctly > .prettierrc 1`] = `"{"singleQuote":true}"`;
|
|
2936
|
-
|
|
2937
2937
|
exports[`react-website generator > Tanstack router integration > should generate website with router correctly > biome.json 1`] = `
|
|
2938
2938
|
"{
|
|
2939
2939
|
"$schema": "https://biomejs.dev/schemas/2.5.11/schema.json",
|
|
@@ -3117,11 +3117,11 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
3117
3117
|
"name": "@proj/source",
|
|
3118
3118
|
"dependencies": {},
|
|
3119
3119
|
"devDependencies": {
|
|
3120
|
-
"@nx/js": "23.
|
|
3120
|
+
"@nx/js": "23.2.0",
|
|
3121
3121
|
"@nx/react": "catalog:",
|
|
3122
|
-
"@nx/vite": "23.
|
|
3123
|
-
"@nx/vitest": "
|
|
3124
|
-
"@nx/web": "23.
|
|
3122
|
+
"@nx/vite": "23.2.0",
|
|
3123
|
+
"@nx/vitest": "catalog:",
|
|
3124
|
+
"@nx/web": "23.2.0",
|
|
3125
3125
|
"@swc/helpers": "~0.5.18",
|
|
3126
3126
|
"@tailwindcss/vite": "catalog:",
|
|
3127
3127
|
"@tanstack/router-generator": "catalog:",
|
|
@@ -3137,7 +3137,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
3137
3137
|
"@vitest/coverage-v8": "catalog:",
|
|
3138
3138
|
"@vitest/ui": "catalog:",
|
|
3139
3139
|
"jiti": "2.4.2",
|
|
3140
|
-
"jsdom": "
|
|
3140
|
+
"jsdom": "catalog:",
|
|
3141
3141
|
"typescript": "~6.0.3",
|
|
3142
3142
|
"vite": "catalog:",
|
|
3143
3143
|
"vitest": "catalog:"
|
|
@@ -4205,12 +4205,14 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
4205
4205
|
- test-app
|
|
4206
4206
|
- packages/common/*
|
|
4207
4207
|
catalog:
|
|
4208
|
+
'@types/node': 26.4.0
|
|
4208
4209
|
vite: 8.2.2
|
|
4209
4210
|
vitest: 4.1.11
|
|
4210
4211
|
'@vitest/coverage-v8': 4.1.11
|
|
4212
|
+
jsdom: 27.4.0
|
|
4213
|
+
'@nx/vitest': 23.2.0
|
|
4211
4214
|
constructs: 10.8.1
|
|
4212
4215
|
aws-cdk-lib: 2.267.0
|
|
4213
|
-
'@types/node': 26.4.0
|
|
4214
4216
|
react: 19.2.8
|
|
4215
4217
|
react-dom: 19.2.8
|
|
4216
4218
|
'@cloudscape-design/components': 3.0.1356
|
|
@@ -4218,7 +4220,7 @@ catalog:
|
|
|
4218
4220
|
'@cloudscape-design/global-styles': 1.0.67
|
|
4219
4221
|
tailwindcss: 4.3.3
|
|
4220
4222
|
'@tanstack/react-router': 1.170.32
|
|
4221
|
-
'@nx/react': 23.
|
|
4223
|
+
'@nx/react': 23.2.0
|
|
4222
4224
|
'@vitest/ui': 4.1.11
|
|
4223
4225
|
'@tailwindcss/vite': 4.3.3
|
|
4224
4226
|
'@tanstack/router-plugin': 1.168.35
|
|
@@ -4313,7 +4315,9 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
4313
4315
|
"react-dom": "catalog:",
|
|
4314
4316
|
"tailwindcss": "catalog:"
|
|
4315
4317
|
},
|
|
4316
|
-
"devDependencies": {
|
|
4318
|
+
"devDependencies": {
|
|
4319
|
+
"@types/node": "catalog:"
|
|
4320
|
+
}
|
|
4317
4321
|
}
|
|
4318
4322
|
"
|
|
4319
4323
|
`;
|
|
@@ -4985,7 +4989,7 @@ exports[`react-website generator > Tanstack router integration > should generate
|
|
|
4985
4989
|
"
|
|
4986
4990
|
`;
|
|
4987
4991
|
|
|
4988
|
-
exports[`react-website generator > Tanstack router integration > should generate website with router correctly > vitest.config.
|
|
4992
|
+
exports[`react-website generator > Tanstack router integration > should generate website with router correctly > vitest.config.mts 1`] = `
|
|
4989
4993
|
"import { defineConfig } from 'vitest/config';
|
|
4990
4994
|
|
|
4991
4995
|
export default defineConfig({
|
|
@@ -72,6 +72,17 @@ export declare const DEPENDENCIES: import("../../../utils/declared-dependencies.
|
|
|
72
72
|
}, {
|
|
73
73
|
readonly name: "express";
|
|
74
74
|
readonly versionOnly: true;
|
|
75
|
+
}, {
|
|
76
|
+
readonly name: "@types/node";
|
|
77
|
+
readonly dev: true;
|
|
78
|
+
} & {
|
|
79
|
+
versionOnly: true;
|
|
80
|
+
}, {
|
|
81
|
+
readonly name: "@types/node";
|
|
82
|
+
readonly dev: true;
|
|
83
|
+
readonly root: true;
|
|
84
|
+
} & {
|
|
85
|
+
versionOnly: true;
|
|
75
86
|
}, {
|
|
76
87
|
readonly name: "react";
|
|
77
88
|
} & {
|
|
@@ -116,6 +127,27 @@ export declare const DEPENDENCIES: import("../../../utils/declared-dependencies.
|
|
|
116
127
|
readonly name: "@vitest/coverage-v8";
|
|
117
128
|
} & {
|
|
118
129
|
versionOnly: true;
|
|
130
|
+
}, {
|
|
131
|
+
readonly name: "jsdom";
|
|
132
|
+
} & {
|
|
133
|
+
versionOnly: true;
|
|
134
|
+
}, {
|
|
135
|
+
readonly name: "@nx/vitest";
|
|
136
|
+
readonly dev: true;
|
|
137
|
+
readonly root: true;
|
|
138
|
+
} & {
|
|
139
|
+
versionOnly: true;
|
|
140
|
+
}, {
|
|
141
|
+
readonly name: "@types/node";
|
|
142
|
+
readonly dev: true;
|
|
143
|
+
} & {
|
|
144
|
+
versionOnly: true;
|
|
145
|
+
}, {
|
|
146
|
+
readonly name: "@types/node";
|
|
147
|
+
readonly dev: true;
|
|
148
|
+
readonly root: true;
|
|
149
|
+
} & {
|
|
150
|
+
versionOnly: true;
|
|
119
151
|
}, {
|
|
120
152
|
readonly name: "vite";
|
|
121
153
|
} & {
|
|
@@ -128,6 +160,16 @@ export declare const DEPENDENCIES: import("../../../utils/declared-dependencies.
|
|
|
128
160
|
readonly name: "@vitest/coverage-v8";
|
|
129
161
|
} & {
|
|
130
162
|
versionOnly: true;
|
|
163
|
+
}, {
|
|
164
|
+
readonly name: "jsdom";
|
|
165
|
+
} & {
|
|
166
|
+
versionOnly: true;
|
|
167
|
+
}, {
|
|
168
|
+
readonly name: "@nx/vitest";
|
|
169
|
+
readonly dev: true;
|
|
170
|
+
readonly root: true;
|
|
171
|
+
} & {
|
|
172
|
+
versionOnly: true;
|
|
131
173
|
}, {
|
|
132
174
|
readonly name: "constructs";
|
|
133
175
|
readonly when: (m: IacMetadata) => boolean;
|
|
@@ -23,7 +23,7 @@ import { PACKAGES_DIR, SHARED_SHADCN_DIR, TERRAFORM_WEBSITE_RUNTIME_CONFIG_FILE
|
|
|
23
23
|
import { addSharedShadcnDependency, SHADCN_DEPENDENCIES, sharedShadcnGenerator } from "../../../utils/shared-shadcn.js";
|
|
24
24
|
import { withVersions } from "../../../utils/versions.js";
|
|
25
25
|
import { addWebsiteInfra, WEBSITE_CONSTRUCTS_PY_DEPENDENCIES } from "../../../utils/website-constructs/website-constructs.js";
|
|
26
|
-
import { configureTsProject } from "../../lib/ts-project-utils.js";
|
|
26
|
+
import { configureTsProject, mergeTsProjectDirReference, TS_PROJECT_DEPENDENCIES } from "../../lib/ts-project-utils.js";
|
|
27
27
|
import { VITEST_DEPENDENCIES } from "../../lib/vitest.js";
|
|
28
28
|
// Each entry names the branch it belongs to, so the same declaration drives both
|
|
29
29
|
// adding and the version sync.
|
|
@@ -108,6 +108,7 @@ export const DEPENDENCIES = declareDependencies()({
|
|
|
108
108
|
name: 'express',
|
|
109
109
|
versionOnly: true
|
|
110
110
|
},
|
|
111
|
+
...ownedElsewhere(TS_PROJECT_DEPENDENCIES),
|
|
111
112
|
...ownedElsewhere(SHADCN_DEPENDENCIES),
|
|
112
113
|
...ownedElsewhere(VITEST_DEPENDENCIES),
|
|
113
114
|
...ownedElsewhere(SHARED_CONSTRUCTS_DEPENDENCIES)
|
|
@@ -311,7 +312,7 @@ export async function tsReactWebsiteGenerator(tree, schema) {
|
|
|
311
312
|
const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);
|
|
312
313
|
const libraryRoot = projectConfig.root;
|
|
313
314
|
const sharedShadcnStylesImport = relative(joinPathFragments(libraryRoot, 'src'), joinPathFragments(PACKAGES_DIR, SHARED_SHADCN_DIR, 'src', 'styles', 'globals.css')).split(sep).join('/');
|
|
314
|
-
const
|
|
315
|
+
const sharedShadcnProjectRef = relative(joinPathFragments(tree.root, websiteContentPath), joinPathFragments(tree.root, PACKAGES_DIR, SHARED_SHADCN_DIR)).split(sep).join('/');
|
|
315
316
|
const templateOptions = {
|
|
316
317
|
...schema,
|
|
317
318
|
fullyQualifiedName,
|
|
@@ -422,12 +423,7 @@ export async function tsReactWebsiteGenerator(tree, schema) {
|
|
|
422
423
|
'DOM'
|
|
423
424
|
]
|
|
424
425
|
},
|
|
425
|
-
references: ux === 'shadcn' ?
|
|
426
|
-
...(tsconfig.references ?? []).filter((ref)=>ref.path !== sharedShadcnTsconfigRef),
|
|
427
|
-
{
|
|
428
|
-
path: sharedShadcnTsconfigRef
|
|
429
|
-
}
|
|
430
|
-
] : tsconfig.references
|
|
426
|
+
references: ux === 'shadcn' ? mergeTsProjectDirReference(tsconfig.references, sharedShadcnProjectRef) : tsconfig.references
|
|
431
427
|
}));
|
|
432
428
|
addTsDependencies(tree, DEPENDENCIES, {
|
|
433
429
|
metadata,
|
|
@@ -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 { 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 addSharedShadcnDependency,\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 addSharedShadcnDependency(tree, websiteContentPath);\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","addSharedShadcnDependency","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,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,SAASC,UAAU,QAA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F,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"}
|
|
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 addSharedShadcnDependency,\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 {\n configureTsProject,\n mergeTsProjectDirReference,\n TS_PROJECT_DEPENDENCIES,\n} 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(TS_PROJECT_DEPENDENCIES),\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 addSharedShadcnDependency(tree, websiteContentPath);\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 sharedShadcnProjectRef = relative(\n joinPathFragments(tree.root, websiteContentPath),\n joinPathFragments(tree.root, PACKAGES_DIR, SHARED_SHADCN_DIR),\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 ? mergeTsProjectDirReference(\n tsconfig.references,\n sharedShadcnProjectRef,\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\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","addSharedShadcnDependency","SHADCN_DEPENDENCIES","sharedShadcnGenerator","withVersions","addWebsiteInfra","WEBSITE_CONSTRUCTS_PY_DEPENDENCIES","configureTsProject","mergeTsProjectDirReference","TS_PROJECT_DEPENDENCIES","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","sharedShadcnProjectRef","templateOptions","pkgMgrCmd","appCommonTemplatePath","dirname","appTemplatePath","toLowerCase","overwriteStrategy","KeepExisting","routerCommonTemplatePath","routerTemplatePath","e2eFullyQualifiedName","e2eRoot","viteConfigPath","outDir","scope","tsconfig","compilerOptions","moduleResolution","module","outDirToRootRelativePath","distDir","tsBuildInfoFile","lib","references","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,SAASC,UAAU,QAAQ,yBAAyB;AACpD,SACEC,8BAA8B,EAC9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AE;mBAChDD,iBAAkB;oBAAC;iBAA0B,GAAa,EAAE;aACjE;QACH;AACJ;AACA,eAAeO,wBAAwB"}
|
|
@@ -181,7 +181,8 @@ export interface PyMcpFamilyConnection extends PyClientNaming {
|
|
|
181
181
|
export declare const PY_MCP_FAMILY_CONNECTIONS: Record<AgentFramework, PyMcpFamilyConnection>;
|
|
182
182
|
/**
|
|
183
183
|
* Add a re-export to the Python agent-connection module's __init__.py.
|
|
184
|
-
* Equivalent to addStarExport for TS
|
|
184
|
+
* Equivalent to addStarExport for TS, including creating the file when it does
|
|
185
|
+
* not yet exist in the tree.
|
|
185
186
|
* Uses `__all__` to mark re-exports as public (satisfies ruff F401).
|
|
186
187
|
* Uses GritQL for AST-aware transforms where possible.
|
|
187
188
|
*/
|
|
@@ -569,7 +569,8 @@ export const PY_MCP_FAMILY_CONNECTIONS = {
|
|
|
569
569
|
};
|
|
570
570
|
/**
|
|
571
571
|
* Add a re-export to the Python agent-connection module's __init__.py.
|
|
572
|
-
* Equivalent to addStarExport for TS
|
|
572
|
+
* Equivalent to addStarExport for TS, including creating the file when it does
|
|
573
|
+
* not yet exist in the tree.
|
|
573
574
|
* Uses `__all__` to mark re-exports as public (satisfies ruff F401).
|
|
574
575
|
* Uses GritQL for AST-aware transforms where possible.
|
|
575
576
|
*/ export async function addPythonReExport(tree, initFilePath, fromModule, importName) {
|
|
@@ -579,6 +580,10 @@ export const PY_MCP_FAMILY_CONNECTIONS = {
|
|
|
579
580
|
}
|
|
580
581
|
const importLine = `from ${fromModule} import ${importName}`;
|
|
581
582
|
const allEntry = `"${importName}"`;
|
|
583
|
+
if (!tree.exists(initFilePath)) {
|
|
584
|
+
tree.write(initFilePath, `${importLine}\n\n__all__ = [${allEntry}]\n`);
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
582
587
|
// If there's already an import from the same module, merge into its name list
|
|
583
588
|
// (ruff I001 rejects two `from X import ...` lines for the same module).
|
|
584
589
|
const mergedImport = await applyGritQL(tree, initFilePath, py(`\`from ${fromModule} import $names\` where {
|