Skip to content
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

v3-development -> sandbox #699

Merged
merged 15 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"lint": "yarn flow",
"start": "unset HOST && react-scripts start",
"build": "unset HOST && export NODE_OPTIONS=--max-old-space-size=8192 && react-scripts build",
"postbuild": "node scripts/patchUrls.js",
"postbuild": "node scripts/patchUrls.js --max-old-space-size=3072",
"ppostbuild": "react-snap",
"test": "react-scripts test",
"eject": "react-scripts eject"
Expand Down
32 changes: 31 additions & 1 deletion scripts/patchUrls.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,36 @@ const getFiles = (directory) => {
}; // getFiles


/**
* The function filters environment variables and returns only the important ones.
*
* @returns {object}
*/
const filterEnvVars = () => {
const vars = process.env;
const valid_keys = [
"BASE_URL",
"MAIN_CDN",
"DOWNLOADS_CDN",
"API_ENDPOINT",
"USER_API_ENDPOINT",
"APPINSIGHTS_INSTRUMENTATIONKEY"
]
const filteredVars = {}

Object.keys(vars).forEach(key => {
// Check if it can be one of the vars to use.
valid_keys.forEach(valid_key => {
if(vars.hasOwnProperty(key) && key.includes(valid_key)) {
filteredVars[key] = vars[key]
}
})
})

return filteredVars
}


/**
* Replaces placeholders formatted as `%key%` with environment
* variables defined using the same key.
Expand All @@ -94,7 +124,7 @@ const main = async () => {
files = getFiles(directory),
Replacements = {
...extractEnvVars(),
...process.env
...filterEnvVars()
};

for ( const file of files ) {
Expand Down
Loading