shopify-cli 1.6.0 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +15 -2
  3. data/CHANGELOG.md +21 -0
  4. data/Gemfile +12 -12
  5. data/Gemfile.lock +14 -14
  6. data/Rakefile +32 -30
  7. data/bin/load_shopify.rb +6 -6
  8. data/bin/shopify +2 -2
  9. data/dev.yml +3 -0
  10. data/ext/shopify-cli/extconf.rb +7 -7
  11. data/lib/docgen/markdown.rb +12 -12
  12. data/lib/graphql/extension_create.graphql +17 -2
  13. data/lib/graphql/fetch_specifications.graphql +14 -0
  14. data/lib/{project_types/extension/graphql → graphql}/get_app_by_api_key.graphql +0 -0
  15. data/lib/project_types/extension/cli.rb +56 -55
  16. data/lib/project_types/extension/commands/build.rb +3 -3
  17. data/lib/project_types/extension/commands/create.rb +17 -10
  18. data/lib/project_types/extension/commands/extension_command.rb +14 -7
  19. data/lib/project_types/extension/commands/push.rb +10 -10
  20. data/lib/project_types/extension/commands/register.rb +22 -32
  21. data/lib/project_types/extension/commands/serve.rb +1 -7
  22. data/lib/project_types/extension/commands/tunnel.rb +12 -12
  23. data/lib/project_types/extension/extension_project.rb +22 -7
  24. data/lib/project_types/extension/extension_project_keys.rb +5 -4
  25. data/lib/project_types/extension/features/argo.rb +26 -42
  26. data/lib/project_types/extension/features/argo_config.rb +5 -5
  27. data/lib/project_types/extension/features/argo_dependencies.rb +5 -5
  28. data/lib/project_types/extension/features/argo_renderer_package.rb +47 -0
  29. data/lib/project_types/extension/features/argo_serve.rb +69 -0
  30. data/lib/project_types/extension/features/argo_setup.rb +3 -3
  31. data/lib/project_types/extension/features/argo_setup_steps.rb +4 -4
  32. data/lib/project_types/extension/forms/create.rb +28 -34
  33. data/lib/project_types/extension/forms/questions/ask_app.rb +53 -0
  34. data/lib/project_types/extension/forms/questions/ask_name.rb +40 -0
  35. data/lib/project_types/extension/forms/questions/ask_type.rb +47 -0
  36. data/lib/project_types/extension/messages/message_loading.rb +3 -1
  37. data/lib/project_types/extension/messages/messages.rb +55 -55
  38. data/lib/project_types/extension/models/lazy_specification_handler.rb +12 -0
  39. data/lib/project_types/extension/models/registration.rb +1 -0
  40. data/lib/project_types/extension/models/specification.rb +6 -2
  41. data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +1 -1
  42. data/lib/project_types/extension/models/specification_handlers/default.rb +10 -2
  43. data/lib/project_types/extension/models/specifications.rb +14 -3
  44. data/lib/project_types/extension/models/version.rb +1 -1
  45. data/lib/project_types/extension/tasks/configure_features.rb +7 -5
  46. data/lib/project_types/extension/tasks/converters/app_converter.rb +6 -6
  47. data/lib/project_types/extension/tasks/converters/registration_converter.rb +8 -6
  48. data/lib/project_types/extension/tasks/converters/validation_error_converter.rb +4 -4
  49. data/lib/project_types/extension/tasks/converters/version_converter.rb +7 -7
  50. data/lib/project_types/extension/tasks/create_extension.rb +4 -4
  51. data/lib/project_types/extension/tasks/fetch_specifications.rb +8 -28
  52. data/lib/project_types/extension/tasks/get_app.rb +4 -4
  53. data/lib/project_types/extension/tasks/get_apps.rb +3 -3
  54. data/lib/project_types/extension/tasks/update_draft.rb +4 -4
  55. data/lib/project_types/extension/tasks/user_errors.rb +4 -4
  56. data/lib/project_types/node/cli.rb +19 -19
  57. data/lib/project_types/node/commands/connect.rb +3 -3
  58. data/lib/project_types/node/commands/create.rb +40 -38
  59. data/lib/project_types/node/commands/deploy.rb +4 -4
  60. data/lib/project_types/node/commands/deploy/heroku.rb +24 -24
  61. data/lib/project_types/node/commands/generate.rb +2 -24
  62. data/lib/project_types/node/commands/open.rb +2 -2
  63. data/lib/project_types/node/commands/populate.rb +6 -6
  64. data/lib/project_types/node/commands/populate/customer.rb +5 -5
  65. data/lib/project_types/node/commands/populate/draft_order.rb +5 -5
  66. data/lib/project_types/node/commands/populate/product.rb +5 -5
  67. data/lib/project_types/node/commands/serve.rb +9 -9
  68. data/lib/project_types/node/commands/tunnel.rb +7 -7
  69. data/lib/project_types/node/forms/create.rb +17 -8
  70. data/lib/project_types/node/messages/messages.rb +8 -7
  71. data/lib/project_types/rails/cli.rb +21 -21
  72. data/lib/project_types/rails/commands/connect.rb +3 -3
  73. data/lib/project_types/rails/commands/create.rb +51 -48
  74. data/lib/project_types/rails/commands/deploy.rb +4 -4
  75. data/lib/project_types/rails/commands/deploy/heroku.rb +30 -30
  76. data/lib/project_types/rails/commands/generate.rb +7 -7
  77. data/lib/project_types/rails/commands/generate/webhook.rb +6 -6
  78. data/lib/project_types/rails/commands/open.rb +2 -2
  79. data/lib/project_types/rails/commands/populate.rb +6 -6
  80. data/lib/project_types/rails/commands/populate/customer.rb +5 -5
  81. data/lib/project_types/rails/commands/populate/draft_order.rb +5 -5
  82. data/lib/project_types/rails/commands/populate/product.rb +5 -5
  83. data/lib/project_types/rails/commands/serve.rb +11 -11
  84. data/lib/project_types/rails/commands/tunnel.rb +7 -7
  85. data/lib/project_types/rails/forms/create.rb +34 -24
  86. data/lib/project_types/rails/gem.rb +23 -23
  87. data/lib/project_types/rails/messages/messages.rb +9 -8
  88. data/lib/project_types/rails/ruby.rb +2 -2
  89. data/lib/project_types/script/cli.rb +36 -40
  90. data/lib/project_types/script/commands/create.rb +9 -13
  91. data/lib/project_types/script/commands/push.rb +6 -5
  92. data/lib/project_types/script/config/extension_points.yml +25 -10
  93. data/lib/project_types/script/errors.rb +1 -19
  94. data/lib/project_types/script/forms/create.rb +7 -18
  95. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +7 -5
  96. data/lib/project_types/script/graphql/script_service_proxy.graphql +1 -2
  97. data/lib/project_types/script/layers/application/build_script.rb +6 -8
  98. data/lib/project_types/script/layers/application/create_script.rb +34 -24
  99. data/lib/project_types/script/layers/application/extension_points.rb +3 -2
  100. data/lib/project_types/script/layers/application/project_dependencies.rb +4 -4
  101. data/lib/project_types/script/layers/application/push_script.rb +10 -15
  102. data/lib/project_types/script/layers/domain/config_ui.rb +16 -0
  103. data/lib/project_types/script/layers/domain/errors.rb +16 -0
  104. data/lib/project_types/script/layers/domain/extension_point.rb +60 -45
  105. data/lib/project_types/script/layers/domain/metadata.rb +18 -25
  106. data/lib/project_types/script/layers/domain/push_package.rb +9 -5
  107. data/lib/project_types/script/layers/domain/script_project.rb +38 -0
  108. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +39 -10
  109. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +9 -44
  110. data/lib/project_types/script/layers/infrastructure/errors.rb +50 -19
  111. data/lib/project_types/script/layers/infrastructure/extension_point_repository.rb +2 -2
  112. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +16 -21
  113. data/lib/project_types/script/layers/infrastructure/rust_project_creator.rb +4 -4
  114. data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +2 -2
  115. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +179 -0
  116. data/lib/project_types/script/layers/infrastructure/script_service.rb +35 -78
  117. data/lib/project_types/script/messages/messages.rb +33 -57
  118. data/lib/project_types/script/ui/error_handler.rb +116 -88
  119. data/lib/project_types/script/ui/printing_spinner.rb +1 -1
  120. data/lib/project_types/script/ui/strict_spinner.rb +1 -1
  121. data/lib/project_types/theme/cli.rb +19 -19
  122. data/lib/project_types/theme/commands/connect.rb +12 -12
  123. data/lib/project_types/theme/commands/create.rb +11 -11
  124. data/lib/project_types/theme/commands/deploy.rb +8 -8
  125. data/lib/project_types/theme/commands/generate.rb +3 -3
  126. data/lib/project_types/theme/commands/generate/env.rb +15 -15
  127. data/lib/project_types/theme/commands/push.rb +15 -15
  128. data/lib/project_types/theme/commands/serve.rb +5 -5
  129. data/lib/project_types/theme/forms/connect.rb +4 -4
  130. data/lib/project_types/theme/forms/create.rb +5 -5
  131. data/lib/project_types/theme/tasks/ensure_themekit_installed.rb +22 -22
  132. data/lib/project_types/theme/themekit.rb +15 -15
  133. data/lib/rubygems_plugin.rb +3 -3
  134. data/lib/shopify-cli/admin_api.rb +11 -11
  135. data/lib/shopify-cli/admin_api/populate_resource_command.rb +17 -17
  136. data/lib/shopify-cli/admin_api/schema.rb +3 -3
  137. data/lib/shopify-cli/api.rb +10 -10
  138. data/lib/shopify-cli/command.rb +1 -1
  139. data/lib/shopify-cli/commands.rb +9 -9
  140. data/lib/shopify-cli/commands/config.rb +28 -52
  141. data/lib/shopify-cli/commands/connect.rb +10 -10
  142. data/lib/shopify-cli/commands/create.rb +5 -5
  143. data/lib/shopify-cli/commands/help.rb +6 -6
  144. data/lib/shopify-cli/commands/logout.rb +3 -3
  145. data/lib/shopify-cli/commands/system.rb +32 -32
  146. data/lib/shopify-cli/commands/version.rb +2 -2
  147. data/lib/shopify-cli/context.rb +51 -23
  148. data/lib/shopify-cli/core.rb +4 -4
  149. data/lib/shopify-cli/core/entry_point.rb +5 -5
  150. data/lib/shopify-cli/core/executor.rb +1 -1
  151. data/lib/shopify-cli/core/help_resolver.rb +2 -2
  152. data/lib/shopify-cli/core/monorail.rb +16 -16
  153. data/lib/shopify-cli/db.rb +2 -2
  154. data/lib/shopify-cli/feature.rb +1 -1
  155. data/lib/shopify-cli/form.rb +1 -1
  156. data/lib/shopify-cli/git.rb +17 -17
  157. data/lib/shopify-cli/helpers.rb +1 -1
  158. data/lib/shopify-cli/helpers/haikunator.rb +1 -1
  159. data/lib/shopify-cli/heroku.rb +28 -28
  160. data/lib/shopify-cli/http_request.rb +2 -2
  161. data/lib/shopify-cli/js_deps.rb +12 -12
  162. data/lib/shopify-cli/js_system.rb +7 -7
  163. data/lib/shopify-cli/lazy_delegator.rb +55 -0
  164. data/lib/shopify-cli/messages/messages.rb +7 -16
  165. data/lib/shopify-cli/method_object.rb +1 -1
  166. data/lib/shopify-cli/oauth.rb +27 -27
  167. data/lib/shopify-cli/oauth/servlet.rb +9 -9
  168. data/lib/shopify-cli/options.rb +3 -3
  169. data/lib/shopify-cli/packager.rb +25 -25
  170. data/lib/shopify-cli/partners_api.rb +16 -16
  171. data/lib/shopify-cli/partners_api/organizations.rb +10 -10
  172. data/lib/shopify-cli/process_supervision.rb +7 -7
  173. data/lib/shopify-cli/project.rb +16 -16
  174. data/lib/shopify-cli/project_type.rb +3 -3
  175. data/lib/shopify-cli/resolve_constant.rb +1 -1
  176. data/lib/shopify-cli/resources.rb +1 -1
  177. data/lib/shopify-cli/resources/env_file.rb +10 -10
  178. data/lib/shopify-cli/result.rb +11 -11
  179. data/lib/shopify-cli/shopifolk.rb +6 -9
  180. data/lib/shopify-cli/sub_command.rb +1 -1
  181. data/lib/shopify-cli/task.rb +3 -3
  182. data/lib/shopify-cli/tasks.rb +7 -7
  183. data/lib/shopify-cli/tasks/create_api_client.rb +5 -5
  184. data/lib/shopify-cli/tasks/ensure_dev_store.rb +12 -12
  185. data/lib/shopify-cli/tasks/ensure_env.rb +15 -15
  186. data/lib/shopify-cli/tasks/ensure_loopback_url.rb +4 -4
  187. data/lib/shopify-cli/tasks/select_org_and_shop.rb +19 -19
  188. data/lib/shopify-cli/tasks/update_dashboard_urls.rb +10 -10
  189. data/lib/shopify-cli/transform_data_structure.rb +86 -0
  190. data/lib/shopify-cli/tunnel.rb +30 -30
  191. data/lib/shopify-cli/version.rb +1 -1
  192. data/lib/shopify_cli.rb +56 -54
  193. data/shopify-cli.gemspec +6 -6
  194. data/vendor/deps/smart_properties/REVISION +1 -1
  195. data/vendor/deps/smart_properties/lib/smart_properties/property.rb +7 -1
  196. data/vendor/deps/smart_properties/lib/smart_properties/version.rb +1 -1
  197. data/vendor/gen/template/bin/update-deps +9 -9
  198. metadata +15 -11
  199. data/lib/project_types/extension/forms/register.rb +0 -47
  200. data/lib/project_types/script/commands/disable.rb +0 -25
  201. data/lib/project_types/script/commands/enable.rb +0 -78
  202. data/lib/project_types/script/graphql/shop_script_delete.graphql +0 -14
  203. data/lib/project_types/script/graphql/shop_script_update_or_create.graphql +0 -28
  204. data/lib/project_types/script/layers/application/disable_script.rb +0 -21
  205. data/lib/project_types/script/layers/application/enable_script.rb +0 -23
  206. data/lib/project_types/script/script_project.rb +0 -63
@@ -5,15 +5,15 @@ module Node
5
5
  prerequisite_task :ensure_env, :ensure_dev_store
6
6
 
7
7
  options do |parser, flags|
8
- parser.on('--host=HOST') do |h|
9
- flags[:host] = h.gsub('"', '')
8
+ parser.on("--host=HOST") do |h|
9
+ flags[:host] = h.gsub('"', "")
10
10
  end
11
11
  end
12
12
 
13
13
  def call(*)
14
14
  project = ShopifyCli::Project.current
15
15
  url = options.flags[:host] || ShopifyCli::Tunnel.start(@ctx)
16
- @ctx.abort(@ctx.message('node.serve.error.host_must_be_https')) if url.match(/^https/i).nil?
16
+ @ctx.abort(@ctx.message("node.serve.error.host_must_be_https")) if url.match(/^https/i).nil?
17
17
  project.env.update(@ctx, :host, url)
18
18
  ShopifyCli::Tasks::UpdateDashboardURLS.call(
19
19
  @ctx,
@@ -23,22 +23,22 @@ module Node
23
23
 
24
24
  if project.env.shop
25
25
  project_url = "#{project.env.host}/auth?shop=#{project.env.shop}"
26
- @ctx.puts("\n" + @ctx.message('node.serve.open_info', project_url) + "\n")
26
+ @ctx.puts("\n" + @ctx.message("node.serve.open_info", project_url) + "\n")
27
27
  end
28
28
 
29
- CLI::UI::Frame.open(@ctx.message('node.serve.running_server')) do
29
+ CLI::UI::Frame.open(@ctx.message("node.serve.running_server")) do
30
30
  env = project.env.to_h
31
- env['PORT'] = ShopifyCli::Tunnel::PORT.to_s
32
- @ctx.system('npm run dev', env: env)
31
+ env["PORT"] = ShopifyCli::Tunnel::PORT.to_s
32
+ @ctx.system("npm run dev", env: env)
33
33
  end
34
34
  end
35
35
 
36
36
  def self.help
37
- ShopifyCli::Context.message('node.serve.help', ShopifyCli::TOOL_NAME)
37
+ ShopifyCli::Context.message("node.serve.help", ShopifyCli::TOOL_NAME)
38
38
  end
39
39
 
40
40
  def self.extended_help
41
- ShopifyCli::Context.message('node.serve.extended_help')
41
+ ShopifyCli::Context.message("node.serve.extended_help")
42
42
  end
43
43
  end
44
44
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'shopify_cli'
3
+ require "shopify_cli"
4
4
 
5
5
  module Node
6
6
  module Commands
@@ -10,17 +10,17 @@ module Node
10
10
  def call(args, _name)
11
11
  subcommand = args.shift
12
12
  case subcommand
13
- when 'auth'
13
+ when "auth"
14
14
  token = args.shift
15
15
  if token.nil?
16
- @ctx.puts(@ctx.message('node.tunnel.error.token_argument_missing'))
16
+ @ctx.puts(@ctx.message("node.tunnel.error.token_argument_missing"))
17
17
  @ctx.puts("#{self.class.help}\n#{self.class.extended_help}")
18
18
  else
19
19
  ShopifyCli::Tunnel.auth(@ctx, token)
20
20
  end
21
- when 'start'
21
+ when "start"
22
22
  ShopifyCli::Tunnel.start(@ctx)
23
- when 'stop'
23
+ when "stop"
24
24
  ShopifyCli::Tunnel.stop(@ctx)
25
25
  else
26
26
  @ctx.puts(self.class.help)
@@ -28,11 +28,11 @@ module Node
28
28
  end
29
29
 
30
30
  def self.help
31
- ShopifyCli::Context.message('node.tunnel.help', ShopifyCli::TOOL_NAME)
31
+ ShopifyCli::Context.message("node.tunnel.help", ShopifyCli::TOOL_NAME)
32
32
  end
33
33
 
34
34
  def self.extended_help
35
- ShopifyCli::Context.message('node.tunnel.extended_help', ShopifyCli::TOOL_NAME)
35
+ ShopifyCli::Context.message("node.tunnel.extended_help", ShopifyCli::TOOL_NAME)
36
36
  end
37
37
  end
38
38
  end
@@ -1,4 +1,4 @@
1
- require 'uri'
1
+ require "uri"
2
2
 
3
3
  module Node
4
4
  module Forms
@@ -7,9 +7,9 @@ module Node
7
7
  flag_arguments :title, :organization_id, :shop_domain, :type
8
8
 
9
9
  def ask
10
- self.title ||= CLI::UI::Prompt.ask(ctx.message('node.forms.create.app_name'))
10
+ self.title ||= CLI::UI::Prompt.ask(ctx.message("node.forms.create.app_name"))
11
+ self.name = format_name
11
12
  self.type = ask_type
12
- self.name = self.title.downcase.split(" ").join("_")
13
13
  res = ShopifyCli::Tasks::SelectOrgAndShop.call(ctx, organization_id: organization_id, shop_domain: shop_domain)
14
14
  self.organization_id = res[:organization_id]
15
15
  self.shop_domain = res[:shop_domain]
@@ -17,18 +17,27 @@ module Node
17
17
 
18
18
  private
19
19
 
20
+ def format_name
21
+ name = title.downcase.split(" ").join("_")
22
+
23
+ if name.include?("shopify")
24
+ ctx.abort(ctx.message("node.forms.create.error.invalid_app_name"))
25
+ end
26
+ name
27
+ end
28
+
20
29
  def ask_type
21
30
  if type.nil?
22
- return CLI::UI::Prompt.ask(ctx.message('node.forms.create.app_type.select')) do |handler|
23
- handler.option(ctx.message('node.forms.create.app_type.select_public')) { 'public' }
24
- handler.option(ctx.message('node.forms.create.app_type.select_custom')) { 'custom' }
31
+ return CLI::UI::Prompt.ask(ctx.message("node.forms.create.app_type.select")) do |handler|
32
+ handler.option(ctx.message("node.forms.create.app_type.select_public")) { "public" }
33
+ handler.option(ctx.message("node.forms.create.app_type.select_custom")) { "custom" }
25
34
  end
26
35
  end
27
36
 
28
37
  unless ShopifyCli::Tasks::CreateApiClient::VALID_APP_TYPES.include?(type)
29
- ctx.abort(ctx.message('node.forms.create.error.invalid_app_type', type))
38
+ ctx.abort(ctx.message("node.forms.create.error.invalid_app_type", type))
30
39
  end
31
- ctx.puts(ctx.message('node.forms.create.app_type.selected', type))
40
+ ctx.puts(ctx.message("node.forms.create.app_type.selected", type))
32
41
  type
33
42
  end
34
43
  end
@@ -21,9 +21,9 @@ module Node
21
21
  Usage: {{command:%s create node}}
22
22
  Options:
23
23
  {{command:--name=NAME}} App name. Any string.
24
- {{command:--app_url=APPURL}} App URL. Must be a valid URL.
25
- {{command:--organization_id=ID}} Partner organization ID. Must be an existing organization.
26
- {{command:--shop_domain=MYSHOPIFYDOMAIN }} Development store URL. Must be an existing development store.
24
+ {{command:--app-url=APPURL}} App URL. Must be a valid URL.
25
+ {{command:--organization-id=ID}} Partner organization ID. Must be an existing organization.
26
+ {{command:--shop-domain=MYSHOPIFYDOMAIN }} Development store URL. Must be an existing development store.
27
27
  HELP
28
28
  error: {
29
29
  node_required: "node is required to create an app project. Download at https://nodejs.org/en/download.",
@@ -59,21 +59,21 @@ module Node
59
59
  installed: "Installed Heroku CLI",
60
60
  authenticating: "Authenticating with Heroku…",
61
61
  authenticated: "{{v}} Authenticated with Heroku",
62
- authenticated_with_account: "{{v}} Authenticated with Heroku as `%s`",
62
+ authenticated_with_account: "{{v}} Authenticated with Heroku as {{green:%s}}",
63
63
  deploying: "Deploying to Heroku…",
64
64
  deployed: "{{v}} Deployed to Heroku",
65
65
  git: {
66
66
  checking: "Checking git repo…",
67
67
  initialized: "Git repo initialized",
68
68
  what_branch: "What branch would you like to deploy?",
69
- branch_selected: "{{v}} Git branch `%s` selected for deploy",
69
+ branch_selected: "{{v}} Git branch {{green:%s}} selected for deploy",
70
70
  },
71
71
  app: {
72
72
  no_apps_found: "No existing Heroku app found. What would you like to do?",
73
73
  name: "What is your Heroku app’s name?",
74
74
  select: "Specify an existing Heroku app",
75
- selecting: "Selecting Heroku app `%s`…",
76
- selected: "{{v}} Heroku app `%s` selected",
75
+ selecting: "Selecting Heroku app %s",
76
+ selected: "{{v}} Heroku app {{green:%s}} selected",
77
77
  create: "Create a new Heroku app",
78
78
  creating: "Creating new Heroku app…",
79
79
  created: "{{v}} New Heroku app created",
@@ -202,6 +202,7 @@ module Node
202
202
  forms: {
203
203
  create: {
204
204
  error: {
205
+ invalid_app_name: "App name cannot contain 'Shopify'",
205
206
  invalid_app_type: "Invalid app type %s",
206
207
  },
207
208
  app_name: "App name",
@@ -1,32 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
  module Rails
3
3
  class Project < ShopifyCli::ProjectType
4
- title('Ruby on Rails App')
5
- creator('Rails::Commands::Create')
6
- connector('Rails::Commands::Connect')
4
+ title("Ruby on Rails App")
5
+ creator("Rails::Commands::Create")
6
+ connector("Rails::Commands::Connect")
7
7
 
8
- register_command('Rails::Commands::Deploy', "deploy")
9
- register_command('Rails::Commands::Generate', "generate")
10
- register_command('Rails::Commands::Open', "open")
11
- register_command('Rails::Commands::Populate', "populate")
12
- register_command('Rails::Commands::Serve', "serve")
13
- register_command('Rails::Commands::Tunnel', "tunnel")
8
+ register_command("Rails::Commands::Deploy", "deploy")
9
+ register_command("Rails::Commands::Generate", "generate")
10
+ register_command("Rails::Commands::Open", "open")
11
+ register_command("Rails::Commands::Populate", "populate")
12
+ register_command("Rails::Commands::Serve", "serve")
13
+ register_command("Rails::Commands::Tunnel", "tunnel")
14
14
  # register_task('Rails::Tasks::RailsTask', 'rails_task')
15
15
 
16
- require Project.project_filepath('messages/messages')
16
+ require Project.project_filepath("messages/messages")
17
17
  register_messages(Rails::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,9 +35,9 @@ module Rails
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
 
41
- autoload :Ruby, Project.project_filepath('ruby')
42
- autoload :Gem, Project.project_filepath('gem')
41
+ autoload :Ruby, Project.project_filepath("ruby")
42
+ autoload :Gem, Project.project_filepath("gem")
43
43
  end
@@ -4,11 +4,11 @@ module Rails
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('rails.connect.production_warning'))
7
+ @ctx.puts(@ctx.message("rails.connect.production_warning"))
8
8
  end
9
9
 
10
- app = ShopifyCli::Commands::Connect.new.default_connect('rails')
11
- @ctx.done(@ctx.message('rails.connect.connected', app))
10
+ app = ShopifyCli::Commands::Connect.new.default_connect("rails")
11
+ @ctx.done(@ctx.message("rails.connect.connected", app))
12
12
  end
13
13
  end
14
14
  end
@@ -14,13 +14,16 @@ module Rails
14
14
 
15
15
  options do |parser, flags|
16
16
  # backwards compatibility allow 'title' for now
17
- parser.on('--title=TITLE') { |t| flags[:title] = t }
18
- parser.on('--name=NAME') { |t| flags[:title] = t }
19
- parser.on('--organization_id=ID') { |url| flags[:organization_id] = url }
20
- parser.on('--shop_domain=MYSHOPIFYDOMAIN') { |url| flags[:shop_domain] = url }
21
- parser.on('--type=APPTYPE') { |url| flags[:type] = url }
22
- parser.on('--db=DB') { |db| flags[:db] = db }
23
- parser.on('--rails_opts=RAILSOPTS') { |opts| flags[:rails_opts] = opts }
17
+ parser.on("--title=TITLE") { |t| flags[:title] = t }
18
+ parser.on("--name=NAME") { |t| flags[:title] = t }
19
+ parser.on("--organization_id=ID") { |url| flags[:organization_id] = url }
20
+ parser.on("--organization-id=ID") { |url| flags[:organization_id] = url }
21
+ parser.on("--shop_domain=MYSHOPIFYDOMAIN") { |url| flags[:shop_domain] = url }
22
+ parser.on("--shop-domain=MYSHOPIFYDOMAIN") { |url| flags[:shop_domain] = url }
23
+ parser.on("--type=APPTYPE") { |url| flags[:type] = url }
24
+ parser.on("--db=DB") { |db| flags[:db] = db }
25
+ parser.on("--rails_opts=RAILSOPTS") { |opts| flags[:rails_opts] = opts }
26
+ parser.on("--rails-opts=RAILSOPTS") { |opts| flags[:rails_opts] = opts }
24
27
  end
25
28
 
26
29
  def call(args, _name)
@@ -28,8 +31,8 @@ module Rails
28
31
  return @ctx.puts(self.class.help) if form.nil?
29
32
 
30
33
  ruby_version = Ruby.version(@ctx)
31
- @ctx.abort(@ctx.message('rails.create.error.invalid_ruby_version')) unless
32
- ruby_version.satisfies?('~>2.5') || ruby_version.satisfies?('~>3.0.0')
34
+ @ctx.abort(@ctx.message("rails.create.error.invalid_ruby_version")) unless
35
+ ruby_version.satisfies?("~>2.5") || ruby_version.satisfies?("~>3.0.0")
33
36
 
34
37
  check_node
35
38
  check_yarn
@@ -38,7 +41,7 @@ module Rails
38
41
  set_custom_ua
39
42
  ShopifyCli::Project.write(
40
43
  @ctx,
41
- project_type: 'rails',
44
+ project_type: "rails",
42
45
  organization_id: form.organization_id,
43
46
  )
44
47
 
@@ -53,74 +56,74 @@ module Rails
53
56
  api_key: api_client["apiKey"],
54
57
  secret: api_client["apiSecretKeys"].first["secret"],
55
58
  shop: form.shop_domain,
56
- scopes: 'write_products,write_customers,write_draft_orders',
59
+ scopes: "write_products,write_customers,write_draft_orders",
57
60
  ).write(@ctx)
58
61
 
59
- partners_url = ShopifyCli::PartnersAPI.partners_url_for(form.organization_id, api_client['id'], local_debug?)
62
+ partners_url = ShopifyCli::PartnersAPI.partners_url_for(form.organization_id, api_client["id"], local_debug?)
60
63
 
61
- @ctx.puts(@ctx.message('apps.create.info.created', form.title, partners_url))
62
- @ctx.puts(@ctx.message('apps.create.info.serve', form.name, ShopifyCli::TOOL_NAME))
64
+ @ctx.puts(@ctx.message("apps.create.info.created", form.title, partners_url))
65
+ @ctx.puts(@ctx.message("apps.create.info.serve", form.name, ShopifyCli::TOOL_NAME))
63
66
  unless ShopifyCli::Shopifolk.acting_as_shopify_organization?
64
- @ctx.puts(@ctx.message('apps.create.info.install', partners_url, form.title))
67
+ @ctx.puts(@ctx.message("apps.create.info.install", partners_url, form.title))
65
68
  end
66
69
  end
67
70
 
68
71
  def self.help
69
- ShopifyCli::Context.message('rails.create.help', ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
72
+ ShopifyCli::Context.message("rails.create.help", ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
70
73
  end
71
74
 
72
75
  private
73
76
 
74
77
  def check_node
75
- cmd_path = @ctx.which('node')
78
+ cmd_path = @ctx.which("node")
76
79
  if cmd_path.nil?
77
- @ctx.abort(@ctx.message('rails.create.error.node_required')) unless @ctx.windows?
78
- @ctx.puts("{{x}} {{red:" + @ctx.message('rails.create.error.node_required') + "}}")
79
- @ctx.puts(@ctx.message('rails.create.info.open_new_shell', 'node'))
80
+ @ctx.abort(@ctx.message("rails.create.error.node_required")) unless @ctx.windows?
81
+ @ctx.puts("{{x}} {{red:" + @ctx.message("rails.create.error.node_required") + "}}")
82
+ @ctx.puts(@ctx.message("rails.create.info.open_new_shell", "node"))
80
83
  raise ShopifyCli::AbortSilent
81
84
  end
82
85
 
83
- version, stat = @ctx.capture2e('node', '-v')
86
+ version, stat = @ctx.capture2e("node", "-v")
84
87
  unless stat.success?
85
- @ctx.abort(@ctx.message('rails.create.error.node_version_failure')) unless @ctx.windows?
88
+ @ctx.abort(@ctx.message("rails.create.error.node_version_failure")) unless @ctx.windows?
86
89
  # execution stops above if not Windows
87
- @ctx.puts("{{x}} {{red:" + @ctx.message('rails.create.error.node_version_failure') + "}}")
88
- @ctx.puts(@ctx.message('rails.create.info.open_new_shell', 'node'))
90
+ @ctx.puts("{{x}} {{red:" + @ctx.message("rails.create.error.node_version_failure") + "}}")
91
+ @ctx.puts(@ctx.message("rails.create.info.open_new_shell", "node"))
89
92
  raise ShopifyCli::AbortSilent
90
93
  end
91
94
 
92
- @ctx.done(@ctx.message('rails.create.node_version', version))
95
+ @ctx.done(@ctx.message("rails.create.node_version", version))
93
96
  end
94
97
 
95
98
  def check_yarn
96
- cmd_path = @ctx.which('yarn')
99
+ cmd_path = @ctx.which("yarn")
97
100
  if cmd_path.nil?
98
- @ctx.abort(@ctx.message('rails.create.error.yarn_required')) unless @ctx.windows?
99
- @ctx.puts("{{x}} {{red:" + @ctx.message('rails.create.error.yarn_required') + "}}")
100
- @ctx.puts(@ctx.message('rails.create.info.open_new_shell', 'yarn'))
101
+ @ctx.abort(@ctx.message("rails.create.error.yarn_required")) unless @ctx.windows?
102
+ @ctx.puts("{{x}} {{red:" + @ctx.message("rails.create.error.yarn_required") + "}}")
103
+ @ctx.puts(@ctx.message("rails.create.info.open_new_shell", "yarn"))
101
104
  raise ShopifyCli::AbortSilent
102
105
  end
103
106
 
104
- version, stat = @ctx.capture2e('yarn', '-v')
107
+ version, stat = @ctx.capture2e("yarn", "-v")
105
108
  unless stat.success?
106
- @ctx.abort(@ctx.message('rails.create.error.yarn_version_failure')) unless @ctx.windows?
107
- @ctx.puts("{{x}} {{red:" + @ctx.message('rails.create.error.yarn_version_failure') + "}}")
108
- @ctx.puts(@ctx.message('rails.create.info.open_new_shell', 'yarn'))
109
+ @ctx.abort(@ctx.message("rails.create.error.yarn_version_failure")) unless @ctx.windows?
110
+ @ctx.puts("{{x}} {{red:" + @ctx.message("rails.create.error.yarn_version_failure") + "}}")
111
+ @ctx.puts(@ctx.message("rails.create.info.open_new_shell", "yarn"))
109
112
  raise ShopifyCli::AbortSilent
110
113
  end
111
114
 
112
- @ctx.done(@ctx.message('rails.create.yarn_version', version))
115
+ @ctx.done(@ctx.message("rails.create.yarn_version", version))
113
116
  end
114
117
 
115
118
  def build(name, db)
116
- @ctx.abort(@ctx.message('rails.create.error.install_failure', 'rails')) unless install_gem('rails', '<6.1')
117
- @ctx.abort(@ctx.message('rails.create.error.install_failure', 'bundler ~>2.0')) unless
118
- install_gem('bundler', '~>2.0')
119
+ @ctx.abort(@ctx.message("rails.create.error.install_failure", "rails")) unless install_gem("rails", "<6.1")
120
+ @ctx.abort(@ctx.message("rails.create.error.install_failure", "bundler ~>2.0")) unless
121
+ install_gem("bundler", "~>2.0")
119
122
 
120
123
  full_path = File.join(@ctx.root, name)
121
- @ctx.abort(@ctx.message('rails.create.error.dir_exists', name)) if Dir.exist?(full_path)
124
+ @ctx.abort(@ctx.message("rails.create.error.dir_exists", name)) if Dir.exist?(full_path)
122
125
 
123
- CLI::UI::Frame.open(@ctx.message('rails.create.generating_app', name)) do
126
+ CLI::UI::Frame.open(@ctx.message("rails.create.generating_app", name)) do
124
127
  new_command = %w(rails new)
125
128
  new_command += DEFAULT_RAILS_FLAGS
126
129
  new_command << "--database=#{db}"
@@ -132,34 +135,34 @@ module Rails
132
135
 
133
136
  @ctx.root = full_path
134
137
 
135
- File.open(File.join(@ctx.root, '.gitignore'), 'a') { |f| f.write('.env') }
138
+ File.open(File.join(@ctx.root, ".gitignore"), "a") { |f| f.write(".env") }
136
139
 
137
- @ctx.puts(@ctx.message('rails.create.adding_shopify_gem'))
138
- File.open(File.join(@ctx.root, 'Gemfile'), 'a') do |f|
140
+ @ctx.puts(@ctx.message("rails.create.adding_shopify_gem"))
141
+ File.open(File.join(@ctx.root, "Gemfile"), "a") do |f|
139
142
  f.puts "\ngem 'shopify_app', '>=17.0.3'"
140
143
  end
141
- CLI::UI::Frame.open(@ctx.message('rails.create.running_bundle_install')) do
144
+ CLI::UI::Frame.open(@ctx.message("rails.create.running_bundle_install")) do
142
145
  syscall(%w(bundle install))
143
146
  end
144
147
 
145
- CLI::UI::Frame.open(@ctx.message('rails.create.running_generator')) do
148
+ CLI::UI::Frame.open(@ctx.message("rails.create.running_generator")) do
146
149
  syscall(%w(rails generate shopify_app --new-shopify-cli-app))
147
150
  end
148
151
 
149
- CLI::UI::Frame.open(@ctx.message('rails.create.running_migrations')) do
152
+ CLI::UI::Frame.open(@ctx.message("rails.create.running_migrations")) do
150
153
  syscall(%w(rails db:create))
151
154
  syscall(%w(rails db:migrate RAILS_ENV=development))
152
155
  end
153
156
 
154
- unless File.exist?(File.join(@ctx.root, 'config/webpacker.yml'))
155
- CLI::UI::Frame.open(@ctx.message('rails.create.running_webpacker_install')) do
157
+ unless File.exist?(File.join(@ctx.root, "config/webpacker.yml"))
158
+ CLI::UI::Frame.open(@ctx.message("rails.create.running_webpacker_install")) do
156
159
  syscall(%w(rails webpacker:install))
157
160
  end
158
161
  end
159
162
  end
160
163
 
161
164
  def set_custom_ua
162
- ua_path = File.join('config', 'initializers', 'user_agent.rb')
165
+ ua_path = File.join("config", "initializers", "user_agent.rb")
163
166
  @ctx.write(ua_path, USER_AGENT_CODE)
164
167
  end
165
168