Files
freeCodeCamp/tools/challenge-helper-scripts/helpers/project-metadata.ts
2025-10-23 10:54:57 +05:30

36 lines
853 B
TypeScript

import path from 'path';
import {
getBlockStructure,
writeBlockStructure
} from '../../../curriculum/src/file-handler';
import { getProjectPath } from './get-project-info';
export type Meta = {
name: string;
blockLayout: string;
blockType: string;
isUpcomingChange: boolean;
dashedName: string;
helpCategory: string;
time: string;
template: string;
required: string[];
challengeOrder: { id: string; title: string }[];
};
function getMetaData() {
const block = getBlock(getProjectPath());
return getBlockStructure(block) as Meta;
}
function getBlock(filePath: string) {
return path.basename(filePath);
}
async function updateMetaData(newMetaData: Record<string, unknown>) {
const block = getBlock(getProjectPath());
await writeBlockStructure(block, newMetaData);
}
export { getMetaData, updateMetaData, getBlock };