shop 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Changelog.md +6 -1
- data/Gemfile.lock +1 -1
- data/README.md +7 -4
- data/lib/shop.rb +1 -1
- data/lib/shop/command.rb +31 -11
- data/lib/shop/template.rb +20 -4
- data/shop.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTUxZjYwODM5NjMwNGY2OGJhMzZiNTFlMTI1YzRmYjQ1ZTc5N2QwZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmRjNjJmNzU0YWI5NzA3ODk2MTlkMWQ2NzI0NWYwNTRkYmExYWJhYg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWE3ZTIxYjIxNzZmZmFlZjg2Y2E4NzgyMmQxOTdhZmEwNTFmNzYzYTc4ZjFk
|
10
|
+
NmQ3MThkOGE4MTNlZjg0ZDU2NmJhNDE0YTQ0YTNkODQwMzVmNDkwYWEzOWM0
|
11
|
+
MmYxNzk2NTg2NDUzOWY3M2U0ZDBmOThkZDZjZDQxZDkyN2RhNGE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDFhMzVhMjEzMTRjMDVmZWVmNWRlNzlmOWNkOGNhZTNiMDc1ZmI0OTNhY2U4
|
14
|
+
NDUwZGZlNTVlMDc1ZGE3MTgyZTc3NjgzYjY3MjBjYWU0ZDJhYjVmMThlMjEx
|
15
|
+
YWQ2MmZjM2YxMjkxY2Y0MjkzODM3NDFmNDI5MGMyZmVlMmE4ZWM=
|
data/Changelog.md
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
# Shop changelog
|
2
2
|
## Head
|
3
3
|
|
4
|
-
##
|
4
|
+
## 0.1.8
|
5
|
+
- By default the clean task clean the cache
|
6
|
+
- Add a `template` section to the configuration file so you can use custom templates
|
7
|
+
- Output the files created for every tasks
|
8
|
+
- Allow the use of the `module` task with or without file extension. ie. `shop module template name template` or `shop module template name template.tpl`
|
9
|
+
- Fix controller task and keep camelcased controllers name
|
5
10
|
|
6
11
|
## 0.1.6
|
7
12
|
- Add an `edit` command to edit the config file
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
CLI for easier [PrestaShop](http://www.prestashop.com/en/) development. Actually it's just for the lazy people.
|
4
4
|
|
5
|
-
I always use Rakefiles and Makefiles for lots of tasks. With this gem you can use these tasks without having to create any *akefiles.
|
5
|
+
I always use Rakefiles and Makefiles for lots of tasks. With this gem you can use these tasks without having to create any *akefiles. For more infos about how and why see: [Introducing Shop](http://romainberger.com/2013/09/29/introducing-shop/).
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -104,7 +104,7 @@ Creates a module css file in your theme:
|
|
104
104
|
|
105
105
|
Cleans the css and js caches.
|
106
106
|
|
107
|
-
shop clean cache
|
107
|
+
shop clean [cache]
|
108
108
|
# cleans the css and js caches
|
109
109
|
|
110
110
|
When you create a new override for a controller or a class, the class index needs to be rewritten. You can call this task
|
@@ -112,6 +112,8 @@ When you create a new override for a controller or a class, the class index need
|
|
112
112
|
shop clean class
|
113
113
|
# clean the class index - automatically done when generating a new controller or class
|
114
114
|
|
115
|
+
By default the `clean` task will clean the cache so you can just use `shop clean`.
|
116
|
+
|
115
117
|
**Note**: The class index is automatically regenerated when you create an override with Shop. You probably won't need to run this command.
|
116
118
|
|
117
119
|
### Jshint
|
@@ -158,14 +160,15 @@ You can edit this file with the command
|
|
158
160
|
|
159
161
|
shop edit
|
160
162
|
|
161
|
-
It will open the config file in your `$EDITOR
|
163
|
+
It will open the config file in your `$EDITOR`. It's YAML so it shouldn't be scary.
|
162
164
|
|
163
165
|
## Compatibility
|
164
166
|
|
165
|
-
Shop has been developed and tested on osx. It may not work on platforms other than *nix, particularly the `new` command that uses the unix `unzip` command. I plan on working on rewriting this part with only Ruby so it could work everywhere.
|
167
|
+
Shop has been developed and tested on osx. It may not work on platforms other than *nix, particularly the `new` command that uses the unix `unzip` command. I plan on working on rewriting this part with only Ruby so it could work everywhere. I'm not going to try it on Windows so feel free to open issues (or even better, contribute) if you notice something not working as expected.
|
166
168
|
|
167
169
|
## Who
|
168
170
|
|
169
171
|
By [Romain Berger](http://romainberger.com).
|
170
172
|
Ping me at [@romain__berger](http://twitter.com/romain__berger) if you're having issues or create an issue.
|
173
|
+
|
171
174
|
If you become billionaire with a shop made with the help of Shop you must buy me a beer.
|
data/lib/shop.rb
CHANGED
data/lib/shop/command.rb
CHANGED
@@ -160,6 +160,7 @@ module Shop
|
|
160
160
|
return puts " $ shop init <theme-name>"
|
161
161
|
end
|
162
162
|
|
163
|
+
puts " #{green("create")} .shop"
|
163
164
|
File.open('.shop', 'w') do |f|
|
164
165
|
f.write(name)
|
165
166
|
end
|
@@ -187,11 +188,13 @@ module Shop
|
|
187
188
|
path = "#{path}/#{minor}"
|
188
189
|
FileUtils.mkpath(path) unless File.directory?(path)
|
189
190
|
|
190
|
-
filepath = "#{path}/#{extra}
|
191
|
+
filepath = "#{path}/#{extra}"
|
192
|
+
filepath = "#{filepath}.tpl" unless filepath.match(/\.tpl$/)
|
191
193
|
if File.exists?(filepath)
|
192
194
|
puts "#{red("Error:")} File already exists"
|
193
195
|
exit
|
194
196
|
else
|
197
|
+
puts " #{green("create")} #{filepath}"
|
195
198
|
File.open(filepath, "w") do; end
|
196
199
|
end
|
197
200
|
elsif major == 'css'
|
@@ -200,12 +203,14 @@ module Shop
|
|
200
203
|
path = "themes/#{theme}/css/modules/#{minor}"
|
201
204
|
FileUtils.mkpath(path) unless File.directory?(path)
|
202
205
|
|
203
|
-
filepath = "#{path}/#{minor}
|
206
|
+
filepath = "#{path}/#{minor}"
|
207
|
+
filepath = "#{filepath}.css" unless filepath.match(/\.css$/)
|
204
208
|
|
205
209
|
if File.exists?(filepath)
|
206
210
|
puts "#{red("Error:")} File already exists"
|
207
211
|
exit
|
208
212
|
elsif
|
213
|
+
puts " #{green("create")} #{filepath}"
|
209
214
|
File.open(filepath, "w") do; end
|
210
215
|
end
|
211
216
|
else
|
@@ -213,6 +218,7 @@ module Shop
|
|
213
218
|
if File.directory?("modules/#{major}")
|
214
219
|
return puts "Module #{major} already exists"
|
215
220
|
else
|
221
|
+
puts " #{green("create")} modules/#{major}"
|
216
222
|
FileUtils.mkpath("modules/#{major}")
|
217
223
|
config = ShopConfig.new
|
218
224
|
values = {
|
@@ -222,6 +228,7 @@ module Shop
|
|
222
228
|
"tab" => config.get('module', 'tab')
|
223
229
|
}
|
224
230
|
content = template.template("module.php", values)
|
231
|
+
puts " #{green("create")} modules/#{major}/#{major}.php"
|
225
232
|
File.open("modules/#{major}/#{major}.php", 'w') do |f|
|
226
233
|
f.write(content)
|
227
234
|
end
|
@@ -230,9 +237,11 @@ module Shop
|
|
230
237
|
logo = config.get('module', 'logo')
|
231
238
|
if logo.length != 0
|
232
239
|
if File.exists?("#{logo}.png")
|
240
|
+
puts " #{green("create")} modules/#{major}/logo.png"
|
233
241
|
FileUtils.cp("#{logo}.png", "modules/#{major}/logo.png")
|
234
242
|
end
|
235
243
|
if File.exists?("#{logo}.gif")
|
244
|
+
puts " #{green("create")} modules/#{major}/logo.gif"
|
236
245
|
FileUtils.cp("#{logo}.gif", "modules/#{major}/logo.gif")
|
237
246
|
end
|
238
247
|
end
|
@@ -270,6 +279,7 @@ module Shop
|
|
270
279
|
return puts "#{red("Error:")} You need to be at the root of your Prestashop site"
|
271
280
|
end
|
272
281
|
|
282
|
+
puts " #{green("create")} #{path}"
|
273
283
|
File.open(path, 'w') do |f|
|
274
284
|
f.write(content)
|
275
285
|
end
|
@@ -291,8 +301,11 @@ module Shop
|
|
291
301
|
version = psVersion
|
292
302
|
version = version[0, 3]
|
293
303
|
|
294
|
-
name
|
295
|
-
|
304
|
+
# convert the name to camelcase to hyphen
|
305
|
+
name = major.split(/(?=[A-Z])/)
|
306
|
+
name = name.join('-').downcase
|
307
|
+
|
308
|
+
controller_name = "#{major}Controller"
|
296
309
|
filename = "#{controller_name}.php"
|
297
310
|
if version.to_f >= 1.5
|
298
311
|
controller_path = "controllers/front/#{filename}"
|
@@ -300,7 +313,6 @@ module Shop
|
|
300
313
|
controller_path = "controllers/#{filename}"
|
301
314
|
end
|
302
315
|
|
303
|
-
|
304
316
|
if File.exists?(controller_path)
|
305
317
|
puts "#{red("Error")}: Controller already exists"
|
306
318
|
exit
|
@@ -309,14 +321,15 @@ module Shop
|
|
309
321
|
# datas for templates
|
310
322
|
datas = {
|
311
323
|
'controller_name' => controller_name,
|
312
|
-
'name' => name
|
324
|
+
'name' => name
|
313
325
|
}
|
314
326
|
|
315
327
|
# For PS 1.4 creates a php file a the root
|
316
328
|
# and use the appropriate template
|
317
329
|
if version[0, 3] == "1.4"
|
318
330
|
content = template.template("page.php", datas)
|
319
|
-
|
331
|
+
puts " #{green("create")} #{name}.php"
|
332
|
+
File.open("#{name}.php", "w") do |f|
|
320
333
|
f.write(content)
|
321
334
|
end
|
322
335
|
controllerContent = template.template("controller-1.4.php", datas)
|
@@ -324,6 +337,7 @@ module Shop
|
|
324
337
|
controllerContent = template.template("controller.php", datas)
|
325
338
|
end
|
326
339
|
|
340
|
+
puts " #{green("create")} #{controller_path}"
|
327
341
|
File.open(controller_path, "w") do |f|
|
328
342
|
f.write(controllerContent)
|
329
343
|
end
|
@@ -335,6 +349,7 @@ module Shop
|
|
335
349
|
]
|
336
350
|
|
337
351
|
files.each do |f|
|
352
|
+
puts " #{green("create")} #{f}"
|
338
353
|
File.open(f, "w") do; end
|
339
354
|
end
|
340
355
|
|
@@ -345,7 +360,7 @@ module Shop
|
|
345
360
|
|
346
361
|
# Clean cache or class index
|
347
362
|
def clean(major)
|
348
|
-
if major == 'cache'
|
363
|
+
if major.nil? || major == 'cache'
|
349
364
|
theme
|
350
365
|
files = Dir["themes/#{theme}/cache/*.css"]
|
351
366
|
files = files + Dir["themes/#{theme}/cache/*.js"]
|
@@ -359,7 +374,7 @@ module Shop
|
|
359
374
|
return
|
360
375
|
end
|
361
376
|
|
362
|
-
print "Cleaning class index... "
|
377
|
+
print " Cleaning class index... "
|
363
378
|
index = "cache/class_index.php"
|
364
379
|
if File.exists?(index)
|
365
380
|
File.delete(index)
|
@@ -403,6 +418,7 @@ module Shop
|
|
403
418
|
end
|
404
419
|
else
|
405
420
|
File.open("Makefile", "w") do |f|
|
421
|
+
puts " #{green("create")} Makefile"
|
406
422
|
f.write(content)
|
407
423
|
end
|
408
424
|
end
|
@@ -411,7 +427,7 @@ module Shop
|
|
411
427
|
end
|
412
428
|
|
413
429
|
def done
|
414
|
-
puts "#{green("✔ Done")}"
|
430
|
+
puts "\n #{green("✔ Done")}"
|
415
431
|
end
|
416
432
|
|
417
433
|
def edit
|
@@ -445,7 +461,7 @@ module Shop
|
|
445
461
|
shop override controller <name> admin Creates an override for an admin controller
|
446
462
|
shop override class <name> Creates an override for a class
|
447
463
|
|
448
|
-
shop clean cache
|
464
|
+
shop clean [cache] Cleans the css and js caches
|
449
465
|
shop clean class Cleans the class index
|
450
466
|
|
451
467
|
shop jshint Run jshint on the theme files
|
@@ -454,6 +470,10 @@ module Shop
|
|
454
470
|
|
455
471
|
shop makefile Creates a Makefile or add tasks to an existing one
|
456
472
|
|
473
|
+
shop edit Open the configuration file in your $EDITOR
|
474
|
+
shop help Output this help text
|
475
|
+
shop version Output the version of Shop you are using
|
476
|
+
|
457
477
|
See the complete documentation at:
|
458
478
|
https://github.com/romainberger/shop
|
459
479
|
|
data/lib/shop/template.rb
CHANGED
@@ -2,15 +2,31 @@
|
|
2
2
|
module Shop
|
3
3
|
class Template
|
4
4
|
|
5
|
+
# Returns the path to the custom template if it exists
|
6
|
+
def custom_template_path(name)
|
7
|
+
config = ShopConfig.new
|
8
|
+
custom_path = config.get('template', 'path')
|
9
|
+
if File.exists?("#{custom_path}/#{name}")
|
10
|
+
"#{custom_path}/#{name}"
|
11
|
+
else
|
12
|
+
false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
5
16
|
# Returns the path to the templates directory
|
6
17
|
#
|
7
18
|
# Returns string
|
8
19
|
def template_path(name=false)
|
9
|
-
|
20
|
+
custom_path = custom_template_path(name)
|
21
|
+
if custom_path
|
22
|
+
custom_path
|
23
|
+
else
|
24
|
+
path = File.expand_path File.dirname(__FILE__)
|
10
25
|
|
11
|
-
|
26
|
+
return "#{path}/../../templates/#{name}" if name
|
12
27
|
|
13
|
-
|
28
|
+
"#{path}/../../templates"
|
29
|
+
end
|
14
30
|
end
|
15
31
|
|
16
32
|
# Replace the placeholders by the variables
|
@@ -20,7 +36,7 @@ module Shop
|
|
20
36
|
#
|
21
37
|
# Returns string
|
22
38
|
def template(name, datas)
|
23
|
-
file =
|
39
|
+
file = template_path(name)
|
24
40
|
content = File.read(file)
|
25
41
|
|
26
42
|
datas.each do |k, v|
|
data/shop.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'shop'
|
16
|
-
s.version = '0.1.
|
16
|
+
s.version = '0.1.8'
|
17
17
|
s.date = '2013-09-29'
|
18
18
|
s.rubyforge_project = 'shop'
|
19
19
|
|