From 36fda2f793e8e83d5f0bb3a476427f926aa003a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9F=E8=B4=A4?= Date: Mon, 27 Jun 2022 11:40:01 +0800 Subject: [PATCH] use umi@3 --- lib/BasicGenerator.js | 4 ++-- lib/generators/ant-design-pro/index.js | 12 +++++++----- lib/run.js | 8 ++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/BasicGenerator.js b/lib/BasicGenerator.js index b19dd9b..1441241 100644 --- a/lib/BasicGenerator.js +++ b/lib/BasicGenerator.js @@ -46,8 +46,8 @@ class BasicGenerator extends Generator { dot: true, }) .filter(filterFiles) - .filter(file => !file.includes('welcomeImgs')) - .forEach(file => { + .filter((file) => !file.includes('welcomeImgs')) + .forEach((file) => { debug(`copy ${file}`); const filePath = this.templatePath(file); if (statSync(filePath).isFile()) { diff --git a/lib/generators/ant-design-pro/index.js b/lib/generators/ant-design-pro/index.js index 4ff25be..568f091 100644 --- a/lib/generators/ant-design-pro/index.js +++ b/lib/generators/ant-design-pro/index.js @@ -17,7 +17,7 @@ function log(...args) { function globList(patternList, options) { let fileList = []; - patternList.forEach(pattern => { + patternList.forEach((pattern) => { fileList = [...fileList, ...glob.sync(pattern, options)]; }); @@ -55,14 +55,14 @@ class AntDesignProGenerator extends BasicGenerator { default: 'simple', }, ]; - return this.prompt(prompts).then(props => { + return this.prompt(prompts).then((props) => { this.prompts = props; }); } } async writing() { - const { language = 'TypeScript', allBlocks, } = this.prompts; + const { language = 'TypeScript', allBlocks } = this.prompts; const isTypeScript = language === 'TypeScript'; const projectName = this.opts.name || this.opts.env.cwd; @@ -79,6 +79,8 @@ class AntDesignProGenerator extends BasicGenerator { if (allBlocks === 'complete') { log(`🙈 complete mode can only use the version of antd@4`); gitArgs.push('--branch', 'all-blocks'); + } else { + gitArgs.push('--branch', 'umi@3'); } gitArgs.push(projectName); @@ -135,7 +137,7 @@ class AntDesignProGenerator extends BasicGenerator { log('[JS] Clean up...'); const removeTsFiles = globList(['tsconfig.json', '**/*.d.ts'], envOptions); - removeTsFiles.forEach(filePath => { + removeTsFiles.forEach((filePath) => { const targetPath = path.resolve(projectPath, filePath); fs.removeSync(targetPath); }); @@ -172,7 +174,7 @@ class AntDesignProGenerator extends BasicGenerator { const ignoreFiles = pkg['create-umi'].ignore; const fileList = globList(ignoreFiles, envOptions); - fileList.forEach(filePath => { + fileList.forEach((filePath) => { const targetPath = path.resolve(projectPath, filePath); fs.removeSync(targetPath); }); diff --git a/lib/run.js b/lib/run.js index daac120..68414ad 100644 --- a/lib/run.js +++ b/lib/run.js @@ -8,8 +8,8 @@ const yeoman = require('yeoman-environment'); const generators = fs .readdirSync(`${__dirname}/generators`) - .filter(f => !f.startsWith('.')) - .map(f => { + .filter((f) => !f.startsWith('.')) + .map((f) => { return { name: `${f.padEnd(15)} - ${chalk.gray(require(`./generators/${f}/meta.json`).description)}`, value: f, @@ -18,7 +18,7 @@ const generators = fs }); const runGenerator = async (generatorPath, { name = '', cwd = process.cwd(), args = {} }) => { - return new Promise(resolve => { + return new Promise((resolve) => { if (name) { mkdirp.sync(name); cwd = path.join(cwd, name); @@ -48,7 +48,7 @@ const runGenerator = async (generatorPath, { name = '', cwd = process.cwd(), arg }); }; -const run = async config => { +const run = async (config) => { process.send && process.send({ type: 'prompt' }); process.emit('message', { type: 'prompt' });