shopify-cli 2.33.1 → 2.35.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b36bc404542b0e83792be77e63389a35c2d28d453390b6f5de47b83e18e104ca
4
- data.tar.gz: 6ceadf801362de66172f8b59d3d39c7cf608a419f08c5ede5eef2d8143092b57
3
+ metadata.gz: e7ff4aa2c4934ffc7d8ea74b5411396057302d3c689de0118e8d575dffe1f80e
4
+ data.tar.gz: 3f6c1e379cf651d615f12f399bb219f791cf9881e910f0b253a2d7511acdb3af
5
5
  SHA512:
6
- metadata.gz: ae5a1f3ba940cdd89f0edb5ee914b53d1269238fdabc7d25bc5b43754825b74cbc2134cd5835194a4438e5be27e1f861227550bff4c9156e1de6cef9574e1b1a
7
- data.tar.gz: 48e9d6c4477ae2a441d56e3cb4554aded9fe8829726c2b72ab5d51224908f340ed67153905242b5d90b5166034f0cff1d38d7f29d8c8340f8222251f804c5510
6
+ metadata.gz: 63f11f8ba2303796b678fcc0a0b30163ec556bdb3551ed6b3f0b036e2bf2564c9c8adfde10a23d9cd45bfaa67f5fcff678fc25055243edd2b99c2445fbb7a8e7
7
+ data.tar.gz: eca42fd71a12ed6fd22547b55590c2bcf64e0ed675420478de0b771e9483d4a42e5c959d967a301cc5814b7393ca51b29444cbd4873349249122f3af9d962e1d
data/CHANGELOG.md CHANGED
@@ -2,6 +2,23 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## Version 2.35.0 - 2023-02-22
6
+
7
+ ### Fixed
8
+ * [#2721](https://github.com/Shopify/shopify-cli/pull/2721): Do not `replace_asset_urls` in font bodies
9
+ * [#2729](https://github.com/Shopify/shopify-cli/pull/2729): Do not inject hot-reload code into web-pixels-manager sandbox (from cli#1370)
10
+ * [#2731](https://github.com/Shopify/shopify-cli/pull/2731): The CLI should not report IO messages when the `--json` flag is passed
11
+
12
+ ### Added
13
+ * [#2724](https://github.com/Shopify/shopify-cli/pull/2724): Introduce hidden `--overwrite-json` flag
14
+ * [#2729](https://github.com/Shopify/shopify-cli/pull/2729): Introduce hidden `--generate_tmp_theme` flag (from cli#1264)
15
+
16
+ ## Version 2.34.0 - 2023-01-11
17
+
18
+ ### Added
19
+ * [#2715](https://github.com/Shopify/shopify-cli/pull/2715): Update theme-check to 1.14.0 (introduce section groups support)
20
+ * [#2714](https://github.com/Shopify/shopify-cli/pull/2714): Update theme-check to 1.13.0 (introduce section groups support)
21
+
5
22
  ## Version 2.33.1 - 2023-01-09
6
23
 
7
24
  ### Fixed
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify-cli (2.33.1)
4
+ shopify-cli (2.35.0)
5
5
  bugsnag (~> 6.22)
6
6
  listen (~> 3.7.0)
7
- theme-check (~> 1.12.1)
7
+ theme-check (~> 1.14.0)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
@@ -89,7 +89,7 @@ GEM
89
89
  mime-types (3.3.1)
90
90
  mime-types-data (~> 3.2015)
91
91
  mime-types-data (3.2021.0901)
92
- mini_portile2 (2.8.0)
92
+ mini_portile2 (2.8.1)
93
93
  minitest (5.14.4)
94
94
  minitest-fail-fast (0.1.0)
95
95
  minitest (~> 5)
@@ -108,7 +108,7 @@ GEM
108
108
  faraday (>= 0.9)
109
109
  sawyer (~> 0.8.0, >= 0.5.3)
110
110
  parallel (1.21.0)
111
- parser (3.1.3.0)
111
+ parser (3.2.0.0)
112
112
  ast (~> 2.4.1)
113
113
  pry (0.13.1)
114
114
  coderay (~> 1.1)
@@ -117,7 +117,7 @@ GEM
117
117
  byebug (~> 11.0)
118
118
  pry (~> 0.13.0)
119
119
  public_suffix (4.0.6)
120
- racc (1.6.1)
120
+ racc (1.6.2)
121
121
  rack (2.2.3.1)
122
122
  rainbow (3.1.1)
123
123
  rake (13.0.6)
@@ -150,7 +150,7 @@ GEM
150
150
  faraday (> 0.8, < 2.0)
151
151
  sys-uname (1.2.2)
152
152
  ffi (~> 1.1)
153
- theme-check (1.12.1)
153
+ theme-check (1.14.0)
154
154
  liquid (>= 5.4.0)
155
155
  nokogiri (>= 1.12)
156
156
  parser (~> 3)
@@ -165,7 +165,7 @@ PLATFORMS
165
165
  ruby
166
166
 
167
167
  DEPENDENCIES
168
- bundler (~> 2.3.11)
168
+ bundler (>= 2.3.11)
169
169
  byebug
170
170
  colorize (~> 0.8.1)
171
171
  cucumber (~> 7.0)
@@ -20,6 +20,9 @@ module Extension
20
20
  parser.on("-T", "--theme=NAME_OR_ID", "Theme ID or name of the theme app extension host theme.") do |theme|
21
21
  flags[:theme] = theme
22
22
  end
23
+ parser.on("--generate-tmp-theme", "Populate host theme, created by CLI 3, with assets") do |generate_tmp_theme|
24
+ flags[:generate_tmp_theme] = generate_tmp_theme
25
+ end
23
26
  parser.on("--api-key=API_KEY", "Connect your extension and app by inserting your app's API key") do |api_key|
24
27
  flags[:api_key] = api_key.gsub('"', "")
25
28
  end
@@ -45,6 +48,7 @@ module Extension
45
48
  property! :tunnel_requested, accepts: [true, false], reader: :tunnel_requested?, default: true
46
49
  property :port, accepts: (1...(2**16))
47
50
  property :theme, accepts: String, default: nil
51
+ property :generate_tmp_theme, accepts: [true, false], reader: :generate_tmp_theme?, default: false
48
52
  property :api_key, accepts: String, default: nil
49
53
  property :api_secret, accepts: String, default: nil
50
54
  property :registration_id, accepts: String, default: nil
@@ -60,6 +64,7 @@ module Extension
60
64
  resource_url: options.flags[:resource_url],
61
65
  port: options.flags[:port],
62
66
  theme: options.flags[:theme],
67
+ generate_tmp_theme: generate_tmp_theme?,
63
68
  api_key: options.flags[:api_key],
64
69
  api_secret: options.flags[:api_secret],
65
70
  registration_id: options.flags[:registration_id],
@@ -103,6 +108,10 @@ module Extension
103
108
  tunnel.nil? || !!tunnel
104
109
  end
105
110
 
111
+ def generate_tmp_theme?
112
+ options.flags[:generate_tmp_theme] == true
113
+ end
114
+
106
115
  def find_available_port(runtime_configuration)
107
116
  return runtime_configuration unless runtime_configuration.port.nil?
108
117
  return runtime_configuration unless specification_handler.choose_port?(@ctx)
@@ -137,6 +146,7 @@ module Extension
137
146
  tunnel_url: runtime_configuration.tunnel_url,
138
147
  port: runtime_configuration.port,
139
148
  theme: runtime_configuration.theme,
149
+ generate_tmp_theme: runtime_configuration.generate_tmp_theme?,
140
150
  api_key: runtime_configuration.api_key,
141
151
  api_secret: runtime_configuration.api_secret,
142
152
  registration_id: runtime_configuration.registration_id,
@@ -78,7 +78,7 @@ module Extension
78
78
  root = options[:context]&.root
79
79
  project = options[:project]
80
80
  properties = options
81
- .slice(:port, :theme)
81
+ .slice(:port, :theme, :generate_tmp_theme)
82
82
  .compact
83
83
  .merge({
84
84
  project: project,
@@ -67,6 +67,7 @@ module Theme
67
67
  begin
68
68
  syncer.start_threads
69
69
  if options.flags[:json]
70
+ syncer.standard_reporter.disable!
70
71
  syncer.upload_theme!(delete: delete)
71
72
  else
72
73
  CLI::UI::Frame.open(@ctx.message("theme.push.info.pushing", theme.name, theme.id, theme.shop)) do
@@ -35,6 +35,7 @@ module Theme
35
35
  flags[:ignores] |= pattern
36
36
  end
37
37
  parser.on("-f", "--force") { flags[:force] = true }
38
+ parser.on("--overwrite-json") { flags[:overwrite_json] = true }
38
39
  end
39
40
 
40
41
  def call(_args, name)
@@ -313,7 +313,7 @@ module ShopifyCLI
313
313
  },
314
314
  error_reporting: {
315
315
  unhandled_error: {
316
- message: "{{x}} {{red:An unexpected error occured.}}",
316
+ message: "{{x}} {{red:An unexpected error occurred.}}",
317
317
  issue_message: "{{red:\tTo \e]8;;%s\e\\submit an issue\e]8;;\e\\"\
318
318
  " include the stack trace.}}",
319
319
  stacktrace_message: "{{red:\tTo print the stack trace, add the environment variable %s.}}",
@@ -25,7 +25,7 @@ module ShopifyCLI
25
25
  "</script>",
26
26
  ].join("\n")
27
27
 
28
- body = body.join.gsub("</body>", "#{hot_reload_script}\n</body>")
28
+ body = body.join.sub("</body>", "#{hot_reload_script}\n</body>")
29
29
 
30
30
  [body]
31
31
  end
@@ -16,12 +16,15 @@ module ShopifyCLI
16
16
  end
17
17
 
18
18
  def call(env)
19
- if env["PATH_INFO"] == "/hot-reload"
19
+ path = env["PATH_INFO"]
20
+ if path == "/hot-reload"
20
21
  create_stream
21
22
  else
22
23
  status, headers, body = @app.call(env)
23
24
 
24
- body = inject_hot_reload_javascript(body) if request_is_html?(headers)
25
+ if request_is_html?(headers) && leads_to_injectable_body?(path)
26
+ body = inject_hot_reload_javascript(body)
27
+ end
25
28
 
26
29
  [status, headers, body]
27
30
  end
@@ -43,6 +46,10 @@ module ShopifyCLI
43
46
  headers["content-type"]&.start_with?("text/html")
44
47
  end
45
48
 
49
+ def leads_to_injectable_body?(path)
50
+ path !~ /web-pixels-manager.+sandbox/
51
+ end
52
+
46
53
  def inject_hot_reload_javascript(body)
47
54
  @script_injector&.inject(body: body, dir: __dir__, mode: @mode)
48
55
  end
@@ -29,13 +29,14 @@ module ShopifyCLI
29
29
  end
30
30
 
31
31
  def call(env)
32
- if env["PATH_INFO"].start_with?("/assets")
32
+ path_info = env["PATH_INFO"]
33
+ if path_info.start_with?("/assets")
33
34
  # Serve from disk
34
- serve_file(env["PATH_INFO"])
35
+ serve_file(path_info)
35
36
  else
36
37
  # Proxy the request, and replace the URLs in the response
37
38
  status, headers, body = @app.call(env)
38
- body = replace_asset_urls(body)
39
+ body = replace_asset_urls(body) unless path_info.start_with?("/fonts")
39
40
  [status, headers, body]
40
41
  end
41
42
  end
@@ -53,6 +54,10 @@ module ShopifyCLI
53
54
  end
54
55
 
55
56
  [replaced_body]
57
+ rescue ArgumentError => error
58
+ return [body.join] if error.message.include?("invalid byte sequence")
59
+
60
+ raise error
56
61
  end
57
62
 
58
63
  def serve_fail(status, body)
@@ -41,6 +41,7 @@ module ShopifyCLI
41
41
  port: 9292,
42
42
  poll: false,
43
43
  editor_sync: false,
44
+ overwrite_json: false,
44
45
  stable: false,
45
46
  mode: ReloadMode.default,
46
47
  includes: nil,
@@ -55,6 +56,7 @@ module ShopifyCLI
55
56
  port,
56
57
  poll,
57
58
  editor_sync,
59
+ overwrite_json,
58
60
  stable,
59
61
  mode,
60
62
  includes,
@@ -78,6 +80,7 @@ module ShopifyCLI
78
80
  port,
79
81
  poll,
80
82
  editor_sync,
83
+ overwrite_json,
81
84
  stable,
82
85
  mode,
83
86
  includes,
@@ -91,6 +94,7 @@ module ShopifyCLI
91
94
  @port = port
92
95
  @poll = poll
93
96
  @editor_sync = editor_sync
97
+ @overwrite_json = overwrite_json
94
98
  @stable = stable
95
99
  @mode = mode
96
100
  @includes = includes
@@ -199,7 +203,7 @@ module ShopifyCLI
199
203
  theme: theme,
200
204
  include_filter: include_filter,
201
205
  ignore_filter: ignore_filter,
202
- overwrite_json: !editor_sync,
206
+ overwrite_json: !editor_sync || @overwrite_json,
203
207
  stable: stable
204
208
  )
205
209
  end
@@ -26,12 +26,13 @@ module ShopifyCLI
26
26
  # Extensions
27
27
  ScriptInjector = ShopifyCLI::Theme::Extension::DevServer::HotReload::ScriptInjector
28
28
 
29
- attr_accessor :project, :specification_handler
29
+ attr_accessor :project, :specification_handler, :generate_tmp_theme
30
30
 
31
31
  class << self
32
- def start(ctx, root, port: 9292, theme: nil, project:, specification_handler:)
32
+ def start(ctx, root, port: 9292, theme: nil, generate_tmp_theme: false, project:, specification_handler:)
33
33
  instance.project = project
34
34
  instance.specification_handler = specification_handler
35
+ instance.generate_tmp_theme = generate_tmp_theme
35
36
 
36
37
  super(ctx, root, port: port, theme: theme)
37
38
  end
@@ -66,8 +67,10 @@ module ShopifyCLI
66
67
 
67
68
  def theme
68
69
  @theme ||= if theme_identifier
69
- theme = ShopifyCLI::Theme::Theme.find_by_identifier(ctx, identifier: theme_identifier)
70
- theme || ctx.abort(not_found_error_message)
70
+ theme = HostTheme.find_by_identifier(ctx, identifier: theme_identifier)
71
+ ctx.abort(not_found_error_message) unless theme
72
+ theme.generate_tmp_theme if generate_tmp_theme
73
+ theme
71
74
  else
72
75
  HostTheme.find_or_create!(ctx)
73
76
  end
@@ -61,20 +61,9 @@ module ShopifyCLI
61
61
  new(ctx, root: nil).ensure_exists!
62
62
  end
63
63
 
64
- private
65
-
66
- def generate_host_theme_name
67
- hostname = Socket.gethostname.split(".").shift
68
- hash = SecureRandom.hex(3)
69
-
70
- theme_name = "App Ext. Host ()"
71
- hostname_character_limit = API_NAME_LIMIT - theme_name.length - hash.length - 1
72
- identifier = encode_identifier("#{hash}-#{hostname[0, hostname_character_limit]}")
73
- theme_name = "App Ext. Host (#{identifier})"
74
-
75
- ShopifyCLI::DB.set(host_theme_name: theme_name)
76
-
77
- theme_name
64
+ def self.find_by_identifier(ctx, root: nil, identifier:)
65
+ ShopifyCLI::DB.set(host_theme_id: identifier)
66
+ find(ctx, root: root)
78
67
  end
79
68
 
80
69
  def generate_tmp_theme
@@ -98,6 +87,22 @@ module ShopifyCLI
98
87
  end
99
88
  end
100
89
  end
90
+
91
+ private
92
+
93
+ def generate_host_theme_name
94
+ hostname = Socket.gethostname.split(".").shift
95
+ hash = SecureRandom.hex(3)
96
+
97
+ theme_name = "App Ext. Host ()"
98
+ hostname_character_limit = API_NAME_LIMIT - theme_name.length - hash.length - 1
99
+ identifier = encode_identifier("#{hash}-#{hostname[0, hostname_character_limit]}")
100
+ theme_name = "App Ext. Host (#{identifier})"
101
+
102
+ ShopifyCLI::DB.set(host_theme_name: theme_name)
103
+
104
+ theme_name
105
+ end
101
106
  end
102
107
  end
103
108
  end
@@ -5,7 +5,7 @@ module ShopifyCLI
5
5
  class Syncer
6
6
  ##
7
7
  # ShopifyCLI::Theme::Syncer::StdReporter allows disabling/enabling
8
- # messages reported in the standard output (ShopifyCLI::Context#puts).
8
+ # messages reported in the standard error output (ShopifyCLI::Context#puts).
9
9
  #
10
10
  class StandardReporter
11
11
  attr_reader :ctx
@@ -24,7 +24,7 @@ module ShopifyCLI
24
24
  end
25
25
 
26
26
  def report(message)
27
- ctx.puts(message) if @enabled
27
+ ctx.error(message) if @enabled
28
28
  end
29
29
  end
30
30
  end
@@ -33,7 +33,7 @@ module ShopifyCLI
33
33
  :union_merge, # - Union merges the local file content with the remote file content
34
34
  ]
35
35
 
36
- attr_reader :ctx, :theme, :checksums, :error_checksums, :api_client, :pending
36
+ attr_reader :ctx, :theme, :checksums, :error_checksums, :api_client, :pending, :standard_reporter
37
37
  attr_accessor :include_filter, :ignore_filter
38
38
 
39
39
  def_delegators :@error_reporter, :has_any_error?
@@ -1,3 +1,3 @@
1
1
  module ShopifyCLI
2
- VERSION = "2.33.1"
2
+ VERSION = "2.35.0"
3
3
  end
data/shopify-cli.gemspec CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.require_paths = ["lib", "vendor"]
36
36
  spec.executables << "shopify"
37
37
 
38
- spec.add_development_dependency("bundler", "~> 2.3.11")
38
+ spec.add_development_dependency("bundler", ">= 2.3.11")
39
39
  spec.add_development_dependency("rake", "~> 12.3", ">= 12.3.3")
40
40
  spec.add_development_dependency("minitest", "~> 5.0")
41
41
 
@@ -48,7 +48,7 @@ Gem::Specification.new do |spec|
48
48
  # Whereas if we were to have "~> 1.9", that version would still be satisfied and thus not upgraded.
49
49
  # Both shopify-cli and theme-check gems are owned and developed by Shopify.
50
50
  # These gems are currently being actively developed and it's easiest to update them together.
51
- spec.add_dependency("theme-check", "~> 1.12.1")
51
+ spec.add_dependency("theme-check", "~> 1.14.0")
52
52
 
53
53
  spec.extensions = ["ext/shopify-extensions/extconf.rb"]
54
54
  end
@@ -157,7 +157,7 @@ module SmartProperties
157
157
  rescue NoMethodError => error
158
158
  # BasicObject does not respond to #nil? by default, so we need to double
159
159
  # check if somebody implemented it and it fails internally or if the
160
- # error occured because the method is actually not present. In the former
160
+ # error occurred because the method is actually not present. In the former
161
161
  # case, we want to raise the exception because there is something wrong
162
162
  # with the implementation of object#nil?. In the latter case we treat the
163
163
  # object as truthy because we don't know better.
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.33.1
4
+ version: 2.35.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-09 00:00:00.000000000 Z
11
+ date: 2023-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.3.11
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.3.11
27
27
  - !ruby/object:Gem::Dependency
@@ -92,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: 1.12.1
95
+ version: 1.14.0
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: 1.12.1
102
+ version: 1.14.0
103
103
  description: |
104
104
  Shopify CLI helps you build Shopify apps faster. It quickly scaffolds Node.js
105
105
  and Ruby on Rails embedded apps. It also automates many common tasks in the