refactor(config): removed new tools env config

This commit is contained in:
Corentin Thomasset 2023-04-10 13:11:10 +02:00
parent 9d639edf2d
commit 9fa4c26929
No known key found for this signature in database
GPG key ID: DBD997E935996158
3 changed files with 3 additions and 17 deletions

View file

@ -1,17 +1,10 @@
import { config } from '@/config';
import { isAfter, subWeeks } from 'date-fns';
import type { Tool } from './tools.types';
type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
export function defineTool(
tool: WithOptional<Tool, 'isNew'>,
{ newTools }: { newTools: string[] } = { newTools: config.tools.newTools },
) {
const isInNewToolConfig = newTools.includes(tool.name);
const isRecentTool = tool.createdAt ? isAfter(tool.createdAt, subWeeks(new Date(), 2)) : false;
const isNew = isInNewToolConfig || isRecentTool;
export function defineTool(tool: WithOptional<Tool, 'isNew'>) {
const isNew = tool.createdAt ? isAfter(tool.createdAt, subWeeks(new Date(), 2)) : false;
return {
isNew,