import fs from 'fs'; import path from 'path'; import { getApiEtaConfig } from '@configs/gen-source/api.config'; import { generateApiFile } from '@generator/generateApiFile'; import { getApiLabel } from '@questions/getApiLabel'; import { getPathOnCWD, getPathOnSrc } from '@utils/path'; export async function apiResolver() { const apiLabel = await getApiLabel(); const outputPath = getPathOnCWD('src', 'apis', apiLabel); const templatePath = getPathOnSrc('templates', 'api'); const templates = fs.readdirSync(templatePath, { encoding: 'utf-8', // withFileTypes: true, }); const config = getApiEtaConfig(apiLabel); templates.forEach(async (template) => { const targetTemplate = path.resolve(templatePath, template.name); generateApiFile({ targetTemplate, // outputPath, config, }); }); }