-
Notifications
You must be signed in to change notification settings - Fork 824
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: inject project info into overrides (#12064)
* feat: inject project info into overrides * chore: format * chore: rename * chore: make project info readonly * chore: api * chore: some pr feedback * chore: better tests * chore: fix test * chore: fix typo
- Loading branch information
Showing
24 changed files
with
133 additions
and
47 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
packages/amplify-category-auth/resources/overrides-resource/auth/override.ts.sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { AmplifyAuthCognitoStackTemplate } from '@aws-amplify/cli-extensibility-helper'; | ||
import { AmplifyAuthCognitoStackTemplate, AmplifyProjectInfo } from '@aws-amplify/cli-extensibility-helper'; | ||
|
||
export function override(resources: AmplifyAuthCognitoStackTemplate, amplifyProjectInfo: AmplifyProjectInfo) { | ||
|
||
export function override(resources: AmplifyAuthCognitoStackTemplate) { | ||
|
||
} |
6 changes: 3 additions & 3 deletions
6
...ages/amplify-category-auth/resources/overrides-resource/userPoolGroups/override.ts.sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { AmplifyUserPoolGroupStackTemplate } from '@aws-amplify/cli-extensibility-helper'; | ||
import { AmplifyProjectInfo, AmplifyUserPoolGroupStackTemplate } from '@aws-amplify/cli-extensibility-helper'; | ||
|
||
export function override(resources: AmplifyUserPoolGroupStackTemplate, amplifyProjectInfo: AmplifyProjectInfo) { | ||
|
||
export function override(resources: AmplifyUserPoolGroupStackTemplate) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
packages/amplify-category-storage/resources/overrides-resource/DynamoDB/override.ts.sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { AmplifyDDBResourceTemplate } from '@aws-amplify/cli-extensibility-helper'; | ||
import { AmplifyDDBResourceTemplate, AmplifyProjectInfo } from '@aws-amplify/cli-extensibility-helper'; | ||
|
||
export function override(resources: AmplifyDDBResourceTemplate, amplifyProjectInfo: AmplifyProjectInfo) { | ||
|
||
export function override(resources: AmplifyDDBResourceTemplate) { | ||
|
||
} |
6 changes: 3 additions & 3 deletions
6
packages/amplify-category-storage/resources/overrides-resource/S3/override.ts.sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { AmplifyS3ResourceTemplate } from '@aws-amplify/cli-extensibility-helper'; | ||
import { AmplifyProjectInfo, AmplifyS3ResourceTemplate } from '@aws-amplify/cli-extensibility-helper'; | ||
|
||
export function override(resources: AmplifyS3ResourceTemplate, amplifyProjectInfo: AmplifyProjectInfo) { | ||
|
||
export function override(resources: AmplifyS3ResourceTemplate) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/** | ||
* PUBLIC API: Amplify project type | ||
*/ | ||
export type AmplifyProjectInfo = { | ||
export type AmplifyProjectInfo = Readonly<{ | ||
envName: string; | ||
projectName: string; | ||
}; | ||
}>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as fs from 'fs-extra'; | ||
|
||
export const replaceOverrideFileWithProjectInfo = (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); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
export function override(props: any): any { | ||
import { AmplifyProjectInfo, AmplifyAuthCognitoStackTemplate } from '@aws-amplify/cli-extensibility-helper'; | ||
|
||
export function override(props: AmplifyAuthCognitoStackTemplate, amplifyProjectInfo: AmplifyProjectInfo): void { | ||
props.userPool.deviceConfiguration = { | ||
challengeRequiredOnNewDevice: true, | ||
}; | ||
props.userPool.userAttributeUpdateSettings = { | ||
attributesRequireVerificationBeforeUpdate: ['email'], | ||
}; | ||
return props; | ||
|
||
if (!amplifyProjectInfo || !amplifyProjectInfo.envName || !amplifyProjectInfo.projectName) { | ||
throw new Error(`Project info is missing in override: ${JSON.stringify(amplifyProjectInfo)}`); | ||
} | ||
|
||
if (amplifyProjectInfo.envName != '##EXPECTED_ENV_NAME') { | ||
throw new Error(`Unexpected envName: ${amplifyProjectInfo.envName}`); | ||
} | ||
|
||
if (amplifyProjectInfo.projectName != '##EXPECTED_PROJECT_NAME') { | ||
throw new Error(`Unexpected envName: ${amplifyProjectInfo.envName}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,20 @@ | ||
import { AmplifyProjectInfo, AmplifyRootStackTemplate } from '@aws-amplify/cli-extensibility-helper'; | ||
|
||
function getRandomInt(max) { | ||
return Math.floor(Math.random() * max); | ||
} | ||
export function override(props: any): void { | ||
export function override(props: AmplifyRootStackTemplate, amplifyProjectInfo: AmplifyProjectInfo): void { | ||
props.authRole.roleName = `mockRole-${getRandomInt(10000)}`; | ||
return props; | ||
|
||
if (!amplifyProjectInfo || !amplifyProjectInfo.envName || !amplifyProjectInfo.projectName) { | ||
throw new Error(`Project info is missing in override: ${JSON.stringify(amplifyProjectInfo)}`); | ||
} | ||
|
||
if (amplifyProjectInfo.envName != '##EXPECTED_ENV_NAME') { | ||
throw new Error(`Unexpected envName: ${amplifyProjectInfo.envName}`); | ||
} | ||
|
||
if (amplifyProjectInfo.projectName != '##EXPECTED_PROJECT_NAME') { | ||
throw new Error(`Unexpected envName: ${amplifyProjectInfo.envName}`); | ||
} | ||
} |
16 changes: 15 additions & 1 deletion
16
packages/amplify-e2e-tests/overrides/override-storage-ddb.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,19 @@ | ||
export function override(props: any) { | ||
import { AmplifyDDBResourceTemplate, AmplifyProjectInfo } from '@aws-amplify/cli-extensibility-helper'; | ||
|
||
export function override(props: AmplifyDDBResourceTemplate, amplifyProjectInfo: AmplifyProjectInfo): void { | ||
props.dynamoDBTable.streamSpecification = { | ||
streamViewType: 'NEW_AND_OLD_IMAGES', | ||
}; | ||
|
||
if (!amplifyProjectInfo || !amplifyProjectInfo.envName || !amplifyProjectInfo.projectName) { | ||
throw new Error(`Project info is missing in override: ${JSON.stringify(amplifyProjectInfo)}`); | ||
} | ||
|
||
if (amplifyProjectInfo.envName != '##EXPECTED_ENV_NAME') { | ||
throw new Error(`Unexpected envName: ${amplifyProjectInfo.envName}`); | ||
} | ||
|
||
if (amplifyProjectInfo.projectName != '##EXPECTED_PROJECT_NAME') { | ||
throw new Error(`Unexpected envName: ${amplifyProjectInfo.envName}`); | ||
} | ||
} |
16 changes: 15 additions & 1 deletion
16
packages/amplify-e2e-tests/overrides/override-storage-s3.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,20 @@ | ||
export function override(props: any) { | ||
import { AmplifyProjectInfo, AmplifyS3ResourceTemplate } from '@aws-amplify/cli-extensibility-helper'; | ||
|
||
export function override(props: AmplifyS3ResourceTemplate, amplifyProjectInfo: AmplifyProjectInfo) { | ||
//Enable versioning on the bucket | ||
props.s3Bucket.versioningConfiguration = { | ||
status: 'Enabled', | ||
}; | ||
|
||
if (!amplifyProjectInfo || !amplifyProjectInfo.envName || !amplifyProjectInfo.projectName) { | ||
throw new Error(`Project info is missing in override: ${JSON.stringify(amplifyProjectInfo)}`); | ||
} | ||
|
||
if (amplifyProjectInfo.envName != '##EXPECTED_ENV_NAME') { | ||
throw new Error(`Unexpected envName: ${amplifyProjectInfo.envName}`); | ||
} | ||
|
||
if (amplifyProjectInfo.projectName != '##EXPECTED_PROJECT_NAME') { | ||
throw new Error(`Unexpected envName: ${amplifyProjectInfo.envName}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.