forked from awslabs/amplify-video
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Support multiple backends & minor fixes #1
Open
armenr
wants to merge
8
commits into
master
Choose a base branch
from
armenr/fix_multi_env
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1c38170
fix(props): Extend code to support individual props files & support m…
armenr 4496a32
fix(multiEnv): committing WIP - half-working test script for generati…
armenr 63dd5df
fix(video-staging): Added logic for generating unique props from exis…
armenr 2198628
fix(build): Added logic to build props from existing resource when bu…
armenr aa9b0df
fix(tokenGen): Fix CloudFront Token Gen Lambda (as per pull #247)
armenr 5a95c3f
fix(tokenGen): Added env interpolation to tokenGen GQL schema (as per…
armenr c054bca
fix(gqlSchema): Capitalize GQL models for Admin-UI compliance/friendl…
armenr f08c60e
fix(tagging): Added resource-level tagging in accordance with pr #205
armenr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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,47 @@ | ||
/* eslint-disable guard-for-in */ | ||
/* eslint-disable no-restricted-syntax */ | ||
const fs = require('fs'); | ||
|
||
const newEnvName = 'tonia'; | ||
const resourceDirectoryFiles = fs.readdirSync( | ||
`${__dirname}/`, | ||
); | ||
|
||
// Check if env-specific props file already exists | ||
const hasOwnEnvProps = resourceDirectoryFiles.includes(`${newEnvName}-props.json`); | ||
|
||
// Check if ANY env props exist | ||
const hasAnyEnvProps = resourceDirectoryFiles.find(item => item.includes('-props.json')); | ||
|
||
// console.log('hasOwnEnv', hasOwnEnvProps); | ||
// console.log('hasAnyEnvProps', hasAnyEnvProps); | ||
|
||
if (!hasOwnEnvProps) { | ||
if (hasAnyEnvProps) { | ||
// take the first props file you find and copy that! | ||
const propsFilenameToCopy = resourceDirectoryFiles.filter(propsFileName => propsFileName.includes('-props.json'))[0]; | ||
const envNameToReplace = propsFilenameToCopy.substr(0, propsFilenameToCopy.indexOf('-')); | ||
const propsToMutate = JSON.parse(fs.readFileSync(`${__dirname}/${propsFilenameToCopy}`)); | ||
|
||
const searchAndReplaceProps = () => { | ||
const newPropsObj = {}; | ||
for (const [key, value] of Object.entries(propsToMutate.contentDeliveryNetwork)) { | ||
if (typeof value === 'string' && value.includes(`${envNameToReplace}`)) { | ||
const newValue = value.replace(new RegExp(envNameToReplace, 'g'), `${newEnvName}`); | ||
newPropsObj[key] = newValue; | ||
} else { | ||
newPropsObj[key] = value; | ||
} | ||
} | ||
return newPropsObj; | ||
}; | ||
|
||
const newPropsToSave = Object.assign( | ||
propsToMutate, { contentDeliveryNetwork: searchAndReplaceProps() }, | ||
); | ||
|
||
console.log('IM GONNA SAVE THIS, ', newPropsToSave); | ||
|
||
fs.writeFileSync(`${__dirname}/${newEnvName}-props.json`, JSON.stringify(newPropsToSave, null, 4)); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@armenr
If I'm looking at the right output file (
dev-props.json
),projectDetails.localEnvInfo.envName
seems to be empty.(*) Notice
rCloudFrontPublicKeyvv37ttp5
doesn't contain the environment name ("dev")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.
@arturocanalda - Interesting. I'm comparing my results to yours, and there is a difference here. I'm wondering - what version of the amplify libs are you using?
I have a backend called
ingrid
, that was "auto-created" when I pushed a new branch to my codebase, and it produces thisingrid-props.json
:This was "inherited" or "generated" from a
staging-props.json
which the plugin correctly created, that has the following in it:As you can see, it appears to be working for me. I am running the following in my environment:
Which version of node are you running, and which version of the amplify library?
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.
@armenr
Indeed, the versions we're using might be the reason why I'm experiencing this issue:
I will upgrade nodeJS to
14.16.1
and test again later this afternoon. I'll keep you posted.