-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
9562-implement-dynamic-environment-variable-loading-for-single-artifa…
…ct-deployment
- Loading branch information
1 parent
66643f8
commit 8a08f2e
Showing
112 changed files
with
531 additions
and
463 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,24 @@ | ||
import * as fs from 'fs' | ||
import * as path from 'path' | ||
import { runtimeEnvironmentScript } from './utils' | ||
|
||
function main() { | ||
// Create the script content | ||
const scriptContent = `//DO NOT MODIFY THIS environment file directly, to updat this file. | ||
//To update environments please update the files under "/Users/l.mendoza/code/orcid-angular/src/environments" | ||
${runtimeEnvironmentScript()}` | ||
|
||
// Write the file. For example, dist/local-dev-environment.js | ||
const outputPath = path.resolve( | ||
__dirname, | ||
'../src/assets/local-dev-environment.js' | ||
) | ||
|
||
fs.writeFileSync(outputPath, scriptContent, { encoding: 'utf8' }) | ||
|
||
console.log(`Generated: ${outputPath}`) | ||
} | ||
console.log('runtime-environment-setter.dev-runtime.ts') | ||
if (require.main === module) { | ||
main() | ||
} |
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,22 @@ | ||
import { runtimeEnvironmentScript } from "./utils"; | ||
|
||
/** | ||
* Receives an HTML string, replaces the [ENVIRONMENT_VARAIBLES_PLACEHOLDER] | ||
* with a <script> that sets window.environment at runtime, | ||
* and returns the modified HTML string. | ||
*/ | ||
export function replaceEnvPlaceholder(htmlContent: string): string { | ||
// 1. Build the script that runs in the browser | ||
|
||
|
||
// 2. Wrap the content in a <script> tag | ||
const scriptTag = `<script>${runtimeEnvironmentScript()}</script>`; | ||
|
||
// 3. Replace the placeholder in the HTML | ||
const placeholderBlockRegex = /<!-- ENV_SCRIPT_PLACEHOLDER -->([\s\S]*?)<!-- \/ENV_SCRIPT_PLACEHOLDER -->/; | ||
|
||
const updatedHtml = htmlContent.replace(placeholderBlockRegex, scriptTag); | ||
|
||
// 4. Return the updated HTML | ||
return updatedHtml; | ||
} |
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
Oops, something went wrong.