@aws/nx-plugin 1.0.0-rc.24 → 1.0.0-rc.25
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 +2020 -702
- package/package.json +6 -6
- package/src/agentcore-gateway/gateway-connection/generator.d.ts +1 -1
- package/src/agentcore-gateway/gateway-connection/generator.js +7 -5
- package/src/agentcore-gateway/gateway-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/gateway-connection/schema.d.js.map +1 -1
- package/src/agentcore-gateway/gateway-connection/schema.d.ts +1 -0
- package/src/agentcore-gateway/gateway-connection/schema.json +5 -0
- package/src/agentcore-gateway/generator.js +7 -4
- package/src/agentcore-gateway/generator.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/generator.d.ts +1 -1
- package/src/agentcore-gateway/mcp-connection/generator.js +7 -5
- package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/schema.d.js.map +1 -1
- package/src/agentcore-gateway/mcp-connection/schema.d.ts +1 -0
- package/src/agentcore-gateway/mcp-connection/schema.json +5 -0
- package/src/agentcore-gateway/schema.d.js.map +1 -1
- package/src/agentcore-gateway/schema.d.ts +1 -0
- package/src/agentcore-gateway/schema.json +5 -0
- package/src/connection/generator.d.ts +1 -0
- package/src/connection/generator.js +8 -4
- package/src/connection/generator.js.map +1 -1
- package/src/connection/schema.d.js.map +1 -1
- package/src/connection/schema.d.ts +1 -0
- package/src/connection/schema.json +5 -0
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +29 -21
- package/src/infra/app/generator.js +12 -6
- package/src/infra/app/generator.js.map +1 -1
- package/src/infra/app/schema.d.js.map +1 -1
- package/src/infra/app/schema.d.ts +1 -1
- package/src/infra/app/schema.json +5 -0
- package/src/license/schema.d.js.map +1 -1
- package/src/license/schema.d.ts +2 -0
- package/src/license/schema.json +5 -0
- package/src/mcp-server/tools/general-guidance.js +17 -0
- package/src/mcp-server/tools/general-guidance.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 +8 -5
- package/src/preset/generator.js.map +1 -1
- package/src/preset/schema.d.js.map +1 -1
- package/src/preset/schema.d.ts +1 -0
- package/src/preset/schema.json +5 -0
- package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +9 -9
- package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +10 -10
- package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +1 -1
- package/src/py/agent/a2a-connection/generator.js +7 -4
- package/src/py/agent/a2a-connection/generator.js.map +1 -1
- package/src/py/agent/a2a-connection/schema.d.js.map +1 -1
- package/src/py/agent/a2a-connection/schema.d.ts +1 -0
- package/src/py/agent/a2a-connection/schema.json +5 -0
- package/src/py/agent/gateway-connection/generator.js +7 -4
- package/src/py/agent/gateway-connection/generator.js.map +1 -1
- package/src/py/agent/gateway-connection/schema.d.js.map +1 -1
- package/src/py/agent/gateway-connection/schema.d.ts +1 -0
- package/src/py/agent/gateway-connection/schema.json +5 -0
- package/src/py/agent/generator.js +8 -6
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/generator.js +7 -4
- package/src/py/agent/mcp-connection/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/schema.d.js.map +1 -1
- package/src/py/agent/mcp-connection/schema.d.ts +1 -0
- package/src/py/agent/mcp-connection/schema.json +5 -0
- package/src/py/agent/react-connection/generator.d.ts +1 -1
- package/src/py/agent/react-connection/generator.js +7 -4
- package/src/py/agent/react-connection/generator.js.map +1 -1
- package/src/py/agent/react-connection/schema.d.js.map +1 -1
- package/src/py/agent/react-connection/schema.d.ts +1 -0
- package/src/py/agent/react-connection/schema.json +5 -0
- package/src/py/agent/schema.d.js.map +1 -1
- package/src/py/agent/schema.d.ts +1 -0
- package/src/py/agent/schema.json +5 -0
- package/src/py/api/generator.js +2 -1
- package/src/py/api/generator.js.map +1 -1
- package/src/py/api/schema.d.js.map +1 -1
- package/src/py/api/schema.d.ts +1 -0
- package/src/py/api/schema.json +5 -0
- package/src/py/dynamodb/agent-connection/generator.js +8 -6
- package/src/py/dynamodb/agent-connection/generator.js.map +1 -1
- package/src/py/dynamodb/agent-connection/schema.d.js.map +1 -1
- package/src/py/dynamodb/agent-connection/schema.d.ts +1 -0
- package/src/py/dynamodb/agent-connection/schema.json +5 -0
- package/src/py/dynamodb/fast-api-connection/generator.js +8 -6
- package/src/py/dynamodb/fast-api-connection/generator.js.map +1 -1
- package/src/py/dynamodb/fast-api-connection/schema.d.js.map +1 -1
- package/src/py/dynamodb/fast-api-connection/schema.d.ts +1 -0
- package/src/py/dynamodb/fast-api-connection/schema.json +5 -0
- package/src/py/dynamodb/generator.js +10 -7
- package/src/py/dynamodb/generator.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/generator.js +8 -6
- package/src/py/dynamodb/mcp-server-connection/generator.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/schema.d.js.map +1 -1
- package/src/py/dynamodb/mcp-server-connection/schema.d.ts +1 -0
- package/src/py/dynamodb/mcp-server-connection/schema.json +5 -0
- package/src/py/dynamodb/schema.d.js.map +1 -1
- package/src/py/dynamodb/schema.d.ts +1 -0
- package/src/py/dynamodb/schema.json +5 -0
- package/src/py/fast-api/generator.js +10 -7
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/react/generator.d.ts +2 -2
- package/src/py/fast-api/react/generator.js +7 -5
- package/src/py/fast-api/react/generator.js.map +1 -1
- package/src/py/fast-api/react/schema.d.js.map +1 -1
- package/src/py/fast-api/react/schema.d.ts +1 -0
- package/src/py/fast-api/react/schema.json +5 -0
- package/src/py/fast-api/schema.d.js.map +1 -1
- package/src/py/fast-api/schema.d.ts +1 -0
- package/src/py/fast-api/schema.json +5 -0
- package/src/py/lambda-function/generator.js +8 -6
- package/src/py/lambda-function/generator.js.map +1 -1
- package/src/py/lambda-function/schema.d.js.map +1 -1
- package/src/py/lambda-function/schema.d.ts +1 -0
- package/src/py/lambda-function/schema.json +5 -0
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/py/mcp-server/generator.js +8 -6
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/mcp-server/schema.d.js.map +1 -1
- package/src/py/mcp-server/schema.d.ts +1 -0
- package/src/py/mcp-server/schema.json +5 -0
- package/src/py/project/generator.js +9 -6
- package/src/py/project/generator.js.map +1 -1
- package/src/py/project/schema.d.js.map +1 -1
- package/src/py/project/schema.d.ts +1 -0
- package/src/py/project/schema.json +5 -0
- package/src/sdk/open-api.d.ts +1 -1
- package/src/sdk/open-api.js +1 -1
- package/src/sdk/open-api.js.map +1 -1
- package/src/sdk/utils/ast.d.ts +1 -2
- package/src/sdk/utils/ast.js +1 -2
- package/src/sdk/utils/ast.js.map +1 -1
- package/src/smithy/project/generator.js +7 -4
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/project/schema.d.js.map +1 -1
- package/src/smithy/project/schema.d.ts +1 -0
- package/src/smithy/project/schema.json +5 -0
- package/src/smithy/react-connection/generator.js +7 -4
- package/src/smithy/react-connection/generator.js.map +1 -1
- package/src/smithy/react-connection/schema.d.js.map +1 -1
- package/src/smithy/react-connection/schema.d.ts +1 -0
- package/src/smithy/react-connection/schema.json +5 -0
- package/src/smithy/ts/api/generator.js +11 -6
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/smithy/ts/api/schema.d.js.map +1 -1
- package/src/smithy/ts/api/schema.d.ts +1 -0
- package/src/smithy/ts/api/schema.json +5 -0
- package/src/terraform/project/generator.js +13 -4
- package/src/terraform/project/generator.js.map +1 -1
- package/src/terraform/project/schema.d.js.map +1 -1
- package/src/terraform/project/schema.d.ts +1 -0
- package/src/terraform/project/schema.json +5 -0
- package/src/trpc/backend/generator.d.ts +1 -1
- package/src/trpc/backend/generator.js +9 -5
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.d.js.map +1 -1
- package/src/trpc/backend/schema.d.ts +1 -0
- package/src/trpc/backend/schema.json +5 -0
- package/src/trpc/react/generator.d.ts +1 -1
- package/src/trpc/react/generator.js +9 -5
- package/src/trpc/react/generator.js.map +1 -1
- package/src/trpc/react/schema.d.js.map +1 -1
- package/src/trpc/react/schema.d.ts +1 -0
- package/src/trpc/react/schema.json +5 -0
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/agent/a2a-connection/generator.js +7 -4
- package/src/ts/agent/a2a-connection/generator.js.map +1 -1
- package/src/ts/agent/a2a-connection/schema.d.js.map +1 -1
- package/src/ts/agent/a2a-connection/schema.d.ts +1 -0
- package/src/ts/agent/a2a-connection/schema.json +5 -0
- package/src/ts/agent/gateway-connection/generator.js +7 -4
- package/src/ts/agent/gateway-connection/generator.js.map +1 -1
- package/src/ts/agent/gateway-connection/schema.d.js.map +1 -1
- package/src/ts/agent/gateway-connection/schema.d.ts +1 -0
- package/src/ts/agent/gateway-connection/schema.json +5 -0
- package/src/ts/agent/generator.js +7 -4
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/generator.js +7 -4
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/schema.d.js.map +1 -1
- package/src/ts/agent/mcp-connection/schema.d.ts +1 -0
- package/src/ts/agent/mcp-connection/schema.json +5 -0
- package/src/ts/agent/react-connection/generator.d.ts +1 -1
- package/src/ts/agent/react-connection/generator.js +14 -8
- package/src/ts/agent/react-connection/generator.js.map +1 -1
- package/src/ts/agent/react-connection/schema.d.js.map +1 -1
- package/src/ts/agent/react-connection/schema.d.ts +1 -0
- package/src/ts/agent/react-connection/schema.json +5 -0
- package/src/ts/agent/schema.d.js.map +1 -1
- package/src/ts/agent/schema.d.ts +1 -0
- package/src/ts/agent/schema.json +5 -0
- package/src/ts/api/generator.js +4 -2
- package/src/ts/api/generator.js.map +1 -1
- package/src/ts/api/schema.d.js.map +1 -1
- package/src/ts/api/schema.d.ts +1 -0
- package/src/ts/api/schema.json +5 -0
- package/src/ts/astro-docs/generator.js +7 -6
- package/src/ts/astro-docs/generator.js.map +1 -1
- package/src/ts/astro-docs/schema.d.js.map +1 -1
- package/src/ts/astro-docs/schema.d.ts +2 -2
- package/src/ts/astro-docs/schema.json +3 -3
- package/src/ts/docs/schema.d.js.map +1 -1
- package/src/ts/docs/schema.d.ts +1 -4
- package/src/ts/docs/schema.json +3 -3
- package/src/ts/dynamodb/agent-connection/schema.d.js.map +1 -1
- package/src/ts/dynamodb/agent-connection/schema.d.ts +1 -0
- package/src/ts/dynamodb/agent-connection/schema.json +5 -0
- package/src/ts/dynamodb/generator.js +9 -5
- package/src/ts/dynamodb/generator.js.map +1 -1
- package/src/ts/dynamodb/mcp-server-connection/schema.d.js.map +1 -1
- package/src/ts/dynamodb/mcp-server-connection/schema.d.ts +1 -0
- package/src/ts/dynamodb/mcp-server-connection/schema.json +5 -0
- package/src/ts/dynamodb/schema.d.js.map +1 -1
- package/src/ts/dynamodb/schema.d.ts +1 -0
- package/src/ts/dynamodb/schema.json +5 -0
- package/src/ts/dynamodb/smithy-connection/schema.d.js.map +1 -1
- package/src/ts/dynamodb/smithy-connection/schema.d.ts +1 -0
- package/src/ts/dynamodb/smithy-connection/schema.json +5 -0
- package/src/ts/dynamodb/trpc-connection/schema.d.js.map +1 -1
- package/src/ts/dynamodb/trpc-connection/schema.d.ts +1 -0
- package/src/ts/dynamodb/trpc-connection/schema.json +5 -0
- package/src/ts/lambda-function/generator.js +7 -4
- package/src/ts/lambda-function/generator.js.map +1 -1
- package/src/ts/lambda-function/schema.d.js.map +1 -1
- package/src/ts/lambda-function/schema.d.ts +1 -0
- package/src/ts/lambda-function/schema.json +5 -0
- package/src/ts/lib/generator.js +10 -6
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/schema.d.js.map +1 -1
- package/src/ts/lib/schema.d.ts +1 -1
- package/src/ts/lib/schema.json +5 -0
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/mcp-server/generator.js +7 -4
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/mcp-server/schema.d.js.map +1 -1
- package/src/ts/mcp-server/schema.d.ts +1 -0
- package/src/ts/mcp-server/schema.json +5 -0
- package/src/ts/nx-generator/__snapshots__/generator.spec.ts.snap +18 -8
- package/src/ts/nx-generator/files/common/schema.d.ts.template +1 -0
- package/src/ts/nx-generator/files/common/schema.json.template +5 -0
- package/src/ts/nx-generator/files/nx-plugin-for-aws/generator/generator.ts.template +3 -4
- package/src/ts/nx-generator/generator.js +7 -4
- package/src/ts/nx-generator/generator.js.map +1 -1
- package/src/ts/nx-generator/schema.d.js.map +1 -1
- package/src/ts/nx-generator/schema.d.ts +1 -0
- package/src/ts/nx-generator/schema.json +5 -0
- package/src/ts/nx-plugin/generator.js +13 -6
- package/src/ts/nx-plugin/generator.js.map +1 -1
- package/src/ts/nx-plugin/schema.json +5 -0
- package/src/ts/rdb/agent-connection/schema.d.js.map +1 -1
- package/src/ts/rdb/agent-connection/schema.d.ts +1 -0
- package/src/ts/rdb/agent-connection/schema.json +5 -0
- package/src/ts/rdb/generator.js +9 -5
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/schema.d.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/schema.d.ts +1 -0
- package/src/ts/rdb/mcp-server-connection/schema.json +5 -0
- package/src/ts/rdb/schema.d.js.map +1 -1
- package/src/ts/rdb/schema.d.ts +1 -0
- package/src/ts/rdb/schema.json +5 -0
- package/src/ts/rdb/smithy-connection/schema.d.js.map +1 -1
- package/src/ts/rdb/smithy-connection/schema.d.ts +1 -0
- package/src/ts/rdb/smithy-connection/schema.json +5 -0
- package/src/ts/rdb/trpc-connection/schema.d.js.map +1 -1
- package/src/ts/rdb/trpc-connection/schema.d.ts +1 -0
- package/src/ts/rdb/trpc-connection/schema.json +5 -0
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +26 -26
- package/src/ts/react-website/app/generator.d.ts +1 -1
- package/src/ts/react-website/app/generator.js +18 -6
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/app/schema.d.js.map +1 -1
- package/src/ts/react-website/app/schema.d.ts +1 -1
- package/src/ts/react-website/app/schema.json +5 -0
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +1 -1
- package/src/ts/react-website/cognito-auth/generator.d.ts +1 -1
- package/src/ts/react-website/cognito-auth/generator.js +9 -5
- package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/schema.d.js.map +1 -1
- package/src/ts/react-website/cognito-auth/schema.d.ts +1 -0
- package/src/ts/react-website/cognito-auth/schema.json +5 -0
- package/src/ts/react-website/runtime-config/schema.d.js.map +1 -1
- package/src/ts/react-website/runtime-config/schema.d.ts +1 -0
- package/src/ts/react-website/runtime-config/schema.json +5 -0
- package/src/ts/website/app/schema.d.js.map +1 -1
- package/src/ts/website/app/schema.d.ts +1 -1
- package/src/ts/website/app/schema.json +5 -0
- package/src/ts/website/auth/generator.d.ts +1 -1
- package/src/ts/website/auth/generator.js +2 -1
- package/src/ts/website/auth/generator.js.map +1 -1
- package/src/ts/website/auth/schema.d.js.map +1 -1
- package/src/ts/website/auth/schema.d.ts +1 -0
- package/src/ts/website/auth/schema.json +5 -0
- package/src/utils/files/common/scripts/src/infra/stage-credentials/cdk-command.ts.template +11 -3
- package/src/utils/install.d.ts +32 -0
- package/src/utils/install.js +56 -0
- package/src/utils/install.js.map +1 -0
- package/src/utils/versions.d.ts +64 -64
- package/src/utils/versions.js +63 -63
- package/src/utils/versions.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/project/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 ensurePackage,\n type GeneratorCallback,\n installPackagesTask,\n joinPathFragments,\n readNxJson,\n readProjectConfiguration,\n type Tree,\n updateNxJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport {\n addLicenseCheckToLintTarget,\n ensurePythonLicenseCollector,\n} from '../../license/config';\nimport { updateGitIgnore } from '../../utils/git';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { normalizeDistributionName, toSnakeCase } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx';\nimport type { UVPyprojectToml } from '../../utils/nxlv-python';\nimport {\n Logger,\n migrateToSharedVenvGenerator,\n UVProvider,\n uvProjectGenerator,\n} from '../../utils/nxlv-python';\nimport { sortObjectKeys } from '../../utils/object';\nimport { addDependenciesToDependencyGroupInPyProjectToml } from '../../utils/py';\nimport { updateToml } from '../../utils/toml';\nimport { withVersions } from '../../utils/versions';\nimport type { PyProjectGeneratorSchema } from './schema';\n\nexport const PY_PROJECT_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\n// Transient artifacts that pytest, coverage and ruff create and remove while\n// the test, typecheck and compile targets run concurrently. `.coverage.*` are\n// the per-process data files pytest-cov writes (`.coverage.<host>.<pid>.<rand>`)\n// before combining them. Both `ty` (which respects .gitignore) and the\n// `@nxlv/python:build` copy (which respects `ignorePaths`) would otherwise fail\n// when they read one of these mid-deletion.\nconst PYTHON_TRANSIENT_ARTIFACTS = [\n '__pycache__',\n '.coverage',\n '.coverage.*',\n '.pytest_cache',\n 'pytest-cache-files-*',\n '.ruff_cache',\n];\n\nexport interface PyProjectDetails {\n /**\n * Fully qualified Nx project id including scope, in dot notation (eg foo.bar).\n * This is the identifier Nx uses (readProjectConfiguration, the project\n * graph, target references) and is intentionally kept dotted.\n */\n readonly fullyQualifiedName: string;\n /**\n * PEP 503 normalised Python distribution name (eg foo-bar). This is the name\n * written to the project's `[project].name`, the root `[tool.uv.sources]`\n * key, and any inter-project dependency string. It is hyphenated (not dotted)\n * so `uv` and `@nxlv/python` can match it: uv writes `uv.lock` keyed by the\n * PEP 503 hyphenated name, and `@nxlv/python`'s dependency inference splits a\n * dotted name on `.` and so would otherwise drop the edge entirely. Keeping\n * the distribution name decoupled from `fullyQualifiedName` is what lets the\n * workspace dependency edge appear in the Nx project graph.\n */\n readonly distributionName: string;\n /**\n * Directory of the library relative to the root\n */\n readonly dir: string;\n /**\n * Module name for the project\n */\n readonly normalizedModuleName: string;\n}\n\n/**\n * Returns details about the Python project to be created\n */\nexport const getPyProjectDetails = (\n tree: Tree,\n schema: {\n name: string;\n directory?: string;\n subDirectory?: string;\n moduleName?: string;\n },\n): PyProjectDetails => {\n const scope = toSnakeCase(getNpmScope(tree));\n const normalizedName = toSnakeCase(schema.name);\n const normalizedModuleName = toSnakeCase(\n schema.moduleName ?? `${scope}_${normalizedName}`,\n );\n const fullyQualifiedName = `${scope}.${normalizedName}`;\n // The Python distribution name is the PEP 503 normalised form of the\n // fully qualified name: hyphenated, never dotted. See PyProjectDetails.\n const distributionName = normalizeDistributionName(fullyQualifiedName);\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, distributionName, normalizedModuleName };\n};\n\n/**\n * Generates a Python project\n */\nexport const pyProjectGenerator = async (\n tree: Tree,\n schema: PyProjectGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const { dir, normalizedModuleName, fullyQualifiedName, distributionName } =\n getPyProjectDetails(tree, schema);\n\n const pythonPlugin = withVersions(['@nxlv/python']);\n addDependenciesToPackageJson(tree, {}, pythonPlugin);\n\n Object.entries(pythonPlugin).forEach(([name, version]) =>\n ensurePackage(name, version),\n );\n\n const nxJson = readNxJson(tree);\n\n // Only rewrite nx.json when the plugin needs adding, so re-running does not\n // reserialize (and reformat) the file when nothing has changed.\n if (\n !nxJson.plugins?.find((p) =>\n typeof p === 'string'\n ? p === '@nxlv/python'\n : p.plugin === '@nxlv/python',\n )\n ) {\n nxJson.plugins = [\n ...(nxJson.plugins ?? []),\n {\n plugin: '@nxlv/python',\n options: {\n packageManager: 'uv',\n },\n },\n ];\n updateNxJson(tree, nxJson);\n }\n\n // Only scaffold the project when it does not already exist so re-running with\n // the same name does not throw. The rest of the generator still runs to apply\n // any changed options to the existing project.\n if (!projectExists(tree, fullyQualifiedName)) {\n if (!tree.exists('uv.lock')) {\n await migrateToSharedVenvGenerator(tree, {\n autoActivate: true,\n packageManager: 'uv',\n moveDevDependencies: false,\n pyenvPythonVersion: '3.14.0',\n pyprojectPythonDependency: '>=3.14',\n });\n }\n\n await uvProjectGenerator(tree, {\n // The Nx project id (and `uv.workspace.members` etc.) keys off `name`, so\n // keep it dotted. `packageName` is the separate PEP 503 distribution name\n // written to `[project].name` and the root `[tool.uv.sources]` key; it is\n // hyphenated so `@nxlv/python` infers the workspace dependency edge (it\n // splits a dotted name on `.` and would otherwise drop it). This split is\n // the whole fix (see PyProjectDetails.distributionName).\n name: fullyQualifiedName,\n packageName: distributionName,\n publishable: false,\n buildLockedVersions: true,\n buildBundleLocalDependencies: true,\n linter: 'ruff',\n rootPyprojectDependencyGroup: 'main',\n pyenvPythonVersion: '3.14.0',\n pyprojectPythonDependency: '>=3.14',\n projectType: schema.type,\n projectNameAndRootFormat: 'as-provided',\n moduleName: normalizedModuleName,\n directory: dir,\n unitTestRunner: 'pytest',\n codeCoverage: true,\n codeCoverageHtmlReport: true,\n codeCoverageXmlReport: true,\n unitTestHtmlReport: true,\n unitTestJUnitReport: true,\n buildSystem: 'hatch',\n srcDir: false,\n });\n\n // Remove generated hello.py and test_hello.py as they are not needed\n [\n joinPathFragments(dir, normalizedModuleName, 'hello.py'),\n joinPathFragments(dir, 'tests', 'test_hello.py'),\n ].forEach((f) => tree.delete(f));\n\n // Add a placeholder test so pytest doesn't fail with \"no tests collected\"\n tree.write(\n joinPathFragments(dir, 'tests', 'test_noop.py'),\n 'def test_noop():\\n pass\\n',\n );\n }\n\n const outputPath = '{workspaceRoot}/dist/{projectRoot}';\n const buildOutputPath = joinPathFragments(outputPath, 'build');\n const projectConfiguration = readProjectConfiguration(\n tree,\n fullyQualifiedName,\n );\n projectConfiguration.name = fullyQualifiedName;\n // Derive the compile target from the uv build target, and rewrite build to\n // orchestrate the other targets. This only runs on first creation: on re-run\n // build has already been transformed, so re-deriving would corrupt compile\n // and duplicate the build dependencies.\n if (!projectConfiguration.targets.compile) {\n const buildTarget = projectConfiguration.targets.build;\n projectConfiguration.targets.compile = {\n ...buildTarget,\n inputs: ['default', '^production'],\n outputs: [buildOutputPath],\n options: {\n ...buildTarget.options,\n outputPath: buildOutputPath,\n // The build executor copies the project to a temp folder; exclude the\n // executor defaults plus transient artifacts so the copy does not race\n // a concurrent test/typecheck target deleting a file mid-copy.\n ignorePaths: ['.venv', '.tox', 'tests', ...PYTHON_TRANSIENT_ARTIFACTS],\n },\n };\n projectConfiguration.targets.build = {\n inputs: ['default', '^production'],\n dependsOn: [\n 'lint',\n 'compile',\n 'test',\n 'typecheck',\n ...(buildTarget.dependsOn ?? []),\n ],\n options: {\n outputPath,\n },\n };\n }\n projectConfiguration.targets.typecheck = {\n cache: true,\n inputs: ['default', '^production'],\n executor: '@nxlv/python:run-commands',\n options: {\n command: 'uv run ty check',\n cwd: '{projectRoot}',\n },\n };\n\n // Set the default line length to 120, as 88 is a little too strict\n updateToml(\n tree,\n joinPathFragments(dir, 'pyproject.toml'),\n (pyProjectToml: UVPyprojectToml) => {\n if ((pyProjectToml.tool as any)?.ruff) {\n (pyProjectToml.tool as any).ruff['line-length'] = 120;\n }\n return pyProjectToml;\n },\n );\n\n addDependenciesToDependencyGroupInPyProjectToml(tree, '.', 'dev', ['ty']);\n\n // Add a dependency on the format target for lint in order to reduce the number of\n // fixable lint errors (eg line too long)\n projectConfiguration.targets.lint = {\n ...projectConfiguration.targets.lint,\n cache: true,\n inputs: ['default', '^production'],\n configurations: {\n ...projectConfiguration.targets.lint?.configurations,\n fix: {\n fix: true,\n },\n 'skip-lint': {\n exitZero: true,\n },\n },\n };\n // Append `format` without moving an existing entry, so re-running does not\n // reorder lint dependencies (e.g. relative to a later-added license-check).\n addDependencyToTargetIfNotPresent(projectConfiguration, 'lint', 'format');\n\n projectConfiguration.targets = sortObjectKeys(projectConfiguration.targets);\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfiguration);\n\n addGeneratorMetadata(tree, fullyQualifiedName, PY_PROJECT_GENERATOR_INFO);\n\n // Update root .gitignore\n updateGitIgnore(tree, '.', (patterns) => [...patterns, '/reports']);\n\n // Update project level .gitignore. The cache directories are also kept out\n // of type checking: `ty` respects .gitignore, and pytest creates and removes\n // transient `pytest-cache-files-*` directories while the test and typecheck\n // targets run concurrently, which would otherwise make `ty` fail with an I/O\n // error when it scans one mid-deletion.\n updateGitIgnore(tree, dir, (patterns) => [\n ...patterns,\n '**/__pycache__',\n ...PYTHON_TRANSIENT_ARTIFACTS.filter((p) => p !== '__pycache__'),\n ]);\n\n await addGeneratorMetricsIfApplicable(tree, [PY_PROJECT_GENERATOR_INFO]);\n\n await ensurePythonLicenseCollector(tree);\n\n // If license checking is configured, make this project's lint target depend\n // on the root license-check target. No-op if license checking isn't set up;\n // the license generator wires up existing projects itself, so the dependency\n // is added regardless of which generator runs first.\n addLicenseCheckToLintTarget(tree, fullyQualifiedName);\n\n return async () => {\n installPackagesTask(tree);\n await new UVProvider(tree.root, new Logger(), tree).install();\n };\n};\nexport default pyProjectGenerator;\n"],"names":["addDependenciesToPackageJson","ensurePackage","installPackagesTask","joinPathFragments","readNxJson","readProjectConfiguration","updateNxJson","updateProjectConfiguration","addLicenseCheckToLintTarget","ensurePythonLicenseCollector","updateGitIgnore","addGeneratorMetricsIfApplicable","normalizeDistributionName","toSnakeCase","getNpmScope","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","projectExists","Logger","migrateToSharedVenvGenerator","UVProvider","uvProjectGenerator","sortObjectKeys","addDependenciesToDependencyGroupInPyProjectToml","updateToml","withVersions","PY_PROJECT_GENERATOR_INFO","filename","PYTHON_TRANSIENT_ARTIFACTS","getPyProjectDetails","tree","schema","scope","normalizedName","name","normalizedModuleName","moduleName","fullyQualifiedName","distributionName","dir","directory","subDirectory","pyProjectGenerator","pythonPlugin","Object","entries","forEach","version","nxJson","plugins","find","p","plugin","options","packageManager","exists","autoActivate","moveDevDependencies","pyenvPythonVersion","pyprojectPythonDependency","packageName","publishable","buildLockedVersions","buildBundleLocalDependencies","linter","rootPyprojectDependencyGroup","projectType","type","projectNameAndRootFormat","unitTestRunner","codeCoverage","codeCoverageHtmlReport","codeCoverageXmlReport","unitTestHtmlReport","unitTestJUnitReport","buildSystem","srcDir","f","delete","write","outputPath","buildOutputPath","projectConfiguration","targets","compile","buildTarget","build","inputs","outputs","ignorePaths","dependsOn","typecheck","cache","executor","command","cwd","pyProjectToml","tool","ruff","lint","configurations","fix","exitZero","patterns","filter","root","install"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAC5BC,aAAa,EAEbC,mBAAmB,EACnBC,iBAAiB,EACjBC,UAAU,EACVC,wBAAwB,EAExBC,YAAY,EACZC,0BAA0B,QACrB,aAAa;AACpB,SACEC,2BAA2B,EAC3BC,4BAA4B,QACvB,0BAAuB;AAC9B,SAASC,eAAe,QAAQ,qBAAkB;AAClD,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,yBAAyB,EAAEC,WAAW,QAAQ,uBAAoB;AAC3E,SAASC,WAAW,QAAQ,2BAAwB;AACpD,SACEC,iCAAiC,EACjCC,oBAAoB,EACpBC,gBAAgB,EAEhBC,aAAa,QACR,oBAAiB;AAExB,SACEC,MAAM,EACNC,4BAA4B,EAC5BC,UAAU,EACVC,kBAAkB,QACb,6BAA0B;AACjC,SAAS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,qBAAqBC,OAAO,CAACgB,IAAI;QACpCP,OAAO;QACPL,QAAQ;YAAC;YAAW;SAAc;QAClCa,gBAAgB;YACd,GAAGlB,qBAAqBC,OAAO,CAACgB,IAAI,EAAEC,cAAc;YACpDC,KAAK;gBACHA,KAAK;YACP;YACA,aAAa;gBACXC,UAAU;YACZ;QACF;IACF;IACA,2EAA2E;IAC3E,4EAA4E;IAC5ExF,kCAAkCoE,sBAAsB,QAAQ;IAEhEA,qBAAqBC,OAAO,GAAG7D,eAAe4D,qBAAqBC,OAAO;IAC1E7E,2BAA2BwB,MAAMO,oBAAoB6C;IAErDnE,qBAAqBe,MAAMO,oBAAoBX;IAE/C,yBAAyB;IACzBjB,gBAAgBqB,MAAM,KAAK,CAACyE,WAAa;eAAIA;YAAU;SAAW;IAElE,2EAA2E;IAC3E,6EAA6E;IAC7E,4EAA4E;IAC5E,6EAA6E;IAC7E,wCAAwC;IACxC9F,gBAAgBqB,MAAMS,KAAK,CAACgE,WAAa;eACpCA;YACH;eACG3E,2BAA2B4E,MAAM,CAAC,CAACrD,IAAMA,MAAM;SACnD;IAED,MAAMzC,gCAAgCoB,MAAM;QAACJ;KAA0B;IAEvE,MAAMlB,6BAA6BsB;IAEnC,4EAA4E;IAC5E,4EAA4E;IAC5E,6EAA6E;IAC7E,qDAAqD;IACrDvB,4BAA4BuB,MAAMO;IAElC,OAAO;QACLpC,oBAAoB6B;QACpB,MAAM,IAAIV,WAAWU,KAAK2E,IAAI,EAAE,IAAIvF,UAAUY,MAAM4E,OAAO;IAC7D;AACF,EAAE;AACF,eAAehE,mBAAmB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/project/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 ensurePackage,\n type GeneratorCallback,\n joinPathFragments,\n readNxJson,\n readProjectConfiguration,\n type Tree,\n updateNxJson,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport {\n addLicenseCheckToLintTarget,\n ensurePythonLicenseCollector,\n} from '../../license/config';\nimport { updateGitIgnore } from '../../utils/git';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { normalizeDistributionName, toSnakeCase } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx';\nimport type { UVPyprojectToml } from '../../utils/nxlv-python';\nimport {\n migrateToSharedVenvGenerator,\n uvProjectGenerator,\n} from '../../utils/nxlv-python';\nimport { sortObjectKeys } from '../../utils/object';\nimport { addDependenciesToDependencyGroupInPyProjectToml } from '../../utils/py';\nimport { updateToml } from '../../utils/toml';\nimport { withVersions } from '../../utils/versions';\nimport type { PyProjectGeneratorSchema } from './schema';\n\nexport const PY_PROJECT_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\n// Transient artifacts that pytest, coverage and ruff create and remove while\n// the test, typecheck and compile targets run concurrently. `.coverage.*` are\n// the per-process data files pytest-cov writes (`.coverage.<host>.<pid>.<rand>`)\n// before combining them. Both `ty` (which respects .gitignore) and the\n// `@nxlv/python:build` copy (which respects `ignorePaths`) would otherwise fail\n// when they read one of these mid-deletion.\nconst PYTHON_TRANSIENT_ARTIFACTS = [\n '__pycache__',\n '.coverage',\n '.coverage.*',\n '.pytest_cache',\n 'pytest-cache-files-*',\n '.ruff_cache',\n];\n\nexport interface PyProjectDetails {\n /**\n * Fully qualified Nx project id including scope, in dot notation (eg foo.bar).\n * This is the identifier Nx uses (readProjectConfiguration, the project\n * graph, target references) and is intentionally kept dotted.\n */\n readonly fullyQualifiedName: string;\n /**\n * PEP 503 normalised Python distribution name (eg foo-bar). This is the name\n * written to the project's `[project].name`, the root `[tool.uv.sources]`\n * key, and any inter-project dependency string. It is hyphenated (not dotted)\n * so `uv` and `@nxlv/python` can match it: uv writes `uv.lock` keyed by the\n * PEP 503 hyphenated name, and `@nxlv/python`'s dependency inference splits a\n * dotted name on `.` and so would otherwise drop the edge entirely. Keeping\n * the distribution name decoupled from `fullyQualifiedName` is what lets the\n * workspace dependency edge appear in the Nx project graph.\n */\n readonly distributionName: string;\n /**\n * Directory of the library relative to the root\n */\n readonly dir: string;\n /**\n * Module name for the project\n */\n readonly normalizedModuleName: string;\n}\n\n/**\n * Returns details about the Python project to be created\n */\nexport const getPyProjectDetails = (\n tree: Tree,\n schema: {\n name: string;\n directory?: string;\n subDirectory?: string;\n moduleName?: string;\n },\n): PyProjectDetails => {\n const scope = toSnakeCase(getNpmScope(tree));\n const normalizedName = toSnakeCase(schema.name);\n const normalizedModuleName = toSnakeCase(\n schema.moduleName ?? `${scope}_${normalizedName}`,\n );\n const fullyQualifiedName = `${scope}.${normalizedName}`;\n // The Python distribution name is the PEP 503 normalised form of the\n // fully qualified name: hyphenated, never dotted. See PyProjectDetails.\n const distributionName = normalizeDistributionName(fullyQualifiedName);\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, distributionName, normalizedModuleName };\n};\n\n/**\n * Generates a Python project\n */\nexport const pyProjectGenerator = async (\n tree: Tree,\n schema: PyProjectGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const { dir, normalizedModuleName, fullyQualifiedName, distributionName } =\n getPyProjectDetails(tree, schema);\n\n const pythonPlugin = withVersions(['@nxlv/python']);\n addDependenciesToPackageJson(tree, {}, pythonPlugin);\n\n Object.entries(pythonPlugin).forEach(([name, version]) =>\n ensurePackage(name, version),\n );\n\n const nxJson = readNxJson(tree);\n\n // Only rewrite nx.json when the plugin needs adding, so re-running does not\n // reserialize (and reformat) the file when nothing has changed.\n if (\n !nxJson.plugins?.find((p) =>\n typeof p === 'string'\n ? p === '@nxlv/python'\n : p.plugin === '@nxlv/python',\n )\n ) {\n nxJson.plugins = [\n ...(nxJson.plugins ?? []),\n {\n plugin: '@nxlv/python',\n options: {\n packageManager: 'uv',\n },\n },\n ];\n updateNxJson(tree, nxJson);\n }\n\n // Only scaffold the project when it does not already exist so re-running with\n // the same name does not throw. The rest of the generator still runs to apply\n // any changed options to the existing project.\n if (!projectExists(tree, fullyQualifiedName)) {\n if (!tree.exists('uv.lock')) {\n await migrateToSharedVenvGenerator(tree, {\n autoActivate: true,\n packageManager: 'uv',\n moveDevDependencies: false,\n pyenvPythonVersion: '3.14.0',\n pyprojectPythonDependency: '>=3.14',\n });\n }\n\n await uvProjectGenerator(tree, {\n // The Nx project id (and `uv.workspace.members` etc.) keys off `name`, so\n // keep it dotted. `packageName` is the separate PEP 503 distribution name\n // written to `[project].name` and the root `[tool.uv.sources]` key; it is\n // hyphenated so `@nxlv/python` infers the workspace dependency edge (it\n // splits a dotted name on `.` and would otherwise drop it). This split is\n // the whole fix (see PyProjectDetails.distributionName).\n name: fullyQualifiedName,\n packageName: distributionName,\n publishable: false,\n buildLockedVersions: true,\n buildBundleLocalDependencies: true,\n linter: 'ruff',\n rootPyprojectDependencyGroup: 'main',\n pyenvPythonVersion: '3.14.0',\n pyprojectPythonDependency: '>=3.14',\n projectType: schema.type,\n projectNameAndRootFormat: 'as-provided',\n moduleName: normalizedModuleName,\n directory: dir,\n unitTestRunner: 'pytest',\n codeCoverage: true,\n codeCoverageHtmlReport: true,\n codeCoverageXmlReport: true,\n unitTestHtmlReport: true,\n unitTestJUnitReport: true,\n buildSystem: 'hatch',\n srcDir: false,\n });\n\n // Remove generated hello.py and test_hello.py as they are not needed\n [\n joinPathFragments(dir, normalizedModuleName, 'hello.py'),\n joinPathFragments(dir, 'tests', 'test_hello.py'),\n ].forEach((f) => tree.delete(f));\n\n // Add a placeholder test so pytest doesn't fail with \"no tests collected\"\n tree.write(\n joinPathFragments(dir, 'tests', 'test_noop.py'),\n 'def test_noop():\\n pass\\n',\n );\n }\n\n const outputPath = '{workspaceRoot}/dist/{projectRoot}';\n const buildOutputPath = joinPathFragments(outputPath, 'build');\n const projectConfiguration = readProjectConfiguration(\n tree,\n fullyQualifiedName,\n );\n projectConfiguration.name = fullyQualifiedName;\n // Derive the compile target from the uv build target, and rewrite build to\n // orchestrate the other targets. This only runs on first creation: on re-run\n // build has already been transformed, so re-deriving would corrupt compile\n // and duplicate the build dependencies.\n if (!projectConfiguration.targets.compile) {\n const buildTarget = projectConfiguration.targets.build;\n projectConfiguration.targets.compile = {\n ...buildTarget,\n inputs: ['default', '^production'],\n outputs: [buildOutputPath],\n options: {\n ...buildTarget.options,\n outputPath: buildOutputPath,\n // The build executor copies the project to a temp folder; exclude the\n // executor defaults plus transient artifacts so the copy does not race\n // a concurrent test/typecheck target deleting a file mid-copy.\n ignorePaths: ['.venv', '.tox', 'tests', ...PYTHON_TRANSIENT_ARTIFACTS],\n },\n };\n projectConfiguration.targets.build = {\n inputs: ['default', '^production'],\n dependsOn: [\n 'lint',\n 'compile',\n 'test',\n 'typecheck',\n ...(buildTarget.dependsOn ?? []),\n ],\n options: {\n outputPath,\n },\n };\n }\n projectConfiguration.targets.typecheck = {\n cache: true,\n inputs: ['default', '^production'],\n executor: '@nxlv/python:run-commands',\n options: {\n command: 'uv run ty check',\n cwd: '{projectRoot}',\n },\n };\n\n // Set the default line length to 120, as 88 is a little too strict\n updateToml(\n tree,\n joinPathFragments(dir, 'pyproject.toml'),\n (pyProjectToml: UVPyprojectToml) => {\n if ((pyProjectToml.tool as any)?.ruff) {\n (pyProjectToml.tool as any).ruff['line-length'] = 120;\n }\n return pyProjectToml;\n },\n );\n\n addDependenciesToDependencyGroupInPyProjectToml(tree, '.', 'dev', ['ty']);\n\n // Add a dependency on the format target for lint in order to reduce the number of\n // fixable lint errors (eg line too long)\n projectConfiguration.targets.lint = {\n ...projectConfiguration.targets.lint,\n cache: true,\n inputs: ['default', '^production'],\n configurations: {\n ...projectConfiguration.targets.lint?.configurations,\n fix: {\n fix: true,\n },\n 'skip-lint': {\n exitZero: true,\n },\n },\n };\n // Append `format` without moving an existing entry, so re-running does not\n // reorder lint dependencies (e.g. relative to a later-added license-check).\n addDependencyToTargetIfNotPresent(projectConfiguration, 'lint', 'format');\n\n projectConfiguration.targets = sortObjectKeys(projectConfiguration.targets);\n updateProjectConfiguration(tree, fullyQualifiedName, projectConfiguration);\n\n addGeneratorMetadata(tree, fullyQualifiedName, PY_PROJECT_GENERATOR_INFO);\n\n // Update root .gitignore\n updateGitIgnore(tree, '.', (patterns) => [...patterns, '/reports']);\n\n // Update project level .gitignore. The cache directories are also kept out\n // of type checking: `ty` respects .gitignore, and pytest creates and removes\n // transient `pytest-cache-files-*` directories while the test and typecheck\n // targets run concurrently, which would otherwise make `ty` fail with an I/O\n // error when it scans one mid-deletion.\n updateGitIgnore(tree, dir, (patterns) => [\n ...patterns,\n '**/__pycache__',\n ...PYTHON_TRANSIENT_ARTIFACTS.filter((p) => p !== '__pycache__'),\n ]);\n\n await addGeneratorMetricsIfApplicable(tree, [PY_PROJECT_GENERATOR_INFO]);\n\n await ensurePythonLicenseCollector(tree);\n\n // If license checking is configured, make this project's lint target depend\n // on the root license-check target. No-op if license checking isn't set up;\n // the license generator wires up existing projects itself, so the dependency\n // is added regardless of which generator runs first.\n addLicenseCheckToLintTarget(tree, fullyQualifiedName);\n\n return () =>\n installDependencies(tree, schema.preferInstallDependencies, {\n languages: ['typescript', 'python'],\n });\n};\nexport default pyProjectGenerator;\n"],"names":["addDependenciesToPackageJson","ensurePackage","joinPathFragments","readNxJson","readProjectConfiguration","updateNxJson","updateProjectConfiguration","addLicenseCheckToLintTarget","ensurePythonLicenseCollector","updateGitIgnore","installDependencies","addGeneratorMetricsIfApplicable","normalizeDistributionName","toSnakeCase","getNpmScope","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","projectExists","migrateToSharedVenvGenerator","uvProjectGenerator","sortObjectKeys","addDependenciesToDependencyGroupInPyProjectToml","updateToml","withVersions","PY_PROJECT_GENERATOR_INFO","filename","PYTHON_TRANSIENT_ARTIFACTS","getPyProjectDetails","tree","schema","scope","normalizedName","name","normalizedModuleName","moduleName","fullyQualifiedName","distributionName","dir","directory","subDirectory","pyProjectGenerator","pythonPlugin","Object","entries","forEach","version","nxJson","plugins","find","p","plugin","options","packageManager","exists","autoActivate","moveDevDependencies","pyenvPythonVersion","pyprojectPythonDependency","packageName","publishable","buildLockedVersions","buildBundleLocalDependencies","linter","rootPyprojectDependencyGroup","projectType","type","projectNameAndRootFormat","unitTestRunner","codeCoverage","codeCoverageHtmlReport","codeCoverageXmlReport","unitTestHtmlReport","unitTestJUnitReport","buildSystem","srcDir","f","delete","write","outputPath","buildOutputPath","projectConfiguration","targets","compile","buildTarget","build","inputs","outputs","ignorePaths","dependsOn","typecheck","cache","executor","command","cwd","pyProjectToml","tool","ruff","lint","configurations","fix","exitZero","patterns","filter","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAC5BC,aAAa,EAEbC,iBAAiB,EACjBC,UAAU,EACVC,wBAAwB,EAExBC,YAAY,EACZC,0BAA0B,QACrB,aAAa;AACpB,SACEC,2BAA2B,EAC3BC,4BAA4B,QACvB,0BAAuB;AAC9B,SAASC,eAAe,QAAQ,qBAAkB;AAClD,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,yBAAyB,EAAEC,WAAW,QAAQ,uBAAoB;AAC3E,SAASC,WAAW,QAAQ,2BAAwB;AACpD,SACEC,iCAAiC,EACjCC,oBAAoB,EACpBC,gBAAgB,EAEhBC,aAAa,QACR,oBAAiB;AAExB,SACEC,4BAA4B,EAC5BC,kBAAkB,QACb,6BAA0B;AACjC,SAASC,cAAc,QAAQ,wBAAqB;AACpD,SAASC,+CAA+C,QAAQ,oBAAiB;AACjF,SAASC,UAAU,QAAQ,sBAAmB;AAC9C,SAASC,YAA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BC,OAAO,CAACgB,IAAI,EAAEC,cAAc;YACpDC,KAAK;gBACHA,KAAK;YACP;YACA,aAAa;gBACXC,UAAU;YACZ;QACF;IACF;IACA,2EAA2E;IAC3E,4EAA4E;IAC5EtF,kCAAkCkE,sBAAsB,QAAQ;IAEhEA,qBAAqBC,OAAO,GAAG7D,eAAe4D,qBAAqBC,OAAO;IAC1E5E,2BAA2BuB,MAAMO,oBAAoB6C;IAErDjE,qBAAqBa,MAAMO,oBAAoBX;IAE/C,yBAAyB;IACzBhB,gBAAgBoB,MAAM,KAAK,CAACyE,WAAa;eAAIA;YAAU;SAAW;IAElE,2EAA2E;IAC3E,6EAA6E;IAC7E,4EAA4E;IAC5E,6EAA6E;IAC7E,wCAAwC;IACxC7F,gBAAgBoB,MAAMS,KAAK,CAACgE,WAAa;eACpCA;YACH;eACG3E,2BAA2B4E,MAAM,CAAC,CAACrD,IAAMA,MAAM;SACnD;IAED,MAAMvC,gCAAgCkB,MAAM;QAACJ;KAA0B;IAEvE,MAAMjB,6BAA6BqB;IAEnC,4EAA4E;IAC5E,4EAA4E;IAC5E,6EAA6E;IAC7E,qDAAqD;IACrDtB,4BAA4BsB,MAAMO;IAElC,OAAO,IACL1B,oBAAoBmB,MAAMC,OAAO0E,yBAAyB,EAAE;YAC1DC,WAAW;gBAAC;gBAAc;aAAS;QACrC;AACJ,EAAE;AACF,eAAehE,mBAAmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/project/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport interface PyProjectGeneratorSchema {\n readonly name: string;\n readonly type: 'application' | 'library';\n readonly directory?: string;\n readonly subDirectory?: string;\n readonly moduleName?: string;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAED,
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/py/project/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport interface PyProjectGeneratorSchema {\n readonly name: string;\n readonly type: 'application' | 'library';\n readonly directory?: string;\n readonly subDirectory?: string;\n readonly moduleName?: string;\n readonly preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAED,WAOC"}
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
"moduleName": {
|
|
37
37
|
"type": "string",
|
|
38
38
|
"description": "Python module name"
|
|
39
|
+
},
|
|
40
|
+
"preferInstallDependencies": {
|
|
41
|
+
"type": "boolean",
|
|
42
|
+
"description": "Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.",
|
|
43
|
+
"default": true
|
|
39
44
|
}
|
|
40
45
|
},
|
|
41
46
|
"required": ["name", "type"]
|
package/src/sdk/open-api.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
export {
|
|
5
|
+
export { buildOpenApiCodeGenerationData, openApiTsClientGenerator, } from '../open-api/ts-client/generator';
|
|
6
6
|
export type { OpenApiTsClientGeneratorSchema } from '../open-api/ts-client/schema';
|
|
7
7
|
export { openApiTsHooksGenerator } from '../open-api/ts-hooks/generator';
|
|
8
8
|
export type { OpenApiTsHooksGeneratorSchema } from '../open-api/ts-hooks/schema';
|
package/src/sdk/open-api.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/ export {
|
|
4
|
+
*/ export { buildOpenApiCodeGenerationData, openApiTsClientGenerator } from "../open-api/ts-client/generator.js";
|
|
5
5
|
export { openApiTsHooksGenerator } from "../open-api/ts-hooks/generator.js";
|
|
6
6
|
export { openApiTsMetadataGenerator } from "../open-api/ts-metadata/generator.js";
|
|
7
7
|
|
package/src/sdk/open-api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/sdk/open-api.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport {\n
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/sdk/open-api.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport {\n buildOpenApiCodeGenerationData,\n openApiTsClientGenerator,\n} from '../open-api/ts-client/generator';\nexport type { OpenApiTsClientGeneratorSchema } from '../open-api/ts-client/schema';\n\nexport { openApiTsHooksGenerator } from '../open-api/ts-hooks/generator';\nexport type { OpenApiTsHooksGeneratorSchema } from '../open-api/ts-hooks/schema';\n\nexport { openApiTsMetadataGenerator } from '../open-api/ts-metadata/generator';\nexport type { OpenApiTsMetadataGeneratorSchema } from '../open-api/ts-metadata/schema';\n"],"names":["buildOpenApiCodeGenerationData","openApiTsClientGenerator","openApiTsHooksGenerator","openApiTsMetadataGenerator"],"mappings":"AAAA;;;CAGC,GAED,SACEA,8BAA8B,EAC9BC,wBAAwB,QACnB,qCAAkC;AAGzC,SAASC,uBAAuB,QAAQ,oCAAiC;AAGzE,SAASC,0BAA0B,QAAQ,uCAAoC"}
|
package/src/sdk/utils/ast.d.ts
CHANGED
|
@@ -2,5 +2,4 @@
|
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
*/
|
|
5
|
-
export { applyGritQL } from '../../utils/ast';
|
|
6
|
-
export { matchGritQL } from '../../utils/ast';
|
|
5
|
+
export { applyGritQL, matchGritQL } from '../../utils/ast';
|
package/src/sdk/utils/ast.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/ export { applyGritQL } from "../../utils/ast.js";
|
|
5
|
-
export { matchGritQL } from "../../utils/ast.js";
|
|
4
|
+
*/ export { applyGritQL, matchGritQL } from "../../utils/ast.js";
|
|
6
5
|
|
|
7
6
|
//# sourceMappingURL=ast.js.map
|
package/src/sdk/utils/ast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/sdk/utils/ast.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nexport { applyGritQL
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/sdk/utils/ast.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nexport { applyGritQL, matchGritQL } from '../../utils/ast';\n"],"names":["applyGritQL","matchGritQL"],"mappings":"AAAA;;;CAGC,GACD,SAASA,WAAW,EAAEC,WAAW,QAAQ,qBAAkB"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/ import { addProjectConfiguration, generateFiles,
|
|
4
|
+
*/ import { addProjectConfiguration, generateFiles, joinPathFragments } from "@nx/devkit";
|
|
5
5
|
import { getTsLibDetails } from "../../ts/lib/generator.js";
|
|
6
6
|
import { resolveContainers } from "../../utils/containers.js";
|
|
7
7
|
import { formatFilesInSubtree } from "../../utils/format.js";
|
|
8
8
|
import { FsCommands } from "../../utils/fs.js";
|
|
9
|
+
import { installDependencies } from "../../utils/install.js";
|
|
9
10
|
import { addGeneratorMetricsIfApplicable } from "../../utils/metrics.js";
|
|
10
11
|
import { toClassName, toKebabCase } from "../../utils/names.js";
|
|
11
12
|
import { getNpmScope } from "../../utils/npm-scope.js";
|
|
@@ -65,9 +66,11 @@ export const smithyProjectGenerator = async (tree, options)=>{
|
|
|
65
66
|
SMITHY_PROJECT_GENERATOR_INFO
|
|
66
67
|
]);
|
|
67
68
|
await formatFilesInSubtree(tree);
|
|
68
|
-
return ()=>{
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
return ()=>installDependencies(tree, options.preferInstallDependencies, {
|
|
70
|
+
languages: [
|
|
71
|
+
'typescript'
|
|
72
|
+
]
|
|
73
|
+
});
|
|
71
74
|
};
|
|
72
75
|
export default smithyProjectGenerator;
|
|
73
76
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/smithy/project/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addProjectConfiguration,\n type GeneratorCallback,\n generateFiles,\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/smithy/project/generator.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport {\n addProjectConfiguration,\n type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n type Tree,\n} from '@nx/devkit';\nimport { getTsLibDetails } from '../../ts/lib/generator';\nimport { resolveContainers } from '../../utils/containers';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { FsCommands } from '../../utils/fs';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport { toClassName, toKebabCase } from '../../utils/names';\nimport { getNpmScope } from '../../utils/npm-scope';\nimport {\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n projectExists,\n} from '../../utils/nx';\nimport type { SmithyProjectGeneratorSchema } from './schema';\n\nexport const SMITHY_PROJECT_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const smithyProjectGenerator = async (\n tree: Tree,\n options: SmithyProjectGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const cmd = new FsCommands(tree);\n const containers = await resolveContainers(tree, 'inherit');\n\n // Create project.json\n const { fullyQualifiedName, dir } = getTsLibDetails(tree, options);\n\n if (!projectExists(tree, fullyQualifiedName)) {\n addProjectConfiguration(tree, fullyQualifiedName, {\n name: fullyQualifiedName,\n root: dir,\n sourceRoot: joinPathFragments(dir, 'src'),\n projectType: 'library',\n targets: {\n build: {\n dependsOn: ['compile'],\n },\n compile: {\n cache: true,\n outputs: ['{workspaceRoot}/dist/{projectRoot}/build'],\n executor: 'nx:run-commands',\n options: {\n commands: [\n cmd.rm('dist/{projectRoot}/build'),\n cmd.mkdir('dist/{projectRoot}/build'),\n `${containers} build -f {projectRoot}/build.Dockerfile --target export --output type=local,dest=dist/{projectRoot}/build {projectRoot}`,\n ],\n parallel: false,\n cwd: '{workspaceRoot}',\n },\n },\n },\n });\n }\n\n const serviceName = options.serviceName ?? options.name;\n const serviceNameClassName = toClassName(serviceName);\n const serviceNameKebabCase = toKebabCase(serviceName);\n const scope = getNpmScope(tree);\n const namespace = options.namespace ?? toKebabCase(scope).replace(/-/g, '.');\n\n generateFiles(tree, joinPathFragments(import.meta.dirname, 'files'), dir, {\n namespace,\n serviceNameClassName,\n serviceNameKebabCase,\n scope,\n });\n\n addGeneratorMetadata(\n tree,\n fullyQualifiedName,\n SMITHY_PROJECT_GENERATOR_INFO,\n {\n apiName: options.name,\n },\n );\n\n await addGeneratorMetricsIfApplicable(tree, [SMITHY_PROJECT_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nexport default smithyProjectGenerator;\n"],"names":["addProjectConfiguration","generateFiles","joinPathFragments","getTsLibDetails","resolveContainers","formatFilesInSubtree","FsCommands","installDependencies","addGeneratorMetricsIfApplicable","toClassName","toKebabCase","getNpmScope","addGeneratorMetadata","getGeneratorInfo","projectExists","SMITHY_PROJECT_GENERATOR_INFO","filename","smithyProjectGenerator","tree","options","cmd","containers","fullyQualifiedName","dir","name","root","sourceRoot","projectType","targets","build","dependsOn","compile","cache","outputs","executor","commands","rm","mkdir","parallel","cwd","serviceName","serviceNameClassName","serviceNameKebabCase","scope","namespace","replace","dirname","apiName","preferInstallDependencies","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,uBAAuB,EAEvBC,aAAa,EACbC,iBAAiB,QAEZ,aAAa;AACpB,SAASC,eAAe,QAAQ,4BAAyB;AACzD,SAASC,iBAAiB,QAAQ,4BAAyB;AAC3D,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,UAAU,QAAQ,oBAAiB;AAC5C,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SAASC,WAAW,EAAEC,WAAW,QAAQ,uBAAoB;AAC7D,SAASC,WAAW,QAAQ,2BAAwB;AACpD,SACEC,oBAAoB,EACpBC,gBAAgB,EAEhBC,aAAa,QACR,oBAAiB;AAGxB,OAAO,MAAMC,gCAAiDF,iBAC5D,YAAYG,QAAQ,EACpB;AAEF,OAAO,MAAMC,yBAAyB,OACpCC,MACAC;IAEA,MAAMC,MAAM,IAAId,WAAWY;IAC3B,MAAMG,aAAa,MAAMjB,kBAAkBc,MAAM;IAEjD,sBAAsB;IACtB,MAAM,EAAEI,kBAAkB,EAAEC,GAAG,EAAE,GAAGpB,gBAAgBe,MAAMC;IAE1D,IAAI,CAACL,cAAcI,MAAMI,qBAAqB;QAC5CtB,wBAAwBkB,MAAMI,oBAAoB;YAChDE,MAAMF;YACNG,MAAMF;YACNG,YAAYxB,kBAAkBqB,KAAK;YACnCI,aAAa;YACbC,SAAS;gBACPC,OAAO;oBACLC,WAAW;wBAAC;qBAAU;gBACxB;gBACAC,SAAS;oBACPC,OAAO;oBACPC,SAAS;wBAAC;qBAA2C;oBACrDC,UAAU;oBACVf,SAAS;wBACPgB,UAAU;4BACRf,IAAIgB,EAAE,CAAC;4BACPhB,IAAIiB,KAAK,CAAC;4BACV,GAAGhB,WAAW,wHAAwH,CAAC;yBACxI;wBACDiB,UAAU;wBACVC,KAAK;oBACP;gBACF;YACF;QACF;IACF;IAEA,MAAMC,cAAcrB,QAAQqB,WAAW,IAAIrB,QAAQK,IAAI;IACvD,MAAMiB,uBAAuBhC,YAAY+B;IACzC,MAAME,uBAAuBhC,YAAY8B;IACzC,MAAMG,QAAQhC,YAAYO;IAC1B,MAAM0B,YAAYzB,QAAQyB,SAAS,IAAIlC,YAAYiC,OAAOE,OAAO,CAAC,MAAM;IAExE5C,cAAciB,MAAMhB,kBAAkB,YAAY4C,OAAO,EAAE,UAAUvB,KAAK;QACxEqB;QACAH;QACAC;QACAC;IACF;IAEA/B,qBACEM,MACAI,oBACAP,+BACA;QACEgC,SAAS5B,QAAQK,IAAI;IACvB;IAGF,MAAMhB,gCAAgCU,MAAM;QAACH;KAA8B;IAE3E,MAAMV,qBAAqBa;IAC3B,OAAO,IACLX,oBAAoBW,MAAMC,QAAQ6B,yBAAyB,EAAE;YAC3DC,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,eAAehC,uBAAuB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/smithy/project/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nexport interface SmithyProjectGeneratorSchema {\n name: string;\n serviceName?: string;\n namespace?: string;\n directory?: string;\n subDirectory?: string;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GACD,
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/smithy/project/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nexport interface SmithyProjectGeneratorSchema {\n name: string;\n serviceName?: string;\n namespace?: string;\n directory?: string;\n subDirectory?: string;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GACD,WAOC"}
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
"type": "string",
|
|
37
37
|
"description": "The sub directory the Smithy project is placed in. By default this is the project name.",
|
|
38
38
|
"x-prompt": "Which sub directory do you want to create the Smithy project in? (By default this is the project name)"
|
|
39
|
+
},
|
|
40
|
+
"preferInstallDependencies": {
|
|
41
|
+
"type": "boolean",
|
|
42
|
+
"description": "Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.",
|
|
43
|
+
"default": true
|
|
39
44
|
}
|
|
40
45
|
},
|
|
41
46
|
"required": ["name"]
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/ import { generateFiles,
|
|
4
|
+
*/ import { generateFiles, joinPathFragments, OverwriteStrategy } from "@nx/devkit";
|
|
5
5
|
import { addOpenApiReactClient } from "../../utils/connection/open-api/react.js";
|
|
6
6
|
import { formatFilesInSubtree } from "../../utils/format.js";
|
|
7
|
+
import { installDependencies } from "../../utils/install.js";
|
|
7
8
|
import { addGeneratorMetricsIfApplicable } from "../../utils/metrics.js";
|
|
8
9
|
import { getGeneratorInfo, readProjectConfigurationUnqualified } from "../../utils/nx.js";
|
|
9
10
|
import { SMITHY_PROJECT_GENERATOR_INFO } from "../project/generator.js";
|
|
@@ -39,9 +40,11 @@ export const smithyReactConnectionGenerator = async (tree, options)=>{
|
|
|
39
40
|
SMITHY_REACT_CONNECTION_GENERATOR_INFO
|
|
40
41
|
]);
|
|
41
42
|
await formatFilesInSubtree(tree);
|
|
42
|
-
return ()=>{
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
return ()=>installDependencies(tree, options.preferInstallDependencies, {
|
|
44
|
+
languages: [
|
|
45
|
+
'typescript'
|
|
46
|
+
]
|
|
47
|
+
});
|
|
45
48
|
};
|
|
46
49
|
const resolveProjectConfig = (tree, modelOrBackendConfig)=>{
|
|
47
50
|
if ((modelOrBackendConfig.metadata ?? {}).generator === SMITHY_PROJECT_GENERATOR_INFO.id) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/smithy/react-connection/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
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/smithy/react-connection/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 OverwriteStrategy,\n type ProjectConfiguration,\n type Tree,\n} from '@nx/devkit';\nimport { addOpenApiReactClient } from '../../utils/connection/open-api/react';\nimport { formatFilesInSubtree } from '../../utils/format';\nimport { installDependencies } from '../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../utils/metrics';\nimport {\n getGeneratorInfo,\n type NxGeneratorInfo,\n readProjectConfigurationUnqualified,\n} from '../../utils/nx';\nimport { SMITHY_PROJECT_GENERATOR_INFO } from '../project/generator';\nimport { TS_SMITHY_API_GENERATOR_INFO } from '../ts/api/generator';\nimport type { SmithyReactConnectionGeneratorSchema } from './schema';\n\nexport const SMITHY_REACT_CONNECTION_GENERATOR_INFO: NxGeneratorInfo =\n getGeneratorInfo(import.meta.filename);\n\nexport const smithyReactConnectionGenerator = async (\n tree: Tree,\n options: SmithyReactConnectionGeneratorSchema,\n): Promise<GeneratorCallback> => {\n const frontendProjectConfig = readProjectConfigurationUnqualified(\n tree,\n options.frontendProjectName,\n );\n const targetConfig = readProjectConfigurationUnqualified(\n tree,\n options.smithyModelOrBackendProjectName,\n );\n\n // Target could either be the model or backend project\n const { modelProjectConfig, backendProjectConfig } = resolveProjectConfig(\n tree,\n targetConfig,\n );\n\n const backendMetadata = backendProjectConfig.metadata as any;\n const apiName = backendMetadata?.apiName;\n const auth = (backendMetadata?.auth ?? 'iam').toLowerCase();\n const port = backendMetadata?.port ?? backendMetadata?.ports?.[0] ?? 3001;\n\n const namespace = inferNamespace(tree, modelProjectConfig);\n\n // Add extensions.smithy for customising the client\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files', 'model'),\n modelProjectConfig.sourceRoot,\n {\n namespace,\n },\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n\n await addOpenApiReactClient(tree, {\n apiName,\n frontendProjectConfig,\n backendProjectConfig,\n specBuildProject: modelProjectConfig,\n specPath: joinPathFragments(\n 'dist',\n modelProjectConfig.root,\n 'build',\n 'openapi',\n 'openapi.json',\n ),\n specBuildTargetName: `${modelProjectConfig.name}:build`,\n auth,\n port,\n });\n\n await addGeneratorMetricsIfApplicable(tree, [\n SMITHY_REACT_CONNECTION_GENERATOR_INFO,\n ]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nconst resolveProjectConfig = (\n tree: Tree,\n modelOrBackendConfig: ProjectConfiguration,\n) => {\n if (\n ((modelOrBackendConfig.metadata as any) ?? {}).generator ===\n SMITHY_PROJECT_GENERATOR_INFO.id\n ) {\n // It's the model project\n const backendProjectName = ((modelOrBackendConfig.metadata as any) ?? {})\n .backendProject;\n if (!backendProjectName) {\n throw new Error(\n `Could not find associated backend for Smithy model project ${modelOrBackendConfig.name}`,\n );\n }\n\n return {\n modelProjectConfig: modelOrBackendConfig,\n backendProjectConfig: readProjectConfigurationUnqualified(\n tree,\n backendProjectName,\n ),\n };\n } else if (\n ((modelOrBackendConfig.metadata as any) ?? {}).generator ===\n TS_SMITHY_API_GENERATOR_INFO.id\n ) {\n // It's the backend project\n const modelProjectName = ((modelOrBackendConfig.metadata as any) ?? {})\n .modelProject;\n if (!modelProjectName) {\n throw new Error(\n `Could not find associated model for Smithy backend project ${modelOrBackendConfig.name}`,\n );\n }\n\n return {\n modelProjectConfig: readProjectConfigurationUnqualified(\n tree,\n ((modelOrBackendConfig.metadata as any) ?? {}).modelProject,\n ),\n backendProjectConfig: modelOrBackendConfig,\n };\n }\n throw new Error(\n `Unsupported connection target ${modelOrBackendConfig.name}. Expected a Smithy model or backend project.`,\n );\n};\n\n/**\n * Get the namespace from a model project\n */\nconst inferNamespace = (\n tree: Tree,\n modelProject: ProjectConfiguration,\n): string => {\n const smithyBuildJsonPath = joinPathFragments(\n modelProject.root,\n 'smithy-build.json',\n );\n if (!tree.exists(smithyBuildJsonPath)) {\n throw new Error(\n `No smithy-build.json file found for model project ${modelProject.name}`,\n );\n }\n\n try {\n const smithyBuild = JSON.parse(tree.read(smithyBuildJsonPath, 'utf-8'));\n return smithyBuild.plugins.openapi.service.split('#')[0];\n } catch {\n throw new Error(\n `Unable to determine namespace from ${smithyBuildJsonPath}. Expected plugins.openapi.service to be defined.`,\n );\n }\n};\n\nexport default smithyReactConnectionGenerator;\n"],"names":["generateFiles","joinPathFragments","OverwriteStrategy","addOpenApiReactClient","formatFilesInSubtree","installDependencies","addGeneratorMetricsIfApplicable","getGeneratorInfo","readProjectConfigurationUnqualified","SMITHY_PROJECT_GENERATOR_INFO","TS_SMITHY_API_GENERATOR_INFO","SMITHY_REACT_CONNECTION_GENERATOR_INFO","filename","smithyReactConnectionGenerator","tree","options","frontendProjectConfig","frontendProjectName","targetConfig","smithyModelOrBackendProjectName","modelProjectConfig","backendProjectConfig","resolveProjectConfig","backendMetadata","metadata","apiName","auth","toLowerCase","port","ports","namespace","inferNamespace","dirname","sourceRoot","overwriteStrategy","KeepExisting","specBuildProject","specPath","root","specBuildTargetName","name","preferInstallDependencies","languages","modelOrBackendConfig","generator","id","backendProjectName","backendProject","Error","modelProjectName","modelProject","smithyBuildJsonPath","exists","smithyBuild","JSON","parse","read","plugins","openapi","service","split"],"mappings":"AAAA;;;CAGC,GACD,SAEEA,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,QAGZ,aAAa;AACpB,SAASC,qBAAqB,QAAQ,2CAAwC;AAC9E,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,SAASC,mBAAmB,QAAQ,yBAAsB;AAC1D,SAASC,+BAA+B,QAAQ,yBAAsB;AACtE,SACEC,gBAAgB,EAEhBC,mCAAmC,QAC9B,oBAAiB;AACxB,SAASC,6BAA6B,QAAQ,0BAAuB;AACrE,SAASC,4BAA4B,QAAQ,yBAAsB;AAGnE,OAAO,MAAMC,yCACXJ,iBAAiB,YAAYK,QAAQ,EAAE;AAEzC,OAAO,MAAMC,iCAAiC,OAC5CC,MACAC;IAEA,MAAMC,wBAAwBR,oCAC5BM,MACAC,QAAQE,mBAAmB;IAE7B,MAAMC,eAAeV,oCACnBM,MACAC,QAAQI,+BAA+B;IAGzC,sDAAsD;IACtD,MAAM,EAAEC,kBAAkB,EAAEC,oBAAoB,EAAE,GAAGC,qBACnDR,MACAI;IAGF,MAAMK,kBAAkBF,qBAAqBG,QAAQ;IACrD,MAAMC,UAAUF,iBAAiBE;IACjC,MAAMC,OAAO,AAACH,CAAAA,iBAAiBG,QAAQ,KAAI,EAAGC,WAAW;IACzD,MAAMC,OAAOL,iBAAiBK,QAAQL,iBAAiBM,OAAO,CAAC,EAAE,IAA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AACD,kBAAkB;YACrB,MAAM,IAAID,MACR,CAAC,2DAA2D,EAAEL,qBAAqBH,IAAI,EAAE;QAE7F;QAEA,OAAO;YACLpB,oBAAoBZ,oCAClBM,MACA,AAAC,CAAA,AAAC6B,qBAAqBnB,QAAQ,IAAY,CAAC,CAAA,EAAG0B,YAAY;YAE7D7B,sBAAsBsB;QACxB;IACF;IACA,MAAM,IAAIK,MACR,CAAC,8BAA8B,EAAEL,qBAAqBH,IAAI,CAAC,6CAA6C,CAAC;AAE7G;AAEA;;CAEC,GACD,MAAMT,iBAAiB,CACrBjB,MACAoC;IAEA,MAAMC,sBAAsBlD,kBAC1BiD,aAAaZ,IAAI,EACjB;IAEF,IAAI,CAACxB,KAAKsC,MAAM,CAACD,sBAAsB;QACrC,MAAM,IAAIH,MACR,CAAC,kDAAkD,EAAEE,aAAaV,IAAI,EAAE;IAE5E;IAEA,IAAI;QACF,MAAMa,cAAcC,KAAKC,KAAK,CAACzC,KAAK0C,IAAI,CAACL,qBAAqB;QAC9D,OAAOE,YAAYI,OAAO,CAACC,OAAO,CAACC,OAAO,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;IAC1D,EAAE,OAAM;QACN,MAAM,IAAIZ,MACR,CAAC,mCAAmC,EAAEG,oBAAoB,iDAAiD,CAAC;IAEhH;AACF;AAEA,eAAetC,+BAA+B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/smithy/react-connection/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nexport interface SmithyReactConnectionGeneratorSchema {\n frontendProjectName: string;\n smithyModelOrBackendProjectName: string;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GACD,
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/smithy/react-connection/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nexport interface SmithyReactConnectionGeneratorSchema {\n frontendProjectName: string;\n smithyModelOrBackendProjectName: string;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GACD,WAIC"}
|
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
"description": "",
|
|
21
21
|
"x-prompt": "Project containing your Smithy API (either model or backend)",
|
|
22
22
|
"x-dropdown": "projects"
|
|
23
|
+
},
|
|
24
|
+
"preferInstallDependencies": {
|
|
25
|
+
"type": "boolean",
|
|
26
|
+
"description": "Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.",
|
|
27
|
+
"default": true
|
|
23
28
|
}
|
|
24
29
|
},
|
|
25
30
|
"required": ["frontendProjectName", "smithyModelOrBackendProjectName"]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/ import { addDependenciesToPackageJson, generateFiles,
|
|
4
|
+
*/ import { addDependenciesToPackageJson, generateFiles, joinPathFragments, OverwriteStrategy, updateProjectConfiguration } from "@nx/devkit";
|
|
5
5
|
import tsProjectGenerator, { getTsLibDetails } from "../../../ts/lib/generator.js";
|
|
6
6
|
import { addApiGatewayInfra } from "../../../utils/api-constructs/api-constructs.js";
|
|
7
7
|
import { addSharedConstructsOpenApiMetadataGenerateTarget } from "../../../utils/api-constructs/open-api-metadata.js";
|
|
@@ -10,6 +10,7 @@ import { formatFilesInSubtree } from "../../../utils/format.js";
|
|
|
10
10
|
import { FsCommands } from "../../../utils/fs.js";
|
|
11
11
|
import { updateGitIgnore } from "../../../utils/git.js";
|
|
12
12
|
import { resolveIac } from "../../../utils/iac.js";
|
|
13
|
+
import { installDependencies } from "../../../utils/install.js";
|
|
13
14
|
import { addGeneratorMetricsIfApplicable } from "../../../utils/metrics.js";
|
|
14
15
|
import { toClassName, toKebabCase } from "../../../utils/names.js";
|
|
15
16
|
import { addDependencyToTargetIfNotPresent, addGeneratorMetadata, getGeneratorInfo, normalizeTargetKeyOrder, readProjectConfigurationUnqualified } from "../../../utils/nx.js";
|
|
@@ -41,13 +42,15 @@ export const tsSmithyApiGenerator = async (tree, options)=>{
|
|
|
41
42
|
serviceName: apiNameClassName,
|
|
42
43
|
namespace: options.namespace,
|
|
43
44
|
directory: dir,
|
|
44
|
-
subDirectory: 'model'
|
|
45
|
+
subDirectory: 'model',
|
|
46
|
+
preferInstallDependencies: false
|
|
45
47
|
});
|
|
46
48
|
// Generate the backend project
|
|
47
49
|
await tsProjectGenerator(tree, {
|
|
48
50
|
name: options.name,
|
|
49
51
|
directory: dir,
|
|
50
|
-
subDirectory: 'backend'
|
|
52
|
+
subDirectory: 'backend',
|
|
53
|
+
preferInstallDependencies: false
|
|
51
54
|
});
|
|
52
55
|
}
|
|
53
56
|
// Add metadata to associate backend project with model project
|
|
@@ -216,9 +219,11 @@ export const tsSmithyApiGenerator = async (tree, options)=>{
|
|
|
216
219
|
TS_SMITHY_API_GENERATOR_INFO
|
|
217
220
|
]);
|
|
218
221
|
await formatFilesInSubtree(tree);
|
|
219
|
-
return ()=>{
|
|
220
|
-
|
|
221
|
-
|
|
222
|
+
return ()=>installDependencies(tree, options.preferInstallDependencies, {
|
|
223
|
+
languages: [
|
|
224
|
+
'typescript'
|
|
225
|
+
]
|
|
226
|
+
});
|
|
222
227
|
};
|
|
223
228
|
const getIntegrationPattern = (options)=>options.integrationPattern ?? 'isolated';
|
|
224
229
|
export default tsSmithyApiGenerator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/smithy/ts/api/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 type GeneratorCallback,\n generateFiles,\n installPackagesTask,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport tsProjectGenerator, { getTsLibDetails } from '../../../ts/lib/generator';\nimport { addApiGatewayInfra } from '../../../utils/api-constructs/api-constructs';\nimport { addSharedConstructsOpenApiMetadataGenerateTarget } from '../../../utils/api-constructs/open-api-metadata';\nimport { addTypeScriptBundleTarget } from '../../../utils/bundle/bundle';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport { FsCommands } from '../../../utils/fs';\nimport { updateGitIgnore } from '../../../utils/git';\nimport { resolveIac } from '../../../utils/iac';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics';\nimport { toClassName, toKebabCase } from '../../../utils/names';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n normalizeTargetKeyOrder,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx';\nimport { assignPort } from '../../../utils/port';\nimport { sharedConstructsGenerator } from '../../../utils/shared-constructs';\nimport { withVersions } from '../../../utils/versions';\nimport smithyProjectGenerator from '../../project/generator';\nimport type { TsSmithyApiGeneratorSchema } from './schema';\n\nexport const TS_SMITHY_API_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsSmithyApiGenerator = async (\n tree: Tree,\n options: TsSmithyApiGeneratorSchema,\n): Promise<GeneratorCallback> => {\n if (\n (options.infra as string) !== 'rest-lambda' &&\n (options.infra as string) !== 'none'\n ) {\n throw new Error(\n `Unsupported infra '${options.infra}' for Smithy TypeScript API. ` +\n `Only 'rest-lambda' (API Gateway REST API) is supported.`,\n );\n }\n\n const integrationPattern = getIntegrationPattern(options);\n const apiNameClassName = toClassName(options.name);\n const apiNameKebabCase = toKebabCase(options.name);\n const { fullyQualifiedName: backendFullyQualifiedName, dir } =\n getTsLibDetails(tree, options);\n const modelProjectName = `${apiNameKebabCase}-model`;\n\n let projectExists: boolean;\n try {\n readProjectConfigurationUnqualified(tree, backendFullyQualifiedName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n // Generate the model project\n await smithyProjectGenerator(tree, {\n name: modelProjectName,\n serviceName: apiNameClassName,\n namespace: options.namespace,\n directory: dir,\n subDirectory: 'model',\n });\n\n // Generate the backend project\n await tsProjectGenerator(tree, {\n name: options.name,\n directory: dir,\n subDirectory: 'backend',\n });\n }\n\n // Add metadata to associate backend project with model project\n const modelProjectConfig = readProjectConfigurationUnqualified(\n tree,\n modelProjectName,\n );\n updateProjectConfiguration(tree, modelProjectConfig.name, {\n ...modelProjectConfig,\n metadata: {\n ...modelProjectConfig.metadata,\n backendProject: backendFullyQualifiedName,\n } as any,\n });\n\n addGeneratorMetadata(\n tree,\n backendFullyQualifiedName,\n TS_SMITHY_API_GENERATOR_INFO,\n {\n apiName: options.name,\n auth: options.auth,\n modelProject: modelProjectConfig.name,\n },\n );\n\n const backendProjectConfig = readProjectConfigurationUnqualified(\n tree,\n backendFullyQualifiedName,\n );\n const port = assignPort(tree, backendProjectConfig, 3001);\n\n // Delete default index.ts with \"hello\" function\n tree.delete(joinPathFragments(backendProjectConfig.sourceRoot, 'index.ts'));\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n backendProjectConfig.sourceRoot,\n {\n apiNameClassName,\n port,\n },\n );\n\n if (options.infra !== 'none') {\n if (options.auth === 'custom') {\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n '..',\n '..',\n '..',\n 'utils',\n 'api-constructs',\n 'files',\n 'cdk',\n 'authorizer',\n 'rest',\n ),\n backendProjectConfig.sourceRoot,\n {},\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n }\n\n // Add infrastructure\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, {\n iac,\n });\n await addApiGatewayInfra(tree, {\n iac,\n apiProjectName: backendFullyQualifiedName,\n apiNameClassName,\n apiNameKebabCase,\n auth: options.auth,\n constructType: 'rest',\n backend: {\n type: 'smithy',\n bundleOutputDir: joinPathFragments(\n 'dist',\n backendProjectConfig.root,\n 'bundle',\n ),\n integrationPattern,\n ...(options.auth === 'custom' && {\n authorizerBundleOutputDir: joinPathFragments(\n 'dist',\n backendProjectConfig.root,\n 'bundle',\n 'authorizer',\n ),\n }),\n },\n });\n addSharedConstructsOpenApiMetadataGenerateTarget(tree, {\n iac,\n apiNameKebabCase,\n specPath: joinPathFragments(\n 'dist',\n modelProjectConfig.root,\n 'build',\n 'openapi',\n 'openapi.json',\n ),\n specBuildTargetName: `${modelProjectConfig.name}:build`,\n });\n\n // Add bundle target using rolldown\n await addTypeScriptBundleTarget(tree, backendProjectConfig, {\n targetFilePath: 'src/handler.ts',\n external: [/@aws-sdk\\/.*/], // lambda runtime provides aws sdk\n });\n\n if (options.auth === 'custom') {\n await addTypeScriptBundleTarget(tree, backendProjectConfig, {\n targetFilePath: 'src/authorizer.ts',\n bundleOutputDir: 'authorizer',\n external: [/@aws-sdk\\/.*/],\n });\n }\n }\n\n const cmd = new FsCommands(tree);\n const generatedSrcDirFromRoot = '{projectRoot}/src/generated';\n\n // Target for copying the ssdk built by the model\n backendProjectConfig.targets['copy-ssdk'] = {\n cache: true,\n inputs: [\n {\n dependentTasksOutputFiles: '**/*',\n },\n ],\n executor: 'nx:run-commands',\n options: {\n commands: [\n cmd.rm(generatedSrcDirFromRoot),\n cmd.mkdir(generatedSrcDirFromRoot),\n cmd.cp(\n joinPathFragments('dist', modelProjectConfig.root, 'build', 'ssdk'),\n joinPathFragments(generatedSrcDirFromRoot, 'ssdk'),\n ),\n ],\n parallel: false,\n },\n outputs: ['{projectRoot}/src/generated'],\n dependsOn: [`${modelProjectConfig.name}:build`],\n };\n addDependencyToTargetIfNotPresent(\n backendProjectConfig,\n 'compile',\n 'copy-ssdk',\n );\n\n // Add a project which continuously copies based on changes to the model project\n // This allows the \"serve\" target to hot reload when the smithy model is changed\n backendProjectConfig.targets['watch-copy-ssdk'] = {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n command: `nx watch --projects=${modelProjectConfig.name} --includeDependencies -- nx run ${backendFullyQualifiedName}:copy-ssdk`,\n },\n };\n\n // Add serve target for running the server locally\n backendProjectConfig.targets.serve = normalizeTargetKeyOrder({\n executor: 'nx:run-commands',\n continuous: true,\n dependsOn: ['copy-ssdk', 'watch-copy-ssdk'],\n options: {\n command: 'tsx --watch src/local-server.ts',\n cwd: '{projectRoot}',\n },\n });\n\n const existingDevDependsOn =\n backendProjectConfig.targets['dev']?.dependsOn ?? [];\n\n backendProjectConfig.targets['dev'] = normalizeTargetKeyOrder({\n ...backendProjectConfig.targets.serve,\n // Own copy of dependsOn so adding dev dependencies below doesn't\n // mutate the shared array referenced by the serve target.\n dependsOn: [...(backendProjectConfig.targets.serve.dependsOn ?? [])],\n options: {\n ...backendProjectConfig.targets.serve.options,\n env: {\n LOCAL_DEV: 'true',\n },\n },\n });\n\n // Preserve any dependencies added to dev by connection generators\n for (const dependency of existingDevDependsOn) {\n addDependencyToTargetIfNotPresent(backendProjectConfig, 'dev', dependency);\n }\n\n // Ignore generated code\n updateGitIgnore(tree, backendProjectConfig.root, (patterns) => [\n ...patterns,\n 'src/generated',\n ]);\n\n updateProjectConfiguration(\n tree,\n backendFullyQualifiedName,\n backendProjectConfig,\n );\n\n addDependenciesToPackageJson(\n tree,\n withVersions([\n '@aws-smithy/server-apigateway',\n '@aws-smithy/server-node',\n '@middy/core',\n '@aws-lambda-powertools/logger',\n '@aws-lambda-powertools/parameters',\n '@aws-lambda-powertools/tracer',\n '@aws-lambda-powertools/metrics',\n '@aws-sdk/client-appconfigdata',\n ...(options.auth === 'custom'\n ? (['@aws-lambda-powertools/parser'] as const)\n : []),\n ]),\n withVersions(['@types/aws-lambda', 'tsx']),\n );\n\n await addGeneratorMetricsIfApplicable(tree, [TS_SMITHY_API_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () => {\n installPackagesTask(tree);\n };\n};\n\nconst getIntegrationPattern = (\n options: TsSmithyApiGeneratorSchema,\n): 'isolated' | 'shared' => options.integrationPattern ?? 'isolated';\n\nexport default tsSmithyApiGenerator;\n"],"names":["addDependenciesToPackageJson","generateFiles","installPackagesTask","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","tsProjectGenerator","getTsLibDetails","addApiGatewayInfra","addSharedConstructsOpenApiMetadataGenerateTarget","addTypeScriptBundleTarget","formatFilesInSubtree","FsCommands","updateGitIgnore","resolveIac","addGeneratorMetricsIfApplicable","toClassName","toKebabCase","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","normalizeTargetKeyOrder","readProjectConfigurationUnqualified","assignPort","sharedConstructsGenerator","withVersions","smithyProjectGenerator","TS_SMITHY_API_GENERATOR_INFO","filename","tsSmithyApiGenerator","tree","options","infra","Error","integrationPattern","getIntegrationPattern","apiNameClassName","name","apiNameKebabCase","fullyQualifiedName","backendFullyQualifiedName","dir","modelProjectName","projectExists","serviceName","namespace","directory","subDirectory","modelProjectConfig","metadata","backendProject","apiName","auth","modelProject","backendProjectConfig","port","delete","sourceRoot","dirname","overwriteStrategy","KeepExisting","iac","apiProjectName","constructType","backend","type","bundleOutputDir","root","authorizerBundleOutputDir","specPath","specBuildTargetName","targetFilePath","external","cmd","generatedSrcDirFromRoot","targets","cache","inputs","dependentTasksOutputFiles","executor","commands","rm","mkdir","cp","parallel","outputs","dependsOn","continuous","command","serve","cwd","existingDevDependsOn","env","LOCAL_DEV","dependency","patterns"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAE5BC,aAAa,EACbC,mBAAmB,EACnBC,iBAAiB,EACjBC,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,OAAOC,sBAAsBC,eAAe,QAAQ,+BAA4B;AAChF,SAASC,kBAAkB,QAAQ,kDAA+C;AAClF,SAASC,gDAAgD,QAAQ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qBmB;IAC3B,OAAO;QACL5B,oBAAoB4B;IACtB;AACF,EAAE;AAEF,MAAMK,wBAAwB,CAC5BJ,UAC0BA,QAAQG,kBAAkB,IAAI;AAE1D,eAAeL,qBAAqB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/smithy/ts/api/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 type GeneratorCallback,\n generateFiles,\n joinPathFragments,\n OverwriteStrategy,\n type Tree,\n updateProjectConfiguration,\n} from '@nx/devkit';\nimport tsProjectGenerator, { getTsLibDetails } from '../../../ts/lib/generator';\nimport { addApiGatewayInfra } from '../../../utils/api-constructs/api-constructs';\nimport { addSharedConstructsOpenApiMetadataGenerateTarget } from '../../../utils/api-constructs/open-api-metadata';\nimport { addTypeScriptBundleTarget } from '../../../utils/bundle/bundle';\nimport { formatFilesInSubtree } from '../../../utils/format';\nimport { FsCommands } from '../../../utils/fs';\nimport { updateGitIgnore } from '../../../utils/git';\nimport { resolveIac } from '../../../utils/iac';\nimport { installDependencies } from '../../../utils/install';\nimport { addGeneratorMetricsIfApplicable } from '../../../utils/metrics';\nimport { toClassName, toKebabCase } from '../../../utils/names';\nimport {\n addDependencyToTargetIfNotPresent,\n addGeneratorMetadata,\n getGeneratorInfo,\n type NxGeneratorInfo,\n normalizeTargetKeyOrder,\n readProjectConfigurationUnqualified,\n} from '../../../utils/nx';\nimport { assignPort } from '../../../utils/port';\nimport { sharedConstructsGenerator } from '../../../utils/shared-constructs';\nimport { withVersions } from '../../../utils/versions';\nimport smithyProjectGenerator from '../../project/generator';\nimport type { TsSmithyApiGeneratorSchema } from './schema';\n\nexport const TS_SMITHY_API_GENERATOR_INFO: NxGeneratorInfo = getGeneratorInfo(\n import.meta.filename,\n);\n\nexport const tsSmithyApiGenerator = async (\n tree: Tree,\n options: TsSmithyApiGeneratorSchema,\n): Promise<GeneratorCallback> => {\n if (\n (options.infra as string) !== 'rest-lambda' &&\n (options.infra as string) !== 'none'\n ) {\n throw new Error(\n `Unsupported infra '${options.infra}' for Smithy TypeScript API. ` +\n `Only 'rest-lambda' (API Gateway REST API) is supported.`,\n );\n }\n\n const integrationPattern = getIntegrationPattern(options);\n const apiNameClassName = toClassName(options.name);\n const apiNameKebabCase = toKebabCase(options.name);\n const { fullyQualifiedName: backendFullyQualifiedName, dir } =\n getTsLibDetails(tree, options);\n const modelProjectName = `${apiNameKebabCase}-model`;\n\n let projectExists: boolean;\n try {\n readProjectConfigurationUnqualified(tree, backendFullyQualifiedName);\n projectExists = true;\n } catch {\n projectExists = false;\n }\n\n if (!projectExists) {\n // Generate the model project\n await smithyProjectGenerator(tree, {\n name: modelProjectName,\n serviceName: apiNameClassName,\n namespace: options.namespace,\n directory: dir,\n subDirectory: 'model',\n preferInstallDependencies: false,\n });\n\n // Generate the backend project\n await tsProjectGenerator(tree, {\n name: options.name,\n directory: dir,\n subDirectory: 'backend',\n preferInstallDependencies: false,\n });\n }\n\n // Add metadata to associate backend project with model project\n const modelProjectConfig = readProjectConfigurationUnqualified(\n tree,\n modelProjectName,\n );\n updateProjectConfiguration(tree, modelProjectConfig.name, {\n ...modelProjectConfig,\n metadata: {\n ...modelProjectConfig.metadata,\n backendProject: backendFullyQualifiedName,\n } as any,\n });\n\n addGeneratorMetadata(\n tree,\n backendFullyQualifiedName,\n TS_SMITHY_API_GENERATOR_INFO,\n {\n apiName: options.name,\n auth: options.auth,\n modelProject: modelProjectConfig.name,\n },\n );\n\n const backendProjectConfig = readProjectConfigurationUnqualified(\n tree,\n backendFullyQualifiedName,\n );\n const port = assignPort(tree, backendProjectConfig, 3001);\n\n // Delete default index.ts with \"hello\" function\n tree.delete(joinPathFragments(backendProjectConfig.sourceRoot, 'index.ts'));\n\n generateFiles(\n tree,\n joinPathFragments(import.meta.dirname, 'files'),\n backendProjectConfig.sourceRoot,\n {\n apiNameClassName,\n port,\n },\n );\n\n if (options.infra !== 'none') {\n if (options.auth === 'custom') {\n generateFiles(\n tree,\n joinPathFragments(\n import.meta.dirname,\n '..',\n '..',\n '..',\n 'utils',\n 'api-constructs',\n 'files',\n 'cdk',\n 'authorizer',\n 'rest',\n ),\n backendProjectConfig.sourceRoot,\n {},\n {\n overwriteStrategy: OverwriteStrategy.KeepExisting,\n },\n );\n }\n\n // Add infrastructure\n const iac = await resolveIac(tree, options.iac);\n await sharedConstructsGenerator(tree, {\n iac,\n });\n await addApiGatewayInfra(tree, {\n iac,\n apiProjectName: backendFullyQualifiedName,\n apiNameClassName,\n apiNameKebabCase,\n auth: options.auth,\n constructType: 'rest',\n backend: {\n type: 'smithy',\n bundleOutputDir: joinPathFragments(\n 'dist',\n backendProjectConfig.root,\n 'bundle',\n ),\n integrationPattern,\n ...(options.auth === 'custom' && {\n authorizerBundleOutputDir: joinPathFragments(\n 'dist',\n backendProjectConfig.root,\n 'bundle',\n 'authorizer',\n ),\n }),\n },\n });\n addSharedConstructsOpenApiMetadataGenerateTarget(tree, {\n iac,\n apiNameKebabCase,\n specPath: joinPathFragments(\n 'dist',\n modelProjectConfig.root,\n 'build',\n 'openapi',\n 'openapi.json',\n ),\n specBuildTargetName: `${modelProjectConfig.name}:build`,\n });\n\n // Add bundle target using rolldown\n await addTypeScriptBundleTarget(tree, backendProjectConfig, {\n targetFilePath: 'src/handler.ts',\n external: [/@aws-sdk\\/.*/], // lambda runtime provides aws sdk\n });\n\n if (options.auth === 'custom') {\n await addTypeScriptBundleTarget(tree, backendProjectConfig, {\n targetFilePath: 'src/authorizer.ts',\n bundleOutputDir: 'authorizer',\n external: [/@aws-sdk\\/.*/],\n });\n }\n }\n\n const cmd = new FsCommands(tree);\n const generatedSrcDirFromRoot = '{projectRoot}/src/generated';\n\n // Target for copying the ssdk built by the model\n backendProjectConfig.targets['copy-ssdk'] = {\n cache: true,\n inputs: [\n {\n dependentTasksOutputFiles: '**/*',\n },\n ],\n executor: 'nx:run-commands',\n options: {\n commands: [\n cmd.rm(generatedSrcDirFromRoot),\n cmd.mkdir(generatedSrcDirFromRoot),\n cmd.cp(\n joinPathFragments('dist', modelProjectConfig.root, 'build', 'ssdk'),\n joinPathFragments(generatedSrcDirFromRoot, 'ssdk'),\n ),\n ],\n parallel: false,\n },\n outputs: ['{projectRoot}/src/generated'],\n dependsOn: [`${modelProjectConfig.name}:build`],\n };\n addDependencyToTargetIfNotPresent(\n backendProjectConfig,\n 'compile',\n 'copy-ssdk',\n );\n\n // Add a project which continuously copies based on changes to the model project\n // This allows the \"serve\" target to hot reload when the smithy model is changed\n backendProjectConfig.targets['watch-copy-ssdk'] = {\n executor: 'nx:run-commands',\n continuous: true,\n options: {\n command: `nx watch --projects=${modelProjectConfig.name} --includeDependencies -- nx run ${backendFullyQualifiedName}:copy-ssdk`,\n },\n };\n\n // Add serve target for running the server locally\n backendProjectConfig.targets.serve = normalizeTargetKeyOrder({\n executor: 'nx:run-commands',\n continuous: true,\n dependsOn: ['copy-ssdk', 'watch-copy-ssdk'],\n options: {\n command: 'tsx --watch src/local-server.ts',\n cwd: '{projectRoot}',\n },\n });\n\n const existingDevDependsOn =\n backendProjectConfig.targets['dev']?.dependsOn ?? [];\n\n backendProjectConfig.targets['dev'] = normalizeTargetKeyOrder({\n ...backendProjectConfig.targets.serve,\n // Own copy of dependsOn so adding dev dependencies below doesn't\n // mutate the shared array referenced by the serve target.\n dependsOn: [...(backendProjectConfig.targets.serve.dependsOn ?? [])],\n options: {\n ...backendProjectConfig.targets.serve.options,\n env: {\n LOCAL_DEV: 'true',\n },\n },\n });\n\n // Preserve any dependencies added to dev by connection generators\n for (const dependency of existingDevDependsOn) {\n addDependencyToTargetIfNotPresent(backendProjectConfig, 'dev', dependency);\n }\n\n // Ignore generated code\n updateGitIgnore(tree, backendProjectConfig.root, (patterns) => [\n ...patterns,\n 'src/generated',\n ]);\n\n updateProjectConfiguration(\n tree,\n backendFullyQualifiedName,\n backendProjectConfig,\n );\n\n addDependenciesToPackageJson(\n tree,\n withVersions([\n '@aws-smithy/server-apigateway',\n '@aws-smithy/server-node',\n '@middy/core',\n '@aws-lambda-powertools/logger',\n '@aws-lambda-powertools/parameters',\n '@aws-lambda-powertools/tracer',\n '@aws-lambda-powertools/metrics',\n '@aws-sdk/client-appconfigdata',\n ...(options.auth === 'custom'\n ? (['@aws-lambda-powertools/parser'] as const)\n : []),\n ]),\n withVersions(['@types/aws-lambda', 'tsx']),\n );\n\n await addGeneratorMetricsIfApplicable(tree, [TS_SMITHY_API_GENERATOR_INFO]);\n\n await formatFilesInSubtree(tree);\n return () =>\n installDependencies(tree, options.preferInstallDependencies, {\n languages: ['typescript'],\n });\n};\n\nconst getIntegrationPattern = (\n options: TsSmithyApiGeneratorSchema,\n): 'isolated' | 'shared' => options.integrationPattern ?? 'isolated';\n\nexport default tsSmithyApiGenerator;\n"],"names":["addDependenciesToPackageJson","generateFiles","joinPathFragments","OverwriteStrategy","updateProjectConfiguration","tsProjectGenerator","getTsLibDetails","addApiGatewayInfra","addSharedConstructsOpenApiMetadataGenerateTarget","addTypeScriptBundleTarget","formatFilesInSubtree","FsCommands","updateGitIgnore","resolveIac","installDependencies","addGeneratorMetricsIfApplicable","toClassName","toKebabCase","addDependencyToTargetIfNotPresent","addGeneratorMetadata","getGeneratorInfo","normalizeTargetKeyOrder","readProjectConfigurationUnqualified","assignPort","sharedConstructsGenerator","withVersions","smithyProjectGenerator","TS_SMITHY_API_GENERATOR_INFO","filename","tsSmithyApiGenerator","tree","options","infra","Error","integrationPattern","getIntegrationPattern","apiNameClassName","name","apiNameKebabCase","fullyQualifiedName","backendFullyQualifiedName","dir","modelProjectName","projectExists","serviceName","namespace","directory","subDirectory","preferInstallDependencies","modelProjectConfig","metadata","backendProject","apiName","auth","modelProject","backendProjectConfig","port","delete","sourceRoot","dirname","overwriteStrategy","KeepExisting","iac","apiProjectName","constructType","backend","type","bundleOutputDir","root","authorizerBundleOutputDir","specPath","specBuildTargetName","targetFilePath","external","cmd","generatedSrcDirFromRoot","targets","cache","inputs","dependentTasksOutputFiles","executor","commands","rm","mkdir","cp","parallel","outputs","dependsOn","continuous","command","serve","cwd","existingDevDependsOn","env","LOCAL_DEV","dependency","patterns","languages"],"mappings":"AAAA;;;CAGC,GACD,SACEA,4BAA4B,EAE5BC,aAAa,EACbC,iBAAiB,EACjBC,iBAAiB,EAEjBC,0BAA0B,QACrB,aAAa;AACpB,OAAOC,sBAAsBC,eAAe,QAAQ,+BAA4B;AAChF,SAASC,kBAAkB,QAAQ,kDAA+C;AAClF,SAASC,gDAAgD,QAAQ,qDAAkD;AACnH,SAASC,yBAAyB,QAAQ,kCAA+B;AACzE,SAASC,oBAAoB,QAAQ,2BAAwB;AAC7D,SAASC,UAAU,QAAQ,uBAAoB;AAC/C,SAASC,eAAe,QAAQ,wBAAqB;AACrD,SAASC,UAAU,QAAQ,wBAAqB;AAChD,SAASC,mBAAmB,QAAQ,4BAAyB;AAC7D,SAASC,+BAA+B,QAAQ,4BAAyB;AACzE,SAASC,WAAW,EAAEC,WAAW,QAAQ,0BAAuB;AAChE,SACEC,iCAAiC,EACjCC,oBAAoB,EACpBC,gBAAgB,EAEhBC,uBAAuB,EACvBC,mCAAmC,QAC9B,uBAAoB;AAC3B,SAASC,UAAU,QAAQ,yBAAsB;AACjD,SAASC,yBAAyB,QAAQ,sCAAmC;AAC7E,SAASC,YAAY,QAAQ,6BAA0B;AACvD,OAAOC,4BAA4B,6BAA0B;AAG7D,OAAO,MAAMC,+BAAgDP,iBAC3D,YAAYQ,QAAQ,EACpB;AAEF,OAAO,MAAMC,uBAAuB,OAClCC,MACAC;IAEA,IACE,AAACA,QAAQC,KAAK,KAAgB,iBAC9B,AAACD,QAAQC,KAAK,KAAgB,QAC9B;QACA,MAAM,IAAIC,MACR,CAAC,mBAAmB,EAAEF,QAAQC,KAAK,CAAC,6BAA6B,CAAC,GAChE,CAAC,uDAAuD,CAAC;IAE/D;IAEA,MAAME,qBAAqBC,sBAAsBJ;I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,kEAAkE;IAClE,KAAK,MAAMC,cAAcH,qBAAsB;QAC7C1E,kCAAkCqC,sBAAsB,OAAOwC;IACjE;IAEA,wBAAwB;IACxBnF,gBAAgBkB,MAAMyB,qBAAqBa,IAAI,EAAE,CAAC4B,WAAa;eAC1DA;YACH;SACD;IAED5F,2BACE0B,MACAU,2BACAe;IAGFvD,6BACE8B,MACAL,aAAa;QACX;QACA;QACA;QACA;QACA;QACA;QACA;QACA;WACIM,QAAQsB,IAAI,KAAK,WAChB;YAAC;SAAgC,GAClC,EAAE;KACP,GACD5B,aAAa;QAAC;QAAqB;KAAM;IAG3C,MAAMV,gCAAgCe,MAAM;QAACH;KAA6B;IAE1E,MAAMjB,qBAAqBoB;IAC3B,OAAO,IACLhB,oBAAoBgB,MAAMC,QAAQiB,yBAAyB,EAAE;YAC3DiD,WAAW;gBAAC;aAAa;QAC3B;AACJ,EAAE;AAEF,MAAM9D,wBAAwB,CAC5BJ,UAC0BA,QAAQG,kBAAkB,IAAI;AAE1D,eAAeL,qBAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/smithy/ts/api/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { TsProjectGeneratorSchema } from '../../../ts/lib/schema';\nimport { IacOption } from '../../../utils/iac';\n\nexport interface TsSmithyApiGeneratorSchema {\n name: string;\n namespace?: string;\n infra: 'rest-lambda' | 'none';\n integrationPattern?: 'isolated' | 'shared';\n auth: 'iam' | 'cognito' | 'custom';\n directory?: TsProjectGeneratorSchema['directory'];\n subDirectory?: TsProjectGeneratorSchema['subDirectory'];\n iac: IacOption;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAID,
|
|
1
|
+
{"version":3,"sources":["../../../../../../../packages/nx-plugin/src/smithy/ts/api/schema.d.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { TsProjectGeneratorSchema } from '../../../ts/lib/schema';\nimport { IacOption } from '../../../utils/iac';\n\nexport interface TsSmithyApiGeneratorSchema {\n name: string;\n namespace?: string;\n infra: 'rest-lambda' | 'none';\n integrationPattern?: 'isolated' | 'shared';\n auth: 'iam' | 'cognito' | 'custom';\n directory?: TsProjectGeneratorSchema['directory'];\n subDirectory?: TsProjectGeneratorSchema['subDirectory'];\n iac: IacOption;\n preferInstallDependencies?: boolean;\n}\n"],"names":[],"mappings":"AAAA;;;CAGC,GAID,WAUC"}
|
|
@@ -77,6 +77,11 @@
|
|
|
77
77
|
"enum": ["rest-lambda", "none"],
|
|
78
78
|
"x-prompt": "What infrastructure would you like to deploy your API with?",
|
|
79
79
|
"x-priority": "internal"
|
|
80
|
+
},
|
|
81
|
+
"preferInstallDependencies": {
|
|
82
|
+
"type": "boolean",
|
|
83
|
+
"description": "Whether to prefer installing dependencies after the generator runs. Set to false to defer installing when batching multiple generators (an install still runs if needed so subsequent generators can compute the Nx project graph); install once at the end.",
|
|
84
|
+
"default": true
|
|
80
85
|
}
|
|
81
86
|
},
|
|
82
87
|
"required": ["name"]
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/ import { addDependenciesToPackageJson, addProjectConfiguration, detectPackageManager, generateFiles,
|
|
4
|
+
*/ import { addDependenciesToPackageJson, addProjectConfiguration, detectPackageManager, generateFiles, joinPathFragments, OverwriteStrategy, readNxJson, updateJson, updateNxJson } from "@nx/devkit";
|
|
5
5
|
import { join, relative } from "path";
|
|
6
6
|
import { getTsLibDetails } from "../../ts/lib/generator.js";
|
|
7
7
|
import { updateGitIgnore } from "../../utils/git.js";
|
|
8
|
+
import { installDependencies } from "../../utils/install.js";
|
|
8
9
|
import { addGeneratorMetricsIfApplicable } from "../../utils/metrics.js";
|
|
9
10
|
import { kebabCase } from "../../utils/names.js";
|
|
10
11
|
import { addGeneratorMetadata, getGeneratorInfo, projectExists } from "../../utils/nx.js";
|
|
@@ -274,9 +275,17 @@ export async function terraformProjectGenerator(tree, schema) {
|
|
|
274
275
|
return packageJson;
|
|
275
276
|
});
|
|
276
277
|
}
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
// `@nx-extend/terraform` is registered as an Nx plugin in nx.json, so Nx
|
|
279
|
+
// loads it when computing the project graph — it must resolve even if the
|
|
280
|
+
// caller would otherwise prefer to defer installing.
|
|
281
|
+
return ()=>installDependencies(tree, schema.preferInstallDependencies, {
|
|
282
|
+
languages: [
|
|
283
|
+
'typescript'
|
|
284
|
+
],
|
|
285
|
+
ensureResolvable: [
|
|
286
|
+
NX_EXTEND_PLUGIN
|
|
287
|
+
]
|
|
288
|
+
});
|
|
280
289
|
}
|
|
281
290
|
export default terraformProjectGenerator;
|
|
282
291
|
|