-
-
Notifications
You must be signed in to change notification settings - Fork 68
/
create.ts
95 lines (78 loc) · 2.41 KB
/
create.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// IMPORTS
import { Config, Libraries } from "./lib/create/common/config.ts";
import { ask, confirm } from "./lib/create/common/ask.ts";
import { createUltraApp } from "./lib/create/common/createUltraApp.ts";
import { c, gradient } from "./lib/create/common/styling.ts";
//INIT
console.log(gradient(
`
▄• ▄▌▄▄▌ ▄▄▄▄▄▄▄▄ ▄▄▄·
█▪██▌██• •██ ▀▄ █·▐█ ▀█
█▌▐█▌██▪ ▐█.▪▐▀▀▄ ▄█▀▀█
▐█▄█▌▐█▌▐▌ ▐█▌·▐█•█▌▐█ ▪▐▌
▀▀▀ .▀▀▀ ▀▀▀ .▀ ▀ ▀ ▀`,
.5,
));
console.log(`
\nWelcome to ${gradient("Ultra")}\n
Let's get you setup with your new ${gradient("Ultra")} project.
`);
const projectName =
(await ask<string>(`\nWhat is the name of your project?`)) ||
"my-ultra-app";
const useTypescript = await confirm("\nDo you want to use TypeScript?");
// if arguments were provided, use them instead of asking the user
if (Deno.args.length) {
// CONFIG GENERATION
const config: Config = {
ts: useTypescript,
name: projectName,
cwd: Deno.cwd(),
includes: Deno.args as Libraries[],
};
// FILE CREATION AND FORMATTING, will exit
await createUltraApp(config);
}
// or else, continue
const styleLibrary = await ask<Libraries>(
`\nWhich css/style library do you want to use?\n'${c(0, "(0) None ")} ${
c(1, "(1) Twind ")
} ${c(2, "(2) Stitches ")}`,
["none", "twind", "stitches"],
);
const routingLibrary = await ask<Libraries>(
`\nWhich routing library do you want to use?\n${c(0, "(0) None ")} ${
c(1, "(1) React Router ")
} ${c(2, "(2) Wouter ")}`,
["none", "react-router", "wouter"],
);
const headLibrary = await ask<Libraries>(
`\nWhich head management library do you want to use?\n${c(0, "(0) None ")} ${
c(1, "(1) React Helmet")
}`,
["none", "react-helmet-async"],
);
const queryLibrary = await ask<Libraries>(
`\nWhich query library do you want to use?\n${c(0, "(0) None")} ${
c(1, "(1) React Query")
}`,
["none", "react-query"],
);
// CONFIG GENERATION
function parseImports() {
const imports = [
styleLibrary,
routingLibrary,
headLibrary,
queryLibrary,
];
return imports as Libraries[];
}
const config: Config = {
ts: useTypescript,
name: projectName,
cwd: Deno.cwd(),
includes: parseImports(),
};
// FILE CREATION AND FORMATTING, will exit
await createUltraApp(config);