Skip to content

Commit

Permalink
fix: support base url for stage and prod env
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-pribilinskiy committed Jun 18, 2023
1 parent 6149e00 commit 7ca2f02
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
22 changes: 14 additions & 8 deletions src/helpers/cloudbedsRemoteManifests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@ import {
CLOUDBEDS_REMOTES_MANIFEST_FILE_NAME,
} from '../constants';
import { ModuleFederationTypesPluginOptions, RemoteManifestUrls } from '../types';
import { isValidUrl } from './validation';

export function getRemoteManifestUrls(options?: ModuleFederationTypesPluginOptions): RemoteManifestUrls | undefined {
if (options?.cloudbedsRemoteManifestsBaseUrl !== undefined) {
let artifactsBaseUrl: string = CloudbedsCloudfrontDomain.Dev as string;
let manifestBaseUrl = `${CloudbedsCloudfrontDomain.Dev}/remotes/dev-ga`;
let artifactsBaseUrl = '';
let manifestBaseUrl = options?.cloudbedsRemoteManifestsBaseUrl;

if (['stage', 'stage-ga'].includes(manifestBaseUrl)) {
artifactsBaseUrl = `${CloudbedsCloudfrontDomain.Stage}/builds`;
manifestBaseUrl = `${CloudbedsCloudfrontDomain.Stage}/remotes/stage-ga/{version}`;
} else if (['prod', 'prod-ga'].includes(manifestBaseUrl)) {
artifactsBaseUrl = `${CloudbedsCloudfrontDomain.Prod}/builds`;
manifestBaseUrl = `${CloudbedsCloudfrontDomain.Prod}/remotes/prod-ga/{version}`;
if (!isValidUrl(manifestBaseUrl)) {
artifactsBaseUrl = CloudbedsCloudfrontDomain.Dev;
manifestBaseUrl = `${CloudbedsCloudfrontDomain.Dev}/remotes/dev-ga`;

if (['stage', 'stage-ga'].includes(manifestBaseUrl)) {
artifactsBaseUrl = `${CloudbedsCloudfrontDomain.Stage}/builds`;
manifestBaseUrl = `${CloudbedsCloudfrontDomain.Stage}/remotes/stage-ga/{version}`;
} else if (['prod', 'prod-ga'].includes(manifestBaseUrl)) {
artifactsBaseUrl = `${CloudbedsCloudfrontDomain.Prod}/builds`;
manifestBaseUrl = `${CloudbedsCloudfrontDomain.Prod}/remotes/prod-ga/{version}`;
}
}

return {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type ModuleFederationTypesPluginOptions = {
remoteManifestUrls?: RemoteManifestUrls,
remoteManifestUrl?: string,

cloudbedsRemoteManifestsBaseUrl?: string | /** @deprecated */ 'use-domain-name'
cloudbedsRemoteManifestsBaseUrl?: string | ''
| 'dev' | 'dev-ga'
| 'stage' | 'stage-ga'
| 'prod' | 'prod-ga',
Expand Down

0 comments on commit 7ca2f02

Please sign in to comment.