mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-19 10:07:46 -05:00
36 lines
853 B
TypeScript
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 };
|