import { join, dirname } from 'path'; import { promises as fs } from 'fs'; import api from './api'; const Template = (output, { api, title, redoc }) => fs.writeFile(output, ` ${title} `); const Api = output => fs.writeFile(output, JSON.stringify(api)); const Redoc = output => fs.copyFile(join( dirname(require.resolve('redoc')), 'redoc.standalone.js'), output); export default (async () => { const out = join(__dirname, 'static'); const apiFile = 'api.json'; const redocFile = 'redoc.js'; await fs.mkdir(out, { recursive: true }); return Promise.all([ Api(join(out, apiFile)), Redoc(join(out, redocFile)), Template(join(out, 'index.html'), { api: apiFile, title: api.info.title, redoc: redocFile }), ]); })();