voog-kit 0.1.11 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.markdown +11 -0
- data/bin/kit +21 -2
- data/lib/voog/dtk/filemanager.rb +6 -7
- data/lib/voog/dtk/version.rb +1 -1
- data/lib/voog/dtk.rb +9 -2
- data/spec/fixtures/manifest.json +1 -1
- data/spec/models/dtk/filemanager_spec.rb +13 -4
- data/spec/spec_helper.rb +0 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1c88db6b03fc5e1e036dd8ed3df13bb2f5cb1b2
|
4
|
+
data.tar.gz: eb9caf57e75c716860c4c2b719d5f283a8cd090a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 621fd03b7e3dfdbd2801bff9df93337cdbaf93b329de9b71fcc99579b4cb329bca156746ac41c39be6fc3a56a0a5b73adec06b78852084cb3daf18b2fabd75a4
|
7
|
+
data.tar.gz: 2771bf3cad4702850652021296b9e3fa1253bf090b125206885e6954b29fdbb4de6459d3a42cd2bf3ba94fe57b2d0fbda98111681d15e9c24b3373c719af1ecd
|
data/README.markdown
CHANGED
@@ -62,6 +62,17 @@ If the configuration file isn't present and you provide the token, hostname and
|
|
62
62
|
command, the file is then generated and the options are stored within so you don't have to provide them
|
63
63
|
later.
|
64
64
|
|
65
|
+
Another useful option is `--overwrite` to allow updating asset files you normally couldn't update. This deletes the
|
66
|
+
old file and uploads the newer one as a replacement. This cannot be undone, so take caution!
|
67
|
+
To enable overwriting for all commands, you can add it to the site's configuration block in the `.voog` file like so:
|
68
|
+
|
69
|
+
```
|
70
|
+
[site1]
|
71
|
+
host=mysite.voog.com
|
72
|
+
api_token=afcf30182aecfc8155d390d7d4552d14
|
73
|
+
overwrite=true
|
74
|
+
```
|
75
|
+
|
65
76
|
### init
|
66
77
|
|
67
78
|
This command either initializes an empty folder structure via `kit init empty`, clones the file and folder
|
data/bin/kit
CHANGED
@@ -24,6 +24,7 @@ silent_args = [:silent, { default_value: false, negatable: false, desc: 'Hide al
|
|
24
24
|
hostname_args = [:h, :host, :hostname, { desc: 'Provide a hostname', arg_name: :HOST }]
|
25
25
|
api_token_args = [:t, :token, :api_token, { desc: 'Provide an API token', arg_name: :API_TOKEN }]
|
26
26
|
site_args = [:s, :site, { arg_name: :SITE, default_value: nil, desc: 'Specify which site block to use when parsing the .voog file' }]
|
27
|
+
overwrite_args = [:overwrite, { negatable: true, default_value: false, desc: 'Enable overwriting asset files that cannot be normally updated. '}]
|
27
28
|
|
28
29
|
flag *hostname_args
|
29
30
|
flag *api_token_args
|
@@ -32,6 +33,8 @@ flag *site_args
|
|
32
33
|
switch *debug_args
|
33
34
|
switch *verbose_args
|
34
35
|
switch *silent_args
|
36
|
+
switch *overwrite_args
|
37
|
+
|
35
38
|
version Voog::Dtk::VERSION
|
36
39
|
|
37
40
|
desc 'Initializes the local folder structure and files for a site'
|
@@ -47,6 +50,7 @@ command :init do |c|
|
|
47
50
|
c.switch *debug_args
|
48
51
|
c.switch *verbose_args
|
49
52
|
c.switch *silent_args
|
53
|
+
c.switch *overwrite_args
|
50
54
|
c.flag *hostname_args
|
51
55
|
c.flag *api_token_args
|
52
56
|
c.flag *site_args
|
@@ -74,6 +78,7 @@ command :check do |c|
|
|
74
78
|
c.switch *debug_args
|
75
79
|
c.switch *verbose_args
|
76
80
|
c.switch *silent_args
|
81
|
+
c.switch *overwrite_args
|
77
82
|
c.flag *hostname_args
|
78
83
|
c.flag *api_token_args
|
79
84
|
c.flag *site_args
|
@@ -92,6 +97,7 @@ command :pull do |c|
|
|
92
97
|
c.switch *debug_args
|
93
98
|
c.switch *verbose_args
|
94
99
|
c.switch *silent_args
|
100
|
+
c.switch *overwrite_args
|
95
101
|
c.flag *hostname_args
|
96
102
|
c.flag *api_token_args
|
97
103
|
c.flag *site_args
|
@@ -115,6 +121,7 @@ command :push do |c|
|
|
115
121
|
c.switch *debug_args
|
116
122
|
c.switch *verbose_args
|
117
123
|
c.switch *silent_args
|
124
|
+
c.switch *overwrite_args
|
118
125
|
c.flag *hostname_args
|
119
126
|
c.flag *api_token_args
|
120
127
|
c.flag *site_args
|
@@ -135,6 +142,7 @@ command :manifest do |c|
|
|
135
142
|
c.switch *debug_args
|
136
143
|
c.switch *verbose_args
|
137
144
|
c.switch *silent_args
|
145
|
+
c.switch *overwrite_args
|
138
146
|
c.flag *hostname_args
|
139
147
|
c.flag *api_token_args
|
140
148
|
c.flag *site_args
|
@@ -162,6 +170,7 @@ command :watch do |c|
|
|
162
170
|
c.switch *debug_args
|
163
171
|
c.switch *verbose_args
|
164
172
|
c.switch *silent_args
|
173
|
+
c.switch *overwrite_args
|
165
174
|
c.flag *hostname_args
|
166
175
|
c.flag *api_token_args
|
167
176
|
c.flag *site_args
|
@@ -177,6 +186,7 @@ pre do |global, command, options, args|
|
|
177
186
|
|
178
187
|
silent = global.fetch(:silent, false) || options.fetch(:silent, false)
|
179
188
|
verbose = global.fetch(:verbose, false) || options.fetch(:verbose, false)
|
189
|
+
overwrite = global.fetch(:overwrite, false) || options.fetch(:overwrite, false)
|
180
190
|
|
181
191
|
@notifier = Voog::Dtk::Notifier.new($stderr, silent)
|
182
192
|
|
@@ -184,7 +194,12 @@ pre do |global, command, options, args|
|
|
184
194
|
api_token = global.fetch(:token, nil) || options.fetch(:token, nil)
|
185
195
|
|
186
196
|
if host && api_token && @config_block
|
187
|
-
Voog::Dtk.write_config(
|
197
|
+
Voog::Dtk.write_config({
|
198
|
+
host: host,
|
199
|
+
api_token: api_token,
|
200
|
+
block: @config_block,
|
201
|
+
overwrite: overwrite
|
202
|
+
})
|
188
203
|
end
|
189
204
|
|
190
205
|
@config = Voog::Dtk.read_config @config_block
|
@@ -204,7 +219,11 @@ pre do |global, command, options, args|
|
|
204
219
|
api_token ||= @config[:api_token]
|
205
220
|
|
206
221
|
client = Voog::Client.new(host, api_token)
|
207
|
-
@filemanager = Voog::Dtk::FileManager.new(client,
|
222
|
+
@filemanager = Voog::Dtk::FileManager.new(client, {
|
223
|
+
silent: silent,
|
224
|
+
verbose: verbose,
|
225
|
+
overwrite: overwrite
|
226
|
+
})
|
208
227
|
end
|
209
228
|
|
210
229
|
on_error do |exception|
|
data/lib/voog/dtk/filemanager.rb
CHANGED
@@ -8,12 +8,12 @@ require 'mime/types'
|
|
8
8
|
module Voog::Dtk
|
9
9
|
class FileManager
|
10
10
|
attr_accessor :notifier
|
11
|
-
def initialize(client,
|
12
|
-
@notifier = Voog::Dtk::Notifier.new($stderr, silent)
|
11
|
+
def initialize(client, opts = {})
|
13
12
|
@client = client
|
14
|
-
@
|
15
|
-
@
|
16
|
-
|
13
|
+
@silent = opts.fetch(:silent, false)
|
14
|
+
@verbose = opts.fetch(:verbose, false)
|
15
|
+
@overwrite = opts.fetch(:overwrite, false)
|
16
|
+
@notifier = Voog::Dtk::Notifier.new($stderr, @silent)
|
17
17
|
end
|
18
18
|
|
19
19
|
def read_manifest
|
@@ -430,7 +430,6 @@ module Voog::Dtk
|
|
430
430
|
not_ok_char = "!"
|
431
431
|
@notifier.info "Checking manifest.json..."
|
432
432
|
|
433
|
-
# Check for manifest
|
434
433
|
if File.exists? 'manifest.json'
|
435
434
|
@manifest = read_manifest
|
436
435
|
@notifier.success 'OK!'
|
@@ -611,7 +610,7 @@ module Voog::Dtk
|
|
611
610
|
@notifier.error "Unable to update file #{file}!"
|
612
611
|
end
|
613
612
|
else
|
614
|
-
if @
|
613
|
+
if @overwrite
|
615
614
|
@notifier.info "Re-uploading file #{file}..."
|
616
615
|
if delete_layout_asset(layout_assets[file]) && create_remote_file(file)
|
617
616
|
@notifier.success 'OK!'
|
data/lib/voog/dtk/version.rb
CHANGED
data/lib/voog/dtk.rb
CHANGED
@@ -45,7 +45,12 @@ module Voog
|
|
45
45
|
config
|
46
46
|
end
|
47
47
|
|
48
|
-
def write_config(
|
48
|
+
def write_config(opts)
|
49
|
+
block = opts.fetch(:block, '')
|
50
|
+
host = opts.fetch(:host, '')
|
51
|
+
api_token = opts.fetch(:api_token, '')
|
52
|
+
silent = opts.fetch(:silent, false)
|
53
|
+
|
49
54
|
@file = if config_exists?
|
50
55
|
CONFIG_FILENAME
|
51
56
|
elsif global_config_exists?
|
@@ -61,11 +66,13 @@ module Voog
|
|
61
66
|
puts "Writing new configuration options to existing config block.".white unless silent
|
62
67
|
options.params[block]['host'] = host unless host.empty?
|
63
68
|
options.params[block]['api_token'] = api_token unless api_token.empty?
|
69
|
+
options.params[block]['overwrite'] = overwrite unless overwrite.empty?
|
64
70
|
else
|
65
71
|
puts "Writing configuration options to new config block.".white unless silent
|
66
72
|
options.params[block] = {
|
67
73
|
'host' => host,
|
68
|
-
'api_token' => api_token
|
74
|
+
'api_token' => api_token,
|
75
|
+
'overwrite' => overwrite
|
69
76
|
}
|
70
77
|
end
|
71
78
|
|
data/spec/fixtures/manifest.json
CHANGED
@@ -7,7 +7,7 @@ describe Voog::Dtk::FileManager do
|
|
7
7
|
before :all do
|
8
8
|
Dir.mkdir 'TEST'
|
9
9
|
Dir.chdir 'TEST'
|
10
|
-
@filemanager = Voog::Dtk::FileManager.new(nil, false, true)
|
10
|
+
@filemanager = Voog::Dtk::FileManager.new(nil, {silent: false, verbose: true, overwrite: false})
|
11
11
|
@dir = Dir.new('.')
|
12
12
|
end
|
13
13
|
|
@@ -284,7 +284,7 @@ describe Voog::Dtk::FileManager do
|
|
284
284
|
end
|
285
285
|
end
|
286
286
|
|
287
|
-
describe '#remove_from_manifest'
|
287
|
+
describe '#remove_from_manifest' do
|
288
288
|
before :all do
|
289
289
|
@filemanager.generate_manifest(get_layouts, get_layout_assets)
|
290
290
|
@filemanager.add_to_manifest ['components/testfile2.tpl', 'assets/test.svg']
|
@@ -319,12 +319,21 @@ describe Voog::Dtk::FileManager do
|
|
319
319
|
|
320
320
|
describe '#check' do
|
321
321
|
context 'with an empty folder' do
|
322
|
+
before :all do
|
323
|
+
Dir.mkdir('temp')
|
324
|
+
Dir.chdir('temp')
|
325
|
+
end
|
326
|
+
|
327
|
+
after :all do
|
328
|
+
Dir.chdir('..')
|
329
|
+
Dir.delete('temp')
|
330
|
+
end
|
322
331
|
it 'returns false' do
|
323
332
|
expect(@filemanager.check).to be_false
|
324
333
|
end
|
325
334
|
end
|
326
335
|
|
327
|
-
context 'with empty manifest.json
|
336
|
+
context 'with empty manifest.json and no files' do
|
328
337
|
it 'returns false' do
|
329
338
|
File.open('manifest.json', 'w+') do |file|
|
330
339
|
file << {
|
@@ -338,7 +347,7 @@ describe Voog::Dtk::FileManager do
|
|
338
347
|
|
339
348
|
context 'with filled manifest.json but no files' do
|
340
349
|
it 'returns false' do
|
341
|
-
File.open('manifest.json', 'w+') do |file|
|
350
|
+
@manifest = File.open('manifest.json', 'w+') do |file|
|
342
351
|
file << {
|
343
352
|
'layouts' => [{
|
344
353
|
"component" => false,
|
data/spec/spec_helper.rb
CHANGED