@aws/nx-plugin 1.0.0-rc.57 → 1.0.0-rc.59
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 +2917 -1295
- package/generators.json +17 -1
- package/migrations.json +36 -26
- package/package.json +13 -13
- package/src/agentcore-gateway/__snapshots__/generator.spec.ts.snap +273 -0
- package/src/agentcore-gateway/agent-connection/generator.d.ts +19 -0
- package/src/agentcore-gateway/agent-connection/generator.js +90 -0
- package/src/agentcore-gateway/agent-connection/generator.js.map +1 -0
- package/src/agentcore-gateway/agent-connection/schema.d.js +6 -0
- package/src/agentcore-gateway/agent-connection/schema.d.js.map +1 -0
- package/src/agentcore-gateway/agent-connection/schema.d.ts +13 -0
- package/src/agentcore-gateway/agent-connection/schema.json +31 -0
- package/src/agentcore-gateway/attach-upstream.d.ts +16 -0
- package/src/agentcore-gateway/attach-upstream.js +32 -11
- package/src/agentcore-gateway/attach-upstream.js.map +1 -1
- package/src/agentcore-gateway/files/project/http/local-dev.ts.template +77 -0
- package/src/agentcore-gateway/generator.d.ts +17 -1
- package/src/agentcore-gateway/generator.js +25 -12
- package/src/agentcore-gateway/generator.js.map +1 -1
- package/src/agentcore-gateway/react-connection/__snapshots__/generator.spec.ts.snap +68 -0
- package/src/agentcore-gateway/react-connection/generator.d.ts +19 -0
- package/src/agentcore-gateway/react-connection/generator.js +119 -0
- package/src/agentcore-gateway/react-connection/generator.js.map +1 -0
- package/src/agentcore-gateway/react-connection/schema.d.js +6 -0
- package/src/agentcore-gateway/react-connection/schema.d.js.map +1 -0
- package/src/agentcore-gateway/react-connection/schema.d.ts +13 -0
- package/src/agentcore-gateway/react-connection/schema.json +31 -0
- package/src/agentcore-gateway/schema.d.js.map +1 -1
- package/src/agentcore-gateway/schema.d.ts +1 -1
- package/src/agentcore-gateway/schema.json +3 -2
- package/src/connection/agent-local-dev.d.ts +16 -0
- package/src/connection/agent-local-dev.js +44 -2
- package/src/connection/agent-local-dev.js.map +1 -1
- package/src/connection/gateway-runtime-config.d.ts +19 -0
- package/src/connection/gateway-runtime-config.js +47 -0
- package/src/connection/gateway-runtime-config.js.map +1 -0
- package/src/connection/generator.js +5 -0
- package/src/connection/generator.js.map +1 -1
- package/src/connection/scaffold-catalog.d.ts +267 -0
- package/src/connection/scaffold-catalog.js +347 -0
- package/src/connection/scaffold-catalog.js.map +1 -0
- package/src/connection/schema-resolver.d.ts +5 -0
- package/src/connection/schema-resolver.js +27 -0
- package/src/connection/schema-resolver.js.map +1 -0
- package/src/connection/supported-connections.d.ts +9 -0
- package/src/connection/supported-connections.js +12 -0
- package/src/connection/supported-connections.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +7 -7
- package/src/internal/test-matrix/generator.js +39 -1
- package/src/internal/test-matrix/generator.js.map +1 -1
- package/src/migrations/latest/gateway-agent-targets/__snapshots__/migration.spec.ts.snap +223 -0
- package/src/migrations/latest/gateway-agent-targets/metadata.json +3 -0
- package/src/migrations/latest/gateway-agent-targets/migration.js +217 -0
- package/src/migrations/latest/gateway-agent-targets/migration.js.map +1 -0
- package/src/migrations/latest/smithy-ssdk-bundle-pins/metadata.json +3 -0
- package/src/migrations/latest/smithy-ssdk-bundle-pins/migration.js +78 -0
- package/src/migrations/latest/smithy-ssdk-bundle-pins/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.50/modernize-function-props-cast/metadata.json +3 -0
- package/src/migrations/v1.0.0-rc.50/modernize-function-props-cast/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.50/restrict-cors-to-custom-domains/metadata.json +3 -0
- package/src/migrations/v1.0.0-rc.50/restrict-cors-to-custom-domains/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.50/terraform-bootstrap-adopt-existing-bucket/metadata.json +3 -0
- package/src/migrations/v1.0.0-rc.50/terraform-bootstrap-adopt-existing-bucket/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.52/user-identity-waf-allow-localhost-callback/metadata.json +3 -0
- package/src/migrations/v1.0.0-rc.52/user-identity-waf-allow-localhost-callback/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.54/order-access-log-delivery-after-bucket-policy/metadata.json +3 -0
- package/src/migrations/v1.0.0-rc.54/order-access-log-delivery-after-bucket-policy/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.55/backfill-generator-metadata/metadata.json +3 -0
- package/src/migrations/v1.0.0-rc.55/backfill-generator-metadata/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.56/dynamodb-local-remove-optimize-flag/metadata.json +3 -0
- package/src/migrations/v1.0.0-rc.56/dynamodb-local-remove-optimize-flag/migration.d.ts +6 -0
- package/src/migrations/v1.0.0-rc.56/dynamodb-local-remove-optimize-flag/migration.js.map +1 -0
- package/src/migrations/v1.0.0-rc.57/ts-agent-session-management-support/metadata.json +3 -0
- package/src/migrations/v1.0.0-rc.57/ts-agent-session-management-support/migration.d.ts +6 -0
- package/src/migrations/v1.0.0-rc.57/ts-agent-session-management-support/migration.js.map +1 -0
- package/src/preset/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +10 -8
- package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +8 -8
- package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +2 -2
- package/src/py/agent/a2a-connection/generator.d.ts +1 -1
- package/src/py/agent/gateway-connection/generator.d.ts +1 -1
- package/src/py/agent/mcp-connection/generator.d.ts +1 -1
- package/src/py/agent/react-connection/generator.d.ts +4 -1
- package/src/py/agent/react-connection/generator.js +35 -14
- package/src/py/agent/react-connection/generator.js.map +1 -1
- package/src/py/agent/schema.json +1 -0
- package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/dynamodb/schema.json +1 -0
- package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +12 -12
- package/src/py/fast-api/generator.d.ts +5 -0
- package/src/py/fast-api/generator.js +3 -2
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/schema.json +1 -0
- package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +5 -5
- package/src/py/mcp-server/schema.json +1 -0
- package/src/py/rdb/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/py/rdb/schema.json +1 -0
- package/src/smithy/project/__snapshots__/generator.spec.ts.snap +4 -4
- package/src/smithy/project/files/service/build.Dockerfile.template +2 -2
- package/src/smithy/project/generator.d.ts +25 -0
- package/src/smithy/project/generator.js +24 -3
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +7 -7
- package/src/smithy/ts/api/generator.d.ts +6 -1
- package/src/smithy/ts/api/generator.js +3 -2
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/smithy/ts/api/schema.json +1 -0
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +12 -12
- package/src/trpc/backend/generator.d.ts +6 -1
- package/src/trpc/backend/generator.js +3 -2
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.json +1 -0
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +9 -5
- package/src/ts/agent/generator.d.ts +32 -1
- package/src/ts/agent/generator.js +7 -4
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/react-connection/generator.d.ts +16 -1
- package/src/ts/agent/react-connection/generator.js +21 -8
- package/src/ts/agent/react-connection/generator.js.map +1 -1
- package/src/ts/agent/schema.json +1 -0
- package/src/ts/dcr-proxy/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/dynamodb/schema.json +1 -0
- package/src/ts/lambda-function/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +2 -2
- package/src/ts/mcp-server/generator.d.ts +32 -1
- 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.json +1 -0
- package/src/ts/nx-migration/generator.js +40 -27
- package/src/ts/nx-migration/generator.js.map +1 -1
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/ts/rdb/generator.d.ts +8 -0
- package/src/ts/rdb/generator.js +3 -2
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/rdb/schema.json +1 -0
- package/src/ts/react-website/agui/files/common/src/hooks/useAgui__agentNameClassName__.tsx.template +16 -0
- package/src/ts/react-website/agui/generator.d.ts +11 -0
- package/src/ts/react-website/agui/generator.js +11 -7
- package/src/ts/react-website/agui/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +61 -45
- package/src/ts/react-website/app/generator.d.ts +6 -1
- package/src/ts/react-website/app/generator.js +3 -2
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/app/schema.json +1 -0
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +2 -2
- package/src/ts/react-website/cognito-auth/generator.d.ts +6 -1
- package/src/ts/react-website/cognito-auth/generator.js +3 -2
- package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +23 -0
- package/src/utils/agent-core-constructs/agent-core-constructs.js +24 -1
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +3 -0
- package/src/utils/agent-core-constructs/files/cdk/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.ts.template +6 -4
- package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/agentcore-gateway.ts.template +119 -3
- package/src/utils/agent-core-constructs/files/terraform/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.tf.template +17 -0
- package/src/utils/api-constructs/api-constructs.d.ts +9 -0
- package/src/utils/api-constructs/api-constructs.js +11 -1
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/config/utils.d.ts +5 -0
- package/src/utils/config/utils.js +7 -1
- package/src/utils/config/utils.js.map +1 -1
- package/src/utils/connection/open-api/files/components/__apiNameClassName__Provider.tsx.template +13 -2
- package/src/utils/connection/open-api/react.d.ts +10 -1
- package/src/utils/connection/open-api/react.js +3 -2
- package/src/utils/connection/open-api/react.js.map +1 -1
- package/src/utils/docker.d.ts +27 -2
- package/src/utils/docker.js +31 -2
- package/src/utils/docker.js.map +1 -1
- package/src/utils/identity-constructs/identity-constructs.d.ts +10 -0
- package/src/utils/identity-constructs/identity-constructs.js +11 -1
- package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
- package/src/utils/migration-manifest.d.ts +58 -0
- package/src/utils/migration-manifest.js +76 -0
- package/src/utils/migration-manifest.js.map +1 -0
- package/src/utils/migration-versions.d.ts +2 -0
- package/src/utils/migration-versions.js.map +1 -1
- package/src/utils/shared-constructs-constants.d.ts +6 -0
- package/src/utils/shared-constructs-constants.js +5 -0
- package/src/utils/shared-constructs-constants.js.map +1 -1
- package/src/utils/version-upgrade-migration/owned-dependencies.d.ts +26 -0
- package/src/utils/version-upgrade-migration/owned-dependencies.js +52 -4
- package/src/utils/version-upgrade-migration/owned-dependencies.js.map +1 -1
- package/src/utils/version-upgrade-migration/register.d.ts +9 -3
- package/src/utils/version-upgrade-migration/register.js +18 -14
- package/src/utils/version-upgrade-migration/register.js.map +1 -1
- package/src/utils/version-upgrade-migration/sync-embedded-versions.d.ts +26 -0
- package/src/utils/version-upgrade-migration/sync-embedded-versions.js +304 -0
- package/src/utils/version-upgrade-migration/sync-embedded-versions.js.map +1 -0
- package/src/utils/version-upgrade-migration/sync-vended-versions.js +14 -0
- package/src/utils/version-upgrade-migration/sync-vended-versions.js.map +1 -1
- package/src/utils/versions.d.ts +90 -77
- package/src/utils/versions.js +86 -75
- package/src/utils/versions.js.map +1 -1
- package/src/utils/website-constructs/website-constructs.d.ts +11 -0
- package/src/utils/website-constructs/website-constructs.js +12 -1
- package/src/utils/website-constructs/website-constructs.js.map +1 -1
- package/src/migrations/latest/backfill-generator-metadata/migration.js.map +0 -1
- package/src/migrations/latest/dynamodb-local-remove-optimize-flag/migration.js.map +0 -1
- package/src/migrations/latest/modernize-function-props-cast/migration.js.map +0 -1
- package/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.js.map +0 -1
- package/src/migrations/latest/restrict-cors-to-custom-domains/migration.js.map +0 -1
- package/src/migrations/latest/terraform-bootstrap-adopt-existing-bucket/migration.js.map +0 -1
- package/src/migrations/latest/ts-agent-session-management-support/migration.js.map +0 -1
- package/src/migrations/latest/user-identity-waf-allow-localhost-callback/migration.js.map +0 -1
- /package/src/agentcore-gateway/files/project/{local-dev.ts.template → mcp/local-dev.ts.template} +0 -0
- /package/src/migrations/latest/{dynamodb-local-remove-optimize-flag → gateway-agent-targets}/migration.d.ts +0 -0
- /package/src/migrations/latest/{modernize-function-props-cast → smithy-ssdk-bundle-pins}/migration.d.ts +0 -0
- /package/src/migrations/{latest/restrict-cors-to-custom-domains → v1.0.0-rc.50/modernize-function-props-cast}/migration.d.ts +0 -0
- /package/src/migrations/{latest → v1.0.0-rc.50}/modernize-function-props-cast/migration.js +0 -0
- /package/src/migrations/{latest/terraform-bootstrap-adopt-existing-bucket → v1.0.0-rc.50/restrict-cors-to-custom-domains}/migration.d.ts +0 -0
- /package/src/migrations/{latest → v1.0.0-rc.50}/restrict-cors-to-custom-domains/migration.js +0 -0
- /package/src/migrations/{latest/ts-agent-session-management-support → v1.0.0-rc.50/terraform-bootstrap-adopt-existing-bucket}/migration.d.ts +0 -0
- /package/src/migrations/{latest → v1.0.0-rc.50}/terraform-bootstrap-adopt-existing-bucket/migration.js +0 -0
- /package/src/migrations/{latest/order-access-log-delivery-after-bucket-policy → v1.0.0-rc.52/user-identity-waf-allow-localhost-callback}/migration.d.ts +0 -0
- /package/src/migrations/{latest → v1.0.0-rc.52}/user-identity-waf-allow-localhost-callback/migration.js +0 -0
- /package/src/migrations/{latest/user-identity-waf-allow-localhost-callback → v1.0.0-rc.54/order-access-log-delivery-after-bucket-policy}/migration.d.ts +0 -0
- /package/src/migrations/{latest → v1.0.0-rc.54}/order-access-log-delivery-after-bucket-policy/migration.js +0 -0
- /package/src/migrations/{latest → v1.0.0-rc.55}/backfill-generator-metadata/migration.d.ts +0 -0
- /package/src/migrations/{latest → v1.0.0-rc.55}/backfill-generator-metadata/migration.js +0 -0
- /package/src/migrations/{latest → v1.0.0-rc.56}/dynamodb-local-remove-optimize-flag/migration.js +0 -0
- /package/src/migrations/{latest → v1.0.0-rc.57}/ts-agent-session-management-support/migration.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/migration-versions.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { compare, valid } from 'semver';\n\n/**\n * Version stamping for migrations.\n *\n * A new migration is committed with no `version` — releases are calculated from\n * conventional commits and written only to `dist/` and a git tag, so versions\n * reach the published `migrations.json` two ways:\n *\n * - At release time (`scripts/stamp-migrations.ts`) entries still missing a\n * version are stamped into the compiled `migrations.json`: an already shipped\n * one gets the earliest release tag registering it, and a net-new one gets the\n * version the release is about to publish, which the release job passes in\n * after `nx release version` writes it to the dist manifests.\n * - The weekly `update-versions` PR backfills the version of the release that\n * shipped each migration, moving and re-keying it accordingly\n * (`scripts/backfill-migration-versions.ts`), so source converges on the\n * versions of everything already released. `packageJsonUpdates` entries are\n * dated in place there too, since their keys never change.\n *\n * A version already in source always wins, so backfilled entries are stable.\n *\n * An entry marked `everyMigration: true` is never backfilled or pinned, and is\n * re-stamped with each pending version, so it runs on every upgrade.\n */\n\nexport interface MigrationsJson {\n generators?: Record<\n string,\n { version?: string; everyMigration?: boolean } & Record<string, unknown>\n >;\n /**\n * Declarative dependency bumps `nx migrate` applies to the root manifest.\n * Keyed by what the bump targets rather than the release that ships it, so an\n * entry is unique from the moment it is written and one release's bump can sit\n * beside the next; nx itself gates on the entry's `version`.\n */\n packageJsonUpdates?: Record<\n string,\n { version: string } & Record<string, unknown>\n >;\n}\n\n/** Ascending semver comparator for `Array.prototype.sort`. */\nexport const compareVersions = compare;\n\n/** Whether a string is an exact semver version. */\nexport const isValidVersion = (version: string): boolean =>\n valid(version) !== null;\n\n/**\n * Map of entry key -> version of the earliest release that registers it, across\n * both `generators` and `packageJsonUpdates`. Resolved only for the entries still\n * missing a version (one already recorded in source wins, so its history doesn't\n * need reading). An entry that hasn't been released is absent.\n *\n * Walks releases newest first and stops as soon as every entry is resolved: an\n * entry that has disappeared from a release's `migrations.json` was first\n * registered by the release after it, which is the one that shipped it.\n *\n * Both sections resolve the same way and share the walk, so the release doesn't\n * read tag history twice. Keys can't collide: a migration is keyed by its own\n * name, an nx bump by the nx version it moves to.\n *\n * @param migrations parsed source migrations.json\n * @param versions released versions in descending semver order\n * @param readReleasedMigrations reads the `migrations.json` published by a given\n * version, or undefined if it predates the manifest\n */\nexport const readShippedMigrationVersions = (\n migrations: MigrationsJson,\n versions: string[],\n readReleasedMigrations: (version: string) => MigrationsJson | undefined,\n): Record<string, string> => {\n const shippedVersions: Record<string, string> = {};\n // A `packageJsonUpdates` entry records `latest` rather than omitting its\n // version, since nx requires the field.\n let unresolved = [\n ...Object.entries(migrations.generators ?? {})\n .filter(([, entry]) => !entry.version)\n .map(([key]) => key),\n ...Object.entries(migrations.packageJsonUpdates ?? {})\n .filter(([, entry]) => entry.version === LATEST_MIGRATIONS_DIR)\n .map(([key]) => key),\n ];\n\n for (const version of versions) {\n if (unresolved.length === 0) {\n break;\n }\n const released = readReleasedMigrations(version);\n const registered = new Set([\n ...Object.keys(released?.generators ?? {}),\n ...Object.keys(released?.packageJsonUpdates ?? {}),\n ]);\n // Entries gone at this release keep the version recorded from the release\n // after it (if any) and stop being looked up.\n unresolved = unresolved.filter((key) => registered.has(key));\n for (const key of unresolved) {\n shippedVersions[key] = version;\n }\n }\n\n return shippedVersions;\n};\n\n/**\n * Return a copy of the migrations collection with a `version` stamped onto\n * every generator entry, preserving any already present, and the pending version\n * recorded on any `packageJsonUpdates` entry still holding `latest`.\n *\n * @param migrations parsed migrations.json to stamp\n * @param shippedVersions migration key -> version of the earliest release\n * tag that registers it (absent for migrations that haven't shipped)\n * @param pendingVersion version the release is about to publish, stamped onto\n * unshipped migrations so their version is one that really shipped\n */\nexport const stampMigrationVersions = (\n migrations: MigrationsJson,\n shippedVersions: Record<string, string>,\n pendingVersion: string,\n): MigrationsJson => ({\n ...migrations,\n generators: Object.fromEntries(\n // `nx migrate` sorts the run ascending by version and preserves the\n // manifest's order among equal versions, so emitting the every-migration\n // entries last is what makes them run after the release's own migrations.\n Object.entries(migrations.generators ?? {})\n .sort(\n ([, a], [, b]) =>\n Number(a.everyMigration ?? false) - Number(b.everyMigration ?? false),\n )\n .map(([name, entry]) => {\n // Source-only marker, stripped from what nx reads.\n const { everyMigration, version: sourceVersion, ...published } = entry;\n // Overrides any source version so it stays ahead of what is installed.\n const version = everyMigration\n ? pendingVersion\n : (sourceVersion ?? shippedVersions[name] ?? pendingVersion);\n return [name, { version, ...published }];\n }),\n ),\n ...(migrations.packageJsonUpdates && {\n packageJsonUpdates: stampPackageJsonUpdates(\n migrations.packageJsonUpdates,\n pendingVersion,\n ),\n }),\n});\n\n/**\n * Version any `packageJsonUpdates` entry still holding `latest` with the release\n * about to publish it, so the nx bump ships under a version `nx migrate` gates on.\n */\nconst stampPackageJsonUpdates = (\n packageJsonUpdates: NonNullable<MigrationsJson['packageJsonUpdates']>,\n pendingVersion: string,\n): NonNullable<MigrationsJson['packageJsonUpdates']> =>\n resolvePackageJsonUpdateVersions(packageJsonUpdates, () => pendingVersion);\n\n/** Directory a newly scaffolded migration lands in, before a release claims it. */\nexport const LATEST_MIGRATIONS_DIR = 'latest';\n\n/** Directory holding the migrations shipped by a given release. */\nexport const versionMigrationsDir = (version: string) => `v${version}`;\n\n/**\n * Key a migration is registered under in `migrations.json`. Prefixed with its\n * directory so reusing a name in a later release can't silently overwrite the\n * one that already shipped.\n */\nexport const migrationKey = (dir: string, name: string) => `${dir}-${name}`;\n\nconst LATEST_KEY_PREFIX = `${LATEST_MIGRATIONS_DIR}-`;\n\n/** A migration directory move the caller needs to make on disk. */\nexport interface MigrationDirMove {\n name: string;\n version: string;\n from: string;\n to: string;\n}\n\n/**\n * Record the release that shipped each migration on entries without a version,\n * re-keying them and re-pointing their paths at that release's folder, and\n * return the collection alongside the keys that changed and the directory moves\n * to make on disk.\n *\n * Unlike `stampMigrationVersions` this only records already-released versions,\n * leaving the release to decide what a net-new migration gets.\n *\n * @param migrations parsed migrations.json to backfill\n * @param shippedVersions migration key -> version of the earliest release tag\n * that registers it (absent for migrations that haven't shipped)\n */\nexport const backfillMigrationVersions = (\n migrations: MigrationsJson,\n shippedVersions: Record<string, string>,\n): {\n migrations: MigrationsJson;\n backfilled: string[];\n moves: MigrationDirMove[];\n} => {\n const generators: NonNullable<MigrationsJson['generators']> = {};\n const backfilled: string[] = [];\n const moves: MigrationDirMove[] = [];\n // Reported alongside the migrations so the update's PR says an nx bump was\n // dated, and so the caller knows there is something to commit.\n const backfilledUpdates = Object.entries(migrations.packageJsonUpdates ?? {})\n .filter(\n ([key, entry]) =>\n entry.version === LATEST_MIGRATIONS_DIR && shippedVersions[key],\n )\n .map(([key]) => key);\n\n for (const [key, entry] of Object.entries(migrations.generators ?? {})) {\n const version = shippedVersions[key];\n // Pinning an every-migration entry would stop it running on later upgrades.\n if (entry.version || !version || entry.everyMigration) {\n generators[key] = entry;\n continue;\n }\n\n const name = key.startsWith(LATEST_KEY_PREFIX)\n ? key.slice(LATEST_KEY_PREFIX.length)\n : key;\n const versionDir = versionMigrationsDir(version);\n const latestSegment = `/${LATEST_MIGRATIONS_DIR}/${name}/`;\n const versionSegment = `/${versionDir}/${name}/`;\n\n // Re-point each path field at the version folder, recording the move the\n // caller needs to make on disk the first time one is found.\n const repointed: Record<string, unknown> = {};\n let moved = false;\n for (const [field, value] of Object.entries(entry)) {\n if (typeof value !== 'string' || !value.includes(latestSegment)) {\n repointed[field] = value;\n continue;\n }\n repointed[field] = value.replace(latestSegment, versionSegment);\n if (!moved) {\n moved = true;\n const dir = value.slice(0, value.indexOf(latestSegment));\n moves.push({\n name,\n version,\n from: `${dir}${latestSegment}`.replace(/^\\.\\/|\\/$/g, ''),\n to: `${dir}${versionSegment}`.replace(/^\\.\\/|\\/$/g, ''),\n });\n }\n }\n\n generators[migrationKey(versionDir, name)] = { version, ...repointed };\n backfilled.push(key);\n }\n\n return {\n migrations: {\n ...migrations,\n generators,\n ...(migrations.packageJsonUpdates && {\n packageJsonUpdates: resolvePackageJsonUpdateVersions(\n migrations.packageJsonUpdates,\n (key) => shippedVersions[key],\n ),\n }),\n },\n backfilled: [...backfilled, ...backfilledUpdates],\n moves,\n };\n};\n\n/**\n * Record the version each `packageJsonUpdates` entry ships under, for those still\n * holding `latest`.\n *\n * The key already identifies the entry — an nx bump is named for the nx version\n * it moves to — so only the `version` field changes. Nothing is re-keyed, which\n * is what lets one release's bump sit alongside the next without either being\n * overwritten before it ships.\n */\nconst resolvePackageJsonUpdateVersions = (\n packageJsonUpdates: NonNullable<MigrationsJson['packageJsonUpdates']>,\n resolve: (key: string) => string | undefined,\n): NonNullable<MigrationsJson['packageJsonUpdates']> =>\n Object.fromEntries(\n Object.entries(packageJsonUpdates).map(([key, entry]) => {\n const version =\n entry.version === LATEST_MIGRATIONS_DIR ? resolve(key) : undefined;\n return [key, version ? { ...entry, version } : entry];\n }),\n );\n"],"names":["compare","valid","compareVersions","isValidVersion","version","readShippedMigrationVersions","migrations","versions","readReleasedMigrations","shippedVersions","unresolved","Object","entries","generators","filter","entry","map","key","packageJsonUpdates","LATEST_MIGRATIONS_DIR","length","released","registered","Set","keys","has","stampMigrationVersions","pendingVersion","fromEntries","sort","a","b","Number","everyMigration","name","sourceVersion","published","stampPackageJsonUpdates","resolvePackageJsonUpdateVersions","versionMigrationsDir","migrationKey","dir","LATEST_KEY_PREFIX","backfillMigrationVersions","backfilled","moves","backfilledUpdates","startsWith","slice","versionDir","latestSegment","versionSegment","repointed","moved","field","value","includes","replace","indexOf","push","from","to","resolve","undefined"],"mappings":"AAAA;;;CAGC,GACD,SAASA,OAAO,EAAEC,KAAK,QAAQ,SAAS;AA2CxC,4DAA4D,GAC5D,OAAO,MAAMC,kBAAkBF,QAAQ;AAEvC,iDAAiD,GACjD,OAAO,MAAMG,iBAAiB,CAACC,UAC7BH,MAAMG,aAAa,KAAK;AAE1B;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,MAAMC,+BAA+B,CAC1CC,YACAC,UACAC;IAEA,MAAMC,kBAA0C,CAAC;IACjD,yEAAyE;IACzE,wCAAwC;IACxC,IAAIC,aAAa;WACZC,OAAOC,OAAO,CAACN,WAAWO,UAAU,IAAI,CAAC,GACzCC,MAAM,CAAC,CAAC,GAAGC,MAAM,GAAK,CAACA,MAAMX,OAAO,EACpCY,GAAG,CAAC,CAAC,CAACC,IAAI,GAAKA;WACfN,OAAOC,OAAO,CAACN,WAAWY,kBAAkB,IAAI,CAAC,GACjDJ,MAAM,CAAC,CAAC,GAAGC,MAAM,GAAKA,MAAMX,OAAO,KAAKe,uBACxCH,GAAG,CAAC,CAAC,CAACC,IAAI,GAAKA;KACnB;IAED,KAAK,MAAMb,WAAWG,SAAU;QAC9B,IAAIG,WAAWU,MAAM,KAAK,GAAG;YAC3B;QACF;QACA,MAAMC,WAAWb,uBAAuBJ;QACxC,MAAMkB,aAAa,IAAIC,IAAI;eACtBZ,OAAOa,IAAI,CAACH,UAAUR,cAAc,CAAC;eACrCF,OAAOa,IAAI,CAACH,UAAUH,sBAAsB,CAAC;SACjD;QACD,0EAA0E;QAC1E,8CAA8C;QAC9CR,aAAaA,WAAWI,MAAM,CAAC,CAACG,MAAQK,WAAWG,GAAG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ACE,MAAM,GAAGC;gBACnB;YACF;YACAH,SAAS,CAACE,MAAM,GAAGC,MAAME,OAAO,CAACP,eAAeC;YAChD,IAAI,CAACE,OAAO;gBACVA,QAAQ;gBACR,MAAMZ,MAAMc,MAAMP,KAAK,CAAC,GAAGO,MAAMG,OAAO,CAACR;gBACzCL,MAAMc,IAAI,CAAC;oBACTzB;oBACA9B;oBACAwD,MAAM,GAAGnB,MAAMS,eAAe,CAACO,OAAO,CAAC,cAAc;oBACrDI,IAAI,GAAGpB,MAAMU,gBAAgB,CAACM,OAAO,CAAC,cAAc;gBACtD;YACF;QACF;QAEA5C,UAAU,CAAC2B,aAAaS,YAAYf,MAAM,GAAG;YAAE9B;YAAS,GAAGgD,SAAS;QAAC;QACrER,WAAWe,IAAI,CAAC1C;IAClB;IAEA,OAAO;QACLX,YAAY;YACV,GAAGA,UAAU;YACbO;YACA,GAAIP,WAAWY,kBAAkB,IAAI;gBACnCA,oBAAoBoB,iCAClBhC,WAAWY,kBAAkB,EAC7B,CAACD,MAAQR,eAAe,CAACQ,IAAI;YAEjC,CAAC;QACH;QACA2B,YAAY;eAAIA;eAAeE;SAAkB;QACjDD;IACF;AACF,EAAE;AAEF;;;;;;;;CAQC,GACD,MAAMP,mCAAmC,CACvCpB,oBACA4C,UAEAnD,OAAOiB,WAAW,CAChBjB,OAAOC,OAAO,CAACM,oBAAoBF,GAAG,CAAC,CAAC,CAACC,KAAKF,MAAM;QAClD,MAAMX,UACJW,MAAMX,OAAO,KAAKe,wBAAwB2C,QAAQ7C,OAAO8C;QAC3D,OAAO;YAAC9C;YAAKb,UAAU;gBAAE,GAAGW,KAAK;gBAAEX;YAAQ,IAAIW;SAAM;IACvD"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/migration-versions.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { compare, valid } from 'semver';\n\n/**\n * Version stamping for migrations.\n *\n * A new migration is committed with no `version` — releases are calculated from\n * conventional commits and written only to `dist/` and a git tag, so versions\n * reach the published `migrations.json` two ways:\n *\n * - At release time (`scripts/stamp-migrations.ts`) entries still missing a\n * version are stamped into the compiled `migrations.json`: an already shipped\n * one gets the earliest release tag registering it, and a net-new one gets the\n * version the release is about to publish, which the release job passes in\n * after `nx release version` writes it to the dist manifests.\n * - The weekly `update-versions` PR backfills the version of the release that\n * shipped each migration, moving and re-keying it accordingly\n * (`scripts/backfill-migration-versions.ts`), so source converges on the\n * versions of everything already released. `packageJsonUpdates` entries are\n * dated in place there too, since their keys never change.\n *\n * A version already in source always wins, so backfilled entries are stable.\n *\n * An entry marked `everyMigration: true` is never backfilled or pinned, and is\n * re-stamped with each pending version, so it runs on every upgrade.\n */\n\nexport interface MigrationsJson {\n $schema?: string;\n name?: string;\n generators?: Record<\n string,\n { version?: string; everyMigration?: boolean } & Record<string, unknown>\n >;\n /**\n * Declarative dependency bumps `nx migrate` applies to the root manifest.\n * Keyed by what the bump targets rather than the release that ships it, so an\n * entry is unique from the moment it is written and one release's bump can sit\n * beside the next; nx itself gates on the entry's `version`.\n */\n packageJsonUpdates?: Record<\n string,\n { version: string } & Record<string, unknown>\n >;\n}\n\n/** Ascending semver comparator for `Array.prototype.sort`. */\nexport const compareVersions = compare;\n\n/** Whether a string is an exact semver version. */\nexport const isValidVersion = (version: string): boolean =>\n valid(version) !== null;\n\n/**\n * Map of entry key -> version of the earliest release that registers it, across\n * both `generators` and `packageJsonUpdates`. Resolved only for the entries still\n * missing a version (one already recorded in source wins, so its history doesn't\n * need reading). An entry that hasn't been released is absent.\n *\n * Walks releases newest first and stops as soon as every entry is resolved: an\n * entry that has disappeared from a release's `migrations.json` was first\n * registered by the release after it, which is the one that shipped it.\n *\n * Both sections resolve the same way and share the walk, so the release doesn't\n * read tag history twice. Keys can't collide: a migration is keyed by its own\n * name, an nx bump by the nx version it moves to.\n *\n * @param migrations parsed source migrations.json\n * @param versions released versions in descending semver order\n * @param readReleasedMigrations reads the `migrations.json` published by a given\n * version, or undefined if it predates the manifest\n */\nexport const readShippedMigrationVersions = (\n migrations: MigrationsJson,\n versions: string[],\n readReleasedMigrations: (version: string) => MigrationsJson | undefined,\n): Record<string, string> => {\n const shippedVersions: Record<string, string> = {};\n // A `packageJsonUpdates` entry records `latest` rather than omitting its\n // version, since nx requires the field.\n let unresolved = [\n ...Object.entries(migrations.generators ?? {})\n .filter(([, entry]) => !entry.version)\n .map(([key]) => key),\n ...Object.entries(migrations.packageJsonUpdates ?? {})\n .filter(([, entry]) => entry.version === LATEST_MIGRATIONS_DIR)\n .map(([key]) => key),\n ];\n\n for (const version of versions) {\n if (unresolved.length === 0) {\n break;\n }\n const released = readReleasedMigrations(version);\n const registered = new Set([\n ...Object.keys(released?.generators ?? {}),\n ...Object.keys(released?.packageJsonUpdates ?? {}),\n ]);\n // Entries gone at this release keep the version recorded from the release\n // after it (if any) and stop being looked up.\n unresolved = unresolved.filter((key) => registered.has(key));\n for (const key of unresolved) {\n shippedVersions[key] = version;\n }\n }\n\n return shippedVersions;\n};\n\n/**\n * Return a copy of the migrations collection with a `version` stamped onto\n * every generator entry, preserving any already present, and the pending version\n * recorded on any `packageJsonUpdates` entry still holding `latest`.\n *\n * @param migrations parsed migrations.json to stamp\n * @param shippedVersions migration key -> version of the earliest release\n * tag that registers it (absent for migrations that haven't shipped)\n * @param pendingVersion version the release is about to publish, stamped onto\n * unshipped migrations so their version is one that really shipped\n */\nexport const stampMigrationVersions = (\n migrations: MigrationsJson,\n shippedVersions: Record<string, string>,\n pendingVersion: string,\n): MigrationsJson => ({\n ...migrations,\n generators: Object.fromEntries(\n // `nx migrate` sorts the run ascending by version and preserves the\n // manifest's order among equal versions, so emitting the every-migration\n // entries last is what makes them run after the release's own migrations.\n Object.entries(migrations.generators ?? {})\n .sort(\n ([, a], [, b]) =>\n Number(a.everyMigration ?? false) - Number(b.everyMigration ?? false),\n )\n .map(([name, entry]) => {\n // Source-only marker, stripped from what nx reads.\n const { everyMigration, version: sourceVersion, ...published } = entry;\n // Overrides any source version so it stays ahead of what is installed.\n const version = everyMigration\n ? pendingVersion\n : (sourceVersion ?? shippedVersions[name] ?? pendingVersion);\n return [name, { version, ...published }];\n }),\n ),\n ...(migrations.packageJsonUpdates && {\n packageJsonUpdates: stampPackageJsonUpdates(\n migrations.packageJsonUpdates,\n pendingVersion,\n ),\n }),\n});\n\n/**\n * Version any `packageJsonUpdates` entry still holding `latest` with the release\n * about to publish it, so the nx bump ships under a version `nx migrate` gates on.\n */\nconst stampPackageJsonUpdates = (\n packageJsonUpdates: NonNullable<MigrationsJson['packageJsonUpdates']>,\n pendingVersion: string,\n): NonNullable<MigrationsJson['packageJsonUpdates']> =>\n resolvePackageJsonUpdateVersions(packageJsonUpdates, () => pendingVersion);\n\n/** Directory a newly scaffolded migration lands in, before a release claims it. */\nexport const LATEST_MIGRATIONS_DIR = 'latest';\n\n/** Directory holding the migrations shipped by a given release. */\nexport const versionMigrationsDir = (version: string) => `v${version}`;\n\n/**\n * Key a migration is registered under in `migrations.json`. Prefixed with its\n * directory so reusing a name in a later release can't silently overwrite the\n * one that already shipped.\n */\nexport const migrationKey = (dir: string, name: string) => `${dir}-${name}`;\n\nconst LATEST_KEY_PREFIX = `${LATEST_MIGRATIONS_DIR}-`;\n\n/** A migration directory move the caller needs to make on disk. */\nexport interface MigrationDirMove {\n name: string;\n version: string;\n from: string;\n to: string;\n}\n\n/**\n * Record the release that shipped each migration on entries without a version,\n * re-keying them and re-pointing their paths at that release's folder, and\n * return the collection alongside the keys that changed and the directory moves\n * to make on disk.\n *\n * Unlike `stampMigrationVersions` this only records already-released versions,\n * leaving the release to decide what a net-new migration gets.\n *\n * @param migrations parsed migrations.json to backfill\n * @param shippedVersions migration key -> version of the earliest release tag\n * that registers it (absent for migrations that haven't shipped)\n */\nexport const backfillMigrationVersions = (\n migrations: MigrationsJson,\n shippedVersions: Record<string, string>,\n): {\n migrations: MigrationsJson;\n backfilled: string[];\n moves: MigrationDirMove[];\n} => {\n const generators: NonNullable<MigrationsJson['generators']> = {};\n const backfilled: string[] = [];\n const moves: MigrationDirMove[] = [];\n // Reported alongside the migrations so the update's PR says an nx bump was\n // dated, and so the caller knows there is something to commit.\n const backfilledUpdates = Object.entries(migrations.packageJsonUpdates ?? {})\n .filter(\n ([key, entry]) =>\n entry.version === LATEST_MIGRATIONS_DIR && shippedVersions[key],\n )\n .map(([key]) => key);\n\n for (const [key, entry] of Object.entries(migrations.generators ?? {})) {\n const version = shippedVersions[key];\n // Pinning an every-migration entry would stop it running on later upgrades.\n if (entry.version || !version || entry.everyMigration) {\n generators[key] = entry;\n continue;\n }\n\n const name = key.startsWith(LATEST_KEY_PREFIX)\n ? key.slice(LATEST_KEY_PREFIX.length)\n : key;\n const versionDir = versionMigrationsDir(version);\n const latestSegment = `/${LATEST_MIGRATIONS_DIR}/${name}/`;\n const versionSegment = `/${versionDir}/${name}/`;\n\n // Re-point each path field at the version folder, recording the move the\n // caller needs to make on disk the first time one is found.\n const repointed: Record<string, unknown> = {};\n let moved = false;\n for (const [field, value] of Object.entries(entry)) {\n if (typeof value !== 'string' || !value.includes(latestSegment)) {\n repointed[field] = value;\n continue;\n }\n repointed[field] = value.replace(latestSegment, versionSegment);\n if (!moved) {\n moved = true;\n const dir = value.slice(0, value.indexOf(latestSegment));\n moves.push({\n name,\n version,\n from: `${dir}${latestSegment}`.replace(/^\\.\\/|\\/$/g, ''),\n to: `${dir}${versionSegment}`.replace(/^\\.\\/|\\/$/g, ''),\n });\n }\n }\n\n generators[migrationKey(versionDir, name)] = { version, ...repointed };\n backfilled.push(key);\n }\n\n return {\n migrations: {\n ...migrations,\n generators,\n ...(migrations.packageJsonUpdates && {\n packageJsonUpdates: resolvePackageJsonUpdateVersions(\n migrations.packageJsonUpdates,\n (key) => shippedVersions[key],\n ),\n }),\n },\n backfilled: [...backfilled, ...backfilledUpdates],\n moves,\n };\n};\n\n/**\n * Record the version each `packageJsonUpdates` entry ships under, for those still\n * holding `latest`.\n *\n * The key already identifies the entry — an nx bump is named for the nx version\n * it moves to — so only the `version` field changes. Nothing is re-keyed, which\n * is what lets one release's bump sit alongside the next without either being\n * overwritten before it ships.\n */\nconst resolvePackageJsonUpdateVersions = (\n packageJsonUpdates: NonNullable<MigrationsJson['packageJsonUpdates']>,\n resolve: (key: string) => string | undefined,\n): NonNullable<MigrationsJson['packageJsonUpdates']> =>\n Object.fromEntries(\n Object.entries(packageJsonUpdates).map(([key, entry]) => {\n const version =\n entry.version === LATEST_MIGRATIONS_DIR ? resolve(key) : undefined;\n return [key, version ? { ...entry, version } : entry];\n }),\n );\n"],"names":["compare","valid","compareVersions","isValidVersion","version","readShippedMigrationVersions","migrations","versions","readReleasedMigrations","shippedVersions","unresolved","Object","entries","generators","filter","entry","map","key","packageJsonUpdates","LATEST_MIGRATIONS_DIR","length","released","registered","Set","keys","has","stampMigrationVersions","pendingVersion","fromEntries","sort","a","b","Number","everyMigration","name","sourceVersion","published","stampPackageJsonUpdates","resolvePackageJsonUpdateVersions","versionMigrationsDir","migrationKey","dir","LATEST_KEY_PREFIX","backfillMigrationVersions","backfilled","moves","backfilledUpdates","startsWith","slice","versionDir","latestSegment","versionSegment","repointed","moved","field","value","includes","replace","indexOf","push","from","to","resolve","undefined"],"mappings":"AAAA;;;CAGC,GACD,SAASA,OAAO,EAAEC,KAAK,QAAQ,SAAS;AA6CxC,4DAA4D,GAC5D,OAAO,MAAMC,kBAAkBF,QAAQ;AAEvC,iDAAiD,GACjD,OAAO,MAAMG,iBAAiB,CAACC,UAC7BH,MAAMG,aAAa,KAAK;AAE1B;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,MAAMC,+BAA+B,CAC1CC,YACAC,UACAC;IAEA,MAAMC,kBAA0C,CAAC;IACjD,yEAAyE;IACzE,wCAAwC;IACxC,IAAIC,aAAa;WACZC,OAAOC,OAAO,CAACN,WAAWO,UAAU,IAAI,CAAC,GACzCC,MAAM,CAAC,CAAC,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eAAe,CAACQ,IAAI;YAEjC,CAAC;QACH;QACA2B,YAAY;eAAIA;eAAeE;SAAkB;QACjDD;IACF;AACF,EAAE;AAEF;;;;;;;;CAQC,GACD,MAAMP,mCAAmC,CACvCpB,oBACA4C,UAEAnD,OAAOiB,WAAW,CAChBjB,OAAOC,OAAO,CAACM,oBAAoBF,GAAG,CAAC,CAAC,CAACC,KAAKF,MAAM;QAClD,MAAMX,UACJW,MAAMX,OAAO,KAAKe,wBAAwB2C,QAAQ7C,OAAO8C;QAC3D,OAAO;YAAC9C;YAAKb,UAAU;gBAAE,GAAGW,KAAK;gBAAEX;YAAQ,IAAIW;SAAM;IACvD"}
|
|
@@ -31,6 +31,12 @@ export interface IacMetadata {
|
|
|
31
31
|
* questions and no generator needs a second one.
|
|
32
32
|
*/
|
|
33
33
|
export declare const generatedInfrastructure: (m: IacMetadata) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether Terraform infrastructure was generated, for the versions only a `.tf`
|
|
36
|
+
* module pins — a Terraform inline script's `uv run --with` pins, which the CDK
|
|
37
|
+
* branch never writes.
|
|
38
|
+
*/
|
|
39
|
+
export declare const generatedTerraform: (m: IacMetadata) => boolean;
|
|
34
40
|
/**
|
|
35
41
|
* Dependencies a caller must declare to use the shared constructs project.
|
|
36
42
|
* Lives here so generators can spread it without importing the generator.
|
|
@@ -24,6 +24,11 @@ export const DYNAMODB_GENERATOR_IDS = [
|
|
|
24
24
|
* resolves `iac` only on the infra branch, so one recorded field answers both
|
|
25
25
|
* questions and no generator needs a second one.
|
|
26
26
|
*/ export const generatedInfrastructure = (m)=>m.iac !== undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Whether Terraform infrastructure was generated, for the versions only a `.tf`
|
|
29
|
+
* module pins — a Terraform inline script's `uv run --with` pins, which the CDK
|
|
30
|
+
* branch never writes.
|
|
31
|
+
*/ export const generatedTerraform = (m)=>m.iac === 'terraform';
|
|
27
32
|
/**
|
|
28
33
|
* Dependencies a caller must declare to use the shared constructs project.
|
|
29
34
|
* Lives here so generators can spread it without importing the generator.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/shared-constructs-constants.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { DeclaredTsDependency } from './declared-dependencies';\nimport type { ITsDepVersion } from './versions';\n\nexport const PACKAGES_DIR = 'packages';\nexport const SHARED_CONSTRUCTS_NAME = 'common-constructs';\nexport const SHARED_CONSTRUCTS_DIR = 'common/constructs';\nexport const SHARED_TERRAFORM_NAME = 'terraform';\nexport const SHARED_TERRAFORM_DIR = 'common/terraform';\nexport const SHARED_SHADCN_NAME = 'common-shadcn';\nexport const SHARED_SHADCN_DIR = 'common/shadcn';\nexport const SHARED_INFRA_CONFIG_NAME = 'common-infra-config';\nexport const SHARED_INFRA_CONFIG_DIR = 'common/infra-config';\nexport const SHARED_SCRIPTS_NAME = 'common-scripts';\nexport const SHARED_SCRIPTS_DIR = 'common/scripts';\n\nexport const DYNAMODB_GENERATOR_IDS = ['ts#dynamodb', 'py#dynamodb'];\n\n/**\n * What a generator records about the infrastructure it generated.\n *\n * Every generator that creates infrastructure records the `iac` it used, so a\n * predicate can tell a CDK project from a Terraform one at upgrade time. Absent\n * when the generator was run with no infrastructure, so its presence doubles as\n * \"infrastructure was generated\" — which is what gates the packages an infra\n * helper adds.\n */\nexport interface IacMetadata {\n readonly iac?: string;\n}\n\n/**\n * Whether infrastructure was generated at all, so the packages an infra helper\n * adds are only claimed where that helper ran.\n *\n * Reads `iac` rather than the generator's own `infra` option: every generator\n * resolves `iac` only on the infra branch, so one recorded field answers both\n * questions and no generator needs a second one.\n */\nexport const generatedInfrastructure = (m: IacMetadata): boolean =>\n m.iac !== undefined;\n\n/**\n * Dependencies a caller must declare to use the shared constructs project.\n * Lives here so generators can spread it without importing the generator.\n *\n * `constructs` and `aws-cdk-lib` are gated on CDK because\n * `sharedConstructsGenerator` creates the TypeScript constructs project on that\n * branch alone — a Terraform workspace gets the shared Terraform project and\n * never receives them.\n */\nexport const SHARED_CONSTRUCTS_DEPENDENCIES = [\n { name: 'constructs', when: (m: IacMetadata) => m.iac === 'cdk' },\n { name: 'aws-cdk-lib', when: (m: IacMetadata) => m.iac === 'cdk' },\n { name: '@types/node' },\n] as const satisfies readonly DeclaredTsDependency<\n ITsDepVersion,\n IacMetadata\n>[];\n"],"names":["PACKAGES_DIR","SHARED_CONSTRUCTS_NAME","SHARED_CONSTRUCTS_DIR","SHARED_TERRAFORM_NAME","SHARED_TERRAFORM_DIR","SHARED_SHADCN_NAME","SHARED_SHADCN_DIR","SHARED_INFRA_CONFIG_NAME","SHARED_INFRA_CONFIG_DIR","SHARED_SCRIPTS_NAME","SHARED_SCRIPTS_DIR","DYNAMODB_GENERATOR_IDS","generatedInfrastructure","m","iac","undefined","SHARED_CONSTRUCTS_DEPENDENCIES","name","when"],"mappings":"AAAA;;;CAGC,GAID,OAAO,MAAMA,eAAe,WAAW;AACvC,OAAO,MAAMC,yBAAyB,oBAAoB;AAC1D,OAAO,MAAMC,wBAAwB,oBAAoB;AACzD,OAAO,MAAMC,wBAAwB,YAAY;AACjD,OAAO,MAAMC,uBAAuB,mBAAmB;AACvD,OAAO,MAAMC,qBAAqB,gBAAgB;AAClD,OAAO,MAAMC,oBAAoB,gBAAgB;AACjD,OAAO,MAAMC,2BAA2B,sBAAsB;AAC9D,OAAO,MAAMC,0BAA0B,sBAAsB;AAC7D,OAAO,MAAMC,sBAAsB,iBAAiB;AACpD,OAAO,MAAMC,qBAAqB,iBAAiB;AAEnD,OAAO,MAAMC,yBAAyB;IAAC;IAAe;CAAc,CAAC;AAerE;;;;;;;CAOC,GACD,OAAO,MAAMC,0BAA0B,CAACC,IACtCA,EAAEC,GAAG,KAAKC,UAAU;AAEtB;;;;;;;;CAQC,GACD,OAAO,
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/utils/shared-constructs-constants.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { DeclaredTsDependency } from './declared-dependencies';\nimport type { ITsDepVersion } from './versions';\n\nexport const PACKAGES_DIR = 'packages';\nexport const SHARED_CONSTRUCTS_NAME = 'common-constructs';\nexport const SHARED_CONSTRUCTS_DIR = 'common/constructs';\nexport const SHARED_TERRAFORM_NAME = 'terraform';\nexport const SHARED_TERRAFORM_DIR = 'common/terraform';\nexport const SHARED_SHADCN_NAME = 'common-shadcn';\nexport const SHARED_SHADCN_DIR = 'common/shadcn';\nexport const SHARED_INFRA_CONFIG_NAME = 'common-infra-config';\nexport const SHARED_INFRA_CONFIG_DIR = 'common/infra-config';\nexport const SHARED_SCRIPTS_NAME = 'common-scripts';\nexport const SHARED_SCRIPTS_DIR = 'common/scripts';\n\nexport const DYNAMODB_GENERATOR_IDS = ['ts#dynamodb', 'py#dynamodb'];\n\n/**\n * What a generator records about the infrastructure it generated.\n *\n * Every generator that creates infrastructure records the `iac` it used, so a\n * predicate can tell a CDK project from a Terraform one at upgrade time. Absent\n * when the generator was run with no infrastructure, so its presence doubles as\n * \"infrastructure was generated\" — which is what gates the packages an infra\n * helper adds.\n */\nexport interface IacMetadata {\n readonly iac?: string;\n}\n\n/**\n * Whether infrastructure was generated at all, so the packages an infra helper\n * adds are only claimed where that helper ran.\n *\n * Reads `iac` rather than the generator's own `infra` option: every generator\n * resolves `iac` only on the infra branch, so one recorded field answers both\n * questions and no generator needs a second one.\n */\nexport const generatedInfrastructure = (m: IacMetadata): boolean =>\n m.iac !== undefined;\n\n/**\n * Whether Terraform infrastructure was generated, for the versions only a `.tf`\n * module pins — a Terraform inline script's `uv run --with` pins, which the CDK\n * branch never writes.\n */\nexport const generatedTerraform = (m: IacMetadata): boolean =>\n m.iac === 'terraform';\n\n/**\n * Dependencies a caller must declare to use the shared constructs project.\n * Lives here so generators can spread it without importing the generator.\n *\n * `constructs` and `aws-cdk-lib` are gated on CDK because\n * `sharedConstructsGenerator` creates the TypeScript constructs project on that\n * branch alone — a Terraform workspace gets the shared Terraform project and\n * never receives them.\n */\nexport const SHARED_CONSTRUCTS_DEPENDENCIES = [\n { name: 'constructs', when: (m: IacMetadata) => m.iac === 'cdk' },\n { name: 'aws-cdk-lib', when: (m: IacMetadata) => m.iac === 'cdk' },\n { name: '@types/node' },\n] as const satisfies readonly DeclaredTsDependency<\n ITsDepVersion,\n IacMetadata\n>[];\n"],"names":["PACKAGES_DIR","SHARED_CONSTRUCTS_NAME","SHARED_CONSTRUCTS_DIR","SHARED_TERRAFORM_NAME","SHARED_TERRAFORM_DIR","SHARED_SHADCN_NAME","SHARED_SHADCN_DIR","SHARED_INFRA_CONFIG_NAME","SHARED_INFRA_CONFIG_DIR","SHARED_SCRIPTS_NAME","SHARED_SCRIPTS_DIR","DYNAMODB_GENERATOR_IDS","generatedInfrastructure","m","iac","undefined","generatedTerraform","SHARED_CONSTRUCTS_DEPENDENCIES","name","when"],"mappings":"AAAA;;;CAGC,GAID,OAAO,MAAMA,eAAe,WAAW;AACvC,OAAO,MAAMC,yBAAyB,oBAAoB;AAC1D,OAAO,MAAMC,wBAAwB,oBAAoB;AACzD,OAAO,MAAMC,wBAAwB,YAAY;AACjD,OAAO,MAAMC,uBAAuB,mBAAmB;AACvD,OAAO,MAAMC,qBAAqB,gBAAgB;AAClD,OAAO,MAAMC,oBAAoB,gBAAgB;AACjD,OAAO,MAAMC,2BAA2B,sBAAsB;AAC9D,OAAO,MAAMC,0BAA0B,sBAAsB;AAC7D,OAAO,MAAMC,sBAAsB,iBAAiB;AACpD,OAAO,MAAMC,qBAAqB,iBAAiB;AAEnD,OAAO,MAAMC,yBAAyB;IAAC;IAAe;CAAc,CAAC;AAerE;;;;;;;CAOC,GACD,OAAO,MAAMC,0BAA0B,CAACC,IACtCA,EAAEC,GAAG,KAAKC,UAAU;AAEtB;;;;CAIC,GACD,OAAO,MAAMC,qBAAqB,CAACH,IACjCA,EAAEC,GAAG,KAAK,YAAY;AAExB;;;;;;;;CAQC,GACD,OAAO,MAAMG,iCAAiC;IAC5C;QAAEC,MAAM;QAAcC,MAAM,CAACN,IAAmBA,EAAEC,GAAG,KAAK;IAAM;IAChE;QAAEI,MAAM;QAAeC,MAAM,CAACN,IAAmBA,EAAEC,GAAG,KAAK;IAAM;IACjE;QAAEI,MAAM;IAAc;CACvB,CAGG"}
|
|
@@ -12,6 +12,15 @@ export declare const PLUGIN_ROOT: string;
|
|
|
12
12
|
export interface OwnedDependencies {
|
|
13
13
|
readonly ts: ReadonlySet<string>;
|
|
14
14
|
readonly py: ReadonlySet<string>;
|
|
15
|
+
/**
|
|
16
|
+
* The same, split by the root of the project that owns it, for scoping a pin
|
|
17
|
+
* embedded in a generated file to the project it sits in. Keyed by project
|
|
18
|
+
* root; read through {@link ownedForFile}.
|
|
19
|
+
*/
|
|
20
|
+
readonly byProject: ReadonlyMap<string, {
|
|
21
|
+
readonly ts: ReadonlySet<string>;
|
|
22
|
+
readonly py: ReadonlySet<string>;
|
|
23
|
+
}>;
|
|
15
24
|
}
|
|
16
25
|
/**
|
|
17
26
|
* One recorded run of a generator, with the metadata it wrote.
|
|
@@ -22,6 +31,8 @@ export interface OwnedDependencies {
|
|
|
22
31
|
export interface GeneratorOccurrence {
|
|
23
32
|
readonly id: string;
|
|
24
33
|
readonly metadata: DependencyMetadata;
|
|
34
|
+
/** Root of the project this ran against, for scoping what it owns to it. */
|
|
35
|
+
readonly projectRoot?: string;
|
|
25
36
|
}
|
|
26
37
|
/**
|
|
27
38
|
* Every recorded run of a generator in this workspace, from the metadata
|
|
@@ -48,3 +59,18 @@ export declare const generatorsRun: (tree: Tree) => ReadonlySet<string>;
|
|
|
48
59
|
* rather than a run — the generators themselves are never invoked.
|
|
49
60
|
*/
|
|
50
61
|
export declare const ownedDependencies: (tree: Tree) => Promise<OwnedDependencies>;
|
|
62
|
+
/**
|
|
63
|
+
* The dependencies owned where a file sits: those of the project it belongs to,
|
|
64
|
+
* or the workspace-wide union for a file in a shared project or under none.
|
|
65
|
+
*
|
|
66
|
+
* Used for the pins embedded in a generated file, so a version is only rewritten
|
|
67
|
+
* where the generator that pins it actually ran: a `Dockerfile` under one
|
|
68
|
+
* project's root is not upgraded because a sibling project owns the package.
|
|
69
|
+
*
|
|
70
|
+
* The longest matching root wins, since a nested project's root is a prefix of
|
|
71
|
+
* nothing else but its own files.
|
|
72
|
+
*/
|
|
73
|
+
export declare const ownedForFile: (owned: OwnedDependencies, filePath: string) => {
|
|
74
|
+
ts: ReadonlySet<string>;
|
|
75
|
+
py: ReadonlySet<string>;
|
|
76
|
+
};
|
|
@@ -6,6 +6,7 @@ import { getProjects } from "@nx/devkit";
|
|
|
6
6
|
import { AWS_NX_PLUGIN_CONFIG_FILE_NAME } from "../config/utils.js";
|
|
7
7
|
import { ownedDependencyEntries } from "../declared-dependencies.js";
|
|
8
8
|
import { buildGeneratorInfoList } from "../generators.js";
|
|
9
|
+
import { PACKAGES_DIR, SHARED_CONSTRUCTS_DIR, SHARED_TERRAFORM_DIR } from "../shared-constructs-constants.js";
|
|
9
10
|
/** Directory holding `generators.json`, which maps ids to their modules. */ export const PLUGIN_ROOT = path.resolve(import.meta.dirname, '..', '..', '..');
|
|
10
11
|
/**
|
|
11
12
|
* Every recorded run of a generator in this workspace, from the metadata
|
|
@@ -29,14 +30,16 @@ import { buildGeneratorInfoList } from "../generators.js";
|
|
|
29
30
|
const { components, ...ownMetadata } = metadata;
|
|
30
31
|
occurrences.push({
|
|
31
32
|
id: metadata.generator,
|
|
32
|
-
metadata: ownMetadata
|
|
33
|
+
metadata: ownMetadata,
|
|
34
|
+
projectRoot: project.root
|
|
33
35
|
});
|
|
34
36
|
}
|
|
35
37
|
for (const component of metadata?.components ?? []){
|
|
36
38
|
if (component.generator) {
|
|
37
39
|
occurrences.push({
|
|
38
40
|
id: component.generator,
|
|
39
|
-
metadata: component
|
|
41
|
+
metadata: component,
|
|
42
|
+
projectRoot: project.root
|
|
40
43
|
});
|
|
41
44
|
}
|
|
42
45
|
}
|
|
@@ -59,6 +62,7 @@ import { buildGeneratorInfoList } from "../generators.js";
|
|
|
59
62
|
const occurrences = generatorOccurrences(tree);
|
|
60
63
|
const ts = new Set();
|
|
61
64
|
const py = new Set();
|
|
65
|
+
const byProject = new Map();
|
|
62
66
|
for (const info of buildGeneratorInfoList(PLUGIN_ROOT)){
|
|
63
67
|
const matching = occurrences.filter((occurrence)=>occurrence.id === info.id);
|
|
64
68
|
if (matching.length === 0) {
|
|
@@ -68,20 +72,64 @@ import { buildGeneratorInfoList } from "../generators.js";
|
|
|
68
72
|
if (!declaration) {
|
|
69
73
|
continue;
|
|
70
74
|
}
|
|
71
|
-
for (const { metadata } of matching){
|
|
75
|
+
for (const { metadata, projectRoot } of matching){
|
|
76
|
+
const scoped = projectRoot ? byProject.get(projectRoot) ?? byProject.set(projectRoot, {
|
|
77
|
+
ts: new Set(),
|
|
78
|
+
py: new Set()
|
|
79
|
+
}).get(projectRoot) : undefined;
|
|
72
80
|
for (const entry of ownedDependencyEntries(declaration.ts, metadata)){
|
|
73
81
|
ts.add(entry.name);
|
|
82
|
+
scoped?.ts.add(entry.name);
|
|
74
83
|
}
|
|
75
84
|
for (const entry of ownedDependencyEntries(declaration.py, metadata)){
|
|
76
85
|
py.add(entry.name);
|
|
86
|
+
scoped?.py.add(entry.name);
|
|
77
87
|
}
|
|
78
88
|
}
|
|
79
89
|
}
|
|
80
90
|
return {
|
|
81
91
|
ts,
|
|
82
|
-
py
|
|
92
|
+
py,
|
|
93
|
+
byProject
|
|
83
94
|
};
|
|
84
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* Roots of the projects every generator contributes into, rather than one
|
|
98
|
+
* generator owning outright.
|
|
99
|
+
*
|
|
100
|
+
* `sharedConstructsGenerator` creates these and each infra generator writes its
|
|
101
|
+
* own module into them — the Terraform modules carrying the `uv run --with` pins
|
|
102
|
+
* come from the agent-core, api, identity and website helpers alike. Both are
|
|
103
|
+
* registered projects, so scoping a file here to the generator that created the
|
|
104
|
+
* project would strand every pin the others put there.
|
|
105
|
+
*/ const SHARED_PROJECT_ROOTS = [
|
|
106
|
+
`${PACKAGES_DIR}/${SHARED_CONSTRUCTS_DIR}`,
|
|
107
|
+
`${PACKAGES_DIR}/${SHARED_TERRAFORM_DIR}`
|
|
108
|
+
];
|
|
109
|
+
/**
|
|
110
|
+
* The dependencies owned where a file sits: those of the project it belongs to,
|
|
111
|
+
* or the workspace-wide union for a file in a shared project or under none.
|
|
112
|
+
*
|
|
113
|
+
* Used for the pins embedded in a generated file, so a version is only rewritten
|
|
114
|
+
* where the generator that pins it actually ran: a `Dockerfile` under one
|
|
115
|
+
* project's root is not upgraded because a sibling project owns the package.
|
|
116
|
+
*
|
|
117
|
+
* The longest matching root wins, since a nested project's root is a prefix of
|
|
118
|
+
* nothing else but its own files.
|
|
119
|
+
*/ export const ownedForFile = (owned, filePath)=>{
|
|
120
|
+
if (SHARED_PROJECT_ROOTS.some((root)=>filePath === root || filePath.startsWith(`${root}/`))) {
|
|
121
|
+
return owned;
|
|
122
|
+
}
|
|
123
|
+
let best;
|
|
124
|
+
let bestLength = -1;
|
|
125
|
+
for (const [root, scoped] of owned.byProject){
|
|
126
|
+
if ((filePath === root || filePath.startsWith(`${root}/`)) && root.length > bestLength) {
|
|
127
|
+
best = scoped;
|
|
128
|
+
bestLength = root.length;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return best ?? owned;
|
|
132
|
+
};
|
|
85
133
|
/**
|
|
86
134
|
* A generator's `DEPENDENCIES`, or undefined when it declares none.
|
|
87
135
|
* A generator that fails to load must not fail the upgrade, so its dependencies
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/version-upgrade-migration/owned-dependencies.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport * as path from 'node:path';\nimport { getProjects, type Tree } from '@nx/devkit';\nimport { AWS_NX_PLUGIN_CONFIG_FILE_NAME } from '../config/utils';\nimport {\n type DependencyDeclaration,\n type DependencyMetadata,\n ownedDependencyEntries,\n} from '../declared-dependencies';\nimport { buildGeneratorInfoList } from '../generators';\n\n/** Directory holding `generators.json`, which maps ids to their modules. */\nexport const PLUGIN_ROOT = path.resolve(import.meta.dirname, '..', '..', '..');\n\n/**\n * Which vended dependencies this workspace's generators are responsible for.\n *\n * Only these are synced, so a package the user added themselves keeps the version\n * they chose. Ownership is derived from the generators the workspace has run and\n * the dependencies each declares — nothing extra is recorded in the workspace.\n */\nexport interface OwnedDependencies {\n readonly ts: ReadonlySet<string>;\n readonly py: ReadonlySet<string>;\n}\n\n/**\n * One recorded run of a generator, with the metadata it wrote.\n *\n * The metadata carries the values the generator's dependency conditions read, so\n * a declaration filters down to the branch this occurrence actually took.\n */\nexport interface GeneratorOccurrence {\n readonly id: string;\n readonly metadata: DependencyMetadata;\n}\n\n/**\n * Every recorded run of a generator in this workspace, from the metadata\n * generators record on the projects (and components) they create.\n *\n * A generator appears once per project or component it created, since each may\n * have been run with different options.\n *\n * `init` creates no project, so its config file stands in for it.\n */\nexport const generatorOccurrences = (\n tree: Tree,\n): readonly GeneratorOccurrence[] => {\n const occurrences: GeneratorOccurrence[] = [];\n if (tree.exists(AWS_NX_PLUGIN_CONFIG_FILE_NAME)) {\n occurrences.push({ id: 'init', metadata: {} });\n }\n for (const [, project] of getProjects(tree)) {\n const metadata = project.metadata as\n | {\n generator?: string;\n components?: ({ generator?: string } & DependencyMetadata)[];\n }\n | undefined;\n if (metadata?.generator) {\n const { components, ...ownMetadata } = metadata;\n occurrences.push({ id: metadata.generator, metadata: ownMetadata });\n }\n for (const component of metadata?.components ?? []) {\n if (component.generator) {\n occurrences.push({ id: component.generator, metadata: component });\n }\n }\n }\n return occurrences;\n};\n\n/** Generator ids this workspace has run. */\nexport const generatorsRun = (tree: Tree): ReadonlySet<string> =>\n new Set(generatorOccurrences(tree).map((occurrence) => occurrence.id));\n\n/**\n * Union of the dependencies declared by the generators this workspace has run,\n * narrowed per occurrence to those whose conditions its recorded metadata\n * satisfies — a project generated with one protocol does not own another's\n * packages.\n *\n * A `versionOnly` entry is owned like any other: it is declared precisely so the\n * sync keeps its pinned version current wherever the workspace already holds it.\n *\n * Each generator module exports its declaration, so reading one is an import\n * rather than a run — the generators themselves are never invoked.\n */\nexport const ownedDependencies = async (\n tree: Tree,\n): Promise<OwnedDependencies> => {\n const occurrences = generatorOccurrences(tree);\n const ts = new Set<string>();\n const py = new Set<string>();\n\n for (const info of buildGeneratorInfoList(PLUGIN_ROOT)) {\n const matching = occurrences.filter(\n (occurrence) => occurrence.id === info.id,\n );\n if (matching.length === 0) {\n continue;\n }\n const declaration = await readDeclaration(info.resolvedFactoryPath);\n if (!declaration) {\n continue;\n }\n for (const { metadata } of matching) {\n for (const entry of ownedDependencyEntries(declaration.ts, metadata)) {\n ts.add(entry.name as string);\n }\n for (const entry of ownedDependencyEntries(declaration.py, metadata)) {\n py.add(entry.name as string);\n }\n }\n }\n\n return { ts, py };\n};\n\n/**\n * A generator's `DEPENDENCIES`, or undefined when it declares none.\n * A generator that fails to load must not fail the upgrade, so its dependencies\n * are treated as unowned and left as they are.\n */\nconst readDeclaration = async (\n factoryPath: string,\n): Promise<DependencyDeclaration | undefined> => {\n try {\n const module = await import(`${factoryPath}.js`);\n return module.DEPENDENCIES;\n } catch {\n return undefined;\n }\n};\n"],"names":["path","getProjects","AWS_NX_PLUGIN_CONFIG_FILE_NAME","ownedDependencyEntries","buildGeneratorInfoList","PLUGIN_ROOT","resolve","dirname","generatorOccurrences","tree","occurrences","exists","push","id","metadata","project","generator","components","ownMetadata","component","generatorsRun","Set","map","occurrence","ownedDependencies","ts","py","info","matching","filter","length","declaration","readDeclaration","resolvedFactoryPath","entry","add","name","factoryPath","module","DEPENDENCIES","undefined"],"mappings":"AAAA;;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uBC,aAAc;QACtD,MAAMuB,WAAWlB,YAAYmB,MAAM,CACjC,CAACN,aAAeA,WAAWV,EAAE,KAAKc,KAAKd,EAAE;QAE3C,IAAIe,SAASE,MAAM,KAAK,GAAG;YACzB;QACF;QACA,MAAMC,cAAc,MAAMC,gBAAgBL,KAAKM,mBAAmB;QAClE,IAAI,CAACF,aAAa;YAChB;QACF;QACA,KAAK,MAAM,EAAEjB,QAAQ,EAAE,IAAIc,SAAU;YACnC,KAAK,MAAMM,SAAS/B,uBAAuB4B,YAAYN,EAAE,EAAEX,UAAW;gBACpEW,GAAGU,GAAG,CAACD,MAAME,IAAI;YACnB;YACA,KAAK,MAAMF,SAAS/B,uBAAuB4B,YAAYL,EAAE,EAAEZ,UAAW;gBACpEY,GAAGS,GAAG,CAACD,MAAME,IAAI;YACnB;QACF;IACF;IAEA,OAAO;QAAEX;QAAIC;IAAG;AAClB,EAAE;AAEF;;;;CAIC,GACD,MAAMM,kBAAkB,OACtBK;IAEA,IAAI;QACF,MAAMC,SAAS,MAAM,MAAM,CAAC,GAAGD,YAAY,GAAG,CAAC;QAC/C,OAAOC,OAAOC,YAAY;IAC5B,EAAE,OAAM;QACN,OAAOC;IACT;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/version-upgrade-migration/owned-dependencies.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport * as path from 'node:path';\nimport { getProjects, type Tree } from '@nx/devkit';\nimport { AWS_NX_PLUGIN_CONFIG_FILE_NAME } from '../config/utils';\nimport {\n type DependencyDeclaration,\n type DependencyMetadata,\n ownedDependencyEntries,\n} from '../declared-dependencies';\nimport { buildGeneratorInfoList } from '../generators';\nimport {\n PACKAGES_DIR,\n SHARED_CONSTRUCTS_DIR,\n SHARED_TERRAFORM_DIR,\n} from '../shared-constructs-constants';\n\n/** Directory holding `generators.json`, which maps ids to their modules. */\nexport const PLUGIN_ROOT = path.resolve(import.meta.dirname, '..', '..', '..');\n\n/**\n * Which vended dependencies this workspace's generators are responsible for.\n *\n * Only these are synced, so a package the user added themselves keeps the version\n * they chose. Ownership is derived from the generators the workspace has run and\n * the dependencies each declares — nothing extra is recorded in the workspace.\n */\nexport interface OwnedDependencies {\n readonly ts: ReadonlySet<string>;\n readonly py: ReadonlySet<string>;\n /**\n * The same, split by the root of the project that owns it, for scoping a pin\n * embedded in a generated file to the project it sits in. Keyed by project\n * root; read through {@link ownedForFile}.\n */\n readonly byProject: ReadonlyMap<\n string,\n { readonly ts: ReadonlySet<string>; readonly py: ReadonlySet<string> }\n >;\n}\n\n/**\n * One recorded run of a generator, with the metadata it wrote.\n *\n * The metadata carries the values the generator's dependency conditions read, so\n * a declaration filters down to the branch this occurrence actually took.\n */\nexport interface GeneratorOccurrence {\n readonly id: string;\n readonly metadata: DependencyMetadata;\n /** Root of the project this ran against, for scoping what it owns to it. */\n readonly projectRoot?: string;\n}\n\n/**\n * Every recorded run of a generator in this workspace, from the metadata\n * generators record on the projects (and components) they create.\n *\n * A generator appears once per project or component it created, since each may\n * have been run with different options.\n *\n * `init` creates no project, so its config file stands in for it.\n */\nexport const generatorOccurrences = (\n tree: Tree,\n): readonly GeneratorOccurrence[] => {\n const occurrences: GeneratorOccurrence[] = [];\n if (tree.exists(AWS_NX_PLUGIN_CONFIG_FILE_NAME)) {\n occurrences.push({ id: 'init', metadata: {} });\n }\n for (const [, project] of getProjects(tree)) {\n const metadata = project.metadata as\n | {\n generator?: string;\n components?: ({ generator?: string } & DependencyMetadata)[];\n }\n | undefined;\n if (metadata?.generator) {\n const { components, ...ownMetadata } = metadata;\n occurrences.push({\n id: metadata.generator,\n metadata: ownMetadata,\n projectRoot: project.root,\n });\n }\n for (const component of metadata?.components ?? []) {\n if (component.generator) {\n occurrences.push({\n id: component.generator,\n metadata: component,\n projectRoot: project.root,\n });\n }\n }\n }\n return occurrences;\n};\n\n/** Generator ids this workspace has run. */\nexport const generatorsRun = (tree: Tree): ReadonlySet<string> =>\n new Set(generatorOccurrences(tree).map((occurrence) => occurrence.id));\n\n/**\n * Union of the dependencies declared by the generators this workspace has run,\n * narrowed per occurrence to those whose conditions its recorded metadata\n * satisfies — a project generated with one protocol does not own another's\n * packages.\n *\n * A `versionOnly` entry is owned like any other: it is declared precisely so the\n * sync keeps its pinned version current wherever the workspace already holds it.\n *\n * Each generator module exports its declaration, so reading one is an import\n * rather than a run — the generators themselves are never invoked.\n */\nexport const ownedDependencies = async (\n tree: Tree,\n): Promise<OwnedDependencies> => {\n const occurrences = generatorOccurrences(tree);\n const ts = new Set<string>();\n const py = new Set<string>();\n const byProject = new Map<string, { ts: Set<string>; py: Set<string> }>();\n\n for (const info of buildGeneratorInfoList(PLUGIN_ROOT)) {\n const matching = occurrences.filter(\n (occurrence) => occurrence.id === info.id,\n );\n if (matching.length === 0) {\n continue;\n }\n const declaration = await readDeclaration(info.resolvedFactoryPath);\n if (!declaration) {\n continue;\n }\n for (const { metadata, projectRoot } of matching) {\n const scoped = projectRoot\n ? (byProject.get(projectRoot) ??\n byProject\n .set(projectRoot, { ts: new Set(), py: new Set() })\n .get(projectRoot)!)\n : undefined;\n for (const entry of ownedDependencyEntries(declaration.ts, metadata)) {\n ts.add(entry.name as string);\n scoped?.ts.add(entry.name as string);\n }\n for (const entry of ownedDependencyEntries(declaration.py, metadata)) {\n py.add(entry.name as string);\n scoped?.py.add(entry.name as string);\n }\n }\n }\n\n return { ts, py, byProject };\n};\n\n/**\n * Roots of the projects every generator contributes into, rather than one\n * generator owning outright.\n *\n * `sharedConstructsGenerator` creates these and each infra generator writes its\n * own module into them — the Terraform modules carrying the `uv run --with` pins\n * come from the agent-core, api, identity and website helpers alike. Both are\n * registered projects, so scoping a file here to the generator that created the\n * project would strand every pin the others put there.\n */\nconst SHARED_PROJECT_ROOTS = [\n `${PACKAGES_DIR}/${SHARED_CONSTRUCTS_DIR}`,\n `${PACKAGES_DIR}/${SHARED_TERRAFORM_DIR}`,\n];\n\n/**\n * The dependencies owned where a file sits: those of the project it belongs to,\n * or the workspace-wide union for a file in a shared project or under none.\n *\n * Used for the pins embedded in a generated file, so a version is only rewritten\n * where the generator that pins it actually ran: a `Dockerfile` under one\n * project's root is not upgraded because a sibling project owns the package.\n *\n * The longest matching root wins, since a nested project's root is a prefix of\n * nothing else but its own files.\n */\nexport const ownedForFile = (\n owned: OwnedDependencies,\n filePath: string,\n): { ts: ReadonlySet<string>; py: ReadonlySet<string> } => {\n if (\n SHARED_PROJECT_ROOTS.some(\n (root) => filePath === root || filePath.startsWith(`${root}/`),\n )\n ) {\n return owned;\n }\n let best: { ts: ReadonlySet<string>; py: ReadonlySet<string> } | undefined;\n let bestLength = -1;\n for (const [root, scoped] of owned.byProject) {\n if (\n (filePath === root || filePath.startsWith(`${root}/`)) &&\n root.length > bestLength\n ) {\n best = scoped;\n bestLength = root.length;\n }\n }\n return best ?? owned;\n};\n\n/**\n * A generator's `DEPENDENCIES`, or undefined when it declares none.\n * A generator that fails to load must not fail the upgrade, so its dependencies\n * are treated as unowned and left as they are.\n */\nconst readDeclaration = async (\n factoryPath: string,\n): Promise<DependencyDeclaration | undefined> => {\n try {\n const module = await import(`${factoryPath}.js`);\n return module.DEPENDENCIES;\n } catch {\n return undefined;\n }\n};\n"],"names":["path","getProjects","AWS_NX_PLUGIN_CONFIG_FILE_NAME","ownedDependencyEntries","buildGeneratorInfoList","PACKAGES_DIR","SHARED_CONSTRUCTS_DIR","SHARED_TERRAFORM_DIR","PLUGIN_ROOT","resolve","dirname","generatorOccurrences","tree","occurrences","exists","push","id","metadata","project","generator","components","ownMetadata","projectRoot","root","component","generatorsRun","Set","map","occurrence","ownedDependencies","ts","py","byProject","Map","info","matching","filter","length","declaration","readDeclaration","resolvedFactoryPath","scoped","get","set","undefined","entry","add","name","SHARED_PROJECT_ROOTS","ownedForFile","owned","filePath","some","startsWith","best","bestLength","factoryPath","module","DEPENDENCIES"],"mappings":"AAAA;;;CAG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AQ4B,SAASE,UAAU,CAAC,GAAG9B,KAAK,CAAC,CAAC,IAE/D;QACA,OAAO2B;IACT;IACA,IAAII;IACJ,IAAIC,aAAa,CAAC;IAClB,KAAK,MAAM,CAAChC,MAAMkB,OAAO,IAAIS,MAAMlB,SAAS,CAAE;QAC5C,IACE,AAACmB,CAAAA,aAAa5B,QAAQ4B,SAASE,UAAU,CAAC,GAAG9B,KAAK,CAAC,CAAC,CAAA,KACpDA,KAAKc,MAAM,GAAGkB,YACd;YACAD,OAAOb;YACPc,aAAahC,KAAKc,MAAM;QAC1B;IACF;IACA,OAAOiB,QAAQJ;AACjB,EAAE;AAEF;;;;CAIC,GACD,MAAMX,kBAAkB,OACtBiB;IAEA,IAAI;QACF,MAAMC,SAAS,MAAM,MAAM,CAAC,GAAGD,YAAY,GAAG,CAAC;QAC/C,OAAOC,OAAOC,YAAY;IAC5B,EAAE,OAAM;QACN,OAAOd;IACT;AACF"}
|
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { type Tree } from '@nx/devkit';
|
|
6
6
|
/**
|
|
7
|
-
* Register the nx bump a version update needs, in `
|
|
8
|
-
* when an nx package actually moved.
|
|
7
|
+
* Register the nx bump a version update needs, in `packageJsonUpdates.json`. Call
|
|
8
|
+
* only when an nx package actually moved.
|
|
9
9
|
*
|
|
10
|
+
* The bumps live in their own committed file, assembled into `migrations.json`
|
|
11
|
+
* at build time, so this weekly-bot edit never conflicts with a migration PR.
|
|
10
12
|
* The version sync migration itself is a committed `everyMigration` entry, so
|
|
11
13
|
* only the nx packages need registering per update: they go through
|
|
12
14
|
* `packageJsonUpdates` rather than a migration (see `nx-package-updates.ts`).
|
|
@@ -18,6 +20,10 @@ import { type Tree } from '@nx/devkit';
|
|
|
18
20
|
*
|
|
19
21
|
* Idempotent: re-running before a release replaces the pending entry with itself.
|
|
20
22
|
*
|
|
23
|
+
* @param nxVersion nx version being moved to. The update script rewrites
|
|
24
|
+
* `versions.ts` on the tree, which cannot change the `NX_VERSION` this process
|
|
25
|
+
* imported at load — so the caller passes the version it just wrote, or the
|
|
26
|
+
* entry would record the one being replaced.
|
|
21
27
|
* @returns paths written, for the update report
|
|
22
28
|
*/
|
|
23
|
-
export declare const registerNxPackageUpdates: (tree: Tree) => string[];
|
|
29
|
+
export declare const registerNxPackageUpdates: (tree: Tree, nxVersion?: string) => string[];
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/ import {
|
|
4
|
+
*/ import { writeJson } from "@nx/devkit";
|
|
5
5
|
import { LATEST_MIGRATIONS_DIR } from "../migration-versions.js";
|
|
6
6
|
import { nxPackageJsonUpdates } from "./nx-package-updates.js";
|
|
7
|
-
const
|
|
7
|
+
const PACKAGE_JSON_UPDATES_PATH = 'packages/nx-plugin/packageJsonUpdates.json';
|
|
8
8
|
/**
|
|
9
|
-
* Register the nx bump a version update needs, in `
|
|
10
|
-
* when an nx package actually moved.
|
|
9
|
+
* Register the nx bump a version update needs, in `packageJsonUpdates.json`. Call
|
|
10
|
+
* only when an nx package actually moved.
|
|
11
11
|
*
|
|
12
|
+
* The bumps live in their own committed file, assembled into `migrations.json`
|
|
13
|
+
* at build time, so this weekly-bot edit never conflicts with a migration PR.
|
|
12
14
|
* The version sync migration itself is a committed `everyMigration` entry, so
|
|
13
15
|
* only the nx packages need registering per update: they go through
|
|
14
16
|
* `packageJsonUpdates` rather than a migration (see `nx-package-updates.ts`).
|
|
@@ -20,18 +22,20 @@ const MIGRATIONS_JSON_PATH = 'packages/nx-plugin/migrations.json';
|
|
|
20
22
|
*
|
|
21
23
|
* Idempotent: re-running before a release replaces the pending entry with itself.
|
|
22
24
|
*
|
|
25
|
+
* @param nxVersion nx version being moved to. The update script rewrites
|
|
26
|
+
* `versions.ts` on the tree, which cannot change the `NX_VERSION` this process
|
|
27
|
+
* imported at load — so the caller passes the version it just wrote, or the
|
|
28
|
+
* entry would record the one being replaced.
|
|
23
29
|
* @returns paths written, for the update report
|
|
24
|
-
*/ export const registerNxPackageUpdates = (tree)=>{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
}));
|
|
30
|
+
*/ export const registerNxPackageUpdates = (tree, nxVersion)=>{
|
|
31
|
+
const existing = tree.exists(PACKAGE_JSON_UPDATES_PATH) ? JSON.parse(tree.read(PACKAGE_JSON_UPDATES_PATH, 'utf-8')) : {};
|
|
32
|
+
writeJson(tree, PACKAGE_JSON_UPDATES_PATH, {
|
|
33
|
+
// Recorded under `latest` until stamping resolves the version it ships with.
|
|
34
|
+
...Object.fromEntries(Object.entries(existing).filter(([, entry])=>entry.version !== LATEST_MIGRATIONS_DIR)),
|
|
35
|
+
...nxPackageJsonUpdates(LATEST_MIGRATIONS_DIR, nxVersion)
|
|
36
|
+
});
|
|
33
37
|
return [
|
|
34
|
-
|
|
38
|
+
PACKAGE_JSON_UPDATES_PATH
|
|
35
39
|
];
|
|
36
40
|
};
|
|
37
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/version-upgrade-migration/register.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { type Tree,
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/version-upgrade-migration/register.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { type Tree, writeJson } from '@nx/devkit';\nimport { LATEST_MIGRATIONS_DIR } from '../migration-versions';\nimport {\n nxPackageJsonUpdates,\n type PackageJsonUpdates,\n} from './nx-package-updates';\n\nconst PACKAGE_JSON_UPDATES_PATH = 'packages/nx-plugin/packageJsonUpdates.json';\n\n/**\n * Register the nx bump a version update needs, in `packageJsonUpdates.json`. Call\n * only when an nx package actually moved.\n *\n * The bumps live in their own committed file, assembled into `migrations.json`\n * at build time, so this weekly-bot edit never conflicts with a migration PR.\n * The version sync migration itself is a committed `everyMigration` entry, so\n * only the nx packages need registering per update: they go through\n * `packageJsonUpdates` rather than a migration (see `nx-package-updates.ts`).\n *\n * A bump already dated by a release stays — a workspace several releases behind\n * needs each hop in turn. One still waiting for a release is dropped: this bump\n * supersedes it, and both would otherwise ship under the same version, leaving\n * which nx a workspace lands on down to the order nx happens to apply them in.\n *\n * Idempotent: re-running before a release replaces the pending entry with itself.\n *\n * @param nxVersion nx version being moved to. The update script rewrites\n * `versions.ts` on the tree, which cannot change the `NX_VERSION` this process\n * imported at load — so the caller passes the version it just wrote, or the\n * entry would record the one being replaced.\n * @returns paths written, for the update report\n */\nexport const registerNxPackageUpdates = (\n tree: Tree,\n nxVersion?: string,\n): string[] => {\n const existing: PackageJsonUpdates = tree.exists(PACKAGE_JSON_UPDATES_PATH)\n ? JSON.parse(tree.read(PACKAGE_JSON_UPDATES_PATH, 'utf-8'))\n : {};\n\n writeJson(tree, PACKAGE_JSON_UPDATES_PATH, {\n // Recorded under `latest` until stamping resolves the version it ships with.\n ...Object.fromEntries(\n Object.entries(existing).filter(\n ([, entry]) => entry.version !== LATEST_MIGRATIONS_DIR,\n ),\n ),\n ...nxPackageJsonUpdates(LATEST_MIGRATIONS_DIR, nxVersion),\n });\n\n return [PACKAGE_JSON_UPDATES_PATH];\n};\n"],"names":["writeJson","LATEST_MIGRATIONS_DIR","nxPackageJsonUpdates","PACKAGE_JSON_UPDATES_PATH","registerNxPackageUpdates","tree","nxVersion","existing","exists","JSON","parse","read","Object","fromEntries","entries","filter","entry","version"],"mappings":"AAAA;;;CAGC,GACD,SAAoBA,SAAS,QAAQ,aAAa;AAClD,SAASC,qBAAqB,QAAQ,2BAAwB;AAC9D,SACEC,oBAAoB,QAEf,0BAAuB;AAE9B,MAAMC,4BAA4B;AAElC;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,MAAMC,2BAA2B,CACtCC,MACAC;IAEA,MAAMC,WAA+BF,KAAKG,MAAM,CAACL,6BAC7CM,KAAKC,KAAK,CAACL,KAAKM,IAAI,CAACR,2BAA2B,YAChD,CAAC;IAELH,UAAUK,MAAMF,2BAA2B;QACzC,6EAA6E;QAC7E,GAAGS,OAAOC,WAAW,CACnBD,OAAOE,OAAO,CAACP,UAAUQ,MAAM,CAC7B,CAAC,GAAGC,MAAM,GAAKA,MAAMC,OAAO,KAAKhB,uBAEpC;QACD,GAAGC,qBAAqBD,uBAAuBK,UAAU;IAC3D;IAEA,OAAO;QAACH;KAA0B;AACpC,EAAE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { Tree } from '@nx/devkit';
|
|
6
|
+
import { type OwnedDependencies } from './owned-dependencies';
|
|
7
|
+
/**
|
|
8
|
+
* Whether a file is a Dockerfile: exactly `Dockerfile`, or the `<name>.Dockerfile`
|
|
9
|
+
* form the smithy templates vend as `build.Dockerfile`.
|
|
10
|
+
*
|
|
11
|
+
* Deliberately exact rather than a prefix match, which would also claim a
|
|
12
|
+
* `Dockerfile.bak` or a `Dockerfile.md` the user keeps beside a real one.
|
|
13
|
+
*/
|
|
14
|
+
export declare const isDockerfile: (filePath: string) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Sync the vended versions baked into generated file bodies: `Dockerfile` pins,
|
|
17
|
+
* the Python pins in Terraform inline scripts, and the tooling images
|
|
18
|
+
* `project.json` target commands run.
|
|
19
|
+
*
|
|
20
|
+
* Reports only the files left for the user: a pin that takes effect the next time
|
|
21
|
+
* the thing holding it runs needs no follow-up, but one this skipped for holding
|
|
22
|
+
* more occurrences than it will rewrite at once does.
|
|
23
|
+
*
|
|
24
|
+
* @returns paths whose pins were left as they were
|
|
25
|
+
*/
|
|
26
|
+
export declare const syncEmbeddedVersions: (tree: Tree, owned: OwnedDependencies) => Promise<string[]>;
|