@shopify/cli-kit 3.48.3 → 3.48.5

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.
@@ -10,14 +10,13 @@ module ShopifyCLI
10
10
  class FileChangeHook
11
11
  include ShopifyCLI::Theme::IgnoreHelper
12
12
 
13
- attr_reader :include_filter, :ignore_filter, :notifier
13
+ attr_reader :include_filter, :ignore_filter
14
14
 
15
- def initialize(ctx, theme:, include_filter: nil, ignore_filter: nil, notifier: nil)
15
+ def initialize(ctx, theme:, include_filter: nil, ignore_filter: nil)
16
16
  @ctx = ctx
17
17
  @theme = theme
18
18
  @include_filter = include_filter
19
19
  @ignore_filter = ignore_filter
20
- @notifier = notifier
21
20
  end
22
21
 
23
22
  def call(modified, added, removed, streams: nil)
@@ -35,8 +34,6 @@ module ShopifyCLI
35
34
 
36
35
  hot_reload(files) unless files.empty?
37
36
  remote_reload(liquid_css_files)
38
-
39
- notifier.notify_updates(modified + added + removed) unless (modified + added + removed).empty?
40
37
  end
41
38
 
42
39
  private
@@ -102,10 +102,21 @@ module ShopifyCLI
102
102
  def patch_body(env, body)
103
103
  return [""] unless body
104
104
 
105
- body.gsub(%r{(data-base-url=(["']))(http:|https:)?//#{shop}(.*?)(\2)}) do |_|
105
+ # Patch custom font asset urls
106
+ body = body.gsub(
107
+ %r{(url\((["']))?(http:|https:)?//#{shop}(/.*?\.(woff2?|eot|ttf))(\?[^'"\)]*)?(\2\))?\s*}
108
+ ) do |_|
109
+ match = Regexp.last_match
110
+ "#{match[1]}http://#{host(env)}#{match[4]}#{match[6]}#{match[7]} "
111
+ end
112
+
113
+ # Patch data-base-url attributes
114
+ body = body.gsub(%r{(data-base-url=(["']))(http:|https:)?//#{shop}(.*?)(\2)}) do |_|
106
115
  match = Regexp.last_match
107
116
  "#{match[1]}http://#{host(env)}#{match[4]}#{match[5]}"
108
117
  end
118
+
119
+ body
109
120
  end
110
121
 
111
122
  def host(env)
@@ -23,7 +23,6 @@ require_relative "development_theme"
23
23
  require_relative "ignore_filter"
24
24
  require_relative "include_filter"
25
25
  require_relative "syncer"
26
- require_relative "notifier"
27
26
 
28
27
  module ShopifyCLI
29
28
  module Theme
@@ -207,14 +206,11 @@ module ShopifyCLI
207
206
  include_filter: include_filter,
208
207
  ignore_filter: ignore_filter,
209
208
  overwrite_json: !editor_sync || @overwrite_json,
210
- stable: stable
209
+ stable: stable,
210
+ notify: notify
211
211
  )
212
212
  end
213
213
 
214
- def notifier
215
- @notifier ||= Notifier.new(ctx, path: notify)
216
- end
217
-
218
214
  def watcher
219
215
  @watcher ||= Watcher.new(
220
216
  ctx,
@@ -261,7 +257,7 @@ module ShopifyCLI
261
257
 
262
258
  def broadcast_hooks
263
259
  file_handler = Hooks::FileChangeHook.new(ctx, theme: theme, include_filter: include_filter,
264
- ignore_filter: ignore_filter, notifier: notifier)
260
+ ignore_filter: ignore_filter)
265
261
  [file_handler]
266
262
  end
267
263
 
@@ -9,14 +9,13 @@ module ShopifyCLI
9
9
  class FileChangeHook
10
10
  include ShopifyCLI::Theme::Extension::IgnoreHelper
11
11
 
12
- attr_reader :ctx, :extension, :syncer, :streams, :notifier, :ignore_filter
12
+ attr_reader :ctx, :extension, :syncer, :streams, :ignore_filter
13
13
 
14
- def initialize(ctx, extension:, syncer:, notifier:, ignore_filter: nil)
14
+ def initialize(ctx, extension:, syncer:, ignore_filter: nil)
15
15
  @ctx = ctx
16
16
  @extension = extension
17
17
  @syncer = syncer
18
18
  @ignore_filter = ignore_filter
19
- @notifier = notifier
20
19
  end
21
20
 
22
21
  def call(modified, added, removed, streams: nil)
@@ -32,8 +31,6 @@ module ShopifyCLI
32
31
 
33
32
  hot_reload(modified) unless modified.empty?
34
33
  reload_page(added, removed) unless (added + removed).empty?
35
-
36
- notifier.notify_updates(modified + added + removed) unless (modified + added + removed).empty?
37
34
  end
38
35
 
39
36
  private
@@ -6,7 +6,6 @@ require "shopify_cli/theme/extension/app_extension"
6
6
  require "shopify_cli/theme/dev_server"
7
7
  require "shopify_cli/theme/extension/host_theme"
8
8
  require "shopify_cli/theme/syncer"
9
- require "shopify_cli/theme/notifier"
10
9
  require "shopify_cli/theme/ignore_filter"
11
10
 
12
11
  require_relative "dev_server/local_assets"
@@ -29,10 +28,11 @@ module ShopifyCLI
29
28
  ScriptInjector = ShopifyCLI::Theme::Extension::DevServer::HotReload::ScriptInjector
30
29
 
31
30
  attr_accessor :project, :specification_handler, :generate_tmp_theme
31
+ attr_reader :notify
32
32
 
33
33
  class << self
34
34
  def start(ctx, root, port: 9292, theme: nil, generate_tmp_theme: false, project:, specification_handler:,
35
- notify: nil)
35
+ notify:)
36
36
  instance.project = project
37
37
  instance.specification_handler = specification_handler
38
38
  instance.generate_tmp_theme = generate_tmp_theme
@@ -65,14 +65,11 @@ module ShopifyCLI
65
65
  extension: extension,
66
66
  project: project,
67
67
  specification_handler: specification_handler,
68
- ignore_filter: ignore_filter
68
+ ignore_filter: ignore_filter,
69
+ notify: notify
69
70
  )
70
71
  end
71
72
 
72
- def notifier
73
- @notifier ||= ShopifyCLI::Theme::Notifier.new(ctx, path: notify)
74
- end
75
-
76
73
  def theme
77
74
  @theme ||= if theme_identifier
78
75
  theme = HostTheme.find_by_identifier(ctx, identifier: theme_identifier)
@@ -142,7 +139,7 @@ module ShopifyCLI
142
139
  # Hooks
143
140
 
144
141
  def broadcast_hooks
145
- file_handler = Hooks::FileChangeHook.new(ctx, extension: extension, syncer: syncer, notifier: notifier,
142
+ file_handler = Hooks::FileChangeHook.new(ctx, extension: extension, syncer: syncer,
146
143
  ignore_filter: ignore_filter)
147
144
  [file_handler]
148
145
  end
@@ -3,6 +3,7 @@ require "project_types/extension/loaders/project"
3
3
  require "project_types/extension/loaders/specification_handler"
4
4
  require "shopify_cli/partners_api"
5
5
  require "shopify_cli/thread_pool/job"
6
+ require "shopify_cli/theme/notifier"
6
7
 
7
8
  module ShopifyCLI
8
9
  module Theme
@@ -17,7 +18,7 @@ module ShopifyCLI
17
18
  USER_ERRORS_FIELD = "userErrors"
18
19
  ERROR_FILE_REGEX = /\[([^\]\[]*)\]/
19
20
 
20
- def initialize(ctx, syncer:, extension:, project:, specification_handler:)
21
+ def initialize(ctx, syncer:, extension:, project:, specification_handler:, notify:)
21
22
  super(POLL_FREQUENCY)
22
23
 
23
24
  @ctx = ctx
@@ -25,6 +26,7 @@ module ShopifyCLI
25
26
  @project = project
26
27
  @specification_handler = specification_handler
27
28
 
29
+ @notifier = ShopifyCLI::Theme::Notifier.new(ctx, path: notify)
28
30
  @syncer = syncer
29
31
  @syncer_mutex = Mutex.new
30
32
 
@@ -60,6 +62,10 @@ module ShopifyCLI
60
62
  ::Extension::Tasks::Converters::VersionConverter.from_hash(@ctx, response.dig(VERSION_FIELD))
61
63
  end
62
64
 
65
+ files = @syncer.pending_files.map(&:relative_path)
66
+ # Notify changes after the sync is complete
67
+ @notifier.notify_updates(files)
68
+
63
69
  @syncer_mutex.synchronize do
64
70
  @syncer.pending_operations.clear
65
71
  @syncer.latest_sync = Time.now
@@ -12,14 +12,15 @@ module ShopifyCLI
12
12
  class Syncer
13
13
  include ShopifyCLI::Theme::Extension::IgnoreHelper
14
14
 
15
- attr_accessor :pending_operations, :latest_sync, :ignore_filter
15
+ attr_accessor :pending_operations, :latest_sync, :ignore_filter, :notify
16
16
 
17
- def initialize(ctx, extension:, project:, specification_handler:, ignore_filter: nil)
17
+ def initialize(ctx, extension:, project:, specification_handler:, ignore_filter: nil, notify: nil)
18
18
  @ctx = ctx
19
19
  @extension = extension
20
20
  @project = project
21
21
  @specification_handler = specification_handler
22
22
  @ignore_filter = ignore_filter
23
+ @notify = notify
23
24
 
24
25
  @pool = ThreadPool.new(pool_size: 1)
25
26
  @pending_operations = []
@@ -89,7 +90,8 @@ module ShopifyCLI
89
90
  syncer: self,
90
91
  extension: @extension,
91
92
  project: @project,
92
- specification_handler: @specification_handler
93
+ specification_handler: @specification_handler,
94
+ notify: notify,
93
95
  )
94
96
  end
95
97
  end
@@ -17,6 +17,7 @@ require_relative "syncer/operation"
17
17
  require_relative "syncer/standard_reporter"
18
18
  require_relative "syncer/unsupported_script_warning"
19
19
  require_relative "syncer/uploader"
20
+ require_relative "notifier"
20
21
 
21
22
  module ShopifyCLI
22
23
  module Theme
@@ -38,7 +39,8 @@ module ShopifyCLI
38
39
 
39
40
  def_delegators :@error_reporter, :has_any_error?
40
41
 
41
- def initialize(ctx, theme:, include_filter: nil, ignore_filter: nil, overwrite_json: true, stable: false)
42
+ def initialize(ctx, theme:, include_filter: nil, ignore_filter: nil, overwrite_json: true, stable: false,
43
+ notify: nil)
42
44
  @ctx = ctx
43
45
  @theme = theme
44
46
  @include_filter = include_filter
@@ -46,6 +48,7 @@ module ShopifyCLI
46
48
  @overwrite_json = overwrite_json
47
49
  @error_reporter = ErrorReporter.new(ctx)
48
50
  @standard_reporter = StandardReporter.new(ctx)
51
+ @notifier = Notifier.new(ctx, path: notify)
49
52
  @reporters = [@error_reporter, @standard_reporter]
50
53
 
51
54
  # Queue of `Operation`s waiting to be picked up from a thread for processing.
@@ -298,6 +301,8 @@ module ShopifyCLI
298
301
  handle_operation_error(operation, error)
299
302
  ensure
300
303
  @pending.delete(operation)
304
+ # Notify changes after the operation performs
305
+ @notifier.notify_updates([operation.file_path])
301
306
  end
302
307
 
303
308
  def update(file)
@@ -1 +1 @@
1
- export declare const CLI_KIT_VERSION = "3.48.3";
1
+ export declare const CLI_KIT_VERSION = "3.48.5";
@@ -1,2 +1,2 @@
1
- export const CLI_KIT_VERSION = '3.48.3';
1
+ export const CLI_KIT_VERSION = '3.48.5';
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.48.3'\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.48.5'\n"]}
@@ -118,6 +118,6 @@ export function moduleDirectory(moduleURL) {
118
118
  */
119
119
  export function cwd() {
120
120
  // eslint-disable-next-line @shopify/cli/no-process-cwd
121
- return process.env.INIT_CWD ? normalize(process.env.INIT_CWD) : process.cwd();
121
+ return normalize(process.env.INIT_CWD ? process.env.INIT_CWD : process.cwd());
122
122
  }
123
123
  //# sourceMappingURL=path.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/public/node/path.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,EACL,QAAQ,EACR,OAAO,IAAI,YAAY,EACvB,IAAI,EACJ,SAAS,EACT,OAAO,EACP,QAAQ,IAAI,aAAa,EACzB,OAAO,IAAI,YAAY,EACvB,UAAU,GACX,MAAM,OAAO,CAAA;AACd,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAA;AAIjC;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,KAAe;IACzC,OAAO,IAAI,CAAC,GAAG,KAAK,CAAC,CAAA;AACvB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAA;AACxB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAG,KAAe;IAC5C,OAAO,OAAO,CAAC,GAAG,KAAK,CAAC,CAAA;AAC1B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,EAAU;IACnD,OAAO,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;AAC3B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,UAAU,CAAC,IAAI,C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AAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAA;AAC/E,CAAC","sourcesContent":["import commondir from 'commondir'\nimport {\n relative,\n dirname as patheDirname,\n join,\n normalize,\n resolve,\n basename as basenamePathe,\n extname as extnamePathe,\n isAbsolute,\n} from 'pathe'\nimport {fileURLToPath} from 'url'\n// eslint-disable-next-line node/prefer-global/url\nimport type {URL} from 'url'\n\n/**\n * Joins a list of paths together.\n *\n * @param paths - Paths to join.\n * @returns Joined path.\n */\nexport function joinPath(...paths: string[]): string {\n return join(...paths)\n}\n\n/**\n * Normalizes a path.\n *\n * @param path - Path to normalize.\n * @returns Normalized path.\n */\nexport function normalizePath(path: string): string {\n return normalize(path)\n}\n\n/**\n * Resolves a list of paths together.\n *\n * @param paths - Paths to resolve.\n * @returns Resolved path.\n */\nexport function resolvePath(...paths: string[]): string {\n return resolve(...paths)\n}\n\n/**\n * Returns the relative path from one path to another.\n *\n * @param from - Path to resolve from.\n * @param to - Path to resolve to.\n * @returns Relative path.\n */\nexport function relativePath(from: string, to: string): string {\n return relative(from, to)\n}\n\n/**\n * Returns whether the path is absolute.\n *\n * @param path - Path to check.\n * @returns Whether the path is absolute.\n */\nexport function isAbsolutePath(path: string): boolean {\n return isAbsolute(path)\n}\n\n/**\n * Returns the directory name of a path.\n *\n * @param path - Path to get the directory name of.\n * @returns Directory name.\n */\nexport function dirname(path: string): string {\n return patheDirname(path)\n}\n\n/**\n * Returns the base name of a path.\n *\n * @param path - Path to get the base name of.\n * @param ext - Optional extension to remove from the result.\n * @returns Base name.\n */\nexport function basename(path: string, ext?: string): string {\n return basenamePathe(path, ext)\n}\n\n/**\n * Returns the extension of the path.\n *\n * @param path - Path to get the extension of.\n * @returns Extension.\n */\nexport function extname(path: string): string {\n return extnamePathe(path)\n}\n\n/**\n * Given an absolute filesystem path, it makes it relative to\n * the current working directory. This is useful when logging paths\n * to allow the users to click on the file and let the OS open it\n * in the editor of choice.\n *\n * @param path - Path to relativize.\n * @param dir - Current working directory.\n * @returns Relativized path.\n */\nexport function relativizePath(path: string, dir: string = cwd()): string {\n const result = commondir([path, dir])\n const relativePath = relative(dir, path)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const relativeComponents = relativePath.split('/').filter((component) => component === '..').length\n if (result === '/' || relativePath === '' || relativeComponents > 2) {\n return path\n } else {\n return relativePath\n }\n}\n\n/**\n * Given a module's import.meta.url it returns the directory containing the module.\n *\n * @param moduleURL - The value of import.meta.url in the context of the caller module.\n * @returns The path to the directory containing the caller module.\n */\nexport function moduleDirectory(moduleURL: string | URL): string {\n return dirname(fileURLToPath(moduleURL))\n}\n\n/**\n * When running a script using `npm run`, something interesting happens. If the current\n * folder does not have a `package.json` or a `node_modules` folder, npm will traverse\n * the directory tree upwards until it finds one. Then it will run the script and set\n * `process.cwd()` to that folder, while the actual path is stored in the INIT_CWD\n * environment variable (see here: https://docs.npmjs.com/cli/v9/commands/npm-run-script#description).\n *\n * @returns The path to the current working directory.\n */\nexport function cwd(): string {\n // eslint-disable-next-line @shopify/cli/no-process-cwd\n return process.env.INIT_CWD ? normalize(process.env.INIT_CWD) : process.cwd()\n}\n"]}
1
+ {"version":3,"file":"path.js","sourceRoot":"","sources":["../../../src/public/node/path.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,EACL,QAAQ,EACR,OAAO,IAAI,YAAY,EACvB,IAAI,EACJ,SAAS,EACT,OAAO,EACP,QAAQ,IAAI,aAAa,EACzB,OAAO,IAAI,YAAY,EACvB,UAAU,GACX,MAAM,OAAO,CAAA;AACd,OAAO,EAAC,aAAa,EAAC,MAAM,KAAK,CAAA;AAIjC;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAG,KAAe;IACzC,OAAO,IAAI,CAAC,GAAG,KAAK,CAAC,CAAA;AACvB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,SAAS,CAAC,IA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AI,CAAA;KACZ;SAAM;QACL,OAAO,YAAY,CAAA;KACpB;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,SAAuB;IACrD,OAAO,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAA;AAC1C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,GAAG;IACjB,uDAAuD;IACvD,OAAO,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;AAC/E,CAAC","sourcesContent":["import commondir from 'commondir'\nimport {\n relative,\n dirname as patheDirname,\n join,\n normalize,\n resolve,\n basename as basenamePathe,\n extname as extnamePathe,\n isAbsolute,\n} from 'pathe'\nimport {fileURLToPath} from 'url'\n// eslint-disable-next-line node/prefer-global/url\nimport type {URL} from 'url'\n\n/**\n * Joins a list of paths together.\n *\n * @param paths - Paths to join.\n * @returns Joined path.\n */\nexport function joinPath(...paths: string[]): string {\n return join(...paths)\n}\n\n/**\n * Normalizes a path.\n *\n * @param path - Path to normalize.\n * @returns Normalized path.\n */\nexport function normalizePath(path: string): string {\n return normalize(path)\n}\n\n/**\n * Resolves a list of paths together.\n *\n * @param paths - Paths to resolve.\n * @returns Resolved path.\n */\nexport function resolvePath(...paths: string[]): string {\n return resolve(...paths)\n}\n\n/**\n * Returns the relative path from one path to another.\n *\n * @param from - Path to resolve from.\n * @param to - Path to resolve to.\n * @returns Relative path.\n */\nexport function relativePath(from: string, to: string): string {\n return relative(from, to)\n}\n\n/**\n * Returns whether the path is absolute.\n *\n * @param path - Path to check.\n * @returns Whether the path is absolute.\n */\nexport function isAbsolutePath(path: string): boolean {\n return isAbsolute(path)\n}\n\n/**\n * Returns the directory name of a path.\n *\n * @param path - Path to get the directory name of.\n * @returns Directory name.\n */\nexport function dirname(path: string): string {\n return patheDirname(path)\n}\n\n/**\n * Returns the base name of a path.\n *\n * @param path - Path to get the base name of.\n * @param ext - Optional extension to remove from the result.\n * @returns Base name.\n */\nexport function basename(path: string, ext?: string): string {\n return basenamePathe(path, ext)\n}\n\n/**\n * Returns the extension of the path.\n *\n * @param path - Path to get the extension of.\n * @returns Extension.\n */\nexport function extname(path: string): string {\n return extnamePathe(path)\n}\n\n/**\n * Given an absolute filesystem path, it makes it relative to\n * the current working directory. This is useful when logging paths\n * to allow the users to click on the file and let the OS open it\n * in the editor of choice.\n *\n * @param path - Path to relativize.\n * @param dir - Current working directory.\n * @returns Relativized path.\n */\nexport function relativizePath(path: string, dir: string = cwd()): string {\n const result = commondir([path, dir])\n const relativePath = relative(dir, path)\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const relativeComponents = relativePath.split('/').filter((component) => component === '..').length\n if (result === '/' || relativePath === '' || relativeComponents > 2) {\n return path\n } else {\n return relativePath\n }\n}\n\n/**\n * Given a module's import.meta.url it returns the directory containing the module.\n *\n * @param moduleURL - The value of import.meta.url in the context of the caller module.\n * @returns The path to the directory containing the caller module.\n */\nexport function moduleDirectory(moduleURL: string | URL): string {\n return dirname(fileURLToPath(moduleURL))\n}\n\n/**\n * When running a script using `npm run`, something interesting happens. If the current\n * folder does not have a `package.json` or a `node_modules` folder, npm will traverse\n * the directory tree upwards until it finds one. Then it will run the script and set\n * `process.cwd()` to that folder, while the actual path is stored in the INIT_CWD\n * environment variable (see here: https://docs.npmjs.com/cli/v9/commands/npm-run-script#description).\n *\n * @returns The path to the current working directory.\n */\nexport function cwd(): string {\n // eslint-disable-next-line @shopify/cli/no-process-cwd\n return normalize(process.env.INIT_CWD ? process.env.INIT_CWD : process.cwd())\n}\n"]}