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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
|
# File 'lib/cli/scaffold.rb', line 15
def scaffold(path)
msg = Util::Message.new()
fs = Util::FS.new()
git = Util::Git.new()
config_dir = "#{path}/.konstruct"
msg.heading("SCAFFOLDING A NEW SITE FOR YOU")
fs.clear_directory(path)
type = choose("What type of site are you building?", :Default, :Jekyll, :Angular)
if type == :Default
git.install(path, Konstruct::BOILERPLATE["Default"], "www", "")
end
if type == :Jekyll
git.install(path, Konstruct::BOILERPLATE["Jekyll"], "www", "")
end
if type == :Angular
git.install(path, Konstruct::BOILERPLATE["Angular"], "www", "")
end
msg.success("Successfully installed the #{ type } repository!");
msg.paragraph("Installing CSS Assets.")
css_dir = "#{path}/assets/scss"
fs.make_dir(css_dir)
git.install(css_dir, Konstruct::FRAMEWORK["scss"], "scss", "konstruct")
msg.success("Successfully installed the Konstruct SCSS framework!")
git.install(css_dir, Konstruct::FRAMEWORK["site"], "site", "site")
msg.success("Successfully installed the Konstruct Site module")
git.install(css_dir, Konstruct::FRAMEWORK["glue"], "glue", "")
msg.success("Successfully installed the Konstruct Glue module")
msg.paragraph("Installing JS Assets.")
js_dir = "#{path}/assets/js"
if type == :Angular
git.install(js_dir, Konstruct::FRAMEWORK["angular"], "scripts", "scripts")
msg.success("Successfully installed the Konstruct Angular module")
else
git.install(js_dir, Konstruct::FRAMEWORK["js"], "scripts", "scripts")
msg.success("Successfully installed the Konstruct JS module")
end
doSudo = choose("Do you need to install node modules as root?", :Yes, :No)
if doSudo == :Yes
msg.warning("You should fix your installation of nodeJS to not require root privileges!")
msg.paragraph("Installing NPM Assets. This might take a while.")
FileUtils.cd("#{path}/assets") do
`sudo npm install`
end
else
msg.paragraph("Installing NPM Assets. This might take a while.")
FileUtils.cd("#{path}/assets") do
`npm install`
end
end
msg.success("Installed NPM Assets")
want_git = choose("Want to initialise a git repository?", :Yes, :No)
if want_git == :Yes
git.init(path)
has_remote = choose("Do you already have a remote git repository?", :Yes, :No)
if has_remote == :Yes
remote_url = ask("Remote Url:")
git.remote(path, remote_url)
git.add(path)
msg.success("Successfully initialised your git repo")
end
end
fs.make_dir(config_dir)
date = Time.new
date_installed = "#{ date.year }-#{ date.month }-#{ date.day }"
file_data = {
"konstruct_version" => Konstruct::VERSION,
"date_installed" => date_installed,
"path" => path,
"type" => type,
"git_remote" => remote_url
}
File.open("#{config_dir}/data.json","w") do |f|
f.write(JSON.pretty_generate(file_data))
end
msg.success("Created #{config_dir}/data.json")
analytics_file = File.expand_path('~/.konstruct/analytics/data.json')
analytics_data = {
"site" => {
"path" => path,
"date" => date_installed,
"actions" => {
"action" => "Installed the site.",
"date" => date_installed
}
}
}
json = File.read(analytics_file)
File.open(analytics_file,"w") do |f|
f.write(JSON.pretty_generate(analytics_data))
end
msg.success("Logged Analytics to #{analytics_file}")
puts ""
puts ""
puts Paint[' $III7IIIIIIIIIIIIIIIIIIIIIIIIII: ', "#de544b"]
puts Paint[' ZZZZZZ$7IIIIIIIIIIIIIIIIIIIIIIII ', "#de544b"]
puts Paint[' ZZZZZZZZZZZZ$7IIIIIIIIIIIIIIIIII ', "#de544b"]
puts Paint[' ZZZZZZZZZZZZZZZZZZZ$IIIIIIIIIIII~', "#de544b"]
puts Paint[' ZZZZZZZZZZZZZZZZZZZZZZZ:,:+IIIIII', "#de544b"]
puts Paint[' ZZZZZZZZZZZZZZZZZZZZZZ. :?', "#de544b"]
puts Paint[' I$ZZZZZZZZZZZZZZZZZZ7 ', "#de544b"]
puts Paint[' III$ZZZZZZZZZZZZZZZ~ ', "#de544b"]
puts Paint[' IIIII7ZZZZZZZZZZZZ ', "#de544b"]
puts Paint[' IIIIIII7ZZZZZZZZ$ ', "#de544b"]
puts Paint[' IIIIIIIIIIZZZZZ: ', "#de544b"]
puts Paint[' IIIIIIIIIIIIZI ', "#de544b"]
puts Paint[' IIIIIIIIIIIIII ', "#de544b"]
puts Paint[' IIIIIIIIIIIIIIII= ', "#de544b"]
puts Paint[' IIIIIIIIIIIIIIIII7= ', "#de544b"]
puts Paint[' IIIIIIIIIIIIIIIIIIII~ ', "#de544b"]
puts Paint[' IIIIIIIIIIIIIIIIIIIIII= ', "#de544b"]
puts Paint[' IIIIIIIIIIIIIIIIIIIIIII7~ ', "#de544b"]
puts Paint[' IIIIIIIIIIIIIIIIIIIIIIIIIII.. ', "#de544b"]
puts Paint[' IIIIIIIIIIIIIIIIIIIIIIIIIIII7 ', "#de544b"]
puts Paint[' IIIIIIIIIIIIIIIIIIIIIIIIIIIIIII,.', "#de544b"]
puts Paint[' IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7', "#de544b"]
puts ""
puts ""
puts Paint[" GO BUILD SOMETHING AWESOME!", "#999999"]
puts ""
puts Paint[" Successfully installed your #{type} site.", "#999999"]
puts ""
puts Paint[" You can run the dev tools with '$ konstruct develop' or '$ konstruct documentation' to get help.", "#999999"]
puts ""
exit(0)
end
|