-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean.js
169 lines (134 loc) · 4.62 KB
/
clean.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
import fs from 'fs-extra'
import path from 'path';
import replace from 'replace-in-file';
import * as readline from "readline-sync";
const pathToProject = path.resolve('./');
const demoProjectFolderName = '/Gulp_Default_Project'
const snippetsFolderName = '/mySnippets'
const readmeFolder = '/readmeFiles'
const src = '/#src'
const scriptModules = `${pathToProject}${src}/scripts/modules/`
const stylesModules = `${pathToProject}${src}/styles/modules/`
const fontsGitkeep = `${src}/fonts/.gitkeep`
const mainStyleFile = `${src}/styles/style.styl`
const mainHtmlFile = `${src}/index.html`
const mainScriptFile = `${src}/scripts/script.ts`
const gulpSliderConnectionFile = `${pathToProject}/gulpfile.js`
const slidersFile = `${pathToProject}${src}/scripts/sliders.js`
const srcDemoFoldersAndFIles =
[`${src}/img/demo`, `${src}/styles/_demoStyles.styl`, `${src}/_demo.htm`,];
const demoStyles = {
files: pathToProject + mainStyleFile,
from: "@import '_demoStyles';", to: '',
};
const demoHtml = {
files: pathToProject + mainHtmlFile,
from: "@@include('_demo.htm')", to: '',
};
const hint = '(enter [y], if you not, enter [enter or another])';
deleteFontsGitkeep()
await deleteDemoContent()
cleanReadmeFilesAndFolders()
deleteSnippets()
deleteDemoProject()
console.log('Initialize the slider? ' + hint);
await setSlider()
await setModules()
console.log('🎆🎆🎆 I wish You a successful job!');
async function setModules() {
await includeModuleByQuestion(`Include Burger Menu? ${hint}`,
`${scriptModules}fsNavmenu.ts`, `${stylesModules}_fsNavmenu.styl;`)
await includeModuleByQuestion(`Include Filter? ${hint}`,
`${scriptModules}filter.ts`)
await includeModuleByQuestion(`Include Modal-Window? ${hint}`,
`${scriptModules}modalWindow.ts`)
await includeModuleByQuestion(`Include Spoilers? ${hint}`,
`${scriptModules}spoiler.ts`, `${stylesModules}_spoiler.styl;`)
await includeModuleByQuestion(`Include Sidebar? ${hint}`,
`${scriptModules}sidebar.ts`, `${stylesModules}_sidebar.styl;`)
await includeModuleByQuestion(`Include Submenu? ${hint}`,
`${scriptModules}submenu.ts`, `${stylesModules}_submenu.styl;`)
await includeModuleByQuestion(`Include Accordion? ${hint}`,
`${scriptModules}accord.ts`)
await includeModuleByQuestion(`Include Element-modal? ${hint}`,
`${scriptModules}elementMenu.ts`)
await includeModuleByQuestion(`Include Parallax? ${hint}`,
`${scriptModules}parallax.ts`)
await includeModuleByQuestion(`Include ScrollToElement? ${hint}`,
`${scriptModules}scrollToElement.ts`)
await includeModuleByQuestion(`Include Animations by scroll? ${hint}`,
`${scriptModules}animateByScroll.ts`)
await includeModuleByQuestion(`Include Searchbar styles? ${hint}`,
``, `${stylesModules}_searchbar.styl;`)
}
function deleteFontsGitkeep() {
try {
fs.removeSync(pathToProject + fontsGitkeep)
console.log('✅ .gitkeep in fonts folder have been deleted.');
} catch (error) {
console.log('❌' + error);
}
}
async function deleteDemoContent() {
try {
for (const pathToDemo of srcDemoFoldersAndFIles) {
fs.removeSync(pathToProject + pathToDemo)
}
await replace(demoStyles)
await replace(demoHtml)
console.log('✅ The demo content have been deleted.');
} catch (error) {
console.log('❌' + error);
}
}
function cleanReadmeFilesAndFolders() {
try {
fs.emptyDir(pathToProject + readmeFolder)
fs.removeSync('./README.md')
fs.createFileSync('README.md')
console.log('✅ The readme folder and file are clean.');
} catch (error) {
console.log('❌' + error);
}
}
function deleteDemoProject() {
try {
fs.removeSync(pathToProject + demoProjectFolderName)
console.log('✅ Demo Project have been deleted.');
} catch (error) {
console.log('❌' + error);
}
}
function deleteSnippets() {
try {
fs.removeSync(pathToProject + snippetsFolderName)
console.log('✅ Snippets have been deleted.');
} catch (error) {
console.log('❌' + error);
}
}
async function setSlider(questionString) {
let answer = readline.question(questionString).toLowerCase()
if (answer !== 'y') {
await replace({
files: gulpSliderConnectionFile,
from: `let build = gulp.series(recreate, setupSwiperCss, setupSwiperJs,`,
to: 'let build = gulp.series(recreate,',
})
fs.removeSync(slidersFile)
}
}
async function includeModuleByQuestion(questionString, scriptPath, stylePath) {
let answer = readline.question(questionString).toLowerCase()
if (answer !== 'y') {
fs.removeSync(scriptPath)
if (stylePath) {
fs.removeSync(stylePath)
let styleModuleName = path.basename(stylePath, '.styl')
await replace({
files: pathToProject + mainStyleFile,
from: `@import 'modules/${styleModuleName}'`, to: '',
})
}
}
}