forked from anthonyromaine/cs472-team6
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filesystem.js
139 lines (125 loc) · 3.54 KB
/
filesystem.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
import fs from 'node:fs';
import path from 'node:path';
const baseFiles = [
'webcontainer/package.json',
'webcontainer/postcss.config.js',
'webcontainer/vite.config.js',
'index.html',
'tailwind.config.cjs',
]
const publicFiles = [
'public/vite.svg'
]
const srcFiles = [
'src/index.css',
'src/main.jsx',
'webcontainer/App.jsx',
'webcontainer/registeredComponents.js'
]
const componentFiles = new Map([
['404Section', [
'src/components/404Section/FourZeroFour.jsx',
'src/components/404Section/404_img.png'
]],
['AboutHeadImages', [
'src/components/AboutHeadImages/AboutHeadImages.jsx'
]],
['AboutHeadSection', [
'src/components/AboutHeadSection/AboutHeadSection.jsx'
]],
['Banner', [
'src/components/Banner/Banner.jsx',
'src/components/Banner/star.svg'
]],
['BlogPage', [
'src/components/BlogPage/BlogPage.jsx'
]],
// ['Companies', [
// 'src/components/Companies/Companies.jsx'
// ]],
['ContactSection', [
'src/components/ContactSection/ContactSection.jsx',
'src/components/ContactSection/emailIcon.svg',
'src/components/ContactSection/phoneIcon.svg',
'src/components/ContactSection/miniEmailIcon.svg',
'src/components/ContactSection/miniDollarIcon.svg',
'src/components/ContactSection/blackMiniDollarSign.svg',
'src/components/ContactSection/blackMiniEmail.svg'
]],
['CtaSection', [
'src/components/CtaSection/CtaSection.jsx',
'src/components/CtaSection/vector.svg'
]],
['EducationAndWork', [
'src/components/EducationAndWork/EducationAndWork.jsx'
]],
['Footer', [
'src/components/Footer/Footer.jsx'
]],
['MoreArticles', [
'src/components/MoreArticles/MoreArticles.jsx'
]],
['NavbarComponent', [
'src/components/NavbarComponent/NavbarComponent.jsx'
]],
['ServicesSection', [
'src/components/ServicesSection/ServicesSection.jsx'
]],
['ServiceWrapper', [
'src/components/ServiceWrapper/ServiceWrapper.jsx'
]],
['Skills', [
'src/components/Skills/Skills.jsx'
]],
['SocialMedia', [
'src/components/SocialMedia/SocialMedia.jsx'
]],
['StatsWrapper', [
'src/components/StatsWrapper/StatsWrapper.jsx'
]],
['Testimonial', [
'src/components/Testimonial/Testimonial.jsx',
'src/components/Testimonial/star.svg'
]]
]);
class Directory {
directory = {};
addFile(filename, contents) {
this.directory[filename] = new File(contents);
}
addDir(dirname){
this.directory[dirname] = new Directory();
}
}
class File {
file = {};
constructor(contents){
this.file.contents = contents;
}
}
const files = {};
// add base files
for (const file of baseFiles){
files[path.basename(file)] = new File(Array.from(fs.readFileSync(path.join('./', file))));
}
// add public directory
files['public'] = new Directory();
// add public files
for (const file of publicFiles){
files['public'].addFile(path.basename(file), Array.from(fs.readFileSync(path.join('./', file))));
}
// add src files
files['src'] = new Directory();
for (const file of srcFiles){
files['src'].addFile(path.basename(file), Array.from(fs.readFileSync(path.join('./', file))));
}
files['src'].addDir('components');
let componentsFolder = files['src'].directory['components'];
for (const [folder, files] of componentFiles){
componentsFolder.addDir(folder);
let componentFolder = componentsFolder.directory[folder];
for (const file of files){
componentFolder.addFile(path.basename(file), Array.from(fs.readFileSync(path.join('./', file))));
}
}
fs.writeFileSync('./src/utils/files.js', "export const files = " + JSON.stringify(files));