shopify-cli 2.32.0 → 2.33.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1f827e0b1d481a8fdd6e7160ef85d6e63bee0a7607f6bf148693956f901d67c
4
- data.tar.gz: 5882878a69100c7ac97255c80a0ca868ca616be1eca5a523c3e1ddf1e8896dc4
3
+ metadata.gz: ac3c8680848c4b1caae004aba8327a321aded59a73e9454130534726a16a5a4d
4
+ data.tar.gz: 46bc06119d1fce33ebef93562bcbe904c5938502d9394b8748000b0ff260671a
5
5
  SHA512:
6
- metadata.gz: 5f2335aecb476e962d7283d33187acb94cae34a1b6b23f52f48ad890c4daaeeabf0afeaecb0a3740a57ac98c86a18a7f35422430da2eea5413472fc85c740360
7
- data.tar.gz: 6e9b70d65c59e9531b44e270d752637999bccaaf844c7f89be659c04f3f6f343bd89ce72e1e25c46d0d16dc66873233a5268aba8aab2eed873e0a086a7af0b6a
6
+ metadata.gz: 51da54fda07bd8d66d0aa4e8aedd54df04c23fc50fff79e520179f5e956f4eb940c961e933794f59187b92171fb9998393666dd58986219887a003f848341e78
7
+ data.tar.gz: 35a4a6bda609ff6775880f80e9b31171e9edbeef0bbc9745bd5b17b47c6e9d428e4b0a146f075642e229e0cc224e3202b9f5bfed170650b91b1fe7ebb5c30725
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@ 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.33.0 - 2022-12-19
6
+
7
+ ### Added
8
+ * [#2681](https://github.com/Shopify/shopify-cli/pull/2681): Enable Theme Access passwords for theme serve
9
+ * [#2701](https://github.com/Shopify/shopify-cli/pull/2701): Update theme-check to 1.12.1 (introduce intelligent code completion)
10
+
11
+ ## Version 2.32.1 - 2022-12-05
12
+
13
+ ### Fixed
14
+ * [#2694](https://github.com/Shopify/shopify-cli/pull/2694): Add sunset warnings
15
+
5
16
  ## Version 2.32.0 - 2022-11-14
6
17
 
7
18
  ### Added
@@ -9,6 +20,7 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
9
20
 
10
21
  ### Fixed
11
22
  * [#2683](https://github.com/Shopify/shopify-cli/pull/2683): Fix timeout issue with the `shopify theme push` command and the `--json` flag
23
+ * [#2688](https://github.com/Shopify/shopify-cli/pull/2688): Fix `shopify theme push` to report pushes with errors
12
24
 
13
25
  ## Version 2.31.0 - 2022-11-07
14
26
 
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify-cli (2.32.0)
4
+ shopify-cli (2.33.0)
5
5
  bugsnag (~> 6.22)
6
6
  listen (~> 3.7.0)
7
- theme-check (~> 1.11.0)
7
+ theme-check (~> 1.12.1)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
@@ -101,14 +101,14 @@ GEM
101
101
  mocha (1.13.0)
102
102
  multi_test (0.1.2)
103
103
  multipart-post (2.1.1)
104
- nokogiri (1.13.9)
104
+ nokogiri (1.13.10)
105
105
  mini_portile2 (~> 2.8.0)
106
106
  racc (~> 1.4)
107
107
  octokit (4.22.0)
108
108
  faraday (>= 0.9)
109
109
  sawyer (~> 0.8.0, >= 0.5.3)
110
110
  parallel (1.21.0)
111
- parser (3.1.2.1)
111
+ parser (3.1.3.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.0)
120
+ racc (1.6.1)
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.11.0)
153
+ theme-check (1.12.1)
154
154
  liquid (>= 5.4.0)
155
155
  nokogiri (>= 1.12)
156
156
  parser (~> 3)
data/README.md CHANGED
@@ -11,17 +11,11 @@
11
11
  <img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License">
12
12
  <img src="https://img.shields.io/badge/Powered%20by-Ruby-red" alt="Powered by Ruby">
13
13
 
14
-
15
14
  Shopify CLI 2.0 is a command line to help you build on Shopify. It's available as a Ruby gem and can be run and installed on Mac, Linux, and Windows systems.
16
15
 
17
- ## Note on Shopify CLI 2.0 versus Shopify CLI 3.0 ##
18
-
19
- Use 2.0 for developing themes. For developing apps and custom storefronts, we recommend using [Shopify CLI 3.0](https://github.com/Shopify/cli).
20
-
21
-
22
- ## Installation
16
+ ## CLI Deprecation & Sunset
23
17
 
24
- Check out our [installation steps](docs/users/installation.md).
18
+ Note that Shopify 2.0 is deprecated and will be [sunset on May 31, 2023](https://shopify.dev/changelog/cli-2-0-to-be-sunset-on-may-31-2023). We encourage using [Shopify CLI 3.0](https://github.com/Shopify/cli) to develop apps, custom storefronts, and themes.
25
19
 
26
20
  ## Contributing 👩‍💻
27
21
 
@@ -5,28 +5,7 @@ module ShopifyCLI
5
5
  module EntryPoint
6
6
  class << self
7
7
  def call(args, ctx = Context.new)
8
- # Only instruct the user to update the CLI, or warn them that they're
9
- # using CLI2 not CLI3, if they're running CLI2 directly. Otherwise the
10
- # warnings will be confusing and/or incorrect.
11
- unless Environment.run_as_subprocess?
12
- if ctx.development? && !ctx.testing?
13
- ctx.warn(
14
- ctx.message(
15
- "core.warning.development_version",
16
- File.join(ShopifyCLI::ROOT, "bin", ShopifyCLI::TOOL_NAME)
17
- )
18
- )
19
- # because `!ctx.new_version.nil?` will change the config by calling ::Config.set
20
- # it's important to keep the checks in this order so that we don't trigger it while testing
21
- # since changing the config will throw errors
22
- elsif !ctx.testing? && !ctx.new_version.nil?
23
- ctx.warn(ctx.message("core.warning.new_version", ShopifyCLI::VERSION, ctx.new_version))
24
- end
25
-
26
- if ShopifyCLI::Core::CliVersion.using_3_0?
27
- ctx.warn(ctx.message("core.warning.in_3_0_directory"))
28
- end
29
- end
8
+ show_warnings(ctx, args.join(" "))
30
9
 
31
10
  ProjectType.load_all
32
11
 
@@ -38,6 +17,47 @@ module ShopifyCLI
38
17
  executor.call(command, command_name, args)
39
18
  end
40
19
  end
20
+
21
+ def show_warnings(ctx, args)
22
+ # Only instruct the user to update the CLI, or warn them that they're
23
+ # using CLI2 not CLI3, if they're running CLI2 directly. Otherwise the
24
+ # warnings will be confusing and/or incorrect.
25
+ return if Environment.run_as_subprocess?
26
+
27
+ show_sunset_warning(ctx, args)
28
+
29
+ if ctx.development? && !ctx.testing?
30
+ ctx.warn(
31
+ ctx.message(
32
+ "core.warning.development_version",
33
+ File.join(ShopifyCLI::ROOT, "bin", ShopifyCLI::TOOL_NAME)
34
+ )
35
+ )
36
+ # because `!ctx.new_version.nil?` will change the config by calling ::Config.set
37
+ # it's important to keep the checks in this order so that we don't trigger it while testing
38
+ # since changing the config will throw errors
39
+ elsif !ctx.testing? && !ctx.new_version.nil?
40
+ ctx.warn(ctx.message("core.warning.new_version", ShopifyCLI::VERSION, ctx.new_version))
41
+ end
42
+
43
+ if ShopifyCLI::Core::CliVersion.using_3_0?
44
+ ctx.warn(ctx.message("core.warning.in_3_0_directory"))
45
+ end
46
+ end
47
+
48
+ def show_sunset_warning(ctx, args)
49
+ return if ctx.testing?
50
+
51
+ if args.start_with?("app create") || args.start_with?("app extension create")
52
+ ctx.warn(ctx.message("core.warning.sunset_create_app"))
53
+ elsif args.start_with?("app")
54
+ ctx.warn(ctx.message("core.warning.sunset_app"))
55
+ elsif args.start_with?("theme")
56
+ ctx.warn(ctx.message("core.warning.sunset_theme"))
57
+ else
58
+ ctx.warn(ctx.message("core.warning.sunset"))
59
+ end
60
+ end
41
61
  end
42
62
  end
43
63
  end
@@ -804,6 +804,22 @@ module ShopifyCLI
804
804
  Already have CLI 3.0 installed? Run it using your node package manager, as explained here:
805
805
  {{underline:https://shopify.dev/apps/tools/cli/cli-2#running-shopify-cli-2-x-and-3-x-in-the-same-environment}}
806
806
  MESSAGE
807
+
808
+ sunset: <<~MESSAGE,
809
+ {{*}} {{yellow:Note that CLI 2.x will be sunset on May 31, 2023.}}
810
+ MESSAGE
811
+
812
+ sunset_create_app: <<~MESSAGE,
813
+ {{*}} {{yellow:Note that this CLI 2.x command will be sunset on April 28, 2023. Check here for instructions on how to migrate over to CLI 3.x: {{underline:https://shopify.dev/apps/tools/cli/migrate}}.}}
814
+ MESSAGE
815
+
816
+ sunset_app: <<~MESSAGE,
817
+ {{*}} {{yellow:Note that CLI 2.x will be sunset on May 31, 2023. Check here for instructions on how to migrate over to CLI 3.x: {{underline:https://shopify.dev/apps/tools/cli/migrate}}.}}
818
+ MESSAGE
819
+
820
+ sunset_theme: <<~MESSAGE,
821
+ {{*}} {{yellow:Note that CLI 2.x will be sunset on May 31, 2023. Check here for instructions on how to migrate over to CLI 3.x: {{underline:https://shopify.dev/themes/tools/cli/migrate}}.}}
822
+ MESSAGE
807
823
  },
808
824
  reporting: {
809
825
  help: <<~HELP,
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require "stringio"
3
4
  require "time"
4
5
  require "cgi"
@@ -20,6 +21,7 @@ module ShopifyCLI
20
21
  "transfer-encoding",
21
22
  "upgrade",
22
23
  "content-security-policy",
24
+ "content-length",
23
25
  ]
24
26
 
25
27
  class Proxy
@@ -54,14 +56,14 @@ module ShopifyCLI
54
56
  "POST", env["PATH_INFO"],
55
57
  headers: headers,
56
58
  query: query,
57
- form_data: form_data.merge(replace_templates).merge(_method: env["REQUEST_METHOD"]),
59
+ form_data: form_data.merge(replace_templates).merge(_method: env["REQUEST_METHOD"])
58
60
  )
59
61
  else
60
62
  request(
61
63
  env["REQUEST_METHOD"], env["PATH_INFO"],
62
64
  headers: headers,
63
65
  query: query,
64
- body_stream: (env["rack.input"] if has_body?(headers)),
66
+ body_stream: (env["rack.input"] if has_body?(headers))
65
67
  )
66
68
  end
67
69
 
@@ -97,7 +99,7 @@ module ShopifyCLI
97
99
 
98
100
  def bearer_token
99
101
  Environment.storefront_renderer_auth_token ||
100
- ShopifyCLI::DB.get(:storefront_renderer_production_exchange_token) ||
102
+ ShopifyCLI::DB.get(:storefront_renderer_production_exchange_token) ||
101
103
  raise(KeyError, "storefront_renderer_production_exchange_token missing")
102
104
  end
103
105
 
@@ -152,11 +154,13 @@ module ShopifyCLI
152
154
 
153
155
  def secure_session_id_expired?
154
156
  return true unless @secure_session_id && @last_session_cookie_refresh
157
+
155
158
  Time.now - @last_session_cookie_refresh >= SESSION_COOKIE_MAX_AGE
156
159
  end
157
160
 
158
161
  def extract_secure_session_id_from_response_headers(headers)
159
162
  return unless headers["set-cookie"]
163
+
160
164
  headers["set-cookie"][SESSION_COOKIE_REGEXP, 1]
161
165
  end
162
166
 
@@ -173,7 +177,7 @@ module ShopifyCLI
173
177
 
174
178
  def get_response_headers(response, env)
175
179
  response_headers = normalize_headers(
176
- response.respond_to?(:headers) ? response.headers : response.to_hash
180
+ response.respond_to?(:headers) ? response.headers : response.to_hash,
177
181
  )
178
182
  # According to https://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-14#section-7.1.3.1Acc
179
183
  # should remove hop-by-hop header fields
@@ -196,6 +200,16 @@ module ShopifyCLI
196
200
 
197
201
  def request(method, path, headers: nil, query: [], form_data: nil, body_stream: nil)
198
202
  uri = URI.join("https://#{shop}", path)
203
+
204
+ if Environment.theme_access_password?
205
+ headers = headers ? headers.slice("ACCEPT", "CONTENT-TYPE", "CONTENT-LENGTH", "Cookie") : {}
206
+ headers.merge!({
207
+ "X-Shopify-Access-Token" => Environment.admin_auth_token,
208
+ "X-Shopify-Shop" => shop,
209
+ })
210
+ uri = URI.join("https://#{ThemeAccessAPI::BASE_URL}", "cli/sfr#{path}")
211
+ end
212
+
199
213
  uri.query = URI.encode_www_form(query + [[:_fd, 0], [:pb, 0]])
200
214
 
201
215
  @ctx.debug("Proxying #{method} #{uri}")
@@ -26,13 +26,11 @@ module ShopifyCLI
26
26
  :ignore_file?,
27
27
  :overwrite_json?,
28
28
  :bulk_updates_activated?,
29
-
30
29
  # enqueue
31
30
  :enqueue_deletes,
32
31
  :enqueue_get,
33
32
  :enqueue_union_merges,
34
33
  :enqueue_updates,
35
-
36
34
  # checksums
37
35
  :checksums,
38
36
  :update_checksums,
@@ -112,7 +110,7 @@ module ShopifyCLI
112
110
  retries = 0
113
111
  pending_items = files.map { |file| bulk_item(file) }
114
112
 
115
- while pending_items.any? && retries < 4
113
+ while pending_items.any? && retries < 2
116
114
  bulk = Bulk.new(ctx, theme, api_client)
117
115
 
118
116
  files
@@ -183,7 +181,7 @@ module ShopifyCLI
183
181
  [
184
182
  theme["config/settings_schema.json"],
185
183
  theme["config/settings_data.json"],
186
- ]
184
+ ],
187
185
  )
188
186
  end
189
187
 
@@ -217,8 +215,14 @@ module ShopifyCLI
217
215
 
218
216
  # Handler errors
219
217
 
220
- def report(file, _error)
221
- error_message = "The asset #{file.relative_path} could not be uploaded.\n#{e.inspect}"
218
+ def report(file, error)
219
+ file_path = file.relative_path
220
+
221
+ error_message = syncer
222
+ .parse_api_errors(file, error)
223
+ .map { |msg| "#{file_path}: #{msg}" }
224
+ .join("\n")
225
+
222
226
  syncer.report_file_error(file, error_message)
223
227
  end
224
228
  end
@@ -121,6 +121,7 @@ module ShopifyCLI
121
121
 
122
122
  def wait!
123
123
  raise ThreadError, "No syncer threads" if @threads.empty?
124
+
124
125
  total = size
125
126
  last_size = size
126
127
  until empty? || @queue.closed?
@@ -134,7 +135,7 @@ module ShopifyCLI
134
135
 
135
136
  def fetch_checksums!
136
137
  _status, response = api_client.get(
137
- path: "themes/#{@theme.id}/assets.json"
138
+ path: "themes/#{@theme.id}/assets.json",
138
139
  )
139
140
  update_checksums(response)
140
141
  end
@@ -151,6 +152,7 @@ module ShopifyCLI
151
152
  loop do
152
153
  operation = @queue.pop
153
154
  break if operation.nil? # shutdown was called
155
+
154
156
  perform(operation)
155
157
  rescue Exception => e # rubocop:disable Lint/RescueException
156
158
  error_suffix = ": #{e}"
@@ -195,7 +197,7 @@ module ShopifyCLI
195
197
  end
196
198
 
197
199
  def handle_operation_error(operation, error)
198
- error_suffix = ":\n " + parse_api_errors(operation, error).join("\n ")
200
+ error_suffix = ":\n " + parse_api_errors(operation.file, error).join("\n ")
199
201
  report_error(operation, error_suffix)
200
202
  end
201
203
 
@@ -206,6 +208,7 @@ module ShopifyCLI
206
208
  def update_checksums(api_response)
207
209
  api_response.values.flatten.each do |asset|
208
210
  next unless asset["key"]
211
+
209
212
  checksums[asset["key"]] = asset["checksum"]
210
213
  end
211
214
 
@@ -219,6 +222,33 @@ module ShopifyCLI
219
222
  @error_reporter.report(error_message)
220
223
  end
221
224
 
225
+ def parse_api_errors(file, exception)
226
+ parsed_body = {}
227
+
228
+ if exception.respond_to?(:response)
229
+ response = exception.response
230
+
231
+ parsed_body = if response&.is_a?(Hash)
232
+ response&.[](:body)
233
+ else
234
+ JSON.parse(response&.body)
235
+ end
236
+ end
237
+
238
+ errors = parsed_body.dig("errors") # either nil or another type
239
+ errors = errors.dig("asset") if errors&.is_a?(Hash)
240
+
241
+ message = errors || parsed_body["message"] || exception.message
242
+ # Truncate to first lines
243
+ [message].flatten.map { |m| m.split("\n", 2).first }
244
+ rescue JSON::ParserError
245
+ [exception.message]
246
+ rescue StandardError => e
247
+ cause = "(cause: #{e.message})"
248
+ backtrace = e.backtrace.join("\n")
249
+ ["The asset #{file} could not be synced #{cause} #{backtrace}"]
250
+ end
251
+
222
252
  private
223
253
 
224
254
  def report_error(operation, error_suffix = "")
@@ -256,6 +286,7 @@ module ShopifyCLI
256
286
 
257
287
  def perform(operation)
258
288
  return if @queue.closed?
289
+
259
290
  wait_for_backoff!
260
291
  @ctx.debug(operation.to_s)
261
292
 
@@ -263,7 +294,6 @@ module ShopifyCLI
263
294
 
264
295
  report_performed_operation(operation)
265
296
  backoff_if_near_limit!(response)
266
-
267
297
  rescue StandardError => error
268
298
  handle_operation_error(operation, error)
269
299
  ensure
@@ -283,7 +313,7 @@ module ShopifyCLI
283
313
 
284
314
  _status, body, response = api_client.put(
285
315
  path: path,
286
- body: JSON.generate(asset: asset)
316
+ body: JSON.generate(asset: asset),
287
317
  )
288
318
  file.warnings = body.dig("asset", "warnings")
289
319
 
@@ -315,7 +345,7 @@ module ShopifyCLI
315
345
  path: "themes/#{@theme.id}/assets.json",
316
346
  body: JSON.generate(asset: {
317
347
  key: file.relative_path,
318
- })
348
+ }),
319
349
  )
320
350
 
321
351
  response
@@ -342,33 +372,6 @@ module ShopifyCLI
342
372
  response
343
373
  end
344
374
 
345
- def parse_api_errors(operation, exception)
346
- parsed_body = {}
347
-
348
- if exception.respond_to?(:response)
349
- response = exception.response
350
-
351
- parsed_body = if response&.is_a?(Hash)
352
- response&.[](:body)
353
- else
354
- JSON.parse(response&.body)
355
- end
356
- end
357
-
358
- errors = parsed_body.dig("errors") # either nil or another type
359
- errors = errors.dig("asset") if errors&.is_a?(Hash)
360
-
361
- message = errors || parsed_body["message"] || exception.message
362
- # Truncate to first lines
363
- [message].flatten.map { |m| m.split("\n", 2).first }
364
- rescue JSON::ParserError
365
- [exception.message]
366
- rescue StandardError => e
367
- cause = "(cause: #{e.message})"
368
- backtrace = e.backtrace.join("\n")
369
- ["The asset #{operation.file} could not be synced #{cause} #{backtrace}"]
370
- end
371
-
372
375
  def theme_created_at_runtime?
373
376
  @theme.created_at_runtime?
374
377
  end
@@ -61,6 +61,7 @@ module ShopifyCLI
61
61
  if empty_response?(error)
62
62
  return permission_error
63
63
  elsif unauthorized_response?(error)
64
+ @ctx.debug("[#{self.class}] (#{error.class}) cause: #{response_body(error)}")
64
65
  raise ShopifyCLI::Abort, @ctx.message("theme.unauthorized_error", @shop)
65
66
  end
66
67
 
@@ -1,3 +1,3 @@
1
1
  module ShopifyCLI
2
- VERSION = "2.32.0"
2
+ VERSION = "2.33.0"
3
3
  end
data/shopify-cli.gemspec CHANGED
@@ -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.11.0")
51
+ spec.add_dependency("theme-check", "~> 1.12.1")
52
52
 
53
53
  spec.extensions = ["ext/shopify-extensions/extconf.rb"]
54
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.32.0
4
+ version: 2.33.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-14 00:00:00.000000000 Z
11
+ date: 2022-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -92,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: 1.11.0
95
+ version: 1.12.1
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.11.0
102
+ version: 1.12.1
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