@shopify/cli-kit 3.46.2 → 3.46.3

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.
@@ -6,9 +6,9 @@ module ShopifyCLI
6
6
  class CdnFonts
7
7
  FONTS_PATH = "/fonts"
8
8
  FONTS_CDN = "https://fonts.shopifycdn.com"
9
- FONTS_REGEX = %r{#{FONTS_CDN}}
10
9
 
11
- def initialize(app, theme:)
10
+ def initialize(ctx, app, theme:)
11
+ @ctx = ctx
12
12
  @app = app
13
13
  @theme = theme
14
14
  end
@@ -69,7 +69,12 @@ module ShopifyCLI
69
69
  end
70
70
 
71
71
  def replace_font_urls(body)
72
- [body.join.gsub(FONTS_REGEX, FONTS_PATH)]
72
+ fonts_regex = %r{#{FONTS_CDN}|((http:|https:)?//#{shop}/cdn/fonts)}
73
+ [body.join.gsub(fonts_regex, FONTS_PATH)]
74
+ end
75
+
76
+ def shop
77
+ @shop ||= ShopifyCLI::Theme::ThemeAdminAPI.new(@ctx).get_shop_or_abort
73
78
  end
74
79
  end
75
80
  end
@@ -4,8 +4,9 @@ module ShopifyCLI
4
4
  module Theme
5
5
  class DevServer
6
6
  class LocalAssets
7
- THEME_REGEX = %r{//cdn\.shopify\.com/s/.+?/(assets/.+?\.(?:css|js))}
8
- VANITY_THEME_REGEX = %r{/cdn/shop/.+?/(assets/.+?\.(?:css|js))}
7
+ SUPPORTED_EXTENSIONS = [:jpg, :jpeg, :js, :css, :png, :svg].join("|")
8
+ CDN_REGEX = %r{(//cdn)\.shopify\.com/s/.+?/(assets/.+?\.(?:#{SUPPORTED_EXTENSIONS}))}
9
+ VANITY_CDN_REGEX = %r{(/cdn)/shop/.+?/(assets/.+?\.(?:#{SUPPORTED_EXTENSIONS}))}
9
10
 
10
11
  class FileBody
11
12
  def initialize(path)
@@ -42,13 +43,17 @@ module ShopifyCLI
42
43
  end
43
44
  end
44
45
 
46
+ def shop_regex
47
+ %r{(http:|https:)?//#{shop}/(assets/.+?\.(?:#{SUPPORTED_EXTENSIONS}))}
48
+ end
49
+
45
50
  private
46
51
 
47
52
  def replace_asset_urls(body)
48
53
  replaced_body = body.join
49
- [THEME_REGEX, VANITY_THEME_REGEX].each do |regex|
54
+ [CDN_REGEX, VANITY_CDN_REGEX, shop_regex].each do |regex|
50
55
  replaced_body = replaced_body.gsub(regex) do |match|
51
- path = Regexp.last_match[1]
56
+ path = Regexp.last_match[2]
52
57
  @target.static_asset_paths.include?(path) ? "/#{path}" : match
53
58
  end
54
59
  end
@@ -86,6 +91,10 @@ module ShopifyCLI
86
91
  serve_fail(404, "Not found")
87
92
  end
88
93
  end
94
+
95
+ def shop
96
+ @shop ||= ShopifyCLI::Theme::ThemeAdminAPI.new(@ctx).get_shop_or_abort
97
+ end
89
98
  end
90
99
  end
91
100
  end
@@ -168,7 +168,7 @@ module ShopifyCLI
168
168
 
169
169
  def middleware_stack
170
170
  @app = Proxy.new(ctx, theme, param_builder)
171
- @app = CdnFonts.new(@app, theme: theme)
171
+ @app = CdnFonts.new(ctx, @app, theme: theme)
172
172
  @app = LocalAssets.new(ctx, @app, theme)
173
173
  @app = HotReload.new(ctx, @app, broadcast_hooks: broadcast_hooks, watcher: watcher, mode: mode,
174
174
  script_injector: script_injector)
@@ -7,7 +7,8 @@ module ShopifyCLI
7
7
  module Extension
8
8
  class DevServer < ShopifyCLI::Theme::DevServer
9
9
  class LocalAssets < ShopifyCLI::Theme::DevServer::LocalAssets
10
- TAE_ASSET_REGEX = %r{(http:|https:)?//cdn\.shopify\.com/extensions/.+?/(assets/.+?\.(?:css|js))}
10
+ SUPPORTED_EXTENSIONS = [:jpg, :jpeg, :js, :css, :png, :svg].join("|")
11
+ TAE_ASSET_REGEX = %r{(http:|https:)?//cdn\.shopify\.com/extensions/.+?/(assets/.+?\.(?:#{SUPPORTED_EXTENSIONS}))}
11
12
 
12
13
  private
13
14
 
@@ -44,7 +44,7 @@ module ShopifyCLI
44
44
 
45
45
  def middleware_stack
46
46
  @app = Proxy.new(ctx, theme, param_builder)
47
- @app = CdnFonts.new(@app, theme: theme)
47
+ @app = CdnFonts.new(ctx, @app, theme: theme)
48
48
  @app = LocalAssets.new(ctx, @app, extension)
49
49
  @app = HotReload.new(ctx, @app, broadcast_hooks: broadcast_hooks, watcher: watcher, mode: mode,
50
50
  script_injector: script_injector)
@@ -57,7 +57,7 @@ module ShopifyCLI
57
57
 
58
58
  def middleware_stack
59
59
  @app = proxy
60
- @app = CdnFonts.new(app, theme: theme)
60
+ @app = CdnFonts.new(ctx, app, theme: theme)
61
61
  @app = AuthMiddleware.new(app, proxy, repl) { WebServer.shutdown }
62
62
  end
63
63
 
@@ -1 +1 @@
1
- export declare const CLI_KIT_VERSION = "3.46.2";
1
+ export declare const CLI_KIT_VERSION = "3.46.3";
@@ -1,2 +1,2 @@
1
- export const CLI_KIT_VERSION = '3.46.2';
1
+ export const CLI_KIT_VERSION = '3.46.3';
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.46.2'\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../src/public/common/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA","sourcesContent":["export const CLI_KIT_VERSION = '3.46.3'\n"]}