forked from solidjs-community/solid-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstants.ts
More file actions
122 lines (108 loc) · 3.11 KB
/
constants.ts
File metadata and controls
122 lines (108 loc) · 3.11 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
export const GIT_IGNORE = `dist
.wrangler
.output
.vercel
.netlify
.vinxi
app.config.timestamp_*.js
# Environment
.env
.env*.local
# dependencies
/node_modules
# IDEs and editors
/.idea
.project
.classpath
*.launch
.settings/
# Temp
gitignore
# System Files
.DS_Store
Thumbs.db
`;
export const JS_CONFIG = {
compilerOptions: {
jsx: "preserve",
jsxImportSource: "solid-js",
paths: {
"~/*": ["./src/*"],
},
},
};
// Supported templates
/**Supported Vanilla Templates */
const VANILLA_TEMPLATES = [
"ts",
"ts-vitest",
"ts-uvu",
"ts-unocss",
"ts-tailwindcss",
"ts-sass",
"ts-router",
"ts-router-file-based",
"ts-minimal",
"ts-jest",
"ts-bootstrap",
"js",
"js-vitest",
"js-tailwindcss",
] as const satisfies string[];
export type VanillaTemplate = (typeof VANILLA_TEMPLATES)[number];
/**
* @description This list is hardcoded. But templates are fetched from another github repo.
* @see https://github.com/solidjs/templates/tree/main/solid-start
*/
const START_TEMPLATES = [
"basic",
"bare",
"with-solidbase",
"with-auth",
"with-authjs",
"with-drizzle",
"with-mdx",
"with-prisma",
"with-solid-styled",
"with-tailwindcss",
"with-tanstack-router",
"with-trpc",
"with-unocss",
"with-vitest",
"with-strict-csp",
] as const satisfies string[];
export type StartTemplate = (typeof START_TEMPLATES)[number];
/**Supported Library Templates */
export const LIBRARY_TEMPLATES = ["solid-lib-starter"] as const satisfies string[];
export type LibraryTemplate = (typeof LIBRARY_TEMPLATES)[number];
export const PROJECT_TYPES = ["start", "vanilla", "library"] as const satisfies string[];
export type ProjectType = (typeof PROJECT_TYPES)[number];
/**
* Fetches the template list for the project type given
* @param projectType type of project
*/
export function getTemplatesList(projectType: "vanilla"): StartTemplate[];
export function getTemplatesList(projectType: "start"): VanillaTemplate[];
export function getTemplatesList(projectType: "library"): VanillaTemplate[];
export function getTemplatesList(projectType: ProjectType): VanillaTemplate[] | StartTemplate[] | LibraryTemplate[];
export function getTemplatesList(projectType: ProjectType) {
if (projectType === "start") {
return START_TEMPLATES as StartTemplate[];
} else if (projectType === "library") {
return LIBRARY_TEMPLATES as LibraryTemplate[];
}
return VANILLA_TEMPLATES as VanillaTemplate[];
}
/**
* Tests is the template given is a valid template, and returns it as a template if it is
* @param type expected type of the template
* @param maybe_template the template string to test
* @returns the template string if it is valid, undefined if not
*/
export function isValidTemplate(type: "vanilla", maybe_template: string): maybe_template is VanillaTemplate;
export function isValidTemplate(type: "start", maybe_template: string): maybe_template is StartTemplate;
export function isValidTemplate(type: "library", maybe_template: string): maybe_template is LibraryTemplate;
export function isValidTemplate(type: ProjectType, maybe_template: string) {
const templates = getTemplatesList(type);
return templates.find((t) => t === maybe_template) !== undefined;
}