shopify-cli 2.8.0 → 2.9.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 +18 -0
- data/Gemfile.lock +1 -1
- data/RELEASING.md +4 -3
- data/ext/javy/javy.rb +1 -1
- data/lib/project_types/extension/commands/push.rb +2 -2
- data/lib/project_types/extension/messages/messages.rb +1 -1
- data/lib/project_types/extension/models/development_server.rb +2 -4
- data/lib/project_types/rails/gem.rb +1 -2
- data/lib/project_types/script/cli.rb +5 -0
- data/lib/project_types/script/commands/connect.rb +1 -1
- data/lib/project_types/script/commands/create.rb +8 -2
- data/lib/project_types/script/commands/push.rb +35 -12
- data/lib/project_types/script/layers/application/connect_app.rb +11 -5
- data/lib/project_types/script/layers/application/extension_points.rb +50 -26
- data/lib/project_types/script/layers/application/push_script.rb +5 -2
- data/lib/project_types/script/layers/domain/extension_point.rb +14 -0
- data/lib/project_types/script/layers/infrastructure/errors.rb +2 -0
- data/lib/project_types/script/loaders/project.rb +44 -0
- data/lib/project_types/script/loaders/specification_handler.rb +22 -0
- data/lib/project_types/script/messages/messages.rb +15 -1
- data/lib/project_types/script/ui/error_handler.rb +5 -0
- data/lib/project_types/theme/commands/pull.rb +39 -16
- data/lib/project_types/theme/commands/push.rb +56 -26
- data/lib/project_types/theme/commands/serve.rb +5 -0
- data/lib/project_types/theme/messages/messages.rb +29 -18
- data/lib/shopify_cli/commands/login.rb +10 -4
- data/lib/shopify_cli/constants.rb +1 -0
- data/lib/shopify_cli/context.rb +66 -12
- data/lib/shopify_cli/environment.rb +15 -4
- data/lib/shopify_cli/identity_auth.rb +1 -0
- data/lib/shopify_cli/messages/messages.rb +3 -1
- data/lib/shopify_cli/resources/env_file.rb +5 -1
- data/lib/shopify_cli/theme/dev_server/hot-reload.js +19 -1
- data/lib/shopify_cli/theme/dev_server/hot_reload.rb +18 -2
- data/lib/shopify_cli/theme/dev_server/proxy.rb +1 -0
- data/lib/shopify_cli/theme/dev_server/reload_mode.rb +34 -0
- data/lib/shopify_cli/theme/dev_server.rb +6 -21
- data/lib/shopify_cli/theme/theme.rb +26 -4
- data/lib/shopify_cli/version.rb +1 -1
- data/lib/shopify_cli.rb +4 -0
- metadata +5 -2
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ShopifyCLI
|
4
|
+
module Theme
|
5
|
+
module DevServer
|
6
|
+
class ReloadMode
|
7
|
+
MODES = [:"hot-reload", :"full-page", :off]
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def default
|
11
|
+
:"hot-reload"
|
12
|
+
end
|
13
|
+
|
14
|
+
def get!(mode)
|
15
|
+
MODES.find { |m| m == mode.to_sym } || raise_error(mode)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def raise_error(invalid_mode)
|
21
|
+
error_message = ShopifyCLI::Context.message("theme.serve.reload_mode_is_not_valid", invalid_mode)
|
22
|
+
help_message = ShopifyCLI::Context.message("theme.serve.try_a_valid_reload_mode", valid_modes)
|
23
|
+
|
24
|
+
ShopifyCLI::Context.abort(error_message, help_message)
|
25
|
+
end
|
26
|
+
|
27
|
+
def valid_modes
|
28
|
+
MODES.map { |v| "`#{v}`" }.join(", ")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -6,6 +6,7 @@ require_relative "syncer"
|
|
6
6
|
require_relative "dev_server/cdn_fonts"
|
7
7
|
require_relative "dev_server/hot_reload"
|
8
8
|
require_relative "dev_server/header_hash"
|
9
|
+
require_relative "dev_server/reload_mode"
|
9
10
|
require_relative "dev_server/local_assets"
|
10
11
|
require_relative "dev_server/proxy"
|
11
12
|
require_relative "dev_server/sse"
|
@@ -25,7 +26,7 @@ module ShopifyCLI
|
|
25
26
|
class << self
|
26
27
|
attr_accessor :ctx
|
27
28
|
|
28
|
-
def start(ctx, root, host: "127.0.0.1", port: 9292, poll: false)
|
29
|
+
def start(ctx, root, host: "127.0.0.1", port: 9292, poll: false, mode: ReloadMode.default)
|
29
30
|
@ctx = ctx
|
30
31
|
theme = DevelopmentTheme.new(ctx, root: root)
|
31
32
|
ignore_filter = IgnoreFilter.from_path(root)
|
@@ -36,7 +37,7 @@ module ShopifyCLI
|
|
36
37
|
@app = Proxy.new(ctx, theme: theme, syncer: @syncer)
|
37
38
|
@app = CdnFonts.new(@app, theme: theme)
|
38
39
|
@app = LocalAssets.new(ctx, @app, theme: theme)
|
39
|
-
@app = HotReload.new(ctx, @app, theme: theme, watcher: watcher, ignore_filter: ignore_filter)
|
40
|
+
@app = HotReload.new(ctx, @app, theme: theme, watcher: watcher, mode: mode, ignore_filter: ignore_filter)
|
40
41
|
stopped = false
|
41
42
|
address = "http://#{host}:#{port}"
|
42
43
|
|
@@ -83,7 +84,9 @@ module ShopifyCLI
|
|
83
84
|
ShopifyCLI::API::APIRequestUnauthorizedError
|
84
85
|
raise ShopifyCLI::Abort, @ctx.message("theme.serve.ensure_user", theme.shop)
|
85
86
|
rescue Errno::EADDRINUSE
|
86
|
-
|
87
|
+
error_message = @ctx.message("theme.serve.address_already_in_use", address)
|
88
|
+
help_message = @ctx.message("theme.serve.try_port_option")
|
89
|
+
@ctx.abort(error_message, help_message)
|
87
90
|
rescue Errno::EADDRNOTAVAIL
|
88
91
|
raise AddressBindingError, "Error binding to the address #{host}."
|
89
92
|
end
|
@@ -94,24 +97,6 @@ module ShopifyCLI
|
|
94
97
|
@syncer.shutdown
|
95
98
|
WebServer.shutdown
|
96
99
|
end
|
97
|
-
|
98
|
-
private
|
99
|
-
|
100
|
-
def abort_address_already_in_use(address)
|
101
|
-
open_frame(@ctx.message("theme.serve.already_in_use_error"), color: :red) do
|
102
|
-
@ctx.puts(@ctx.message("theme.serve.address_already_in_use", address))
|
103
|
-
end
|
104
|
-
|
105
|
-
open_frame(@ctx.message("theme.serve.try_this"), color: :green) do
|
106
|
-
@ctx.puts(@ctx.message("theme.serve.try_port_option"))
|
107
|
-
end
|
108
|
-
|
109
|
-
raise ShopifyCLI::AbortSilent
|
110
|
-
end
|
111
|
-
|
112
|
-
def open_frame(title, color:, &block)
|
113
|
-
CLI::UI::Frame.open(title, color: CLI::UI.resolve_color(color), timing: false, &block)
|
114
|
-
end
|
115
100
|
end
|
116
101
|
end
|
117
102
|
end
|
@@ -173,15 +173,37 @@ module ShopifyCLI
|
|
173
173
|
end
|
174
174
|
|
175
175
|
def live(ctx, root: nil)
|
176
|
-
|
176
|
+
find(ctx, root) { |attrs| attrs["role"] == "main" }
|
177
|
+
end
|
177
178
|
|
178
|
-
|
179
|
-
|
180
|
-
|
179
|
+
def development(ctx, root: nil)
|
180
|
+
find(ctx, root) { |attrs| attrs["role"] == "development" }
|
181
|
+
end
|
182
|
+
|
183
|
+
# Finds a Theme by its identifier
|
184
|
+
#
|
185
|
+
# #### Parameters
|
186
|
+
# * `ctx` - current running context of your command
|
187
|
+
# * `root` - theme root
|
188
|
+
# * `identifier` - theme ID or theme name
|
189
|
+
def find_by_identifier(ctx, root: nil, identifier:)
|
190
|
+
find(ctx, root) do |attrs|
|
191
|
+
attrs.slice("name", "id").values.map(&:to_s).include?(identifier)
|
192
|
+
end
|
181
193
|
end
|
182
194
|
|
183
195
|
private
|
184
196
|
|
197
|
+
def find(ctx, root, &block)
|
198
|
+
_status, body = fetch_themes(ctx)
|
199
|
+
|
200
|
+
body["themes"]
|
201
|
+
.find(&block)
|
202
|
+
.tap do |attrs|
|
203
|
+
break new(ctx, root: root, **allowed_attrs(attrs)) if attrs
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
185
207
|
def allowed_attrs(attrs)
|
186
208
|
attrs.slice("id", "name", "role").transform_keys(&:to_sym)
|
187
209
|
end
|
data/lib/shopify_cli/version.rb
CHANGED
data/lib/shopify_cli.rb
CHANGED
@@ -139,6 +139,10 @@ module ShopifyCLI
|
|
139
139
|
require "shopify_cli/messages/messages"
|
140
140
|
Context.load_messages(ShopifyCLI::Messages::MESSAGES)
|
141
141
|
|
142
|
+
# cli-ui utilities for capturing the output close the stream while capturing.
|
143
|
+
# By setting the value here we persist the tty value for the whole lifetime of the process.
|
144
|
+
Environment.interactive = $stdin.tty?
|
145
|
+
|
142
146
|
def self.cache_dir
|
143
147
|
cache_dir = if Environment.test?
|
144
148
|
TEMP_DIR
|
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.9.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-01-
|
11
|
+
date: 2022-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -322,6 +322,8 @@ files:
|
|
322
322
|
- lib/project_types/script/layers/infrastructure/script_service.rb
|
323
323
|
- lib/project_types/script/layers/infrastructure/script_uploader.rb
|
324
324
|
- lib/project_types/script/layers/infrastructure/service_locator.rb
|
325
|
+
- lib/project_types/script/loaders/project.rb
|
326
|
+
- lib/project_types/script/loaders/specification_handler.rb
|
325
327
|
- lib/project_types/script/messages/messages.rb
|
326
328
|
- lib/project_types/script/ui/error_handler.rb
|
327
329
|
- lib/project_types/script/ui/printing_spinner.rb
|
@@ -464,6 +466,7 @@ files:
|
|
464
466
|
- lib/shopify_cli/theme/dev_server/local_assets.rb
|
465
467
|
- lib/shopify_cli/theme/dev_server/proxy.rb
|
466
468
|
- lib/shopify_cli/theme/dev_server/proxy/template_param_builder.rb
|
469
|
+
- lib/shopify_cli/theme/dev_server/reload_mode.rb
|
467
470
|
- lib/shopify_cli/theme/dev_server/sse.rb
|
468
471
|
- lib/shopify_cli/theme/dev_server/watcher.rb
|
469
472
|
- lib/shopify_cli/theme/dev_server/web_server.rb
|