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 4, 2025
1 parent 8a08f2e commit 70f10d1
Show file tree
Hide file tree
Showing 37 changed files with 484 additions and 162 deletions.
5 changes: 2 additions & 3 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,11 @@
"local": {
"browserTarget": "ng-orcid:build:local"
},
"local-tomcat": {
},
"local-tomcat": {},
"production": {
"browserTarget": "ng-orcid:build:production"
},

"en": {
"browserTarget": "ng-orcid:build:en"
},
Expand Down
14 changes: 7 additions & 7 deletions scripts/runtime-environment-setter.postbuild.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { runtimeEnvironmentScript } from "./utils";
import { runtimeEnvironmentScript } from './utils'

/**
* Receives an HTML string, replaces the [ENVIRONMENT_VARAIBLES_PLACEHOLDER]
Expand All @@ -8,15 +8,15 @@ import { runtimeEnvironmentScript } from "./utils";
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>`;
const scriptTag = `<script>${runtimeEnvironmentScript()}</script>`

// 3. Replace the placeholder in the HTML
const placeholderBlockRegex = /<!-- ENV_SCRIPT_PLACEHOLDER -->([\s\S]*?)<!-- \/ENV_SCRIPT_PLACEHOLDER -->/;
const placeholderBlockRegex =
/<!-- ENV_SCRIPT_PLACEHOLDER -->([\s\S]*?)<!-- \/ENV_SCRIPT_PLACEHOLDER -->/

const updatedHtml = htmlContent.replace(placeholderBlockRegex, scriptTag);
const updatedHtml = htmlContent.replace(placeholderBlockRegex, scriptTag)

// 4. Return the updated HTML
return updatedHtml;
}
return updatedHtml
}
12 changes: 8 additions & 4 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ export function runtimeEnvironmentScript() {
return `
(function() {
// The raw environment objects
var environmentProduction = ${JSON.stringify(environmentProduction.environment)};
var environmentProduction = ${JSON.stringify(
environmentProduction.environment
)};
var environmentQa = ${JSON.stringify(environmentQa.environment)};
var environmentSandbox = ${JSON.stringify(environmentSandbox.environment)};
var environmentSandbox = ${JSON.stringify(
environmentSandbox.environment
)};
var environment4200 = ${JSON.stringify(environment4200.environment)};
var environmentDev = ${JSON.stringify(environmentDev.environment)};
Expand Down Expand Up @@ -102,5 +106,5 @@ export function runtimeEnvironmentScript() {
window.runtimeEnvironment = chosenEnv;
})();
`;
}
`
}
3 changes: 2 additions & 1 deletion src/app/cdk/platform-info/browserlist.regexp.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// tslint:disable-next-line: max-line-length
export const BROWSERLIST_REGEXP = /((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(13[_.]4|13[_.]([5-9]|\d{2,})|13[_.]7|13[_.]([8-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})[_.]\d+|14[_.]0|14[_.]([1-9]|\d{2,})|14[_.]4|14[_.]([5-9]|\d{2,})|14[_.]8|14[_.](9|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})[_.]\d+|15[_.]0|15[_.]([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})[_.]\d+|16[_.]0|16[_.]([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})[_.]\d+|17[_.]0|17[_.]([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})[_.]\d+)(?:[_.]\d+)?)|((?:Chrome).*OPR\/(74|(7[5-9]|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Edge\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))(?:\.\d+)?)|((Chromium|Chrome)\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))\.\d+(?:\.\d+)?)|(Version\/(13\.1|13\.([2-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})\.\d+|14\.0|14\.([1-9]|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})\.\d+|15\.0|15\.([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})\.\d+|16\.0|16\.([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})\.\d+|17\.0|17\.([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})\.\d+)(?:\.\d+)? Safari\/)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+(pre|[ab]\d+[a-z]*)?)/
export const BROWSERLIST_REGEXP =
/((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(13[_.]4|13[_.]([5-9]|\d{2,})|13[_.]7|13[_.]([8-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})[_.]\d+|14[_.]0|14[_.]([1-9]|\d{2,})|14[_.]4|14[_.]([5-9]|\d{2,})|14[_.]8|14[_.](9|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})[_.]\d+|15[_.]0|15[_.]([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})[_.]\d+|16[_.]0|16[_.]([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})[_.]\d+|17[_.]0|17[_.]([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})[_.]\d+)(?:[_.]\d+)?)|((?:Chrome).*OPR\/(74|(7[5-9]|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Edge\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))(?:\.\d+)?)|((Chromium|Chrome)\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))\.\d+(?:\.\d+)?)|(Version\/(13\.1|13\.([2-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})\.\d+|14\.0|14\.([1-9]|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})\.\d+|15\.0|15\.([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})\.\d+|16\.0|16\.([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})\.\d+|17\.0|17\.([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})\.\d+)(?:\.\d+)? Safari\/)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+(pre|[ab]\d+[a-z]*)?)/
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export class AccountDefaultEmailFrequenciesService {
updateAmendNotifications(frequency: number): Observable<void> {
return this._http
.post<void>(
runtimeEnvironment.API_WEB + `notifications/frequencies/update/amendUpdates`,
runtimeEnvironment.API_WEB +
`notifications/frequencies/update/amendUpdates`,
frequency,
{ headers: this.headers }
)
Expand All @@ -46,7 +47,8 @@ export class AccountDefaultEmailFrequenciesService {
updateAdminNotifications(frequency: string): Observable<void> {
return this._http
.post<void>(
runtimeEnvironment.API_WEB + `notifications/frequencies/update/adminUpdates`,
runtimeEnvironment.API_WEB +
`notifications/frequencies/update/adminUpdates`,
frequency,
{ headers: this.headers }
)
Expand All @@ -58,7 +60,8 @@ export class AccountDefaultEmailFrequenciesService {
updateMemberNotifications(frequency: string): Observable<void> {
return this._http
.post<void>(
runtimeEnvironment.API_WEB + `notifications/frequencies/update/memberUpdates`,
runtimeEnvironment.API_WEB +
`notifications/frequencies/update/memberUpdates`,
frequency,
{ headers: this.headers }
)
Expand All @@ -71,7 +74,8 @@ export class AccountDefaultEmailFrequenciesService {
updateMemberTipsUpdates(tips: boolean): Observable<void> {
return this._http
.post<void>(
runtimeEnvironment.API_WEB + `notifications/frequencies/update/tipsUpdates`,
runtimeEnvironment.API_WEB +
`notifications/frequencies/update/tipsUpdates`,
tips,
{ headers: this.headers }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ export class AccountTrustedIndividualsService {

getPersonDetails(orcid: string) {
return this._http
.get<PersonDetails>(runtimeEnvironment.API_PUB + `${orcid}/personal-details`, {
headers: this.headers,
})
.get<PersonDetails>(
runtimeEnvironment.API_PUB + `${orcid}/personal-details`,
{
headers: this.headers,
}
)
.pipe(
retry(3),
catchError((error) => this._errorHandler.handleError(error))
Expand Down
4 changes: 3 additions & 1 deletion src/app/core/canonocal-url/canonocal-url.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export class CanonocalUrlService {
let canonicalUrl =
'https:' +
runtimeEnvironment.BASE_URL +
(runtimeEnvironment.BASE_URL.endsWith('/') ? publicOrcid : '/' + publicOrcid)
(runtimeEnvironment.BASE_URL.endsWith('/')
? publicOrcid
: '/' + publicOrcid)
let link: HTMLLinkElement = this.doc.createElement('link')

link.setAttribute('rel', 'canonical')
Expand Down
13 changes: 9 additions & 4 deletions src/app/core/developer-tools/developer-tools.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export class DeveloperToolsService {

getDeveloperToolsClient(): Observable<Client> {
return this._http
.get<Client>(runtimeEnvironment.BASE_URL + 'developer-tools/get-client.json')
.get<Client>(
runtimeEnvironment.BASE_URL + 'developer-tools/get-client.json'
)
.pipe(
retry(3),
catchError((error) =>
Expand Down Expand Up @@ -58,7 +60,8 @@ export class DeveloperToolsService {
postResetClientSecret(client: Client): Observable<Client> {
return this._http
.post<Client>(
runtimeEnvironment.BASE_URL + 'developer-tools/reset-client-secret.json',
runtimeEnvironment.BASE_URL +
'developer-tools/reset-client-secret.json',
client
)
.pipe(
Expand All @@ -72,7 +75,8 @@ export class DeveloperToolsService {
enableDeveloperTools() {
return this._http
.post<Client>(
runtimeEnvironment.BASE_URL + 'developer-tools/enable-developer-tools.json',
runtimeEnvironment.BASE_URL +
'developer-tools/enable-developer-tools.json',
{}
)
.pipe(
Expand All @@ -86,7 +90,8 @@ export class DeveloperToolsService {
resetClientSecret(client: Client): Observable<Client> {
return this._http
.post<Client>(
runtimeEnvironment.BASE_URL + 'developer-tools/reset-client-secret.json',
runtimeEnvironment.BASE_URL +
'developer-tools/reset-client-secret.json',
client
)
.pipe(
Expand Down
4 changes: 3 additions & 1 deletion src/app/core/disco/disco.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ export class DiscoService {
if (!this.discoFeedSubject) {
this.discoFeedSubject = new ReplaySubject(1)
return this._http
.get<Institutional[]>(runtimeEnvironment.BASE_URL + 'Shibboleth.sso/DiscoFeed')
.get<Institutional[]>(
runtimeEnvironment.BASE_URL + 'Shibboleth.sso/DiscoFeed'
)
.pipe(
tap((feed) => {
this.discoFeedSubject.next(feed)
Expand Down
4 changes: 3 additions & 1 deletion src/app/core/inbox/inbox.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ export class InboxService {
}

retrieveUnreadCount(): any {
return this._http.get(runtimeEnvironment.BASE_URL + 'inbox/unreadCount.json')
return this._http.get(
runtimeEnvironment.BASE_URL + 'inbox/unreadCount.json'
)
}

totalNumber() {
Expand Down
10 changes: 6 additions & 4 deletions src/app/core/oauth/oauth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { OauthParameters, RequestInfoForm } from 'src/app/types'
import { OauthAuthorize } from 'src/app/types/authorize.endpoint'
import { UserSessionUpdateParameters } from 'src/app/types/session.local'


import { SignInData } from '../../types/sign-in-data.endpoint'
import { TwoFactor } from '../../types/two-factor.endpoint'
import { ErrorHandlerService } from '../error-handler/error-handler.service'
Expand Down Expand Up @@ -193,9 +192,12 @@ export class OauthService {

loadShibbolethSignInData(): Observable<SignInData> {
return this._http
.get<SignInData>(runtimeEnvironment.BASE_URL + 'shibboleth/signinData.json', {
headers: this.headers,
})
.get<SignInData>(
runtimeEnvironment.BASE_URL + 'shibboleth/signinData.json',
{
headers: this.headers,
}
)
.pipe(
retry(3),
catchError((error) =>
Expand Down
4 changes: 3 additions & 1 deletion src/app/core/open-graph/open-graph.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ export class OpenGraphService {
{
property: this.imageMeta,
content:
'https:' + runtimeEnvironment.BASE_URL + 'assets/img/orcid-og-image.png',
'https:' +
runtimeEnvironment.BASE_URL +
'assets/img/orcid-og-image.png',
},
])
} catch (e) {
Expand Down
1 change: 0 additions & 1 deletion src/app/core/organizations/organizations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { catchError, retry } from 'rxjs/operators'
import { WHITE_SPACE_REGEXP } from 'src/app/constants'
import { OrgDisambiguated } from 'src/app/types'


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

@Injectable({
Expand Down
10 changes: 7 additions & 3 deletions src/app/core/password-recovery/password-recovery.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ export class PasswordRecoveryService {

remindOrcidId(data) {
return this._http
.post<PasswordRecovery>(runtimeEnvironment.API_WEB + `forgot-id.json`, data, {
withCredentials: true,
})
.post<PasswordRecovery>(
runtimeEnvironment.API_WEB + `forgot-id.json`,
data,
{
withCredentials: true,
}
)
.pipe(
retry(3),
catchError((error) =>
Expand Down
10 changes: 7 additions & 3 deletions src/app/core/record-emails/record-emails.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,13 @@ export class RecordEmailsService {
const encoded_data = JSON.stringify(email)

return this._http
.post(runtimeEnvironment.API_WEB + `account/email/visibility`, encoded_data, {
headers: this.headers,
})
.post(
runtimeEnvironment.API_WEB + `account/email/visibility`,
encoded_data,
{
headers: this.headers,
}
)
.pipe(
retry(3),
catchError((error) => this._errorHandler.handleError(error)),
Expand Down
15 changes: 11 additions & 4 deletions src/app/core/record-fundings/record-fundings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ export class RecordFundingsService {
getFundingDetails(putCode): Observable<Funding> {
return this._http
.get<Funding>(
runtimeEnvironment.API_WEB + `fundings/fundingDetails.json?id=${putCode}`
runtimeEnvironment.API_WEB +
`fundings/fundingDetails.json?id=${putCode}`
)
.pipe(
retry(3),
Expand All @@ -87,7 +88,9 @@ export class RecordFundingsService {
getPublicFundingDetails(orcid, putCode): Observable<any> {
return this._http
.get<Funding>(
runtimeEnvironment.API_WEB + orcid + `/fundingDetails.json?id=${putCode}`
runtimeEnvironment.API_WEB +
orcid +
`/fundingDetails.json?id=${putCode}`
)
.pipe(
retry(3),
Expand Down Expand Up @@ -165,7 +168,10 @@ export class RecordFundingsService {

save(funding: Funding) {
return this._http
.post<Funding>(runtimeEnvironment.API_WEB + `fundings/funding.json`, funding)
.post<Funding>(
runtimeEnvironment.API_WEB + `fundings/funding.json`,
funding
)
.pipe(
retry(3),
catchError((error) => this._errorHandler.handleError(error)),
Expand Down Expand Up @@ -196,7 +202,8 @@ export class RecordFundingsService {

loadFundingImportWizardList(): Observable<RecordImportWizard[]> {
return this._http.get<RecordImportWizard[]>(
runtimeEnvironment.API_WEB + 'workspace/retrieve-funding-import-wizards.json'
runtimeEnvironment.API_WEB +
'workspace/retrieve-funding-import-wizards.json'
)
}

Expand Down
9 changes: 6 additions & 3 deletions src/app/core/record-names/record-names.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ export class RecordNamesService {
}

this._http
.get<NamesEndPoint>(runtimeEnvironment.API_WEB + `account/nameForm.json`, {
headers: this.headers,
})
.get<NamesEndPoint>(
runtimeEnvironment.API_WEB + `account/nameForm.json`,
{
headers: this.headers,
}
)
.pipe(
retry(3),
catchError((error) => this._errorHandler.handleError(error)),
Expand Down
12 changes: 9 additions & 3 deletions src/app/core/record-peer-review/record-peer-review.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,25 @@ export class RecordPeerReviewService {

getPeerReviewById(putCode: number): Observable<PeerReview> {
return this._http.get<PeerReview>(
runtimeEnvironment.API_WEB + 'peer-reviews/peer-review.json?putCode=' + putCode
runtimeEnvironment.API_WEB +
'peer-reviews/peer-review.json?putCode=' +
putCode
)
}

getPeerReviewImportWizardList(): Observable<RecordImportWizard[]> {
return this._http.get<RecordImportWizard[]>(
runtimeEnvironment.API_WEB + 'workspace/retrieve-peer-review-import-wizards.json'
runtimeEnvironment.API_WEB +
'workspace/retrieve-peer-review-import-wizards.json'
)
}

getPublicPeerReviewById(orcid: string, putCode: number): Observable<any> {
return this._http.get(
runtimeEnvironment.API_WEB + orcid + '/peer-review.json?putCode=' + putCode
runtimeEnvironment.API_WEB +
orcid +
'/peer-review.json?putCode=' +
putCode
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export class RecordPublicSideBarService {

return this._http
.get<UserRecord>(
runtimeEnvironment.API_WEB + options.publicRecordId + `/public-record.json`,
runtimeEnvironment.API_WEB +
options.publicRecordId +
`/public-record.json`,
{
headers: this.headers,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Observable, of, ReplaySubject } from 'rxjs'
import { catchError, map, retry, tap } from 'rxjs/operators'
import { UserRecordOptions } from 'src/app/types/record.local'


import {
ResearchResource,
ResearchResourcesEndpoint,
Expand Down Expand Up @@ -97,7 +96,10 @@ export class RecordResearchResourceService {

getPublicResearchResourceById(orcid, putCode): Observable<ResearchResource> {
return this._http.get<ResearchResource>(
runtimeEnvironment.API_WEB + orcid + '/researchResource.json?id=' + putCode
runtimeEnvironment.API_WEB +
orcid +
'/researchResource.json?id=' +
putCode
)
}

Expand Down
Loading

0 comments on commit 70f10d1

Please sign in to comment.