@aws/nx-plugin 1.0.0-rc.32 → 1.0.0-rc.33
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 +72 -70
- package/package.json +5 -5
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +15 -15
- package/src/infra/app/files/app/src/main.ts.template +1 -1
- package/src/infra/app/files/app/src/stages/application-stage.ts.template +1 -1
- package/src/infra/app/generator.js +3 -1
- package/src/infra/app/generator.js.map +1 -1
- package/src/open-api/ts-client/files/client.gen.ts.template +1 -1
- package/src/open-api/ts-client/generator.js +5 -1
- package/src/open-api/ts-client/generator.js.map +1 -1
- package/src/open-api/ts-hooks/files/options-proxy.gen.ts.template +2 -2
- package/src/open-api/ts-hooks/generator.js +5 -1
- package/src/open-api/ts-hooks/generator.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/preset/generator.d.ts +1 -1
- package/src/preset/generator.js +5 -2
- package/src/preset/generator.js.map +1 -1
- package/src/preset/schema.d.js.map +1 -1
- package/src/preset/schema.d.ts +2 -0
- package/src/preset/schema.json +6 -0
- package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +7 -7
- package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +8 -8
- package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +89 -3
- package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +12 -12
- package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +91 -5
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +7 -7
- package/src/smithy/ts/api/files/handler.ts.template +2 -2
- package/src/smithy/ts/api/files/local-server.ts.template +2 -2
- package/src/smithy/ts/api/files/operations/echo.ts.template +2 -2
- package/src/smithy/ts/api/files/service.ts.template +3 -3
- package/src/smithy/ts/api/generator.js +3 -1
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +12 -12
- package/src/trpc/backend/files/src/client/index.ts.template +1 -1
- package/src/trpc/backend/files/src/handler.ts.template +1 -1
- package/src/trpc/backend/files/src/index.ts.template +5 -5
- package/src/trpc/backend/files/src/init.ts.template +1 -1
- package/src/trpc/backend/files/src/local-server.ts.template +1 -1
- package/src/trpc/backend/files/src/middleware/index.ts.template +7 -7
- package/src/trpc/backend/files/src/procedures/echo.ts.template +2 -2
- package/src/trpc/backend/files/src/router.ts.template +2 -2
- package/src/trpc/backend/files/src/schema/index.ts.template +1 -1
- package/src/trpc/backend/generator.js +3 -1
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +89 -3
- package/src/ts/agent/a2a-connection/files/agent-connection/app/__targetAgentKebabCase__-client-strands.ts.template +2 -2
- package/src/ts/agent/a2a-connection/generator.js +3 -1
- package/src/ts/agent/a2a-connection/generator.js.map +1 -1
- package/src/ts/agent/files/a2a/index.ts.template +1 -1
- package/src/ts/agent/files/ag-ui/index.ts.template +1 -1
- package/src/ts/agent/files/http/client.ts.template +2 -2
- package/src/ts/agent/files/http/index.ts.template +2 -2
- package/src/ts/agent/files/http/router.ts.template +3 -3
- package/src/ts/agent/gateway-connection/files/agent-connection/app/__gatewayKebabCase__-client-strands.ts.template +2 -2
- package/src/ts/agent/gateway-connection/generator.js +3 -1
- package/src/ts/agent/gateway-connection/generator.js.map +1 -1
- package/src/ts/agent/generator.js +5 -2
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/files/agent-connection/app/__mcpServerKebabCase__-client-strands.ts.template +2 -2
- package/src/ts/agent/mcp-connection/generator.js +3 -1
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/astro-docs/files/translation/scripts/translate.ts.template +3 -2
- package/src/ts/astro-docs/generator.js +2 -0
- package/src/ts/astro-docs/generator.js.map +1 -1
- package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/dynamodb/files/src/client.ts.template +5 -2
- package/src/ts/dynamodb/files/src/entities/example.ts.template +1 -1
- package/src/ts/dynamodb/files/src/entities/index.ts.template +1 -1
- package/src/ts/dynamodb/files/src/index.ts.template +2 -2
- package/src/ts/dynamodb/generator.js +3 -1
- package/src/ts/dynamodb/generator.js.map +1 -1
- package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/lib/generator.js +7 -1
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/ts-project-utils.js +19 -4
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/lib/types.d.ts +6 -0
- package/src/ts/lib/types.js.map +1 -1
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +94 -8
- package/src/ts/mcp-server/generator.js +3 -2
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/nx-generator/files/local/generator.ts.template +2 -2
- package/src/ts/nx-generator/files/nx-plugin-for-aws/generator/generator.ts.template +2 -2
- package/src/ts/nx-generator/generator.js +5 -2
- package/src/ts/nx-generator/generator.js.map +1 -1
- package/src/ts/nx-plugin/files/mcp-server/server.ts.template +5 -5
- package/src/ts/nx-plugin/files/mcp-server/tools/create-workspace-command.ts.template +2 -2
- package/src/ts/nx-plugin/files/mcp-server/tools/general-guidance.ts.template +1 -1
- package/src/ts/nx-plugin/files/mcp-server/tools/generator-guide.ts.template +2 -2
- package/src/ts/nx-plugin/files/mcp-server/tools/list-generators.ts.template +2 -2
- package/src/ts/nx-plugin/files/mcp-server/utils.ts.template +3 -3
- package/src/ts/nx-plugin/generator.js +3 -1
- package/src/ts/nx-plugin/generator.js.map +1 -1
- package/src/ts/nx-plugin/utils.js +7 -4
- package/src/ts/nx-plugin/utils.js.map +1 -1
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/ts/rdb/files/src/create-db-user-handler.ts.template +2 -2
- package/src/ts/rdb/files/src/index.ts.template +1 -1
- package/src/ts/rdb/files/src/migration-handler.ts.template +1 -1
- package/src/ts/rdb/files/src/prisma.ts.template +7 -4
- package/src/ts/rdb/generator.js +3 -1
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +35 -35
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +2 -2
- package/src/utils/agent-chat/agent-chat.js +3 -1
- package/src/utils/agent-chat/agent-chat.js.map +1 -1
- package/src/utils/agent-chat/files/a2a/chat.ts.template +1 -1
- package/src/utils/agent-chat/files/ag-ui/chat.ts.template +1 -1
- package/src/utils/agent-chat/files/http-py/chat.ts.template +2 -2
- package/src/utils/agent-chat/files/http-ts/chat.ts.template +1 -1
- package/src/utils/agent-connection/agent-connection.js +4 -1
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-connection/files/core-a2a/agentcore-a2a-client-config.ts.template +2 -2
- package/src/utils/agent-connection/files/core-auth/agentcore-fetch.ts.template +1 -1
- package/src/utils/agent-connection/files/core-gateway/agentcore-gateway-mcp-transport.ts.template +2 -2
- package/src/utils/agent-connection/files/core-mcp/agentcore-mcp-transport.ts.template +2 -2
- package/src/utils/agent-connection/files/core-shared/agentcore-transport.ts.template +1 -1
- package/src/utils/agent-connection/files/core-strands/a2a/agentcore-a2a-client-strands.ts.template +1 -1
- package/src/utils/agent-connection/files/core-strands/base/with-session-id-strands.ts.template +1 -1
- package/src/utils/agent-connection/files/core-strands/gateway/agentcore-gateway-mcp-client-strands.ts.template +1 -1
- package/src/utils/agent-connection/files/core-strands/mcp/agentcore-mcp-client-strands.ts.template +1 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.js +10 -3
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +3 -3
- package/src/utils/agent-core-constructs/files/cdk/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.ts.template +4 -4
- package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/agentcore-gateway.ts.template +1 -1
- package/src/utils/agent-core-constructs/files/terraform/app/agent-core/__nameKebabCase__/__nameKebabCase__.tf.template +27 -0
- package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +60 -1
- package/src/utils/api-constructs/api-constructs.js +8 -2
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/api-constructs/files/cdk/app/apis/http/__apiNameKebabCase__.ts.template +8 -8
- package/src/utils/api-constructs/files/cdk/app/apis/rest/__apiNameKebabCase__.ts.template +8 -8
- package/src/utils/api-constructs/files/cdk/core/api/http/http-api.ts.template +3 -3
- package/src/utils/api-constructs/files/cdk/core/api/rest/api-gateway-account/index.js.template +32 -20
- package/src/utils/api-constructs/files/cdk/core/api/rest/api-gateway-account.ts.template +1 -1
- package/src/utils/api-constructs/files/cdk/core/api/rest/rest-api.ts.template +4 -4
- package/src/utils/api-constructs/files/cdk/core/api/trpc/trpc-utils.ts.template +1 -1
- package/src/utils/ast.js +16 -0
- package/src/utils/ast.js.map +1 -1
- package/src/utils/commands.d.ts +1 -1
- package/src/utils/commands.js +4 -1
- package/src/utils/commands.js.map +1 -1
- package/src/utils/dynamodb-constructs/dynamodb-constructs.js +9 -2
- package/src/utils/dynamodb-constructs/dynamodb-constructs.js.map +1 -1
- package/src/utils/dynamodb-constructs/files/cdk/app/dynamodb/__nameKebabCase__.ts.template +3 -3
- package/src/utils/dynamodb-constructs/files/cdk/core/dynamodb.ts.template +1 -1
- package/src/utils/files/common/constructs/src/core/index.ts.template +4 -4
- package/src/utils/files/common/constructs/src/index.ts.template +2 -2
- package/src/utils/files/common/infra-config/src/index.ts.template +3 -3
- package/src/utils/files/common/infra-config/src/resolve-stage.ts.template +2 -2
- package/src/utils/files/common/infra-config/src/stages.config.ts.template +1 -1
- package/src/utils/files/common/scripts/src/infra/infra-deploy.ts.template +1 -1
- package/src/utils/files/common/scripts/src/infra/infra-destroy.ts.template +1 -1
- package/src/utils/files/common/scripts/src/infra/stage-credentials/run.ts.template +3 -3
- package/src/utils/files/common/shadcn/src/index.ts.template +2 -2
- package/src/utils/function-constructs/files/cdk/app/lambda-functions/__nameKebabCase__.ts.template +1 -1
- package/src/utils/function-constructs/function-constructs.js +3 -1
- package/src/utils/function-constructs/function-constructs.js.map +1 -1
- package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +2 -2
- package/src/utils/identity-constructs/identity-constructs.js +5 -1
- package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
- package/src/utils/module-format.d.ts +28 -0
- package/src/utils/module-format.js +28 -0
- package/src/utils/module-format.js.map +1 -0
- package/src/utils/rdb-constructs/files/cdk/app/dbs/__nameKebabCase__.ts.template +5 -5
- package/src/utils/rdb-constructs/files/cdk/core/rdb/aurora.ts.template +1 -1
- package/src/utils/rdb-constructs/rdb-constructs.js +9 -2
- package/src/utils/rdb-constructs/rdb-constructs.js.map +1 -1
- package/src/utils/shared-constructs.js +3 -1
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/shared-infra-config.js +3 -1
- package/src/utils/shared-infra-config.js.map +1 -1
- package/src/utils/shared-infra-scripts.js +3 -1
- package/src/utils/shared-infra-scripts.js.map +1 -1
- package/src/utils/shared-shadcn.js +3 -1
- package/src/utils/shared-shadcn.js.map +1 -1
- package/src/utils/test.d.ts +2 -0
- package/src/utils/test.js +7 -1
- package/src/utils/test.js.map +1 -1
- package/src/utils/versions.d.ts +58 -58
- package/src/utils/versions.js +56 -56
- package/src/utils/versions.js.map +1 -1
- package/src/utils/website-constructs/files/cdk/app/static-websites/__websiteNameKebabCase__.ts.template +2 -2
- package/src/utils/website-constructs/files/cdk/core/static-website.ts.template +2 -2
- package/src/utils/website-constructs/website-constructs.js +9 -2
- package/src/utils/website-constructs/website-constructs.js.map +1 -1
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { formatFilesInSubtree } from "../../utils/format.js";
|
|
6
6
|
import { installDependencies } from "../../utils/install.js";
|
|
7
7
|
import { addGeneratorMetricsIfApplicable } from "../../utils/metrics.js";
|
|
8
|
+
import { isEsmWorkspace } from "../../utils/module-format.js";
|
|
8
9
|
import { toKebabCase } from "../../utils/names.js";
|
|
9
10
|
import { getNpmScopePrefix } from "../../utils/npm-scope.js";
|
|
10
11
|
import { addGeneratorMetadata, getGeneratorInfo, projectExists } from "../../utils/nx.js";
|
|
@@ -81,6 +82,7 @@ export const tsAstroDocsGenerator = async (tree, schema)=>{
|
|
|
81
82
|
title: schema.name,
|
|
82
83
|
includeTranslation,
|
|
83
84
|
includeBlog,
|
|
85
|
+
esm: isEsmWorkspace(tree),
|
|
84
86
|
pkgMgrCmd: getPackageManagerDisplayCommands().exec,
|
|
85
87
|
today: new Date().toISOString().slice(0, 10)
|
|
86
88
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/astro-docs/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addDependenciesToPackageJson,\n addProjectConfiguration,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type ProjectConfiguration,\n type Tree,\n} from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { toKebabCase } from '../../utils/names';\nimport { getNpmScopePrefix } from '../../utils/npm-scope';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx';\nimport { getPackageManagerDisplayCommands } from '../../utils/pkg-manager';\nimport { type ITsDepVersion, withVersions } from '../../utils/versions';\nimport type { TsAstroDocsGeneratorSchema } from './schema';\n\nexport const TS_ASTRO_DOCS_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsAstroDocsGenerator = async (\n tree: Tree,\n schema: TsAstroDocsGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const includeTranslation = !(schema.noTranslation ?? false);\n const includeBlog = !(schema.noBlog ?? false);\n const npmScopePrefix = getNpmScopePrefix(tree);\n const docsNameKebabCase = toKebabCase(schema.name);\n const fullyQualifiedName = `${npmScopePrefix}${docsNameKebabCase}`;\n // NB: interactive nx generator cli can pass empty string\n const dir = joinPathFragments(\n schema.directory || '.',\n schema.subDirectory || docsNameKebabCase,\n );\n\n const alreadyExists = projectExists(tree, fullyQualifiedName);\n\n const targets: ProjectConfiguration['targets'] = {\n build: {\n executor: 'nx:run-commands',\n options: {\n command: 'astro build',\n cwd: dir,\n },\n outputs: [`{workspaceRoot}/${dir}/dist`],\n cache: true,\n },\n start: {\n executor: 'nx:run-commands',\n options: {\n command: 'astro dev',\n cwd: dir,\n },\n continuous: true,\n },\n serve: {\n dependsOn: ['start'],\n },\n preview: {\n executor: 'nx:run-commands',\n options: {\n command: 'astro preview',\n cwd: dir,\n },\n dependsOn: ['build'],\n continuous: true,\n },\n };\n\n if (includeTranslation) {\n targets['translate'] = {\n executor: 'nx:run-commands',\n options: {\n command: 'tsx ./scripts/translate.ts',\n cwd: dir,\n forwardAllArgs: true,\n },\n };\n }\n\n if (!alreadyExists) {\n addProjectConfiguration(tree, fullyQualifiedName, {\n name: fullyQualifiedName,\n root: dir,\n sourceRoot: joinPathFragments(dir, 'src'),\n projectType: 'application',\n targets,\n });\n }\n\n const templateOptions = {\n fullyQualifiedName,\n title: schema.name,\n includeTranslation,\n includeBlog,\n pkgMgrCmd: getPackageManagerDisplayCommands().exec,\n today: new Date().toISOString().slice(0, 10),\n };\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'base'),\n dir,\n templateOptions,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // The sample blog post is always emitted above — drop it if the user opted out.\n if (!includeBlog) {\n tree.delete(\n joinPathFragments(\n dir,\n 'src',\n 'content',\n 'docs',\n 'en',\n 'blog',\n 'welcome.mdx',\n ),\n );\n }\n\n if (includeTranslation) {\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'translation'),\n dir,\n templateOptions,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n }\n\n addGeneratorMetadata(tree, fullyQualifiedName, TS_ASTRO_DOCS_GENERATOR_INFO, {\n framework: 'astro',\n includeTranslation,\n includeBlog,\n });\n\n const dependencies: ITsDepVersion[] = ['astro', '@astrojs/starlight'];\n const devDependencies: ITsDepVersion[] = [];\n\n if (includeBlog) {\n dependencies.push('starlight-blog');\n }\n\n if (includeTranslation) {\n dependencies.push(\n '@strands-agents/sdk',\n 'commander',\n 'fast-glob',\n 'fs-extra',\n 'simple-git',\n );\n devDependencies.push('tsx', '@types/fs-extra');\n }\n\n addDependenciesToPackageJson(\n tree,\n withVersions(dependencies),\n withVersions(devDependencies),\n );\n\n await addGeneratorMetricsIfApplicable(tree, [TS_ASTRO_DOCS_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsAstroDocsGenerator;\n"],"names":["addDependenciesToPackageJson","addProjectConfiguration","generateFiles","joinPathFragments","OverwriteStrategy","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","toKebabCase","getNpmScopePrefix","addGeneratorMetadata","getGeneratorInfo","projectExists","getPackageManagerDisplayCommands","withVersions","TS_ASTRO_DOCS_GENERATOR_INFO","filename","tsAstroDocsGenerator","tree","schema","includeTranslation","noTranslation","includeBlog","noBlog","npmScopePrefix","docsNameKebabCase","name","fullyQualifiedName","dir","directory","subDirectory","alreadyExists","targets","build","executor","options","command","cwd","outputs","cache","start","continuous","serve","dependsOn","preview","forwardAllArgs","root","sourceRoot","projectType","templateOptions","title","pkgMgrCmd","exec","today","Date","toISOString","slice","dirname","overwriteStrategy","KeepExisting","delete","framework","dependencies","devDependencies","push","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAC5BC,uBAAuB,EAEvBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,QAGZ,aAAa;AACpB,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,WAAW,QAAQ,uBAAoB;AAChD,SAASC,iBAAiB,QAAQ,2BAAwB;AAC1D,SACEC,oBAAoB,EACpBC,gBAAgB,EAEhBC,aAAa,QACR,oBAAiB;AACxB,SAASC,gCAAgC,QAAQ,6BAA0B;AAC3E,SAA6BC,YAAY,QAAQ,0BAAuB;AAGxE,OAAO,MAAMC,+BAAgDJ,iBAC3D,YAAYK,QAAQ,EACpB;AAEF,OAAO,MAAMC,uBAAuB,OAClCC,MACAC;IAEA,MAAMC,qBAAqB,CAAED,CAAAA,OAAOE,aAAa,IAAI,KAAI;IACzD,MAAMC,cAAc,CAAEH,CAAAA,OAAOI,MAAM,IAAI,KAAI;IAC3C,MAAMC,iBAAiBf,kBAAkBS;IACzC,MAAMO,oBAAoBjB,YAAYW,OAAOO,IAAI;IACjD,MAAMC,qBAAqB,GAAGH,iBAAiBC,mBAAmB;IAClE,yDAAyD;IACzD,MAAMG,
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/astro-docs/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addDependenciesToPackageJson,\n addProjectConfiguration,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type ProjectConfiguration,\n type Tree,\n} from '@nx/devkit';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { isEsmWorkspace } from '../../utils/module-format';\nimport { toKebabCase } from '../../utils/names';\nimport { getNpmScopePrefix } from '../../utils/npm-scope';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx';\nimport { getPackageManagerDisplayCommands } from '../../utils/pkg-manager';\nimport { type ITsDepVersion, withVersions } from '../../utils/versions';\nimport type { TsAstroDocsGeneratorSchema } from './schema';\n\nexport const TS_ASTRO_DOCS_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsAstroDocsGenerator = async (\n tree: Tree,\n schema: TsAstroDocsGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const includeTranslation = !(schema.noTranslation ?? false);\n const includeBlog = !(schema.noBlog ?? false);\n const npmScopePrefix = getNpmScopePrefix(tree);\n const docsNameKebabCase = toKebabCase(schema.name);\n const fullyQualifiedName = `${npmScopePrefix}${docsNameKebabCase}`;\n // NB: interactive nx generator cli can pass empty string\n const dir = joinPathFragments(\n schema.directory || '.',\n schema.subDirectory || docsNameKebabCase,\n );\n\n const alreadyExists = projectExists(tree, fullyQualifiedName);\n\n const targets: ProjectConfiguration['targets'] = {\n build: {\n executor: 'nx:run-commands',\n options: {\n command: 'astro build',\n cwd: dir,\n },\n outputs: [`{workspaceRoot}/${dir}/dist`],\n cache: true,\n },\n start: {\n executor: 'nx:run-commands',\n options: {\n command: 'astro dev',\n cwd: dir,\n },\n continuous: true,\n },\n serve: {\n dependsOn: ['start'],\n },\n preview: {\n executor: 'nx:run-commands',\n options: {\n command: 'astro preview',\n cwd: dir,\n },\n dependsOn: ['build'],\n continuous: true,\n },\n };\n\n if (includeTranslation) {\n targets['translate'] = {\n executor: 'nx:run-commands',\n options: {\n command: 'tsx ./scripts/translate.ts',\n cwd: dir,\n forwardAllArgs: true,\n },\n };\n }\n\n if (!alreadyExists) {\n addProjectConfiguration(tree, fullyQualifiedName, {\n name: fullyQualifiedName,\n root: dir,\n sourceRoot: joinPathFragments(dir, 'src'),\n projectType: 'application',\n targets,\n });\n }\n\n const templateOptions = {\n fullyQualifiedName,\n title: schema.name,\n includeTranslation,\n includeBlog,\n esm: isEsmWorkspace(tree),\n pkgMgrCmd: getPackageManagerDisplayCommands().exec,\n today: new Date().toISOString().slice(0, 10),\n };\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'base'),\n dir,\n templateOptions,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n\n // The sample blog post is always emitted above — drop it if the user opted out.\n if (!includeBlog) {\n tree.delete(\n joinPathFragments(\n dir,\n 'src',\n 'content',\n 'docs',\n 'en',\n 'blog',\n 'welcome.mdx',\n ),\n );\n }\n\n if (includeTranslation) {\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'translation'),\n dir,\n templateOptions,\n { overwriteStrategy: OverwriteStrategy.KeepExisting },\n );\n }\n\n addGeneratorMetadata(tree, fullyQualifiedName, TS_ASTRO_DOCS_GENERATOR_INFO, {\n framework: 'astro',\n includeTranslation,\n includeBlog,\n });\n\n const dependencies: ITsDepVersion[] = ['astro', '@astrojs/starlight'];\n const devDependencies: ITsDepVersion[] = [];\n\n if (includeBlog) {\n dependencies.push('starlight-blog');\n }\n\n if (includeTranslation) {\n dependencies.push(\n '@strands-agents/sdk',\n 'commander',\n 'fast-glob',\n 'fs-extra',\n 'simple-git',\n );\n devDependencies.push('tsx', '@types/fs-extra');\n }\n\n addDependenciesToPackageJson(\n tree,\n withVersions(dependencies),\n withVersions(devDependencies),\n );\n\n await addGeneratorMetricsIfApplicable(tree, [TS_ASTRO_DOCS_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsAstroDocsGenerator;\n"],"names":["addDependenciesToPackageJson","addProjectConfiguration","generateFiles","joinPathFragments","OverwriteStrategy","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","isEsmWorkspace","toKebabCase","getNpmScopePrefix","addGeneratorMetadata","getGeneratorInfo","projectExists","getPackageManagerDisplayCommands","withVersions","TS_ASTRO_DOCS_GENERATOR_INFO","filename","tsAstroDocsGenerator","tree","schema","includeTranslation","noTranslation","includeBlog","noBlog","npmScopePrefix","docsNameKebabCase","name","fullyQualifiedName","dir","directory","subDirectory","alreadyExists","targets","build","executor","options","command","cwd","outputs","cache","start","continuous","serve","dependsOn","preview","forwardAllArgs","root","sourceRoot","projectType","templateOptions","title","esm","pkgMgrCmd","exec","today","Date","toISOString","slice","dirname","overwriteStrategy","KeepExisting","delete","framework","dependencies","devDependencies","push","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAC5BC,uBAAuB,EAEvBC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,QAGZ,aAAa;AACpB,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,cAAc,QAAQ,+BAA4B;AAC3D,SAASC,WAAW,QAAQ,uBAAoB;AAChD,SAASC,iBAAiB,QAAQ,2BAAwB;AAC1D,SACEC,oBAAoB,EACpBC,gBAAgB,EAEhBC,aAAa,QACR,oBAAiB;AACxB,SAASC,gCAAgC,QAAQ,6BAA0B;AAC3E,SAA6BC,YAAY,QAAQ,0BAAuB;AAGxE,OAAO,MAAMC,+BAAgDJ,iBAC3D,YAAYK,QAAQ,EACpB;AAEF,OAAO,MAAMC,uBAAuB,OAClCC,MACAC;IAEA,MAAMC,qBAAqB,CAAED,CAAAA,OAAOE,aAAa,IAAI,KAAI;IACzD,MAAMC,cAAc,CAAEH,CAAAA,OAAOI,MAAM,IAAI,KAAI;IAC3C,MAAMC,iBAAiBf,kBAAkBS;I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AAkByD,YAAY;IAAC;IAGtD,gFAAgF;IAChF,IAAI,CAACtC,aAAa;QAChBJ,KAAK2C,MAAM,CACT3D,kBACE0B,KACA,OACA,WACA,QACA,MACA,QACA;IAGN;IAEA,IAAIR,oBAAoB;QACtBnB,cACEiB,MACAhB,kBAAkB,YAAYwD,OAAO,EAAE,SAAS,gBAChD9B,KACAqB,iBACA;YAAEU,mBAAmBxD,kBAAkByD,YAAY;QAAC;IAExD;IAEAlD,qBAAqBQ,MAAMS,oBAAoBZ,8BAA8B;QAC3E+C,WAAW;QACX1C;QACAE;IACF;IAEA,MAAMyC,eAAgC;QAAC;QAAS;KAAqB;IACrE,MAAMC,kBAAmC,EAAE;IAE3C,IAAI1C,aAAa;QACfyC,aAAaE,IAAI,CAAC;IACpB;IAEA,IAAI7C,oBAAoB;QACtB2C,aAAaE,IAAI,CACf,uBACA,aACA,aACA,YACA;QAEFD,gBAAgBC,IAAI,CAAC,OAAO;IAC9B;IAEAlE,6BACEmB,MACAJ,aAAaiD,eACbjD,aAAakD;IAGf,MAAM1D,gCAAgCY,MAAM;QAACH;KAA6B;IAE1E,MAAMX,qBAAqBc;IAC3B,OAAO,IACLb,oBAAoBa,MAAMC,OAAO+C,yBAAyB,EAAE;YAC1DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAelD,qBAAqB"}
|
|
@@ -35,7 +35,7 @@ exports[`ts#dynamodb generator > should generate terraform modules when iac is t
|
|
|
35
35
|
required_providers {
|
|
36
36
|
aws = {
|
|
37
37
|
source = "hashicorp/aws"
|
|
38
|
-
version = "6.
|
|
38
|
+
version = "6.54.0"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -192,7 +192,7 @@ exports[`ts#dynamodb generator > should generate terraform modules when iac is t
|
|
|
192
192
|
required_providers {
|
|
193
193
|
aws = {
|
|
194
194
|
source = "hashicorp/aws"
|
|
195
|
-
version = "6.
|
|
195
|
+
version = "6.54.0"
|
|
196
196
|
}
|
|
197
197
|
random = {
|
|
198
198
|
source = "hashicorp/random"
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
2
2
|
import { getAppConfig } from '@aws-lambda-powertools/parameters/appconfig';
|
|
3
3
|
import { readFileSync } from 'fs';
|
|
4
|
-
import { join
|
|
4
|
+
import { join<% if (esm) { %>, dirname<% } %> } from 'path';
|
|
5
|
+
<%_ if (esm) { _%>
|
|
5
6
|
import { fileURLToPath } from 'url';
|
|
7
|
+
<%_ } _%>
|
|
6
8
|
|
|
7
9
|
// Generated: must match runtimeConfigKey in config.json
|
|
8
10
|
const runtimeConfigKey = '<%= runtimeConfigKey %>';
|
|
9
|
-
|
|
11
|
+
<% if (esm) { %>
|
|
10
12
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
<%_ } _%>
|
|
11
14
|
// config.json is only present in local dev (not included in the deployed bundle); guard with LOCAL_DEV check
|
|
12
15
|
const localDev = () =>
|
|
13
16
|
JSON.parse(readFileSync(join(__dirname, '../config.json'), 'utf-8')).localDev;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Entity } from 'electrodb';
|
|
2
|
-
import { getDynamoDBClient, resolveTableName } from '../client
|
|
2
|
+
import { getDynamoDBClient, resolveTableName } from '../client<% if (esm) { %>.js<% } %>';
|
|
3
3
|
|
|
4
4
|
// Example entity - replace with your own entities using ElectroDB
|
|
5
5
|
// See https://electrodb.dev/en/modeling/entities/ for documentation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createExampleEntity } from './example
|
|
1
|
+
export { createExampleEntity } from './example<% if (esm) { %>.js<% } %>';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { getDynamoDBClient, resolveTableName } from './client
|
|
2
|
-
export * from './entities/index
|
|
1
|
+
export { getDynamoDBClient, resolveTableName } from './client<% if (esm) { %>.js<% } %>';
|
|
2
|
+
export * from './entities/index<% if (esm) { %>.js<% } %>';
|
|
@@ -9,6 +9,7 @@ import { formatFilesInSubtree } from "../../utils/format.js";
|
|
|
9
9
|
import { resolveIac } from "../../utils/iac.js";
|
|
10
10
|
import { installDependencies } from "../../utils/install.js";
|
|
11
11
|
import { addGeneratorMetricsIfApplicable } from "../../utils/metrics.js";
|
|
12
|
+
import { esmVars } from "../../utils/module-format.js";
|
|
12
13
|
import { kebabCase, toClassName } from "../../utils/names.js";
|
|
13
14
|
import { getNpmScope } from "../../utils/npm-scope.js";
|
|
14
15
|
import { addGeneratorMetadata, getGeneratorInfo } from "../../utils/nx.js";
|
|
@@ -51,7 +52,8 @@ export const tsDynamoDBGenerator = async (tree, options)=>{
|
|
|
51
52
|
localDynamoDBPort,
|
|
52
53
|
localTableName,
|
|
53
54
|
containerName,
|
|
54
|
-
containerEngine
|
|
55
|
+
containerEngine,
|
|
56
|
+
...esmVars(tree)
|
|
55
57
|
};
|
|
56
58
|
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files'), dir, templateOptions);
|
|
57
59
|
await sharedDynamoDBScriptsGenerator(tree);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/dynamodb/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { relative } from 'node:path';\nimport {\n addDependenciesToPackageJson,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n readProjectConfiguration,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { resolveContainers } from '../../utils/containers';\nimport { addDynamoDBInfra } from '../../utils/dynamodb-constructs/dynamodb-constructs';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { kebabCase, toClassName } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../utils/nx';\nimport { assignSharedPort } from '../../utils/port';\nimport { sharedConstructsGenerator } from '../../utils/shared-constructs';\nimport {\n DYNAMODB_GENERATOR_IDS,\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n} from '../../utils/shared-constructs-constants';\nimport { sharedDynamoDBScriptsGenerator } from '../../utils/shared-dynamodb-scripts';\nimport { withVersions } from '../../utils/versions';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator';\nimport type { TsDynamoDBGeneratorSchema } from './schema';\n\nexport const TS_DYNAMODB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsDynamoDBGenerator = async (\n tree: Tree,\n options: TsDynamoDBGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const nameKebabCase = kebabCase(options.name);\n const nameClassName = toClassName(options.name);\n const localTableName = `${getNpmScope(tree)}-${kebabCase(options.tableName ?? options.name)}`;\n const containerEngine = await resolveContainers(tree, 'inherit');\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n });\n\n let projectExists: boolean;\n try {\n readProjectConfiguration(tree, fullyQualifiedName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n await tsProjectGenerator(tree, {\n name: options.name,\n directory: options.directory,\n preferInstallDependencies: false,\n });\n }\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n\n const localDynamoDBPort = assignSharedPort(\n tree,\n projectConfig,\n DYNAMODB_GENERATOR_IDS,\n 8000,\n );\n\n const containerName = `${getNpmScope(tree)}-dynamodb`;\n\n const templateOptions = {\n runtimeConfigKey: nameClassName,\n localDynamoDBPort,\n localTableName,\n containerName,\n containerEngine,\n };\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n dir,\n templateOptions,\n );\n\n await sharedDynamoDBScriptsGenerator(tree);\n\n const scriptsDir = relative(\n dir,\n joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'src', 'dynamodb'),\n );\n\n projectConfig.targets['pull-image'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/pull-image.ts`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['dev'] = {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [\n `tsx ${scriptsDir}/start-container.ts`,\n `tsx ${scriptsDir}/create-local-table.ts`,\n ],\n parallel: true,\n cwd: '{projectRoot}',\n },\n };\n\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfig);\n addGeneratorMetadata(tree, fullyQualifiedName, TS_DYNAMODB_GENERATOR_INFO);\n\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, { iac });\n await addDynamoDBInfra(tree, {\n iac,\n projectName: fullyQualifiedName,\n nameClassName,\n nameKebabCase,\n tableName: localTableName,\n projectRoot: dir,\n });\n }\n\n addDependenciesToPackageJson(\n tree,\n withVersions([\n '@aws-sdk/client-dynamodb',\n 'electrodb',\n '@aws-lambda-powertools/parameters',\n '@aws-sdk/client-appconfigdata',\n ]),\n withVersions(['tsx', '@types/aws-lambda', '@types/node']),\n );\n\n await addGeneratorMetricsIfApplicable(tree, [TS_DYNAMODB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsDynamoDBGenerator;\n"],"names":["relative","addDependenciesToPackageJson","generateFiles","joinPathFragments","readProjectConfiguration","updateProjectConfiguration","resolveContainers","addDynamoDBInfra","formatFilesInSubtree","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","kebabCase","toClassName","getNpmScope","addGeneratorMetadata","getGeneratorInfo","assignSharedPort","sharedConstructsGenerator","DYNAMODB_GENERATOR_IDS","PACKAGES_DIR","SHARED_SCRIPTS_DIR","sharedDynamoDBScriptsGenerator","withVersions","tsProjectGenerator","getTsLibDetails","TS_DYNAMODB_GENERATOR_INFO","filename","tsDynamoDBGenerator","tree","options","nameKebabCase","name","nameClassName","localTableName","tableName","containerEngine","fullyQualifiedName","dir","directory","subDirectory","projectExists","preferInstallDependencies","projectConfig","localDynamoDBPort","containerName","templateOptions","runtimeConfigKey","dirname","scriptsDir","targets","executor","command","cwd","continuous","commands","parallel","infra","iac","projectName","projectRoot","languages"],"mappings":"AAAA;;;CAGC,GAED,SAASA,QAAQ,QAAQ,YAAY;AACrC,SACEC,4BAA4B,EAE5BC,aAAa,EACbC,iBAAiB,EACjBC,wBAAwB,EAExBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,iBAAiB,QAAQ,4BAAyB;AAC3D,SAASC,gBAAgB,QAAQ,yDAAsD;AACvF,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,UAAU,QAAQ,qBAAkB;AAC7C,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,SAAS,EAAEC,WAAW,QAAQ,uBAAoB;AAC3D,SAASC,WAAW,QAAQ,2BAAwB;AACpD,SACEC,oBAAoB,EACpBC,gBAAgB,QAEX,oBAAiB;AACxB,SAASC,gBAAgB,QAAQ,sBAAmB;AACpD,SAASC,yBAAyB,QAAQ,mCAAgC;AAC1E,SACEC,sBAAsB,EACtBC,YAAY,EACZC,kBAAkB,QACb,6CAA0C;AACjD,SAASC,8BAA8B,QAAQ,yCAAsC;AACrF,SAASC,YAAY,QAAQ,0BAAuB;AACpD,OAAOC,sBAAsBC,eAAe,QAAQ,sBAAmB;AAGvE,OAAO,MAAMC,6BAA8CV,iBACzD,YAAYW,QAAQ,EACpB;AAEF,OAAO,MAAMC,sBAAsB,OACjCC,MACAC;IAEA,MAAMC,gBAAgBnB,UAAUkB,QAAQE,IAAI;IAC5C,MAAMC,gBAAgBpB,YAAYiB,QAAQE,IAAI;IAC9C,MAAME,iBAAiB,GAAGpB,YAAYe,MAAM,CAAC,EAAEjB,UAAUkB,QAAQK,SAAS,IAAIL,QAAQE,IAAI,GAAG;IAC7F,MAAMI,kBAAkB,
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/dynamodb/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { relative } from 'node:path';\nimport {\n addDependenciesToPackageJson,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n readProjectConfiguration,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { resolveContainers } from '../../utils/containers';\nimport { addDynamoDBInfra } from '../../utils/dynamodb-constructs/dynamodb-constructs';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { resolveIac } from '../../utils/iac';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { esmVars } from '../../utils/module-format';\nimport { kebabCase, toClassName } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n} from '../../utils/nx';\nimport { assignSharedPort } from '../../utils/port';\nimport { sharedConstructsGenerator } from '../../utils/shared-constructs';\nimport {\n DYNAMODB_GENERATOR_IDS,\n PACKAGES_DIR,\n SHARED_SCRIPTS_DIR,\n} from '../../utils/shared-constructs-constants';\nimport { sharedDynamoDBScriptsGenerator } from '../../utils/shared-dynamodb-scripts';\nimport { withVersions } from '../../utils/versions';\nimport tsProjectGenerator, { getTsLibDetails } from '../lib/generator';\nimport type { TsDynamoDBGeneratorSchema } from './schema';\n\nexport const TS_DYNAMODB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsDynamoDBGenerator = async (\n tree: Tree,\n options: TsDynamoDBGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const nameKebabCase = kebabCase(options.name);\n const nameClassName = toClassName(options.name);\n const localTableName = `${getNpmScope(tree)}-${kebabCase(options.tableName ?? options.name)}`;\n const containerEngine = await resolveContainers(tree, 'inherit');\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, {\n name: options.name,\n directory: options.directory,\n subDirectory: options.subDirectory,\n });\n\n let projectExists: boolean;\n try {\n readProjectConfiguration(tree, fullyQualifiedName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n await tsProjectGenerator(tree, {\n name: options.name,\n directory: options.directory,\n preferInstallDependencies: false,\n });\n }\n\n const projectConfig = readProjectConfiguration(tree, fullyQualifiedName);\n\n const localDynamoDBPort = assignSharedPort(\n tree,\n projectConfig,\n DYNAMODB_GENERATOR_IDS,\n 8000,\n );\n\n const containerName = `${getNpmScope(tree)}-dynamodb`;\n\n const templateOptions = {\n runtimeConfigKey: nameClassName,\n localDynamoDBPort,\n localTableName,\n containerName,\n containerEngine,\n ...esmVars(tree),\n };\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n dir,\n templateOptions,\n );\n\n await sharedDynamoDBScriptsGenerator(tree);\n\n const scriptsDir = relative(\n dir,\n joinPathFragments(PACKAGES_DIR, SHARED_SCRIPTS_DIR, 'src', 'dynamodb'),\n );\n\n projectConfig.targets['pull-image'] = {\n executor: 'nx:run-commands',\n options: {\n command: `tsx ${scriptsDir}/pull-image.ts`,\n cwd: '{projectRoot}',\n },\n };\n projectConfig.targets['dev'] = {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n commands: [\n `tsx ${scriptsDir}/start-container.ts`,\n `tsx ${scriptsDir}/create-local-table.ts`,\n ],\n parallel: true,\n cwd: '{projectRoot}',\n },\n };\n\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfig);\n addGeneratorMetadata(tree, fullyQualifiedName, TS_DYNAMODB_GENERATOR_INFO);\n\n if (options.infra !== 'none') {\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, { iac });\n await addDynamoDBInfra(tree, {\n iac,\n projectName: fullyQualifiedName,\n nameClassName,\n nameKebabCase,\n tableName: localTableName,\n projectRoot: dir,\n });\n }\n\n addDependenciesToPackageJson(\n tree,\n withVersions([\n '@aws-sdk/client-dynamodb',\n 'electrodb',\n '@aws-lambda-powertools/parameters',\n '@aws-sdk/client-appconfigdata',\n ]),\n withVersions(['tsx', '@types/aws-lambda', '@types/node']),\n );\n\n await addGeneratorMetricsIfApplicable(tree, [TS_DYNAMODB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default tsDynamoDBGenerator;\n"],"names":["relative","addDependenciesToPackageJson","generateFiles","joinPathFragments","readProjectConfiguration","updateProjectConfiguration","resolveContainers","addDynamoDBInfra","formatFilesInSubtree","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","esmVars","kebabCase","toClassName","getNpmScope","addGeneratorMetadata","getGeneratorInfo","assignSharedPort","sharedConstructsGenerator","DYNAMODB_GENERATOR_IDS","PACKAGES_DIR","SHARED_SCRIPTS_DIR","sharedDynamoDBScriptsGenerator","withVersions","tsProjectGenerator","getTsLibDetails","TS_DYNAMODB_GENERATOR_INFO","filename","tsDynamoDBGenerator","tree","options","nameKebabCase","name","nameClassName","localTableName","tableName","containerEngine","fullyQualifiedName","dir","directory","subDirectory","projectExists","preferInstallDependencies","projectConfig","localDynamoDBPort","containerName","templateOptions","runtimeConfigKey","dirname","scriptsDir","targets","executor","command","cwd","continuous","commands","parallel","infra","iac","projectName","projectRoot","languages"],"mappings":"AAAA;;;CAGC,GAED,SAASA,QAAQ,QAAQ,YAAY;AACrC,SACEC,4BAA4B,EAE5BC,aAAa,EACbC,iBAAiB,EACjBC,wBAAwB,EAExBC,0BAA0B,QACrB,aAAa;AACpB,SAASC,iBAAiB,QAAQ,4BAAyB;AAC3D,SAASC,gBAAgB,QAAQ,y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A;QACA;KACD,GACDA,aAAa;QAAC;QAAO;QAAqB;KAAc;IAG1D,MAAMb,gCAAgCmB,MAAM;QAACH;KAA2B;IAExE,MAAMnB,qBAAqBsB;IAC3B,OAAO,IACLpB,oBAAoBoB,MAAMC,QAAQY,yBAAyB,EAAE;YAC3DmB,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAejC,oBAAoB"}
|
|
@@ -139,7 +139,7 @@ exports[`ts-lambda-function generator > terraform iac > should generate terrafor
|
|
|
139
139
|
required_providers {
|
|
140
140
|
aws = {
|
|
141
141
|
source = "hashicorp/aws"
|
|
142
|
-
version = "6.
|
|
142
|
+
version = "6.54.0"
|
|
143
143
|
}
|
|
144
144
|
archive = {
|
|
145
145
|
source = "hashicorp/archive"
|
|
@@ -320,7 +320,7 @@ exports[`ts-lambda-function generator > terraform iac > should match snapshot fo
|
|
|
320
320
|
required_providers {
|
|
321
321
|
aws = {
|
|
322
322
|
source = "hashicorp/aws"
|
|
323
|
-
version = "6.
|
|
323
|
+
version = "6.54.0"
|
|
324
324
|
}
|
|
325
325
|
archive = {
|
|
326
326
|
source = "hashicorp/archive"
|
package/src/ts/lib/generator.js
CHANGED
|
@@ -6,6 +6,7 @@ import { libraryGenerator } from "@nx/js";
|
|
|
6
6
|
import { formatFilesInSubtree } from "../../utils/format.js";
|
|
7
7
|
import { installDependencies } from "../../utils/install.js";
|
|
8
8
|
import { addGeneratorMetricsIfApplicable } from "../../utils/metrics.js";
|
|
9
|
+
import { isEsmWorkspace } from "../../utils/module-format.js";
|
|
9
10
|
import { toKebabCase } from "../../utils/names.js";
|
|
10
11
|
import { getNpmScopePrefix } from "../../utils/npm-scope.js";
|
|
11
12
|
import { addGeneratorMetadata, getGeneratorInfo, projectExists } from "../../utils/nx.js";
|
|
@@ -30,6 +31,9 @@ export const TS_LIB_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
|
30
31
|
* Generates a typescript project
|
|
31
32
|
*/ export const tsProjectGenerator = async (tree, schema)=>{
|
|
32
33
|
const { fullyQualifiedName, dir } = getTsLibDetails(tree, schema);
|
|
34
|
+
// The module format is workspace-wide, established by the preset when the
|
|
35
|
+
// workspace is created, so vending generators always infer it from the tree.
|
|
36
|
+
const esm = isEsmWorkspace(tree);
|
|
33
37
|
// Only scaffold the project on first run; on re-run skip creation so user
|
|
34
38
|
// edits are preserved, but continue to (re)apply the configuration below.
|
|
35
39
|
if (!projectExists(tree, fullyQualifiedName)) {
|
|
@@ -49,6 +53,7 @@ export const TS_LIB_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
|
49
53
|
tree.delete(joinPathFragments(dir, 'src'));
|
|
50
54
|
generateFiles(tree, joinPathFragments(import.meta.dirname, 'files'), joinPathFragments(dir), {
|
|
51
55
|
fullyQualifiedName,
|
|
56
|
+
esm,
|
|
52
57
|
pkgMgrCmd: getPackageManagerDisplayCommands().exec
|
|
53
58
|
}, {
|
|
54
59
|
overwriteStrategy: OverwriteStrategy.KeepExisting
|
|
@@ -56,7 +61,8 @@ export const TS_LIB_GENERATOR_INFO = getGeneratorInfo(import.meta.filename);
|
|
|
56
61
|
}
|
|
57
62
|
await configureTsProject(tree, {
|
|
58
63
|
dir,
|
|
59
|
-
fullyQualifiedName
|
|
64
|
+
fullyQualifiedName,
|
|
65
|
+
esm
|
|
60
66
|
});
|
|
61
67
|
const projectConfiguration = readProjectConfiguration(tree, fullyQualifiedName);
|
|
62
68
|
const targets = projectConfiguration.targets;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n type NxJsonConfiguration,\n OverwriteStrategy,\n readProjectConfiguration,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { libraryGenerator } from '@nx/js';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { toKebabCase } from '../../utils/names';\nimport { getNpmScopePrefix } from '../../utils/npm-scope';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport { getPackageManagerDisplayCommands } from '../../utils/pkg-manager';\nimport type { TsProjectGeneratorSchema } from './schema';\nimport { configureTsProject } from './ts-project-utils';\n\nexport const TS_LIB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport interface TsLibDetails {\n /**\n * Full package name including scope (eg @foo/bar)\n */\n readonly fullyQualifiedName: string;\n /**\n * Directory of the library relative to the root\n */\n readonly dir: string;\n}\n\n/**\n * Returns details about the TS library to be created\n */\nexport const getTsLibDetails = (\n tree: Tree,\n schema: TsProjectGeneratorSchema,\n): TsLibDetails => {\n const scope = getNpmScopePrefix(tree);\n const normalizedName = toKebabCase(schema.name);\n const fullyQualifiedName = `${scope}${normalizedName}`;\n // NB: interactive nx generator cli can pass empty string\n const dir = joinPathFragments(\n schema.directory || '.',\n schema.subDirectory || normalizedName,\n );\n return { dir, fullyQualifiedName };\n};\n\n/**\n * Generates a typescript project\n */\nexport const tsProjectGenerator = async (\n tree: Tree,\n schema: TsProjectGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, schema);\n\n // Only scaffold the project on first run; on re-run skip creation so user\n // edits are preserved, but continue to (re)apply the configuration below.\n if (!projectExists(tree, fullyQualifiedName)) {\n await libraryGenerator(tree, {\n ...schema,\n name: fullyQualifiedName,\n directory: dir,\n skipPackageJson: true,\n bundler: 'tsc', // TODO: consider supporting others\n linter: 'none',\n unitTestRunner: 'vitest',\n // Register the @nx/vitest plugin so the test target is inferred rather\n // than emitting the deprecated @nx/vitest:test executor target.\n addPlugin: true,\n });\n\n // Replace with simpler sample source code\n tree.delete(joinPathFragments(dir, 'src'));\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n joinPathFragments(dir),\n {\n fullyQualifiedName,\n pkgMgrCmd: getPackageManagerDisplayCommands().exec,\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n }\n await configureTsProject(tree, {\n dir,\n fullyQualifiedName,\n });\n\n const projectConfiguration = readProjectConfiguration(\n tree,\n fullyQualifiedName,\n );\n const targets = projectConfiguration.targets;\n\n targets['compile'] = {\n executor: 'nx:run-commands',\n outputs: ['{workspaceRoot}/dist/{projectRoot}/tsc'],\n options: {\n command: 'tsc --build tsconfig.lib.json',\n cwd: '{projectRoot}',\n },\n };\n targets['build'] = {\n dependsOn: ['lint', 'compile', 'test'],\n };\n projectConfiguration.targets = sortObjectKeys(targets);\n\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfiguration);\n\n addGeneratorMetadata(tree, fullyQualifiedName, TS_LIB_GENERATOR_INFO);\n\n updateJson(tree, 'nx.json', (nxJson: NxJsonConfiguration) => {\n nxJson.namedInputs = {\n ...nxJson.namedInputs,\n default: [\n ...(nxJson.namedInputs?.default ?? []).filter(\n (input) =>\n typeof input !== 'object' ||\n !('dependentTasksOutputFiles' in input) ||\n !(input.dependentTasksOutputFiles === '**/*' && input.transitive),\n ),\n {\n dependentTasksOutputFiles: '**/*',\n transitive: true,\n },\n ],\n };\n\n nxJson.targetDefaults = {\n ...nxJson.targetDefaults,\n compile: {\n cache: true,\n ...nxJson.targetDefaults?.compile,\n inputs: [\n ...(nxJson.targetDefaults?.compile?.inputs ?? []).filter(\n (i) => i !== 'default',\n ),\n 'default',\n ],\n },\n build: {\n cache: true,\n ...nxJson.targetDefaults?.build,\n inputs: [\n ...(nxJson.targetDefaults?.build?.inputs ?? []).filter(\n (i) => i !== 'default',\n ),\n 'default',\n ],\n },\n test: {\n ...nxJson.targetDefaults?.test,\n inputs: [\n ...(nxJson.targetDefaults?.test?.inputs ?? []).filter(\n (i) => i !== 'default',\n ),\n 'default',\n ],\n },\n };\n\n // Ensure we only declare a single typescript plugin with the correct settings\n nxJson.plugins = [\n {\n plugin: '@nx/js/typescript',\n options: {\n typecheck: {\n targetName: 'typecheck',\n },\n build: {\n targetName: 'compile',\n configName: 'tsconfig.lib.json',\n buildDepsName: 'build-deps',\n watchDepsName: 'watch-deps',\n },\n },\n },\n ...(nxJson.plugins ?? []).filter(\n (p) => typeof p === 'string' || p.plugin !== '@nx/js/typescript',\n ),\n ];\n\n return nxJson;\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_LIB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n\n // `installDependencies` ensures vitest resolves for the `typescript` language (the\n // generated vitest.config.mts imports it and Nx loads that config when\n // computing the project graph), so a deferred install still runs when needed.\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\nexport default tsProjectGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readProjectConfiguration","updateJson","updateProjectConfiguration","libraryGenerator","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","toKebabCase","getNpmScopePrefix","addGeneratorMetadata","getGeneratorInfo","projectExists","sortObjectKeys","getPackageManagerDisplayCommands","configureTsProject","TS_LIB_GENERATOR_INFO","filename","getTsLibDetails","tree","schema","scope","normalizedName","name","fullyQualifiedName","dir","directory","subDirectory","tsProjectGenerator","skipPackageJson","bundler","linter","unitTestRunner","addPlugin","delete","dirname","pkgMgrCmd","exec","overwriteStrategy","KeepExisting","projectConfiguration","targets","executor","outputs","options","command","cwd","dependsOn","nxJson","namedInputs","default","filter","input","dependentTasksOutputFiles","transitive","targetDefaults","compile","cache","inputs","i","build","test","plugins","plugin","typecheck","targetName","configName","buildDepsName","watchDepsName","p","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACb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CAACQ,IAAMA,MAAM;oBAEf;iBACD;YACH;YACAC,OAAO;gBACLH,OAAO;gBACP,GAAGT,OAAOO,cAAc,EAAEK,KAAK;gBAC/BF,QAAQ;uBACH,AAACV,CAAAA,OAAOO,cAAc,EAAEK,OAAOF,UAAU,EAAE,AAAD,EAAGP,MAAM,CACpD,CAACQ,IAAMA,MAAM;oBAEf;iBACD;YACH;YACAE,MAAM;gBACJ,GAAGb,OAAOO,cAAc,EAAEM,IAAI;gBAC9BH,QAAQ;uBACH,AAACV,CAAAA,OAAOO,cAAc,EAAEM,MAAMH,UAAU,EAAE,AAAD,EAAGP,MAAM,CACnD,CAACQ,IAAMA,MAAM;oBAEf;iBACD;YACH;QACF;QAEA,8EAA8E;QAC9EX,OAAOc,OAAO,GAAG;YACf;gBACEC,QAAQ;gBACRnB,SAAS;oBACPoB,WAAW;wBACTC,YAAY;oBACd;oBACAL,OAAO;wBACLK,YAAY;wBACZC,YAAY;wBACZC,eAAe;wBACfC,eAAe;oBACjB;gBACF;YACF;eACG,AAACpB,CAAAA,OAAOc,OAAO,IAAI,EAAE,AAAD,EAAGX,MAAM,CAC9B,CAACkB,IAAM,OAAOA,MAAM,YAAYA,EAAEN,MAAM,KAAK;SAEhD;QAED,OAAOf;IACT;IAEA,MAAMzC,gCAAgCY,MAAM;QAACH;KAAsB;IAEnE,MAAMX,qBAAqBc;IAE3B,mFAAmF;IACnF,uEAAuE;IACvE,8EAA8E;IAC9E,OAAO,IACLb,oBAAoBa,MAAMC,OAAOkD,yBAAyB,EAAE;YAC1DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AACF,eAAe3C,mBAAmB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n type NxJsonConfiguration,\n OverwriteStrategy,\n readProjectConfiguration,\n type Tree,\n updateJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport { libraryGenerator } from '@nx/js';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { isEsmWorkspace } from '../../utils/module-format';\nimport { toKebabCase } from '../../utils/names';\nimport { getNpmScopePrefix } from '../../utils/npm-scope';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx';\nimport { sortObjectKeys } from '../../utils/object';\nimport { getPackageManagerDisplayCommands } from '../../utils/pkg-manager';\nimport type { TsProjectGeneratorSchema } from './schema';\nimport { configureTsProject } from './ts-project-utils';\n\nexport const TS_LIB_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport interface TsLibDetails {\n /**\n * Full package name including scope (eg @foo/bar)\n */\n readonly fullyQualifiedName: string;\n /**\n * Directory of the library relative to the root\n */\n readonly dir: string;\n}\n\n/**\n * Returns details about the TS library to be created\n */\nexport const getTsLibDetails = (\n tree: Tree,\n schema: TsProjectGeneratorSchema,\n): TsLibDetails => {\n const scope = getNpmScopePrefix(tree);\n const normalizedName = toKebabCase(schema.name);\n const fullyQualifiedName = `${scope}${normalizedName}`;\n // NB: interactive nx generator cli can pass empty string\n const dir = joinPathFragments(\n schema.directory || '.',\n schema.subDirectory || normalizedName,\n );\n return { dir, fullyQualifiedName };\n};\n\n/**\n * Generates a typescript project\n */\nexport const tsProjectGenerator = async (\n tree: Tree,\n schema: TsProjectGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, schema);\n // The module format is workspace-wide, established by the preset when the\n // workspace is created, so vending generators always infer it from the tree.\n const esm = isEsmWorkspace(tree);\n\n // Only scaffold the project on first run; on re-run skip creation so user\n // edits are preserved, but continue to (re)apply the configuration below.\n if (!projectExists(tree, fullyQualifiedName)) {\n await libraryGenerator(tree, {\n ...schema,\n name: fullyQualifiedName,\n directory: dir,\n skipPackageJson: true,\n bundler: 'tsc', // TODO: consider supporting others\n linter: 'none',\n unitTestRunner: 'vitest',\n // Register the @nx/vitest plugin so the test target is inferred rather\n // than emitting the deprecated @nx/vitest:test executor target.\n addPlugin: true,\n });\n\n // Replace with simpler sample source code\n tree.delete(joinPathFragments(dir, 'src'));\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n joinPathFragments(dir),\n {\n fullyQualifiedName,\n esm,\n pkgMgrCmd: getPackageManagerDisplayCommands().exec,\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n }\n await configureTsProject(tree, {\n dir,\n fullyQualifiedName,\n esm,\n });\n\n const projectConfiguration = readProjectConfiguration(\n tree,\n fullyQualifiedName,\n );\n const targets = projectConfiguration.targets;\n\n targets['compile'] = {\n executor: 'nx:run-commands',\n outputs: ['{workspaceRoot}/dist/{projectRoot}/tsc'],\n options: {\n command: 'tsc --build tsconfig.lib.json',\n cwd: '{projectRoot}',\n },\n };\n targets['build'] = {\n dependsOn: ['lint', 'compile', 'test'],\n };\n projectConfiguration.targets = sortObjectKeys(targets);\n\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfiguration);\n\n addGeneratorMetadata(tree, fullyQualifiedName, TS_LIB_GENERATOR_INFO);\n\n updateJson(tree, 'nx.json', (nxJson: NxJsonConfiguration) => {\n nxJson.namedInputs = {\n ...nxJson.namedInputs,\n default: [\n ...(nxJson.namedInputs?.default ?? []).filter(\n (input) =>\n typeof input !== 'object' ||\n !('dependentTasksOutputFiles' in input) ||\n !(input.dependentTasksOutputFiles === '**/*' && input.transitive),\n ),\n {\n dependentTasksOutputFiles: '**/*',\n transitive: true,\n },\n ],\n };\n\n nxJson.targetDefaults = {\n ...nxJson.targetDefaults,\n compile: {\n cache: true,\n ...nxJson.targetDefaults?.compile,\n inputs: [\n ...(nxJson.targetDefaults?.compile?.inputs ?? []).filter(\n (i) => i !== 'default',\n ),\n 'default',\n ],\n },\n build: {\n cache: true,\n ...nxJson.targetDefaults?.build,\n inputs: [\n ...(nxJson.targetDefaults?.build?.inputs ?? []).filter(\n (i) => i !== 'default',\n ),\n 'default',\n ],\n },\n test: {\n ...nxJson.targetDefaults?.test,\n inputs: [\n ...(nxJson.targetDefaults?.test?.inputs ?? []).filter(\n (i) => i !== 'default',\n ),\n 'default',\n ],\n },\n };\n\n // Ensure we only declare a single typescript plugin with the correct settings\n nxJson.plugins = [\n {\n plugin: '@nx/js/typescript',\n options: {\n typecheck: {\n targetName: 'typecheck',\n },\n build: {\n targetName: 'compile',\n configName: 'tsconfig.lib.json',\n buildDepsName: 'build-deps',\n watchDepsName: 'watch-deps',\n },\n },\n },\n ...(nxJson.plugins ?? []).filter(\n (p) => typeof p === 'string' || p.plugin !== '@nx/js/typescript',\n ),\n ];\n\n return nxJson;\n });\n\n await addGeneratorMetricsIfApplicable(tree, [TS_LIB_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n\n // `installDependencies` ensures vitest resolves for the `typescript` language (the\n // generated vitest.config.mts imports it and Nx loads that config when\n // computing the project graph), so a deferred install still runs when needed.\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\nexport default tsProjectGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","readProjectConfiguration","updateJson","updateProjectConfiguration","libraryGenerator","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","isEsmWorkspace","toKebabCase","getNpmScopePrefix","addGeneratorMetadata","getGeneratorInfo","projectExists","sortObjectKeys","getPackageManagerDisplayCommands","configureTsProject","TS_LIB_GENERATOR_INFO","filename","getTsLibDetails","tree","schema","scope","normalizedName","name","fullyQualifiedName","dir","directory","subDirectory","tsProjectGenerator","esm","skipPackageJson","bundler","linter","unitTestRunner","addPlugin","delete","dirname","pkgMgrCmd","exec","overwriteStrategy","KeepExisting","projectConfiguration","targets","executor","outputs","options","command","cwd","dependsOn","nxJson","namedInputs","default","filter","input","dependentTasksOutputFiles","transitive","targetDefaults","compile","cache","inputs","i","build","test","plugins","plugin","typecheck","targetName","configName","buildDepsName","watchDepsName","p","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EAEjBC,iBAAiB,EACjBC,wBAAwB,EAExBC,UAAU,EACVC,0BAA0B,QACrB,aAAa;AACpB,SAASC,gBAAgB,QAAQ,SAAS;AAC1C,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,cAAc,QAAQ,+BAA4B;AAC3D,SAASC,WAAW,QAAQ,uBAAoB;AAChD,SAASC,iBAAiB,QAAQ,2BAAwB;AAC1D,SACEC,oBAAoB,EACpBC,gBAAgB,EAEhBC,aAAa,QACR,oBAAiB;AACxB,SAASC,cAAc,QAAQ,wBAAqB;AACpD,SAASC,gCAAgC,QAAQ,6BAA0B;AAE3E,SAASC,kBAAkB,QAAQ,wBAAqB;AAExD,OAAO,MAAMC,wBAAyCL,iBACpD,YAAYM,QAAQ,EACpB;AAaF;;CAEC,GACD,OAAO,MAAMC,kBAAkB,CAC7BC,MACAC;IAEA,MAAMC,QAAQZ,kBAAkBU;IAChC,MAAMG,iBAAiBd,YAAYY,OAAOG,IAAI;IAC9C,MAAMC,qBAAqB,GAAGH,QAAQC,gBAAgB;IACtD,yDAAyD;IACzD,MAAMG,MAAM3B,kBACVsB,OAAOM,SAAS,IAAI,KACpBN,OAAOO,YAAY,IAAIL;IAEzB,OAAO;QAAEG;QAAKD;IAAmB;AACnC,EAAE;AAEF;;CAEC,GACD,OAAO,MAAMI,qBAAqB,OAChCT,MACAC;IAEA,MAAM,EAAEI,kBAAkB,EAAEC,GAAG,EAAE,GAAGP,gBAAgBC,MAAMC;IAC1D,0EAA0E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AAO,IACLd,oBAAoBc,MAAMC,OAAOmD,yBAAyB,EAAE;YAC1DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AACF,eAAe5C,mBAAmB"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/ import { joinPathFragments, updateJson } from "@nx/devkit";
|
|
5
5
|
import { join, relative } from "path";
|
|
6
6
|
import { addLicenseCheckToLintTarget } from "../../license/config.js";
|
|
7
|
+
import { isEsmWorkspace } from "../../utils/module-format.js";
|
|
7
8
|
import { toScopeAlias } from "../../utils/npm-scope.js";
|
|
8
9
|
import { configureBiomeLint } from "./biome.js";
|
|
9
10
|
import { configureVitest } from "./vitest.js";
|
|
@@ -27,7 +28,11 @@ import { configureVitest } from "./vitest.js";
|
|
|
27
28
|
/**
|
|
28
29
|
* Updates typescript projects
|
|
29
30
|
*/ export const configureTsProject = async (tree, options)=>{
|
|
30
|
-
//
|
|
31
|
+
// When the caller doesn't specify a module format, infer it from the
|
|
32
|
+
// workspace root package.json (defaulting to ESM for a fresh workspace).
|
|
33
|
+
const esm = options.esm ?? isEsmWorkspace(tree);
|
|
34
|
+
// Remove a conflicting `module: commonjs` from the project tsconfig.json
|
|
35
|
+
// (CommonJS is configured on tsconfig.lib.json below when needed).
|
|
31
36
|
updateJson(tree, join(options.dir, 'tsconfig.json'), (tsConfig)=>({
|
|
32
37
|
...tsConfig,
|
|
33
38
|
compilerOptions: {
|
|
@@ -46,7 +51,15 @@ import { configureVitest } from "./vitest.js";
|
|
|
46
51
|
baseUrl: undefined,
|
|
47
52
|
rootDir: '.',
|
|
48
53
|
outDir: distDir,
|
|
49
|
-
tsBuildInfoFile: join(distDir, 'tsconfig.lib.tsbuildinfo')
|
|
54
|
+
tsBuildInfoFile: join(distDir, 'tsconfig.lib.tsbuildinfo'),
|
|
55
|
+
// @nx/js configures the lib for ESM (module `nodenext`). CommonJS
|
|
56
|
+
// projects use `node16`, which honours the workspace's
|
|
57
|
+
// `type: commonjs`, emits CommonJS and resolves extensionless relative
|
|
58
|
+
// imports. (Plain `commonjs`/`node` is deprecated in TypeScript 6.)
|
|
59
|
+
...esm ? {} : {
|
|
60
|
+
module: 'node16',
|
|
61
|
+
moduleResolution: 'node16'
|
|
62
|
+
}
|
|
50
63
|
}
|
|
51
64
|
}));
|
|
52
65
|
}
|
|
@@ -79,10 +92,12 @@ import { configureVitest } from "./vitest.js";
|
|
|
79
92
|
])
|
|
80
93
|
}));
|
|
81
94
|
}
|
|
82
|
-
// Update the root package.json
|
|
95
|
+
// Update the root package.json. ESM projects require `type: module`; for
|
|
96
|
+
// CommonJS we write an explicit `type: commonjs` marker (which Node treats
|
|
97
|
+
// identically to an absent `type`).
|
|
83
98
|
updateJson(tree, 'package.json', (packageJson)=>({
|
|
84
99
|
...packageJson,
|
|
85
|
-
type: 'module'
|
|
100
|
+
type: esm ? 'module' : 'commonjs'
|
|
86
101
|
}));
|
|
87
102
|
// Remove package.json if it exists
|
|
88
103
|
if (tree.exists(join(options.dir, 'package.json'))) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/ts-project-utils.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { joinPathFragments, type Tree, updateJson } from '@nx/devkit';\nimport { join, relative } from 'path';\nimport { addLicenseCheckToLintTarget } from '../../license/config';\nimport { toScopeAlias } from '../../utils/npm-scope';\nimport { configureBiomeLint } from './biome';\nimport type { ConfigureProjectOptions } from './types';\nimport { configureVitest } from './vitest';\n\ninterface TsConfigReference {\n path: string;\n}\n\n/**\n * Merges new TypeScript project references into existing ones, deduplicating by\n * path and preserving the order of existing references so re-running a\n * generator neither duplicates nor reorders references.\n */\nexport const mergeTsReferences = (\n existing: TsConfigReference[] | undefined,\n toAdd: TsConfigReference[],\n): TsConfigReference[] => {\n const references = [...(existing ?? [])];\n const existingPaths = new Set(references.map((ref) => ref.path));\n for (const ref of toAdd) {\n if (!existingPaths.has(ref.path)) {\n references.push(ref);\n existingPaths.add(ref.path);\n }\n }\n return references;\n};\n\n/**\n * Updates typescript projects\n */\nexport const configureTsProject = async (\n tree: Tree,\n options: ConfigureProjectOptions,\n) => {\n // Remove conflicting commonjs
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/ts-project-utils.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { joinPathFragments, type Tree, updateJson } from '@nx/devkit';\nimport { join, relative } from 'path';\nimport { addLicenseCheckToLintTarget } from '../../license/config';\nimport { isEsmWorkspace } from '../../utils/module-format';\nimport { toScopeAlias } from '../../utils/npm-scope';\nimport { configureBiomeLint } from './biome';\nimport type { ConfigureProjectOptions } from './types';\nimport { configureVitest } from './vitest';\n\ninterface TsConfigReference {\n path: string;\n}\n\n/**\n * Merges new TypeScript project references into existing ones, deduplicating by\n * path and preserving the order of existing references so re-running a\n * generator neither duplicates nor reorders references.\n */\nexport const mergeTsReferences = (\n existing: TsConfigReference[] | undefined,\n toAdd: TsConfigReference[],\n): TsConfigReference[] => {\n const references = [...(existing ?? [])];\n const existingPaths = new Set(references.map((ref) => ref.path));\n for (const ref of toAdd) {\n if (!existingPaths.has(ref.path)) {\n references.push(ref);\n existingPaths.add(ref.path);\n }\n }\n return references;\n};\n\n/**\n * Updates typescript projects\n */\nexport const configureTsProject = async (\n tree: Tree,\n options: ConfigureProjectOptions,\n) => {\n // When the caller doesn't specify a module format, infer it from the\n // workspace root package.json (defaulting to ESM for a fresh workspace).\n const esm = options.esm ?? isEsmWorkspace(tree);\n\n // Remove a conflicting `module: commonjs` from the project tsconfig.json\n // (CommonJS is configured on tsconfig.lib.json below when needed).\n updateJson(tree, join(options.dir, 'tsconfig.json'), (tsConfig) => ({\n ...tsConfig,\n compilerOptions: {\n ...tsConfig.compilerOptions,\n module:\n tsConfig.compilerOptions?.module === 'commonjs'\n ? undefined\n : tsConfig.compilerOptions?.module,\n },\n }));\n const outDirToRootRelativePath = relative(\n join(tree.root, options.dir),\n tree.root,\n );\n const distDir = join(outDirToRootRelativePath, 'dist', options.dir, 'tsc');\n // Remove baseUrl and rootDir from the tsconfig.lib.json\n if (tree.exists(join(options.dir, 'tsconfig.lib.json'))) {\n updateJson(tree, join(options.dir, 'tsconfig.lib.json'), (tsConfig) => ({\n ...tsConfig,\n compilerOptions: {\n ...tsConfig.compilerOptions,\n baseUrl: undefined,\n rootDir: '.',\n outDir: distDir,\n tsBuildInfoFile: join(distDir, 'tsconfig.lib.tsbuildinfo'),\n // @nx/js configures the lib for ESM (module `nodenext`). CommonJS\n // projects use `node16`, which honours the workspace's\n // `type: commonjs`, emits CommonJS and resolves extensionless relative\n // imports. (Plain `commonjs`/`node` is deprecated in TypeScript 6.)\n ...(esm ? {} : { module: 'node16', moduleResolution: 'node16' }),\n },\n }));\n }\n // Update root project tsconfig\n updateJson(tree, 'tsconfig.base.json', (tsConfig) => ({\n ...tsConfig,\n compilerOptions: {\n ...tsConfig.compilerOptions,\n // baseUrl is deprecated in TypeScript 6 — use ./ prefix in paths instead\n baseUrl: undefined,\n rootDir: '.',\n paths: {\n // Remove any path aliases for this project with the npm scope prefix (eg remove @foo/bar)\n ...Object.fromEntries(\n Object.entries(tsConfig.compilerOptions?.paths ?? {}).filter(\n ([k]) => k !== options.fullyQualifiedName,\n ),\n ),\n // Add aliases which begin with colon (eg :foo/bar) to avoid sniping attacks\n [toScopeAlias(options.fullyQualifiedName)]: [\n `./${joinPathFragments(options.dir, 'src', 'index.ts')}`,\n ],\n },\n },\n }));\n if (tree.exists('tsconfig.json')) {\n updateJson(tree, 'tsconfig.json', (tsConfig) => ({\n ...tsConfig,\n // Add project references, deduplicating and preserving existing order\n references: mergeTsReferences(tsConfig.references, [\n { path: `./${options.dir}` },\n ]),\n }));\n }\n // Update the root package.json. ESM projects require `type: module`; for\n // CommonJS we write an explicit `type: commonjs` marker (which Node treats\n // identically to an absent `type`).\n updateJson(tree, 'package.json', (packageJson) => ({\n ...packageJson,\n type: esm ? 'module' : 'commonjs',\n }));\n // Remove package.json if it exists\n if (tree.exists(join(options.dir, 'package.json'))) {\n tree.delete(join(options.dir, 'package.json'));\n }\n\n await configureBiomeLint(tree, options);\n await configureVitest(tree, options);\n\n // If license checking is configured, make this project's lint target depend\n // on the root license-check target. No-op if there's no license-check target\n // (i.e. the license generator hasn't run); the license generator wires up\n // existing projects itself, so this works regardless of generator order.\n addLicenseCheckToLintTarget(tree, options.fullyQualifiedName);\n};\n"],"names":["joinPathFragments","updateJson","join","relative","addLicenseCheckToLintTarget","isEsmWorkspace","toScopeAlias","configureBiomeLint","configureVitest","mergeTsReferences","existing","toAdd","references","existingPaths","Set","map","ref","path","has","push","add","configureTsProject","tree","options","esm","dir","tsConfig","compilerOptions","module","undefined","outDirToRootRelativePath","root","distDir","exists","baseUrl","rootDir","outDir","tsBuildInfoFile","moduleResolution","paths","Object","fromEntries","entries","filter","k","fullyQualifiedName","packageJson","type","delete"],"mappings":"AAAA;;;CAGC,GACD,SAASA,iBAAiB,EAAaC,UAAU,QAAQ,aAAa;AACtE,SAASC,IAAI,EAAEC,QAAQ,QAAQ,OAAO;AACtC,SAASC,2BAA2B,QAAQ,0BAAuB;AACnE,SAASC,cAAc,QAAQ,+BAA4B;AAC3D,SAASC,YAAY,QAAQ,2BAAwB;AACrD,SAASC,kBAAkB,QAAQ,aAAU;AAE7C,SAASC,eAAe,QAAQ,cAAW;AAM3C;;;;CAIC,GACD,OAAO,MAAMC,oBAAoB,CAC/BC,UACAC;IAEA,MAAMC,aAAa;WAAKF,YAAY,EAAE;KAAE;IACxC,MAAMG,gBAAgB,IAAIC,IAAIF,WAAWG,GAAG,CAAC,CAACC,MAAQA,IAAIC,IAAI;IAC9D,KAAK,MAAMD,OAAOL,MAAO;QACvB,IAAI,CAACE,cAAcK,GAAG,CAACF,IAAIC,IAAI,GA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ptions {
|
|
|
11
11
|
* Directory of the project relative to the root
|
|
12
12
|
*/
|
|
13
13
|
readonly dir: string;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the project uses ES modules. When false, the project is configured
|
|
16
|
+
* for CommonJS (tsconfig `module`/`moduleResolution`, no root `type: module`).
|
|
17
|
+
* Defaults to true (ESM) when not specified.
|
|
18
|
+
*/
|
|
19
|
+
readonly esm?: boolean;
|
|
14
20
|
}
|
package/src/ts/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/types.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nexport interface ConfigureProjectOptions {\n /**\n * Full package name including scope (eg @foo/bar)\n */\n readonly fullyQualifiedName: string;\n /**\n * Directory of the project relative to the root\n */\n readonly dir: string;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GACD,
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/ts/lib/types.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nexport interface ConfigureProjectOptions {\n /**\n * Full package name including scope (eg @foo/bar)\n */\n readonly fullyQualifiedName: string;\n /**\n * Directory of the project relative to the root\n */\n readonly dir: string;\n /**\n * Whether the project uses ES modules. When false, the project is configured\n * for CommonJS (tsconfig `module`/`moduleResolution`, no root `type: module`).\n * Defaults to true (ESM) when not specified.\n */\n readonly esm?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GACD,WAeC"}
|
|
@@ -135,7 +135,7 @@ exports[`ts#mcp-server generator > should match snapshot for Terraform generated
|
|
|
135
135
|
required_providers {
|
|
136
136
|
aws = {
|
|
137
137
|
source = "hashicorp/aws"
|
|
138
|
-
version = "6.
|
|
138
|
+
version = "6.54.0"
|
|
139
139
|
}
|
|
140
140
|
null = {
|
|
141
141
|
source = "hashicorp/null"
|
|
@@ -201,6 +201,30 @@ variable "additional_iam_policy_statements" {
|
|
|
201
201
|
default = []
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
# VPC Configuration (optional)
|
|
205
|
+
variable "enable_vpc" {
|
|
206
|
+
description = "Run the agent core runtime inside a VPC. Set alongside vpc_id/subnet_ids."
|
|
207
|
+
type = bool
|
|
208
|
+
default = false
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
variable "vpc_id" {
|
|
212
|
+
description = "VPC ID to run the agent core runtime in. Required when enable_vpc is true."
|
|
213
|
+
type = string
|
|
214
|
+
default = null
|
|
215
|
+
|
|
216
|
+
validation {
|
|
217
|
+
condition = !var.enable_vpc || (var.vpc_id != null && var.subnet_ids != null)
|
|
218
|
+
error_message = "vpc_id and subnet_ids must be set when enable_vpc is true."
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
variable "subnet_ids" {
|
|
223
|
+
description = "Subnet IDs to run the agent core runtime in. Required when enable_vpc is true."
|
|
224
|
+
type = list(string)
|
|
225
|
+
default = null
|
|
226
|
+
}
|
|
227
|
+
|
|
204
228
|
variable "tags" {
|
|
205
229
|
description = "Tags to apply to resources"
|
|
206
230
|
type = map(string)
|
|
@@ -436,6 +460,28 @@ resource "null_resource" "docker_publish" {
|
|
|
436
460
|
depends_on = [aws_ecr_repository_policy.agent_core_ecr_policy]
|
|
437
461
|
}
|
|
438
462
|
|
|
463
|
+
# Security group for the agent core runtime, used when running inside a VPC
|
|
464
|
+
resource "aws_security_group" "agent_core_runtime" {
|
|
465
|
+
count = var.enable_vpc ? 1 : 0
|
|
466
|
+
|
|
467
|
+
#checkov:skip=CKV2_AWS_5:Attached to the runtime via network_configuration; Checkov cannot resolve this reference
|
|
468
|
+
name_prefix = "\${var.agent_runtime_name}-runtime-"
|
|
469
|
+
description = "Security group for the \${var.agent_runtime_name} agent core runtime"
|
|
470
|
+
vpc_id = var.vpc_id
|
|
471
|
+
tags = var.tags
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
resource "aws_vpc_security_group_egress_rule" "agent_core_runtime_https" {
|
|
475
|
+
count = var.enable_vpc ? 1 : 0
|
|
476
|
+
|
|
477
|
+
security_group_id = aws_security_group.agent_core_runtime[0].id
|
|
478
|
+
cidr_ipv4 = "0.0.0.0/0"
|
|
479
|
+
from_port = 443
|
|
480
|
+
to_port = 443
|
|
481
|
+
ip_protocol = "tcp"
|
|
482
|
+
description = "Allow outbound HTTPS to AWS service endpoints"
|
|
483
|
+
}
|
|
484
|
+
|
|
439
485
|
# Bedrock AgentCore Agent Runtime
|
|
440
486
|
resource "aws_bedrockagentcore_agent_runtime" "agent_runtime" {
|
|
441
487
|
agent_runtime_name = "\${var.agent_runtime_name}_\${random_id.unique_suffix.hex}"
|
|
@@ -462,7 +508,15 @@ resource "aws_bedrockagentcore_agent_runtime" "agent_runtime" {
|
|
|
462
508
|
}
|
|
463
509
|
|
|
464
510
|
network_configuration {
|
|
465
|
-
network_mode = "PUBLIC"
|
|
511
|
+
network_mode = var.enable_vpc ? "VPC" : "PUBLIC"
|
|
512
|
+
|
|
513
|
+
dynamic "network_mode_config" {
|
|
514
|
+
for_each = var.enable_vpc ? [1] : []
|
|
515
|
+
content {
|
|
516
|
+
security_groups = [aws_security_group.agent_core_runtime[0].id]
|
|
517
|
+
subnets = var.subnet_ids
|
|
518
|
+
}
|
|
519
|
+
}
|
|
466
520
|
}
|
|
467
521
|
|
|
468
522
|
protocol_configuration {
|
|
@@ -489,7 +543,7 @@ resource "null_resource" "runtime_ready" {
|
|
|
489
543
|
|
|
490
544
|
provisioner "local-exec" {
|
|
491
545
|
command = <<-EOT
|
|
492
|
-
uv run --with boto3==1.43.
|
|
546
|
+
uv run --with boto3==1.43.46 python -c "
|
|
493
547
|
import boto3
|
|
494
548
|
import json
|
|
495
549
|
import os
|
|
@@ -564,6 +618,11 @@ output "agent_runtime_version" {
|
|
|
564
618
|
description = "Version of the Bedrock Agent Core runtime"
|
|
565
619
|
value = aws_bedrockagentcore_agent_runtime.agent_runtime.agent_runtime_version
|
|
566
620
|
}
|
|
621
|
+
|
|
622
|
+
output "security_group_id" {
|
|
623
|
+
description = "Security group ID of the agent core runtime, for use in ingress rules on resources it must reach (e.g. a database). Null unless enable_vpc is true."
|
|
624
|
+
value = var.enable_vpc ? aws_security_group.agent_core_runtime[0].id : null
|
|
625
|
+
}
|
|
567
626
|
"
|
|
568
627
|
`;
|
|
569
628
|
|
|
@@ -590,6 +649,25 @@ variable "tags" {
|
|
|
590
649
|
default = {}
|
|
591
650
|
}
|
|
592
651
|
|
|
652
|
+
# VPC Configuration (optional)
|
|
653
|
+
variable "enable_vpc" {
|
|
654
|
+
description = "Run the agent core runtime inside a VPC. Set alongside vpc_id/subnet_ids."
|
|
655
|
+
type = bool
|
|
656
|
+
default = false
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
variable "vpc_id" {
|
|
660
|
+
description = "VPC ID to run the agent core runtime in. Required when enable_vpc is true."
|
|
661
|
+
type = string
|
|
662
|
+
default = null
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
variable "subnet_ids" {
|
|
666
|
+
description = "Subnet IDs to run the agent core runtime in. Required when enable_vpc is true."
|
|
667
|
+
type = list(string)
|
|
668
|
+
default = null
|
|
669
|
+
}
|
|
670
|
+
|
|
593
671
|
variable "appconfig_application_id" {
|
|
594
672
|
description = "ID of the shared runtime-config AppConfig application (from \`core/runtime-config/appconfig.application_id\`). The agent reads its runtime configuration from this application."
|
|
595
673
|
type = string
|
|
@@ -605,6 +683,9 @@ module "agent_core_runtime" {
|
|
|
605
683
|
agent_runtime_name = "TerraformSnapshotServer"
|
|
606
684
|
docker_image_tag = "proj-terraform-snapshot-server:latest"
|
|
607
685
|
server_protocol = "MCP"
|
|
686
|
+
enable_vpc = var.enable_vpc
|
|
687
|
+
vpc_id = var.vpc_id
|
|
688
|
+
subnet_ids = var.subnet_ids
|
|
608
689
|
|
|
609
690
|
env = merge({
|
|
610
691
|
RUNTIME_CONFIG_APP_ID = var.appconfig_application_id
|
|
@@ -647,12 +728,17 @@ output "appconfig_application_id" {
|
|
|
647
728
|
description = "AppConfig Application ID for runtime config (passthrough of the shared \`appconfig_application_id\` input)."
|
|
648
729
|
value = var.appconfig_application_id
|
|
649
730
|
}
|
|
731
|
+
|
|
732
|
+
output "security_group_id" {
|
|
733
|
+
description = "Security group ID of the agent core runtime, for use in ingress rules on resources it must reach (e.g. a database). Null unless enable_vpc is true."
|
|
734
|
+
value = module.agent_core_runtime.security_group_id
|
|
735
|
+
}
|
|
650
736
|
"
|
|
651
737
|
`;
|
|
652
738
|
|
|
653
739
|
exports[`ts#mcp-server generator > should match snapshot for generated files > mcp-server-http.ts 1`] = `
|
|
654
740
|
"#!/usr/bin/env node
|
|
655
|
-
import { createServer } from './server';
|
|
741
|
+
import { createServer } from './server.js';
|
|
656
742
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
657
743
|
import express, { Request, Response } from 'express';
|
|
658
744
|
|
|
@@ -740,14 +826,14 @@ void (async () => {
|
|
|
740
826
|
`;
|
|
741
827
|
|
|
742
828
|
exports[`ts#mcp-server generator > should match snapshot for generated files > mcp-server-index.ts 1`] = `
|
|
743
|
-
"export * from './server';
|
|
829
|
+
"export * from './server.js';
|
|
744
830
|
"
|
|
745
831
|
`;
|
|
746
832
|
|
|
747
833
|
exports[`ts#mcp-server generator > should match snapshot for generated files > mcp-server-server.ts 1`] = `
|
|
748
834
|
"import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
749
|
-
import { registerDivideTool } from './tools/divide';
|
|
750
|
-
import { registerSampleGuidanceResource } from './resources/sample-guidance';
|
|
835
|
+
import { registerDivideTool } from './tools/divide.js';
|
|
836
|
+
import { registerSampleGuidanceResource } from './resources/sample-guidance.js';
|
|
751
837
|
|
|
752
838
|
/**
|
|
753
839
|
* Create the MCP Server
|
|
@@ -769,7 +855,7 @@ export const createServer = async () => {
|
|
|
769
855
|
exports[`ts#mcp-server generator > should match snapshot for generated files > mcp-server-stdio.ts 1`] = `
|
|
770
856
|
"#!/usr/bin/env node
|
|
771
857
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
772
|
-
import { createServer } from './server';
|
|
858
|
+
import { createServer } from './server.js';
|
|
773
859
|
|
|
774
860
|
export const startMcpServer = async () => {
|
|
775
861
|
const transport = new StdioServerTransport();
|