Commit cf62ddb1 authored by tom goriunov's avatar tom goriunov Committed by GitHub

fix envs validator (#1259)

[skip ci] fix envs validator
parent 57e70751
import isBrowser from 'lib/isBrowser';
import * as regexp from 'lib/regexp';
export const replaceQuotes = (value: string | undefined) => value?.replaceAll('\'', '"');
export const getEnvValue = (envName: string) => {
const envs = isBrowser() ? window.__envs : process.env;
......@@ -12,7 +14,7 @@ export const getEnvValue = (envName: string) => {
}
}
return envs[envName]?.replaceAll('\'', '"');
return replaceQuotes(envs[envName]);
};
export const parseEnvJson = <DataType>(env: string | undefined): DataType | null => {
......
......@@ -36,6 +36,9 @@ NEXT_PUBLIC_VIEWS_ADDRESS_IDENTICON_TYPE=gradient_avatar
# app features
NEXT_PUBLIC_APP_ENV=development
NEXT_PUBLIC_AD_BANNER_PROVIDER=adbutler
NEXT_PUBLIC_AD_ADBUTLER_CONFIG_DESKTOP='{ "id": "632019", "width": "728", "height": "90" }'
NEXT_PUBLIC_AD_ADBUTLER_CONFIG_MOBILE="{ 'id': '632018', 'width': '320', 'height': '100' }"
NEXT_PUBLIC_GRAPHIQL_TRANSACTION=0x4a0ed8ddf751a7cb5297f827699117b0f6d21a0b2907594d300dc9fed75c7e62
NEXT_PUBLIC_WEB3_WALLETS=['coinbase']
NEXT_PUBLIC_WEB3_DISABLE_ADD_TOKEN_TO_WALLET=true
......
......@@ -22,7 +22,7 @@ import { IDENTICON_TYPES } from '../../../types/views/address';
import { BLOCK_FIELDS_IDS } from '../../../types/views/block';
import type { BlockFieldId } from '../../../types/views/block';
import { getEnvValue } from '../../../configs/app/utils';
import { replaceQuotes } from '../../../configs/app/utils';
import * as regexp from '../../../lib/regexp';
const protocols = [ 'http', 'https' ];
......@@ -119,7 +119,7 @@ const rollupSchema = yup
const adButlerConfigSchema = yup
.object<AdButlerConfig>()
.transform(getEnvValue)
.transform(replaceQuotes)
.json()
.when('NEXT_PUBLIC_AD_BANNER_PROVIDER', {
is: (value: AdBannerProviders) => value === 'adbutler',
......@@ -288,7 +288,7 @@ const schema = yup
// a. homepage
NEXT_PUBLIC_HOMEPAGE_CHARTS: yup
.array()
.transform(getEnvValue)
.transform(replaceQuotes)
.json()
.of(yup.string<ChainIndicatorId>().oneOf([ 'daily_txs', 'coin_price', 'market_cap' ])),
NEXT_PUBLIC_HOMEPAGE_PLATE_TEXT_COLOR: yup.string(),
......@@ -303,7 +303,7 @@ const schema = yup
.of(featuredNetworkSchema),
NEXT_PUBLIC_OTHER_LINKS: yup
.array()
.transform(getEnvValue)
.transform(replaceQuotes)
.json()
.of(navItemExternalSchema),
NEXT_PUBLIC_NETWORK_LOGO: yup.string().test(urlTest),
......@@ -320,7 +320,7 @@ const schema = yup
// d. views
NEXT_PUBLIC_VIEWS_BLOCK_HIDDEN_FIELDS: yup
.array()
.transform(getEnvValue)
.transform(replaceQuotes)
.json()
.of(yup.string<BlockFieldId>().oneOf(BLOCK_FIELDS_IDS)),
NEXT_PUBLIC_VIEWS_ADDRESS_IDENTICON_TYPE: yup.string().oneOf(IDENTICON_TYPES),
......@@ -328,7 +328,7 @@ const schema = yup
// e. misc
NEXT_PUBLIC_NETWORK_EXPLORERS: yup
.array()
.transform(getEnvValue)
.transform(replaceQuotes)
.json()
.of(networkExplorerSchema),
NEXT_PUBLIC_HIDE_INDEXING_ALERT: yup.boolean(),
......@@ -346,7 +346,7 @@ const schema = yup
const isNoneSchema = yup.string().equals([ 'none' ]);
const isArrayOfWalletsSchema = yup
.array()
.transform(getEnvValue)
.transform(replaceQuotes)
.json()
.of(yup.string<WalletType>().oneOf(SUPPORTED_WALLETS));
......@@ -364,6 +364,9 @@ const schema = yup
NEXT_PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID: yup.string(),
NEXT_PUBLIC_MIXPANEL_PROJECT_TOKEN: yup.string(),
NEXT_PUBLIC_FAVICON_GENERATOR_API_KEY: yup.string(),
// Misc
NEXT_PUBLIC_USE_NEXT_JS_PROXY: yup.boolean(),
})
.concat(accountSchema)
.concat(adsBannerSchema)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment