This repository has been archived by the owner on Jan 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
178 lines (138 loc) · 3.26 KB
/
index.js
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/env node
const {
exec
} = require('child_process')
const fs = require('fs')
const html = `<!DOCTYPE html>
<html lang="en">
<head>
<title>Tailwind Starter Template</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<link href="assets/css/style.css" rel="stylesheet" />
</head>
<body>
<h1 class="text-4xl text-center my-16 text-gray-400 font-bold font-sans">Greetings, comrade.</h1>
</body>
</html>`
const css = `
@tailwind base;
@tailwind components;
@tailwind utilities;`
const json = `{
"scripts": {
"dev": "parcel src/index.html",
"prod": "parcel build src/index.html --public-url='./'",
"build": "parcel build src/index.html --public-url='./'"
}
}
`
const commands = 'npm i -D @fullhuman/postcss-purgecss autoprefixer@^9 parcel-bundler postcss@^7 tailwindcss@npm:@tailwindcss/postcss7-compat'
function dependencies() {
console.log('📦 Installing dependencies from NPM... this will take a bit.');
console.log('✌ Configuring files in the meantime.');
exec(commands, (err) => {
if (err) {
throw err
} else {
console.log('✅ All done! \n');
}
})
}
function postcss() {
console.log(` ↳ Creating PostCSS config...`);
fs.writeFile('postcss.config.js', config, (err) => {
if (err) {
throw err
} else {
return console.log(' ✅ postcss.config.js\n')
}
})
}
function treeHTML() {
console.log(` ↳ Creating index.html...`);
fs.writeFile('src/index.html', html, (err) => {
if (err) {
throw err
} else {
console.log(' ✅ src/index.html\n')
}
})
}
function treeDirs() {
console.log(` ↳ Creating file structure...`);
fs.mkdir('src/assets/css', {
recursive: true
}, err => {
if (err) {
throw err
} else {
console.log(' ✅ src/assets/css')
}
})
fs.mkdir('src/assets/js', {
recursive: true
}, err => {
if (err) {
throw err
} else {
console.log(' ✅ src/assets/js\n')
}
})
}
function treeCSS() {
console.log(` ↳ Creating style.css...`);
fs.writeFile('src/assets/css/style.css', css, (err) => {
if (err) {
throw err
} else {
console.log(' ✅ style.css\n')
}
})
}
function treeJS() {
console.log(' ↳ Creating index.js...');
fs.writeFile('src/assets/js/index.js', '', (err) => {
if (err) {
throw err
} else { }
console.log(' ✅ index.js\n')
})
}
function treePkg() {
console.log(' ↳ Creating package.json...');
fs.writeFile('package.json', json, (err) => {
if (err) {
throw err
} else { }
console.log(' ✅ package.json\n')
})
}
async function install() {
treePkg()
await setTimeout(async () => {
dependencies()
}, 0)
await setTimeout(async () => {
postcss()
}, 10)
await setTimeout(async () => {
treeDirs()
}, 250)
await setTimeout(async () => {
treeHTML()
}, 500)
await setTimeout(async () => {
treeCSS()
}, 750)
await setTimeout(async () => {
treeJS()
}, 1000)
await setTimeout(async () => {
treePkg()
}, 1250)
await setTimeout(async () => {
console.log('Waiting for dependencies to finish installing...');
}, 1500)
}
install()