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,14 +5,14 @@ module Theme
5
5
  prerequisite_task :ensure_themekit_installed
6
6
 
7
7
  options do |parser, flags|
8
- parser.on('--env=ENV') { |env| flags[:env] = env }
9
- parser.on('--allow-live') { flags['allow_live'] = true }
8
+ parser.on("--env=ENV") { |env| flags[:env] = env }
9
+ parser.on("--allow-live") { flags["allow_live"] = true }
10
10
  end
11
11
 
12
12
  def call(*)
13
- CLI::UI::Frame.open(@ctx.message('theme.deploy.deploying')) do
14
- unless CLI::UI::Prompt.confirm(@ctx.message('theme.deploy.confirmation'))
15
- @ctx.abort(@ctx.message('theme.deploy.abort'))
13
+ CLI::UI::Frame.open(@ctx.message("theme.deploy.deploying")) do
14
+ unless CLI::UI::Prompt.confirm(@ctx.message("theme.deploy.confirmation"))
15
+ @ctx.abort(@ctx.message("theme.deploy.abort"))
16
16
  end
17
17
 
18
18
  if options.flags[:env]
@@ -23,15 +23,15 @@ module Theme
23
23
  flags = Themekit.add_flags(options.flags)
24
24
 
25
25
  unless Themekit.deploy(@ctx, flags: flags, env: env)
26
- @ctx.abort(@ctx.message('theme.deploy.error'))
26
+ @ctx.abort(@ctx.message("theme.deploy.error"))
27
27
  end
28
28
  end
29
29
 
30
- @ctx.done(@ctx.message('theme.deploy.info.deployed'))
30
+ @ctx.done(@ctx.message("theme.deploy.info.deployed"))
31
31
  end
32
32
 
33
33
  def self.help
34
- ShopifyCli::Context.message('theme.deploy.help', ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
34
+ ShopifyCli::Context.message("theme.deploy.help", ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
35
35
  end
36
36
  end
37
37
  end
@@ -1,19 +1,19 @@
1
1
  # frozen_string_literal: true
2
- require 'shopify_cli'
2
+ require "shopify_cli"
3
3
 
4
4
  module Theme
5
5
  module Commands
6
6
  class Generate < ShopifyCli::Command
7
7
  prerequisite_task :ensure_themekit_installed
8
8
 
9
- subcommand :Env, 'env', Project.project_filepath('commands/generate/env')
9
+ subcommand :Env, "env", Project.project_filepath("commands/generate/env")
10
10
 
11
11
  def call(*)
12
12
  @ctx.puts(self.class.help)
13
13
  end
14
14
 
15
15
  def self.help
16
- ShopifyCli::Context.message('theme.generate.help', ShopifyCli::TOOL_NAME)
16
+ ShopifyCli::Context.message("theme.generate.help", ShopifyCli::TOOL_NAME)
17
17
  end
18
18
  end
19
19
  end
@@ -3,10 +3,10 @@ module Theme
3
3
  class Generate
4
4
  class Env < ShopifyCli::SubCommand
5
5
  options do |parser, flags|
6
- parser.on('--store=STORE') { |url| flags[:store] = url }
7
- parser.on('--password=PASSWORD') { |p| flags[:password] = p }
8
- parser.on('--themeid=THEME_ID') { |id| flags[:themeid] = id }
9
- parser.on('--env=ENV') { |env| flags[:env] = env }
6
+ parser.on("--store=STORE") { |url| flags[:store] = url }
7
+ parser.on("--password=PASSWORD") { |p| flags[:password] = p }
8
+ parser.on("--themeid=THEME_ID") { |id| flags[:themeid] = id }
9
+ parser.on("--env=ENV") { |env| flags[:env] = env }
10
10
  end
11
11
 
12
12
  def call(*)
@@ -20,19 +20,19 @@ module Theme
20
20
  end
21
21
 
22
22
  def self.help
23
- ShopifyCli::Context.message('theme.generate.env.help', ShopifyCli::TOOL_NAME)
23
+ ShopifyCli::Context.message("theme.generate.env.help", ShopifyCli::TOOL_NAME)
24
24
  end
25
25
 
26
26
  private
27
27
 
28
28
  def fetch_credentials
29
- unless File.exist?('config.yml')
29
+ unless File.exist?("config.yml")
30
30
  return nil
31
31
  end
32
32
 
33
- config = YAML.load_file('config.yml')
34
- store = config['development']['store']
35
- password = config['development']['password']
33
+ config = YAML.load_file("config.yml")
34
+ store = config["development"]["store"]
35
+ password = config["development"]["password"]
36
36
 
37
37
  [store, password]
38
38
  end
@@ -40,9 +40,9 @@ module Theme
40
40
  def ask_store(default)
41
41
  store = options.flags[:store] ||
42
42
  if default
43
- CLI::UI::Prompt.ask(@ctx.message('theme.generate.env.ask_store_default', default))
43
+ CLI::UI::Prompt.ask(@ctx.message("theme.generate.env.ask_store_default", default))
44
44
  else
45
- CLI::UI::Prompt.ask(@ctx.message('theme.generate.env.ask_store'), allow_empty: false)
45
+ CLI::UI::Prompt.ask(@ctx.message("theme.generate.env.ask_store"), allow_empty: false)
46
46
  end
47
47
  return nil if store.empty?
48
48
  store
@@ -51,9 +51,9 @@ module Theme
51
51
  def ask_password(default)
52
52
  password = options.flags[:password] ||
53
53
  if default
54
- CLI::UI::Prompt.ask(@ctx.message('theme.generate.env.ask_password_default', default))
54
+ CLI::UI::Prompt.ask(@ctx.message("theme.generate.env.ask_password_default", default))
55
55
  else
56
- CLI::UI::Prompt.ask(@ctx.message('theme.generate.env.ask_password'), allow_empty: false)
56
+ CLI::UI::Prompt.ask(@ctx.message("theme.generate.env.ask_password"), allow_empty: false)
57
57
  end
58
58
  return nil if password.empty?
59
59
  password
@@ -65,9 +65,9 @@ module Theme
65
65
 
66
66
  themes = Themekit.query_themes(@ctx, store: store, password: password)
67
67
 
68
- @ctx.abort(@ctx.message('theme.generate.env.no_themes', ShopifyCli::TOOL_NAME)) if themes.empty?
68
+ @ctx.abort(@ctx.message("theme.generate.env.no_themes", ShopifyCli::TOOL_NAME)) if themes.empty?
69
69
 
70
- CLI::UI::Prompt.ask(@ctx.message('theme.generate.env.ask_theme')) do |handler|
70
+ CLI::UI::Prompt.ask(@ctx.message("theme.generate.env.ask_theme")) do |handler|
71
71
  themes.each do |name, id|
72
72
  handler.option(name) { id }
73
73
  end
@@ -5,16 +5,16 @@ module Theme
5
5
  prerequisite_task :ensure_themekit_installed
6
6
 
7
7
  options do |parser, flags|
8
- parser.on('--remove') { flags['remove'] = true }
9
- parser.on('--nodelete') { flags['nodelete'] = true }
10
- parser.on('--allow-live') { flags['allow-live'] = true }
11
- parser.on('--env=ENV') { |env| flags[:env] = env }
8
+ parser.on("--remove") { flags["remove"] = true }
9
+ parser.on("--nodelete") { flags["nodelete"] = true }
10
+ parser.on("--allow-live") { flags["allow-live"] = true }
11
+ parser.on("--env=ENV") { |env| flags[:env] = env }
12
12
  end
13
13
 
14
14
  def call(args, _name)
15
- if options.flags['remove']
15
+ if options.flags["remove"]
16
16
  remove = true
17
- options.flags.delete('remove')
17
+ options.flags.delete("remove")
18
18
  end
19
19
 
20
20
  if options.flags[:env]
@@ -25,30 +25,30 @@ module Theme
25
25
  flags = Themekit.add_flags(options.flags)
26
26
 
27
27
  if remove
28
- CLI::UI::Frame.open(@ctx.message('theme.push.remove')) do
29
- unless CLI::UI::Prompt.confirm(@ctx.message('theme.push.remove_confirm'))
30
- @ctx.abort(@ctx.message('theme.push.remove_abort'))
28
+ CLI::UI::Frame.open(@ctx.message("theme.push.remove")) do
29
+ unless CLI::UI::Prompt.confirm(@ctx.message("theme.push.remove_confirm"))
30
+ @ctx.abort(@ctx.message("theme.push.remove_abort"))
31
31
  end
32
32
 
33
33
  unless Themekit.push(@ctx, files: args, flags: flags, remove: remove, env: env)
34
- @ctx.abort(@ctx.message('theme.push.error.remove_error'))
34
+ @ctx.abort(@ctx.message("theme.push.error.remove_error"))
35
35
  end
36
36
  end
37
37
 
38
- @ctx.done(@ctx.message('theme.push.info.remove', @ctx.root))
38
+ @ctx.done(@ctx.message("theme.push.info.remove", @ctx.root))
39
39
  else
40
- CLI::UI::Frame.open(@ctx.message('theme.push.push')) do
40
+ CLI::UI::Frame.open(@ctx.message("theme.push.push")) do
41
41
  unless Themekit.push(@ctx, files: args, flags: flags, remove: remove, env: env)
42
- @ctx.abort(@ctx.message('theme.push.error.push_error'))
42
+ @ctx.abort(@ctx.message("theme.push.error.push_error"))
43
43
  end
44
44
  end
45
45
 
46
- @ctx.done(@ctx.message('theme.push.info.push', @ctx.root))
46
+ @ctx.done(@ctx.message("theme.push.info.push", @ctx.root))
47
47
  end
48
48
  end
49
49
 
50
50
  def self.help
51
- ShopifyCli::Context.message('theme.push.help', ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
51
+ ShopifyCli::Context.message("theme.push.help", ShopifyCli::TOOL_NAME, ShopifyCli::TOOL_NAME)
52
52
  end
53
53
  end
54
54
  end
@@ -5,9 +5,9 @@ module Theme
5
5
  prerequisite_task :ensure_themekit_installed
6
6
 
7
7
  options do |parser, flags|
8
- parser.on('--env=ENV') { |env| flags[:env] = env }
9
- parser.on('--allow-live') { flags['allow-live'] = true }
10
- parser.on('--notify=FILES') { |files| flags['notify'] = files }
8
+ parser.on("--env=ENV") { |env| flags[:env] = env }
9
+ parser.on("--allow-live") { flags["allow-live"] = true }
10
+ parser.on("--notify=FILES") { |files| flags["notify"] = files }
11
11
  end
12
12
 
13
13
  def call(*)
@@ -18,13 +18,13 @@ module Theme
18
18
 
19
19
  flags = Themekit.add_flags(options.flags)
20
20
 
21
- CLI::UI::Frame.open(@ctx.message('theme.serve.serve')) do
21
+ CLI::UI::Frame.open(@ctx.message("theme.serve.serve")) do
22
22
  Themekit.serve(@ctx, flags: flags, env: env)
23
23
  end
24
24
  end
25
25
 
26
26
  def self.help
27
- ShopifyCli::Context.message('theme.serve.help', ShopifyCli::TOOL_NAME)
27
+ ShopifyCli::Context.message("theme.serve.help", ShopifyCli::TOOL_NAME)
28
28
  end
29
29
  end
30
30
  end
@@ -5,14 +5,14 @@ module Theme
5
5
  flag_arguments :themeid, :password, :store, :env
6
6
 
7
7
  def ask
8
- self.store ||= CLI::UI::Prompt.ask(ctx.message('theme.forms.ask_store'), allow_empty: false)
9
- ctx.puts(ctx.message('theme.forms.connect.private_app', store))
10
- self.password ||= CLI::UI::Prompt.ask(ctx.message('theme.forms.ask_password'), allow_empty: false)
8
+ self.store ||= CLI::UI::Prompt.ask(ctx.message("theme.forms.ask_store"), allow_empty: false)
9
+ ctx.puts(ctx.message("theme.forms.connect.private_app", store))
10
+ self.password ||= CLI::UI::Prompt.ask(ctx.message("theme.forms.ask_password"), allow_empty: false)
11
11
 
12
12
  errors = []
13
13
  errors << "store" if store.strip.empty?
14
14
  errors << "password" if password.strip.empty?
15
- ctx.abort(ctx.message('theme.forms.errors', errors.join(", ").capitalize)) unless errors.empty?
15
+ ctx.abort(ctx.message("theme.forms.errors", errors.join(", ").capitalize)) unless errors.empty?
16
16
 
17
17
  self.themeid, self.name = ask_theme(store: store, password: password, themeid: themeid)
18
18
  end
@@ -5,17 +5,17 @@ module Theme
5
5
  flag_arguments :title, :password, :store, :env
6
6
 
7
7
  def ask
8
- self.store ||= CLI::UI::Prompt.ask(ctx.message('theme.forms.ask_store'), allow_empty: false)
9
- ctx.puts(ctx.message('theme.forms.create.private_app', store))
10
- self.password ||= CLI::UI::Prompt.ask(ctx.message('theme.forms.ask_password'), allow_empty: false)
11
- self.title ||= CLI::UI::Prompt.ask(ctx.message('theme.forms.create.ask_title'), allow_empty: false)
8
+ self.store ||= CLI::UI::Prompt.ask(ctx.message("theme.forms.ask_store"), allow_empty: false)
9
+ ctx.puts(ctx.message("theme.forms.create.private_app", store))
10
+ self.password ||= CLI::UI::Prompt.ask(ctx.message("theme.forms.ask_password"), allow_empty: false)
11
+ self.title ||= CLI::UI::Prompt.ask(ctx.message("theme.forms.create.ask_title"), allow_empty: false)
12
12
  self.name = self.title.downcase.split(" ").join("_")
13
13
 
14
14
  errors = []
15
15
  errors << "store" if store.strip.empty?
16
16
  errors << "password" if password.strip.empty?
17
17
  errors << "title" if title.strip.empty?
18
- ctx.abort(ctx.message('theme.forms.errors', errors.join(", ").capitalize)) unless errors.empty?
18
+ ctx.abort(ctx.message("theme.forms.errors", errors.join(", ").capitalize)) unless errors.empty?
19
19
  end
20
20
  end
21
21
  end
@@ -1,29 +1,29 @@
1
1
  module Theme
2
2
  module Tasks
3
3
  class EnsureThemekitInstalled < ShopifyCli::Task
4
- URL = 'https://shopify-themekit.s3.amazonaws.com/releases/latest.json'
4
+ URL = "https://shopify-themekit.s3.amazonaws.com/releases/latest.json"
5
5
  OSMAP = {
6
- mac: 'darwin-amd64',
7
- linux: 'linux-amd64',
8
- windows: 'windows-amd64',
6
+ mac: "darwin-amd64",
7
+ linux: "linux-amd64",
8
+ windows: "windows-amd64",
9
9
  }
10
10
  VERSION_CHECK_INTERVAL = 604800
11
- VERSION_CHECK_SECTION = 'themekit_version_check'
12
- LAST_CHECKED_AT_FIELD = 'last_checked_at'
11
+ VERSION_CHECK_SECTION = "themekit_version_check"
12
+ LAST_CHECKED_AT_FIELD = "last_checked_at"
13
13
 
14
14
  def call(ctx)
15
15
  _out, stat = ctx.capture2e(Themekit::THEMEKIT)
16
16
  unless stat.success?
17
- CLI::UI::Frame.open(ctx.message('theme.tasks.ensure_themekit_installed.installing_themekit')) do
17
+ CLI::UI::Frame.open(ctx.message("theme.tasks.ensure_themekit_installed.installing_themekit")) do
18
18
  install_themekit(ctx)
19
19
  end
20
20
  end
21
21
 
22
22
  now = Time.now.to_i
23
23
  if ShopifyCli::Feature.enabled?(:themekit_auto_update) && (time_of_last_check + VERSION_CHECK_INTERVAL) < now
24
- CLI::UI::Frame.open(ctx.message('theme.tasks.ensure_themekit_installed.updating_themekit')) do
24
+ CLI::UI::Frame.open(ctx.message("theme.tasks.ensure_themekit_installed.updating_themekit")) do
25
25
  unless Themekit.update(ctx)
26
- ctx.abort(ctx.message('theme.tasks.ensure_themekit_installed.errors.update_fail'))
26
+ ctx.abort(ctx.message("theme.tasks.ensure_themekit_installed.errors.update_fail"))
27
27
  end
28
28
  update_time_of_last_check(now)
29
29
  end
@@ -33,32 +33,32 @@ module Theme
33
33
  private
34
34
 
35
35
  def install_themekit(ctx)
36
- require 'json'
37
- require 'fileutils'
38
- require 'digest'
39
- require 'open-uri'
36
+ require "json"
37
+ require "fileutils"
38
+ require "digest"
39
+ require "open-uri"
40
40
 
41
41
  begin
42
42
  begin
43
43
  releases = JSON.parse(Net::HTTP.get(URI(URL)))
44
44
  release = releases["platforms"].find { |r| r["name"] == OSMAP[ctx.os] }
45
45
  rescue
46
- ctx.abort(ctx.message('theme.tasks.ensure_themekit_installed.errors.releases_fail'))
46
+ ctx.abort(ctx.message("theme.tasks.ensure_themekit_installed.errors.releases_fail"))
47
47
  end
48
48
 
49
- ctx.puts(ctx.message('theme.tasks.ensure_themekit_installed.downloading', releases['version']))
50
- _out, stat = ctx.capture2e('curl', '-o', Themekit::THEMEKIT, release["url"])
51
- ctx.abort(ctx.message('theme.tasks.ensure_themekit_installed.errors.write_fail')) unless stat.success?
49
+ ctx.puts(ctx.message("theme.tasks.ensure_themekit_installed.downloading", releases["version"]))
50
+ _out, stat = ctx.capture2e("curl", "-o", Themekit::THEMEKIT, release["url"])
51
+ ctx.abort(ctx.message("theme.tasks.ensure_themekit_installed.errors.write_fail")) unless stat.success?
52
52
 
53
- ctx.puts(ctx.message('theme.tasks.ensure_themekit_installed.verifying'))
54
- if Digest::MD5.file(Themekit::THEMEKIT) == release['digest']
53
+ ctx.puts(ctx.message("theme.tasks.ensure_themekit_installed.verifying"))
54
+ if Digest::MD5.file(Themekit::THEMEKIT) == release["digest"]
55
55
  FileUtils.chmod("+x", Themekit::THEMEKIT)
56
- ctx.puts(ctx.message('theme.tasks.ensure_themekit_installed.successful'))
56
+ ctx.puts(ctx.message("theme.tasks.ensure_themekit_installed.successful"))
57
57
 
58
- auto = CLI::UI.confirm(ctx.message('theme.tasks.ensure_themekit_installed.auto_update'))
58
+ auto = CLI::UI.confirm(ctx.message("theme.tasks.ensure_themekit_installed.auto_update"))
59
59
  ShopifyCli::Feature.set(:themekit_auto_update, auto)
60
60
  else
61
- ctx.abort(ctx.message('theme.tasks.ensure_themekit_installed.errors.digest_fail'))
61
+ ctx.abort(ctx.message("theme.tasks.ensure_themekit_installed.errors.digest_fail"))
62
62
  end
63
63
  rescue StandardError, ShopifyCli::Abort => e
64
64
  FileUtils.rm(Themekit::THEMEKIT) if File.exist?(Themekit::THEMEKIT)
@@ -12,7 +12,7 @@ module Theme
12
12
  end
13
13
 
14
14
  def connect(ctx, store:, password:, themeid:, env:)
15
- command = build_command('get', env)
15
+ command = build_command("get", env)
16
16
  command << "--password=#{password}"
17
17
  command << "--store=#{store}"
18
18
  command << "--themeid=#{themeid}"
@@ -22,7 +22,7 @@ module Theme
22
22
  end
23
23
 
24
24
  def create(ctx, password:, store:, name:, env:)
25
- command = build_command('new', env)
25
+ command = build_command("new", env)
26
26
  command << "--password=#{password}"
27
27
  command << "--store=#{store}"
28
28
  command << "--name=#{name}"
@@ -33,11 +33,11 @@ module Theme
33
33
 
34
34
  def deploy(ctx, flags: nil, env:)
35
35
  unless push(ctx, flags: flags, env: env)
36
- ctx.abort(ctx.message('theme.deploy.push_fail'))
36
+ ctx.abort(ctx.message("theme.deploy.push_fail"))
37
37
  end
38
- ctx.done(ctx.message('theme.deploy.info.pushed'))
38
+ ctx.done(ctx.message("theme.deploy.info.pushed"))
39
39
 
40
- command = build_command('publish', env)
40
+ command = build_command("publish", env)
41
41
  (command << flags).compact!
42
42
  command.flatten!
43
43
 
@@ -46,7 +46,7 @@ module Theme
46
46
  end
47
47
 
48
48
  def generate_env(ctx, store:, password:, themeid:, env:)
49
- command = build_command('configure', env)
49
+ command = build_command("configure", env)
50
50
  command << "--password=#{password}"
51
51
  command << "--store=#{store}"
52
52
  command << "--themeid=#{themeid}"
@@ -56,7 +56,7 @@ module Theme
56
56
  end
57
57
 
58
58
  def push(ctx, files: nil, flags: nil, remove: false, env:)
59
- action = remove ? 'remove' : 'deploy'
59
+ action = remove ? "remove" : "deploy"
60
60
  command = build_command(action, env)
61
61
 
62
62
  (command << files << flags).compact!
@@ -75,28 +75,28 @@ module Theme
75
75
  path: "themes.json",
76
76
  )
77
77
  rescue ShopifyCli::API::APIRequestUnauthorizedError
78
- ctx.abort(ctx.message('theme.themekit.query_themes.bad_password'))
78
+ ctx.abort(ctx.message("theme.themekit.query_themes.bad_password"))
79
79
  rescue StandardError
80
- ctx.abort(ctx.message('theme.themekit.query_themes.not_connect'))
80
+ ctx.abort(ctx.message("theme.themekit.query_themes.not_connect"))
81
81
  end
82
82
 
83
- resp[1]['themes'].map { |theme| [theme['name'], theme['id']] }.to_h
83
+ resp[1]["themes"].map { |theme| [theme["name"], theme["id"]] }.to_h
84
84
  end
85
85
 
86
86
  def serve(ctx, flags: nil, env:)
87
- command = build_command('open', env)
87
+ command = build_command("open", env)
88
88
  out, stat = ctx.capture2e(*command)
89
89
  ctx.puts(out)
90
- ctx.abort(ctx.message('theme.serve.open_fail')) unless stat.success?
90
+ ctx.abort(ctx.message("theme.serve.open_fail")) unless stat.success?
91
91
 
92
- command = build_command('watch', env)
92
+ command = build_command("watch", env)
93
93
  (command << flags).compact!
94
94
  command.flatten!
95
95
  ctx.system(*command)
96
96
  end
97
97
 
98
98
  def update(ctx)
99
- command = build_command('update')
99
+ command = build_command("update")
100
100
  ctx.system(*command)
101
101
  end
102
102
 
@@ -104,7 +104,7 @@ module Theme
104
104
 
105
105
  def build_command(action, env = nil)
106
106
  command = [THEMEKIT, action]
107
- command << '--no-update-notifier'
107
+ command << "--no-update-notifier"
108
108
  command << "--env=#{env}" if env
109
109
  command
110
110
  end