forked from alibaba/lowcode-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
84 lines (80 loc) · 1.85 KB
/
index.ts
File metadata and controls
84 lines (80 loc) · 1.85 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env node
import * as inquirer from 'inquirer';
import * as path from 'path';
import initComponent from './component';
import initSetter from './setter';
import initPlugin from './plugin';
import initEditor from './editor';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers'
const getQuestions = ({ argv }) => {
return [
{
type: 'list',
name: 'componentType',
message: '请选择引擎生态元素类型',
choices: [
{
name: '组件/物料',
value: 'component',
},
{
name: '设置器 (setter)',
value: 'setter',
},
{
name: '插件 (plugin)',
value: 'plugin',
},
{
name: '编辑器 (editor)',
value: 'editor',
},
]
},
{
type: 'input',
name: 'projectName',
message: '生态元素包名',
default(ans) {
const pathBaseName = path.basename(path.join(process.cwd(), argv._[0] || './'));
return pathBaseName;
}
},
{
type: 'input',
name: 'description',
message: '简要介绍生态元素',
default(ans) {
return ans.projectName;
},
},
{
type: 'input',
name: 'author',
message: '作者名',
default() {
return process.env.USER || process.env.USERNAME;
},
},
];
}
const initMap = {
component: initComponent,
setter: initSetter,
plugin: initPlugin,
editor: initEditor,
};
const main = async () => {
const argv = yargs(hideBin(process.argv))
.options('beta', {
type: 'boolean',
describe: 'use beta template package to init',
default: false,
})
.argv;
const result = await inquirer.prompt(getQuestions({ argv }));
const initializer = initMap[result.componentType];
await initializer(result);
}
main();