-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: updated .env deployment to demo-api
- Loading branch information
Showing
11 changed files
with
189 additions
and
204 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CLIENT_APP_URL=https://components.dereekb.com |
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,6 @@ | ||
{ | ||
"projects": { | ||
"default": "dereekb-components" | ||
"default": "dereekb-components", | ||
"prod": "dereekb-components" | ||
} | ||
} |
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 @@ | ||
/** | ||
* This is a stand-alone tool used to generate .env files for your deployments. | ||
* | ||
* The expected usage is: | ||
* | ||
* node make-env.js | ||
*/ | ||
const fs = require('fs'); | ||
const { | ||
parse, | ||
stringify | ||
} = require('envfile'); | ||
|
||
// NOTE: If run within nx, remember that nx adds all variables within .env to the environment and, thus, process.env. | ||
// Variables that are within bash take prority. | ||
const templateFilePath = '.env'; | ||
const templateEnv = fs.readFileSync(templateFilePath).toString(); | ||
const template = parse(templateEnv); | ||
|
||
const env = {}; // this is the object that is parsed | ||
|
||
const keysToIgnoreFromTemplate = ['PUT_YOUR_REAL_SECRETS_INTO_ENV_SECRET', 'THIS_FILE_IS_COMMITTED_TO_GITHUB']; // these keys are ignored | ||
const keysToIgnore = new Set(keysToIgnoreFromTemplate); | ||
|
||
Object.keys(template) | ||
.filter((x) => !keysToIgnore.has(x)) | ||
.forEach((key) => (env[key] = '')); | ||
|
||
function copyToEnvFromProcessEnv(key, defaultValue = '') { | ||
env[key] = process.env[key] || defaultValue; | ||
} | ||
|
||
function initWithProcessEnv(defaultValue, keysSource = env) { | ||
Object.keys(keysSource).forEach((key) => copyToEnvFromProcessEnv(key, defaultValue)); | ||
} | ||
|
||
// ====================================== | ||
// Configure Here using JS | ||
// ====================================== | ||
|
||
const placeholderValue = 'plc'; | ||
initWithProcessEnv(placeholderValue); // Init with process.env, copying values from process.env onto the existing keys of our env variable | ||
|
||
// ====================================== | ||
// Finish Configuration | ||
// ====================================== | ||
console.log(stringify(env)); // output to console/stdout to allow piping. |
Oops, something went wrong.