shopify_app 7.3.0 → 7.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7ac19c7d6dc8350502dfc1a432ecdab6292305f
4
- data.tar.gz: 0d46aaddf9e228435f64ffba054cc8066f2ac048
3
+ metadata.gz: b534fe893fb126d699a8e2a0908cc06aab2ea3e9
4
+ data.tar.gz: 7da8663a89439030d2198be0f4d09e947d68ae63
5
5
  SHA512:
6
- metadata.gz: 636b704eaee4e2b522b628cf99677073b4c2d1b161689e80f483652203ab0a1420c209093e691e3ad244f256f404020909e850c5cbe76f113816f67ae7695900
7
- data.tar.gz: 3e35b142261e9b6e8aad531fec7d5a55027ab36d45dd7fe4a2f67d0bc9f6ad9dcfb01a832c22dfa1ddb80924df01afb814217ef4889329622cf6483c9ff327d9
6
+ metadata.gz: 189dfc0d53bd7eae968b3270151b00a363a9ecd964b38cbabd378824156fa2eaf5aecb93c9932b1fa3fde2323bd35c9a8fcddec3f8b62b2c02cd6bd2001c8e1f
7
+ data.tar.gz: 9e11244536e4039e59b1170ab3fcf9717f9f0e53036dbd791cf30e72279d95737cb640cee2a19736e9e74da380c1209a49446aeb32cb2223baf36fe28e8eabcd
File without changes
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ 7.4.0
2
+ -----
3
+ * Add an after_authenticate job which will be run once the shop is authenticated. [[#431]](https://github.com/Shopify/shopify_app/pull/432)
4
+
1
5
  7.3.0
2
6
  -----
3
7
  * Bump required omniauth-shopify-oauth2 version to 1.2.0.
data/README.md CHANGED
@@ -27,6 +27,7 @@ Table of Contents
27
27
  * [**Managing Api Keys**](#managing-api-keys)
28
28
  * [**WebhooksManager**](#webhooksmanager)
29
29
  * [**ScripttagsManager**](#scripttagsmanager)
30
+ * [**AfterAuthenticate Job**](#afterauthenticate-job)
30
31
  * [**ShopifyApp::SessionRepository**](#shopifyappsessionrepository)
31
32
  * [**AuthenticatedController**](#authenticatedcontroller)
32
33
  * [**AppProxyVerification**](#appproxyverification)
@@ -54,7 +55,7 @@ Check out this screencast on how to create and deploy a new Shopify App to Herok
54
55
 
55
56
  [https://vimeo.com/130247240](https://vimeo.com/130247240)
56
57
 
57
- Or if you prefer text instructions the steps in the video are written out [here](https://github.com/Shopify/shopify_app/blob/master/QUICKSTART.md)
58
+ Or if you prefer text instructions the steps in the video are written out [here](https://github.com/Shopify/shopify_app/blob/master/docs/Quickstart.md)
58
59
 
59
60
  Becoming a Shopify App Developer
60
61
  --------------------------------
@@ -185,10 +186,18 @@ Mounting the Engine will provide the basic routes to authenticating a shop with
185
186
  The default routes of the Shopify rails engine, which is mounted to the root, can be altered to mount on a different route. The `config/routes.rb` can be modified to put these under a nested route (say `/app-name`) as:
186
187
 
187
188
  ```ruby
188
- mount ShopifyApp::Engine, at: '/app-name'
189
+ mount ShopifyApp::Engine, at: '/nested'
189
190
  ```
190
191
 
191
- This will create the Shopify engine routes under the specified Subdirectory, as a result it will redirect new consumers to `/app-name/login` and following a similar format for the other engine routes.
192
+ This will create the Shopify engine routes under the specified subpath, as a result it will redirect new consumers to `/nested/login`. If you mount the engine at a subpath you'll also need to update the omniauth initializer to include a custom `callback_path` e.g:
193
+
194
+ ```ruby
195
+ provider :shopify,
196
+ ShopifyApp.configuration.api_key,
197
+ ShopifyApp.configuration.secret,
198
+ scope: ShopifyApp.configuration.scope,
199
+ callback_path: '/nested/auth/shopify/callback'
200
+ ```
192
201
 
193
202
  To use named routes with the engine so that it can route between the application and the engine's routes it should be prefixed with `main_app` or `shopify_app`.
194
203
 
@@ -290,6 +299,31 @@ Scripttags are created in the same way as the Webhooks, with a background job wh
290
299
 
291
300
  If `src` responds to `call` its return value will be used as the scripttag's source. It will be called on scripttag creation and deletion.
292
301
 
302
+ AfterAuthenticate Job
303
+ ---------------------
304
+
305
+ If your app needs to perform specific actions after it is installed ShopifyApp can queue or run a job of your choosing (note that we already provide support for automatically creating Webhooks and Scripttags). To configure the after authenticate job update your initializer as follows:
306
+
307
+ ```ruby
308
+ ShopifyApp.configure do |config|
309
+ config.add_after_authenticate_job = { job: Shopify::AfterAuthenticateJob }
310
+ end
311
+ ```
312
+
313
+ If you need the job to run synchronously add the `inline` flag:
314
+
315
+ ```ruby
316
+ ShopifyApp.configure do |config|
317
+ config.add_after_authenticate_job = { job: Shopify::AfterAuthenticateJob, inline: true }
318
+ end
319
+ ```
320
+
321
+ We've also provided a generator which creates a skeleton job and updates the initializer for you:
322
+
323
+ ```
324
+ bin/rails g shopify_app:add_after_authenticate_job
325
+ ```
326
+
293
327
  ShopifyApp::SessionRepository
294
328
  -----------------------------
295
329
 
@@ -326,7 +360,7 @@ Create your app proxy url in the [Shopify Partners' Dashboard](https://app.shopi
326
360
  Troubleshooting
327
361
  ---------------
328
362
 
329
- see [TROUBLESHOOTING.md](TROUBLESHOOTING.md)
363
+ see [TROUBLESHOOTING.md](https://github.com/Shopify/shopify_app/blob/master/docs/Troubleshooting.md)
330
364
 
331
365
  Testing an embedded app outside the Shopify admin
332
366
  -------------------------------------------------
File without changes
File without changes
File without changes
@@ -0,0 +1,43 @@
1
+ require 'rails/generators/base'
2
+
3
+ module ShopifyApp
4
+ module Generators
5
+ class AddAfterAuthenticateJobGenerator < Rails::Generators::Base
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ hook_for :test_framework, as: :job, in: :rails do |instance, generator|
9
+ instance.invoke generator, [ instance.send(:job_file_name) ]
10
+ end
11
+
12
+ def init_after_authenticate_config
13
+ initializer = load_initializer
14
+
15
+ after_authenticate_job_config = " config.after_authenticate_job = { job: Shopify::AfterAuthenticateJob, inline: false }\n"
16
+
17
+ inject_into_file(
18
+ 'config/initializers/shopify_app.rb',
19
+ after_authenticate_job_config,
20
+ before: 'end'
21
+ )
22
+
23
+ unless initializer.include?(after_authenticate_job_config)
24
+ shell.say "Error adding after_authneticate_job to config. Add this line manually: #{after_authenticate_job_config}", :red
25
+ end
26
+ end
27
+
28
+ def add_after_authenticate_job
29
+ template 'after_authenticate_job.rb', "app/jobs/#{job_file_name}_job.rb"
30
+ end
31
+
32
+ private
33
+
34
+ def load_initializer
35
+ File.read(File.join(destination_root, 'config/initializers/shopify_app.rb'))
36
+ end
37
+
38
+ def job_file_name
39
+ 'shopify/after_authenticate'
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,10 @@
1
+ module Shopify
2
+ class AfterAuthenticateJob < ActiveJob::Base
3
+ def perform(shop_domain:)
4
+ shop = Shop.find_by(shopify_domain: shop_domain)
5
+
6
+ shop.with_shopify_session do
7
+ end
8
+ end
9
+ end
10
+ end
@@ -4,4 +4,5 @@ ShopifyApp.configure do |config|
4
4
  config.secret = "<%= @secret %>"
5
5
  config.scope = "<%= @scope %>"
6
6
  config.embedded_app = <%= embedded_app? %>
7
+ config.after_authenticate_job = false
7
8
  end
@@ -12,6 +12,7 @@ module ShopifyApp
12
12
  alias_method :embedded_app?, :embedded_app
13
13
  attr_accessor :webhooks
14
14
  attr_accessor :scripttags
15
+ attr_accessor :after_authenticate_job
15
16
 
16
17
  # customise ActiveJob queue names
17
18
  attr_accessor :scripttags_manager_queue_name
@@ -20,6 +20,7 @@ module ShopifyApp
20
20
  login_shop
21
21
  install_webhooks
22
22
  install_scripttags
23
+ perform_after_authenticate_job
23
24
 
24
25
  redirect_to return_address
25
26
  else
@@ -87,5 +88,16 @@ module ShopifyApp
87
88
  session.delete(:return_to) || main_app.root_url
88
89
  end
89
90
 
91
+ def perform_after_authenticate_job
92
+ config = ShopifyApp.configuration.after_authenticate_job
93
+
94
+ return unless config && config[:job].present?
95
+
96
+ if config[:inline] == true
97
+ config[:job].perform_now(shop_domain: session[:shopify_domain])
98
+ else
99
+ config[:job].perform_later(shop_domain: session[:shopify_domain])
100
+ end
101
+ end
90
102
  end
91
103
  end
@@ -1,3 +1,3 @@
1
1
  module ShopifyApp
2
- VERSION = '7.3.0'
2
+ VERSION = '7.4.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.3.0
4
+ version: 7.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-18 00:00:00.000000000 Z
11
+ date: 2017-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -128,17 +128,14 @@ executables: []
128
128
  extensions: []
129
129
  extra_rdoc_files: []
130
130
  files:
131
+ - ".github/ISSUE_TEMPLATE.md"
131
132
  - ".gitignore"
132
133
  - ".travis.yml"
133
134
  - CHANGELOG.md
134
135
  - Gemfile
135
- - ISSUE_TEMPLATE.md
136
136
  - LICENSE
137
- - QUICKSTART.md
138
137
  - README.md
139
- - RELEASING
140
138
  - Rakefile
141
- - TROUBLESHOOTING.md
142
139
  - app/controllers/shopify_app/authenticated_controller.rb
143
140
  - app/controllers/shopify_app/sessions_controller.rb
144
141
  - app/controllers/shopify_app/webhooks_controller.rb
@@ -149,7 +146,12 @@ files:
149
146
  - config/locales/fr.yml
150
147
  - config/locales/ja.yml
151
148
  - config/routes.rb
149
+ - docs/Quickstart.md
150
+ - docs/Releasing.md
151
+ - docs/Troubleshooting.md
152
152
  - images/app-proxy-screenshot.png
153
+ - lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb
154
+ - lib/generators/shopify_app/add_after_authenticate_job/templates/after_authenticate_job.rb
153
155
  - lib/generators/shopify_app/add_webhook/add_webhook_generator.rb
154
156
  - lib/generators/shopify_app/add_webhook/templates/webhook_job.rb
155
157
  - lib/generators/shopify_app/app_proxy_controller/app_proxy_controller_generator.rb