Skip to content

Commit

Permalink
9562-implement-dynamic-environment-variable-loading-for-single-artifa…
Browse files Browse the repository at this point in the history
…ct-deployment
  • Loading branch information
leomendoza123 committed Jan 28, 2025
1 parent 6237024 commit 921d46c
Show file tree
Hide file tree
Showing 98 changed files with 135 additions and 229 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ cypress/plugins/token.json

# Packages ignore package-lock to depend only on yarn
package-lock.json
src/assets/local-dev-environment.js
src/assets/runtime-environment.js
52 changes: 5 additions & 47 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,7 @@
"src/styles.scss",
"src/assets/scss/grid.scss"
],
"scripts": ["src/assets/local-dev-environment.js"],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.local.ts"
}
]
"scripts": ["src/assets/runtime-environment.js"]
},
"configurations": {
"local": {
Expand Down Expand Up @@ -172,12 +166,6 @@
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.local-with-proxy.ts"
}
]
},
"local-with-proxy-localize-en": {
Expand All @@ -195,53 +183,23 @@
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.local-with-proxy.ts"
}
]
},
"local-with-proxy-localize-fr": {
"localize": ["fr"],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.local-with-proxy.ts"
}
]
"localize": ["fr"]
},
"local-with-proxy-localize-ar": {
"localize": ["ar"],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.local-with-proxy.ts"
}
]
"localize": ["ar"]
},
"local-with-proxy-localize-xx": {
"localize": ["xx"],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.local-with-proxy.ts"
}
]
"localize": ["xx"]
},
"production": {
"budgets": [
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.production.ts"
}
]
},
"en": {
Expand Down Expand Up @@ -412,7 +370,7 @@
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.scss"
],
"scripts": ["src/assets/local-dev-environment.js"],
"scripts": ["src/assets/runtime-environment.js"],
"assets": ["src/favicon.ico", "src/assets", "src/manifest.json"],
"sourceMap": true
}
Expand Down
132 changes: 66 additions & 66 deletions documentation.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build-runtime-env": "ts-node -P scripts/tsconfig.json scripts/runtime-environment-setter.dev-runtime.ts",
"lint": "echo 'temporally disable Angular linter to until eslint update'",
"e2e": "ng e2e",
"prebuild": "rimraf dist && yarn build:i18n && yarn build:browserslist",
"prebuild": "rimraf dist && yarn build:i18n && yarn build:browserslist && npm run build-runtime-env",
"build": "ng build --configuration production --localize",
"postbuild": "ts-node -P scripts/tsconfig.json scripts/postbuild.ts",
"build:i18n:clone": "ts-node -P scripts/tsconfig.json scripts/properties-clone.postbuild.ts",
Expand Down
3 changes: 1 addition & 2 deletions scripts/runtime-environment-setter.dev-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ ${runtimeEnvironmentScript()}`

const outputPath = path.resolve(
__dirname,
'../src/assets/local-dev-environment.js'
'../src/assets/runtime-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()
}
11 changes: 7 additions & 4 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { writeFileSync } from 'fs'
import * as environmentProduction from '../src/environments/environment.production'
import * as environmentQa from '../src/environments/environment.qa'
import * as environmentSandbox from '../src/environments/environment.sandbox'
import * as environment4200 from '../src/environments/environment.local-with-proxy'
import * as environmentDev from '../src/environments/environment.local'
import * as environment4200 from '../src/environments/environment.local4200'
import * as environmentDev from '../src/environments/environment.local.dev.orcid.org'

export function save(data, options) {
writeFileSync(options.file, data, 'utf8')
Expand Down Expand Up @@ -89,8 +89,11 @@ export function runtimeEnvironmentScript() {
}
}
var domain = window.location.hostname + window.location.pathname;
var chosenEnv = environmentProduction; // default to production
var domain =
window.location.hostname +
(window.location.port ? ':' + window.location.port : '') +
window.location.pathname
var chosenEnv = environmentProduction; // default to production
if (domain.includes('qa.orcid.org')) {
chosenEnv = environmentQa;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import {
MatLegacyDialogRef as MatDialogRef,
} from '@angular/material/legacy-dialog'
import { DuplicateRemoveEndpoint } from 'src/app/types/account-actions-duplicated'
import { environment } from 'src/environments/environment'

@Component({
selector: 'app-dialog-actions-duplicated-merged-confirmed',
templateUrl: './dialog-actions-duplicated-merged-confirmed.component.html',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {
} from '@angular/material/legacy-dialog'
import { PlatformInfoService } from 'src/app/cdk/platform-info'
import { DuplicateRemoveEndpoint } from 'src/app/types/account-actions-duplicated'
import { environment } from 'src/environments/environment'

@Component({
selector: 'app-dialog-actions-duplicated',
templateUrl: './dialog-actions-duplicated.component.html',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { Subject } from 'rxjs'
import { takeUntil } from 'rxjs/operators'
import { WINDOW } from 'src/app/cdk/window'
import { LanguageService } from 'src/app/core/language/language.service'
import { environment } from 'src/environments/environment'

@Component({
selector: 'app-settings-defaults-language',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Component, EventEmitter, OnInit, Output } from '@angular/core'
import { take } from 'rxjs/operators'
import { UserService } from 'src/app/core'
import { UserSession } from 'src/app/types/session.local'
import { environment } from 'src/environments/environment'

@Component({
selector: 'app-settings-sharing-html-code',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from '@angular/material/legacy-dialog'
import { PlatformInfoService } from 'src/app/cdk/platform-info'
import { ExpandedSearchResultsContent } from 'src/app/types'
import { environment } from 'src/environments/environment'

@Component({
selector: 'app-dialog-add-trusted-individuals-your-own-email',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from '@angular/material/legacy-dialog'
import { PlatformInfoService } from 'src/app/cdk/platform-info'
import { ExpandedSearchResultsContent } from 'src/app/types'
import { environment } from 'src/environments/environment'

@Component({
selector: 'app-dialog-add-trusted-individuals',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import {
MatLegacyDialogRef as MatDialogRef,
} from '@angular/material/legacy-dialog'
import { PlatformInfoService } from 'src/app/cdk/platform-info'
import { AccountTrustedIndividualsService } from 'src/app/core/account-trusted-individuals/account-trusted-individuals.service'
import { AccountTrustedIndividual } from 'src/app/types/account-trusted-individuals'
import { AccountTrustedOrganization } from 'src/app/types/account-trusted-organizations'
import { environment } from 'src/environments/environment'

@Component({
selector: 'app-dialog-revoke-trusted-individuals',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { SearchService } from 'src/app/core/search/search.service'
import { ExpandedSearchResultsContent, SearchResults } from 'src/app/types'
import { AccountTrustedIndividual } from 'src/app/types/account-trusted-individuals'
import { UserSession } from 'src/app/types/session.local'
import { environment } from 'src/environments/environment'
import { DialogAddTrustedIndividualsYourOwnEmailComponent } from '../dialog-add-trusted-individuals-your-own-email/dialog-add-trusted-individuals-your-own-email.component'
import { DialogAddTrustedIndividualsComponent } from '../dialog-add-trusted-individuals/dialog-add-trusted-individuals.component'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { startWith, switchMap, takeUntil, tap } from 'rxjs/operators'
import { PlatformInfoService } from 'src/app/cdk/platform-info'
import { AccountTrustedIndividualsService } from 'src/app/core/account-trusted-individuals/account-trusted-individuals.service'
import { AccountTrustedIndividual } from 'src/app/types/account-trusted-individuals'
import { environment } from 'src/environments/environment'

import { DialogRevokeTrustedIndividualsComponent } from '../dialog-revoke-trusted-individuals/dialog-revoke-trusted-individuals.component'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { takeUntil } from 'rxjs/operators'
import { PlatformInfoService } from 'src/app/cdk/platform-info'
import { TrustedIndividualsService } from 'src/app/core/trusted-individuals/trusted-individuals.service'
import { TrustedIndividuals } from 'src/app/types/trusted-individuals.endpoint'
import { environment } from 'src/environments/environment'

@Component({
selector: 'app-settings-users-that-thrust-you',
Expand Down
3 changes: 1 addition & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
import { environment } from 'src/environments/environment'
import { EnvironmentBannerModule } from '../app/environment-banner/environment-banner.module'

import { AppRoutingModule } from './app-routing.module'
Expand All @@ -25,7 +24,7 @@ import { HTTP_INTERCEPTORS } from '@angular/common/http'
BidiModule,
PseudoModule, // Remove on angular 10 https://bit.ly/3ezbF4v
// Environmental dependent modules
environment.SHOW_TEST_WARNING_BANNER ? EnvironmentBannerModule : [],
EnvironmentBannerModule,
],
providers: [
TitleService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
Delegator,
TrustedIndividuals,
} from 'src/app/types/trusted-individuals.endpoint'
import { environment } from 'src/environments/environment'
import { GoogleTagManagerService } from '../../../core/google-tag-manager/google-tag-manager.service'
import { Title } from '@angular/platform-browser'

Expand All @@ -41,7 +40,7 @@ import { Title } from '@angular/platform-browser'
export class FormAuthorizeComponent implements OnInit, OnDestroy {
@Output() redirectUrl = new EventEmitter<string>()
@Output() organizationName = new EventEmitter<string>()
environment = environment
environment = runtimeEnvironment
$destroy: Subject<boolean> = new Subject<boolean>()
orcidUrl: string
userName: string
Expand Down
1 change: 0 additions & 1 deletion src/app/cdk/recaptcha/recaptcha.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
} from '@angular/core'
import { WINDOW } from '../window'
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
import { environment } from 'src/environments/environment'
import { ErrorHandlerService } from 'src/app/core/error-handler/error-handler.service'

export interface ReCaptchaConfig {
Expand Down
3 changes: 1 addition & 2 deletions src/app/cdk/side-bar/side-bar-id/side-bar-id.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Component, Inject, Input, OnDestroy, OnInit } from '@angular/core'
import { Subject } from 'rxjs'
import { takeUntil } from 'rxjs/operators'
import { PlatformInfo, PlatformInfoService } from '../../platform-info'
import { environment } from '../../../../environments/environment'
import { WINDOW } from '../../window'

@Component({
Expand All @@ -17,7 +16,7 @@ export class SideBarIdComponent implements OnInit, OnDestroy {
labelPreviewRecord = $localize`:@@record.ariaLabelPreviewPublicRecord:Preview the public version of this record (Opens in a new tab)`
$destroy: Subject<boolean> = new Subject<boolean>()
labelPreviewPublicRecord = $localize`:@@record.ariaLabelpreviewPublicRecord:Preview the public version of this record (Opens in a new tab)`
environment = environment
environment = runtimeEnvironment
@Input() id: string
@Input() privateView = true
platform: PlatformInfo
Expand Down
1 change: 0 additions & 1 deletion src/app/cdk/snackbar/snackbar.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { PlatformInfoService } from '../platform-info'
import { SnackbarModule } from './snackbar.module'
import { SnackbarComponent } from './snackbar/snackbar.component'
import { HttpErrorResponse } from '@angular/common/http'
import { environment } from 'src/environments/environment'

@Injectable({
providedIn: SnackbarModule,
Expand Down
1 change: 0 additions & 1 deletion src/app/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
AffiliationUIGroup,
} from './types/record-affiliation.endpoint'
import { WorkBibtexModalComponent } from './record/components/work-stack-group/modals/work-bibtex-modal/work-bibtex-modal.component'
import { environment } from 'src/environments/environment'

export { COUNTRY_NAMES_TO_COUNTRY_CODES } from './constants-country-codes'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { Observable } from 'rxjs'
import { catchError, retry } from 'rxjs/operators'
import { environment } from 'src/environments/environment'

import { ErrorHandlerService } from '../error-handler/error-handler.service'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { HttpClient } from '@angular/common/http'
import { Inject, Injectable } from '@angular/core'
import { catchError, retry, tap } from 'rxjs/operators'
import { WINDOW } from 'src/app/cdk/window'
import { environment } from 'src/environments/environment'
import { ErrorHandlerService } from '../error-handler/error-handler.service'

@Injectable({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Observable } from 'rxjs'
import { catchError, retry } from 'rxjs/operators'
import { ERROR_REPORT } from 'src/app/errors'
import { DuplicateRemoveEndpoint } from 'src/app/types/account-actions-duplicated'
import { environment } from 'src/environments/environment'

import { ErrorHandlerService } from '../error-handler/error-handler.service'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Injectable } from '@angular/core'
import { Observable } from 'rxjs'
import { catchError, retry } from 'rxjs/operators'
import { AccountDefaultEmailFrequenciesEndpoint } from 'src/app/types/account-default-visibility.endpoint'
import { environment } from 'src/environments/environment'

import { ErrorHandlerService } from '../error-handler/error-handler.service'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Injectable } from '@angular/core'
import { Observable } from 'rxjs'
import { catchError, retry } from 'rxjs/operators'
import { VisibilityStrings } from 'src/app/types/common.endpoint'
import { environment } from 'src/environments/environment'
import { ErrorHandlerService } from '../error-handler/error-handler.service'

@Injectable({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
SocialAccountId,
} from 'src/app/types/account-alternate-sign-in.endpoint'
import { Institutional } from 'src/app/types/institutional.endpoint'
import { environment } from 'src/environments/environment'

import { DiscoService } from '../disco/disco.service'
import { ErrorHandlerService } from '../error-handler/error-handler.service'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Injectable } from '@angular/core'
import { Observable } from 'rxjs'
import { catchError, retry } from 'rxjs/operators'
import { AccountPasswordEndpoint } from 'src/app/types/account-settings-password'
import { environment } from 'src/environments/environment'

import { ErrorHandlerService } from '../error-handler/error-handler.service'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
AccountTrustedIndividual,
PersonDetails,
} from 'src/app/types/account-trusted-individuals'
import { environment } from 'src/environments/environment'

import { ErrorHandlerService } from '../error-handler/error-handler.service'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { HttpClient, HttpHeaders } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { Observable } from 'rxjs'
import { catchError, retry } from 'rxjs/operators'
import { ERROR_REPORT } from 'src/app/errors'
import { AccountTrustedOrganization } from 'src/app/types/account-trusted-organizations'
import { environment } from 'src/environments/environment'
import { ErrorHandlerService } from '../error-handler/error-handler.service'

@Injectable({
Expand Down
1 change: 0 additions & 1 deletion src/app/core/announcer/announcer.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { LiveAnnouncer } from '@angular/cdk/a11y'
import { Injectable } from '@angular/core'
import { LegacyPageEvent as PageEvent } from '@angular/material/legacy-paginator'
import { environment } from 'src/environments/environment'

@Injectable({
providedIn: 'root',
Expand Down
1 change: 0 additions & 1 deletion src/app/core/canonocal-url/canonocal-url.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Inject, Injectable } from '@angular/core'
import { NavigationEnd, Router } from '@angular/router'
import { filter, map } from 'rxjs/operators'
import { ORCID_REGEXP } from 'src/app/constants'
import { environment } from 'src/environments/environment'

@Injectable({
providedIn: 'root',
Expand Down
Loading

0 comments on commit 921d46c

Please sign in to comment.