shopify-cli 2.34.0 → 2.35.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: dd29ef210f31fc605f44e4ecc7402157b79ab92091aa247a2025576a87e7159b
4
- data.tar.gz: bf8c1081b70e4c97d5dabd6ed54818b5e6fada2787ebc51cb5406791af9e5982
3
+ metadata.gz: e7ff4aa2c4934ffc7d8ea74b5411396057302d3c689de0118e8d575dffe1f80e
4
+ data.tar.gz: 3f6c1e379cf651d615f12f399bb219f791cf9881e910f0b253a2d7511acdb3af
5
5
  SHA512:
6
- metadata.gz: e941e27b0d6a5faf0bf210f21cb0fd8d86bcc1bfc142e4e57ba44f6918fdc44664c6d82d32f605a3a1aa047119242014e1c4b324031212fdc849c7361c0e29fa
7
- data.tar.gz: '09b978061cecd114d072d17df1667601f0275fb6a28f42219a3ba359b44cde4c7becb63d65a6ec6e686eeeedbdf54f29ca911cfb7eaf3b19d116d3a816740f78'
6
+ metadata.gz: 63f11f8ba2303796b678fcc0a0b30163ec556bdb3551ed6b3f0b036e2bf2564c9c8adfde10a23d9cd45bfaa67f5fcff678fc25055243edd2b99c2445fbb7a8e7
7
+ data.tar.gz: eca42fd71a12ed6fd22547b55590c2bcf64e0ed675420478de0b771e9483d4a42e5c959d967a301cc5814b7393ca51b29444cbd4873349249122f3af9d962e1d
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.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
+
5
16
  ## Version 2.34.0 - 2023-01-11
6
17
 
7
18
  ### Added
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify-cli (2.34.0)
4
+ shopify-cli (2.35.0)
5
5
  bugsnag (~> 6.22)
6
6
  listen (~> 3.7.0)
7
7
  theme-check (~> 1.14.0)
@@ -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.34.0"
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
 
@@ -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.34.0
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-11 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