shopify-cli 2.20.1 → 2.21.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/Gemfile.lock +1 -1
- data/lib/shopify_cli/constants.rb +1 -0
- data/lib/shopify_cli/context.rb +3 -2
- data/lib/shopify_cli/environment.rb +4 -0
- data/lib/shopify_cli/theme/dev_server/hot-reload.js +22 -7
- data/lib/shopify_cli/theme/dev_server/hot_reload/remote_file_deleter.rb +62 -0
- data/lib/shopify_cli/theme/dev_server/hot_reload.rb +23 -1
- data/lib/shopify_cli/theme/dev_server/proxy.rb +1 -0
- data/lib/shopify_cli/theme/syncer.rb +5 -1
- data/lib/shopify_cli/theme/theme.rb +5 -0
- data/lib/shopify_cli/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8971e6497feaa24c2fd34b00c29208f44ffb4cd6405b1b1ec08324b41ade05ad
|
4
|
+
data.tar.gz: 111bbf0f53d8d57812916ee930773887e07163008bd04a1796312378148d70ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f83037ed5100015bb76f76864af37bff6a735c61d43f1d7870f67441f45d565530e2ebe43537f1f0891a6eda67a2631604916359b678ab8a7d262576a576171d
|
7
|
+
data.tar.gz: 7dd3af12ba1f384d7232c48c5a6f2724a99917eeb598d61d9a01cb86be4d2f114142daf226dc4f58f8083b4f0f8937cbd7f55d9b9283272be4e5c8c6e257ae04
|
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.21.0 - 2022-08-03
|
6
|
+
|
7
|
+
### Fixed
|
8
|
+
* [#2453](https://github.com/Shopify/shopify-cli/pull/2453): Fix [#2382](https://github.com/Shopify/shopify-cli/issues/2382): Ensure we wait 24 hours to show update message again
|
9
|
+
* [#2463](https://github.com/Shopify/shopify-cli/pull/2463): Fix for "Keep the remote version" deletes files on new development theme
|
10
|
+
* [#2405](https://github.com/Shopify/shopify-cli/pull/2405): Fix `theme serve` to trigger page refresh when a file is deleted
|
11
|
+
* [#2489](https://github.com/Shopify/shopify-cli/pull/2489): Fix `theme serve` to hot reload many occurrences of a stylesheet
|
12
|
+
|
13
|
+
### Added
|
14
|
+
* [#2496](https://github.com/Shopify/shopify-cli/pull/2496): Accept storefront renderer token from ENV variable
|
15
|
+
|
5
16
|
## Version 2.20.1 - 2022-07-18
|
6
17
|
|
7
18
|
### Fixed
|
data/Gemfile.lock
CHANGED
@@ -54,6 +54,7 @@ module ShopifyCLI
|
|
54
54
|
# Authentication
|
55
55
|
AUTH_TOKEN = "SHOPIFY_CLI_AUTH_TOKEN"
|
56
56
|
ADMIN_AUTH_TOKEN = "SHOPIFY_CLI_ADMIN_AUTH_TOKEN"
|
57
|
+
STOREFRONT_RENDERER_AUTH_TOKEN = "SHOPIFY_CLI_STOREFRONT_RENDERER_AUTH_TOKEN"
|
57
58
|
|
58
59
|
# Monorail
|
59
60
|
MONORAIL_REAL_EVENTS = "MONORAIL_REAL_EVENTS"
|
data/lib/shopify_cli/context.rb
CHANGED
@@ -628,9 +628,10 @@ module ShopifyCLI
|
|
628
628
|
thread = Thread.new { retrieve_latest_gem_version }
|
629
629
|
at_exit { thread.join }
|
630
630
|
end
|
631
|
+
latest_version =
|
632
|
+
ShopifyCLI::Config.get(VERSION_CHECK_SECTION, LATEST_VERSION_FIELD, default: ShopifyCLI::VERSION)
|
633
|
+
latest_version if ::Semantic::Version.new(latest_version) > ::Semantic::Version.new(ShopifyCLI::VERSION)
|
631
634
|
end
|
632
|
-
latest_version = ShopifyCLI::Config.get(VERSION_CHECK_SECTION, LATEST_VERSION_FIELD, default: ShopifyCLI::VERSION)
|
633
|
-
latest_version if ::Semantic::Version.new(latest_version) > ::Semantic::Version.new(ShopifyCLI::VERSION)
|
634
635
|
end
|
635
636
|
|
636
637
|
# Returns file extension depending on OS
|
@@ -170,6 +170,10 @@ module ShopifyCLI
|
|
170
170
|
env_variables[Constants::EnvironmentVariables::ADMIN_AUTH_TOKEN]
|
171
171
|
end
|
172
172
|
|
173
|
+
def self.storefront_renderer_auth_token(env_variables: ENV)
|
174
|
+
env_variables[Constants::EnvironmentVariables::STOREFRONT_RENDERER_AUTH_TOKEN]
|
175
|
+
end
|
176
|
+
|
173
177
|
def self.store(env_variables: ENV)
|
174
178
|
env_variables[Constants::EnvironmentVariables::STORE]
|
175
179
|
end
|
@@ -14,7 +14,7 @@
|
|
14
14
|
function connect() {
|
15
15
|
const eventSource = new EventSource('/hot-reload');
|
16
16
|
|
17
|
-
eventSource.onmessage =
|
17
|
+
eventSource.onmessage = onMessage;
|
18
18
|
|
19
19
|
eventSource.onopen = () => console.log('[HotReload] SSE connected.');
|
20
20
|
|
@@ -97,10 +97,23 @@
|
|
97
97
|
window.location.reload();
|
98
98
|
}
|
99
99
|
|
100
|
-
function
|
101
|
-
|
100
|
+
function onMessage(message) {
|
101
|
+
const data = JSON.parse(message.data);
|
102
|
+
if (data.reload_page) {
|
103
|
+
refreshPage([]);
|
104
|
+
return;
|
105
|
+
}
|
106
|
+
|
107
|
+
handleUpdate(data);
|
108
|
+
}
|
109
|
+
|
110
|
+
function handleUpdate(data) {
|
102
111
|
var modifiedFiles = data.modified;
|
103
112
|
|
113
|
+
if (modifiedFiles === undefined) {
|
114
|
+
return;
|
115
|
+
}
|
116
|
+
|
104
117
|
if (isRefreshRequired(modifiedFiles)) {
|
105
118
|
refreshPage(modifiedFiles);
|
106
119
|
} else {
|
@@ -114,13 +127,15 @@
|
|
114
127
|
|
115
128
|
function reloadCssFile(filename) {
|
116
129
|
// Find a stylesheet link starting with /assets (locally-served only) containing the filename
|
117
|
-
let
|
130
|
+
let links = document.querySelectorAll(`link[href^="/assets"][href*="${filename}"][rel="stylesheet"]`);
|
118
131
|
|
119
|
-
if (!
|
132
|
+
if (!links.length) {
|
120
133
|
console.log(`[HotReload] Could not find link for stylesheet ${filename}`);
|
121
134
|
} else {
|
122
|
-
|
123
|
-
|
135
|
+
links.forEach(link => {
|
136
|
+
link.href = new URL(link.href).pathname + `?v=${Date.now()}`;
|
137
|
+
console.log(`[HotReload] Reloaded stylesheet ${filename}`);
|
138
|
+
})
|
124
139
|
}
|
125
140
|
}
|
126
141
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ShopifyCLI
|
4
|
+
module Theme
|
5
|
+
module DevServer
|
6
|
+
class HotReload
|
7
|
+
class RemoteFileDeleter
|
8
|
+
def initialize(ctx, theme:, streams:)
|
9
|
+
@ctx = ctx
|
10
|
+
@theme = theme
|
11
|
+
@streams = streams
|
12
|
+
end
|
13
|
+
|
14
|
+
def delete(file)
|
15
|
+
retries = 6
|
16
|
+
|
17
|
+
until retries.zero?
|
18
|
+
retries -= 1
|
19
|
+
|
20
|
+
_status, body = fetch_asset(file)
|
21
|
+
retries = 0 if deleted_file?(body)
|
22
|
+
|
23
|
+
wait
|
24
|
+
end
|
25
|
+
|
26
|
+
notify(file)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def api_client
|
32
|
+
@api_client ||= ThemeAdminAPI.new(@ctx, @theme.shop)
|
33
|
+
end
|
34
|
+
|
35
|
+
def deleted_file?(body)
|
36
|
+
remote_checksum = body.dig("asset", "checksum")
|
37
|
+
|
38
|
+
remote_checksum.nil?
|
39
|
+
end
|
40
|
+
|
41
|
+
def notify(file)
|
42
|
+
@streams.broadcast(JSON.generate(deleted: [file]))
|
43
|
+
@ctx.debug("[RemoteFileDeleter] Deleted #{file}")
|
44
|
+
end
|
45
|
+
|
46
|
+
def wait
|
47
|
+
sleep(1)
|
48
|
+
end
|
49
|
+
|
50
|
+
def fetch_asset(file)
|
51
|
+
api_client.get(
|
52
|
+
path: "themes/#{@theme.id}/assets.json",
|
53
|
+
query: URI.encode_www_form("asset[key]" => file.relative_path),
|
54
|
+
)
|
55
|
+
rescue ShopifyCLI::API::APIRequestNotFoundError
|
56
|
+
[404, {}]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "hot_reload/remote_file_reloader"
|
4
|
+
require_relative "hot_reload/remote_file_deleter"
|
4
5
|
require_relative "hot_reload/sections_index"
|
5
6
|
|
6
7
|
module ShopifyCLI
|
@@ -14,6 +15,7 @@ module ShopifyCLI
|
|
14
15
|
@mode = mode
|
15
16
|
@streams = SSE::Streams.new
|
16
17
|
@remote_file_reloader = RemoteFileReloader.new(ctx, theme: @theme, streams: @streams)
|
18
|
+
@remote_file_deleter = RemoteFileDeleter.new(ctx, theme: @theme, streams: @streams)
|
17
19
|
@sections_index = SectionsIndex.new(@theme)
|
18
20
|
@watcher = watcher
|
19
21
|
@watcher.add_observer(self, :notify_streams_of_file_change)
|
@@ -36,13 +38,20 @@ module ShopifyCLI
|
|
36
38
|
@streams.close
|
37
39
|
end
|
38
40
|
|
39
|
-
def notify_streams_of_file_change(modified, added,
|
41
|
+
def notify_streams_of_file_change(modified, added, removed)
|
40
42
|
files = (modified + added)
|
41
43
|
.reject { |file| @ignore_filter&.ignore?(file) }
|
42
44
|
.map { |file| @theme[file] }
|
43
45
|
|
44
46
|
files -= liquid_css_files = files.select(&:liquid_css?)
|
45
47
|
|
48
|
+
deleted_files = removed
|
49
|
+
.reject { |file| @ignore_filter&.ignore?(file) }
|
50
|
+
.map { |file| @theme[file] }
|
51
|
+
|
52
|
+
remote_delete(deleted_files) unless deleted_files.empty?
|
53
|
+
reload_page(removed) unless deleted_files.empty?
|
54
|
+
|
46
55
|
hot_reload(files) unless files.empty?
|
47
56
|
remote_reload(liquid_css_files)
|
48
57
|
end
|
@@ -55,8 +64,21 @@ module ShopifyCLI
|
|
55
64
|
@ctx.debug("[HotReload] Modified #{paths.join(", ")}")
|
56
65
|
end
|
57
66
|
|
67
|
+
def reload_page(removed)
|
68
|
+
@streams.broadcast(JSON.generate(reload_page: true))
|
69
|
+
@ctx.debug("[ReloadPage] Deleted #{removed.join(", ")}")
|
70
|
+
end
|
71
|
+
|
72
|
+
def remote_delete(files)
|
73
|
+
files.each do |file|
|
74
|
+
@ctx.debug("delete file each -> file.relative_path #{file.relative_path}")
|
75
|
+
@remote_file_deleter.delete(file)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
58
79
|
def remote_reload(files)
|
59
80
|
files.each do |file|
|
81
|
+
@ctx.debug("reload file each -> file.relative_path #{file.relative_path}")
|
60
82
|
@remote_file_reloader.reload(file)
|
61
83
|
end
|
62
84
|
end
|
@@ -120,6 +120,7 @@ module ShopifyCLI
|
|
120
120
|
)
|
121
121
|
|
122
122
|
@id = body["theme"]["id"]
|
123
|
+
@created_at_runtime = true
|
123
124
|
end
|
124
125
|
|
125
126
|
def delete
|
@@ -147,6 +148,10 @@ module ShopifyCLI
|
|
147
148
|
development? && id != ShopifyCLI::DB.get(:development_theme_id)
|
148
149
|
end
|
149
150
|
|
151
|
+
def created_at_runtime?
|
152
|
+
@created_at_runtime ||= false
|
153
|
+
end
|
154
|
+
|
150
155
|
def to_h
|
151
156
|
{
|
152
157
|
id: id,
|
data/lib/shopify_cli/version.rb
CHANGED
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.
|
4
|
+
version: 2.21.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
|
+
date: 2022-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -507,6 +507,7 @@ files:
|
|
507
507
|
- lib/shopify_cli/theme/dev_server/hot-reload-no-script.html
|
508
508
|
- lib/shopify_cli/theme/dev_server/hot-reload.js
|
509
509
|
- lib/shopify_cli/theme/dev_server/hot_reload.rb
|
510
|
+
- lib/shopify_cli/theme/dev_server/hot_reload/remote_file_deleter.rb
|
510
511
|
- lib/shopify_cli/theme/dev_server/hot_reload/remote_file_reloader.rb
|
511
512
|
- lib/shopify_cli/theme/dev_server/hot_reload/sections_index.rb
|
512
513
|
- lib/shopify_cli/theme/dev_server/local_assets.rb
|