/* eslint-disable @typescript-eslint/no-var-requires */ const { mkdir, writeFile } = require('fs/promises'); const inquirer = require('inquirer'); const { join } = require('path'); const less = () => `@import '../../less/common.less'; @import '../../less/var.less'; `; const ts = (name) => `import './index.less'; console.log('${name}'); `; const ejs = (name) => ` <%- include('../_layout/base') -%> new page: <%= name %>

${name}

`; inquirer .prompt([ { type: 'input', name: 'name', message: '输入页面文件夹名称', }, ]) .then(async (res) => { const { name } = res; const targetDir = join(process.cwd(), 'src/view/pages', name); await mkdir(targetDir); await writeFile(`${targetDir}/index.ts`, ts(name)); await writeFile(`${targetDir}/index.ejs`, ejs(name)); await writeFile(`${targetDir}/index.less`, less()); });