1 | import inquirer from 'inquirer';
|
2 | import path from "path";
|
3 | import {Group} from "./classLibrary/Group";
|
4 | import {CyanSafe} from "./classLibrary/TargetUtil/CyanResponse";
|
5 | import {GenerateTemplate, Interrogate} from "./generator";
|
6 | import {Dependency} from "./Depedency";
|
7 |
|
8 | export async function Create(dep: Dependency, folderName: string): Promise<string> {
|
9 |
|
10 | let root = path.resolve(__dirname, '../templates');
|
11 | let group: Group = new Group(dep.core, dep.objex, root, dep.util);
|
12 |
|
13 | let map: Map<string, string> = new Map(group.ListAsArray());
|
14 |
|
15 | let answers: any = await inquirer.prompt([
|
16 | {
|
17 | type: "list",
|
18 | message: "Please choose the template Group you want to use",
|
19 | name: "group",
|
20 | choices: map.Keys()
|
21 | }
|
22 | ]);
|
23 | return await CreateTemplates(dep, group, map.get(answers["group"])!, folderName);
|
24 | }
|
25 |
|
26 | async function CreateTemplates(dep: Dependency, g: Group, group: string, folderName: string): Promise<string> {
|
27 |
|
28 |
|
29 | let root = path.resolve(__dirname, '../templates/', group);
|
30 |
|
31 |
|
32 | const templates: Map<string, string>
|
33 | = new Map(g.ListTemplate(group).Map(([k, v]) => [v, k] as [string, string]));
|
34 |
|
35 |
|
36 | let answers: any = await inquirer.prompt([
|
37 | {
|
38 | type: "list",
|
39 | message: "Please choose the template to use",
|
40 | name: "template",
|
41 | choices: templates.Keys()
|
42 | }
|
43 | ]);
|
44 |
|
45 | let templatePath = path.resolve(root, templates.get(answers["template"])!);
|
46 |
|
47 | let settings: CyanSafe = await Interrogate(dep, dep.autoInquirer, templatePath, folderName);
|
48 | return GenerateTemplate(dep, templatePath, folderName, settings, true);
|
49 | }
|
50 |
|