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
@@ -1,78 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Script
4
- module Commands
5
- class Enable < ShopifyCli::Command
6
- options do |parser, flags|
7
- parser.on('--config_props=KEYVALUEPAIRS', Array) { |t| flags[:config_props] = t }
8
- parser.on('--config_file=CONFIGFILEPATH') { |t| flags[:config_file] = t }
9
- end
10
-
11
- def call(_args, _name)
12
- ShopifyCli::Tasks::EnsureEnv.call(@ctx, required: [:api_key, :secret, :shop])
13
- project = ScriptProject.current
14
- api_key = project.env[:api_key]
15
- shop_domain = project.env[:shop]
16
-
17
- Layers::Application::EnableScript.call(
18
- ctx: @ctx,
19
- api_key: api_key,
20
- shop_domain: shop_domain,
21
- configuration: acquire_configuration(**slice(options.flags, :config_file, :config_props)),
22
- extension_point_type: project.extension_point_type,
23
- title: project.script_name
24
- )
25
- @ctx.puts(@ctx.message(
26
- 'script.enable.script_enabled',
27
- api_key: api_key,
28
- shop_domain: shop_domain,
29
- type: project.extension_point_type.capitalize,
30
- title: project.script_name
31
- ))
32
- @ctx.puts(@ctx.message('script.enable.info'))
33
- rescue Errors::InvalidConfigYAMLError => e
34
- UI::ErrorHandler.pretty_print_and_raise(e)
35
- rescue StandardError => e
36
- UI::ErrorHandler.pretty_print_and_raise(e, failed_op: @ctx.message('script.enable.error.operation_failed'))
37
- end
38
-
39
- def self.help
40
- ShopifyCli::Context.message('script.enable.help', ShopifyCli::TOOL_NAME)
41
- end
42
-
43
- private
44
-
45
- def acquire_configuration(config_file: nil, config_props: nil)
46
- properties = {}
47
- properties = YAML.load(File.read(config_file)) unless config_file.nil?
48
- properties = properties.merge(parse_config_props(config_props)) unless config_props.nil?
49
-
50
- configuration = { entries: [] }
51
- properties.each do |key, value|
52
- configuration[:entries].push({
53
- key: key,
54
- value: value,
55
- })
56
- end
57
- configuration
58
- rescue Errno::ENOENT, Psych::SyntaxError
59
- raise Errors::InvalidConfigYAMLError, options.flags[:config_file]
60
- end
61
-
62
- def parse_config_props(config_props)
63
- Hash[
64
- config_props.map do |s|
65
- args = s.split(':').map(&:strip)
66
- raise Errors::InvalidConfigProps unless args.size == 2
67
- args
68
- end
69
- ]
70
- end
71
-
72
- # No slice pre Ruby 2.5 so roll our own
73
- def slice(hash, *keys)
74
- Hash[hash.to_a - hash.select { |key, _value| !keys.include?(key) }.to_a]
75
- end
76
- end
77
- end
78
- end
@@ -1,14 +0,0 @@
1
- mutation ShopScriptDelete($extensionPointName: ExtensionPointName!) {
2
- shopScriptDelete(extensionPointName: $extensionPointName) {
3
- userErrors {
4
- field
5
- message
6
- tag
7
- }
8
- shopScript {
9
- extensionPointName
10
- shopId
11
- title
12
- }
13
- }
14
- }
@@ -1,28 +0,0 @@
1
- mutation ShopScriptUpdateOrCreate(
2
- $extensionPointName: ExtensionPointName!,
3
- $configuration: ConfigurationInput,
4
- $title: String
5
- ) {
6
- shopScriptUpdateOrCreate(
7
- extensionPointName: $extensionPointName,
8
- configuration: $configuration,
9
- title: $title
10
- ) {
11
- userErrors {
12
- field
13
- message
14
- tag
15
- }
16
- shopScript {
17
- extensionPointName
18
- shopId
19
- title
20
- configuration {
21
- entries {
22
- key,
23
- value
24
- }
25
- }
26
- }
27
- }
28
- }
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Script
4
- module Layers
5
- module Application
6
- class DisableScript
7
- def self.call(ctx:, api_key:, shop_domain:, extension_point_type:)
8
- UI::PrintingSpinner.spin(ctx, ctx.message('script.application.disabling')) do |p_ctx, spinner|
9
- script_service = Infrastructure::ScriptService.new(ctx: p_ctx)
10
- script_service.disable(
11
- api_key: api_key,
12
- shop_domain: shop_domain,
13
- extension_point_type: extension_point_type,
14
- )
15
- spinner.update_title(p_ctx.message('script.application.disabled'))
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Script
4
- module Layers
5
- module Application
6
- class EnableScript
7
- def self.call(ctx:, api_key:, shop_domain:, configuration:, extension_point_type:, title:)
8
- UI::PrintingSpinner.spin(ctx, ctx.message('script.application.enabling')) do |p_ctx, spinner|
9
- script_service = Infrastructure::ScriptService.new(ctx: p_ctx)
10
- script_service.enable(
11
- api_key: api_key,
12
- shop_domain: shop_domain,
13
- configuration: configuration,
14
- extension_point_type: extension_point_type,
15
- title: title
16
- )
17
- spinner.update_title(p_ctx.message('script.application.enabled'))
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Script
4
- class ScriptProject < ShopifyCli::Project
5
- attr_reader :extension_point_type, :script_name, :language, :description
6
-
7
- def initialize(*args)
8
- super
9
- @extension_point_type = lookup_config!('extension_point_type')
10
- raise Errors::DeprecatedEPError, @extension_point_type if deprecated?(@extension_point_type)
11
- @script_name = lookup_config!('script_name')
12
- @description = lookup_config('description')
13
- @language = lookup_language
14
- ShopifyCli::Core::Monorail.metadata = {
15
- "script_name" => @script_name,
16
- "extension_point_type" => @extension_point_type,
17
- "language" => @language,
18
- }
19
- end
20
-
21
- def api_key
22
- env[:api_key]
23
- end
24
-
25
- private
26
-
27
- def deprecated?(ep)
28
- Script::Layers::Application::ExtensionPoints.deprecated_types.include?(ep)
29
- end
30
-
31
- def lookup_config(key)
32
- return nil unless config.key?(key)
33
- config[key]
34
- end
35
-
36
- def lookup_config!(key)
37
- raise Errors::InvalidContextError, key unless config.key?(key)
38
- config[key]
39
- end
40
-
41
- def lookup_language
42
- lang = lookup_config('language')&.downcase || Layers::Domain::ExtensionPointAssemblyScriptSDK.language
43
- if Layers::Application::ExtensionPoints.supported_language?(type: extension_point_type, language: lang)
44
- lang
45
- else
46
- raise Errors::InvalidLanguageError.new(lang, extension_point_type)
47
- end
48
- end
49
-
50
- class << self
51
- def create(ctx, dir)
52
- raise Errors::ScriptProjectAlreadyExistsError, dir if ctx.dir_exist?(dir)
53
- ctx.mkdir_p(dir)
54
- ctx.chdir(dir)
55
- end
56
-
57
- def cleanup(ctx:, script_name:, root_dir:)
58
- ctx.chdir(root_dir)
59
- ctx.rm_r("#{root_dir}/#{script_name}") if ctx.dir_exist?("#{root_dir}/#{script_name}")
60
- end
61
- end
62
- end
63
- end