Skip to content

Commit

Permalink
chore: fix remove pro v5 (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Jul 4, 2021
1 parent 4fa31e7 commit bcc36b5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 52 deletions.
51 changes: 1 addition & 50 deletions lib/generators/ant-design-pro/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,54 +40,19 @@ class AntDesignProGenerator extends BasicGenerator {
};
} else {
const prompts = [
{
name: 'nextPro',
type: 'list',
choices: ['Pro V5', 'Pro V4'],
message: '🧙 Be the first to experience the new umi@3 ?',
default: 'Pro V4',
when: () => {
// 为了测试,没有任何用处
process.send && process.send({ type: 'prompt' });
process.emit('message', { type: 'prompt' });
return true;
},
},
{
name: 'language',
type: 'list',
message: '🤓 Which language do you want to use?',
choices: ['TypeScript', 'JavaScript'],
default: 'TypeScript',
when: ({ nextPro }) => {
process.send && process.send({ type: 'prompt' });
process.emit('message', { type: 'prompt' });
return nextPro === 'Pro V4';
},
},
{
name: 'allBlocks',
type: 'list',
message: '🚀 Do you need all the blocks or a simple scaffold?',
choices: ['simple', 'complete'],
default: 'simple',
when: ({ nextPro }) => {
process.send && process.send({ type: 'prompt' });
process.emit('message', { type: 'prompt' });
return nextPro === 'Pro V4';
},
},
{
name: 'nextAntd',
type: 'list',
choices: ['antd@4', 'antd@3'],
when: ({ allBlocks, nextPro }) => {
process.send && process.send({ type: 'prompt' });
process.emit('message', { type: 'prompt' });
return allBlocks === 'simple' && nextPro === 'Pro V4';
},
message: '🦄 Time to use better, faster and latest antd@4!',
default: 'antd@4',
},
];
return this.prompt(prompts).then(props => {
Expand All @@ -97,7 +62,7 @@ class AntDesignProGenerator extends BasicGenerator {
}

async writing() {
const { language = 'TypeScript', allBlocks, nextPro, nextAntd } = this.prompts;
const { language = 'TypeScript', allBlocks, } = this.prompts;

const isTypeScript = language === 'TypeScript';
const projectName = this.opts.name || this.opts.env.cwd;
Expand All @@ -110,26 +75,12 @@ class AntDesignProGenerator extends BasicGenerator {
const githubUrl = await getGithubUrl();
const gitArgs = [`clone`, githubUrl, `--depth=1`];

// 如果想要使用旧的 antd,使用 antd@3 分支
if (nextAntd === 'antd@3' && allBlocks === 'simple') {
gitArgs.push('--branch', 'antd@3');
}

if (nextPro === 'Pro V5') {
gitArgs.push('--branch', 'v5');
}

// all-blocks 分支上包含了所有的区块
if (allBlocks === 'complete') {
log(`🙈 complete mode can only use the version of antd@4`);
gitArgs.push('--branch', 'all-blocks');
}

// Set branch if provided
if (this.opts.args.branch && !nextPro) {
gitArgs.push('--branch', this.opts.args.branch);
}

gitArgs.push(projectName);

// // 没有提供关闭的配置
Expand Down
2 changes: 0 additions & 2 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ describe('typescript', () => {
.beforeScript(path.join(fixtures, 'mock_github.js'))
.waitForPrompt()
.writeKey('ENTER')
.writeKey('ENTER')
.writeKey('ENTER')
// js
.writeKey('DOWN', 'ENTER')
// all blocks
Expand Down

0 comments on commit bcc36b5

Please sign in to comment.