shopify-cli 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +0 -4
  3. data/CHANGELOG.md +24 -0
  4. data/Gemfile.lock +4 -4
  5. data/lib/graphql/get_variant_id.graphql +16 -0
  6. data/lib/project_types/extension/cli.rb +9 -1
  7. data/lib/project_types/extension/commands/push.rb +0 -1
  8. data/lib/project_types/extension/commands/serve.rb +8 -2
  9. data/lib/project_types/extension/extension_project.rb +21 -1
  10. data/lib/project_types/extension/features/argo.rb +1 -11
  11. data/lib/project_types/extension/features/argo_runtime.rb +6 -38
  12. data/lib/project_types/extension/features/argo_serve.rb +30 -1
  13. data/lib/project_types/extension/features/runtimes/admin.rb +29 -0
  14. data/lib/project_types/extension/features/runtimes/base.rb +19 -0
  15. data/lib/project_types/extension/features/runtimes/checkout_post_purchase.rb +23 -0
  16. data/lib/project_types/extension/features/runtimes/checkout_ui_extension.rb +29 -0
  17. data/lib/project_types/extension/messages/messages.rb +9 -0
  18. data/lib/project_types/extension/models/product.rb +12 -0
  19. data/lib/project_types/extension/models/specification_handlers/checkout_post_purchase.rb +10 -0
  20. data/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +11 -3
  21. data/lib/project_types/extension/models/specification_handlers/default.rb +13 -4
  22. data/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +12 -0
  23. data/lib/project_types/extension/tasks/configure_features.rb +1 -0
  24. data/lib/project_types/extension/tasks/converters/product_converter.rb +21 -0
  25. data/lib/project_types/extension/tasks/get_product.rb +22 -0
  26. data/lib/project_types/script/commands/create.rb +1 -1
  27. data/lib/project_types/script/graphql/app_script_set.graphql +40 -0
  28. data/lib/project_types/script/graphql/app_script_update_or_create.graphql +0 -44
  29. data/lib/project_types/script/graphql/module_upload_url_generate.graphql +9 -0
  30. data/lib/project_types/script/layers/domain/push_package.rb +1 -2
  31. data/lib/project_types/script/layers/infrastructure/errors.rb +2 -0
  32. data/lib/project_types/script/layers/infrastructure/push_package_repository.rb +0 -1
  33. data/lib/project_types/script/layers/infrastructure/script_service.rb +95 -45
  34. data/lib/project_types/script/messages/messages.rb +3 -0
  35. data/lib/project_types/script/ui/error_handler.rb +5 -0
  36. data/lib/project_types/theme/commands/pull.rb +6 -0
  37. data/lib/project_types/theme/commands/push.rb +6 -0
  38. data/lib/project_types/theme/forms/select.rb +1 -1
  39. data/lib/shopify-cli/core/monorail.rb +2 -1
  40. data/lib/shopify-cli/process_supervision.rb +14 -14
  41. data/lib/shopify-cli/theme/dev_server/header_hash.rb +4 -0
  42. data/lib/shopify-cli/theme/dev_server/proxy.rb +13 -1
  43. data/lib/shopify-cli/theme/file.rb +11 -3
  44. data/lib/shopify-cli/theme/ignore_filter.rb +7 -0
  45. data/lib/shopify-cli/theme/syncer.rb +1 -1
  46. data/lib/shopify-cli/version.rb +1 -1
  47. data/shopify-cli.gemspec +1 -1
  48. metadata +14 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df03f65d3f06543a72fff5a777f93b7948aaa97c5ea10b42039d550cb82c0432
4
- data.tar.gz: b0741e669b67f6a39e030d7dfb7aa252dcf79ff5b15fd4ad27d543a9ef6347d1
3
+ metadata.gz: 200674ac9337744994af930500ea30904f13292fba380ec0d58cf990f94c50f5
4
+ data.tar.gz: cb7f7b17ebbdbc430afe269d713e68cf9db00e71a7aa5026c1752ba8f2db9792
5
5
  SHA512:
6
- metadata.gz: 8ab134a89911c7b4468253efc5798eae0552bcb38099fd8f8aa9aa0a5144efa52cb7cd62d7b4b064b6cf8618ca0dbc7d24572fd2f3e83bb1ffa320bfb7849ab9
7
- data.tar.gz: 9db58f843181d955b76a7c48af7663b3ab2327b6884c25ffba9a36a4cf5b1b4d184740c42ee7e2dc6ba6eece85785aa15709df8c3d604610e58f2e5a320ba084
6
+ metadata.gz: eed6884b0ee2ec5dc30bfbd4927dedb13ac3a77088af02a24ada09b08d1341696c56c8ce01d177cffe7c67f5db262d2146c51a0f95345e628c1e8a477debe543
7
+ data.tar.gz: e5211bf92e8b8cab56a17e3714ffcc3d8a8bf8d63aa408c4621a1a65778d4ff0a0d3ae6c57613ee46661d19d9441246aa57388f58f46116acbb712c8f1841750
@@ -24,10 +24,6 @@ Tip: include an error message (in a `<details></details>` tag) if your issue is
24
24
  1.
25
25
  1.
26
26
 
27
- ## Reduced test case
28
-
29
- The best way to get your bug fixed is to provide a [reduced test case](https://developer.mozilla.org/en-US/docs/Mozilla/QA/Reducing_testcases).
30
-
31
27
 
32
28
 
33
29
  ## Specifications
data/CHANGELOG.md CHANGED
@@ -1,6 +1,30 @@
1
1
  Unreleased
2
2
  ------
3
3
 
4
+ Version 2.3.0
5
+ ------
6
+
7
+ * [#1386](https://github.com/Shopify/shopify-cli/pull/1386): Update Theme-Check to 1.2
8
+ * [#1457](https://github.com/Shopify/shopify-cli/pull/1457): Fix uploading of binary theme files under Windows
9
+ * [#1480](https://github.com/Shopify/shopify-cli/pull/1480): Fix customers pages not working with `theme serve`
10
+ * [#1479](https://github.com/Shopify/shopify-cli/pull/1479): Add theme push & pull option to ignore files per command
11
+
12
+ Version 2.2.2
13
+ ------
14
+ * [1382](https://github.com/Shopify/shopify-cli/pull/1382): Client side module upload for Scripts
15
+
16
+ Version 2.2.1
17
+ ------
18
+
19
+ * [1432](https://github.com/Shopify/shopify-cli/pull/1432) New method for determining renderer package name
20
+
21
+ Version 2.2.0
22
+ ------
23
+ * [#1424](https://github.com/Shopify/shopify-cli/pull/1424/): Add `--resourceUrl` flag to extension serve command
24
+ * [#1419](https://github.com/Shopify/shopify-cli/pull/1419): Remove analytics prompt when used in CI
25
+ * [#1418](https://github.com/Shopify/shopify-cli/pull/1418): Auto configure resource URL for Checkout Extensions
26
+ * [#1399](https://github.com/Shopify/shopify-cli/pull/1399): Fix error when running `shopify extension serve` in a theme app extension project
27
+
4
28
  Version 2.1.0
5
29
  -------------
6
30
  * [#1357](https://github.com/Shopify/shopify-cli/pull/1357): Update Theme-Check to 1.1
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify-cli (2.1.0)
4
+ shopify-cli (2.3.0)
5
5
  listen (~> 3.5)
6
- theme-check (~> 1.1)
6
+ theme-check (~> 1.2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -76,7 +76,7 @@ GEM
76
76
  rubocop-shopify (2.0.1)
77
77
  rubocop (~> 1.11)
78
78
  ruby-progressbar (1.11.0)
79
- theme-check (1.1.0)
79
+ theme-check (1.2.0)
80
80
  liquid (>= 5.0.1)
81
81
  nokogumbo
82
82
  timecop (0.9.2)
@@ -108,4 +108,4 @@ DEPENDENCIES
108
108
  webmock
109
109
 
110
110
  BUNDLED WITH
111
- 2.1.4
111
+ 2.2.22
@@ -0,0 +1,16 @@
1
+ query {
2
+ products(first: 1) {
3
+ edges {
4
+ node {
5
+ id
6
+ variants(first: 1) {
7
+ edges {
8
+ node {
9
+ id
10
+ }
11
+ }
12
+ }
13
+ }
14
+ }
15
+ }
16
+ }
@@ -40,12 +40,14 @@ module Extension
40
40
  autoload :ChooseNextAvailablePort, Project.project_filepath("tasks/choose_next_available_port")
41
41
  autoload :FindNpmPackages, Project.project_filepath("tasks/find_npm_packages")
42
42
  autoload :GetExtensions, Project.project_filepath("tasks/get_extensions")
43
+ autoload :GetProduct, Project.project_filepath("tasks/get_product")
43
44
 
44
45
  module Converters
45
46
  autoload :RegistrationConverter, Project.project_filepath("tasks/converters/registration_converter")
46
47
  autoload :VersionConverter, Project.project_filepath("tasks/converters/version_converter")
47
48
  autoload :ValidationErrorConverter, Project.project_filepath("tasks/converters/validation_error_converter")
48
49
  autoload :AppConverter, Project.project_filepath("tasks/converters/app_converter")
50
+ autoload :ProductConverter, Project.project_filepath("tasks/converters/product_converter")
49
51
  end
50
52
  end
51
53
 
@@ -63,6 +65,12 @@ module Extension
63
65
  end
64
66
 
65
67
  module Features
68
+ module Runtimes
69
+ autoload :Admin, Project.project_filepath("features/runtimes/admin")
70
+ autoload :Base, Project.project_filepath("features/runtimes/base")
71
+ autoload :CheckoutPostPurchase, Project.project_filepath("features/runtimes/checkout_post_purchase")
72
+ autoload :CheckoutUiExtension, Project.project_filepath("features/runtimes/checkout_ui_extension")
73
+ end
66
74
  autoload :ArgoServe, Project.project_filepath("features/argo_serve")
67
75
  autoload :ArgoServeOptions, Project.project_filepath("features/argo_serve_options")
68
76
  autoload :ArgoSetup, Project.project_filepath("features/argo_setup")
@@ -77,7 +85,6 @@ module Extension
77
85
  module Models
78
86
  module SpecificationHandlers
79
87
  autoload :Default, Project.project_filepath("models/specification_handlers/default")
80
- autoload :CheckoutArgoExtension, Project.project_filepath("models/specification_handlers/checkout_ui_extension")
81
88
  end
82
89
 
83
90
  autoload :App, Project.project_filepath("models/app")
@@ -88,6 +95,7 @@ module Extension
88
95
  autoload :Specifications, Project.project_filepath("models/specifications")
89
96
  autoload :LazySpecificationHandler, Project.project_filepath("models/lazy_specification_handler")
90
97
  autoload :NpmPackage, Project.project_filepath("models/npm_package")
98
+ autoload :Product, Project.project_filepath("models/product")
91
99
  end
92
100
 
93
101
  autoload :ExtensionProjectKeys, Project.project_filepath("extension_project_keys")
@@ -11,7 +11,6 @@ module Extension
11
11
  def call(args, name)
12
12
  Command::Register.new(@ctx).call(args, name) unless project.registered?
13
13
  Command::Build.new(@ctx).call(args, name) unless specification_handler.specification.options[:skip_build]
14
-
15
14
  CLI::UI::Frame.open(@ctx.message("push.frame_title")) do
16
15
  updated_draft_version = update_draft
17
16
  show_message(updated_draft_version)
@@ -9,19 +9,24 @@ module Extension
9
9
 
10
10
  options do |parser, flags|
11
11
  parser.on("-t", "--[no-]tunnel", "Establish an ngrok tunnel") { |tunnel| flags[:tunnel] = tunnel }
12
+ parser.on("--resourceUrl=RESOURCE_URL", "Provide a resource URL") do |resource_url|
13
+ flags[:resource_url] = resource_url
14
+ end
12
15
  end
13
16
 
14
17
  class RuntimeConfiguration
15
18
  include SmartProperties
16
19
 
17
20
  property :tunnel_url, accepts: String, default: nil
21
+ property :resource_url, accepts: String, default: nil
18
22
  property! :tunnel_requested, accepts: [true, false], reader: :tunnel_requested?, default: true
19
23
  property! :port, accepts: (1...(2**16)), default: DEFAULT_PORT
20
24
  end
21
25
 
22
26
  def call(_args, _command_name)
23
27
  config = RuntimeConfiguration.new(
24
- tunnel_requested: tunnel_requested?
28
+ tunnel_requested: tunnel_requested?,
29
+ resource_url: options.flags[:resource_url]
25
30
  )
26
31
 
27
32
  ShopifyCli::Result
@@ -74,7 +79,8 @@ module Extension
74
79
  specification_handler.serve(
75
80
  context: @ctx,
76
81
  tunnel_url: runtime_configuration.tunnel_url,
77
- port: runtime_configuration.port
82
+ port: runtime_configuration.port,
83
+ resource_url: runtime_configuration.resource_url
78
84
  )
79
85
  runtime_configuration
80
86
  end
@@ -14,6 +14,24 @@ module Extension
14
14
  )
15
15
  end
16
16
 
17
+ def update_env_file(context:, **updates)
18
+ current_config = {
19
+ title: current.title,
20
+ shop: current.env.shop,
21
+ api_key: current.app.api_key,
22
+ api_secret: current.app.secret,
23
+ registration_id: current.registration_id,
24
+ registration_uuid: current.registration_uuid,
25
+ resource_url: current.resource_url,
26
+ }
27
+
28
+ write_env_file(
29
+ context: context,
30
+ **current_config,
31
+ **updates
32
+ )
33
+ end
34
+
17
35
  def write_env_file(
18
36
  context:,
19
37
  title:,
@@ -21,11 +39,13 @@ module Extension
21
39
  api_secret: "",
22
40
  registration_id: nil,
23
41
  registration_uuid: nil,
24
- resource_url: nil
42
+ resource_url: nil,
43
+ shop: nil
25
44
  )
26
45
  ShopifyCli::Resources::EnvFile.new(
27
46
  api_key: api_key,
28
47
  secret: api_secret,
48
+ shop: shop,
29
49
  extra: {
30
50
  ExtensionProjectKeys::TITLE_KEY => title,
31
51
  ExtensionProjectKeys::REGISTRATION_ID_KEY => registration_id,
@@ -19,16 +19,6 @@ module Extension
19
19
  YARN_RUN_SCRIPT_NAME = %w(build).freeze
20
20
  private_constant :YARN_INSTALL_COMMAND, :YARN_INSTALL_PARAMETERS, :YARN_RUN_COMMAND, :YARN_RUN_SCRIPT_NAME
21
21
 
22
- UI_EXTENSIONS_CHECKOUT = "@shopify/checkout-ui-extensions"
23
- UI_EXTENSIONS_ADMIN = "@shopify/admin-ui-extensions"
24
- UI_EXTENSIONS_POST_PURCHASE = "@shopify/post-purchase-ui-extensions"
25
-
26
- PACKAGE_NAMES = [
27
- UI_EXTENSIONS_CHECKOUT,
28
- UI_EXTENSIONS_ADMIN,
29
- UI_EXTENSIONS_POST_PURCHASE,
30
- ].freeze
31
-
32
22
  def create(directory_name, identifier, context)
33
23
  Features::ArgoSetup.new(git_template: git_template).call(directory_name, identifier, context)
34
24
  end
@@ -54,7 +44,7 @@ module Extension
54
44
  def renderer_package(context)
55
45
  js_system = ShopifyCli::JsSystem.new(ctx: context)
56
46
  Tasks::FindNpmPackages
57
- .exactly_one_of(*PACKAGE_NAMES, js_system: js_system)
47
+ .exactly_one_of(renderer_package_name, js_system: js_system)
58
48
  .unwrap { |err| raise err }
59
49
  rescue Extension::PackageResolutionFailed
60
50
  context.abort(
@@ -1,46 +1,14 @@
1
1
  module Extension
2
2
  module Features
3
3
  class ArgoRuntime
4
- include SmartProperties
5
-
6
- UI_EXTENSIONS_CHECKOUT_RUN = "@shopify/checkout-ui-extensions-run"
7
- UI_EXTENSIONS_ADMIN_RUN = "@shopify/admin-ui-extensions-run"
8
-
9
- ADMIN_RUN_FLAGS = [
10
- :api_key,
11
- :name,
12
- :port,
13
- :public_url,
14
- :renderer_version,
15
- :shop,
16
- :uuid,
4
+ RUNTIMES = [
5
+ Runtimes::Admin.new,
6
+ Runtimes::CheckoutPostPurchase.new,
7
+ Runtimes::CheckoutUiExtension.new,
17
8
  ]
18
9
 
19
- CHECKOUT_RUN_FLAGS = [
20
- :port,
21
- :public_url,
22
- ]
23
-
24
- property! :renderer, accepts: Models::NpmPackage
25
- property! :cli, accepts: Models::NpmPackage
26
-
27
- def supports?(flag)
28
- case cli
29
- when admin?
30
- ADMIN_RUN_FLAGS.include?(flag.to_sym)
31
- when checkout?
32
- CHECKOUT_RUN_FLAGS.include?(flag.to_sym)
33
- end
34
- end
35
-
36
- private
37
-
38
- def admin?
39
- ->(cli) { cli.name == UI_EXTENSIONS_ADMIN_RUN }
40
- end
41
-
42
- def checkout?
43
- ->(cli) { cli.name == UI_EXTENSIONS_CHECKOUT_RUN }
10
+ def self.find(cli_package:, identifier:)
11
+ RUNTIMES.find { |runtime| runtime.active_runtime?(cli_package, identifier) }
44
12
  end
45
13
  end
46
14
  end
@@ -7,11 +7,12 @@ module Extension
7
7
  NPM_SERVE_COMMAND = %w(run-script server)
8
8
 
9
9
  property! :specification_handler, accepts: Extension::Models::SpecificationHandlers::Default
10
- property! :argo_runtime, accepts: Features::ArgoRuntime
10
+ property! :argo_runtime, accepts: -> (runtime) { runtime.class < Features::Runtimes::Base }
11
11
  property! :context, accepts: ShopifyCli::Context
12
12
  property! :port, accepts: Integer, default: 39351
13
13
  property :tunnel_url, accepts: String, default: nil
14
14
  property! :js_system, accepts: ->(jss) { jss.respond_to?(:call) }, default: ShopifyCli::JsSystem
15
+ property :resource_url, accepts: String, default: nil
15
16
 
16
17
  def call
17
18
  validate_env!
@@ -22,6 +23,10 @@ module Extension
22
23
  end
23
24
  end
24
25
 
26
+ def resource_url
27
+ super || ExtensionProject.current(force_reload: true).resource_url
28
+ end
29
+
25
30
  private
26
31
 
27
32
  def start_server
@@ -57,6 +62,7 @@ module Extension
57
62
  ShopifyCli::Tasks::EnsureDevStore.call(context) if required_fields.include?(:shop)
58
63
 
59
64
  project = ExtensionProject.current
65
+ ensure_resource_resource_url! if specification_handler.supplies_resource_url?
60
66
 
61
67
  return if required_fields.all? do |field|
62
68
  value = project.env.public_send(field)
@@ -77,8 +83,31 @@ module Extension
77
83
  options << "--uuid=#{project.registration_uuid}" if argo_runtime.supports?(:uuid)
78
84
  options << "--publicUrl=#{tunnel_url}" if !tunnel_url.nil? && argo_runtime.supports?(:public_url)
79
85
  options << "--name=#{project.title}" if argo_runtime.supports?(:name)
86
+ options << "--resourceUrl=#{resource_url}" if !resource_url.nil? && argo_runtime.supports?(:resource_url)
80
87
  end
81
88
  end
89
+
90
+ def ensure_resource_resource_url!
91
+ project = ExtensionProject.current(force_reload: true)
92
+
93
+ ShopifyCli::Result
94
+ .wrap(project.resource_url)
95
+ .rescue { specification_handler.build_resource_url(shop: project.env.shop, context: context) }
96
+ .then(&method(:persist_resource_url))
97
+ .unwrap do |nil_or_exception|
98
+ case nil_or_exception
99
+ when nil
100
+ context.warn(context.message("warnings.resource_url_auto_generation_failed", project.env.shop))
101
+ else
102
+ context.abort(nil_or_exception)
103
+ end
104
+ end
105
+ end
106
+
107
+ def persist_resource_url(resource_url)
108
+ ExtensionProject.update_env_file(context: context, resource_url: resource_url)
109
+ resource_url
110
+ end
82
111
  end
83
112
  end
84
113
  end
@@ -0,0 +1,29 @@
1
+ module Extension
2
+ module Features
3
+ module Runtimes
4
+ class Admin < Base
5
+ ADMIN_UI_EXTENSIONS_RUN = "@shopify/admin-ui-extensions-run"
6
+ PRODUCT_SUBSCRIPTION = "PRODUCT_SUBSCRIPTION"
7
+
8
+ AVAILABLE_FLAGS = [
9
+ :api_key,
10
+ :name,
11
+ :port,
12
+ :public_url,
13
+ :renderer_version,
14
+ :resource_url,
15
+ :shop,
16
+ :uuid,
17
+ ]
18
+
19
+ def available_flags
20
+ AVAILABLE_FLAGS
21
+ end
22
+
23
+ def active_runtime?(cli_package, identifier)
24
+ cli_package.name == ADMIN_UI_EXTENSIONS_RUN && identifier == PRODUCT_SUBSCRIPTION
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,19 @@
1
+ module Extension
2
+ module Features
3
+ module Runtimes
4
+ class Base
5
+ def available_flags
6
+ []
7
+ end
8
+
9
+ def supports?(flag)
10
+ available_flags.include?(flag)
11
+ end
12
+
13
+ def active_runtime?(cli_package, identifier)
14
+ raise NotImplementedError
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ module Extension
2
+ module Features
3
+ module Runtimes
4
+ class CheckoutPostPurchase < Base
5
+ CHECKOUT_UI_EXTENSIONS_RUN = "@shopify/checkout-ui-extensions-run"
6
+ CHECKOUT_POST_PURCHASE = "CHECKOUT_POST_PURCHASE"
7
+
8
+ AVAILABLE_FLAGS = [
9
+ :port,
10
+ :public_url,
11
+ ]
12
+
13
+ def available_flags
14
+ AVAILABLE_FLAGS
15
+ end
16
+
17
+ def active_runtime?(cli_package, identifier)
18
+ cli_package.name == CHECKOUT_UI_EXTENSIONS_RUN && identifier == CHECKOUT_POST_PURCHASE
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end