Flag deprecated environment variables
This commit is contained in:
parent
dfc05d5c14
commit
0de8087fb4
@ -10,6 +10,7 @@ import {
|
|||||||
} from '@/photo/db/query';
|
} from '@/photo/db/query';
|
||||||
import AdminAppInsightsClient from './AdminAppInsightsClient';
|
import AdminAppInsightsClient from './AdminAppInsightsClient';
|
||||||
import { getAllInsights, getGitHubMetaForCurrentApp } from '.';
|
import { getAllInsights, getGitHubMetaForCurrentApp } from '.';
|
||||||
|
import { USED_DEPRECATED_ENV_VARS } from '@/app/config';
|
||||||
|
|
||||||
export default async function AdminAppInsights() {
|
export default async function AdminAppInsights() {
|
||||||
const [
|
const [
|
||||||
@ -47,6 +48,7 @@ export default async function AdminAppInsights() {
|
|||||||
photosCountNeedSync,
|
photosCountNeedSync,
|
||||||
photosCountPortrait,
|
photosCountPortrait,
|
||||||
})}
|
})}
|
||||||
|
usedDeprecatedEnvVars={USED_DEPRECATED_ENV_VARS}
|
||||||
photoStats={{
|
photoStats={{
|
||||||
photosCount,
|
photosCount,
|
||||||
photosCountHidden,
|
photosCountHidden,
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
import ScoreCard from '@/components/ScoreCard';
|
import ScoreCard from '@/components/ScoreCard';
|
||||||
import ScoreCardRow from '@/components/ScoreCardRow';
|
import ScoreCardRow from '@/components/ScoreCardRow';
|
||||||
import { dateRangeForPhotos } from '@/photo';
|
import { dateRangeForPhotos } from '@/photo';
|
||||||
import { FaCircleInfo, FaRegCalendar } from 'react-icons/fa6';
|
import { FaArrowRight, FaCircleInfo, FaRegCalendar } from 'react-icons/fa6';
|
||||||
import { MdAspectRatio } from 'react-icons/md';
|
import { MdAspectRatio } from 'react-icons/md';
|
||||||
import { PiWarningBold } from 'react-icons/pi';
|
import { PiWarningBold } from 'react-icons/pi';
|
||||||
import { TbSparkles } from 'react-icons/tb';
|
import { TbSparkles } from 'react-icons/tb';
|
||||||
@ -17,9 +17,10 @@ import {
|
|||||||
TEMPLATE_REPO_URL_FORK,
|
TEMPLATE_REPO_URL_FORK,
|
||||||
TEMPLATE_REPO_URL_README,
|
TEMPLATE_REPO_URL_README,
|
||||||
CATEGORY_VISIBILITY,
|
CATEGORY_VISIBILITY,
|
||||||
|
USED_DEPRECATED_ENV_VARS,
|
||||||
} from '@/app/config';
|
} from '@/app/config';
|
||||||
import {
|
import {
|
||||||
AdminAppInsights,
|
getAllInsights,
|
||||||
getGitHubMetaForCurrentApp,
|
getGitHubMetaForCurrentApp,
|
||||||
hasTemplateRecommendations,
|
hasTemplateRecommendations,
|
||||||
PhotoStats,
|
PhotoStats,
|
||||||
@ -88,6 +89,7 @@ const renderHighlightText = (
|
|||||||
export default function AdminAppInsightsClient({
|
export default function AdminAppInsightsClient({
|
||||||
codeMeta,
|
codeMeta,
|
||||||
insights,
|
insights,
|
||||||
|
usedDeprecatedEnvVars,
|
||||||
photoStats: {
|
photoStats: {
|
||||||
photosCount,
|
photosCount,
|
||||||
photosCountHidden,
|
photosCountHidden,
|
||||||
@ -102,12 +104,14 @@ export default function AdminAppInsightsClient({
|
|||||||
},
|
},
|
||||||
}: {
|
}: {
|
||||||
codeMeta?: Awaited<ReturnType<typeof getGitHubMetaForCurrentApp>>
|
codeMeta?: Awaited<ReturnType<typeof getGitHubMetaForCurrentApp>>
|
||||||
insights: AdminAppInsights
|
insights: ReturnType<typeof getAllInsights>
|
||||||
|
usedDeprecatedEnvVars: typeof USED_DEPRECATED_ENV_VARS
|
||||||
photoStats: PhotoStats
|
photoStats: PhotoStats
|
||||||
}) {
|
}) {
|
||||||
const { shouldDebugInsights: debug } = useAppState();
|
const { shouldDebugInsights: debug } = useAppState();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
deprecatedEnvVars,
|
||||||
noFork,
|
noFork,
|
||||||
forkBehind,
|
forkBehind,
|
||||||
noAi,
|
noAi,
|
||||||
@ -250,6 +254,36 @@ export default function AdminAppInsightsClient({
|
|||||||
<ScoreCard title="Template recommendations">
|
<ScoreCard title="Template recommendations">
|
||||||
{(hasTemplateRecommendations(insights) || debug)
|
{(hasTemplateRecommendations(insights) || debug)
|
||||||
? <>
|
? <>
|
||||||
|
{(deprecatedEnvVars || debug) && <ScoreCardRow
|
||||||
|
icon={<PiWarningBold
|
||||||
|
size={17}
|
||||||
|
className={clsx(
|
||||||
|
'translate-x-[0.5px]',
|
||||||
|
TEXT_COLOR_WARNING,
|
||||||
|
)}
|
||||||
|
/>}
|
||||||
|
content={isExpanded => renderHighlightText(
|
||||||
|
'Update environment variables',
|
||||||
|
'yellow',
|
||||||
|
!isExpanded,
|
||||||
|
)}
|
||||||
|
expandContent={<div className="flex flex-col gap-2">
|
||||||
|
Future versions of this template will not build correctly
|
||||||
|
when including the following deprecated environment variables:
|
||||||
|
<div className="space-y-1">
|
||||||
|
{usedDeprecatedEnvVars.map(({ old, replacement }) => (
|
||||||
|
<div
|
||||||
|
key={old}
|
||||||
|
className="flex items-center gap-2"
|
||||||
|
>
|
||||||
|
<div className="text-xs">{old}</div>
|
||||||
|
<FaArrowRight size={10} />
|
||||||
|
<EnvVar variable={replacement} className="w-full" />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>}
|
||||||
|
/>}
|
||||||
{(noAiRateLimiting || debug) && <ScoreCardRow
|
{(noAiRateLimiting || debug) && <ScoreCardRow
|
||||||
icon={<PiWarningBold
|
icon={<PiWarningBold
|
||||||
size={17}
|
size={17}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import {
|
|||||||
HAS_STATIC_OPTIMIZATION,
|
HAS_STATIC_OPTIMIZATION,
|
||||||
GRID_HOMEPAGE_ENABLED,
|
GRID_HOMEPAGE_ENABLED,
|
||||||
AI_CONTENT_GENERATION_ENABLED,
|
AI_CONTENT_GENERATION_ENABLED,
|
||||||
|
HAS_DEPRECATED_ENV_VARS,
|
||||||
} from '@/app/config';
|
} from '@/app/config';
|
||||||
import { PhotoDateRange } from '@/photo';
|
import { PhotoDateRange } from '@/photo';
|
||||||
import { getGitHubMeta } from '@/platforms/github';
|
import { getGitHubMeta } from '@/platforms/github';
|
||||||
@ -25,6 +26,7 @@ const AdminAppInsightCode = [
|
|||||||
type AdminAppInsightCode = typeof AdminAppInsightCode[number];
|
type AdminAppInsightCode = typeof AdminAppInsightCode[number];
|
||||||
|
|
||||||
const _INSIGHTS_TEMPLATE = [
|
const _INSIGHTS_TEMPLATE = [
|
||||||
|
'deprecatedEnvVars',
|
||||||
'noAi',
|
'noAi',
|
||||||
'noAiRateLimiting',
|
'noAiRateLimiting',
|
||||||
'noConfiguredDomain',
|
'noConfiguredDomain',
|
||||||
@ -89,6 +91,7 @@ export const getSignificantInsights = ({
|
|||||||
} = APP_CONFIGURATION;
|
} = APP_CONFIGURATION;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
deprecatedEnvVars: HAS_DEPRECATED_ENV_VARS,
|
||||||
forkBehind: Boolean(codeMeta?.isBehind),
|
forkBehind: Boolean(codeMeta?.isBehind),
|
||||||
noAiRateLimiting: isAiTextGenerationEnabled && !hasRedisStorage,
|
noAiRateLimiting: isAiTextGenerationEnabled && !hasRedisStorage,
|
||||||
noConfiguredDomain: !hasDomain,
|
noConfiguredDomain: !hasDomain,
|
||||||
@ -108,13 +111,14 @@ export const indicatorStatusForSignificantInsights = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
deprecatedEnvVars,
|
||||||
forkBehind,
|
forkBehind,
|
||||||
noAiRateLimiting,
|
noAiRateLimiting,
|
||||||
noConfiguredDomain,
|
noConfiguredDomain,
|
||||||
photosNeedSync,
|
photosNeedSync,
|
||||||
} = insights;
|
} = insights;
|
||||||
|
|
||||||
if (noAiRateLimiting || noConfiguredDomain) {
|
if (deprecatedEnvVars || noAiRateLimiting || noConfiguredDomain) {
|
||||||
return 'yellow';
|
return 'yellow';
|
||||||
} else if (forkBehind || photosNeedSync) {
|
} else if (forkBehind || photosNeedSync) {
|
||||||
return 'blue';
|
return 'blue';
|
||||||
|
|||||||
@ -504,24 +504,37 @@ export const APP_CONFIGURATION = {
|
|||||||
commitUrl: VERCEL_GIT_COMMIT_URL,
|
commitUrl: VERCEL_GIT_COMMIT_URL,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ALL_LEGACY_ENV_VARS = [
|
const ALL_DEPRECATED_ENV_VARS = [{
|
||||||
{ old: 'NEXT_PUBLIC_SITE_DOMAIN', new: 'NEXT_PUBLIC_DOMAIN' },
|
old: 'NEXT_PUBLIC_SITE_DOMAIN',
|
||||||
{ old: 'NEXT_PUBLIC_SITE_DESCRIPTION', new: 'NEXT_PUBLIC_NAV_CAPTION' },
|
replacement: 'NEXT_PUBLIC_DOMAIN',
|
||||||
{ old: 'NEXT_PUBLIC_SITE_TITLE', new: 'NEXT_PUBLIC_META_TITLE' },
|
}, {
|
||||||
{ old: 'NEXT_PUBLIC_SITE_ABOUT', new: 'NEXT_PUBLIC_PAGE_ABOUT' },
|
old: 'NEXT_PUBLIC_SITE_DESCRIPTION',
|
||||||
// eslint-disable-next-line max-len
|
replacement: 'NEXT_PUBLIC_NAV_CAPTION',
|
||||||
{ old: 'NEXT_PUBLIC_STATICALLY_OPTIMIZE_PAGES', new: 'NEXT_PUBLIC_STATICALLY_OPTIMIZE_PHOTOS' },
|
}, {
|
||||||
// eslint-disable-next-line max-len
|
old: 'NEXT_PUBLIC_SITE_TITLE',
|
||||||
{ old: 'NEXT_PUBLIC_STATICALLY_OPTIMIZE_OG_IMAGES', new: 'NEXT_PUBLIC_STATICALLY_OPTIMIZE_PHOTO_OG_IMAGES' },
|
replacement: 'NEXT_PUBLIC_META_TITLE',
|
||||||
{ old: 'NEXT_PUBLIC_PRO_MODE', new: 'NEXT_PUBLIC_PRESERVE_ORIGINAL_UPLOADS' },
|
}, {
|
||||||
{ old: 'NEXT_PUBLIC_HIDE_SOCIAL', new: 'NEXT_PUBLIC_SOCIAL_NETWORKS' },
|
old: 'NEXT_PUBLIC_SITE_ABOUT',
|
||||||
];
|
replacement: 'NEXT_PUBLIC_PAGE_ABOUT',
|
||||||
|
}, {
|
||||||
|
old: 'NEXT_PUBLIC_STATICALLY_OPTIMIZE_PAGES',
|
||||||
|
replacement: 'NEXT_PUBLIC_STATICALLY_OPTIMIZE_PHOTOS',
|
||||||
|
}, {
|
||||||
|
old: 'NEXT_PUBLIC_STATICALLY_OPTIMIZE_OG_IMAGES',
|
||||||
|
replacement: 'NEXT_PUBLIC_STATICALLY_OPTIMIZE_PHOTO_OG_IMAGES',
|
||||||
|
}, {
|
||||||
|
old: 'NEXT_PUBLIC_PRO_MODE',
|
||||||
|
replacement: 'NEXT_PUBLIC_PRESERVE_ORIGINAL_UPLOADS',
|
||||||
|
}, {
|
||||||
|
old: 'NEXT_PUBLIC_HIDE_SOCIAL',
|
||||||
|
replacement: 'NEXT_PUBLIC_SOCIAL_NETWORKS',
|
||||||
|
}];
|
||||||
|
|
||||||
export const USED_LEGACY_ENV_VARS = ALL_LEGACY_ENV_VARS
|
export const USED_DEPRECATED_ENV_VARS = ALL_DEPRECATED_ENV_VARS
|
||||||
.filter(({ old }) => Boolean(process.env[old]));
|
.filter(({ old }) => Boolean(process.env[old]));
|
||||||
|
|
||||||
export const DOES_APP_HAVE_LEGACY_ENV_VARS =
|
export const HAS_DEPRECATED_ENV_VARS =
|
||||||
USED_LEGACY_ENV_VARS.length > 0;
|
USED_DEPRECATED_ENV_VARS.length > 0;
|
||||||
|
|
||||||
export const IS_APP_READY =
|
export const IS_APP_READY =
|
||||||
APP_CONFIGURATION.hasDatabase &&
|
APP_CONFIGURATION.hasDatabase &&
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user