shopify_cli 1.0.0 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +3 -0
- data/Gemfile.lock +5 -45
- data/README.md +10 -53
- data/bin/shopify-cli +1 -3
- data/lib/shopify_cli.rb +5 -1
- data/shopify_cli.gemspec +5 -17
- metadata +9 -96
- data/lib/shopify_cli/cli.rb +0 -179
- data/test/cli_test.rb +0 -137
- data/test/test_helper.rb +0 -77
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
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
ADDED
data/Gemfile.lock
CHANGED
@@ -1,59 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
shopify_cli (1.0.
|
5
|
-
pry (>= 0.9.12.6)
|
6
|
-
shopify_api
|
7
|
-
thor (~> 0.18.1)
|
4
|
+
shopify_cli (1.0.5)
|
8
5
|
|
9
6
|
GEM
|
10
7
|
remote: https://rubygems.org/
|
11
8
|
specs:
|
12
|
-
|
13
|
-
activesupport (= 4.0.13)
|
14
|
-
builder (~> 3.1.0)
|
15
|
-
activeresource (4.0.0)
|
16
|
-
activemodel (~> 4.0)
|
17
|
-
activesupport (~> 4.0)
|
18
|
-
rails-observers (~> 0.1.1)
|
19
|
-
activesupport (4.0.13)
|
20
|
-
i18n (~> 0.6, >= 0.6.9)
|
21
|
-
minitest (~> 4.2)
|
22
|
-
multi_json (~> 1.3)
|
23
|
-
thread_safe (~> 0.1)
|
24
|
-
tzinfo (~> 0.3.37)
|
25
|
-
builder (3.1.4)
|
26
|
-
coderay (1.1.0)
|
27
|
-
fakeweb (1.3.0)
|
28
|
-
i18n (0.7.0)
|
29
|
-
metaclass (0.0.4)
|
30
|
-
method_source (0.8.2)
|
31
|
-
minitest (4.7.5)
|
32
|
-
mocha (1.1.0)
|
33
|
-
metaclass (~> 0.0.1)
|
34
|
-
multi_json (1.11.0)
|
35
|
-
pry (0.10.1)
|
36
|
-
coderay (~> 1.1.0)
|
37
|
-
method_source (~> 0.8.1)
|
38
|
-
slop (~> 3.4)
|
39
|
-
rails-observers (0.1.2)
|
40
|
-
activemodel (~> 4.0)
|
41
|
-
rake (10.4.2)
|
42
|
-
shopify_api (3.2.7)
|
43
|
-
activeresource
|
44
|
-
pry (>= 0.9.12.6)
|
45
|
-
thor (~> 0.18.1)
|
46
|
-
slop (3.6.0)
|
47
|
-
thor (0.18.1)
|
48
|
-
thread_safe (0.3.5)
|
49
|
-
tzinfo (0.3.43)
|
9
|
+
rake (13.0.1)
|
50
10
|
|
51
11
|
PLATFORMS
|
52
12
|
ruby
|
53
13
|
|
54
14
|
DEPENDENCIES
|
55
|
-
fakeweb
|
56
|
-
minitest (~> 4.0)
|
57
|
-
mocha (>= 0.9.8)
|
58
15
|
rake
|
59
16
|
shopify_cli!
|
17
|
+
|
18
|
+
BUNDLED WITH
|
19
|
+
1.17.3
|
data/README.md
CHANGED
@@ -1,58 +1,15 @@
|
|
1
|
-
|
1
|
+
# This gem has been renamed to shopify_api_console
|
2
2
|
|
3
|
-
|
3
|
+
* Name: shopify_cli --> shopify_api_console
|
4
|
+
* GitHub: https://github.com/Shopify/shopify_cli --> https://github.com/Shopify/shopify_api_console
|
5
|
+
* RubyGems: https://rubygems.org/gems/shopify_cli --> https://rubygems.org/gems/shopify_api_console
|
4
6
|
|
5
|
-
1.
|
7
|
+
shopify_cli 1.x will not be supported going forward. v1.0.3+ will produce a deprecation warning.
|
6
8
|
|
7
|
-
|
9
|
+
Starting with v2.0, the gem has been renamed to `shopify_api_console`. We recommend switching to shopify_api_console v2.0+ as soon as possible.
|
8
10
|
|
9
|
-
|
10
|
-
shopify-cli add yourshopname
|
11
|
-
```
|
11
|
+
1.x versions will continue to exist on [RubyGems](https://rubygems.org/gems/shopify_cli) and in the [GitHub releases](https://github.com/Shopify/shopify_cli/releases). If you _must_ use one of these releases, make sure to specify a version:
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
```bash
|
18
|
-
shopify-cli console
|
19
|
-
```
|
20
|
-
|
21
|
-
4. To see the full list of commands, type:
|
22
|
-
|
23
|
-
```bash
|
24
|
-
shopify-cli help
|
25
|
-
```
|
26
|
-
|
27
|
-
## Installation:
|
28
|
-
|
29
|
-
`gem install shopify_cli`
|
30
|
-
|
31
|
-
## Contributing
|
32
|
-
|
33
|
-
After checking out the source, run:
|
34
|
-
|
35
|
-
`$ bundle install && bundle exec rake test`
|
36
|
-
|
37
|
-
## License:
|
38
|
-
|
39
|
-
Copyright (c) 2015 Shopify
|
40
|
-
|
41
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
42
|
-
a copy of this software and associated documentation files (the
|
43
|
-
'Software'), to deal in the Software without restriction, including
|
44
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
45
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
46
|
-
permit persons to whom the Software is furnished to do so, subject to
|
47
|
-
the following conditions:
|
48
|
-
|
49
|
-
The above copyright notice and this permission notice shall be
|
50
|
-
included in all copies or substantial portions of the Software.
|
51
|
-
|
52
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
53
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
54
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
55
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
56
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
57
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
58
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
13
|
+
```
|
14
|
+
gem install shopify_cli -v v1.0.4
|
15
|
+
```
|
data/bin/shopify-cli
CHANGED
data/lib/shopify_cli.rb
CHANGED
data/shopify_cli.gemspec
CHANGED
@@ -1,37 +1,25 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require 'shopify_cli'
|
4
2
|
|
5
3
|
Gem::Specification.new do |s|
|
6
4
|
s.name = %q{shopify_cli}
|
7
|
-
s.version =
|
5
|
+
s.version = "1.0.5"
|
8
6
|
s.author = "Shopify"
|
9
7
|
|
10
|
-
s.summary = %q{
|
8
|
+
s.summary = %q{Deprecated! Please use the `shopify_api_console` gem.}
|
11
9
|
s.description = %q{}
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
|
10
|
+
s.homepage = %q{https://github.com/Shopify/shopify_api_console}
|
11
|
+
s.metadata["allowed_push_host"] = "https://rubygems.org"
|
15
12
|
s.extra_rdoc_files = [
|
16
13
|
"LICENSE",
|
17
14
|
"README.md"
|
18
15
|
]
|
19
16
|
s.files = `git ls-files`.split("\n")
|
20
|
-
s.test_files = `git ls-files -- {test}/*`.split("\n")
|
21
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
18
|
|
23
19
|
s.rdoc_options = ["--charset=UTF-8"]
|
24
20
|
s.license = 'MIT'
|
25
21
|
|
26
|
-
|
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', '~> 4.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,99 +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: thor
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 0.18.1
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 0.18.1
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: pry
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.9.12.6
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.9.12.6
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: mocha
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 0.9.8
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 0.9.8
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: fakeweb
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: minitest
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '4.0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '4.0'
|
97
13
|
- !ruby/object:Gem::Dependency
|
98
14
|
name: rake
|
99
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +25,7 @@ dependencies:
|
|
109
25
|
- !ruby/object:Gem::Version
|
110
26
|
version: '0'
|
111
27
|
description: ''
|
112
|
-
email:
|
28
|
+
email:
|
113
29
|
executables:
|
114
30
|
- shopify-cli
|
115
31
|
extensions: []
|
@@ -117,6 +33,7 @@ extra_rdoc_files:
|
|
117
33
|
- LICENSE
|
118
34
|
- README.md
|
119
35
|
files:
|
36
|
+
- ".gitignore"
|
120
37
|
- Gemfile
|
121
38
|
- Gemfile.lock
|
122
39
|
- LICENSE
|
@@ -124,15 +41,13 @@ files:
|
|
124
41
|
- Rakefile
|
125
42
|
- bin/shopify-cli
|
126
43
|
- lib/shopify_cli.rb
|
127
|
-
- lib/shopify_cli/cli.rb
|
128
44
|
- shipit.rubygems.yml
|
129
45
|
- shopify_cli.gemspec
|
130
|
-
|
131
|
-
- test/test_helper.rb
|
132
|
-
homepage: http://www.shopify.com/partners/apps
|
46
|
+
homepage: https://github.com/Shopify/shopify_api_console
|
133
47
|
licenses:
|
134
48
|
- MIT
|
135
|
-
metadata:
|
49
|
+
metadata:
|
50
|
+
allowed_push_host: https://rubygems.org
|
136
51
|
post_install_message:
|
137
52
|
rdoc_options:
|
138
53
|
- "--charset=UTF-8"
|
@@ -149,10 +64,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
64
|
- !ruby/object:Gem::Version
|
150
65
|
version: '0'
|
151
66
|
requirements: []
|
152
|
-
|
153
|
-
rubygems_version: 2.4.5
|
67
|
+
rubygems_version: 3.0.3
|
154
68
|
signing_key:
|
155
69
|
specification_version: 4
|
156
|
-
summary:
|
157
|
-
from the console
|
70
|
+
summary: Deprecated! Please use the `shopify_api_console` gem.
|
158
71
|
test_files: []
|
data/lib/shopify_cli/cli.rb
DELETED
@@ -1,179 +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
|
-
launch_shell(config)
|
110
|
-
end
|
111
|
-
|
112
|
-
tasks.keys.abbrev.each do |shortcut, command|
|
113
|
-
map shortcut => command.to_sym
|
114
|
-
end
|
115
|
-
|
116
|
-
private
|
117
|
-
|
118
|
-
def shop_config_dir
|
119
|
-
@shop_config_dir ||= File.join(ENV['HOME'], '.shopify', 'shops')
|
120
|
-
end
|
121
|
-
|
122
|
-
def default_symlink
|
123
|
-
@default_symlink ||= File.join(shop_config_dir, 'default')
|
124
|
-
end
|
125
|
-
|
126
|
-
def config_file(connection)
|
127
|
-
if connection
|
128
|
-
File.join(shop_config_dir, "#{connection}.yml")
|
129
|
-
else
|
130
|
-
default_symlink
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
def site_from_config(config)
|
135
|
-
protocol = config['protocol'] || 'https'
|
136
|
-
api_key = config['api_key']
|
137
|
-
password = config['password']
|
138
|
-
domain = config['domain']
|
139
|
-
|
140
|
-
ShopifyAPI::Base.site = "#{protocol}://#{api_key}:#{password}@#{domain}/admin"
|
141
|
-
end
|
142
|
-
|
143
|
-
def launch_shell(config)
|
144
|
-
if config["shell"] === "pry"
|
145
|
-
require 'pry'
|
146
|
-
ARGV.clear
|
147
|
-
Pry.start
|
148
|
-
else
|
149
|
-
require 'irb'
|
150
|
-
require 'irb/completion'
|
151
|
-
ARGV.clear
|
152
|
-
IRB.start
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
def available_connections
|
157
|
-
@available_connections ||= begin
|
158
|
-
pattern = File.join(shop_config_dir, "*.yml")
|
159
|
-
Dir.glob(pattern).map { |f| File.basename(f, ".yml") }
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
def default_connection_target
|
164
|
-
@default_connection_target ||= File.readlink(default_symlink)
|
165
|
-
end
|
166
|
-
|
167
|
-
def default_connection
|
168
|
-
@default_connection ||= File.basename(default_connection_target, ".yml")
|
169
|
-
end
|
170
|
-
|
171
|
-
def default?(connection)
|
172
|
-
default_connection == connection
|
173
|
-
end
|
174
|
-
|
175
|
-
def no_config_file_error(filename)
|
176
|
-
raise ConfigFileError, "There is no config file at #{filename}"
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
data/test/cli_test.rb
DELETED
@@ -1,137 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'shopify_cli/cli'
|
3
|
-
require 'fileutils'
|
4
|
-
|
5
|
-
class CliTest < Test::Unit::TestCase
|
6
|
-
HOME_DIR = File.expand_path(File.dirname(__FILE__))
|
7
|
-
TEST_HOME = File.join(HOME_DIR, 'files', 'home')
|
8
|
-
CONFIG_DIR = File.join(TEST_HOME, '.shopify', 'shops')
|
9
|
-
DEFAULT_SYMLINK = File.join(CONFIG_DIR, 'default')
|
10
|
-
|
11
|
-
def setup
|
12
|
-
force_remove(TEST_HOME)
|
13
|
-
|
14
|
-
ENV['HOME'] = TEST_HOME
|
15
|
-
@cli = ShopifyCLI::Cli.new
|
16
|
-
|
17
|
-
FileUtils.mkdir_p(CONFIG_DIR)
|
18
|
-
Dir.chdir(CONFIG_DIR)
|
19
|
-
|
20
|
-
add_config('foo', default: true, config: valid_options.merge(domain: 'foo.myshopify.com'))
|
21
|
-
add_config('bar', config: valid_options.merge(domain: 'bar.myshopify.com'))
|
22
|
-
end
|
23
|
-
|
24
|
-
def teardown
|
25
|
-
Dir.chdir(HOME_DIR)
|
26
|
-
force_remove(TEST_HOME)
|
27
|
-
end
|
28
|
-
|
29
|
-
test "add with blank domain" do
|
30
|
-
standard_add_shop_prompts
|
31
|
-
$stdin.expects(:gets).times(4).returns("", "key", "pass", "y")
|
32
|
-
@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")
|
33
|
-
@cli.expects(:puts).with("Default connection is foo")
|
34
|
-
|
35
|
-
@cli.add('foo')
|
36
|
-
|
37
|
-
config = YAML.load(File.read(config_file('foo')))
|
38
|
-
assert_equal 'foo.myshopify.com', config['domain']
|
39
|
-
assert_equal 'key', config['api_key']
|
40
|
-
assert_equal 'pass', config['password']
|
41
|
-
assert_equal 'pry', config['shell']
|
42
|
-
assert_equal 'https', config['protocol']
|
43
|
-
assert_equal config_file('foo'), File.readlink(DEFAULT_SYMLINK)
|
44
|
-
end
|
45
|
-
|
46
|
-
test "add with explicit domain" do
|
47
|
-
standard_add_shop_prompts
|
48
|
-
$stdin.expects(:gets).times(4).returns("bar.myshopify.com", "key", "pass", "y")
|
49
|
-
@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")
|
50
|
-
@cli.expects(:puts).with("Default connection is foo")
|
51
|
-
|
52
|
-
@cli.add('foo')
|
53
|
-
|
54
|
-
config = YAML.load(File.read(config_file('foo')))
|
55
|
-
assert_equal 'bar.myshopify.com', config['domain']
|
56
|
-
end
|
57
|
-
|
58
|
-
test "add with irb as shell" do
|
59
|
-
standard_add_shop_prompts
|
60
|
-
$stdin.expects(:gets).times(4).returns("bar.myshopify.com", "key", "pass", "fuuuuuuu")
|
61
|
-
@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")
|
62
|
-
@cli.expects(:puts).with("Default connection is foo")
|
63
|
-
|
64
|
-
@cli.add('foo')
|
65
|
-
|
66
|
-
config = YAML.load(File.read(config_file('foo')))
|
67
|
-
assert_equal 'irb', config['shell']
|
68
|
-
end
|
69
|
-
|
70
|
-
test "list" do
|
71
|
-
@cli.expects(:puts).with(" bar")
|
72
|
-
@cli.expects(:puts).with(" * foo")
|
73
|
-
|
74
|
-
@cli.list
|
75
|
-
end
|
76
|
-
|
77
|
-
test "show default" do
|
78
|
-
@cli.expects(:puts).with("Default connection is foo")
|
79
|
-
|
80
|
-
@cli.default
|
81
|
-
end
|
82
|
-
|
83
|
-
test "set default" do
|
84
|
-
@cli.expects(:puts).with("Default connection is bar")
|
85
|
-
|
86
|
-
@cli.default('bar')
|
87
|
-
|
88
|
-
assert_equal config_file('bar'), File.readlink(DEFAULT_SYMLINK)
|
89
|
-
end
|
90
|
-
|
91
|
-
test "remove default connection" do
|
92
|
-
@cli.remove('foo')
|
93
|
-
|
94
|
-
assert !File.exist?(DEFAULT_SYMLINK)
|
95
|
-
assert !File.exist?(config_file('foo'))
|
96
|
-
assert File.exist?(config_file('bar'))
|
97
|
-
end
|
98
|
-
|
99
|
-
test "remove non-default connection" do
|
100
|
-
@cli.remove('bar')
|
101
|
-
|
102
|
-
assert_equal 'foo.yml', File.readlink(DEFAULT_SYMLINK)
|
103
|
-
assert File.exist?(config_file('foo'))
|
104
|
-
assert !File.exist?(config_file('bar'))
|
105
|
-
end
|
106
|
-
|
107
|
-
private
|
108
|
-
|
109
|
-
def valid_options
|
110
|
-
{'domain' => 'snowdevil.myshopify.com', 'api_key' => 'key', 'password' => 'pass', 'shell' => 'pry', 'protocol' => 'https'}
|
111
|
-
end
|
112
|
-
|
113
|
-
def config_file(connection)
|
114
|
-
File.join(CONFIG_DIR, "#{connection}.yml")
|
115
|
-
end
|
116
|
-
|
117
|
-
def add_config(name, config: nil, default: false)
|
118
|
-
File.open("#{name}.yml", 'w') do |file|
|
119
|
-
file.puts config.to_yaml
|
120
|
-
end
|
121
|
-
File.symlink("#{name}.yml", DEFAULT_SYMLINK) if default
|
122
|
-
end
|
123
|
-
|
124
|
-
def standard_add_shop_prompts
|
125
|
-
force_remove("#{CONFIG_DIR}/*")
|
126
|
-
|
127
|
-
$stdout.expects(:print).with("Domain? (leave blank for foo.myshopify.com) ")
|
128
|
-
$stdout.expects(:print).with("API key? ")
|
129
|
-
$stdout.expects(:print).with("Password? ")
|
130
|
-
$stdout.expects(:print).with("Would you like to use pry as your shell? (y/n) ")
|
131
|
-
end
|
132
|
-
|
133
|
-
def force_remove(pattern)
|
134
|
-
`rm -rf #{pattern}`
|
135
|
-
end
|
136
|
-
|
137
|
-
end
|
data/test/test_helper.rb
DELETED
@@ -1,77 +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
|
-
module Test
|
14
|
-
module Unit
|
15
|
-
class TestCase < MiniTest::Unit::TestCase
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
# setup ShopifyAPI with fake api_key and secret
|
20
|
-
|
21
|
-
class Test::Unit::TestCase
|
22
|
-
def self.test(string, &block)
|
23
|
-
define_method("test:#{string}", &block)
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.should(string, &block)
|
27
|
-
self.test("should_#{string}", &block)
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.context(string)
|
31
|
-
yield
|
32
|
-
end
|
33
|
-
|
34
|
-
def setup
|
35
|
-
ActiveResource::Base.format = :json
|
36
|
-
ShopifyAPI.constants.each do |const|
|
37
|
-
begin
|
38
|
-
const = "ShopifyAPI::#{const}".constantize
|
39
|
-
const.format = :json if const.respond_to?(:format=)
|
40
|
-
rescue NameError
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
ShopifyAPI::Base.clear_session
|
45
|
-
ShopifyAPI::Base.site = "https://this-is-my-test-shop.myshopify.com/admin"
|
46
|
-
ShopifyAPI::Base.password = nil
|
47
|
-
ShopifyAPI::Base.user = nil
|
48
|
-
end
|
49
|
-
|
50
|
-
def teardown
|
51
|
-
FakeWeb.clean_registry
|
52
|
-
end
|
53
|
-
|
54
|
-
# Custom Assertions
|
55
|
-
def assert_not(expression)
|
56
|
-
assert_block("Expected <#{expression}> to be false!") { not expression }
|
57
|
-
end
|
58
|
-
|
59
|
-
def load_fixture(name, format=:json)
|
60
|
-
File.read(File.dirname(__FILE__) + "/fixtures/#{name}.#{format}")
|
61
|
-
end
|
62
|
-
|
63
|
-
def fake(endpoint, options={})
|
64
|
-
body = options.has_key?(:body) ? options.delete(:body) : load_fixture(endpoint)
|
65
|
-
format = options.delete(:format) || :json
|
66
|
-
method = options.delete(:method) || :get
|
67
|
-
extension = ".#{options.delete(:extension)||'json'}" unless options[:extension]==false
|
68
|
-
|
69
|
-
url = if options.has_key?(:url)
|
70
|
-
options[:url]
|
71
|
-
else
|
72
|
-
"https://this-is-my-test-shop.myshopify.com/admin/#{endpoint}#{extension}"
|
73
|
-
end
|
74
|
-
|
75
|
-
FakeWeb.register_uri(method, url, {:body => body, :status => 200, :content_type => "text/#{format}", :content_length => 1}.merge(options))
|
76
|
-
end
|
77
|
-
end
|