shopifydev 0.0.19 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +31 -2
- data/lib/shopifydev/console.rb +10 -10
- data/lib/shopifydev/pry/commands.rb +14 -14
- data/lib/shopifydev/pry/save_json.rb +6 -6
- data/lib/shopifydev/shopify_api/caches.rb +12 -12
- data/lib/shopifydev/version.rb +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
|
+
Mzk3YTFjNzhmNjJhZTU4MTI4MGEwYmZmZmExN2Q3ZGYwN2FkZjk4MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDQxZThmZGJiYWRlNWEyZjc2NzA0MTkxMmZjNzYzNjhhNDMwMjM4ZQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Yzg3N2YxMmYzODY2ZGYxY2QyYWU2ZWQ2OWI2OWQ3MDgwMWY4ODg4MTNhMmRh
|
10
|
+
OTdkYWI2ZGJjYWU0NzIyNGNlYTIzNjA2MGQ5ODVkOWNlMGQ2YTYwNjNlMGJi
|
11
|
+
NDRlN2RkNjUwY2Q0N2NhZGFhMmJkODY3Nzk4NzBlMDI5MmFhODI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzQzOWRmYWJmMzY3ZDMyZmNhMWVlZmVlYWIyNmQxNTQ5MzM4NzYxNjFmODkz
|
14
|
+
OTk1MjJmMzA2N2RjZmFhNzc3MWQ5YzEwNzJjMWY4N2VhZGY1Y2M1MmNhNzJj
|
15
|
+
ZWNkYjUzYWVmYTUxYmI2MzZiMmI4NmQyMTc0NzcyZWQwNzg2NzI=
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Abstract out and port to ruby the functionality of the shopify textmate bundle f
|
|
4
4
|
|
5
5
|
## Compatibility
|
6
6
|
|
7
|
-
shopifydev
|
7
|
+
There is a branch of shopifydev that specifically targets **Rails 3.2.13**. This is due to a dependency problem with ```shopify_api``` that arose when Rails 4.0 was released. If you have problems using shopifydev with Rails 3, try using the rails3 branch.
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -73,8 +73,37 @@ you won't upload a file twice unless it gets changed twice in the same commit)
|
|
73
73
|
|
74
74
|
One final tip: `alias upify='shopifydev upload'`
|
75
75
|
|
76
|
-
#
|
76
|
+
# Rails Console / Pry
|
77
|
+
To use shopifydev in the console of a rails app, add the following to your .pryrc:
|
77
78
|
|
79
|
+
require 'shopifydev'
|
80
|
+
require 'shopifydev/console'
|
81
|
+
|
82
|
+
|
83
|
+
## Switch
|
84
|
+
The switch command lets you switch between shops in the console. In a rails app, it knows how to look up shops the local rails app knows about (that have been installed) or you can configure it in ```~/.shopifydev.yaml``` thusly:
|
85
|
+
|
86
|
+
test_shops:
|
87
|
+
arbitrary-label:
|
88
|
+
api_key: xxx
|
89
|
+
password: xxx
|
90
|
+
myshopify_domain: weird-autogenerated-name.myshopify.com
|
91
|
+
weird2:
|
92
|
+
api_key: xxx
|
93
|
+
password: xxx
|
94
|
+
myshopify_domain: weird-autogenerated-name2.myshopify.com
|
95
|
+
apps:
|
96
|
+
development:
|
97
|
+
app_name1: /path/to/a/rails/app
|
98
|
+
app_name1: /path/to/a/rails/app
|
99
|
+
|
100
|
+
heroku:
|
101
|
+
name: heroku-app-name
|
102
|
+
|
103
|
+
The heroku support may or may not be working currently.
|
104
|
+
|
105
|
+
## Caches
|
106
|
+
When using pry or rails console in a rails app, shopifydev keeps caches of the current shop's resources.
|
78
107
|
Caches are defined on ```ShopifyAPI```.
|
79
108
|
Assuming you ```cd ShopifyAPI```:
|
80
109
|
|
data/lib/shopifydev/console.rb
CHANGED
@@ -1,4 +1,13 @@
|
|
1
|
-
|
1
|
+
require 'shopifydev/pry/commands'
|
2
|
+
require 'shopifydev/pry/save_json'
|
3
|
+
require 'shopifydev/shopify_api/caches'
|
4
|
+
|
5
|
+
require 'term/ansicolor'
|
6
|
+
|
7
|
+
require 'shydra'
|
8
|
+
require 'shydra/hydra'
|
9
|
+
|
10
|
+
class TColor
|
2
11
|
if Pry.config.color
|
3
12
|
extend Term::ANSIColor
|
4
13
|
else
|
@@ -10,15 +19,6 @@ class Color
|
|
10
19
|
end
|
11
20
|
end
|
12
21
|
|
13
|
-
require 'shopifydev/pry/commands'
|
14
|
-
require 'shopifydev/pry/save_json'
|
15
|
-
require 'shopifydev/shopify_api/caches'
|
16
|
-
|
17
|
-
require 'term/ansicolor'
|
18
|
-
|
19
|
-
require 'shydra'
|
20
|
-
require 'shydra/hydra'
|
21
|
-
|
22
22
|
|
23
23
|
|
24
24
|
Pry.config.hooks.add_hook(:before_session, :set_context) { |_, _, pry| pry.input = StringIO.new("cd ShopifyAPI") }
|
@@ -9,7 +9,7 @@ class Switch
|
|
9
9
|
|
10
10
|
def current_shop
|
11
11
|
@current_shop = ShopifyAPI::Base.site || 'none'
|
12
|
-
|
12
|
+
TColor.green{ "current shop:"} + " #{@current_shop}"
|
13
13
|
end
|
14
14
|
|
15
15
|
def reset!
|
@@ -36,7 +36,7 @@ class Switch
|
|
36
36
|
@breadcrumbs, @cfg = pick_config(ix)
|
37
37
|
|
38
38
|
if @breadcrumbs == :no_such_config
|
39
|
-
result <<
|
39
|
+
result << TColor.red{ "I don't know about #{ix}\n" }
|
40
40
|
result << self.menu.print
|
41
41
|
else
|
42
42
|
# update the menu based on the choice
|
@@ -90,7 +90,7 @@ class Switch
|
|
90
90
|
if menu_method
|
91
91
|
result << "you picked #{@breadcrumbs.join('.')}\n"
|
92
92
|
result << @cfg.inspect + "\n"
|
93
|
-
result <<
|
93
|
+
result << TColor.yellow { menu_method.call.print }
|
94
94
|
end
|
95
95
|
result
|
96
96
|
end
|
@@ -104,7 +104,7 @@ class Switch
|
|
104
104
|
session.valid? # returns true
|
105
105
|
ShopifyAPI::Base.activate_session(session)
|
106
106
|
when :heroku
|
107
|
-
puts
|
107
|
+
puts TColor.red{ "can't handle heroku yet"}
|
108
108
|
end
|
109
109
|
else
|
110
110
|
ShopifyAPI::Base.clear_session
|
@@ -279,7 +279,7 @@ class ConfigMenu
|
|
279
279
|
header("Local Apps")
|
280
280
|
json[:apps][:development].each do |k, path|
|
281
281
|
if Pathname(path).expand_path == Pathname.getwd
|
282
|
-
path =
|
282
|
+
path = TColor.green{ path }
|
283
283
|
end
|
284
284
|
choice([:apps, :development, k], path)
|
285
285
|
end
|
@@ -311,17 +311,17 @@ class ConfigMenu
|
|
311
311
|
# TODO I think these three related methods could be moved into a module called "Writer" or something
|
312
312
|
def header(label)
|
313
313
|
@lines << ''
|
314
|
-
@lines <<
|
314
|
+
@lines << TColor.blue { label }
|
315
315
|
end
|
316
316
|
|
317
317
|
def warn(label)
|
318
318
|
@lines << ''
|
319
|
-
@lines <<
|
319
|
+
@lines << TColor.red { label }
|
320
320
|
end
|
321
321
|
|
322
322
|
def choice(path, value)
|
323
323
|
ix = @choices.length
|
324
|
-
@lines <<
|
324
|
+
@lines << TColor.yellow{ ix.to_s } + '. ' + value.to_s
|
325
325
|
@choices[ix] = path
|
326
326
|
end
|
327
327
|
end
|
@@ -343,9 +343,9 @@ shopifydev_command_set = Pry::CommandSet.new do
|
|
343
343
|
result = ''
|
344
344
|
until _pry_.switch.finished?
|
345
345
|
output.puts _pry_.switch.menu.print
|
346
|
-
print "❔ " +
|
346
|
+
print "❔ " + TColor.yellow
|
347
347
|
choice = $stdin.gets
|
348
|
-
print
|
348
|
+
print TColor.clear
|
349
349
|
if choice.blank?
|
350
350
|
_pry_.switch.reset!
|
351
351
|
else
|
@@ -366,10 +366,10 @@ shopifydev_command_set = Pry::CommandSet.new do
|
|
366
366
|
def process
|
367
367
|
case args.first
|
368
368
|
when 'off'
|
369
|
-
puts
|
369
|
+
puts TColor.black{"ActiveResource logging "} + TColor.red{'off'}
|
370
370
|
ActiveResource::Base.logger = nil
|
371
371
|
else
|
372
|
-
puts
|
372
|
+
puts TColor.black{"ActiveResource logging "} + TColor.yellow{'on'}
|
373
373
|
ActiveResource::Base.logger = Logger.new STDOUT
|
374
374
|
end
|
375
375
|
end
|
@@ -384,9 +384,9 @@ shopifydev_command_set = Pry::CommandSet.new do
|
|
384
384
|
report = Shopifydev::ShopifyAPI::ConsumeAPI.consume(num) do |report_line|
|
385
385
|
case report_line.level
|
386
386
|
when :info
|
387
|
-
puts
|
387
|
+
puts TColor.yellow{ report_line.msg }
|
388
388
|
when :status
|
389
|
-
puts
|
389
|
+
puts TColor.blue{ report_line.msg}
|
390
390
|
else
|
391
391
|
puts report_line.msg
|
392
392
|
end
|
@@ -6,7 +6,7 @@ module Kernel
|
|
6
6
|
path = UnixTree.get_path(path, require: :file, new: true)
|
7
7
|
if path
|
8
8
|
path = path.sub_ext('json') unless path.nil?
|
9
|
-
puts
|
9
|
+
puts TColor.green{"writing json to #{path.to_s}..."}
|
10
10
|
File.open(path, 'w'){|f| f.write(json)}
|
11
11
|
true
|
12
12
|
else
|
@@ -17,7 +17,7 @@ module Kernel
|
|
17
17
|
def load_json(path=nil)
|
18
18
|
path = UnixTree.get_path(path, require: :file)
|
19
19
|
if path
|
20
|
-
puts
|
20
|
+
puts TColor.green{"loading json from #{path.to_s}..."}
|
21
21
|
Oj.load(path)
|
22
22
|
else
|
23
23
|
nil
|
@@ -35,12 +35,12 @@ module UnixTree
|
|
35
35
|
path.expand_path.descend{|p| unless p.exist?; missing = p; break; end} if path
|
36
36
|
if missing
|
37
37
|
what = (missing == path) ? opts[:require].to_s : 'directory'
|
38
|
-
puts
|
38
|
+
puts TColor.red{ "couldn't find #{what} #{missing.to_s}" }
|
39
39
|
missing = missing.dirname
|
40
40
|
print_tree missing
|
41
41
|
|
42
42
|
end
|
43
|
-
print
|
43
|
+
print TColor.yellow{ "enter path: "}
|
44
44
|
in_path = $stdin.gets.chomp
|
45
45
|
return nil if in_path == 'q'
|
46
46
|
unless in_path.blank?
|
@@ -74,8 +74,8 @@ module UnixTree
|
|
74
74
|
path ||= Pathname.getwd
|
75
75
|
path = Pathname.new(path) unless path.is_a?(Pathname)
|
76
76
|
path = path.dirname if path.file?
|
77
|
-
puts
|
78
|
-
puts `cd #{path.expand_path.to_s}; tree`.gsub(%r{(^[^\w]+)},
|
77
|
+
puts TColor.blue{ "listing #{path}..."}
|
78
|
+
puts `cd #{path.expand_path.to_s}; tree`.gsub(%r{(^[^\w]+)}, TColor.black{'\1'})
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -23,18 +23,18 @@ module ShopifyAPI
|
|
23
23
|
dirty?
|
24
24
|
subset = ''
|
25
25
|
opts = ''
|
26
|
-
length =
|
26
|
+
length = TColor.black{'unloaded'}
|
27
27
|
since = ''
|
28
28
|
unless cache.nil?
|
29
29
|
if !show_opts && (cache.params.keys.to_set != Set[:limit])
|
30
|
-
subset =
|
30
|
+
subset = TColor.red('!')
|
31
31
|
end
|
32
32
|
if show_opts
|
33
|
-
opts = cache.params.map{|k, v|
|
33
|
+
opts = cache.params.map{|k, v| TColor.magenta{k.to_s} + TColor.black{':'} + TColor.green{v.to_s}}.join(TColor.black{', '})
|
34
34
|
opts = "\n #{opts}"
|
35
35
|
end
|
36
|
-
length = (cache.length > 0) ? "#{cache.length.to_s}#{subset} #{
|
37
|
-
since = "#{
|
36
|
+
length = (cache.length > 0) ? "#{cache.length.to_s}#{subset} #{TColor.black{cache.label}}" : 'empty'
|
37
|
+
since = "#{TColor.black{'on:'}}#{cache.since.strftime("%a %H:%M:%S")}"
|
38
38
|
end
|
39
39
|
"#{length.ljust(18)} #{since}#{opts}"
|
40
40
|
end
|
@@ -43,13 +43,13 @@ module ShopifyAPI
|
|
43
43
|
return if warn_site
|
44
44
|
dirty?
|
45
45
|
puts <<-EOF
|
46
|
-
#{
|
47
|
-
#{
|
48
|
-
#{
|
49
|
-
#{
|
50
|
-
#{
|
51
|
-
#{
|
52
|
-
#{
|
46
|
+
#{TColor.blue{'products'}}: #{cache_status(@@products, show_opts)}
|
47
|
+
#{TColor.blue{'variants'}}: #{cache_status(@@variants, show_opts)}
|
48
|
+
#{TColor.blue{'metafields'}}: #{cache_status(@@metafields, show_opts)}
|
49
|
+
#{TColor.blue{'orders'}}: #{cache_status(@@orders, show_opts)}
|
50
|
+
#{TColor.blue{'customers'}}: #{cache_status(@@customers, show_opts)}
|
51
|
+
#{TColor.blue{'custom_collections'}}: #{cache_status(@@custom_collections, show_opts)}
|
52
|
+
#{TColor.blue{'smart_collections'}}: #{cache_status(@@smart_collections, show_opts)}
|
53
53
|
EOF
|
54
54
|
end
|
55
55
|
|
data/lib/shopifydev/version.rb
CHANGED