Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: all use select #111

Merged
merged 1 commit into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions lib/generators/ant-design-pro/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ class AntDesignProGenerator extends BasicGenerator {
const prompts = [
{
name: 'nextPro',
type: 'confirm',
type: 'list',
choices: ['Pro V5', 'Pro V4'],
message: '🧙 Be the first to experience the new umi@3 ?',
default: false,
default: 'Pro V4',
when: () => {
// 为了测试,没有任何用处
process.send && process.send({ type: 'prompt' });
Expand All @@ -61,7 +62,7 @@ class AntDesignProGenerator extends BasicGenerator {
when: ({ nextPro }) => {
process.send && process.send({ type: 'prompt' });
process.emit('message', { type: 'prompt' });
return !nextPro;
return nextPro === 'Pro V4';
},
},
{
Expand All @@ -73,20 +74,20 @@ class AntDesignProGenerator extends BasicGenerator {
when: ({ nextPro }) => {
process.send && process.send({ type: 'prompt' });
process.emit('message', { type: 'prompt' });
return !nextPro;
return nextPro === 'Pro V4';
},
},
{
name: 'nextAntd',
type: 'confirm',
type: 'list',
choices: ['antd@4', 'antd@3'],
when: ({ allBlocks, nextPro }) => {
process.send && process.send({ type: 'prompt' });
process.emit('message', { type: 'prompt' });
console.log(nextPro);
return allBlocks === 'simple' && !nextPro;
return allBlocks === 'simple' && nextPro === 'Pro V4';
},
message: '🦄 Time to use better, faster and latest antd@4!',
default: true,
default: 'antd@4',
},
];
return this.prompt(prompts).then(props => {
Expand All @@ -110,11 +111,11 @@ class AntDesignProGenerator extends BasicGenerator {
const gitArgs = [`clone`, githubUrl, `--depth=1`];

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

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

Expand Down
20 changes: 12 additions & 8 deletions test/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ exports[`test umi-create test generate antd pro project from gitee.org 1`] = `
block - Create a umi block.
library - Create a library with umi.
plugin - Create a umi plugin. ? Select the boilerplate type ant-design-pro
? 🧙 Be the first to experience the new umi@3 ? (y/N) ? 🧙 Be the first to experience the new umi@3 ? No

? 🧙 Be the first to experience the new umi@3 ? (Use arrow keys)
Pro V5
❯ Pro V4 ? 🧙 Be the first to experience the new umi@3 ? Pro V4
? 🤓 Which language do you want to use? (Use arrow keys)
❯ TypeScript
JavaScript ? 🤓 Which language do you want to use? TypeScript
? 🚀 Do you need all the blocks or a simple scaffold? (Use arrow keys)
❯ simple
complete ? 🚀 Do you need all the blocks or a simple scaffold? simple
false
? 🦄 Time to use better, faster and latest antd@4! (Y/n) ? 🦄 Time to use better, faster and latest antd@4! Yes
? 🦄 Time to use better, faster and latest antd@4! (Use arrow keys)
❯ antd@4
antd@3 ? 🦄 Time to use better, faster and latest antd@4! antd@4
❯ 🚚 clone success
❯ Clean up...
✨ File Generate Done
Expand All @@ -34,8 +36,9 @@ exports[`test umi-create test generate antd pro project from github 1`] = `
block - Create a umi block.
library - Create a library with umi.
plugin - Create a umi plugin. ? Select the boilerplate type ant-design-pro
? 🧙 Be the first to experience the new umi@3 ? (y/N) ? 🧙 Be the first to experience the new umi@3 ? No

? 🧙 Be the first to experience the new umi@3 ? (Use arrow keys)
Pro V5
❯ Pro V4 ? 🧙 Be the first to experience the new umi@3 ? Pro V4
? 🤓 Which language do you want to use? (Use arrow keys)
❯ TypeScript
JavaScript ? 🤓 Which language do you want to use?
Expand All @@ -44,8 +47,9 @@ exports[`test umi-create test generate antd pro project from github 1`] = `
? 🚀 Do you need all the blocks or a simple scaffold? (Use arrow keys)
❯ simple
complete ? 🚀 Do you need all the blocks or a simple scaffold? simple
false
? 🦄 Time to use better, faster and latest antd@4! (Y/n) ? 🦄 Time to use better, faster and latest antd@4! Yes
? 🦄 Time to use better, faster and latest antd@4! (Use arrow keys)
❯ antd@4
antd@3 ? 🦄 Time to use better, faster and latest antd@4! antd@4
❯ 🚚 clone success
❯ [Sylvanas] Prepare js environment...
❯ [JS] Clean up...
Expand Down