konstruct 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7060840fc67ea5d400dfa5eb23c631f12a246809
4
- data.tar.gz: 64186607120c776fac8a4cfdf787d1123c785d89
3
+ metadata.gz: 7208b113d64ffc11e18edcc9ff1de391ae4eafec
4
+ data.tar.gz: c8b6b63fe184c53095f95d0a7d8019e4eafeded9
5
5
  SHA512:
6
- metadata.gz: 483c01386db58e6f9ac3022b4b7ca71d193e461056f301d198452fe3fa982165b71b0c97e4da957a89ac0fe2bff287cb3ae993a7375e675befdf168dec8a35c1
7
- data.tar.gz: 3f173c33a6856a4ae0d955b0490d483518f88de70f5c09bc03a8d221ce85902d3d7a85b6ac2d7a8a4a133ae867c6f23f4840947a13efe3d04a25d38157b65131
6
+ metadata.gz: 7bf25b6f71076e99b135d98f3d1afdcaf1dfd5f18d90e1528fb86390a3ae615d45a5a2149996c4ece950d76cf169647bcd5c8d15991e0d971fee7c8e1b796990
7
+ data.tar.gz: 8793076d5481b7be0b63f2df2994b08d7907dda3288436e37d6452c11790e46a26586f90d7a30e11cf61c90201476d06aa71639f9150e3425a5a28e2fad533d1
data/.gitignore CHANGED
File without changes
File without changes
data/Gemfile CHANGED
File without changes
File without changes
data/README.md CHANGED
@@ -8,9 +8,9 @@ The Konstruct Cli provides tools to make working with Konstruct painless and qui
8
8
 
9
9
  - Set up a new project structure in seconds.
10
10
  - Scaffold out a new HTML, Jekyll or Angular site in seconds.
11
- - Gulp in a central location.
12
- - Develop with Browserify & PostCSS.
13
- - Build process to optimise assets for deployment.
11
+ - Globally installed Gulp with [Konstruct.gulp](https://github.com/konstruct/konstruct.gulp).
12
+ - Develop with SASS, Browserify (CommonJS).
13
+ - Build process to optimise assets for deployment in separate git branches.
14
14
  - Quick link to Konstruct Documentation.
15
15
 
16
16
  ## Installation
@@ -42,19 +42,13 @@ Scaffolds a set of project folders from a template to help you organise your pro
42
42
 
43
43
  #### Create
44
44
 
45
- $ konstruct create [options]
46
-
47
- **Options:**
48
- * --sudo : Run NPM install as root if your node installation requires root privileges.
45
+ $ konstruct create
49
46
 
50
47
  Creates a new Konstruct starter project through an interactive wizard.
51
48
 
52
49
  #### Refresh
53
50
 
54
- $ konstruct refresh [options]
55
-
56
- **Options:**
57
- * --sudo : Run NPM install as root if your node installation requires root privileges.
51
+ $ konstruct refresh
58
52
 
59
53
  Refreshes the project by installing dependencies again. Useful if you inherit a repo from another developer.
60
54
 
@@ -76,7 +70,8 @@ Runs build scripts & optimisations on your codebase in the branches you specifie
76
70
 
77
71
  Currently optimising:
78
72
 
79
- * Minify app.js
73
+ * Minify JS
74
+ * Minify CSS
80
75
  * Optimise images
81
76
 
82
77
  #### Documentation
data/Rakefile CHANGED
File without changes
File without changes
File without changes
@@ -1,8 +1,9 @@
1
- # KONSTRUCT CLI [ DEVELOPMENT TASKS ] ==========================================
1
+ # KONSTRUCT CLI [DEVELOPMENT TASKS] ============================================
2
2
 
3
3
  # ====== INDEX ================================================================
4
4
  # ==
5
5
  # == 1. WATCH
6
+ # == 2. BUILD
6
7
  # ==
7
8
  # ====== INDEX ================================================================
8
9
 
@@ -34,6 +35,12 @@ module Konstruct
34
35
 
35
36
  end
36
37
 
38
+ if type == :theme
39
+
40
+ stream = "silent"
41
+
42
+ end
43
+
37
44
  if type == :jekyll
38
45
 
39
46
  stream = "jekyll"
@@ -81,7 +88,7 @@ module Konstruct
81
88
 
82
89
  # 2.3. SET GULP STREAM ---------------------------------------------------
83
90
 
84
- if type == :html || type == :angular
91
+ if type == :html || type == :angular || type == :theme
85
92
 
86
93
  stream = "default"
87
94
 
@@ -149,14 +156,6 @@ module Konstruct
149
156
 
150
157
  # 2.2. GIT TASKS ---------------------------------------------------------
151
158
 
152
- msg.paragraph("Committing build")
153
- `git commit -m "Konstruct Build - #{ date.year }-#{ date.month }-#{ date.day }"`
154
- msg.success("Commit successfull")
155
-
156
- msg.paragraph("Pushing build")
157
- `git push`
158
- msg.success("Push successfull")
159
-
160
159
  # 2.2. END ---------------------------------------------------------------
161
160
 
162
161
  end
@@ -1,10 +1,11 @@
1
- # KONSTRUCT CLI [ KONSTRUCT MODULE ] ===========================================
1
+ # KONSTRUCT CLI [PROJECT TASKS] ================================================
2
2
 
3
3
  # ====== INDEX ================================================================
4
4
  # ==
5
5
  # == 1. FOLDERS
6
6
  # == 2. CREATE
7
7
  # == 3. REFRESH
8
+ # == 4. DOCUMENTATION
8
9
  # ==
9
10
  # ====== INDEX ================================================================
10
11
 
@@ -89,7 +90,7 @@ module Konstruct
89
90
 
90
91
  # 2. CREATE ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
91
92
 
92
- def create(path, sudo)
93
+ def create(path)
93
94
 
94
95
  # 2.1. INIT FUNCTIONS ----------------------------------------------------
95
96
 
@@ -119,7 +120,7 @@ module Konstruct
119
120
 
120
121
  # 2.4. INSTALL BOILERPLATE -----------------------------------------------
121
122
 
122
- type = choose("What type of site are you building?", :html, :jekyll, :angular)
123
+ type = choose("What are you building?", :html, :theme, :jekyll, :angular)
123
124
 
124
125
  if type == :html
125
126
 
@@ -130,6 +131,15 @@ module Konstruct
130
131
 
131
132
  end
132
133
 
134
+ if type == :theme
135
+
136
+ recipe["html"].each do |key, val|
137
+ git.install("#{path}#{val[0]}", "#{repo}#{val[1]}", val[2], val[3])
138
+ msg.success("Installed #{ key }");
139
+ end
140
+
141
+ end
142
+
133
143
  if type == :jekyll
134
144
 
135
145
  recipe["jekyll"].each do |key, val|
@@ -154,24 +164,10 @@ module Konstruct
154
164
 
155
165
  # 2.7. INSTALL NPM ASSETS ------------------------------------------------
156
166
 
157
- if sudo
158
-
159
- msg.warning("Installing NPM as root is not advisable. You should fix
160
- your installation of nodeJS to not require root privileges!")
161
- msg.paragraph("Installing NPM Assets. This might take a while.")
162
-
163
- FileUtils.cd("#{path}/assets") do
164
- `sudo npm install`
165
- end
166
-
167
- else
168
-
169
- msg.paragraph("Installing NPM Assets. This might take a while.")
170
-
171
- FileUtils.cd("#{path}/assets") do
172
- `npm install`
173
- end
167
+ msg.paragraph("Installing NPM Assets. This might take a while.")
174
168
 
169
+ FileUtils.cd("#{path}/assets") do
170
+ `npm install`
175
171
  end
176
172
 
177
173
  msg.success("Installed NPM Assets")
@@ -179,25 +175,28 @@ module Konstruct
179
175
  # 2.7. END ---------------------------------------------------------------
180
176
 
181
177
  # 2.8. SET UP NEW GIT REPOSITORY -----------------------------------------
178
+ unless type == :theme
179
+
180
+ want_git = choose("Want to initialise a git repository?", :Yes, :No)
182
181
 
183
- want_git = choose("Want to initialise a git repository?", :Yes, :No)
182
+ if want_git == :Yes
184
183
 
185
- if want_git == :Yes
184
+ git.init(path)
186
185
 
187
- git.init(path)
186
+ has_remote = choose("Do you already have a remote git repository?", :Yes, :No)
188
187
 
189
- has_remote = choose("Do you already have a remote git repository?", :Yes, :No)
188
+ if has_remote == :Yes
190
189
 
191
- if has_remote == :Yes
190
+ remote_url = ask("Remote Url:")
192
191
 
193
- remote_url = ask("Remote Url:")
192
+ git.remote(path, remote_url)
193
+ git.add(path)
194
194
 
195
- git.remote(path, remote_url)
196
- git.add(path)
195
+ msg.success("Initialised your git repo")
197
196
 
198
- msg.success("Initialised your git repo")
197
+ end
199
198
 
200
- end
199
+ end
201
200
 
202
201
  end
203
202
 
@@ -279,28 +278,14 @@ module Konstruct
279
278
 
280
279
  # 3. END +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
281
280
 
282
- def refresh(path, sudo)
281
+ def refresh(path)
283
282
 
284
283
  # 3.1. INSTALL NPM ASSETS ------------------------------------------------
285
284
 
286
- if sudo
287
-
288
- msg.warning("Installing NPM as root is not advisable. You should fix your
289
- installation of nodeJS to not require root privileges!")
290
- msg.paragraph("Refreshing NPM Assets. This might take a while.")
291
-
292
- FileUtils.cd("#{path}/assets") do
293
- `sudo npm install`
294
- end
295
-
296
- else
297
-
298
- msg.paragraph("Refreshing NPM Assets. This might take a while.")
299
-
300
- FileUtils.cd("#{path}/assets") do
301
- `npm install`
302
- end
285
+ msg.paragraph("Refreshing NPM Assets. This might take a while.")
303
286
 
287
+ FileUtils.cd("#{path}/assets") do
288
+ `npm install`
304
289
  end
305
290
 
306
291
  msg.success("Refreshed NPM Assets")
@@ -311,32 +296,29 @@ module Konstruct
311
296
 
312
297
  # 3. END +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
313
298
 
314
- # 3. END +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
299
+ # 4. DOCUMENTATION +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
315
300
 
316
301
  def documentation
317
302
 
318
- # B.1. INITIALISE FUNCTIONS ----------------------------------------------
303
+ # 4.1. INITIALISE FUNCTIONS ----------------------------------------------
319
304
 
320
305
  msg = Util::Message.new()
321
306
 
322
- # B.1. END ---------------------------------------------------------------
307
+ # 4.1. END ---------------------------------------------------------------
323
308
 
324
- msg.heading("KONSTRUCT DOCUMENTATION")
309
+ # 4.2. OPEN DOCUMENTATION ------------------------------------------------
325
310
 
326
- # B.2. IS YOUR DIRECTORY EMPTY? ------------------------------------------
327
-
328
- puts Paint["Opening documentation in your default browser!", "999999"]
329
- puts ""
311
+ msg.paragraph("Opening documentation in your default browser!")
330
312
 
331
313
  Launchy.open( "http://konstruct.github.io/" )
332
314
 
333
315
  exit(0)
334
316
 
335
- # B.3. END ---------------------------------------------------------------
317
+ # 4.2. END ---------------------------------------------------------------
336
318
 
337
319
  end
338
320
 
339
- # 3. END +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
321
+ # 4. END +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
340
322
 
341
323
  end
342
324
 
@@ -35,8 +35,6 @@ require 'xmlsimple'
35
35
  #1.2.1. UTILITIES
36
36
 
37
37
  require_relative 'utilities/utils'
38
- require_relative 'utilities/gulp'
39
- require_relative 'utilities/git'
40
38
  require_relative 'utilities/system'
41
39
 
42
40
  # 1.2.2. CLI SCRIPTS
@@ -130,12 +128,9 @@ command :create do |c|
130
128
  c.syntax = 'konstruct create [options]'
131
129
  c.summary = 'Create a new Konstruct project.'
132
130
  c.description = 'Creates a new starter project from the chosen flavours of Konstruct boilerplates.'
133
- c.option '--sudo', 'Runs install tasks as root.'
134
131
  c.action do |args, options|
135
132
 
136
- options.default :sudo => false
137
-
138
- project.create(projectDir, options.sudo)
133
+ project.create(projectDir)
139
134
 
140
135
  end
141
136
 
@@ -152,12 +147,9 @@ command :refresh do |c|
152
147
  c.syntax = 'konstruct refresh [options]'
153
148
  c.summary = 'Refresh external assets'
154
149
  c.description = 'Re-installs NPM assets. Usefull when you pull an existing project that did not commit NPM assets.'
155
- c.option '--sudo', 'Runs install tasks as root.'
156
150
  c.action do |args, options|
157
151
 
158
- options.default :sudo => false
159
-
160
- project.create(projectDir, options.sudo)
152
+ project.refresh(projectDir)
161
153
 
162
154
  end
163
155
 
File without changes
@@ -1,3 +1,3 @@
1
1
  module Konstruct
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -1,4 +1,4 @@
1
- # KONSTRUCT CLI [ KONSTRUCT MODULE ] ===========================================
1
+ # KONSTRUCT CLI [KONSTRUCT MODULE] =============================================
2
2
 
3
3
  # ====== INDEX ================================================================
4
4
  # ==
@@ -99,15 +99,12 @@ module Util
99
99
 
100
100
  `rm -rf #{config_dir}`
101
101
  msg.warning("Uninstalled existing .konstruct")
102
- fs.make_dir(config_dir)
103
- msg.success("Created #{config_dir}")
104
102
 
105
- else
103
+ end
106
104
 
107
- fs.make_dir(config_dir)
108
- msg.success("Created #{config_dir}")
105
+ fs.make_dir(config_dir)
109
106
 
110
- end
107
+ msg.success("Created #{config_dir}")
111
108
 
112
109
  # 2.2. END ---------------------------------------------------------------
113
110
 
@@ -139,28 +136,11 @@ module Util
139
136
 
140
137
  # 2.4. INSTALL NPM -------------------------------------------------------
141
138
 
142
- doSudo = choose("Do you need to install node modules as root?", :Yes, :No)
143
-
144
- if doSudo == :Yes
145
-
146
- msg.warning("You should fix your installation of nodeJS to not require root privileges!")
147
- msg.paragraph("Installing NPM Assets. This might take a while.")
148
-
149
- FileUtils.cd(gulpDir) do
150
-
151
- `sudo npm install`
152
-
153
- end
154
-
155
- else
156
-
157
- msg.paragraph("Installing NPM Assets. This might take a while.")
158
-
159
- FileUtils.cd(gulpDir) do
139
+ msg.paragraph("Installing NPM Assets. This might take a while.")
160
140
 
161
- `npm install`
141
+ FileUtils.cd(gulpDir) do
162
142
 
163
- end
143
+ `npm install`
164
144
 
165
145
  end
166
146
 
@@ -1,78 +1,81 @@
1
- # KONSTRUCT CLI [ UTILITY MODULE ] ====================================================================================
1
+ # KONSTRUCT CLI [UTILITIES] ====================================================
2
2
 
3
- # ====== INDEX =======================================================================================================
3
+ # ====== INDEX ================================================================
4
4
  # ==
5
- # == A. LOAD DEPENDENCIES
6
- # == B. UTILITY MODULES
5
+ # == 1. MESSAGES
6
+ # == 2. FILE SYSTEM
7
+ # == 3. GIT
8
+ # == 4. GULP
7
9
  # ==
8
- # ====== INDEX =======================================================================================================
9
-
10
- # B. UTILITIES ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10
+ # ====== INDEX ================================================================
11
11
 
12
12
  module Util
13
13
 
14
- # B.1. MESSAGES -----------------------------------------------------------------------------------------------------
14
+ # 1. MESSAGES ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
15
15
 
16
16
  class Message
17
17
 
18
- # B.1.1. WARNING MESSAGE
18
+ # 1.1. WARNING MESSAGE -----------------------------------------------------
19
19
 
20
20
  def warning(msg)
21
21
 
22
+ symbol = "\u2757"
23
+
22
24
  puts ""
23
- puts Paint["[WARNING:]", :yellow]
24
- puts Paint[msg, :yellow]
25
+ puts Paint["#{symbol.encode('utf-8')} : #{msg}", :yellow]
25
26
  puts ""
26
27
 
27
28
  end
28
29
 
29
- # B.1.1. END
30
+ # 1.1. END -----------------------------------------------------------------
30
31
 
31
- # B.1.2. SUCCESS MESSAGE
32
+ # 1.2. SUCCESS MESSAGE -----------------------------------------------------
32
33
 
33
34
  def success(msg)
34
35
 
36
+ symbol = "\u2713"
37
+
35
38
  puts ""
36
- puts Paint["[SUCCESS]", :green]
37
- puts Paint[msg, :green]
39
+ puts Paint["#{symbol.encode('utf-8')} : #{msg}", :green]
38
40
  puts ""
39
41
 
40
42
  end
41
43
 
42
- # B.1.2. END
44
+ # 1.2. END -----------------------------------------------------------------
43
45
 
44
- # B.1.3. ERROR MESSAGE
46
+ # 1.3. ERROR MESSAGE -------------------------------------------------------
45
47
 
46
48
  def error(msg)
47
49
 
50
+ symbol = "\u274C"
51
+
48
52
  puts ""
49
- puts Paint["[ERROR]", :red]
50
- puts Paint[msg, :red]
53
+ puts Paint["#{symbol.encode('utf-8')} : #{msg}", :red]
51
54
  puts ""
52
55
 
53
56
  exit 1
54
57
 
55
58
  end
56
59
 
57
- # B.1.3. END
60
+ # 1.3. END -----------------------------------------------------------------
58
61
 
59
- # B.1.4. HEADING
62
+ # 1.4. HEADING
60
63
 
61
64
  def heading(msg)
62
65
 
63
66
  puts ""
64
- puts Paint["----------------------------------------------------------------------------", :cyan]
67
+ puts Paint["-----------------------------------------------------", :cyan]
65
68
  puts Paint["--", :cyan]
66
69
  puts Paint["-- #{ msg }", :cyan]
67
70
  puts Paint["--", :cyan]
68
- puts Paint["----------------------------------------------------------------------------", :cyan]
71
+ puts Paint["-----------------------------------------------------", :cyan]
69
72
  puts ""
70
73
 
71
74
  end
72
75
 
73
- # B.1.4. END
76
+ # 1.4. END -----------------------------------------------------------------
74
77
 
75
- # B.1.5. PARAGRAPH
78
+ # 1.5. PARAGRAPH
76
79
 
77
80
  def paragraph(msg)
78
81
 
@@ -82,13 +85,13 @@ module Util
82
85
 
83
86
  end
84
87
 
85
- # B.1.5. END
88
+ # 1.5. END -----------------------------------------------------------------
86
89
 
87
90
  end
88
91
 
89
- # B.1. END ----------------------------------------------------------------------------------------------------------
92
+ # 1. END +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
90
93
 
91
- # B.2. FILE SYSTEM --------------------------------------------------------------------------------------------------
94
+ # 2. FILE SYSTEM +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
92
95
 
93
96
  class FS
94
97
 
@@ -115,13 +118,6 @@ module Util
115
118
  if isEmpty(path)
116
119
 
117
120
  msg.warning("Your directory isn't empty! Konstruct can only be installed in an empty directory.");
118
- puts Paint["----------------------------------------------------------------------------", :yellow]
119
- puts ""
120
- puts Paint["DIRECTORY LISTING: #{path}", :yellow]
121
- puts ""
122
- puts Paint[Dir.entries(path), :yellow]
123
- puts ""
124
- puts Paint["----------------------------------------------------------------------------", :yellow]
125
121
  puts ""
126
122
  choice = choose("Do you want to clear your working directory?", :yes, :no)
127
123
 
@@ -190,10 +186,81 @@ module Util
190
186
 
191
187
  end
192
188
 
193
- # B.2. END ----------------------------------------------------------------------------------------------------------
189
+ # 2. END +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
194
190
 
195
- end
191
+ # 3. GIT +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
192
+
193
+ class Git
194
+
195
+ # 3.1. GIT INSTALL ---------------------------------------------------------
196
+
197
+ def install(path, repository, target, dest)
198
+
199
+ `git clone #{repository} "#{path}/.tmp"`
200
+
201
+ FileUtils.copy_entry("#{path}/.tmp/#{target}", "#{path}/#{dest}")
202
+
203
+ FileUtils.rm_rf(Dir.glob("#{path}/.tmp"))
204
+
205
+ end
206
+
207
+ # 3.1. END -----------------------------------------------------------------
208
+
209
+ # 3.2. GIT INIT ------------------------------------------------------------
210
+
211
+ def init(path)
212
+
213
+ FileUtils.cd(path) do
214
+
215
+ `git init`
216
+
217
+ end
218
+
219
+ end
220
+
221
+ # 3.2. END -----------------------------------------------------------------
222
+
223
+ # 3.3. GIT REMOTE ----------------------------------------------------------
196
224
 
197
- # B. END ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
225
+ def remote(path, remote)
226
+
227
+ FileUtils.cd(path) do
228
+
229
+ `git remote add origin #{remote}`
230
+
231
+ end
232
+
233
+ end
234
+
235
+ # 3.3. END -----------------------------------------------------------------
236
+
237
+ end
238
+
239
+ # 3. END +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
240
+
241
+ # 4. GULP ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
242
+
243
+ class Gulp
244
+
245
+ def task(task, path, stream)
246
+
247
+ gulp = Util::Gulp.new()
248
+ msg = Util::Message.new()
249
+
250
+ gulp_path = File.expand_path('~/.konstruct/gulp')
251
+
252
+ FileUtils.cd(gulp_path) do
253
+
254
+ exec "gulp #{task} --path #{path} --stream #{stream}"
255
+
256
+ end
257
+
258
+ end
259
+
260
+ end
261
+
262
+ # 4. END +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
263
+
264
+ end
198
265
 
199
- # END OF FILE =========================================================================================================
266
+ # END OF FILE ==================================================================
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: konstruct
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Kirsten
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-28 00:00:00.000000000 Z
11
+ date: 2016-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -147,12 +147,9 @@ files:
147
147
  - lib/cli/deploy.rb
148
148
  - lib/cli/develop.rb
149
149
  - lib/cli/project.rb
150
- - lib/cli/scaffold.rb
151
150
  - lib/konstruct.rb
152
151
  - lib/konstruct/template.rb
153
152
  - lib/konstruct/version.rb
154
- - lib/utilities/git.rb
155
- - lib/utilities/gulp.rb
156
153
  - lib/utilities/system.rb
157
154
  - lib/utilities/utils.rb
158
155
  homepage: https://github.com/konstruct/konstruct.cli
@@ -1,276 +0,0 @@
1
- # KONSTRUCT CLI [ KONSTRUCT MODULE ] ==================================================================================
2
-
3
- # ====== INDEX =======================================================================================================
4
- # ==
5
- # == A. SCAFFOLD A NEW SITE
6
- # ==
7
- # ====== INDEX =======================================================================================================
8
-
9
- # A. SCAFFOLD A NEW SITE ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10
-
11
- module Konstruct
12
-
13
- class Cli
14
-
15
- def scaffold(path)
16
-
17
- # B.1. INITIALISE FUNCTIONS -------------------------------------------------------------------------------
18
-
19
- msg = Util::Message.new()
20
- fs = Util::FS.new()
21
- git = Util::Git.new()
22
-
23
- config_dir = "#{path}/.konstruct"
24
-
25
- # B.1. END ------------------------------------------------------------------------------------------------
26
-
27
- msg.heading("SCAFFOLDING A NEW SITE FOR YOU")
28
-
29
- # B.2. IS YOUR DIRECTORY EMPTY? ---------------------------------------------------------------------------
30
-
31
- fs.clear_directory(path)
32
-
33
- # B.2. END ------------------------------------------------------------------------------------------------
34
-
35
- # B.3. INSTALL BOILERPLATE --------------------------------------------------------------------------------
36
-
37
- type = choose("What type of site are you building?", :Default, :Jekyll, :Angular)
38
-
39
- if type == :Default
40
-
41
- git.install(path, Konstruct::BOILERPLATE["Default"], "www", "")
42
-
43
- end
44
-
45
- if type == :Jekyll
46
-
47
- git.install(path, Konstruct::BOILERPLATE["Jekyll"], "www", "")
48
-
49
- end
50
-
51
- if type == :Angular
52
-
53
- git.install(path, Konstruct::BOILERPLATE["Angular"], "www", "")
54
-
55
- end
56
-
57
- msg.success("Successfully installed the #{ type } repository!");
58
-
59
- # B.3. END ------------------------------------------------------------------------------------------------
60
-
61
- # B.4. INSTALL CSS ----------------------------------------------------------------------------------------
62
-
63
- msg.paragraph("Installing CSS Assets.")
64
-
65
- css_dir = "#{path}/assets/scss"
66
-
67
- fs.make_dir(css_dir)
68
-
69
- # B.4.1. INSTALL KONSTRUCT SCSS MODULE
70
-
71
- git.install(css_dir, Konstruct::FRAMEWORK["scss"], "scss", "konstruct")
72
-
73
- msg.success("Successfully installed the Konstruct SCSS framework!")
74
-
75
- # B.4.1. END
76
-
77
- # B.4.2. INSTALL KONSTRUCT SITE MODULE
78
-
79
- git.install(css_dir, Konstruct::FRAMEWORK["site"], "site", "site")
80
-
81
- msg.success("Successfully installed the Konstruct Site module")
82
-
83
- # B.4.2. END
84
-
85
- # B.4.1. INSTALL KONSTRUCT GLUE MODULE
86
-
87
- git.install(css_dir, Konstruct::FRAMEWORK["glue"], "glue", "")
88
-
89
- msg.success("Successfully installed the Konstruct Glue module")
90
-
91
- # B.4.1. END
92
-
93
- # B.4. END ------------------------------------------------------------------------------------------------
94
-
95
- # B.5. INSTALL JS -----------------------------------------------------------------------------------------
96
-
97
- msg.paragraph("Installing JS Assets.")
98
-
99
- js_dir = "#{path}/assets/js"
100
-
101
- if type == :Angular
102
-
103
- git.install(js_dir, Konstruct::FRAMEWORK["angular"], "scripts", "scripts")
104
-
105
- msg.success("Successfully installed the Konstruct Angular module")
106
-
107
- else
108
-
109
- git.install(js_dir, Konstruct::FRAMEWORK["js"], "scripts", "scripts")
110
-
111
- msg.success("Successfully installed the Konstruct JS module")
112
-
113
- end
114
-
115
- # B.5. END ------------------------------------------------------------------------------------------------
116
-
117
- # B.6. INSTALL NPM ASSETS ---------------------------------------------------------------------------------
118
-
119
- doSudo = choose("Do you need to install node modules as root?", :Yes, :No)
120
-
121
- if doSudo == :Yes
122
-
123
- msg.warning("You should fix your installation of nodeJS to not require root privileges!")
124
- msg.paragraph("Installing NPM Assets. This might take a while.")
125
-
126
- FileUtils.cd("#{path}/assets") do
127
-
128
- `sudo npm install`
129
-
130
- end
131
-
132
- else
133
-
134
- msg.paragraph("Installing NPM Assets. This might take a while.")
135
-
136
- FileUtils.cd("#{path}/assets") do
137
-
138
- `npm install`
139
-
140
- end
141
-
142
- end
143
-
144
- msg.success("Installed NPM Assets")
145
-
146
- # B.6. END ------------------------------------------------------------------------------------------------
147
-
148
- # B.6. SET UP NEW GIT REPOSITORY --------------------------------------------------------------------------
149
-
150
- want_git = choose("Want to initialise a git repository?", :Yes, :No)
151
-
152
- if want_git == :Yes
153
-
154
- git.init(path)
155
-
156
- has_remote = choose("Do you already have a remote git repository?", :Yes, :No)
157
-
158
- if has_remote == :Yes
159
-
160
- remote_url = ask("Remote Url:")
161
-
162
- git.remote(path, remote_url)
163
- git.add(path)
164
-
165
- msg.success("Successfully initialised your git repo")
166
-
167
- end
168
-
169
- end
170
-
171
- # B.6. END ------------------------------------------------------------------------------------------------
172
-
173
- # B.4. INSTALL .konstruct ---------------------------------------------------------------------------------
174
-
175
- fs.make_dir(config_dir)
176
-
177
- date = Time.new
178
- date_installed = "#{ date.year }-#{ date.month }-#{ date.day }"
179
-
180
- file_data = {
181
-
182
- "konstruct_version" => Konstruct::VERSION,
183
- "date_installed" => date_installed,
184
- "path" => path,
185
- "type" => type,
186
- "git_remote" => remote_url
187
-
188
- }
189
-
190
- File.open("#{config_dir}/data.json","w") do |f|
191
- f.write(JSON.pretty_generate(file_data))
192
- end
193
-
194
- msg.success("Created #{config_dir}/data.json")
195
-
196
- # B.4. END ------------------------------------------------------------------------------------------------
197
-
198
- # B.5. SEND BUILD DATA TO ANALYTICS -----------------------------------------------------------------------
199
-
200
- analytics_file = File.expand_path('~/.konstruct/analytics/data.json')
201
-
202
- analytics_data = {
203
-
204
- "site" => {
205
-
206
- "path" => path,
207
- "date" => date_installed,
208
- "actions" => {
209
-
210
- "action" => "Installed the site.",
211
- "date" => date_installed
212
-
213
- }
214
-
215
- }
216
-
217
- }
218
-
219
- json = File.read(analytics_file)
220
-
221
- File.open(analytics_file,"w") do |f|
222
- f.write(JSON.pretty_generate(analytics_data))
223
- end
224
-
225
- msg.success("Logged Analytics to #{analytics_file}")
226
-
227
- # B.5. END ------------------------------------------------------------------------------------------------
228
-
229
- # B.6. THANKS FOR INSTALLING ------------------------------------------------------------------------------
230
-
231
- puts ""
232
- puts ""
233
- puts Paint[' $III7IIIIIIIIIIIIIIIIIIIIIIIIII: ', "#de544b"]
234
- puts Paint[' ZZZZZZ$7IIIIIIIIIIIIIIIIIIIIIIII ', "#de544b"]
235
- puts Paint[' ZZZZZZZZZZZZ$7IIIIIIIIIIIIIIIIII ', "#de544b"]
236
- puts Paint[' ZZZZZZZZZZZZZZZZZZZ$IIIIIIIIIIII~', "#de544b"]
237
- puts Paint[' ZZZZZZZZZZZZZZZZZZZZZZZ:,:+IIIIII', "#de544b"]
238
- puts Paint[' ZZZZZZZZZZZZZZZZZZZZZZ. :?', "#de544b"]
239
- puts Paint[' I$ZZZZZZZZZZZZZZZZZZ7 ', "#de544b"]
240
- puts Paint[' III$ZZZZZZZZZZZZZZZ~ ', "#de544b"]
241
- puts Paint[' IIIII7ZZZZZZZZZZZZ ', "#de544b"]
242
- puts Paint[' IIIIIII7ZZZZZZZZ$ ', "#de544b"]
243
- puts Paint[' IIIIIIIIIIZZZZZ: ', "#de544b"]
244
- puts Paint[' IIIIIIIIIIIIZI ', "#de544b"]
245
- puts Paint[' IIIIIIIIIIIIII ', "#de544b"]
246
- puts Paint[' IIIIIIIIIIIIIIII= ', "#de544b"]
247
- puts Paint[' IIIIIIIIIIIIIIIII7= ', "#de544b"]
248
- puts Paint[' IIIIIIIIIIIIIIIIIIII~ ', "#de544b"]
249
- puts Paint[' IIIIIIIIIIIIIIIIIIIIII= ', "#de544b"]
250
- puts Paint[' IIIIIIIIIIIIIIIIIIIIIII7~ ', "#de544b"]
251
- puts Paint[' IIIIIIIIIIIIIIIIIIIIIIIIIII.. ', "#de544b"]
252
- puts Paint[' IIIIIIIIIIIIIIIIIIIIIIIIIIII7 ', "#de544b"]
253
- puts Paint[' IIIIIIIIIIIIIIIIIIIIIIIIIIIIIII,.', "#de544b"]
254
- puts Paint[' IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7', "#de544b"]
255
- puts ""
256
- puts ""
257
- puts Paint[" GO BUILD SOMETHING AWESOME!", "#999999"]
258
- puts ""
259
- puts Paint[" Successfully installed your #{type} site.", "#999999"]
260
- puts ""
261
- puts Paint[" You can run the dev tools with '$ konstruct develop' or '$ konstruct documentation' to get help.", "#999999"]
262
- puts ""
263
-
264
- exit(0)
265
-
266
- # B.6. END ------------------------------------------------------------------------------------------------
267
-
268
- end
269
-
270
- end
271
-
272
- end
273
-
274
- # B. END ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
275
-
276
- # END OF FILE =========================================================================================================
@@ -1,82 +0,0 @@
1
- # KONSTRUCT CLI [ UTILITY MODULE ] ====================================================================================
2
-
3
- # ====== INDEX =======================================================================================================
4
- # ==
5
- # == A. LOAD DEPENDENCIES
6
- # == B. GIT MODULES
7
- # ==
8
- # ====== INDEX =======================================================================================================
9
-
10
- # A. UTILITIES ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11
-
12
- module Util
13
-
14
- # A.1. GIT COMMANDS -----------------------------------------------------------------------------------------------
15
-
16
- class Git
17
-
18
- # A.1.1. GIT INSTALL
19
-
20
- def install(path, repository, target, dest)
21
-
22
- `git clone #{repository} "#{path}/.tmp"`
23
-
24
- FileUtils.copy_entry("#{path}/.tmp/#{target}", "#{path}/#{dest}")
25
-
26
- FileUtils.rm_rf(Dir.glob("#{path}/.tmp"))
27
-
28
- end
29
-
30
- # A.1.1. END
31
-
32
- # A.1.2. GIT INIT
33
-
34
- def init(path)
35
-
36
- FileUtils.cd(path) do
37
-
38
- `git init`
39
-
40
- end
41
-
42
- end
43
-
44
- # A.1.2. END
45
-
46
- # A.1.3. GIT REMOTE
47
-
48
- def remote(path, remote)
49
-
50
- FileUtils.cd(path) do
51
-
52
- `git remote add origin #{remote}`
53
-
54
- end
55
-
56
- end
57
-
58
- # A.1.3. END
59
-
60
- # A.1.4. GIT SCAFFOLD
61
-
62
- def add(path)
63
-
64
- FileUtils.cd(path) do
65
-
66
- `git add *`
67
-
68
- end
69
-
70
- end
71
-
72
- # A.1.4. END
73
-
74
- end
75
-
76
- # A.1. END --------------------------------------------------------------------------------------------------------
77
-
78
- end
79
-
80
- # A. END ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
81
-
82
- # END OF FILE =========================================================================================================
@@ -1,44 +0,0 @@
1
- # KONSTRUCT CLI [ UTILITY MODULE ] =============================================
2
-
3
- # ====== INDEX ================================================================
4
- # ==
5
- # == 1. GULP MODULES
6
- # ==
7
- # ====== INDEX ================================================================
8
-
9
- # 1. GULP MODULES ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10
-
11
- module Util
12
-
13
- # 1.1. GIT COMMANDS --------------------------------------------------------
14
-
15
- class Gulp
16
-
17
- # 1.1.1. GULP DEFAULT
18
-
19
- def task(task, path, stream)
20
-
21
- gulp = Util::Gulp.new()
22
- msg = Util::Message.new()
23
-
24
- gulp_path = File.expand_path('~/.konstruct/gulp')
25
-
26
- FileUtils.cd(gulp_path) do
27
-
28
- exec "gulp #{task} --path #{path} --stream #{stream}"
29
-
30
- end
31
-
32
- end
33
-
34
- # 1.1.1. END
35
-
36
- end
37
-
38
- # 1.1. END -----------------------------------------------------------------
39
-
40
- end
41
-
42
- # A. END +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
43
-
44
- # END OF FILE ==================================================================