shopify_app 13.0.0 → 13.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rubocop.yml +28 -0
- data/.rubocop.yml +13 -6
- data/.travis.yml +4 -3
- data/CHANGELOG.md +33 -0
- data/Gemfile +5 -0
- data/README.md +67 -38
- data/Rakefile +1 -0
- data/SECURITY.md +59 -0
- data/app/controllers/concerns/shopify_app/require_known_shop.rb +39 -0
- data/app/controllers/shopify_app/authenticated_controller.rb +1 -0
- data/app/controllers/shopify_app/callback_controller.rb +39 -8
- data/app/controllers/shopify_app/extension_verification_controller.rb +2 -7
- data/app/controllers/shopify_app/sessions_controller.rb +9 -6
- data/app/controllers/shopify_app/webhooks_controller.rb +6 -5
- data/config/locales/fi.yml +1 -1
- data/config/locales/nl.yml +7 -7
- data/config/routes.rb +1 -0
- data/docs/Quickstart.md +5 -14
- data/docs/Releasing.md +1 -0
- data/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb +5 -3
- data/lib/generators/shopify_app/add_after_authenticate_job/templates/after_authenticate_job.rb +1 -0
- data/lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb +2 -1
- data/lib/generators/shopify_app/add_marketing_activity_extension/templates/marketing_activities_controller.rb +4 -4
- data/lib/generators/shopify_app/add_webhook/add_webhook_generator.rb +5 -4
- data/lib/generators/shopify_app/add_webhook/templates/{webhook_job.rb → webhook_job.rb.tt} +5 -0
- data/lib/generators/shopify_app/app_proxy_controller/app_proxy_controller_generator.rb +4 -3
- data/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_controller.rb +3 -3
- data/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_route.rb +10 -9
- data/lib/generators/shopify_app/controllers/controllers_generator.rb +1 -0
- data/lib/generators/shopify_app/home_controller/home_controller_generator.rb +4 -3
- data/lib/generators/shopify_app/install/install_generator.rb +10 -9
- data/lib/generators/shopify_app/install/templates/omniauth.rb +2 -1
- data/lib/generators/shopify_app/install/templates/{shopify_app.rb → shopify_app.rb.tt} +1 -1
- data/lib/generators/shopify_app/install/templates/user_agent.rb +2 -1
- data/lib/generators/shopify_app/routes/routes_generator.rb +1 -0
- data/lib/generators/shopify_app/routes/templates/routes.rb +10 -9
- data/lib/generators/shopify_app/shop_model/shop_model_generator.rb +12 -7
- data/lib/generators/shopify_app/shop_model/templates/shop.rb +1 -0
- data/lib/generators/shopify_app/shopify_app_generator.rb +4 -3
- data/lib/generators/shopify_app/user_model/templates/user.rb +1 -0
- data/lib/generators/shopify_app/user_model/user_model_generator.rb +12 -7
- data/lib/generators/shopify_app/views/views_generator.rb +1 -0
- data/lib/shopify_app.rb +11 -5
- data/lib/shopify_app/configuration.rb +15 -8
- data/lib/shopify_app/controller_concerns/app_proxy_verification.rb +3 -3
- data/lib/shopify_app/controller_concerns/embedded_app.rb +3 -2
- data/lib/shopify_app/controller_concerns/localization.rb +1 -0
- data/lib/shopify_app/controller_concerns/login_protection.rb +52 -15
- data/lib/shopify_app/controller_concerns/payload_verification.rb +24 -0
- data/lib/shopify_app/controller_concerns/webhook_verification.rb +3 -18
- data/lib/shopify_app/engine.rb +5 -0
- data/lib/shopify_app/jobs/scripttags_manager_job.rb +1 -1
- data/lib/shopify_app/jobs/webhooks_manager_job.rb +1 -1
- data/lib/shopify_app/managers/scripttags_manager.rb +4 -3
- data/lib/shopify_app/managers/webhooks_manager.rb +4 -3
- data/lib/shopify_app/middleware/jwt_middleware.rb +42 -0
- data/lib/shopify_app/middleware/same_site_cookie_middleware.rb +2 -1
- data/lib/shopify_app/session/in_memory_session_store.rb +7 -3
- data/lib/shopify_app/session/in_memory_shop_session_store.rb +10 -0
- data/lib/shopify_app/session/in_memory_user_session_store.rb +10 -0
- data/lib/shopify_app/session/jwt.rb +61 -0
- data/lib/shopify_app/session/null_user_session_store.rb +22 -0
- data/lib/shopify_app/session/session_repository.rb +13 -16
- data/lib/shopify_app/session/session_storage.rb +1 -0
- data/lib/shopify_app/session/shop_session_storage.rb +21 -9
- data/lib/shopify_app/session/user_session_storage.rb +19 -8
- data/lib/shopify_app/test_helpers/all.rb +2 -0
- data/lib/shopify_app/test_helpers/webhook_verification_helper.rb +17 -0
- data/lib/shopify_app/utils.rb +6 -5
- data/lib/shopify_app/version.rb +2 -1
- data/package-lock.json +4 -4
- data/package.json +1 -1
- data/shopify_app.gemspec +12 -7
- data/yarn.lock +3 -3
- metadata +48 -10
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ShopifyApp
|
4
|
+
module RequireKnownShop
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
before_action :check_shop_domain
|
9
|
+
before_action :check_shop_known
|
10
|
+
end
|
11
|
+
|
12
|
+
def current_shopify_domain
|
13
|
+
return if params[:shop].blank?
|
14
|
+
@shopify_domain ||= ShopifyApp::Utils.sanitize_shop_domain(params[:shop])
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def check_shop_domain
|
20
|
+
redirect_to(ShopifyApp.configuration.login_url) unless current_shopify_domain
|
21
|
+
end
|
22
|
+
|
23
|
+
def check_shop_known
|
24
|
+
@shop = SessionRepository.retrieve_shop_session_by_shopify_domain(current_shopify_domain)
|
25
|
+
redirect_to(shop_login) unless @shop
|
26
|
+
end
|
27
|
+
|
28
|
+
def shop_login
|
29
|
+
url = URI(ShopifyApp.configuration.login_url)
|
30
|
+
|
31
|
+
url.query = URI.encode_www_form(
|
32
|
+
shop: params[:shop],
|
33
|
+
return_to: request.fullpath,
|
34
|
+
)
|
35
|
+
|
36
|
+
url.to_s
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -6,10 +6,22 @@ module ShopifyApp
|
|
6
6
|
include ShopifyApp::LoginProtection
|
7
7
|
|
8
8
|
def callback
|
9
|
-
|
10
|
-
|
9
|
+
unless auth_hash
|
10
|
+
return respond_with_error
|
11
|
+
end
|
12
|
+
|
13
|
+
if jwt_request? && !valid_jwt_auth?
|
14
|
+
return respond_with_error
|
15
|
+
end
|
16
|
+
|
17
|
+
if jwt_request?
|
18
|
+
set_shopify_session
|
19
|
+
head(:ok)
|
20
|
+
else
|
21
|
+
reset_session_options
|
22
|
+
set_shopify_session
|
11
23
|
|
12
|
-
if
|
24
|
+
if redirect_for_user_token?
|
13
25
|
return redirect_to(login_url_with_optional_shop)
|
14
26
|
end
|
15
27
|
|
@@ -17,18 +29,31 @@ module ShopifyApp
|
|
17
29
|
install_scripttags
|
18
30
|
perform_after_authenticate_job
|
19
31
|
|
20
|
-
redirect_to
|
32
|
+
redirect_to(return_address)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def respond_with_error
|
39
|
+
if jwt_request?
|
40
|
+
head(:unauthorized)
|
21
41
|
else
|
22
42
|
flash[:error] = I18n.t('could_not_log_in')
|
23
43
|
redirect_to(login_url_with_optional_shop)
|
24
44
|
end
|
25
45
|
end
|
26
46
|
|
27
|
-
|
47
|
+
def redirect_for_user_token?
|
48
|
+
ShopifyApp::SessionRepository.user_storage.present? && user_session.blank?
|
49
|
+
end
|
28
50
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
51
|
+
def jwt_request?
|
52
|
+
jwt_shopify_domain || jwt_shopify_user_id
|
53
|
+
end
|
54
|
+
|
55
|
+
def valid_jwt_auth?
|
56
|
+
auth_hash && jwt_shopify_domain == shop_name && jwt_shopify_user_id == associated_user_id
|
32
57
|
end
|
33
58
|
|
34
59
|
def auth_hash
|
@@ -45,6 +70,10 @@ module ShopifyApp
|
|
45
70
|
auth_hash['extra']['associated_user']
|
46
71
|
end
|
47
72
|
|
73
|
+
def associated_user_id
|
74
|
+
associated_user && associated_user['id']
|
75
|
+
end
|
76
|
+
|
48
77
|
def token
|
49
78
|
auth_hash['credentials']['token']
|
50
79
|
end
|
@@ -63,9 +92,11 @@ module ShopifyApp
|
|
63
92
|
|
64
93
|
session[:shopify_user] = associated_user
|
65
94
|
if session[:shopify_user].present?
|
95
|
+
session[:shop_id] = nil if shop_session && shop_session.domain != shop_name
|
66
96
|
session[:user_id] = ShopifyApp::SessionRepository.store_user_session(session_store, associated_user)
|
67
97
|
else
|
68
98
|
session[:shop_id] = ShopifyApp::SessionRepository.store_shop_session(session_store)
|
99
|
+
session[:user_id] = nil if user_session && user_session.domain != shop_name
|
69
100
|
end
|
70
101
|
session[:shopify_domain] = shop_name
|
71
102
|
session[:user_session] = auth_hash&.extra&.session
|
@@ -2,19 +2,14 @@
|
|
2
2
|
|
3
3
|
module ShopifyApp
|
4
4
|
class ExtensionVerificationController < ActionController::Base
|
5
|
+
include ShopifyApp::PayloadVerification
|
5
6
|
protect_from_forgery with: :null_session
|
6
7
|
before_action :verify_request
|
7
8
|
|
8
9
|
private
|
9
10
|
|
10
11
|
def verify_request
|
11
|
-
|
12
|
-
request_body = request.body.read
|
13
|
-
secret = ShopifyApp.configuration.secret
|
14
|
-
digest = OpenSSL::Digest.new('sha256')
|
15
|
-
|
16
|
-
expected_hmac = Base64.strict_encode64(OpenSSL::HMAC.digest(digest, secret, request_body))
|
17
|
-
head(:unauthorized) unless ActiveSupport::SecurityUtils.secure_compare(expected_hmac, hmac_header)
|
12
|
+
head(:unauthorized) unless hmac_valid?(request.body.read)
|
18
13
|
end
|
19
14
|
end
|
20
15
|
end
|
@@ -1,5 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module ShopifyApp
|
2
|
-
class SessionsController < ActionController::Base
|
3
|
+
class SessionsController < ActionController::Base
|
3
4
|
include ShopifyApp::LoginProtection
|
4
5
|
|
5
6
|
layout false, only: :new
|
@@ -29,7 +30,7 @@ module ShopifyApp
|
|
29
30
|
shop: sanitized_shop_name,
|
30
31
|
return_to: params[:return_to]
|
31
32
|
),
|
32
|
-
current_shopify_domain: current_shopify_domain
|
33
|
+
current_shopify_domain: current_shopify_domain,
|
33
34
|
})
|
34
35
|
end
|
35
36
|
|
@@ -91,6 +92,7 @@ module ShopifyApp
|
|
91
92
|
end
|
92
93
|
end
|
93
94
|
|
95
|
+
# rubocop:disable Lint/SuppressedException
|
94
96
|
def set_user_tokens_option
|
95
97
|
if shop_session.blank?
|
96
98
|
session[:user_tokens] = false
|
@@ -110,6 +112,7 @@ module ShopifyApp
|
|
110
112
|
session[:user_tokens] = false
|
111
113
|
rescue StandardError
|
112
114
|
end
|
115
|
+
# rubocop:enable Lint/SuppressedException
|
113
116
|
|
114
117
|
def validate_shop_presence
|
115
118
|
@shop = sanitized_shop_name
|
@@ -122,12 +125,12 @@ module ShopifyApp
|
|
122
125
|
end
|
123
126
|
|
124
127
|
def copy_return_to_param_to_session
|
125
|
-
session[:return_to] = params[:return_to] if params[:return_to]
|
128
|
+
session[:return_to] = RedirectSafely.make_safe(params[:return_to], '/') if params[:return_to]
|
126
129
|
end
|
127
130
|
|
128
131
|
def render_invalid_shop_error
|
129
132
|
flash[:error] = I18n.t('invalid_shop_url')
|
130
|
-
redirect_to
|
133
|
+
redirect_to(return_address)
|
131
134
|
end
|
132
135
|
|
133
136
|
def enable_cookie_access
|
@@ -138,7 +141,7 @@ module ShopifyApp
|
|
138
141
|
end
|
139
142
|
|
140
143
|
def authenticate_in_context
|
141
|
-
redirect_to
|
144
|
+
redirect_to("#{main_app.root_path}auth/shopify")
|
142
145
|
end
|
143
146
|
|
144
147
|
def authenticate_at_top_level
|
@@ -173,7 +176,7 @@ module ShopifyApp
|
|
173
176
|
shop: sanitized_shop_name,
|
174
177
|
return_to: session[:return_to]
|
175
178
|
),
|
176
|
-
current_shopify_domain: current_shopify_domain
|
179
|
+
current_shopify_domain: current_shopify_domain,
|
177
180
|
}
|
178
181
|
)
|
179
182
|
end
|
@@ -1,14 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module ShopifyApp
|
3
|
+
class MissingWebhookJobError < StandardError; end
|
4
|
+
|
2
5
|
class WebhooksController < ActionController::Base
|
3
6
|
include ShopifyApp::WebhookVerification
|
4
7
|
|
5
|
-
class ShopifyApp::MissingWebhookJobError < StandardError; end
|
6
|
-
|
7
8
|
def receive
|
8
9
|
params.permit!
|
9
|
-
job_args = {shop_domain: shop_domain, webhook: webhook_params.to_h}
|
10
|
+
job_args = { shop_domain: shop_domain, webhook: webhook_params.to_h }
|
10
11
|
webhook_job_klass.perform_later(job_args)
|
11
|
-
head
|
12
|
+
head(:ok)
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
@@ -18,7 +19,7 @@ module ShopifyApp
|
|
18
19
|
end
|
19
20
|
|
20
21
|
def webhook_job_klass
|
21
|
-
webhook_job_klass_name.safe_constantize
|
22
|
+
webhook_job_klass_name.safe_constantize || raise(ShopifyApp::MissingWebhookJobError)
|
22
23
|
end
|
23
24
|
|
24
25
|
def webhook_job_klass_name(type = webhook_type)
|
data/config/locales/fi.yml
CHANGED
@@ -15,6 +15,6 @@ fi:
|
|
15
15
|
top_level_interaction_action: Jatka
|
16
16
|
request_storage_access_heading: "%{app} edellyttää evästeiden käyttöä"
|
17
17
|
request_storage_access_body: Näin sovellus voi todentaa sinut tallentamalla henkilötietosi
|
18
|
-
tilapäisesti.
|
18
|
+
tilapäisesti. Klikkaa Jatka ja salli evästeet sovelluksen käyttämiseksi.
|
19
19
|
request_storage_access_footer: Evästeet vanhenevat 30 päivän kuluttua.
|
20
20
|
request_storage_access_action: Jatka
|
data/config/locales/nl.yml
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
---
|
2
2
|
nl:
|
3
|
-
logged_out:
|
3
|
+
logged_out: Je bent afgemeld
|
4
4
|
could_not_log_in: Kon niet aanmelden bij Shopify-winkel
|
5
5
|
invalid_shop_url: Ongeldig winkeldomein
|
6
6
|
enable_cookies_heading: Schakel cookies in van %{app}
|
7
|
-
enable_cookies_body:
|
7
|
+
enable_cookies_body: Je moet cookies in deze browser handmatig inschakelen om %{app}
|
8
8
|
binnen Shopify te gebruiken.
|
9
|
-
enable_cookies_footer: Met cookies kan de app
|
9
|
+
enable_cookies_footer: Met cookies kan de app je verifiëren door je voorkeuren en
|
10
10
|
persoonlijke informatie tijdelijk op te slaan. Ze vervallen na 30 dagen.
|
11
11
|
enable_cookies_action: Schakel cookies in
|
12
|
-
top_level_interaction_heading:
|
13
|
-
top_level_interaction_body:
|
14
|
-
te vragen tot cookies voordat Shopify het voor
|
12
|
+
top_level_interaction_heading: Je browser moet %{app} verifiëren
|
13
|
+
top_level_interaction_body: Je browser heeft apps nodig zoals %{app} om je toegang
|
14
|
+
te vragen tot cookies voordat Shopify het voor je kan openen.
|
15
15
|
top_level_interaction_action: Doorgaan
|
16
16
|
request_storage_access_heading: "%{app} heeft toegang tot cookies nodig"
|
17
|
-
request_storage_access_body: Hiermee kan de app
|
17
|
+
request_storage_access_body: Hiermee kan de app je verifiëren door je persoonlijke
|
18
18
|
gegevens tijdelijk op te slaan. Klik op Doorgaan en sta cookies toe om de app
|
19
19
|
te gebruiken.
|
20
20
|
request_storage_access_footer: Cookies verlopen na 30 dagen.
|
data/config/routes.rb
CHANGED
data/docs/Quickstart.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
Quickstart
|
2
2
|
==========
|
3
3
|
|
4
|
-
Get started building and deploying a new Shopify App to Heroku in just a few minutes.
|
4
|
+
Get started building and deploying a new Shopify App to Heroku in just a few minutes.
|
5
|
+
This guide assumes you have Ruby, Rails and PostgreSQL installed on your computer already; if you haven't done that already start with [this guide.](https://guides.rubyonrails.org/v5.0/getting_started.html#installing-rails)
|
5
6
|
|
6
7
|
1. New Rails App (with postgres)
|
7
8
|
--------------------------------
|
@@ -26,15 +27,6 @@ Head to the Heroku dashboard and create a new app, or run the following commands
|
|
26
27
|
CLI:
|
27
28
|
```sh
|
28
29
|
$ heroku create name
|
29
|
-
$ heroku git:remote -a name
|
30
|
-
```
|
31
|
-
|
32
|
-
Once you have created an app on Heroku, we need to let Git know where the Heroku server is so we can deploy to it later. Copy the app's name from your Heroku dashboard and substitute `appname.git` with the name you chose earlier:
|
33
|
-
|
34
|
-
web:
|
35
|
-
```sh
|
36
|
-
# https://dashboard.heroku.com/new
|
37
|
-
$ git remote add heroku git@heroku.com:appname.git
|
38
30
|
```
|
39
31
|
|
40
32
|
3. Create a new App in the Shopify Partner dashboard
|
@@ -64,14 +56,13 @@ Generate the code for your app by running these commands:
|
|
64
56
|
|
65
57
|
```sh
|
66
58
|
# Use the keys from your app you created in the partners area
|
67
|
-
$ rails generate shopify_app
|
59
|
+
$ rails generate shopify_app
|
68
60
|
$ git add .
|
69
61
|
$ git commit -m 'generated shopify app'
|
70
62
|
```
|
71
63
|
|
72
|
-
|
73
|
-
|
74
|
-
We recommend adding a gem or utilizing environment variables (`.env`) to handle your keys before releasing your app. [Learn more about using environment variables.](https://www.honeybadger.io/blog/ruby-guide-environment-variables/)
|
64
|
+
Your API key and secret are read from environment variables. Refer to the main
|
65
|
+
README for further details on how to set this up.
|
75
66
|
|
76
67
|
6. Deploy your app
|
77
68
|
---------
|
data/docs/Releasing.md
CHANGED
@@ -3,6 +3,7 @@ Releasing ShopifyApp
|
|
3
3
|
1. Check the Semantic Versioning page for info on how to version the new release: http://semver.org
|
4
4
|
2. Create a pull request with the following changes:
|
5
5
|
* Update the version of ShopifyApp in lib/shopify_app/version.rb
|
6
|
+
* Update the version of shopify_app in package.json
|
6
7
|
* Add a CHANGELOG entry for the new release with the date
|
7
8
|
* Change the title of the PR to something like: "Packaging for release X.Y.Z"
|
8
9
|
3. Merge your pull request
|
data/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'rails/generators/base'
|
2
3
|
|
3
4
|
module ShopifyApp
|
@@ -6,7 +7,7 @@ module ShopifyApp
|
|
6
7
|
source_root File.expand_path('../templates', __FILE__)
|
7
8
|
|
8
9
|
hook_for :test_framework, as: :job, in: :rails do |instance, generator|
|
9
|
-
instance.invoke
|
10
|
+
instance.invoke(generator, [instance.send(:job_file_name)])
|
10
11
|
end
|
11
12
|
|
12
13
|
def init_after_authenticate_config
|
@@ -23,12 +24,13 @@ module ShopifyApp
|
|
23
24
|
)
|
24
25
|
|
25
26
|
unless initializer.include?(after_authenticate_job_config)
|
26
|
-
shell.say("Error adding after_authenticate_job to config. Add this line manually:
|
27
|
+
shell.say("Error adding after_authenticate_job to config. Add this line manually: "\
|
28
|
+
"#{after_authenticate_job_config}", :red)
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
32
|
def add_after_authenticate_job
|
31
|
-
template
|
33
|
+
template('after_authenticate_job.rb', "app/jobs/#{job_file_name}_job.rb")
|
32
34
|
end
|
33
35
|
|
34
36
|
private
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'rails/generators/base'
|
2
3
|
|
3
4
|
module ShopifyApp
|
@@ -6,7 +7,7 @@ module ShopifyApp
|
|
6
7
|
source_root File.expand_path('../templates', __FILE__)
|
7
8
|
|
8
9
|
def generate_app_extension
|
9
|
-
template
|
10
|
+
template("marketing_activities_controller.rb", "app/controllers/marketing_activities_controller.rb")
|
10
11
|
generate_routes
|
11
12
|
end
|
12
13
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class MarketingActivitiesController < ShopifyApp::ExtensionVerificationController
|
4
4
|
def preload_form_data
|
5
5
|
preload_data = {
|
6
|
-
"form_data": {}
|
6
|
+
"form_data": {},
|
7
7
|
}
|
8
8
|
render(json: preload_data, status: :ok)
|
9
9
|
end
|
@@ -31,14 +31,14 @@ class MarketingActivitiesController < ShopifyApp::ExtensionVerificationControlle
|
|
31
31
|
"preview_url": placeholder_img,
|
32
32
|
"content_type": "text/html",
|
33
33
|
"width": 360,
|
34
|
-
"height": 200
|
34
|
+
"height": 200,
|
35
35
|
},
|
36
36
|
"mobile": {
|
37
37
|
"preview_url": placeholder_img,
|
38
38
|
"content_type": "text/html",
|
39
39
|
"width": 360,
|
40
|
-
"height": 200
|
41
|
-
}
|
40
|
+
"height": 200,
|
41
|
+
},
|
42
42
|
}
|
43
43
|
render(json: preview_response, status: :ok)
|
44
44
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'rails/generators/base'
|
2
3
|
|
3
4
|
module ShopifyApp
|
@@ -8,7 +9,7 @@ module ShopifyApp
|
|
8
9
|
class_option :address, type: :string, aliases: "-a", required: true
|
9
10
|
|
10
11
|
hook_for :test_framework, as: :job, in: :rails do |instance, generator|
|
11
|
-
instance.invoke
|
12
|
+
instance.invoke(generator, [instance.send(:job_file_name)])
|
12
13
|
end
|
13
14
|
|
14
15
|
def init_webhook_config
|
@@ -32,14 +33,14 @@ module ShopifyApp
|
|
32
33
|
initializer = load_initializer
|
33
34
|
|
34
35
|
unless initializer.include?(webhook_config)
|
35
|
-
shell.say
|
36
|
+
shell.say("Error adding webhook to config. Add this line manually: #{webhook_config}", :red)
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
40
|
def add_webhook_job
|
40
41
|
@job_file_name = job_file_name + '_job'
|
41
|
-
@job_class_name
|
42
|
-
template
|
42
|
+
@job_class_name = @job_file_name.classify
|
43
|
+
template('webhook_job.rb', "app/jobs/#{@job_file_name}.rb")
|
43
44
|
end
|
44
45
|
|
45
46
|
private
|