forked from lgwebdream/fe-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvue2code.js
More file actions
37 lines (31 loc) · 894 Bytes
/
vue2code.js
File metadata and controls
37 lines (31 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const { join } = require('path');
const { prompt } = require('inquirer');
const { generateVueCode } = require('../lib/utils/vue2Code');
// 交互问题采集
const questions = [
{
type: 'list',
name: 'version',
message: 'Select of version: ',
choices: ['vue2', 'vue3'],
default: 'vue2',
},
];
const templatePath = join(__dirname, '../lib/vue/');
const vue2code = program => {
program
.command('vue2code')
.alias('v2c')
.usage('-o <output>')
.description('🍉 generate vue code of crud')
.requiredOption('-o, --output <output>', 'path of generation file')
.action(({ output }) => {
prompt(questions).then(answers => {
// write path
const toPath = join(process.cwd(), output);
// generate react crud code
generateVueCode(templatePath, toPath, answers);
});
});
};
module.exports = vue2code;