-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: inject project info into overrides #12064
feat: inject project info into overrides #12064
Conversation
import { AmplifyAuthCognitoStackTemplate } from '@aws-amplify/cli-extensibility-helper'; | ||
import { AmplifyAuthCognitoStackTemplate, AmplifyProjectInfo } from '@aws-amplify/cli-extensibility-helper'; | ||
|
||
export function override(resources: AmplifyAuthCognitoStackTemplate, projectInfo: AmplifyProjectInfo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the variable name should be called amplifyProjectInfo
even with the type specifying it's Amplify since this var name gets used in the customer code.
|
||
if (!projectInfo || !projectInfo.envName || !projectInfo.projectName) { | ||
throw new Error('Project info is missing in override'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a test that actually uses the projectInfo
?
@@ -123,10 +124,11 @@ export class AmplifyAuthTransform extends AmplifyCategoryTransform { | |||
external: true, | |||
}, | |||
}); | |||
const projectInfo = getProjectInfo(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does getProjectInfo return a clone / readonly version of the object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it returns reference to fresh object with two strings, see
amplify-cli/packages/amplify-cli-extensibility-helper/src/helpers/project-info.ts
Lines 11 to 16 in 73eb14a
const projectInfo: AmplifyProjectInfo = { | |
envName: localEnvInfo.envName, | |
projectName: projectConfig.projectName, | |
}; | |
return projectInfo; |
I think I can make AmplifyProjectInfo
readonly to make it better.
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## cdkv2 #12064 +/- ##
==========================================
- Coverage 50.18% 46.62% -3.56%
==========================================
Files 702 826 +124
Lines 33976 37986 +4010
Branches 6976 7752 +776
==========================================
+ Hits 17050 17712 +662
- Misses 15447 18607 +3160
- Partials 1479 1667 +188
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
export const replaceOverrideFileWitProjectInfo = (srcPath: string, destPath: string, envName: string, projectName: string) => { | ||
const content = fs.readFileSync(srcPath).toString(); | ||
const contentWithProjectInfo = content.replace('##EXPECTED_ENV_NAME', envName).replace('##EXPECTED_PROJECT_NAME', projectName); | ||
fs.writeFileSync(destPath, contentWithProjectInfo); |
Check failure
Code scanning / CodeQL
Insecure temporary file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dismissed as occurring in tests.
Description of changes
This PR injects
AmplifyProjectInfo
into override functions as second parameter.Issue #, if available
Description of how you validated changes
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.