@aws/nx-plugin 1.0.0-rc.55 → 1.0.0-rc.57

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.
Files changed (81) hide show
  1. package/migrations.json +13 -3
  2. package/package.json +1 -1
  3. package/src/migrations/latest/dynamodb-local-remove-optimize-flag/migration.d.ts +6 -0
  4. package/src/migrations/latest/dynamodb-local-remove-optimize-flag/migration.js +89 -0
  5. package/src/migrations/latest/dynamodb-local-remove-optimize-flag/migration.js.map +1 -0
  6. package/src/migrations/latest/modernize-function-props-cast/migration.js +0 -1
  7. package/src/migrations/latest/modernize-function-props-cast/migration.js.map +1 -1
  8. package/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.js +0 -1
  9. package/src/migrations/latest/order-access-log-delivery-after-bucket-policy/migration.js.map +1 -1
  10. package/src/migrations/latest/restrict-cors-to-custom-domains/migration.js +0 -2
  11. package/src/migrations/latest/restrict-cors-to-custom-domains/migration.js.map +1 -1
  12. package/src/migrations/latest/terraform-bootstrap-adopt-existing-bucket/migration.js +0 -1
  13. package/src/migrations/latest/terraform-bootstrap-adopt-existing-bucket/migration.js.map +1 -1
  14. package/src/migrations/latest/ts-agent-session-management-support/migration.d.ts +6 -0
  15. package/src/migrations/latest/ts-agent-session-management-support/migration.js +449 -0
  16. package/src/migrations/latest/ts-agent-session-management-support/migration.js.map +1 -0
  17. package/src/migrations/latest/user-identity-waf-allow-localhost-callback/migration.js +0 -2
  18. package/src/migrations/latest/user-identity-waf-allow-localhost-callback/migration.js.map +1 -1
  19. package/src/py/agent/__snapshots__/generator.constructs.spec.ts.snap +3 -1
  20. package/src/py/agent/__snapshots__/generator.frameworks.spec.ts.snap +12 -12
  21. package/src/py/agent/__snapshots__/generator.protocols.spec.ts.snap +1 -1
  22. package/src/py/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +2 -1
  23. package/src/py/agent/a2a-connection/files/agent-connection/app/__targetAgentSnakeCase___client_strands.py.template +2 -1
  24. package/src/py/agent/a2a-connection/files/langchain/agent-connection/app/__targetAgentSnakeCase___client_langchain.py.template +2 -1
  25. package/src/py/agent/generator.js +4 -0
  26. package/src/py/agent/generator.js.map +1 -1
  27. package/src/py/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +2 -1
  28. package/src/py/agent/mcp-connection/files/agent-connection/app/__mcpServerSnakeCase___client_strands.py.template +2 -1
  29. package/src/py/agent/mcp-connection/files/langchain/agent-connection/app/__mcpServerSnakeCase___client_langchain.py.template +2 -1
  30. package/src/py/agent/react-connection/__snapshots__/generator.spec.ts.snap +6 -0
  31. package/src/py/agent/schema.d.js.map +1 -1
  32. package/src/py/agent/schema.d.ts +3 -0
  33. package/src/py/agent/schema.json +8 -0
  34. package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +0 -2
  35. package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +4 -2
  36. package/src/ts/agent/__snapshots__/generator.spec.ts.snap +663 -19
  37. package/src/ts/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +2 -1
  38. package/src/ts/agent/a2a-connection/files/agent-connection/app/__targetAgentKebabCase__-client-strands.ts.template +1 -1
  39. package/src/ts/agent/files/ag-ui/index.ts.template +10 -1
  40. package/src/ts/agent/files/common/agent.ts.template +11 -3
  41. package/src/ts/agent/files/common/session.ts.template +43 -0
  42. package/src/ts/agent/gateway-connection/__snapshots__/generator.spec.ts.snap +1 -0
  43. package/src/ts/agent/generator.d.ts +4 -0
  44. package/src/ts/agent/generator.js +21 -0
  45. package/src/ts/agent/generator.js.map +1 -1
  46. package/src/ts/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +2 -1
  47. package/src/ts/agent/mcp-connection/files/agent-connection/app/__mcpServerKebabCase__-client-strands.ts.template +2 -1
  48. package/src/ts/agent/react-connection/__snapshots__/generator.spec.ts.snap +8 -4
  49. package/src/ts/agent/react-connection/files/src/components/__agentNameClassName__AgentClientProvider.tsx.template +2 -1
  50. package/src/ts/agent/schema.d.js.map +1 -1
  51. package/src/ts/agent/schema.d.ts +3 -0
  52. package/src/ts/agent/schema.json +8 -0
  53. package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +0 -2
  54. package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +4 -2
  55. package/src/ts/nx-migration/files/migration.ts.template +4 -0
  56. package/src/utils/agent-chat/files/common/agentcore.ts.template +2 -2
  57. package/src/utils/agent-connection/agent-connection.js +4 -0
  58. package/src/utils/agent-connection/agent-connection.js.map +1 -1
  59. package/src/utils/agent-connection/files/core-runtime-config/runtime-config.ts.template +11 -1
  60. package/src/utils/agent-connection/files/core-strands/base/model-errors-strands.ts.template +26 -15
  61. package/src/utils/agent-connection/files/core-strands/base/tool-errors-strands.ts.template +23 -16
  62. package/src/utils/agent-connection/files/py-core-runtime-config/runtime_config.py.template +4 -3
  63. package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +4 -0
  64. package/src/utils/agent-core-constructs/agent-core-constructs.js +7 -1
  65. package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
  66. package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +131 -3
  67. package/src/utils/agent-core-constructs/files/terraform/app/agent-core/__nameKebabCase__/__nameKebabCase__.tf.template +180 -1
  68. package/src/utils/ast.d.ts +5 -0
  69. package/src/utils/ast.js +25 -0
  70. package/src/utils/ast.js.map +1 -1
  71. package/src/utils/connection/open-api/files/components/__apiNameClassName__Provider.tsx.template +2 -0
  72. package/src/utils/files/common/scripts/src/dynamodb/start-container.ts.template +0 -1
  73. package/src/utils/migration-versions.d.ts +15 -10
  74. package/src/utils/migration-versions.js +48 -36
  75. package/src/utils/migration-versions.js.map +1 -1
  76. package/src/utils/version-upgrade-migration/nx-package-updates.d.ts +18 -8
  77. package/src/utils/version-upgrade-migration/nx-package-updates.js +19 -11
  78. package/src/utils/version-upgrade-migration/nx-package-updates.js.map +1 -1
  79. package/src/utils/version-upgrade-migration/register.d.ts +6 -1
  80. package/src/utils/version-upgrade-migration/register.js +8 -3
  81. package/src/utils/version-upgrade-migration/register.js.map +1 -1
@@ -5,27 +5,40 @@
5
5
  /** Ascending semver comparator for `Array.prototype.sort`. */ export const compareVersions = compare;
6
6
  /** Whether a string is an exact semver version. */ export const isValidVersion = (version)=>valid(version) !== null;
7
7
  /**
8
- * Map of migration key -> version of the earliest release that registers it,
9
- * resolved only for the entries still missing a `version` (one already recorded
10
- * in source wins, so its history doesn't need reading). A migration that hasn't
11
- * been released is absent.
8
+ * Map of entry key -> version of the earliest release that registers it, across
9
+ * both `generators` and `packageJsonUpdates`. Resolved only for the entries still
10
+ * missing a version (one already recorded in source wins, so its history doesn't
11
+ * need reading). An entry that hasn't been released is absent.
12
12
  *
13
13
  * Walks releases newest first and stops as soon as every entry is resolved: an
14
14
  * entry that has disappeared from a release's `migrations.json` was first
15
15
  * registered by the release after it, which is the one that shipped it.
16
16
  *
17
+ * Both sections resolve the same way and share the walk, so the release doesn't
18
+ * read tag history twice. Keys can't collide: a migration is keyed by its own
19
+ * name, an nx bump by the nx version it moves to.
20
+ *
17
21
  * @param migrations parsed source migrations.json
18
22
  * @param versions released versions in descending semver order
19
23
  * @param readReleasedMigrations reads the `migrations.json` published by a given
20
24
  * version, or undefined if it predates the manifest
21
25
  */ export const readShippedMigrationVersions = (migrations, versions, readReleasedMigrations)=>{
22
26
  const shippedVersions = {};
23
- let unresolved = Object.entries(migrations.generators ?? {}).filter(([, entry])=>!entry.version).map(([key])=>key);
27
+ // A `packageJsonUpdates` entry records `latest` rather than omitting its
28
+ // version, since nx requires the field.
29
+ let unresolved = [
30
+ ...Object.entries(migrations.generators ?? {}).filter(([, entry])=>!entry.version).map(([key])=>key),
31
+ ...Object.entries(migrations.packageJsonUpdates ?? {}).filter(([, entry])=>entry.version === LATEST_MIGRATIONS_DIR).map(([key])=>key)
32
+ ];
24
33
  for (const version of versions){
25
34
  if (unresolved.length === 0) {
26
35
  break;
27
36
  }
28
- const registered = new Set(Object.keys(readReleasedMigrations(version)?.generators ?? {}));
37
+ const released = readReleasedMigrations(version);
38
+ const registered = new Set([
39
+ ...Object.keys(released?.generators ?? {}),
40
+ ...Object.keys(released?.packageJsonUpdates ?? {})
41
+ ]);
29
42
  // Entries gone at this release keep the version recorded from the release
30
43
  // after it (if any) and stop being looked up.
31
44
  unresolved = unresolved.filter((key)=>registered.has(key));
@@ -37,9 +50,8 @@
37
50
  };
38
51
  /**
39
52
  * Return a copy of the migrations collection with a `version` stamped onto
40
- * every generator entry, preserving any already present, and any
41
- * `packageJsonUpdates` entry still keyed `latest` re-keyed to the version it
42
- * ships under.
53
+ * every generator entry, preserving any already present, and the pending version
54
+ * recorded on any `packageJsonUpdates` entry still holding `latest`.
43
55
  *
44
56
  * @param migrations parsed migrations.json to stamp
45
57
  * @param shippedVersions migration key -> version of the earliest release
@@ -69,19 +81,9 @@
69
81
  }
70
82
  });
71
83
  /**
72
- * Version any unreleased `packageJsonUpdates` entry and re-key it out of
73
- * `latest`, so the nx bump ships under the same version as its migrations.
74
- */ const stampPackageJsonUpdates = (packageJsonUpdates, pendingVersion)=>Object.fromEntries(Object.entries(packageJsonUpdates).map(([key, entry])=>entry.version === LATEST_MIGRATIONS_DIR ? [
75
- reKeyToVersion(key, pendingVersion),
76
- {
77
- ...entry,
78
- version: pendingVersion
79
- }
80
- ] : [
81
- key,
82
- entry
83
- ]));
84
- /** Swap a `latest-<name>` key for the release that ships it. */ const reKeyToVersion = (key, version)=>key.startsWith(LATEST_KEY_PREFIX) ? migrationKey(versionMigrationsDir(version), key.slice(LATEST_KEY_PREFIX.length)) : key;
84
+ * Version any `packageJsonUpdates` entry still holding `latest` with the release
85
+ * about to publish it, so the nx bump ships under a version `nx migrate` gates on.
86
+ */ const stampPackageJsonUpdates = (packageJsonUpdates, pendingVersion)=>resolvePackageJsonUpdateVersions(packageJsonUpdates, ()=>pendingVersion);
85
87
  /** Directory a newly scaffolded migration lands in, before a release claims it. */ export const LATEST_MIGRATIONS_DIR = 'latest';
86
88
  /** Directory holding the migrations shipped by a given release. */ export const versionMigrationsDir = (version)=>`v${version}`;
87
89
  /**
@@ -106,6 +108,9 @@ const LATEST_KEY_PREFIX = `${LATEST_MIGRATIONS_DIR}-`;
106
108
  const generators = {};
107
109
  const backfilled = [];
108
110
  const moves = [];
111
+ // Reported alongside the migrations so the update's PR says an nx bump was
112
+ // dated, and so the caller knows there is something to commit.
113
+ const backfilledUpdates = Object.entries(migrations.packageJsonUpdates ?? {}).filter(([key, entry])=>entry.version === LATEST_MIGRATIONS_DIR && shippedVersions[key]).map(([key])=>key);
109
114
  for (const [key, entry] of Object.entries(migrations.generators ?? {})){
110
115
  const version = shippedVersions[key];
111
116
  // Pinning an every-migration entry would stop it running on later upgrades.
@@ -149,26 +154,33 @@ const LATEST_KEY_PREFIX = `${LATEST_MIGRATIONS_DIR}-`;
149
154
  ...migrations,
150
155
  generators,
151
156
  ...migrations.packageJsonUpdates && {
152
- packageJsonUpdates: backfillPackageJsonUpdates(migrations.packageJsonUpdates, // Re-keyed with the earliest release it shipped alongside.
153
- backfilled.map((key)=>shippedVersions[key]).sort(compareVersions)[0])
157
+ packageJsonUpdates: resolvePackageJsonUpdateVersions(migrations.packageJsonUpdates, (key)=>shippedVersions[key])
154
158
  }
155
159
  },
156
- backfilled,
160
+ backfilled: [
161
+ ...backfilled,
162
+ ...backfilledUpdates
163
+ ],
157
164
  moves
158
165
  };
159
166
  };
160
167
  /**
161
- * Record the release that shipped an unreleased `packageJsonUpdates` entry,
162
- * re-keying it out of `latest`, and leave it alone until one has.
163
- */ const backfillPackageJsonUpdates = (packageJsonUpdates, shippedVersion)=>Object.fromEntries(Object.entries(packageJsonUpdates).map(([key, entry])=>entry.version === LATEST_MIGRATIONS_DIR && shippedVersion ? [
164
- reKeyToVersion(key, shippedVersion),
165
- {
166
- ...entry,
167
- version: shippedVersion
168
- }
169
- ] : [
168
+ * Record the version each `packageJsonUpdates` entry ships under, for those still
169
+ * holding `latest`.
170
+ *
171
+ * The key already identifies the entry — an nx bump is named for the nx version
172
+ * it moves to — so only the `version` field changes. Nothing is re-keyed, which
173
+ * is what lets one release's bump sit alongside the next without either being
174
+ * overwritten before it ships.
175
+ */ const resolvePackageJsonUpdateVersions = (packageJsonUpdates, resolve)=>Object.fromEntries(Object.entries(packageJsonUpdates).map(([key, entry])=>{
176
+ const version = entry.version === LATEST_MIGRATIONS_DIR ? resolve(key) : undefined;
177
+ return [
170
178
  key,
171
- entry
172
- ]));
179
+ version ? {
180
+ ...entry,
181
+ version
182
+ } : entry
183
+ ];
184
+ }));
173
185
 
174
186
  //# sourceMappingURL=migration-versions.js.map
@@ -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.\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 `<dir>-<name>` like the migrations so entries from different releases\n * can't collide; 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 migration key -> version of the earliest release that registers it,\n * resolved only for the entries still missing a `version` (one already recorded\n * in source wins, so its history doesn't need reading). A migration that hasn't\n * 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 * @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 let unresolved = Object.entries(migrations.generators ?? {})\n .filter(([, entry]) => !entry.version)\n .map(([key]) => key);\n\n for (const version of versions) {\n if (unresolved.length === 0) {\n break;\n }\n const registered = new Set(\n Object.keys(readReleasedMigrations(version)?.generators ?? {}),\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 any\n * `packageJsonUpdates` entry still keyed `latest` re-keyed to the version it\n * ships under.\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 unreleased `packageJsonUpdates` entry and re-key it out of\n * `latest`, so the nx bump ships under the same version as its migrations.\n */\nconst stampPackageJsonUpdates = (\n packageJsonUpdates: NonNullable<MigrationsJson['packageJsonUpdates']>,\n pendingVersion: string,\n): NonNullable<MigrationsJson['packageJsonUpdates']> =>\n Object.fromEntries(\n Object.entries(packageJsonUpdates).map(([key, entry]) =>\n entry.version === LATEST_MIGRATIONS_DIR\n ? [\n reKeyToVersion(key, pendingVersion),\n { ...entry, version: pendingVersion },\n ]\n : [key, entry],\n ),\n );\n\n/** Swap a `latest-<name>` key for the release that ships it. */\nconst reKeyToVersion = (key: string, version: string): string =>\n key.startsWith(LATEST_KEY_PREFIX)\n ? migrationKey(\n versionMigrationsDir(version),\n key.slice(LATEST_KEY_PREFIX.length),\n )\n : key;\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\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: backfillPackageJsonUpdates(\n migrations.packageJsonUpdates,\n // Re-keyed with the earliest release it shipped alongside.\n backfilled\n .map((key) => shippedVersions[key])\n .sort(compareVersions)[0],\n ),\n }),\n },\n backfilled,\n moves,\n };\n};\n\n/**\n * Record the release that shipped an unreleased `packageJsonUpdates` entry,\n * re-keying it out of `latest`, and leave it alone until one has.\n */\nconst backfillPackageJsonUpdates = (\n packageJsonUpdates: NonNullable<MigrationsJson['packageJsonUpdates']>,\n shippedVersion: string | undefined,\n): NonNullable<MigrationsJson['packageJsonUpdates']> =>\n Object.fromEntries(\n Object.entries(packageJsonUpdates).map(([key, entry]) =>\n entry.version === LATEST_MIGRATIONS_DIR && shippedVersion\n ? [\n reKeyToVersion(key, shippedVersion),\n { ...entry, version: shippedVersion },\n ]\n : [key, entry],\n ),\n );\n"],"names":["compare","valid","compareVersions","isValidVersion","version","readShippedMigrationVersions","migrations","versions","readReleasedMigrations","shippedVersions","unresolved","Object","entries","generators","filter","entry","map","key","length","registered","Set","keys","has","stampMigrationVersions","pendingVersion","fromEntries","sort","a","b","Number","everyMigration","name","sourceVersion","published","packageJsonUpdates","stampPackageJsonUpdates","LATEST_MIGRATIONS_DIR","reKeyToVersion","startsWith","LATEST_KEY_PREFIX","migrationKey","versionMigrationsDir","slice","dir","backfillMigrationVersions","backfilled","moves","versionDir","latestSegment","versionSegment","repointed","moved","field","value","includes","replace","indexOf","push","from","to","backfillPackageJsonUpdates","shippedVersion"],"mappings":"AAAA;;;CAGC,GACD,SAASA,OAAO,EAAEC,KAAK,QAAQ,SAAS;AAyCxC,4DAA4D,GAC5D,OAAO,MAAMC,kBAAkBF,QAAQ;AAEvC,iDAAiD,GACjD,OAAO,MAAMG,iBAAiB,CAACC,UAC7BH,MAAM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CA,oBAAoB0B,2BAClBtD,WAAW4B,kBAAkB,EAC7B,2DAA2D;gBAC3DW,WACG7B,GAAG,CAAC,CAACC,MAAQR,eAAe,CAACQ,IAAI,EACjCS,IAAI,CAACxB,gBAAgB,CAAC,EAAE;YAE/B,CAAC;QACH;QACA2C;QACAC;IACF;AACF,EAAE;AAEF;;;CAGC,GACD,MAAMc,6BAA6B,CACjC1B,oBACA2B,iBAEAlD,OAAOc,WAAW,CAChBd,OAAOC,OAAO,CAACsB,oBAAoBlB,GAAG,CAAC,CAAC,CAACC,KAAKF,MAAM,GAClDA,MAAMX,OAAO,KAAKgC,yBAAyByB,iBACvC;YACExB,eAAepB,KAAK4C;YACpB;gBAAE,GAAG9C,KAAK;gBAAEX,SAASyD;YAAe;SACrC,GACD;YAAC5C;YAAKF;SAAM"}
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,CAAC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gB;gBAC/DE,SAAS,CAACE,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"}
@@ -22,14 +22,24 @@ export interface PackageJsonUpdate extends Record<string, unknown> {
22
22
  }
23
23
  export type PackageJsonUpdates = Record<string, PackageJsonUpdate>;
24
24
  /**
25
- * `alwaysAddToPackageJson: false` so only packages already present are updated.
25
+ * Key an nx bump is registered under, named for the nx version it moves to.
26
+ *
27
+ * The plugin version the bump ships under isn't known when it is written — the
28
+ * weekly update writes it, and only the release that publishes it can say which
29
+ * version that is. The nx version, though, is exactly what the entry is *for*,
30
+ * and two bumps to the same nx version would be the same bump — so it keys the
31
+ * entry uniquely from the moment it is written, with no re-keying later.
26
32
  *
27
- * Keyed by directory rather than version, because the key has to exist before
28
- * the version does: an entry is written under `latest` and only re-keyed to
29
- * `v<version>` once a release claims it. One release's entry stays behind as the
30
- * next is written, so a workspace several releases behind gets each nx bump in
31
- * turn — hence `<dir>-<name>`, which keeps every release's entry distinct.
33
+ * That matters because each release's bump has to stay behind as the next is
34
+ * written: a workspace several releases behind gets every nx hop in turn rather
35
+ * than only the newest. A key that had to be rewritten once the plugin version
36
+ * was known would let a second bump land on the first before either shipped.
37
+ */
38
+ export declare const nxPackageUpdatesKey: (nxVersion: string) => string;
39
+ /**
40
+ * `alwaysAddToPackageJson: false` so only packages already present are updated.
32
41
  *
33
- * @param version version `nx migrate` gates the bump on
42
+ * @param version plugin version `nx migrate` gates the bump on, or
43
+ * {@link LATEST_MIGRATIONS_DIR} while it is still waiting for a release
34
44
  */
35
- export declare const nxPackageJsonUpdates: (dir: string, version: string, nxVersion?: string) => PackageJsonUpdates;
45
+ export declare const nxPackageJsonUpdates: (version: string, nxVersion?: string) => PackageJsonUpdates;
@@ -1,8 +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 { migrationKey } from "../migration-versions.js";
5
- import { NX_PACKAGES, NX_VERSION } from "../versions.js";
4
+ */ import { NX_PACKAGES, NX_VERSION } from "../versions.js";
6
5
  /**
7
6
  * `packageJsonUpdates` for the nx packages a generated workspace pins.
8
7
  *
@@ -17,17 +16,26 @@ import { NX_PACKAGES, NX_VERSION } from "../versions.js";
17
16
  */ export const NX_PACKAGE_UPDATES_NAME = 'nx-packages';
18
17
  export const isNxPackage = (name)=>NX_PACKAGES.includes(name);
19
18
  /**
20
- * `alwaysAddToPackageJson: false` so only packages already present are updated.
19
+ * Key an nx bump is registered under, named for the nx version it moves to.
20
+ *
21
+ * The plugin version the bump ships under isn't known when it is written — the
22
+ * weekly update writes it, and only the release that publishes it can say which
23
+ * version that is. The nx version, though, is exactly what the entry is *for*,
24
+ * and two bumps to the same nx version would be the same bump — so it keys the
25
+ * entry uniquely from the moment it is written, with no re-keying later.
21
26
  *
22
- * Keyed by directory rather than version, because the key has to exist before
23
- * the version does: an entry is written under `latest` and only re-keyed to
24
- * `v<version>` once a release claims it. One release's entry stays behind as the
25
- * next is written, so a workspace several releases behind gets each nx bump in
26
- * turn hence `<dir>-<name>`, which keeps every release's entry distinct.
27
+ * That matters because each release's bump has to stay behind as the next is
28
+ * written: a workspace several releases behind gets every nx hop in turn rather
29
+ * than only the newest. A key that had to be rewritten once the plugin version
30
+ * was known would let a second bump land on the first before either shipped.
31
+ */ export const nxPackageUpdatesKey = (nxVersion)=>`nx-${nxVersion}-${NX_PACKAGE_UPDATES_NAME}`;
32
+ /**
33
+ * `alwaysAddToPackageJson: false` so only packages already present are updated.
27
34
  *
28
- * @param version version `nx migrate` gates the bump on
29
- */ export const nxPackageJsonUpdates = (dir, version, nxVersion = NX_VERSION)=>({
30
- [migrationKey(dir, NX_PACKAGE_UPDATES_NAME)]: {
35
+ * @param version plugin version `nx migrate` gates the bump on, or
36
+ * {@link LATEST_MIGRATIONS_DIR} while it is still waiting for a release
37
+ */ export const nxPackageJsonUpdates = (version, nxVersion = NX_VERSION)=>({
38
+ [nxPackageUpdatesKey(nxVersion)]: {
31
39
  version,
32
40
  packages: Object.fromEntries(NX_PACKAGES.map((name)=>[
33
41
  name,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/version-upgrade-migration/nx-package-updates.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { migrationKey } from '../migration-versions';\nimport { NX_PACKAGES, NX_VERSION } from '../versions';\n\n/**\n * `packageJsonUpdates` for the nx packages a generated workspace pins.\n *\n * A migration cannot bump these: `nx migrate` builds its migration list from the\n * packages it is itself bumping, so an nx version only rewritten by our migration\n * silently skips Nx's own migrations for that hop. Declaring the bump here pulls\n * them in.\n *\n * It also keeps every nx pin moving together. A workspace nx even a patch apart\n * from the plugin's `@nx/*` packages hoists a second nested nx, and the two\n * deadlock `nx sync`.\n */\n\nexport const NX_PACKAGE_UPDATES_NAME = 'nx-packages';\n\nexport const isNxPackage = (name: string): boolean =>\n (NX_PACKAGES as readonly string[]).includes(name);\n\n/** Indexed to satisfy the open shape `migrations.json` entries carry. */\nexport interface PackageJsonUpdate extends Record<string, unknown> {\n version: string;\n packages: Record<string, { version: string; alwaysAddToPackageJson: false }>;\n}\n\nexport type PackageJsonUpdates = Record<string, PackageJsonUpdate>;\n\n/**\n * `alwaysAddToPackageJson: false` so only packages already present are updated.\n *\n * Keyed by directory rather than version, because the key has to exist before\n * the version does: an entry is written under `latest` and only re-keyed to\n * `v<version>` once a release claims it. One release's entry stays behind as the\n * next is written, so a workspace several releases behind gets each nx bump in\n * turn hence `<dir>-<name>`, which keeps every release's entry distinct.\n *\n * @param version version `nx migrate` gates the bump on\n */\nexport const nxPackageJsonUpdates = (\n dir: string,\n version: string,\n nxVersion: string = NX_VERSION,\n): PackageJsonUpdates => ({\n [migrationKey(dir, NX_PACKAGE_UPDATES_NAME)]: {\n version,\n packages: Object.fromEntries(\n NX_PACKAGES.map((name) => [\n name,\n { version: nxVersion, alwaysAddToPackageJson: false as const },\n ]),\n ),\n },\n});\n"],"names":["migrationKey","NX_PACKAGES","NX_VERSION","NX_PACKAGE_UPDATES_NAME","isNxPackage","name","includes","nxPackageJsonUpdates","dir","version","nxVersion","packages","Object","fromEntries","map","alwaysAddToPackageJson"],"mappings":"AAAA;;;CAGC,GACD,SAASA,YAAY,QAAQ,2BAAwB;AACrD,SAASC,WAAW,EAAEC,UAAU,QAAQ,iBAAc;AAEtD;;;;;;;;;;;CAWC,GAED,OAAO,MAAMC,0BAA0B,cAAc;AAErD,OAAO,MAAMC,cAAc,CAACC,OAC1B,AAACJ,YAAkCK,QAAQ,CAACD,MAAM;AAUpD;;;;;;;;;;CAUC,GACD,OAAO,MAAME,uBAAuB,CAClCC,KACAC,SACAC,YAAoBR,UAAU,GACN,CAAA;QACxB,CAACF,aAAaQ,KAAKL,yBAAyB,EAAE;YAC5CM;YACAE,UAAUC,OAAOC,WAAW,CAC1BZ,YAAYa,GAAG,CAAC,CAACT,OAAS;oBACxBA;oBACA;wBAAEI,SAASC;wBAAWK,wBAAwB;oBAAe;iBAC9D;QAEL;IACF,CAAA,EAAG"}
1
+ {"version":3,"sources":["../../../../../../packages/nx-plugin/src/utils/version-upgrade-migration/nx-package-updates.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { migrationKey } from '../migration-versions';\nimport { NX_PACKAGES, NX_VERSION } from '../versions';\n\n/**\n * `packageJsonUpdates` for the nx packages a generated workspace pins.\n *\n * A migration cannot bump these: `nx migrate` builds its migration list from the\n * packages it is itself bumping, so an nx version only rewritten by our migration\n * silently skips Nx's own migrations for that hop. Declaring the bump here pulls\n * them in.\n *\n * It also keeps every nx pin moving together. A workspace nx even a patch apart\n * from the plugin's `@nx/*` packages hoists a second nested nx, and the two\n * deadlock `nx sync`.\n */\n\nexport const NX_PACKAGE_UPDATES_NAME = 'nx-packages';\n\nexport const isNxPackage = (name: string): boolean =>\n (NX_PACKAGES as readonly string[]).includes(name);\n\n/** Indexed to satisfy the open shape `migrations.json` entries carry. */\nexport interface PackageJsonUpdate extends Record<string, unknown> {\n version: string;\n packages: Record<string, { version: string; alwaysAddToPackageJson: false }>;\n}\n\nexport type PackageJsonUpdates = Record<string, PackageJsonUpdate>;\n\n/**\n * Key an nx bump is registered under, named for the nx version it moves to.\n *\n * The plugin version the bump ships under isn't known when it is written — the\n * weekly update writes it, and only the release that publishes it can say which\n * version that is. The nx version, though, is exactly what the entry is *for*,\n * and two bumps to the same nx version would be the same bump — so it keys the\n * entry uniquely from the moment it is written, with no re-keying later.\n *\n * That matters because each release's bump has to stay behind as the next is\n * written: a workspace several releases behind gets every nx hop in turn rather\n * than only the newest. A key that had to be rewritten once the plugin version\n * was known would let a second bump land on the first before either shipped.\n */\nexport const nxPackageUpdatesKey = (nxVersion: string) =>\n `nx-${nxVersion}-${NX_PACKAGE_UPDATES_NAME}`;\n\n/**\n * `alwaysAddToPackageJson: false` so only packages already present are updated.\n *\n * @param version plugin version `nx migrate` gates the bump on, or\n * {@link LATEST_MIGRATIONS_DIR} while it is still waiting for a release\n */\nexport const nxPackageJsonUpdates = (\n version: string,\n nxVersion: string = NX_VERSION,\n): PackageJsonUpdates => ({\n [nxPackageUpdatesKey(nxVersion)]: {\n version,\n packages: Object.fromEntries(\n NX_PACKAGES.map((name) => [\n name,\n { version: nxVersion, alwaysAddToPackageJson: false as const },\n ]),\n ),\n },\n});\n"],"names":["NX_PACKAGES","NX_VERSION","NX_PACKAGE_UPDATES_NAME","isNxPackage","name","includes","nxPackageUpdatesKey","nxVersion","nxPackageJsonUpdates","version","packages","Object","fromEntries","map","alwaysAddToPackageJson"],"mappings":"AAAA;;;CAGC,GAED,SAASA,WAAW,EAAEC,UAAU,QAAQ,iBAAc;AAEtD;;;;;;;;;;;CAWC,GAED,OAAO,MAAMC,0BAA0B,cAAc;AAErD,OAAO,MAAMC,cAAc,CAACC,OAC1B,AAACJ,YAAkCK,QAAQ,CAACD,MAAM;AAUpD;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAME,sBAAsB,CAACC,YAClC,CAAC,GAAG,EAAEA,UAAU,CAAC,EAAEL,yBAAyB,CAAC;AAE/C;;;;;CAKC,GACD,OAAO,MAAMM,uBAAuB,CAClCC,SACAF,YAAoBN,UAAU,GACN,CAAA;QACxB,CAACK,oBAAoBC,WAAW,EAAE;YAChCE;YACAC,UAAUC,OAAOC,WAAW,CAC1BZ,YAAYa,GAAG,CAAC,CAACT,OAAS;oBACxBA;oBACA;wBAAEK,SAASF;wBAAWO,wBAAwB;oBAAe;iBAC9D;QAEL;IACF,CAAA,EAAG"}
@@ -11,7 +11,12 @@ import { type Tree } from '@nx/devkit';
11
11
  * only the nx packages need registering per update: they go through
12
12
  * `packageJsonUpdates` rather than a migration (see `nx-package-updates.ts`).
13
13
  *
14
- * Idempotent: re-running before a release claims the entry refreshes it in place.
14
+ * A bump already dated by a release stays a workspace several releases behind
15
+ * needs each hop in turn. One still waiting for a release is dropped: this bump
16
+ * supersedes it, and both would otherwise ship under the same version, leaving
17
+ * which nx a workspace lands on down to the order nx happens to apply them in.
18
+ *
19
+ * Idempotent: re-running before a release replaces the pending entry with itself.
15
20
  *
16
21
  * @returns paths written, for the update report
17
22
  */
@@ -13,7 +13,12 @@ const MIGRATIONS_JSON_PATH = 'packages/nx-plugin/migrations.json';
13
13
  * only the nx packages need registering per update: they go through
14
14
  * `packageJsonUpdates` rather than a migration (see `nx-package-updates.ts`).
15
15
  *
16
- * Idempotent: re-running before a release claims the entry refreshes it in place.
16
+ * A bump already dated by a release stays a workspace several releases behind
17
+ * needs each hop in turn. One still waiting for a release is dropped: this bump
18
+ * supersedes it, and both would otherwise ship under the same version, leaving
19
+ * which nx a workspace lands on down to the order nx happens to apply them in.
20
+ *
21
+ * Idempotent: re-running before a release replaces the pending entry with itself.
17
22
  *
18
23
  * @returns paths written, for the update report
19
24
  */ export const registerNxPackageUpdates = (tree)=>{
@@ -21,8 +26,8 @@ const MIGRATIONS_JSON_PATH = 'packages/nx-plugin/migrations.json';
21
26
  ...migrations,
22
27
  // Recorded under `latest` until stamping resolves the version it ships with.
23
28
  packageJsonUpdates: {
24
- ...migrations.packageJsonUpdates,
25
- ...nxPackageJsonUpdates(LATEST_MIGRATIONS_DIR, LATEST_MIGRATIONS_DIR)
29
+ ...Object.fromEntries(Object.entries(migrations.packageJsonUpdates ?? {}).filter(([, entry])=>entry.version !== LATEST_MIGRATIONS_DIR)),
30
+ ...nxPackageJsonUpdates(LATEST_MIGRATIONS_DIR)
26
31
  }
27
32
  }));
28
33
  return [
@@ -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, updateJson } from '@nx/devkit';\nimport {\n LATEST_MIGRATIONS_DIR,\n type MigrationsJson,\n} from '../migration-versions';\nimport { nxPackageJsonUpdates } from './nx-package-updates';\n\nconst MIGRATIONS_JSON_PATH = 'packages/nx-plugin/migrations.json';\n\n/**\n * Register the nx bump a version update needs, in `migrations.json`. Call only\n * when an nx package actually moved.\n *\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 * Idempotent: re-running before a release claims the entry refreshes it in place.\n *\n * @returns paths written, for the update report\n */\nexport const registerNxPackageUpdates = (tree: Tree): string[] => {\n updateJson<MigrationsJson>(tree, MIGRATIONS_JSON_PATH, (migrations) => ({\n ...migrations,\n // Recorded under `latest` until stamping resolves the version it ships with.\n packageJsonUpdates: {\n ...migrations.packageJsonUpdates,\n ...nxPackageJsonUpdates(LATEST_MIGRATIONS_DIR, LATEST_MIGRATIONS_DIR),\n },\n }));\n\n return [MIGRATIONS_JSON_PATH];\n};\n"],"names":["updateJson","LATEST_MIGRATIONS_DIR","nxPackageJsonUpdates","MIGRATIONS_JSON_PATH","registerNxPackageUpdates","tree","migrations","packageJsonUpdates"],"mappings":"AAAA;;;CAGC,GACD,SAAoBA,UAAU,QAAQ,aAAa;AACnD,SACEC,qBAAqB,QAEhB,2BAAwB;AAC/B,SAASC,oBAAoB,QAAQ,0BAAuB;AAE5D,MAAMC,uBAAuB;AAE7B;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,2BAA2B,CAACC;IACvCL,WAA2BK,MAAMF,sBAAsB,CAACG,aAAgB,CAAA;YACtE,GAAGA,UAAU;YACb,6EAA6E;YAC7EC,oBAAoB;gBAClB,GAAGD,WAAWC,kBAAkB;gBAChC,GAAGL,qBAAqBD,uBAAuBA,sBAAsB;YACvE;QACF,CAAA;IAEA,OAAO;QAACE;KAAqB;AAC/B,EAAE"}
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, updateJson } from '@nx/devkit';\nimport {\n LATEST_MIGRATIONS_DIR,\n type MigrationsJson,\n} from '../migration-versions';\nimport { nxPackageJsonUpdates } from './nx-package-updates';\n\nconst MIGRATIONS_JSON_PATH = 'packages/nx-plugin/migrations.json';\n\n/**\n * Register the nx bump a version update needs, in `migrations.json`. Call only\n * when an nx package actually moved.\n *\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 * @returns paths written, for the update report\n */\nexport const registerNxPackageUpdates = (tree: Tree): string[] => {\n updateJson<MigrationsJson>(tree, MIGRATIONS_JSON_PATH, (migrations) => ({\n ...migrations,\n // Recorded under `latest` until stamping resolves the version it ships with.\n packageJsonUpdates: {\n ...Object.fromEntries(\n Object.entries(migrations.packageJsonUpdates ?? {}).filter(\n ([, entry]) => entry.version !== LATEST_MIGRATIONS_DIR,\n ),\n ),\n ...nxPackageJsonUpdates(LATEST_MIGRATIONS_DIR),\n },\n }));\n\n return [MIGRATIONS_JSON_PATH];\n};\n"],"names":["updateJson","LATEST_MIGRATIONS_DIR","nxPackageJsonUpdates","MIGRATIONS_JSON_PATH","registerNxPackageUpdates","tree","migrations","packageJsonUpdates","Object","fromEntries","entries","filter","entry","version"],"mappings":"AAAA;;;CAGC,GACD,SAAoBA,UAAU,QAAQ,aAAa;AACnD,SACEC,qBAAqB,QAEhB,2BAAwB;AAC/B,SAASC,oBAAoB,QAAQ,0BAAuB;AAE5D,MAAMC,uBAAuB;AAE7B;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMC,2BAA2B,CAACC;IACvCL,WAA2BK,MAAMF,sBAAsB,CAACG,aAAgB,CAAA;YACtE,GAAGA,UAAU;YACb,6EAA6E;YAC7EC,oBAAoB;gBAClB,GAAGC,OAAOC,WAAW,CACnBD,OAAOE,OAAO,CAACJ,WAAWC,kBAAkB,IAAI,CAAC,GAAGI,MAAM,CACxD,CAAC,GAAGC,MAAM,GAAKA,MAAMC,OAAO,KAAKZ,uBAEpC;gBACD,GAAGC,qBAAqBD,sBAAsB;YAChD;QACF,CAAA;IAEA,OAAO;QAACE;KAAqB;AAC/B,EAAE"}