shopify-cli 1.6.0 → 1.9.1
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/.rubocop_todo.yml +15 -2
- data/CHANGELOG.md +21 -0
- data/Gemfile +12 -12
- data/Gemfile.lock +14 -14
- data/Rakefile +32 -30
- data/bin/load_shopify.rb +6 -6
- data/bin/shopify +2 -2
- data/dev.yml +3 -0
- data/ext/shopify-cli/extconf.rb +7 -7
- data/lib/docgen/markdown.rb +12 -12
- data/lib/graphql/extension_create.graphql +17 -2
- data/lib/graphql/fetch_specifications.graphql +14 -0
- data/lib/{project_types/extension/graphql → graphql}/get_app_by_api_key.graphql +0 -0
- data/lib/project_types/extension/cli.rb +56 -55
- data/lib/project_types/extension/commands/build.rb +3 -3
- data/lib/project_types/extension/commands/create.rb +17 -10
- data/lib/project_types/extension/commands/extension_command.rb +14 -7
- data/lib/project_types/extension/commands/push.rb +10 -10
- data/lib/project_types/extension/commands/register.rb +22 -32
- data/lib/project_types/extension/commands/serve.rb +1 -7
- data/lib/project_types/extension/commands/tunnel.rb +12 -12
- data/lib/project_types/extension/extension_project.rb +22 -7
- data/lib/project_types/extension/extension_project_keys.rb +5 -4
- data/lib/project_types/extension/features/argo.rb +26 -42
- 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_renderer_package.rb +47 -0
- data/lib/project_types/extension/features/argo_serve.rb +69 -0
- data/lib/project_types/extension/features/argo_setup.rb +3 -3
- 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 +47 -0
- data/lib/project_types/extension/messages/message_loading.rb +3 -1
- data/lib/project_types/extension/messages/messages.rb +55 -55
- data/lib/project_types/extension/models/lazy_specification_handler.rb +12 -0
- data/lib/project_types/extension/models/registration.rb +1 -0
- data/lib/project_types/extension/models/specification.rb +6 -2
- data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +1 -1
- data/lib/project_types/extension/models/specification_handlers/default.rb +10 -2
- data/lib/project_types/extension/models/specifications.rb +14 -3
- data/lib/project_types/extension/models/version.rb +1 -1
- data/lib/project_types/extension/tasks/configure_features.rb +7 -5
- data/lib/project_types/extension/tasks/converters/app_converter.rb +6 -6
- data/lib/project_types/extension/tasks/converters/registration_converter.rb +8 -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 +8 -28
- 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 +2 -24
- 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 +17 -8
- data/lib/project_types/node/messages/messages.rb +8 -7
- 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 +34 -24
- data/lib/project_types/rails/gem.rb +23 -23
- data/lib/project_types/rails/messages/messages.rb +9 -8
- data/lib/project_types/rails/ruby.rb +2 -2
- data/lib/project_types/script/cli.rb +36 -40
- data/lib/project_types/script/commands/create.rb +9 -13
- data/lib/project_types/script/commands/push.rb +6 -5
- data/lib/project_types/script/config/extension_points.yml +25 -10
- data/lib/project_types/script/errors.rb +1 -19
- data/lib/project_types/script/forms/create.rb +7 -18
- data/lib/project_types/script/graphql/app_script_update_or_create.graphql +7 -5
- data/lib/project_types/script/graphql/script_service_proxy.graphql +1 -2
- data/lib/project_types/script/layers/application/build_script.rb +6 -8
- data/lib/project_types/script/layers/application/create_script.rb +34 -24
- data/lib/project_types/script/layers/application/extension_points.rb +3 -2
- data/lib/project_types/script/layers/application/project_dependencies.rb +4 -4
- data/lib/project_types/script/layers/application/push_script.rb +10 -15
- data/lib/project_types/script/layers/domain/config_ui.rb +16 -0
- data/lib/project_types/script/layers/domain/errors.rb +16 -0
- data/lib/project_types/script/layers/domain/extension_point.rb +60 -45
- data/lib/project_types/script/layers/domain/metadata.rb +18 -25
- data/lib/project_types/script/layers/domain/push_package.rb +9 -5
- data/lib/project_types/script/layers/domain/script_project.rb +38 -0
- data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +39 -10
- data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +9 -44
- data/lib/project_types/script/layers/infrastructure/errors.rb +50 -19
- data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +2 -2
- data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +16 -21
- data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +4 -4
- data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +2 -2
- data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +179 -0
- data/lib/project_types/script/layers/infrastructure/script_service.rb +35 -78
- data/lib/project_types/script/messages/messages.rb +33 -57
- data/lib/project_types/script/ui/error_handler.rb +116 -88
- 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 +51 -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 +7 -7
- data/lib/shopify-cli/lazy_delegator.rb +55 -0
- data/lib/shopify-cli/messages/messages.rb +7 -16
- data/lib/shopify-cli/method_object.rb +1 -1
- data/lib/shopify-cli/oauth.rb +27 -27
- data/lib/shopify-cli/oauth/servlet.rb +9 -9
- data/lib/shopify-cli/options.rb +3 -3
- data/lib/shopify-cli/packager.rb +25 -25
- 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/resolve_constant.rb +1 -1
- data/lib/shopify-cli/resources.rb +1 -1
- data/lib/shopify-cli/resources/env_file.rb +10 -10
- data/lib/shopify-cli/result.rb +11 -11
- 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 +12 -12
- 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/deps/smart_properties/REVISION +1 -1
- data/vendor/deps/smart_properties/lib/smart_properties/property.rb +7 -1
- data/vendor/deps/smart_properties/lib/smart_properties/version.rb +1 -1
- data/vendor/gen/template/bin/update-deps +9 -9
- metadata +15 -11
- data/lib/project_types/extension/forms/register.rb +0 -47
- data/lib/project_types/script/commands/disable.rb +0 -25
- data/lib/project_types/script/commands/enable.rb +0 -78
- data/lib/project_types/script/graphql/shop_script_delete.graphql +0 -14
- data/lib/project_types/script/graphql/shop_script_update_or_create.graphql +0 -28
- data/lib/project_types/script/layers/application/disable_script.rb +0 -21
- data/lib/project_types/script/layers/application/enable_script.rb +0 -23
- data/lib/project_types/script/script_project.rb +0 -63
|
@@ -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
|
##
|
|
@@ -37,8 +37,8 @@ module ShopifyCli
|
|
|
37
37
|
#
|
|
38
38
|
# ShopifyCli::JsSystem.call(ctx, yarn: ['install', '--silent'], npm: ['install', '--no-audit'])
|
|
39
39
|
#
|
|
40
|
-
def call(ctx, yarn:, npm:)
|
|
41
|
-
JsSystem.new(ctx: ctx).call(yarn: yarn, npm: npm)
|
|
40
|
+
def call(ctx, yarn:, npm:, capture_response: false)
|
|
41
|
+
JsSystem.new(ctx: ctx).call(yarn: yarn, npm: npm, capture_response: capture_response)
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -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,23 +76,14 @@ 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: {
|
|
92
82
|
error: {
|
|
93
83
|
directory_exists: "Project directory already exists. Please create a project with a new name.",
|
|
94
84
|
no_branches_found: "Could not find any git branches",
|
|
95
|
-
repo_not_initiated:
|
|
85
|
+
repo_not_initiated:
|
|
86
|
+
"Git repo is not initiated. Please run {{command:git init}} and make at least one commit.",
|
|
96
87
|
no_commits_made: "No git commits have been made. Please make at least one commit.",
|
|
97
88
|
},
|
|
98
89
|
|
|
@@ -120,7 +111,7 @@ module ShopifyCli
|
|
|
120
111
|
deploy: "Could not deploy to Heroku",
|
|
121
112
|
download: "Heroku CLI could not be downloaded",
|
|
122
113
|
install: "Could not install Heroku CLI",
|
|
123
|
-
could_not_select_app: "Heroku app
|
|
114
|
+
could_not_select_app: "Heroku app {{green:%s}} could not be selected",
|
|
124
115
|
},
|
|
125
116
|
},
|
|
126
117
|
|
|
@@ -129,7 +120,7 @@ module ShopifyCli
|
|
|
129
120
|
missing_package: "expected to have a file at: %s",
|
|
130
121
|
invalid_package: "{{info:%s}} was not valid JSON. Fix this then try again",
|
|
131
122
|
install_spinner_error: "Unable to install all %d dependencies",
|
|
132
|
-
install_error:
|
|
123
|
+
install_error: "An error occurred while installing dependencies",
|
|
133
124
|
},
|
|
134
125
|
|
|
135
126
|
installing: "Installing dependencies with %s...",
|
|
@@ -192,9 +183,9 @@ module ShopifyCli
|
|
|
192
183
|
|
|
193
184
|
api: {
|
|
194
185
|
error: {
|
|
195
|
-
internal_server_error:
|
|
186
|
+
internal_server_error: "{{red:{{x}} An unexpected error occurred on Shopify.}}",
|
|
196
187
|
internal_server_error_debug: "\n{{red:Response details:}}\n%s\n\n",
|
|
197
|
-
invalid_url:
|
|
188
|
+
invalid_url: "Invalid URL: %s",
|
|
198
189
|
},
|
|
199
190
|
},
|
|
200
191
|
|
|
@@ -282,7 +273,7 @@ module ShopifyCli
|
|
|
282
273
|
MESSAGE
|
|
283
274
|
development_store_select: "Which development store would you like to use?",
|
|
284
275
|
app_select: "To which app does this project belong?",
|
|
285
|
-
no_apps:
|
|
276
|
+
no_apps: "You have no apps to connect to, creating a new app.",
|
|
286
277
|
app_name: "App name",
|
|
287
278
|
app_type: {
|
|
288
279
|
select: "What type of app are you building?",
|
|
@@ -61,7 +61,7 @@ module ShopifyCli
|
|
|
61
61
|
##
|
|
62
62
|
# creates a new instance and invokes `call`. Any positional argument
|
|
63
63
|
# is forward to `call`. Keyword arguments are either forwarded to the
|
|
64
|
-
#
|
|
64
|
+
# initializer or to `call`. If the keyword argument matches the name of
|
|
65
65
|
# property, it is forwarded to the initializer, otherwise to call.
|
|
66
66
|
#
|
|
67
67
|
def call(*args, **kwargs)
|
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)
|
|
@@ -24,10 +24,10 @@ module ShopifyCli
|
|
|
24
24
|
property! :service, accepts: String
|
|
25
25
|
property! :client_id, accepts: String
|
|
26
26
|
property! :scopes
|
|
27
|
-
property :store, default: ShopifyCli::DB.new
|
|
27
|
+
property :store, default: -> { ShopifyCli::DB.new }
|
|
28
28
|
property :secret, accepts: String
|
|
29
29
|
property :request_exchange, accepts: String
|
|
30
|
-
property :options, default: {}, accepts: Hash
|
|
30
|
+
property :options, default: -> { {} }, accepts: Hash
|
|
31
31
|
property :auth_path, default: "/authorize", accepts: ->(path) { path.is_a?(String) && path.start_with?("/") }
|
|
32
32
|
property :token_path, default: "/token", accepts: ->(path) { path.is_a?(String) && path.start_with?("/") }
|
|
33
33
|
property :state_token, accepts: String, default: SecureRandom.hex(30)
|
|
@@ -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,11 +95,11 @@ 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.
|
|
102
|
-
You can install it by running
|
|
102
|
+
You can install it by running #{installation_cmd}.
|
|
103
103
|
|
|
104
104
|
MESSAGE
|
|
105
105
|
end
|