shopify_app 13.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. checksums.yaml +7 -0
  2. data/.babelrc +5 -0
  3. data/.github/CODEOWNERS +1 -0
  4. data/.github/ISSUE_TEMPLATE.md +14 -0
  5. data/.github/PULL_REQUEST_TEMPLATE.md +6 -0
  6. data/.github/probots.yml +2 -0
  7. data/.github/workflows/rubocop.yml +28 -0
  8. data/.gitignore +16 -0
  9. data/.nvmrc +1 -0
  10. data/.rubocop.yml +17 -0
  11. data/.ruby-version +1 -0
  12. data/.travis.yml +28 -0
  13. data/CHANGELOG.md +505 -0
  14. data/Gemfile +11 -0
  15. data/LICENSE +19 -0
  16. data/README.md +620 -0
  17. data/Rakefile +7 -0
  18. data/SECURITY.md +59 -0
  19. data/app/assets/images/storage_access.svg +2 -0
  20. data/app/assets/javascripts/shopify_app/enable_cookies.js +3 -0
  21. data/app/assets/javascripts/shopify_app/itp_helper.js +40 -0
  22. data/app/assets/javascripts/shopify_app/partition_cookies.js +8 -0
  23. data/app/assets/javascripts/shopify_app/redirect.js +33 -0
  24. data/app/assets/javascripts/shopify_app/request_storage_access.js +3 -0
  25. data/app/assets/javascripts/shopify_app/storage_access.js +153 -0
  26. data/app/assets/javascripts/shopify_app/storage_access_redirect.js +17 -0
  27. data/app/assets/javascripts/shopify_app/top_level.js +2 -0
  28. data/app/assets/javascripts/shopify_app/top_level_interaction.js +11 -0
  29. data/app/controllers/concerns/shopify_app/authenticated.rb +16 -0
  30. data/app/controllers/concerns/shopify_app/require_known_shop.rb +39 -0
  31. data/app/controllers/shopify_app/authenticated_controller.rb +8 -0
  32. data/app/controllers/shopify_app/callback_controller.rb +140 -0
  33. data/app/controllers/shopify_app/extension_verification_controller.rb +15 -0
  34. data/app/controllers/shopify_app/sessions_controller.rb +184 -0
  35. data/app/controllers/shopify_app/webhooks_controller.rb +37 -0
  36. data/app/views/shopify_app/partials/_button_styles.html.erb +104 -0
  37. data/app/views/shopify_app/partials/_card_styles.html.erb +33 -0
  38. data/app/views/shopify_app/partials/_empty_state_styles.html.erb +129 -0
  39. data/app/views/shopify_app/partials/_layout_styles.html.erb +167 -0
  40. data/app/views/shopify_app/partials/_typography_styles.html.erb +35 -0
  41. data/app/views/shopify_app/sessions/enable_cookies.html.erb +75 -0
  42. data/app/views/shopify_app/sessions/new.html.erb +123 -0
  43. data/app/views/shopify_app/sessions/request_storage_access.html.erb +68 -0
  44. data/app/views/shopify_app/sessions/top_level_interaction.html.erb +64 -0
  45. data/app/views/shopify_app/shared/redirect.html.erb +23 -0
  46. data/config/locales/cs.yml +23 -0
  47. data/config/locales/da.yml +20 -0
  48. data/config/locales/de.yml +22 -0
  49. data/config/locales/en.yml +15 -0
  50. data/config/locales/es.yml +22 -0
  51. data/config/locales/fi.yml +20 -0
  52. data/config/locales/fr.yml +23 -0
  53. data/config/locales/hi.yml +23 -0
  54. data/config/locales/it.yml +21 -0
  55. data/config/locales/ja.yml +17 -0
  56. data/config/locales/ko.yml +19 -0
  57. data/config/locales/ms.yml +22 -0
  58. data/config/locales/nb.yml +21 -0
  59. data/config/locales/nl.yml +21 -0
  60. data/config/locales/pl.yml +21 -0
  61. data/config/locales/pt-BR.yml +21 -0
  62. data/config/locales/pt-PT.yml +22 -0
  63. data/config/locales/sv.yml +21 -0
  64. data/config/locales/th.yml +20 -0
  65. data/config/locales/tr.yml +22 -0
  66. data/config/locales/zh-CN.yml +16 -0
  67. data/config/locales/zh-TW.yml +16 -0
  68. data/config/routes.rb +23 -0
  69. data/docs/Quickstart.md +93 -0
  70. data/docs/Releasing.md +18 -0
  71. data/docs/Troubleshooting.md +16 -0
  72. data/docs/install-on-dev-shop.png +0 -0
  73. data/docs/test-your-app.png +0 -0
  74. data/images/app-proxy-screenshot.png +0 -0
  75. data/karma.conf.js +44 -0
  76. data/lib/generators/shopify_app/add_after_authenticate_job/add_after_authenticate_job_generator.rb +47 -0
  77. data/lib/generators/shopify_app/add_after_authenticate_job/templates/after_authenticate_job.rb +11 -0
  78. data/lib/generators/shopify_app/add_marketing_activity_extension/add_marketing_activity_extension_generator.rb +40 -0
  79. data/lib/generators/shopify_app/add_marketing_activity_extension/templates/marketing_activities_controller.rb +62 -0
  80. data/lib/generators/shopify_app/add_webhook/add_webhook_generator.rb +69 -0
  81. data/lib/generators/shopify_app/add_webhook/templates/webhook_job.rb.tt +13 -0
  82. data/lib/generators/shopify_app/app_proxy_controller/app_proxy_controller_generator.rb +26 -0
  83. data/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_controller.rb +8 -0
  84. data/lib/generators/shopify_app/app_proxy_controller/templates/app_proxy_route.rb +11 -0
  85. data/lib/generators/shopify_app/app_proxy_controller/templates/index.html.erb +19 -0
  86. data/lib/generators/shopify_app/authenticated_controller/authenticated_controller_generator.rb +15 -0
  87. data/lib/generators/shopify_app/authenticated_controller/templates/authenticated_controller.rb +5 -0
  88. data/lib/generators/shopify_app/controllers/controllers_generator.rb +30 -0
  89. data/lib/generators/shopify_app/home_controller/home_controller_generator.rb +26 -0
  90. data/lib/generators/shopify_app/home_controller/templates/home_controller.rb +8 -0
  91. data/lib/generators/shopify_app/home_controller/templates/index.html.erb +21 -0
  92. data/lib/generators/shopify_app/install/install_generator.rb +83 -0
  93. data/lib/generators/shopify_app/install/templates/_flash_messages.html.erb +3 -0
  94. data/lib/generators/shopify_app/install/templates/embedded_app.html.erb +41 -0
  95. data/lib/generators/shopify_app/install/templates/flash_messages.js +24 -0
  96. data/lib/generators/shopify_app/install/templates/omniauth.rb +3 -0
  97. data/lib/generators/shopify_app/install/templates/session_store.rb +4 -0
  98. data/lib/generators/shopify_app/install/templates/shopify_app.js +15 -0
  99. data/lib/generators/shopify_app/install/templates/shopify_app.rb.tt +15 -0
  100. data/lib/generators/shopify_app/install/templates/shopify_app_index.js +2 -0
  101. data/lib/generators/shopify_app/install/templates/shopify_provider.rb +20 -0
  102. data/lib/generators/shopify_app/install/templates/user_agent.rb +6 -0
  103. data/lib/generators/shopify_app/rotate_shopify_token_job/rotate_shopify_token_job_generator.rb +16 -0
  104. data/lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token.rake +17 -0
  105. data/lib/generators/shopify_app/rotate_shopify_token_job/templates/rotate_shopify_token_job.rb +42 -0
  106. data/lib/generators/shopify_app/routes/routes_generator.rb +32 -0
  107. data/lib/generators/shopify_app/routes/templates/routes.rb +12 -0
  108. data/lib/generators/shopify_app/shop_model/shop_model_generator.rb +43 -0
  109. data/lib/generators/shopify_app/shop_model/templates/db/migrate/create_shops.erb +15 -0
  110. data/lib/generators/shopify_app/shop_model/templates/shop.rb +8 -0
  111. data/lib/generators/shopify_app/shop_model/templates/shops.yml +3 -0
  112. data/lib/generators/shopify_app/shopify_app_generator.rb +18 -0
  113. data/lib/generators/shopify_app/user_model/templates/db/migrate/create_users.erb +16 -0
  114. data/lib/generators/shopify_app/user_model/templates/user.rb +8 -0
  115. data/lib/generators/shopify_app/user_model/templates/users.yml +4 -0
  116. data/lib/generators/shopify_app/user_model/user_model_generator.rb +43 -0
  117. data/lib/generators/shopify_app/views/views_generator.rb +30 -0
  118. data/lib/shopify_app.rb +61 -0
  119. data/lib/shopify_app/configuration.rb +94 -0
  120. data/lib/shopify_app/controller_concerns/app_proxy_verification.rb +38 -0
  121. data/lib/shopify_app/controller_concerns/csrf_protection.rb +15 -0
  122. data/lib/shopify_app/controller_concerns/embedded_app.rb +20 -0
  123. data/lib/shopify_app/controller_concerns/itp.rb +45 -0
  124. data/lib/shopify_app/controller_concerns/localization.rb +23 -0
  125. data/lib/shopify_app/controller_concerns/login_protection.rb +231 -0
  126. data/lib/shopify_app/controller_concerns/payload_verification.rb +24 -0
  127. data/lib/shopify_app/controller_concerns/webhook_verification.rb +23 -0
  128. data/lib/shopify_app/engine.rb +25 -0
  129. data/lib/shopify_app/jobs/scripttags_manager_job.rb +16 -0
  130. data/lib/shopify_app/jobs/webhooks_manager_job.rb +16 -0
  131. data/lib/shopify_app/managers/scripttags_manager.rb +78 -0
  132. data/lib/shopify_app/managers/webhooks_manager.rb +62 -0
  133. data/lib/shopify_app/middleware/jwt_middleware.rb +42 -0
  134. data/lib/shopify_app/middleware/same_site_cookie_middleware.rb +34 -0
  135. data/lib/shopify_app/session/in_memory_session_store.rb +31 -0
  136. data/lib/shopify_app/session/in_memory_shop_session_store.rb +14 -0
  137. data/lib/shopify_app/session/in_memory_user_session_store.rb +14 -0
  138. data/lib/shopify_app/session/jwt.rb +61 -0
  139. data/lib/shopify_app/session/null_user_session_store.rb +22 -0
  140. data/lib/shopify_app/session/session_repository.rb +56 -0
  141. data/lib/shopify_app/session/session_storage.rb +20 -0
  142. data/lib/shopify_app/session/shop_session_storage.rb +42 -0
  143. data/lib/shopify_app/session/user_session_storage.rb +42 -0
  144. data/lib/shopify_app/test_helpers/all.rb +2 -0
  145. data/lib/shopify_app/test_helpers/webhook_verification_helper.rb +17 -0
  146. data/lib/shopify_app/utils.rb +24 -0
  147. data/lib/shopify_app/version.rb +4 -0
  148. data/package-lock.json +7177 -0
  149. data/package.json +28 -0
  150. data/service.yml +7 -0
  151. data/shipit.rubygems.yml +4 -0
  152. data/shopify_app.gemspec +37 -0
  153. data/translation.yml +7 -0
  154. data/webpack.config.js +24 -0
  155. data/yarn.lock +5263 -0
  156. metadata +420 -0
@@ -0,0 +1,22 @@
1
+ ---
2
+ pt-PT:
3
+ logged_out: Terminou a sessão com sucesso
4
+ could_not_log_in: Não foi possível iniciar sessão na loja da Shopify
5
+ invalid_shop_url: Domínio de loja inválido
6
+ enable_cookies_heading: Ativar cookies de %{app}
7
+ enable_cookies_body: Tem de ativar manualmente os cookies neste navegador para utilizar
8
+ %{app} dentro da Shopify.
9
+ enable_cookies_footer: Os cookies permitem que a aplicação o autentique armazenando
10
+ temporariamente as suas preferências e informações pessoais. Expiram ao fim de
11
+ 30 dias.
12
+ enable_cookies_action: Ativar cookies
13
+ top_level_interaction_heading: O seu navegador tem de autenticar %{app}
14
+ top_level_interaction_body: O seu navegador exige que aplicações como %{app} lhe
15
+ solicitem o acesso de cookies, antes que a Shopify as possa abrir.
16
+ top_level_interaction_action: Continuar
17
+ request_storage_access_heading: "%{app} tem de aceder a cookies"
18
+ request_storage_access_body: Isto permite que a aplicação o autentique armazenando
19
+ temporariamente as suas informações pessoais. Clique em continuar e permita os
20
+ cookies para utilizar a aplicação.
21
+ request_storage_access_footer: Os cookies expiram ao fim de 30 dias.
22
+ request_storage_access_action: Continuar
@@ -0,0 +1,21 @@
1
+ ---
2
+ sv:
3
+ logged_out: Har loggats ut
4
+ could_not_log_in: Det gick inte att logga in i Shopify-butiken
5
+ invalid_shop_url: Ogiltig butiksdomän
6
+ enable_cookies_heading: Aktivera cookies från %{app}
7
+ enable_cookies_body: Du måste aktivera cookies manuellt i den här webbläsaren för
8
+ att kunna använda %{app} inom Shopify.
9
+ enable_cookies_footer: Cookies låter appen autentisera dig genom att tillfälligt
10
+ lagra dina inställningar och personuppgifter. De upphör efter 30 dagar.
11
+ enable_cookies_action: Aktivera cookies
12
+ top_level_interaction_heading: Din webbläsare måste verifiera %{app}
13
+ top_level_interaction_body: Din webbläsare kräver att appar som %{app} frågar dig
14
+ om tillgång till cookies innan Shopify kan öppna den för dig.
15
+ top_level_interaction_action: Fortsätt
16
+ request_storage_access_heading: "%{app} behöver tillgång till cookies"
17
+ request_storage_access_body: Detta gör det möjligt för appen att autentisera dig
18
+ genom att tillfälligt lagra din personliga information. Klicka på fortsätt och
19
+ tillåta cookies att använda appen.
20
+ request_storage_access_footer: Cookies upphör efter 30 dagar.
21
+ request_storage_access_action: Fortsätt
@@ -0,0 +1,20 @@
1
+ ---
2
+ th:
3
+ logged_out: ออกจากระบบสำเร็จ
4
+ could_not_log_in: ไม่สามารถเข้าสู่ระบบร้านค้า Shopify ได้
5
+ invalid_shop_url: โดเมนร้านค้าไม่ถูกต้อง
6
+ enable_cookies_heading: เปิดใช้งานคุกกี้จาก %{app}
7
+ enable_cookies_body: คุณต้องเปิดใช้งานคุกกี้ด้วยตนเองในเบราว์เซอร์นี้เพื่อใช้งาน
8
+ %{app} ภายใน Shopify
9
+ enable_cookies_footer: คุกกี้ช่วยให้แอปตรวจสอบความถูกต้องของคุณด้วยการจัดเก็บความชื่นชอบและข้อมูลส่วนตัวของคุณชั่วคราว
10
+ คุกกี้จะหมดอายุหลังจาก 30 วัน
11
+ enable_cookies_action: เปิดใช้งานคุกกี้
12
+ top_level_interaction_heading: เบราว์เซอร์ของคุณต้องรับรองความถูกต้องของ %{app}
13
+ top_level_interaction_body: เบราว์เซอร์ของคุณต้องการแอปอย่าง %{app} เพื่อขอให้คุณเข้าถึงคุกกี้ก่อนที่
14
+ Shopify จะสามารถเปิดมันให้คุณได้
15
+ top_level_interaction_action: ดำเนินการต่อ
16
+ request_storage_access_heading: "%{app} ต้องการสิทธิ์การเข้าถึงคุกกี้"
17
+ request_storage_access_body: สิ่งนี้ช่วยให้แอปตรวจสอบความถูกต้องของคุณด้วยการจัดเก็บข้อมูลส่วนตัวของคุณชั่วคราว
18
+ คลิกดำเนินการต่อและอนุญาตให้คุกกี้ใช้แอป
19
+ request_storage_access_footer: คุกกี้จะหมดอายุหลังจาก 30 วัน
20
+ request_storage_access_action: ดำเนินการต่อ
@@ -0,0 +1,22 @@
1
+ ---
2
+ tr:
3
+ logged_out: Oturum başarıyla kapatıldı
4
+ could_not_log_in: Shopify mağazasında oturum açılamadı
5
+ invalid_shop_url: Geçersiz mağaza alan adı
6
+ enable_cookies_heading: "%{app} uygulamasından çerezleri etkinleştir"
7
+ enable_cookies_body: "%{app} uygulamasını Shopify içinde kullanabilmek için bu tarayıcıda
8
+ çerezleri manuel olarak etkinleştirmelisiniz."
9
+ enable_cookies_footer: Çerezler, tercihlerinizi ve kişisel bilgilerinizi geçici
10
+ olarak saklayıp uygulamanın kimliğinizi doğrulamasına imkan tanır. Çerezlerin
11
+ süresi 30 gün sonra sonra sona erer.
12
+ enable_cookies_action: Çerezleri etkinleştir
13
+ top_level_interaction_heading: Tarayıcınızın %{app} kimliğini doğrulaması gerekiyor
14
+ top_level_interaction_body: Tarayıcınız, Shopify tarafından açılmadan önce %{app}
15
+ gibi uygulamaların sizden çerezlere erişim izni istemesini zorunlu tutuyor.
16
+ top_level_interaction_action: Devam
17
+ request_storage_access_heading: "%{app} uygulamasının çerezlere erişmesi gerekiyor"
18
+ request_storage_access_body: Böylece uygulama, kişisel bilgilerinizi geçici olarak
19
+ saklayıp kimliğinizi doğrulayabilir. Devam et'e tıklayın ve çerezlerin uygulamayı
20
+ kullanmasına izin verin.
21
+ request_storage_access_footer: Çerezlerin süresi 30 gün sonra sonra sona erer.
22
+ request_storage_access_action: Devam
@@ -0,0 +1,16 @@
1
+ ---
2
+ zh-CN:
3
+ logged_out: 已成功退出
4
+ could_not_log_in: 无法登录到 Shopify 商店
5
+ invalid_shop_url: 商店域名无效
6
+ enable_cookies_heading: 从 %{app} 启用 Cookie
7
+ enable_cookies_body: 您必须在此浏览器中手动启用 Cookie 才能在 Shopify 中使用 %{app}。
8
+ enable_cookies_footer: Cookie 使此应用能够通过暂时存储您的偏好设置和个人信息来验证您的身份。这些信息将在 30 天后过期。
9
+ enable_cookies_action: 启用 Cookie
10
+ top_level_interaction_heading: 您的浏览器需要对 %{app} 进行验证
11
+ top_level_interaction_body: 您的浏览器要求类似 %{app} 的应用向您请求访问 Cookie,之后 Shopify 才能为您打开它。
12
+ top_level_interaction_action: 继续
13
+ request_storage_access_heading: "%{app} 需要访问 Cookie"
14
+ request_storage_access_body: 这使此应用能够通过暂时存储您的个人信息来验证您的身份。单击继续并启用 Cookie 以使用此应用。
15
+ request_storage_access_footer: Cookie 将在 30 天后过期。
16
+ request_storage_access_action: 继续
@@ -0,0 +1,16 @@
1
+ ---
2
+ zh-TW:
3
+ logged_out: 登出成功
4
+ could_not_log_in: 無法登入 Shopify 商店
5
+ invalid_shop_url: 商店網域無效
6
+ enable_cookies_heading: 啟用 %{app} 的 Cookie
7
+ enable_cookies_body: 您必須在此瀏覽器中手動啟用 Cookie,才能夠在 Shopify 使用 %{app}。
8
+ enable_cookies_footer: Cookie 可讓應用程式暫時儲存您的偏好設定和個人資訊,藉此驗證您的身分,這些資料會在 30 天後失效。
9
+ enable_cookies_action: 啟用 Cookie
10
+ top_level_interaction_heading: 您的瀏覽器需要驗證 %{app}
11
+ top_level_interaction_body: 您的瀏覽器要求 %{app} 等應用程式向您請求 Cookie 的存取權限,才能讓 Shopify 為您開啟該應用程式。
12
+ top_level_interaction_action: 繼續
13
+ request_storage_access_heading: "%{app} 需要 Cookie 存取權限"
14
+ request_storage_access_body: Cookie 可讓應用程式暫時儲存您的個人資訊,藉此驗證您的身分。按一下繼續並允許 Cookie 使用此應用程式。
15
+ request_storage_access_footer: Cookie 將於 30 天後失效。
16
+ request_storage_access_action: 繼續
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+ ShopifyApp::Engine.routes.draw do
3
+ controller :sessions do
4
+ get 'login' => :new, :as => :login
5
+ post 'login' => :create, :as => :authenticate
6
+ get 'enable_cookies' => :enable_cookies, :as => :enable_cookies
7
+ get 'top_level_interaction' =>
8
+ :top_level_interaction,
9
+ :as => :top_level_interaction
10
+ get 'granted_storage_access' =>
11
+ :granted_storage_access,
12
+ :as => :granted_storage_access
13
+ get 'logout' => :destroy, :as => :logout
14
+ end
15
+
16
+ controller :callback do
17
+ get 'auth/shopify/callback' => :callback
18
+ end
19
+
20
+ namespace :webhooks do
21
+ post ':type' => :receive
22
+ end
23
+ end
@@ -0,0 +1,93 @@
1
+ Quickstart
2
+ ==========
3
+
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)
6
+
7
+ 1. New Rails App (with postgres)
8
+ --------------------------------
9
+
10
+ To create a new Rails app and use this generator, open your terminal and run the following commands:
11
+
12
+ ```sh
13
+ $ rails new test-app --database=postgresql
14
+ $ cd test-app
15
+ $ git init
16
+ $ git add .
17
+ $ git commit -m 'new rails app'
18
+ ```
19
+
20
+ 2. Create a new Heroku app
21
+ --------------------------
22
+
23
+ The next step is to create a new Heroku app to host your application. If you haven't got a Heroku account yet, create a free account [here](https://www.heroku.com/).
24
+
25
+ Head to the Heroku dashboard and create a new app, or run the following commands with the [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli#download-and-install) installed, substituting `name` for the name of your own app:
26
+
27
+ CLI:
28
+ ```sh
29
+ $ heroku create name
30
+ ```
31
+
32
+ 3. Create a new App in the Shopify Partner dashboard
33
+ -----------------------------------------
34
+ * Create a Shopify app in the [Partners dashboard](https://partner.shopify.com). For this tutorial, you can choose either a public or custom app, but you can [learn about App Types here.](https://help.shopify.com/en/manual/apps/app-types)
35
+ [https://app.shopify.com/services/partners/api_clients](https://app.shopify.com/services/partners/api_clients)
36
+ * Set the callback url to `https://<appname>.herokuapp.com/`
37
+ * Choose an embedded app
38
+ * Set the app's `redirect_uri` to `https://<appname>.herokuapp.com/auth/shopify/callback`
39
+
40
+ 4. Add ShopifyApp to Gemfile
41
+ ----------------------------
42
+
43
+ Run this command to add the `shopify_app` Gem to your app:
44
+
45
+ ```sh
46
+ $ bundle add shopify_app
47
+ ```
48
+
49
+ **Note:** we recommend using the latest version of Shopify Gem. Check the [Git tags](https://github.com/Shopify/shopify_app/tags) to see the latest release version and then add it to your Gemfile e.g `gem 'shopify_app', '~> 7.0.0'`
50
+
51
+ 5. Run the ShopifyApp generator
52
+ -------------------------------
53
+
54
+ Generate the code for your app by running these commands:
55
+
56
+ ```sh
57
+ # Use the keys from your app you created in the partners area
58
+ $ rails generate shopify_app
59
+ $ git add .
60
+ $ git commit -m 'generated shopify app'
61
+ ```
62
+
63
+ Your API key and secret are read from environment variables. Refer to the main
64
+ README for further details on how to set this up.
65
+
66
+ 6. Deploy your app
67
+ ---------
68
+
69
+ Once you've generated your app, push it into your Heroku environment to see it up and running:
70
+ ```sh
71
+ $ git push heroku
72
+ $ heroku run rake db:migrate
73
+ ```
74
+
75
+ 7. Install the App!
76
+ -------------------
77
+
78
+ Ensure you have created a [development store](https://help.shopify.com/en/api/getting-started/making-your-first-request#create-a-development-store) using the Shopify Partner Dashboard. If you don't already have one, [create one by following these instructions](https://help.shopify.com/en/api/getting-started/making-your-first-request#create-a-development-store).
79
+
80
+ ##### Note: The following step will cause your store to become `transfer-disabled.` Read more about store transfer and why it's important [here](https://help.shopify.com/en/api/guides/store-transfers#transfer-disabled-stores). This is an irreversible change, so be sure you don't plan to transfer this store to a merchant.
81
+
82
+ Install the app onto your new development store using the Partner Dashboard. Log in to your account, visit the apps page, click the app you created earlier, and looking for the `Test your app` instructions where you can select a store to install your app on.
83
+
84
+ ![Installing an app on the partners dashboard dropdown](/docs/install-on-dev-shop.png)
85
+
86
+ ### OR
87
+
88
+ ![Installing an app on the partners dashboard card](/docs/test-your-app.png)
89
+
90
+ 8. Great work!
91
+ -------------------
92
+
93
+ You're done creating your first app on Shopify. Keep going and learn more by [diving into our full documentation](https://help.shopify.com/en/api/getting-started), or join our [community of developers.](https://community.shopify.com/c/Shopify-Apps/bd-p/shopify-apps)
@@ -0,0 +1,18 @@
1
+ Releasing ShopifyApp
2
+
3
+ 1. Check the Semantic Versioning page for info on how to version the new release: http://semver.org
4
+ 2. Create a pull request with the following changes:
5
+ * Update the version of ShopifyApp in lib/shopify_app/version.rb
6
+ * Update the version of shopify_app in package.json
7
+ * Add a CHANGELOG entry for the new release with the date
8
+ * Change the title of the PR to something like: "Packaging for release X.Y.Z"
9
+ 3. Merge your pull request
10
+ 4. Pull from master so you have the latest version of the shopify_app
11
+ 5. Tag the HEAD with the version (Leave REV blank for HEAD or provide a SHA)
12
+ $ git tag vX.Y.Z
13
+ 6. Push out your tags
14
+ $ git push --tags
15
+ 7. Use Shipit to build and push the gem
16
+
17
+ If you see an error like 'You need to create the vX.Y.X tag first', clear GIT
18
+ cache in Shipit settings
@@ -0,0 +1,16 @@
1
+ Troubleshooting Shopify App
2
+ ===========
3
+
4
+ ### Generator shopify_app:install hangs
5
+
6
+ Rails uses spring by default to speed up development. To run the generator, spring has to be stopped:
7
+
8
+ ```sh
9
+ $ bundle exec spring stop
10
+ ```
11
+
12
+ Run shopify_app generator again.
13
+
14
+ ### App installation fails with 'The page you’re looking for could not be found' if the app was installed before
15
+
16
+ This issue can occur when the session (the model you set as `ShopifyApp::SessionRepository.storage`) isn't deleted when the user uninstalls your app. A possible fix for this is listening to the `app/uninstalled` webhook and deleting the corresponding session in the webhook handler.
Binary file
@@ -0,0 +1,44 @@
1
+ const karmaReporters = ['mocha-clean'];
2
+
3
+ function isDebug(argument) {
4
+ return argument === '--debug';
5
+ }
6
+
7
+ module.exports = function(config) {
8
+ config.set({
9
+ mode: 'development',
10
+ basePath: '',
11
+ frameworks: ['mocha-debug', 'mocha', 'chai-sinon'],
12
+ files: [
13
+ 'app/assets/javascripts/**/*.js',
14
+ 'test/javascripts/**/*test.js',
15
+ ],
16
+ exclude: [
17
+ // Exclude JS files that create 'DOMContentLoaded' event listeners
18
+ 'app/assets/javascripts/**/redirect.js',
19
+ 'app/assets/javascripts/**/storage_access_redirect.js',
20
+ 'app/assets/javascripts/**/top_level_interaction.js',
21
+ 'app/assets/javascripts/**/partition_cookies.js',
22
+ ],
23
+ mochaReporter: {
24
+ output: 'autowatch',
25
+ },
26
+ preprocessors: {
27
+ 'test/javascripts/**/*test.js': ['webpack'],
28
+ },
29
+ webpack: {},
30
+ reporters: karmaReporters,
31
+ port: 9876,
32
+ colors: true,
33
+ logLevel: config.LOG_WARN,
34
+ autoWatch: false,
35
+ browsers: ['ChromeHeadless'],
36
+ singleRun: true,
37
+ client: {
38
+ mocha: {
39
+ ui: 'tdd',
40
+ grep: config.grep,
41
+ },
42
+ },
43
+ });
44
+ };
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+ require 'rails/generators/base'
3
+
4
+ module ShopifyApp
5
+ module Generators
6
+ class AddAfterAuthenticateJobGenerator < Rails::Generators::Base
7
+ source_root File.expand_path('../templates', __FILE__)
8
+
9
+ hook_for :test_framework, as: :job, in: :rails do |instance, generator|
10
+ instance.invoke(generator, [instance.send(:job_file_name)])
11
+ end
12
+
13
+ def init_after_authenticate_config
14
+ initializer = load_initializer
15
+
16
+ after_authenticate_job_config =
17
+ " config.after_authenticate_job = "\
18
+ "{ job: \"Shopify::AfterAuthenticateJob\", inline: false }\n"
19
+
20
+ inject_into_file(
21
+ 'config/initializers/shopify_app.rb',
22
+ after_authenticate_job_config,
23
+ before: 'end'
24
+ )
25
+
26
+ unless initializer.include?(after_authenticate_job_config)
27
+ shell.say("Error adding after_authenticate_job to config. Add this line manually: "\
28
+ "#{after_authenticate_job_config}", :red)
29
+ end
30
+ end
31
+
32
+ def add_after_authenticate_job
33
+ template('after_authenticate_job.rb', "app/jobs/#{job_file_name}_job.rb")
34
+ end
35
+
36
+ private
37
+
38
+ def load_initializer
39
+ File.read(File.join(destination_root, 'config/initializers/shopify_app.rb'))
40
+ end
41
+
42
+ def job_file_name
43
+ 'shopify/after_authenticate'
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+ module Shopify
3
+ class AfterAuthenticateJob < ActiveJob::Base
4
+ def perform(shop_domain:)
5
+ shop = Shop.find_by(shopify_domain: shop_domain)
6
+
7
+ shop.with_shopify_session do
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ require 'rails/generators/base'
3
+
4
+ module ShopifyApp
5
+ module Generators
6
+ class AddMarketingActivityExtensionGenerator < Rails::Generators::Base
7
+ source_root File.expand_path('../templates', __FILE__)
8
+
9
+ def generate_app_extension
10
+ template("marketing_activities_controller.rb", "app/controllers/marketing_activities_controller.rb")
11
+ generate_routes
12
+ end
13
+
14
+ private
15
+
16
+ def generate_routes
17
+ inject_into_file(
18
+ 'config/routes.rb',
19
+ optimize_indentation(routes, 2),
20
+ after: "root :to => 'home#index'\n"
21
+ )
22
+ end
23
+
24
+ def routes
25
+ <<~EOS
26
+
27
+ resource :marketing_activities, only: [:create, :update] do
28
+ patch :resume
29
+ patch :pause
30
+ patch :delete
31
+ post :republish
32
+ post :preload_form_data
33
+ post :preview
34
+ post :errors
35
+ end
36
+ EOS
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ class MarketingActivitiesController < ShopifyApp::ExtensionVerificationController
4
+ def preload_form_data
5
+ preload_data = {
6
+ "form_data": {},
7
+ }
8
+ render(json: preload_data, status: :ok)
9
+ end
10
+
11
+ def update
12
+ render(json: {}, status: :accepted)
13
+ end
14
+
15
+ def pause
16
+ render(json: {}, status: :accepted)
17
+ end
18
+
19
+ def resume
20
+ render(json: {}, status: :accepted)
21
+ end
22
+
23
+ def delete
24
+ render(json: {}, status: :accepted)
25
+ end
26
+
27
+ def preview
28
+ placeholder_img = "https://cdn.shopify.com/s/files/1/0533/2089/files/placeholder-images-image_small.png"
29
+ preview_response = {
30
+ "desktop": {
31
+ "preview_url": placeholder_img,
32
+ "content_type": "text/html",
33
+ "width": 360,
34
+ "height": 200,
35
+ },
36
+ "mobile": {
37
+ "preview_url": placeholder_img,
38
+ "content_type": "text/html",
39
+ "width": 360,
40
+ "height": 200,
41
+ },
42
+ }
43
+ render(json: preview_response, status: :ok)
44
+ end
45
+
46
+ def create
47
+ render(json: {}, status: :ok)
48
+ end
49
+
50
+ def republish
51
+ render(json: {}, status: :accepted)
52
+ end
53
+
54
+ def errors
55
+ request_id = params[:request_id]
56
+ message = params[:message]
57
+
58
+ Rails.logger.info("[Marketing Activity App Error Feedback] Request id: #{request_id}, message: #{message}")
59
+
60
+ render(json: {}, status: :ok)
61
+ end
62
+ end