@aws/nx-plugin-mcp 1.0.0-rc.49 → 1.0.0-rc.50

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.
@@ -39,6 +39,21 @@ This means:
39
39
 
40
40
  If you don't like something in the generated code, you are free to modify it. Generators give you a head start, not a cage.
41
41
 
42
+ ## In step with improvements
43
+
44
+ Owning your code usually comes at a cost: the moment you start editing a scaffold, you're cut off from the fixes and improvements made upstream. Adopting them again means reading a changelog, regenerating, and reconciling a diff by hand. <Link path="/get_started/upgrading">Migrations</Link> are how the `@aws/nx-plugin` works to keep that from happening.
45
+
46
+ Releases ship migrations alongside them, aiming to bring the code earlier generators produced into step with the improvements we've made since. When we fix a bug, harden a security default or refine a generated pattern, running `nx migrate` applies that change to your code, in place — instead of leaving you to spot it in a changelog and port it across yourself.
47
+
48
+ In practice:
49
+
50
+ - **Upgrading is automated, not a re-adoption exercise.** A workspace generated months ago can move forward with the plugin rather than drifting further from it.
51
+ - **Customisations are pattern-matched, not overwritten.** Migrations check that a file still matches the shape the generator produced. Where it has diverged beyond what they can safely update, they leave your code alone and report the manual follow-up instead.
52
+ - **Some changes arrive as agent prompts.** Where the right edit depends on what you've built, the migration is a prompt your AI coding agent applies rather than a codemod.
53
+ - **Upgrades are opt-in.** Nothing in your workspace changes until you choose to run `nx migrate`.
54
+
55
+ Migrations narrow the gap rather than close it: how far your code has moved decides how much they can do, and some steps will still need your hands.
56
+
42
57
  ## Minimal dependencies
43
58
 
44
59
  The `@aws/nx-plugin` strives to keep the number of global dependencies to a minimum. What you need to get started boils down to which generators you invoke.
@@ -200,6 +200,7 @@ import {
200
200
  IntegrationBuilder,
201
201
  RestApiIntegration,
202
202
  } from '../../core/api/utils.js';
203
+ import { findCloudFrontDomainNames } from '../../core/cloudfront.js';
203
204
  import { AddCorsPreflightAspect, RestApi } from '../../core/api/rest-api.js';
204
205
  import { Procedures, routerToOperations } from '../../core/api/trpc-utils.js';
205
206
  import { AppRouter, appRouter } from '@dungeon-adventure/game-api';
@@ -241,7 +242,7 @@ export class GameApi<
241
242
  public static defaultIntegrations = (scope: Construct) => {
242
243
  return IntegrationBuilder.rest({
243
244
  operations: routerToOperations(appRouter),
244
- defaultIntegrationOptions: <FunctionProps>{
245
+ defaultIntegrationOptions: {
245
246
  runtime: Runtime.NODEJS_LATEST,
246
247
  handler: 'index.handler',
247
248
  code: Code.fromAsset(
@@ -254,7 +255,7 @@ export class GameApi<
254
255
  ),
255
256
  timeout: Duration.seconds(30),
256
257
  tracing: Tracing.ACTIVE,
257
- },
258
+ } as FunctionProps,
258
259
  buildDefaultIntegration: (op, props: FunctionProps) => {
259
260
  const handler = new Function(scope, `GameApi${op}Handler`, props);
260
261
  return {
@@ -302,19 +303,23 @@ export class GameApi<
302
303
  *
303
304
  * Configures the CloudFront distribution domains or origin strings
304
305
  * as the only permitted CORS origins in API Gateway preflight responses and the AWS
305
- * Lambda integrations.
306
+ * Lambda integrations. Any custom domain names (aliases) configured on a CloudFront
307
+ * distribution are included automatically alongside its default `*.cloudfront.net`
308
+ * domain.
306
309
  *
307
310
  * @param origins - The origin strings, CloudFront distributions, or objects containing a CloudFront distribution to grant CORS from
308
311
  */
309
312
  public restrictCorsTo(
310
313
  ...origins: (string | Distribution | { cloudFrontDistribution: Distribution })[]
311
314
  ) {
312
- const allowedOrigins = origins.map((origin) =>
315
+ const allowedOrigins = origins.flatMap((origin) =>
313
316
  typeof origin === 'string'
314
- ? origin
315
- : 'cloudFrontDistribution' in origin
316
- ? `https://${origin.cloudFrontDistribution.distributionDomainName}`
317
- : `https://${origin.distributionDomainName}`,
317
+ ? [origin]
318
+ : findCloudFrontDomainNames(
319
+ 'cloudFrontDistribution' in origin
320
+ ? origin.cloudFrontDistribution
321
+ : origin,
322
+ ).map((domain) => `https://${domain}`),
318
323
  );
319
324
 
320
325
  this.allowedOrigins = allowedOrigins;
@@ -32,9 +32,9 @@ We recommend using the <Link path="/guides/ts-nx-plugin">`ts#nx-plugin`</Link> g
32
32
 
33
33
  Migrations come in three forms, discriminated by which fields the `migrations.json` entry carries. Pass `--kind` to choose (default `deterministic`):
34
34
 
35
- - **Deterministic** (`implementation`) — a codemod with an exact before/after. Runs unattended, including in CI and non-interactive terminals. Use it alone when the change has a shape you can match reliably everywhere it appears.
36
- - **Agentic** (`prompt`) — a markdown instruction file applied by the user's local coding agent via Nx's agentic `nx migrate` flow. Use it alone when no mechanical before/after holds, because the correct edit depends on what the user has built. When no agent runs (CI, no agent installed, consent declined), Nx surfaces the prompt as manual instructions so write prompts as self-contained, human-actionable steps.
37
- - **Hybrid** (`implementation` + `prompt`) — both halves of one change, and usually the right choice. Everything your generators vend is code the user owns and may have modified, so the codemod does as much as it can safely match and returns `agentContext` describing what it changed *and what it skipped*; Nx passes that context to the paired `prompt`, which directs the agent at the rest.
35
+ - **Deterministic** (`implementation`) — a codemod with an exact before/after, and the one to reach for first. It runs unattended, including in CI and non-interactive terminals, and applies identically for every user. Use it alone when the change has a shape you can match reliably everywhere it appears, reporting anything it skipped via `nextSteps`.
36
+ - **Hybrid** (`implementation` + `prompt`) — both halves of one change. Use it when a change is breaking and can't be fully applied mechanically: the codemod does as much as it can safely match and returns `agentContext` describing what it changed *and what it skipped*; Nx passes that context to the paired `prompt`, which directs the agent at the rest. The prompt is what stops a workspace being left broken when the leftover edits span too many shapes to codemod.
37
+ - **Agentic** (`prompt`) — a markdown instruction file applied by the user's local coding agent via Nx's agentic `nx migrate` flow. Use it alone when no mechanical before/after holds at all, because the correct edit depends on what the user has built. When no agent runs (CI, no agent installed, consent declined), Nx surfaces the prompt as manual instructions so write prompts as self-contained, human-actionable steps.
38
38
 
39
39
  ## Generator Output
40
40
 
@@ -84,8 +84,9 @@ For some example operations you can perform in your migration (generating files,
84
84
 
85
85
  Migrations run against workspaces you don't control, so it is recommended to adhere to the following (the scaffolded skeleton bakes these in):
86
86
 
87
- - **Pattern-match before writing.** If a target file has diverged from the shape your generators produce, skip it and report it via `nextSteps`, or consider a hybrid migration, rather than clobbering the user's changes.
88
- - **Idempotent.** Re-running the migration must be a no-op.
87
+ - **Transform source code with GritQL.** Use the <Link path="/guides/nx-generator">GritQL helpers</Link> (`applyGritQL`, `matchGritQL`) to edit source rather than regexes or string replacements. GritQL matches the AST, so one pattern holds across the formatting, whitespace and quoting a user's copy may have drifted into, where text matching quietly misses equivalent code or corrupts the file. Use `updateJson` for JSON and the matching parser for other structured config.
88
+ - **Pattern-match before writing.** If a target file has diverged from the shape your generators produce, skip it and report it via `nextSteps`, or consider a hybrid migration, rather than clobbering the user's changes. `matchGritQL` is a convenient way to make that check.
89
+ - **Idempotent.** Re-running the migration must be a no-op. Guard GritQL rewrites that inject code with a `where { ... <: not contains ... }` clause so a second run doesn't append a duplicate.
89
90
  - **Format what you write.** Finish with `formatFilesInSubtree(tree)` so the files your migration wrote are formatted correctly.
90
91
 
91
92
  ### Testing Your Migration
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/nx-plugin-mcp",
3
- "version": "1.0.0-rc.49",
3
+ "version": "1.0.0-rc.50",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/awslabs/nx-plugin-for-aws.git",