mirror of
https://github.com/logto-io/logto.git
synced 2024-12-30 20:33:54 -05:00
chore(core,shared): add isDevFeatureEnabled to envset (#4707)
This commit is contained in:
parent
b5553e7237
commit
cc81d8de33
6 changed files with 12 additions and 7 deletions
|
@ -6,4 +6,4 @@ export const isCloud = yes(process.env.IS_CLOUD);
|
|||
export const adminEndpoint = process.env.ADMIN_ENDPOINT;
|
||||
// eslint-disable-next-line unicorn/prevent-abbreviations -- we love dev
|
||||
export const isDevFeaturesEnabled =
|
||||
yes(process.env.DEV_FEATURES_ENABLED) || yes(process.env.INTEGRATION_TEST);
|
||||
!isProduction || yes(process.env.DEV_FEATURES_ENABLED) || yes(process.env.INTEGRATION_TEST);
|
||||
|
|
|
@ -5,7 +5,7 @@ import assertThat from '#src/utils/assert-that.js';
|
|||
|
||||
export const validateMfa = (mfa: Mfa) => {
|
||||
// TODO @sijie: remove this check when MFA is ready for production.
|
||||
if (EnvSet.values.isProduction && !EnvSet.values.isIntegrationTest) {
|
||||
if (!EnvSet.values.isDevFeaturesEnabled) {
|
||||
throw new Error('MFA is not ready for production yet.');
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import AppBoundary from './Providers/AppBoundary';
|
|||
import LoadingLayerProvider from './Providers/LoadingLayerProvider';
|
||||
import PageContextProvider from './Providers/PageContextProvider';
|
||||
import SettingsProvider from './Providers/SettingsProvider';
|
||||
import { isDevelopmentFeaturesEnabled } from './constants/env';
|
||||
import { isDevFeaturesEnabled as isDevelopmentFeaturesEnabled } from './constants/env';
|
||||
import Callback from './pages/Callback';
|
||||
import Consent from './pages/Consent';
|
||||
import Continue from './pages/Continue';
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import { yes } from '@silverhand/essentials';
|
||||
|
||||
export const isDevelopmentFeaturesEnabled =
|
||||
yes(process.env.DEV_FEATURES_ENABLED) || yes(process.env.INTEGRATION_TEST);
|
||||
// eslint-disable-next-line unicorn/prevent-abbreviations -- keep the same as in other packages
|
||||
export const isDevFeaturesEnabled =
|
||||
process.env.NODE_ENV !== 'production' ||
|
||||
yes(process.env.DEV_FEATURES_ENABLED) ||
|
||||
yes(process.env.INTEGRATION_TEST);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { conditional } from '@silverhand/essentials';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import { isDevelopmentFeaturesEnabled } from '@/constants/env';
|
||||
import { isDevFeaturesEnabled } from '@/constants/env';
|
||||
|
||||
import { type ErrorHandlers } from './use-error-handler';
|
||||
import useMfaErrorHandler, {
|
||||
|
@ -20,7 +20,7 @@ const usePreSignInErrorHandler = ({ replace, linkSocial }: Options = {}): ErrorH
|
|||
return useMemo(
|
||||
() => ({
|
||||
...requiredProfileErrorHandler,
|
||||
...conditional(isDevelopmentFeaturesEnabled && mfaErrorHandler),
|
||||
...conditional(isDevFeaturesEnabled && mfaErrorHandler),
|
||||
}),
|
||||
[mfaErrorHandler, requiredProfileErrorHandler]
|
||||
);
|
||||
|
|
2
packages/shared/src/node/env/GlobalValues.ts
vendored
2
packages/shared/src/node/env/GlobalValues.ts
vendored
|
@ -7,6 +7,8 @@ export default class GlobalValues {
|
|||
public readonly isProduction = getEnv('NODE_ENV') === 'production';
|
||||
public readonly isIntegrationTest = yes(getEnv('INTEGRATION_TEST'));
|
||||
public readonly isUnitTest = getEnv('NODE_ENV') === 'test';
|
||||
public readonly isDevFeaturesEnabled =
|
||||
!this.isProduction || yes(getEnv('DEV_FEATURES_ENABLED')) || this.isIntegrationTest;
|
||||
|
||||
public readonly httpsCert = process.env.HTTPS_CERT_PATH;
|
||||
public readonly httpsKey = process.env.HTTPS_KEY_PATH;
|
||||
|
|
Loading…
Reference in a new issue