shopify-cli 1.8.0 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +15 -2
  3. data/CHANGELOG.md +4 -1
  4. data/Gemfile.lock +3 -3
  5. data/dev.yml +3 -0
  6. data/lib/graphql/extension_create.graphql +17 -2
  7. data/lib/project_types/extension/cli.rb +2 -0
  8. data/lib/project_types/extension/commands/extension_command.rb +4 -4
  9. data/lib/project_types/extension/commands/push.rb +2 -2
  10. data/lib/project_types/extension/commands/register.rb +4 -3
  11. data/lib/project_types/extension/commands/serve.rb +1 -35
  12. data/lib/project_types/extension/extension_project.rb +15 -4
  13. data/lib/project_types/extension/extension_project_keys.rb +2 -1
  14. data/lib/project_types/extension/features/argo.rb +6 -0
  15. data/lib/project_types/extension/features/argo_renderer_package.rb +32 -0
  16. data/lib/project_types/extension/features/argo_serve.rb +69 -0
  17. data/lib/project_types/extension/messages/message_loading.rb +3 -1
  18. data/lib/project_types/extension/models/registration.rb +1 -0
  19. data/lib/project_types/extension/models/specification.rb +2 -0
  20. data/lib/project_types/extension/models/specification_handlers/default.rb +8 -0
  21. data/lib/project_types/extension/tasks/configure_features.rb +2 -0
  22. data/lib/project_types/extension/tasks/converters/registration_converter.rb +2 -0
  23. data/lib/project_types/node/commands/generate.rb +0 -22
  24. data/lib/project_types/script/cli.rb +2 -8
  25. data/lib/project_types/script/commands/create.rb +0 -7
  26. data/lib/project_types/script/commands/push.rb +2 -2
  27. data/lib/project_types/script/config/extension_points.yml +2 -0
  28. data/lib/project_types/script/errors.rb +0 -19
  29. data/lib/project_types/script/forms/create.rb +3 -14
  30. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +0 -3
  31. data/lib/project_types/script/graphql/script_service_proxy.graphql +1 -2
  32. data/lib/project_types/script/layers/application/build_script.rb +1 -2
  33. data/lib/project_types/script/layers/application/create_script.rb +30 -51
  34. data/lib/project_types/script/layers/application/extension_points.rb +3 -2
  35. data/lib/project_types/script/layers/application/push_script.rb +2 -4
  36. data/lib/project_types/script/layers/domain/extension_point.rb +56 -46
  37. data/lib/project_types/script/layers/domain/metadata.rb +18 -25
  38. data/lib/project_types/script/layers/domain/push_package.rb +0 -4
  39. data/lib/project_types/script/layers/domain/script_project.rb +34 -0
  40. data/lib/project_types/script/layers/infrastructure/assemblyscript_project_creator.rb +6 -2
  41. data/lib/project_types/script/layers/infrastructure/assemblyscript_task_runner.rb +4 -4
  42. data/lib/project_types/script/layers/infrastructure/errors.rb +12 -10
  43. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +10 -12
  44. data/lib/project_types/script/layers/infrastructure/rust_task_runner.rb +1 -1
  45. data/lib/project_types/script/layers/infrastructure/script_project_repository.rb +145 -0
  46. data/lib/project_types/script/layers/infrastructure/script_service.rb +9 -72
  47. data/lib/project_types/script/messages/messages.rb +0 -47
  48. data/lib/project_types/script/ui/error_handler.rb +7 -24
  49. data/lib/shopify-cli/context.rb +28 -0
  50. data/lib/shopify-cli/version.rb +1 -1
  51. metadata +6 -10
  52. data/lib/project_types/script/commands/disable.rb +0 -25
  53. data/lib/project_types/script/commands/enable.rb +0 -80
  54. data/lib/project_types/script/graphql/shop_script_delete.graphql +0 -14
  55. data/lib/project_types/script/graphql/shop_script_update_or_create.graphql +0 -28
  56. data/lib/project_types/script/layers/application/disable_script.rb +0 -21
  57. data/lib/project_types/script/layers/application/enable_script.rb +0 -23
  58. data/lib/project_types/script/layers/infrastructure/config_ui_repository.rb +0 -46
  59. data/lib/project_types/script/script_project.rb +0 -64
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30e766112b0e09d6de0e907ecf7e002377fe8a0ecb6776bf0975ec1677a5858a
4
- data.tar.gz: 3fbcc004481a0b06c8ccfcd0fb5890d7ab4bf6ee778a6b4dc43c773508376a05
3
+ metadata.gz: a1eb0f785e6ead5199faf7921e48209506987a24d942568e24661e96f2bc0861
4
+ data.tar.gz: 06e4effc8a4b95bf78404630b452e4cf364407019846660b0d293cace45ae245
5
5
  SHA512:
6
- metadata.gz: d3b9f2da8984619e58cb73a5a066bd67b7b0e3f050a82f794b36079d3f0850d8c57e4e346e7f6ae0c0ea01601d07e26d54359cced3e132d23246ad88bbed314f
7
- data.tar.gz: 1ec7d262e39e6b112cf25a35b85788faeb77fce56febdeb46e0f8630608ca19ec0eb032b668302515e23fbfa0831ad25492439cc8cb35e5fb376c6e2277e4596
6
+ metadata.gz: 65df9edf44e3c2ce1263acb79d619736ffc6c4b30c50d9d71f6943dfa7c740dd0a9c9440a6879d46c59387f9bc2db6671cd65a31f700bf964b65bfb9dc1da2dc
7
+ data.tar.gz: a1b9f5a17dc58b2570294205e33dd3fc1cb0a198bb4b7ca9594d91366d6169d4c92f7c9b7df0cbf8401f9a81123e78b55331ef8afd909247889a17cc046e58a2
data/.rubocop_todo.yml CHANGED
@@ -1,11 +1,24 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2020-12-01 16:33:09 UTC using RuboCop version 1.4.1.
3
+ # on 2021-04-08 18:25:36 UTC using RuboCop version 1.12.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
- # Offense count: 30
9
+ # Offense count: 35
10
10
  Minitest/MultipleAssertions:
11
11
  Max: 9
12
+
13
+ # Offense count: 1
14
+ # Cop supports --auto-correct.
15
+ Style/PerlBackrefs:
16
+ Exclude:
17
+ - 'lib/docgen/markdown.rb'
18
+
19
+ # Offense count: 2
20
+ # Cop supports --auto-correct.
21
+ Style/RedundantBegin:
22
+ Exclude:
23
+ - 'lib/shopify-cli/shopifolk.rb'
24
+ - 'test/shopify-cli/tunnel_test.rb'
data/CHANGELOG.md CHANGED
@@ -1,9 +1,12 @@
1
1
  Unreleased
2
2
  ------
3
3
 
4
- Version 1.8.0
4
+ Version 1.9.0
5
5
  -------------
6
+ * [1181](https://github.com/Shopify/shopify-app-cli/pull/1181): Remove the subcommand references of the `generate` command for node apps (fixes [1176](https://github.com/Shopify/shopify-app-cli/issues/1176))
6
7
 
8
+ Version 1.8.0
9
+ -------------
7
10
  * [1119](https://github.com/Shopify/shopify-app-cli/pull/1119): Enable guest serialization for scripts
8
11
 
9
12
  Version 1.7.1
data/Gemfile.lock CHANGED
@@ -22,7 +22,7 @@ GEM
22
22
  ruby-progressbar
23
23
  mocha (1.11.2)
24
24
  parallel (1.20.1)
25
- parser (3.0.0.0)
25
+ parser (3.0.1.0)
26
26
  ast (~> 2.4.1)
27
27
  pry (0.13.1)
28
28
  coderay (~> 1.1)
@@ -34,8 +34,8 @@ GEM
34
34
  rainbow (3.0.0)
35
35
  rake (13.0.1)
36
36
  regexp_parser (2.1.1)
37
- rexml (3.2.4)
38
- rubocop (1.11.0)
37
+ rexml (3.2.5)
38
+ rubocop (1.12.1)
39
39
  parallel (~> 1.10)
40
40
  parser (>= 3.0.0.0)
41
41
  rainbow (>= 2.2.2, < 4.0)
data/dev.yml CHANGED
@@ -5,6 +5,9 @@ type:
5
5
  up:
6
6
  - ruby: 2.5.1
7
7
  - bundler
8
+ - node:
9
+ version: 14.9.0
10
+ yarn: true
8
11
 
9
12
  test:
10
13
  desc: 'Run tests.'
@@ -1,7 +1,22 @@
1
- mutation ExtensionCreate($api_key: String!, $type: ExtensionType!, $title: String!, $config: JSON!, $extension_context: String) {
2
- extensionCreate(input: {apiKey: $api_key, type: $type, title: $title, config: $config, context: $extension_context}) {
1
+ mutation ExtensionCreate(
2
+ $api_key: String!
3
+ $type: ExtensionType!
4
+ $title: String!
5
+ $config: JSON!
6
+ $extension_context: String
7
+ ) {
8
+ extensionCreate(
9
+ input: {
10
+ apiKey: $api_key
11
+ type: $type
12
+ title: $title
13
+ config: $config
14
+ context: $extension_context
15
+ }
16
+ ) {
3
17
  extensionRegistration {
4
18
  id
19
+ uuid
5
20
  type
6
21
  title
7
22
  draftVersion {
@@ -57,6 +57,8 @@ module Extension
57
57
  end
58
58
 
59
59
  module Features
60
+ autoload :ArgoRendererPackage, Project.project_filepath("features/argo_renderer_package")
61
+ autoload :ArgoServe, Project.project_filepath("features/argo_serve")
60
62
  autoload :ArgoSetup, Project.project_filepath("features/argo_setup")
61
63
  autoload :ArgoSetupStep, Project.project_filepath("features/argo_setup_step")
62
64
  autoload :ArgoSetupSteps, Project.project_filepath("features/argo_setup_steps")
@@ -8,16 +8,16 @@ module Extension
8
8
  @project ||= ExtensionProject.current
9
9
  end
10
10
 
11
- def extension_type
12
- @extension_type ||= begin
13
- identifier = project.extension_type_identifier
11
+ def specification_handler
12
+ @specification_handler ||= begin
13
+ identifier = project.specification_identifier
14
14
  Models::LazySpecificationHandler.new(identifier) do
15
15
  specifications = Models::Specifications.new(
16
16
  fetch_specifications: Tasks::FetchSpecifications.new(api_key: project.app.api_key, context: @ctx)
17
17
  )
18
18
 
19
19
  unless specifications.valid?(identifier)
20
- @ctx.abort(@ctx.message("errors.unknown_type", project.extension_type_identifier))
20
+ @ctx.abort(@ctx.message("errors.unknown_type", project.specification_identifier))
21
21
  end
22
22
 
23
23
  specifications[identifier]
@@ -59,8 +59,8 @@ module Extension
59
59
  context: @ctx,
60
60
  api_key: project.app.api_key,
61
61
  registration_id: project.registration_id,
62
- config: extension_type.config(@ctx),
63
- extension_context: extension_type.extension_context(@ctx)
62
+ config: specification_handler.config(@ctx),
63
+ extension_context: specification_handler.extension_context(@ctx)
64
64
  )
65
65
  end
66
66
  end
@@ -27,7 +27,7 @@ module Extension
27
27
  private
28
28
 
29
29
  def confirm_registration
30
- @ctx.puts(@ctx.message("register.confirm_info", extension_type.name))
30
+ @ctx.puts(@ctx.message("register.confirm_info", specification_handler.name))
31
31
  CLI::UI::Prompt.confirm(@ctx.message("register.confirm_question"))
32
32
  end
33
33
 
@@ -37,10 +37,10 @@ module Extension
37
37
  Tasks::CreateExtension.call(
38
38
  context: @ctx,
39
39
  api_key: app.api_key,
40
- type: extension_type.graphql_identifier,
40
+ type: specification_handler.graphql_identifier,
41
41
  title: project.title,
42
42
  config: {},
43
- extension_context: extension_type.extension_context(@ctx)
43
+ extension_context: specification_handler.extension_context(@ctx)
44
44
  )
45
45
  end
46
46
 
@@ -50,6 +50,7 @@ module Extension
50
50
  api_key: app.api_key,
51
51
  api_secret: app.secret,
52
52
  registration_id: registration.id,
53
+ registration_uuid: registration.uuid,
53
54
  title: project.title
54
55
  )
55
56
  end
@@ -3,27 +3,8 @@
3
3
  module Extension
4
4
  module Commands
5
5
  class Serve < ExtensionCommand
6
- YARN_SERVE_COMMAND = %w(server)
7
- NPM_SERVE_COMMAND = %w(run-script server)
8
-
9
6
  def call(_args, _command_name)
10
- if argo_admin?
11
- ShopifyCli::Tasks::EnsureEnv.call(@ctx, required: [:api_key, :secret, :shop])
12
- ShopifyCli::Tasks::EnsureDevStore.call(@ctx)
13
- validate_env
14
- end
15
-
16
- CLI::UI::Frame.open(@ctx.message("serve.frame_title")) do
17
- yarn_serve_command = YARN_SERVE_COMMAND
18
- npm_serve_command = NPM_SERVE_COMMAND
19
- if argo_admin?
20
- serve_args = %W(--shop=#{project.env.shop} --apiKey=#{project.env.api_key})
21
- yarn_serve_command += serve_args
22
- npm_serve_command += %w(--) + serve_args
23
- end
24
- success = ShopifyCli::JsSystem.call(@ctx, yarn: yarn_serve_command, npm: npm_serve_command)
25
- @ctx.abort(@ctx.message("serve.serve_failure_message")) unless success
26
- end
7
+ specification_handler.serve(@ctx)
27
8
  end
28
9
 
29
10
  def self.help
@@ -32,21 +13,6 @@ module Extension
32
13
  Usage: {{command:#{ShopifyCli::TOOL_NAME} serve}}
33
14
  HELP
34
15
  end
35
-
36
- private
37
-
38
- def argo_admin?
39
- ShopifyCli::Shopifolk.check &&
40
- ShopifyCli::Feature.enabled?(:argo_admin_beta) &&
41
- extension_type.specification.features&.argo&.surface == "admin"
42
- end
43
-
44
- def validate_env
45
- ExtensionProject.reload
46
- @ctx.abort(@ctx.message("serve.serve_missing_information")) if
47
- project.env.shop.nil? || project.env.api_key.nil? ||
48
- project.env.shop.strip.empty? || project.env.api_key.strip.empty?
49
- end
50
16
  end
51
17
  end
52
18
  end
@@ -9,17 +9,20 @@ module Extension
9
9
  context,
10
10
  project_type: :extension,
11
11
  organization_id: nil,
12
- "#{ExtensionProjectKeys::EXTENSION_TYPE_KEY}": type
12
+ "#{ExtensionProjectKeys::SPECIFICATION_IDENTIFIER_KEY}": type
13
13
  )
14
14
  end
15
15
 
16
- def write_env_file(context:, title:, api_key: "", api_secret: "", registration_id: nil)
16
+ def write_env_file(
17
+ context:, title:, api_key: "", api_secret: "", registration_id: nil, registration_uuid: nil
18
+ )
17
19
  ShopifyCli::Resources::EnvFile.new(
18
20
  api_key: api_key,
19
21
  secret: api_secret,
20
22
  extra: {
21
23
  ExtensionProjectKeys::TITLE_KEY => title,
22
24
  ExtensionProjectKeys::REGISTRATION_ID_KEY => registration_id,
25
+ ExtensionProjectKeys::REGISTRATION_UUID_KEY => registration_uuid || generate_temporary_uuid,
23
26
  }.compact
24
27
  ).write(context)
25
28
 
@@ -49,8 +52,8 @@ module Extension
49
52
  get_extra_field(ExtensionProjectKeys::TITLE_KEY)
50
53
  end
51
54
 
52
- def extension_type_identifier
53
- config[ExtensionProjectKeys::EXTENSION_TYPE_KEY]
55
+ def specification_identifier
56
+ config[ExtensionProjectKeys::SPECIFICATION_IDENTIFIER_KEY]
54
57
  end
55
58
 
56
59
  def registration_id?
@@ -63,10 +66,18 @@ module Extension
63
66
  get_extra_field(ExtensionProjectKeys::REGISTRATION_ID_KEY).to_i
64
67
  end
65
68
 
69
+ def registration_uuid
70
+ get_extra_field(ExtensionProjectKeys::REGISTRATION_UUID_KEY)
71
+ end
72
+
66
73
  def reload
67
74
  @env = nil
68
75
  end
69
76
 
77
+ def self.generate_temporary_uuid
78
+ "dev-#{SecureRandom.uuid}"
79
+ end
80
+
70
81
  private
71
82
 
72
83
  def get_extra_field(key)
@@ -4,7 +4,8 @@ require "shopify_cli"
4
4
  module Extension
5
5
  module ExtensionProjectKeys
6
6
  REGISTRATION_ID_KEY = "EXTENSION_ID"
7
- EXTENSION_TYPE_KEY = "EXTENSION_TYPE"
7
+ REGISTRATION_UUID_KEY = "EXTENSION_UUID"
8
+ SPECIFICATION_IDENTIFIER_KEY = "EXTENSION_TYPE"
8
9
  TITLE_KEY = "EXTENSION_TITLE"
9
10
  end
10
11
  end
@@ -47,6 +47,12 @@ module Extension
47
47
  end
48
48
  end
49
49
 
50
+ def renderer_package(context)
51
+ Features::ArgoRendererPackage.new(
52
+ package_name: renderer_package_name, version: extract_argo_renderer_version(context)
53
+ )
54
+ end
55
+
50
56
  private
51
57
 
52
58
  def extract_argo_renderer_version(context)
@@ -0,0 +1,32 @@
1
+ module Extension
2
+ module Features
3
+ class ArgoRendererPackage
4
+ include SmartProperties
5
+
6
+ ARGO_CHECKOUT = "@shopify/argo-checkout"
7
+ ARGO_ADMIN = "@shopify/argo-admin"
8
+
9
+ PACKAGE_NAMES = [
10
+ ARGO_CHECKOUT,
11
+ ARGO_ADMIN,
12
+ ].freeze
13
+ MINIMUM_ARGO_VERSION = "0.9.3".freeze
14
+
15
+ property! :package_name, accepts: PACKAGE_NAMES
16
+ property! :version, accepts: String
17
+
18
+ def checkout?
19
+ package_name == ARGO_CHECKOUT
20
+ end
21
+
22
+ def admin?
23
+ package_name == ARGO_ADMIN
24
+ end
25
+
26
+ def supports_uuid_flag?
27
+ return false if checkout?
28
+ Gem::Version.new(version) > Gem::Version.new(MINIMUM_ARGO_VERSION)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,69 @@
1
+ module Extension
2
+ module Features
3
+ class ArgoServe
4
+ include SmartProperties
5
+
6
+ property! :specification_handler, accepts: Extension::Models::SpecificationHandlers::Default
7
+ property! :context, accepts: ShopifyCli::Context
8
+
9
+ YARN_SERVE_COMMAND = %w(server)
10
+ NPM_SERVE_COMMAND = %w(run-script server)
11
+
12
+ def call
13
+ validate_env!
14
+
15
+ CLI::UI::Frame.open(context.message("serve.frame_title")) do
16
+ success = ShopifyCli::JsSystem.call(context, yarn: yarn_serve_command, npm: npm_serve_command)
17
+ context.abort(context.message("serve.serve_failure_message")) unless success
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def specification
24
+ specification_handler.specification
25
+ end
26
+
27
+ def validate_env!
28
+ ExtensionProject.reload
29
+
30
+ ShopifyCli::Shopifolk.check && ShopifyCli::Feature.enabled?(:argo_admin_beta)
31
+
32
+ required_fields = specification.features.argo.required_fields
33
+
34
+ return if required_fields.none?
35
+
36
+ ShopifyCli::Tasks::EnsureEnv.call(context, required: required_fields)
37
+ ShopifyCli::Tasks::EnsureDevStore.call(context) if required_fields.include?(:shop)
38
+
39
+ project = ExtensionProject.current
40
+
41
+ return if required_fields.all? do |field|
42
+ value = project.env.public_send(field)
43
+ value && !value.strip.empty?
44
+ end
45
+
46
+ context.abort(context.message("serve.serve_missing_information"))
47
+ end
48
+
49
+ def yarn_serve_command
50
+ YARN_SERVE_COMMAND + serve_options(specification.features.argo.required_fields)
51
+ end
52
+
53
+ def npm_serve_command
54
+ NPM_SERVE_COMMAND + ["--"] + serve_options(specification.features.argo.required_fields)
55
+ end
56
+
57
+ def serve_options(required_fields)
58
+ renderer_package = specification_handler.renderer_package(context)
59
+ project = ExtensionProject.current
60
+ @serve_options ||= [].tap do |options|
61
+ options << "--shop=#{project.env.shop}" if required_fields.include?(:shop)
62
+ options << "--apiKey=#{project.env.api_key}" if required_fields.include?(:api_key)
63
+ options << "--argoVersion=#{renderer_package.version}" if renderer_package.admin?
64
+ options << "--uuid=#{project.registration_uuid}" if renderer_package.supports_uuid_flag?
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -16,7 +16,9 @@ module Extension
16
16
 
17
17
  def self.load_current_type_messages
18
18
  return unless ShopifyCli::Project.has_current?
19
- messages_for_type(ShopifyCli::Project.current.config[Extension::ExtensionProjectKeys::EXTENSION_TYPE_KEY])
19
+ messages_for_type(
20
+ ShopifyCli::Project.current.config[Extension::ExtensionProjectKeys::SPECIFICATION_IDENTIFIER_KEY]
21
+ )
20
22
  end
21
23
 
22
24
  def self.messages_for_type(type_identifier)
@@ -7,6 +7,7 @@ module Extension
7
7
  include SmartProperties
8
8
 
9
9
  property! :id, accepts: Integer
10
+ property! :uuid, accepts: String
10
11
  property! :type, accepts: String
11
12
  property! :title, accepts: String
12
13
  property! :draft_version, accepts: Extension::Models::Version
@@ -10,6 +10,8 @@ module Extension
10
10
  property! :surface, converts: :to_str
11
11
  property! :renderer_package_name, converts: :to_str
12
12
  property! :git_template, converts: :to_str
13
+ property! :required_fields, accepts: Array, default: []
14
+ property! :required_shop_beta_flags, accepts: Array, default: []
13
15
  end
14
16
 
15
17
  def self.build(feature_set_attributes)