shopify_cli 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +3 -53
- data/README.md +1 -1
- data/bin/shopify-cli +1 -3
- data/lib/shopify_cli.rb +5 -2
- data/shopify_cli.gemspec +3 -15
- metadata +5 -121
- data/.travis.yml +0 -3
- data/lib/shopify_cli/cli.rb +0 -183
- data/test/cli_test.rb +0 -136
- data/test/test_helper.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9770048b8fb57f21450b6040a628a7b5968169d550bf6e711374e54f18316c5c
|
4
|
+
data.tar.gz: b724e9c43a7b93f4b6946be0b716ad0ce45ba339dc36832853d8ae73beb9df97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6a396daa013e9703bba115ca84b7b3c3225cf2c3eb1be0f2197bfbfe27270499083831b793cc25ff3f40fef1e12ec82e43a3166ed3fc38d352bfe240464dc07
|
7
|
+
data.tar.gz: 6503eeae69926cb196347eb28887208439577be3fa7f7e78a2364595ea9522e538c2e20745889db479131704f9f5854c26122aab979d090432b9bcbc395f0bd2
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,69 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
shopify_cli (1.0.
|
5
|
-
activemodel (>= 4.2.2)
|
6
|
-
activesupport (>= 4.2.2)
|
7
|
-
pry (>= 0.9.12.6)
|
8
|
-
shopify_api
|
9
|
-
thor (~> 0.18.1)
|
4
|
+
shopify_cli (1.0.5)
|
10
5
|
|
11
6
|
GEM
|
12
7
|
remote: https://rubygems.org/
|
13
8
|
specs:
|
14
|
-
|
15
|
-
activesupport (= 5.2.2)
|
16
|
-
activemodel-serializers-xml (1.0.2)
|
17
|
-
activemodel (> 5.x)
|
18
|
-
activesupport (> 5.x)
|
19
|
-
builder (~> 3.1)
|
20
|
-
activeresource (5.1.0)
|
21
|
-
activemodel (>= 5.0, < 7)
|
22
|
-
activemodel-serializers-xml (~> 1.0)
|
23
|
-
activesupport (>= 5.0, < 7)
|
24
|
-
activesupport (5.2.2)
|
25
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
|
-
i18n (>= 0.7, < 2)
|
27
|
-
minitest (~> 5.1)
|
28
|
-
tzinfo (~> 1.1)
|
29
|
-
builder (3.2.3)
|
30
|
-
coderay (1.1.2)
|
31
|
-
concurrent-ruby (1.1.3)
|
32
|
-
fakeweb (1.3.0)
|
33
|
-
graphql (1.8.11)
|
34
|
-
graphql-client (0.14.0)
|
35
|
-
activesupport (>= 3.0, < 6.0)
|
36
|
-
graphql (~> 1.6)
|
37
|
-
i18n (1.1.1)
|
38
|
-
concurrent-ruby (~> 1.0)
|
39
|
-
metaclass (0.0.4)
|
40
|
-
method_source (0.9.2)
|
41
|
-
minitest (5.7.0)
|
42
|
-
mocha (1.1.0)
|
43
|
-
metaclass (~> 0.0.1)
|
44
|
-
pry (0.12.2)
|
45
|
-
coderay (~> 1.1.0)
|
46
|
-
method_source (~> 0.9.0)
|
47
|
-
rack (2.0.6)
|
48
|
-
rake (10.4.2)
|
49
|
-
shopify_api (5.2.0)
|
50
|
-
activeresource (>= 3.0.0)
|
51
|
-
graphql-client
|
52
|
-
rack
|
53
|
-
thor (0.18.1)
|
54
|
-
thread_safe (0.3.6)
|
55
|
-
tzinfo (1.2.5)
|
56
|
-
thread_safe (~> 0.1)
|
9
|
+
rake (13.0.1)
|
57
10
|
|
58
11
|
PLATFORMS
|
59
12
|
ruby
|
60
13
|
|
61
14
|
DEPENDENCIES
|
62
|
-
fakeweb
|
63
|
-
minitest (~> 5.0)
|
64
|
-
mocha (>= 0.9.8)
|
65
15
|
rake
|
66
16
|
shopify_cli!
|
67
17
|
|
68
18
|
BUNDLED WITH
|
69
|
-
1.
|
19
|
+
1.17.3
|
data/README.md
CHANGED
data/bin/shopify-cli
CHANGED
data/lib/shopify_cli.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
module ShopifyCLI
|
2
|
-
|
3
|
-
|
2
|
+
warn <<~MESSAGE
|
3
|
+
[DEPRECATION] The shopify_cli gem is no longer supported. Please switch to:
|
4
|
+
- shopify_api_console v2+ for the Shopify API console
|
5
|
+
- shopify-cli for the Shopify CLI
|
6
|
+
MESSAGE
|
4
7
|
end
|
data/shopify_cli.gemspec
CHANGED
@@ -1,37 +1,25 @@
|
|
1
1
|
$:.push File.expand_path("../lib", __FILE__)
|
2
|
-
require 'shopify_cli'
|
3
2
|
|
4
3
|
Gem::Specification.new do |s|
|
5
4
|
s.name = %q{shopify_cli}
|
6
|
-
s.version =
|
5
|
+
s.version = "1.0.5"
|
7
6
|
s.author = "Shopify"
|
8
7
|
|
9
8
|
s.summary = %q{Deprecated! Please use the `shopify_api_console` gem.}
|
10
9
|
s.description = %q{}
|
11
10
|
s.homepage = %q{https://github.com/Shopify/shopify_api_console}
|
12
|
-
|
11
|
+
s.metadata["allowed_push_host"] = "https://rubygems.org"
|
13
12
|
s.extra_rdoc_files = [
|
14
13
|
"LICENSE",
|
15
14
|
"README.md"
|
16
15
|
]
|
17
16
|
s.files = `git ls-files`.split("\n")
|
18
|
-
s.test_files = `git ls-files -- {test}/*`.split("\n")
|
19
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
18
|
|
21
19
|
s.rdoc_options = ["--charset=UTF-8"]
|
22
20
|
s.license = 'MIT'
|
23
21
|
|
24
|
-
|
25
|
-
s.add_dependency("activemodel", ">= 4.2.2")
|
26
|
-
s.add_dependency("activesupport", ">= 4.2.2")
|
27
|
-
s.add_dependency("thor", "~> 0.18.1")
|
28
|
-
s.add_dependency("pry", ">= 0.9.12.6")
|
29
|
-
|
30
|
-
dev_dependencies = [['mocha', '>= 0.9.8'],
|
31
|
-
['fakeweb'],
|
32
|
-
['minitest', '~> 5.0'],
|
33
|
-
['rake']
|
34
|
-
]
|
22
|
+
dev_dependencies = [['rake']]
|
35
23
|
|
36
24
|
if s.respond_to?(:add_development_dependency)
|
37
25
|
dev_dependencies.each { |dep| s.add_development_dependency(*dep) }
|
metadata
CHANGED
@@ -1,127 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: shopify_api
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: activemodel
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 4.2.2
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 4.2.2
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: activesupport
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 4.2.2
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 4.2.2
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: thor
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.18.1
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 0.18.1
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 0.9.12.6
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 0.9.12.6
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: mocha
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.9.8
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.9.8
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: fakeweb
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: minitest
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '5.0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '5.0'
|
125
13
|
- !ruby/object:Gem::Dependency
|
126
14
|
name: rake
|
127
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,7 +34,6 @@ extra_rdoc_files:
|
|
146
34
|
- README.md
|
147
35
|
files:
|
148
36
|
- ".gitignore"
|
149
|
-
- ".travis.yml"
|
150
37
|
- Gemfile
|
151
38
|
- Gemfile.lock
|
152
39
|
- LICENSE
|
@@ -154,15 +41,13 @@ files:
|
|
154
41
|
- Rakefile
|
155
42
|
- bin/shopify-cli
|
156
43
|
- lib/shopify_cli.rb
|
157
|
-
- lib/shopify_cli/cli.rb
|
158
44
|
- shipit.rubygems.yml
|
159
45
|
- shopify_cli.gemspec
|
160
|
-
- test/cli_test.rb
|
161
|
-
- test/test_helper.rb
|
162
46
|
homepage: https://github.com/Shopify/shopify_api_console
|
163
47
|
licenses:
|
164
48
|
- MIT
|
165
|
-
metadata:
|
49
|
+
metadata:
|
50
|
+
allowed_push_host: https://rubygems.org
|
166
51
|
post_install_message:
|
167
52
|
rdoc_options:
|
168
53
|
- "--charset=UTF-8"
|
@@ -179,8 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
64
|
- !ruby/object:Gem::Version
|
180
65
|
version: '0'
|
181
66
|
requirements: []
|
182
|
-
|
183
|
-
rubygems_version: 2.7.6
|
67
|
+
rubygems_version: 3.0.3
|
184
68
|
signing_key:
|
185
69
|
specification_version: 4
|
186
70
|
summary: Deprecated! Please use the `shopify_api_console` gem.
|
data/.travis.yml
DELETED
data/lib/shopify_cli/cli.rb
DELETED
@@ -1,183 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'abbrev'
|
3
|
-
require 'yaml'
|
4
|
-
require 'shopify_api'
|
5
|
-
|
6
|
-
module ShopifyCLI
|
7
|
-
class Cli < Thor
|
8
|
-
include Thor::Actions
|
9
|
-
|
10
|
-
class ConfigFileError < StandardError
|
11
|
-
end
|
12
|
-
|
13
|
-
desc "list", "list available connections"
|
14
|
-
def list
|
15
|
-
available_connections.each do |c|
|
16
|
-
prefix = default?(c) ? " * " : " "
|
17
|
-
puts prefix + c
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
desc "add CONNECTION", "create a config file for a connection named CONNECTION"
|
22
|
-
def add(connection)
|
23
|
-
file = config_file(connection)
|
24
|
-
if File.exist?(file)
|
25
|
-
raise ConfigFileError, "There is already a config file at #{file}"
|
26
|
-
else
|
27
|
-
config = {'protocol' => 'https'}
|
28
|
-
config['domain'] = ask("Domain? (leave blank for #{connection}.myshopify.com)")
|
29
|
-
config['domain'] = "#{connection}.myshopify.com" if config['domain'].blank?
|
30
|
-
config['domain'] = "#{config['domain']}.myshopify.com" unless config['domain'].match(/[.:]/)
|
31
|
-
puts "\nopen https://#{config['domain']}/admin/apps/private in your browser to create a private app and get API credentials\n"
|
32
|
-
config['api_key'] = ask("API key?")
|
33
|
-
config['password'] = ask("Password?")
|
34
|
-
if ask("Would you like to use pry as your shell? (y/n)") === "y"
|
35
|
-
config["shell"] = "pry"
|
36
|
-
else
|
37
|
-
config["shell"] = "irb"
|
38
|
-
end
|
39
|
-
create_file(file, config.to_yaml)
|
40
|
-
end
|
41
|
-
if available_connections.one?
|
42
|
-
default(connection)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
desc "remove CONNECTION", "remove the config file for CONNECTION"
|
47
|
-
def remove(connection)
|
48
|
-
file = config_file(connection)
|
49
|
-
if File.exist?(file)
|
50
|
-
remove_file(default_symlink) if default?(connection)
|
51
|
-
remove_file(file)
|
52
|
-
else
|
53
|
-
no_config_file_error(file)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
desc "edit [CONNECTION]", "open the config file for CONNECTION with your default editor"
|
58
|
-
def edit(connection=nil)
|
59
|
-
file = config_file(connection)
|
60
|
-
if File.exist?(file)
|
61
|
-
if ENV['EDITOR'].present?
|
62
|
-
system(ENV['EDITOR'], file)
|
63
|
-
else
|
64
|
-
puts "Please set an editor in the EDITOR environment variable"
|
65
|
-
end
|
66
|
-
else
|
67
|
-
no_config_file_error(file)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
desc "show [CONNECTION]", "output the location and contents of the CONNECTION's config file"
|
72
|
-
def show(connection=nil)
|
73
|
-
connection ||= default_connection
|
74
|
-
file = config_file(connection)
|
75
|
-
if File.exist?(file)
|
76
|
-
puts file
|
77
|
-
puts `cat #{file}`
|
78
|
-
else
|
79
|
-
no_config_file_error(file)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
desc "default [CONNECTION]", "show the default connection, or make CONNECTION the default"
|
84
|
-
def default(connection=nil)
|
85
|
-
if connection
|
86
|
-
target = config_file(connection)
|
87
|
-
if File.exist?(target)
|
88
|
-
remove_file(default_symlink)
|
89
|
-
`ln -s #{target} #{default_symlink}`
|
90
|
-
else
|
91
|
-
no_config_file_error(target)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
if File.exist?(default_symlink)
|
95
|
-
puts "Default connection is #{default_connection}"
|
96
|
-
else
|
97
|
-
puts "There is no default connection set"
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
desc "console [CONNECTION]", "start an API console for CONNECTION"
|
102
|
-
def console(connection=nil)
|
103
|
-
file = config_file(connection)
|
104
|
-
|
105
|
-
config = YAML.load(File.read(file))
|
106
|
-
puts "using #{config['domain']}"
|
107
|
-
ShopifyAPI::Base.site = site_from_config(config)
|
108
|
-
|
109
|
-
logger = Logger.new(STDOUT)
|
110
|
-
logger.level = Logger::WARN
|
111
|
-
ActiveResource::Base.logger = logger
|
112
|
-
|
113
|
-
launch_shell(config)
|
114
|
-
end
|
115
|
-
|
116
|
-
tasks.keys.abbrev.each do |shortcut, command|
|
117
|
-
map shortcut => command.to_sym
|
118
|
-
end
|
119
|
-
|
120
|
-
private
|
121
|
-
|
122
|
-
def shop_config_dir
|
123
|
-
@shop_config_dir ||= File.join(ENV['HOME'], '.shopify', 'shops')
|
124
|
-
end
|
125
|
-
|
126
|
-
def default_symlink
|
127
|
-
@default_symlink ||= File.join(shop_config_dir, 'default')
|
128
|
-
end
|
129
|
-
|
130
|
-
def config_file(connection)
|
131
|
-
if connection
|
132
|
-
File.join(shop_config_dir, "#{connection}.yml")
|
133
|
-
else
|
134
|
-
default_symlink
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
def site_from_config(config)
|
139
|
-
protocol = config['protocol'] || 'https'
|
140
|
-
api_key = config['api_key']
|
141
|
-
password = config['password']
|
142
|
-
domain = config['domain']
|
143
|
-
|
144
|
-
ShopifyAPI::Base.site = "#{protocol}://#{api_key}:#{password}@#{domain}/admin"
|
145
|
-
end
|
146
|
-
|
147
|
-
def launch_shell(config)
|
148
|
-
if config["shell"] === "pry"
|
149
|
-
require 'pry'
|
150
|
-
ARGV.clear
|
151
|
-
Pry.start
|
152
|
-
else
|
153
|
-
require 'irb'
|
154
|
-
require 'irb/completion'
|
155
|
-
ARGV.clear
|
156
|
-
IRB.start
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
def available_connections
|
161
|
-
@available_connections ||= begin
|
162
|
-
pattern = File.join(shop_config_dir, "*.yml")
|
163
|
-
Dir.glob(pattern).map { |f| File.basename(f, ".yml") }
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
def default_connection_target
|
168
|
-
@default_connection_target ||= File.readlink(default_symlink)
|
169
|
-
end
|
170
|
-
|
171
|
-
def default_connection
|
172
|
-
@default_connection ||= File.basename(default_connection_target, ".yml")
|
173
|
-
end
|
174
|
-
|
175
|
-
def default?(connection)
|
176
|
-
default_connection == connection
|
177
|
-
end
|
178
|
-
|
179
|
-
def no_config_file_error(filename)
|
180
|
-
raise ConfigFileError, "There is no config file at #{filename}"
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
data/test/cli_test.rb
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'shopify_cli/cli'
|
3
|
-
require 'fileutils'
|
4
|
-
class CliTest < Minitest::Test
|
5
|
-
HOME_DIR = File.expand_path(File.dirname(__FILE__))
|
6
|
-
TEST_HOME = File.join(HOME_DIR, 'files', 'home')
|
7
|
-
CONFIG_DIR = File.join(TEST_HOME, '.shopify', 'shops')
|
8
|
-
DEFAULT_SYMLINK = File.join(CONFIG_DIR, 'default')
|
9
|
-
|
10
|
-
def setup
|
11
|
-
force_remove(TEST_HOME)
|
12
|
-
|
13
|
-
ENV['HOME'] = TEST_HOME
|
14
|
-
@cli = ShopifyCLI::Cli.new
|
15
|
-
|
16
|
-
FileUtils.mkdir_p(CONFIG_DIR)
|
17
|
-
Dir.chdir(CONFIG_DIR)
|
18
|
-
|
19
|
-
add_config('foo', default: true, config: valid_options.merge(domain: 'foo.myshopify.com'))
|
20
|
-
add_config('bar', config: valid_options.merge(domain: 'bar.myshopify.com'))
|
21
|
-
end
|
22
|
-
|
23
|
-
def teardown
|
24
|
-
Dir.chdir(HOME_DIR)
|
25
|
-
force_remove(TEST_HOME)
|
26
|
-
end
|
27
|
-
|
28
|
-
test "add with blank domain" do
|
29
|
-
standard_add_shop_prompts
|
30
|
-
$stdin.expects(:gets).times(4).returns("", "key", "pass", "y")
|
31
|
-
@cli.expects(:puts).with("\nopen https://foo.myshopify.com/admin/apps/private in your browser to create a private app and get API credentials\n")
|
32
|
-
@cli.expects(:puts).with("Default connection is foo")
|
33
|
-
|
34
|
-
@cli.add('foo')
|
35
|
-
|
36
|
-
config = YAML.load(File.read(config_file('foo')))
|
37
|
-
assert_equal 'foo.myshopify.com', config['domain']
|
38
|
-
assert_equal 'key', config['api_key']
|
39
|
-
assert_equal 'pass', config['password']
|
40
|
-
assert_equal 'pry', config['shell']
|
41
|
-
assert_equal 'https', config['protocol']
|
42
|
-
assert_equal config_file('foo'), File.readlink(DEFAULT_SYMLINK)
|
43
|
-
end
|
44
|
-
|
45
|
-
test "add with explicit domain" do
|
46
|
-
standard_add_shop_prompts
|
47
|
-
$stdin.expects(:gets).times(4).returns("bar.myshopify.com", "key", "pass", "y")
|
48
|
-
@cli.expects(:puts).with("\nopen https://bar.myshopify.com/admin/apps/private in your browser to create a private app and get API credentials\n")
|
49
|
-
@cli.expects(:puts).with("Default connection is foo")
|
50
|
-
|
51
|
-
@cli.add('foo')
|
52
|
-
|
53
|
-
config = YAML.load(File.read(config_file('foo')))
|
54
|
-
assert_equal 'bar.myshopify.com', config['domain']
|
55
|
-
end
|
56
|
-
|
57
|
-
test "add with irb as shell" do
|
58
|
-
standard_add_shop_prompts
|
59
|
-
$stdin.expects(:gets).times(4).returns("bar.myshopify.com", "key", "pass", "fuuuuuuu")
|
60
|
-
@cli.expects(:puts).with("\nopen https://bar.myshopify.com/admin/apps/private in your browser to create a private app and get API credentials\n")
|
61
|
-
@cli.expects(:puts).with("Default connection is foo")
|
62
|
-
|
63
|
-
@cli.add('foo')
|
64
|
-
|
65
|
-
config = YAML.load(File.read(config_file('foo')))
|
66
|
-
assert_equal 'irb', config['shell']
|
67
|
-
end
|
68
|
-
|
69
|
-
test "list" do
|
70
|
-
@cli.expects(:puts).with(" bar")
|
71
|
-
@cli.expects(:puts).with(" * foo")
|
72
|
-
|
73
|
-
@cli.list
|
74
|
-
end
|
75
|
-
|
76
|
-
test "show default" do
|
77
|
-
@cli.expects(:puts).with("Default connection is foo")
|
78
|
-
|
79
|
-
@cli.default
|
80
|
-
end
|
81
|
-
|
82
|
-
test "set default" do
|
83
|
-
@cli.expects(:puts).with("Default connection is bar")
|
84
|
-
|
85
|
-
@cli.default('bar')
|
86
|
-
|
87
|
-
assert_equal config_file('bar'), File.readlink(DEFAULT_SYMLINK)
|
88
|
-
end
|
89
|
-
|
90
|
-
test "remove default connection" do
|
91
|
-
@cli.remove('foo')
|
92
|
-
|
93
|
-
assert !File.exist?(DEFAULT_SYMLINK)
|
94
|
-
assert !File.exist?(config_file('foo'))
|
95
|
-
assert File.exist?(config_file('bar'))
|
96
|
-
end
|
97
|
-
|
98
|
-
test "remove non-default connection" do
|
99
|
-
@cli.remove('bar')
|
100
|
-
|
101
|
-
assert_equal 'foo.yml', File.readlink(DEFAULT_SYMLINK)
|
102
|
-
assert File.exist?(config_file('foo'))
|
103
|
-
assert !File.exist?(config_file('bar'))
|
104
|
-
end
|
105
|
-
|
106
|
-
private
|
107
|
-
|
108
|
-
def valid_options
|
109
|
-
{'domain' => 'snowdevil.myshopify.com', 'api_key' => 'key', 'password' => 'pass', 'shell' => 'pry', 'protocol' => 'https'}
|
110
|
-
end
|
111
|
-
|
112
|
-
def config_file(connection)
|
113
|
-
File.join(CONFIG_DIR, "#{connection}.yml")
|
114
|
-
end
|
115
|
-
|
116
|
-
def add_config(name, config: nil, default: false)
|
117
|
-
File.open("#{name}.yml", 'w') do |file|
|
118
|
-
file.puts config.to_yaml
|
119
|
-
end
|
120
|
-
File.symlink("#{name}.yml", DEFAULT_SYMLINK) if default
|
121
|
-
end
|
122
|
-
|
123
|
-
def standard_add_shop_prompts
|
124
|
-
force_remove("#{CONFIG_DIR}/*")
|
125
|
-
|
126
|
-
$stdout.expects(:print).with("Domain? (leave blank for foo.myshopify.com) ")
|
127
|
-
$stdout.expects(:print).with("API key? ")
|
128
|
-
$stdout.expects(:print).with("Password? ")
|
129
|
-
$stdout.expects(:print).with("Would you like to use pry as your shell? (y/n) ")
|
130
|
-
end
|
131
|
-
|
132
|
-
def force_remove(pattern)
|
133
|
-
`rm -rf #{pattern}`
|
134
|
-
end
|
135
|
-
|
136
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'minitest/autorun'
|
3
|
-
require 'fakeweb'
|
4
|
-
require 'mocha/setup'
|
5
|
-
|
6
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
8
|
-
require 'shopify_cli'
|
9
|
-
require 'shopify_api'
|
10
|
-
|
11
|
-
FakeWeb.allow_net_connect = false
|
12
|
-
|
13
|
-
# setup ShopifyAPI with fake api_key and secret
|
14
|
-
|
15
|
-
class Minitest::Test
|
16
|
-
def self.test(string, &block)
|
17
|
-
define_method("test_#{string}", &block)
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.should(string, &block)
|
21
|
-
self.test("should_#{string}", &block)
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.context(string)
|
25
|
-
yield
|
26
|
-
end
|
27
|
-
|
28
|
-
def setup
|
29
|
-
ActiveResource::Base.format = :json
|
30
|
-
ShopifyAPI.constants.each do |const|
|
31
|
-
begin
|
32
|
-
const = "ShopifyAPI::#{const}".constantize
|
33
|
-
const.format = :json if const.respond_to?(:format=)
|
34
|
-
rescue NameError
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
ShopifyAPI::Base.clear_session
|
39
|
-
ShopifyAPI::Base.site = "https://this-is-my-test-shop.myshopify.com/admin"
|
40
|
-
ShopifyAPI::Base.password = nil
|
41
|
-
ShopifyAPI::Base.user = nil
|
42
|
-
end
|
43
|
-
|
44
|
-
def teardown
|
45
|
-
FakeWeb.clean_registry
|
46
|
-
end
|
47
|
-
|
48
|
-
# Custom Assertions
|
49
|
-
def assert_not(expression)
|
50
|
-
assert_block("Expected <#{expression}> to be false!") { not expression }
|
51
|
-
end
|
52
|
-
|
53
|
-
def load_fixture(name, format=:json)
|
54
|
-
File.read(File.dirname(__FILE__) + "/fixtures/#{name}.#{format}")
|
55
|
-
end
|
56
|
-
|
57
|
-
def fake(endpoint, options={})
|
58
|
-
body = options.has_key?(:body) ? options.delete(:body) : load_fixture(endpoint)
|
59
|
-
format = options.delete(:format) || :json
|
60
|
-
method = options.delete(:method) || :get
|
61
|
-
extension = ".#{options.delete(:extension)||'json'}" unless options[:extension]==false
|
62
|
-
|
63
|
-
url = if options.has_key?(:url)
|
64
|
-
options[:url]
|
65
|
-
else
|
66
|
-
"https://this-is-my-test-shop.myshopify.com/admin/#{endpoint}#{extension}"
|
67
|
-
end
|
68
|
-
|
69
|
-
FakeWeb.register_uri(method, url, {:body => body, :status => 200, :content_type => "text/#{format}", :content_length => 1}.merge(options))
|
70
|
-
end
|
71
|
-
end
|