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.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/Gemfile +12 -12
  4. data/Rakefile +32 -30
  5. data/bin/load_shopify.rb +6 -6
  6. data/bin/shopify +2 -2
  7. data/ext/shopify-cli/extconf.rb +7 -7
  8. data/lib/docgen/markdown.rb +11 -11
  9. data/lib/{project_types/extension/graphql → graphql}/get_app_by_api_key.graphql +0 -0
  10. data/lib/project_types/extension/cli.rb +52 -45
  11. data/lib/project_types/extension/commands/build.rb +3 -3
  12. data/lib/project_types/extension/commands/create.rb +16 -9
  13. data/lib/project_types/extension/commands/extension_command.rb +8 -5
  14. data/lib/project_types/extension/commands/push.rb +8 -8
  15. data/lib/project_types/extension/commands/register.rb +19 -30
  16. data/lib/project_types/extension/commands/serve.rb +2 -2
  17. data/lib/project_types/extension/commands/tunnel.rb +12 -12
  18. data/lib/project_types/extension/extension_project.rb +4 -4
  19. data/lib/project_types/extension/extension_project_keys.rb +4 -4
  20. data/lib/project_types/extension/features/argo.rb +13 -13
  21. data/lib/project_types/extension/features/argo_config.rb +5 -5
  22. data/lib/project_types/extension/features/argo_dependencies.rb +5 -5
  23. data/lib/project_types/extension/features/argo_setup.rb +2 -2
  24. data/lib/project_types/extension/features/argo_setup_steps.rb +4 -4
  25. data/lib/project_types/extension/forms/create.rb +28 -34
  26. data/lib/project_types/extension/forms/questions/ask_app.rb +53 -0
  27. data/lib/project_types/extension/forms/questions/ask_name.rb +40 -0
  28. data/lib/project_types/extension/forms/questions/ask_type.rb +36 -0
  29. data/lib/project_types/extension/messages/messages.rb +53 -52
  30. data/lib/project_types/extension/models/lazy_specification_handler.rb +12 -0
  31. data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +1 -1
  32. data/lib/project_types/extension/models/specification_handlers/default.rb +2 -2
  33. data/lib/project_types/extension/models/specifications.rb +3 -3
  34. data/lib/project_types/extension/tasks/configure_features.rb +4 -4
  35. data/lib/project_types/extension/tasks/converters/app_converter.rb +6 -6
  36. data/lib/project_types/extension/tasks/converters/registration_converter.rb +6 -6
  37. data/lib/project_types/extension/tasks/converters/validation_error_converter.rb +4 -4
  38. data/lib/project_types/extension/tasks/converters/version_converter.rb +7 -7
  39. data/lib/project_types/extension/tasks/create_extension.rb +4 -4
  40. data/lib/project_types/extension/tasks/fetch_specifications.rb +4 -4
  41. data/lib/project_types/extension/tasks/get_app.rb +4 -4
  42. data/lib/project_types/extension/tasks/get_apps.rb +3 -3
  43. data/lib/project_types/extension/tasks/update_draft.rb +4 -4
  44. data/lib/project_types/extension/tasks/user_errors.rb +4 -4
  45. data/lib/project_types/node/cli.rb +19 -19
  46. data/lib/project_types/node/commands/connect.rb +3 -3
  47. data/lib/project_types/node/commands/create.rb +40 -38
  48. data/lib/project_types/node/commands/deploy.rb +4 -4
  49. data/lib/project_types/node/commands/deploy/heroku.rb +24 -24
  50. data/lib/project_types/node/commands/generate.rb +8 -8
  51. data/lib/project_types/node/commands/open.rb +2 -2
  52. data/lib/project_types/node/commands/populate.rb +6 -6
  53. data/lib/project_types/node/commands/populate/customer.rb +5 -5
  54. data/lib/project_types/node/commands/populate/draft_order.rb +5 -5
  55. data/lib/project_types/node/commands/populate/product.rb +5 -5
  56. data/lib/project_types/node/commands/serve.rb +9 -9
  57. data/lib/project_types/node/commands/tunnel.rb +7 -7
  58. data/lib/project_types/node/forms/create.rb +7 -7
  59. data/lib/project_types/node/messages/messages.rb +3 -3
  60. data/lib/project_types/rails/cli.rb +21 -21
  61. data/lib/project_types/rails/commands/connect.rb +3 -3
  62. data/lib/project_types/rails/commands/create.rb +51 -48
  63. data/lib/project_types/rails/commands/deploy.rb +4 -4
  64. data/lib/project_types/rails/commands/deploy/heroku.rb +30 -30
  65. data/lib/project_types/rails/commands/generate.rb +7 -7
  66. data/lib/project_types/rails/commands/generate/webhook.rb +6 -6
  67. data/lib/project_types/rails/commands/open.rb +2 -2
  68. data/lib/project_types/rails/commands/populate.rb +6 -6
  69. data/lib/project_types/rails/commands/populate/customer.rb +5 -5
  70. data/lib/project_types/rails/commands/populate/draft_order.rb +5 -5
  71. data/lib/project_types/rails/commands/populate/product.rb +5 -5
  72. data/lib/project_types/rails/commands/serve.rb +11 -11
  73. data/lib/project_types/rails/commands/tunnel.rb +7 -7
  74. data/lib/project_types/rails/forms/create.rb +23 -23
  75. data/lib/project_types/rails/gem.rb +23 -23
  76. data/lib/project_types/rails/messages/messages.rb +4 -4
  77. data/lib/project_types/rails/ruby.rb +2 -2
  78. data/lib/project_types/script/cli.rb +40 -40
  79. data/lib/project_types/script/commands/create.rb +9 -8
  80. data/lib/project_types/script/commands/disable.rb +3 -3
  81. data/lib/project_types/script/commands/enable.rb +9 -7
  82. data/lib/project_types/script/commands/push.rb +5 -4
  83. data/lib/project_types/script/errors.rb +17 -0
  84. data/lib/project_types/script/forms/create.rb +5 -5
  85. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +2 -0
  86. data/lib/project_types/script/layers/application/build_script.rb +6 -8
  87. data/lib/project_types/script/layers/application/create_script.rb +2 -2
  88. data/lib/project_types/script/layers/application/disable_script.rb +2 -2
  89. data/lib/project_types/script/layers/application/enable_script.rb +2 -2
  90. data/lib/project_types/script/layers/application/project_dependencies.rb +4 -4
  91. data/lib/project_types/script/layers/application/push_script.rb +4 -12
  92. data/lib/project_types/script/layers/domain/push_package.rb +5 -1
  93. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +3 -3
  94. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +10 -10
  95. data/lib/project_types/script/layers/infrastructure/errors.rb +1 -1
  96. data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +2 -2
  97. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +12 -17
  98. data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +4 -4
  99. data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +1 -1
  100. data/lib/project_types/script/layers/infrastructure/script_service.rb +18 -16
  101. data/lib/project_types/script/messages/messages.rb +14 -8
  102. data/lib/project_types/script/script_project.rb +27 -5
  103. data/lib/project_types/script/ui/error_handler.rb +80 -68
  104. data/lib/project_types/script/ui/printing_spinner.rb +1 -1
  105. data/lib/project_types/script/ui/strict_spinner.rb +1 -1
  106. data/lib/project_types/theme/cli.rb +19 -19
  107. data/lib/project_types/theme/commands/connect.rb +12 -12
  108. data/lib/project_types/theme/commands/create.rb +11 -11
  109. data/lib/project_types/theme/commands/deploy.rb +8 -8
  110. data/lib/project_types/theme/commands/generate.rb +3 -3
  111. data/lib/project_types/theme/commands/generate/env.rb +15 -15
  112. data/lib/project_types/theme/commands/push.rb +15 -15
  113. data/lib/project_types/theme/commands/serve.rb +5 -5
  114. data/lib/project_types/theme/forms/connect.rb +4 -4
  115. data/lib/project_types/theme/forms/create.rb +5 -5
  116. data/lib/project_types/theme/tasks/ensure_themekit_installed.rb +22 -22
  117. data/lib/project_types/theme/themekit.rb +15 -15
  118. data/lib/rubygems_plugin.rb +3 -3
  119. data/lib/shopify-cli/admin_api.rb +11 -11
  120. data/lib/shopify-cli/admin_api/populate_resource_command.rb +17 -17
  121. data/lib/shopify-cli/admin_api/schema.rb +3 -3
  122. data/lib/shopify-cli/api.rb +10 -10
  123. data/lib/shopify-cli/command.rb +1 -1
  124. data/lib/shopify-cli/commands.rb +9 -9
  125. data/lib/shopify-cli/commands/config.rb +28 -52
  126. data/lib/shopify-cli/commands/connect.rb +10 -10
  127. data/lib/shopify-cli/commands/create.rb +5 -5
  128. data/lib/shopify-cli/commands/help.rb +6 -6
  129. data/lib/shopify-cli/commands/logout.rb +3 -3
  130. data/lib/shopify-cli/commands/system.rb +32 -32
  131. data/lib/shopify-cli/commands/version.rb +2 -2
  132. data/lib/shopify-cli/context.rb +23 -23
  133. data/lib/shopify-cli/core.rb +4 -4
  134. data/lib/shopify-cli/core/entry_point.rb +5 -5
  135. data/lib/shopify-cli/core/executor.rb +1 -1
  136. data/lib/shopify-cli/core/help_resolver.rb +2 -2
  137. data/lib/shopify-cli/core/monorail.rb +16 -16
  138. data/lib/shopify-cli/db.rb +2 -2
  139. data/lib/shopify-cli/feature.rb +1 -1
  140. data/lib/shopify-cli/form.rb +1 -1
  141. data/lib/shopify-cli/git.rb +17 -17
  142. data/lib/shopify-cli/helpers.rb +1 -1
  143. data/lib/shopify-cli/helpers/haikunator.rb +1 -1
  144. data/lib/shopify-cli/heroku.rb +28 -28
  145. data/lib/shopify-cli/http_request.rb +2 -2
  146. data/lib/shopify-cli/js_deps.rb +12 -12
  147. data/lib/shopify-cli/js_system.rb +5 -5
  148. data/lib/shopify-cli/lazy_delegator.rb +55 -0
  149. data/lib/shopify-cli/messages/messages.rb +4 -14
  150. data/lib/shopify-cli/oauth.rb +25 -25
  151. data/lib/shopify-cli/oauth/servlet.rb +9 -9
  152. data/lib/shopify-cli/options.rb +3 -3
  153. data/lib/shopify-cli/packager.rb +24 -24
  154. data/lib/shopify-cli/partners_api.rb +16 -16
  155. data/lib/shopify-cli/partners_api/organizations.rb +10 -10
  156. data/lib/shopify-cli/process_supervision.rb +7 -7
  157. data/lib/shopify-cli/project.rb +16 -16
  158. data/lib/shopify-cli/project_type.rb +3 -3
  159. data/lib/shopify-cli/resources.rb +1 -1
  160. data/lib/shopify-cli/resources/env_file.rb +9 -9
  161. data/lib/shopify-cli/result.rb +8 -8
  162. data/lib/shopify-cli/shopifolk.rb +6 -9
  163. data/lib/shopify-cli/sub_command.rb +1 -1
  164. data/lib/shopify-cli/task.rb +3 -3
  165. data/lib/shopify-cli/tasks.rb +7 -7
  166. data/lib/shopify-cli/tasks/create_api_client.rb +5 -5
  167. data/lib/shopify-cli/tasks/ensure_dev_store.rb +11 -11
  168. data/lib/shopify-cli/tasks/ensure_env.rb +15 -15
  169. data/lib/shopify-cli/tasks/ensure_loopback_url.rb +4 -4
  170. data/lib/shopify-cli/tasks/select_org_and_shop.rb +19 -19
  171. data/lib/shopify-cli/tasks/update_dashboard_urls.rb +10 -10
  172. data/lib/shopify-cli/transform_data_structure.rb +86 -0
  173. data/lib/shopify-cli/tunnel.rb +30 -30
  174. data/lib/shopify-cli/version.rb +1 -1
  175. data/lib/shopify_cli.rb +56 -54
  176. data/shopify-cli.gemspec +6 -6
  177. data/vendor/gen/template/bin/update-deps +9 -9
  178. metadata +9 -4
  179. data/lib/project_types/extension/forms/register.rb +0 -47
@@ -0,0 +1,12 @@
1
+ module Extension
2
+ module Models
3
+ class LazySpecificationHandler < ShopifyCli::LazyDelegator
4
+ attr_reader :identifier
5
+
6
+ def initialize(identifier, &specification_handler_initializer)
7
+ super(&specification_handler_initializer)
8
+ @identifier = identifier
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'base64'
2
+ require "base64"
3
3
 
4
4
  module Extension
5
5
  module Models
@@ -19,11 +19,11 @@ module Extension
19
19
  end
20
20
 
21
21
  def name
22
- message('name')
22
+ message("name")
23
23
  end
24
24
 
25
25
  def tagline
26
- message('tagline') || ""
26
+ message("tagline") || ""
27
27
  end
28
28
 
29
29
  def config(context)
@@ -5,7 +5,7 @@ module Extension
5
5
 
6
6
  property! :custom_handler_root,
7
7
  accepts: ->(d) { File.directory?(d) },
8
- default: -> { File.expand_path('lib/project_types/extension/models/specification_handlers', ShopifyCli::ROOT) }
8
+ default: -> { File.expand_path("lib/project_types/extension/models/specification_handlers", ShopifyCli::ROOT) }
9
9
 
10
10
  property! :custom_handler_namespace,
11
11
  accepts: ->(m) { m.respond_to?(:const_get) },
@@ -64,8 +64,8 @@ module Extension
64
64
 
65
65
  def ensure_legacy_compatibility(specification_attribute_sets)
66
66
  specification_attribute_sets.each do |attributes|
67
- next unless attributes.fetch(:identifier) == 'product_subscription'
68
- attributes[:graphql_identifier] = 'SUBSCRIPTION_MANAGEMENT'
67
+ next unless attributes.fetch(:identifier) == "product_subscription"
68
+ attributes[:graphql_identifier] = "SUBSCRIPTION_MANAGEMENT"
69
69
  end
70
70
  end
71
71
 
@@ -38,12 +38,12 @@ module Extension
38
38
  def surface_area_configurations
39
39
  {
40
40
  admin: {
41
- git_template: 'https://github.com/Shopify/argo-admin-template.git',
42
- renderer_package_name: '@shopify/argo-admin',
41
+ git_template: "https://github.com/Shopify/argo-admin-template.git",
42
+ renderer_package_name: "@shopify/argo-admin",
43
43
  },
44
44
  checkout: {
45
- git_template: 'https://github.com/Shopify/argo-checkout-template.git',
46
- renderer_package_name: '@shopify/argo-checkout',
45
+ git_template: "https://github.com/Shopify/argo-checkout-template.git",
46
+ renderer_package_name: "@shopify/argo-checkout",
47
47
  },
48
48
  }
49
49
  end
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
- require 'shopify_cli'
2
+ require "shopify_cli"
3
3
 
4
4
  module Extension
5
5
  module Tasks
6
6
  module Converters
7
7
  module AppConverter
8
- API_KEY_FIELD = 'apiKey'
9
- API_SECRET_KEYS_FIELD = 'apiSecretKeys'
10
- API_SECRET_FIELD = 'secret'
11
- TITLE_FIELD = 'title'
12
- ORGANIZATION_NAME_FIELD = 'businessName'
8
+ API_KEY_FIELD = "apiKey"
9
+ API_SECRET_KEYS_FIELD = "apiSecretKeys"
10
+ API_SECRET_FIELD = "secret"
11
+ TITLE_FIELD = "title"
12
+ ORGANIZATION_NAME_FIELD = "businessName"
13
13
 
14
14
  def self.from_hash(hash, organization = {})
15
15
  return nil if hash.nil?
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
- require 'shopify_cli'
2
+ require "shopify_cli"
3
3
 
4
4
  module Extension
5
5
  module Tasks
6
6
  module Converters
7
7
  module RegistrationConverter
8
- ID_FIELD = 'id'
9
- TYPE_FIELD = 'type'
10
- TITLE_FIELD = 'title'
11
- DRAFT_VERSION_FIELD = 'draftVersion'
8
+ ID_FIELD = "id"
9
+ TYPE_FIELD = "type"
10
+ TITLE_FIELD = "title"
11
+ DRAFT_VERSION_FIELD = "draftVersion"
12
12
 
13
13
  def self.from_hash(context, hash)
14
- context.abort(context.message('tasks.errors.parse_error')) if hash.nil?
14
+ context.abort(context.message("tasks.errors.parse_error")) if hash.nil?
15
15
 
16
16
  Models::Registration.new(
17
17
  id: hash[ID_FIELD].to_i,
@@ -1,16 +1,16 @@
1
1
  # frozen_string_literal: true
2
- require 'shopify_cli'
2
+ require "shopify_cli"
3
3
 
4
4
  module Extension
5
5
  module Tasks
6
6
  module Converters
7
7
  module ValidationErrorConverter
8
- FIELD_FIELD = 'field'
9
- MESSAGE_FIELD = 'message'
8
+ FIELD_FIELD = "field"
9
+ MESSAGE_FIELD = "message"
10
10
 
11
11
  def self.from_array(context, errors)
12
12
  return [] if errors.nil?
13
- context.abort(context.message('tasks.errors.parse_error')) unless errors.is_a?(Array)
13
+ context.abort(context.message("tasks.errors.parse_error")) unless errors.is_a?(Array)
14
14
 
15
15
  errors.map do |error|
16
16
  Models::ValidationError.new(
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
- require 'shopify_cli'
2
+ require "shopify_cli"
3
3
 
4
4
  module Extension
5
5
  module Tasks
6
6
  module Converters
7
7
  module VersionConverter
8
- REGISTRATION_ID_FIELD = 'registrationId'
9
- CONTEXT_FIELD = 'context'
10
- LAST_USER_INTERACTION_AT_FIELD = 'lastUserInteractionAt'
11
- LOCATION_FIELD = 'location'
12
- VALIDATION_ERRORS_FIELD = 'validationErrors'
8
+ REGISTRATION_ID_FIELD = "registrationId"
9
+ CONTEXT_FIELD = "context"
10
+ LAST_USER_INTERACTION_AT_FIELD = "lastUserInteractionAt"
11
+ LOCATION_FIELD = "location"
12
+ VALIDATION_ERRORS_FIELD = "validationErrors"
13
13
 
14
14
  def self.from_hash(context, hash)
15
- context.abort(context.message('tasks.errors.parse_error')) if hash.nil?
15
+ context.abort(context.message("tasks.errors.parse_error")) if hash.nil?
16
16
 
17
17
  Models::Version.new(
18
18
  registration_id: hash[REGISTRATION_ID_FIELD].to_i,
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
- require 'shopify_cli'
2
+ require "shopify_cli"
3
3
 
4
4
  module Extension
5
5
  module Tasks
6
6
  class CreateExtension < ShopifyCli::Task
7
7
  include UserErrors
8
8
 
9
- GRAPHQL_FILE = 'extension_create'
9
+ GRAPHQL_FILE = "extension_create"
10
10
 
11
11
  RESPONSE_FIELD = %w(data extensionCreate)
12
- REGISTRATION_FIELD = 'extensionRegistration'
12
+ REGISTRATION_FIELD = "extensionRegistration"
13
13
 
14
14
  def call(context:, api_key:, type:, title:, config:, extension_context: nil)
15
15
  input = {
@@ -21,7 +21,7 @@ module Extension
21
21
  }
22
22
 
23
23
  response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
24
- context.abort(context.message('tasks.errors.parse_error')) if response.nil?
24
+ context.abort(context.message("tasks.errors.parse_error")) if response.nil?
25
25
 
26
26
  abort_if_user_errors(context, response)
27
27
  Converters::RegistrationConverter.from_hash(context, response.dig(REGISTRATION_FIELD))
@@ -14,10 +14,10 @@ module Extension
14
14
 
15
15
  def product_subscription_specification
16
16
  {
17
- identifier: 'product_subscription',
17
+ identifier: "product_subscription",
18
18
  features: {
19
19
  argo: {
20
- surface_area: 'admin',
20
+ surface_area: "admin",
21
21
  },
22
22
  },
23
23
  }
@@ -25,10 +25,10 @@ module Extension
25
25
 
26
26
  def checkout_post_purchase_specification
27
27
  {
28
- identifier: 'checkout_post_purchase',
28
+ identifier: "checkout_post_purchase",
29
29
  features: {
30
30
  argo: {
31
- surface_area: 'checkout',
31
+ surface_area: "checkout",
32
32
  },
33
33
  },
34
34
  }
@@ -1,19 +1,19 @@
1
1
  # frozen_string_literal: true
2
- require 'shopify_cli'
2
+ require "shopify_cli"
3
3
 
4
4
  module Extension
5
5
  module Tasks
6
6
  class GetApp < ShopifyCli::Task
7
- GRAPHQL_FILE = 'get_app_by_api_key'
7
+ GRAPHQL_FILE = "get_app_by_api_key"
8
8
 
9
9
  RESPONSE_FIELD = %w(data)
10
- APP_FIELD = 'app'
10
+ APP_FIELD = "app"
11
11
 
12
12
  def call(context:, api_key:)
13
13
  input = { api_key: api_key }
14
14
 
15
15
  response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
16
- context.abort(context.message('tasks.errors.parse_error')) if response.nil?
16
+ context.abort(context.message("tasks.errors.parse_error")) if response.nil?
17
17
 
18
18
  Converters::AppConverter.from_hash(response.dig(APP_FIELD))
19
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'shopify_cli'
2
+ require "shopify_cli"
3
3
 
4
4
  module Extension
5
5
  module Tasks
@@ -18,9 +18,9 @@ module Extension
18
18
  end
19
19
 
20
20
  def apps_owned_by_organization(organization)
21
- return [] unless organization.key?('apps') && organization['apps'].any?
21
+ return [] unless organization.key?("apps") && organization["apps"].any?
22
22
 
23
- organization['apps'].map do |app|
23
+ organization["apps"].map do |app|
24
24
  Converters::AppConverter.from_hash(app, organization)
25
25
  end
26
26
  end
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
- require 'shopify_cli'
2
+ require "shopify_cli"
3
3
 
4
4
  module Extension
5
5
  module Tasks
6
6
  class UpdateDraft < ShopifyCli::Task
7
7
  include UserErrors
8
8
 
9
- GRAPHQL_FILE = 'extension_update_draft'
9
+ GRAPHQL_FILE = "extension_update_draft"
10
10
 
11
11
  RESPONSE_FIELD = %w(data extensionUpdateDraft)
12
- VERSION_FIELD = 'extensionVersion'
12
+ VERSION_FIELD = "extensionVersion"
13
13
 
14
14
  def call(context:, api_key:, registration_id:, config:, extension_context:)
15
15
  input = {
@@ -19,7 +19,7 @@ module Extension
19
19
  extension_context: extension_context,
20
20
  }
21
21
  response = ShopifyCli::PartnersAPI.query(context, GRAPHQL_FILE, **input).dig(*RESPONSE_FIELD)
22
- context.abort(context.message('tasks.errors.parse_error')) if response.nil?
22
+ context.abort(context.message("tasks.errors.parse_error")) if response.nil?
23
23
 
24
24
  abort_if_user_errors(context, response)
25
25
  Converters::VersionConverter.from_hash(context, response.dig(VERSION_FIELD))
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
- require 'shopify_cli'
2
+ require "shopify_cli"
3
3
 
4
4
  module Extension
5
5
  module Tasks
6
6
  module UserErrors
7
- USER_ERRORS_FIELD = 'userErrors'
8
- MESSAGE_FIELD = 'message'
9
- USER_ERRORS_PARSE_ERROR = 'Unable to parse errors from server.'
7
+ USER_ERRORS_FIELD = "userErrors"
8
+ MESSAGE_FIELD = "message"
9
+ USER_ERRORS_PARSE_ERROR = "Unable to parse errors from server."
10
10
 
11
11
  def abort_if_user_errors(context, response)
12
12
  return if response.nil?
@@ -1,32 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
  module Node
3
3
  class Project < ShopifyCli::ProjectType
4
- title('Node.js App')
5
- creator('Node::Commands::Create')
6
- connector('Node::Commands::Connect')
4
+ title("Node.js App")
5
+ creator("Node::Commands::Create")
6
+ connector("Node::Commands::Connect")
7
7
 
8
- register_command('Node::Commands::Deploy', "deploy")
9
- register_command('Node::Commands::Generate', "generate")
10
- register_command('Node::Commands::Open', "open")
11
- register_command('Node::Commands::Populate', "populate")
12
- register_command('Node::Commands::Serve', "serve")
13
- register_command('Node::Commands::Tunnel', "tunnel")
8
+ register_command("Node::Commands::Deploy", "deploy")
9
+ register_command("Node::Commands::Generate", "generate")
10
+ register_command("Node::Commands::Open", "open")
11
+ register_command("Node::Commands::Populate", "populate")
12
+ register_command("Node::Commands::Serve", "serve")
13
+ register_command("Node::Commands::Tunnel", "tunnel")
14
14
  # register_task('Node::Tasks::NodeTask', 'node_task')
15
15
 
16
- require Project.project_filepath('messages/messages')
16
+ require Project.project_filepath("messages/messages")
17
17
  register_messages(Node::Messages::MESSAGES)
18
18
  end
19
19
 
20
20
  # define/autoload project specific Commands
21
21
  module Commands
22
- autoload :Connect, Project.project_filepath('commands/connect')
23
- autoload :Create, Project.project_filepath('commands/create')
24
- autoload :Deploy, Project.project_filepath('commands/deploy')
25
- autoload :Generate, Project.project_filepath('commands/generate')
26
- autoload :Open, Project.project_filepath('commands/open')
27
- autoload :Populate, Project.project_filepath('commands/populate')
28
- autoload :Serve, Project.project_filepath('commands/serve')
29
- autoload :Tunnel, Project.project_filepath('commands/tunnel')
22
+ autoload :Connect, Project.project_filepath("commands/connect")
23
+ autoload :Create, Project.project_filepath("commands/create")
24
+ autoload :Deploy, Project.project_filepath("commands/deploy")
25
+ autoload :Generate, Project.project_filepath("commands/generate")
26
+ autoload :Open, Project.project_filepath("commands/open")
27
+ autoload :Populate, Project.project_filepath("commands/populate")
28
+ autoload :Serve, Project.project_filepath("commands/serve")
29
+ autoload :Tunnel, Project.project_filepath("commands/tunnel")
30
30
  end
31
31
 
32
32
  # define/autoload project specific Tasks
@@ -35,6 +35,6 @@ module Node
35
35
 
36
36
  # define/autoload project specific Forms
37
37
  module Forms
38
- autoload :Create, Project.project_filepath('forms/create')
38
+ autoload :Create, Project.project_filepath("forms/create")
39
39
  end
40
40
  end
@@ -4,11 +4,11 @@ module Node
4
4
  class Connect < ShopifyCli::SubCommand
5
5
  def call(*)
6
6
  if ShopifyCli::Project.has_current? && ShopifyCli::Project.current.env
7
- @ctx.puts(@ctx.message('node.connect.production_warning'))
7
+ @ctx.puts(@ctx.message("node.connect.production_warning"))
8
8
  end
9
9
 
10
- app = ShopifyCli::Commands::Connect.new.default_connect('node')
11
- @ctx.done(@ctx.message('node.connect.connected', app))
10
+ app = ShopifyCli::Commands::Connect.new.default_connect("node")
11
+ @ctx.done(@ctx.message("node.connect.connected", app))
12
12
  end
13
13
  end
14
14
  end
@@ -4,12 +4,14 @@ module Node
4
4
  class Create < ShopifyCli::SubCommand
5
5
  options do |parser, flags|
6
6
  # backwards compatibility allow 'title' for now
7
- parser.on('--title=TITLE') { |t| flags[:title] = t }
8
- parser.on('--name=NAME') { |t| flags[:title] = t }
9
- parser.on('--organization_id=ID') { |url| flags[:organization_id] = url }
10
- parser.on('--shop_domain=MYSHOPIFYDOMAIN') { |url| flags[:shop_domain] = url }
11
- parser.on('--type=APPTYPE') { |url| flags[:type] = url }
12
- parser.on('--verbose') { flags[:verbose] = true }
7
+ parser.on("--title=TITLE") { |t| flags[:title] = t }
8
+ parser.on("--name=NAME") { |t| flags[:title] = t }
9
+ parser.on("--organization_id=ID") { |url| flags[:organization_id] = url }
10
+ parser.on("--organization-id=ID") { |url| flags[:organization_id] = url }
11
+ parser.on("--shop_domain=MYSHOPIFYDOMAIN") { |url| flags[:shop_domain] = url }
12
+ parser.on("--shop-domain=MYSHOPIFYDOMAIN") { |url| flags[:shop_domain] = url }
13
+ parser.on("--type=APPTYPE") { |url| flags[:type] = url }
14
+ parser.on("--verbose") { flags[:verbose] = true }
13
15
  end
14
16
 
15
17
  def call(args, _name)
@@ -22,7 +24,7 @@ module Node
22
24
 
23
25
  ShopifyCli::Project.write(
24
26
  @ctx,
25
- project_type: 'node',
27
+ project_type: "node",
26
28
  organization_id: form.organization_id,
27
29
  )
28
30
 
@@ -37,65 +39,65 @@ module Node
37
39
  api_key: api_client["apiKey"],
38
40
  secret: api_client["apiSecretKeys"].first["secret"],
39
41
  shop: form.shop_domain,
40
- scopes: 'write_products,write_customers,write_draft_orders',
42
+ scopes: "write_products,write_customers,write_draft_orders",
41
43
  ).write(@ctx)
42
44
 
43
- partners_url = ShopifyCli::PartnersAPI.partners_url_for(form.organization_id, api_client['id'], local_debug?)
45
+ partners_url = ShopifyCli::PartnersAPI.partners_url_for(form.organization_id, api_client["id"], local_debug?)
44
46
 
45
- @ctx.puts(@ctx.message('apps.create.info.created', form.title, partners_url))
46
- @ctx.puts(@ctx.message('apps.create.info.serve', form.name, ShopifyCli::TOOL_NAME))
47
+ @ctx.puts(@ctx.message("apps.create.info.created", form.title, partners_url))
48
+ @ctx.puts(@ctx.message("apps.create.info.serve", form.name, ShopifyCli::TOOL_NAME))
47
49
  unless ShopifyCli::Shopifolk.acting_as_shopify_organization?
48
- @ctx.puts(@ctx.message('apps.create.info.install', partners_url, form.title))
50
+ @ctx.puts(@ctx.message("apps.create.info.install", partners_url, form.title))
49
51
  end
50
52
  end
51
53
 
52
54
  def self.help
53
- ShopifyCli::Context.message('node.create.help', ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
55
+ ShopifyCli::Context.message("node.create.help", ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
54
56
  end
55
57
 
56
58
  private
57
59
 
58
60
  def check_node
59
- cmd_path = @ctx.which('node')
60
- @ctx.abort(@ctx.message('node.create.error.node_required')) if cmd_path.nil?
61
+ cmd_path = @ctx.which("node")
62
+ @ctx.abort(@ctx.message("node.create.error.node_required")) if cmd_path.nil?
61
63
 
62
- version, stat = @ctx.capture2e('node', '-v')
63
- @ctx.abort(@ctx.message('node.create.error.node_version_failure')) unless stat.success?
64
+ version, stat = @ctx.capture2e("node", "-v")
65
+ @ctx.abort(@ctx.message("node.create.error.node_version_failure")) unless stat.success?
64
66
 
65
- @ctx.done(@ctx.message('node.create.node_version', version))
67
+ @ctx.done(@ctx.message("node.create.node_version", version))
66
68
  end
67
69
 
68
70
  def check_npm
69
- cmd_path = @ctx.which('npm')
70
- @ctx.abort(@ctx.message('node.create.error.npm_required')) if cmd_path.nil?
71
+ cmd_path = @ctx.which("npm")
72
+ @ctx.abort(@ctx.message("node.create.error.npm_required")) if cmd_path.nil?
71
73
 
72
- version, stat = @ctx.capture2e('npm', '-v')
73
- @ctx.abort(@ctx.message('node.create.error.npm_version_failure')) unless stat.success?
74
+ version, stat = @ctx.capture2e("npm", "-v")
75
+ @ctx.abort(@ctx.message("node.create.error.npm_version_failure")) unless stat.success?
74
76
 
75
- @ctx.done(@ctx.message('node.create.npm_version', version))
77
+ @ctx.done(@ctx.message("node.create.npm_version", version))
76
78
  end
77
79
 
78
80
  def set_npm_config
79
81
  # check available npmrc (either user or system) for production registry
80
- registry, _ = @ctx.capture2('npm config get @shopify:registry')
81
- return if registry.include?('https://registry.yarnpkg.com')
82
+ registry, _ = @ctx.capture2("npm config get @shopify:registry")
83
+ return if registry.include?("https://registry.yarnpkg.com")
82
84
 
83
85
  # available npmrc doesn't have production registry =>
84
86
  # set a project-based .npmrc
85
87
  @ctx.system(
86
- 'npm',
87
- '--userconfig',
88
- './.npmrc',
89
- 'config',
90
- 'set',
91
- '@shopify:registry',
92
- 'https://registry.yarnpkg.com',
88
+ "npm",
89
+ "--userconfig",
90
+ "./.npmrc",
91
+ "config",
92
+ "set",
93
+ "@shopify:registry",
94
+ "https://registry.yarnpkg.com",
93
95
  chdir: @ctx.root
94
96
  )
95
97
  end
96
98
 
97
99
  def build(name)
98
- ShopifyCli::Git.clone('https://github.com/Shopify/shopify-app-node.git', name)
100
+ ShopifyCli::Git.clone("https://github.com/Shopify/shopify-app-node.git", name)
99
101
 
100
102
  @ctx.root = File.join(@ctx.root, name)
101
103
 
@@ -103,12 +105,12 @@ module Node
103
105
  ShopifyCli::JsDeps.install(@ctx, !options.flags[:verbose].nil?)
104
106
 
105
107
  begin
106
- @ctx.rm_r('.git')
107
- @ctx.rm_r('.github')
108
- @ctx.rm(File.join('server', 'handlers', 'client.js'))
108
+ @ctx.rm_r(".git")
109
+ @ctx.rm_r(".github")
110
+ @ctx.rm(File.join("server", "handlers", "client.js"))
109
111
  @ctx.rename(
110
- File.join('server', 'handlers', 'client.cli.js'),
111
- File.join('server', 'handlers', 'client.js')
112
+ File.join("server", "handlers", "client.cli.js"),
113
+ File.join("server", "handlers", "client.js")
112
114
  )
113
115
  rescue Errno::ENOENT => e
114
116
  @ctx.debug(e)