shopify-cli 2.11.0 → 2.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -1
  3. data/Gemfile.lock +1 -1
  4. data/bin/shopify +13 -0
  5. data/docs/users/installation.md +1 -44
  6. data/lib/project_types/extension/commands/build.rb +0 -3
  7. data/lib/project_types/extension/commands/check.rb +0 -1
  8. data/lib/project_types/extension/commands/create.rb +0 -1
  9. data/lib/project_types/extension/commands/push.rb +13 -1
  10. data/lib/project_types/extension/commands/serve.rb +0 -1
  11. data/lib/project_types/extension/loaders/project.rb +28 -8
  12. data/lib/project_types/extension/messages/messages.rb +10 -2
  13. data/lib/project_types/extension/models/specification_handlers/checkout_ui_extension.rb +114 -0
  14. data/lib/project_types/extension/models/specification_handlers/theme_app_extension.rb +7 -1
  15. data/lib/project_types/script/cli.rb +2 -0
  16. data/lib/project_types/script/commands/create.rb +2 -2
  17. data/lib/project_types/script/commands/push.rb +4 -6
  18. data/lib/project_types/script/config/extension_points.yml +0 -4
  19. data/lib/project_types/script/forms/create.rb +1 -14
  20. data/lib/project_types/script/layers/application/connect_app.rb +3 -2
  21. data/lib/project_types/script/layers/application/create_script.rb +1 -1
  22. data/lib/project_types/script/layers/application/push_script.rb +1 -1
  23. data/lib/project_types/script/layers/infrastructure/errors.rb +11 -0
  24. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_project_creator.rb +2 -6
  25. data/lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb +30 -26
  26. data/lib/project_types/script/layers/infrastructure/languages/task_runner.rb +35 -9
  27. data/lib/project_types/script/layers/infrastructure/languages/tool_version_checker.rb +26 -0
  28. data/lib/project_types/script/layers/infrastructure/languages/typescript_project_creator.rb +3 -6
  29. data/lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb +31 -27
  30. data/lib/project_types/script/layers/infrastructure/languages/wasm_task_runner.rb +3 -7
  31. data/lib/project_types/script/loaders/project.rb +8 -7
  32. data/lib/project_types/script/messages/messages.rb +14 -13
  33. data/lib/project_types/script/ui/error_handler.rb +13 -0
  34. data/lib/project_types/theme/commands/check.rb +0 -1
  35. data/lib/project_types/theme/commands/common/root_helper.rb +65 -0
  36. data/lib/project_types/theme/commands/delete.rb +0 -1
  37. data/lib/project_types/theme/commands/init.rb +2 -1
  38. data/lib/project_types/theme/commands/language_server.rb +0 -1
  39. data/lib/project_types/theme/commands/package.rb +0 -1
  40. data/lib/project_types/theme/commands/publish.rb +0 -1
  41. data/lib/project_types/theme/commands/pull.rb +18 -9
  42. data/lib/project_types/theme/commands/push.rb +16 -11
  43. data/lib/project_types/theme/commands/serve.rb +6 -3
  44. data/lib/project_types/theme/conversions/base_glob.rb +50 -0
  45. data/lib/project_types/theme/conversions/ignore_glob.rb +15 -0
  46. data/lib/project_types/theme/conversions/include_glob.rb +15 -0
  47. data/lib/project_types/theme/messages/messages.rb +5 -5
  48. data/lib/shopify_cli/command.rb +11 -3
  49. data/lib/shopify_cli/commands/app/create/node.rb +1 -0
  50. data/lib/shopify_cli/commands/app/create/php.rb +1 -0
  51. data/lib/shopify_cli/commands/app/create/rails.rb +2 -1
  52. data/lib/shopify_cli/commands/app/create.rb +0 -3
  53. data/lib/shopify_cli/commands/app/deploy.rb +1 -1
  54. data/lib/shopify_cli/commands/app/serve.rb +0 -1
  55. data/lib/shopify_cli/constants.rb +2 -2
  56. data/lib/shopify_cli/environment.rb +45 -45
  57. data/lib/shopify_cli/git.rb +9 -1
  58. data/lib/shopify_cli/messages/messages.rb +23 -2
  59. data/lib/shopify_cli/tasks/ensure_git_dependency.rb +14 -0
  60. data/lib/shopify_cli/tasks.rb +1 -0
  61. data/lib/shopify_cli/theme/dev_server/hot_reload/remote_file_reloader.rb +63 -0
  62. data/lib/shopify_cli/theme/dev_server/hot_reload.rb +22 -6
  63. data/lib/shopify_cli/theme/dev_server/proxy.rb +18 -7
  64. data/lib/shopify_cli/theme/dev_server.rb +1 -3
  65. data/lib/shopify_cli/theme/development_theme.rb +11 -0
  66. data/lib/shopify_cli/theme/file.rb +4 -0
  67. data/lib/shopify_cli/theme/include_filter.rb +4 -2
  68. data/lib/shopify_cli/theme/syncer.rb +13 -4
  69. data/lib/shopify_cli/theme/theme.rb +0 -4
  70. data/lib/shopify_cli/version.rb +1 -1
  71. metadata +9 -2
@@ -3,7 +3,6 @@ require "net/http"
3
3
  require "stringio"
4
4
  require "time"
5
5
  require "cgi"
6
-
7
6
  require_relative "proxy/template_param_builder"
8
7
 
9
8
  module ShopifyCLI
@@ -43,9 +42,8 @@ module ShopifyCLI
43
42
  headers["Accept-Encoding"] = "none"
44
43
  headers["User-Agent"] = "Shopify CLI"
45
44
 
46
- query = URI.decode_www_form(env["QUERY_STRING"]).to_h
45
+ query = URI.decode_www_form(env["QUERY_STRING"])
47
46
  replace_templates = build_replace_templates_param(env)
48
-
49
47
  response = if replace_templates.any?
50
48
  # Pass to SFR the recently modified templates in `replace_templates` body param
51
49
  headers["Authorization"] = "Bearer #{bearer_token}"
@@ -71,13 +69,26 @@ module ShopifyCLI
71
69
  @core_endpoints << env["PATH_INFO"]
72
70
  end
73
71
 
74
- body = response.body || [""]
72
+ body = patch_body(env, response.body)
75
73
  body = [body] unless body.respond_to?(:each)
76
74
  [response.code, headers, body]
77
75
  end
78
76
 
79
77
  private
80
78
 
79
+ def patch_body(env, body)
80
+ return [""] unless body
81
+
82
+ body.gsub(%r{(data-.+=(["']))(http:|https:)?//#{@theme.shop}(.*)(\2)}) do |_|
83
+ match = Regexp.last_match
84
+ "#{match[1]}http://#{host(env)}#{match[4]}#{match[5]}"
85
+ end
86
+ end
87
+
88
+ def host(env)
89
+ env["HTTP_HOST"]
90
+ end
91
+
81
92
  def has_body?(headers)
82
93
  headers["Content-Length"] || headers["Transfer-Encoding"]
83
94
  end
@@ -158,7 +169,7 @@ module ShopifyCLI
158
169
  def secure_session_id
159
170
  if secure_session_id_expired?
160
171
  @ctx.debug("Refreshing preview _secure_session_id cookie")
161
- response = request("HEAD", "/", query: { preview_theme_id: @theme.id })
172
+ response = request("HEAD", "/", query: [[:preview_theme_id, @theme.id]])
162
173
  @secure_session_id = extract_secure_session_id_from_response_headers(response)
163
174
  @last_session_cookie_refresh = Time.now
164
175
  end
@@ -189,9 +200,9 @@ module ShopifyCLI
189
200
  response_headers
190
201
  end
191
202
 
192
- def request(method, path, headers: nil, query: {}, form_data: nil, body_stream: nil)
203
+ def request(method, path, headers: nil, query: [], form_data: nil, body_stream: nil)
193
204
  uri = URI.join("https://#{@theme.shop}", path)
194
- uri.query = URI.encode_www_form(query.merge(_fd: 0, pb: 0))
205
+ uri.query = URI.encode_www_form(query + [[:_fd, 0], [:pb, 0]])
195
206
 
196
207
  @ctx.debug("Proxying #{method} #{uri}")
197
208
 
@@ -28,7 +28,7 @@ module ShopifyCLI
28
28
 
29
29
  def start(ctx, root, host: "127.0.0.1", port: 9292, poll: false, mode: ReloadMode.default)
30
30
  @ctx = ctx
31
- theme = DevelopmentTheme.new(ctx, root: root)
31
+ theme = DevelopmentTheme.find_or_create!(ctx, root: root)
32
32
  ignore_filter = IgnoreFilter.from_path(root)
33
33
  @syncer = Syncer.new(ctx, theme: theme, ignore_filter: ignore_filter)
34
34
  watcher = Watcher.new(ctx, theme: theme, syncer: @syncer, ignore_filter: ignore_filter, poll: poll)
@@ -41,8 +41,6 @@ module ShopifyCLI
41
41
  stopped = false
42
42
  address = "http://#{host}:#{port}"
43
43
 
44
- theme.ensure_exists!
45
-
46
44
  trap("INT") do
47
45
  stopped = true
48
46
  stop
@@ -38,6 +38,8 @@ module ShopifyCLI
38
38
  @ctx.debug("Created temporary development theme: #{@id}")
39
39
  ShopifyCLI::DB.set(development_theme_id: @id)
40
40
  end
41
+
42
+ self
41
43
  end
42
44
 
43
45
  def exists?
@@ -63,6 +65,15 @@ module ShopifyCLI
63
65
  new(ctx).delete
64
66
  end
65
67
 
68
+ def self.find(ctx, root: nil)
69
+ dev_theme = new(ctx, root: root)
70
+ dev_theme.exists? ? dev_theme : nil
71
+ end
72
+
73
+ def self.find_or_create!(ctx, root: nil)
74
+ new(ctx, root: root).ensure_exists!
75
+ end
76
+
66
77
  private
67
78
 
68
79
  def generate_theme_name
@@ -53,6 +53,10 @@ module ShopifyCLI
53
53
  path.extname == ".liquid"
54
54
  end
55
55
 
56
+ def liquid_css?
57
+ relative_path.to_s.end_with?(".css.liquid")
58
+ end
59
+
56
60
  def json?
57
61
  path.extname == ".json"
58
62
  end
@@ -9,7 +9,8 @@ module ShopifyCLI
9
9
 
10
10
  attr_reader :globs, :regexes
11
11
 
12
- def initialize(patterns = [])
12
+ def initialize(root, patterns = [])
13
+ @root = Pathname.new(root)
13
14
  @patterns = patterns.nil? ? [] : patterns.compact.reject(&:empty?)
14
15
 
15
16
  regexes, globs = patterns_to_regexes_and_globs(@patterns)
@@ -22,9 +23,10 @@ module ShopifyCLI
22
23
  return true unless present?(@patterns)
23
24
 
24
25
  path = path.to_s
25
-
26
26
  return true if path.empty?
27
27
 
28
+ path = @root.join(path).to_s
29
+
28
30
  regexes.each do |regex|
29
31
  return true if regex_match?(regex, path)
30
32
  end
@@ -42,7 +42,7 @@ module ShopifyCLI
42
42
  # Latest theme assets checksums. Updated on each upload.
43
43
  @checksums = {}
44
44
 
45
- # Checksums of assets with errors.
45
+ # Checksums of assets with errors.
46
46
  @error_checksums = []
47
47
  end
48
48
 
@@ -168,7 +168,7 @@ module ShopifyCLI
168
168
  # Delete local files not present remotely
169
169
  missing_files = @theme.theme_files
170
170
  .reject { |file| checksums.key?(file.relative_path.to_s) }.uniq
171
- .reject { |file| @ignore_filter&.ignore?(file) }
171
+ .reject { |file| ignore_file?(file) }
172
172
  missing_files.each do |file|
173
173
  @ctx.debug("rm #{file.relative_path}")
174
174
  file.delete
@@ -195,7 +195,7 @@ module ShopifyCLI
195
195
  # Already enqueued
196
196
  return if @pending.include?(operation)
197
197
 
198
- if ignore?(operation)
198
+ if ignore_operation?(operation)
199
199
  @ctx.debug("ignore #{operation.file_path}")
200
200
  return
201
201
  end
@@ -253,8 +253,17 @@ module ShopifyCLI
253
253
  response
254
254
  end
255
255
 
256
- def ignore?(operation)
256
+ def ignore_operation?(operation)
257
257
  path = operation.file_path
258
+ ignore_path?(path)
259
+ end
260
+
261
+ def ignore_file?(file)
262
+ path = file.path
263
+ ignore_path?(path)
264
+ end
265
+
266
+ def ignore_path?(path)
258
267
  ignored_by_ignore_filter?(path) || ignored_by_include_filter?(path)
259
268
  end
260
269
 
@@ -176,10 +176,6 @@ module ShopifyCLI
176
176
  find(ctx, root) { |attrs| attrs["role"] == "main" }
177
177
  end
178
178
 
179
- def development(ctx, root: nil)
180
- find(ctx, root) { |attrs| attrs["role"] == "development" }
181
- end
182
-
183
179
  # Finds a Theme by its identifier
184
180
  #
185
181
  # #### Parameters
@@ -1,3 +1,3 @@
1
1
  module ShopifyCLI
2
- VERSION = "2.11.0"
2
+ VERSION = "2.12.0"
3
3
  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.11.0
4
+ version: 2.12.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-02-07 00:00:00.000000000 Z
11
+ date: 2022-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -317,6 +317,7 @@ files:
317
317
  - lib/project_types/script/layers/infrastructure/languages/assemblyscript_task_runner.rb
318
318
  - lib/project_types/script/layers/infrastructure/languages/project_creator.rb
319
319
  - lib/project_types/script/layers/infrastructure/languages/task_runner.rb
320
+ - lib/project_types/script/layers/infrastructure/languages/tool_version_checker.rb
320
321
  - lib/project_types/script/layers/infrastructure/languages/typescript_project_creator.rb
321
322
  - lib/project_types/script/layers/infrastructure/languages/typescript_task_runner.rb
322
323
  - lib/project_types/script/layers/infrastructure/languages/wasm_project_creator.rb
@@ -335,6 +336,7 @@ files:
335
336
  - lib/project_types/script/ui/strict_spinner.rb
336
337
  - lib/project_types/theme/cli.rb
337
338
  - lib/project_types/theme/commands/check.rb
339
+ - lib/project_types/theme/commands/common/root_helper.rb
338
340
  - lib/project_types/theme/commands/delete.rb
339
341
  - lib/project_types/theme/commands/init.rb
340
342
  - lib/project_types/theme/commands/language_server.rb
@@ -343,6 +345,9 @@ files:
343
345
  - lib/project_types/theme/commands/pull.rb
344
346
  - lib/project_types/theme/commands/push.rb
345
347
  - lib/project_types/theme/commands/serve.rb
348
+ - lib/project_types/theme/conversions/base_glob.rb
349
+ - lib/project_types/theme/conversions/ignore_glob.rb
350
+ - lib/project_types/theme/conversions/include_glob.rb
346
351
  - lib/project_types/theme/forms/confirm_store.rb
347
352
  - lib/project_types/theme/forms/select.rb
348
353
  - lib/project_types/theme/messages/messages.rb
@@ -459,6 +464,7 @@ files:
459
464
  - lib/shopify_cli/tasks/ensure_authenticated.rb
460
465
  - lib/shopify_cli/tasks/ensure_dev_store.rb
461
466
  - lib/shopify_cli/tasks/ensure_env.rb
467
+ - lib/shopify_cli/tasks/ensure_git_dependency.rb
462
468
  - lib/shopify_cli/tasks/ensure_loopback_url.rb
463
469
  - lib/shopify_cli/tasks/ensure_project_type.rb
464
470
  - lib/shopify_cli/tasks/select_org_and_shop.rb
@@ -469,6 +475,7 @@ files:
469
475
  - lib/shopify_cli/theme/dev_server/header_hash.rb
470
476
  - lib/shopify_cli/theme/dev_server/hot-reload.js
471
477
  - lib/shopify_cli/theme/dev_server/hot_reload.rb
478
+ - lib/shopify_cli/theme/dev_server/hot_reload/remote_file_reloader.rb
472
479
  - lib/shopify_cli/theme/dev_server/local_assets.rb
473
480
  - lib/shopify_cli/theme/dev_server/proxy.rb
474
481
  - lib/shopify_cli/theme/dev_server/proxy/template_param_builder.rb