shopify-cli 1.0.4 → 1.0.5
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/.travis.yml +3 -2
- data/CHANGELOG.md +5 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +13 -13
- data/docs/Gemfile.lock +23 -13
- data/lib/project_types/extension/models/type.rb +1 -0
- data/lib/project_types/extension/tasks/create_extension.rb +1 -1
- data/lib/project_types/extension/tasks/get_app.rb +1 -1
- data/lib/project_types/extension/tasks/update_draft.rb +1 -1
- data/lib/project_types/script/commands/create.rb +1 -5
- data/lib/project_types/script/commands/disable.rb +1 -2
- data/lib/project_types/script/commands/enable.rb +5 -5
- data/lib/project_types/script/commands/push.rb +1 -6
- data/lib/project_types/script/config/extension_points.yml +2 -2
- data/lib/project_types/script/errors.rb +8 -0
- data/lib/project_types/script/layers/domain/errors.rb +2 -0
- data/lib/project_types/script/layers/infrastructure/errors.rb +1 -0
- data/lib/project_types/script/messages/messages.rb +11 -14
- data/lib/project_types/script/ui/error_handler.rb +4 -0
- data/lib/shopify-cli/command.rb +12 -6
- data/lib/shopify-cli/commands/connect.rb +7 -75
- data/lib/shopify-cli/commands/create.rb +1 -1
- data/lib/shopify-cli/commands/system.rb +13 -5
- data/lib/shopify-cli/core/entry_point.rb +1 -1
- data/lib/shopify-cli/core/executor.rb +3 -5
- data/lib/shopify-cli/core/monorail.rb +1 -1
- data/lib/shopify-cli/db.rb +1 -1
- data/lib/shopify-cli/heroku.rb +4 -4
- data/lib/shopify-cli/messages/messages.rb +15 -19
- data/lib/shopify-cli/process_supervision.rb +8 -6
- data/lib/shopify-cli/project_type.rb +3 -2
- data/lib/shopify-cli/sub_command.rb +1 -0
- data/lib/shopify-cli/task.rb +2 -2
- data/lib/shopify-cli/tasks.rb +11 -4
- data/lib/shopify-cli/tasks/ensure_env.rb +74 -17
- data/lib/shopify-cli/tunnel.rb +6 -6
- data/lib/shopify-cli/version.rb +1 -1
- data/lib/shopify_cli.rb +31 -9
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b05da9533ccffc11607217b455d2a23590668a445a0af58c67c168fe5a5dfe96
|
|
4
|
+
data.tar.gz: e10408bf78ac963dd50953edbf438bc4dbf247d0001db8a1b1013b0f981189f1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7626a67bc6ba0fe13b6223b4239927e4f4e39c74a2536e7fe0a38b4403d9c115771a913c4921d28a81175de84c1cc9e7fc9b84e046042a5957ba9f3aa1d56d7d
|
|
7
|
+
data.tar.gz: 630008b941f6c034f51fcdb370f6dd09dba5bcb18a44b5bd1035367443bdc28d679adf69ee9e0f3a9417ddfcbef473411d99934a9a14fc777310edf67677711c
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
Version 1.0.5
|
|
2
|
+
------
|
|
3
|
+
* Fix a bug in out opt-in metrics
|
|
4
|
+
|
|
1
5
|
Version 1.0.4
|
|
2
6
|
------
|
|
3
|
-
* Fix a bug when running the `connect` command with an account with multiple organizations
|
|
7
|
+
* Fix a bug when running the `connect` command with an account with multiple organizations
|
|
4
8
|
|
|
5
9
|
Version 1.0.3
|
|
6
10
|
------
|
data/Gemfile
CHANGED
|
@@ -16,7 +16,7 @@ group :test do
|
|
|
16
16
|
gem 'mocha', require: false
|
|
17
17
|
gem 'minitest', '>= 5.0.0', require: false
|
|
18
18
|
gem 'minitest-reporters', require: false
|
|
19
|
-
gem 'fakefs', require: false
|
|
19
|
+
gem 'fakefs', '>= 1.0', require: false
|
|
20
20
|
gem 'webmock', require: false
|
|
21
21
|
gem 'timecop', require: false
|
|
22
22
|
end
|
data/Gemfile.lock
CHANGED
|
@@ -4,13 +4,13 @@ GEM
|
|
|
4
4
|
addressable (2.5.2)
|
|
5
5
|
public_suffix (>= 2.0.2, < 4.0)
|
|
6
6
|
ansi (1.5.0)
|
|
7
|
-
ast (2.4.
|
|
7
|
+
ast (2.4.1)
|
|
8
8
|
builder (3.2.3)
|
|
9
|
-
byebug (8.2.
|
|
9
|
+
byebug (8.2.5)
|
|
10
10
|
coderay (1.1.2)
|
|
11
11
|
crack (0.4.3)
|
|
12
12
|
safe_yaml (~> 1.0.0)
|
|
13
|
-
fakefs (
|
|
13
|
+
fakefs (1.2.2)
|
|
14
14
|
hashdiff (0.3.2)
|
|
15
15
|
metaclass (0.0.4)
|
|
16
16
|
method_source (0.9.2)
|
|
@@ -22,9 +22,9 @@ GEM
|
|
|
22
22
|
ruby-progressbar
|
|
23
23
|
mocha (1.7.0)
|
|
24
24
|
metaclass (~> 0.0.1)
|
|
25
|
-
parallel (1.19.
|
|
26
|
-
parser (2.7.1.
|
|
27
|
-
ast (~> 2.4.
|
|
25
|
+
parallel (1.19.2)
|
|
26
|
+
parser (2.7.1.4)
|
|
27
|
+
ast (~> 2.4.1)
|
|
28
28
|
pry (0.12.2)
|
|
29
29
|
coderay (~> 1.1.0)
|
|
30
30
|
method_source (~> 0.9.0)
|
|
@@ -34,19 +34,19 @@ GEM
|
|
|
34
34
|
public_suffix (3.0.3)
|
|
35
35
|
rainbow (3.0.0)
|
|
36
36
|
rake (13.0.1)
|
|
37
|
-
regexp_parser (1.7.
|
|
37
|
+
regexp_parser (1.7.1)
|
|
38
38
|
rexml (3.2.4)
|
|
39
|
-
rubocop (0.
|
|
39
|
+
rubocop (0.89.1)
|
|
40
40
|
parallel (~> 1.10)
|
|
41
|
-
parser (>= 2.7.
|
|
41
|
+
parser (>= 2.7.1.1)
|
|
42
42
|
rainbow (>= 2.2.2, < 4.0)
|
|
43
43
|
regexp_parser (>= 1.7)
|
|
44
44
|
rexml
|
|
45
|
-
rubocop-ast (>= 0.0.
|
|
45
|
+
rubocop-ast (>= 0.3.0, < 1.0)
|
|
46
46
|
ruby-progressbar (~> 1.7)
|
|
47
47
|
unicode-display_width (>= 1.4.0, < 2.0)
|
|
48
|
-
rubocop-ast (0.0
|
|
49
|
-
parser (>= 2.7.
|
|
48
|
+
rubocop-ast (0.3.0)
|
|
49
|
+
parser (>= 2.7.1.4)
|
|
50
50
|
ruby-progressbar (1.10.1)
|
|
51
51
|
safe_yaml (1.0.4)
|
|
52
52
|
session (3.2.0)
|
|
@@ -62,7 +62,7 @@ PLATFORMS
|
|
|
62
62
|
|
|
63
63
|
DEPENDENCIES
|
|
64
64
|
byebug
|
|
65
|
-
fakefs
|
|
65
|
+
fakefs (>= 1.0)
|
|
66
66
|
minitest (>= 5.0.0)
|
|
67
67
|
minitest-reporters
|
|
68
68
|
mocha
|
data/docs/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
GEM
|
|
2
2
|
remote: https://rubygems.org/
|
|
3
3
|
specs:
|
|
4
|
-
activesupport (6.0.3.
|
|
4
|
+
activesupport (6.0.3.2)
|
|
5
5
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
6
6
|
i18n (>= 0.7, < 2)
|
|
7
7
|
minitest (~> 5.1)
|
|
@@ -16,9 +16,9 @@ GEM
|
|
|
16
16
|
colorator (1.1.0)
|
|
17
17
|
commonmarker (0.17.13)
|
|
18
18
|
ruby-enum (~> 0.5)
|
|
19
|
-
concurrent-ruby (1.1.
|
|
20
|
-
dnsruby (1.61.
|
|
21
|
-
|
|
19
|
+
concurrent-ruby (1.1.7)
|
|
20
|
+
dnsruby (1.61.4)
|
|
21
|
+
simpleidn (~> 0.1)
|
|
22
22
|
em-websocket (0.5.1)
|
|
23
23
|
eventmachine (>= 0.12.9)
|
|
24
24
|
http_parser.rb (~> 0.6.0)
|
|
@@ -28,12 +28,12 @@ GEM
|
|
|
28
28
|
execjs (2.7.0)
|
|
29
29
|
faraday (1.0.1)
|
|
30
30
|
multipart-post (>= 1.2, < 3)
|
|
31
|
-
ffi (1.13.
|
|
31
|
+
ffi (1.13.1)
|
|
32
32
|
forwardable-extended (2.6.0)
|
|
33
33
|
gemoji (3.0.1)
|
|
34
|
-
github-pages (
|
|
34
|
+
github-pages (207)
|
|
35
35
|
github-pages-health-check (= 1.16.1)
|
|
36
|
-
jekyll (= 3.
|
|
36
|
+
jekyll (= 3.9.0)
|
|
37
37
|
jekyll-avatar (= 0.7.0)
|
|
38
38
|
jekyll-coffeescript (= 1.1.1)
|
|
39
39
|
jekyll-commonmark-ghpages (= 0.1.6)
|
|
@@ -67,7 +67,8 @@ GEM
|
|
|
67
67
|
jekyll-theme-time-machine (= 0.1.1)
|
|
68
68
|
jekyll-titles-from-headings (= 0.5.3)
|
|
69
69
|
jemoji (= 0.11.1)
|
|
70
|
-
kramdown (=
|
|
70
|
+
kramdown (= 2.3.0)
|
|
71
|
+
kramdown-parser-gfm (= 1.1.0)
|
|
71
72
|
liquid (= 4.0.3)
|
|
72
73
|
mercenary (~> 0.3)
|
|
73
74
|
minima (= 2.5.1)
|
|
@@ -86,14 +87,14 @@ GEM
|
|
|
86
87
|
http_parser.rb (0.6.0)
|
|
87
88
|
i18n (0.9.5)
|
|
88
89
|
concurrent-ruby (~> 1.0)
|
|
89
|
-
jekyll (3.
|
|
90
|
+
jekyll (3.9.0)
|
|
90
91
|
addressable (~> 2.4)
|
|
91
92
|
colorator (~> 1.0)
|
|
92
93
|
em-websocket (~> 0.5)
|
|
93
94
|
i18n (~> 0.7)
|
|
94
95
|
jekyll-sass-converter (~> 1.0)
|
|
95
96
|
jekyll-watch (~> 2.0)
|
|
96
|
-
kramdown (
|
|
97
|
+
kramdown (>= 1.17, < 3)
|
|
97
98
|
liquid (~> 4.0)
|
|
98
99
|
mercenary (~> 0.3.3)
|
|
99
100
|
pathutil (~> 0.9)
|
|
@@ -191,7 +192,10 @@ GEM
|
|
|
191
192
|
gemoji (~> 3.0)
|
|
192
193
|
html-pipeline (~> 2.2)
|
|
193
194
|
jekyll (>= 3.0, < 5.0)
|
|
194
|
-
kramdown (
|
|
195
|
+
kramdown (2.3.0)
|
|
196
|
+
rexml
|
|
197
|
+
kramdown-parser-gfm (1.1.0)
|
|
198
|
+
kramdown (~> 2.0)
|
|
195
199
|
liquid (4.0.3)
|
|
196
200
|
listen (3.2.1)
|
|
197
201
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
@@ -204,7 +208,7 @@ GEM
|
|
|
204
208
|
jekyll-seo-tag (~> 2.1)
|
|
205
209
|
minitest (5.14.1)
|
|
206
210
|
multipart-post (2.1.1)
|
|
207
|
-
nokogiri (1.10.
|
|
211
|
+
nokogiri (1.10.10)
|
|
208
212
|
mini_portile2 (~> 2.4.0)
|
|
209
213
|
octokit (4.18.0)
|
|
210
214
|
faraday (>= 0.9)
|
|
@@ -215,6 +219,7 @@ GEM
|
|
|
215
219
|
rb-fsevent (0.10.4)
|
|
216
220
|
rb-inotify (0.10.1)
|
|
217
221
|
ffi (~> 1.0)
|
|
222
|
+
rexml (3.2.4)
|
|
218
223
|
rouge (3.19.0)
|
|
219
224
|
ruby-enum (0.8.0)
|
|
220
225
|
i18n
|
|
@@ -228,6 +233,8 @@ GEM
|
|
|
228
233
|
sawyer (0.8.2)
|
|
229
234
|
addressable (>= 2.3.5)
|
|
230
235
|
faraday (> 0.8, < 2.0)
|
|
236
|
+
simpleidn (0.1.1)
|
|
237
|
+
unf (~> 0.1.4)
|
|
231
238
|
terminal-table (1.8.0)
|
|
232
239
|
unicode-display_width (~> 1.1, >= 1.1.1)
|
|
233
240
|
thread_safe (0.3.6)
|
|
@@ -235,8 +242,11 @@ GEM
|
|
|
235
242
|
ethon (>= 0.9.0)
|
|
236
243
|
tzinfo (1.2.7)
|
|
237
244
|
thread_safe (~> 0.1)
|
|
245
|
+
unf (0.1.4)
|
|
246
|
+
unf_ext
|
|
247
|
+
unf_ext (0.0.7.7)
|
|
238
248
|
unicode-display_width (1.7.0)
|
|
239
|
-
zeitwerk (2.
|
|
249
|
+
zeitwerk (2.4.0)
|
|
240
250
|
|
|
241
251
|
PLATFORMS
|
|
242
252
|
ruby
|
|
@@ -20,7 +20,7 @@ module Extension
|
|
|
20
20
|
extension_context: extension_context,
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, input).dig(*RESPONSE_FIELD)
|
|
23
|
+
response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
|
|
24
24
|
context.abort(context.message('tasks.errors.parse_error')) if response.nil?
|
|
25
25
|
|
|
26
26
|
abort_if_user_errors(context, response)
|
|
@@ -12,7 +12,7 @@ module Extension
|
|
|
12
12
|
def call(context:, api_key:)
|
|
13
13
|
input = { api_key: api_key }
|
|
14
14
|
|
|
15
|
-
response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, input).dig(*RESPONSE_FIELD)
|
|
15
|
+
response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
|
|
16
16
|
context.abort(context.message('tasks.errors.parse_error')) if response.nil?
|
|
17
17
|
|
|
18
18
|
Converters::AppConverter.from_hash(response.dig(APP_FIELD))
|
|
@@ -18,7 +18,7 @@ module Extension
|
|
|
18
18
|
config: JSON.generate(config),
|
|
19
19
|
extension_context: extension_context,
|
|
20
20
|
}
|
|
21
|
-
response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, input).dig(*RESPONSE_FIELD)
|
|
21
|
+
response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
|
|
22
22
|
context.abort(context.message('tasks.errors.parse_error')) if response.nil?
|
|
23
23
|
|
|
24
24
|
abort_if_user_errors(context, response)
|
|
@@ -34,12 +34,8 @@ module Script
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def self.help
|
|
37
|
-
ShopifyCli::Context.message('script.create.help', ShopifyCli::TOOL_NAME)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def self.extended_help
|
|
41
37
|
allowed_values = Script::Layers::Application::ExtensionPoints.types.map { |type| "{{cyan:#{type}}}" }
|
|
42
|
-
ShopifyCli::Context.message('script.create.
|
|
38
|
+
ShopifyCli::Context.message('script.create.help', ShopifyCli::TOOL_NAME, allowed_values.join(', '))
|
|
43
39
|
end
|
|
44
40
|
end
|
|
45
41
|
end
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
module Script
|
|
4
4
|
module Commands
|
|
5
5
|
class Disable < ShopifyCli::Command
|
|
6
|
-
prerequisite_task :ensure_env
|
|
7
|
-
|
|
8
6
|
def call(_args, _name)
|
|
7
|
+
ShopifyCli::Tasks::EnsureEnv.call(@ctx, required: [:api_key, :secret, :shop])
|
|
9
8
|
project = ScriptProject.current
|
|
10
9
|
Layers::Application::DisableScript.call(
|
|
11
10
|
ctx: @ctx,
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
module Script
|
|
4
4
|
module Commands
|
|
5
5
|
class Enable < ShopifyCli::Command
|
|
6
|
-
prerequisite_task :ensure_env
|
|
7
6
|
options do |parser, flags|
|
|
8
7
|
parser.on('--config_props=KEYVALUEPAIRS', Array) do |t|
|
|
9
8
|
flags[:config_props] = Hash[t.map { |s| s.split(':') }]
|
|
@@ -12,6 +11,7 @@ module Script
|
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
def call(_args, _name)
|
|
14
|
+
ShopifyCli::Tasks::EnsureEnv.call(@ctx, required: [:api_key, :secret, :shop])
|
|
15
15
|
project = ScriptProject.current
|
|
16
16
|
api_key = project.env[:api_key]
|
|
17
17
|
shop_domain = project.env[:shop]
|
|
@@ -32,6 +32,8 @@ module Script
|
|
|
32
32
|
title: project.script_name
|
|
33
33
|
))
|
|
34
34
|
@ctx.puts(@ctx.message('script.enable.info'))
|
|
35
|
+
rescue Errors::InvalidConfigYAMLError => e
|
|
36
|
+
UI::ErrorHandler.pretty_print_and_raise(e)
|
|
35
37
|
rescue StandardError => e
|
|
36
38
|
UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message('script.enable.error.operation_failed'))
|
|
37
39
|
end
|
|
@@ -40,10 +42,6 @@ module Script
|
|
|
40
42
|
ShopifyCli::Context.message('script.enable.help', ShopifyCli::TOOL_NAME)
|
|
41
43
|
end
|
|
42
44
|
|
|
43
|
-
def self.extended_help
|
|
44
|
-
ShopifyCli::Context.message('script.enable.extended_help', ShopifyCli::TOOL_NAME)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
45
|
private
|
|
48
46
|
|
|
49
47
|
def acquire_configuration(config_file: nil, config_props: nil)
|
|
@@ -59,6 +57,8 @@ module Script
|
|
|
59
57
|
})
|
|
60
58
|
end
|
|
61
59
|
configuration
|
|
60
|
+
rescue Errno::ENOENT, Psych::SyntaxError
|
|
61
|
+
raise Errors::InvalidConfigYAMLError, options.flags[:config_file]
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
# No slice pre Ruby 2.5 so roll our own
|
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
module Script
|
|
4
4
|
module Commands
|
|
5
5
|
class Push < ShopifyCli::Command
|
|
6
|
-
prerequisite_task :ensure_env
|
|
7
|
-
|
|
8
6
|
options do |parser, flags|
|
|
9
7
|
parser.on('--force') { |t| flags[:force] = t }
|
|
10
8
|
end
|
|
11
9
|
|
|
12
10
|
def call(_args, _name)
|
|
11
|
+
ShopifyCli::Tasks::EnsureEnv.call(@ctx, required: [:api_key, :secret, :shop])
|
|
13
12
|
project = ScriptProject.current
|
|
14
13
|
api_key = project.env[:api_key]
|
|
15
14
|
return @ctx.puts(self.class.help) unless api_key &&
|
|
@@ -31,10 +30,6 @@ module Script
|
|
|
31
30
|
def self.help
|
|
32
31
|
ShopifyCli::Context.message('script.push.help', ShopifyCli::TOOL_NAME)
|
|
33
32
|
end
|
|
34
|
-
|
|
35
|
-
def self.extended_help
|
|
36
|
-
ShopifyCli::Context.message('script.push.extended_help', ShopifyCli::TOOL_NAME)
|
|
37
|
-
end
|
|
38
33
|
end
|
|
39
34
|
end
|
|
40
35
|
end
|
|
@@ -7,13 +7,13 @@ discount:
|
|
|
7
7
|
unit_limit_per_order:
|
|
8
8
|
assemblyscript:
|
|
9
9
|
package: "@shopify/extension-point-as-unit-limit-per-order"
|
|
10
|
-
version: "^0.1.
|
|
10
|
+
version: "^0.1.8"
|
|
11
11
|
sdk-version: "^6.0.0"
|
|
12
12
|
toolchain-version: "^1.1.0"
|
|
13
13
|
payment_filter:
|
|
14
14
|
assemblyscript:
|
|
15
15
|
package: "@shopify/extension-point-as-payment-filter"
|
|
16
|
-
version: "^0.2.
|
|
16
|
+
version: "^0.2.3"
|
|
17
17
|
sdk-version: "^6.0.0"
|
|
18
18
|
toolchain-version: "^1.1.0"
|
|
19
19
|
shipping_filter:
|
|
@@ -9,9 +9,17 @@ module Script
|
|
|
9
9
|
class NoExistingStoresError < ScriptProjectError
|
|
10
10
|
attr_reader :organization_id
|
|
11
11
|
def initialize(organization_id)
|
|
12
|
+
super()
|
|
12
13
|
@organization_id = organization_id
|
|
13
14
|
end
|
|
14
15
|
end
|
|
15
16
|
class ScriptProjectAlreadyExistsError < ScriptProjectError; end
|
|
17
|
+
class InvalidConfigYAMLError < ScriptProjectError
|
|
18
|
+
attr_reader :config_file
|
|
19
|
+
def initialize(config_file)
|
|
20
|
+
super()
|
|
21
|
+
@config_file = config_file
|
|
22
|
+
end
|
|
23
|
+
end
|
|
16
24
|
end
|
|
17
25
|
end
|
|
@@ -8,12 +8,14 @@ module Script
|
|
|
8
8
|
class InvalidExtensionPointError < ScriptProjectError
|
|
9
9
|
attr_reader :type
|
|
10
10
|
def initialize(type)
|
|
11
|
+
super()
|
|
11
12
|
@type = type
|
|
12
13
|
end
|
|
13
14
|
end
|
|
14
15
|
class ScriptNotFoundError < ScriptProjectError
|
|
15
16
|
attr_reader :script_name, :extension_point_type
|
|
16
17
|
def initialize(extension_point_type, script_name)
|
|
18
|
+
super()
|
|
17
19
|
@script_name = script_name
|
|
18
20
|
@extension_point_type = extension_point_type
|
|
19
21
|
end
|
|
@@ -38,6 +38,9 @@ module Script
|
|
|
38
38
|
invalid_extension_cause: "Invalid extension point %s",
|
|
39
39
|
invalid_extension_help: "Allowed values: %s.",
|
|
40
40
|
|
|
41
|
+
invalid_config: "Can't change the configuration values because %1$s is missing or "\
|
|
42
|
+
"it is not formatted properly.",
|
|
43
|
+
|
|
41
44
|
script_not_found_cause: "Couldn't find script %s for extension point %s",
|
|
42
45
|
|
|
43
46
|
app_not_installed_cause: "App not installed on development store.",
|
|
@@ -74,11 +77,9 @@ module Script
|
|
|
74
77
|
help: <<~HELP,
|
|
75
78
|
{{command:%1$s create script}}: Creates a script project.
|
|
76
79
|
Usage: {{command:%1$s create script}}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
\s\s{{command:--name=NAME}} Script project name. Use any string.
|
|
81
|
-
\s\s{{command:--extension_point=TYPE}} Extension point name. Allowed values: %2$s.
|
|
80
|
+
Options:
|
|
81
|
+
{{command:--name=NAME}} Script project name. Use any string.
|
|
82
|
+
{{command:--extension_point=TYPE}} Extension point name. Allowed values: %2$s.
|
|
82
83
|
HELP
|
|
83
84
|
|
|
84
85
|
error: {
|
|
@@ -94,10 +95,8 @@ module Script
|
|
|
94
95
|
help: <<~HELP,
|
|
95
96
|
Build the script and put it into production. If you've already pushed a script with the same extension point, use --force to replace the current script with the newest one.
|
|
96
97
|
Usage: {{command:%s push}}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
\s\sOptions:
|
|
100
|
-
\s\s{{command:[--force]}} Forces the script to be overwritten if an instance of it already exists.
|
|
98
|
+
Options:
|
|
99
|
+
{{command:[--force]}} Forces the script to be overwritten if an instance of it already exists.
|
|
101
100
|
HELP
|
|
102
101
|
|
|
103
102
|
error: {
|
|
@@ -125,11 +124,9 @@ module Script
|
|
|
125
124
|
help: <<~HELP,
|
|
126
125
|
Turn on script in development store.
|
|
127
126
|
Usage: {{command:%s enable}}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
\s\s{{command:--config_props='name1:value1, name2:value2'}} Optional. Define the configuration of your script by passing individual name and value pairs. If used with --config_file, then matching values in --config_props will override those set in the file.
|
|
132
|
-
\s\s{{command:--config_file=<path/to/YAMLFilename>}} Optional. Define the configuration of your script using a YAML formatted file. --config_props values override properties in this file.
|
|
127
|
+
Options:
|
|
128
|
+
{{command:--config_props='name1:value1, name2:value2'}} Optional. Define the configuration of your script by passing individual name and value pairs. If used with --config_file, then matching values in --config_props will override those set in the file.
|
|
129
|
+
{{command:--config_file=<path/to/YAMLFilename>}} Optional. Define the configuration of your script using a YAML formatted file. --config_props values override properties in this file.
|
|
133
130
|
HELP
|
|
134
131
|
|
|
135
132
|
info: "{{*}} A script always remains enabled until you disable it - even after pushing "\
|
|
@@ -44,6 +44,10 @@ module Script
|
|
|
44
44
|
cause_of_error: ShopifyCli::Context.message('script.error.invalid_context_cause'),
|
|
45
45
|
help_suggestion: ShopifyCli::Context.message('script.error.invalid_context_help'),
|
|
46
46
|
}
|
|
47
|
+
when Errors::InvalidConfigYAMLError
|
|
48
|
+
{
|
|
49
|
+
cause_of_error: ShopifyCli::Context.message('script.error.invalid_config', e.config_file),
|
|
50
|
+
}
|
|
47
51
|
when Errors::InvalidScriptNameError
|
|
48
52
|
{
|
|
49
53
|
cause_of_error: ShopifyCli::Context.message('script.error.invalid_script_name_cause'),
|
data/lib/shopify-cli/command.rb
CHANGED
|
@@ -9,17 +9,19 @@ module ShopifyCli
|
|
|
9
9
|
attr_accessor :options
|
|
10
10
|
|
|
11
11
|
class << self
|
|
12
|
-
attr_writer :ctx
|
|
12
|
+
attr_writer :ctx, :task_registry
|
|
13
13
|
|
|
14
14
|
def call(args, command_name)
|
|
15
15
|
subcommand, resolved_name = subcommand_registry.lookup_command(args.first)
|
|
16
16
|
if subcommand
|
|
17
17
|
subcommand.ctx = @ctx
|
|
18
|
+
subcommand.task_registry = @task_registry
|
|
18
19
|
subcommand.call(args, resolved_name, command_name)
|
|
19
20
|
else
|
|
20
21
|
cmd = new(@ctx)
|
|
21
22
|
cmd.options.parse(@_options, args)
|
|
22
23
|
return call_help(command_name) if cmd.options.help
|
|
24
|
+
run_prerequisites
|
|
23
25
|
cmd.call(args, command_name)
|
|
24
26
|
end
|
|
25
27
|
end
|
|
@@ -41,13 +43,16 @@ module ShopifyCli
|
|
|
41
43
|
end
|
|
42
44
|
|
|
43
45
|
def prerequisite_task(*tasks)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
@prerequisite_tasks ||= []
|
|
47
|
+
@prerequisite_tasks += tasks
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def run_prerequisites
|
|
51
|
+
(@prerequisite_tasks || []).each { |task| task_registry[task]&.call(@ctx) }
|
|
47
52
|
end
|
|
48
53
|
|
|
49
|
-
def
|
|
50
|
-
@
|
|
54
|
+
def task_registry
|
|
55
|
+
@task_registry || ShopifyCli::Tasks::Registry
|
|
51
56
|
end
|
|
52
57
|
|
|
53
58
|
def call_help(*cmds)
|
|
@@ -57,6 +62,7 @@ module ShopifyCli
|
|
|
57
62
|
end
|
|
58
63
|
|
|
59
64
|
def initialize(ctx = nil)
|
|
65
|
+
super()
|
|
60
66
|
@ctx = ctx || ShopifyCli::Context.new
|
|
61
67
|
self.options = Options.new
|
|
62
68
|
end
|
|
@@ -12,21 +12,14 @@ module ShopifyCli
|
|
|
12
12
|
@ctx.puts prod_warning if [:rails, :node].include?(Project.current_project_type)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
org = fetch_org
|
|
22
|
-
id = org['id']
|
|
23
|
-
app = get_app(id, org['apps'])
|
|
24
|
-
shop = get_shop(org['stores'], id)
|
|
25
|
-
|
|
26
|
-
write_env(app, shop, env_data[:scopes], env_data[:extra])
|
|
27
|
-
write_cli_yml(project_type, id) unless Project.has_current?
|
|
15
|
+
org = ShopifyCli::Tasks::EnsureEnv.call(@ctx, regenerate: true)
|
|
16
|
+
api_key = Project.current.env['api_key']
|
|
17
|
+
write_cli_yml(project_type, org['id']) unless Project.has_current?
|
|
18
|
+
@ctx.puts(@ctx.message('core.connect.connected', get_app(org['apps'], api_key).first["title"]))
|
|
19
|
+
end
|
|
28
20
|
|
|
29
|
-
|
|
21
|
+
def get_app(apps, api_key)
|
|
22
|
+
apps.select { |app| app["apiKey"] == api_key }
|
|
30
23
|
end
|
|
31
24
|
|
|
32
25
|
def ask_project_type
|
|
@@ -37,67 +30,6 @@ module ShopifyCli
|
|
|
37
30
|
end
|
|
38
31
|
end
|
|
39
32
|
|
|
40
|
-
def fetch_org
|
|
41
|
-
orgs = PartnersAPI::Organizations.fetch_with_app(@ctx)
|
|
42
|
-
org_id = if orgs.count == 1
|
|
43
|
-
orgs.first["id"]
|
|
44
|
-
else
|
|
45
|
-
CLI::UI::Prompt.ask(@ctx.message('core.connect.organization_select')) do |handler|
|
|
46
|
-
orgs.each do |org|
|
|
47
|
-
handler.option(
|
|
48
|
-
@ctx.message('core.partners_api.org_name_and_id', org['businessName'], org['id'])
|
|
49
|
-
) { org["id"] }
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
org = orgs.find { |o| o["id"] == org_id }
|
|
54
|
-
org
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def get_app(org_id, apps)
|
|
58
|
-
if apps.count == 1
|
|
59
|
-
apps.first
|
|
60
|
-
elsif apps.count == 0
|
|
61
|
-
@ctx.puts(@ctx.message('core.connect.no_apps'))
|
|
62
|
-
title = CLI::UI::Prompt.ask(@ctx.message('core.connect.app_name'))
|
|
63
|
-
type = CLI::UI::Prompt.ask(@ctx.message('core.connect.app_type.select')) do |handler|
|
|
64
|
-
handler.option(@ctx.message('core.connect.app_type.select_public')) { 'public' }
|
|
65
|
-
handler.option(@ctx.message('core.connect.app_type.select_custom')) { 'custom' }
|
|
66
|
-
end
|
|
67
|
-
ShopifyCli::Tasks::CreateApiClient.call(@ctx, org_id: org_id, title: title, type: type)
|
|
68
|
-
else
|
|
69
|
-
CLI::UI::Prompt.ask(@ctx.message('core.connect.app_select')) do |handler|
|
|
70
|
-
apps.each { |app| handler.option(app["title"]) { app } }
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def get_shop(shops, id)
|
|
76
|
-
if shops.count == 1
|
|
77
|
-
shop = shops.first["shopDomain"]
|
|
78
|
-
elsif shops.count == 0
|
|
79
|
-
@ctx.puts(@ctx.message('core.connect.no_development_stores', id))
|
|
80
|
-
else
|
|
81
|
-
shop = CLI::UI::Prompt.ask(@ctx.message('core.connect.development_store_select')) do |handler|
|
|
82
|
-
shops.each { |s| handler.option(s["shopName"]) { s["shopDomain"] } }
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
shop
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def write_env(app, shop, scopes, extra)
|
|
89
|
-
scopes = 'write_products,write_customers,write_draft_orders' if scopes.nil?
|
|
90
|
-
extra = {} if extra.nil?
|
|
91
|
-
|
|
92
|
-
Resources::EnvFile.new(
|
|
93
|
-
api_key: app["apiKey"],
|
|
94
|
-
secret: app["apiSecretKeys"].first["secret"],
|
|
95
|
-
shop: shop,
|
|
96
|
-
scopes: scopes,
|
|
97
|
-
extra: extra,
|
|
98
|
-
).write(@ctx)
|
|
99
|
-
end
|
|
100
|
-
|
|
101
33
|
def write_cli_yml(project_type, org_id)
|
|
102
34
|
ShopifyCli::Project.write(
|
|
103
35
|
@ctx,
|
|
@@ -32,7 +32,7 @@ module ShopifyCli
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def self.help
|
|
35
|
-
project_types = all_visible_type.map(&:project_type).join(" | ")
|
|
35
|
+
project_types = all_visible_type.map(&:project_type).sort.join(" | ")
|
|
36
36
|
ShopifyCli::Context.message('core.create.help', ShopifyCli::TOOL_NAME, project_types)
|
|
37
37
|
end
|
|
38
38
|
|
|
@@ -36,11 +36,13 @@ module ShopifyCli
|
|
|
36
36
|
cli_constants_extra = %w(
|
|
37
37
|
PROJECT_TYPES_DIR
|
|
38
38
|
TEMP_DIR
|
|
39
|
-
CACHE_DIR
|
|
40
|
-
TOOL_CONFIG_PATH
|
|
41
|
-
LOG_FILE
|
|
42
|
-
DEBUG_LOG_FILE
|
|
43
39
|
)
|
|
40
|
+
cli_path_methods = [
|
|
41
|
+
:cache_dir,
|
|
42
|
+
:tool_config_path,
|
|
43
|
+
:log_file,
|
|
44
|
+
:debug_log_file,
|
|
45
|
+
]
|
|
44
46
|
|
|
45
47
|
cli_constants += cli_constants_extra if show_all_details
|
|
46
48
|
|
|
@@ -48,6 +50,12 @@ module ShopifyCli
|
|
|
48
50
|
cli_constants.each do |s|
|
|
49
51
|
@ctx.puts(" " + @ctx.message('core.system.const', s, ShopifyCli.const_get(s.to_sym)) + "\n")
|
|
50
52
|
end
|
|
53
|
+
|
|
54
|
+
if show_all_details
|
|
55
|
+
cli_path_methods.each do |m|
|
|
56
|
+
@ctx.puts(" " + @ctx.message('core.system.const', m.upcase, ShopifyCli.send(m)) + "\n")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
51
59
|
end
|
|
52
60
|
|
|
53
61
|
def display_cli_ruby(_show_all_details)
|
|
@@ -74,7 +82,7 @@ module ShopifyCli
|
|
|
74
82
|
end
|
|
75
83
|
|
|
76
84
|
def display_ngrok
|
|
77
|
-
ngrok_location = File.join(ShopifyCli
|
|
85
|
+
ngrok_location = File.join(ShopifyCli.cache_dir, 'ngrok')
|
|
78
86
|
if File.exist?(ngrok_location)
|
|
79
87
|
@ctx.puts(" " + @ctx.message('core.system.ngrok_available', ngrok_location))
|
|
80
88
|
else
|
|
@@ -35,7 +35,7 @@ module ShopifyCli
|
|
|
35
35
|
task_registry = ShopifyCli::Tasks::Registry
|
|
36
36
|
|
|
37
37
|
command, command_name, args = ShopifyCli::Resolver.call(args)
|
|
38
|
-
executor = ShopifyCli::Core::Executor.new(ctx, task_registry, log_file: ShopifyCli
|
|
38
|
+
executor = ShopifyCli::Core::Executor.new(ctx, task_registry, log_file: ShopifyCli.log_file)
|
|
39
39
|
ShopifyCli::Core::Monorail.log(command_name, args) do
|
|
40
40
|
executor.call(command, command_name, args)
|
|
41
41
|
end
|
|
@@ -3,16 +3,14 @@ require 'shopify_cli'
|
|
|
3
3
|
module ShopifyCli
|
|
4
4
|
module Core
|
|
5
5
|
class Executor < CLI::Kit::Executor
|
|
6
|
-
def initialize(ctx, task_registry, *args)
|
|
6
|
+
def initialize(ctx, task_registry, *args, **kwargs)
|
|
7
7
|
@ctx = ctx || ShopifyCli::Context.new
|
|
8
8
|
@task_registry = task_registry || ShopifyCli::Tasks::TaskRegistry.new
|
|
9
|
-
super(*args)
|
|
9
|
+
super(*args, **kwargs)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def call(command, command_name, args)
|
|
13
|
-
command.
|
|
14
|
-
@task_registry[task]&.call(@ctx)
|
|
15
|
-
end
|
|
13
|
+
command.task_registry = @task_registry
|
|
16
14
|
command.ctx = @ctx
|
|
17
15
|
super
|
|
18
16
|
end
|
|
@@ -99,7 +99,7 @@ module ShopifyCli
|
|
|
99
99
|
success: err.nil?,
|
|
100
100
|
error_message: err,
|
|
101
101
|
uname: RbConfig::CONFIG["host"],
|
|
102
|
-
cli_version: ShopifyCli::
|
|
102
|
+
cli_version: ShopifyCli::VERSION,
|
|
103
103
|
ruby_version: RUBY_VERSION,
|
|
104
104
|
}.tap do |payload|
|
|
105
105
|
payload[:metadata] = JSON.dump(metadata) unless metadata.empty?
|
data/lib/shopify-cli/db.rb
CHANGED
data/lib/shopify-cli/heroku.rb
CHANGED
|
@@ -36,7 +36,7 @@ module ShopifyCli
|
|
|
36
36
|
def download
|
|
37
37
|
return if installed?
|
|
38
38
|
|
|
39
|
-
result = @ctx.system('curl', '-o', download_path, DOWNLOAD_URLS[@ctx.os], chdir: ShopifyCli
|
|
39
|
+
result = @ctx.system('curl', '-o', download_path, DOWNLOAD_URLS[@ctx.os], chdir: ShopifyCli.cache_dir)
|
|
40
40
|
@ctx.abort(@ctx.message('core.heroku.error.download')) unless result.success?
|
|
41
41
|
@ctx.abort(@ctx.message('core.heroku.error.download')) unless File.exist?(download_path)
|
|
42
42
|
end
|
|
@@ -44,7 +44,7 @@ module ShopifyCli
|
|
|
44
44
|
def install
|
|
45
45
|
return if installed?
|
|
46
46
|
|
|
47
|
-
result = @ctx.system('tar', '-xf', download_path, chdir: ShopifyCli
|
|
47
|
+
result = @ctx.system('tar', '-xf', download_path, chdir: ShopifyCli.cache_dir)
|
|
48
48
|
@ctx.abort(@ctx.message('core.heroku.error.install')) unless result.success?
|
|
49
49
|
|
|
50
50
|
@ctx.rm(download_path)
|
|
@@ -70,7 +70,7 @@ module ShopifyCli
|
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
def download_path
|
|
73
|
-
File.join(ShopifyCli
|
|
73
|
+
File.join(ShopifyCli.cache_dir, download_filename)
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
def git_remote
|
|
@@ -79,7 +79,7 @@ module ShopifyCli
|
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
def heroku_command
|
|
82
|
-
local_path = File.join(ShopifyCli
|
|
82
|
+
local_path = File.join(ShopifyCli.cache_dir, 'heroku', 'bin', 'heroku').to_s
|
|
83
83
|
if File.exist?(local_path)
|
|
84
84
|
local_path
|
|
85
85
|
else
|
|
@@ -16,23 +16,7 @@ module ShopifyCli
|
|
|
16
16
|
already_connected_warning: "{{yellow:! This app appears to be already connected}}",
|
|
17
17
|
connected: "{{v}} Project now connected to {{green:%s}}",
|
|
18
18
|
project_type_select: "What type of project would you like to connect?",
|
|
19
|
-
organization_select: "To which partner organization does this project belong?",
|
|
20
|
-
app_select: "To which app does this project belong?",
|
|
21
|
-
no_development_stores: <<~MESSAGE,
|
|
22
|
-
No development stores available.
|
|
23
|
-
Visit {{underline:https://partners.shopify.com/%d/stores}} to create one
|
|
24
|
-
MESSAGE
|
|
25
|
-
development_store_select: "Which development store would you like to use?",
|
|
26
19
|
cli_yml_saved: ".shopify-cli.yml saved to project root",
|
|
27
|
-
|
|
28
|
-
no_apps: 'You have no apps to connect to, creating a new app.',
|
|
29
|
-
app_name: "App name",
|
|
30
|
-
app_type: {
|
|
31
|
-
select: "What type of app are you building?",
|
|
32
|
-
select_public: "Public: An app built for a wide merchant audience.",
|
|
33
|
-
select_custom: "Custom: An app custom built for a single client.",
|
|
34
|
-
selected: "App type {{green:%s}}",
|
|
35
|
-
},
|
|
36
20
|
},
|
|
37
21
|
|
|
38
22
|
context: {
|
|
@@ -254,9 +238,21 @@ module ShopifyCli
|
|
|
254
238
|
|
|
255
239
|
tasks: {
|
|
256
240
|
ensure_env: {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
241
|
+
organization_select: "To which partner organization does this project belong?",
|
|
242
|
+
no_development_stores: <<~MESSAGE,
|
|
243
|
+
No development stores available.
|
|
244
|
+
Visit {{underline:https://partners.shopify.com/%d/stores}} to create one
|
|
245
|
+
MESSAGE
|
|
246
|
+
development_store_select: "Which development store would you like to use?",
|
|
247
|
+
app_select: "To which app does this project belong?",
|
|
248
|
+
no_apps: 'You have no apps to connect to, creating a new app.',
|
|
249
|
+
app_name: "App name",
|
|
250
|
+
app_type: {
|
|
251
|
+
select: "What type of app are you building?",
|
|
252
|
+
select_public: "Public: An app built for a wide merchant audience.",
|
|
253
|
+
select_custom: "Custom: An app custom built for a single client.",
|
|
254
|
+
selected: "App type {{green:%s}}",
|
|
255
|
+
},
|
|
260
256
|
},
|
|
261
257
|
ensure_dev_store: {
|
|
262
258
|
could_not_verify_store: "Couldn't verify your store %s",
|
|
@@ -5,9 +5,6 @@ module ShopifyCli
|
|
|
5
5
|
# ProcessSupervision wraps a running process spawned by `exec` and keeps track
|
|
6
6
|
# if its `pid` and keeps a log file for it as well
|
|
7
7
|
class ProcessSupervision
|
|
8
|
-
# is the directory where the pid and logfile are kept
|
|
9
|
-
RUN_DIR = File.join(ShopifyCli::CACHE_DIR, 'sv')
|
|
10
|
-
|
|
11
8
|
# a string or a symbol to identify this process by
|
|
12
9
|
attr_reader :identifier
|
|
13
10
|
# process ID for the running process
|
|
@@ -20,6 +17,11 @@ module ShopifyCli
|
|
|
20
17
|
attr_reader :log_path
|
|
21
18
|
|
|
22
19
|
class << self
|
|
20
|
+
def run_dir
|
|
21
|
+
# is the directory where the pid and logfile are kept
|
|
22
|
+
File.join(ShopifyCli.cache_dir, 'sv')
|
|
23
|
+
end
|
|
24
|
+
|
|
23
25
|
##
|
|
24
26
|
# Will find and create a new instance of ProcessSupervision for a running process
|
|
25
27
|
# if it is currently running. It will return nil if the process is not running.
|
|
@@ -34,7 +36,7 @@ module ShopifyCli
|
|
|
34
36
|
# will be nil if the process is not running.
|
|
35
37
|
#
|
|
36
38
|
def for_ident(identifier)
|
|
37
|
-
pid, time = File.read(File.join(
|
|
39
|
+
pid, time = File.read(File.join(ShopifyCli::ProcessSupervision.run_dir, "#{identifier}.pid")).split(':')
|
|
38
40
|
new(identifier, pid: Integer(pid), time: time)
|
|
39
41
|
rescue Errno::ENOENT
|
|
40
42
|
nil
|
|
@@ -108,8 +110,8 @@ module ShopifyCli
|
|
|
108
110
|
@identifier = identifier
|
|
109
111
|
@pid = pid
|
|
110
112
|
@time = time
|
|
111
|
-
@pid_path = File.join(
|
|
112
|
-
@log_path = File.join(
|
|
113
|
+
@pid_path = File.join(ShopifyCli::ProcessSupervision.run_dir, "#{identifier}.pid")
|
|
114
|
+
@log_path = File.join(ShopifyCli::ProcessSupervision.run_dir, "#{identifier}.log")
|
|
113
115
|
end
|
|
114
116
|
|
|
115
117
|
##
|
|
@@ -14,6 +14,7 @@ module ShopifyCli
|
|
|
14
14
|
alias_method :all_loaded, :repository
|
|
15
15
|
|
|
16
16
|
def inherited(klass)
|
|
17
|
+
super
|
|
17
18
|
repository << klass
|
|
18
19
|
klass.project_type = @current_type
|
|
19
20
|
klass.project_load_shallow = @shallow_load
|
|
@@ -32,7 +33,7 @@ module ShopifyCli
|
|
|
32
33
|
|
|
33
34
|
def load_all
|
|
34
35
|
Dir.glob(File.join(ShopifyCli::ROOT, 'lib', 'project_types', '*', 'cli.rb')).map do |filepath|
|
|
35
|
-
load_type(filepath.split(File::Separator)[-2], true)
|
|
36
|
+
load_type(filepath.split(File::Separator)[-2].to_sym, true)
|
|
36
37
|
end
|
|
37
38
|
end
|
|
38
39
|
|
|
@@ -64,7 +65,7 @@ module ShopifyCli
|
|
|
64
65
|
|
|
65
66
|
def register_task(task, name)
|
|
66
67
|
return if project_load_shallow
|
|
67
|
-
Task
|
|
68
|
+
ShopifyCli::Task.register(task, name)
|
|
68
69
|
end
|
|
69
70
|
|
|
70
71
|
def register_messages(messages)
|
data/lib/shopify-cli/task.rb
CHANGED
data/lib/shopify-cli/tasks.rb
CHANGED
|
@@ -12,15 +12,22 @@ module ShopifyCli
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def [](name)
|
|
15
|
-
@tasks[name]
|
|
15
|
+
class_or_proc = @tasks[name]
|
|
16
|
+
if class_or_proc.is_a?(Class)
|
|
17
|
+
class_or_proc
|
|
18
|
+
elsif class_or_proc.respond_to?(:call)
|
|
19
|
+
class_or_proc.call
|
|
20
|
+
else
|
|
21
|
+
class_or_proc
|
|
22
|
+
end
|
|
16
23
|
end
|
|
17
24
|
end
|
|
18
25
|
|
|
19
26
|
Registry = TaskRegistry.new
|
|
20
27
|
|
|
21
|
-
def self.register(task, name, path)
|
|
22
|
-
autoload(task, path)
|
|
23
|
-
Registry.add(const_get(task), name)
|
|
28
|
+
def self.register(task, name, path = nil)
|
|
29
|
+
autoload(task, path) if path
|
|
30
|
+
Registry.add(-> () { const_get(task) }, name)
|
|
24
31
|
end
|
|
25
32
|
|
|
26
33
|
register :CreateApiClient, :create_api_client, 'shopify-cli/tasks/create_api_client'
|
|
@@ -3,27 +3,84 @@ require 'shopify_cli'
|
|
|
3
3
|
module ShopifyCli
|
|
4
4
|
module Tasks
|
|
5
5
|
class EnsureEnv < ShopifyCli::Task
|
|
6
|
-
def call(ctx)
|
|
6
|
+
def call(ctx, regenerate: false, required: [:api_key, :secret])
|
|
7
7
|
@ctx = ctx
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
env_data =
|
|
9
|
+
begin
|
|
10
|
+
Resources::EnvFile.parse_external_env
|
|
11
|
+
rescue Errno::ENOENT
|
|
12
|
+
{}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
return {} if !regenerate && required.all? { |property| env_data[property] }
|
|
16
|
+
|
|
17
|
+
org = fetch_org
|
|
18
|
+
write_env(env_data, org)
|
|
19
|
+
org
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def fetch_org
|
|
25
|
+
orgs = PartnersAPI::Organizations.fetch_with_app(@ctx)
|
|
26
|
+
org_id = if orgs.count == 1
|
|
27
|
+
orgs.first["id"]
|
|
28
|
+
else
|
|
29
|
+
CLI::UI::Prompt.ask(@ctx.message('core.tasks.ensure_env.organization_select')) do |handler|
|
|
30
|
+
orgs.each do |org|
|
|
31
|
+
handler.option(
|
|
32
|
+
@ctx.message('core.partners_api.org_name_and_id', org['businessName'], org['id'])
|
|
33
|
+
) { org["id"] }
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
orgs.find { |o| o["id"] == org_id }
|
|
11
38
|
end
|
|
12
39
|
|
|
13
|
-
def
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
40
|
+
def get_app(org_id, apps)
|
|
41
|
+
if apps.count == 1
|
|
42
|
+
apps.first
|
|
43
|
+
elsif apps.count == 0
|
|
44
|
+
@ctx.puts(@ctx.message('core.tasks.ensure_env.no_apps'))
|
|
45
|
+
title = CLI::UI::Prompt.ask(@ctx.message('core.tasks.ensure_env.app_name'))
|
|
46
|
+
type = CLI::UI::Prompt.ask(@ctx.message('core.tasks.ensure_env.app_type.select')) do |handler|
|
|
47
|
+
handler.option(@ctx.message('core.tasks.ensure_env.app_type.select_public')) { 'public' }
|
|
48
|
+
handler.option(@ctx.message('core.tasks.ensure_env.app_type.select_custom')) { 'custom' }
|
|
49
|
+
end
|
|
50
|
+
ShopifyCli::Tasks::CreateApiClient.call(@ctx, org_id: org_id, title: title, type: type)
|
|
51
|
+
else
|
|
52
|
+
CLI::UI::Prompt.ask(@ctx.message('core.tasks.ensure_env.app_select')) do |handler|
|
|
53
|
+
apps.each { |app| handler.option(app["title"]) { app } }
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def get_shop(shops, id)
|
|
59
|
+
if shops.count == 1
|
|
60
|
+
shop = shops.first["shopDomain"]
|
|
61
|
+
elsif shops.count == 0
|
|
62
|
+
@ctx.puts(@ctx.message('core.tasks.ensure_env.no_development_stores', id))
|
|
63
|
+
else
|
|
64
|
+
shop = CLI::UI::Prompt.ask(@ctx.message('core.tasks.ensure_env.development_store_select')) do |handler|
|
|
65
|
+
shops.each { |s| handler.option(s["shopName"]) { s["shopDomain"] } }
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
shop
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def write_env(env_data, org)
|
|
72
|
+
id = org['id']
|
|
73
|
+
app = get_app(id, org['apps'])
|
|
74
|
+
|
|
75
|
+
env_data[:shop] = get_shop(org['stores'], id)
|
|
76
|
+
env_data[:api_key] = app["apiKey"]
|
|
77
|
+
env_data[:secret] = app["apiSecretKeys"].first["secret"]
|
|
78
|
+
env_data[:scopes] = 'write_products,write_customers,write_draft_orders' if env_data[:scopes].nil?
|
|
79
|
+
env_data[:extra] = {} if env_data[:extra].nil?
|
|
80
|
+
|
|
81
|
+
Resources::EnvFile.new(
|
|
82
|
+
env_data
|
|
25
83
|
).write(@ctx)
|
|
26
|
-
env
|
|
27
84
|
end
|
|
28
85
|
end
|
|
29
86
|
end
|
data/lib/shopify-cli/tunnel.rb
CHANGED
|
@@ -88,7 +88,7 @@ module ShopifyCli
|
|
|
88
88
|
#
|
|
89
89
|
def auth(ctx, token)
|
|
90
90
|
install(ctx)
|
|
91
|
-
ctx.system(File.join(ShopifyCli
|
|
91
|
+
ctx.system(File.join(ShopifyCli.cache_dir, 'ngrok'), 'authtoken', token)
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
##
|
|
@@ -122,14 +122,14 @@ module ShopifyCli
|
|
|
122
122
|
private
|
|
123
123
|
|
|
124
124
|
def install(ctx)
|
|
125
|
-
return if File.exist?(File.join(ShopifyCli
|
|
125
|
+
return if File.exist?(File.join(ShopifyCli.cache_dir, 'ngrok'))
|
|
126
126
|
spinner = CLI::UI::SpinGroup.new
|
|
127
127
|
spinner.add('Installing ngrok...') do
|
|
128
|
-
zip_dest = File.join(ShopifyCli
|
|
128
|
+
zip_dest = File.join(ShopifyCli.cache_dir, 'ngrok.zip')
|
|
129
129
|
unless File.exist?(zip_dest)
|
|
130
|
-
ctx.system('curl', '-o', zip_dest, DOWNLOAD_URLS[ctx.os], chdir: ShopifyCli
|
|
130
|
+
ctx.system('curl', '-o', zip_dest, DOWNLOAD_URLS[ctx.os], chdir: ShopifyCli.cache_dir)
|
|
131
131
|
end
|
|
132
|
-
ctx.system('unzip', '-u', zip_dest, chdir: ShopifyCli
|
|
132
|
+
ctx.system('unzip', '-u', zip_dest, chdir: ShopifyCli.cache_dir)
|
|
133
133
|
ctx.rm(zip_dest)
|
|
134
134
|
end
|
|
135
135
|
spinner.wait
|
|
@@ -143,7 +143,7 @@ module ShopifyCli
|
|
|
143
143
|
end
|
|
144
144
|
|
|
145
145
|
def ngrok_command(port)
|
|
146
|
-
"exec #{File.join(ShopifyCli
|
|
146
|
+
"exec #{File.join(ShopifyCli.cache_dir, 'ngrok')} http -inspect=false -log=stdout -log-level=debug #{port}"
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
def seconds_to_hm(seconds)
|
data/lib/shopify-cli/version.rb
CHANGED
data/lib/shopify_cli.rb
CHANGED
|
@@ -44,10 +44,6 @@ module ShopifyCli
|
|
|
44
44
|
ROOT = File.expand_path('../..', __FILE__)
|
|
45
45
|
PROJECT_TYPES_DIR = File.join(ROOT, 'lib', 'project_types')
|
|
46
46
|
TEMP_DIR = File.join(ROOT, '.tmp')
|
|
47
|
-
CACHE_DIR = File.join(File.expand_path(ENV.fetch('XDG_CACHE_HOME', '~/.cache')), TOOL_NAME)
|
|
48
|
-
TOOL_CONFIG_PATH = File.join(File.expand_path(ENV.fetch('XDG_CONFIG_HOME', '~/.config')), TOOL_NAME)
|
|
49
|
-
LOG_FILE = File.join(TOOL_CONFIG_PATH, 'logs', 'log.log')
|
|
50
|
-
DEBUG_LOG_FILE = File.join(TOOL_CONFIG_PATH, 'logs', 'debug.log')
|
|
51
47
|
|
|
52
48
|
# programmer emoji if default install location, else wrench emoji
|
|
53
49
|
EMOJI = ROOT == '/opt/shopify' ? "\u{1f469}\u{200d}\u{1f4bb}" : "\u{1f527}"
|
|
@@ -82,7 +78,7 @@ module ShopifyCli
|
|
|
82
78
|
# ShopifyCli::Config
|
|
83
79
|
autocall(:Config) { CLI::Kit::Config.new(tool_name: TOOL_NAME) }
|
|
84
80
|
# ShopifyCli::Logger
|
|
85
|
-
autocall(:Logger) { CLI::Kit::Logger.new(debug_log_file:
|
|
81
|
+
autocall(:Logger) { CLI::Kit::Logger.new(debug_log_file: ShopifyCli.debug_log_file) }
|
|
86
82
|
# ShopifyCli::Resolver
|
|
87
83
|
autocall(:Resolver) do
|
|
88
84
|
ShopifyCli::Core::HelpResolver.new(
|
|
@@ -93,7 +89,7 @@ module ShopifyCli
|
|
|
93
89
|
# ShopifyCli::ErrorHandler
|
|
94
90
|
autocall(:ErrorHandler) do
|
|
95
91
|
CLI::Kit::ErrorHandler.new(
|
|
96
|
-
log_file: ShopifyCli
|
|
92
|
+
log_file: ShopifyCli.log_file,
|
|
97
93
|
exception_reporter: nil,
|
|
98
94
|
)
|
|
99
95
|
end
|
|
@@ -127,7 +123,33 @@ module ShopifyCli
|
|
|
127
123
|
|
|
128
124
|
require 'shopify-cli/messages/messages'
|
|
129
125
|
Context.load_messages(ShopifyCli::Messages::MESSAGES)
|
|
130
|
-
end
|
|
131
126
|
|
|
132
|
-
|
|
133
|
-
|
|
127
|
+
def self.cache_dir
|
|
128
|
+
cache_dir = if ENV.key?('RUNNING_SHOPIFY_CLI_TESTS')
|
|
129
|
+
TEMP_DIR
|
|
130
|
+
else
|
|
131
|
+
File.join(File.expand_path(ENV.fetch('XDG_CACHE_HOME', '~/.cache')), TOOL_NAME)
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Make sure the cache dir always exists
|
|
135
|
+
@cache_dir_exists ||= FileUtils.mkdir_p(cache_dir)
|
|
136
|
+
|
|
137
|
+
cache_dir
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def self.tool_config_path
|
|
141
|
+
if ENV.key?('RUNNING_SHOPIFY_CLI_TESTS')
|
|
142
|
+
TEMP_DIR
|
|
143
|
+
else
|
|
144
|
+
File.join(File.expand_path(ENV.fetch('XDG_CONFIG_HOME', '~/.config')), TOOL_NAME)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def self.log_file
|
|
149
|
+
File.join(tool_config_path, 'logs', 'log.log')
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def self.debug_log_file
|
|
153
|
+
File.join(tool_config_path, 'logs', 'debug.log')
|
|
154
|
+
end
|
|
155
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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: 2020-08-
|
|
11
|
+
date: 2020-08-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|