This repository has been archived by the owner on Apr 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple backends & minor fixes (#255)
* fix(props): Extend code to support individual props files & support multiple backend envs * fix(multiEnv): committing WIP - half-working test script for generating new props from existing props * fix(video-staging): Added logic for generating unique props from existing video resource * fix(build): Added logic to build props from existing resource when build is invoked * fix(tokenGen): Fix CloudFront Token Gen Lambda (as per pull #247) * fix(tokenGen): Added env interpolation to tokenGen GQL schema (as per pr #219) * fix(gqlSchema): Capitalize GQL models for Admin-UI compliance/friendliness * fix(tagging): Added resource-level tagging in accordance with pr #205
- Loading branch information
Showing
12 changed files
with
174 additions
and
19 deletions.
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
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)); | ||
} | ||
} |