shopify-cli 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +12 -12
- data/Rakefile +32 -30
- data/bin/load_shopify.rb +6 -6
- data/bin/shopify +2 -2
- data/ext/shopify-cli/extconf.rb +7 -7
- data/lib/docgen/markdown.rb +11 -11
- data/lib/{project_types/extension/graphql → graphql}/get_app_by_api_key.graphql +0 -0
- data/lib/project_types/extension/cli.rb +52 -45
- data/lib/project_types/extension/commands/build.rb +3 -3
- data/lib/project_types/extension/commands/create.rb +16 -9
- data/lib/project_types/extension/commands/extension_command.rb +8 -5
- data/lib/project_types/extension/commands/push.rb +8 -8
- data/lib/project_types/extension/commands/register.rb +19 -30
- data/lib/project_types/extension/commands/serve.rb +2 -2
- data/lib/project_types/extension/commands/tunnel.rb +12 -12
- data/lib/project_types/extension/extension_project.rb +4 -4
- data/lib/project_types/extension/extension_project_keys.rb +4 -4
- data/lib/project_types/extension/features/argo.rb +13 -13
- data/lib/project_types/extension/features/argo_config.rb +5 -5
- data/lib/project_types/extension/features/argo_dependencies.rb +5 -5
- data/lib/project_types/extension/features/argo_setup.rb +2 -2
- data/lib/project_types/extension/features/argo_setup_steps.rb +4 -4
- data/lib/project_types/extension/forms/create.rb +28 -34
- data/lib/project_types/extension/forms/questions/ask_app.rb +53 -0
- data/lib/project_types/extension/forms/questions/ask_name.rb +40 -0
- data/lib/project_types/extension/forms/questions/ask_type.rb +36 -0
- data/lib/project_types/extension/messages/messages.rb +53 -52
- data/lib/project_types/extension/models/lazy_specification_handler.rb +12 -0
- data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +1 -1
- data/lib/project_types/extension/models/specification_handlers/default.rb +2 -2
- data/lib/project_types/extension/models/specifications.rb +3 -3
- data/lib/project_types/extension/tasks/configure_features.rb +4 -4
- data/lib/project_types/extension/tasks/converters/app_converter.rb +6 -6
- data/lib/project_types/extension/tasks/converters/registration_converter.rb +6 -6
- data/lib/project_types/extension/tasks/converters/validation_error_converter.rb +4 -4
- data/lib/project_types/extension/tasks/converters/version_converter.rb +7 -7
- data/lib/project_types/extension/tasks/create_extension.rb +4 -4
- data/lib/project_types/extension/tasks/fetch_specifications.rb +4 -4
- data/lib/project_types/extension/tasks/get_app.rb +4 -4
- data/lib/project_types/extension/tasks/get_apps.rb +3 -3
- data/lib/project_types/extension/tasks/update_draft.rb +4 -4
- data/lib/project_types/extension/tasks/user_errors.rb +4 -4
- data/lib/project_types/node/cli.rb +19 -19
- data/lib/project_types/node/commands/connect.rb +3 -3
- data/lib/project_types/node/commands/create.rb +40 -38
- data/lib/project_types/node/commands/deploy.rb +4 -4
- data/lib/project_types/node/commands/deploy/heroku.rb +24 -24
- data/lib/project_types/node/commands/generate.rb +8 -8
- data/lib/project_types/node/commands/open.rb +2 -2
- data/lib/project_types/node/commands/populate.rb +6 -6
- data/lib/project_types/node/commands/populate/customer.rb +5 -5
- data/lib/project_types/node/commands/populate/draft_order.rb +5 -5
- data/lib/project_types/node/commands/populate/product.rb +5 -5
- data/lib/project_types/node/commands/serve.rb +9 -9
- data/lib/project_types/node/commands/tunnel.rb +7 -7
- data/lib/project_types/node/forms/create.rb +7 -7
- data/lib/project_types/node/messages/messages.rb +3 -3
- data/lib/project_types/rails/cli.rb +21 -21
- data/lib/project_types/rails/commands/connect.rb +3 -3
- data/lib/project_types/rails/commands/create.rb +51 -48
- data/lib/project_types/rails/commands/deploy.rb +4 -4
- data/lib/project_types/rails/commands/deploy/heroku.rb +30 -30
- data/lib/project_types/rails/commands/generate.rb +7 -7
- data/lib/project_types/rails/commands/generate/webhook.rb +6 -6
- data/lib/project_types/rails/commands/open.rb +2 -2
- data/lib/project_types/rails/commands/populate.rb +6 -6
- data/lib/project_types/rails/commands/populate/customer.rb +5 -5
- data/lib/project_types/rails/commands/populate/draft_order.rb +5 -5
- data/lib/project_types/rails/commands/populate/product.rb +5 -5
- data/lib/project_types/rails/commands/serve.rb +11 -11
- data/lib/project_types/rails/commands/tunnel.rb +7 -7
- data/lib/project_types/rails/forms/create.rb +23 -23
- data/lib/project_types/rails/gem.rb +23 -23
- data/lib/project_types/rails/messages/messages.rb +4 -4
- data/lib/project_types/rails/ruby.rb +2 -2
- data/lib/project_types/script/cli.rb +40 -40
- data/lib/project_types/script/commands/create.rb +9 -8
- data/lib/project_types/script/commands/disable.rb +3 -3
- data/lib/project_types/script/commands/enable.rb +9 -7
- data/lib/project_types/script/commands/push.rb +5 -4
- data/lib/project_types/script/errors.rb +17 -0
- data/lib/project_types/script/forms/create.rb +5 -5
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +2 -0
- data/lib/project_types/script/layers/application/build_script.rb +6 -8
- data/lib/project_types/script/layers/application/create_script.rb +2 -2
- data/lib/project_types/script/layers/application/disable_script.rb +2 -2
- data/lib/project_types/script/layers/application/enable_script.rb +2 -2
- data/lib/project_types/script/layers/application/project_dependencies.rb +4 -4
- data/lib/project_types/script/layers/application/push_script.rb +4 -12
- data/lib/project_types/script/layers/domain/push_package.rb +5 -1
- data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +3 -3
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +10 -10
- data/lib/project_types/script/layers/infrastructure/errors.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +2 -2
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +12 -17
- data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +4 -4
- data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +1 -1
- data/lib/project_types/script/layers/infrastructure/script_service.rb +18 -16
- data/lib/project_types/script/messages/messages.rb +14 -8
- data/lib/project_types/script/script_project.rb +27 -5
- data/lib/project_types/script/ui/error_handler.rb +80 -68
- data/lib/project_types/script/ui/printing_spinner.rb +1 -1
- data/lib/project_types/script/ui/strict_spinner.rb +1 -1
- data/lib/project_types/theme/cli.rb +19 -19
- data/lib/project_types/theme/commands/connect.rb +12 -12
- data/lib/project_types/theme/commands/create.rb +11 -11
- data/lib/project_types/theme/commands/deploy.rb +8 -8
- data/lib/project_types/theme/commands/generate.rb +3 -3
- data/lib/project_types/theme/commands/generate/env.rb +15 -15
- data/lib/project_types/theme/commands/push.rb +15 -15
- data/lib/project_types/theme/commands/serve.rb +5 -5
- data/lib/project_types/theme/forms/connect.rb +4 -4
- data/lib/project_types/theme/forms/create.rb +5 -5
- data/lib/project_types/theme/tasks/ensure_themekit_installed.rb +22 -22
- data/lib/project_types/theme/themekit.rb +15 -15
- data/lib/rubygems_plugin.rb +3 -3
- data/lib/shopify-cli/admin_api.rb +11 -11
- data/lib/shopify-cli/admin_api/populate_resource_command.rb +17 -17
- data/lib/shopify-cli/admin_api/schema.rb +3 -3
- data/lib/shopify-cli/api.rb +10 -10
- data/lib/shopify-cli/command.rb +1 -1
- data/lib/shopify-cli/commands.rb +9 -9
- data/lib/shopify-cli/commands/config.rb +28 -52
- data/lib/shopify-cli/commands/connect.rb +10 -10
- data/lib/shopify-cli/commands/create.rb +5 -5
- data/lib/shopify-cli/commands/help.rb +6 -6
- data/lib/shopify-cli/commands/logout.rb +3 -3
- data/lib/shopify-cli/commands/system.rb +32 -32
- data/lib/shopify-cli/commands/version.rb +2 -2
- data/lib/shopify-cli/context.rb +23 -23
- data/lib/shopify-cli/core.rb +4 -4
- data/lib/shopify-cli/core/entry_point.rb +5 -5
- data/lib/shopify-cli/core/executor.rb +1 -1
- data/lib/shopify-cli/core/help_resolver.rb +2 -2
- data/lib/shopify-cli/core/monorail.rb +16 -16
- data/lib/shopify-cli/db.rb +2 -2
- data/lib/shopify-cli/feature.rb +1 -1
- data/lib/shopify-cli/form.rb +1 -1
- data/lib/shopify-cli/git.rb +17 -17
- data/lib/shopify-cli/helpers.rb +1 -1
- data/lib/shopify-cli/helpers/haikunator.rb +1 -1
- data/lib/shopify-cli/heroku.rb +28 -28
- data/lib/shopify-cli/http_request.rb +2 -2
- data/lib/shopify-cli/js_deps.rb +12 -12
- data/lib/shopify-cli/js_system.rb +5 -5
- data/lib/shopify-cli/lazy_delegator.rb +55 -0
- data/lib/shopify-cli/messages/messages.rb +4 -14
- data/lib/shopify-cli/oauth.rb +25 -25
- data/lib/shopify-cli/oauth/servlet.rb +9 -9
- data/lib/shopify-cli/options.rb +3 -3
- data/lib/shopify-cli/packager.rb +24 -24
- data/lib/shopify-cli/partners_api.rb +16 -16
- data/lib/shopify-cli/partners_api/organizations.rb +10 -10
- data/lib/shopify-cli/process_supervision.rb +7 -7
- data/lib/shopify-cli/project.rb +16 -16
- data/lib/shopify-cli/project_type.rb +3 -3
- data/lib/shopify-cli/resources.rb +1 -1
- data/lib/shopify-cli/resources/env_file.rb +9 -9
- data/lib/shopify-cli/result.rb +8 -8
- data/lib/shopify-cli/shopifolk.rb +6 -9
- data/lib/shopify-cli/sub_command.rb +1 -1
- data/lib/shopify-cli/task.rb +3 -3
- data/lib/shopify-cli/tasks.rb +7 -7
- data/lib/shopify-cli/tasks/create_api_client.rb +5 -5
- data/lib/shopify-cli/tasks/ensure_dev_store.rb +11 -11
- data/lib/shopify-cli/tasks/ensure_env.rb +15 -15
- data/lib/shopify-cli/tasks/ensure_loopback_url.rb +4 -4
- data/lib/shopify-cli/tasks/select_org_and_shop.rb +19 -19
- data/lib/shopify-cli/tasks/update_dashboard_urls.rb +10 -10
- data/lib/shopify-cli/transform_data_structure.rb +86 -0
- data/lib/shopify-cli/tunnel.rb +30 -30
- data/lib/shopify-cli/version.rb +1 -1
- data/lib/shopify_cli.rb +56 -54
- data/shopify-cli.gemspec +6 -6
- data/vendor/gen/template/bin/update-deps +9 -9
- metadata +9 -4
- data/lib/project_types/extension/forms/register.rb +0 -47
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "net/http"
|
2
2
|
|
3
3
|
module ShopifyCli
|
4
4
|
class HttpRequest
|
@@ -18,7 +18,7 @@ module ShopifyCli
|
|
18
18
|
http.use_ssl = true
|
19
19
|
|
20
20
|
req.body = body unless body.nil?
|
21
|
-
req[
|
21
|
+
req["Content-Type"] = "application/json"
|
22
22
|
headers.each { |header, value| req[header] = value }
|
23
23
|
http.request(req)
|
24
24
|
end
|
data/lib/shopify-cli/js_deps.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "shopify_cli"
|
2
2
|
|
3
3
|
module ShopifyCli
|
4
4
|
##
|
@@ -37,9 +37,9 @@ module ShopifyCli
|
|
37
37
|
# ShopifyCli::JsDeps.new(context).install(true)
|
38
38
|
#
|
39
39
|
def install(verbose = false)
|
40
|
-
title = ctx.message(
|
41
|
-
success = ctx.message(
|
42
|
-
failure = ctx.message(
|
40
|
+
title = ctx.message("core.js_deps.installing", @system.package_manager)
|
41
|
+
success = ctx.message("core.js_deps.installed")
|
42
|
+
failure = ctx.message("core.js_deps.error.install_error", @system.package_manager)
|
43
43
|
|
44
44
|
CLI::UI::Frame.open(title, success_text: success, failure_text: failure) do
|
45
45
|
@system.call(
|
@@ -53,14 +53,14 @@ module ShopifyCli
|
|
53
53
|
|
54
54
|
def yarn(verbose = false)
|
55
55
|
cmd = %w(yarn install)
|
56
|
-
cmd <<
|
56
|
+
cmd << "--silent" unless verbose
|
57
57
|
|
58
58
|
run_install_command(cmd)
|
59
59
|
end
|
60
60
|
|
61
61
|
def npm(verbose = false)
|
62
62
|
cmd = %w(npm install --no-audit)
|
63
|
-
cmd <<
|
63
|
+
cmd << "--quiet" unless verbose
|
64
64
|
|
65
65
|
run_install_command(cmd)
|
66
66
|
end
|
@@ -69,7 +69,7 @@ module ShopifyCli
|
|
69
69
|
deps = parse_dependencies
|
70
70
|
errors = nil
|
71
71
|
|
72
|
-
spinner_title = ctx.message(
|
72
|
+
spinner_title = ctx.message("core.js_deps.installing", @system.package_manager)
|
73
73
|
success = CLI::UI::Spinner.spin(spinner_title, auto_debrief: false) do |spinner|
|
74
74
|
_, errors, status = CLI::Kit::System.capture3(*cmd, env: @ctx.env, chdir: ctx.root)
|
75
75
|
update_spinner_title_and_status(spinner, status, deps)
|
@@ -81,19 +81,19 @@ module ShopifyCli
|
|
81
81
|
|
82
82
|
def update_spinner_title_and_status(spinner, status, deps)
|
83
83
|
if status.success?
|
84
|
-
spinner.update_title(ctx.message(
|
84
|
+
spinner.update_title(ctx.message("core.js_deps.installed", deps.size))
|
85
85
|
else
|
86
|
-
spinner.update_title(ctx.message(
|
86
|
+
spinner.update_title(ctx.message("core.js_deps.error.install_spinner_error", deps.size))
|
87
87
|
CLI::UI::Spinner::TASK_FAILED
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
91
|
def parse_dependencies
|
92
|
-
package_json = File.join(ctx.root,
|
92
|
+
package_json = File.join(ctx.root, "package.json")
|
93
93
|
pkg = begin
|
94
94
|
JSON.parse(File.read(package_json))
|
95
95
|
rescue Errno::ENOENT, Errno::ENOTDIR
|
96
|
-
ctx.abort(ctx.message(
|
96
|
+
ctx.abort(ctx.message("core.js_deps.error.missing_package", package_json))
|
97
97
|
end
|
98
98
|
|
99
99
|
%w(dependencies devDependencies).map do |key|
|
@@ -101,7 +101,7 @@ module ShopifyCli
|
|
101
101
|
end.flatten
|
102
102
|
rescue JSON::ParserError
|
103
103
|
ctx.puts(
|
104
|
-
ctx.message(
|
104
|
+
ctx.message("core.js_deps.error.invalid_package", File.read(File.join(path, "package.json"))),
|
105
105
|
error: true
|
106
106
|
)
|
107
107
|
raise ShopifyCli::AbortSilent
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "shopify_cli"
|
2
2
|
|
3
3
|
module ShopifyCli
|
4
4
|
##
|
@@ -7,8 +7,8 @@ module ShopifyCli
|
|
7
7
|
class JsSystem
|
8
8
|
include SmartProperties
|
9
9
|
|
10
|
-
YARN_CORE_COMMAND =
|
11
|
-
NPM_CORE_COMMAND =
|
10
|
+
YARN_CORE_COMMAND = "yarn"
|
11
|
+
NPM_CORE_COMMAND = "npm"
|
12
12
|
|
13
13
|
class << self
|
14
14
|
##
|
@@ -64,8 +64,8 @@ module ShopifyCli
|
|
64
64
|
#
|
65
65
|
def yarn?
|
66
66
|
@has_yarn ||= begin
|
67
|
-
cmd_path = @ctx.which(
|
68
|
-
File.exist?(File.join(ctx.root,
|
67
|
+
cmd_path = @ctx.which("yarn")
|
68
|
+
File.exist?(File.join(ctx.root, "yarn.lock")) && !cmd_path.nil?
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "delegate"
|
2
|
+
|
3
|
+
module ShopifyCli
|
4
|
+
##
|
5
|
+
# `LazyDelegator` defers initialization of its underlying delegatee until the
|
6
|
+
# latter is accessed for the first time due to a method call that the
|
7
|
+
# delegator cannot handle itself:
|
8
|
+
#
|
9
|
+
# result = LazyDelegator.new do
|
10
|
+
# # carry out costly operation ...
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# result # referencing the object itself does not result in Proc evaluation
|
14
|
+
# result.to_h # however, calling a method on it will result in Proc evaluation
|
15
|
+
#
|
16
|
+
# LazyDelegator lends itself to being subclassed in scenarios where some
|
17
|
+
# facts are known and others are costly to compute:
|
18
|
+
#
|
19
|
+
# class LazySpecificationHandler < ShopifyCli::LazyDelegator
|
20
|
+
# attr_reader :identifier
|
21
|
+
#
|
22
|
+
# def initialize(identifier, &initializer)
|
23
|
+
# super(&initializer)
|
24
|
+
# @identifier = identifier
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# handler = LazySpecificationHandler.new(:product_subscription) do
|
29
|
+
# # fetch specification from the Partners Dashboard API ...
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# # Accessing identifier will not result in Proc evaluation as it is
|
33
|
+
# # available as an attribute of the delegator itself
|
34
|
+
# handler.identifier # => :product_subscription
|
35
|
+
#
|
36
|
+
# # Accessing the specification will result in evaluation of the Proc
|
37
|
+
# # and in our example in a subsequent network call
|
38
|
+
# handler.specification # => <Extension::Models::Specifcation:...>
|
39
|
+
#
|
40
|
+
class LazyDelegator < SimpleDelegator
|
41
|
+
def initialize(&delegatee_initializer)
|
42
|
+
super([false, delegatee_initializer])
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
|
47
|
+
def __getobj__(*)
|
48
|
+
initialized, value_or_initializer = super
|
49
|
+
return value_or_initializer if initialized
|
50
|
+
value_or_initializer.call.tap do |value|
|
51
|
+
__setobj__([true, value])
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -76,16 +76,6 @@ module ShopifyCli
|
|
76
76
|
is_enabled: "{{v}} analytics are currently enabled",
|
77
77
|
is_disabled: "{{v}} analytics are currently disabled",
|
78
78
|
},
|
79
|
-
shopifolk_beta: {
|
80
|
-
help: <<~HELP,
|
81
|
-
Opt in/out of shopifolk beta
|
82
|
-
Usage: {{command:%s config [ analytics ] }}
|
83
|
-
HELP
|
84
|
-
enabled: "{{v}} shopifolk-beta has been enabled",
|
85
|
-
disabled: "{{v}} shopifolk-beta has been disabled",
|
86
|
-
is_enabled: "{{v}} shopifolk-beta is currently enabled",
|
87
|
-
is_disabled: "{{v}} shopifolk-beta is currently disabled",
|
88
|
-
},
|
89
79
|
},
|
90
80
|
|
91
81
|
git: {
|
@@ -129,7 +119,7 @@ module ShopifyCli
|
|
129
119
|
missing_package: "expected to have a file at: %s",
|
130
120
|
invalid_package: "{{info:%s}} was not valid JSON. Fix this then try again",
|
131
121
|
install_spinner_error: "Unable to install all %d dependencies",
|
132
|
-
install_error:
|
122
|
+
install_error: "An error occurred while installing dependencies",
|
133
123
|
},
|
134
124
|
|
135
125
|
installing: "Installing dependencies with %s...",
|
@@ -192,9 +182,9 @@ module ShopifyCli
|
|
192
182
|
|
193
183
|
api: {
|
194
184
|
error: {
|
195
|
-
internal_server_error:
|
185
|
+
internal_server_error: "{{red:{{x}} An unexpected error occurred on Shopify.}}",
|
196
186
|
internal_server_error_debug: "\n{{red:Response details:}}\n%s\n\n",
|
197
|
-
invalid_url:
|
187
|
+
invalid_url: "Invalid URL: %s",
|
198
188
|
},
|
199
189
|
},
|
200
190
|
|
@@ -282,7 +272,7 @@ module ShopifyCli
|
|
282
272
|
MESSAGE
|
283
273
|
development_store_select: "Which development store would you like to use?",
|
284
274
|
app_select: "To which app does this project belong?",
|
285
|
-
no_apps:
|
275
|
+
no_apps: "You have no apps to connect to, creating a new app.",
|
286
276
|
app_name: "App name",
|
287
277
|
app_type: {
|
288
278
|
select: "What type of app are you building?",
|
data/lib/shopify-cli/oauth.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
1
|
+
require "base64"
|
2
|
+
require "digest"
|
3
|
+
require "json"
|
4
|
+
require "net/http"
|
5
|
+
require "securerandom"
|
6
|
+
require "openssl"
|
7
|
+
require "shopify_cli"
|
8
|
+
require "uri"
|
9
|
+
require "webrick"
|
10
10
|
|
11
11
|
module ShopifyCli
|
12
12
|
class OAuth
|
13
13
|
include SmartProperties
|
14
14
|
|
15
|
-
autoload :Servlet,
|
15
|
+
autoload :Servlet, "shopify-cli/oauth/servlet"
|
16
16
|
|
17
17
|
class Error < StandardError; end
|
18
18
|
LocalRequest = Struct.new(:method, :path, :query, :protocol)
|
@@ -54,10 +54,10 @@ module ShopifyCli
|
|
54
54
|
@server ||= begin
|
55
55
|
server = WEBrick::HTTPServer.new(
|
56
56
|
Port: DEFAULT_PORT,
|
57
|
-
Logger: WEBrick::Log.new(File.open(File::NULL,
|
57
|
+
Logger: WEBrick::Log.new(File.open(File::NULL, "w")),
|
58
58
|
AccessLog: [],
|
59
59
|
)
|
60
|
-
server.mount(
|
60
|
+
server.mount("/", Servlet, self, state_token)
|
61
61
|
server
|
62
62
|
end
|
63
63
|
end
|
@@ -80,17 +80,17 @@ module ShopifyCli
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def output_authentication_info(uri)
|
83
|
-
login_location = ctx.message(service ==
|
84
|
-
ctx.puts(ctx.message(
|
83
|
+
login_location = ctx.message(service == "admin" ? "core.oauth.location.admin" : "core.oauth.location.partner")
|
84
|
+
ctx.puts(ctx.message("core.oauth.authentication_required", login_location))
|
85
85
|
ctx.open_url!(uri)
|
86
86
|
end
|
87
87
|
|
88
88
|
def receive_access_code
|
89
89
|
@access_code ||= begin
|
90
90
|
@server_thread.join(240)
|
91
|
-
raise Error, ctx.message(
|
92
|
-
raise Error, response_query[
|
93
|
-
response_query[
|
91
|
+
raise Error, ctx.message("core.oauth.error.timeout") if response_query.nil?
|
92
|
+
raise Error, response_query["error_description"] unless response_query["error"].nil?
|
93
|
+
response_query["code"]
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -105,8 +105,8 @@ module ShopifyCli
|
|
105
105
|
}.merge(confirmation_param)
|
106
106
|
)
|
107
107
|
store.set(
|
108
|
-
"#{service}_access_token".to_sym => resp[
|
109
|
-
"#{service}_refresh_token".to_sym => resp[
|
108
|
+
"#{service}_access_token".to_sym => resp["access_token"],
|
109
|
+
"#{service}_refresh_token".to_sym => resp["refresh_token"],
|
110
110
|
)
|
111
111
|
end
|
112
112
|
|
@@ -130,8 +130,8 @@ module ShopifyCli
|
|
130
130
|
client_id: client_id,
|
131
131
|
)
|
132
132
|
store.set(
|
133
|
-
"#{service}_access_token".to_sym => resp[
|
134
|
-
"#{service}_refresh_token".to_sym => resp[
|
133
|
+
"#{service}_access_token".to_sym => resp["access_token"],
|
134
|
+
"#{service}_refresh_token".to_sym => resp["refresh_token"],
|
135
135
|
)
|
136
136
|
end
|
137
137
|
|
@@ -155,7 +155,7 @@ module ShopifyCli
|
|
155
155
|
scope: scopes,
|
156
156
|
subject_token: store.get("#{service}_access_token".to_sym),
|
157
157
|
)
|
158
|
-
store.set("#{service}_exchange_token".to_sym => resp[
|
158
|
+
store.set("#{service}_exchange_token".to_sym => resp["access_token"])
|
159
159
|
end
|
160
160
|
|
161
161
|
def post_token_request(url, params)
|
@@ -163,17 +163,17 @@ module ShopifyCli
|
|
163
163
|
https = Net::HTTP.new(uri.host, uri.port)
|
164
164
|
https.use_ssl = true
|
165
165
|
request = Net::HTTP::Post.new(uri.path)
|
166
|
-
request[
|
166
|
+
request["User-Agent"] = "Shopify App CLI #{::ShopifyCli::VERSION}"
|
167
167
|
request.body = URI.encode_www_form(params)
|
168
168
|
res = https.request(request)
|
169
|
-
raise Error, JSON.parse(res.body)[
|
169
|
+
raise Error, JSON.parse(res.body)["error_description"] unless res.is_a?(Net::HTTPSuccess)
|
170
170
|
JSON.parse(res.body)
|
171
171
|
end
|
172
172
|
|
173
173
|
def challange_params
|
174
174
|
{
|
175
175
|
code_challenge: code_challenge,
|
176
|
-
code_challenge_method:
|
176
|
+
code_challenge_method: "S256",
|
177
177
|
}
|
178
178
|
end
|
179
179
|
|
@@ -26,18 +26,18 @@ module ShopifyCli
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def do_GET(req, res) # rubocop:disable Naming/MethodName
|
29
|
-
if !req.query[
|
29
|
+
if !req.query["error"].nil?
|
30
30
|
respond_with(
|
31
31
|
res,
|
32
32
|
400,
|
33
|
-
Context.message(
|
33
|
+
Context.message("core.oauth.servlet.invalid_request_response", req.query["error_description"])
|
34
34
|
)
|
35
|
-
elsif req.query[
|
36
|
-
response_message = Context.message(
|
37
|
-
req.query.merge!(
|
35
|
+
elsif req.query["state"] != @state_token
|
36
|
+
response_message = Context.message("core.oauth.servlet.invalid_state_response")
|
37
|
+
req.query.merge!("error" => "invalid_state", "error_description" => response_message)
|
38
38
|
respond_with(res, 403, response_message)
|
39
39
|
else
|
40
|
-
respond_with(res, 200, Context.message(
|
40
|
+
respond_with(res, 200, Context.message("core.oauth.servlet.success_response"))
|
41
41
|
end
|
42
42
|
@oauth.response_query = req.query
|
43
43
|
@server.shutdown
|
@@ -48,10 +48,10 @@ module ShopifyCli
|
|
48
48
|
locals = {
|
49
49
|
status: status,
|
50
50
|
message: message,
|
51
|
-
color: successful ?
|
51
|
+
color: successful ? "black" : "red",
|
52
52
|
title:
|
53
|
-
Context.message(successful ?
|
54
|
-
autoclose: successful ? AUTOCLOSE_TEMPLATE :
|
53
|
+
Context.message(successful ? "core.oauth.servlet.authenticated" : "core.oauth.servlet.not_authenticated"),
|
54
|
+
autoclose: successful ? AUTOCLOSE_TEMPLATE : "",
|
55
55
|
}
|
56
56
|
response.status = status
|
57
57
|
response.body = format(TEMPLATE, locals)
|
data/lib/shopify-cli/options.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require "shopify_cli"
|
3
|
+
require "optparse"
|
4
4
|
|
5
5
|
module ShopifyCli
|
6
6
|
class Options
|
@@ -31,7 +31,7 @@ module ShopifyCli
|
|
31
31
|
def parser
|
32
32
|
@parser ||= begin
|
33
33
|
opt = OptionParser.new
|
34
|
-
opt.on(
|
34
|
+
opt.on("--help", "-h", Context.message("core.options.help_text")) do |v|
|
35
35
|
@help = v
|
36
36
|
end
|
37
37
|
end
|
data/lib/shopify-cli/packager.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
module ShopifyCli
|
2
2
|
class Packager
|
3
|
-
PACKAGING_DIR = File.join(ShopifyCli::ROOT,
|
4
|
-
BUILDS_DIR = File.join(PACKAGING_DIR,
|
3
|
+
PACKAGING_DIR = File.join(ShopifyCli::ROOT, "packaging")
|
4
|
+
BUILDS_DIR = File.join(PACKAGING_DIR, "builds", ShopifyCli::VERSION)
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
FileUtils.mkdir_p(BUILDS_DIR)
|
8
8
|
end
|
9
9
|
|
10
10
|
def build_debian
|
11
|
-
ensure_program_installed(
|
11
|
+
ensure_program_installed("dpkg-deb", "brew install dpkg")
|
12
12
|
|
13
|
-
root_dir = File.join(PACKAGING_DIR,
|
14
|
-
debian_dir = File.join(root_dir,
|
13
|
+
root_dir = File.join(PACKAGING_DIR, "debian")
|
14
|
+
debian_dir = File.join(root_dir, "shopify-cli", "DEBIAN")
|
15
15
|
FileUtils.mkdir_p(debian_dir)
|
16
16
|
|
17
17
|
puts "\nBuilding Debian package"
|
@@ -24,15 +24,15 @@ module ShopifyCli
|
|
24
24
|
file_path = File.join(debian_dir, file)
|
25
25
|
|
26
26
|
file_contents = File.read(File.join(root_dir, "#{file}.base"))
|
27
|
-
file_contents = file_contents.gsub(
|
28
|
-
File.open(file_path,
|
27
|
+
file_contents = file_contents.gsub("SHOPIFY_CLI_VERSION", ShopifyCli::VERSION)
|
28
|
+
File.open(file_path, "w", 0775) { |f| f.write(file_contents) }
|
29
29
|
end
|
30
30
|
|
31
31
|
puts "Building package..."
|
32
32
|
Dir.chdir(root_dir)
|
33
|
-
raise "Failed to build package" unless system(
|
33
|
+
raise "Failed to build package" unless system("dpkg-deb", "-b", "shopify-cli")
|
34
34
|
|
35
|
-
output_path = File.join(root_dir,
|
35
|
+
output_path = File.join(root_dir, "shopify-cli.deb")
|
36
36
|
final_path = File.join(BUILDS_DIR, "shopify-cli-#{ShopifyCli::VERSION}.deb")
|
37
37
|
|
38
38
|
puts "Moving generated package: \n From: #{output_path}\n To: #{final_path}\n\n"
|
@@ -40,34 +40,34 @@ module ShopifyCli
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def build_rpm
|
43
|
-
ensure_program_installed(
|
43
|
+
ensure_program_installed("rpmbuild", "brew install rpm")
|
44
44
|
|
45
|
-
root_dir = File.join(PACKAGING_DIR,
|
46
|
-
rpm_build_dir = File.join(root_dir,
|
45
|
+
root_dir = File.join(PACKAGING_DIR, "rpm")
|
46
|
+
rpm_build_dir = File.join(root_dir, "build")
|
47
47
|
FileUtils.mkdir_p(rpm_build_dir)
|
48
48
|
|
49
|
-
spec_path = File.join(root_dir,
|
49
|
+
spec_path = File.join(root_dir, "shopify-cli.spec")
|
50
50
|
puts "\nBuilding RPM package"
|
51
51
|
|
52
52
|
puts "Generating spec file..."
|
53
53
|
File.delete(spec_path) if File.exist?(spec_path)
|
54
54
|
|
55
|
-
spec_contents = File.read(File.join(root_dir,
|
56
|
-
spec_contents = spec_contents.gsub(
|
55
|
+
spec_contents = File.read(File.join(root_dir, "shopify-cli.spec.base"))
|
56
|
+
spec_contents = spec_contents.gsub("SHOPIFY_CLI_VERSION", ShopifyCli::VERSION)
|
57
57
|
File.write(spec_path, spec_contents)
|
58
58
|
|
59
59
|
puts "Building package..."
|
60
60
|
Dir.chdir(root_dir)
|
61
|
-
system(
|
61
|
+
system("rpmbuild", "-bb", File.basename(spec_path))
|
62
62
|
|
63
|
-
output_dir = File.join(root_dir,
|
63
|
+
output_dir = File.join(root_dir, "build", "noarch")
|
64
64
|
|
65
65
|
puts "Moving generated packages: \n From: #{output_dir}\n To: #{BUILDS_DIR}\n\n"
|
66
66
|
FileUtils.mv(Dir.glob("#{output_dir}/*.rpm"), BUILDS_DIR)
|
67
67
|
end
|
68
68
|
|
69
69
|
def build_homebrew
|
70
|
-
root_dir = File.join(PACKAGING_DIR,
|
70
|
+
root_dir = File.join(PACKAGING_DIR, "homebrew")
|
71
71
|
|
72
72
|
build_path = File.join(BUILDS_DIR, "shopify-cli.rb")
|
73
73
|
puts "\nBuilding Homebrew package"
|
@@ -75,18 +75,18 @@ module ShopifyCli
|
|
75
75
|
puts "Generating formula..."
|
76
76
|
File.delete(build_path) if File.exist?(build_path)
|
77
77
|
|
78
|
-
spec_contents = File.read(File.join(root_dir,
|
79
|
-
spec_contents = spec_contents.gsub(
|
78
|
+
spec_contents = File.read(File.join(root_dir, "shopify-cli.base.rb"))
|
79
|
+
spec_contents = spec_contents.gsub("SHOPIFY_CLI_VERSION", ShopifyCli::VERSION)
|
80
80
|
|
81
81
|
puts "Grabbing sha256 checksum from Rubygems.org"
|
82
|
-
require
|
83
|
-
require
|
82
|
+
require "digest/sha2"
|
83
|
+
require "open-uri"
|
84
84
|
gem_checksum = open("https://rubygems.org/downloads/shopify-cli-#{ShopifyCli::VERSION}.gem") do |io|
|
85
85
|
Digest::SHA256.new.hexdigest(io.read)
|
86
86
|
end
|
87
87
|
|
88
88
|
puts "Got sha256 checksum for gem: #{gem_checksum}"
|
89
|
-
spec_contents = spec_contents.gsub(
|
89
|
+
spec_contents = spec_contents.gsub("SHOPIFY_CLI_GEM_CHECKSUM", gem_checksum)
|
90
90
|
|
91
91
|
puts "Writing generated formula\n To: #{build_path}\n\n"
|
92
92
|
File.write(build_path, spec_contents)
|
@@ -95,7 +95,7 @@ module ShopifyCli
|
|
95
95
|
private
|
96
96
|
|
97
97
|
def ensure_program_installed(program, installation_cmd)
|
98
|
-
unless system(program,
|
98
|
+
unless system(program, "--version", out: File::NULL, err: File::NULL)
|
99
99
|
raise <<~MESSAGE
|
100
100
|
|
101
101
|
Could not find program #{program} which is required to build the package.
|