Skip to content

Commit

Permalink
Revert "💥 feat: support umi@3 app (#106)" (#108)
Browse files Browse the repository at this point in the history
This reverts commit cfb00c7.
  • Loading branch information
chenshuai2144 authored Apr 30, 2020
1 parent 0e0596e commit 368bc65
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 59 deletions.
14 changes: 5 additions & 9 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@ if (!semver.satisfies(process.version, '>= 8.0.0')) {
const name = args._[0] || '';
const { type } = args;
delete args.type;

(async () => {
await run({
name,
type,
args,
});
process.exit(0);
})();
run({
name,
type,
args,
});
37 changes: 10 additions & 27 deletions lib/generators/ant-design-pro/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,17 @@ class AntDesignProGenerator extends BasicGenerator {
};
} else {
const prompts = [
{
name: 'nextPro',
type: 'confirm',
message: '🧙 Be the first to experience the new umi@3 ?',
default: false,
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 }) => {
filter: value => {
// 为了测试,没有任何用处
process.send && process.send({ type: 'prompt' });
process.emit('message', { type: 'prompt' });
return !nextPro;
return value;
},
},
{
Expand All @@ -70,20 +59,18 @@ class AntDesignProGenerator extends BasicGenerator {
message: '🚀 Do you need all the blocks or a simple scaffold?',
choices: ['simple', 'complete'],
default: 'simple',
when: ({ nextPro }) => {
filter: value => {
// 为了测试,没有任何用处
process.send && process.send({ type: 'prompt' });
process.emit('message', { type: 'prompt' });
return !nextPro;
return value;
},
},
{
name: 'nextAntd',
type: 'confirm',
when: ({ allBlocks, nextPro }) => {
process.send && process.send({ type: 'prompt' });
process.emit('message', { type: 'prompt' });
console.log(nextPro);
return allBlocks === 'simple' && !nextPro;
when: ({ allBlocks }) => {
return allBlocks === 'simple';
},
message: '🦄 Time to use better, faster and latest antd@4!',
default: true,
Expand All @@ -96,7 +83,7 @@ class AntDesignProGenerator extends BasicGenerator {
}

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

const isTypeScript = language === 'TypeScript';
const projectName = this.opts.name || this.opts.env.cwd;
Expand All @@ -114,18 +101,14 @@ class AntDesignProGenerator extends BasicGenerator {
gitArgs.push('--branch', 'antd@3');
}

if (nextPro) {
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) {
if (this.opts.args.branch) {
gitArgs.push('--branch', this.opts.args.branch);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const run = async config => {

try {
return runGenerator(`./generators/${type}`, config);
} catch (e) {
} catch(e) {
console.error(chalk.red(`> Generate failed`), e);
process.exit(1);
}
Expand Down
6 changes: 0 additions & 6 deletions test/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ 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
? 🤓 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
❯ 🚚 clone success
❯ Clean up...
Expand All @@ -34,8 +31,6 @@ 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
? 🤓 Which language do you want to use? (Use arrow keys)
❯ TypeScript
JavaScript ? 🤓 Which language do you want to use?
Expand All @@ -44,7 +39,6 @@ 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
❯ 🚚 clone success
❯ [Sylvanas] Prepare js environment...
Expand Down
20 changes: 4 additions & 16 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ describe('test umi-create', () => {
.beforeScript(path.join(fixtures, 'mock_github.js'))
.waitForPrompt()
.write('\n')
.write('\n')
.write('\n')
.writeKey('DOWN', 'ENTER')
.write('\n')
.write('\n')
Expand Down Expand Up @@ -53,8 +51,6 @@ describe('test umi-create', () => {
.write('\n')
.write('\n')
.write('\n')
.write('\n')
.write('\n')
.end();

expect(winEOL(response.stdout).replace(/>/g, '❯')).toMatchSnapshot();
Expand Down Expand Up @@ -82,9 +78,6 @@ describe('typescript', () => {
.write('\n')
.write('\n')
.write('\n')
.write('\n')
.write('\n')
.write('\n')
.end();

expect(response.code).toBe(0);
Expand All @@ -109,14 +102,13 @@ describe('typescript', () => {
.beforeScript(path.join(fixtures, 'mock_github.js'))
.waitForPrompt()
.write('\n')
.write('\n')
.write('\n')
// ts
.write('\n')
// all-blocks
.writeKey('DOWN', 'ENTER')
.write('\n')
.end();

expect(response.code).toBe(0);
expect(fs.existsSync(path.join(temp, '/src/pages/exception/403/index.tsx'))).toBeTruthy();
});
Expand All @@ -135,18 +127,14 @@ describe('typescript', () => {
})
.beforeScript(path.join(fixtures, 'mock_github.js'))
.waitForPrompt()
.writeKey('ENTER')
.writeKey('ENTER')
.writeKey('ENTER')
.write('\n')
// js
.writeKey('DOWN', 'ENTER')
// all blocks
.writeKey('DOWN', 'ENTER')
.writeKey('ENTER')
.writeKey('ENTER')
.write('\n')
.end();
console.log(response);
console.log(temp);

expect(response.code).toBe(0);
expect(fs.existsSync(path.join(temp, 'tsconfig.json'))).toBeFalsy();
expect(fs.existsSync(path.join(temp, '/src/pages/exception/403/index.jsx'))).toBeTruthy();
Expand Down

0 comments on commit 368bc65

Please sign in to comment.