-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
71 lines (54 loc) · 1.61 KB
/
index.ts
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
/*
* @Author: lyyyd David.Jackson.Lyd@gmail.com
* @Date: 2023-05-05 20:35:49
* @LastEditors: lyyyd David.Jackson.Lyd@gmail.com
* @LastEditTime: 2023-05-14 18:36:19
* @FilePath: \nestleify\src\index.ts
* @Description:
*
* Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
*/
import prompts from 'prompts'
import list, { ListOptions } from './list'
import { file, http, config, exec, Ware, Middleware } from './core'
import { Options, Context, Template } from './types'
import confirm from './confirm'
import require from './require'
import prepare from './prepare'
import upload from './upload.oss'
import writefile from './writefile'
import outtput from './outtput'
// export inject for test
const { inject } = prompts
const creator = new Ware<Context>()
creator.use(confirm)
creator.use(require)
creator.use(prepare)
creator.use(upload)
creator.use(outtput)
// creator.use(writefile)
export default async (template: string, project: string = '.', options: Options = {}, src: string): Promise<void> => {
// required arguments
if (template == null || template === '') {
throw new Error('Missing required argument: `template`.')
}
// await getMdFiles(src);
// create context
const context = {
template,
project,
options,
src: '',
dest: '',
config: Object.create(null),
answers: Object.create(null),
files: [],
fileInfoList: [],
// filePathsArr: [],
map: new Map(),
oss: new Map(),
}
// running creator
await creator.run(context)
}
export { inject, file, http, config, exec, Ware, list, Middleware, Options, Context, Template, ListOptions }