Skip to content

Conversation

@sanjanaravikumar-az
Copy link

Added support for transforming AmplifyHelpers.getProjectInfo().projectName from Gen1 to Gen2 during custom resource migration.

1. amplify-helper-transformer.ts
Enhanced the AST transformer to handle projectName transformations:

Added:

  • Optional projectName parameter to transform() and addRequiredImports() methods

  • Tracking of variables assigned from AmplifyHelpers.getProjectInfo()

  • Removal of entire variable statements like const amplifyProjectInfo = AmplifyHelpers.getProjectInfo();

Transformations:

  • AmplifyHelpers.getProjectInfo().projectName → projectName

  • amplifyProjectInfo.projectName → projectName

2. command-handlers.ts
Integrated the transformer into the migration pipeline:

Added:

  • TypeScript and AmplifyHelperTransformer imports

  • Logic to read projectName from amplify/.config/project-config.json

  • AST-based transformation using the transformer

  • Passes projectName to transformer methods

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

sanjanaravikumar-az added 5 commits November 7, 2025 14:08
- Added amplify-helper-transformer.ts
- Updated code-transformer.ts, command-handlers.ts
- Updated functions and storage generators
- Updated yarn.lock dependencies
- Add missing custom-resource-migrator.ts file
- Fix DataDefinitionFetcher constructor call to use correct number of arguments
…cess.env.AMPLIFY_ENV

The test was expecting the wrong replacement value. The code transformer
correctly replaces cdk.Fn.ref('env') with branchName, not process.env.AMPLIFY_ENV.
- Add amplify-helper-transformer.ts with branchName transformation
- Transform cdk.Fn.ref('env') and Fn.ref('env') to branchName
- Transform AmplifyHelpers.getProjectInfo().envName to branchName
- Add branchName declaration using process.env.AWS_BRANCH ?? 'sandbox'
- Remove AmplifyHelpers.getProjectInfo() replacement from command-handlers
- Remove in-place Gen1 file transformation to preserve original files
- Add projectName parameter to AmplifyHelperTransformer methods
- Transform AmplifyHelpers.getProjectInfo().projectName to Gen2 equivalent
- Read projectName from project-config.json during migration
- Remove string-based branchName replacement in favor of AST transformation
- Handle both direct and variable-based property access patterns
@sanjanaravikumar-az sanjanaravikumar-az requested a review from a team as a code owner November 10, 2025 02:27
@sanjanaravikumar-az sanjanaravikumar-az changed the title feat: replace AmplifyHelpers.getProjectInfo().projectName to projectName feat: replace AmplifyHelpers.getProjectInfo().projectName with projectName Nov 10, 2025
@iliapolo iliapolo changed the base branch from gen2-migration to sanjrkmr/aws-branch-env-variable-replacement November 14, 2025 16:34
@sanjanaravikumar-az sanjanaravikumar-az force-pushed the sanjrkmr/aws-branch-env-variable-replacement branch from 96ad63c to 019426e Compare November 14, 2025 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant